From 1ee3d37912f9708a58fba38dd63c7e6da62c5fc6 Mon Sep 17 00:00:00 2001 From: siyi98 Date: Wed, 2 Mar 2022 19:30:29 +0800 Subject: [PATCH 1/2] chore:update gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 244f3749d..cdec481fa 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,6 @@ node_modules # custom old-doc test.json -/docs/guide/.test \ No newline at end of file +/docs/guide/.test + +/coverage \ No newline at end of file From 57977421cc2df949e72ea7787ba2dd5e3c4a9f44 Mon Sep 17 00:00:00 2001 From: siyi98 Date: Tue, 22 Mar 2022 19:39:01 +0800 Subject: [PATCH 2/2] chore(code):format --- .prettierrc | 3 +- docs/form-render/.test/1.4.0.jsx | 6 +- docs/form-render/.test/complex-bind-demo.jsx | 6 +- .../.test/deep-structure-validation.jsx | 6 +- docs/form-render/.test/hidden-validate.jsx | 6 +- docs/form-render/.test/simple-migrate.jsx | 6 +- docs/form-render/.test/simple.jsx | 6 +- docs/form-render/.test/simple2.jsx | 6 +- docs/form-render/.test/test-1.2.0.jsx | 2 +- docs/form-render/.test/test-allCollapsed.jsx | 4 +- docs/form-render/.test/test-bind-setvalue.jsx | 6 +- docs/form-render/.test/test-list-1.4.0.jsx | 2 +- docs/form-render/.test/test-list.jsx | 2 +- docs/form-render/.test/test-setError.jsx | 4 +- docs/form-render/.test/tester.jsx | 6 +- .../.test/testing-validation-array.jsx | 6 +- docs/form-render/.test/very-complex-form.jsx | 2 +- docs/form-render/advanced/listDisplay.md | 4 +- docs/form-render/demo/FR.jsx | 2 +- docs/form-render/demo/bind-example.jsx | 2 +- docs/form-render/demo/display.js | 2 +- docs/form-render/demo/index.jsx | 2 +- docs/form-render/demo/otherWidgets/Percent.js | 4 +- docs/form-render/demo/simple.jsx | 2 +- docs/form-render/demo/simple1.jsx | 2 +- docs/form-render/demos/customMessage.jsx | 4 +- docs/form-render/demos/dependencies.jsx | 4 +- docs/form-render/demos/doubleBind.jsx | 2 +- docs/form-render/demos/listExpression.jsx | 4 +- docs/form-render/demos/rightPath.jsx | 4 +- docs/form-render/index.md | 4 +- docs/generator/demo/layout.jsx | 2 +- docs/generator/demo/modal.jsx | 4 +- docs/generator/demo/playground.jsx | 7 +- docs/generator/demo/settings.jsx | 4 +- docs/generator/demo/transformer.jsx | 4 +- docs/generator/index.md | 4 +- docs/playground/index.jsx | 4 +- docs/playground/main.js | 9 +- docs/playground/monaco/index.js | 6 +- docs/table-render/.test/simple2.jsx | 6 +- docs/table-render/.test/test1.jsx | 2 +- docs/table-render/demo/advanced.tsx | 6 +- docs/table-render/demo/noSearch.tsx | 6 +- docs/table-render/demo/noTitle.tsx | 6 +- docs/table-render/demo/paramTable.tsx | 8 +- docs/table-render/demo/useTs.tsx | 6 +- docs/table-render/index.md | 4 +- docs/table-render/test1.jsx | 2 +- package.json | 14 +- packages/chart-render/package.json | 52 ++--- .../src/components/Column/index.tsx | 11 +- .../src/components/Line/index.tsx | 15 +- .../src/components/PivotTable/index.tsx | 16 +- packages/chart-render/src/utils/index.ts | 2 +- packages/form-render/README.md | 22 +-- packages/form-render/package.json | 46 ++--- .../src/form-render-core/src/atom.less | 2 +- .../RenderChildren/RenderList/CardList.js | 10 +- .../RenderChildren/RenderList/DrawerList.js | 10 +- .../RenderChildren/RenderList/SimpleList.js | 12 +- .../core/RenderChildren/RenderList/TabList.js | 2 +- .../RenderChildren/RenderList/TableList.js | 4 +- .../RenderChildren/RenderList/VirtualList.js | 6 +- .../core/RenderChildren/RenderList/index.js | 15 +- .../src/core/RenderField/ExtendedWidget.js | 7 +- .../src/core/RenderField/index.js | 15 +- .../src/form-render-core/src/core/index.js | 20 +- .../src/form-render-core/src/hooks.js | 6 +- .../src/form-render-core/src/index.js | 19 +- .../src/form-render-core/src/processData.js | 7 +- .../src/form-render-core/src/useDebounce.js | 8 +- .../src/form-render-core/src/useForm.js | 12 +- .../src/form-render-core/src/utils.js | 2 +- .../src/form-render-core/src/validator.js | 12 +- packages/form-render/src/index.d.ts | 2 +- packages/form-render/src/index.js | 6 +- .../src/widgets/antd/checkboxes.js | 2 +- .../form-render/src/widgets/antd/color.js | 184 +++++++++--------- packages/form-render/src/widgets/antd/date.js | 6 +- .../form-render/src/widgets/antd/dateRange.js | 2 +- .../src/widgets/antd/imageInput.js | 2 +- .../form-render/src/widgets/antd/index.js | 20 +- packages/form-render/src/widgets/antd/map.js | 2 +- .../src/widgets/antd/multiSelect.js | 2 +- .../src/widgets/antd/percentSlider.js | 2 +- .../form-render/src/widgets/antd/radio.js | 2 +- .../form-render/src/widgets/antd/select.js | 4 +- .../form-render/src/widgets/antd/slider.js | 2 +- packages/form-render/src/widgets/antd/time.js | 4 +- .../form-render/src/widgets/antd/timeRange.js | 2 +- .../form-render/src/widgets/antd/upload.js | 4 +- .../form-render/src/widgets/antd/urlInput.js | 2 +- packages/table-render/README.md | 4 +- packages/table-render/package.json | 52 ++--- .../src/components/ErrorBoundary/index.tsx | 3 +- .../table-render/src/components/Search.tsx | 4 +- .../table-render/src/components/Table.tsx | 6 +- .../ToolBarAction/ColumnSetting.tsx | 9 +- .../components/ToolBarAction/DensityIcon.tsx | 4 +- .../ToolBarAction/FullScreenIcon.tsx | 2 +- .../components/ToolBarAction/ReloadIcon.tsx | 4 +- .../src/components/ToolBarAction/index.tsx | 5 +- .../table-render/src/components/field.tsx | 2 +- packages/table-render/src/components/hooks.ts | 10 +- .../table-render/src/components/index.tsx | 12 +- .../table-render/src/components/widgets.tsx | 4 +- packages/table-render/src/index.ts | 5 +- scripts/prettier-plugin/index.js | 75 +++++++ tools/form-render-excel/package.json | 38 ++-- tools/form-render-excel/src/index.js | 27 +-- .../src/method/exportExcel.js | 2 +- .../src/method/importExcel.js | 24 +-- tools/form-render-excel/src/utils.js | 32 +-- tools/form-render-snippets/package.json | 20 +- tools/form-render_v0.x/package.json | 28 +-- tools/form-render_v0.x/src/antd.js | 6 +- tools/form-render_v0.x/src/atom.less | 2 +- tools/form-render_v0.x/src/base/asField.jsx | 14 +- tools/form-render_v0.x/src/base/isHidden.js | 2 +- .../src/base/subFieldGenerator.jsx | 22 +-- .../form-render_v0.x/src/base/useDebounce.js | 8 +- tools/form-render_v0.x/src/base/validate.js | 6 +- .../src/components/dateHoc.jsx | 2 +- .../src/components/listHoc.jsx | 10 +- .../src/components/rangeHoc.jsx | 2 +- tools/form-render_v0.x/src/hooks.js | 2 +- tools/form-render_v0.x/src/index.js | 20 +- .../src/widgets/antd/checkbox.jsx | 2 +- .../src/widgets/antd/checkboxes.jsx | 2 +- .../src/widgets/antd/color.jsx | 6 +- .../src/widgets/antd/date.jsx | 2 +- .../src/widgets/antd/index.jsx | 2 +- .../src/widgets/antd/input.jsx | 2 +- .../src/widgets/antd/list.jsx | 10 +- .../form-render_v0.x/src/widgets/antd/map.jsx | 2 +- .../src/widgets/antd/radio.jsx | 2 +- .../src/widgets/antd/range.jsx | 2 +- .../src/widgets/antd/switch.jsx | 2 +- .../src/widgets/antd/textarea.jsx | 2 +- .../src/widgets/antd/upload.jsx | 4 +- .../form-render_v0.x/src/widgets/antd/url.jsx | 2 +- .../src/widgets/fusion/checkbox.jsx | 2 +- .../src/widgets/fusion/checkboxes.jsx | 2 +- .../src/widgets/fusion/color.jsx | 6 +- .../src/widgets/fusion/date.jsx | 2 +- .../src/widgets/fusion/dateRange.jsx | 2 +- .../src/widgets/fusion/index.jsx | 2 +- .../src/widgets/fusion/input.jsx | 2 +- .../src/widgets/fusion/list.jsx | 4 +- .../src/widgets/fusion/map.jsx | 2 +- .../src/widgets/fusion/radio.jsx | 2 +- .../src/widgets/fusion/switch.jsx | 2 +- .../src/widgets/fusion/textarea.jsx | 2 +- .../src/widgets/fusion/upload.jsx | 2 +- tools/proptypes-to-json-schema/demo/index.jsx | 16 +- tools/proptypes-to-json-schema/package.json | 22 +-- .../proptypes-to-json-schema/src/to-schema.js | 2 +- tools/schema-generator/package.json | 26 +-- tools/schema-generator/src/Provider.jsx | 26 +-- .../components/Canvas/core/RenderField.jsx | 6 +- .../src/components/Canvas/core/Wrapper.jsx | 6 +- .../src/components/Canvas/core/index.jsx | 7 +- .../src/components/Canvas/index.jsx | 12 +- .../components/Settings/GlobalSettings.jsx | 4 +- .../src/components/Settings/ItemSettings.jsx | 17 +- .../src/components/Settings/index.jsx | 8 +- .../src/components/Sidebar/Element.jsx | 10 +- tools/schema-generator/src/index.d.ts | 2 +- tools/schema-generator/src/index.js | 6 +- tools/schema-generator/src/utils/hooks.js | 2 +- .../src/widgets/htmlInput.jsx | 2 +- .../schema-generator/src/widgets/idInput.jsx | 4 +- tools/schema-generator/src/widgets/list.jsx | 4 +- .../src/widgets/percentSlider.jsx | 2 +- .../vscode-plugin-fr-schema/examples/form.tsx | 2 +- .../vscode-plugin-fr-schema/examples/page.jsx | 16 +- tools/vscode-plugin-fr-schema/package.json | 140 ++++++------- .../src/extension/frProp2Schema.ts | 4 +- .../src/extension/index.ts | 10 +- .../src/extension/utils/index.ts | 4 +- .../src/pages/index.jsx | 2 +- widgets/AsyncOptions/package.json | 16 +- widgets/RichText/package.json | 16 +- widgets/RichText/src/index.js | 2 +- widgets/template/package.json | 16 +- 186 files changed, 912 insertions(+), 850 deletions(-) create mode 100644 scripts/prettier-plugin/index.js diff --git a/.prettierrc b/.prettierrc index 20aede29c..68703de70 100644 --- a/.prettierrc +++ b/.prettierrc @@ -8,5 +8,6 @@ "files": ".prettierrc", "options": { "parser": "json" } } - ] + ], + "plugins": ["prettier-plugin-packagejson", "./scripts/prettier-plugin"] } diff --git a/docs/form-render/.test/1.4.0.jsx b/docs/form-render/.test/1.4.0.jsx index a8af87dc4..5524381d1 100644 --- a/docs/form-render/.test/1.4.0.jsx +++ b/docs/form-render/.test/1.4.0.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/complex-bind-demo.jsx b/docs/form-render/.test/complex-bind-demo.jsx index 80163a067..138cfd418 100644 --- a/docs/form-render/.test/complex-bind-demo.jsx +++ b/docs/form-render/.test/complex-bind-demo.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message, Tag } from 'antd'; +import { Button, message, Space, Tag } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const SelectableTag = ({ value, onChange, options }) => { const handleChange = newValue => { diff --git a/docs/form-render/.test/deep-structure-validation.jsx b/docs/form-render/.test/deep-structure-validation.jsx index cf8991d27..350a36523 100644 --- a/docs/form-render/.test/deep-structure-validation.jsx +++ b/docs/form-render/.test/deep-structure-validation.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/hidden-validate.jsx b/docs/form-render/.test/hidden-validate.jsx index b908ae1c3..1baaf30b0 100644 --- a/docs/form-render/.test/hidden-validate.jsx +++ b/docs/form-render/.test/hidden-validate.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/simple-migrate.jsx b/docs/form-render/.test/simple-migrate.jsx index 0b40ae9bb..dd6bee199 100644 --- a/docs/form-render/.test/simple-migrate.jsx +++ b/docs/form-render/.test/simple-migrate.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const [schema, setSchema] = useState({}); diff --git a/docs/form-render/.test/simple.jsx b/docs/form-render/.test/simple.jsx index b56d4e2fd..b91fbfaf6 100644 --- a/docs/form-render/.test/simple.jsx +++ b/docs/form-render/.test/simple.jsx @@ -2,10 +2,10 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/simple2.jsx b/docs/form-render/.test/simple2.jsx index 50bb35928..9614866e7 100644 --- a/docs/form-render/.test/simple2.jsx +++ b/docs/form-render/.test/simple2.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/test-1.2.0.jsx b/docs/form-render/.test/test-1.2.0.jsx index a5717e383..b5912b41d 100644 --- a/docs/form-render/.test/test-1.2.0.jsx +++ b/docs/form-render/.test/test-1.2.0.jsx @@ -1,6 +1,6 @@ -import React from 'react'; import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const schema = { type: 'object', diff --git a/docs/form-render/.test/test-allCollapsed.jsx b/docs/form-render/.test/test-allCollapsed.jsx index 25ee0f97e..82d0acdd5 100644 --- a/docs/form-render/.test/test-allCollapsed.jsx +++ b/docs/form-render/.test/test-allCollapsed.jsx @@ -2,9 +2,9 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React, { useEffect, useState } from 'react'; import { fakeApi } from './advanced/utils'; const Demo = () => { diff --git a/docs/form-render/.test/test-bind-setvalue.jsx b/docs/form-render/.test/test-bind-setvalue.jsx index 2d76b9f2b..e78bfd897 100644 --- a/docs/form-render/.test/test-bind-setvalue.jsx +++ b/docs/form-render/.test/test-bind-setvalue.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/test-list-1.4.0.jsx b/docs/form-render/.test/test-list-1.4.0.jsx index 1789b8a8f..ba38fe16e 100644 --- a/docs/form-render/.test/test-list-1.4.0.jsx +++ b/docs/form-render/.test/test-list-1.4.0.jsx @@ -1,6 +1,6 @@ -import React from 'react'; import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const Ha = props => { console.log(props, ''); diff --git a/docs/form-render/.test/test-list.jsx b/docs/form-render/.test/test-list.jsx index a91afd554..7f94b2cab 100644 --- a/docs/form-render/.test/test-list.jsx +++ b/docs/form-render/.test/test-list.jsx @@ -1,6 +1,6 @@ -import React from 'react'; import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const schema = { type: 'object', diff --git a/docs/form-render/.test/test-setError.jsx b/docs/form-render/.test/test-setError.jsx index f2b6daeb0..ce24a5d5f 100644 --- a/docs/form-render/.test/test-setError.jsx +++ b/docs/form-render/.test/test-setError.jsx @@ -1,6 +1,6 @@ -import React from 'react'; -import { Button, Select } from 'antd'; +import { Button } from 'antd'; import Form, { useForm } from 'form-render'; +import React from 'react'; const schema = { type: 'object', diff --git a/docs/form-render/.test/tester.jsx b/docs/form-render/.test/tester.jsx index 9dcd1eeaa..c03d61533 100644 --- a/docs/form-render/.test/tester.jsx +++ b/docs/form-render/.test/tester.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, message, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/testing-validation-array.jsx b/docs/form-render/.test/testing-validation-array.jsx index bf331ad23..3b49b9231 100644 --- a/docs/form-render/.test/testing-validation-array.jsx +++ b/docs/form-render/.test/testing-validation-array.jsx @@ -2,11 +2,11 @@ * transform: true * defaultShowCode: true */ -import React, { useState, useEffect } from 'react'; -import { Button, Space, message } from 'antd'; +import { Button, Space } from 'antd'; import FormRender, { useForm } from 'form-render'; -import { fakeApi, delay } from './advanced/utils'; +import React, { useEffect, useState } from 'react'; import RichTextEditor from '../../widgets/RichText/src'; +import { fakeApi } from './advanced/utils'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/.test/very-complex-form.jsx b/docs/form-render/.test/very-complex-form.jsx index 276792013..c61829c9c 100644 --- a/docs/form-render/.test/very-complex-form.jsx +++ b/docs/form-render/.test/very-complex-form.jsx @@ -1,6 +1,6 @@ -import React from 'react'; import { Button } from 'antd'; import Form, { useForm } from 'form-render'; +import React from 'react'; const numberRule = [ { pattern: '^(([1-9]{1}\\d*)|(0{1}))(\\.\\d{1,2})?$', diff --git a/docs/form-render/advanced/listDisplay.md b/docs/form-render/advanced/listDisplay.md index d94b9297a..a5d64a042 100644 --- a/docs/form-render/advanced/listDisplay.md +++ b/docs/form-render/advanced/listDisplay.md @@ -37,7 +37,7 @@ const schema = { type: 'string', enum: ['a', 'b', 'c'], enumNames: ['早', '中', '晚'], - default: 'a' + default: 'a', }, obj: { title: '对象', @@ -47,7 +47,7 @@ const schema = { title: '简单输入框', type: 'string', required: true, - default: '卡片列表' + default: '卡片列表', }, select1: { title: '单选', diff --git a/docs/form-render/demo/FR.jsx b/docs/form-render/demo/FR.jsx index b7f3061bc..13be0395d 100644 --- a/docs/form-render/demo/FR.jsx +++ b/docs/form-render/demo/FR.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const Demo = ({ schema }) => { const form = useForm(); diff --git a/docs/form-render/demo/bind-example.jsx b/docs/form-render/demo/bind-example.jsx index 33d3b2602..eeae05035 100644 --- a/docs/form-render/demo/bind-example.jsx +++ b/docs/form-render/demo/bind-example.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const delay = ms => new Promise(res => setTimeout(res, ms)); diff --git a/docs/form-render/demo/display.js b/docs/form-render/demo/display.js index e30200e62..381fbf165 100644 --- a/docs/form-render/demo/display.js +++ b/docs/form-render/demo/display.js @@ -1,5 +1,5 @@ -import React from 'react'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const Demo = props => { const form = useForm(); diff --git a/docs/form-render/demo/index.jsx b/docs/form-render/demo/index.jsx index a16ab8aa3..d75bf76df 100644 --- a/docs/form-render/demo/index.jsx +++ b/docs/form-render/demo/index.jsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react'; import FormRender, { useForm } from 'form-render'; +import React, { useState } from 'react'; import schema from './basic.js'; import Percent from './otherWidgets/Percent'; // import schema1 from './basic1.json'; diff --git a/docs/form-render/demo/otherWidgets/Percent.js b/docs/form-render/demo/otherWidgets/Percent.js index 3f51d6011..e76dfac51 100644 --- a/docs/form-render/demo/otherWidgets/Percent.js +++ b/docs/form-render/demo/otherWidgets/Percent.js @@ -1,6 +1,6 @@ -import React, { useEffect } from 'react'; -import { Progress, Button } from 'antd'; import { MinusOutlined, PlusOutlined } from '@ant-design/icons'; +import { Button, Progress } from 'antd'; +import React from 'react'; const App = ({ percent = 0, onPress = () => {} }) => { const increase = () => { diff --git a/docs/form-render/demo/simple.jsx b/docs/form-render/demo/simple.jsx index 80d542829..f88004fc7 100644 --- a/docs/form-render/demo/simple.jsx +++ b/docs/form-render/demo/simple.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const delay = ms => new Promise(res => setTimeout(res, ms)); diff --git a/docs/form-render/demo/simple1.jsx b/docs/form-render/demo/simple1.jsx index c248b720a..2cb206b08 100644 --- a/docs/form-render/demo/simple1.jsx +++ b/docs/form-render/demo/simple1.jsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react'; import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React, { useState } from 'react'; import testSchema from './testJson.json'; const schema = { diff --git a/docs/form-render/demos/customMessage.jsx b/docs/form-render/demos/customMessage.jsx index e1d14e17a..7516e04c9 100644 --- a/docs/form-render/demos/customMessage.jsx +++ b/docs/form-render/demos/customMessage.jsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; -import { Button, Input } from 'antd'; +import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/demos/dependencies.jsx b/docs/form-render/demos/dependencies.jsx index 93b900048..428d0322e 100644 --- a/docs/form-render/demos/dependencies.jsx +++ b/docs/form-render/demos/dependencies.jsx @@ -1,6 +1,6 @@ -import React from 'react'; -import { Button, message, Input } from 'antd'; +import { Button, Input, message } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const { TextArea } = Input; diff --git a/docs/form-render/demos/doubleBind.jsx b/docs/form-render/demos/doubleBind.jsx index 9e1c333d6..96f1a8900 100644 --- a/docs/form-render/demos/doubleBind.jsx +++ b/docs/form-render/demos/doubleBind.jsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; import { Button, Checkbox } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const MyCheckbox = ({ addons }) => { const { dependValues, setValueByPath } = addons; diff --git a/docs/form-render/demos/listExpression.jsx b/docs/form-render/demos/listExpression.jsx index d98aca450..a38d6f576 100644 --- a/docs/form-render/demos/listExpression.jsx +++ b/docs/form-render/demos/listExpression.jsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; -import { Button, Input } from 'antd'; +import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/demos/rightPath.jsx b/docs/form-render/demos/rightPath.jsx index 376e0906f..3b6ef9ef0 100644 --- a/docs/form-render/demos/rightPath.jsx +++ b/docs/form-render/demos/rightPath.jsx @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; -import { Button, Input } from 'antd'; +import { Button } from 'antd'; import FormRender, { useForm } from 'form-render'; +import React from 'react'; const Demo = () => { const form = useForm(); diff --git a/docs/form-render/index.md b/docs/form-render/index.md index ae339b517..b750e0186 100644 --- a/docs/form-render/index.md +++ b/docs/form-render/index.md @@ -305,11 +305,11 @@ export default connectForm(Demo); **form 方法** | 参数 | 描述 | 类型 | -| ---------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| ---------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ----------------- | | submit | 触发提交流程,一般在提交按钮上使用 | `() => void` | | resetFields | 清空表单(也会清空一些内置状态,例如校验) | `({formData?: any, submitData?: any, errorFields?: Error[], touchedKeys?: any[], allTouched?: boolean}) => void` | | errorFields | 表单校验错误的数组 | `array,[{name, error: []}]` | -| setErrorFields | 外部手动修改 errorFields 校验信息,用于外部校验回填 | `(error: Error | Error[]) => void` | +| setErrorFields | 外部手动修改 errorFields 校验信息,用于外部校验回填 | `(error: Error | Error[]) => void` | | setValues | 外部手动修改 formData,用于已填写的表单的数据回填 | `(formData: any) => void` | | setValueByPath | 外部修改指定单个 field 的数据(原名 onItemChange) | `(path: string, value: any) => void` | | setSchemaByPath | 指定路径修改 schema | `(path: string, value: any) => void` | diff --git a/docs/generator/demo/layout.jsx b/docs/generator/demo/layout.jsx index 958fb54d2..6476245d2 100644 --- a/docs/generator/demo/layout.jsx +++ b/docs/generator/demo/layout.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import Generator from 'fr-generator'; +import React from 'react'; import './index.less'; const { Provider, Sidebar, Canvas, Settings } = Generator; diff --git a/docs/generator/demo/modal.jsx b/docs/generator/demo/modal.jsx index 41104ac40..7037f959a 100644 --- a/docs/generator/demo/modal.jsx +++ b/docs/generator/demo/modal.jsx @@ -1,6 +1,6 @@ -import React, { useState, useRef } from 'react'; +import { Button, Input, Modal } from 'antd'; import Generator from 'fr-generator'; -import { Button, Modal, Input } from 'antd'; +import React, { useRef, useState } from 'react'; const { TextArea } = Input; const defaultValue = { diff --git a/docs/generator/demo/playground.jsx b/docs/generator/demo/playground.jsx index 75c4a6b6c..3ca60369f 100644 --- a/docs/generator/demo/playground.jsx +++ b/docs/generator/demo/playground.jsx @@ -1,13 +1,12 @@ -import React, { useState, useRef, useEffect } from 'react'; -import { useHistory } from 'umi'; import Generator from 'fr-generator'; +import React, { useEffect, useRef } from 'react'; import './index.less'; const Demo = () => { const ref = useRef(); - + useEffect(() => { - window.onbeforeunload = function(e) { + window.onbeforeunload = function (e) { e = e || window.event; // 兼容IE8和Firefox 4之前的版本 if (e) { diff --git a/docs/generator/demo/settings.jsx b/docs/generator/demo/settings.jsx index 67d8ed7b4..3e2c5bdd2 100644 --- a/docs/generator/demo/settings.jsx +++ b/docs/generator/demo/settings.jsx @@ -1,9 +1,9 @@ -import React from 'react'; import Generator, { - defaultSettings, defaultCommonSettings, defaultGlobalSettings, + defaultSettings, } from 'fr-generator'; +import React from 'react'; const NewWidget = ({ value = 0, onChange }) => ( diff --git a/docs/generator/demo/transformer.jsx b/docs/generator/demo/transformer.jsx index b8d16ec18..9c6123a62 100644 --- a/docs/generator/demo/transformer.jsx +++ b/docs/generator/demo/transformer.jsx @@ -1,6 +1,6 @@ -import React, { useState, useRef } from 'react'; +import { Button, Input, Modal } from 'antd'; import Generator from 'fr-generator'; -import { Button, Modal, Input } from 'antd'; +import React, { useRef, useState } from 'react'; const { TextArea } = Input; const defaultValue = { diff --git a/docs/generator/index.md b/docs/generator/index.md index cc4ce2a54..f1ac80f0c 100644 --- a/docs/generator/index.md +++ b/docs/generator/index.md @@ -48,7 +48,7 @@ export default Demo; ### Props | 参数 | 说明 | 类型 | 默认值 | -| ------------------ | ------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------- | +| ------------------ | ------------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------- | ------- | | getId | 设置如何生成新的 id | `Function` | name => `${name}_${nanoid(6)}` | | hideId | 隐藏组件 ID | `boolean` | `false` | | fixedName | 固定 settings 的 name 为组件 ID | `boolean` | `false` | @@ -62,7 +62,7 @@ export default Demo; | globalSettings | 全局配置 | `object` | [`defaultGlobalSettings`](https://github.com/alibaba/form-render/blob/master/tools/schema-generator/src/Settings/index.js) | | widgets | 自定义组件 | `object` | `{}` | | mapping | 组件和 schema 的映射规则 | `object` | `{}` | -| validation | 是否启用配置表单校验 | `boolean` | `true` | +| validation | 是否启用配置表单校验 | `boolean` | `true` | | fieldRender | 自定义组件渲染函数 | `Function` | `(schema, widgetProps, children, originNode) => originNode` | | fieldWrapperRender | 自定义容器组件渲染函数 | `Function` | `(schema, isSelected, children, originNode) => originNode` | diff --git a/docs/playground/index.jsx b/docs/playground/index.jsx index e697808ef..2e5c4ed91 100644 --- a/docs/playground/index.jsx +++ b/docs/playground/index.jsx @@ -1,8 +1,8 @@ +import { Radio, Select, Slider, Switch } from 'antd'; import React, { Component } from 'react'; +import './index.css'; // import GithubCorner from 'react-github-corner'; import Demo from './main'; -import { Radio, Select, Switch, Slider } from 'antd'; -import './index.css'; const Option = Select.Option; class Root extends Component { diff --git a/docs/playground/main.js b/docs/playground/main.js index c3d80a3e7..35f9a2f64 100644 --- a/docs/playground/main.js +++ b/docs/playground/main.js @@ -1,10 +1,9 @@ -import React, { useState, useEffect } from 'react'; -import deepEqual from 'deep-equal'; -import parseJson from 'json-parse-better-errors'; -import FormRender, { useForm } from 'form-render'; -import DefaultSchema from './json/simplest.json'; import { Tabs } from 'antd'; +import FormRender, { useForm } from 'form-render'; +import parseJson from 'json-parse-better-errors'; +import React, { useEffect, useState } from 'react'; import AsyncSelect from './customized/AsyncSelect'; +import DefaultSchema from './json/simplest.json'; import CodeBlock from './monaco'; const { TabPane } = Tabs; diff --git a/docs/playground/monaco/index.js b/docs/playground/monaco/index.js index fbb8d229d..aba597776 100644 --- a/docs/playground/monaco/index.js +++ b/docs/playground/monaco/index.js @@ -1,8 +1,8 @@ -import React from 'react'; -import Editor from 'react-simple-code-editor'; -import { languages, highlight } from 'prismjs/components/prism-core'; import 'prismjs/components/prism-clike'; +import { highlight, languages } from 'prismjs/components/prism-core'; import 'prismjs/components/prism-javascript'; +import React from 'react'; +import Editor from 'react-simple-code-editor'; import './theme.css'; const Demo = ({ value, onChange }) => { diff --git a/docs/table-render/.test/simple2.jsx b/docs/table-render/.test/simple2.jsx index cb36e9803..7f01d9e5f 100644 --- a/docs/table-render/.test/simple2.jsx +++ b/docs/table-render/.test/simple2.jsx @@ -1,7 +1,7 @@ +import { InfoCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { Button, Menu, message, Space, Tag, Tooltip } from 'antd'; import React from 'react'; -import { Table, Search, withTable, useTable } from 'table-render'; -import { Tag, Space, Menu, message, Tooltip, Button } from 'antd'; -import { PlusOutlined, InfoCircleOutlined } from '@ant-design/icons'; +import { Search, Table, useTable, withTable } from 'table-render'; import request from 'umi-request'; const schema = { diff --git a/docs/table-render/.test/test1.jsx b/docs/table-render/.test/test1.jsx index 92d8bace9..2ae79878b 100644 --- a/docs/table-render/.test/test1.jsx +++ b/docs/table-render/.test/test1.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Table, Search, withTable } from 'table-render'; +import { Search, Table, withTable } from 'table-render'; const dataSource = []; for (let i = 0; i < 6; i++) { diff --git a/docs/table-render/demo/advanced.tsx b/docs/table-render/demo/advanced.tsx index 441d97478..369b01621 100644 --- a/docs/table-render/demo/advanced.tsx +++ b/docs/table-render/demo/advanced.tsx @@ -3,10 +3,10 @@ * defaultShowCode: true */ +import { InfoCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { Button, message, Space, Tag, Tooltip } from 'antd'; import React from 'react'; -import { Table, Search, withTable, useTable } from 'table-render'; -import { Tag, Space, message, Tooltip, Button } from 'antd'; -import { PlusOutlined, InfoCircleOutlined } from '@ant-design/icons'; +import { Search, Table, useTable, withTable } from 'table-render'; import request from 'umi-request'; const schema = { diff --git a/docs/table-render/demo/noSearch.tsx b/docs/table-render/demo/noSearch.tsx index 660c91914..0f72839b8 100644 --- a/docs/table-render/demo/noSearch.tsx +++ b/docs/table-render/demo/noSearch.tsx @@ -3,10 +3,10 @@ * defaultShowCode: true */ +import { InfoCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { Button, message, Space, Tag, Tooltip } from 'antd'; import React from 'react'; -import { Table, Search, withTable, useTable } from 'table-render'; -import { Tag, Space, message, Tooltip, Button } from 'antd'; -import { PlusOutlined, InfoCircleOutlined } from '@ant-design/icons'; +import { Search, Table, useTable, withTable } from 'table-render'; import request from 'umi-request'; const schema = { diff --git a/docs/table-render/demo/noTitle.tsx b/docs/table-render/demo/noTitle.tsx index 7bbe20517..762e37db7 100644 --- a/docs/table-render/demo/noTitle.tsx +++ b/docs/table-render/demo/noTitle.tsx @@ -3,10 +3,10 @@ * defaultShowCode: true */ -import React from 'react'; -import { Table, Search, withTable, useTable } from 'table-render'; -import { Tag, Space, message, Tooltip } from 'antd'; import { InfoCircleOutlined } from '@ant-design/icons'; +import { message, Space, Tag, Tooltip } from 'antd'; +import React from 'react'; +import { Search, Table, useTable, withTable } from 'table-render'; import request from 'umi-request'; const schema = { diff --git a/docs/table-render/demo/paramTable.tsx b/docs/table-render/demo/paramTable.tsx index 4c28371bd..2c2b2eaad 100644 --- a/docs/table-render/demo/paramTable.tsx +++ b/docs/table-render/demo/paramTable.tsx @@ -3,12 +3,12 @@ * defaultShowCode: true */ +import { InfoCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { Button, message, Space, Tag, Tooltip } from 'antd'; import React, { useEffect } from 'react'; -import { Table, Search, withTable, useTable } from 'table-render'; -import { Tag, Space, message, Tooltip, Button } from 'antd'; -import { PlusOutlined, InfoCircleOutlined } from '@ant-design/icons'; -import request from 'umi-request'; +import { Search, Table, useTable, withTable } from 'table-render'; import { history } from 'umi'; +import request from 'umi-request'; const schema = { type: 'object', diff --git a/docs/table-render/demo/useTs.tsx b/docs/table-render/demo/useTs.tsx index 4115c19f0..db0b82b34 100644 --- a/docs/table-render/demo/useTs.tsx +++ b/docs/table-render/demo/useTs.tsx @@ -3,11 +3,11 @@ * defaultShowCode: true */ +import { InfoCircleOutlined } from '@ant-design/icons'; +import { message, Space, Tag, Tooltip } from 'antd'; import React from 'react'; -import { Table, Search, withTable, useTable } from 'table-render'; +import { Search, Table, useTable, withTable } from 'table-render'; import { ProColumnsType } from 'table-render/src/interface'; -import { Tag, Space, message, Tooltip } from 'antd'; -import { InfoCircleOutlined } from '@ant-design/icons'; import request from 'umi-request'; const schema = { diff --git a/docs/table-render/index.md b/docs/table-render/index.md index 1b3cc1b47..949b7b9c7 100644 --- a/docs/table-render/index.md +++ b/docs/table-render/index.md @@ -163,8 +163,8 @@ export default withTable(Page) **支持所有 antd table 的 props,但是`dataSource`, `loading`, `pagination`这几个参数是内部状态,不需要填写,最基本的使用就需要填写`columns`** | 属性 | 描述 | 类型 | 默认值 | -| --------------------- | ------------------------------------------------------------------------- | ------------------- | ----------- | -| headerTitle | 表格标题 | `string` | `ReactNode` | - | +| --------------------- | ------------------------------------------------------------------------- | ------------------- | ----------- | --- | +| headerTitle | 表格标题 | `string` | `ReactNode` | - | | toolbarRender | 表格主体右上方的控件,例如“添加”按钮 | `() => ReactNode[]` | `false` | | toolbarAction | 显示在表格主体右上方的 Icon 列表,内置了`刷新、调整密度、全屏显示` 等功能 | `boolean` | `false` | | pageChangeWithRequest | 切换分页时是否需要请求接口 | `boolean` | `true` | diff --git a/docs/table-render/test1.jsx b/docs/table-render/test1.jsx index 55640e612..ffe5d7c19 100644 --- a/docs/table-render/test1.jsx +++ b/docs/table-render/test1.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Table, Search, withTable } from 'table-render'; +import { Search, Table, withTable } from 'table-render'; const dataSource = []; for (let i = 0; i < 6; i++) { diff --git a/package.json b/package.json index a6017c9b1..3a4614beb 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "clean": "lerna clean -y", "changelog": "lerna-changelog", "publish": "npm run build && lerna publish -m \"chore: publish\" --no-verify-access", - "prettier": "prettier -c --write \"docs/**/*\" \"packages/**/*\" \"tools/**/*\" \"widgets/**/*\"", + "format": "prettier -c --write \"docs/**/*\" \"packages/**/*\" \"tools/**/*\" \"widgets/**/*\"", "test": "jest", "test:clean": "jest --clearCache" }, @@ -38,13 +38,23 @@ "lerna-changelog": "^1.0.1", "lint-staged": "^10.0.7", "monaco-editor-webpack-plugin": "^4.1.1", - "prettier": "^1.19.1", + "prettier": "^2.6.0", + "prettier-plugin-organize-imports": "^2.3.4", + "prettier-plugin-packagejson": "^2.2.16", "prismjs": "^1.20.0", "react": "^16.12.0", "react-monaco-editor": "^0.44.0", "react-simple-code-editor": "^0.11.0", "yorkie": "^2.0.0" }, + "lint-staged": { + "*.{js,jsx,less,md,json}": [ + "prettier --write" + ], + "*.ts?(x)": [ + "prettier --parser=typescript --write" + ] + }, "repository": { "type": "git", "url": "git+https://github.com/alibaba/x-render.git", diff --git a/packages/chart-render/package.json b/packages/chart-render/package.json index 9d50156cc..4dbd1c5bc 100644 --- a/packages/chart-render/package.json +++ b/packages/chart-render/package.json @@ -1,24 +1,35 @@ { "name": "chart-render", "version": "0.1.9", - "scripts": { - "build": "father-build", - "prepare": "npm run build", - "postpublish": "git push --tags", - "beta": "npm publish --tag beta", - "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", - "test": "umi-test", - "test:coverage": "umi-test --coverage" + "keywords": [ + "Chart", + "ChartRender", + "Render", + "XRender", + "React", + "Json Schema", + "Ant Design" + ], + "homepage": "https://x-render.gitee.io/chart-render", + "bugs": { + "url": "https://github.com/alibaba/x-render/issues" }, "repository": { "type": "git", "url": "git@github.com:alibaba/form-render.git" }, + "license": "MIT", "main": "dist/index.js", "module": "dist/index.esm.js", "typings": "dist/index.d.ts", - "gitHooks": { - "pre-commit": "lint-staged" + "scripts": { + "beta": "npm publish --tag beta", + "build": "father-build", + "prepare": "npm run build", + "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", + "test": "umi-test", + "test:coverage": "umi-test --coverage" }, "lint-staged": { "*.{js,jsx,less,md,json}": [ @@ -28,9 +39,6 @@ "prettier --parser=typescript --write" ] }, - "peerDependencies": { - "react": ">=16.8.0" - }, "dependencies": { "@ant-design/charts": "~1.2.14", "ali-react-table": "^2.4.0", @@ -40,18 +48,10 @@ "@types/react": "^17.0.3", "@umijs/test": "^3.0.5" }, - "keywords": [ - "Chart", - "ChartRender", - "Render", - "XRender", - "React", - "Json Schema", - "Ant Design" - ], - "homepage": "https://x-render.gitee.io/chart-render", - "license": "MIT", - "bugs": { - "url": "https://github.com/alibaba/x-render/issues" + "peerDependencies": { + "react": ">=16.8.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/packages/chart-render/src/components/Column/index.tsx b/packages/chart-render/src/components/Column/index.tsx index 7f99252d3..290077fdd 100644 --- a/packages/chart-render/src/components/Column/index.tsx +++ b/packages/chart-render/src/components/Column/index.tsx @@ -1,8 +1,7 @@ +import { Bar, Column, ColumnConfig } from '@ant-design/charts'; import React from 'react'; -import { ICommonProps } from '../../utils/types'; -import { Bar, Column } from '@ant-design/charts'; import { splitMeta } from '../../utils'; -import { ColumnConfig } from '@ant-design/charts'; +import { ICommonProps } from '../../utils/types'; import ErrorTemplate from '../ErrorTemplate'; export interface ICRColumnProps @@ -31,7 +30,7 @@ export function generateConfig( xField, yField, data: data - .map(item => { + .map((item) => { return metaInd.map(({ id, name }) => { return { [xField]: id, @@ -42,7 +41,7 @@ export function generateConfig( .flat(), meta: { [xField]: { - formatter: label => + formatter: (label) => meta.find(({ id }) => label === id)?.name || label, }, }, @@ -72,7 +71,7 @@ export function generateConfig( const seriesField = 'type'; return { data: data - .map(item => { + .map((item) => { return metaInd.map(({ id, name }) => { return { [xField]: item[xField], diff --git a/packages/chart-render/src/components/Line/index.tsx b/packages/chart-render/src/components/Line/index.tsx index bc3a9ed70..ca23c422d 100644 --- a/packages/chart-render/src/components/Line/index.tsx +++ b/packages/chart-render/src/components/Line/index.tsx @@ -1,10 +1,9 @@ -import React from 'react'; -import { Area, Line, DualAxes } from '@ant-design/charts'; -import { AreaConfig } from '@ant-design/charts'; -import { LineConfig } from '@ant-design/charts/es/plots/line'; +import { Area, AreaConfig, DualAxes, Line } from '@ant-design/charts'; import { DualAxesConfig } from '@ant-design/charts/es/plots/dualAxes'; -import { ICommonProps, IMetaItem } from '../../utils/types'; +import { LineConfig } from '@ant-design/charts/es/plots/line'; +import React from 'react'; import { splitMeta, strip } from '../../utils'; +import { ICommonProps, IMetaItem } from '../../utils/types'; import ErrorTemplate from '../ErrorTemplate'; export interface ILine @@ -48,7 +47,7 @@ export function generateConfig( yField, yAxis: { label: { - formatter: v => { + formatter: (v) => { return yFieldMeta.isRate ? `${strip(100 * Number(v))}%` : v; }, }, @@ -80,7 +79,7 @@ export function generateConfig( seriesField, yAxis: { label: { - formatter: v => { + formatter: (v) => { return yFieldMeta.isRate ? `${strip(100 * Number(v))}%` : v; }, }, @@ -130,7 +129,7 @@ export function generateConfig( const seriesField = 'type'; return { data: data - .map(item => { + .map((item) => { return metaInd.map(({ id, name }) => { return { [xField]: item[xField], diff --git a/packages/chart-render/src/components/PivotTable/index.tsx b/packages/chart-render/src/components/PivotTable/index.tsx index 1abc4834b..5a4636f18 100644 --- a/packages/chart-render/src/components/PivotTable/index.tsx +++ b/packages/chart-render/src/components/PivotTable/index.tsx @@ -1,13 +1,13 @@ -import React, { useState } from 'react'; import { - CrossTable, buildDrillTree, buildRecordMatrix, convertDrillTreeToCrossTree, + CrossTable, } from 'ali-react-table/pivot'; import { createAggregateFunction } from 'dvt-aggregation'; -import { ICommonProps, IDataItem } from '../../utils/types'; +import React, { useState } from 'react'; import { splitMeta, strip } from '../../utils'; +import { ICommonProps, IDataItem } from '../../utils/types'; import './index.less'; export interface ICRPivotTableProps extends ICommonProps { @@ -94,7 +94,9 @@ const CRPivotTable: React.FC = ({ const leftCodes = leftMetaDim.map(({ id }) => id); const leftDrillTree = buildDrillTree(data, leftCodes, { includeTopWrapper: true, - isExpand: leftExpandable ? key => leftExpandKeys.includes(key) : undefined, + isExpand: leftExpandable + ? (key) => leftExpandKeys.includes(key) + : undefined, }); const [leftTreeRoot] = convertDrillTreeToCrossTree(leftDrillTree, { // @ts-expect-error => 可以传入 align 字段 @@ -103,7 +105,7 @@ const CRPivotTable: React.FC = ({ expandKeys: leftExpandKeys, onChangeExpandKeys: setLeftExpandKeys, generateSubtotalNode: showSubtotal - ? drillNode => ({ + ? (drillNode) => ({ position: 'start', value: drillNode.path.length === 0 @@ -118,7 +120,7 @@ const CRPivotTable: React.FC = ({ const topCodes = topMetaDim.map(({ id }) => id); const topDrillTree = buildDrillTree(data, topCodes, { includeTopWrapper: true, - isExpand: topExpandable ? key => topExpandKeys.includes(key) : undefined, + isExpand: topExpandable ? (key) => topExpandKeys.includes(key) : undefined, }); const [topTreeRoot] = convertDrillTreeToCrossTree(topDrillTree, { // @ts-expect-error => 可以传入 align 字段 @@ -127,7 +129,7 @@ const CRPivotTable: React.FC = ({ expandKeys: topExpandKeys, onChangeExpandKeys: setTopExpandKeys, generateSubtotalNode: showSubtotal - ? drillNode => ({ + ? (drillNode) => ({ position: 'start', value: drillNode.path.length === 0 diff --git a/packages/chart-render/src/utils/index.ts b/packages/chart-render/src/utils/index.ts index 137e89ebf..054c8e95f 100644 --- a/packages/chart-render/src/utils/index.ts +++ b/packages/chart-render/src/utils/index.ts @@ -8,7 +8,7 @@ import { IMetaItem } from './types'; export function splitMeta(meta: IMetaItem[]) { const metaDim: IMetaItem[] = []; const metaInd: IMetaItem[] = []; - meta.forEach(item => { + meta.forEach((item) => { if (item.isDim) { metaDim.push(item); } else { diff --git a/packages/form-render/README.md b/packages/form-render/README.md index 801d0a86e..f367b85b4 100644 --- a/packages/form-render/README.md +++ b/packages/form-render/README.md @@ -134,15 +134,15 @@ import Form, { useForm, connectForm } from 'form-render'; ### \
(常用 props) -| 参数 | 描述 | 类型 | 是否必填 | 默认值 | -| ------------ | ------------------------------------------------------------------------------ | ----------------------------------------------------------------- | -------- | -------- | -| schema | 描述表单的 schema,详见 | `object` | 是 | | -| form | `useForm`创建的表单实例,与 Form 一对一绑定 | `FormInstance` | 是 | | -| onFinish | 提交后的回调,执行 form.submit() 后触发 | `(formData, errorFields: Error[]) => void` | 否 | () => {} | -| beforeFinish | 在 onFinish 前触发,一般用于外部校验逻辑的回填,入参是个对象,便于扩展 | `({ data, errors, schema, ...rest }) => Error[]|Promise` | 否 | () => {} | -| displayType | 表单元素与 label 同行 or 分两行展示, inline 则整个展示自然顺排 | `string('column' / 'row' / 'inline')` | 否 | 'column' | -| widgets | 自定义组件,当内置组件无法满足时使用 | `object` | 否 | {} | -| watch | 类似于 vue 的 watch 的用法,详见[表单监听 & 回调](/form-render/advanced/watch) | `object` | 否 | {} | +| 参数 | 描述 | 类型 | 是否必填 | 默认值 | +| ------------ | ------------------------------------------------------------------------------ | ----------------------------------------------- | ----------------- | -------- | -------- | +| schema | 描述表单的 schema,详见 | `object` | 是 | | +| form | `useForm`创建的表单实例,与 Form 一对一绑定 | `FormInstance` | 是 | | +| onFinish | 提交后的回调,执行 form.submit() 后触发 | `(formData, errorFields: Error[]) => void` | 否 | () => {} | +| beforeFinish | 在 onFinish 前触发,一般用于外部校验逻辑的回填,入参是个对象,便于扩展 | `({ data, errors, schema, ...rest }) => Error[] | Promise` | 否 | () => {} | +| displayType | 表单元素与 label 同行 or 分两行展示, inline 则整个展示自然顺排 | `string('column' / 'row' / 'inline')` | 否 | 'column' | +| widgets | 自定义组件,当内置组件无法满足时使用 | `object` | 否 | {} | +| watch | 类似于 vue 的 watch 的用法,详见[表单监听 & 回调](/form-render/advanced/watch) | `object` | 否 | {} | 注 1: @@ -200,11 +200,11 @@ export default connectForm(Demo); **form 方法** | 参数 | 描述 | 类型 | -| ---------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| ---------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ----------------- | | submit | 触发提交流程,一般在提交按钮上使用 | `() => void` | | resetFields | 清空表单(也会清空一些内置状态,例如校验) | `({formData?: any, submitData?: any, errorFields?: Error[], touchedKeys?: any[], allTouched?: boolean}) => void` | | errorFields | 表单校验错误的数组 | `array,[{name, error: []}]` | -| setErrorFields | 外部手动修改 errorFields 校验信息,用于外部校验回填 | `(error: Error | Error[]) => void` | +| setErrorFields | 外部手动修改 errorFields 校验信息,用于外部校验回填 | `(error: Error | Error[]) => void` | | setValues | 外部手动修改 formData,用于已填写的表单的数据回填 | `(formData: any) => void` | | onItemChange | 外部修改指定单个 field 的数据 | `(path: string, value: any) => void` | | getValues | 获取表单内部维护的数据 formData | `() => void` | diff --git a/packages/form-render/package.json b/packages/form-render/package.json index e48ab110b..f86b0613a 100644 --- a/packages/form-render/package.json +++ b/packages/form-render/package.json @@ -2,6 +2,19 @@ "name": "form-render", "version": "1.9.5", "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成", + "keywords": [ + "Form", + "FormRender", + "Render", + "XRender", + "React", + "Json Schema", + "Ant Design" + ], + "homepage": "https://x-render.gitee.io/form-render", + "bugs": { + "url": "https://github.com/alibaba/x-render/issues" + }, "repository": { "type": "git", "url": "git@github.com:alibaba/form-render.git" @@ -21,20 +34,17 @@ "email": "fateriddle@gmail.com" } ], + "main": "lib/index.js", + "module": "es/index.js", "scripts": { + "beta": "npm publish --tag beta", "build": "father-build", "prepare": "npm run build", - "postpublish": "git push --tags", - "beta": "npm publish --tag beta", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "lib/index.js", - "module": "es/index.js", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -53,26 +63,16 @@ "rc-color-picker": "^1.2.6", "virtualizedtableforantd4": "^1.1.2" }, + "devDependencies": { + "deep-equal": "^2.0.3", + "rollup-plugin-copy": "^3.4.0" + }, "peerDependencies": { "antd": "4.x", "react": ">=16.8.0", "react-dom": ">=16.8.0" }, - "devDependencies": { - "deep-equal": "^2.0.3", - "rollup-plugin-copy": "^3.4.0" - }, - "keywords": [ - "Form", - "FormRender", - "Render", - "XRender", - "React", - "Json Schema", - "Ant Design" - ], - "homepage": "https://x-render.gitee.io/form-render", - "bugs": { - "url": "https://github.com/alibaba/x-render/issues" + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/packages/form-render/src/form-render-core/src/atom.less b/packages/form-render/src/form-render-core/src/atom.less index ae58ae8c6..03a988625 100644 --- a/packages/form-render/src/form-render-core/src/atom.less +++ b/packages/form-render/src/form-render-core/src/atom.less @@ -1085,7 +1085,7 @@ } .debug-grid { background: transparent - url( data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVR4AWPAC97/9x0eCsAEPgwAVLshdpENIxcAAAAASUVORK5CYII= ) + url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVR4AWPAC97/9x0eCsAEPgwAVLshdpENIxcAAAAASUVORK5CYII=) repeat top left; } diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/CardList.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/CardList.js index 2513cbb98..ec4abac00 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/CardList.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/CardList.js @@ -1,14 +1,14 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ -import React from 'react'; -import Core from '../../index'; -import { Button, Popconfirm } from 'antd'; // import ArrowDown from '../../../components/ArrowDown'; import { + ArrowDownOutlined, + ArrowUpOutlined, CloseOutlined, CopyOutlined, - ArrowUpOutlined, - ArrowDownOutlined, } from '@ant-design/icons'; +import { Button, Popconfirm } from 'antd'; +import React from 'react'; +import Core from '../../index'; const CardList = ({ displayList = [], diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/DrawerList.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/DrawerList.js index 689e535d6..e9a2b2c17 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/DrawerList.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/DrawerList.js @@ -1,11 +1,11 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ +// import ArrowDown from '../../../components/ArrowDown'; +import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons'; +import { Button, Drawer, Popconfirm, Table } from 'antd'; import React, { useRef } from 'react'; -import Core from '../../index'; import { useSet, useTools } from '../../../hooks'; -import { getDataPath, getKeyFromPath, getDisplayValue } from '../../../utils'; -import { Button, Table, Drawer, Popconfirm } from 'antd'; -// import ArrowDown from '../../../components/ArrowDown'; -import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; +import { getDataPath, getDisplayValue, getKeyFromPath } from '../../../utils'; +import Core from '../../index'; import ErrorMessage from '../../RenderField/ErrorMessage'; const FIELD_LENGTH = 170; diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/SimpleList.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/SimpleList.js index 2d829ec2b..de5ab5e6a 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/SimpleList.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/SimpleList.js @@ -1,12 +1,12 @@ -import React from 'react'; -import Core from '../../index'; -import { Button, Popconfirm } from 'antd'; import { - DeleteOutlined, - CopyOutlined, - ArrowUpOutlined, ArrowDownOutlined, + ArrowUpOutlined, + CopyOutlined, + DeleteOutlined, } from '@ant-design/icons'; +import { Button, Popconfirm } from 'antd'; +import React from 'react'; +import Core from '../../index'; const SimpleList = ({ schema, diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TabList.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TabList.js index d2873259d..9d38d6aca 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TabList.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TabList.js @@ -1,7 +1,7 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ +import { Tabs } from 'antd'; import React, { useState } from 'react'; import Core from '../../index'; -import { Tabs } from 'antd'; const { TabPane } = Tabs; diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TableList.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TableList.js index b1a992839..b5de9a914 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TableList.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/TableList.js @@ -1,8 +1,8 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ +import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons'; +import { Button, Popconfirm, Table } from 'antd'; import React from 'react'; import Core from '../../index'; -import { Button, Table, Popconfirm } from 'antd'; -import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; const FIELD_LENGTH = 170; diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/VirtualList.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/VirtualList.js index 09bf05df0..ff51e4034 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/VirtualList.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/VirtualList.js @@ -1,9 +1,9 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ -import React from 'react'; -import Core from '../../index'; +import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons'; import { Button, Popconfirm, Table } from 'antd'; +import React from 'react'; import { useVT } from 'virtualizedtableforantd4'; -import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; +import Core from '../../index'; const FIELD_LENGTH = 170; diff --git a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/index.js b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/index.js index 69ed51225..cbc3fe624 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/index.js +++ b/packages/form-render/src/form-render-core/src/core/RenderChildren/RenderList/index.js @@ -1,15 +1,19 @@ /* eslint-disable jsx-a11y/anchor-is-valid */ -import React from 'react'; import { get } from 'lodash-es'; +import React from 'react'; import { useStore, useTools } from '../../../hooks'; -import { getDataPath, getSchemaFromFlatten, generateDataSkeleton } from '../../../utils'; +import { + generateDataSkeleton, + getDataPath, + getSchemaFromFlatten, +} from '../../../utils'; +import CardList from './CardList'; +import DrawerList from './DrawerList'; import './list.less'; import SimpleList from './SimpleList'; -import CardList from './CardList'; import TableList from './TableList'; -import DrawerList from './DrawerList'; -import VirtualList from './VirtualList'; import TabList from './TabList'; +import VirtualList from './VirtualList'; const RenderList = ({ parentId, @@ -19,7 +23,6 @@ const RenderList = ({ errorFields, displayType, }) => { - const { formData, flatten } = useStore(); const { onItemChange, removeTouched } = useTools(); diff --git a/packages/form-render/src/form-render-core/src/core/RenderField/ExtendedWidget.js b/packages/form-render/src/form-render-core/src/core/RenderField/ExtendedWidget.js index d498a9179..0be5affaa 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderField/ExtendedWidget.js +++ b/packages/form-render/src/form-render-core/src/core/RenderField/ExtendedWidget.js @@ -1,9 +1,8 @@ import React, { Suspense } from 'react'; -import { getWidgetName, extraSchemaList } from '../../mapping'; -import { useTools, useStore } from '../../hooks'; import { transformProps } from '../../createWidget'; - -import { isObjType, isListType, isObject } from '../../utils'; +import { useStore, useTools } from '../../hooks'; +import { extraSchemaList, getWidgetName } from '../../mapping'; +import { isListType, isObject, isObjType } from '../../utils'; const ErrorSchema = schema => { return ( diff --git a/packages/form-render/src/form-render-core/src/core/RenderField/index.js b/packages/form-render/src/form-render-core/src/core/RenderField/index.js index ca20e0e53..560837363 100644 --- a/packages/form-render/src/form-render-core/src/core/RenderField/index.js +++ b/packages/form-render/src/form-render-core/src/core/RenderField/index.js @@ -1,12 +1,12 @@ -import React, { useEffect, useRef } from 'react'; +import React, { useRef } from 'react'; import { useStore, useStore2, useTools } from '../../hooks'; import useDebouncedCallback from '../../useDebounce'; import { getValueByPath, isCheckBoxType, isObjType } from '../../utils'; +import { validateField } from '../../validator'; import ErrorMessage from './ErrorMessage'; +import ExtendedWidget from './ExtendedWidget'; import Extra from './Extra'; import FieldTitle from './Title'; -import { validateField } from '../../validator'; -import ExtendedWidget from './ExtendedWidget'; // TODO: 之后不要直接用get,收口到一个内部方法getValue,便于全局 ctrl + f 查找 const RenderField = props => { @@ -36,13 +36,8 @@ const RenderField = props => { locale, watch, } = useStore2(); - const { - onValuesChange, - onItemChange, - setEditing, - touchKey, - _setErrors, - } = useTools(); + const { onValuesChange, onItemChange, setEditing, touchKey, _setErrors } = + useTools(); const formDataRef = useRef(); formDataRef.current = formData; // console.log('', $id); diff --git a/packages/form-render/src/form-render-core/src/core/index.js b/packages/form-render/src/form-render-core/src/core/index.js index ab6ac7d40..d286cd434 100644 --- a/packages/form-render/src/form-render-core/src/core/index.js +++ b/packages/form-render/src/form-render-core/src/core/index.js @@ -1,21 +1,21 @@ import React, { useRef } from 'react'; -import RenderList from './RenderChildren/RenderList'; -import RenderObject from './RenderChildren/RenderObject'; -import RenderField from './RenderField'; import { useStore, useStore2 } from '../hooks'; import { - isLooselyNumber, - isCssLength, - getParentProps, + clone, + getDataPath, getParentPath, - isListType, + getParentProps, + getValueByPath, isCheckBoxType, + isCssLength, + isListType, + isLooselyNumber, isObjType, - getValueByPath, - getDataPath, parseRootValueInSchema, - clone, } from '../utils'; +import RenderList from './RenderChildren/RenderList'; +import RenderObject from './RenderChildren/RenderObject'; +import RenderField from './RenderField'; const Core = ({ id = '#', diff --git a/packages/form-render/src/form-render-core/src/hooks.js b/packages/form-render/src/form-render-core/src/hooks.js index 76b763049..48680ec36 100644 --- a/packages/form-render/src/form-render-core/src/hooks.js +++ b/packages/form-render/src/form-render-core/src/hooks.js @@ -1,10 +1,10 @@ import { - useReducer, + createContext, useContext, - useRef, useEffect, + useReducer, + useRef, useState, - createContext, } from 'react'; export const Ctx = createContext(() => {}); diff --git a/packages/form-render/src/form-render-core/src/index.js b/packages/form-render/src/form-render-core/src/index.js index 2736ab1c7..f09b2fb8f 100644 --- a/packages/form-render/src/form-render-core/src/index.js +++ b/packages/form-render/src/form-render-core/src/index.js @@ -1,25 +1,26 @@ /* eslint-disable react-hooks/exhaustive-deps */ import React, { useEffect, useMemo, useRef } from 'react'; +import './atom.less'; +import Core from './core'; +import { Ctx, Store2Ctx, StoreCtx } from './hooks'; +import './index.less'; +import { mapping as defaultMapping } from './mapping'; import { - updateSchemaToNewVersion, + getParamByName, msToTime, + updateSchemaToNewVersion, yymmdd, - getParamByName, } from './utils'; -import Core from './core'; import Watcher from './Watcher'; -import { Ctx, StoreCtx, Store2Ctx } from './hooks'; -import './atom.less'; -import './index.less'; -import { mapping as defaultMapping } from './mapping'; const defaultFinish = (data, errors) => { console.log('onFinish:', { data, errors }); }; +export { default as connectForm } from './connectForm'; +export { createWidget } from './createWidget'; export { default as useForm } from './useForm'; export { defaultMapping as mapping }; -export { default as connectForm } from './connectForm'; function App({ id, @@ -359,8 +360,6 @@ function App({ ); } -export { createWidget } from './createWidget'; - const Wrapper = props => { const { isOldVersion = true, schema, ...rest } = props || {}; let _schema = useRef(schema); diff --git a/packages/form-render/src/form-render-core/src/processData.js b/packages/form-render/src/form-render-core/src/processData.js index 17b00e38a..e54fc384c 100644 --- a/packages/form-render/src/form-render-core/src/processData.js +++ b/packages/form-render/src/form-render-core/src/processData.js @@ -1,10 +1,11 @@ +import { get, set, unset } from 'lodash-es'; import { - removeEmptyItemFromList, cleanEmpty, + clone, + isObject, + removeEmptyItemFromList, removeHiddenFromResult, } from './utils'; -import { unset, get, set } from 'lodash-es'; -import { isObject, clone } from './utils'; // 提交前需要先处理formData的逻辑 export const processData = (data, flatten, removeHiddenData) => { // 1. 去掉 hidden = true 的元素 diff --git a/packages/form-render/src/form-render-core/src/useDebounce.js b/packages/form-render/src/form-render-core/src/useDebounce.js index d71c32dbb..a002858ef 100644 --- a/packages/form-render/src/form-render-core/src/useDebounce.js +++ b/packages/form-render/src/form-render-core/src/useDebounce.js @@ -1,4 +1,4 @@ -import { useRef, useEffect, useMemo } from 'react'; +import { useEffect, useMemo, useRef } from 'react'; function useDebouncedCallback(func, wait, options) { const lastCallTime = useRef(null); @@ -147,7 +147,11 @@ function useDebouncedCallback(func, wait, options) { : clearTimeout(timerId.current); } lastInvokeTime.current = 0; - lastArgs.current = lastCallTime.current = lastThis.current = timerId.current = null; + lastArgs.current = + lastCallTime.current = + lastThis.current = + timerId.current = + null; }; func.isPending = () => { diff --git a/packages/form-render/src/form-render-core/src/useForm.js b/packages/form-render/src/form-render-core/src/useForm.js index fe800f4f5..a86778ba4 100644 --- a/packages/form-render/src/form-render-core/src/useForm.js +++ b/packages/form-render/src/form-render-core/src/useForm.js @@ -1,16 +1,16 @@ /* eslint-disable react-hooks/exhaustive-deps */ -import { useEffect, useRef, useMemo, useState } from 'react'; -import { validateAll } from './validator'; -import { useSet } from './hooks'; import { set, sortedUniqBy } from 'lodash-es'; +import { useEffect, useMemo, useRef, useState } from 'react'; +import { useSet } from './hooks'; import { processData, transformDataWithBind2 } from './processData'; import { - generateDataSkeleton, - flattenSchema, clone, - schemaContainsExpression, + flattenSchema, + generateDataSkeleton, parseAllExpression, + schemaContainsExpression, } from './utils'; +import { validateAll } from './validator'; const useForm = props => { const { diff --git a/packages/form-render/src/form-render-core/src/utils.js b/packages/form-render/src/form-render-core/src/utils.js index c99ae0536..5398a792e 100644 --- a/packages/form-render/src/form-render-core/src/utils.js +++ b/packages/form-render/src/form-render-core/src/utils.js @@ -1,4 +1,4 @@ -import { get, set, cloneDeep, isEmpty } from 'lodash-es'; +import { cloneDeep, get, isEmpty, set } from 'lodash-es'; export function getParamByName(name, url = window.location.href) { name = name.replace(/[\[\]]/g, '\\$&'); diff --git a/packages/form-render/src/form-render-core/src/validator.js b/packages/form-render/src/form-render-core/src/validator.js index cc8fb0639..81309a0dc 100644 --- a/packages/form-render/src/form-render-core/src/validator.js +++ b/packages/form-render/src/form-render-core/src/validator.js @@ -1,19 +1,19 @@ /* eslint-disable react-hooks/exhaustive-deps */ +import Validator from 'async-validator'; +import { get, merge } from 'lodash-es'; import { - getDescriptorSimple, + allPromiseFinish, dataToKeys, destructDataPath, getDataPath, + getDescriptorSimple, isExpression, - parseSingleExpression, isObject, - allPromiseFinish, + parseSingleExpression, removeDups, } from './utils'; -import { defaultValidateMessagesCN } from './validateMessageCN'; import { defaultValidateMessages } from './validateMessage'; -import Validator from 'async-validator'; -import { get, merge } from 'lodash-es'; +import { defaultValidateMessagesCN } from './validateMessageCN'; export const parseSchemaExpression = (schema, formData, path) => { if (!isObject(schema)) return schema; diff --git a/packages/form-render/src/index.d.ts b/packages/form-render/src/index.d.ts index 6b701e7da..ed4d19430 100644 --- a/packages/form-render/src/index.d.ts +++ b/packages/form-render/src/index.d.ts @@ -1,5 +1,5 @@ -import * as React from 'react'; import { RuleItem } from 'async-validator'; +import * as React from 'react'; interface SchemaBase { type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'range' | 'html'; diff --git a/packages/form-render/src/index.js b/packages/form-render/src/index.js index f625cb057..8d639638d 100644 --- a/packages/form-render/src/index.js +++ b/packages/form-render/src/index.js @@ -1,16 +1,16 @@ -import React from 'react'; import { ConfigProvider } from 'antd'; import zhCN from 'antd/lib/locale/zh_CN'; +import React from 'react'; import FRCore from './form-render-core/src'; import { widgets as defaultWidgets } from './widgets/antd'; -export { defaultWidgets as widgets }; export { - useForm, connectForm, createWidget, mapping, + useForm, } from './form-render-core/src'; +export { defaultWidgets as widgets }; const FR = ({ widgets, configProvider, ...rest }) => { return ( diff --git a/packages/form-render/src/widgets/antd/checkboxes.js b/packages/form-render/src/widgets/antd/checkboxes.js index 875742ec7..0ff0c8f74 100644 --- a/packages/form-render/src/widgets/antd/checkboxes.js +++ b/packages/form-render/src/widgets/antd/checkboxes.js @@ -1,5 +1,5 @@ -import React from 'react'; import { Checkbox } from 'antd'; +import React from 'react'; import { getArray } from '../../utils'; const Checkboxes = ({ schema, options: _options, ...rest }) => { diff --git a/packages/form-render/src/widgets/antd/color.js b/packages/form-render/src/widgets/antd/color.js index de87bdf2b..6974b2eb5 100644 --- a/packages/form-render/src/widgets/antd/color.js +++ b/packages/form-render/src/widgets/antd/color.js @@ -1,109 +1,109 @@ -import React from 'react'; -import ColorPicker from 'rc-color-picker'; import { Input } from 'antd'; +import ColorPicker from 'rc-color-picker'; import 'rc-color-picker/assets/index.css'; +import React from 'react'; const alphaHexMap = { '1.00': 'FF', - '0.99': 'FC', - '0.98': 'FA', - '0.97': 'F7', - '0.96': 'F5', - '0.95': 'F2', - '0.94': 'F0', - '0.93': 'ED', - '0.92': 'EB', - '0.91': 'E8', + 0.99: 'FC', + 0.98: 'FA', + 0.97: 'F7', + 0.96: 'F5', + 0.95: 'F2', + 0.94: 'F0', + 0.93: 'ED', + 0.92: 'EB', + 0.91: 'E8', '0.90': 'E6', - '0.89': 'E3', - '0.88': 'E0', - '0.87': 'DE', - '0.86': 'DB', - '0.85': 'D9', - '0.84': 'D6', - '0.83': 'D4', - '0.82': 'D1', - '0.81': 'CF', + 0.89: 'E3', + 0.88: 'E0', + 0.87: 'DE', + 0.86: 'DB', + 0.85: 'D9', + 0.84: 'D6', + 0.83: 'D4', + 0.82: 'D1', + 0.81: 'CF', '0.80': 'CC', - '0.79': 'C9', - '0.78': 'C7', - '0.77': 'C4', - '0.76': 'C2', - '0.75': 'BF', - '0.74': 'BD', - '0.73': 'BA', - '0.72': 'B8', - '0.71': 'B5', + 0.79: 'C9', + 0.78: 'C7', + 0.77: 'C4', + 0.76: 'C2', + 0.75: 'BF', + 0.74: 'BD', + 0.73: 'BA', + 0.72: 'B8', + 0.71: 'B5', '0.70': 'B3', - '0.69': 'B0', - '0.68': 'AD', - '0.67': 'AB', - '0.66': 'A8', - '0.65': 'A6', - '0.64': 'A3', - '0.63': 'A1', - '0.62': '9E', - '0.61': '9C', + 0.69: 'B0', + 0.68: 'AD', + 0.67: 'AB', + 0.66: 'A8', + 0.65: 'A6', + 0.64: 'A3', + 0.63: 'A1', + 0.62: '9E', + 0.61: '9C', '0.60': '99', - '0.59': '96', - '0.58': '94', - '0.57': '91', - '0.56': '8F', - '0.55': '8C', - '0.54': '8A', - '0.53': '87', - '0.52': '85', - '0.51': '82', + 0.59: '96', + 0.58: '94', + 0.57: '91', + 0.56: '8F', + 0.55: '8C', + 0.54: '8A', + 0.53: '87', + 0.52: '85', + 0.51: '82', '0.50': '80', - '0.49': '7D', - '0.48': '7A', - '0.47': '78', - '0.46': '75', - '0.45': '73', - '0.44': '70', - '0.43': '6E', - '0.42': '6B', - '0.41': '69', + 0.49: '7D', + 0.48: '7A', + 0.47: '78', + 0.46: '75', + 0.45: '73', + 0.44: '70', + 0.43: '6E', + 0.42: '6B', + 0.41: '69', '0.40': '66', - '0.39': '63', - '0.38': '61', - '0.37': '5E', - '0.36': '5C', - '0.35': '59', - '0.34': '57', - '0.33': '54', - '0.32': '52', - '0.31': '4F', + 0.39: '63', + 0.38: '61', + 0.37: '5E', + 0.36: '5C', + 0.35: '59', + 0.34: '57', + 0.33: '54', + 0.32: '52', + 0.31: '4F', '0.30': '4D', - '0.29': '4A', - '0.28': '47', - '0.27': '45', - '0.26': '42', - '0.25': '40', - '0.24': '3D', - '0.23': '3B', - '0.22': '38', - '0.21': '36', + 0.29: '4A', + 0.28: '47', + 0.27: '45', + 0.26: '42', + 0.25: '40', + 0.24: '3D', + 0.23: '3B', + 0.22: '38', + 0.21: '36', '0.20': '33', - '0.19': '30', - '0.18': '2E', - '0.17': '2B', - '0.16': '29', - '0.15': '26', - '0.14': '24', - '0.13': '21', - '0.12': '1F', - '0.11': '1C', + 0.19: '30', + 0.18: '2E', + 0.17: '2B', + 0.16: '29', + 0.15: '26', + 0.14: '24', + 0.13: '21', + 0.12: '1F', + 0.11: '1C', '0.10': '1A', - '0.09': '17', - '0.08': '14', - '0.07': '12', - '0.06': '0F', - '0.05': '0D', - '0.04': '0A', - '0.03': '08', - '0.02': '05', - '0.01': '03', + 0.09: '17', + 0.08: '14', + 0.07: '12', + 0.06: '0F', + 0.05: '0D', + 0.04: '0A', + 0.03: '08', + 0.02: '05', + 0.01: '03', '0.00': '00', }; diff --git a/packages/form-render/src/widgets/antd/date.js b/packages/form-render/src/widgets/antd/date.js index db98ae066..f6cf2c8c2 100644 --- a/packages/form-render/src/widgets/antd/date.js +++ b/packages/form-render/src/widgets/antd/date.js @@ -1,6 +1,6 @@ -import React, { useMemo } from 'react'; -import moment from 'moment'; import { DatePicker } from 'antd'; +import moment from 'moment'; +import React, { useMemo } from 'react'; import { getFormat } from '../../utils'; // TODO: 不要使用 moment,使用 dayjs @@ -21,7 +21,7 @@ export default ({ onChange, format, value, style, ...rest }) => { if (_value) { _value = moment(_value, dateFormat); } - return _value + return _value; }, [value]); const handleChange = (value, string) => { diff --git a/packages/form-render/src/widgets/antd/dateRange.js b/packages/form-render/src/widgets/antd/dateRange.js index 56e7bbac8..1591af219 100644 --- a/packages/form-render/src/widgets/antd/dateRange.js +++ b/packages/form-render/src/widgets/antd/dateRange.js @@ -2,9 +2,9 @@ * Updated by Tw93 on 2019-12-08. * 日历多选组件 */ -import React from 'react'; import { DatePicker } from 'antd'; import moment from 'moment'; +import React from 'react'; import { getFormat } from '../../utils'; const { RangePicker } = DatePicker; diff --git a/packages/form-render/src/widgets/antd/imageInput.js b/packages/form-render/src/widgets/antd/imageInput.js index ea264f44e..b6034ed8b 100644 --- a/packages/form-render/src/widgets/antd/imageInput.js +++ b/packages/form-render/src/widgets/antd/imageInput.js @@ -1,6 +1,6 @@ -import React from 'react'; import { PictureOutlined } from '@ant-design/icons'; import { Input, Popover } from 'antd'; +import React from 'react'; const DEFAULT_IMG = 'https://img.alicdn.com/tfs/TB14tSiKhTpK1RjSZFKXXa2wXXa-354-330.png'; diff --git a/packages/form-render/src/widgets/antd/index.js b/packages/form-render/src/widgets/antd/index.js index 72f33283d..dafa5616e 100644 --- a/packages/form-render/src/widgets/antd/index.js +++ b/packages/form-render/src/widgets/antd/index.js @@ -1,20 +1,20 @@ +import { Checkbox, Input, InputNumber, Rate, Switch, TreeSelect } from 'antd'; +import checkboxes from './checkboxes'; +import color from './color'; +import date from './date'; +import dateRange from './dateRange'; +import Html from './html'; +import ImageInput from './imageInput'; import list from './list'; import map from './map'; -import { InputNumber, Checkbox, Input, Switch, Rate, TreeSelect } from 'antd'; -import ImageInput from './imageInput'; -import urlInput from './urlInput'; -import Html from './html'; -import select from './select'; -import checkboxes from './checkboxes'; import multiSelect from './multiSelect'; import radio from './radio'; +import select from './select'; +import slider from './slider'; import time from './time'; -import date from './date'; -import dateRange from './dateRange'; import timeRange from './timeRange'; -import color from './color'; -import slider from './slider'; import upload from './upload'; +import urlInput from './urlInput'; // const Cascader = React.lazy(() => import('antd/es/cascader')); diff --git a/packages/form-render/src/widgets/antd/map.js b/packages/form-render/src/widgets/antd/map.js index a098efe9f..a2ecea469 100644 --- a/packages/form-render/src/widgets/antd/map.js +++ b/packages/form-render/src/widgets/antd/map.js @@ -1,5 +1,5 @@ -import React, { useState, useEffect } from 'react'; import { Collapse } from 'antd'; +import React, { useEffect, useState } from 'react'; // import { useStore2 } from '../../hooks'; const { Panel } = Collapse; diff --git a/packages/form-render/src/widgets/antd/multiSelect.js b/packages/form-render/src/widgets/antd/multiSelect.js index a2aa8aecb..379e199d0 100644 --- a/packages/form-render/src/widgets/antd/multiSelect.js +++ b/packages/form-render/src/widgets/antd/multiSelect.js @@ -1,5 +1,5 @@ -import React from 'react'; import { Select } from 'antd'; +import React from 'react'; import { getArray } from '../../utils'; const MultiSelect = ({ schema, value, style, options: _options, ...rest }) => { diff --git a/packages/form-render/src/widgets/antd/percentSlider.js b/packages/form-render/src/widgets/antd/percentSlider.js index e63b5838e..c36abd85b 100644 --- a/packages/form-render/src/widgets/antd/percentSlider.js +++ b/packages/form-render/src/widgets/antd/percentSlider.js @@ -1,5 +1,5 @@ -import React from 'react'; import { InputNumber, Slider } from 'antd'; +import React from 'react'; const PercentSlider = p => { const { max, min, step } = p.schema; diff --git a/packages/form-render/src/widgets/antd/radio.js b/packages/form-render/src/widgets/antd/radio.js index 95c4ecb62..a410a3b81 100644 --- a/packages/form-render/src/widgets/antd/radio.js +++ b/packages/form-render/src/widgets/antd/radio.js @@ -1,5 +1,5 @@ -import React from 'react'; import { Radio } from 'antd'; +import React from 'react'; import { getArray } from '../../utils'; const Radioes = ({ schema, options: _options, props, ...rest }) => { diff --git a/packages/form-render/src/widgets/antd/select.js b/packages/form-render/src/widgets/antd/select.js index d3e98f9b0..2629c69dc 100644 --- a/packages/form-render/src/widgets/antd/select.js +++ b/packages/form-render/src/widgets/antd/select.js @@ -1,7 +1,7 @@ -import React, { useMemo } from 'react'; import { Select } from 'antd'; -import { getArray } from '../../utils'; import { isUndefined } from 'lodash-es'; +import React from 'react'; +import { getArray } from '../../utils'; const FrSelect = ({ schema, diff --git a/packages/form-render/src/widgets/antd/slider.js b/packages/form-render/src/widgets/antd/slider.js index b7a982cee..15e746839 100644 --- a/packages/form-render/src/widgets/antd/slider.js +++ b/packages/form-render/src/widgets/antd/slider.js @@ -3,8 +3,8 @@ * 滑动输入组件 */ -import React from 'react'; import { InputNumber, Slider } from 'antd'; +import React from 'react'; const SliderWithNumber = ({ schema, diff --git a/packages/form-render/src/widgets/antd/time.js b/packages/form-render/src/widgets/antd/time.js index 02016421b..b714e60ad 100644 --- a/packages/form-render/src/widgets/antd/time.js +++ b/packages/form-render/src/widgets/antd/time.js @@ -1,6 +1,6 @@ -import React from 'react'; -import moment from 'moment'; import { TimePicker } from 'antd'; +import moment from 'moment'; +import React from 'react'; import { getFormat } from '../../utils'; // TODO: 不要使用moment,使用dayjs diff --git a/packages/form-render/src/widgets/antd/timeRange.js b/packages/form-render/src/widgets/antd/timeRange.js index 967b34cdf..5595738c5 100644 --- a/packages/form-render/src/widgets/antd/timeRange.js +++ b/packages/form-render/src/widgets/antd/timeRange.js @@ -2,9 +2,9 @@ * Updated by Tw93 on 2019-12-08. * 日历多选组件 */ -import React from 'react'; import { TimePicker } from 'antd'; import moment from 'moment'; +import React from 'react'; import { getFormat } from '../../utils'; const { RangePicker } = TimePicker; diff --git a/packages/form-render/src/widgets/antd/upload.js b/packages/form-render/src/widgets/antd/upload.js index 7bc892e5e..3ab093445 100644 --- a/packages/form-render/src/widgets/antd/upload.js +++ b/packages/form-render/src/widgets/antd/upload.js @@ -1,6 +1,6 @@ -import React from 'react'; import { UploadOutlined } from '@ant-design/icons'; -import { Upload, message, Button } from 'antd'; +import { Button, message, Upload } from 'antd'; +import React from 'react'; export default function FrUpload({ action, diff --git a/packages/form-render/src/widgets/antd/urlInput.js b/packages/form-render/src/widgets/antd/urlInput.js index 282fc40f6..4ba5832fe 100644 --- a/packages/form-render/src/widgets/antd/urlInput.js +++ b/packages/form-render/src/widgets/antd/urlInput.js @@ -1,5 +1,5 @@ -import React from 'react'; import { Input } from 'antd'; +import React from 'react'; import { isUrl } from '../../utils'; const UrlNode = ({ value, addonText = '测试链接' }) => { diff --git a/packages/table-render/README.md b/packages/table-render/README.md index fd6bd7ee1..9b0209f68 100644 --- a/packages/table-render/README.md +++ b/packages/table-render/README.md @@ -144,8 +144,8 @@ export default withTable(Wrapper); **支持所有 antd table 的 props,但是`dataSource`, `loading`, `pagination`这几个参数是内部状态,不需要填写,最基本的使用就需要填写`columns`** | 属性 | 描述 | 类型 | 默认值 | -| --------------------- | ------------------------------------------------------------------------- | ------------------- | ----------- | -| headerTitle | 表格标题 | `string` | `ReactNode` | - | +| --------------------- | ------------------------------------------------------------------------- | ------------------- | ----------- | --- | +| headerTitle | 表格标题 | `string` | `ReactNode` | - | | toolbarRender | 表格主体右上方的控件,例如“添加”按钮 | `() => ReactNode[]` | `false` | | toolbarAction | 显示在表格主体右上方的 Icon 列表,内置了`刷新、调整密度、全屏显示` 等功能 | `boolean` | `false` | | pageChangeWithRequest | 切换分页时是否需要请求接口 | `boolean` | `true` | diff --git a/packages/table-render/package.json b/packages/table-render/package.json index 84e30c133..309d1cae0 100644 --- a/packages/table-render/package.json +++ b/packages/table-render/package.json @@ -2,25 +2,35 @@ "name": "table-render", "version": "1.2.4", "description": "中后台表格解决方案", + "keywords": [ + "TableRender", + "Render", + "XRender", + "React", + "Json Schema", + "Ant Design" + ], + "homepage": "https://x-render.gitee.io/table-render", + "bugs": { + "url": "https://github.com/alibaba/x-render/issues" + }, + "license": "MIT", + "main": "dist/index.js", + "module": "dist/index.esm.js", + "typings": "dist/index.d.ts", "scripts": { - "start": "dumi dev", - "site": "dumi build", - "build": "father-build", "analyze": "ANALYZE=1 dumi dev", + "build": "father-build", "predeploy": "npm run site", "deploy": "gh-pages -d docs-dist", "prepare": "npm run build", - "postpublish": "git push --tags", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", + "site": "dumi build", + "start": "dumi dev", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "dist/index.js", - "module": "dist/index.esm.js", - "typings": "dist/index.d.ts", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -29,10 +39,6 @@ "prettier --parser=typescript --write" ] }, - "peerDependencies": { - "antd": "4.x", - "react": ">=16.8.0" - }, "dependencies": { "@ant-design/icons": "^4.2.2", "dayjs": "^1.8.29", @@ -42,17 +48,11 @@ "devDependencies": { "umi-request": "^1.3.5" }, - "keywords": [ - "TableRender", - "Render", - "XRender", - "React", - "Json Schema", - "Ant Design" - ], - "homepage": "https://x-render.gitee.io/table-render", - "license": "MIT", - "bugs": { - "url": "https://github.com/alibaba/x-render/issues" + "peerDependencies": { + "antd": "4.x", + "react": ">=16.8.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/packages/table-render/src/components/ErrorBoundary/index.tsx b/packages/table-render/src/components/ErrorBoundary/index.tsx index 1c6a430fb..6ed83bb7c 100644 --- a/packages/table-render/src/components/ErrorBoundary/index.tsx +++ b/packages/table-render/src/components/ErrorBoundary/index.tsx @@ -1,6 +1,5 @@ -import { ErrorInfo } from 'react'; -import React from 'react'; import { Result } from 'antd'; +import React, { ErrorInfo } from 'react'; class ErrorBoundary extends React.Component< {}, diff --git a/packages/table-render/src/components/Search.tsx b/packages/table-render/src/components/Search.tsx index 6f465b045..cbeee39a4 100644 --- a/packages/table-render/src/components/Search.tsx +++ b/packages/table-render/src/components/Search.tsx @@ -1,8 +1,8 @@ -import React, { useEffect, useRef, useState } from 'react'; -import { useTable } from './hooks'; import { Button } from 'antd'; import SearchForm from 'form-render'; +import React, { useEffect, useRef, useState } from 'react'; import { SearchProps } from '../interface'; +import { useTable } from './hooks'; const SearchBtn = ({ clearSearch, diff --git a/packages/table-render/src/components/Table.tsx b/packages/table-render/src/components/Table.tsx index b2ac0f4ed..1aa861537 100644 --- a/packages/table-render/src/components/Table.tsx +++ b/packages/table-render/src/components/Table.tsx @@ -1,11 +1,11 @@ +import { Radio, Space, Table, TableProps } from 'antd'; import React, { useEffect, useRef } from 'react'; -import { Table, Radio, Space, TableProps } from 'antd'; +import { TableRenderProps } from '../interface'; import { getDate, getDateTime, getMoneyType } from '../utils'; import ErrorBoundary from './ErrorBoundary'; -import ToolBarAction from './ToolBarAction'; -import { TableRenderProps } from '../interface'; import { renderDom } from './field'; import { useTable } from './hooks'; +import ToolBarAction from './ToolBarAction'; const ProTable: ( props: TableRenderProps diff --git a/packages/table-render/src/components/ToolBarAction/ColumnSetting.tsx b/packages/table-render/src/components/ToolBarAction/ColumnSetting.tsx index 1d1d551bd..025512696 100644 --- a/packages/table-render/src/components/ToolBarAction/ColumnSetting.tsx +++ b/packages/table-render/src/components/ToolBarAction/ColumnSetting.tsx @@ -1,11 +1,6 @@ +import { SettingOutlined } from '@ant-design/icons'; +import { Popover, Tooltip } from 'antd'; import React from 'react'; -import { Checkbox, Tree, Popover, ConfigProvider, Tooltip } from 'antd'; -import { - SettingOutlined, - VerticalAlignMiddleOutlined, - VerticalAlignTopOutlined, - VerticalAlignBottomOutlined, -} from '@ant-design/icons'; const ColumnSetting = props => { return ( diff --git a/packages/table-render/src/components/ToolBarAction/DensityIcon.tsx b/packages/table-render/src/components/ToolBarAction/DensityIcon.tsx index b87d0ff0d..5cda65619 100644 --- a/packages/table-render/src/components/ToolBarAction/DensityIcon.tsx +++ b/packages/table-render/src/components/ToolBarAction/DensityIcon.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import { ColumnHeightOutlined } from '@ant-design/icons'; -import { Menu, Dropdown, Tooltip } from 'antd'; +import { Dropdown, Menu, Tooltip } from 'antd'; +import React from 'react'; import { useTable } from '../hooks'; export type DensitySize = 'middle' | 'small' | 'default' | undefined; diff --git a/packages/table-render/src/components/ToolBarAction/FullScreenIcon.tsx b/packages/table-render/src/components/ToolBarAction/FullScreenIcon.tsx index a1729ca48..feec2d0f8 100644 --- a/packages/table-render/src/components/ToolBarAction/FullScreenIcon.tsx +++ b/packages/table-render/src/components/ToolBarAction/FullScreenIcon.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useState } from 'react'; import { FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons'; import { message, Tooltip } from 'antd'; +import React, { useState } from 'react'; const FullScreenIcon = props => { const [isFullScreen, setFullScreen] = useState(false); diff --git a/packages/table-render/src/components/ToolBarAction/ReloadIcon.tsx b/packages/table-render/src/components/ToolBarAction/ReloadIcon.tsx index a65964683..2c008a3b8 100644 --- a/packages/table-render/src/components/ToolBarAction/ReloadIcon.tsx +++ b/packages/table-render/src/components/ToolBarAction/ReloadIcon.tsx @@ -1,7 +1,7 @@ +import { ReloadOutlined } from '@ant-design/icons'; +import { Tooltip } from 'antd'; import React from 'react'; import { useTable } from '../hooks'; -import { Tooltip } from 'antd'; -import { ReloadOutlined } from '@ant-design/icons'; const ReloadIcon = () => { const { refresh }: any = useTable(); diff --git a/packages/table-render/src/components/ToolBarAction/index.tsx b/packages/table-render/src/components/ToolBarAction/index.tsx index d64b1f3ce..ee3d24e72 100644 --- a/packages/table-render/src/components/ToolBarAction/index.tsx +++ b/packages/table-render/src/components/ToolBarAction/index.tsx @@ -1,9 +1,8 @@ -import React from 'react'; import { Space } from 'antd'; -import FullScreenIcon from './FullScreenIcon'; +import React from 'react'; import DensityIcon from './DensityIcon'; +import FullScreenIcon from './FullScreenIcon'; import ReloadIcon from './ReloadIcon'; -import SettingIcon from './ColumnSetting'; const ToolBar = props => { return ( diff --git a/packages/table-render/src/components/field.tsx b/packages/table-render/src/components/field.tsx index 220701cd3..a5b862579 100644 --- a/packages/table-render/src/components/field.tsx +++ b/packages/table-render/src/components/field.tsx @@ -1,5 +1,5 @@ -import React from 'react'; import { message, Tooltip, Typography } from 'antd'; +import React from 'react'; export const renderEllipsis = ( dom: {} | null | undefined, diff --git a/packages/table-render/src/components/hooks.ts b/packages/table-render/src/components/hooks.ts index adb96674f..834dfe412 100644 --- a/packages/table-render/src/components/hooks.ts +++ b/packages/table-render/src/components/hooks.ts @@ -1,11 +1,11 @@ -import { useReducer, useContext } from 'react'; -import { Ctx, StoreCtx } from './Context'; +import { useContext, useReducer } from 'react'; import { TableContext } from '../interface'; +import { Ctx, StoreCtx } from './Context'; // 使用最顶层组件的 setState -export const useTable: () => TableContext< - RecordType -> = () => { +export const useTable: < + RecordType extends object = any +>() => TableContext = () => { return useContext(Ctx); }; diff --git a/packages/table-render/src/components/index.tsx b/packages/table-render/src/components/index.tsx index ca1d2b0e6..5ba402153 100644 --- a/packages/table-render/src/components/index.tsx +++ b/packages/table-render/src/components/index.tsx @@ -1,13 +1,11 @@ -import React, { useRef, forwardRef, useImperativeHandle } from 'react'; -import { useSet, useTable } from './hooks'; -import { Ctx } from './Context'; -import Search from './Search'; -import Table from './Table'; -import { message, ConfigProvider } from 'antd'; -import _get from 'lodash.get'; +import { ConfigProvider, message } from 'antd'; import zh_CN from 'antd/lib/locale/zh_CN'; import { useForm } from 'form-render'; +import _get from 'lodash.get'; +import React, { forwardRef, useImperativeHandle, useRef } from 'react'; import { SearchApi } from '../interface'; +import { Ctx } from './Context'; +import { useSet } from './hooks'; import './index.css'; const useTableRoot = props => { diff --git a/packages/table-render/src/components/widgets.tsx b/packages/table-render/src/components/widgets.tsx index 7552a7b0f..dfb8d44ad 100644 --- a/packages/table-render/src/components/widgets.tsx +++ b/packages/table-render/src/components/widgets.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import { Tag, Tooltip } from 'antd'; -import { getDateTime, getDate } from '../utils'; +import React from 'react'; +import { getDate, getDateTime } from '../utils'; const PrompText = ({ text = '', prompText = '' }) => ( diff --git a/packages/table-render/src/index.ts b/packages/table-render/src/index.ts index f9e502264..67259fb6e 100644 --- a/packages/table-render/src/index.ts +++ b/packages/table-render/src/index.ts @@ -1,5 +1,4 @@ +export { TableProvider, withTable } from './components'; +export { useTable } from './components/hooks'; export { default as Search } from './components/Search'; export { default as Table } from './components/Table'; - -export { useTable } from './components/hooks'; -export { withTable, TableProvider } from './components'; diff --git a/scripts/prettier-plugin/index.js b/scripts/prettier-plugin/index.js new file mode 100644 index 000000000..b7ae5bd4b --- /dev/null +++ b/scripts/prettier-plugin/index.js @@ -0,0 +1,75 @@ +const { parsers } = require('prettier-plugin-organize-imports'); + +function createParser(original, transform) { + return { + ...original, + parse: (text, parsers, options) => { + const ast = original.parse(text, parsers, options); + transform(ast, { ...options, text }); + return ast; + } + } +} + +// https://lihautan.com/manipulating-ast-with-javascript/ +function visit(ast, callbackMap) { + function _visit(node, parent, key, index) { + if (typeof callbackMap === 'function') { + if (callbackMap(node, parent, key, index) === false) { + return + } + } else if (node.type in callbackMap) { + if (callbackMap[node.type](node, parent, key, index) === false) { + return + } + } + + const keys = Object.keys(node) + for (let i = 0; i < keys.length; i++) { + const child = node[keys[i]] + if (Array.isArray(child)) { + for (let j = 0; j < child.length; j++) { + if (child[j] !== null) { + _visit(child[j], node, keys[i], j) + } + } + } else if (typeof child?.type === 'string') { + _visit(child, node, keys[i], i) + } + } + } + _visit(ast) +} + +function transformJavaScript(ast, options) { + if (!options.text.includes('// sort-object-keys')) return; + visit(ast, { + ObjectExpression(node) { + const { properties } = node; + properties.sort((a, b) => { + const { key: aKey } = a; + const { key: bKey } = b; + if (aKey.type === 'Identifier' && bKey.type === 'Identifier') { + return aKey.name.localeCompare(bKey.name); + } + return 0; + }); + }, + TSTypeLiteral(node) { + const { members } = node; + members.sort((a, b) => { + const { key: aKey } = a; + const { key: bKey } = b; + if (aKey.type === 'Identifier' && bKey.type === 'Identifier') { + return aKey.name.localeCompare(bKey.name); + } + return 0; + }); + } + }) +} + +exports.parsers = { + ...parsers, + typescript: createParser(parsers.typescript, transformJavaScript), +}; diff --git a/tools/form-render-excel/package.json b/tools/form-render-excel/package.json index 50c639473..3e0351381 100644 --- a/tools/form-render-excel/package.json +++ b/tools/form-render-excel/package.json @@ -1,18 +1,6 @@ { "name": "form-render-excel", "version": "1.0.1", - "scripts": { - "start": "dumi dev", - "docs:build": "dumi build", - "docs:deploy": "gh-pages -d docs-dist", - "build": "father-build", - "deploy": "npm run docs:build && npm run docs:deploy", - "release": "npm run build && npm publish", - "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", - "test": "umi-test", - "test:coverage": "umi-test --coverage" - }, - "group": "form-render", "repository": { "type": "git", "url": "git@github.com:form-render/form-render-excel.git" @@ -23,8 +11,16 @@ }, "main": "dist/index.js", "module": "dist/index.esm.js", - "gitHooks": { - "pre-commit": "lint-staged" + "scripts": { + "build": "father-build", + "deploy": "npm run docs:build && npm run docs:deploy", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d docs-dist", + "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "release": "npm run build && npm publish", + "start": "dumi dev", + "test": "umi-test", + "test:coverage": "umi-test --coverage" }, "lint-staged": { "*.{js,jsx,less,md,json}": [ @@ -38,10 +34,6 @@ "lodash-es": "^4.17.21", "xlsx": ">=0.17.0" }, - "peerDependencies": { - "antd": "^4.x", - "react": ">=16.8.0" - }, "devDependencies": { "@umijs/test": "^3.0.5", "antd": "^4.8.6", @@ -53,5 +45,13 @@ "prettier": "^1.19.1", "react": "^17.0.1", "yorkie": "^2.0.0" - } + }, + "peerDependencies": { + "antd": "^4.x", + "react": ">=16.8.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" + }, + "group": "form-render" } diff --git a/tools/form-render-excel/src/index.js b/tools/form-render-excel/src/index.js index 723770385..9336108e6 100644 --- a/tools/form-render-excel/src/index.js +++ b/tools/form-render-excel/src/index.js @@ -1,11 +1,11 @@ -import React from 'react'; import { get, set } from 'lodash-es'; +import React from 'react'; import clearAll from './method/clearAll'; -import importExcel from './method/importExcel'; import exportExcel from './method/exportExcel'; +import importExcel from './method/importExcel'; // 给 schema 中的 array 加按钮 -const addButton = schema => { +const addButton = (schema) => { const type = get(schema, 'type'); const itemsType = get(schema, 'items.type'); const useExcel = get(schema, 'ui:options.useExcel'); @@ -21,18 +21,19 @@ const addButton = schema => { const properties = get(schema, 'properties') || get(schema, 'items.properties'); if (properties) { - Object.values(properties).forEach(nextSchema => addButton(nextSchema)); + Object.values(properties).forEach((nextSchema) => addButton(nextSchema)); } return schema; }; -export default FR => ({ schema, ...rest }) => { - // eslint-disable-next-line - window['_fre_clear'] = clearAll; - // eslint-disable-next-line - window['_fre_import'] = importExcel; - // eslint-disable-next-line - window['_fre_export'] = exportExcel; +export default (FR) => + ({ schema, ...rest }) => { + // eslint-disable-next-line + window['_fre_clear'] = clearAll; + // eslint-disable-next-line + window['_fre_import'] = importExcel; + // eslint-disable-next-line + window['_fre_export'] = exportExcel; - return ; -}; + return ; + }; diff --git a/tools/form-render-excel/src/method/exportExcel.js b/tools/form-render-excel/src/method/exportExcel.js index 939ad0cde..ca34280ba 100644 --- a/tools/form-render-excel/src/method/exportExcel.js +++ b/tools/form-render-excel/src/method/exportExcel.js @@ -1,6 +1,6 @@ import { get } from 'lodash-es'; import XLSX from 'xlsx'; -import { generateSheetHeader, generateSheetData } from '../utils'; +import { generateSheetData, generateSheetHeader } from '../utils'; export default (arrayData, onChange, schema) => { const itemsProperties = get(schema, 'items.properties', {}); diff --git a/tools/form-render-excel/src/method/importExcel.js b/tools/form-render-excel/src/method/importExcel.js index f49a380ed..5d624c2a7 100644 --- a/tools/form-render-excel/src/method/importExcel.js +++ b/tools/form-render-excel/src/method/importExcel.js @@ -1,7 +1,7 @@ -import React from 'react'; -import { Modal, Input } from 'antd'; -import { flatProperties, toBoolean, enumNamesToEnum } from '../utils'; +import { Input, Modal } from 'antd'; import { get, set } from 'lodash-es'; +import React from 'react'; +import { enumNamesToEnum, flatProperties, toBoolean } from '../utils'; export default (arrayData, onChange, schema) => { let excelText = ''; @@ -32,7 +32,7 @@ export default (arrayData, onChange, schema) => { content: ( { + onChange={(event) => { excelText = event.target.value || ''; }} /> @@ -40,30 +40,30 @@ export default (arrayData, onChange, schema) => { okText: '确定', cancelText: '取消', onOk() { - const sheetData = excelText.split('\n').map(line => line.split('\t')); + const sheetData = excelText.split('\n').map((line) => line.split('\t')); const itemsProperties = get(schema, 'items.properties', {}); const flatProp = flatProperties(itemsProperties, true); Object.keys(flatProp).forEach((keyPath, index) => { const prop = flatProp[keyPath]; if (prop.type.toLowerCase() === 'number') { // 数字类型的,从字符串转成数字 - sheetData.forEach(lineArr => { + sheetData.forEach((lineArr) => { lineArr[index] = Number(lineArr[index]) || lineArr[index]; }); } else if (prop.type.toLowerCase() === 'boolean') { // 布尔类型的,从字符串转成布尔 - sheetData.forEach(lineArr => { + sheetData.forEach((lineArr) => { lineArr[index] = toBoolean(lineArr[index]); }); } else if (prop.type.toLowerCase() === 'range') { // range类型的,从字符串转成数组 - sheetData.forEach(lineArr => { + sheetData.forEach((lineArr) => { lineArr[index] = String(lineArr[index]).split('_'); }); } else if (prop.enum) { // 有 enum 的,可能是单选可能是多选 if (prop.type.toLowerCase() === 'array') { - sheetData.forEach(lineArr => { + sheetData.forEach((lineArr) => { lineArr[index] = enumNamesToEnum( String(lineArr[index]).split('_'), prop.enum, @@ -71,7 +71,7 @@ export default (arrayData, onChange, schema) => { ); }); } else { - sheetData.forEach(lineArr => { + sheetData.forEach((lineArr) => { lineArr[index] = enumNamesToEnum( lineArr[index], prop.enum, @@ -81,12 +81,12 @@ export default (arrayData, onChange, schema) => { } } else if (prop.type.toLowerCase() === 'array') { // 复杂数组类型,直接清空 - sheetData.forEach(lineArr => { + sheetData.forEach((lineArr) => { lineArr[index] = []; }); } }); - const formData = sheetData.map(lineArr => { + const formData = sheetData.map((lineArr) => { const retObj = {}; Object.keys(flatProp).forEach((keyPath, index) => { set(retObj, keyPath, lineArr[index]); diff --git a/tools/form-render-excel/src/utils.js b/tools/form-render-excel/src/utils.js index 630d1ff8c..de1674503 100644 --- a/tools/form-render-excel/src/utils.js +++ b/tools/form-render-excel/src/utils.js @@ -6,7 +6,7 @@ export function flatProperties(properties, ignoreObject = false, preKey = '') { return {}; } let obj = {}; - Object.keys(properties).forEach(key => { + Object.keys(properties).forEach((key) => { obj[preKey ? `${preKey}[${key}]` : `[${key}]`] = properties[key]; if (get(properties[key], 'type', '').toLocaleLowerCase() === 'object') { if (ignoreObject) { @@ -34,16 +34,16 @@ export function enumToEnumNames(data, enums, enumNames = enums) { // 原有的 data 值是 ['apple', 'pear'] 这种,换成 苹果_梨子 retData = data .map( - item => - enumNames[enums.findIndex(i => String(i) === String(item))] || - enumNames.findIndex(i => String(i) === String(item)), + (item) => + enumNames[enums.findIndex((i) => String(i) === String(item))] || + enumNames.findIndex((i) => String(i) === String(item)), ) .join('_'); } else { // 原有的 data 值是 'pear' 这种,换成 梨子 retData = - enumNames[enums.findIndex(i => String(i) === String(data))] || - enumNames.findIndex(i => String(i) === String(data)); + enumNames[enums.findIndex((i) => String(i) === String(data))] || + enumNames.findIndex((i) => String(i) === String(data)); } return retData || data; } @@ -53,21 +53,21 @@ export function enumNamesToEnum(data, enums, enumNames = enums) { let retData = null; if (Array.isArray(data)) { retData = data.map( - item => - enums[enumNames.findIndex(i => String(i) === String(item))] || - enums.find(i => String(i) === String(item)), + (item) => + enums[enumNames.findIndex((i) => String(i) === String(item))] || + enums.find((i) => String(i) === String(item)), ); } else { retData = - enums[enumNames.findIndex(i => String(i) === String(data))] || - enums.find(i => String(i) === String(data)); + enums[enumNames.findIndex((i) => String(i) === String(data))] || + enums.find((i) => String(i) === String(data)); } return retData || data; } export function generateSheetHeader(properties) { const flatProp = flatProperties(properties, true); - return Object.keys(flatProp).map(key => { + return Object.keys(flatProp).map((key) => { const iProp = get(properties, key.replaceAll('][', '][properties]['), {}); return iProp.type === 'array' && iProp?.items?.type === 'object' ? `【此列勿填】${iProp.title || key}` @@ -77,7 +77,7 @@ export function generateSheetHeader(properties) { export function generateSheetData(properties, arrayData) { function flatObject(obj) { - return Object.values(obj).map(objVal => + return Object.values(obj).map((objVal) => isObject(objVal) ? flatObject(objVal) : objVal, ); } @@ -90,18 +90,18 @@ export function generateSheetData(properties, arrayData) { Object.values(flatProp).forEach((prop, index) => { if (prop.type === 'range') { // 区间类型 - arrayDataFlat.forEach(arr => { + arrayDataFlat.forEach((arr) => { // 原有的 arr[index] 值是 ['2020-01-01', '2020-01-02'] 这种 arr[index] = Array.isArray(arr[index]) ? arr[index].join('_') : ''; }); } else if (prop.enum) { // 带enum的类型 - arrayDataFlat.forEach(arr => { + arrayDataFlat.forEach((arr) => { arr[index] = enumToEnumNames(arr[index], prop.enum, prop.enumNames); }); } else if (prop.type === 'array') { // 数组类型 - arrayDataFlat.forEach(arr => { + arrayDataFlat.forEach((arr) => { // 原有的 arr[index] 值是 [{...}, {...}, {...}] 这种 // 复杂数组直接不导出了 arr[index] = ''; diff --git a/tools/form-render-snippets/package.json b/tools/form-render-snippets/package.json index dcecec15e..67fd5a3dd 100644 --- a/tools/form-render-snippets/package.json +++ b/tools/form-render-snippets/package.json @@ -1,24 +1,20 @@ { "name": "form-render-snippets", "displayName": "FormRender snippets", - "description": "quick way to write form-render schema", "version": "1.1.1", - "icon": "fr-icon.png", + "description": "quick way to write form-render schema", + "categories": [ + "Snippets" + ], "repository": { "type": "git", "url": "https://github.com/FateRiddle/form-render-snippets" }, + "publisher": "fateriddle", "scripts": { "login": "vsce login fateriddle", "release": "vsce publish" }, - "publisher": "fateriddle", - "engines": { - "vscode": "^1.41.0" - }, - "categories": [ - "Snippets" - ], "contributes": { "snippets": [ { @@ -34,5 +30,9 @@ "path": "./snippets/snippets.json" } ] - } + }, + "engines": { + "vscode": "^1.41.0" + }, + "icon": "fr-icon.png" } diff --git a/tools/form-render_v0.x/package.json b/tools/form-render_v0.x/package.json index f6963943a..cb17d2a7c 100644 --- a/tools/form-render_v0.x/package.json +++ b/tools/form-render_v0.x/package.json @@ -2,10 +2,6 @@ "name": "form-render", "version": "0.10.5", "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成", - "repository": { - "type": "git", - "url": "git@github.com:alibaba/form-render.git" - }, "keywords": [ "FormRender", "Render", @@ -14,6 +10,10 @@ "Ant Design", "Fusion Design" ], + "repository": { + "type": "git", + "url": "git@github.com:alibaba/form-render.git" + }, "contributors": [ { "name": "Tw93", @@ -28,20 +28,17 @@ "email": "fateriddle@gmail.com" } ], + "main": "lib/index.js", + "module": "dist/index.esm.js", "scripts": { + "beta": "npm publish --tag beta", "build": "father-build", "prepare": "npm run build", - "postpublish": "git push --tags", - "beta": "npm publish --tag beta", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "lib/index.js", - "module": "dist/index.esm.js", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -60,14 +57,17 @@ "react-sortable-hoc": "^1.6.1", "validator": "^10.7.1" }, + "devDependencies": { + "deep-equal": "^2.0.3", + "rollup-plugin-commonjs": "^10.1.0" + }, "peerDependencies": { "@alifd/next": "^1.x", "antd": "^4.x", "react": ">=16.8.0", "react-dom": ">=16.8.0" }, - "devDependencies": { - "deep-equal": "^2.0.3", - "rollup-plugin-commonjs": "^10.1.0" + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/tools/form-render_v0.x/src/antd.js b/tools/form-render_v0.x/src/antd.js index ef679b0ee..d6ab54b1e 100644 --- a/tools/form-render_v0.x/src/antd.js +++ b/tools/form-render_v0.x/src/antd.js @@ -3,15 +3,15 @@ * antd 主题入口文件 */ -import React, { forwardRef } from 'react'; -import FormRender from './index'; import { ConfigProvider } from 'antd'; +import 'antd/dist/antd.less'; import zhCN from 'antd/lib/locale/zh_CN'; +import React, { forwardRef } from 'react'; +import FormRender from './index'; import { mapping as defaultMapping, widgets as defaultWidgets, } from './widgets/antd'; -import 'antd/dist/antd.less'; const AntdForm = ( { mapping = {}, widgets = {}, configProvider = {}, ...rest }, diff --git a/tools/form-render_v0.x/src/atom.less b/tools/form-render_v0.x/src/atom.less index d915cee35..f2ce612fb 100644 --- a/tools/form-render_v0.x/src/atom.less +++ b/tools/form-render_v0.x/src/atom.less @@ -1085,7 +1085,7 @@ } .debug-grid { background: transparent - url( data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVR4AWPAC97/9x0eCsAEPgwAVLshdpENIxcAAAAASUVORK5CYII= ) + url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVR4AWPAC97/9x0eCsAEPgwAVLshdpENIxcAAAAASUVORK5CYII=) repeat top left; } diff --git a/tools/form-render_v0.x/src/base/asField.jsx b/tools/form-render_v0.x/src/base/asField.jsx index 810ab12c8..1fbd622b7 100644 --- a/tools/form-render_v0.x/src/base/asField.jsx +++ b/tools/form-render_v0.x/src/base/asField.jsx @@ -1,16 +1,16 @@ -import React, { useRef, useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { getValidateText } from './validate'; +import React, { useEffect, useRef, useState } from 'react'; +import FoldIcon from '../components/foldIcon'; import { usePrevious } from '../hooks'; -import { isHidden, isDependShow } from './isHidden'; +import { isDependShow, isHidden } from './isHidden'; import { - isLooselyNumber, - isCssLength, convertValue, - isDeepEqual, getEnum, + isCssLength, + isDeepEqual, + isLooselyNumber, } from './utils'; -import FoldIcon from '../components/foldIcon'; +import { getValidateText } from './validate'; // asField拆分成逻辑组件和展示组件,从而可替换展示组件的方式完全插拔fr的样式 export const asField = ({ FieldUI, Widget }) => { diff --git a/tools/form-render_v0.x/src/base/isHidden.js b/tools/form-render_v0.x/src/base/isHidden.js index 89c1503b7..b442dbaaf 100644 --- a/tools/form-render_v0.x/src/base/isHidden.js +++ b/tools/form-render_v0.x/src/base/isHidden.js @@ -4,7 +4,7 @@ */ import { pope } from 'pope'; -import { parseString, baseGet } from './utils'; +import { baseGet, parseString } from './utils'; export function isDependShow({ formData, dependShow } = {}) { if (formData && dependShow) { diff --git a/tools/form-render_v0.x/src/base/subFieldGenerator.jsx b/tools/form-render_v0.x/src/base/subFieldGenerator.jsx index c88474d3d..47ab7fd3b 100644 --- a/tools/form-render_v0.x/src/base/subFieldGenerator.jsx +++ b/tools/form-render_v0.x/src/base/subFieldGenerator.jsx @@ -1,16 +1,14 @@ import React from 'react'; -const subFieldGenerator = ({ - fieldCanRedefine: can, - Field: SourceField = null, - props = {}, -}) => args => { - const { name, Field: RedefineField = null, ...others } = args; - const Field = (can && RedefineField) || SourceField; - if (Field) { - return ; - } - return null; -}; +const subFieldGenerator = + ({ fieldCanRedefine: can, Field: SourceField = null, props = {} }) => + args => { + const { name, Field: RedefineField = null, ...others } = args; + const Field = (can && RedefineField) || SourceField; + if (Field) { + return ; + } + return null; + }; export default subFieldGenerator; diff --git a/tools/form-render_v0.x/src/base/useDebounce.js b/tools/form-render_v0.x/src/base/useDebounce.js index d71c32dbb..a002858ef 100644 --- a/tools/form-render_v0.x/src/base/useDebounce.js +++ b/tools/form-render_v0.x/src/base/useDebounce.js @@ -1,4 +1,4 @@ -import { useRef, useEffect, useMemo } from 'react'; +import { useEffect, useMemo, useRef } from 'react'; function useDebouncedCallback(func, wait, options) { const lastCallTime = useRef(null); @@ -147,7 +147,11 @@ function useDebouncedCallback(func, wait, options) { : clearTimeout(timerId.current); } lastInvokeTime.current = 0; - lastArgs.current = lastCallTime.current = lastThis.current = timerId.current = null; + lastArgs.current = + lastCallTime.current = + lastThis.current = + timerId.current = + null; }; func.isPending = () => { diff --git a/tools/form-render_v0.x/src/base/validate.js b/tools/form-render_v0.x/src/base/validate.js index 00907aa54..08a33a7f6 100644 --- a/tools/form-render_v0.x/src/base/validate.js +++ b/tools/form-render_v0.x/src/base/validate.js @@ -3,16 +3,16 @@ * 校验表单格式 */ -import isLength from 'validator/lib/isLength'; import Color from 'color'; +import isLength from 'validator/lib/isLength'; import { isHidden } from './isHidden'; import { - hasRepeat, - isFunction, baseGet, convertValue, convertValue2, + hasRepeat, isEmail, + isFunction, isUrl, } from './utils'; diff --git a/tools/form-render_v0.x/src/components/dateHoc.jsx b/tools/form-render_v0.x/src/components/dateHoc.jsx index 63d024fe4..c005cbc16 100644 --- a/tools/form-render_v0.x/src/components/dateHoc.jsx +++ b/tools/form-render_v0.x/src/components/dateHoc.jsx @@ -3,8 +3,8 @@ * 抽离高阶日期组件 */ -import React from 'react'; import moment from 'moment'; +import React from 'react'; import { getFormat } from '../base/utils'; export default (p, onChange, DateComponent) => { diff --git a/tools/form-render_v0.x/src/components/listHoc.jsx b/tools/form-render_v0.x/src/components/listHoc.jsx index 4a21f66a0..4bc3abbd5 100644 --- a/tools/form-render_v0.x/src/components/listHoc.jsx +++ b/tools/form-render_v0.x/src/components/listHoc.jsx @@ -3,17 +3,17 @@ * 抽离高阶列表组件 */ -import React from 'react'; import PropTypes from 'prop-types'; +import React from 'react'; import { + arrayMove, SortableContainer, - SortableHandle, SortableElement, - arrayMove, + SortableHandle, } from 'react-sortable-hoc'; -import { isFunction, evaluateString, isObj, isNumber } from '../base/utils'; -import FoldIcon from './foldIcon'; +import { evaluateString, isFunction, isNumber, isObj } from '../base/utils'; import DescriptionList, { getDescription } from './descList'; +import FoldIcon from './foldIcon'; const DragHandle = SortableHandle(() => (
:::
diff --git a/tools/form-render_v0.x/src/components/rangeHoc.jsx b/tools/form-render_v0.x/src/components/rangeHoc.jsx index 0dff45626..fe7abf0f4 100644 --- a/tools/form-render_v0.x/src/components/rangeHoc.jsx +++ b/tools/form-render_v0.x/src/components/rangeHoc.jsx @@ -3,8 +3,8 @@ * 抽离高阶日期组件 */ -import React from 'react'; import moment from 'moment'; +import React from 'react'; import { getFormat } from '../base/utils'; export default ({ diff --git a/tools/form-render_v0.x/src/hooks.js b/tools/form-render_v0.x/src/hooks.js index e97d44d09..6873c36ab 100644 --- a/tools/form-render_v0.x/src/hooks.js +++ b/tools/form-render_v0.x/src/hooks.js @@ -1,4 +1,4 @@ -import { useRef, useEffect, useReducer } from 'react'; +import { useEffect, useReducer, useRef } from 'react'; export function usePrevious(value) { const ref = useRef(); diff --git a/tools/form-render_v0.x/src/index.js b/tools/form-render_v0.x/src/index.js index 8acf41bfc..c0f6ce554 100755 --- a/tools/form-render_v0.x/src/index.js +++ b/tools/form-render_v0.x/src/index.js @@ -1,19 +1,19 @@ +import PropTypes from 'prop-types'; import React, { - useRef, useEffect, - useMemo, useImperativeHandle, + useMemo, + useRef, useState, } from 'react'; -import useDebouncedCallback from './base/useDebounce'; -import PropTypes from 'prop-types'; -import { combineSchema } from './base/utils'; +import './atom.less'; import { asField, DefaultFieldUI } from './base/asField'; import parse from './base/parser'; import resolve from './base/resolve'; +import useDebouncedCallback from './base/useDebounce'; +import { combineSchema } from './base/utils'; import { getValidateList } from './base/validate'; import fetcher from './HOC/fetcher'; -import './atom.less'; import './index.less'; function RenderField({ fields, onChange, ...settings }) { @@ -85,10 +85,10 @@ function FormRender({ const [isEditing, setEditing] = useState(false); const debouncedSetEditing = useDebouncedCallback(setEditing, 300); - const data = useMemo(() => resolve(schema, formData), [ - JSON.stringify(schema), - JSON.stringify(formData), - ]); + const data = useMemo( + () => resolve(schema, formData), + [JSON.stringify(schema), JSON.stringify(formData)] + ); useEffect(() => { onChange(data); diff --git a/tools/form-render_v0.x/src/widgets/antd/checkbox.jsx b/tools/form-render_v0.x/src/widgets/antd/checkbox.jsx index 69552d3ab..c972715df 100644 --- a/tools/form-render_v0.x/src/widgets/antd/checkbox.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/checkbox.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Checkbox } from 'antd'; +import React from 'react'; export default function radio(p) { return ( diff --git a/tools/form-render_v0.x/src/widgets/antd/checkboxes.jsx b/tools/form-render_v0.x/src/widgets/antd/checkboxes.jsx index bb38f539e..6e9d1ef61 100644 --- a/tools/form-render_v0.x/src/widgets/antd/checkboxes.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/checkboxes.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Checkbox } from 'antd'; +import React from 'react'; import { getArray } from '../../base/utils'; export default function checkboxes(p) { diff --git a/tools/form-render_v0.x/src/widgets/antd/color.jsx b/tools/form-render_v0.x/src/widgets/antd/color.jsx index 5025d8d55..5678f0337 100644 --- a/tools/form-render_v0.x/src/widgets/antd/color.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/color.jsx @@ -1,8 +1,8 @@ -import React from 'react'; -import ColorPicker from 'rc-color-picker'; -import Color from 'color'; import { Input } from 'antd'; +import Color from 'color'; +import ColorPicker from 'rc-color-picker'; import 'rc-color-picker/assets/index.css'; +import React from 'react'; export default function color(p) { const { format } = p.schema; diff --git a/tools/form-render_v0.x/src/widgets/antd/date.jsx b/tools/form-render_v0.x/src/widgets/antd/date.jsx index d6db9a6a9..f1947ba1e 100644 --- a/tools/form-render_v0.x/src/widgets/antd/date.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/date.jsx @@ -3,9 +3,9 @@ * 日期组件 */ -import React, { useState } from 'react'; import { DatePicker, TimePicker } from 'antd'; import moment from 'moment'; +import React from 'react'; import { getFormat } from '../../base/utils'; export default ({ diff --git a/tools/form-render_v0.x/src/widgets/antd/index.jsx b/tools/form-render_v0.x/src/widgets/antd/index.jsx index 888e3581c..172cdaad7 100644 --- a/tools/form-render_v0.x/src/widgets/antd/index.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/index.jsx @@ -3,6 +3,7 @@ import checkboxes from './checkboxes'; import color from './color'; import date from './date'; import dateRange from './dateRange'; +import html from './html'; import input from './input'; import list from './list'; import map from './map'; @@ -14,7 +15,6 @@ import slider from './slider'; import switch1 from './switch'; import textarea from './textarea'; import upload from './upload'; -import html from './html'; import url from './url'; export const widgets = { diff --git a/tools/form-render_v0.x/src/widgets/antd/input.jsx b/tools/form-render_v0.x/src/widgets/antd/input.jsx index 28b0dc658..a91966144 100644 --- a/tools/form-render_v0.x/src/widgets/antd/input.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/input.jsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react'; import { PictureOutlined } from '@ant-design/icons'; import { Input, Popover } from 'antd'; +import React, { useState } from 'react'; import useDebouncedCallback from '../../base/useDebounce'; import previewContent from '../../components/previewContent'; diff --git a/tools/form-render_v0.x/src/widgets/antd/list.jsx b/tools/form-render_v0.x/src/widgets/antd/list.jsx index c434fdbf0..e4121419d 100644 --- a/tools/form-render_v0.x/src/widgets/antd/list.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/list.jsx @@ -3,15 +3,11 @@ * 数组组件 */ +import { DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons'; +import { Button, Drawer, Modal, Pagination } from 'antd'; import React, { useState } from 'react'; -import listHoc from '../../components/listHoc'; -import { - PlusCircleOutlined, - DeleteOutlined, - CopyOutlined, -} from '@ant-design/icons'; import { isObj } from '../../base/utils'; -import { Button, Modal, Drawer, Pagination } from 'antd'; +import listHoc from '../../components/listHoc'; const isComponent = comp => { const type = typeof comp; diff --git a/tools/form-render_v0.x/src/widgets/antd/map.jsx b/tools/form-render_v0.x/src/widgets/antd/map.jsx index 9f344127c..a45593dd0 100644 --- a/tools/form-render_v0.x/src/widgets/antd/map.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/map.jsx @@ -1,5 +1,5 @@ +import { Drawer, Modal } from 'antd'; import React, { useState } from 'react'; -import { Modal, Drawer } from 'antd'; import { isObj } from '../../base/utils'; import Map from '../../components/map'; diff --git a/tools/form-render_v0.x/src/widgets/antd/radio.jsx b/tools/form-render_v0.x/src/widgets/antd/radio.jsx index 42dd0c32b..55e4d8f2d 100644 --- a/tools/form-render_v0.x/src/widgets/antd/radio.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/radio.jsx @@ -2,8 +2,8 @@ * Updated by Tw93 on 2019-12-07. * 单选组件 */ -import React from 'react'; import { Radio } from 'antd'; +import React from 'react'; import RadioHoc from '../../components/radioHoc'; const RadioComponent = p => { diff --git a/tools/form-render_v0.x/src/widgets/antd/range.jsx b/tools/form-render_v0.x/src/widgets/antd/range.jsx index f5638cfd1..0fd287268 100644 --- a/tools/form-render_v0.x/src/widgets/antd/range.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/range.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Input } from 'antd'; +import React from 'react'; export default function range({ value, onChange, name, ...rest }) { return ( diff --git a/tools/form-render_v0.x/src/widgets/antd/switch.jsx b/tools/form-render_v0.x/src/widgets/antd/switch.jsx index 3874b192c..b3600fbb7 100644 --- a/tools/form-render_v0.x/src/widgets/antd/switch.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/switch.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Switch } from 'antd'; +import React from 'react'; export default function sw(p) { return ( diff --git a/tools/form-render_v0.x/src/widgets/antd/textarea.jsx b/tools/form-render_v0.x/src/widgets/antd/textarea.jsx index 6e009c27e..13ac51486 100644 --- a/tools/form-render_v0.x/src/widgets/antd/textarea.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/textarea.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Input } from 'antd'; +import React from 'react'; const { TextArea } = Input; diff --git a/tools/form-render_v0.x/src/widgets/antd/upload.jsx b/tools/form-render_v0.x/src/widgets/antd/upload.jsx index 1267d099e..f6485ee73 100644 --- a/tools/form-render_v0.x/src/widgets/antd/upload.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/upload.jsx @@ -1,6 +1,6 @@ -import React from 'react'; import { UploadOutlined } from '@ant-design/icons'; -import { Upload, message, Button } from 'antd'; +import { Button, message, Upload } from 'antd'; +import React from 'react'; export default function upload({ action, diff --git a/tools/form-render_v0.x/src/widgets/antd/url.jsx b/tools/form-render_v0.x/src/widgets/antd/url.jsx index 53fabec25..69dc92d93 100644 --- a/tools/form-render_v0.x/src/widgets/antd/url.jsx +++ b/tools/form-render_v0.x/src/widgets/antd/url.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Input } from 'antd'; +import React from 'react'; import { isUrl } from '../../base/utils'; const TestNode = ({ value }) => { diff --git a/tools/form-render_v0.x/src/widgets/fusion/checkbox.jsx b/tools/form-render_v0.x/src/widgets/fusion/checkbox.jsx index 03b21f2c0..701a41cf2 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/checkbox.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/checkbox.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Checkbox } from '@alifd/next'; +import React from 'react'; export default function radio(p) { return ( diff --git a/tools/form-render_v0.x/src/widgets/fusion/checkboxes.jsx b/tools/form-render_v0.x/src/widgets/fusion/checkboxes.jsx index 14b0a01aa..f9eeeaa4a 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/checkboxes.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/checkboxes.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Checkbox } from '@alifd/next'; +import React from 'react'; import { getArray } from '../../base/utils'; export default function checkboxes(p) { diff --git a/tools/form-render_v0.x/src/widgets/fusion/color.jsx b/tools/form-render_v0.x/src/widgets/fusion/color.jsx index 0e9a067de..dc3535b82 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/color.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/color.jsx @@ -1,8 +1,8 @@ -import React from 'react'; -import ColorPicker from 'rc-color-picker'; import { Input } from '@alifd/next'; -import 'rc-color-picker/assets/index.css'; import Color from 'color'; +import ColorPicker from 'rc-color-picker'; +import 'rc-color-picker/assets/index.css'; +import React from 'react'; export default function color(p) { const { format } = p.schema; diff --git a/tools/form-render_v0.x/src/widgets/fusion/date.jsx b/tools/form-render_v0.x/src/widgets/fusion/date.jsx index 4102dfc6e..4037efcac 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/date.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/date.jsx @@ -5,8 +5,8 @@ import { DatePicker, TimePicker } from '@alifd/next'; import moment from 'moment'; -import dateHoc from '../../components/dateHoc'; import { getFormatForFusion } from '../../base/utils'; +import dateHoc from '../../components/dateHoc'; const { MonthPicker, YearPicker, WeekPicker } = DatePicker; export default function date(p) { diff --git a/tools/form-render_v0.x/src/widgets/fusion/dateRange.jsx b/tools/form-render_v0.x/src/widgets/fusion/dateRange.jsx index 0c3bef3ec..398f3f643 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/dateRange.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/dateRange.jsx @@ -1,6 +1,6 @@ import { DatePicker } from '@alifd/next'; import moment from 'moment'; -import { getFormatForFusion, getFormat } from '../../base/utils'; +import { getFormat, getFormatForFusion } from '../../base/utils'; const { RangePicker } = DatePicker; export default function dateRange({ diff --git a/tools/form-render_v0.x/src/widgets/fusion/index.jsx b/tools/form-render_v0.x/src/widgets/fusion/index.jsx index 385650337..68a2d6577 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/index.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/index.jsx @@ -3,6 +3,7 @@ import checkboxes from './checkboxes'; import color from './color'; import date from './date'; import dateRange from './dateRange'; +import html from './html'; import input from './input'; import list from './list'; import map from './map'; @@ -14,7 +15,6 @@ import slider from './slider'; import switch1 from './switch'; import textarea from './textarea'; import upload from './upload'; -import html from './html'; export const widgets = { checkbox, diff --git a/tools/form-render_v0.x/src/widgets/fusion/input.jsx b/tools/form-render_v0.x/src/widgets/fusion/input.jsx index c557ba5c8..875daccb1 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/input.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/input.jsx @@ -1,5 +1,5 @@ +import { Balloon, Icon, Input } from '@alifd/next'; import React from 'react'; -import { Input, Icon, Balloon } from '@alifd/next'; import previewContent from '../../components/previewContent'; const previewNode = (format, value) => { diff --git a/tools/form-render_v0.x/src/widgets/fusion/list.jsx b/tools/form-render_v0.x/src/widgets/fusion/list.jsx index f118f87bb..9c9301c7a 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/list.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/list.jsx @@ -1,7 +1,7 @@ +import { Button, Dialog as Modal, Drawer, Icon, Pagination } from '@alifd/next'; import React, { useState } from 'react'; -import { Button, Icon, Dialog as Modal, Drawer, Pagination } from '@alifd/next'; -import listHoc from '../../components/listHoc'; import { isObj } from '../../base/utils'; +import listHoc from '../../components/listHoc'; const Pag = ({ showSizeChanger, onChange, ...rest }) => { const handleChange = val => onChange(val); diff --git a/tools/form-render_v0.x/src/widgets/fusion/map.jsx b/tools/form-render_v0.x/src/widgets/fusion/map.jsx index ad1b25b1a..cf19de0af 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/map.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/map.jsx @@ -1,5 +1,5 @@ -import React, { useState } from 'react'; import { Dialog as Modal, Drawer } from '@alifd/next'; +import React, { useState } from 'react'; import { isObj } from '../../base/utils'; import Map from '../../components/map'; diff --git a/tools/form-render_v0.x/src/widgets/fusion/radio.jsx b/tools/form-render_v0.x/src/widgets/fusion/radio.jsx index fa3463d1e..8918bcfce 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/radio.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/radio.jsx @@ -2,8 +2,8 @@ * Updated by Tw93 on 2019-12-07. * 单选组件 */ -import React from 'react'; import { Radio } from '@alifd/next'; +import React from 'react'; import RadioHoc from '../../components/radioHoc'; const RadioComponent = p => { diff --git a/tools/form-render_v0.x/src/widgets/fusion/switch.jsx b/tools/form-render_v0.x/src/widgets/fusion/switch.jsx index 1880c0f78..224670438 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/switch.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/switch.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Switch } from '@alifd/next'; +import React from 'react'; export default function sw(p) { return ( diff --git a/tools/form-render_v0.x/src/widgets/fusion/textarea.jsx b/tools/form-render_v0.x/src/widgets/fusion/textarea.jsx index 7c3c97296..180b2d0c5 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/textarea.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/textarea.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Input } from '@alifd/next'; +import React from 'react'; const { TextArea } = Input; diff --git a/tools/form-render_v0.x/src/widgets/fusion/upload.jsx b/tools/form-render_v0.x/src/widgets/fusion/upload.jsx index 32ef3213b..ef62142a1 100644 --- a/tools/form-render_v0.x/src/widgets/fusion/upload.jsx +++ b/tools/form-render_v0.x/src/widgets/fusion/upload.jsx @@ -1,5 +1,5 @@ +import { Button, Icon, Message, Upload } from '@alifd/next'; import React from 'react'; -import { Icon, Upload, Message, Button } from '@alifd/next'; export default function upload(p) { const props = { diff --git a/tools/proptypes-to-json-schema/demo/index.jsx b/tools/proptypes-to-json-schema/demo/index.jsx index 8892d66f2..70f3807cd 100644 --- a/tools/proptypes-to-json-schema/demo/index.jsx +++ b/tools/proptypes-to-json-schema/demo/index.jsx @@ -1,7 +1,7 @@ -import React from 'react'; import Loading from '@alife/loading'; - +import React from 'react'; import './index.scss'; + // import { glodLog } from './utils'; const { Component, PropTypes } = React; @@ -117,16 +117,8 @@ export default class FpDemo extends Component { } render() { - const { - bgImage, - title, - upDate, - type, - isLike, - desArr, - num, - styleObj, - } = this.props; + const { bgImage, title, upDate, type, isLike, desArr, num, styleObj } = + this.props; return (
diff --git a/tools/proptypes-to-json-schema/package.json b/tools/proptypes-to-json-schema/package.json index b33c7c17b..7c390c725 100644 --- a/tools/proptypes-to-json-schema/package.json +++ b/tools/proptypes-to-json-schema/package.json @@ -2,35 +2,35 @@ "name": "proptypes-to-json-schema", "version": "0.1.0", "description": "React PropTypes 自动生成 Json Schema", - "main": "src/index.js", - "author": "Tw93", - "contributors": [ - { - "name": "Tw93", - "email": "tw93@qq.com" - } - ], "keywords": [ "FormRender", "React", "Json Schema", "PropTypes" ], - "license": "ISC", "repository": { "type": "git", "url": "git@github.com:tw93/proptypes-to-json-schema.git" }, + "license": "ISC", + "author": "Tw93", + "contributors": [ + { + "name": "Tw93", + "email": "tw93@qq.com" + } + ], + "main": "src/index.js", "dependencies": { "doctrine": "^2.1.0", "fs": "^0.0.1-security", "react-docgen": "^2.20.1" }, "devDependencies": { + "babel-eslint": "^8.1.1", "eslint": "^4.15.0", "eslint-config-ali": "^3.1.0", "eslint-plugin-import": "^2.8.0", - "eslint-plugin-react": "^7.4.0", - "babel-eslint": "^8.1.1" + "eslint-plugin-react": "^7.4.0" } } diff --git a/tools/proptypes-to-json-schema/src/to-schema.js b/tools/proptypes-to-json-schema/src/to-schema.js index 2066ae2f4..74dd18420 100644 --- a/tools/proptypes-to-json-schema/src/to-schema.js +++ b/tools/proptypes-to-json-schema/src/to-schema.js @@ -10,7 +10,7 @@ const { parse, } = require('./tool'); -module.exports = function(componentInfo, options) { +module.exports = function (componentInfo, options) { const { props, description, displayName } = componentInfo; const { shouldAddUi } = options; if (!props || props === 'undefined' || props === undefined) { diff --git a/tools/schema-generator/package.json b/tools/schema-generator/package.json index 2e9179762..2d5532f84 100644 --- a/tools/schema-generator/package.json +++ b/tools/schema-generator/package.json @@ -1,21 +1,18 @@ { "name": "fr-generator", "version": "2.7.5", + "main": "dist/index.js", + "module": "dist/index.esm.js", + "typings": "dist/index.d.ts", "scripts": { + "beta": "npm publish --tag beta", "build": "father-build", "prepare": "npm run build", - "beta": "npm publish --tag beta", - "postpublish": "git push --tags", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "dist/index.js", - "module": "dist/index.esm.js", - "typings": "dist/index.d.ts", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -24,11 +21,6 @@ "prettier --parser=typescript --write" ] }, - "peerDependencies": { - "antd": "4.x", - "react": ">=16.14.0", - "react-dom": ">=16.14.0" - }, "dependencies": { "antd": "^4.4.2", "clone": "^2.1.2", @@ -44,5 +36,13 @@ "devDependencies": { "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-copy": "^3.4.0" + }, + "peerDependencies": { + "antd": "4.x", + "react": ">=16.14.0", + "react-dom": ">=16.14.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/tools/schema-generator/src/Provider.jsx b/tools/schema-generator/src/Provider.jsx index 3ecc8f465..d6000112e 100644 --- a/tools/schema-generator/src/Provider.jsx +++ b/tools/schema-generator/src/Provider.jsx @@ -1,32 +1,32 @@ +import { ConfigProvider } from 'antd'; +import zhCN from 'antd/lib/locale/zh_CN'; +import copyTOClipboard from 'copy-text-to-clipboard'; +import { + mapping as defaultMapping, + widgets as defaultWidgets, +} from 'form-render'; import React, { - useEffect, - useRef, forwardRef, + useEffect, useImperativeHandle, + useRef, useState, } from 'react'; import { DndProvider } from 'react-dnd'; import { HTML5Backend } from 'react-dnd-html5-backend'; -import { ConfigProvider } from 'antd'; -import zhCN from 'antd/lib/locale/zh_CN'; -import { - widgets as defaultWidgets, - mapping as defaultMapping, -} from 'form-render'; -import copyTOClipboard from 'copy-text-to-clipboard'; +import { fromSetting, toSetting } from './transformer/form-render'; import { - flattenSchema, - idToSchema, combineSchema, dataToFlatten, + defaultGetId, + flattenSchema, flattenToData, + idToSchema, newSchemaToOld, schemaToState, - defaultGetId, } from './utils'; import { Ctx, StoreCtx } from './utils/context'; import { useSet } from './utils/hooks'; -import { fromSetting, toSetting } from './transformer/form-render'; import list from './widgets/list'; const DEFAULT_SCHEMA = { diff --git a/tools/schema-generator/src/components/Canvas/core/RenderField.jsx b/tools/schema-generator/src/components/Canvas/core/RenderField.jsx index da1dc04a7..233d2f87d 100644 --- a/tools/schema-generator/src/components/Canvas/core/RenderField.jsx +++ b/tools/schema-generator/src/components/Canvas/core/RenderField.jsx @@ -1,11 +1,11 @@ import React, { Suspense } from 'react'; -import { useStore } from '../../../utils/hooks'; import { - isLooselyNumber, - isCssLength, getParentProps, + isCssLength, + isLooselyNumber, transformProps, } from '../../../utils'; +import { useStore } from '../../../utils/hooks'; import { getWidgetName } from '../../../utils/mapping'; const RenderField = ({ diff --git a/tools/schema-generator/src/components/Canvas/core/Wrapper.jsx b/tools/schema-generator/src/components/Canvas/core/Wrapper.jsx index c05d51f92..7c3257551 100644 --- a/tools/schema-generator/src/components/Canvas/core/Wrapper.jsx +++ b/tools/schema-generator/src/components/Canvas/core/Wrapper.jsx @@ -1,13 +1,13 @@ +import { CopyOutlined, DeleteOutlined, DragOutlined } from '@ant-design/icons'; import React, { useRef, useState } from 'react'; -import { DeleteOutlined, CopyOutlined, DragOutlined } from '@ant-design/icons'; import { useDrag, useDrop } from 'react-dnd'; -import { useGlobal, useStore } from '../../../utils/hooks'; import { copyItem, - getKeyFromUniqueId, dropItem, + getKeyFromUniqueId, isObject, } from '../../../utils'; +import { useGlobal, useStore } from '../../../utils/hooks'; import './Wrapper.less'; function Wrapper({ $id, item, inside = false, children, style }) { diff --git a/tools/schema-generator/src/components/Canvas/core/index.jsx b/tools/schema-generator/src/components/Canvas/core/index.jsx index 8110e2738..4adff6588 100644 --- a/tools/schema-generator/src/components/Canvas/core/index.jsx +++ b/tools/schema-generator/src/components/Canvas/core/index.jsx @@ -1,6 +1,6 @@ -import React, { useEffect } from 'react'; import FormRender, { useForm } from 'form-render'; -import { flattenToData, dataToFlatten } from '../../../utils'; +import React, { useEffect } from 'react'; +import { dataToFlatten, flattenToData } from '../../../utils'; import { useStore } from '../../../utils/hooks'; import RenderChildren from './RenderChildren'; import RenderField from './RenderField'; @@ -45,7 +45,8 @@ const FR = ({ id = '#', preview, displaySchema }) => { const { schema } = item; const displayType = schema.displayType || frProps.displayType; const isObj = schema.type === 'object'; - const isList = schema.type === 'array' && schema.enum === undefined && !!schema.items; + const isList = + schema.type === 'array' && schema.enum === undefined && !!schema.items; const isComplex = isObj || isList; const width = schema['width']; let containerClass = `fr-field w-100 ${isComplex ? 'fr-field-complex' : ''} ${ diff --git a/tools/schema-generator/src/components/Canvas/index.jsx b/tools/schema-generator/src/components/Canvas/index.jsx index 69909f89e..f3228f140 100644 --- a/tools/schema-generator/src/components/Canvas/index.jsx +++ b/tools/schema-generator/src/components/Canvas/index.jsx @@ -1,14 +1,14 @@ -import React, { useEffect } from 'react'; -import { Modal, Input, Button, message } from 'antd'; +import { Button, Input, message, Modal } from 'antd'; import copyTOClipboard from 'copy-text-to-clipboard'; -import FR from './core'; +import React, { useEffect } from 'react'; import { - looseJsonParse, + idToSchema, isObject, + looseJsonParse, schemaToState, - idToSchema, } from '../../utils'; -import { useSet, useGlobal, useStore } from '../../utils/hooks'; +import { useGlobal, useSet, useStore } from '../../utils/hooks'; +import FR from './core'; const { TextArea } = Input; diff --git a/tools/schema-generator/src/components/Settings/GlobalSettings.jsx b/tools/schema-generator/src/components/Settings/GlobalSettings.jsx index 5db8666fb..4fe6b1ac7 100644 --- a/tools/schema-generator/src/components/Settings/GlobalSettings.jsx +++ b/tools/schema-generator/src/components/Settings/GlobalSettings.jsx @@ -1,7 +1,7 @@ -import React, { useState, useEffect } from 'react'; import FormRender, { useForm } from 'form-render'; +import React, { useEffect, useState } from 'react'; import { defaultGlobalSettings } from '../../settings'; -import { useStore, useGlobal } from '../../utils/hooks'; +import { useGlobal, useStore } from '../../utils/hooks'; export default function GlobalSettings({ widgets }) { const form = useForm(); diff --git a/tools/schema-generator/src/components/Settings/ItemSettings.jsx b/tools/schema-generator/src/components/Settings/ItemSettings.jsx index 2d845a6dd..5248cb95b 100644 --- a/tools/schema-generator/src/components/Settings/ItemSettings.jsx +++ b/tools/schema-generator/src/components/Settings/ItemSettings.jsx @@ -1,19 +1,19 @@ -import React, { useState, useEffect } from 'react'; import FormRender, { useForm } from 'form-render'; -import IdInput from '../../widgets/idInput'; -import HtmlInput from '../../widgets/htmlInput'; -import PercentSlider from '../../widgets/percentSlider'; +import React, { useEffect, useState } from 'react'; import { - defaultSettings, + advancedElements, baseCommonSettings, defaultCommonSettings, + defaultSettings, elements, - advancedElements, layouts, } from '../../settings'; import { isObject, mergeInOrder } from '../../utils'; -import { getWidgetName } from '../../utils/mapping'; import { useStore } from '../../utils/hooks'; +import { getWidgetName } from '../../utils/mapping'; +import HtmlInput from '../../widgets/htmlInput'; +import IdInput from '../../widgets/idInput'; +import PercentSlider from '../../widgets/percentSlider'; export default function ItemSettings({ widgets }) { const form = useForm(); @@ -27,7 +27,8 @@ export default function ItemSettings({ widgets }) { mapping: globalMapping, } = useStore(); - const { settings, commonSettings, hideId, validation, transformer } = userProps; + const { settings, commonSettings, hideId, validation, transformer } = + userProps; const [settingSchema, setSettingSchema] = useState({}); const _widgets = { diff --git a/tools/schema-generator/src/components/Settings/index.jsx b/tools/schema-generator/src/components/Settings/index.jsx index 00dc09e9e..8297a7812 100644 --- a/tools/schema-generator/src/components/Settings/index.jsx +++ b/tools/schema-generator/src/components/Settings/index.jsx @@ -1,10 +1,10 @@ -import React, { useEffect } from 'react'; -import { Tabs } from 'antd'; import { RightOutlined } from '@ant-design/icons'; -import ItemSettings from './ItemSettings'; +import { Tabs } from 'antd'; +import React, { useEffect } from 'react'; +import { useSet, useStore } from '../../utils/hooks'; import GlobalSettings from './GlobalSettings'; -import { useStore, useSet } from '../../utils/hooks'; import './index.less'; +import ItemSettings from './ItemSettings'; const { TabPane } = Tabs; diff --git a/tools/schema-generator/src/components/Sidebar/Element.jsx b/tools/schema-generator/src/components/Sidebar/Element.jsx index 10673cece..bbd25f6e1 100644 --- a/tools/schema-generator/src/components/Sidebar/Element.jsx +++ b/tools/schema-generator/src/components/Sidebar/Element.jsx @@ -51,14 +51,16 @@ const Element = ({ text, name, schema, icon, fixedName }) => { const widgetProps = { text, icon, - onClick: handleElementClick - } + onClick: handleElementClick, + }; - const originNode = + const originNode = ; return (
- {elementRender ? elementRender(schema, widgetProps, originNode) : originNode} + {elementRender + ? elementRender(schema, widgetProps, originNode) + : originNode}
); }; diff --git a/tools/schema-generator/src/index.d.ts b/tools/schema-generator/src/index.d.ts index 7900c23fb..bfb280f0d 100644 --- a/tools/schema-generator/src/index.d.ts +++ b/tools/schema-generator/src/index.d.ts @@ -1,4 +1,4 @@ -import { FC, ReactNode, ForwardRefExoticComponent, RefAttributes } from 'react'; +import { FC, ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react'; export interface Transformer { /** 正向的转换函数 */ diff --git a/tools/schema-generator/src/index.js b/tools/schema-generator/src/index.js index 13231e555..d06144d50 100644 --- a/tools/schema-generator/src/index.js +++ b/tools/schema-generator/src/index.js @@ -1,8 +1,8 @@ import React, { forwardRef } from 'react'; -import Provider from './Provider'; -import Sidebar from './components/Sidebar'; import Canvas from './components/Canvas'; import Settings from './components/Settings'; +import Sidebar from './components/Sidebar'; +import Provider from './Provider'; import './styles/index.less'; const Generator = forwardRef( @@ -25,9 +25,9 @@ Generator.Canvas = Canvas; Generator.Settings = Settings; export { - defaultSettings, defaultCommonSettings, defaultGlobalSettings, + defaultSettings, } from './settings'; export { fromSetting, toSetting } from './transformer/form-render'; export default Generator; diff --git a/tools/schema-generator/src/utils/hooks.js b/tools/schema-generator/src/utils/hooks.js index 7eb0f9796..662399052 100644 --- a/tools/schema-generator/src/utils/hooks.js +++ b/tools/schema-generator/src/utils/hooks.js @@ -1,4 +1,4 @@ -import { useReducer, useContext } from 'react'; +import { useContext, useReducer } from 'react'; import { Ctx, StoreCtx } from './context'; // 使用最顶层组件的 setState diff --git a/tools/schema-generator/src/widgets/htmlInput.jsx b/tools/schema-generator/src/widgets/htmlInput.jsx index 5a7ca6fad..3a540108b 100644 --- a/tools/schema-generator/src/widgets/htmlInput.jsx +++ b/tools/schema-generator/src/widgets/htmlInput.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Input } from 'antd'; +import React from 'react'; export default function HtmlInput({ value, diff --git a/tools/schema-generator/src/widgets/idInput.jsx b/tools/schema-generator/src/widgets/idInput.jsx index c89febacf..e69d8b1e1 100644 --- a/tools/schema-generator/src/widgets/idInput.jsx +++ b/tools/schema-generator/src/widgets/idInput.jsx @@ -1,6 +1,6 @@ -import React from 'react'; import { Input } from 'antd'; -import { getKeyFromUniqueId, changeKeyFromUniqueId } from '../utils'; +import React from 'react'; +import { changeKeyFromUniqueId, getKeyFromUniqueId } from '../utils'; export default function IdInput({ onChange, diff --git a/tools/schema-generator/src/widgets/list.jsx b/tools/schema-generator/src/widgets/list.jsx index e6b92ae2a..f6c8ae582 100644 --- a/tools/schema-generator/src/widgets/list.jsx +++ b/tools/schema-generator/src/widgets/list.jsx @@ -1,6 +1,6 @@ -import React from 'react'; +import { DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons'; import { Button } from 'antd'; -import { PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons'; +import React from 'react'; export default function list(props) { if (!/^#/.test(props.schema.$id)) { diff --git a/tools/schema-generator/src/widgets/percentSlider.jsx b/tools/schema-generator/src/widgets/percentSlider.jsx index 1e8034dc4..109952828 100644 --- a/tools/schema-generator/src/widgets/percentSlider.jsx +++ b/tools/schema-generator/src/widgets/percentSlider.jsx @@ -1,5 +1,5 @@ -import React from 'react'; import { InputNumber, Slider } from 'antd'; +import React from 'react'; const PercentSlider = p => { const style = p.invalid ? { borderColor: '#f5222d' } : {}; diff --git a/tools/vscode-plugin-fr-schema/examples/form.tsx b/tools/vscode-plugin-fr-schema/examples/form.tsx index f6da555c3..9fa6138af 100644 --- a/tools/vscode-plugin-fr-schema/examples/form.tsx +++ b/tools/vscode-plugin-fr-schema/examples/form.tsx @@ -1,5 +1,5 @@ -import React from 'react'; import FormRender from 'form-render/lib/antd'; +import React from 'react'; import './index.less'; interface FormProps { diff --git a/tools/vscode-plugin-fr-schema/examples/page.jsx b/tools/vscode-plugin-fr-schema/examples/page.jsx index 4a566f65e..0529dc129 100644 --- a/tools/vscode-plugin-fr-schema/examples/page.jsx +++ b/tools/vscode-plugin-fr-schema/examples/page.jsx @@ -1,7 +1,7 @@ -import React from 'react'; import Loading from '@alife/loading'; - +import React from 'react'; import './index.scss'; + // import { glodLog } from './utils'; const { Component, PropTypes } = React; @@ -117,16 +117,8 @@ export default class FpDemo extends Component { } render() { - const { - bgImage, - title, - upDate, - type, - isLike, - desArr, - num, - styleObj, - } = this.props; + const { bgImage, title, upDate, type, isLike, desArr, num, styleObj } = + this.props; return (
diff --git a/tools/vscode-plugin-fr-schema/package.json b/tools/vscode-plugin-fr-schema/package.json index fc9b03254..ae1590dff 100644 --- a/tools/vscode-plugin-fr-schema/package.json +++ b/tools/vscode-plugin-fr-schema/package.json @@ -1,12 +1,8 @@ { "name": "vscode-plugin-fr-schema", "displayName": "FormRender generator", - "description": "form-render 的表单设计器", "version": "1.0.5", - "publisher": "F-loat", - "engines": { - "vscode": "^1.46.0" - }, + "description": "form-render 的表单设计器", "categories": [ "Snippets", "Other" @@ -15,36 +11,17 @@ "type": "git", "url": "https://github.com/alibaba/x-render.git" }, - "icon": "media/icon.png", + "publisher": "F-loat", "main": "./out/extension/index.js", "scripts": { - "dev:web": "umi dev", - "dev:extension": "webpack --mode development", - "build:web": "umi build", "build:extension": "webpack --mode production", + "build:web": "umi build", + "dev:extension": "webpack --mode development", + "dev:web": "umi dev", "lint": "eslint . --ext .jsx,.ts,.tsx --fix", "vscode:prepublish": "npm run lint && npm run build:web && npm run build:extension" }, - "activationEvents": [ - "onCommand:frSchema.p2s", - "onCommand:frSchema.s2i", - "onCommand:frSchema.c2i", - "onCommand:frSchema.gen", - "onCommand:frSchema.edit", - "onCommand:frSchema.preview", - "onCustomEditor:frSchema.editor" - ], "contributes": { - "snippets": [ - { - "language": "json", - "path": "./out/snippets/snippets.json" - }, - { - "language": "javascript", - "path": "./out/snippets/snippets.json" - } - ], "commands": [ { "command": "frSchema.gen", @@ -76,6 +53,40 @@ "icon": "$(open-preview)" } ], + "configuration": { + "type": "object", + "title": "FormRender generator", + "properties": { + "vscode-plugin-fr-schema.theme": { + "type": "boolean", + "default": true, + "description": "启用主题" + } + } + }, + "customEditors": [ + { + "viewType": "frSchema.editor", + "displayName": "FormRender Schema Editor", + "selector": [ + { + "filenamePattern": "*.json" + } + ], + "priority": "option" + } + ], + "jsonValidation": [ + { + "fileMatch": [ + "*.fr.json", + "*.schema.json", + "schema/*.json", + "schemas/*.json" + ], + "url": "./src/validation/schema.json" + } + ], "menus": { "editor/title": [ { @@ -139,40 +150,37 @@ } ] }, - "customEditors": [ + "snippets": [ { - "viewType": "frSchema.editor", - "displayName": "FormRender Schema Editor", - "selector": [ - { - "filenamePattern": "*.json" - } - ], - "priority": "option" - } - ], - "jsonValidation": [ + "language": "json", + "path": "./out/snippets/snippets.json" + }, { - "fileMatch": [ - "*.fr.json", - "*.schema.json", - "schema/*.json", - "schemas/*.json" - ], - "url": "./src/validation/schema.json" + "language": "javascript", + "path": "./out/snippets/snippets.json" } + ] + }, + "activationEvents": [ + "onCommand:frSchema.p2s", + "onCommand:frSchema.s2i", + "onCommand:frSchema.c2i", + "onCommand:frSchema.gen", + "onCommand:frSchema.edit", + "onCommand:frSchema.preview", + "onCustomEditor:frSchema.editor" + ], + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" ], - "configuration": { - "type": "object", - "title": "FormRender generator", - "properties": { - "vscode-plugin-fr-schema.theme": { - "type": "boolean", - "default": true, - "description": "启用主题" - } - } - } + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] }, "dependencies": { "fr-generator": "^2.0.2", @@ -204,16 +212,8 @@ "webpack": "^4.4.0", "webpack-cli": "^3.3.0" }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } + "engines": { + "vscode": "^1.46.0" + }, + "icon": "media/icon.png" } diff --git a/tools/vscode-plugin-fr-schema/src/extension/frProp2Schema.ts b/tools/vscode-plugin-fr-schema/src/extension/frProp2Schema.ts index 8ffc8da74..333c3df25 100644 --- a/tools/vscode-plugin-fr-schema/src/extension/frProp2Schema.ts +++ b/tools/vscode-plugin-fr-schema/src/extension/frProp2Schema.ts @@ -2,9 +2,9 @@ * proptypes to schema */ -import * as vscode from 'vscode'; -import * as docgen from 'react-docgen'; import * as toSchema from 'proptypes-to-json-schema/src/to-Schema'; +import * as docgen from 'react-docgen'; +import * as vscode from 'vscode'; export class frProp2SchemaProvider { public static register(): vscode.Disposable { diff --git a/tools/vscode-plugin-fr-schema/src/extension/index.ts b/tools/vscode-plugin-fr-schema/src/extension/index.ts index 1b186278f..b36d95f2f 100644 --- a/tools/vscode-plugin-fr-schema/src/extension/index.ts +++ b/tools/vscode-plugin-fr-schema/src/extension/index.ts @@ -1,11 +1,11 @@ import * as vscode from 'vscode'; -import { frSchemaGenProvider } from './frSchemaGen'; -import { frSchemaEditProvider } from './frSchemaEdit'; -import * as frSchemaPreviewProvider from './frSchemaPreview'; -import { frSchemaEditorProvider } from './frSchemaEditor'; +import { frCode2InterfaceProvider } from './frCode2Interface'; import { frProp2SchemaProvider } from './frProp2Schema'; import { frSchema2InterfaceProvider } from './frSchema2Interface'; -import { frCode2InterfaceProvider } from './frCode2Interface'; +import { frSchemaEditProvider } from './frSchemaEdit'; +import { frSchemaEditorProvider } from './frSchemaEditor'; +import { frSchemaGenProvider } from './frSchemaGen'; +import * as frSchemaPreviewProvider from './frSchemaPreview'; export function activate(context: vscode.ExtensionContext) { // Register our custom editor providers diff --git a/tools/vscode-plugin-fr-schema/src/extension/utils/index.ts b/tools/vscode-plugin-fr-schema/src/extension/utils/index.ts index b511bfbc4..2972e9447 100644 --- a/tools/vscode-plugin-fr-schema/src/extension/utils/index.ts +++ b/tools/vscode-plugin-fr-schema/src/extension/utils/index.ts @@ -1,7 +1,7 @@ -import getInterfaceFromModel from './model2interface'; -import getModelFromSchema from './schema2model'; import getSchemaFromCode from './code2schema'; import getHtmlForWebview from './html4webview'; +import getInterfaceFromModel from './model2interface'; +import getModelFromSchema from './schema2model'; export { getInterfaceFromModel, diff --git a/tools/vscode-plugin-fr-schema/src/pages/index.jsx b/tools/vscode-plugin-fr-schema/src/pages/index.jsx index 88a831960..dcefad634 100644 --- a/tools/vscode-plugin-fr-schema/src/pages/index.jsx +++ b/tools/vscode-plugin-fr-schema/src/pages/index.jsx @@ -1,5 +1,5 @@ -import React, { useRef } from 'react'; import Generator from 'fr-generator'; +import React, { useRef } from 'react'; import { vsemit, vson } from './utils'; const { preview, theme = true } = window.pluginConfig; diff --git a/widgets/AsyncOptions/package.json b/widgets/AsyncOptions/package.json index dac2053be..9fea405e6 100644 --- a/widgets/AsyncOptions/package.json +++ b/widgets/AsyncOptions/package.json @@ -8,21 +8,18 @@ "Json Schema", "Ant Design" ], + "main": "dist/index.js", + "module": "dist/index.esm.js", "scripts": { + "beta": "npm publish --tag beta", "build": "father-build", "prepare": "npm run build", - "release": "npm publish --access public", - "postpublish": "git push --tags", - "beta": "npm publish --tag beta", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", + "release": "npm publish --access public", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "dist/index.js", - "module": "dist/index.esm.js", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -37,5 +34,8 @@ "peerDependencies": { "antd": "^4.x", "react": ">=16.8.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/widgets/RichText/package.json b/widgets/RichText/package.json index 29e110103..39668f01c 100644 --- a/widgets/RichText/package.json +++ b/widgets/RichText/package.json @@ -8,21 +8,18 @@ "Json Schema", "Ant Design" ], + "main": "dist/index.js", + "module": "dist/index.esm.js", "scripts": { + "beta": "npm publish --tag beta", "build": "father-build", "prepare": "npm run build", - "release": "npm publish --access public", - "postpublish": "git push --tags", - "beta": "npm publish --tag beta", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", + "release": "npm publish --access public", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "dist/index.js", - "module": "dist/index.esm.js", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -37,5 +34,8 @@ "peerDependencies": { "antd": "^4.x", "react": ">=16.8.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" } } diff --git a/widgets/RichText/src/index.js b/widgets/RichText/src/index.js index 151510d8c..321c0ada5 100644 --- a/widgets/RichText/src/index.js +++ b/widgets/RichText/src/index.js @@ -1,6 +1,6 @@ -import React, { useState, useEffect } from 'react'; import BraftEditor from 'braft-editor'; import 'braft-editor/dist/index.css'; +import React, { useEffect, useState } from 'react'; const { createEditorState } = BraftEditor; diff --git a/widgets/template/package.json b/widgets/template/package.json index 500d48381..cf8dca3d8 100644 --- a/widgets/template/package.json +++ b/widgets/template/package.json @@ -8,21 +8,18 @@ "Json Schema", "Ant Design" ], + "main": "dist/index.js", + "module": "dist/index.esm.js", "scripts": { + "beta": "npm publish --tag beta", "build": "father-build", "prepare": "npm run build", - "release": "npm publish --access public", - "postpublish": "git push --tags", - "beta": "npm publish --tag beta", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "postpublish": "git push --tags", + "release": "npm publish --access public", "test": "umi-test", "test:coverage": "umi-test --coverage" }, - "main": "dist/index.js", - "module": "dist/index.esm.js", - "gitHooks": { - "pre-commit": "lint-staged" - }, "lint-staged": { "*.{js,jsx,less,md,json}": [ "prettier --write" @@ -34,5 +31,8 @@ "peerDependencies": { "antd": "^4.x", "react": ">=16.8.0" + }, + "gitHooks": { + "pre-commit": "lint-staged" } }