diff --git a/designable/.eslintrc b/designable/.eslintrc deleted file mode 100644 index 018630faf56..00000000000 --- a/designable/.eslintrc +++ /dev/null @@ -1,74 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", - "extends": [ - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended", - "prettier/@typescript-eslint", - "plugin:markdown/recommended" - ], - "env": { - "node": true - }, - "plugins": ["@typescript-eslint", "react", "prettier", "markdown"], - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 10, - "ecmaFeatures": { - "jsx": true - } - }, - "settings": { - "react": { - "version": "detect" - } - }, - "rules": { - "prettier/prettier": 0, - // don't force es6 functions to include space before paren - "space-before-function-paren": 0, - "react/prop-types": 0, - "react/no-find-dom-node": 0, - "react/display-name": 0, - // allow specifying true explicitly for boolean props - "react/jsx-boolean-value": 0, - "react/no-did-update-set-state": 0, - // maybe we should no-public - "@typescript-eslint/explicit-member-accessibility": 0, - "@typescript-eslint/interface-name-prefix": 0, - "@typescript-eslint/no-explicit-any": 0, - "@typescript-eslint/explicit-function-return-type": 0, - "@typescript-eslint/no-parameter-properties": 0, - "@typescript-eslint/array-type": 0, - "@typescript-eslint/no-object-literal-type-assertion": 0, - "@typescript-eslint/no-use-before-define": 0, - "@typescript-eslint/no-unused-vars": 1, - "@typescript-eslint/no-namespace": 0, - "@typescript-eslint/ban-types": 0, - "@typescript-eslint/adjacent-overload-signatures": 0, - "@typescript-eslint/explicit-module-boundary-types": 0, - "@typescript-eslint/no-empty-function": 0, - "no-console": [ - "error", - { - "allow": ["warn", "error", "info"] - } - ], - "prefer-const": 0, - "no-var": 1, - "prefer-rest-params": 0 - }, - "overrides": [ - { - "files": ["**/*.md"], - "processor": "markdown/markdown" - }, - { - "files": ["**/*.md/*.{jsx,tsx}"], - "rules": { - "@typescript-eslint/no-unused-vars": "error", - "no-unused-vars": "error", - "no-console": "off" - } - } - ] -} diff --git a/designable/antd/.npmignore b/designable/antd/.npmignore deleted file mode 100644 index 1ff337420fd..00000000000 --- a/designable/antd/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -node_modules -*.log -build -docs -doc-site -__tests__ -.eslintrc -jest.config.js -tsconfig.json -.umi -src \ No newline at end of file diff --git a/designable/antd/.umirc.js b/designable/antd/.umirc.js deleted file mode 100644 index 1362b3c43c6..00000000000 --- a/designable/antd/.umirc.js +++ /dev/null @@ -1,44 +0,0 @@ -import { resolve } from 'path' -export default { - mode: 'site', - logo: '//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg', - title: 'Formily', - hash: true, - favicon: - '//img.alicdn.com/imgextra/i3/O1CN01XtT3Tv1Wd1b5hNVKy_!!6000000002810-55-tps-360-360.svg', - outputPath: './doc-site', - navs: [ - { - title: 'Ant Design', - path: '/components', - }, - { - title: '主站', - path: 'https://v2.formilyjs.org', - }, - { - title: 'GITHUB', - path: 'https://github.com/alibaba/formily', - }, - ], - styles: [ - `.__dumi-default-navbar-logo{ - height: 60px !important; - width: 150px !important; - padding-left:0 !important; - color: transparent !important; - } - .__dumi-default-navbar{ - padding: 0 28px !important; - } - .__dumi-default-layout-hero{ - background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png); - background-size: cover; - background-repeat: no-repeat; - } - nav a{ - text-decoration: none !important; - } - `, - ], -} diff --git a/designable/antd/LICENSE.md b/designable/antd/LICENSE.md deleted file mode 100644 index 509632e8e80..00000000000 --- a/designable/antd/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015-present, Alibaba Group Holding Limited. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/designable/antd/README.md b/designable/antd/README.md deleted file mode 100644 index 84103eebdc5..00000000000 --- a/designable/antd/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @formily/designable-antd - -### Install - -```bash -npm install --save @formily/designable-antd -``` diff --git a/designable/antd/copy.ts b/designable/antd/copy.ts deleted file mode 100644 index d451fc48651..00000000000 --- a/designable/antd/copy.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { runCopy } from '../../scripts/build-style' - -runCopy({ - esStr: 'antd/es/', - libStr: 'antd/lib/', -}) diff --git a/designable/antd/package.json b/designable/antd/package.json deleted file mode 100644 index e0bc10e1dbc..00000000000 --- a/designable/antd/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@formily/designable-antd", - "version": "2.0.0-rc.7", - "license": "MIT", - "main": "lib", - "module": "esm", - "umd:main": "dist/formily.designable.antd.umd.production.js", - "unpkg": "dist/formily.designable.umd.production.js", - "jsdelivr": "dist/formily.designable.umd.production.js", - "jsnext:main": "esm", - "repository": { - "type": "git", - "url": "git+https://github.com/alibaba/formily.git" - }, - "types": "esm/index.d.ts", - "bugs": { - "url": "https://github.com/alibaba/formily/issues" - }, - "homepage": "https://github.com/alibaba/formily#readme", - "engines": { - "npm": ">=3.0.0" - }, - "scripts": { - "build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm && npm run build:umd && ts-node copy", - "build:cjs": "tsc --project tsconfig.build.json", - "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm", - "build:umd": "rollup --config", - "build:playground": "webpack-cli --config playground/webpack.prod.ts", - "start": "webpack-dev-server --config playground/webpack.dev.ts" - }, - "devDependencies": { - "@designable/react-settings-form": "^0.x", - "autoprefixer": "^9.0", - "file-loader": "^5.0.2", - "fs-extra": "^8.1.0", - "html-webpack-plugin": "^3.2.0", - "mini-css-extract-plugin": "^1.6.0", - "monaco-editor-webpack-plugin": "^4.0.0", - "raw-loader": "^4.0.0", - "react-monaco-editor": "^0.43.0", - "style-loader": "^1.1.3", - "ts-loader": "^7.0.4", - "typescript": "4.1.5", - "webpack": "^4.41.5", - "webpack-bundle-analyzer": "^3.9.0", - "webpack-cli": "^3.3.10", - "webpack-dev-server": "^3.10.1" - }, - "peerDependencies": { - "@types/react": ">=16.8.0 || >=17.0.0", - "@types/react-dom": ">=16.8.0 || >=17.0.0", - "antd": "^4.0.0", - "react": ">=16.8.0 || >=17.0.0", - "react-dom": ">=16.8.0", - "react-is": ">=16.8.0 || >=17.0.0" - }, - "dependencies": { - "@designable/core": "^0.x", - "@designable/formily": "^0.x", - "@designable/react": "^0.x", - "@formily/antd": "2.0.0-rc.7", - "@formily/core": "2.0.0-rc.7", - "@formily/designable-setters": "2.0.0-rc.7", - "@formily/react": "2.0.0-rc.7", - "@formily/shared": "2.0.0-rc.7" - }, - "publishConfig": { - "access": "public" - }, - "gitHead": "2c44ae410a73f02735c63c6430e021a50e21f3ec" -} diff --git a/designable/antd/playground/main.tsx b/designable/antd/playground/main.tsx deleted file mode 100644 index df5f255f327..00000000000 --- a/designable/antd/playground/main.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import { - Designer, - DesignerToolsWidget, - ViewToolsWidget, - Workspace, - OutlineTreeWidget, - DragSourceWidget, - HistoryWidget, - MainPanel, - CompositePanel, - WorkspacePanel, - ToolbarPanel, - ViewportPanel, - ViewPanel, - SettingsPanel, - ComponentTreeWidget, -} from '@designable/react' -import { SettingsForm } from '@designable/react-settings-form' -import { - createDesigner, - GlobalRegistry, - Shortcut, - KeyCode, -} from '@designable/core' -import { createDesignableField, createDesignableForm } from '../src' -import { - LogoWidget, - ActionsWidget, - PreviewWidget, - SchemaEditorWidget, - MarkupSchemaWidget, -} from './widgets' -import { saveSchema } from './service' -import 'antd/dist/antd.less' -GlobalRegistry.registerDesignerLocales({ - 'zh-CN': { - sources: { - Inputs: '输入控件', - Layouts: '布局组件', - Arrays: '自增组件', - Displays: '展示组件', - }, - }, - 'en-US': { - sources: { - Inputs: 'Inputs', - Layouts: 'Layouts', - Arrays: 'Arrays', - Displays: 'Displays', - }, - }, -}) - -const Root = createDesignableForm({ - registryName: 'Root', -}) - -const DesignableField = createDesignableField({ - registryName: 'DesignableField', -}) - -const SaveShortCut = new Shortcut({ - codes: [ - [KeyCode.Meta, KeyCode.S], - [KeyCode.Control, KeyCode.S], - ], - handler(ctx) { - saveSchema(ctx.engine) - }, -}) - -const engine = createDesigner({ - shortcuts: [SaveShortCut], -}) - -const App = () => { - return ( - - } actions={}> - - - - - - - - - - - - - - - - - - - - - - - {() => ( - - )} - - - {(tree, onChange) => ( - - )} - - - {(tree) => } - - - {(tree) => } - - - - - - - - - - ) -} - -ReactDOM.render(, document.getElementById('root')) diff --git a/designable/antd/playground/service/index.ts b/designable/antd/playground/service/index.ts deleted file mode 100644 index cb7cdd48bd0..00000000000 --- a/designable/antd/playground/service/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './schema' diff --git a/designable/antd/playground/service/schema.ts b/designable/antd/playground/service/schema.ts deleted file mode 100644 index 1c7b2c63996..00000000000 --- a/designable/antd/playground/service/schema.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Engine } from '@designable/core' -import { transformToSchema, transformToTreeNode } from '@designable/formily' -import { message } from 'antd' - -export const saveSchema = (designer: Engine) => { - localStorage.setItem( - 'formily-schema', - JSON.stringify( - transformToSchema(designer.getCurrentTree(), { - designableFieldName: 'DesignableField', - designableFormName: 'Root', - }) - ) - ) - message.success('Save Success') -} - -export const loadInitialSchema = (designer: Engine) => { - try { - designer.setCurrentTree( - transformToTreeNode(JSON.parse(localStorage.getItem('formily-schema')), { - designableFieldName: 'DesignableField', - designableFormName: 'Root', - }) - ) - } catch {} -} diff --git a/designable/antd/playground/template.ejs b/designable/antd/playground/template.ejs deleted file mode 100644 index 4ea62ab0bcd..00000000000 --- a/designable/antd/playground/template.ejs +++ /dev/null @@ -1,21 +0,0 @@ - - - - - Designable Playground - - - - -
-
- - - - - \ No newline at end of file diff --git a/designable/antd/playground/webpack.base.ts b/designable/antd/playground/webpack.base.ts deleted file mode 100644 index 1fe60d689fb..00000000000 --- a/designable/antd/playground/webpack.base.ts +++ /dev/null @@ -1,104 +0,0 @@ -import path from 'path' -import fs from 'fs-extra' -import { GlobSync } from 'glob' -import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import autoprefixer from 'autoprefixer' -//import { getThemeVariables } from 'antd/dist/theme' - -const getWorkspaceAlias = () => { - const basePath = path.resolve(__dirname, '../../../') - const pkg = fs.readJSONSync(path.resolve(basePath, 'package.json')) || {} - const results = {} - const workspaces = pkg.workspaces - if (Array.isArray(workspaces)) { - workspaces.forEach((pattern) => { - const { found } = new GlobSync(pattern, { cwd: basePath }) - found.forEach((name) => { - const pkg = fs.readJSONSync( - path.resolve(basePath, name, './package.json') - ) - results[pkg.name] = path.resolve(basePath, name, './src') - }) - }) - } - return results -} - -export default { - mode: 'development', - devtool: 'inline-source-map', // 嵌入到源文件中 - stats: { - entrypoints: false, - children: false, - }, - entry: { - playground: path.resolve(__dirname, './main'), - }, - output: { - path: path.resolve(__dirname, '../build'), - filename: '[name].[hash].bundle.js', - }, - resolve: { - modules: ['node_modules'], - extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'], - alias: getWorkspaceAlias(), - }, - externals: { - react: 'React', - 'react-dom': 'ReactDOM', - moment: 'moment', - antd: 'antd', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: [ - { - loader: require.resolve('ts-loader'), - options: { - transpileOnly: true, - }, - }, - ], - }, - { - test: /\.css$/, - use: [MiniCssExtractPlugin.loader, require.resolve('css-loader')], - }, - { - test: /\.less$/, - use: [ - MiniCssExtractPlugin.loader, - { loader: 'css-loader' }, - { - loader: 'postcss-loader', - options: { - plugins: () => autoprefixer(), - }, - }, - { - loader: 'less-loader', - options: { - // modifyVars: getThemeVariables({ - // dark: true, // 开启暗黑模式 - // }), - javascriptEnabled: true, - }, - }, - ], - }, - { - test: /\.(woff|woff2|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, - use: ['url-loader'], - }, - { - test: /\.html?$/, - loader: require.resolve('file-loader'), - options: { - name: '[name].[ext]', - }, - }, - ], - }, -} diff --git a/designable/antd/playground/webpack.dev.ts b/designable/antd/playground/webpack.dev.ts deleted file mode 100644 index 710c0570dae..00000000000 --- a/designable/antd/playground/webpack.dev.ts +++ /dev/null @@ -1,56 +0,0 @@ -import baseConfig from './webpack.base' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import MonacoPlugin from 'monaco-editor-webpack-plugin' -//import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' -import webpack from 'webpack' -import path from 'path' - -const PORT = 3000 - -const createPages = (pages) => { - return pages.map(({ filename, template, chunk }) => { - return new HtmlWebpackPlugin({ - filename, - template, - inject: 'body', - chunks: chunk, - }) - }) -} - -for (const key in baseConfig.entry) { - if (Array.isArray(baseConfig.entry[key])) { - baseConfig.entry[key].push( - require.resolve('webpack/hot/dev-server'), - `${require.resolve('webpack-dev-server/client')}?http://localhost:${PORT}` - ) - } -} - -export default { - ...baseConfig, - plugins: [ - new MiniCssExtractPlugin({ - filename: '[name].[hash].css', - chunkFilename: '[id].[hash].css', - }), - ...createPages([ - { - filename: 'index.html', - template: path.resolve(__dirname, './template.ejs'), - chunk: ['playground'], - }, - ]), - new webpack.HotModuleReplacementPlugin(), - new MonacoPlugin({ - languages: ['json'], - }), - // new BundleAnalyzerPlugin() - ], - devServer: { - host: '127.0.0.1', - open: true, - port: PORT, - }, -} diff --git a/designable/antd/playground/webpack.prod.ts b/designable/antd/playground/webpack.prod.ts deleted file mode 100644 index 520f909e4f0..00000000000 --- a/designable/antd/playground/webpack.prod.ts +++ /dev/null @@ -1,40 +0,0 @@ -import baseConfig from './webpack.base' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import MonacoPlugin from 'monaco-editor-webpack-plugin' -import path from 'path' - -const createPages = (pages) => { - return pages.map(({ filename, template, chunk }) => { - return new HtmlWebpackPlugin({ - filename, - template, - inject: 'body', - chunks: chunk, - }) - }) -} - -export default { - ...baseConfig, - mode: 'production', - plugins: [ - new MiniCssExtractPlugin({ - filename: '[name].[hash].css', - chunkFilename: '[id].[hash].css', - }), - ...createPages([ - { - filename: 'index.html', - template: path.resolve(__dirname, './template.ejs'), - chunk: ['playground'], - }, - ]), - new MonacoPlugin({ - languages: ['json'], - }), - ], - optimization: { - minimize: true, - }, -} diff --git a/designable/antd/playground/widgets/ActionsWidget.tsx b/designable/antd/playground/widgets/ActionsWidget.tsx deleted file mode 100644 index e9cc15e1341..00000000000 --- a/designable/antd/playground/widgets/ActionsWidget.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React, { useEffect } from 'react' -import { Space, Button, Radio } from 'antd' -import { GithubOutlined } from '@ant-design/icons' -import { useDesigner, TextWidget } from '@designable/react' -import { GlobalRegistry } from '@designable/core' -import { observer } from '@formily/react' -import { loadInitialSchema, saveSchema } from '../service' - -export const ActionsWidget = observer(() => { - const designer = useDesigner() - useEffect(() => { - loadInitialSchema(designer) - }, []) - return ( - - - { - GlobalRegistry.setDesignerLanguage(e.target.value) - }} - /> - - - - - ) -}) diff --git a/designable/antd/playground/widgets/LogoWidget.tsx b/designable/antd/playground/widgets/LogoWidget.tsx deleted file mode 100644 index a6b86de416c..00000000000 --- a/designable/antd/playground/widgets/LogoWidget.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import { useTheme } from '@designable/react' - -const logo = { - dark: '//img.alicdn.com/imgextra/i2/O1CN01NTUDi81fHLQvZCPnc_!!6000000003981-55-tps-1141-150.svg', - light: - '//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg', -} - -export const LogoWidget: React.FC = () => { - const url = logo[useTheme()] - return ( -
- -
- ) -} diff --git a/designable/antd/playground/widgets/MarkupSchemaWidget.tsx b/designable/antd/playground/widgets/MarkupSchemaWidget.tsx deleted file mode 100644 index 0331628d258..00000000000 --- a/designable/antd/playground/widgets/MarkupSchemaWidget.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import React from 'react' -import { TreeNode } from '@designable/core' -import { MonacoInput } from '@designable/react-settings-form' -import { isEmpty, isPlainObj } from '@formily/shared' - -export interface IMarkupSchemaWidgetProps { - tree: TreeNode -} - -const transformToMarkupSchemaCode = (tree: TreeNode) => { - const printAttribute = (node: TreeNode) => { - if (!node) return '' - return `${Object.keys(node.props || {}) - .map((key) => { - if ( - key === '_designableId' || - key === '_isJSONSchemaObject' || - key === 'version' || - key === 'type' - ) - return '' - const value = node.props[key] - if (isPlainObj(value) && isEmpty(value)) return '' - if (typeof value === 'string') return `${key}="${value}"` - return `${key}={${JSON.stringify(value)}}` - }) - .join(' ')}` - } - const printChildren = (node: TreeNode) => { - if (!node) return '' - return node.children - .map((child) => { - return printNode(child) - }) - .join('') - } - const printTag = (node: TreeNode) => { - if (node.props.type === 'string') return 'SchemaField.String' - if (node.props.type === 'number') return 'SchemaField.Number' - if (node.props.type === 'boolean') return 'SchemaField.Boolean' - if (node.props.type === 'date') return 'SchemaField.Date' - if (node.props.type === 'datetime') return 'SchemaField.DateTime' - if (node.props.type === 'array') return 'SchemaField.Array' - if (node.props.type === 'object') return 'SchemaField.Object' - if (node.props.type === 'void') return 'SchemaField.Void' - return 'SchemaField.Markup' - } - const printNode = (node: TreeNode) => { - if (!node) return '' - return `<${printTag(node)} ${printAttribute(node)} ${ - node.children.length - ? `>${printChildren(node)}` - : '/>' - }` - } - const root = tree.find((child) => { - return child.componentName === 'Root' - }) - return `import React, { useMemo } from 'react' -import { createForm } from '@formily/core' -import { createSchemaField } from '@formily/react' -import { - Form, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Space, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, -} from '@formily/antd' -import { Card, Slider, Rate } from 'antd' - -const Text: React.FC<{ - content?: string - mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p' -}> = ({ mode, content, ...props }) => { - const tagName = mode === 'normal' || !mode ? 'div' : mode - return React.createElement(tagName, props, content) -} - -const SchemaField = createSchemaField({ - components: { - Space, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - Text, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - Card, - Slider, - Rate, - }, -}) - -export default ()=>{ - const form = useMemo(()=>createForm(),[]) - - return
- - ${printChildren(root)} - -
-} - -` -} - -export const MarkupSchemaWidget: React.FC = ( - props -) => { - return ( - - ) -} diff --git a/designable/antd/playground/widgets/PreviewWidget.tsx b/designable/antd/playground/widgets/PreviewWidget.tsx deleted file mode 100644 index 763be4ae44c..00000000000 --- a/designable/antd/playground/widgets/PreviewWidget.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import React, { useMemo } from 'react' -import { createForm } from '@formily/core' -import { createSchemaField } from '@formily/react' -import { - Form, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Space, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, -} from '@formily/antd' -import { Card, Slider, Rate } from 'antd' -import { TreeNode } from '@designable/core' -import { transformToSchema } from '@designable/formily' - -const Text: React.FC<{ - content?: string - mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p' -}> = ({ mode, content, ...props }) => { - const tagName = mode === 'normal' || !mode ? 'div' : mode - return React.createElement(tagName, props, content) -} - -const SchemaField = createSchemaField({ - components: { - Space, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - Text, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - Card, - Slider, - Rate, - }, -}) - -export interface IPreviewWidgetProps { - tree: TreeNode -} - -export const PreviewWidget: React.FC = (props) => { - const form = useMemo(() => createForm(), []) - const { form: formProps, schema } = transformToSchema(props.tree, { - designableFormName: 'Root', - designableFieldName: 'DesignableField', - }) - return ( -
- - - ) -} diff --git a/designable/antd/playground/widgets/SchemaEditorWidget.tsx b/designable/antd/playground/widgets/SchemaEditorWidget.tsx deleted file mode 100644 index 805703bd94d..00000000000 --- a/designable/antd/playground/widgets/SchemaEditorWidget.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react' -import { transformToSchema, transformToTreeNode } from '@designable/formily' -import { TreeNode, ITreeNode } from '@designable/core' -import { MonacoInput } from '@designable/react-settings-form' - -export interface ISchemaEditorWidgetProps { - tree: TreeNode - onChange?: (tree: ITreeNode) => void -} - -const Parser = { - designableFormName: 'Root', - designableFieldName: 'DesignableField', -} - -export const SchemaEditorWidget: React.FC = ( - props -) => { - return ( - { - props.onChange?.(transformToTreeNode(JSON.parse(value), Parser)) - }} - language="json" - /> - ) -} diff --git a/designable/antd/playground/widgets/index.ts b/designable/antd/playground/widgets/index.ts deleted file mode 100644 index 1ca916232fc..00000000000 --- a/designable/antd/playground/widgets/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './LogoWidget' -export * from './ActionsWidget' -export * from './PreviewWidget' -export * from './SchemaEditorWidget' -export * from './MarkupSchemaWidget' diff --git a/designable/antd/rollup.config.js b/designable/antd/rollup.config.js deleted file mode 100644 index 859c8d570c1..00000000000 --- a/designable/antd/rollup.config.js +++ /dev/null @@ -1,24 +0,0 @@ -import baseConfig, { - removeImportStyleFromInputFilePlugin, -} from '../../scripts/rollup.base.js' -import postcss from 'rollup-plugin-postcss' -import NpmImport from 'less-plugin-npm-import' - -export default baseConfig( - 'formily.designable.antd', - 'Formily.Designable.Antd', - removeImportStyleFromInputFilePlugin(), - postcss({ - extract: true, - minimize: true, - // extensions: ['.css', '.less', '.sass'], - use: { - less: { - plugins: [new NpmImport({ prefix: '~' })], - javascriptEnabled: true, - }, - sass: {}, - stylus: {}, - }, - }) -) diff --git a/designable/antd/src/components/DesignableArrayCards/index.tsx b/designable/antd/src/components/DesignableArrayCards/index.tsx deleted file mode 100644 index dc7ab12a71b..00000000000 --- a/designable/antd/src/components/DesignableArrayCards/index.tsx +++ /dev/null @@ -1,243 +0,0 @@ -import React, { Fragment } from 'react' -import { Card, CardProps } from 'antd' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { useTreeNode, TreeNodeWidget, useNodeIdProps } from '@designable/react' -import { ArrayBase } from '@formily/antd' -import { observer } from '@formily/react' -import { LoadTemplate } from '../LoadTemplate' -import cls from 'classnames' -import { useDropTemplate } from '../../hooks' -import { - hasNodeByComponentPath, - queryNodesByComponentPath, - createEnsureTypeItemsNode, - findNodeByComponentPath, - createNodeId, -} from '../../shared' -import './styles.less' - -const ensureVoidItemsNode = createEnsureTypeItemsNode('void') - -const isArrayCardsOperation = (name: string) => - name === 'ArrayCards.Remove' || - name === 'ArrayCards.MoveDown' || - name === 'ArrayCards.MoveUp' - -export const DesignableArrayCards: React.FC = observer((props) => { - const node = useTreeNode() - const nodeId = useNodeIdProps() - const designer = useDropTemplate('ArrayCards', (source) => { - const indexNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.Index', - }, - }) - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.Addition', - }, - }) - const removeNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.Remove', - }, - }) - const moveDownNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.MoveDown', - }, - }) - const moveUpNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.MoveUp', - }, - }) - - const voidNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - }, - children: [indexNode, ...source, removeNode, moveDownNode, moveUpNode], - }) - return [voidNode, additionNode] - }) - const renderCard = () => { - if (node.children.length === 0) return - const additions = queryNodesByComponentPath(node, [ - 'ArrayCards', - 'ArrayCards.Addition', - ]) - const indexes = queryNodesByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.Index', - ]) - const operations = queryNodesByComponentPath(node, [ - 'ArrayCards', - '*', - isArrayCardsOperation, - ]) - const children = queryNodesByComponentPath(node, [ - 'ArrayCards', - '*', - (name) => name.indexOf('ArrayCards.') === -1, - ]) - return ( - - - - {indexes.map((node, key) => ( - - ))} - {props.title} - - } - className={cls('ant-formily-array-cards-item', props.className)} - extra={ - - {operations.map((node) => ( - - ))} - {props.extra} - - } - > -
- {children.length ? ( - children.map((node) => ( - - )) - ) : ( - - )} -
-
-
- {additions.map((node) => ( - - ))} -
- ) - } - - return ( -
- {renderCard()} - { - if ( - hasNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.Index', - ]) - ) - return - const indexNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.Index', - }, - }) - ensureVoidItemsNode(node).append(indexNode) - }, - }, - - { - title: 'Common.addOperation', - onClick: () => { - const oldAdditionNode = findNodeByComponentPath(node, [ - 'ArrayCards', - 'ArrayCards.Addition', - ]) - if (!oldAdditionNode) { - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.Addition', - }, - }) - ensureVoidItemsNode(node).insertAfter(additionNode) - } - const oldRemoveNode = findNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.Remove', - ]) - const oldMoveDownNode = findNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.MoveDown', - ]) - const oldMoveUpNode = findNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.MoveUp', - ]) - if (!oldRemoveNode) { - ensureVoidItemsNode(node).append( - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.Remove', - }, - }) - ) - } - if (!oldMoveDownNode) { - ensureVoidItemsNode(node).append( - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.MoveDown', - }, - }) - ) - } - if (!oldMoveUpNode) { - ensureVoidItemsNode(node).append( - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.MoveUp', - }, - }) - ) - } - }, - }, - ]} - /> -
- ) -}) - -ArrayBase.mixin(DesignableArrayCards) diff --git a/designable/antd/src/components/DesignableArrayCards/styles.less b/designable/antd/src/components/DesignableArrayCards/styles.less deleted file mode 100644 index 67e6789cd21..00000000000 --- a/designable/antd/src/components/DesignableArrayCards/styles.less +++ /dev/null @@ -1,5 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-array-cards { - background-color: @background-color-light; -} diff --git a/designable/antd/src/components/DesignableArrayCollapse/index.tsx b/designable/antd/src/components/DesignableArrayCollapse/index.tsx deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/designable/antd/src/components/DesignableArrayItems/index.tsx b/designable/antd/src/components/DesignableArrayItems/index.tsx deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/designable/antd/src/components/DesignableArrayTable/index.tsx b/designable/antd/src/components/DesignableArrayTable/index.tsx deleted file mode 100644 index 78fd2b447e6..00000000000 --- a/designable/antd/src/components/DesignableArrayTable/index.tsx +++ /dev/null @@ -1,412 +0,0 @@ -import React from 'react' -import { Table, TableProps } from 'antd' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { useTreeNode, TreeNodeWidget, useNodeIdProps } from '@designable/react' -import { ArrayBase } from '@formily/antd' -import { observer } from '@formily/react' -import { LoadTemplate } from '../LoadTemplate' -import cls from 'classnames' -import { - createNodeId, - queryNodesByComponentPath, - hasNodeByComponentPath, - findNodeByComponentPath, - createEnsureTypeItemsNode, -} from '../../shared' -import { useDropTemplate } from '../../hooks' -import './styles.less' - -const ensureObjectItemsNode = createEnsureTypeItemsNode('object') - -export const DesignableArrayTable: React.FC> = observer( - (props) => { - const node = useTreeNode() - const nodeId = useNodeIdProps() - const designer = useDropTemplate('ArrayTable', (source) => { - const sortHandleNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.SortHandle', - }, - }, - ], - }) - const indexNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Index', - }, - }, - ], - }) - const columnNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: source.map((node) => { - node.props.title = undefined - return node - }), - }) - - const operationNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Remove', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveDown', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveUp', - }, - }, - ], - }) - const objectNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'object', - }, - children: [sortHandleNode, indexNode, columnNode, operationNode], - }) - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayTable.Addition', - }, - }) - return [objectNode, additionNode] - }) - const columns = queryNodesByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - ]) - const additions = queryNodesByComponentPath(node, [ - 'ArrayTable', - 'ArrayTable.Addition', - ]) - const defaultRowKey = () => { - return node.id - } - const createColumnId = (props: any) => { - return createNodeId( - designer, - props.className.match(/data-id\:([^\s]+)/)?.[1] - ) - } - - const renderTable = () => { - if (node.children.length === 0) return - return ( - - { - return ( - - ) - }, - }, - body: { - cell: (props: any) => { - return ( - - ) - }, - }, - }} - > - {columns.map((node, key) => { - const children = node.children.map((child) => { - return - }) - return ( - { - return ( - - {children.length > 0 ? children : 'Droppable'} - - ) - }} - /> - ) - })} - {columns.length === 0 && ( - } /> - )} -
- {props.children} - - {props.children} -
- {additions.map((child) => { - return - })} -
- ) - } - - useDropTemplate('ArrayTable.Column', (source) => { - return source.map((node) => { - node.props.title = undefined - return node - }) - }) - - return ( -
- {renderTable()} - { - if ( - hasNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - 'ArrayTable.SortHandle', - ]) - ) - return - const tableColumn = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.SortHandle', - }, - }, - ], - }) - ensureObjectItemsNode(node).prepend(tableColumn) - }, - }, - { - title: 'Common.addIndex', - onClick: () => { - if ( - hasNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - 'ArrayTable.Index', - ]) - ) - return - const tableColumn = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Index', - }, - }, - ], - }) - const sortNode = findNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - 'ArrayTable.SortHandle', - ]) - if (sortNode) { - sortNode.parent.insertAfter(tableColumn) - } else { - ensureObjectItemsNode(node).prepend(tableColumn) - } - }, - }, - { - title: 'Common.addTableColumn', - onClick: () => { - const operationNode = findNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - (name) => { - return ( - name === 'ArrayTable.Remove' || - name === 'ArrayTable.MoveDown' || - name === 'ArrayTable.MoveUp' - ) - }, - ]) - const tableColumn = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - }) - if (operationNode) { - operationNode.parent.insertBefore(tableColumn) - } else { - ensureObjectItemsNode(node).append(tableColumn) - } - }, - }, - { - title: 'Common.addOperation', - onClick: () => { - const oldOperationNode = findNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - (name) => { - return ( - name === 'ArrayTable.Remove' || - name === 'ArrayTable.MoveDown' || - name === 'ArrayTable.MoveUp' - ) - }, - ]) - const oldAdditionNode = findNodeByComponentPath(node, [ - 'ArrayTable', - 'ArrayTable.Addition', - ]) - if (!oldOperationNode) { - const operationNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Remove', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveDown', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveUp', - }, - }, - ], - }) - ensureObjectItemsNode(node).append(operationNode) - } - if (!oldAdditionNode) { - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayTable.Addition', - }, - }) - ensureObjectItemsNode(node).insertAfter(additionNode) - } - }, - }, - ]} - /> -
- ) - } -) - -ArrayBase.mixin(DesignableArrayTable) diff --git a/designable/antd/src/components/DesignableArrayTable/styles.less b/designable/antd/src/components/DesignableArrayTable/styles.less deleted file mode 100644 index a45490e2904..00000000000 --- a/designable/antd/src/components/DesignableArrayTable/styles.less +++ /dev/null @@ -1,5 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-array-table { - background-color: @background-color-light; -} diff --git a/designable/antd/src/components/DesignableArrayTabs/index.tsx b/designable/antd/src/components/DesignableArrayTabs/index.tsx deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/designable/antd/src/components/DesignableContainer/index.tsx b/designable/antd/src/components/DesignableContainer/index.tsx deleted file mode 100644 index a892319c8c7..00000000000 --- a/designable/antd/src/components/DesignableContainer/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import { useNodeIdProps } from '@designable/react' -import { Droppable } from '../Droppable' -import './styles.less' - -export const createDesignableContainer = ( - Target: React.JSXElementConstructor -) => { - return (props: any) => { - const nodeId = useNodeIdProps() - if (props.children) { - return ( -
- {props.children} -
- ) - } - return - } -} diff --git a/designable/antd/src/components/DesignableContainer/styles.less b/designable/antd/src/components/DesignableContainer/styles.less deleted file mode 100644 index e0f5c30388e..00000000000 --- a/designable/antd/src/components/DesignableContainer/styles.less +++ /dev/null @@ -1,7 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-form-container { - margin: 0 !important; - padding: 20px; - border: 1px solid @border-color-split; -} diff --git a/designable/antd/src/components/DesignableField/index.tsx b/designable/antd/src/components/DesignableField/index.tsx deleted file mode 100644 index dd078bee123..00000000000 --- a/designable/antd/src/components/DesignableField/index.tsx +++ /dev/null @@ -1,438 +0,0 @@ -import React from 'react' -import { FormPath } from '@formily/core' -import { GlobalRegistry, TreeNode } from '@designable/core' -import { useDesigner, useTreeNode } from '@designable/react' -import { - ArrayField, - Field, - ObjectField, - VoidField, - observer, - Schema, - ISchema, -} from '@formily/react' -import { - DataSourceSetter, - ReactionsSetter, - ValidatorSetter, -} from '@formily/designable-setters' -import { FormTab, FormItem } from '@formily/antd' -import { isArr, isStr, each, reduce } from '@formily/shared' -import { FormItemSwitcher } from '../FormItemSwitcher' -import { DesignableObject } from '../DesignableObject' -import { createOptions } from './options' -import { IDesignableFieldFactoryProps } from './types' -import { includesComponent } from '../../shared' -import * as defaultSchemas from '../../schemas' - -Schema.silent() - -const SchemaStateMap = { - title: 'title', - description: 'description', - default: 'value', - enum: 'dataSource', - readOnly: 'readOnly', - writeOnly: 'editable', - required: 'required', - 'x-content': 'content', - 'x-value': 'value', - 'x-editable': 'editable', - 'x-disabled': 'disabled', - 'x-read-pretty': 'readPretty', - 'x-read-only': 'readOnly', - 'x-visible': 'visible', - 'x-hidden': 'hidden', - 'x-display': 'display', - 'x-pattern': 'pattern', -} - -const NeedShownExpression = { - title: true, - description: true, - default: true, - 'x-content': true, - 'x-value': true, -} - -const isExpression = (val: any) => isStr(val) && /^\{\{.*\}\}$/.test(val) - -const filterExpression = (val: any) => { - if (typeof val === 'object') { - const isArray = isArr(val) - const results = reduce( - val, - (buf: any, value, key) => { - if (isExpression(value)) { - return buf - } else { - const results = filterExpression(value) - if (results === undefined || results === null) return buf - if (isArray) { - return buf.concat([results]) - } - buf[key] = results - return buf - } - }, - isArray ? [] : {} - ) - return results - } - if (isExpression(val)) { - return - } - return val -} - -const toDesignableFieldProps = ( - schema: ISchema, - components: any, - nodeIdAttrName: string, - id: string -) => { - const results: any = {} - each(SchemaStateMap, (fieldKey, schemaKey) => { - const value = schema[schemaKey] - if (isExpression(value)) { - if (!NeedShownExpression[schemaKey]) return - if (value) { - results[fieldKey] = value - return - } - } else if (value) { - results[fieldKey] = filterExpression(value) - } - }) - if (!components['FormItem']) { - components['FormItem'] = FormItem - } - const decorator = - schema['x-decorator'] && FormPath.getIn(components, schema['x-decorator']) - const component = - schema['x-component'] && FormPath.getIn(components, schema['x-component']) - const decoratorProps = schema['x-decorator-props'] || {} - const componentProps = schema['x-component-props'] || {} - - if (decorator) { - results.decorator = [decorator, { ...decoratorProps }] - } - if (component) { - results.component = [component, { ...componentProps }] - } - if (decorator) { - FormPath.setIn(results['decorator'][1], nodeIdAttrName, id) - } else if (component) { - FormPath.setIn(results['component'][1], nodeIdAttrName, id) - } - results.title = results.title && ( - {results.title} - ) - results.description = results.description && ( - {results.description} - ) - return results -} - -export const createDesignableField = ( - options: IDesignableFieldFactoryProps -) => { - const realOptions = createOptions(options) - - const tabs = {} - - const getFieldPropsSchema = (node: TreeNode): ISchema => { - const decorator = node.props['x-decorator'] - const component = node.props['x-component'] - const decoratorSchema = - decorator && - (FormPath.getIn(realOptions.componentsPropsSchema, decorator) || - FormPath.getIn(defaultSchemas, decorator)) - const componentSchema = - component && - (FormPath.getIn(realOptions.componentsPropsSchema, component) || - FormPath.getIn(defaultSchemas, component)) - const TabSchema = (key: string, schema: ISchema) => { - tabs[key] = tabs[key] || FormTab.createFormTab() - return { - type: 'object', - properties: { - propsTab: { - type: 'void', - 'x-component': 'FormTab', - 'x-component-props': { - formTab: tabs[key], - style: { - overflow: 'visible', - }, - }, - properties: { - propsPane: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - tab: GlobalRegistry.getDesignerMessage( - `settings.${key}.tab_property` - ), - }, - properties: schema.properties, - }, - stylePane: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - tab: GlobalRegistry.getDesignerMessage( - `settings.${key}.tab_style` - ), - }, - properties: { - style: defaultSchemas.CSSStyle, - }, - }, - }, - }, - }, - } - } - const base = { - type: 'object', - properties: { - name: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - defaultValue: node.id, - }, - 'x-index': 0, - }, - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-index': 1, - }, - description: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - 'x-index': 2, - }, - 'x-display': { - type: 'string', - enum: ['visible', 'hidden', 'none', ''], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'visible', - }, - 'x-index': 3, - }, - 'x-pattern': { - type: 'string', - enum: ['editable', 'disabled', 'readOnly', 'readPretty', ''], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'editable', - }, - 'x-index': 4, - }, - 'x-component-props': - componentSchema && TabSchema('x-component-props', componentSchema), - 'x-decorator-props': - decoratorSchema && TabSchema('x-decorator-props', decoratorSchema), - }, - } - - if (node.props.type === 'void') { - if (!includesComponent(node, realOptions.dropReactionComponents)) { - Object.assign(base.properties, { - 'x-reactions': { - 'x-decorator': 'FormItem', - 'x-index': 5, - 'x-component': ReactionsSetter, - }, - }) - } - if (!includesComponent(node, realOptions.dropFormItemComponents)) { - Object.assign(base.properties, { - 'x-decorator': { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': FormItemSwitcher, - 'x-index': 10, - 'x-reactions': { - target: '*(title,description)', - fulfill: { - state: { - hidden: '{{$self.value !== "FormItem"}}', - }, - }, - }, - }, - }) - } else { - delete base.properties.title - delete base.properties.description - } - } else { - if (!includesComponent(node, realOptions.dropReactionComponents)) { - Object.assign(base.properties, { - 'x-reactions': { - 'x-decorator': 'FormItem', - 'x-index': 7, - 'x-component': ReactionsSetter, - }, - }) - } - Object.assign(base.properties, { - default: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-index': 5, - }, - enum: { - 'x-decorator': 'FormItem', - 'x-component': DataSourceSetter, - 'x-index': 6, - }, - 'x-validator': { - type: 'array', - 'x-component': ValidatorSetter, - 'x-index': 8, - }, - required: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-index': 9, - }, - }) - } - - base['$namespace'] = `namespace.${component}` - - return base - } - - const calculateChildrenRestricts = (target: TreeNode, source: TreeNode[]) => { - const targetComponent = target.props['x-component'] - const restrictChildrenComponents = - realOptions.restrictChildrenComponents?.[targetComponent] - if (restrictChildrenComponents?.length) { - if ( - source.every((node) => - includesComponent(node, restrictChildrenComponents, target) - ) - ) { - return true - } - return false - } - return true - } - - const calculateSiblingsRestricts = (target: TreeNode, source: TreeNode[]) => { - const targetComponent = target.props['x-component'] - const restrictSiblingComponents = - realOptions.restrictSiblingComponents?.[targetComponent] - if (restrictSiblingComponents?.length) { - if ( - source.every((node) => - includesComponent(node, restrictSiblingComponents, target) - ) - ) { - return true - } - return false - } - return true - } - - if (!realOptions.registryName) throw new Error('Can not found registryName') - - GlobalRegistry.registerDesignerProps({ - [realOptions.registryName]: (node) => { - const componentName = node.props?.['x-component'] - const message = GlobalRegistry.getDesignerMessage( - `components.${componentName}` - ) - const isObjectNode = node.props.type === 'object' - const isArrayNode = node.props.type === 'array' - const isVoidNode = node.props.type === 'void' - const title = typeof message === 'string' ? message : message?.title - const nodeTitle = - title || - (isObjectNode - ? GlobalRegistry.getDesignerMessage('components.Object') - : isVoidNode - ? GlobalRegistry.getDesignerMessage('components.Void') - : '') - const sourceIcon = realOptions.componentsSourceIcon?.[componentName] - return { - title: nodeTitle, - sourceIcon: isObjectNode ? 'ObjectSource' : sourceIcon, - icon: realOptions.componentsIcon?.[componentName], - draggable: true, - droppable: isObjectNode || isArrayNode || isVoidNode, - selfRenderChildren: - isArrayNode || - includesComponent(node, realOptions.selfRenderChildrenComponents), - inlineLayout: includesComponent( - node, - realOptions.inlineLayoutComponents - ), - inlineChildrenLayout: includesComponent( - node, - realOptions.inlineChildrenLayoutComponents - ), - allowSiblings(target, source) { - return calculateSiblingsRestricts(target, source) - }, - allowAppend(target, source) { - return ( - (target.props.type === 'void' || - target.props.type === 'array' || - target.props.type === 'object') && - calculateChildrenRestricts(target, source) - ) - }, - propsSchema: getFieldPropsSchema(node), - } - }, - }) - - const DesignableField: React.FC = observer((props) => { - const designer = useDesigner() - const node = useTreeNode() - if (!node) return null - - const fieldProps = toDesignableFieldProps( - props, - realOptions.components, - designer.props.nodeIdAttrName, - node.id - ) - if (props.type === 'object') { - return ( - - - {props.children} - - - ) - } else if (props.type === 'array') { - return - } else if (node.props.type === 'void') { - return ( - - {props.children} - - ) - } - return - }) - - return DesignableField -} diff --git a/designable/antd/src/components/DesignableField/options.ts b/designable/antd/src/components/DesignableField/options.ts deleted file mode 100644 index 7cbf0ed07c4..00000000000 --- a/designable/antd/src/components/DesignableField/options.ts +++ /dev/null @@ -1,186 +0,0 @@ -import { IDesignableFieldFactoryProps } from './types' -import { - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Space, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - FormGrid, - FormLayout, -} from '@formily/antd' -import { Card, Slider, Rate } from 'antd' -import { createDesignableContainer } from '../DesignableContainer' -import { DesignableFormTab } from '../DesignableFormTab' -import { DesignableFormCollapse } from '../DesignableFormCollapse' -import { DesignableArrayTable } from '../DesignableArrayTable' -import { DesignableArrayCards } from '../DesignableArrayCards' -import { DesignableText } from '../DesignableText' -import { TreeNode } from '@designable/core' - -const isChildrenComponents = - (parentName: string, names?: string[]) => (name: string) => - Array.isArray(names) && names.length > 0 - ? names.some((key) => { - return `${parentName}.${key}` === name - }) - : name.indexOf(`${parentName}.`) > -1 - -const InlineArrayChildren = [ - 'Column', - 'Index', - 'SortHandle', - 'Remove', - 'MoveDown', - 'MoveUp', -] - -const isFormTabChildren = isChildrenComponents('FormTab') -const isFormCollapseChildren = isChildrenComponents('FormCollapse') -const isArrayTableInlineChildren = isChildrenComponents( - 'ArrayTable', - InlineArrayChildren -) -const isArrayCardsInlineChildren = isChildrenComponents( - 'ArrayCards', - InlineArrayChildren -) -const isObjectNode = (name: string, node: TreeNode) => { - return node.props['type'] === 'object' -} - -const isNotArrayColumn = (name: string, node: TreeNode) => { - return node.props['x-component'] !== 'ArrayTable.Column' -} - -const allowDropWithEmpty = (name: string, node: TreeNode, target: TreeNode) => { - if (target) return target.children.length === 0 - return false -} - -const noChildren = () => false - -export const createOptions = ( - options: IDesignableFieldFactoryProps -): IDesignableFieldFactoryProps => { - return { - ...options, - dropFormItemComponents: [ - ...(options.dropFormItemComponents || []), - isFormTabChildren, - isFormCollapseChildren, - ], - dropReactionComponents: [ - ...(options.dropReactionComponents || []), - isFormTabChildren, - isFormCollapseChildren, - ], - selfRenderChildrenComponents: [ - ...(options.selfRenderChildrenComponents || []), - 'FormTab', - 'FormCollapse', - ], - inlineChildrenLayoutComponents: [ - ...(options.inlineChildrenLayoutComponents || []), - 'FormItem', - 'FormGrid', - 'Space', - ], - inlineLayoutComponents: [ - ...(options.inlineLayoutComponents || []), - isArrayTableInlineChildren, - isArrayCardsInlineChildren, - ], - restrictChildrenComponents: { - FormTab: [allowDropWithEmpty, 'FormTab.TabPane'], - FormCollapse: [allowDropWithEmpty, 'FormCollapse.CollapsePanel'], - ArrayTable: [allowDropWithEmpty, isObjectNode, 'ArrayTable.Addition'], - 'ArrayTable.Column': [isNotArrayColumn], - Text: [noChildren], - }, - restrictSiblingComponents: { - 'FormTab.TabPane': ['FormTab.TabPane'], - 'FormCollapse.CollapsePanel': ['FormCollapse.CollapsePanel'], - 'ArrayTable.Column': ['ArrayTable.Column'], - }, - componentsSourceIcon: { - ...options.componentsSourceIcon, - Space: 'SpaceSource', - FormGrid: 'GridSource', - FormTab: 'TabSource', - FormCollapse: 'CollapseSource', - ArrayTable: 'ArrayTableSource', - ArrayCards: 'ArrayCardsSource', - DatePicker: 'DatePickerSource', - 'DatePicker.RangePicker': 'DateRangePickerSource', - 'Checkbox.Group': 'CheckboxGroupSource', - 'Radio.Group': 'RadioGroupSource', - Slider: 'SliderSource', - Rate: 'RateSource', - TimePicker: 'TimePickerSource', - 'TimePicker.RangePicker': 'TimeRangePickerSource', - Cascader: 'CascaderSource', - TreeSelect: 'TreeSelectSource', - Select: 'SelectSource', - 'Input.TextArea': 'TextAreaSource', - Input: 'InputSource', - NumberPicker: 'NumberPickerSource', - Password: 'PasswordSource', - Transfer: 'TransferSource', - Switch: 'SwitchSource', - Upload: 'UploadSource', - 'Upload.Dragger': 'UploadDraggerSource', - Card: 'CardSource', - FormLayout: 'FormLayoutSource', - Text: 'TextSource', - Image: 'ImageSource', - Button: 'ButtonSource', - Video: 'MediaSource', - }, - components: { - ...options.components, - Space: createDesignableContainer(Space), - FormGrid: createDesignableContainer(FormGrid), - FormLayout: createDesignableContainer(FormLayout), - FormTab: DesignableFormTab, - FormCollapse: DesignableFormCollapse, - ArrayTable: DesignableArrayTable, - ArrayCards: DesignableArrayCards, - Text: DesignableText, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - Card, - Slider, - Rate, - }, - } -} diff --git a/designable/antd/src/components/DesignableField/types.ts b/designable/antd/src/components/DesignableField/types.ts deleted file mode 100644 index abf5d0b9cc0..00000000000 --- a/designable/antd/src/components/DesignableField/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react' -import { ISchema } from '@formily/react' -import { ComponentNameMatcher } from '../../shared' -export interface IDesignableFieldFactoryProps { - registryName: string - components?: Record> - componentsIcon?: Record - componentsSourceIcon?: Record - componentsPropsSchema?: Record - dropFormItemComponents?: ComponentNameMatcher[] - dropReactionComponents?: ComponentNameMatcher[] - selfRenderChildrenComponents?: ComponentNameMatcher[] - inlineChildrenLayoutComponents?: ComponentNameMatcher[] - inlineLayoutComponents?: ComponentNameMatcher[] - restrictChildrenComponents?: Record - restrictSiblingComponents?: Record -} diff --git a/designable/antd/src/components/DesignableForm/index.tsx b/designable/antd/src/components/DesignableForm/index.tsx deleted file mode 100644 index 9c9fb13d7d4..00000000000 --- a/designable/antd/src/components/DesignableForm/index.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import React, { useMemo } from 'react' -import { IDesignerProps, GlobalRegistry } from '@designable/core' -import { createForm } from '@formily/core' -import { Form, IFormLayoutProps } from '@formily/antd' -import { observer } from '@formily/react' -import { usePrefix } from '@designable/react' -import { Form as FormPropsSchema } from '../../schemas' -import './styles.less' - -export interface IDesignableFormFactoryProps extends IDesignerProps { - registryName: string - component?: React.JSXElementConstructor -} - -export const createDesignableForm = (options: IDesignableFormFactoryProps) => { - const realOptions: IDesignableFormFactoryProps = { - component: Form, - droppable: true, - draggable: false, - propsSchema: FormPropsSchema, - ...options, - defaultProps: { - labelCol: 6, - wrapperCol: 12, - ...options.defaultProps, - }, - } - - const FormComponent = realOptions.component || Form - - const DesignableForm: React.FC = observer((props) => { - const prefix = usePrefix('designable-form') - const form = useMemo( - () => - createForm({ - designable: true, - }), - [] - ) - return ( - - {props.children} - - ) - }) - - if (!realOptions.registryName) throw new Error('Can not found registryName') - - realOptions.title = `components.${realOptions.registryName}` - - GlobalRegistry.registerDesignerProps({ - [realOptions.registryName]: realOptions, - }) - - return DesignableForm -} diff --git a/designable/antd/src/components/DesignableForm/styles.less b/designable/antd/src/components/DesignableForm/styles.less deleted file mode 100644 index 4aaf7758d29..00000000000 --- a/designable/antd/src/components/DesignableForm/styles.less +++ /dev/null @@ -1,34 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-designable-form { - .@{ant-prefix}-input, - .@{ant-prefix}-input-number, - .@{ant-prefix}-input-affix-wrapper, - .@{ant-prefix}-cascader-picker, - .@{ant-prefix}-picker-input, - .@{ant-prefix}-picker, - .@{ant-prefix}-cascader-picker-label, - .@{ant-prefix}-slider, - .@{ant-prefix}-checkbox, - .@{ant-prefix}-rate, - .@{ant-prefix}-switch, - .@{ant-prefix}-radio, - .@{ant-prefix}-radio-wrapper, - .@{ant-prefix}-checkbox-group, - .@{ant-prefix}-checkbox-wrapper, - .@{ant-prefix}-radio-group, - .@{ant-prefix}-upload, - .@{ant-prefix}-transfer, - .@{ant-prefix}-select, - .@{ant-prefix}-select-selector { - pointer-events: none !important; - - input { - pointer-events: none !important; - } - } - - .anticon svg { - pointer-events: none; - } -} diff --git a/designable/antd/src/components/DesignableFormCollapse/index.tsx b/designable/antd/src/components/DesignableFormCollapse/index.tsx deleted file mode 100644 index 5a271e2bd8d..00000000000 --- a/designable/antd/src/components/DesignableFormCollapse/index.tsx +++ /dev/null @@ -1,133 +0,0 @@ -import React, { Fragment, useState } from 'react' -import { observer } from '@formily/react' -import { Collapse } from 'antd' -import { CollapseProps, CollapsePanelProps } from 'antd/lib/collapse' -import { useTreeNode, useNodeIdProps, TreeNodeWidget } from '@designable/react' -import { toArr } from '@formily/shared' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { LoadTemplate } from '../LoadTemplate' -import { useDropTemplate } from '../../hooks' -import { matchComponent } from '../../shared' - -const parseCollpase = (parent: TreeNode) => { - const tabs: TreeNode[] = [] - parent.children.forEach((node) => { - if (matchComponent(node, 'FormCollapse.CollapsePanel')) { - tabs.push(node) - } - }) - return tabs -} - -export const DesignableFormCollapse: React.FC & { - CollapsePanel?: React.FC -} = observer((props) => { - const [activeKey, setActiveKey] = useState([]) - const node = useTreeNode() - const nodeId = useNodeIdProps() - const designer = useDropTemplate('FormCollapse', (source) => { - const panelNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormCollapse.CollapsePanel', - 'x-component-props': { - header: `Unnamed Title`, - }, - }, - children: source, - }) - - setActiveKey(toArr(activeKey).concat(panelNode.id)) - return [panelNode] - }) - const getCorrectActiveKey = ( - activeKey: string[] | string, - tabs: TreeNode[] - ) => { - if (!tabs.length || !activeKey?.length) { - if (props.accordion) { - return tabs[0]?.id - } - return tabs.map((item) => item.id) - } - if ( - tabs.some((node) => - Array.isArray(activeKey) - ? activeKey.includes(node.id) - : node.id === activeKey - ) - ) - return activeKey - return tabs[tabs.length - 1].id - } - const panels = parseCollpase(node) - const renderCollapse = () => { - if (!node.children?.length) return - return ( - { - setActiveKey(toArr(id)) - }} - > - {panels.map((panel) => { - const props = panel.props['x-component-props'] || {} - return ( - - {React.createElement( - 'div', - { - [designer.props.nodeIdAttrName]: panel.id, - }, - panel.children.length ? ( - - ) : ( - - ) - )} - - ) - })} - - ) - } - return ( -
- {renderCollapse()} - { - const tabPane = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormCollapse.CollapsePanel', - 'x-component-props': { - header: `Unnamed Title`, - }, - }, - }) - node.append(tabPane) - const keys = toArr(activeKey) - setActiveKey(keys.concat(tabPane.id)) - }, - }, - ]} - /> -
- ) -}) - -DesignableFormCollapse.CollapsePanel = (props) => { - return {props.children} -} diff --git a/designable/antd/src/components/DesignableFormTab/index.tsx b/designable/antd/src/components/DesignableFormTab/index.tsx deleted file mode 100644 index 7bc6a158963..00000000000 --- a/designable/antd/src/components/DesignableFormTab/index.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import React, { Fragment, useState } from 'react' -import { observer } from '@formily/react' -import { Tabs } from 'antd' -import { TabsProps, TabPaneProps } from 'antd/lib/tabs' -import { useNodeIdProps, useTreeNode, TreeNodeWidget } from '@designable/react' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { LoadTemplate } from '../LoadTemplate' -import { useDropTemplate } from '../../hooks' -import { matchComponent } from '../../shared' - -const parseTabs = (parent: TreeNode) => { - const tabs: TreeNode[] = [] - parent.children.forEach((node) => { - if (matchComponent(node, 'FormTab.TabPane')) { - tabs.push(node) - } - }) - return tabs -} - -const getCorrectActiveKey = (activeKey: string, tabs: TreeNode[]) => { - if (tabs.length === 0) return - if (tabs.some((node) => node.id === activeKey)) return activeKey - return tabs[tabs.length - 1].id -} - -export const DesignableFormTab: React.FC & { - TabPane?: React.FC -} = observer((props) => { - const [activeKey, setActiveKey] = useState() - const nodeId = useNodeIdProps() - const node = useTreeNode() - const designer = useDropTemplate('FormTab', (source) => { - return [ - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - tab: `Unnamed Title`, - }, - }, - children: source, - }), - ] - }) - const tabs = parseTabs(node) - const renderTabs = () => { - if (!node.children?.length) return - return ( - { - setActiveKey(id) - }} - > - {tabs.map((tab) => { - const props = tab.props['x-component-props'] || {} - return ( - - {React.createElement( - 'div', - { - [designer.props.nodeIdAttrName]: tab.id, - }, - tab.children.length ? ( - - ) : ( - - ) - )} - - ) - })} - - ) - } - return ( -
- {renderTabs()} - { - const tabPane = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - tab: `Unnamed Title`, - }, - }, - }) - node.append(tabPane) - setActiveKey(tabPane.id) - }, - }, - ]} - /> -
- ) -}) - -DesignableFormTab.TabPane = (props) => { - return {props.children} -} diff --git a/designable/antd/src/components/DesignableObject/index.tsx b/designable/antd/src/components/DesignableObject/index.tsx deleted file mode 100644 index b894214f3d8..00000000000 --- a/designable/antd/src/components/DesignableObject/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react' -import { useNodeIdProps, useTreeNode } from '@designable/react' -import { Droppable } from '../Droppable' - -export const DesignableObject: React.FC = (props) => { - const node = useTreeNode() - const nodeId = useNodeIdProps() - if (node.children.length === 0) return - return
{props.children}
-} diff --git a/designable/antd/src/components/DesignableText/index.tsx b/designable/antd/src/components/DesignableText/index.tsx deleted file mode 100644 index 6b08755dbf8..00000000000 --- a/designable/antd/src/components/DesignableText/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react' -import { useDesigner } from '@designable/react' -import cls from 'classnames' -import './styles.less' - -export interface IDesignableTextProps { - content?: string - mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p' - style?: React.CSSProperties - className?: string -} - -export const DesignableText: React.FC = (props) => { - const designer = useDesigner() - const tagName = props.mode === 'normal' || !props.mode ? 'div' : props.mode - return React.createElement( - tagName, - { - ...props, - className: cls(props.className, 'dn-text'), - [designer.props.contentEditableAttrName]: 'x-component-props.content', - }, - props.content - ) -} diff --git a/designable/antd/src/components/DesignableText/styles.less b/designable/antd/src/components/DesignableText/styles.less deleted file mode 100644 index a55fac3c947..00000000000 --- a/designable/antd/src/components/DesignableText/styles.less +++ /dev/null @@ -1,10 +0,0 @@ -.dn-text { - &:empty::before { - content: 'Please Input'; - display: block; - opacity: 0.6; - } - &:focus{ - padding: 4px; - } -} diff --git a/designable/antd/src/components/Droppable/index.tsx b/designable/antd/src/components/Droppable/index.tsx deleted file mode 100644 index 0802ab99f5e..00000000000 --- a/designable/antd/src/components/Droppable/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react' -import { usePrefix, TextWidget } from '@designable/react' -import { Empty } from 'antd' -import cls from 'classnames' -import './styles.less' - -export interface IDroppableProps { - style?: React.CSSProperties - className?: string -} - -export const Droppable: React.FC = (props: any) => { - const prefix = usePrefix('droppable') - return ( - } - /> - ) -} diff --git a/designable/antd/src/components/Droppable/styles.less b/designable/antd/src/components/Droppable/styles.less deleted file mode 100644 index d175c36436a..00000000000 --- a/designable/antd/src/components/Droppable/styles.less +++ /dev/null @@ -1,9 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-droppable { - margin-left: 0 !important; - margin-right: 0 !important; - padding: 20px; - border: 1px solid @border-color-split; - color: @text-color; -} diff --git a/designable/antd/src/components/FormItemSwitcher/index.tsx b/designable/antd/src/components/FormItemSwitcher/index.tsx deleted file mode 100644 index 04134856fbd..00000000000 --- a/designable/antd/src/components/FormItemSwitcher/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react' -import { Switch } from 'antd' - -export interface IFormItemSwitcherProps { - value?: string - onChange?: (value: string) => void -} - -export const FormItemSwitcher: React.FC = (props) => { - return ( - { - props.onChange(value ? 'FormItem' : undefined) - }} - /> - ) -} diff --git a/designable/antd/src/components/LoadTemplate/index.tsx b/designable/antd/src/components/LoadTemplate/index.tsx deleted file mode 100644 index 5decd4d1b72..00000000000 --- a/designable/antd/src/components/LoadTemplate/index.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react' -import { Space, Typography, Divider } from 'antd' -import { usePrefix, TextWidget } from '@designable/react' -import cls from 'classnames' -import './styles.less' - -export interface ITemplateAction { - title: React.ReactNode - tooltip?: React.ReactNode - icon?: string | React.ReactNode - onClick: () => void -} - -export interface ILoadTemplateProps { - className?: string - style?: React.CSSProperties - actions?: ITemplateAction[] -} - -export const LoadTemplate: React.FC = (props) => { - const prefix = usePrefix('load-template') - return ( -
-
- }> - {props.actions?.map((action, key) => { - return ( - { - e.stopPropagation() - action?.onClick?.() - }} - > - {action.title} - - ) - })} - -
-
- ) -} diff --git a/designable/antd/src/components/LoadTemplate/styles.less b/designable/antd/src/components/LoadTemplate/styles.less deleted file mode 100644 index 3496c3c8d76..00000000000 --- a/designable/antd/src/components/LoadTemplate/styles.less +++ /dev/null @@ -1,35 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-load-template { - display: flex; - align-items: center; - justify-content: center; - width: 100%; - overflow: hidden; - padding-top: 10px; - padding-bottom: 10px; - &-actions { - position: relative; - padding: 0 20px; - &::before { - position: absolute; - content: ''; - display: block; - height: 0; - width: 300%; - top: 50%; - border-bottom: 2px dashed @border-color-split; - right: 100%; - } - &::after { - position: absolute; - content: ''; - display: block; - height: 0; - width: 300%; - top: 50%; - border-bottom: 2px dashed @border-color-split; - left: 100%; - } - } -} diff --git a/designable/antd/src/components/index.ts b/designable/antd/src/components/index.ts deleted file mode 100644 index 19322276aac..00000000000 --- a/designable/antd/src/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './DesignableField' -export * from './DesignableForm' diff --git a/designable/antd/src/hooks/index.ts b/designable/antd/src/hooks/index.ts deleted file mode 100644 index 6ab5860beb4..00000000000 --- a/designable/antd/src/hooks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useDropTemplate' diff --git a/designable/antd/src/hooks/useDropTemplate.ts b/designable/antd/src/hooks/useDropTemplate.ts deleted file mode 100644 index c07ef103935..00000000000 --- a/designable/antd/src/hooks/useDropTemplate.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { AppendNodeEvent, TreeNode } from '@designable/core' -import { useDesigner } from '@designable/react' -import { matchComponent, matchChildComponent } from '../shared' - -export const useDropTemplate = ( - name: string, - getChildren: (source: TreeNode[]) => TreeNode[] -) => { - return useDesigner((designer) => { - return designer.subscribeTo(AppendNodeEvent, (event) => { - const { source, target } = event.data - if (Array.isArray(target)) return - if (!Array.isArray(source)) return - if ( - matchComponent( - target, - (key) => - key === name && - source.every((child) => !matchChildComponent(child, name)) - ) && - target.children.length === 0 - ) { - target.setChildren(...getChildren(source)) - return false - } - }) - }) -} diff --git a/designable/antd/src/index.ts b/designable/antd/src/index.ts deleted file mode 100644 index e1e3b6f0e4e..00000000000 --- a/designable/antd/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './locales' -import './sources' -export * from './components' diff --git a/designable/antd/src/locales/en-US.ts b/designable/antd/src/locales/en-US.ts deleted file mode 100644 index 14c3635a4da..00000000000 --- a/designable/antd/src/locales/en-US.ts +++ /dev/null @@ -1,464 +0,0 @@ -const StyleLocale = { - width: 'Width', - height: 'Height', - display: 'Display', - background: 'Background', - boxShadow: 'Box Shadow', - font: 'Font', - margin: 'Margin', - padding: 'Padding', - borderRadius: 'Radius', - border: 'Border', - opacity: 'Opacity', -} - -const FormLayoutLocale = { - labelCol: 'Label Col', - wrapperCol: 'Wrapper Col', - colon: 'Colon', - labelAlign: { - title: 'Label Align', - dataSource: ['Left', 'Right', 'Inherit'], - }, - wrapperAlign: { - title: 'Wrapper Align', - dataSource: ['Left', 'Right', 'Inherit'], - }, - labelWrap: 'Label Wrap', - wrapperWrap: 'Wrapper Wrap', - labelWidth: 'Label Width', - wrapperWidth: 'Wrapper Width', - fullness: 'Fullness', - inset: 'Inset', - shallow: 'Shallow', - bordered: 'Bordered', - size: { title: 'Size', dataSource: ['Large', 'Small', 'Default', 'Inherit'] }, - layout: { - title: 'Layout', - dataSource: ['Vertical', 'Horizontal', 'Inline', 'Inherit'], - }, - feedbackLayout: { - title: 'Feedback Layout', - dataSource: ['Loose', 'Terse', 'Popup', 'None', 'Inherit'], - }, - tooltipLayout: { - title: 'Tooltip Layout', - dataSource: ['Icon', 'Text', 'Inherit'], - }, -} - -const InputLocale = { - addonAfter: 'Addon After', - addonBefore: 'Addon Before', - style: StyleLocale, - allowClear: 'Allow Clear', - maxLength: 'Max Length', - prefix: 'Prefix', - suffix: 'Suffix', - placeholder: 'Placeholder', - autoSize: { - title: 'Auto Size', - }, - showCount: 'Show Count', - checkStrength: 'Check Strength', -} - -const FormItemLocale = { - tooltip: 'Tooltip', - asterisk: 'Asterisk', - gridSpan: 'Grid Span', -} - -const SelectLocale = { - mode: { - title: 'Mode', - dataSource: ['Multiple', 'Tags', 'Single'], - }, - autoClearSearchValue: { - title: 'Auto Clear Search Value', - tooltip: 'Only used to multiple and tags mode', - }, - autoFocus: 'Auto Focus', - defaultActiveFirstOption: 'Default Active First Option', - dropdownMatchSelectWidth: 'Dropdown Match Select Width', - defaultOpen: 'Default Open', - filterOption: 'Filter Option', - filterSort: 'Filter Sort', - labelInValue: 'Label In Value', - listHeight: 'List Height', - maxTagCount: 'Max Tag Count', - maxTagPlaceholder: { - title: 'Max Tag Placeholder', - tooltip: 'Content displayed when tag is hidden', - }, - maxTagTextLength: 'Max Tag Text Length', - notFoundContent: 'Not Found Content', - showArrow: 'Show Arrow', - showSearch: 'Show Search', - virtual: 'Use Virtual Scroll', -} - -const CardLocale = { - type: 'Type', - title: 'Title', - extra: 'Extra Content', - cardTypes: [ - { label: 'Built-in', value: 'inner' }, - { label: 'Default', value: '' }, - ], -} - -const CascaderLocale = { - changeOnSelect: { - title: 'Change On Select', - tooltip: 'Click on each level of menu option value will change', - }, - displayRender: { - title: 'Display Render', - tooltip: - 'The rendering function displayed after selection, the default is label => label.join("/") ', - }, - fieldNames: { - title: 'Field Names', - tooltip: - 'Defaults:{ label: "label", value: "value", children: "children" }', - }, -} - -const RadioLocale = { - buttonStyle: { title: 'Button style', dataSource: ['Hollow', 'Solid'] }, - optionType: { title: 'Option type', dataSource: ['Default', 'Button'] }, -} - -const DatePickerLocale = { - disabledDate: { - title: 'Disabled Date', - tooltip: 'Format (currentDate: moment) => boolean', - }, - disabledTime: { - title: 'Disabled Time', - tooltip: 'Format (currentDate: moment) => boolean', - }, - inputReadOnly: 'Input ReadOnly', - format: 'Format', - picker: { - title: 'Picker', - dataSource: ['Time', 'Date', 'Month', 'Year', 'Quart'], - }, - showNow: 'Show Now', - showTime: 'Show Time', - showToday: 'Show Today', -} - -const NumberPickerLocale = { - formatter: { - title: 'Format Converter', - tooltip: 'Format:function(value: number | string): string', - }, - keyboard: 'Enable Shortcut Keys', - parser: { - title: 'Format Parser', - tooltip: - 'Specify the method of converting back to numbers from the format converter, and use it with the format converter, the format:function(string): number', - }, - decimalSeparator: 'Decimal Separator', - precision: 'Precision', - max: 'Max', - min: 'Min', - step: 'Step', - stringMode: { - title: 'String Format', - tooltip: - 'Support high-precision decimals after opening. At the same time onChange will return string type', - }, -} - -const RateLocale = { - allowHalf: 'Allow Half', - tooltips: { title: 'Tooltips', tooltip: 'Format:string[]' }, - count: 'Count', -} - -const SliderLocale = { - sliderDots: 'Fixed Scale', - sliderRange: 'Double Slider', - sliderReverse: 'Reverse Coordinate System', - vertical: 'Vertical', - tooltipPlacement: { - title: 'Tooltip Placement', - tooltip: 'Set up prompt placement. Reference Tooltip', - }, - tooltipVisible: { - title: 'Tooltip Visible', - tooltip: - 'When turned on, the prompt will always be displayed; otherwise, it will always not be displayed, even when dragging and moving in', - }, - marks: 'Marks', -} - -const TimePickerLocale = { - clearText: 'Clear Text', - disabledHours: 'Disbaled Hours', - disabledMinutes: 'Disabled Minutes', - disabledSeconds: 'Disabled Seconds', - hideDisabledOptions: 'Hide Disabled Options', - hourStep: 'Hour Step', - minuteStep: 'Minute Step', - secondStep: 'Second Step', - use12Hours: 'Use 12-hour', -} - -const TreeSelectLocale = { - dropdownMatchSelectWidth: { - title: 'Dropdown Match Select Width', - tooltip: - 'By default, min-width will be set, and it will be ignored when the value is less than the width of the selection box. false will turn off virtual scrolling', - }, - showCheckedStrategy: { - title: 'Show Checked Strategy', - tooltip: - 'When configuring treeCheckable, define how to backfill the selected item. TreeSelect.SHOW_ALL: Show all selected nodes (including parent nodes). TreeSelect.SHOW_PARENT: Only display the parent node (when all child nodes under the parent node are selected). Only show child nodes by default', - dataSource: ['Show All', 'Show Parent Node', 'Show Child Nodes'], - }, - treeCheckable: 'Tree Checkable', - treeDefaultExpandAll: 'Tree Default Expand All', - treeDefaultExpandedKeys: { - title: 'Tree Default Expanded Keys', - tooltip: 'Format:Array', - }, - treeNodeFilterProp: { - title: 'Tree Node Filter Properties', - tooltip: 'The treeNode attribute corresponding to the input item filter', - }, - treeDataSimpleMode: { - title: 'Tree Data Simple Mode', - tooltip: `Use treeData in a simple format. For specific settings, refer to the settable type (the treeData should be a data structure like this: [{id:1, pId:0, value:'1', title:"test1",...} ,...], pId is the id of the parent node)`, - }, - treeNodeLabelProp: { - title: 'Tree Node Label Properties', - tooltip: 'The default is title', - }, - filterTreeNode: 'Filter Tree Node', -} - -const TransferLocale = { - oneWay: 'One Way', - operations: { - title: 'Operations', - tooltip: 'Format:string[]', - }, - titles: { title: 'Titles', tooltip: 'Format:string[]' }, - showSearchAll: 'Show Search All', -} - -const UploadLocale = { - accept: 'Accept', - action: 'Upload Address', - data: 'Data', - directory: 'Support Upload Directory', - headers: 'Headers', - listType: { title: 'List Type', dataSource: ['Text', 'Image', 'Card'] }, - multiple: 'Multiple', - name: 'Name', - openFileDialogOnClick: 'Open File Dialog On Click', - showUploadList: 'Show Upload List', - withCredentials: 'withCredentials', - maxCount: 'Max Count', - method: 'Method', - textContent: 'Text Content', -} - -const FormGridLocale = { - minWidth: 'Min Width', - minColumns: 'Min Columns', - maxWidth: 'Max Width', - maxColumns: 'Max Columns', - breakpoints: 'Breakpoints', - columnGap: 'Column Gap', - rowGap: 'Row Gap', - colWrap: 'Col Wrap', -} - -const SpaceLocale = { - direction: { title: 'Direction', dataSource: ['Vertical', 'Horizontal'] }, - split: 'Split', - wrap: 'Word Wrap', -} - -const FormTabLocale = { - animated: 'Enable Animated', - centered: 'Label Centered', - tab: 'Tab Title', - tabsTypeEnum: [ - { label: 'Line', value: 'line' }, - { label: 'Card', value: 'card' }, - ], -} - -const FormCollapseLocale = { - accordion: 'Accordion Mode', - collapsible: { title: 'Collapsible', dataSource: ['Header', 'Disable'] }, - ghost: 'Ghost Mode', - header: 'Header Title', -} - -const ArrayTableLocale = { - showHeader: 'Show Header', - sticky: 'Sticky', - align: { - title: 'Align', - dataSource: ['Left', 'Right', 'Centered'], - }, - colSpan: 'ColSpan', - fixed: { title: 'Fixed column', dataSource: ['Left', 'Right', 'None'] }, - width: 'Width', - defaultValue: 'DefaultValue', -} - -const ComponentLocale = { - ...FormLayoutLocale, - ...InputLocale, - ...FormItemLocale, - ...SelectLocale, - ...CardLocale, - ...CascaderLocale, - ...RadioLocale, - ...DatePickerLocale, - ...NumberPickerLocale, - ...RateLocale, - ...SliderLocale, - ...TimePickerLocale, - ...TreeSelectLocale, - ...TransferLocale, - ...UploadLocale, - ...FormGridLocale, - ...SpaceLocale, - ...FormTabLocale, - ...FormCollapseLocale, - ...ArrayTableLocale, -} - -const FieldLocale = { - name: 'Name', - title: 'Title', - required: 'Required', - description: 'Description', - default: 'Default', - enum: 'DataSource', - style: StyleLocale, - 'x-display': { - title: 'Display State', - tooltip: - 'When the display value is "None", the data will be "Hidden" and deleted. When the display value is hidden, only the UI will be hidden', - dataSource: ['Visible', 'Hidden', 'None', 'Inherit'], - }, - 'x-pattern': { - title: 'UI Pattern', - dataSource: ['Editable', 'Disabled', 'ReadOnly', 'ReadPretty', 'Inherit'], - }, - 'x-validator': 'Validator', - 'x-reactions': 'Reactions', - 'x-decorator': 'Decorator', - 'x-decorator-props': { - ...ComponentLocale, - tab_property: 'Decorator', - tab_style: 'Style', - }, - 'x-component-props': { - ...ComponentLocale, - tab_property: 'Component', - tab_style: 'Style', - }, -} - -const ArrayOperationsLocale = { - Index: 'Index', - SortHandle: 'Sort Handle', - Addition: 'Addition', - Remove: 'Remove', - MoveDown: 'Move Down', - MoveUp: 'Move Up', -} - -export default { - 'en-US': { - Components: { - Root: 'Root', - DesignableForm: 'Form', - DesignableField: 'Field', - Input: { title: 'Input', TextArea: 'TextArea' }, - Select: 'Select', - Radio: { title: 'Radio', Group: 'Radio Group' }, - Checkbox: { - title: 'Checkbox', - Group: 'Checkbox Group', - }, - Card: 'Card', - FormGrid: 'Form Grid', - FormLayout: 'Form Layout', - Slider: 'Slider', - Rate: 'Rate', - Cascader: 'Cascader', - Space: 'Space', - DatePicker: { title: 'Date', RangePicker: 'Date Range' }, - TimePicker: { title: 'Time', RangePicker: 'Time Range' }, - NumberPicker: 'Number', - Password: 'Password', - Transfer: 'Transfer', - TreeSelect: 'TreeSelect', - Upload: { title: 'Upload', Dragger: 'Dragger Upload' }, - Switch: 'Switch', - FormTab: { title: 'Form Tab', TabPane: 'Tab Panel' }, - FormCollapse: { title: 'Form Collapse', CollapsePanel: 'Collapse Panel' }, - Object: 'Object', - Void: 'Void Element', - Text: 'Text', - ArrayTable: { - title: 'Array Table', - Column: 'Column', - ...ArrayOperationsLocale, - }, - ArrayCards: { - title: 'Array Cards', - ...ArrayOperationsLocale, - }, - ArrayTabs: { - title: 'Array Tabs', - ...ArrayOperationsLocale, - }, - ArrayCollapse: { - title: 'Array Collapse', - ...ArrayOperationsLocale, - }, - FormItem: 'FormItem', - }, - Settings: { - ...FieldLocale, - ...ComponentLocale, - namespace: { - Text: { - content: 'Text Content', - mode: { - title: 'Text Mode', - dataSource: ['H1', 'H2', 'H3', 'Paragraph', 'Normal'], - }, - }, - Space: { - align: { - title: 'Align', - dataSource: ['Start', 'End', 'Center', 'Baseline'], - }, - }, - }, - }, - Common: { - droppable: 'Droppable', - addTabPane: 'Add Panel', - addCollapsePanel: 'Add Panel', - addTableColumn: 'Add Column', - addTableSortHandle: 'Add Sort Handle', - addIndex: 'Add Index', - addOperation: 'Add Operations', - }, - }, -} diff --git a/designable/antd/src/locales/index.ts b/designable/antd/src/locales/index.ts deleted file mode 100644 index 5d64361884b..00000000000 --- a/designable/antd/src/locales/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { GlobalRegistry } from '@designable/core' -import zhCN from './zh-CN' -import enUS from './en-US' - -GlobalRegistry.registerDesignerLocales({ - ...zhCN, - ...enUS, -}) diff --git a/designable/antd/src/locales/zh-CN.ts b/designable/antd/src/locales/zh-CN.ts deleted file mode 100644 index 4e695b2229a..00000000000 --- a/designable/antd/src/locales/zh-CN.ts +++ /dev/null @@ -1,457 +0,0 @@ -const StyleLocale = { - width: '宽度', - height: '高度', - display: '展示', - background: '背景', - boxShadow: '阴影', - font: '字体', - margin: '外边距', - padding: '内边距', - borderRadius: '圆角', - border: '边框', - opacity: '透明度', -} - -const FormLayoutLocale = { - labelCol: '标签网格宽度', - wrapperCol: '组件网格宽度', - colon: '是否有冒号', - labelAlign: { title: '标签对齐', dataSource: ['左对齐', '右对齐', '继承'] }, - wrapperAlign: { title: '组件对齐', dataSource: ['左对齐', '右对齐', '继承'] }, - labelWrap: '标签换行', - wrapperWrap: '组件换行', - labelWidth: '标签宽度', - wrapperWidth: '组件宽度', - fullness: '组件占满', - inset: '内联布局', - shallow: '是否浅传递', - bordered: '是否有边框', - size: { title: '尺寸', dataSource: ['大', '小', '默认', '继承'] }, - layout: { title: '布局', dataSource: ['垂直', '水平', '内联', '继承'] }, - feedbackLayout: { - title: '反馈布局', - dataSource: ['宽松', '紧凑', '弹层', '无', '继承'], - }, - tooltipLayout: { title: '提示布局', dataSource: ['图标', '文本', '继承'] }, -} - -const InputLocale = { - addonAfter: '后缀标签', - addonBefore: '前缀标签', - style: StyleLocale, - allowClear: '允许清除内容', - bordered: '是否有边框', - maxLength: '最大长度', - prefix: '前缀', - suffix: '后缀', - placeholder: '占位提示', - autoSize: { - title: '自适应高度', - tooltip: '可设置为 true | false 或对象:{ minRows: 2, maxRows: 6 }', - }, - showCount: '是否展示字数', - checkStrength: '检测强度', -} - -const FormItemLocale = { - tooltip: '提示', - asterisk: '星号', - gridSpan: '网格跨列', -} - -const SelectLocale = { - mode: { - title: '模式', - dataSource: ['多选', '标签', '单选'], - }, - autoClearSearchValue: { - title: '选中自动清除', - tooltip: '仅在多选或者标签模式下支持', - }, - autoFocus: '自动获取焦点', - defaultActiveFirstOption: '默认高亮第一个选项', - dropdownMatchSelectWidth: { - title: '下拉菜单和选择器同宽', - tooltip: - '默认将设置 min-width,当值小于选择框宽度时会被忽略。false 时会关闭虚拟滚动', - }, - defaultOpen: '默认展开', - filterOption: '选项筛选器', - filterSort: '选项排序器', - labelInValue: { - title: '标签值', - tooltip: - '是否把每个选项的 label 包装到 value 中,会把 Select 的 value 类型从 string 变为 { value: string, label: ReactNode } 的格式', - }, - listHeight: '弹窗滚动高度', - maxTagCount: { - title: '最多标签数量', - tooltip: '最多显示多少个 tag,响应式模式会对性能产生损耗', - }, - maxTagPlaceholder: { - title: '最多标签占位', - tooltip: '隐藏 tag 时显示的内容', - }, - maxTagTextLength: '最多标签文本长度', - notFoundContent: '空状态内容', - showArrow: '显示箭头', - showSearch: '支持搜索', - virtual: '开启虚拟滚动', -} - -const CardLocale = { - type: '类型', - title: '标题', - extra: '右侧扩展', - cardTypes: [ - { label: '内置', value: 'inner' }, - { label: '默认', value: '' }, - ], -} - -const CascaderLocale = { - changeOnSelect: { - title: '选择时触发', - tooltip: '点选每级菜单选项值都会发生变化', - }, - displayRender: { - title: '渲染函数', - tooltip: '选择后展示的渲染函数,默认为label => label.join("/") ', - }, - fieldNames: { - title: '自定义字段名', - tooltip: '默认值:{ label: "label", value: "value", children: "children" }', - }, -} - -const RadioLocale = { - buttonStyle: { title: '按钮风格', dataSource: ['空心', '实心'] }, - optionType: { title: '选项类型', dataSource: ['默认', '按钮'] }, -} - -const DatePickerLocale = { - disabledDate: { - title: '不可选日期', - tooltip: '格式 (currentDate: moment) => boolean', - }, - disabledTime: { - title: '不可选时间', - tooltip: '格式 (currentDate: moment) => boolean', - }, - inputReadOnly: '输入框只读', - format: '格式', - picker: { - title: '选择器类型', - dataSource: ['时间', '日期', '月份', '年', '季度'], - }, - showNow: '显示此刻', - showTime: '时间选择', - showToday: '显示今天', -} - -const NumberPickerLocale = { - formatter: { - title: '格式转换器', - tooltip: '格式:function(value: number | string): string', - }, - keyboard: '启用快捷键', - parser: { - title: '格式解析器', - tooltip: - '指定从 格式转换器 里转换回数字的方式,和 格式转换器 搭配使用,格式:function(string): number', - }, - decimalSeparator: '小数点', - precision: '数字精度', - max: '最大值', - min: '最小值', - step: '步长', - stringMode: { - title: '字符串格式', - tooltip: '开启后支持高精度小数。同时 onChange 将返回 string 类型', - }, -} - -const RateLocale = { - allowHalf: '允许半选', - tooltips: { title: '提示信息', tooltip: '格式:string[]' }, - count: '总数', -} - -const SliderLocale = { - sliderDots: '刻度固定', - sliderRange: '双滑块', - sliderReverse: '反向坐标系', - vertical: '垂直布局', - tooltipPlacement: { - title: '提示位置', - tooltip: '设置 提示 展示位置。参考 Tooltip', - }, - tooltipVisible: { - title: '提示显示', - tooltip: '开启时,提示 将会始终显示;否则始终不显示,哪怕在拖拽及移入时', - }, - marks: '刻度标签', -} - -const TimePickerLocale = { - clearText: '清除提示', - disabledHours: '禁止小时', - disabledMinutes: '禁止分钟', - disabledSeconds: '禁止秒', - hideDisabledOptions: '隐藏禁止选项', - hourStep: '小时间隔', - minuteStep: '分钟间隔', - secondStep: '秒间隔', - use12Hours: '12小时制', -} - -const TreeSelectLocale = { - dropdownMatchSelectWidth: { - title: '下拉选择器同宽', - tooltip: - '默认将设置 min-width,当值小于选择框宽度时会被忽略。false 时会关闭虚拟滚动', - }, - showCheckedStrategy: { - title: '复选回显策略', - tooltip: - '配置 treeCheckable 时,定义选中项回填的方式。TreeSelect.SHOW_ALL: 显示所有选中节点(包括父节点)。TreeSelect.SHOW_PARENT: 只显示父节点(当父节点下所有子节点都选中时)。 默认只显示子节点', - dataSource: ['显示所有', '显示父节点', '显示子节点'], - }, - treeCheckable: '开启复选', - treeDefaultExpandAll: '默认展开所有', - treeDefaultExpandedKeys: { - title: '默认展开选项', - tooltip: '格式:Array', - }, - treeNodeFilterProp: { - title: '节点过滤属性', - tooltip: '输入项过滤对应的 treeNode 属性', - }, - treeDataSimpleMode: { - title: '使用简单数据结构', - tooltip: `使用简单格式的 treeData,具体设置参考可设置的类型 (此时 treeData 应变为这样的数据结构: [{id:1, pId:0, value:'1', title:"test1",...},...], pId 是父节点的 id)`, - }, - treeNodeLabelProp: { title: '标签显示名称', tooltip: '默认为title' }, - filterTreeNode: '节点过滤器', -} - -const TransferLocale = { - oneWay: '单向展示', - operations: { title: '操作文案集合', tooltip: '格式:string[]' }, - titles: { title: '标题集合', tooltip: '格式:string[]' }, - showSearchAll: '支持全选', -} - -const UploadLocale = { - accept: '可接受类型', - action: '上传地址', - data: '数据/参数', - directory: '支持上传目录', - headers: '请求头', - listType: { title: '列表类型', dataSource: ['文本', '图片', '卡片'] }, - multiple: '多选模式', - name: '字段标识', - openFileDialogOnClick: { - title: '点击打开文件对话框', - tooltip: '点击打开文件对话框', - }, - showUploadList: '是否展示文件列表', - withCredentials: '携带Cookie', - maxCount: '最大数量', - method: '方法', - textContent: '上传文案', -} - -const FormGridLocale = { - minWidth: '最小宽度', - minColumns: '最小列数', - maxWidth: '最大宽度', - maxColumns: '最大列数', - breakpoints: '响应式断点', - columnGap: '列间距', - rowGap: '行间距', - colWrap: '自动换行', -} - -const SpaceLocale = { - direction: { title: '方向', dataSource: ['垂直', '水平'] }, - split: '分割内容', - wrap: '自动换行', -} - -const FormTabLocale = { - animated: '启用动画过渡', - centered: '标签居中', - tab: '选项名称', - tabsTypeEnum: [ - { label: '线框', value: 'line' }, - { label: '卡片', value: 'card' }, - ], -} - -const FormCollapseLocale = { - accordion: '手风琴模式', - collapsible: { title: '可折叠区域', dataSource: ['头部', '禁用'] }, - ghost: '幽灵模式', - header: '头部内容', -} - -const ArrayTableLocale = { - showHeader: '显示头部', - sticky: '吸顶', - align: { - title: '对齐', - dataSource: ['左', '右', '居中'], - }, - colSpan: '跨列', - fixed: { title: '固定列', dataSource: ['左', '右', '无'] }, - width: '宽度', - defaultValue: '默认值', -} - -const ComponentLocale = { - ...FormLayoutLocale, - ...InputLocale, - ...FormItemLocale, - ...SelectLocale, - ...CardLocale, - ...CascaderLocale, - ...RadioLocale, - ...DatePickerLocale, - ...NumberPickerLocale, - ...RateLocale, - ...SliderLocale, - ...TimePickerLocale, - ...TreeSelectLocale, - ...TransferLocale, - ...UploadLocale, - ...FormGridLocale, - ...SpaceLocale, - ...FormTabLocale, - ...FormCollapseLocale, - ...ArrayTableLocale, -} - -const FieldLocale = { - name: '字段标识', - title: '标题', - required: '必填', - description: '描述', - default: '默认值', - enum: '数据源', - style: StyleLocale, - 'x-display': { - title: '展示状态', - tooltip: '半隐藏只会隐藏UI,全隐藏会删除数据', - dataSource: ['显示', '半隐藏', '全隐藏', '继承'], - }, - 'x-pattern': { - title: 'UI形态', - dataSource: ['可编辑', '禁用', '只读', '阅读', '继承'], - }, - 'x-validator': '校验规则', - 'x-reactions': '响应器规则', - 'x-decorator': '启用容器组件', - 'x-decorator-props': { - ...ComponentLocale, - tab_property: '容器属性', - tab_style: '容器样式', - }, - 'x-component-props': { - ...ComponentLocale, - tab_property: '组件属性', - tab_style: '组件样式', - }, -} - -const ArrayOperationsLocale = { - Index: '索引', - SortHandle: '排序手柄', - Addition: '新增按钮', - Remove: '删除按钮', - MoveDown: '下移按钮', - MoveUp: '上移按钮', -} - -export default { - 'zh-CN': { - Components: { - Root: '根组件', - DesignableForm: '表单', - DesignableField: '字段', - Input: { title: '输入框', TextArea: '多行文本' }, - Select: '选择框', - Radio: { title: '单选框', Group: '单选框组' }, - Checkbox: { - title: '复选框', - Group: '复选框组', - }, - Card: '卡片布局', - FormGrid: '网格布局', - FormLayout: '表单布局', - Slider: '滑动条', - Rate: '评分器', - Cascader: '联级选择', - Space: '弹性间距', - DatePicker: { title: '日期选择', RangePicker: '日期范围' }, - TimePicker: { title: '时间选择', RangePicker: '时间范围' }, - NumberPicker: '数字输入', - Password: '密码输入', - Transfer: '穿梭框', - TreeSelect: '树选择', - Upload: { title: '上传', Dragger: '拖拽上传' }, - Switch: '开关', - FormTab: { title: '选项卡布局', TabPane: '选项卡面板' }, - FormCollapse: { title: '手风琴布局', CollapsePanel: '手风琴面板' }, - Object: '数据对象', - Void: '虚拟容器', - Text: '文本', - ArrayTable: { - title: '自增表格', - Column: '表格列', - ...ArrayOperationsLocale, - }, - ArrayCards: { - title: '自增卡片', - ...ArrayOperationsLocale, - }, - ArrayTabs: { - title: '自增选项卡', - ...ArrayOperationsLocale, - }, - ArrayCollapse: { - title: '自增手风琴', - ...ArrayOperationsLocale, - }, - FormItem: '表单项容器', - }, - Settings: { - ...FieldLocale, - ...ComponentLocale, - namespace: { - Text: { - content: '文本内容', - mode: { - title: '文本类型', - dataSource: ['H1', 'H2', 'H3', 'Paragraph', 'Normal'], - }, - }, - Space: { - align: { - title: '对齐', - dataSource: ['头部', '尾部', '居中', '基准线'], - }, - }, - }, - }, - Common: { - droppable: '可以拖入组件', - addTabPane: '添加选项卡', - addCollapsePanel: '添加手风琴卡片', - addTableColumn: '添加表格列', - addTableSortHandle: '添加排序', - addIndex: '添加索引', - addOperation: '添加操作', - }, - }, -} diff --git a/designable/antd/src/schemas/ArrayCards.ts b/designable/antd/src/schemas/ArrayCards.ts deleted file mode 100644 index b970c033a98..00000000000 --- a/designable/antd/src/schemas/ArrayCards.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ArrayTable } from './ArrayTable' -import { Card } from './Card' - -export const ArrayCards = Card -ArrayCards.Addition = ArrayTable.Addition diff --git a/designable/antd/src/schemas/ArrayTable.ts b/designable/antd/src/schemas/ArrayTable.ts deleted file mode 100644 index a88dc4cba8f..00000000000 --- a/designable/antd/src/schemas/ArrayTable.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { ISchema } from '@formily/react' - -export const ArrayTable: ISchema & { Addition?: ISchema; Column?: ISchema } = { - type: 'object', - properties: { - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - showHeader: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - sticky: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'small', - }, - }, - }, -} - -const Column: ISchema = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - align: { - type: 'string', - enum: ['left', 'right', 'center'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'left', - optionType: 'button', - }, - }, - colSpan: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - width: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - fixed: { - type: 'string', - enum: ['left', 'right', false], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - optionType: 'button', - }, - }, - }, -} - -const Addition: ISchema = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - method: { - type: 'string', - enum: ['push', 'unshift'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'push', - optionType: 'button', - }, - }, - defaultValue: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - }, - }, -} - -ArrayTable.Column = Column -ArrayTable.Addition = Addition diff --git a/designable/antd/src/schemas/CSSStyle.ts b/designable/antd/src/schemas/CSSStyle.ts deleted file mode 100644 index 53563535aa0..00000000000 --- a/designable/antd/src/schemas/CSSStyle.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ISchema } from '@formily/react' - -export const CSSStyle: ISchema = { - type: 'void', - properties: { - 'style.width': { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - 'style.height': { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - 'style.display': { - 'x-component': 'DisplayStyleSetter', - }, - 'style.background': { - 'x-component': 'BackgroundStyleSetter', - }, - 'style.boxShadow': { - 'x-component': 'BoxShadowStyleSetter', - }, - 'style.font': { - 'x-component': 'FontStyleSetter', - }, - 'style.margin': { - 'x-component': 'BoxStyleSetter', - }, - 'style.padding': { - 'x-component': 'BoxStyleSetter', - }, - 'style.borderRadius': { - 'x-component': 'BorderRadiusStyleSetter', - }, - 'style.border': { - 'x-component': 'BorderStyleSetter', - }, - 'style.opacity': { - 'x-decorator': 'FormItem', - 'x-component': 'Slider', - 'x-component-props': { - defaultValue: 1, - min: 0, - max: 1, - step: 0.01, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Card.ts b/designable/antd/src/schemas/Card.ts deleted file mode 100644 index 22ef2b083ba..00000000000 --- a/designable/antd/src/schemas/Card.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { GlobalRegistry } from '@designable/core' -import { ISchema } from '@formily/react' - -export const Card: ISchema & { Addition?: ISchema } = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - extra: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - type: { - type: 'boolean', - enum: GlobalRegistry.getDesignerMessage('settings.cardTypes'), - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: '', - optionType: 'button', - }, - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Cascader.ts b/designable/antd/src/schemas/Cascader.ts deleted file mode 100644 index e7b7d7d40ae..00000000000 --- a/designable/antd/src/schemas/Cascader.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Cascader: ISchema = { - type: 'object', - properties: { - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - changeOnSelect: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - displayRender: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - fieldNames: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - notFoundContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - defaultValue: 'Not Found', - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'middle', - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Checkbox.ts b/designable/antd/src/schemas/Checkbox.ts deleted file mode 100644 index 9c152bbdb92..00000000000 --- a/designable/antd/src/schemas/Checkbox.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Checkbox: ISchema & { Group?: ISchema } = { - type: 'object', - properties: { - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/antd/src/schemas/DatePicker.ts b/designable/antd/src/schemas/DatePicker.ts deleted file mode 100644 index 5b72fcf4710..00000000000 --- a/designable/antd/src/schemas/DatePicker.ts +++ /dev/null @@ -1,118 +0,0 @@ -import { ISchema } from '@formily/react' - -const CommonDatePickerAPI = { - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - disabledTime: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - disabledDate: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - inputReadOnly: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'middle', - }, - }, - format: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - placeholder: 'YYYY-MM-DD', - }, - }, -} - -export const DatePicker: ISchema & { RangePicker?: ISchema } = { - type: 'object', - properties: { - picker: { - type: 'string', - enum: ['time', 'date', 'month', 'year', 'decade'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'date', - }, - }, - ...CommonDatePickerAPI, - showNow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showTime: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showToday: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} - -DatePicker.RangePicker = { - type: 'object', - properties: { - picker: { - type: 'string', - enum: ['time', 'date', 'month', 'year', 'decade'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'date', - }, - }, - ...CommonDatePickerAPI, - showTime: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/antd/src/schemas/Form.ts b/designable/antd/src/schemas/Form.ts deleted file mode 100644 index 1d5e472ab9f..00000000000 --- a/designable/antd/src/schemas/Form.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ISchema } from '@formily/react' -import { FormLayout } from './FormLayout' -import { CSSStyle } from './CSSStyle' - -export const Form: ISchema = { - type: 'object', - properties: { - ...(FormLayout.properties as any), - style: CSSStyle, - }, -} diff --git a/designable/antd/src/schemas/FormCollapse.ts b/designable/antd/src/schemas/FormCollapse.ts deleted file mode 100644 index 328ba1398dc..00000000000 --- a/designable/antd/src/schemas/FormCollapse.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { ISchema } from '@formily/react' - -export const FormCollapse: ISchema & { CollapsePanel?: ISchema } = { - type: 'object', - properties: { - accordion: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - collapsible: { - type: 'string', - enum: ['header', 'disabled'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'header', - optionType: 'button', - }, - }, - ghost: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} - -FormCollapse.CollapsePanel = { - type: 'object', - properties: { - collapsible: { - type: 'string', - enum: ['header', 'disabled'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'header', - optionType: 'button', - }, - }, - header: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - extra: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, -} diff --git a/designable/antd/src/schemas/FormGrid.ts b/designable/antd/src/schemas/FormGrid.ts deleted file mode 100644 index 73a1fbea9f8..00000000000 --- a/designable/antd/src/schemas/FormGrid.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { ISchema } from '@formily/react' - -export const FormGrid: ISchema = { - type: 'object', - properties: { - minWidth: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 100, - }, - }, - maxWidth: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - minColumns: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 0, - }, - }, - maxColumns: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - breakpoints: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - columnGap: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 10, - }, - }, - rowGap: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 5, - }, - }, - colWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/FormItem.ts b/designable/antd/src/schemas/FormItem.ts deleted file mode 100644 index 354cbd7c417..00000000000 --- a/designable/antd/src/schemas/FormItem.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { ISchema } from '@formily/react' - -export const FormItem: ISchema = { - type: 'object', - properties: { - tooltip: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonBefore: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonAfter: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - labelCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - wrapperCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - labelWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - wrapperWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - colon: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - asterisk: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - gridSpan: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - feedbackLayout: { - type: 'string', - enum: ['loose', 'terse', 'popover', 'none', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'loose', - }, - }, - size: { - type: 'string', - enum: ['large', 'small', 'default', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'default', - }, - }, - layout: { - type: 'string', - enum: ['vertical', 'horizontal', 'inline', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'horizontal', - }, - }, - - tooltipLayout: { - type: 'string', - enum: ['icon', 'text', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'icon', - }, - }, - labelAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'right', - }, - }, - wrapperAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'left', - }, - }, - labelWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - wrapperWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - fullness: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - inset: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/FormLayout.ts b/designable/antd/src/schemas/FormLayout.ts deleted file mode 100644 index 366d27b5f3e..00000000000 --- a/designable/antd/src/schemas/FormLayout.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { ISchema } from '@formily/react' - -export const FormLayout: ISchema = { - type: 'object', - properties: { - labelCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - wrapperCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - labelWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - wrapperWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - colon: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - feedbackLayout: { - type: 'string', - enum: ['loose', 'terse', 'popover', 'none', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'loose', - }, - }, - size: { - type: 'string', - enum: ['large', 'small', 'default', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'default', - }, - }, - layout: { - type: 'string', - enum: ['vertical', 'horizontal', 'inline', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'horizontal', - }, - }, - tooltipLayout: { - type: 'string', - enum: ['icon', 'text', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'icon', - }, - }, - labelAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'right', - }, - }, - wrapperAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'left', - }, - }, - labelWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - wrapperWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - - fullness: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - inset: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - shallow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/FormTab.ts b/designable/antd/src/schemas/FormTab.ts deleted file mode 100644 index 5074ca66159..00000000000 --- a/designable/antd/src/schemas/FormTab.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { GlobalRegistry } from '@designable/core' -import { ISchema } from '@formily/react' - -export const FormTab: ISchema & { TabPane?: ISchema } = { - type: 'object', - properties: { - animated: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - centered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - size: { - type: 'string', - enum: ['large', 'small', 'default', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'default', - }, - }, - type: { - type: 'string', - enum: GlobalRegistry.getDesignerMessage('settings.tabsTypeEnum'), - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'line', - optionType: 'button', - }, - }, - }, -} - -FormTab.TabPane = { - type: 'object', - properties: { - tab: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, -} diff --git a/designable/antd/src/schemas/Input.ts b/designable/antd/src/schemas/Input.ts deleted file mode 100644 index 641033ee824..00000000000 --- a/designable/antd/src/schemas/Input.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Input: ISchema & { TextArea?: ISchema } = { - type: 'object', - properties: { - addonBefore: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonAfter: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - prefix: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - suffix: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - maxLength: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'middle', - }, - }, - }, -} - -Input.TextArea = { - type: 'object', - properties: { - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - maxLength: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - autoSize: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showCount: { - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/antd/src/schemas/NumberPicker.ts b/designable/antd/src/schemas/NumberPicker.ts deleted file mode 100644 index 7b026706fef..00000000000 --- a/designable/antd/src/schemas/NumberPicker.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { ISchema } from '@formily/react' - -export const NumberPicker: ISchema = { - type: 'object', - properties: { - decimalSeparator: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - precision: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - max: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - min: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - step: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'middle', - }, - }, - formatter: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - parser: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - stringMode: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - keyboard: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Password.ts b/designable/antd/src/schemas/Password.ts deleted file mode 100644 index 972ad912052..00000000000 --- a/designable/antd/src/schemas/Password.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ISchema } from '@formily/react' -import { Input } from './Input' -export const Password: ISchema = { - type: 'object', - properties: { - ...(Input.properties as any), - checkStrength: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/antd/src/schemas/Radio.ts b/designable/antd/src/schemas/Radio.ts deleted file mode 100644 index 7101ab5051e..00000000000 --- a/designable/antd/src/schemas/Radio.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Radio: ISchema & { Group?: ISchema } = { - type: 'object', - properties: { - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} - -Radio.Group = { - type: 'object', - properties: { - optionType: { - type: 'string', - enum: ['default', 'button'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'default', - optionType: 'button', - }, - }, - buttonStyle: { - type: 'string', - enum: ['outline', 'solid'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'outline', - optionType: 'button', - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Rate.ts b/designable/antd/src/schemas/Rate.ts deleted file mode 100644 index 1c03dbe0529..00000000000 --- a/designable/antd/src/schemas/Rate.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Rate: ISchema = { - type: 'object', - properties: { - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - count: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 5, - }, - }, - allowHalf: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - tooltips: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/antd/src/schemas/Select.ts b/designable/antd/src/schemas/Select.ts deleted file mode 100644 index eb340cc30c9..00000000000 --- a/designable/antd/src/schemas/Select.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Select: ISchema = { - type: 'object', - properties: { - mode: { - type: 'string', - enum: ['multiple', 'tags', null], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: null, - optionType: 'button', - }, - }, - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - autoClearSearchValue: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - dropdownMatchSelectWidth: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - defaultActiveFirstOption: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - defaultOpen: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - labelInValue: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showArrow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - virtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultValue: true, - }, - }, - filterOption: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['BOOLEAN', 'EXPRESSION'], - }, - }, - filterSort: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - listHeight: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 256, - }, - }, - maxTagCount: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - maxTagPlaceholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - maxTagTextLength: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - notFoundContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - defaultValue: 'Not Found', - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'middle', - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Slider.ts b/designable/antd/src/schemas/Slider.ts deleted file mode 100644 index 00e185512a6..00000000000 --- a/designable/antd/src/schemas/Slider.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { GlobalRegistry } from '@designable/core' -import { ISchema } from '@formily/react' - -export const Slider: ISchema = { - type: 'object', - properties: { - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - dots: { - title: GlobalRegistry.getDesignerMessage('settings.sliderDots'), - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - range: { - title: GlobalRegistry.getDesignerMessage('settings.sliderRange'), - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - reverse: { - title: GlobalRegistry.getDesignerMessage('settings.sliderReverse'), - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - vertical: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - tooltipVisible: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - tooltipPlacement: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - marks: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - max: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 100, - }, - }, - min: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 0, - }, - }, - step: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 1, - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Space.ts b/designable/antd/src/schemas/Space.ts deleted file mode 100644 index da16defeaa7..00000000000 --- a/designable/antd/src/schemas/Space.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Space: ISchema = { - type: 'object', - properties: { - align: { - type: 'string', - enum: ['start', 'end', 'center', 'baseline'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - }, - direction: { - type: 'string', - enum: ['vertical', 'horizontal'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'horizontal', - optionType: 'button', - }, - }, - size: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 8, - }, - }, - split: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - wrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/antd/src/schemas/Switch.ts b/designable/antd/src/schemas/Switch.ts deleted file mode 100644 index 1b5a158ebbd..00000000000 --- a/designable/antd/src/schemas/Switch.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Switch: ISchema = { - type: 'object', - properties: { - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - size: { - type: 'string', - enum: ['large', 'small', 'default', ''], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'default', - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Text.ts b/designable/antd/src/schemas/Text.ts deleted file mode 100644 index 66784e1c78e..00000000000 --- a/designable/antd/src/schemas/Text.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Text: ISchema = { - type: 'object', - properties: { - content: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - }, - mode: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'normal', - }, - enum: ['h1', 'h2', 'h3', 'p', 'normal'], - }, - }, -} diff --git a/designable/antd/src/schemas/TimePicker.ts b/designable/antd/src/schemas/TimePicker.ts deleted file mode 100644 index 8bb9a28f9f6..00000000000 --- a/designable/antd/src/schemas/TimePicker.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { ISchema } from '@formily/react' - -export const CommonTimePickerAPI = { - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - clearText: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - disabledHours: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - disabledMinutes: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - disabledSeconds: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - hideDisabledOptions: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - inputReadOnly: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showNow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - use12Hours: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - hourStep: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 1, - }, - }, - minuteStep: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 1, - }, - }, - secondStep: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 1, - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - }, - format: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - placeholder: 'YYYY-MM-DD', - }, - }, -} - -export const TimePicker: ISchema & { RangePicker?: ISchema } = { - type: 'object', - properties: CommonTimePickerAPI, -} - -TimePicker.RangePicker = { - type: 'object', - properties: CommonTimePickerAPI, -} diff --git a/designable/antd/src/schemas/Transfer.ts b/designable/antd/src/schemas/Transfer.ts deleted file mode 100644 index 7873d1d9213..00000000000 --- a/designable/antd/src/schemas/Transfer.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Transfer: ISchema = { - type: 'object', - properties: { - oneWay: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showSearchAll: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - filterOption: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - operations: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - titles: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - }, -} diff --git a/designable/antd/src/schemas/TreeSelect.ts b/designable/antd/src/schemas/TreeSelect.ts deleted file mode 100644 index 96cc1dfd38e..00000000000 --- a/designable/antd/src/schemas/TreeSelect.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { ISchema } from '@formily/react' - -export const TreeSelect: ISchema = { - type: 'object', - properties: { - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - autoClearSearchValue: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - labelInValue: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showArrow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - virtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - treeCheckable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - treeDefaultExpandAll: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - dropdownMatchSelectWidth: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - showCheckedStrategy: { - type: 'string', - enum: ['SHOW_ALL', 'SHOW_PARENT', 'SHOW_CHILD'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'SHOW_CHILD', - }, - }, - treeDefaultExpandedKeys: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - treeNodeFilterProp: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - treeNodeLabelProp: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - filterTreeNode: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['BOOLEAN', 'EXPRESSION'], - }, - }, - treeDataSimpleMode: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['BOOLEAN', 'EXPRESSION'], - }, - }, - listHeight: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 256, - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - size: { - type: 'string', - enum: ['large', 'small', 'middle', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'middle', - }, - }, - }, -} diff --git a/designable/antd/src/schemas/Upload.ts b/designable/antd/src/schemas/Upload.ts deleted file mode 100644 index a43dc306041..00000000000 --- a/designable/antd/src/schemas/Upload.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Upload: ISchema & { Dragger?: ISchema } = { - type: 'object', - properties: { - textContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - accept: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - action: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['TEXT', 'EXPRESSION'], - }, - }, - name: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - defaultValue: 'file', - }, - }, - maxCount: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - method: { - enum: ['POST', 'PUT', 'GET'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'POST', - optionType: 'button', - }, - }, - data: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - headers: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - - listType: { - enum: ['text', 'picture', 'picture-card'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'text', - optionType: 'button', - }, - }, - directory: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - multiple: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - openFileDialogOnClick: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - showUploadList: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - withCredentials: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} - -Upload.Dragger = Upload diff --git a/designable/antd/src/schemas/index.ts b/designable/antd/src/schemas/index.ts deleted file mode 100644 index e046ffae474..00000000000 --- a/designable/antd/src/schemas/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -export * from './Input' -export * from './Text' -export * from './FormLayout' -export * from './CSSStyle' -export * from './Form' -export * from './FormItem' -export * from './Select' -export * from './Card' -export * from './Cascader' -export * from './Checkbox' -export * from './Radio' -export * from './DatePicker' -export * from './NumberPicker' -export * from './Password' -export * from './Rate' -export * from './Slider' -export * from './TimePicker' -export * from './TreeSelect' -export * from './Transfer' -export * from './Upload' -export * from './Switch' -export * from './FormGrid' -export * from './Space' -export * from './FormTab' -export * from './FormCollapse' -export * from './ArrayTable' -export * from './ArrayCards' diff --git a/designable/antd/src/shared.ts b/designable/antd/src/shared.ts deleted file mode 100644 index 0edd6e34f8c..00000000000 --- a/designable/antd/src/shared.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { TreeNode, Engine } from '@designable/core' - -export type ComponentNameMatcher = - | string - | string[] - | ((name: string, node: TreeNode, context?: any) => boolean) - -export const matchComponent = ( - node: TreeNode, - name: ComponentNameMatcher, - context?: any -) => { - if (name === '*') return true - const componentName = node?.props?.['x-component'] - if (typeof name === 'function') - return name(componentName || '', node, context) - if (Array.isArray(name)) return name.includes(componentName) - return componentName === name -} - -export const matchChildComponent = ( - node: TreeNode, - name: ComponentNameMatcher, - context?: any -) => { - if (name === '*') return true - const componentName = node?.props?.['x-component'] - if (!componentName) return false - if (typeof name === 'function') - return name(componentName || '', node, context) - if (Array.isArray(name)) return name.includes(componentName) - return componentName.indexOf(`${name}.`) > -1 -} - -export const includesComponent = ( - node: TreeNode, - names: ComponentNameMatcher[], - target?: TreeNode -) => { - return names.some((name) => matchComponent(node, name, target)) -} - -export const queryNodesByComponentPath = ( - node: TreeNode, - path: ComponentNameMatcher[] -): TreeNode[] => { - if (path?.length === 0) return [] - if (path?.length === 1) { - if (matchComponent(node, path[0])) { - return [node] - } - } - return matchComponent(node, path[0]) - ? node.children.reduce((buf, child) => { - return buf.concat(queryNodesByComponentPath(child, path.slice(1))) - }, []) - : [] -} - -export const findNodeByComponentPath = ( - node: TreeNode, - path: ComponentNameMatcher[] -): TreeNode => { - if (path?.length === 0) return - if (path?.length === 1) { - if (matchComponent(node, path[0])) { - return node - } - } - if (matchComponent(node, path[0])) { - for (let i = 0; i < node.children.length; i++) { - const next = findNodeByComponentPath(node.children[i], path.slice(1)) - if (next) { - return next - } - } - } -} - -export const hasNodeByComponentPath = ( - node: TreeNode, - path: ComponentNameMatcher[] -) => !!findNodeByComponentPath(node, path) - -export const matchArrayItemsNode = (node: TreeNode) => { - return ( - node?.parent?.props?.type === 'array' && - node?.parent?.children?.[0] === node - ) -} - -export const createNodeId = (designer: Engine, id: string) => { - return { - [designer.props.nodeIdAttrName]: id, - } -} - -export const createEnsureTypeItemsNode = (type: string) => (node: TreeNode) => { - const objectNode = node.children.find((child) => child.props['type'] === type) - if ( - objectNode && - objectNode.designerProps.droppable && - !objectNode.props['x-component'] - ) { - return objectNode - } else { - const newObjectNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type, - }, - }) - node.prepend(newObjectNode) - return newObjectNode - } -} diff --git a/designable/antd/src/sources/arrays.ts b/designable/antd/src/sources/arrays.ts deleted file mode 100644 index 0f8cb421140..00000000000 --- a/designable/antd/src/sources/arrays.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('arrays', [ - { - componentName: 'DesignableField', - props: { - type: 'array', - 'x-decorator': 'FormItem', - 'x-component': 'ArrayTable', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'array', - 'x-decorator': 'FormItem', - 'x-component': 'ArrayCards', - 'x-component-props': { - title: `Title`, - }, - }, - }, -]) diff --git a/designable/antd/src/sources/displays.ts b/designable/antd/src/sources/displays.ts deleted file mode 100644 index 8506ea95256..00000000000 --- a/designable/antd/src/sources/displays.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('displays', [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'Text', - }, - }, -]) diff --git a/designable/antd/src/sources/index.ts b/designable/antd/src/sources/index.ts deleted file mode 100644 index c9da47ecd8a..00000000000 --- a/designable/antd/src/sources/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import './inputs' -import './layouts' -import './arrays' -import './displays' diff --git a/designable/antd/src/sources/inputs.ts b/designable/antd/src/sources/inputs.ts deleted file mode 100644 index 703584626d7..00000000000 --- a/designable/antd/src/sources/inputs.ts +++ /dev/null @@ -1,192 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('inputs', [ - { - componentName: 'DesignableField', - props: { - title: 'Input', - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'TextArea', - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'Select', - 'x-decorator': 'FormItem', - 'x-component': 'Select', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'Tree Select', - 'x-decorator': 'FormItem', - 'x-component': 'TreeSelect', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'Cascader', - 'x-decorator': 'FormItem', - 'x-component': 'Cascader', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string | number', - title: 'Radio Group', - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - enum: [ - { label: '选项1', value: 1 }, - { label: '选项2', value: 2 }, - ], - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Checkbox Group', - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox.Group', - enum: [ - { label: '选项1', value: 1 }, - { label: '选项2', value: 2 }, - ], - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'number', - title: 'Slider', - 'x-decorator': 'FormItem', - 'x-component': 'Slider', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'number', - title: 'Rate', - 'x-decorator': 'FormItem', - 'x-component': 'Rate', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string', - title: 'DatePicker', - 'x-decorator': 'FormItem', - 'x-component': 'DatePicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: '[string,string]', - title: 'DateRangePicker', - 'x-decorator': 'FormItem', - 'x-component': 'DatePicker.RangePicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string', - title: 'TimePicker', - 'x-decorator': 'FormItem', - 'x-component': 'TimePicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: '[string,string]', - title: 'TimeRangePicker', - 'x-decorator': 'FormItem', - 'x-component': 'TimePicker.RangePicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'number', - title: 'NumberPicker', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string', - title: 'Password', - 'x-decorator': 'FormItem', - 'x-component': 'Password', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Transfer', - 'x-decorator': 'FormItem', - 'x-component': 'Transfer', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Upload', - 'x-decorator': 'FormItem', - 'x-component': 'Upload', - 'x-component-props': { - textContent: 'Upload', - }, - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Drag Upload', - 'x-decorator': 'FormItem', - 'x-component': 'Upload.Dragger', - 'x-component-props': { - textContent: 'Click or drag file to this area to upload', - }, - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'boolean', - title: 'Switch', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'object', - }, - }, -]) diff --git a/designable/antd/src/sources/layouts.ts b/designable/antd/src/sources/layouts.ts deleted file mode 100644 index f7809a01540..00000000000 --- a/designable/antd/src/sources/layouts.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('layouts', [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'Card', - 'x-component-props': { - title: 'Title', - }, - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormGrid', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormLayout', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'Space', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormTab', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormCollapse', - }, - }, -]) diff --git a/designable/antd/tsconfig.build.json b/designable/antd/tsconfig.build.json deleted file mode 100644 index dbf069a065d..00000000000 --- a/designable/antd/tsconfig.build.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "paths": { - "@formily/*": [ - "../../packages/*", - "../../designable/*", - "../../devtools/*" - ] - }, - "declaration": true - } -} diff --git a/designable/antd/tsconfig.json b/designable/antd/tsconfig.json deleted file mode 100644 index c6865c25a75..00000000000 --- a/designable/antd/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./src/**/*.ts", "./src/**/*.tsx"], - "exclude": ["./src/__tests__/*", "./esm/*", "./lib/*"] -} diff --git a/designable/next/.npmignore b/designable/next/.npmignore deleted file mode 100644 index 1ff337420fd..00000000000 --- a/designable/next/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -node_modules -*.log -build -docs -doc-site -__tests__ -.eslintrc -jest.config.js -tsconfig.json -.umi -src \ No newline at end of file diff --git a/designable/next/.umirc.js b/designable/next/.umirc.js deleted file mode 100644 index 1362b3c43c6..00000000000 --- a/designable/next/.umirc.js +++ /dev/null @@ -1,44 +0,0 @@ -import { resolve } from 'path' -export default { - mode: 'site', - logo: '//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg', - title: 'Formily', - hash: true, - favicon: - '//img.alicdn.com/imgextra/i3/O1CN01XtT3Tv1Wd1b5hNVKy_!!6000000002810-55-tps-360-360.svg', - outputPath: './doc-site', - navs: [ - { - title: 'Ant Design', - path: '/components', - }, - { - title: '主站', - path: 'https://v2.formilyjs.org', - }, - { - title: 'GITHUB', - path: 'https://github.com/alibaba/formily', - }, - ], - styles: [ - `.__dumi-default-navbar-logo{ - height: 60px !important; - width: 150px !important; - padding-left:0 !important; - color: transparent !important; - } - .__dumi-default-navbar{ - padding: 0 28px !important; - } - .__dumi-default-layout-hero{ - background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png); - background-size: cover; - background-repeat: no-repeat; - } - nav a{ - text-decoration: none !important; - } - `, - ], -} diff --git a/designable/next/LICENSE.md b/designable/next/LICENSE.md deleted file mode 100644 index 509632e8e80..00000000000 --- a/designable/next/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015-present, Alibaba Group Holding Limited. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/designable/next/README.md b/designable/next/README.md deleted file mode 100644 index 79f8236d6e2..00000000000 --- a/designable/next/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @formily/designable-next - -### Install - -```bash -npm install --save @formily/designable-next -``` diff --git a/designable/next/copy.ts b/designable/next/copy.ts deleted file mode 100644 index 669b8f3af0d..00000000000 --- a/designable/next/copy.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { runCopy } from '../../scripts/build-style' - -runCopy({ - esStr: '@alifd/next/es/', - libStr: '@alifd/next/lib/', -}) diff --git a/designable/next/package.json b/designable/next/package.json deleted file mode 100644 index 8ed260399e6..00000000000 --- a/designable/next/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@formily/designable-next", - "version": "2.0.0-rc.7", - "license": "MIT", - "main": "lib", - "module": "esm", - "umd:main": "dist/formily.designable.next.umd.production.js", - "unpkg": "dist/formily.designable.next.umd.production.js", - "jsdelivr": "dist/formily.designable.next.umd.production.js", - "jsnext:main": "esm", - "repository": { - "type": "git", - "url": "git+https://github.com/alibaba/formily.git" - }, - "types": "esm/index.d.ts", - "bugs": { - "url": "https://github.com/alibaba/formily/issues" - }, - "homepage": "https://github.com/alibaba/formily#readme", - "engines": { - "npm": ">=3.0.0" - }, - "scripts": { - "build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm && npm run build:umd && ts-node copy", - "build:cjs": "tsc --project tsconfig.build.json", - "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm", - "build:umd": "rollup --config", - "build:playground": "webpack-cli --config playground/webpack.prod.ts", - "start": "webpack-dev-server --config playground/webpack.dev.ts" - }, - "devDependencies": { - "@designable/react-settings-form": "^0.x", - "autoprefixer": "^9.0", - "file-loader": "^5.0.2", - "fs-extra": "^8.1.0", - "html-webpack-plugin": "^3.2.0", - "mini-css-extract-plugin": "^1.6.0", - "monaco-editor-webpack-plugin": "^4.0.0", - "raw-loader": "^4.0.0", - "react-monaco-editor": "^0.43.0", - "style-loader": "^1.1.3", - "ts-loader": "^7.0.4", - "typescript": "4.1.5", - "webpack": "^4.41.5", - "webpack-bundle-analyzer": "^3.9.0", - "webpack-cli": "^3.3.10", - "webpack-dev-server": "^3.10.1" - }, - "peerDependencies": { - "@alifd/next": "^1.23.0", - "@types/react": ">=16.8.0 || >=17.0.0", - "@types/react-dom": ">=16.8.0 || >=17.0.0", - "antd": "^4.0.0", - "react": ">=16.8.0 || >=17.0.0", - "react-dom": ">=16.8.0", - "react-is": ">=16.8.0 || >=17.0.0" - }, - "dependencies": { - "@designable/core": "^0.x", - "@designable/formily": "^0.x", - "@designable/react": "^0.x", - "@formily/core": "2.0.0-rc.7", - "@formily/designable-setters": "2.0.0-rc.7", - "@formily/next": "2.0.0-rc.7", - "@formily/react": "2.0.0-rc.7", - "@formily/shared": "2.0.0-rc.7" - }, - "publishConfig": { - "access": "public" - }, - "gitHead": "2c44ae410a73f02735c63c6430e021a50e21f3ec" -} diff --git a/designable/next/playground/main.tsx b/designable/next/playground/main.tsx deleted file mode 100644 index 65bf9a67592..00000000000 --- a/designable/next/playground/main.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import { - Designer, - DesignerToolsWidget, - ViewToolsWidget, - Workspace, - OutlineTreeWidget, - DragSourceWidget, - HistoryWidget, - MainPanel, - CompositePanel, - WorkspacePanel, - ToolbarPanel, - ViewportPanel, - ViewPanel, - SettingsPanel, - ComponentTreeWidget, -} from '@designable/react' -import { SettingsForm } from '@designable/react-settings-form' -import { - createDesigner, - GlobalRegistry, - Shortcut, - KeyCode, -} from '@designable/core' -import { createDesignableField, createDesignableForm } from '../src' -import { - LogoWidget, - ActionsWidget, - PreviewWidget, - SchemaEditorWidget, - MarkupSchemaWidget, -} from './widgets' -import { saveSchema } from './service' -import 'antd/dist/antd.less' -import '@alifd/next/dist/next.css' - -GlobalRegistry.registerDesignerLocales({ - 'zh-CN': { - sources: { - Inputs: '输入控件', - Layouts: '布局组件', - Arrays: '自增组件', - Displays: '展示组件', - }, - }, - 'en-US': { - sources: { - Inputs: 'Inputs', - Layouts: 'Layouts', - Arrays: 'Arrays', - Displays: 'Displays', - }, - }, -}) - -const Root = createDesignableForm({ - registryName: 'Root', -}) - -const DesignableField = createDesignableField({ - registryName: 'DesignableField', -}) - -const SaveShortCut = new Shortcut({ - codes: [ - [KeyCode.Meta, KeyCode.S], - [KeyCode.Control, KeyCode.S], - ], - handler(ctx) { - saveSchema(ctx.engine) - }, -}) - -const engine = createDesigner({ - shortcuts: [SaveShortCut], -}) - -const App = () => { - return ( - - } actions={}> - - - - - - - - - - - - - - - - - - - - - - - {() => ( - - )} - - - {(tree, onChange) => ( - - )} - - - {(tree) => } - - - {(tree) => } - - - - - - - - - - ) -} - -ReactDOM.render(, document.getElementById('root')) diff --git a/designable/next/playground/service/index.ts b/designable/next/playground/service/index.ts deleted file mode 100644 index cb7cdd48bd0..00000000000 --- a/designable/next/playground/service/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './schema' diff --git a/designable/next/playground/service/schema.ts b/designable/next/playground/service/schema.ts deleted file mode 100644 index 1c7b2c63996..00000000000 --- a/designable/next/playground/service/schema.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Engine } from '@designable/core' -import { transformToSchema, transformToTreeNode } from '@designable/formily' -import { message } from 'antd' - -export const saveSchema = (designer: Engine) => { - localStorage.setItem( - 'formily-schema', - JSON.stringify( - transformToSchema(designer.getCurrentTree(), { - designableFieldName: 'DesignableField', - designableFormName: 'Root', - }) - ) - ) - message.success('Save Success') -} - -export const loadInitialSchema = (designer: Engine) => { - try { - designer.setCurrentTree( - transformToTreeNode(JSON.parse(localStorage.getItem('formily-schema')), { - designableFieldName: 'DesignableField', - designableFormName: 'Root', - }) - ) - } catch {} -} diff --git a/designable/next/playground/template.ejs b/designable/next/playground/template.ejs deleted file mode 100644 index a4dd656fb7d..00000000000 --- a/designable/next/playground/template.ejs +++ /dev/null @@ -1,20 +0,0 @@ - - - - Designable Playground - - - - -
-
- - - - - \ No newline at end of file diff --git a/designable/next/playground/webpack.base.ts b/designable/next/playground/webpack.base.ts deleted file mode 100644 index 688533b50cb..00000000000 --- a/designable/next/playground/webpack.base.ts +++ /dev/null @@ -1,122 +0,0 @@ -import path from 'path' -import fs from 'fs-extra' -import { GlobSync } from 'glob' -import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import autoprefixer from 'autoprefixer' -//import { getThemeVariables } from 'antd/dist/theme' - -const getWorkspaceAlias = () => { - const basePath = path.resolve(__dirname, '../../../') - const pkg = fs.readJSONSync(path.resolve(basePath, 'package.json')) || {} - const results = {} - const workspaces = pkg.workspaces - if (Array.isArray(workspaces)) { - workspaces.forEach((pattern) => { - const { found } = new GlobSync(pattern, { cwd: basePath }) - found.forEach((name) => { - const pkg = fs.readJSONSync( - path.resolve(basePath, name, './package.json') - ) - results[pkg.name] = path.resolve(basePath, name, './src') - }) - }) - } - return results -} - -export default { - mode: 'development', - devtool: 'inline-source-map', // 嵌入到源文件中 - stats: { - entrypoints: false, - children: false, - }, - entry: { - playground: path.resolve(__dirname, './main'), - }, - output: { - path: path.resolve(__dirname, '../build'), - filename: '[name].[hash].bundle.js', - }, - resolve: { - modules: ['node_modules'], - extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'], - alias: getWorkspaceAlias(), - }, - externals: { - react: 'React', - 'react-dom': 'ReactDOM', - moment: 'moment', - antd: 'antd', - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: [ - { - loader: require.resolve('ts-loader'), - options: { - transpileOnly: true, - }, - }, - ], - }, - { - test: /\.css$/, - use: [MiniCssExtractPlugin.loader, require.resolve('css-loader')], - }, - { - test: /\.less$/, - use: [ - MiniCssExtractPlugin.loader, - { loader: 'css-loader' }, - { - loader: 'postcss-loader', - options: { - plugins: () => autoprefixer(), - }, - }, - { - loader: 'less-loader', - options: { - // modifyVars: getThemeVariables({ - // dark: true // 开启暗黑模式 - // }), - javascriptEnabled: true, - }, - }, - ], - }, - { - test: /\.s[ac]ss$/i, - use: [ - MiniCssExtractPlugin.loader, - { - loader: 'css-loader', - }, - { - loader: 'postcss-loader', - options: { - plugins: () => autoprefixer(), - }, - }, - { - loader: 'sass-loader', - }, - ], - }, - { - test: /\.(woff|woff2|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/, - use: ['url-loader'], - }, - { - test: /\.html?$/, - loader: require.resolve('file-loader'), - options: { - name: '[name].[ext]', - }, - }, - ], - }, -} diff --git a/designable/next/playground/webpack.dev.ts b/designable/next/playground/webpack.dev.ts deleted file mode 100644 index 710c0570dae..00000000000 --- a/designable/next/playground/webpack.dev.ts +++ /dev/null @@ -1,56 +0,0 @@ -import baseConfig from './webpack.base' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import MonacoPlugin from 'monaco-editor-webpack-plugin' -//import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' -import webpack from 'webpack' -import path from 'path' - -const PORT = 3000 - -const createPages = (pages) => { - return pages.map(({ filename, template, chunk }) => { - return new HtmlWebpackPlugin({ - filename, - template, - inject: 'body', - chunks: chunk, - }) - }) -} - -for (const key in baseConfig.entry) { - if (Array.isArray(baseConfig.entry[key])) { - baseConfig.entry[key].push( - require.resolve('webpack/hot/dev-server'), - `${require.resolve('webpack-dev-server/client')}?http://localhost:${PORT}` - ) - } -} - -export default { - ...baseConfig, - plugins: [ - new MiniCssExtractPlugin({ - filename: '[name].[hash].css', - chunkFilename: '[id].[hash].css', - }), - ...createPages([ - { - filename: 'index.html', - template: path.resolve(__dirname, './template.ejs'), - chunk: ['playground'], - }, - ]), - new webpack.HotModuleReplacementPlugin(), - new MonacoPlugin({ - languages: ['json'], - }), - // new BundleAnalyzerPlugin() - ], - devServer: { - host: '127.0.0.1', - open: true, - port: PORT, - }, -} diff --git a/designable/next/playground/webpack.prod.ts b/designable/next/playground/webpack.prod.ts deleted file mode 100644 index 520f909e4f0..00000000000 --- a/designable/next/playground/webpack.prod.ts +++ /dev/null @@ -1,40 +0,0 @@ -import baseConfig from './webpack.base' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import MiniCssExtractPlugin from 'mini-css-extract-plugin' -import MonacoPlugin from 'monaco-editor-webpack-plugin' -import path from 'path' - -const createPages = (pages) => { - return pages.map(({ filename, template, chunk }) => { - return new HtmlWebpackPlugin({ - filename, - template, - inject: 'body', - chunks: chunk, - }) - }) -} - -export default { - ...baseConfig, - mode: 'production', - plugins: [ - new MiniCssExtractPlugin({ - filename: '[name].[hash].css', - chunkFilename: '[id].[hash].css', - }), - ...createPages([ - { - filename: 'index.html', - template: path.resolve(__dirname, './template.ejs'), - chunk: ['playground'], - }, - ]), - new MonacoPlugin({ - languages: ['json'], - }), - ], - optimization: { - minimize: true, - }, -} diff --git a/designable/next/playground/widgets/ActionsWidget.tsx b/designable/next/playground/widgets/ActionsWidget.tsx deleted file mode 100644 index 6ef85e1c374..00000000000 --- a/designable/next/playground/widgets/ActionsWidget.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React, { useEffect } from 'react' -import { Space, Button, Radio } from 'antd' -import { GithubOutlined } from '@ant-design/icons' -import { useDesigner, TextWidget } from '@designable/react' -import { GlobalRegistry } from '@designable/core' -import { observer } from '@formily/react' -import { loadInitialSchema, saveSchema } from '../service' - -export const ActionsWidget = observer(() => { - const designer = useDesigner() - useEffect(() => { - loadInitialSchema(designer) - }, []) - return ( - - - { - GlobalRegistry.setDesignerLanguage(e.target.value) - }} - /> - - - - - ) -}) diff --git a/designable/next/playground/widgets/LogoWidget.tsx b/designable/next/playground/widgets/LogoWidget.tsx deleted file mode 100644 index fa415acf8c4..00000000000 --- a/designable/next/playground/widgets/LogoWidget.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react' - -export const LogoWidget: React.FC = () => ( -
- -
-) diff --git a/designable/next/playground/widgets/MarkupSchemaWidget.tsx b/designable/next/playground/widgets/MarkupSchemaWidget.tsx deleted file mode 100644 index fe1e9651275..00000000000 --- a/designable/next/playground/widgets/MarkupSchemaWidget.tsx +++ /dev/null @@ -1,157 +0,0 @@ -import React from 'react' -import { TreeNode } from '@designable/core' -import { MonacoInput } from '@designable/react-settings-form' -import { isEmpty, isPlainObj } from '@formily/shared' - -export interface IMarkupSchemaWidgetProps { - tree: TreeNode -} - -const transformToMarkupSchemaCode = (tree: TreeNode) => { - const printAttribute = (node: TreeNode) => { - if (!node) return '' - return `${Object.keys(node.props || {}) - .map((key) => { - if ( - key === '_designableId' || - key === '_isJSONSchemaObject' || - key === 'version' || - key === 'type' - ) - return '' - const value = node.props[key] - if (isPlainObj(value) && isEmpty(value)) return '' - if (typeof value === 'string') return `${key}="${value}"` - return `${key}={${JSON.stringify(value)}}` - }) - .join(' ')}` - } - const printChildren = (node: TreeNode) => { - if (!node) return '' - return node.children - .map((child) => { - return printNode(child) - }) - .join('') - } - const printTag = (node: TreeNode) => { - if (node.props.type === 'string') return 'SchemaField.String' - if (node.props.type === 'number') return 'SchemaField.Number' - if (node.props.type === 'boolean') return 'SchemaField.Boolean' - if (node.props.type === 'date') return 'SchemaField.Date' - if (node.props.type === 'datetime') return 'SchemaField.DateTime' - if (node.props.type === 'array') return 'SchemaField.Array' - if (node.props.type === 'object') return 'SchemaField.Object' - if (node.props.type === 'void') return 'SchemaField.Void' - return 'SchemaField.Markup' - } - const printNode = (node: TreeNode) => { - if (!node) return '' - return `<${printTag(node)} ${printAttribute(node)} ${ - node.children.length - ? `>${printChildren(node)}` - : '/>' - }` - } - const root = tree.find((child) => { - return child.componentName === 'Root' - }) - return `import React, { useMemo } from 'react' -import { createForm } from '@formily/core' -import { createSchemaField } from '@formily/react' -import { - Form, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Space, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, -} from '@formily/next' -import { Card, Range, Rating } from '@alifd/next' - -const Text: React.FC<{ - content?: string - mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p' -}> = ({ mode, content, ...props }) => { - const tagName = mode === 'normal' || !mode ? 'div' : mode - return React.createElement(tagName, props, content) -} - -const SchemaField = createSchemaField({ - components: { - Space, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - Card, - Range, - Rating, - }, -}) - -export default ()=>{ - const form = useMemo(() => createForm(), []) - - return
- - ${printChildren(root)} - -
-} - -` -} - -export const MarkupSchemaWidget: React.FC = ( - props -) => { - return ( - - ) -} diff --git a/designable/next/playground/widgets/PreviewWidget.tsx b/designable/next/playground/widgets/PreviewWidget.tsx deleted file mode 100644 index d3250501804..00000000000 --- a/designable/next/playground/widgets/PreviewWidget.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import React, { useMemo } from 'react' -import { createForm } from '@formily/core' -import { createSchemaField } from '@formily/react' -import { - Form, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Space, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, -} from '@formily/next' -import { Card, Range, Rating } from '@alifd/next' -import { TreeNode } from '@designable/core' -import { transformToSchema } from '@designable/formily' - -const Text: React.FC<{ - content?: string - mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p' -}> = ({ mode, content, ...props }) => { - const tagName = mode === 'normal' || !mode ? 'div' : mode - return React.createElement(tagName, props, content) -} - -const SchemaField = createSchemaField({ - components: { - Space, - FormGrid, - FormLayout, - FormTab, - FormCollapse, - ArrayTable, - ArrayCards, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - Text, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - Card, - Range, - Rating, - }, -}) - -export interface IPreviewWidgetProps { - tree: TreeNode -} - -export const PreviewWidget: React.FC = (props) => { - const form = useMemo(() => createForm(), []) - const { form: formProps, schema } = transformToSchema(props.tree, { - designableFormName: 'Root', - designableFieldName: 'DesignableField', - }) - return ( -
- - - ) -} diff --git a/designable/next/playground/widgets/SchemaEditorWidget.tsx b/designable/next/playground/widgets/SchemaEditorWidget.tsx deleted file mode 100644 index 805703bd94d..00000000000 --- a/designable/next/playground/widgets/SchemaEditorWidget.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import React from 'react' -import { transformToSchema, transformToTreeNode } from '@designable/formily' -import { TreeNode, ITreeNode } from '@designable/core' -import { MonacoInput } from '@designable/react-settings-form' - -export interface ISchemaEditorWidgetProps { - tree: TreeNode - onChange?: (tree: ITreeNode) => void -} - -const Parser = { - designableFormName: 'Root', - designableFieldName: 'DesignableField', -} - -export const SchemaEditorWidget: React.FC = ( - props -) => { - return ( - { - props.onChange?.(transformToTreeNode(JSON.parse(value), Parser)) - }} - language="json" - /> - ) -} diff --git a/designable/next/playground/widgets/index.ts b/designable/next/playground/widgets/index.ts deleted file mode 100644 index 1ca916232fc..00000000000 --- a/designable/next/playground/widgets/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './LogoWidget' -export * from './ActionsWidget' -export * from './PreviewWidget' -export * from './SchemaEditorWidget' -export * from './MarkupSchemaWidget' diff --git a/designable/next/rollup.config.js b/designable/next/rollup.config.js deleted file mode 100644 index 3f5783a93d6..00000000000 --- a/designable/next/rollup.config.js +++ /dev/null @@ -1,27 +0,0 @@ -import baseConfig, { - removeImportStyleFromInputFilePlugin, -} from '../../scripts/rollup.base.js' -import postcss from 'rollup-plugin-postcss' -import NpmImport from 'less-plugin-npm-import' - -export default baseConfig( - 'formily.designable.next', - 'Formily.Designable.Next', - removeImportStyleFromInputFilePlugin(), - postcss({ - extract: true, - minimize: true, - // extensions: ['.css', '.less', '.sass'], - use: { - less: { - plugins: [new NpmImport({ prefix: '~' })], - javascriptEnabled: true, - }, - sass: { - plugins: [new NpmImport({ prefix: '~' })], - javascriptEnabled: true, - }, - stylus: {}, - }, - }) -) diff --git a/designable/next/src/components/DesignableArrayCards/index.tsx b/designable/next/src/components/DesignableArrayCards/index.tsx deleted file mode 100644 index 3f3222dec03..00000000000 --- a/designable/next/src/components/DesignableArrayCards/index.tsx +++ /dev/null @@ -1,245 +0,0 @@ -import React, { Fragment } from 'react' -import { Card } from '@alifd/next' -import { CardProps } from '@alifd/next/types/card' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { useTreeNode, TreeNodeWidget, useNodeIdProps } from '@designable/react' -import { ArrayBase } from '@formily/next' -import { observer } from '@formily/react' -import { LoadTemplate } from '../LoadTemplate' -import cls from 'classnames' -import { useDropTemplate } from '../../hooks' -import { - hasNodeByComponentPath, - queryNodesByComponentPath, - createEnsureTypeItemsNode, - findNodeByComponentPath, - createNodeId, -} from '../../shared' -import './styles.less' - -const ensureVoidItemsNode = createEnsureTypeItemsNode('void') - -const isArrayCardsOperation = (name: string) => - name === 'ArrayCards.Remove' || - name === 'ArrayCards.MoveDown' || - name === 'ArrayCards.MoveUp' - -export const DesignableArrayCards: React.FC = observer((props) => { - const node = useTreeNode() - const nodeId = useNodeIdProps() - const designer = useDropTemplate('ArrayCards', (source) => { - const indexNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.Index', - }, - }) - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.Addition', - }, - }) - const removeNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.Remove', - }, - }) - const moveDownNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.MoveDown', - }, - }) - const moveUpNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.MoveUp', - }, - }) - - const voidNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - }, - children: [indexNode, ...source, removeNode, moveDownNode, moveUpNode], - }) - return [voidNode, additionNode] - }) - const renderCard = () => { - if (node.children.length === 0) return - const additions = queryNodesByComponentPath(node, [ - 'ArrayCards', - 'ArrayCards.Addition', - ]) - const indexes = queryNodesByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.Index', - ]) - const operations = queryNodesByComponentPath(node, [ - 'ArrayCards', - '*', - isArrayCardsOperation, - ]) - const children = queryNodesByComponentPath(node, [ - 'ArrayCards', - '*', - (name) => name.indexOf('ArrayCards.') === -1, - ]) - return ( - - - - {indexes.map((node, key) => ( - - ))} - {props.title} - - } - className={cls('ant-formily-array-cards-item', props.className)} - extra={ - - {operations.map((node) => ( - - ))} - {props.extra} - - } - > -
- {children.length ? ( - children.map((node) => ( - - )) - ) : ( - - )} -
-
-
- {additions.map((node) => ( - - ))} -
- ) - } - - return ( -
- {renderCard()} - { - if ( - hasNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.Index', - ]) - ) - return - const indexNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.Index', - }, - }) - ensureVoidItemsNode(node).appendNode(indexNode) - }, - }, - - { - title: 'Common.addOperation', - onClick: () => { - const oldAdditionNode = findNodeByComponentPath(node, [ - 'ArrayCards', - 'ArrayCards.Addition', - ]) - if (!oldAdditionNode) { - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayCards.Addition', - }, - }) - ensureVoidItemsNode(node).insertAfter(additionNode) - } - const oldRemoveNode = findNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.Remove', - ]) - const oldMoveDownNode = findNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.MoveDown', - ]) - const oldMoveUpNode = findNodeByComponentPath(node, [ - 'ArrayCards', - '*', - 'ArrayCards.MoveUp', - ]) - if (!oldRemoveNode) { - ensureVoidItemsNode(node).appendNode( - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.Remove', - }, - }) - ) - } - if (!oldMoveDownNode) { - ensureVoidItemsNode(node).appendNode( - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.MoveDown', - }, - }) - ) - } - if (!oldMoveUpNode) { - ensureVoidItemsNode(node).appendNode( - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayCards.MoveUp', - }, - }) - ) - } - }, - }, - ]} - /> -
- ) -}) - -ArrayBase.mixin(DesignableArrayCards) diff --git a/designable/next/src/components/DesignableArrayCards/styles.less b/designable/next/src/components/DesignableArrayCards/styles.less deleted file mode 100644 index 67e6789cd21..00000000000 --- a/designable/next/src/components/DesignableArrayCards/styles.less +++ /dev/null @@ -1,5 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-array-cards { - background-color: @background-color-light; -} diff --git a/designable/next/src/components/DesignableArrayCollapse/index.tsx b/designable/next/src/components/DesignableArrayCollapse/index.tsx deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/designable/next/src/components/DesignableArrayItems/index.tsx b/designable/next/src/components/DesignableArrayItems/index.tsx deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/designable/next/src/components/DesignableArrayTable/index.tsx b/designable/next/src/components/DesignableArrayTable/index.tsx deleted file mode 100644 index d55886020b7..00000000000 --- a/designable/next/src/components/DesignableArrayTable/index.tsx +++ /dev/null @@ -1,329 +0,0 @@ -import React from 'react' -import { Table } from '@alifd/next' -import { TableProps } from '@alifd/next/types/table' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { useTreeNode, TreeNodeWidget, useNodeIdProps } from '@designable/react' -import { ArrayBase } from '@formily/next' -import { observer } from '@formily/react' -import { LoadTemplate } from '../LoadTemplate' -import cls from 'classnames' -import { - createNodeId, - queryNodesByComponentPath, - hasNodeByComponentPath, - findNodeByComponentPath, - createEnsureTypeItemsNode, -} from '../../shared' -import { useDropTemplate } from '../../hooks' -import './styles.less' - -const ensureObjectItemsNode = createEnsureTypeItemsNode('object') - -export const DesignableArrayTable: React.FC = observer((props) => { - const node = useTreeNode() - const nodeId = useNodeIdProps() - const designer = useDropTemplate('ArrayTable', (source) => { - const indexNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Index', - }, - }, - ], - }) - const columnNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: source.map((node) => { - node.props.title = undefined - return node - }), - }) - - const operationNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Remove', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveDown', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveUp', - }, - }, - ], - }) - const objectNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'object', - }, - children: [indexNode, columnNode, operationNode], - }) - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayTable.Addition', - }, - }) - return [objectNode, additionNode] - }) - const columns = queryNodesByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - ]) - const additions = queryNodesByComponentPath(node, [ - 'ArrayTable', - 'ArrayTable.Addition', - ]) - const defaultRowKey = () => { - return node.id - } - - const renderTable = () => { - if (node.children.length === 0) return - return ( - - - {columns.map((node, key) => { - const children = node.children.map((child) => { - return - }) - return ( - { - return ( - - {children.length > 0 ? children : 'Droppable'} - - ) - }} - /> - ) - })} - {columns.length === 0 && } />} -
- {additions.map((child) => { - return - })} -
- ) - } - - useDropTemplate('ArrayTable.Column', (source) => { - return source.map((node) => { - node.props.title = undefined - return node - }) - }) - - return ( -
- {renderTable()} - { - if ( - hasNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - 'ArrayTable.Index', - ]) - ) - return - const tableColumn = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Index', - }, - }, - ], - }) - const sortNode = findNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - 'ArrayTable.SortHandle', - ]) - if (sortNode) { - sortNode.parent.insertAfter(tableColumn) - } else { - ensureObjectItemsNode(node).prependNode(tableColumn) - } - }, - }, - { - title: 'Common.addTableColumn', - onClick: () => { - const operationNode = findNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - (name) => { - return ( - name === 'ArrayTable.Remove' || - name === 'ArrayTable.MoveDown' || - name === 'ArrayTable.MoveUp' - ) - }, - ]) - const tableColumn = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - }) - if (operationNode) { - operationNode.parent.insertBefore(tableColumn) - } else { - ensureObjectItemsNode(node).appendNode(tableColumn) - } - }, - }, - { - title: 'Common.addOperation', - onClick: () => { - const oldOperationNode = findNodeByComponentPath(node, [ - 'ArrayTable', - '*', - 'ArrayTable.Column', - (name) => { - return ( - name === 'ArrayTable.Remove' || - name === 'ArrayTable.MoveDown' || - name === 'ArrayTable.MoveUp' - ) - }, - ]) - const oldAdditionNode = findNodeByComponentPath(node, [ - 'ArrayTable', - 'ArrayTable.Addition', - ]) - if (!oldOperationNode) { - const operationNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Column', - 'x-component-props': { - title: `Title`, - }, - }, - children: [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.Remove', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveDown', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'ArrayTable.MoveUp', - }, - }, - ], - }) - ensureObjectItemsNode(node).appendNode(operationNode) - } - if (!oldAdditionNode) { - const additionNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - title: 'Addition', - 'x-component': 'ArrayTable.Addition', - }, - }) - ensureObjectItemsNode(node).insertAfter(additionNode) - } - }, - }, - ]} - /> -
- ) -}) - -ArrayBase.mixin(DesignableArrayTable) diff --git a/designable/next/src/components/DesignableArrayTable/styles.less b/designable/next/src/components/DesignableArrayTable/styles.less deleted file mode 100644 index a45490e2904..00000000000 --- a/designable/next/src/components/DesignableArrayTable/styles.less +++ /dev/null @@ -1,5 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-array-table { - background-color: @background-color-light; -} diff --git a/designable/next/src/components/DesignableArrayTabs/index.tsx b/designable/next/src/components/DesignableArrayTabs/index.tsx deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/designable/next/src/components/DesignableContainer/index.tsx b/designable/next/src/components/DesignableContainer/index.tsx deleted file mode 100644 index a892319c8c7..00000000000 --- a/designable/next/src/components/DesignableContainer/index.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import { useNodeIdProps } from '@designable/react' -import { Droppable } from '../Droppable' -import './styles.less' - -export const createDesignableContainer = ( - Target: React.JSXElementConstructor -) => { - return (props: any) => { - const nodeId = useNodeIdProps() - if (props.children) { - return ( -
- {props.children} -
- ) - } - return - } -} diff --git a/designable/next/src/components/DesignableContainer/styles.less b/designable/next/src/components/DesignableContainer/styles.less deleted file mode 100644 index e0f5c30388e..00000000000 --- a/designable/next/src/components/DesignableContainer/styles.less +++ /dev/null @@ -1,7 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-form-container { - margin: 0 !important; - padding: 20px; - border: 1px solid @border-color-split; -} diff --git a/designable/next/src/components/DesignableField/index.tsx b/designable/next/src/components/DesignableField/index.tsx deleted file mode 100644 index 5c4b7b2a2b3..00000000000 --- a/designable/next/src/components/DesignableField/index.tsx +++ /dev/null @@ -1,437 +0,0 @@ -import React from 'react' -import { FormPath } from '@formily/core' -import { GlobalRegistry, TreeNode } from '@designable/core' -import { useDesigner, useTreeNode } from '@designable/react' -import { - ArrayField, - Field, - ObjectField, - VoidField, - observer, - Schema, - ISchema, -} from '@formily/react' -import { - DataSourceSetter, - ReactionsSetter, - ValidatorSetter, -} from '@formily/designable-setters' -import { FormTab, FormItem } from '@formily/antd' -import { isArr, isStr, each, reduce } from '@formily/shared' -import { FormItemSwitcher } from '../FormItemSwitcher' -import { DesignableObject } from '../DesignableObject' -import { createOptions } from './options' -import { IDesignableFieldFactoryProps } from './types' -import { includesComponent } from '../../shared' -import * as defaultSchemas from '../../schemas' - -Schema.silent() - -const SchemaStateMap = { - title: 'title', - description: 'description', - default: 'value', - enum: 'dataSource', - readOnly: 'readOnly', - writeOnly: 'editable', - required: 'required', - 'x-content': 'content', - 'x-value': 'value', - 'x-editable': 'editable', - 'x-disabled': 'disabled', - 'x-read-pretty': 'readPretty', - 'x-read-only': 'readOnly', - 'x-visible': 'visible', - 'x-hidden': 'hidden', - 'x-display': 'display', - 'x-pattern': 'pattern', -} - -const NeedShownExpression = { - title: true, - description: true, - default: true, - 'x-content': true, - 'x-value': true, -} - -const isExpression = (val: any) => isStr(val) && /^\{\{.*\}\}$/.test(val) - -const filterExpression = (val: any) => { - if (typeof val === 'object') { - const isArray = isArr(val) - const results = reduce( - val, - (buf: any, value, key) => { - if (isExpression(value)) { - return buf - } else { - const results = filterExpression(value) - if (results === undefined || results === null) return buf - if (isArray) { - return buf.concat([results]) - } - buf[key] = results - return buf - } - }, - isArray ? [] : {} - ) - return results - } - if (isExpression(val)) { - return - } - return val -} - -const toDesignableFieldProps = ( - schema: ISchema, - components: any, - nodeIdAttrName: string, - id: string -) => { - const results: any = {} - each(SchemaStateMap, (fieldKey, schemaKey) => { - const value = schema[schemaKey] - if (isExpression(value)) { - if (!NeedShownExpression[schemaKey]) return - if (value) { - results[fieldKey] = value - return - } - } else if (value) { - results[fieldKey] = filterExpression(value) - } - }) - if (!components['FormItem']) { - components['FormItem'] = FormItem - } - const decorator = - schema['x-decorator'] && FormPath.getIn(components, schema['x-decorator']) - const component = - schema['x-component'] && FormPath.getIn(components, schema['x-component']) - const decoratorProps = schema['x-decorator-props'] || {} - const componentProps = schema['x-component-props'] || {} - - if (decorator) { - results.decorator = [decorator, { ...decoratorProps }] - } - if (component) { - results.component = [component, { ...componentProps }] - } - if (decorator) { - FormPath.setIn(results['decorator'][1], nodeIdAttrName, id) - } else if (component) { - FormPath.setIn(results['component'][1], nodeIdAttrName, id) - } - results.title = results.title && ( - {results.title} - ) - results.description = results.description && ( - {results.description} - ) - return results -} - -export const createDesignableField = ( - options: IDesignableFieldFactoryProps -) => { - const realOptions = createOptions(options) - const tabs = {} - - const getFieldPropsSchema = (node: TreeNode): ISchema => { - const decorator = node.props['x-decorator'] - const component = node.props['x-component'] - const decoratorSchema = - decorator && - (FormPath.getIn(realOptions.componentsPropsSchema, decorator) || - FormPath.getIn(defaultSchemas, decorator)) - const componentSchema = - component && - (FormPath.getIn(realOptions.componentsPropsSchema, component) || - FormPath.getIn(defaultSchemas, component)) - const TabSchema = (key: string, schema: ISchema) => { - tabs[key] = tabs[key] || FormTab.createFormTab() - return { - type: 'object', - properties: { - propsTab: { - type: 'void', - 'x-component': 'FormTab', - 'x-component-props': { - formTab: tabs[key], - style: { - overflow: 'visible', - }, - }, - properties: { - propsPane: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - tab: GlobalRegistry.getDesignerMessage( - `settings.${key}.tab_property` - ), - }, - properties: schema.properties, - }, - stylePane: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - tab: GlobalRegistry.getDesignerMessage( - `settings.${key}.tab_style` - ), - }, - properties: { - style: defaultSchemas.CSSStyle, - }, - }, - }, - }, - }, - } - } - const base = { - type: 'object', - properties: { - name: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - defaultValue: node.id, - }, - 'x-index': 0, - }, - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-index': 1, - }, - description: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - 'x-index': 2, - }, - 'x-display': { - type: 'string', - enum: ['visible', 'hidden', 'none', ''], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'visible', - }, - 'x-index': 3, - }, - 'x-pattern': { - type: 'string', - enum: ['editable', 'disabled', 'readOnly', 'readPretty', ''], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'editable', - }, - 'x-index': 4, - }, - 'x-component-props': - componentSchema && TabSchema('x-component-props', componentSchema), - 'x-decorator-props': - decoratorSchema && TabSchema('x-decorator-props', decoratorSchema), - }, - } - - if (node.props.type === 'void') { - if (!includesComponent(node, realOptions.dropReactionComponents)) { - Object.assign(base.properties, { - 'x-reactions': { - 'x-decorator': 'FormItem', - 'x-index': 5, - 'x-component': ReactionsSetter, - }, - }) - } - if (!includesComponent(node, realOptions.dropFormItemComponents)) { - Object.assign(base.properties, { - 'x-decorator': { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': FormItemSwitcher, - 'x-index': 10, - 'x-reactions': { - target: '*(title,description)', - fulfill: { - state: { - hidden: '{{$self.value !== "FormItem"}}', - }, - }, - }, - }, - }) - } else { - delete base.properties.title - delete base.properties.description - } - } else { - if (!includesComponent(node, realOptions.dropReactionComponents)) { - Object.assign(base.properties, { - 'x-reactions': { - 'x-decorator': 'FormItem', - 'x-index': 7, - 'x-component': ReactionsSetter, - }, - }) - } - Object.assign(base.properties, { - default: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-index': 5, - }, - enum: { - 'x-decorator': 'FormItem', - 'x-component': DataSourceSetter, - 'x-index': 6, - }, - 'x-validator': { - type: 'array', - 'x-component': ValidatorSetter, - 'x-index': 8, - }, - required: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-index': 9, - }, - }) - } - - base['$namespace'] = `namespace.${component}` - - return base - } - - const calculateChildrenRestricts = (target: TreeNode, source: TreeNode[]) => { - const targetComponent = target.props['x-component'] - const restrictChildrenComponents = - realOptions.restrictChildrenComponents?.[targetComponent] - if (restrictChildrenComponents?.length) { - if ( - source.every((node) => - includesComponent(node, restrictChildrenComponents, target) - ) - ) { - return true - } - return false - } - return true - } - - const calculateSiblingsRestricts = (target: TreeNode, source: TreeNode[]) => { - const targetComponent = target.props['x-component'] - const restrictSiblingComponents = - realOptions.restrictSiblingComponents?.[targetComponent] - if (restrictSiblingComponents?.length) { - if ( - source.every((node) => - includesComponent(node, restrictSiblingComponents, target) - ) - ) { - return true - } - return false - } - return true - } - - if (!realOptions.registryName) throw new Error('Can not found registryName') - - GlobalRegistry.registerDesignerProps({ - [realOptions.registryName]: (node) => { - const componentName = node.props?.['x-component'] - const message = GlobalRegistry.getDesignerMessage( - `components.${componentName}` - ) - const isObjectNode = node.props.type === 'object' - const isArrayNode = node.props.type === 'array' - const isVoidNode = node.props.type === 'void' - const title = typeof message === 'string' ? message : message?.title - const nodeTitle = - title || - (isObjectNode - ? GlobalRegistry.getDesignerMessage('components.Object') - : isVoidNode - ? GlobalRegistry.getDesignerMessage('components.Void') - : '') - const sourceIcon = realOptions.componentsSourceIcon?.[componentName] - return { - title: nodeTitle, - sourceIcon: isObjectNode ? 'ObjectSource' : sourceIcon, - icon: realOptions.componentsIcon?.[componentName], - draggable: true, - droppable: isObjectNode || isArrayNode || isVoidNode, - selfRenderChildren: - isArrayNode || - includesComponent(node, realOptions.selfRenderChildrenComponents), - inlineLayout: includesComponent( - node, - realOptions.inlineLayoutComponents - ), - inlineChildrenLayout: includesComponent( - node, - realOptions.inlineChildrenLayoutComponents - ), - allowSiblings(target, source) { - return calculateSiblingsRestricts(target, source) - }, - allowAppend(target, source) { - return ( - (target.props.type === 'void' || - target.props.type === 'array' || - target.props.type === 'object') && - calculateChildrenRestricts(target, source) - ) - }, - propsSchema: getFieldPropsSchema(node), - } - }, - }) - - const DesignableField: React.FC = observer((props) => { - const designer = useDesigner() - const node = useTreeNode() - if (!node) return null - - const fieldProps = toDesignableFieldProps( - props, - realOptions.components, - designer.props.nodeIdAttrName, - node.id - ) - if (props.type === 'object') { - return ( - - - {props.children} - - - ) - } else if (props.type === 'array') { - return - } else if (node.props.type === 'void') { - return ( - - {props.children} - - ) - } - return - }) - - return DesignableField -} diff --git a/designable/next/src/components/DesignableField/options.ts b/designable/next/src/components/DesignableField/options.ts deleted file mode 100644 index 71560594cd5..00000000000 --- a/designable/next/src/components/DesignableField/options.ts +++ /dev/null @@ -1,186 +0,0 @@ -import { IDesignableFieldFactoryProps } from './types' -import { - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Space, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - FormGrid, - FormLayout, -} from '@formily/next' -import { Card, Range, Rating } from '@alifd/next' -import { createDesignableContainer } from '../DesignableContainer' -import { DesignableFormTab } from '../DesignableFormTab' -import { DesignableFormCollapse } from '../DesignableFormCollapse' -import { DesignableArrayTable } from '../DesignableArrayTable' -import { DesignableArrayCards } from '../DesignableArrayCards' -import { DesignableText } from '../DesignableText' -import { TreeNode } from '@designable/core' - -const isChildrenComponents = - (parentName: string, names?: string[]) => (name: string) => - Array.isArray(names) && names.length > 0 - ? names.some((key) => { - return `${parentName}.${key}` === name - }) - : name.indexOf(`${parentName}.`) > -1 - -const InlineArrayChildren = [ - 'Column', - 'Index', - 'SortHandle', - 'Remove', - 'MoveDown', - 'MoveUp', -] - -const isFormTabChildren = isChildrenComponents('FormTab') -const isFormCollapseChildren = isChildrenComponents('FormCollapse') -const isArrayTableInlineChildren = isChildrenComponents( - 'ArrayTable', - InlineArrayChildren -) -const isArrayCardsInlineChildren = isChildrenComponents( - 'ArrayCards', - InlineArrayChildren -) -const isObjectNode = (name: string, node: TreeNode) => { - return node.props['type'] === 'object' -} - -const isNotArrayColumn = (name: string, node: TreeNode) => { - return node.props['x-component'] !== 'ArrayTable.Column' -} - -const allowDropWithEmpty = (name: string, node: TreeNode, target: TreeNode) => { - if (target) return target.children.length === 0 - return false -} - -const noChildren = () => false - -export const createOptions = ( - options: IDesignableFieldFactoryProps -): IDesignableFieldFactoryProps => { - return { - ...options, - dropFormItemComponents: [ - ...(options.dropFormItemComponents || []), - isFormTabChildren, - isFormCollapseChildren, - ], - dropReactionComponents: [ - ...(options.dropReactionComponents || []), - isFormTabChildren, - isFormCollapseChildren, - ], - selfRenderChildrenComponents: [ - ...(options.selfRenderChildrenComponents || []), - 'FormTab', - 'FormCollapse', - ], - inlineChildrenLayoutComponents: [ - ...(options.inlineChildrenLayoutComponents || []), - 'FormItem', - 'FormGrid', - 'Space', - ], - inlineLayoutComponents: [ - ...(options.inlineLayoutComponents || []), - isArrayTableInlineChildren, - isArrayCardsInlineChildren, - ], - restrictChildrenComponents: { - FormTab: [allowDropWithEmpty, 'FormTab.TabPane'], - FormCollapse: [allowDropWithEmpty, 'FormCollapse.CollapsePanel'], - ArrayTable: [allowDropWithEmpty, isObjectNode, 'ArrayTable.Addition'], - 'ArrayTable.Column': [isNotArrayColumn], - Text: [noChildren], - }, - restrictSiblingComponents: { - 'FormTab.TabPane': ['FormTab.TabPane'], - 'FormCollapse.CollapsePanel': ['FormCollapse.CollapsePanel'], - 'ArrayTable.Column': ['ArrayTable.Column'], - }, - componentsSourceIcon: { - ...options.componentsSourceIcon, - Space: 'SpaceSource', - FormGrid: 'GridSource', - FormTab: 'TabSource', - FormCollapse: 'CollapseSource', - ArrayTable: 'ArrayTableSource', - ArrayCards: 'ArrayCardsSource', - DatePicker: 'DatePickerSource', - 'DatePicker.RangePicker': 'DateRangePickerSource', - 'Checkbox.Group': 'CheckboxGroupSource', - 'Radio.Group': 'RadioGroupSource', - Range: 'SliderSource', - Rating: 'RateSource', - TimePicker: 'TimePickerSource', - 'TimePicker.RangePicker': 'TimeRangePickerSource', - Cascader: 'CascaderSource', - TreeSelect: 'TreeSelectSource', - Select: 'SelectSource', - 'Input.TextArea': 'TextAreaSource', - Input: 'InputSource', - NumberPicker: 'NumberPickerSource', - Password: 'PasswordSource', - Transfer: 'TransferSource', - Switch: 'SwitchSource', - Upload: 'UploadSource', - 'Upload.Dragger': 'UploadDraggerSource', - Card: 'CardSource', - FormLayout: 'FormLayoutSource', - Text: 'TextSource', - Image: 'ImageSource', - Button: 'ButtonSource', - Video: 'MediaSource', - }, - components: { - ...options.components, - Space: createDesignableContainer(Space), - FormGrid: createDesignableContainer(FormGrid), - FormLayout: createDesignableContainer(FormLayout), - FormTab: DesignableFormTab, - FormCollapse: DesignableFormCollapse, - ArrayTable: DesignableArrayTable, - ArrayCards: DesignableArrayCards, - Text: DesignableText, - FormItem, - DatePicker, - Checkbox, - Cascader, - Editable, - Input, - NumberPicker, - Switch, - Password, - PreviewText, - Radio, - Reset, - Select, - Submit, - TimePicker, - Transfer, - TreeSelect, - Upload, - Card, - Range, - Rating, - }, - } -} diff --git a/designable/next/src/components/DesignableField/types.ts b/designable/next/src/components/DesignableField/types.ts deleted file mode 100644 index ca1b59f7aab..00000000000 --- a/designable/next/src/components/DesignableField/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { ISchema } from '@formily/react' -import { ComponentNameMatcher } from '../../shared' -export interface IDesignableFieldFactoryProps { - registryName: string - components?: Record> - componentsIcon?: Record - componentsSourceIcon?: Record - componentsPropsSchema?: Record - dropFormItemComponents?: ComponentNameMatcher[] - dropReactionComponents?: ComponentNameMatcher[] - selfRenderChildrenComponents?: ComponentNameMatcher[] - inlineChildrenLayoutComponents?: ComponentNameMatcher[] - inlineLayoutComponents?: ComponentNameMatcher[] - restrictChildrenComponents?: Record - restrictSiblingComponents?: Record -} diff --git a/designable/next/src/components/DesignableForm/index.tsx b/designable/next/src/components/DesignableForm/index.tsx deleted file mode 100644 index 8f691abbff9..00000000000 --- a/designable/next/src/components/DesignableForm/index.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import React, { useMemo } from 'react' -import { IDesignerProps, GlobalRegistry } from '@designable/core' -import { createForm } from '@formily/core' -import { Form, IFormLayoutProps } from '@formily/next' -import { observer } from '@formily/react' -import { usePrefix } from '@designable/react' -import { Form as FormPropsSchema } from '../../schemas' -import './styles.scss' - -export interface IDesignableFormFactoryProps extends IDesignerProps { - registryName: string - component?: React.JSXElementConstructor -} - -export const createDesignableForm = (options: IDesignableFormFactoryProps) => { - const realOptions: IDesignableFormFactoryProps = { - component: Form, - droppable: true, - draggable: false, - propsSchema: FormPropsSchema, - ...options, - defaultProps: { - labelCol: 6, - wrapperCol: 12, - ...options.defaultProps, - }, - } - - const FormComponent = realOptions.component || Form - - const DesignableForm: React.FC = observer((props) => { - const prefix = usePrefix('designable-form') - const form = useMemo( - () => - createForm({ - designable: true, - }), - [] - ) - return ( - - {props.children} - - ) - }) - - if (!realOptions.registryName) throw new Error('Can not found registryName') - - realOptions.title = `components.${realOptions.registryName}` - - GlobalRegistry.registerDesignerProps({ - [realOptions.registryName]: realOptions, - }) - - return DesignableForm -} diff --git a/designable/next/src/components/DesignableForm/styles.scss b/designable/next/src/components/DesignableForm/styles.scss deleted file mode 100644 index 857cadf3928..00000000000 --- a/designable/next/src/components/DesignableForm/styles.scss +++ /dev/null @@ -1,40 +0,0 @@ -@import '~@alifd/next/lib/core/style/global'; - -$next-prefix: $css-prefix; - -@mixin none-pointer-events($selector, $important: true) { - #{$selector} { - pointer-events: none #{if($important, !important, '')}; - } -} - -@mixin designable-bootstrap($components...) { - .dn-designable-form { - @each $component in $components { - $selector: #{$next-prefix}#{$component}; - @include none-pointer-events('.#{$selector}, .#{$selector} input'); - } - @include none-pointer-events('.anticon svg', false); - } -} - -@include designable-bootstrap( - 'input', - 'input-textarea', - 'select', - 'radio-group', - 'range', - 'cascader', - 'switch', - 'checkbox-group', - 'date-picker', - 'range-picker', - 'month-picker', - 'year-picker', - 'week-picker', - 'time-picker', - 'rating', - 'transfer', - 'tree-select', - 'upload' -); diff --git a/designable/next/src/components/DesignableFormCollapse/index.tsx b/designable/next/src/components/DesignableFormCollapse/index.tsx deleted file mode 100644 index a38e4cf85d3..00000000000 --- a/designable/next/src/components/DesignableFormCollapse/index.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import React, { Fragment, useState } from 'react' -import { observer } from '@formily/react' -import { toArr } from '@formily/shared' -import { Collapse } from '@alifd/next' -import type { - CollapseProps, - PanelProps as CollapsePanelProps, -} from '@alifd/next/types/collapse' -import { useTreeNode, useNodeIdProps, TreeNodeWidget } from '@designable/react' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { LoadTemplate } from '../LoadTemplate' -import { useDropTemplate } from '../../hooks' -import { matchComponent } from '../../shared' - -const parseCollpase = (parent: TreeNode) => { - const panels: TreeNode[] = [] - parent.children.forEach((node) => { - if (matchComponent(node, 'FormCollapse.CollapsePanel')) { - panels.push(node) - } - }) - return panels -} - -export const DesignableFormCollapse: React.FC & { - CollapsePanel?: React.FC -} = observer((props) => { - const [expandedKeys, setExpandedKeys] = useState([]) - const node = useTreeNode() - const nodeId = useNodeIdProps() - const designer = useDropTemplate('FormCollapse', (source) => { - const panelNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormCollapse.CollapsePanel', - 'x-component-props': { - title: `Unnamed Title`, - }, - }, - children: source, - }) - - setExpandedKeys([...expandedKeys, panelNode.id]) - return [panelNode] - }) - - const panels = parseCollpase(node) - - const renderCollapse = () => { - if (!node.children?.length) return - return ( - { - setExpandedKeys(toArr(expandedKeys)) - }} - > - {panels.map((panel) => { - const props = panel.props['x-component-props'] || {} - return ( - - {React.createElement( - 'div', - { - [designer.props.nodeIdAttrName]: panel.id, - }, - panel.children.length ? ( - - ) : ( - - ) - )} - - ) - })} - - ) - } - return ( -
- {renderCollapse()} - { - const collapsePanel = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormCollapse.CollapsePanel', - 'x-component-props': { - title: `Unnamed Title`, - }, - }, - }) - node.appendNode(collapsePanel) - setExpandedKeys([...expandedKeys, collapsePanel.id]) - }, - }, - ]} - /> -
- ) -}) - -DesignableFormCollapse.CollapsePanel = (props) => { - return {props.children} -} diff --git a/designable/next/src/components/DesignableFormTab/index.tsx b/designable/next/src/components/DesignableFormTab/index.tsx deleted file mode 100644 index 1848d5b5273..00000000000 --- a/designable/next/src/components/DesignableFormTab/index.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import React, { Fragment, useState } from 'react' -import { observer } from '@formily/react' -import { Tab } from '@alifd/next' -import { ItemProps, TabProps } from '@alifd/next/types/tab' -import { useNodeIdProps, useTreeNode, TreeNodeWidget } from '@designable/react' -import { Droppable } from '../Droppable' -import { TreeNode } from '@designable/core' -import { LoadTemplate } from '../LoadTemplate' -import { useDropTemplate } from '../../hooks' -import { matchComponent } from '../../shared' - -const parseTabs = (parent: TreeNode) => { - const tabs: TreeNode[] = [] - parent.children.forEach((node) => { - if (matchComponent(node, 'FormTab.TabPane')) { - tabs.push(node) - } - }) - return tabs -} - -const getCorrectActiveKey = (activeKey: string, tabs: TreeNode[]) => { - if (tabs.length === 0) return - if (tabs.some((node) => node.id === activeKey)) return activeKey - return tabs[tabs.length - 1].id -} - -export const DesignableFormTab: React.FC & { - TabPane?: React.FC -} = observer((props) => { - const [activeKey, setActiveKey] = useState() - const nodeId = useNodeIdProps() - const node = useTreeNode() - const designer = useDropTemplate('FormTab', (source) => { - return [ - new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - title: `Unnamed Title`, - }, - }, - children: source, - }), - ] - }) - const tabs = parseTabs(node) - const renderTabs = () => { - if (!node.children?.length) return - return ( - { - setActiveKey(id) - }} - > - {tabs.map((tab) => { - const props = tab.props['x-component-props'] || {} - return ( - - {React.createElement( - 'div', - { - [designer.props.nodeIdAttrName]: tab.id, - }, - tab.children.length ? ( - - ) : ( - - ) - )} - - ) - })} - - ) - } - return ( -
- {renderTabs()} - { - const tabPane = new TreeNode({ - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormTab.TabPane', - 'x-component-props': { - title: `Unnamed Title`, - }, - }, - }) - node.appendNode(tabPane) - setActiveKey(tabPane.id) - }, - }, - ]} - /> -
- ) -}) - -DesignableFormTab.TabPane = (props) => { - return {props.children} -} diff --git a/designable/next/src/components/DesignableObject/index.tsx b/designable/next/src/components/DesignableObject/index.tsx deleted file mode 100644 index b894214f3d8..00000000000 --- a/designable/next/src/components/DesignableObject/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react' -import { useNodeIdProps, useTreeNode } from '@designable/react' -import { Droppable } from '../Droppable' - -export const DesignableObject: React.FC = (props) => { - const node = useTreeNode() - const nodeId = useNodeIdProps() - if (node.children.length === 0) return - return
{props.children}
-} diff --git a/designable/next/src/components/DesignableText/index.tsx b/designable/next/src/components/DesignableText/index.tsx deleted file mode 100644 index 6b08755dbf8..00000000000 --- a/designable/next/src/components/DesignableText/index.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react' -import { useDesigner } from '@designable/react' -import cls from 'classnames' -import './styles.less' - -export interface IDesignableTextProps { - content?: string - mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p' - style?: React.CSSProperties - className?: string -} - -export const DesignableText: React.FC = (props) => { - const designer = useDesigner() - const tagName = props.mode === 'normal' || !props.mode ? 'div' : props.mode - return React.createElement( - tagName, - { - ...props, - className: cls(props.className, 'dn-text'), - [designer.props.contentEditableAttrName]: 'x-component-props.content', - }, - props.content - ) -} diff --git a/designable/next/src/components/DesignableText/styles.less b/designable/next/src/components/DesignableText/styles.less deleted file mode 100644 index a55fac3c947..00000000000 --- a/designable/next/src/components/DesignableText/styles.less +++ /dev/null @@ -1,10 +0,0 @@ -.dn-text { - &:empty::before { - content: 'Please Input'; - display: block; - opacity: 0.6; - } - &:focus{ - padding: 4px; - } -} diff --git a/designable/next/src/components/Droppable/index.tsx b/designable/next/src/components/Droppable/index.tsx deleted file mode 100644 index 0802ab99f5e..00000000000 --- a/designable/next/src/components/Droppable/index.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react' -import { usePrefix, TextWidget } from '@designable/react' -import { Empty } from 'antd' -import cls from 'classnames' -import './styles.less' - -export interface IDroppableProps { - style?: React.CSSProperties - className?: string -} - -export const Droppable: React.FC = (props: any) => { - const prefix = usePrefix('droppable') - return ( - } - /> - ) -} diff --git a/designable/next/src/components/Droppable/styles.less b/designable/next/src/components/Droppable/styles.less deleted file mode 100644 index d175c36436a..00000000000 --- a/designable/next/src/components/Droppable/styles.less +++ /dev/null @@ -1,9 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-droppable { - margin-left: 0 !important; - margin-right: 0 !important; - padding: 20px; - border: 1px solid @border-color-split; - color: @text-color; -} diff --git a/designable/next/src/components/FormItemSwitcher/index.tsx b/designable/next/src/components/FormItemSwitcher/index.tsx deleted file mode 100644 index 04134856fbd..00000000000 --- a/designable/next/src/components/FormItemSwitcher/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react' -import { Switch } from 'antd' - -export interface IFormItemSwitcherProps { - value?: string - onChange?: (value: string) => void -} - -export const FormItemSwitcher: React.FC = (props) => { - return ( - { - props.onChange(value ? 'FormItem' : undefined) - }} - /> - ) -} diff --git a/designable/next/src/components/LoadTemplate/index.tsx b/designable/next/src/components/LoadTemplate/index.tsx deleted file mode 100644 index 3bd2e9fa764..00000000000 --- a/designable/next/src/components/LoadTemplate/index.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React from 'react' -import { Button } from '@alifd/next' -import { Space, Divider } from 'antd' -import { usePrefix, TextWidget } from '@designable/react' -import cls from 'classnames' -import './styles.scss' - -export interface ITemplateAction { - title: React.ReactNode - tooltip?: React.ReactNode - icon?: string | React.ReactNode - onClick: () => void -} - -export interface ILoadTemplateProps { - className?: string - style?: React.CSSProperties - actions?: ITemplateAction[] -} - -export const LoadTemplate: React.FC = (props) => { - const prefix = usePrefix('load-template') - return ( -
-
- }> - {props.actions?.map((action, key) => { - return ( - - ) - })} - -
-
- ) -} diff --git a/designable/next/src/components/LoadTemplate/styles.scss b/designable/next/src/components/LoadTemplate/styles.scss deleted file mode 100644 index 152a6f3469d..00000000000 --- a/designable/next/src/components/LoadTemplate/styles.scss +++ /dev/null @@ -1,35 +0,0 @@ -@import '~@alifd/next/lib/core/style/_color.scss'; - -.dn-load-template { - display: flex; - align-items: center; - justify-content: center; - width: 100%; - overflow: hidden; - padding-top: 10px; - padding-bottom: 10px; - &-actions { - position: relative; - padding: 0 20px; - &::before { - position: absolute; - content: ''; - display: block; - height: 0; - width: 300%; - top: 50%; - border-bottom: 2px dashed $color-line1-2; - right: 100%; - } - &::after { - position: absolute; - content: ''; - display: block; - height: 0; - width: 300%; - top: 50%; - border-bottom: 2px dashed $color-line1-2; - left: 100%; - } - } -} diff --git a/designable/next/src/components/index.ts b/designable/next/src/components/index.ts deleted file mode 100644 index 19322276aac..00000000000 --- a/designable/next/src/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './DesignableField' -export * from './DesignableForm' diff --git a/designable/next/src/hooks/index.ts b/designable/next/src/hooks/index.ts deleted file mode 100644 index 6ab5860beb4..00000000000 --- a/designable/next/src/hooks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './useDropTemplate' diff --git a/designable/next/src/hooks/useDropTemplate.ts b/designable/next/src/hooks/useDropTemplate.ts deleted file mode 100644 index 89a13ad3181..00000000000 --- a/designable/next/src/hooks/useDropTemplate.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { AppendNodeEvent, TreeNode } from '@designable/core' -import { useDesigner } from '@designable/react' -import { matchComponent, matchChildComponent } from '../shared' - -export const useDropTemplate = ( - name: string, - getChildren: (source: TreeNode[]) => TreeNode[] -) => { - return useDesigner((designer) => { - return designer.subscribeTo(AppendNodeEvent, (event) => { - const { source, target } = event.data - if (Array.isArray(target)) return - if (!Array.isArray(source)) return - if ( - matchComponent( - target, - (key) => - key === name && - source.every((child) => !matchChildComponent(child, name)) - ) && - target.children.length === 0 - ) { - target.setNodeChildren(...getChildren(source)) - return false - } - }) - }) -} diff --git a/designable/next/src/index.ts b/designable/next/src/index.ts deleted file mode 100644 index e1e3b6f0e4e..00000000000 --- a/designable/next/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './locales' -import './sources' -export * from './components' diff --git a/designable/next/src/locales/en-US/Array.ts b/designable/next/src/locales/en-US/Array.ts deleted file mode 100644 index a567945a8fe..00000000000 --- a/designable/next/src/locales/en-US/Array.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { ISettingsLocale } from '../types' - -const ArrayOperations: ISettingsLocale = { - Index: 'Indexes', - SortHandle: 'Sort Handle', - Addition: 'Addition', - Remove: 'Remove', - MoveDown: 'Move Down', - MoveUp: 'Move Up', -} - -export const ArrayTable: ISettingsLocale = { - ...ArrayOperations, - title: 'Array Table', - Column: 'Column', -} - -export const ArrayCards: ISettingsLocale = { - ...ArrayOperations, - title: 'Array Cards', -} - -export const ArrayTabs = { - ...ArrayOperations, - title: 'Array Tabs', -} - -export const ArrayCollapse: ISettingsLocale = { - ...ArrayOperations, - title: 'Array Collapse', -} diff --git a/designable/next/src/locales/en-US/ArrayCards.ts b/designable/next/src/locales/en-US/ArrayCards.ts deleted file mode 100644 index 11b5f1a4d56..00000000000 --- a/designable/next/src/locales/en-US/ArrayCards.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ArrayTable } from './ArrayTable' -import { Card } from './Card' - -export const ArrayCards = Card - -ArrayCards.Addition = ArrayTable.Addition diff --git a/designable/next/src/locales/en-US/ArrayTable.ts b/designable/next/src/locales/en-US/ArrayTable.ts deleted file mode 100644 index 1b0bffbee12..00000000000 --- a/designable/next/src/locales/en-US/ArrayTable.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const ArrayTable: ISettingsLocale = { - primaryKey: 'Primary Key', - tableLayout: { - title: 'Table Layout', - dataSource: ['Auto', 'Fixed'], - }, - size: { - title: 'Size', - dataSource: ['Small', 'Medium', 'Inherit', 'None'], - }, - tableWidth: 'Table Width', - hasHeader: 'Header', - isZebra: 'Zebra', - emptyContent: 'Empty Content', - fixedHeader: 'Fixed Header', - maxBodyHeight: { - title: 'Max Body Height', - tooltip: - 'When Fixed Header is enabled, scroll bars will appear when the height exceeds this height', - }, - stickyHeader: 'Sticky Header', -} - -ArrayTable.Column = { - align: { - title: 'Cell Alignment', - dataSource: ['Left', 'Medium', 'Right'], - }, - alignHeader: { - title: 'Header alignment', - tooltip: - 'If not set, the alignment will be the same as that of the Cell Alignment', - dataSource: ['Left', 'Center', 'Right'], - }, - lock: { - title: 'Lock Column', - dataSource: ['None', 'Left', 'Right', 'Lock'], - }, - colSpan: 'Col Span', - wordBreak: { - title: 'Word Break', - dataSource: ['All', 'Word'], - }, -} - -ArrayTable.Addition = { - method: { - title: 'Method', - dataSource: ['Push', 'Unshift'], - }, - defaultValue: 'Default Value', -} diff --git a/designable/next/src/locales/en-US/Card.ts b/designable/next/src/locales/en-US/Card.ts deleted file mode 100644 index f09046fca90..00000000000 --- a/designable/next/src/locales/en-US/Card.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Card: ISettingsLocale = { - subTitle: 'Subtitle', - showTitleBullet: 'Title Bullet', - showHeadDivider: 'Title Divider', - contentHeight: 'Content Height', -} diff --git a/designable/next/src/locales/en-US/Cascader.ts b/designable/next/src/locales/en-US/Cascader.ts deleted file mode 100644 index 0291dd7a1ba..00000000000 --- a/designable/next/src/locales/en-US/Cascader.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Cascader: ISettingsLocale = { - expandTriggerType: { - title: 'Expand Trigger', - dataSource: ['Click', 'Hover'], - }, - canOnlySelectLeaf: 'Only Select Leaf', - canOnlyCheckLeaf: 'Only Check Leaf', - checkStrictly: 'Check Strictly', -} diff --git a/designable/next/src/locales/en-US/Checkbox.ts b/designable/next/src/locales/en-US/Checkbox.ts deleted file mode 100644 index 6e70835994f..00000000000 --- a/designable/next/src/locales/en-US/Checkbox.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Checkbox: ISettingsLocale = {} - -Checkbox.Group = {} diff --git a/designable/next/src/locales/en-US/Common.ts b/designable/next/src/locales/en-US/Common.ts deleted file mode 100644 index c9e52094bb4..00000000000 --- a/designable/next/src/locales/en-US/Common.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Style } from './Style' -import type { ISettingsLocale } from '../types' - -export const Common: ISettingsLocale = { - title: 'Title', - placeholder: 'Placeholder', - extra: 'Extra', - min: 'Min Value', - max: 'Max Value', - step: 'Step', - closeable: 'Closeable', - autoFocus: 'Auto Focus', - width: 'Width', - height: 'Height', - minLength: 'Min Length', - maxLength: 'Max Length', - minWidth: 'Min Width', - maxWidth: 'Max Width', - minHeight: 'Min Height', - maxHeight: 'Max Height', - notFoundContent: 'No Content Prompt', - addonBefore: 'Addon Before', - addonAfter: 'Addon After', - innerBefore: 'Inner Before', - innerAfter: 'Inner After', - addonTextBefore: 'Addon Text Before', - addonTextAfter: 'Addon Text After', - tooltip: 'Tooltip', - autoWidth: 'Auto Width', - name: 'Name', - showSearch: 'Search Button', - multiple: 'Allow Multiple Selections', - hasArrow: 'Dropdown Arrow', - hasBorder: 'Frame', - hasClear: { - title: 'Clear Button', - tooltip: - 'When enabled, you can click the clear button on the right to clear the input quickly', - }, - style: Style, - size: { - title: 'Size', - dataSource: ['Small', 'Medium', 'Large', 'Inherit'], - }, - direction: { - title: 'Direction', - dataSource: ['Horizontal', 'Vertical'], - }, - followTrigger: { - title: 'Follow Scroll', - tooltip: - 'When enabled, allows the popup layer to scroll with the component instead of staying in the popup position', - }, - useVirtual: { - title: 'Virtual Scroll', - tooltip: - 'It is used to optimize performance when the amount of data is large, and may flicker when scrolling quickly', - }, - immutable: 'Immutable Data', - popupTriggerType: { - title: 'Popup Trigger', - dataSource: ['Click', 'Hover'], - }, - popupAlign: { - title: 'Popup Align', - tooltip: 'Refer to the Overlay documentation', - }, -} diff --git a/designable/next/src/locales/en-US/DatePicker.ts b/designable/next/src/locales/en-US/DatePicker.ts deleted file mode 100644 index a259dde6288..00000000000 --- a/designable/next/src/locales/en-US/DatePicker.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { ISettingsLocale } from '../types' - -const CommonDatePickerLocale: ISettingsLocale = { - format: { - title: 'Format', - placeholder: 'YYYY-MM-DD', - }, - showTime: 'Show Time', - resetTime: 'Reset On Select', -} -export const DatePicker: ISettingsLocale = { - ...CommonDatePickerLocale, -} - -DatePicker.RangePicker = { - ...CommonDatePickerLocale, - type: { - title: 'Type', - dataSource: ['Date', 'Month', 'Year'], - }, -} diff --git a/designable/next/src/locales/en-US/Field.ts b/designable/next/src/locales/en-US/Field.ts deleted file mode 100644 index aad03b8ba7b..00000000000 --- a/designable/next/src/locales/en-US/Field.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { FormItem } from './FormItem' -import { Style } from './Style' -import type { ISettingsLocale } from '../types' -import { Common } from './Common' - -export const Field: ISettingsLocale = { - name: 'Name', - title: 'Title', - required: 'Required', - description: 'Description', - default: 'Default', - enum: 'Data Source', - 'x-display': { - title: 'Display State', - tooltip: - 'When the display value is "None", the data will be "Hidden" and deleted. When the display value is hidden, only the UI will be hidden', - dataSource: ['Visible', 'Hidden', 'None', 'Inherit'], - }, - 'x-pattern': { - title: 'UI Pattern', - dataSource: ['Editable', 'Disabled', 'ReadOnly', 'ReadPretty', 'Inherit'], - }, - 'x-validator': 'Validator', - 'x-reactions': 'Reactions', - 'x-decorator': 'Decorator', - 'x-decorator-props': { - ...Common, - ...FormItem, - style: Style, - tab_property: 'Decorator', - tab_style: 'Style', - }, - 'x-component-props': { - ...Common, - tab_property: 'Component', - tab_style: 'Style', - }, -} diff --git a/designable/next/src/locales/en-US/FormCollapse.ts b/designable/next/src/locales/en-US/FormCollapse.ts deleted file mode 100644 index 22c855ee67d..00000000000 --- a/designable/next/src/locales/en-US/FormCollapse.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormCollapse: ISettingsLocale = { - accordion: { - title: 'Accordion', - tooltip: 'When enabled, only one can be expanded at a time', - }, -} - -FormCollapse.CollapsePanel = {} diff --git a/designable/next/src/locales/en-US/FormGrid.ts b/designable/next/src/locales/en-US/FormGrid.ts deleted file mode 100644 index c8a68cdb304..00000000000 --- a/designable/next/src/locales/en-US/FormGrid.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormGrid: ISettingsLocale = { - minColumns: 'Min Columns', - maxColumns: 'Max Columns', - breakpoints: 'Breakpoints', - columnGap: 'Column Gap', - rowGap: 'Row Gap', - colWrap: 'Col Wrap', -} diff --git a/designable/next/src/locales/en-US/FormItem.ts b/designable/next/src/locales/en-US/FormItem.ts deleted file mode 100644 index abead7f5177..00000000000 --- a/designable/next/src/locales/en-US/FormItem.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { FormLayout } from './FormLayout' -import type { ISettingsLocale } from '../types' - -export const FormItem: ISettingsLocale = { - ...FormLayout, - asterisk: 'Asterisk', - gridSpan: 'Grid Span', -} diff --git a/designable/next/src/locales/en-US/FormLayout.ts b/designable/next/src/locales/en-US/FormLayout.ts deleted file mode 100644 index 375d215f26a..00000000000 --- a/designable/next/src/locales/en-US/FormLayout.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormLayout: ISettingsLocale = { - labelCol: 'Label Col', - wrapperCol: 'Component Col', - labelWidth: 'Label Width', - wrapperWidth: 'Wrapper Width', - colon: 'Colon', - feedbackLayout: { - title: 'Feedback layout', - dataSource: ['Loose', 'Terse', 'Popup', 'None', 'Inherit'], - }, - layout: { - title: 'Layout', - dataSource: ['Horizontal', 'Vertical', 'Inline', 'Inherit'], - }, - tooltipLayout: { - title: 'Tooltip Layout', - dataSource: ['Icon', 'Text', 'Inherit'], - }, - labelAlign: { - title: 'Label Align', - dataSource: ['Left', 'Right', 'Inherit'], - }, - wrapperAlign: { - title: 'Wrapper Align', - dataSource: ['Left', 'Right', 'Inherit'], - }, - labelWrap: 'Label Wrap', - wrapperWrap: 'Wrapper wrap', - fullness: 'Fullness', - inset: 'Inset', - shallow: 'Shallow', - bordered: 'Border', -} diff --git a/designable/next/src/locales/en-US/FormTab.ts b/designable/next/src/locales/en-US/FormTab.ts deleted file mode 100644 index 60ffee74be2..00000000000 --- a/designable/next/src/locales/en-US/FormTab.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormTab: ISettingsLocale = { - size: { - title: 'Size', - dataSource: ['Small', 'Medium', 'Inherit'], - }, - shape: { - title: 'Shape', - dataSource: ['Pure', 'Wrapper', 'Text', 'Capsule'], - }, - animation: 'Transition', - excessMode: { - title: 'Excess Mode', - tooltip: 'When there are too many tabs, how to slide?', - dataSource: ['Slider', 'Dropdown'], - }, - tabPosition: { - title: 'Tab Position', - dataSource: ['Top', 'Bottom', 'Left', 'Right'], - }, - triggerType: { - title: 'Trigger Type', - tooltip: 'Trigger method of activation tab', - dataSource: ['Click', 'Hover'], - }, -} - -FormTab.TabPane = {} diff --git a/designable/next/src/locales/en-US/Input.ts b/designable/next/src/locales/en-US/Input.ts deleted file mode 100644 index 95295cf8521..00000000000 --- a/designable/next/src/locales/en-US/Input.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Input: ISettingsLocale = { - showLimitHint: 'Show Limit Hint', - cutString: { - title: 'Cut String', - tooltip: - 'When the maxLength is set, whether to truncate the string is exceeded', - }, - trim: { - title: 'Trim', - tooltip: 'Remove leading and trailing spaces', - }, - composition: 'Filter Ime Middle Letters', - hint: { - title: 'Hint', - tooltip: - 'The value is taken from the type of Icon and is in the same position as the clear button', - }, -} - -Input.TextArea = { - ...Input, - autoHeight: 'Auto Height', - rows: 'Rows', -} diff --git a/designable/next/src/locales/en-US/NumberPicker.ts b/designable/next/src/locales/en-US/NumberPicker.ts deleted file mode 100644 index 6fdafcfeda4..00000000000 --- a/designable/next/src/locales/en-US/NumberPicker.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const NumberPicker: ISettingsLocale = { - type: { - title: 'Type', - dataSource: ['Normal', 'Inline'], - }, - precision: 'Precision', - innerAfter: 'Inner After', - device: { - title: 'Preset Device', - dataSource: ['Desktop', 'Phone', 'Pad'], - }, - hasTrigger: 'Trigger', - alwaysShowTrigger: 'Always Show Trigger', -} diff --git a/designable/next/src/locales/en-US/Password.ts b/designable/next/src/locales/en-US/Password.ts deleted file mode 100644 index 085fb24a106..00000000000 --- a/designable/next/src/locales/en-US/Password.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Password: ISettingsLocale = {} diff --git a/designable/next/src/locales/en-US/Radio.ts b/designable/next/src/locales/en-US/Radio.ts deleted file mode 100644 index 2d95c4a2690..00000000000 --- a/designable/next/src/locales/en-US/Radio.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Radio: ISettingsLocale = {} - -Radio.Group = { - shape: { - title: 'Shape', - dataSource: ['Normal', 'Button'], - }, -} diff --git a/designable/next/src/locales/en-US/Range.ts b/designable/next/src/locales/en-US/Range.ts deleted file mode 100644 index cbad183ee35..00000000000 --- a/designable/next/src/locales/en-US/Range.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Range: ISettingsLocale = { - slider: { - title: 'Slider', - dataSource: ['Single', 'Double'], - }, - step: { - title: 'Step', - tooltip: - 'The value must be greater than 0 and can be divided by (max - min)', - }, - marks: { - title: 'Marks', - tooltip: - 'False means not to display, Array enumeration shows the value, Number means to divide equally by number, Object means to divide by key, and value is displayed)', - }, - marksPosition: { - title: 'Marks Position', - dataSource: ['Top', 'Bottom'], - }, - hasTip: 'Show Tips', - reverse: { - title: 'Reversal', - tooltip: 'Selected state inversion', - }, - pure: 'Pure Rendering', - fixedWidth: { - title: 'Fixed Width', - }, - tooltipVisible: 'Tooltips Visible', -} diff --git a/designable/next/src/locales/en-US/Rating.ts b/designable/next/src/locales/en-US/Rating.ts deleted file mode 100644 index 03b60ddc6fa..00000000000 --- a/designable/next/src/locales/en-US/Rating.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Rating: ISettingsLocale = { - count: 'Star Count', - showGrade: 'Grade', - allowHalf: 'Allow Half Star', - allowClear: { - title: 'Clear After Clicking', - tooltip: 'After scoring, click the Rating again to clear the count', - }, -} diff --git a/designable/next/src/locales/en-US/Select.ts b/designable/next/src/locales/en-US/Select.ts deleted file mode 100644 index 8a2d4a01882..00000000000 --- a/designable/next/src/locales/en-US/Select.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Select: ISettingsLocale = { - filterLocal: 'Local Filter', - filter: 'Filter Function', - autoHighlightFirstItem: 'Auto highlight first item', - mode: { - title: 'Mode', - dataSource: ['Single', 'Multiple', 'Tags'], - }, - notFoundContent: 'No Content Prompt', - showDataSourceChildren: 'Show Data Source Children', - hasSelectAll: 'Can Select All', - cacheValue: { - title: 'Cache Value', - tooltip: - 'Do you want to keep the selected value when the data source changes', - }, - tagInline: 'Tag Inline', - tagClosable: 'Tag Closable', - adjustTagSize: { - title: 'Adjust Tag Size', - tooltip: 'Adjust the tag the same as the selector', - }, - maxTagCount: 'Max Tag Count', - hiddenSelected: 'Hidden Selected', - popupAutoFocus: 'Popup Auto Focus', -} diff --git a/designable/next/src/locales/en-US/Space.ts b/designable/next/src/locales/en-US/Space.ts deleted file mode 100644 index a156842dfcc..00000000000 --- a/designable/next/src/locales/en-US/Space.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Space: ISettingsLocale = { - align: { - title: 'Alignment', - dataSource: ['Start', 'End', 'Center', 'Baseline'], - }, - split: 'Split', - wrap: 'Auto Wrap', -} diff --git a/designable/next/src/locales/en-US/Style.ts b/designable/next/src/locales/en-US/Style.ts deleted file mode 100644 index 8dae5a1bc02..00000000000 --- a/designable/next/src/locales/en-US/Style.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Style: ISettingsLocale = { - width: 'Width', - height: 'Height', - display: 'Display', - background: 'Background', - boxShadow: 'Box Shadow', - font: 'Font', - margin: 'Margin', - padding: 'Padding', - borderRadius: 'Border Radius', - border: 'Border', - opacity: 'Opacity', -} diff --git a/designable/next/src/locales/en-US/Switch.ts b/designable/next/src/locales/en-US/Switch.ts deleted file mode 100644 index 14fa275d935..00000000000 --- a/designable/next/src/locales/en-US/Switch.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Switch: ISettingsLocale = { - size: { - title: 'Size', - dataSource: ['Small', 'Medium', 'Inherit', 'Nothing'], - }, - checkedChildren: 'Open Content', - unCheckedChildren: 'Close Content', -} diff --git a/designable/next/src/locales/en-US/Text.ts b/designable/next/src/locales/en-US/Text.ts deleted file mode 100644 index 03179836474..00000000000 --- a/designable/next/src/locales/en-US/Text.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Text: ISettingsLocale = { - content: 'Text Content', - mode: { - title: 'Text Type', - dataSource: ['H1', 'H2', 'H3', 'Paragraph', 'Normal'], - }, -} diff --git a/designable/next/src/locales/en-US/TimePicker.ts b/designable/next/src/locales/en-US/TimePicker.ts deleted file mode 100644 index 59c3e81bf0b..00000000000 --- a/designable/next/src/locales/en-US/TimePicker.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const TimePicker: ISettingsLocale = { - format: { - title: 'Format', - placeholder: 'e.g. HH:mm:ss', - }, - hourStep: 'Hour Step', - minuteStep: 'Minute Step', - secondStep: 'Second Step', -} diff --git a/designable/next/src/locales/en-US/Transfer.ts b/designable/next/src/locales/en-US/Transfer.ts deleted file mode 100644 index 01ead4e6759..00000000000 --- a/designable/next/src/locales/en-US/Transfer.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Transfer: ISettingsLocale = { - id: 'Id', - mode: { - title: 'Mode', - dataSource: ['Normal', 'Simple'], - }, - leftDisabled: 'Disable Left Panel', - rightDisabled: 'Disable Right Panel', - filter: 'Filter Function', - searchPlaceholder: 'Search placeholder tips', - titles: 'Titles', - sortable: 'Sortable', - showCheckAll: 'Show Check All', -} diff --git a/designable/next/src/locales/en-US/TreeSelect.ts b/designable/next/src/locales/en-US/TreeSelect.ts deleted file mode 100644 index ba21dbcf5c9..00000000000 --- a/designable/next/src/locales/en-US/TreeSelect.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Select } from './Select' -import type { ISettingsLocale } from '../types' - -export const TreeSelect: ISettingsLocale = { - ...Select, - treeCheckable: { - title: 'Tree Checkable', - tooltip: - 'Whether the tree in the drop-down box supports checking the check box of the node', - }, - treeCheckStrictly: { - title: 'Tree Check Strictly', - tooltip: - 'Check whether the node check box in the tree in the drop-down box is completely controlled (the selected status of parent and child nodes is no longer associated)', - }, - treeCheckedStrategy: { - title: 'Tree Checked Strategy', - tooltip: 'How to backfill when selected', - dataSource: [ - 'Return only parents', - 'Return only children', - 'Returns all selected', - ], - }, - treeDefaultExpandAll: 'Expand All By Default', -} diff --git a/designable/next/src/locales/en-US/Upload.ts b/designable/next/src/locales/en-US/Upload.ts deleted file mode 100644 index 187b431b9e7..00000000000 --- a/designable/next/src/locales/en-US/Upload.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Upload: ISettingsLocale = { - action: 'Upload Url', - shape: { - title: 'Shape', - dataSource: ['Normal', 'Card'], - }, - accept: 'Accept File Type', - data: 'Upload Extra Data', - headers: 'Upload Headers', - withCredentials: 'With Credentials', - timeout: 'Timeout(ms)', - method: { - title: 'Upload Method', - dataSource: ['POST', 'PUT'], - }, - request: 'Custom Upload Function', - name: 'Name Key', - listType: { - title: 'Upload List Type', - dataSource: ['Default', 'Text', 'Image', 'Card'], - }, - limit: 'Max Upload count', - dragable: 'Dragable', - useDataURL: 'Local Preview', - autoUpload: 'Auto Upload', -} - -Upload.Dragger = { ...Upload } diff --git a/designable/next/src/locales/en-US/index.ts b/designable/next/src/locales/en-US/index.ts deleted file mode 100644 index aa99fff17b9..00000000000 --- a/designable/next/src/locales/en-US/index.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { Common } from './Common' -import { Field } from './Field' -import { FormLayout } from './FormLayout' -import { Card } from './Card' -import { FormGrid } from './FormGrid' -import { Space } from './Space' -import { FormTab } from './FormTab' -import { FormCollapse } from './FormCollapse' -import { Input } from './Input' -import { Select } from './Select' -import { TreeSelect } from './TreeSelect' -import { Cascader } from './Cascader' -import { Radio } from './Radio' -import { Checkbox } from './Checkbox' -import { Range } from './Range' -import { Rating } from './Rating' -import { DatePicker } from './DatePicker' -import { TimePicker } from './TimePicker' -import { NumberPicker } from './NumberPicker' -import { Password } from './Password' -import { Transfer } from './Transfer' -import { Upload } from './Upload' -import { Switch } from './Switch' -import { ArrayTable } from './ArrayTable' -import { ArrayCards } from './ArrayCards' -import { Text } from './Text' -import * as ArrayComponents from './Array' -import type { ISettingsLocale } from '../types' - -const Form: ISettingsLocale = { ...Common, ...FormLayout } - -const Components: ISettingsLocale = { - FormLayout, - Card, - FormGrid, - Space, - FormTab, - FormCollapse, - Input, - Select, - TreeSelect, - Cascader, - Radio, - Checkbox, - Range, - Rating, - DatePicker, - TimePicker, - NumberPicker, - Password, - Transfer, - Upload, - Switch, - Text, - ArrayTable, - ArrayCards, -} - -const enUS: ISettingsLocale = { - Components: { - Root: 'Root', - DesignableForm: 'Form', - DesignableField: 'Field', - Input: { title: 'Input', TextArea: 'TextArea' }, - Select: 'Select', - Radio: { title: 'Radio', Group: 'Radio Group' }, - Checkbox: { - title: 'Checkbox', - Group: 'Checkbox Group', - }, - Card: 'Card', - FormGrid: 'Form Grid', - FormLayout: 'Form Layout', - Range: 'Range', - Rating: 'Rating', - Cascader: 'Cascader', - Space: 'Space', - DatePicker: { title: 'Date', RangePicker: 'Date Range' }, - TimePicker: { title: 'Time', RangePicker: 'Time Range' }, - NumberPicker: 'Number', - Password: 'Password', - Transfer: 'Transfer', - TreeSelect: 'TreeSelect', - Upload: { title: 'Upload', Dragger: 'Dragger Upload' }, - Switch: 'Switch', - FormTab: { title: 'Form Tab', TabPane: 'Tab Panel' }, - FormCollapse: { title: 'Form Collapse', CollapsePanel: 'Collapse Panel' }, - Object: 'Object', - Void: 'Void Element', - Text: 'Text', - ...ArrayComponents, - FormItem: 'Form Item', - }, - Settings: { - ...Form, - ...Field, - namespace: Components, - }, - Common: { - droppable: 'Droppable', - addTabPane: 'Add Panel', - addCollapsePanel: 'Add Panel', - addTableColumn: 'Add Column', - addTableSortHandle: 'Add Sort Handle', - addIndex: 'Add Index', - addOperation: 'Add Operations', - }, -} - -export default enUS diff --git a/designable/next/src/locales/index.ts b/designable/next/src/locales/index.ts deleted file mode 100644 index a2ddf209801..00000000000 --- a/designable/next/src/locales/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { GlobalRegistry } from '@designable/core' -import zhCN from './zh-CN' -import enUS from './en-US' - -GlobalRegistry.registerDesignerLocales({ - 'zh-CN': zhCN, - 'en-US': enUS, -}) diff --git a/designable/next/src/locales/types.ts b/designable/next/src/locales/types.ts deleted file mode 100644 index aff99c9b286..00000000000 --- a/designable/next/src/locales/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface ISettingsLocale { - [key: string]: - | string - | { - title?: string - description?: string - tooltip?: string - placeholder?: string - dataSource?: string[] - } - | ISettingsLocale -} diff --git a/designable/next/src/locales/zh-CN/Array.ts b/designable/next/src/locales/zh-CN/Array.ts deleted file mode 100644 index f932b425633..00000000000 --- a/designable/next/src/locales/zh-CN/Array.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { ISettingsLocale } from '../types' - -const ArrayOperations: ISettingsLocale = { - Index: '索引', - SortHandle: '排序手柄', - Addition: '新增按钮', - Remove: '删除按钮', - MoveDown: '下移按钮', - MoveUp: '上移按钮', -} - -export const ArrayTable: ISettingsLocale = { - ...ArrayOperations, - title: '自增表格', - Column: '表格列', -} - -export const ArrayCards: ISettingsLocale = { - ...ArrayOperations, - title: '自增卡片', -} - -export const ArrayTabs = { - ...ArrayOperations, - title: '自增选项卡', -} - -export const ArrayCollapse: ISettingsLocale = { - ...ArrayOperations, - title: '自增手风琴', -} diff --git a/designable/next/src/locales/zh-CN/ArrayCards.ts b/designable/next/src/locales/zh-CN/ArrayCards.ts deleted file mode 100644 index 11b5f1a4d56..00000000000 --- a/designable/next/src/locales/zh-CN/ArrayCards.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ArrayTable } from './ArrayTable' -import { Card } from './Card' - -export const ArrayCards = Card - -ArrayCards.Addition = ArrayTable.Addition diff --git a/designable/next/src/locales/zh-CN/ArrayTable.ts b/designable/next/src/locales/zh-CN/ArrayTable.ts deleted file mode 100644 index 70b9080af4a..00000000000 --- a/designable/next/src/locales/zh-CN/ArrayTable.ts +++ /dev/null @@ -1,52 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const ArrayTable: ISettingsLocale = { - primaryKey: '主键', - tableLayout: { - title: '表格布局', - dataSource: ['自动', '固定'], - }, - size: { - title: '尺寸', - dataSource: ['小', '中', '继承', '无'], - }, - tableWidth: '表格宽度', - hasHeader: '表格头', - isZebra: '斑马线', - emptyContent: '空内容文案', - fixedHeader: '固定表格头', - maxBodyHeight: { - title: '最大主体高度', - tooltip: '启用固定表格头时,超过此高度时会出现滚动条', - }, - stickyHeader: '粘性头部', -} - -ArrayTable.Column = { - align: { - title: '单元格对齐', - dataSource: ['左', '中', '右'], - }, - alignHeader: { - title: '表格头对齐', - tooltip: '不设置将与单元格对齐方式相同', - dataSource: ['左', '中', '右'], - }, - lock: { - title: '锁列', - dataSource: ['不锁', '左', '右', '锁'], - }, - colSpan: '格数', - wordBreak: { - title: '单词打破', - dataSource: ['全部', '单词'], - }, -} - -ArrayTable.Addition = { - method: { - title: '添加方法', - dataSource: ['尾部', '头部'], - }, - defaultValue: '默认值', -} diff --git a/designable/next/src/locales/zh-CN/Card.ts b/designable/next/src/locales/zh-CN/Card.ts deleted file mode 100644 index 0a62632e7c5..00000000000 --- a/designable/next/src/locales/zh-CN/Card.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Card: ISettingsLocale = { - subTitle: '子标题', - showTitleBullet: '标题项目符号', - showHeadDivider: '标题分割线', - contentHeight: '内容高度', -} diff --git a/designable/next/src/locales/zh-CN/Cascader.ts b/designable/next/src/locales/zh-CN/Cascader.ts deleted file mode 100644 index 9378baa0d36..00000000000 --- a/designable/next/src/locales/zh-CN/Cascader.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Cascader: ISettingsLocale = { - expandTriggerType: { - title: '展开触发', - dataSource: ['点击', '移入'], - }, - canOnlySelectLeaf: '单选仅叶节点', - canOnlyCheckLeaf: '多选仅叶节点', - checkStrictly: '父子节点选中不关联', -} diff --git a/designable/next/src/locales/zh-CN/Checkbox.ts b/designable/next/src/locales/zh-CN/Checkbox.ts deleted file mode 100644 index 6e70835994f..00000000000 --- a/designable/next/src/locales/zh-CN/Checkbox.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Checkbox: ISettingsLocale = {} - -Checkbox.Group = {} diff --git a/designable/next/src/locales/zh-CN/Common.ts b/designable/next/src/locales/zh-CN/Common.ts deleted file mode 100644 index bca424e0b04..00000000000 --- a/designable/next/src/locales/zh-CN/Common.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Style } from './Style' -import type { ISettingsLocale } from '../types' - -export const Common: ISettingsLocale = { - title: '标题', - placeholder: '占位提示', - extra: '右侧扩展', - min: '最小值', - max: '最大值', - step: '步长', - closeable: '可关闭', - autoFocus: '自动聚焦', - width: '宽度', - height: '高度', - minLength: '最小长度', - maxLength: '最大长度', - minWidth: '最小宽度', - maxWidth: '最大宽度', - minHeight: '最小高度', - maxHeight: '最大高度', - notFoundContent: '无内容提示文案', - addonBefore: '前缀', - addonAfter: '后缀', - innerBefore: '框内前缀', - innerAfter: '框内后缀', - addonTextBefore: '前缀标签', - addonTextAfter: '后缀标签', - tooltip: '提示', - autoWidth: '自动宽度', - name: '名称', - showSearch: '搜索按钮', - multiple: '允许多选', - hasArrow: '下拉箭头', - hasBorder: '边框', - hasClear: { - title: '清除按钮', - tooltip: '启用后,输入时可点击右侧清除按钮快速清空输入', - }, - style: Style, - size: { - title: '尺寸', - dataSource: ['小', '中', '大', '继承'], - }, - direction: { - title: '方向', - dataSource: ['水平', '垂直'], - }, - followTrigger: { - title: '跟随滚动', - tooltip: '启用后可让弹层跟随组件一起滚动,而不是停留在弹出的位置', - }, - useVirtual: { - title: '虚拟滚动', - tooltip: '用于数据量较大时优化性能,快速滚动时可能闪烁', - }, - immutable: '不可变数据', - popupTriggerType: { - title: '触发弹层', - dataSource: ['点击', '移入'], - }, - popupAlign: { - title: '弹层对齐方式', - tooltip: '参考 Overlay 文档', - }, -} diff --git a/designable/next/src/locales/zh-CN/DatePicker.ts b/designable/next/src/locales/zh-CN/DatePicker.ts deleted file mode 100644 index d87f1a98049..00000000000 --- a/designable/next/src/locales/zh-CN/DatePicker.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { ISettingsLocale } from '../types' - -const CommonDatePickerLocale: ISettingsLocale = { - format: { - title: '格式', - placeholder: 'YYYY-MM-DD', - }, - showTime: '使用时间控件', - resetTime: '选择时重置时间', -} -export const DatePicker: ISettingsLocale = { - ...CommonDatePickerLocale, -} - -DatePicker.RangePicker = { - ...CommonDatePickerLocale, - type: { - title: '类型', - dataSource: ['日', '月', '年'], - }, -} diff --git a/designable/next/src/locales/zh-CN/Field.ts b/designable/next/src/locales/zh-CN/Field.ts deleted file mode 100644 index c7439e55ee9..00000000000 --- a/designable/next/src/locales/zh-CN/Field.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { FormItem } from './FormItem' -import { Style } from './Style' -import type { ISettingsLocale } from '../types' -import { Common } from './Common' - -export const Field: ISettingsLocale = { - name: '字段标识', - title: '标题', - required: '必填', - description: '描述', - default: '默认值', - enum: '数据源', - 'x-display': { - title: '展示状态', - tooltip: '半隐藏只会隐藏UI,全隐藏会删除数据', - dataSource: ['显示', '半隐藏', '全隐藏', '继承'], - }, - 'x-pattern': { - title: 'UI形态', - dataSource: ['可编辑', '禁用', '只读', '阅读', '继承'], - }, - 'x-validator': '校验规则', - 'x-reactions': '响应器规则', - 'x-decorator': '启用容器组件', - 'x-decorator-props': { - ...Common, - ...FormItem, - style: Style, - tab_property: '容器属性', - tab_style: '容器样式', - }, - 'x-component-props': { - ...Common, - tab_property: '组件属性', - tab_style: '组件样式', - }, -} diff --git a/designable/next/src/locales/zh-CN/FormCollapse.ts b/designable/next/src/locales/zh-CN/FormCollapse.ts deleted file mode 100644 index 2d6e0a7a05b..00000000000 --- a/designable/next/src/locales/zh-CN/FormCollapse.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormCollapse: ISettingsLocale = { - accordion: { - title: '手风琴模式', - tooltip: '启用后一次只能展开一个', - }, -} - -FormCollapse.CollapsePanel = {} diff --git a/designable/next/src/locales/zh-CN/FormGrid.ts b/designable/next/src/locales/zh-CN/FormGrid.ts deleted file mode 100644 index a14c0aeeddc..00000000000 --- a/designable/next/src/locales/zh-CN/FormGrid.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormGrid: ISettingsLocale = { - minColumns: '最小列数', - maxColumns: '最大列数', - breakpoints: '响应式断点', - columnGap: '列间距', - rowGap: '行间距', - colWrap: '自动换行', -} diff --git a/designable/next/src/locales/zh-CN/FormItem.ts b/designable/next/src/locales/zh-CN/FormItem.ts deleted file mode 100644 index 88c2e057d7f..00000000000 --- a/designable/next/src/locales/zh-CN/FormItem.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { FormLayout } from './FormLayout' -import type { ISettingsLocale } from '../types' - -export const FormItem: ISettingsLocale = { - ...FormLayout, - asterisk: '星号', - gridSpan: '网格跨列', -} diff --git a/designable/next/src/locales/zh-CN/FormLayout.ts b/designable/next/src/locales/zh-CN/FormLayout.ts deleted file mode 100644 index 8361f0173fc..00000000000 --- a/designable/next/src/locales/zh-CN/FormLayout.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormLayout: ISettingsLocale = { - labelCol: '标签网格宽度', - wrapperCol: '组件网格宽度', - labelWidth: '标签宽度', - wrapperWidth: '组件宽度', - colon: '是否有冒号', - feedbackLayout: { - title: '反馈布局', - dataSource: ['宽松', '紧凑', '弹层', '无', '继承'], - }, - layout: { - title: '布局', - dataSource: ['水平', '垂直', '内联', '继承'], - }, - tooltipLayout: { - title: '提示布局', - dataSource: ['图标', '文本', '继承'], - }, - labelAlign: { - title: '标签对齐', - dataSource: ['左', '右', '继承'], - }, - wrapperAlign: { - title: '组件对齐', - dataSource: ['左', '右', '继承'], - }, - labelWrap: '标签换行', - wrapperWrap: '组件换行', - fullness: '组件占满', - inset: '内联布局', - shallow: '是否浅传递', - bordered: '是否有边框', -} diff --git a/designable/next/src/locales/zh-CN/FormTab.ts b/designable/next/src/locales/zh-CN/FormTab.ts deleted file mode 100644 index 9215a5b0157..00000000000 --- a/designable/next/src/locales/zh-CN/FormTab.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const FormTab: ISettingsLocale = { - size: { - title: '尺寸', - dataSource: ['小', '中', '继承'], - }, - shape: { - title: '外观', - dataSource: ['纯净', '包裹', '文本', '胶囊'], - }, - animation: '动画过渡', - excessMode: { - title: '滑动模式', - tooltip: '选项卡过多时,如何滑动?', - dataSource: ['滑动器', '下拉列表'], - }, - tabPosition: { - title: '选项卡位置', - dataSource: ['上', '下', '左', '右'], - }, - triggerType: { - title: '选项卡激活方式', - tooltip: '激活选项卡的触发方式', - dataSource: ['点击', '移入'], - }, -} - -FormTab.TabPane = {} diff --git a/designable/next/src/locales/zh-CN/Input.ts b/designable/next/src/locales/zh-CN/Input.ts deleted file mode 100644 index a0e4a501f4c..00000000000 --- a/designable/next/src/locales/zh-CN/Input.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Input: ISettingsLocale = { - showLimitHint: '长度限制提示', - cutString: { - title: '截断', - tooltip: '当设置最大长度后,超出是否截断字符串', - }, - trim: { - title: '修剪', - tooltip: '移除首尾空格', - }, - composition: '过滤输入法中间字母', - hint: { - title: '水印', - tooltip: '值取自 Icon 的 type,与清除按钮在同一位置', - }, -} - -Input.TextArea = { - ...Input, - autoHeight: '自动高度', - rows: '文本框高度', -} diff --git a/designable/next/src/locales/zh-CN/NumberPicker.ts b/designable/next/src/locales/zh-CN/NumberPicker.ts deleted file mode 100644 index 7141f2570a6..00000000000 --- a/designable/next/src/locales/zh-CN/NumberPicker.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const NumberPicker: ISettingsLocale = { - type: { - title: '类型', - dataSource: ['正常', '内联'], - }, - precision: '保留小数点后位数', - innerAfter: '后缀', - device: { - title: '预设设备', - dataSource: ['桌面', '手机', '平板'], - }, - hasTrigger: '展示调整按钮', - alwaysShowTrigger: '总是展示调整按钮', -} diff --git a/designable/next/src/locales/zh-CN/Password.ts b/designable/next/src/locales/zh-CN/Password.ts deleted file mode 100644 index 085fb24a106..00000000000 --- a/designable/next/src/locales/zh-CN/Password.ts +++ /dev/null @@ -1,3 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Password: ISettingsLocale = {} diff --git a/designable/next/src/locales/zh-CN/Radio.ts b/designable/next/src/locales/zh-CN/Radio.ts deleted file mode 100644 index d46d575081e..00000000000 --- a/designable/next/src/locales/zh-CN/Radio.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Radio: ISettingsLocale = {} - -Radio.Group = { - shape: { - title: '形状', - dataSource: ['正常', '按钮'], - }, -} diff --git a/designable/next/src/locales/zh-CN/Range.ts b/designable/next/src/locales/zh-CN/Range.ts deleted file mode 100644 index bb0176709b3..00000000000 --- a/designable/next/src/locales/zh-CN/Range.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Range: ISettingsLocale = { - slider: { - title: '滑块个数', - dataSource: ['单个', '两个'], - }, - step: { - title: '步长', - tooltip: '取值必须大于 0,并且可被 (最大值 - 最小值) 整除', - }, - marks: { - title: '标记', - tooltip: - '刻度数值显示逻辑(false 代表不显示,array 枚举显示的值,number 代表按 number 平分,object 表示按 key 划分,value 值显示)', - }, - marksPosition: { - title: '标记位置', - dataSource: ['上方', '下方'], - }, - hasTip: '显示提示', - reverse: { - title: '反转', - tooltip: '选中态反转', - }, - pure: '纯净渲染', - fixedWidth: { - title: '是否为拖动线段类型', - }, - tooltipVisible: '默认展示提示', -} diff --git a/designable/next/src/locales/zh-CN/Rating.ts b/designable/next/src/locales/zh-CN/Rating.ts deleted file mode 100644 index aeb22874375..00000000000 --- a/designable/next/src/locales/zh-CN/Rating.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Rating: ISettingsLocale = { - count: '评分总数', - showGrade: '星星总数', - allowHalf: '半星评分', - allowClear: { - title: '点击后清除', - tooltip: '评分后再次点击评分清除评分', - }, -} diff --git a/designable/next/src/locales/zh-CN/Select.ts b/designable/next/src/locales/zh-CN/Select.ts deleted file mode 100644 index 7cfa9e81699..00000000000 --- a/designable/next/src/locales/zh-CN/Select.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Select: ISettingsLocale = { - filterLocal: '本地过滤', - filter: '过滤方法', - autoHighlightFirstItem: '自动高亮首项', - mode: { - title: '模式', - dataSource: ['单选', '多选', '标签'], - }, - notFoundContent: { - title: '无内容提示', - tooltip: '弹层内容为空的文案', - }, - showDataSourceChildren: { - title: '展示数据源子节点', - }, - hasSelectAll: '多选模式下是否可全选', - cacheValue: { - title: '缓存选中值', - tooltip: '数据源变化的时是否保留已选的内容', - }, - tagInline: '标签行内展示', - tagClosable: '标签可关闭', - adjustTagSize: { - title: '调整标签大小', - tooltip: '调整标签大小与选择器相同', - }, - maxTagCount: '最多展示标签数量', - hiddenSelected: '选择后立即隐藏菜单', - popupAutoFocus: '弹出菜单时自动聚焦', -} diff --git a/designable/next/src/locales/zh-CN/Space.ts b/designable/next/src/locales/zh-CN/Space.ts deleted file mode 100644 index 5e4905a741f..00000000000 --- a/designable/next/src/locales/zh-CN/Space.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Space: ISettingsLocale = { - align: { - title: '对齐', - dataSource: ['起始', '结尾', '中间', '基线'], - }, - split: '分割内容', - wrap: '自动换行', -} diff --git a/designable/next/src/locales/zh-CN/Style.ts b/designable/next/src/locales/zh-CN/Style.ts deleted file mode 100644 index 95f58f8a620..00000000000 --- a/designable/next/src/locales/zh-CN/Style.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Style: ISettingsLocale = { - width: '宽度', - height: '高度', - display: '展示', - background: '背景', - boxShadow: '阴影', - font: '字体', - margin: '外边距', - padding: '内边距', - borderRadius: '圆角', - border: '边框', - opacity: '透明度', -} diff --git a/designable/next/src/locales/zh-CN/Switch.ts b/designable/next/src/locales/zh-CN/Switch.ts deleted file mode 100644 index 603f42f9f03..00000000000 --- a/designable/next/src/locales/zh-CN/Switch.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Switch: ISettingsLocale = { - size: { - title: '尺寸', - dataSource: ['小', '中', '继承', '无'], - }, - checkedChildren: '打开时内容', - unCheckedChildren: '关闭时内容', -} diff --git a/designable/next/src/locales/zh-CN/Text.ts b/designable/next/src/locales/zh-CN/Text.ts deleted file mode 100644 index 5ee0dbec454..00000000000 --- a/designable/next/src/locales/zh-CN/Text.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Text: ISettingsLocale = { - content: '文本内容', - mode: { - title: '文本类型', - dataSource: ['H1', 'H2', 'H3', 'Paragraph', 'Normal'], - }, -} diff --git a/designable/next/src/locales/zh-CN/TimePicker.ts b/designable/next/src/locales/zh-CN/TimePicker.ts deleted file mode 100644 index 7cb18b90d86..00000000000 --- a/designable/next/src/locales/zh-CN/TimePicker.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const TimePicker: ISettingsLocale = { - format: { - title: '格式化', - placeholder: '如 HH:mm:ss', - }, - hourStep: '小时步长', - minuteStep: '分钟步长', - secondStep: '秒钟步长', -} diff --git a/designable/next/src/locales/zh-CN/Transfer.ts b/designable/next/src/locales/zh-CN/Transfer.ts deleted file mode 100644 index d2beef4d636..00000000000 --- a/designable/next/src/locales/zh-CN/Transfer.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Transfer: ISettingsLocale = { - id: '标识', - mode: { - title: '模式', - dataSource: ['正常', '简单'], - }, - leftDisabled: '禁用左侧面板', - rightDisabled: '禁用右侧面板', - filter: '过滤函数', - searchPlaceholder: '搜索占位提示', - titles: '左右面板标题', - sortable: '拖拽排序', - showCheckAll: '底部全选', -} diff --git a/designable/next/src/locales/zh-CN/TreeSelect.ts b/designable/next/src/locales/zh-CN/TreeSelect.ts deleted file mode 100644 index caf633e5e71..00000000000 --- a/designable/next/src/locales/zh-CN/TreeSelect.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Select } from './Select' -import type { ISettingsLocale } from '../types' - -export const TreeSelect: ISettingsLocale = { - ...Select, - treeCheckable: { - title: '勾选树', - tooltip: '下拉框中的树是否支持勾选节点的复选框', - }, - treeCheckStrictly: { - title: '严格树勾选', - tooltip: - '下拉框中的树勾选节点复选框是否完全受控(父子节点选中状态不再关联)', - }, - treeCheckedStrategy: { - title: '勾选树策略', - tooltip: '选中时回填的方式', - dataSource: ['只返回父节点', '只返回子节点', '返回所有选中的节点'], - }, - treeDefaultExpandAll: '默认展开所有节点', -} diff --git a/designable/next/src/locales/zh-CN/Upload.ts b/designable/next/src/locales/zh-CN/Upload.ts deleted file mode 100644 index dd20e75c140..00000000000 --- a/designable/next/src/locales/zh-CN/Upload.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ISettingsLocale } from '../types' - -export const Upload: ISettingsLocale = { - action: '上传地址', - shape: { - title: '外观', - dataSource: ['正常', '卡片'], - }, - accept: '接受文件类型', - data: '上传额外参数', - headers: '上传请求头部', - withCredentials: '携带 Cookie', - timeout: '超时(ms)', - method: { - title: '上传方法', - dataSource: ['POST', 'PUT'], - }, - request: '自定义上传函数', - name: '文件名键值', - listType: { - title: '上传列表样式', - dataSource: ['默认', '文本', '图片', '卡片'], - }, - limit: '最大文件上传数量', - dragable: '支持拖拽上传', - useDataURL: '本地预览', - autoUpload: '自动上传', -} - -Upload.Dragger = { ...Upload } diff --git a/designable/next/src/locales/zh-CN/index.ts b/designable/next/src/locales/zh-CN/index.ts deleted file mode 100644 index 6fc8d75e0b9..00000000000 --- a/designable/next/src/locales/zh-CN/index.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { Common } from './Common' -import { Field } from './Field' -import { FormLayout } from './FormLayout' -import { Card } from './Card' -import { FormGrid } from './FormGrid' -import { Space } from './Space' -import { FormTab } from './FormTab' -import { FormCollapse } from './FormCollapse' -import { Input } from './Input' -import { Select } from './Select' -import { TreeSelect } from './TreeSelect' -import { Cascader } from './Cascader' -import { Radio } from './Radio' -import { Checkbox } from './Checkbox' -import { Range } from './Range' -import { Rating } from './Rating' -import { DatePicker } from './DatePicker' -import { TimePicker } from './TimePicker' -import { NumberPicker } from './NumberPicker' -import { Password } from './Password' -import { Transfer } from './Transfer' -import { Upload } from './Upload' -import { Switch } from './Switch' -import { Text } from './Text' -import { ArrayTable } from './ArrayTable' -import { ArrayCards } from './ArrayCards' -import * as ArrayComponents from './Array' -import type { ISettingsLocale } from '../types' - -const Form: ISettingsLocale = { ...Common, ...FormLayout } - -const Components: ISettingsLocale = { - FormLayout, - Card, - FormGrid, - Space, - FormTab, - FormCollapse, - Input, - Select, - TreeSelect, - Cascader, - Radio, - Checkbox, - Range, - Rating, - Text, - DatePicker, - TimePicker, - NumberPicker, - Password, - Transfer, - Upload, - Switch, - ArrayTable, - ArrayCards, -} - -const zhCN: ISettingsLocale = { - Components: { - Root: '根组件', - DesignableForm: '表单', - DesignableField: '字段', - Input: { title: '输入框', TextArea: '多行文本' }, - Select: '选择框', - Radio: { title: '单选框', Group: '单选框组' }, - Checkbox: { - title: '复选框', - Group: '复选框组', - }, - Card: '卡片布局', - FormGrid: '网格布局', - FormLayout: '表单布局', - Range: '滑动条', - Rating: '评分器', - Cascader: '联级选择', - Space: '弹性间距', - DatePicker: { title: '日期选择', RangePicker: '日期范围' }, - TimePicker: { title: '时间选择', RangePicker: '时间范围' }, - NumberPicker: '数字输入', - Password: '密码输入', - Transfer: '穿梭框', - TreeSelect: '树选择', - Upload: { title: '上传', Dragger: '拖拽上传' }, - Switch: '开关', - FormTab: { title: '选项卡布局', TabPane: '选项卡面板' }, - FormCollapse: { title: '手风琴布局', CollapsePanel: '手风琴面板' }, - Object: '数据对象', - Void: '虚拟容器', - Text: '文本', - ...ArrayComponents, - FormItem: '表单项容器', - }, - Settings: { - ...Form, - ...Field, - namespace: Components, - }, - Common: { - droppable: '可以拖入组件', - addTabPane: '添加选项卡', - addCollapsePanel: '添加手风琴卡片', - addTableColumn: '添加表格列', - addTableSortHandle: '添加排序', - addIndex: '添加索引', - addOperation: '添加操作', - }, -} - -export default zhCN diff --git a/designable/next/src/schemas/ArrayCards.ts b/designable/next/src/schemas/ArrayCards.ts deleted file mode 100644 index b970c033a98..00000000000 --- a/designable/next/src/schemas/ArrayCards.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ArrayTable } from './ArrayTable' -import { Card } from './Card' - -export const ArrayCards = Card -ArrayCards.Addition = ArrayTable.Addition diff --git a/designable/next/src/schemas/ArrayTable.ts b/designable/next/src/schemas/ArrayTable.ts deleted file mode 100644 index b4e8623c5e3..00000000000 --- a/designable/next/src/schemas/ArrayTable.ts +++ /dev/null @@ -1,181 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const ArrayTable: ISchema & { Addition?: ISchema; Column?: ISchema } = { - type: 'object', - properties: { - primaryKey: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - defaultValue: 'id', - }, - }, - tableLayout: { - type: 'string', - enum: ['auto', 'fixed'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'auto', - optionType: 'button', - }, - }, - size: { - type: 'string', - enum: ['small', 'medium', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - tableWidth: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - hasBorder: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - hasHeader: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - isZebra: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - emptyContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - fixedHeader: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - default: false, - }, - maxBodyHeight: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-reactions': { - dependencies: ['.fixedHeader'], - fulfill: { - state: { - visible: '{{$deps[0]}}', - }, - }, - }, - }, - stickyHeader: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - useVirtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} - -const Column: ISchema = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - width: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - align: { - type: 'string', - enum: ['left', 'center', 'right'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - optionType: 'button', - }, - }, - alignHeader: { - type: 'string', - enum: ['left', 'center', 'right'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - optionType: 'button', - }, - }, - lock: { - type: 'string', - enum: [false, 'left', 'right', true], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - optionType: 'button', - }, - }, - colSpan: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - wordBreak: { - type: 'string', - enum: ['all', 'word'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'all', - optionType: 'button', - }, - }, - }, -} - -const Addition: ISchema = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - method: { - type: 'string', - enum: ['push', 'unshift'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'push', - optionType: 'button', - }, - }, - defaultValue: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - }, - }, -} - -ArrayTable.Column = Column -ArrayTable.Addition = Addition diff --git a/designable/next/src/schemas/CSSStyle.ts b/designable/next/src/schemas/CSSStyle.ts deleted file mode 100644 index 8d60878091d..00000000000 --- a/designable/next/src/schemas/CSSStyle.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const CSSStyle: ISchema = { - type: 'void', - properties: { - 'style.width': { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - 'style.height': { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - 'style.display': { - 'x-component': 'DisplayStyleSetter', - }, - 'style.background': { - 'x-component': 'BackgroundStyleSetter', - }, - 'style.boxShadow': { - 'x-component': 'BoxShadowStyleSetter', - }, - 'style.font': { - 'x-component': 'FontStyleSetter', - }, - 'style.margin': { - 'x-component': 'BoxStyleSetter', - }, - 'style.padding': { - 'x-component': 'BoxStyleSetter', - }, - 'style.borderRadius': { - 'x-component': 'BorderRadiusStyleSetter', - }, - 'style.border': { - 'x-component': 'BorderStyleSetter', - }, - 'style.opacity': { - 'x-decorator': 'FormItem', - 'x-component': 'Slider', - 'x-component-props': { - defaultValue: 1, - min: 0, - max: 1, - step: 0.01, - }, - }, - }, -} diff --git a/designable/next/src/schemas/Card.ts b/designable/next/src/schemas/Card.ts deleted file mode 100644 index 5f6145433cb..00000000000 --- a/designable/next/src/schemas/Card.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Card: ISchema & { Addition?: ISchema } = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - subTitle: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - showTitleBullet: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - showHeadDivider: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - contentHeight: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - extra: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, -} diff --git a/designable/next/src/schemas/Cascader.ts b/designable/next/src/schemas/Cascader.ts deleted file mode 100644 index 38eec4d401b..00000000000 --- a/designable/next/src/schemas/Cascader.ts +++ /dev/null @@ -1,64 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Cascader: ISchema = { - type: 'object', - properties: { - expandTriggerType: { - type: 'string', - enum: ['click', 'hover'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'click', - optionType: 'button', - }, - }, - useVirtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - multiple: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - default: false, - }, - canOnlySelectLeaf: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-reactions': { - dependencies: ['.multiple'], - fulfill: { - state: { - visible: '{{!$deps[0]}}', - }, - }, - }, - }, - canOnlyCheckLeaf: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-reactions': { - dependencies: ['.multiple'], - fulfill: { - state: { - visible: '{{$deps[0]}}', - }, - }, - }, - }, - checkStrictly: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - immutable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Checkbox.ts b/designable/next/src/schemas/Checkbox.ts deleted file mode 100644 index 98226f8ff8a..00000000000 --- a/designable/next/src/schemas/Checkbox.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Checkbox: ISchema & { Group?: ISchema } = { - type: 'object', - properties: {}, -} - -Checkbox.Group = { - type: 'object', - properties: { - direction: { - type: 'string', - enum: ['hoz', 'ver'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'hoz', - optionType: 'button', - }, - }, - }, -} diff --git a/designable/next/src/schemas/DatePicker.ts b/designable/next/src/schemas/DatePicker.ts deleted file mode 100644 index 54382b5b74c..00000000000 --- a/designable/next/src/schemas/DatePicker.ts +++ /dev/null @@ -1,84 +0,0 @@ -import type { ISchema } from '@formily/react' - -const CommonDatePickerAPI = { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - format: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - showTime: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - resetTime: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - hasClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - popupTriggerType: { - type: 'string', - enum: ['click', 'hover'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'click', - optionType: 'button', - }, - }, - popupAlign: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - followTrigger: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, -} - -export const DatePicker: ISchema & { RangePicker?: ISchema } = { - type: 'object', - properties: { - ...CommonDatePickerAPI, - }, -} - -DatePicker.RangePicker = { - type: 'object', - properties: { - ...CommonDatePickerAPI, - type: { - type: 'string', - enum: ['date', 'month', 'year'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'date', - }, - }, - }, -} diff --git a/designable/next/src/schemas/Form.ts b/designable/next/src/schemas/Form.ts deleted file mode 100644 index 51b143ecd33..00000000000 --- a/designable/next/src/schemas/Form.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ISchema } from '@formily/react' -import { FormLayout } from './FormLayout' -import { CSSStyle } from './CSSStyle' - -export const Form: ISchema = { - type: 'object', - properties: { - ...(FormLayout.properties as any), - style: CSSStyle, - }, -} diff --git a/designable/next/src/schemas/FormCollapse.ts b/designable/next/src/schemas/FormCollapse.ts deleted file mode 100644 index 23e94628ec9..00000000000 --- a/designable/next/src/schemas/FormCollapse.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const FormCollapse: ISchema & { CollapsePanel?: ISchema } = { - type: 'object', - properties: { - accordion: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} - -FormCollapse.CollapsePanel = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, -} diff --git a/designable/next/src/schemas/FormGrid.ts b/designable/next/src/schemas/FormGrid.ts deleted file mode 100644 index ced61bbc994..00000000000 --- a/designable/next/src/schemas/FormGrid.ts +++ /dev/null @@ -1,65 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const FormGrid: ISchema = { - type: 'object', - properties: { - minWidth: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 100, - }, - }, - maxWidth: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - minColumns: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 0, - }, - }, - maxColumns: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - breakpoints: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - columnGap: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 10, - }, - }, - rowGap: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 5, - }, - }, - colWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/next/src/schemas/FormItem.ts b/designable/next/src/schemas/FormItem.ts deleted file mode 100644 index b87bea7c1a1..00000000000 --- a/designable/next/src/schemas/FormItem.ts +++ /dev/null @@ -1,140 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const FormItem: ISchema = { - type: 'object', - properties: { - tooltip: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonBefore: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonAfter: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - labelCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - wrapperCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - labelWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - wrapperWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - colon: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - asterisk: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - gridSpan: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - feedbackLayout: { - type: 'string', - enum: ['loose', 'terse', 'popover', 'none', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'loose', - }, - }, - size: { - type: 'string', - enum: ['small', 'default', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'default', - }, - }, - layout: { - type: 'string', - enum: ['horizontal', 'vertical', 'inline', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'horizontal', - }, - }, - tooltipLayout: { - type: 'string', - enum: ['icon', 'text', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'icon', - }, - }, - labelAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'right', - }, - }, - wrapperAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'left', - }, - }, - labelWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - wrapperWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - fullness: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - inset: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/next/src/schemas/FormLayout.ts b/designable/next/src/schemas/FormLayout.ts deleted file mode 100644 index 517aae1ebbf..00000000000 --- a/designable/next/src/schemas/FormLayout.ts +++ /dev/null @@ -1,123 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const FormLayout: ISchema = { - type: 'object', - properties: { - labelCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - wrapperCol: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - labelWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - wrapperWidth: { - 'x-decorator': 'FormItem', - 'x-component': 'SizeInput', - }, - colon: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - feedbackLayout: { - type: 'string', - enum: ['loose', 'terse', 'popover', 'none', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'loose', - }, - }, - size: { - type: 'string', - enum: ['small', 'default', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'default', - }, - }, - layout: { - type: 'string', - enum: ['horizontal', 'vertical', 'inline', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'horizontal', - }, - }, - tooltipLayout: { - type: 'string', - enum: ['icon', 'text', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'icon', - }, - }, - labelAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'right', - }, - }, - wrapperAlign: { - type: 'string', - enum: ['left', 'right', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'left', - }, - }, - labelWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - wrapperWrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - fullness: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - inset: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - shallow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - bordered: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/next/src/schemas/FormTab.ts b/designable/next/src/schemas/FormTab.ts deleted file mode 100644 index 2e548c66506..00000000000 --- a/designable/next/src/schemas/FormTab.ts +++ /dev/null @@ -1,98 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const FormTab: ISchema & { TabPane?: ISchema } = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - shape: { - type: 'string', - enum: ['pure', 'wrapped', 'text', 'capsule'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - default: 'pure', - }, - animation: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - excessMode: { - type: 'string', - enum: ['slide', 'dropdown'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'slide', - optionType: 'button', - }, - }, - tabPosition: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'top', - optionType: 'button', - }, - 'x-reactions': { - dependencies: ['.shape'], - when: `{{$deps[0] === 'wrapped'}}`, - fulfill: { - schema: { - enum: ['top', 'bottom', 'left', 'right'], - }, - }, - otherwise: { - schema: { - enum: ['top', 'bottom'], - }, - state: { - value: `{{$self.value !== 'bottom' ? 'top' : 'bottom'}}`, - }, - }, - }, - }, - triggerType: { - type: 'string', - enum: ['click', 'hover'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'click', - optionType: 'button', - }, - }, - extra: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, -} - -FormTab.TabPane = { - type: 'object', - properties: { - title: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - closeable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Input.ts b/designable/next/src/schemas/Input.ts deleted file mode 100644 index 4b569352ffa..00000000000 --- a/designable/next/src/schemas/Input.ts +++ /dev/null @@ -1,166 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Input: ISchema & { TextArea?: ISchema } = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - maxLength: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - showLimitHint: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - cutString: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - trim: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - composition: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - hasClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - hasBorder: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - hint: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - innerBefore: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - innerAfter: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonTextBefore: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - addonTextAfter: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} - -Input.TextArea = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - maxLength: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - cutString: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - trim: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - composition: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - hasBorder: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - autoHeight: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - default: false, - }, - rows: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-reactions': { - dependencies: ['.autoHeight'], - fulfill: { - state: { - visible: '{{!$deps[0]}}', - }, - }, - }, - 'x-component-props': { - min: 0, - precision: 0, - }, - }, - }, -} diff --git a/designable/next/src/schemas/NumberPicker.ts b/designable/next/src/schemas/NumberPicker.ts deleted file mode 100644 index 01632c53a89..00000000000 --- a/designable/next/src/schemas/NumberPicker.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const NumberPicker: ISchema = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - type: { - type: 'string', - enum: ['normal', 'inline'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'normal', - optionType: 'button', - }, - }, - step: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - precision: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - min: 0, - precision: 0, - }, - }, - autoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - max: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - min: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - innerAfter: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - device: { - type: 'string', - enum: ['desktop', 'phone', 'tablet'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'desktop', - optionType: 'button', - }, - }, - hasTrigger: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - default: true, - }, - alwaysShowTrigger: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-reactions': { - dependencies: ['.hasTrigger'], - fulfill: { - state: { - visible: '{{$deps[0]}}', - }, - }, - }, - }, - }, -} diff --git a/designable/next/src/schemas/Password.ts b/designable/next/src/schemas/Password.ts deleted file mode 100644 index f3fa977cd0b..00000000000 --- a/designable/next/src/schemas/Password.ts +++ /dev/null @@ -1,7 +0,0 @@ -import type { ISchema } from '@formily/react' -import { Input } from './Input' - -export const Password: ISchema = { - type: 'object', - properties: Input.properties, -} diff --git a/designable/next/src/schemas/Radio.ts b/designable/next/src/schemas/Radio.ts deleted file mode 100644 index 6abe7312b31..00000000000 --- a/designable/next/src/schemas/Radio.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Radio: ISchema & { Group?: ISchema } = { - type: 'object', - properties: {}, -} - -Radio.Group = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - shape: { - type: 'string', - enum: ['normal', 'button'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - default: 'normal', - 'x-component-props': { - optionType: 'button', - }, - }, - direction: { - type: 'string', - enum: ['hoz', 'ver'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'hoz', - optionType: 'button', - }, - 'x-reactions': { - dependencies: ['.shape'], - fulfill: { - state: { - visible: `{{$deps[0] === 'normal'}}`, - }, - }, - }, - }, - }, -} diff --git a/designable/next/src/schemas/Range.ts b/designable/next/src/schemas/Range.ts deleted file mode 100644 index 5f99130c8b0..00000000000 --- a/designable/next/src/schemas/Range.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Range: ISchema = { - type: 'object', - properties: { - slider: { - type: 'string', - enum: ['single', 'double'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'single', - optionType: 'button', - }, - }, - min: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - max: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - step: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - marks: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION', 'BOOLEAN', 'NUMBER'], - }, - }, - marksPosition: { - type: 'string', - enum: ['above', 'below'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'above', - optionType: 'button', - }, - }, - hasTip: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - reverse: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - pure: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - fixedWidth: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - tooltipVisible: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - rtl: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Rating.ts b/designable/next/src/schemas/Rating.ts deleted file mode 100644 index 39ef62d611e..00000000000 --- a/designable/next/src/schemas/Rating.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Rating: ISchema = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - count: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - showGrade: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - allowHalf: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - allowClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Select.ts b/designable/next/src/schemas/Select.ts deleted file mode 100644 index cbc9bd0e1a7..00000000000 --- a/designable/next/src/schemas/Select.ts +++ /dev/null @@ -1,183 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Select: ISchema = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - autoWidth: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - hasClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - followTrigger: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - filterLocal: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - filter: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - helpCode: - 'function(key: string, item: object): boolean {\n return true\n}', - }, - }, - autoHighlightFirstItem: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - useVirtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - mode: { - type: 'string', - enum: ['single', 'multiple', 'tag'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - default: 'single', - 'x-component-props': { - optionType: 'button', - }, - }, - notFoundContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - showDataSourceChildren: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - hasBorder: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - hasArrow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-reactions': { - dependencies: ['.mode'], - fulfill: { - state: { - visible: `{{$deps[0] !== 'tag'}}`, - }, - }, - }, - }, - hasSelectAll: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - cacheValue: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - tagInline: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-reactions': { - dependencies: ['.mode'], - fulfill: { - state: { - visible: `{{$deps[0] === 'multiple'}}`, - }, - }, - }, - }, - tagClosable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - adjustTagSize: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: false, - }, - }, - maxTagCount: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - hiddenSelected: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-reactions': { - dependencies: ['.mode'], - fulfill: { - state: { - visible: `{{$deps[0] === 'tag' || $deps[0] === 'multiple'}}`, - }, - }, - }, - }, - popupAutoFocus: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Space.ts b/designable/next/src/schemas/Space.ts deleted file mode 100644 index 0de4efe051c..00000000000 --- a/designable/next/src/schemas/Space.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Space: ISchema = { - type: 'object', - properties: { - align: { - type: 'string', - enum: ['start', 'end', 'center', 'baseline'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - }, - direction: { - type: 'string', - enum: ['horizontal', 'vertical'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'horizontal', - optionType: 'button', - }, - }, - size: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - 'x-component-props': { - defaultValue: 8, - }, - }, - split: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - wrap: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Switch.ts b/designable/next/src/schemas/Switch.ts deleted file mode 100644 index 03b184c5d56..00000000000 --- a/designable/next/src/schemas/Switch.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Switch: ISchema = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - checkedChildren: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - unCheckedChildren: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - autoWidth: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Text.ts b/designable/next/src/schemas/Text.ts deleted file mode 100644 index 66784e1c78e..00000000000 --- a/designable/next/src/schemas/Text.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ISchema } from '@formily/react' - -export const Text: ISchema = { - type: 'object', - properties: { - content: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - }, - mode: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'normal', - }, - enum: ['h1', 'h2', 'h3', 'p', 'normal'], - }, - }, -} diff --git a/designable/next/src/schemas/TimePicker.ts b/designable/next/src/schemas/TimePicker.ts deleted file mode 100644 index c9d0dba8f9e..00000000000 --- a/designable/next/src/schemas/TimePicker.ts +++ /dev/null @@ -1,64 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const TimePicker: ISchema = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - hasClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - format: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - hourStep: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - minuteStep: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - secondStep: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - popupAlign: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - popupTriggerType: { - type: 'string', - enum: ['click', 'hover'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'click', - optionType: 'button', - }, - }, - }, -} diff --git a/designable/next/src/schemas/Transfer.ts b/designable/next/src/schemas/Transfer.ts deleted file mode 100644 index 47cbb8cee21..00000000000 --- a/designable/next/src/schemas/Transfer.ts +++ /dev/null @@ -1,81 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Transfer: ISchema = { - type: 'object', - properties: { - id: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - mode: { - type: 'string', - enum: ['normal', 'simple'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'normal', - optionType: 'button', - }, - }, - leftDisabled: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - rightDisabled: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - filter: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - helpCode: - 'function(searchedValue: string, data: object): boolean {\n return true\n}', - }, - }, - searchPlaceholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - notFoundContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - titles: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - sortable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - useVirtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - showCheckAll: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} diff --git a/designable/next/src/schemas/TreeSelect.ts b/designable/next/src/schemas/TreeSelect.ts deleted file mode 100644 index 6038be397f0..00000000000 --- a/designable/next/src/schemas/TreeSelect.ts +++ /dev/null @@ -1,104 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const TreeSelect: ISchema = { - type: 'object', - properties: { - size: { - type: 'string', - enum: ['small', 'medium', 'large', null], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'medium', - }, - }, - placeholder: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - hasArrow: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - hasBorder: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - hasClear: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - autoWidth: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - showSearch: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - notFoundContent: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - multiple: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - treeCheckable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - treeCheckStrictly: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - treeCheckedStrategy: { - type: 'string', - enum: ['parent', 'child', 'all'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: 'parent', - }, - }, - treeDefaultExpandAll: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - followTrigger: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - useVirtual: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - immutable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, -} diff --git a/designable/next/src/schemas/Upload.ts b/designable/next/src/schemas/Upload.ts deleted file mode 100644 index 7019b05efd2..00000000000 --- a/designable/next/src/schemas/Upload.ts +++ /dev/null @@ -1,111 +0,0 @@ -import type { ISchema } from '@formily/react' - -export const Upload: ISchema & { Dragger?: ISchema } = { - type: 'object', - properties: { - action: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - shape: { - type: 'string', - enum: [null, 'card'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: null, - optionType: 'button', - }, - }, - accept: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - data: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - headers: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - withCredentials: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - timeout: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - method: { - type: 'string', - enum: ['post', 'put'], - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - 'x-component-props': { - defaultValue: 'post', - optionType: 'button', - }, - }, - request: { - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - helpCode: `// Function(option: Object) => Object`, - }, - }, - name: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - listType: { - type: 'string', - enum: [null, 'text', 'image', 'card'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - defaultValue: null, - }, - }, - limit: { - type: 'number', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - dragable: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - useDataURL: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - autoUpload: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - 'x-component-props': { - defaultChecked: true, - }, - }, - }, -} - -Upload.Dragger = Upload diff --git a/designable/next/src/schemas/index.ts b/designable/next/src/schemas/index.ts deleted file mode 100644 index 77c01f385c0..00000000000 --- a/designable/next/src/schemas/index.ts +++ /dev/null @@ -1,27 +0,0 @@ -export * from './Input' -export * from './FormLayout' -export * from './CSSStyle' -export * from './Form' -export * from './FormItem' -export * from './Select' -export * from './Card' -export * from './Cascader' -export * from './Checkbox' -export * from './Radio' -export * from './DatePicker' -export * from './NumberPicker' -export * from './Password' -export * from './Rating' -export * from './Range' -export * from './TimePicker' -export * from './TreeSelect' -export * from './Transfer' -export * from './Upload' -export * from './Switch' -export * from './FormGrid' -export * from './Space' -export * from './Text' -export * from './FormTab' -export * from './FormCollapse' -export * from './ArrayTable' -export * from './ArrayCards' diff --git a/designable/next/src/shared.ts b/designable/next/src/shared.ts deleted file mode 100644 index 42347831f5c..00000000000 --- a/designable/next/src/shared.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { TreeNode, Engine } from '@designable/core' - -export type ComponentNameMatcher = - | string - | string[] - | ((name: string, node: TreeNode, context?: any) => boolean) - -export const matchComponent = ( - node: TreeNode, - name: ComponentNameMatcher, - context?: any -) => { - if (name === '*') return true - const componentName = node?.props?.['x-component'] - if (typeof name === 'function') - return name(componentName || '', node, context) - if (Array.isArray(name)) return name.includes(componentName) - return componentName === name -} - -export const matchChildComponent = ( - node: TreeNode, - name: ComponentNameMatcher, - context?: any -) => { - if (name === '*') return true - const componentName = node?.props?.['x-component'] - if (!componentName) return false - if (typeof name === 'function') - return name(componentName || '', node, context) - if (Array.isArray(name)) return name.includes(componentName) - return componentName.indexOf(`${name}.`) > -1 -} - -export const includesComponent = ( - node: TreeNode, - names: ComponentNameMatcher[], - target?: TreeNode -) => { - return names.some((name) => matchComponent(node, name, target)) -} - -export const queryNodesByComponentPath = ( - node: TreeNode, - path: ComponentNameMatcher[] -): TreeNode[] => { - if (path?.length === 0) return [] - if (path?.length === 1) { - if (matchComponent(node, path[0])) { - return [node] - } - } - return matchComponent(node, path[0]) - ? node.children.reduce((buf, child) => { - return buf.concat(queryNodesByComponentPath(child, path.slice(1))) - }, []) - : [] -} - -export const findNodeByComponentPath = ( - node: TreeNode, - path: ComponentNameMatcher[] -): TreeNode => { - if (path?.length === 0) return - if (path?.length === 1) { - if (matchComponent(node, path[0])) { - return node - } - } - if (matchComponent(node, path[0])) { - for (let i = 0; i < node.children.length; i++) { - const next = findNodeByComponentPath(node.children[i], path.slice(1)) - if (next) { - return next - } - } - } -} - -export const hasNodeByComponentPath = ( - node: TreeNode, - path: ComponentNameMatcher[] -) => !!findNodeByComponentPath(node, path) - -export const matchArrayItemsNode = (node: TreeNode) => { - return ( - node?.parent?.props?.type === 'array' && - node?.parent?.children?.[0] === node - ) -} - -export const createNodeId = (designer: Engine, id: string) => { - return { - [designer.props.nodeIdAttrName]: id, - } -} - -export const createEnsureTypeItemsNode = (type: string) => (node: TreeNode) => { - const objectNode = node.children.find((child) => child.props['type'] === type) - if ( - objectNode && - objectNode.designerProps.droppable && - !objectNode.props['x-component'] - ) { - return objectNode - } else { - const newObjectNode = new TreeNode({ - componentName: 'DesignableField', - props: { - type, - }, - }) - node.prependNode(newObjectNode) - return newObjectNode - } -} diff --git a/designable/next/src/sources/arrays.ts b/designable/next/src/sources/arrays.ts deleted file mode 100644 index 0f8cb421140..00000000000 --- a/designable/next/src/sources/arrays.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('arrays', [ - { - componentName: 'DesignableField', - props: { - type: 'array', - 'x-decorator': 'FormItem', - 'x-component': 'ArrayTable', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'array', - 'x-decorator': 'FormItem', - 'x-component': 'ArrayCards', - 'x-component-props': { - title: `Title`, - }, - }, - }, -]) diff --git a/designable/next/src/sources/displays.ts b/designable/next/src/sources/displays.ts deleted file mode 100644 index 8506ea95256..00000000000 --- a/designable/next/src/sources/displays.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('displays', [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'Text', - }, - }, -]) diff --git a/designable/next/src/sources/index.ts b/designable/next/src/sources/index.ts deleted file mode 100644 index c9da47ecd8a..00000000000 --- a/designable/next/src/sources/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import './inputs' -import './layouts' -import './arrays' -import './displays' diff --git a/designable/next/src/sources/inputs.ts b/designable/next/src/sources/inputs.ts deleted file mode 100644 index 40c03e750d6..00000000000 --- a/designable/next/src/sources/inputs.ts +++ /dev/null @@ -1,192 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('inputs', [ - { - componentName: 'DesignableField', - props: { - title: 'Input', - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'TextArea', - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'Select', - 'x-decorator': 'FormItem', - 'x-component': 'Select', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'Tree Select', - 'x-decorator': 'FormItem', - 'x-component': 'TreeSelect', - }, - }, - { - componentName: 'DesignableField', - props: { - title: 'Cascader', - 'x-decorator': 'FormItem', - 'x-component': 'Cascader', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string | number', - title: 'Radio Group', - 'x-decorator': 'FormItem', - 'x-component': 'Radio.Group', - enum: [ - { label: '选项1', value: 1 }, - { label: '选项2', value: 2 }, - ], - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Checkbox Group', - 'x-decorator': 'FormItem', - 'x-component': 'Checkbox.Group', - enum: [ - { label: '选项1', value: 1 }, - { label: '选项2', value: 2 }, - ], - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'number', - title: 'Range', - 'x-decorator': 'FormItem', - 'x-component': 'Range', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'number', - title: 'Rating', - 'x-decorator': 'FormItem', - 'x-component': 'Rating', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string', - title: 'DatePicker', - 'x-decorator': 'FormItem', - 'x-component': 'DatePicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: '[string,string]', - title: 'DateRangePicker', - 'x-decorator': 'FormItem', - 'x-component': 'DatePicker.RangePicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string', - title: 'TimePicker', - 'x-decorator': 'FormItem', - 'x-component': 'TimePicker', - }, - }, - // { - // componentName: 'DesignableField', - // props: { - // type: '[string,string]', - // title: 'TimeRangePicker', - // 'x-decorator': 'FormItem', - // 'x-component': 'TimePicker.RangePicker', - // }, - // }, - { - componentName: 'DesignableField', - props: { - type: 'number', - title: 'NumberPicker', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'string', - title: 'Password', - 'x-decorator': 'FormItem', - 'x-component': 'Password', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Transfer', - 'x-decorator': 'FormItem', - 'x-component': 'Transfer', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Upload', - 'x-decorator': 'FormItem', - 'x-component': 'Upload', - 'x-component-props': { - textContent: 'Upload', - }, - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'Array', - title: 'Drag Upload', - 'x-decorator': 'FormItem', - 'x-component': 'Upload.Dragger', - 'x-component-props': { - textContent: 'Click or drag file to this area to upload', - }, - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'boolean', - title: 'Switch', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'object', - }, - }, -]) diff --git a/designable/next/src/sources/layouts.ts b/designable/next/src/sources/layouts.ts deleted file mode 100644 index 3cbaa54b251..00000000000 --- a/designable/next/src/sources/layouts.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { GlobalDragSource } from '@designable/core' - -GlobalDragSource.appendSourcesByGroup('layouts', [ - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'Card', - 'x-component-props': { - title: 'Title', - contentHeight: 'auto', - }, - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormGrid', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormLayout', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'Space', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormTab', - }, - }, - { - componentName: 'DesignableField', - props: { - type: 'void', - 'x-component': 'FormCollapse', - }, - }, -]) diff --git a/designable/next/tsconfig.build.json b/designable/next/tsconfig.build.json deleted file mode 100644 index dbf069a065d..00000000000 --- a/designable/next/tsconfig.build.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "paths": { - "@formily/*": [ - "../../packages/*", - "../../designable/*", - "../../devtools/*" - ] - }, - "declaration": true - } -} diff --git a/designable/next/tsconfig.json b/designable/next/tsconfig.json deleted file mode 100644 index c6865c25a75..00000000000 --- a/designable/next/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["./src/**/*.ts", "./src/**/*.tsx"], - "exclude": ["./src/__tests__/*", "./esm/*", "./lib/*"] -} diff --git a/designable/setters/.npmignore b/designable/setters/.npmignore deleted file mode 100644 index 1ff337420fd..00000000000 --- a/designable/setters/.npmignore +++ /dev/null @@ -1,11 +0,0 @@ -node_modules -*.log -build -docs -doc-site -__tests__ -.eslintrc -jest.config.js -tsconfig.json -.umi -src \ No newline at end of file diff --git a/designable/setters/.umirc.js b/designable/setters/.umirc.js deleted file mode 100644 index 1362b3c43c6..00000000000 --- a/designable/setters/.umirc.js +++ /dev/null @@ -1,44 +0,0 @@ -import { resolve } from 'path' -export default { - mode: 'site', - logo: '//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg', - title: 'Formily', - hash: true, - favicon: - '//img.alicdn.com/imgextra/i3/O1CN01XtT3Tv1Wd1b5hNVKy_!!6000000002810-55-tps-360-360.svg', - outputPath: './doc-site', - navs: [ - { - title: 'Ant Design', - path: '/components', - }, - { - title: '主站', - path: 'https://v2.formilyjs.org', - }, - { - title: 'GITHUB', - path: 'https://github.com/alibaba/formily', - }, - ], - styles: [ - `.__dumi-default-navbar-logo{ - height: 60px !important; - width: 150px !important; - padding-left:0 !important; - color: transparent !important; - } - .__dumi-default-navbar{ - padding: 0 28px !important; - } - .__dumi-default-layout-hero{ - background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png); - background-size: cover; - background-repeat: no-repeat; - } - nav a{ - text-decoration: none !important; - } - `, - ], -} diff --git a/designable/setters/LICENSE.md b/designable/setters/LICENSE.md deleted file mode 100644 index 509632e8e80..00000000000 --- a/designable/setters/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015-present, Alibaba Group Holding Limited. All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/designable/setters/README.md b/designable/setters/README.md deleted file mode 100644 index 84103eebdc5..00000000000 --- a/designable/setters/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# @formily/designable-antd - -### Install - -```bash -npm install --save @formily/designable-antd -``` diff --git a/designable/setters/copy.ts b/designable/setters/copy.ts deleted file mode 100644 index d451fc48651..00000000000 --- a/designable/setters/copy.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { runCopy } from '../../scripts/build-style' - -runCopy({ - esStr: 'antd/es/', - libStr: 'antd/lib/', -}) diff --git a/designable/setters/package.json b/designable/setters/package.json deleted file mode 100644 index efbc3ca3a0d..00000000000 --- a/designable/setters/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "@formily/designable-setters", - "version": "2.0.0-rc.7", - "license": "MIT", - "main": "lib", - "module": "esm", - "umd:main": "dist/formily.designable.antd.umd.production.js", - "unpkg": "dist/formily.designable.umd.production.js", - "jsdelivr": "dist/formily.designable.umd.production.js", - "jsnext:main": "esm", - "repository": { - "type": "git", - "url": "git+https://github.com/alibaba/formily.git" - }, - "types": "esm/index.d.ts", - "bugs": { - "url": "https://github.com/alibaba/formily/issues" - }, - "homepage": "https://github.com/alibaba/formily#readme", - "engines": { - "npm": ">=3.0.0" - }, - "scripts": { - "build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm && npm run build:umd && ts-node copy", - "build:cjs": "tsc --project tsconfig.build.json", - "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm", - "build:umd": "rollup --config", - "start": "webpack-dev-server --config playground/webpack.dev.ts" - }, - "devDependencies": { - "antd": "^4.0.0" - }, - "peerDependencies": { - "@types/react": ">=16.8.0 || >=17.0.0", - "@types/react-dom": ">=16.8.0 || >=17.0.0", - "antd": "^4.0.0", - "react": ">=16.8.0 || >=17.0.0", - "react-dom": ">=16.8.0", - "react-is": ">=16.8.0 || >=17.0.0" - }, - "dependencies": { - "@designable/core": "^0.x", - "@designable/formily": "^0.x", - "@designable/react": "^0.x", - "@designable/react-settings-form": "^0.x", - "@formily/antd": "2.0.0-rc.7", - "@formily/core": "2.0.0-rc.7", - "@formily/react": "2.0.0-rc.7", - "@formily/shared": "2.0.0-rc.7" - }, - "publishConfig": { - "access": "public" - }, - "gitHead": "2c44ae410a73f02735c63c6430e021a50e21f3ec" -} diff --git a/designable/setters/rollup.config.js b/designable/setters/rollup.config.js deleted file mode 100644 index 859c8d570c1..00000000000 --- a/designable/setters/rollup.config.js +++ /dev/null @@ -1,24 +0,0 @@ -import baseConfig, { - removeImportStyleFromInputFilePlugin, -} from '../../scripts/rollup.base.js' -import postcss from 'rollup-plugin-postcss' -import NpmImport from 'less-plugin-npm-import' - -export default baseConfig( - 'formily.designable.antd', - 'Formily.Designable.Antd', - removeImportStyleFromInputFilePlugin(), - postcss({ - extract: true, - minimize: true, - // extensions: ['.css', '.less', '.sass'], - use: { - less: { - plugins: [new NpmImport({ prefix: '~' })], - javascriptEnabled: true, - }, - sass: {}, - stylus: {}, - }, - }) -) diff --git a/designable/setters/src/components/DataSourceSetter/DataSettingPanel.tsx b/designable/setters/src/components/DataSourceSetter/DataSettingPanel.tsx deleted file mode 100644 index 3989b9f5d34..00000000000 --- a/designable/setters/src/components/DataSourceSetter/DataSettingPanel.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import React, { useMemo, Fragment } from 'react' -import { Button } from 'antd' -import { PlusOutlined } from '@ant-design/icons' -import { ArrayItems, Form, Input, FormItem } from '@formily/antd' -import { createForm } from '@formily/core' -import { observer } from '@formily/reactive-react' -import { createSchemaField } from '@formily/react' -import { ValueInput } from '@designable/react-settings-form' -import { usePrefix, TextWidget } from '@designable/react' -import { Header } from './Header' -import { traverseTree } from './shared' -import { ITreeDataSource } from './types' -import './styles.less' - -const SchemaField = createSchemaField({ - components: { - FormItem, - Input, - ArrayItems, - ValueInput, - }, -}) - -export interface IDataSettingPanelProps { - treeDataSource: ITreeDataSource -} - -export const DataSettingPanel: React.FC = observer( - (props) => { - const prefix = usePrefix('data-source-setter') - const form = useMemo(() => { - let values: any - traverseTree(props.treeDataSource.dataSource, (dataItem) => { - if (dataItem.key === props.treeDataSource.selectedKey) { - values = dataItem - } - }) - return createForm({ - values, - }) - }, [ - props.treeDataSource.selectedKey, - props.treeDataSource.dataSource.length, - ]) - if (!props.treeDataSource.selectedKey) - return ( - -
- } - extra={null} - /> -
- -
- - ) - return ( - -
- } - extra={ - - } - /> -
-
- - - - - } - x-decorator="FormItem" - name="label" - x-component="Input" - /> - - } - x-decorator="FormItem" - name="value" - x-component="ValueInput" - /> - - - - -
-
- - ) - } -) diff --git a/designable/setters/src/components/DataSourceSetter/Header.tsx b/designable/setters/src/components/DataSourceSetter/Header.tsx deleted file mode 100644 index 4e81abad2c6..00000000000 --- a/designable/setters/src/components/DataSourceSetter/Header.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React, { ReactNode } from 'react' -import { observer } from '@formily/reactive-react' -import { usePrefix } from '@designable/react' -import './styles.less' - -export interface IHeaderProps { - extra: ReactNode | null - title: ReactNode | string -} - -export const Header: React.FC = observer(({ extra, title }) => { - const prefix = usePrefix('data-source-setter') - return ( -
-
{title}
- {extra} -
- ) -}) diff --git a/designable/setters/src/components/DataSourceSetter/Title.tsx b/designable/setters/src/components/DataSourceSetter/Title.tsx deleted file mode 100644 index b1a5f306da6..00000000000 --- a/designable/setters/src/components/DataSourceSetter/Title.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react' -import { clone, toArr } from '@formily/shared' -import { observer } from '@formily/reactive-react' -import { IconWidget, TextWidget, usePrefix } from '@designable/react' -import { INodeItem, ITreeDataSource } from './types' -import { traverseTree } from './shared' -import './styles.less' -export interface ITitleProps extends INodeItem { - treeDataSource: ITreeDataSource -} - -export const Title: React.FC = observer((props) => { - const prefix = usePrefix('data-source-setter-node-title') - const getTitleValue = (dataSource) => { - const optionalKeys = ['label', 'title', 'header'] - let nodeTitle: string - optionalKeys.some((key) => { - const title = toArr(dataSource).find((item) => item.label === key)?.value - if (title !== undefined) { - nodeTitle = title - return true - } - return false - }) - if (nodeTitle === undefined) { - toArr(dataSource || []).some((item) => { - if (item.value && typeof item.value === 'string') { - nodeTitle = item.value - return true - } - return false - }) - } - return nodeTitle - } - - const renderTitle = (dataSource) => { - const nodeTitle = getTitleValue(dataSource) - if (nodeTitle === undefined) - return ( - - ) - else return nodeTitle + '' - } - - return ( -
- - {renderTitle(props?.map || [])} - - { - const newDataSource = clone(props?.treeDataSource?.dataSource) - traverseTree(newDataSource || [], (dataItem, i, data) => { - if (data[i].key === props.duplicateKey) toArr(data).splice(i, 1) - }) - props.treeDataSource.dataSource = newDataSource - }} - /> -
- ) -}) diff --git a/designable/setters/src/components/DataSourceSetter/TreePanel.tsx b/designable/setters/src/components/DataSourceSetter/TreePanel.tsx deleted file mode 100644 index 3210fb0a4dd..00000000000 --- a/designable/setters/src/components/DataSourceSetter/TreePanel.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import React, { Fragment } from 'react' -import { Tree, Button, TreeProps } from 'antd' -import { uid } from '@formily/shared' -import { observer } from '@formily/reactive-react' -import { usePrefix, TextWidget, IconWidget } from '@designable/react' -import { Title } from './Title' -import { Header } from './Header' -import { traverseTree } from './shared' -import { ITreeDataSource, INodeItem } from './types' -import './styles.less' -import { GlobalRegistry } from '@designable/core' - -export interface ITreePanelProps { - treeDataSource: ITreeDataSource -} - -export const TreePanel: React.FC = observer((props) => { - const prefix = usePrefix('data-source-setter') - const dropHandler = (info: Parameters[0]) => { - const dropKey = info.node?.key - const dragKey = info.dragNode?.key - const dropPos = info.node.pos.split('-') - const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]) - const data = [...props.treeDataSource.dataSource] - // Find dragObject - let dragObj: INodeItem - traverseTree(data, (item, index, arr) => { - if (arr[index].key === dragKey) { - arr.splice(index, 1) - dragObj = item - } - }) - if (!info.dropToGap) { - traverseTree(data, (item) => { - if (item.key === dropKey) { - item.children = item.children || [] - item.children.unshift(dragObj) - } - }) - } else if ( - (info.node.children || []).length > 0 && - info.node.expanded && - dropPosition === 1 - ) { - traverseTree(data, (item) => { - if (item.key === dropKey) { - item.children = item.children || [] - item.children.unshift(dragObj) - } - }) - } else { - let ar: any[] - let i: number - traverseTree(data, (item, index, arr) => { - if (item.key === dropKey) { - ar = arr - i = index - } - }) - if (dropPosition === -1) { - ar.splice(i, 0, dragObj) - } else { - ar.splice(i + 1, 0, dragObj) - } - } - props.treeDataSource.dataSource = data - } - return ( - -
- } - extra={ - - } - /> -
- {}} - onDrop={dropHandler} - titleRender={(titleProps: INodeItem) => { - return ( - - ) - }} - onSelect={(selectedKeys) => { - if (selectedKeys[0]) { - props.treeDataSource.selectedKey = selectedKeys[0].toString() - } - }} - > -
- - ) -}) diff --git a/designable/setters/src/components/DataSourceSetter/index.tsx b/designable/setters/src/components/DataSourceSetter/index.tsx deleted file mode 100644 index 9d8ef8606ac..00000000000 --- a/designable/setters/src/components/DataSourceSetter/index.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React, { Fragment, useMemo, useState } from 'react' -import cls from 'classnames' -import { Modal, Button } from 'antd' -import { observable } from '@formily/reactive' -import { observer } from '@formily/reactive-react' -import { usePrefix, useTheme, TextWidget } from '@designable/react' -import { DataSettingPanel } from './DataSettingPanel' -import { TreePanel } from './TreePanel' -import { transformDataToValue, transformValueToData } from './shared' -import { IDataSourceItem, ITreeDataSource } from './types' -import './styles.less' - -export interface IDataSourceSetterProps { - className?: string - style?: React.CSSProperties - onChange: (dataSource: IDataSourceItem[]) => void - value: IDataSourceItem[] -} -export const DataSourceSetter: React.FC = observer( - (props) => { - const { className, value = [], onChange } = props - const theme = useTheme() - const prefix = usePrefix('data-source-setter') - const [modalVisible, setModalVisible] = useState(false) - const treeDataSource: ITreeDataSource = useMemo( - () => - observable({ - dataSource: transformValueToData(value), - selectedKey: '', - }), - [value, modalVisible] - ) - const openModal = () => setModalVisible(true) - const closeModal = () => setModalVisible(false) - return ( - - - - } - width="65%" - bodyStyle={{ padding: 10 }} - transitionName="" - maskTransitionName="" - visible={modalVisible} - onCancel={closeModal} - onOk={() => { - onChange(transformDataToValue(treeDataSource.dataSource)) - closeModal() - }} - > -
-
- -
-
- -
-
-
-
- ) - } -) diff --git a/designable/setters/src/components/DataSourceSetter/shared.ts b/designable/setters/src/components/DataSourceSetter/shared.ts deleted file mode 100644 index 072c6c70f83..00000000000 --- a/designable/setters/src/components/DataSourceSetter/shared.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { uid, clone, toArr } from '@formily/shared' -import { IDataSourceItem, INodeItem } from './types' - -export interface INode { - key?: string - map?: any - children?: INode[] -} - -export const traverseTree = ( - data: T[], - callback: (dataItem: T, i: number, data: T[]) => any -) => { - for (let i = 0; i < data.length; i++) { - callback(data[i], i, data) - if (data[i]?.children) { - traverseTree(data[i]?.children, callback) - } - } -} - -export const transformValueToData = (value: IDataSourceItem[]): INodeItem[] => { - const data = clone(value) - traverseTree(data, (item, i, dataSource) => { - const dataItem = { - key: '', - duplicateKey: '', - map: [], - children: [], - } - for (const [key, value] of Object.entries(dataSource[i] || {})) { - if (key !== 'children') dataItem.map.push({ label: key, value: value }) - } - const uuid = uid() - dataItem.key = uuid - dataItem.duplicateKey = uuid - dataItem.children = dataSource[i].children || [] - dataSource[i] = dataItem - }) - return data -} - -export const transformDataToValue = (data: INodeItem[]): IDataSourceItem[] => { - const value = clone(data) - traverseTree(value, (item, i, dataSource) => { - let valueItem: IDataSourceItem = { - children: [], - } - toArr(dataSource[i].map).forEach((item) => { - if (item.label) valueItem[item.label] = item.value - }) - valueItem.children = dataSource[i]?.children || [] - dataSource[i] = valueItem - }) - return value -} diff --git a/designable/setters/src/components/DataSourceSetter/styles.less b/designable/setters/src/components/DataSourceSetter/styles.less deleted file mode 100644 index f2561f2726e..00000000000 --- a/designable/setters/src/components/DataSourceSetter/styles.less +++ /dev/null @@ -1,81 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-data-source-setter { - ::-webkit-scrollbar { - width: 5px; - height: 5px; - } - - ::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, 0.2); - border-radius: 0; - transition: all 0.25s ease-in-out; - } - - ::-webkit-scrollbar-thumb:hover { - background-color: rgba(0, 0, 0, 0.3); - } - &-node-title { - display: flex; - justify-content: space-between; - align-items: center; - - &-icon { - transition: all 0.15s ease-in-out; - opacity: 0; - - &:hover { - color: @primary-color; - } - } - } - - &-layout { - display: flex; - justify-content: space-around; - border: 1px solid @border-color-split; - border-radius: 3px; - - .ant-tree-treenode { - padding-right: 10px; - white-space: nowrap; - - &:hover { - .dn-data-source-setter-node-title-icon { - opacity: 1; - } - } - } - - &-item { - position: relative; - - &.left { - width: 40%; - border-right: 1px solid @border-color-split; - } - - &.right { - width: 60%; - } - - &-header { - display: flex; - flex: none; - align-items: center; - justify-content: space-between; - height: 40px; - padding: 8px 12px 9px; - border-bottom: 1px solid @border-color-split; - border-radius: 2px 2px 0 0; - } - - &-content { - padding: 2%; - height: 300px; - max-height: 300px; - overflow: scroll; - } - } - } -} diff --git a/designable/setters/src/components/DataSourceSetter/types.ts b/designable/setters/src/components/DataSourceSetter/types.ts deleted file mode 100644 index ffffd0e65b9..00000000000 --- a/designable/setters/src/components/DataSourceSetter/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -export interface IDataSourceItem { - label?: '' - value?: any - children?: any[] -} - -export interface INodeItem { - key: string - duplicateKey?: string - map?: { label: string; value: any }[] - children?: INodeItem[] -} - -export interface ITreeDataSource { - dataSource: INodeItem[] - selectedKey: string -} diff --git a/designable/setters/src/components/ReactionsSetter/FieldPropertySetter.tsx b/designable/setters/src/components/ReactionsSetter/FieldPropertySetter.tsx deleted file mode 100644 index eb09e255880..00000000000 --- a/designable/setters/src/components/ReactionsSetter/FieldPropertySetter.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import React, { useState } from 'react' -import { TextWidget, usePrefix } from '@designable/react' -import { Menu } from 'antd' -import { MonacoInput } from '@designable/react-settings-form' -import { isPlainObj, reduce } from '@formily/shared' -import { FieldProperties } from './properties' -export interface IFieldProperty { - [key: string]: string -} - -export interface IFieldPropertySetterProps { - extraLib?: string - value?: IFieldProperty - onChange?: (value: IFieldProperty) => void -} - -const template = (code: string) => { - if (!code) return - return code.trim() -} - -export const FieldPropertySetter: React.FC = ( - props -) => { - const [selectKeys, setSelectKeys] = useState(['visible']) - const prefix = usePrefix('field-property-setter') - const value = { ...props.value } - - const parseExpression = (expression: string) => { - if (!expression) return '' - return String(expression).match(/^\{\{([\s\S]*)\}\}$/)?.[1] || '' - } - - const filterEmpty = (value: object) => { - return reduce( - value, - (buf, value, key) => { - if (!value || value === '{{}}') return buf - buf[key] = value - return buf - }, - {} - ) - } - - const currentProperty = FieldProperties.find( - (item) => item.key === selectKeys[0] - ) - - return ( -
- { - setSelectKeys(selectedKeys) - }} - > - {FieldProperties.map((key) => { - if (isPlainObj(key)) { - return ( - - - - ) - } - return ( - - - - ) - })} - -
-
- {`$self.${selectKeys[0]} = (`} - - {'//'}{' '} - {' '} - {'`'} - {currentProperty?.type} - {'`'} - -
-
- { - props.onChange?.( - filterEmpty({ - ...value, - [selectKeys[0]]: `{{${expression}}}`, - }) - ) - }} - /> -
-
{`)`}
-
-
- ) -} diff --git a/designable/setters/src/components/ReactionsSetter/PathSelector.tsx b/designable/setters/src/components/ReactionsSetter/PathSelector.tsx deleted file mode 100644 index b96d326aed6..00000000000 --- a/designable/setters/src/components/ReactionsSetter/PathSelector.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import React from 'react' -import { TreeNode } from '@designable/core' -import { useCurrentNode } from '@designable/react' -import { TreeSelectProps, TreeSelect } from 'antd' - -export interface IPathSelectorProps - extends Omit, 'onChange'> { - value?: string - onChange?: (value: string, node: TreeNode) => void - style?: React.CSSProperties - className?: string -} - -const transformDataSource = (node: TreeNode) => { - const currentNode = node - const dots = (count: number) => { - let dots = '' - for (let i = 0; i < count; i++) { - dots += '.' - } - return dots - } - const targetPath = (parentNode: TreeNode, targetNode: TreeNode) => { - const path = [] - const transform = (node: TreeNode) => { - if (node && node !== parentNode) { - path.push(node.props.name || node.id) - } else { - transform(node.parent) - } - } - transform(targetNode) - return path.reverse().join('.') - } - const hasNoVoidChildren = (node: TreeNode) => { - return node.children?.some((node) => { - if (node.props.type !== 'void' && node !== currentNode) return true - return hasNoVoidChildren(node) - }) - } - const findRoot = (node: TreeNode): TreeNode => { - if (!node?.parent) return node - if (node?.parent?.componentName !== node.componentName) return node.parent - return findRoot(node.parent) - } - const findArrayParent = (node: TreeNode) => { - if (!node?.parent) return - if (node.parent.props.type === 'array') return node.parent - if (node.parent === root) return - return findArrayParent(node.parent) - } - const transformRelativePath = (arrayNode: TreeNode, targetNode: TreeNode) => { - if (targetNode.depth === currentNode.depth) - return `.${targetNode.props.name || targetNode.id}` - return `${dots(currentNode.depth - arrayNode.depth)}[].${targetPath( - arrayNode, - targetNode - )}` - } - const transformChildren = (children: TreeNode[], path = []) => { - return children.reduce((buf, node) => { - if (node === currentNode) return buf - if (node.props.type === 'array' && !node.contains(currentNode)) return buf - if (node.props.type === 'void' && !hasNoVoidChildren(node)) return buf - const currentPath = path.concat(node.props.name || node.id) - const arrayNode = findArrayParent(node) - const label = - node.props.title || - node.props['x-component-props']?.title || - node.props.name || - node.designerProps.title - const value = arrayNode - ? transformRelativePath(arrayNode, node) - : currentPath.join('.') - return buf.concat({ - label, - value, - node, - children: transformChildren(node.children, currentPath), - }) - }, []) - } - const root = findRoot(node) - if (root) { - return transformChildren(root.children) - } - return [] -} - -export const PathSelector: React.FC = (props) => { - const baseNode = useCurrentNode() - const dataSource = transformDataSource(baseNode) - const findNode = (dataSource: any[], value: string) => { - for (let i = 0; i < dataSource.length; i++) { - const item = dataSource[i] - if (item.value === value) return item.node - if (item.children?.length) { - const fondedChild = findNode(item.children, value) - if (fondedChild) return fondedChild - } - } - } - return ( - { - props.onChange(value, findNode(dataSource, value)) - }} - treeDefaultExpandAll - treeData={dataSource} - /> - ) -} diff --git a/designable/setters/src/components/ReactionsSetter/declarations.ts b/designable/setters/src/components/ReactionsSetter/declarations.ts deleted file mode 100644 index 80fedfaa790..00000000000 --- a/designable/setters/src/components/ReactionsSetter/declarations.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { MonacoInput } from '@designable/react-settings-form' - -export interface IDependency { - name: string - path: string -} - -const loadDependencies = async (deps: IDependency[]) => { - return Promise.all( - deps.map(async ({ name, path }) => ({ - name, - path, - library: await fetch(`//cdn.jsdelivr.net/npm/${name}/${path}`).then( - (res) => res.text() - ), - })) - ) -} - -MonacoInput.loader.init().then(async (monaco) => { - const deps = await loadDependencies([ - { name: '@formily/core', path: 'dist/formily.core.all.d.ts' }, - ]) - deps?.forEach(({ name, library }) => { - monaco.languages.typescript.typescriptDefaults.addExtraLib( - `declare module '${name}'{ ${library} }`, - `file:///node_modules/${name}/index.d.ts` - ) - }) - monaco.languages.typescript.typescriptDefaults.addExtraLib( - ` - import { Form, Field } from '@formily/core' - declare global { - /* - * Form Model - **/ - declare var $form: Form - /* - * Field Model - **/ - declare var $self: Field - /* - * create an persistent observable state object - **/ - declare var $observable: (target: T, deps?: any[]) => T - /* - * create a persistent data - **/ - declare var $memo: (callback: () => T, deps?: any[]) => T - /* - * handle side-effect logic - **/ - declare var $effect: (callback: () => void | (() => void), deps?: any[]) => void - /* - * set initial component props to current field - **/ - declare var $props: (props: any) => void - } - `, - `file:///node_modules/formily_global.d.ts` - ) -}) diff --git a/designable/setters/src/components/ReactionsSetter/helpers.ts b/designable/setters/src/components/ReactionsSetter/helpers.ts deleted file mode 100644 index 0b28735bebc..00000000000 --- a/designable/setters/src/components/ReactionsSetter/helpers.ts +++ /dev/null @@ -1,393 +0,0 @@ -export const GlobalHelper = ` -/** - * You can use the built-in context variables - * - * 1. \`$self\` is the current Field Model - * - * 2. \`$form\` is the current Form Model - * - * 3. \`$deps\` is the dependencies value - * - * 4. \`$observable\` function is used to create an persistent observable state object - * - * 5. \`$memo\` function is is used to create a persistent data - * - * 6. \`$effect\` function is used to handle side-effect logic - * - * 7. \`$props\` function is used to set component props to current field - * - * Document Links - * - * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F - **/ -` - -export const BooleanHelper = ` -/** - * Example 1 - * Static Boolean - **/ - -false - -/** - * Example 2 - * Equal Calculation - **/ - -$deps.VariableName === 'TARGET_VALUE' - -/** - * Example 3 - * Not Equal Calculation - **/ - -$deps.VariableName !== 'TARGET_VALUE' - -/** - * Example 4 - * And Logic Calculation - **/ - -$deps.VariableName1 && $deps.VariableName2 - -/** - * Example 5 - * Grater Logic Calculation - **/ - -$deps.VariableName > 100 - -/** - * Example 6 - * Not Logic Calculation - **/ - -!$deps.VariableName - -${GlobalHelper} -` - -export const DisplayHelper = ` -/** - * Example 1 - * Static Mode - **/ - -'none' - -/** - * Example 2 - * Equal Condition Associated - **/ - -$deps.VariableName === 'TARGET_VALUE' ? 'visible' : 'none' - -/** - * Example 3 - * Not Equal Condition Associated - **/ - -$deps.VariableName !== 'TARGET_VALUE' ? 'visible' : 'hidden' - -/** - * Example 4 - * And Logic Condition Associated - **/ - -$deps.VariableName1 && $deps.VariableName2 ? 'visible' : 'none' - -/** - * Example 5 - * Grater Logic Condition Associated - **/ - -$deps.VariableName > 100 ? 'visible' : 'hidden' - -/** - * Example 6 - * Not Logic Condition Associated - **/ - -!$deps.VariableName ? 'visible' : 'none' - -${GlobalHelper} -` - -export const PatternHelper = ` -/** - * Example 1 - * Static Mode - **/ - -'readPretty' - -/** - * Example 2 - * Equal Condition Associated - **/ - -$deps.VariableName === 'TARGET_VALUE' ? 'editable' : 'disabled' - -/** - * Example 3 - * Not Equal Condition Associated - **/ - -$deps.VariableName !== 'TARGET_VALUE' ? 'editable' : 'readOnly' - -/** - * Example 4 - * And Logic Condition Associated - **/ - -$deps.VariableName1 && $deps.VariableName2 ? 'editable' : 'readPretty' - -/** - * Example 5 - * Grater Logic Condition Associated - **/ - -$deps.VariableName > 100 ? 'editable' : 'readOnly' - -/** - * Example 6 - * Not Logic Condition Associated - **/ - -!$deps.VariableName ? 'editable' : 'disabled' - -${GlobalHelper} -` - -export const StringHelper = ` -/** - * Example 1 - * Static String - **/ - -'Normal String Text' - -/** - * Example 2 - * Associated String - **/ - -$deps.VariableName === 'TARGET_VALUE' ? 'Associated String Text' : '' - -${GlobalHelper} -` - -export const AnyHelper = ` -/** - * Example 1 - * String Type - **/ - -'String' - -/** - * Example 2 - * String Array - **/ - -['StringArray'] - -/** - * Example 3 - * Object Array - **/ - -[{ key: 'ObjectArray' }] - -/** - * Example 4 - * Boolean - **/ - -true - -/** - * Example 5 - * RegExp - **/ - -/\d+/ - -/** - * Example 1 - * Associated String Value - **/ - -$deps.VariableName + 'Compose String' - -/** - * Example 2 - * Associated Array Value - **/ - -[ $deps.VariableName ] - -/** - * Example 3 - * Associated Object Value - **/ - -{ - key : $deps.VariableName -} - -/** - * Example 4 - * Associated Boolean Value - **/ - -!$deps.VariableName - -${GlobalHelper} -` - -export const DataSourceHelper = ` -/** - * Example 1 - * Static DataSource - **/ - -[ - { label : "item1", value: "1" }, - { label : "item2", value: "2" } -] - -/** - * Example 2 - * Associated DataSource - **/ - -[ - { label : "item1", value: "1" }, - { label : "item2", value: "2" }, - ...$deps.VariableName -] - -${GlobalHelper} -` - -export const ComponentPropsHelper = ` -/** - * Example 1 - * Static Props - **/ - -{ - placeholder: "This is placeholder" -} - -/** - * Example 2 - * Associated Props - **/ - -{ - placeholder: $deps.VariableName -} - -${GlobalHelper} -` - -export const DecoratorPropsHelper = ` -/** - * Example 1 - * Static Props - **/ - -{ - labelCol:6 -} - -/** - * Example 2 - * Associated Props - **/ - -{ - labelCol: $deps.VariableName -} - -${GlobalHelper} -` - -export const FulfillRunHelper = ` -/** - * Example 1 - * Async Select - **/ - -$effect(()=>{ - $self.loading = true - fetch('//some.domain/getSomething') - .then(response=>response.json()) - .then(({ data })=>{ - $self.loading = false - $self.dataSource = data - },()=>{ - $self.loading = false - }) -},[]) - - -/** - * Example 2 - * Async Search Select - **/ - -const state = $observable({ - keyword:'' -}) - -$props({ - onSearch(keyword){ - state.keyword = keyword - } -}) - -$effect(()=>{ - $self.loading = true - fetch(\`//some.domain/getSomething?q=\${state.keyword}\`) - .then(response=>response.json()) - .then(({ data })=>{ - $self.loading = false - $self.dataSource = data - },()=>{ - $self.loading = false - }) -},[ state.keyword ]) - -/** - * Example 3 - * Async Associated Select - **/ - -const state = $observable({ - keyword:'' -}) - -$props({ - onSearch(keyword){ - state.keyword = keyword - } -}) - -$effect(()=>{ - $self.loading = true - fetch(\`//some.domain/getSomething?q=\${state.keyword}&other=\${$deps.VariableName}\`) - .then(response=>response.json()) - .then(({ data })=>{ - $self.loading = false - $self.dataSource = data - },()=>{ - $self.loading = false - }) -},[ state.keyword, $deps.VariableName ]) - -${GlobalHelper} -` diff --git a/designable/setters/src/components/ReactionsSetter/index.tsx b/designable/setters/src/components/ReactionsSetter/index.tsx deleted file mode 100644 index 19707f88a42..00000000000 --- a/designable/setters/src/components/ReactionsSetter/index.tsx +++ /dev/null @@ -1,435 +0,0 @@ -import React, { useEffect, useMemo, useState } from 'react' -import { clone, uid } from '@formily/shared' -import { createForm, isVoidField } from '@formily/core' -import { createSchemaField } from '@formily/react' -import { GlobalRegistry } from '@designable/core' -import { requestIdle } from '@designable/shared' -import { usePrefix, TextWidget } from '@designable/react' -import { MonacoInput } from '@designable/react-settings-form' -import { - Form, - ArrayTable, - Input, - Select, - FormItem, - FormCollapse, -} from '@formily/antd' -import { Modal, Card, Button, Tag, Tooltip } from 'antd' -import { PathSelector } from './PathSelector' -import { FieldPropertySetter } from './FieldPropertySetter' -import { FulfillRunHelper } from './helpers' -import { IReaction } from './types' -import './declarations' -import './styles.less' - -export interface IReactionsSetterProps { - value?: IReaction - onChange?: (value: IReaction) => void -} - -const TypeView = ({ value }) => { - const text = String(value) - if (text.length <= 26) return {text} - return ( - - - -
-                {text}
-              
-
- - } - > - {text.substring(0, 24)}... -
-
- ) -} - -const SchemaField = createSchemaField({ - components: { - Card, - FormCollapse, - Input, - TypeView, - Select, - FormItem, - PathSelector, - FieldPropertySetter, - ArrayTable, - MonacoInput, - }, -}) - -const FieldStateProperties = [ - 'value', - 'initialValue', - 'inputValue', - 'inputValues', - 'modified', - 'initialized', - 'title', - 'description', - 'mounted', - 'unmounted', - 'active', - 'visited', - 'loading', - 'errors', - 'warnings', - 'successes', - 'feedbacks', - 'valid', - 'invalid', - 'pattern', - 'display', - 'disabled', - 'readOnly', - 'readPretty', - 'visible', - 'hidden', - 'editable', - 'validateStatus', - 'validating', -] - -const FieldStateValueTypes = { - modified: 'boolean', - initialized: 'boolean', - title: 'string', - description: 'string', - mounted: 'boolean', - unmounted: 'boolean', - active: 'boolean', - visited: 'boolean', - loading: 'boolean', - errors: 'string[]', - warnings: 'string[]', - successes: 'string[]', - feedbacks: `Array< - triggerType?: 'onInput' | 'onFocus' | 'onBlur' - type?: 'error' | 'success' | 'warning' - code?: - | 'ValidateError' - | 'ValidateSuccess' - | 'ValidateWarning' - | 'EffectError' - | 'EffectSuccess' - | 'EffectWarning' - messages?: string[] -> -`, - valid: 'boolean', - invalid: 'boolean', - pattern: "'editable' | 'disabled' | 'readOnly' | 'readPretty'", - display: "'visible' | 'hidden' | 'none'", - disabled: 'boolean', - readOnly: 'boolean', - readPretty: 'boolean', - visible: 'boolean', - hidden: 'boolean', - editable: 'boolean', - validateStatus: "'error' | 'warning' | 'success' | 'validating'", - validating: 'boolean', -} - -export const ReactionsSetter: React.FC = (props) => { - const [modalVisible, setModalVisible] = useState(false) - const [innerVisible, setInnerVisible] = useState(false) - const prefix = usePrefix('reactions-setter') - const form = useMemo(() => { - return createForm({ - values: clone(props.value), - }) - }, [modalVisible, props.value]) - const formCollapse = useMemo( - () => FormCollapse.createFormCollapse(['deps', 'state']), - [modalVisible] - ) - const openModal = () => setModalVisible(true) - const closeModal = () => setModalVisible(false) - useEffect(() => { - if (modalVisible) { - requestIdle( - () => { - setInnerVisible(true) - }, - { - timeout: 400, - } - ) - } else { - setInnerVisible(false) - } - }, [modalVisible]) - return ( - <> - - { - form.submit((values) => { - props.onChange?.(values) - }) - closeModal() - }} - > -
- {innerVisible && ( -
- - - - - - - - - - - - - { - if (isVoidField(field)) return - field.query('.source').take((source) => { - if (isVoidField(source)) return - if ( - source.value && - !field.value && - !field.modified - ) { - field.value = - source.inputValues[1]?.props?.name || - `v_${uid()}` - } - }) - }} - /> - - - - { - if (isVoidField(field)) return - const property = field - .query('.property') - .get('inputValues') - field.query('.source').take((source) => { - if (isVoidField(source)) return - if (source.value) { - if ( - property[0] === 'value' || - property[0] === 'initialValue' || - property[0] === 'inputValue' - ) { - field.value = - source.inputValues[1]?.props?.type || - 'any' - } else if (property[0] === 'inputValues') { - field.value = `any[]` - } else if (property[0]) { - field.value = - FieldStateValueTypes[property[0]] - } else { - field.value = 'any' - } - } - }) - }} - /> - - - - - - - - - - - - - - { - const deps = field.query('dependencies').value() - if (Array.isArray(deps)) { - field.componentProps.extraLib = ` - declare var $deps : { - ${deps.map(({ name, type }) => { - if (!name) return '' - return `${name}?:${type || 'any'},` - })} - } - ` - } - }} - /> - - - -
- )} -
-
- - ) -} diff --git a/designable/setters/src/components/ReactionsSetter/properties.ts b/designable/setters/src/components/ReactionsSetter/properties.ts deleted file mode 100644 index 25c2dffce91..00000000000 --- a/designable/setters/src/components/ReactionsSetter/properties.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { - BooleanHelper, - PatternHelper, - StringHelper, - AnyHelper, - DataSourceHelper, - DecoratorPropsHelper, - DisplayHelper, - ComponentPropsHelper, -} from './helpers' - -export const FieldProperties = [ - { - key: 'visible', - type: 'boolean', - helpCode: BooleanHelper, - }, - { key: 'hidden', type: 'boolean', helpCode: BooleanHelper }, - { - key: 'display', - type: '"visible" | "hidden" | "none"', - helpCode: DisplayHelper, - }, - { - key: 'pattern', - type: '"editable" | "disabled" | "readOnly" | "readPretty"', - helpCode: PatternHelper, - }, - { key: 'title', type: 'string', helpCode: StringHelper }, - { key: 'description', type: 'string', helpCode: StringHelper }, - { key: 'value', type: 'any', helpCode: AnyHelper }, - { key: 'initialValue', type: 'any', helpCode: AnyHelper }, - { key: 'required', type: 'boolean', helpCode: BooleanHelper }, - { - key: 'dataSource', - type: 'Array<{label?:string,value?:any}>', - helpCode: DataSourceHelper, - }, - { - key: 'component[1]', - token: 'componentProps', - type: 'object', - helpCode: ComponentPropsHelper, - }, - { - key: 'decorator[1]', - token: 'decoratorProps', - type: 'object', - helpCode: DecoratorPropsHelper, - }, -] diff --git a/designable/setters/src/components/ReactionsSetter/styles.less b/designable/setters/src/components/ReactionsSetter/styles.less deleted file mode 100644 index 45a223967b7..00000000000 --- a/designable/setters/src/components/ReactionsSetter/styles.less +++ /dev/null @@ -1,105 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; - -.dn-reactions-setter { - width: 100%; - min-height: 623px; - overflow: hidden; - - ::-webkit-scrollbar { - width: 5px; - height: 5px; - } - - ::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, 0.2); - border-radius: 0; - transition: all 0.25s ease-in-out; - } - - ::-webkit-scrollbar-thumb:hover { - background-color: rgba(0, 0, 0, 0.3); - } - - .@{ant-prefix}-collapse { - border: 1px solid @border-color-split; - - &-header { - padding: 8px 10px !important; - background-color: @background-color-light !important; - border-bottom: 1px solid @border-color-split !important; - font-weight: 500 !important; - - .@{ant-prefix}-collapse-arrow { - margin-right: 4px !important; - } - } - - &-item { - border: none !important; - } - - &-content { - border: none !important; - transition: none !important; - } - - &-content-box { - padding: 12px !important; - } - } - - .reaction-runner { - .@{ant-prefix}-collapse-content-box { - padding: 12px 0 !important; - } - } - - .reaction-state { - .@{ant-prefix}-collapse-content-box { - padding: 12px 0 !important; - } - } - - .dn-field-property-setter { - display: flex; - height: 300px; - - &-coder-wrapper { - display: flex; - flex-grow: 2; - height: 100%; - padding-left: 10px; - position: relative; - flex-direction: column; - } - - &-coder-start { - font-size: 18px; - line-height: 30px; - margin-bottom: 4px; - color: @text-color; - font-weight: 300; - flex-grow: 0; - opacity: 0.96; - height: 31px; - } - - &-coder-end { - font-size: 18px; - height: 31px; - color: @text-color; - margin-top: 4px; - margin-bottom: 4px; - line-height: 30px; - font-weight: 300; - flex-grow: 0; - opacity: 0.96; - } - - &-coder { - min-width: 0; - flex-grow: 2; - padding-left: 10px; - } - } -} diff --git a/designable/setters/src/components/ReactionsSetter/types.ts b/designable/setters/src/components/ReactionsSetter/types.ts deleted file mode 100644 index ad84a650ed3..00000000000 --- a/designable/setters/src/components/ReactionsSetter/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface IReaction { - dependencies?: { - [key: string]: string - } - fulfill?: { - state?: { - [key: string]: string - } - schema?: { - [key: string]: string - } - } -} diff --git a/designable/setters/src/components/ValidatorSetter/index.tsx b/designable/setters/src/components/ValidatorSetter/index.tsx deleted file mode 100644 index ff02955c452..00000000000 --- a/designable/setters/src/components/ValidatorSetter/index.tsx +++ /dev/null @@ -1,172 +0,0 @@ -import React from 'react' -import { ArrayField } from '@formily/core' -import { - observer, - useField, - SchemaContext, - Schema, - ISchema, -} from '@formily/react' -import { GlobalRegistry } from '@designable/core' -import { ArrayItems } from '@formily/antd' -import { FoldItem } from '@designable/react-settings-form' -import { Select } from 'antd' - -export interface IValidatorSetterProps { - value?: any - onChange?: (value: any) => void -} - -const ValidatorSchema: ISchema = { - type: 'array', - items: { - type: 'object', - 'x-decorator': 'ArrayItems.Item', - 'x-decorator-props': { - style: { - alignItems: 'center', - borderRadius: 3, - paddingTop: 6, - paddingBottom: 6, - }, - }, - properties: { - sortable: { - type: 'void', - 'x-component': 'ArrayItems.SortHandle', - 'x-component-props': { style: { marginRight: 10 } }, - }, - drawer: { - type: 'void', - 'x-component': 'DrawerSetter', - properties: { - triggerType: { - type: 'string', - enum: ['onInput', 'onFocus', 'onBlur'], - 'x-decorator': 'FormItem', - 'x-component': 'Select', - }, - validator: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'ValueInput', - 'x-component-props': { - include: ['EXPRESSION'], - }, - }, - message: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input.TextArea', - }, - format: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Select', - 'x-component-props': { - allowClear: true, - }, - }, - pattern: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'Input', - 'x-component-props': { - prefix: '/', - suffix: '/', - }, - }, - len: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - max: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - min: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - exclusiveMaximum: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - exclusiveMinimum: { - type: 'string', - 'x-decorator': 'FormItem', - 'x-component': 'NumberPicker', - }, - whitespace: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - required: { - type: 'boolean', - 'x-decorator': 'FormItem', - 'x-component': 'Switch', - }, - }, - }, - moveDown: { - type: 'void', - 'x-component': 'ArrayItems.MoveDown', - 'x-component-props': { style: { marginLeft: 10 } }, - }, - moveUp: { - type: 'void', - 'x-component': 'ArrayItems.MoveUp', - 'x-component-props': { style: { marginLeft: 5 } }, - }, - remove: { - type: 'void', - 'x-component': 'ArrayItems.Remove', - 'x-component-props': { style: { marginLeft: 5 } }, - }, - }, - }, - properties: { - addValidatorRules: { - type: 'void', - 'x-component': 'ArrayItems.Addition', - 'x-component-props': { - style: { - marginBottom: 10, - }, - }, - }, - }, -} - -export const ValidatorSetter: React.FC = observer( - (props) => { - const field = useField() - return ( - - -