@formily-design/formily-antd 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/package.json +8 -8
  2. package/.umirc.js +0 -44
  3. package/copy.ts +0 -6
  4. package/playground/components/AsyncSelect/AsyncSelect.tsx +0 -38
  5. package/playground/components/AsyncSelect/index.tsx +0 -1
  6. package/playground/components/AsyncSelect/preview.tsx +0 -36
  7. package/playground/components/ClickEventSetter/ActionConfigModal.tsx +0 -173
  8. package/playground/components/ClickEventSetter/ActionList.tsx +0 -67
  9. package/playground/components/ClickEventSetter/DownloadPanel.tsx +0 -24
  10. package/playground/components/ClickEventSetter/NavigationPanel.tsx +0 -42
  11. package/playground/components/ClickEventSetter/RequestPanel.tsx +0 -190
  12. package/playground/components/ClickEventSetter/index.tsx +0 -90
  13. package/playground/components/ClickEventSetter/styles.less +0 -89
  14. package/playground/components/ClickEventSetter/types.ts +0 -43
  15. package/playground/components/FormButton/FormButton.tsx +0 -189
  16. package/playground/components/FormButton/hooks/useEventActionExecutor.ts +0 -65
  17. package/playground/components/FormButton/index.ts +0 -1
  18. package/playground/components/FormButton/preview.tsx +0 -60
  19. package/playground/components/FormButton/utils/actionExecutors.ts +0 -96
  20. package/playground/components/FormButtonGroup/FormButtonGroup.tsx +0 -21
  21. package/playground/components/FormButtonGroup/index.ts +0 -1
  22. package/playground/components/FormButtonGroup/preview.tsx +0 -66
  23. package/playground/components/FormList/FormList.tsx +0 -164
  24. package/playground/components/FormList/index.tsx +0 -1
  25. package/playground/components/FormList/preview.tsx +0 -429
  26. package/playground/components/LocationPicker/LocationModal.tsx +0 -328
  27. package/playground/components/LocationPicker/LocationPicker.tsx +0 -163
  28. package/playground/components/LocationPicker/SearchBox.tsx +0 -122
  29. package/playground/components/LocationPicker/api.ts +0 -77
  30. package/playground/components/LocationPicker/constants.ts +0 -2
  31. package/playground/components/LocationPicker/index.tsx +0 -44
  32. package/playground/components/LocationPicker/types.ts +0 -160
  33. package/playground/components/LocationPicker/utils.ts +0 -46
  34. package/playground/components/ResourceIcon/index.module.less +0 -10
  35. package/playground/components/ResourceIcon/index.tsx +0 -10
  36. package/playground/designerLocales/en-US.ts +0 -38
  37. package/playground/designerLocales/index.ts +0 -6
  38. package/playground/designerLocales/ko-KR.ts +0 -10
  39. package/playground/designerLocales/zh-CN.ts +0 -38
  40. package/playground/locales/FormButton.ts +0 -38
  41. package/playground/locales/FormButtonGroup.ts +0 -29
  42. package/playground/locales/LocationPicker.ts +0 -30
  43. package/playground/locales/all.ts +0 -3
  44. package/playground/locales/index.ts +0 -3
  45. package/playground/main.tsx +0 -222
  46. package/playground/react-app-env.d.ts +0 -4
  47. package/playground/request.ts +0 -123
  48. package/playground/schemas/FormButton.ts +0 -42
  49. package/playground/schemas/FormButtonGroup.ts +0 -24
  50. package/playground/schemas/LocationPicker.ts +0 -14
  51. package/playground/schemas/all.ts +0 -3
  52. package/playground/schemas/index.ts +0 -3
  53. package/playground/service/index.ts +0 -1
  54. package/playground/service/schema.ts +0 -22
  55. package/playground/template.ejs +0 -20
  56. package/playground/utils.ts +0 -744
  57. package/playground/webpack.base.ts +0 -123
  58. package/playground/webpack.dev.ts +0 -64
  59. package/playground/webpack.prod.ts +0 -46
  60. package/playground/widgets/ActionsWidget.tsx +0 -58
  61. package/playground/widgets/LogoWidget.tsx +0 -20
  62. package/playground/widgets/MarkupSchemaWidget.tsx +0 -164
  63. package/playground/widgets/PreviewWidget.tsx +0 -188
  64. package/playground/widgets/SchemaEditorWidget.tsx +0 -27
  65. package/playground/widgets/index.ts +0 -5
  66. package/tsconfig.build.json +0 -12
@@ -1,123 +0,0 @@
1
- import path from 'path'
2
- import fs from 'fs-extra'
3
- import { GlobSync } from 'glob'
4
- import MiniCssExtractPlugin from 'mini-css-extract-plugin'
5
- import autoprefixer from 'autoprefixer'
6
- import yaml from 'js-yaml'
7
- //import { getThemeVariables } from 'antd/dist/theme'
8
-
9
- const getWorkspaceAlias = () => {
10
- const basePath = path.resolve(__dirname, '../../../')
11
- const results: Record<string, string> = {}
12
-
13
- const pkg = fs.readJSONSync(path.resolve(basePath, 'package.json')) || {}
14
-
15
- let workspaces: string[] = []
16
-
17
- if (Array.isArray(pkg.workspaces)) {
18
- workspaces = pkg.workspaces
19
- } else {
20
- const pnpmWorkspacePath = path.resolve(basePath, 'pnpm-workspace.yaml')
21
- if (fs.existsSync(pnpmWorkspacePath)) {
22
- const pnpmWorkspace = yaml.load(
23
- fs.readFileSync(pnpmWorkspacePath, 'utf-8')
24
- ) as { packages?: string[] }
25
- workspaces = pnpmWorkspace.packages || []
26
- }
27
- }
28
-
29
- if (workspaces.length > 0) {
30
- workspaces.forEach((pattern) => {
31
- const { found } = new GlobSync(pattern, { cwd: basePath })
32
- found.forEach((name) => {
33
- const pkgJson = fs.readJSONSync(
34
- path.resolve(basePath, name, './package.json')
35
- )
36
- results[pkgJson.name] = path.resolve(basePath, name, './src')
37
- })
38
- })
39
- }
40
-
41
- const currentPkg = fs.readJSONSync(path.resolve(__dirname, '../package.json'))
42
- results[currentPkg.name] = path.resolve(__dirname, '../src')
43
-
44
- return results
45
- }
46
-
47
- export default {
48
- mode: 'development',
49
- devtool: 'inline-source-map', // 嵌入到源文件中
50
- stats: {
51
- entrypoints: false,
52
- children: false,
53
- },
54
- entry: {
55
- playground: path.resolve(__dirname, './main'),
56
- },
57
- output: {
58
- path: path.resolve(__dirname, '../build'),
59
- filename: '[name].[hash].bundle.js',
60
- },
61
- resolve: {
62
- modules: [path.resolve(__dirname, '../../../node_modules'), 'node_modules'],
63
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.mjs'],
64
- alias: getWorkspaceAlias(),
65
- },
66
- module: {
67
- rules: [
68
- {
69
- test: /\.tsx?$/,
70
- use: [
71
- {
72
- loader: require.resolve('ts-loader'),
73
- options: {
74
- transpileOnly: true,
75
- },
76
- },
77
- ],
78
- },
79
- {
80
- test: /\.css$/,
81
- use: [MiniCssExtractPlugin.loader, require.resolve('css-loader')],
82
- },
83
- {
84
- test: /\.less$/,
85
- use: [
86
- MiniCssExtractPlugin.loader,
87
- { loader: 'css-loader' },
88
- {
89
- loader: 'postcss-loader',
90
- options: {
91
- plugins: () => autoprefixer(),
92
- },
93
- },
94
- {
95
- loader: 'less-loader',
96
- options: {
97
- // modifyVars: getThemeVariables({
98
- // dark: true, // 开启暗黑模式
99
- // }),
100
- javascriptEnabled: true,
101
- },
102
- },
103
- ],
104
- },
105
- {
106
- test: /\.(woff|woff2|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
107
- use: ['url-loader'],
108
- },
109
- {
110
- test: /\.html?$/,
111
- loader: require.resolve('file-loader'),
112
- options: {
113
- name: '[name].[ext]',
114
- },
115
- },
116
- {
117
- test: /\.mjs$/,
118
- include: /node_modules/,
119
- type: 'javascript/auto',
120
- },
121
- ],
122
- },
123
- }
@@ -1,64 +0,0 @@
1
- import baseConfig from './webpack.base'
2
- import HtmlWebpackPlugin from 'html-webpack-plugin'
3
- import MiniCssExtractPlugin from 'mini-css-extract-plugin'
4
- import MonacoPlugin from 'monaco-editor-webpack-plugin'
5
- //import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
6
- import webpack from 'webpack'
7
- import path from 'path'
8
-
9
- const PORT = 3001
10
-
11
- const createPages = (pages) => {
12
- return pages.map(({ filename, template, chunk }) => {
13
- return new HtmlWebpackPlugin({
14
- filename,
15
- template,
16
- inject: 'body',
17
- chunks: chunk,
18
- })
19
- })
20
- }
21
-
22
- for (const key in baseConfig.entry) {
23
- if (Array.isArray(baseConfig.entry[key])) {
24
- baseConfig.entry[key].push(
25
- require.resolve('webpack/hot/dev-server'),
26
- `${require.resolve('webpack-dev-server/client')}?http://localhost:${PORT}`
27
- )
28
- }
29
- }
30
-
31
- export default {
32
- ...baseConfig,
33
- plugins: [
34
- new MiniCssExtractPlugin({
35
- filename: '[name].[hash].css',
36
- chunkFilename: '[id].[hash].css',
37
- }),
38
- ...createPages([
39
- {
40
- filename: 'index.html',
41
- template: path.resolve(__dirname, './template.ejs'),
42
- chunk: ['playground'],
43
- },
44
- ]),
45
- new webpack.HotModuleReplacementPlugin(),
46
- new MonacoPlugin({
47
- languages: ['json'],
48
- }),
49
- // new BundleAnalyzerPlugin()
50
- ],
51
- devServer: {
52
- host: '127.0.0.1',
53
- open: true,
54
- port: PORT,
55
- proxy: {
56
- '/apimap': {
57
- target: 'https://apis.map.qq.com/ws',
58
- changeOrigin: true,
59
- secure: false,
60
- pathRewrite: { '^/apimap': '' },
61
- },
62
- },
63
- },
64
- }
@@ -1,46 +0,0 @@
1
- import baseConfig from './webpack.base'
2
- import HtmlWebpackPlugin from 'html-webpack-plugin'
3
- import MiniCssExtractPlugin from 'mini-css-extract-plugin'
4
- import MonacoPlugin from 'monaco-editor-webpack-plugin'
5
- import path from 'path'
6
-
7
- const createPages = (pages) => {
8
- return pages.map(({ filename, template, chunk }) => {
9
- return new HtmlWebpackPlugin({
10
- filename,
11
- template,
12
- inject: 'body',
13
- chunks: chunk,
14
- })
15
- })
16
- }
17
-
18
- export default {
19
- ...baseConfig,
20
- mode: 'production',
21
- plugins: [
22
- new MiniCssExtractPlugin({
23
- filename: '[name].[hash].css',
24
- chunkFilename: '[id].[hash].css',
25
- }),
26
- ...createPages([
27
- {
28
- filename: 'index.html',
29
- template: path.resolve(__dirname, './template.ejs'),
30
- chunk: ['playground'],
31
- },
32
- ]),
33
- new MonacoPlugin({
34
- languages: ['json'],
35
- }),
36
- ],
37
- optimization: {
38
- minimize: true,
39
- },
40
- externals: {
41
- react: 'React',
42
- 'react-dom': 'ReactDOM',
43
- moment: 'moment',
44
- antd: 'antd',
45
- },
46
- }
@@ -1,58 +0,0 @@
1
- import React, { useEffect } from 'react'
2
- import { Space, Button, Radio } from 'antd'
3
- import { GithubOutlined } from '@ant-design/icons'
4
- import { useDesigner, TextWidget } from '@formily-design/react'
5
- import { GlobalRegistry } from '@formily-design/core'
6
- import { observer } from '@formily/react'
7
- import { loadInitialSchema, saveSchema } from '../service'
8
-
9
- export const ActionsWidget = observer(() => {
10
- const designer = useDesigner()
11
- useEffect(() => {
12
- loadInitialSchema(designer)
13
- }, [])
14
- const supportLocales = ['zh-cn', 'en-us', 'ko-kr']
15
- useEffect(() => {
16
- if (!supportLocales.includes(GlobalRegistry.getDesignerLanguage())) {
17
- GlobalRegistry.setDesignerLanguage('zh-cn')
18
- }
19
- }, [])
20
- return (
21
- <Space style={{ marginRight: 10 }}>
22
- <Button href="https://designable-fusion.formilyjs.org">
23
- Alibaba Fusion
24
- </Button>
25
- <Radio.Group
26
- value={GlobalRegistry.getDesignerLanguage()}
27
- optionType="button"
28
- options={[
29
- { label: 'English', value: 'en-us' },
30
- { label: '简体中文', value: 'zh-cn' },
31
- { label: '한국어', value: 'ko-kr' },
32
- ]}
33
- onChange={(e) => {
34
- GlobalRegistry.setDesignerLanguage(e.target.value)
35
- }}
36
- />
37
- <Button href="https://github.com/alibaba/designable" target="_blank">
38
- <GithubOutlined />
39
- Github
40
- </Button>
41
- <Button
42
- onClick={() => {
43
- saveSchema(designer)
44
- }}
45
- >
46
- <TextWidget>Save</TextWidget>
47
- </Button>
48
- <Button
49
- type="primary"
50
- onClick={() => {
51
- saveSchema(designer)
52
- }}
53
- >
54
- <TextWidget>Publish</TextWidget>
55
- </Button>
56
- </Space>
57
- )
58
- })
@@ -1,20 +0,0 @@
1
- import React from 'react'
2
- import { useTheme } from '@formily-design/react'
3
-
4
- const logo = {
5
- dark: '//img.alicdn.com/imgextra/i2/O1CN01NTUDi81fHLQvZCPnc_!!6000000003981-55-tps-1141-150.svg',
6
- light:
7
- '//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg',
8
- }
9
-
10
- export const LogoWidget: React.FC = () => {
11
- const url = logo[useTheme()]
12
- return (
13
- <div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
14
- <img
15
- src={url}
16
- style={{ margin: '12px 8px', height: 18, width: 'auto' }}
17
- />
18
- </div>
19
- )
20
- }
@@ -1,164 +0,0 @@
1
- import React from 'react'
2
- import { TreeNode } from '@formily-design/core'
3
- import { MonacoInput } from '@formily-design/react-settings-form'
4
- import { isEmpty, isPlainObj } from '@formily/shared'
5
-
6
- export interface IMarkupSchemaWidgetProps {
7
- tree: TreeNode
8
- }
9
-
10
- const transformToMarkupSchemaCode = (tree: TreeNode) => {
11
- const printAttribute = (node: TreeNode) => {
12
- if (!node) return ''
13
- const props = { ...node.props }
14
- if (node.depth !== 0) {
15
- props.name = node.props.name || node.id
16
- }
17
- return `${Object.keys(props)
18
- .map((key) => {
19
- if (
20
- key === 'x-designable-id' ||
21
- key === 'x-designable-source-name' ||
22
- key === '_isJSONSchemaObject' ||
23
- key === 'version' ||
24
- key === 'type'
25
- )
26
- return ''
27
- const value = props[key]
28
- if (isPlainObj(value) && isEmpty(value)) return ''
29
- if (typeof value === 'string') return `${key}="${value}"`
30
- return `${key}={${JSON.stringify(value)}}`
31
- })
32
- .join(' ')}`
33
- }
34
- const printChildren = (node: TreeNode) => {
35
- if (!node) return ''
36
- return node.children
37
- .map((child) => {
38
- return printNode(child)
39
- })
40
- .join('')
41
- }
42
- const printTag = (node: TreeNode) => {
43
- if (node.props.type === 'string') return 'SchemaField.String'
44
- if (node.props.type === 'number') return 'SchemaField.Number'
45
- if (node.props.type === 'boolean') return 'SchemaField.Boolean'
46
- if (node.props.type === 'date') return 'SchemaField.Date'
47
- if (node.props.type === 'datetime') return 'SchemaField.DateTime'
48
- if (node.props.type === 'array') return 'SchemaField.Array'
49
- if (node.props.type === 'object') return 'SchemaField.Object'
50
- if (node.props.type === 'void') return 'SchemaField.Void'
51
- return 'SchemaField.Markup'
52
- }
53
- const printNode = (node: TreeNode) => {
54
- if (!node) return ''
55
- return `<${printTag(node)} ${printAttribute(node)} ${
56
- node.children.length
57
- ? `>${printChildren(node)}</${printTag(node)}>`
58
- : '/>'
59
- }`
60
- }
61
- const root = tree.find((child) => {
62
- return child.componentName === 'Form' || child.componentName === 'Root'
63
- })
64
- return `import React, { useMemo } from 'react'
65
- import { createForm } from '@formily/core'
66
- import { createSchemaField } from '@formily/react'
67
- import {
68
- Form,
69
- FormItem,
70
- DatePicker,
71
- Checkbox,
72
- Cascader,
73
- Editable,
74
- Input,
75
- NumberPicker,
76
- Switch,
77
- Password,
78
- PreviewText,
79
- Radio,
80
- Reset,
81
- Select,
82
- Space,
83
- Submit,
84
- TimePicker,
85
- Transfer,
86
- TreeSelect,
87
- Upload,
88
- FormGrid,
89
- FormLayout,
90
- FormTab,
91
- FormCollapse,
92
- ArrayTable,
93
- ArrayCards,
94
- } from '@formily/antd-v5'
95
- import { Card, Slider, Rate } from 'antd'
96
-
97
- const Text: React.FC<{
98
- value?: string
99
- content?: string
100
- mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p'
101
- }> = ({ value, mode, content, ...props }) => {
102
- const tagName = mode === 'normal' || !mode ? 'div' : mode
103
- return React.createElement(tagName, props, value || content)
104
- }
105
-
106
- const SchemaField = createSchemaField({
107
- components: {
108
- Space,
109
- FormGrid,
110
- FormLayout,
111
- FormTab,
112
- FormCollapse,
113
- ArrayTable,
114
- ArrayCards,
115
- FormItem,
116
- DatePicker,
117
- Checkbox,
118
- Cascader,
119
- Editable,
120
- Input,
121
- Text,
122
- NumberPicker,
123
- Switch,
124
- Password,
125
- PreviewText,
126
- Radio,
127
- Reset,
128
- Select,
129
- Submit,
130
- TimePicker,
131
- Transfer,
132
- TreeSelect,
133
- Upload,
134
- Card,
135
- Slider,
136
- Rate,
137
- },
138
- })
139
-
140
- export default ()=>{
141
- const form = useMemo(() => createForm(), [])
142
-
143
- return <Form form={form} ${printAttribute(root)}>
144
- <SchemaField>
145
- ${printChildren(root)}
146
- </SchemaField>
147
- </Form>
148
- }
149
-
150
- `
151
- }
152
-
153
- export const MarkupSchemaWidget: React.FC<IMarkupSchemaWidgetProps> = (
154
- props
155
- ) => {
156
- return (
157
- <MonacoInput
158
- {...props}
159
- options={{ readOnly: true }}
160
- value={transformToMarkupSchemaCode(props.tree)}
161
- language="typescript"
162
- />
163
- )
164
- }
@@ -1,188 +0,0 @@
1
- import React, { useEffect, useMemo, useState } from 'react'
2
- import { createForm, onFormSubmitSuccess } from '@formily/core'
3
- import { connect, createSchemaField, mapProps } from '@formily/react'
4
- import {
5
- Form,
6
- FormItem,
7
- DatePicker,
8
- Checkbox,
9
- Cascader,
10
- Editable,
11
- Input,
12
- NumberPicker,
13
- Switch,
14
- Password,
15
- PreviewText,
16
- Radio,
17
- Reset,
18
- Select,
19
- Space,
20
- Submit,
21
- TimePicker,
22
- Transfer,
23
- TreeSelect,
24
- Upload,
25
- FormGrid,
26
- FormLayout,
27
- FormTab,
28
- FormCollapse,
29
- ArrayTable,
30
- ArrayCards,
31
- // FormButtonGroup,
32
- FormProps,
33
- } from '@formily/antd-v5'
34
- import { Card, Slider, Rate, Spin } from 'antd'
35
- import { TreeNode } from '@formily-design/core'
36
- import { transformToSchema } from '@formily-design/formily-transformer'
37
- import {
38
- transformSchema,
39
- executeFormApi,
40
- IFormApiConfig,
41
- getLocalStorageData,
42
- } from '../utils'
43
- import { FormButtonGroup } from '../components/FormButtonGroup/FormButtonGroup'
44
- import { FormButton } from '../components/FormButton/FormButton'
45
- import { LocationPicker } from '../components/LocationPicker/LocationPicker'
46
- import { FormList } from '../components/FormList/FormList'
47
-
48
- const Text: React.FC<{
49
- value?: string
50
- content?: string
51
- mode?: 'normal' | 'h1' | 'h2' | 'h3' | 'p'
52
- }> = ({ value, mode, content, ...props }) => {
53
- const tagName = mode === 'normal' || !mode ? 'div' : mode
54
- return React.createElement(tagName, props, value || content)
55
- }
56
-
57
- // 重置 LocationPicker 组件属性
58
- const LocationPickerComponent = connect(
59
- LocationPicker,
60
- mapProps((props) => {
61
- return {
62
- ...props,
63
- // 将组件值映射为业务字段
64
- fieldNames: {
65
- address: 'fullAddress',
66
- lat: 'latitude',
67
- lng: 'longitude',
68
- ...props.fieldNames,
69
- },
70
- }
71
- })
72
- )
73
-
74
- const SchemaField = createSchemaField({
75
- components: {
76
- Space,
77
- FormGrid,
78
- FormLayout,
79
- FormTab,
80
- FormCollapse,
81
- ArrayTable,
82
- ArrayCards,
83
- FormItem,
84
- DatePicker,
85
- Checkbox,
86
- Cascader,
87
- Editable,
88
- Input,
89
- Text,
90
- NumberPicker,
91
- Switch,
92
- Password,
93
- PreviewText,
94
- Radio,
95
- Reset,
96
- Select,
97
- Submit,
98
- TimePicker,
99
- Transfer,
100
- TreeSelect,
101
- Upload,
102
- Card,
103
- Slider,
104
- Rate,
105
- FormButtonGroup,
106
- FormButton,
107
- LocationPicker: LocationPickerComponent,
108
- FormList,
109
- },
110
- })
111
-
112
- export interface IPreviewWidgetProps {
113
- tree: TreeNode
114
- }
115
-
116
- interface IFormSetterProps extends FormProps {
117
- api?: IFormApiConfig
118
- initApi?: IFormApiConfig
119
- }
120
-
121
- export const PreviewWidget: React.FC<IPreviewWidgetProps> = (props) => {
122
- const form = useMemo(
123
- () =>
124
- createForm({
125
- /** effects 里可以配置各种逻辑,如:字段联动、事件监听、observable + reaction 组合的响应式状态 */
126
- effects() {
127
- /** 监听表单提交成功 */
128
- onFormSubmitSuccess((form) => {
129
- // 处理表单提交后返回页面逻辑
130
- // console.log('onFormSubmitSuccess', form)
131
- })
132
- },
133
- }),
134
- []
135
- )
136
- const { form: transformForm, schema } = useMemo(
137
- () => transformToSchema(props.tree),
138
- [props.tree]
139
- )
140
- const [detailLoading, setDetailLoading] = useState(false)
141
- const formProps = transformForm as IFormSetterProps
142
- // 接口需要的业务参数
143
- const apiParams = {}
144
- const scope = {
145
- /** 所有 localStorage 数据 */
146
- $localStorage: getLocalStorageData(),
147
- /** 表单请求接口需要的业务参数 */
148
- apiParams,
149
- /** 全局数据 */
150
- $globalData: {
151
- ...apiParams,
152
- },
153
- }
154
- useEffect(() => {
155
- // TODO: 需要添加业务数据参数判断
156
- if (form && formProps.initApi) {
157
- setDetailLoading(true)
158
- // 加载初始数据
159
- executeFormApi(formProps.initApi, {})
160
- .then((data) => {
161
- form.setInitialValues(data)
162
- })
163
- .finally(() => {
164
- setDetailLoading(false)
165
- })
166
- }
167
- }, [form, formProps.initApi])
168
- return (
169
- <Spin spinning={detailLoading}>
170
- <Form {...formProps} form={form}>
171
- <SchemaField
172
- schema={transformSchema(schema, { $globalData: scope.$globalData })}
173
- scope={{
174
- ...scope,
175
- /** 表单提交作用域表达式 - 执行 form 配置的 API */
176
- submitFormApi: formProps.api
177
- ? (formValues: Record<string, any>) =>
178
- executeFormApi(formProps.api, formValues, {
179
- apiParams,
180
- scope,
181
- })
182
- : undefined,
183
- }}
184
- />
185
- </Form>
186
- </Spin>
187
- )
188
- }
@@ -1,27 +0,0 @@
1
- import React from 'react'
2
- import {
3
- transformToSchema,
4
- transformToTreeNode,
5
- } from '@formily-design/formily-transformer'
6
- import { TreeNode, ITreeNode } from '@formily-design/core'
7
- import { MonacoInput } from '@formily-design/react-settings-form'
8
-
9
- export interface ISchemaEditorWidgetProps {
10
- tree: TreeNode
11
- onChange?: (tree: ITreeNode) => void
12
- }
13
-
14
- export const SchemaEditorWidget: React.FC<ISchemaEditorWidgetProps> = (
15
- props
16
- ) => {
17
- return (
18
- <MonacoInput
19
- {...props}
20
- value={JSON.stringify(transformToSchema(props.tree), null, 2)}
21
- onChange={(value) => {
22
- props.onChange?.(transformToTreeNode(JSON.parse(value)))
23
- }}
24
- language="json"
25
- />
26
- )
27
- }
@@ -1,5 +0,0 @@
1
- export * from './LogoWidget'
2
- export * from './ActionsWidget'
3
- export * from './PreviewWidget'
4
- export * from './SchemaEditorWidget'
5
- export * from './MarkupSchemaWidget'