Skip to content

Commit

Permalink
➖ chore: remove @c2d2c/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed Jul 22, 2023
1 parent 5c659f2 commit 1f936fc
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@antv/dw-random": "^1",
"@babel/runtime": "^7.21.5",
"@c2d2c/types": "^1",
"@c2d2c/utils": "^1",
"@dnd-kit/core": "^6",
"@dnd-kit/modifiers": "^6",
"@dnd-kit/sortable": "^7",
Expand Down
2 changes: 1 addition & 1 deletion src/ComponentAsset/ComponentAsset.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*eslint no-invalid-this: "error"*/
import { getDefaultValueFromSchema } from '@c2d2c/utils';
import { FC, ReactNode } from 'react';
import { StoreApi } from 'zustand';
import type { UseBoundStore } from 'zustand/react';
import { getDefaultValueFromSchema } from '../utils';

import type { EditorMode } from '../ProEditor';
import type { AssetModels, CanvasRule, CodeEmitter, ComponentAssetParams } from './types';
Expand Down
2 changes: 1 addition & 1 deletion src/ComponentAsset/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from '../../types/schema';
export * from './asset';
export * from './code';
export * from './model';
export * from './render';
export * from './schema';
2 changes: 1 addition & 1 deletion src/LevaPanel/Schema.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { JSONSchema } from '@/ComponentAsset';
import { getDefaultValueFromSchema } from '@c2d2c/utils';
import { useMemoizedFn } from 'ahooks';
import isEqual from 'fast-deep-equal';
import { useControls, useStoreContext } from 'leva';
import { DataInput } from 'leva/src/types';
import merge from 'lodash.merge';
import { ReactNode, memo, useEffect, useMemo } from 'react';
import { getDefaultValueFromSchema } from '../utils';

import { SchemaItem, toLevaSchema } from './utils/schema';

Expand Down
22 changes: 22 additions & 0 deletions src/types/catogory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { CategoryConfig } from '@c2d2c/types';

export enum CategoryMap {
type = 'type',
content = 'content',
function = 'function',
style = 'style',
status = 'status',
bind = 'bind',
table = 'table',
customStyle = 'customStyle',
}

export const configCategoryMap: CategoryConfig = {
[CategoryMap.type]: { title: '类型', defaultActive: true },
[CategoryMap.content]: { title: '内容与功能', defaultActive: true },
[CategoryMap.style]: { title: '样式', defaultActive: true },
[CategoryMap.status]: { title: '状态', defaultActive: true },
[CategoryMap.bind]: { title: '分页字段绑定', defaultActive: true },
[CategoryMap.table]: { title: '表格要素', defaultActive: true },
[CategoryMap.customStyle]: { title: '自定义样式', defaultActive: true },
};
24 changes: 2 additions & 22 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
import type { CategoryConfig } from '@c2d2c/types';

export enum CategoryMap {
type = 'type',
content = 'content',
function = 'function',
style = 'style',
status = 'status',
bind = 'bind',
table = 'table',
customStyle = 'customStyle',
}

export const configCategoryMap: CategoryConfig = {
[CategoryMap.type]: { title: '类型', defaultActive: true },
[CategoryMap.content]: { title: '内容与功能', defaultActive: true },
[CategoryMap.style]: { title: '样式', defaultActive: true },
[CategoryMap.status]: { title: '状态', defaultActive: true },
[CategoryMap.bind]: { title: '分页字段绑定', defaultActive: true },
[CategoryMap.table]: { title: '表格要素', defaultActive: true },
[CategoryMap.customStyle]: { title: '自定义样式', defaultActive: true },
};
export * from './catogory';
export * from './schema';
File renamed without changes.
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './autoId';
export * from './schema';
12 changes: 12 additions & 0 deletions src/utils/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { JSONSchema } from '@/types/schema';
/**
* 从schema 获取预设值
* @param schema
*/
export const getDefaultValueFromSchema = (schema: JSONSchema) => {
if (!schema.properties) return;

return Object.fromEntries(
Object.entries(schema.properties).map(([key, value]) => [key, value.default]),
);
};

0 comments on commit 1f936fc

Please sign in to comment.