@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,222 +0,0 @@
1
- import React, { useMemo } from 'react'
2
- import ReactDOM from 'react-dom/client'
3
- import {
4
- Designer,
5
- DesignerToolsWidget,
6
- ViewToolsWidget,
7
- Workspace,
8
- OutlineTreeWidget,
9
- ResourceWidget,
10
- HistoryWidget,
11
- StudioPanel,
12
- CompositePanel,
13
- WorkspacePanel,
14
- ToolbarPanel,
15
- ViewportPanel,
16
- ViewPanel,
17
- SettingsPanel,
18
- ComponentTreeWidget,
19
- } from '@formily-design/react'
20
- import {
21
- SettingsForm,
22
- setNpmCDNRegistry,
23
- } from '@formily-design/react-settings-form'
24
- import { createDesigner, Shortcut, KeyCode } from '@formily-design/core'
25
- import {
26
- LogoWidget,
27
- ActionsWidget,
28
- PreviewWidget,
29
- SchemaEditorWidget,
30
- MarkupSchemaWidget,
31
- } from './widgets'
32
- import { saveSchema } from './service'
33
- import {
34
- Form,
35
- Field,
36
- Input,
37
- Select,
38
- TreeSelect,
39
- Cascader,
40
- Radio,
41
- Checkbox,
42
- Slider,
43
- Rate,
44
- NumberPicker,
45
- Transfer,
46
- Password,
47
- DatePicker,
48
- TimePicker,
49
- Upload,
50
- Switch,
51
- Text,
52
- Card,
53
- ArrayCards,
54
- ObjectContainer,
55
- ArrayTable,
56
- Space,
57
- FormTab,
58
- FormCollapse,
59
- FormLayout,
60
- FormGrid,
61
- // FormButtonGroup,
62
- // FormButton,
63
- } from '../src'
64
- import { AsyncSelect } from './components/AsyncSelect'
65
- import { FormButtonGroup } from './components/FormButtonGroup'
66
- import { FormButton } from './components/FormButton'
67
- import { LocationPicker } from './components/LocationPicker'
68
- import { FormList } from './components/FormList'
69
- import './designerLocales'
70
-
71
- setNpmCDNRegistry('//unpkg.com')
72
-
73
- const App = () => {
74
- const engine = useMemo(
75
- () =>
76
- createDesigner({
77
- shortcuts: [
78
- new Shortcut({
79
- codes: [
80
- [KeyCode.Meta, KeyCode.S],
81
- [KeyCode.Control, KeyCode.S],
82
- ],
83
- handler(ctx) {
84
- saveSchema(ctx.engine)
85
- },
86
- }),
87
- ],
88
- rootComponentName: 'Form',
89
- }),
90
- []
91
- )
92
- return (
93
- <Designer engine={engine} position="fixed" style={{ height: '100%' }}>
94
- <StudioPanel
95
- logo={<LogoWidget />}
96
- actions={<ActionsWidget />}
97
- style={{ height: '100%' }}
98
- >
99
- <CompositePanel>
100
- <CompositePanel.Item title="panels.Component" icon="Component">
101
- <ResourceWidget
102
- title="sources.Inputs"
103
- sources={[
104
- Input,
105
- Password,
106
- NumberPicker,
107
- Rate,
108
- Slider,
109
- Select,
110
- TreeSelect,
111
- Cascader,
112
- Transfer,
113
- Checkbox,
114
- Radio,
115
- DatePicker,
116
- TimePicker,
117
- Upload,
118
- Switch,
119
- ObjectContainer,
120
- AsyncSelect,
121
- FormButtonGroup,
122
- FormButton,
123
- LocationPicker,
124
- FormList,
125
- ]}
126
- />
127
- <ResourceWidget
128
- title="sources.Layouts"
129
- sources={[
130
- Card,
131
- FormGrid,
132
- FormTab,
133
- FormLayout,
134
- FormCollapse,
135
- Space,
136
- ]}
137
- />
138
- <ResourceWidget
139
- title="sources.Arrays"
140
- sources={[ArrayCards, ArrayTable]}
141
- />
142
- <ResourceWidget title="sources.Displays" sources={[Text]} />
143
- </CompositePanel.Item>
144
- <CompositePanel.Item title="panels.OutlinedTree" icon="Outline">
145
- <OutlineTreeWidget />
146
- </CompositePanel.Item>
147
- <CompositePanel.Item title="panels.History" icon="History">
148
- <HistoryWidget />
149
- </CompositePanel.Item>
150
- </CompositePanel>
151
- <Workspace id="form">
152
- <WorkspacePanel>
153
- <ToolbarPanel>
154
- <DesignerToolsWidget />
155
- <ViewToolsWidget
156
- use={['DESIGNABLE', 'JSONTREE', 'MARKUP', 'PREVIEW']}
157
- />
158
- </ToolbarPanel>
159
- <ViewportPanel style={{ height: '100%' }}>
160
- <ViewPanel type="DESIGNABLE">
161
- {() => (
162
- <ComponentTreeWidget
163
- components={{
164
- Form,
165
- Field,
166
- Input,
167
- Select,
168
- TreeSelect,
169
- Cascader,
170
- Radio,
171
- Checkbox,
172
- Slider,
173
- Rate,
174
- NumberPicker,
175
- Transfer,
176
- Password,
177
- DatePicker,
178
- TimePicker,
179
- Upload,
180
- Switch,
181
- Text,
182
- Card,
183
- ArrayCards,
184
- ArrayTable,
185
- Space,
186
- FormTab,
187
- FormCollapse,
188
- FormGrid,
189
- FormLayout,
190
- ObjectContainer,
191
- AsyncSelect,
192
- FormButtonGroup,
193
- FormButton,
194
- LocationPicker,
195
- FormList,
196
- }}
197
- />
198
- )}
199
- </ViewPanel>
200
- <ViewPanel type="JSONTREE" scrollable={false}>
201
- {(tree, onChange) => (
202
- <SchemaEditorWidget tree={tree} onChange={onChange} />
203
- )}
204
- </ViewPanel>
205
- <ViewPanel type="MARKUP" scrollable={false}>
206
- {(tree) => <MarkupSchemaWidget tree={tree} />}
207
- </ViewPanel>
208
- <ViewPanel type="PREVIEW">
209
- {(tree) => <PreviewWidget tree={tree} />}
210
- </ViewPanel>
211
- </ViewportPanel>
212
- </WorkspacePanel>
213
- </Workspace>
214
- <SettingsPanel title="panels.PropertySettings">
215
- <SettingsForm uploadAction="https://www.mocky.io/v2/5cc8019d300000980a055e76" />
216
- </SettingsPanel>
217
- </StudioPanel>
218
- </Designer>
219
- )
220
- }
221
-
222
- ReactDOM.createRoot(document.getElementById('root')).render(<App />)
@@ -1,4 +0,0 @@
1
- declare module '*.module.less' {
2
- const classes: { readonly [key: string]: string }
3
- export default classes
4
- }
@@ -1,123 +0,0 @@
1
- /**
2
- * 公共请求方法封装
3
- */
4
-
5
- interface RequestOptions extends RequestInit {
6
- /** 请求基础路径 */
7
- baseUrl?: string
8
- /** 请求路径 */
9
- url: string
10
- /** URL 参数 */
11
- params?: Record<string, string | number | boolean | undefined | null>
12
- /** 请求体数据 */
13
- data?: unknown
14
- }
15
-
16
- export interface ResponseResult<T = unknown> {
17
- code: number
18
- data: T
19
- message?: string
20
- }
21
-
22
- /**
23
- * 构建 URL 查询参数
24
- */
25
- function buildQueryString(
26
- params: Record<string, string | number | boolean | undefined | null>
27
- ): string {
28
- const searchParams = new URLSearchParams()
29
- Object.entries(params).forEach(([key, value]) => {
30
- if (value !== undefined && value !== null) {
31
- searchParams.append(key, String(value))
32
- }
33
- })
34
- return searchParams.toString()
35
- }
36
-
37
- /**
38
- * 公共请求方法
39
- * @param options 请求配置
40
- * @returns Promise< ResponseResult<T> >
41
- */
42
- export async function request<T = unknown>(
43
- options: RequestOptions
44
- ): Promise<ResponseResult<T>> {
45
- const { baseUrl = '', url, params, data, headers, ...init } = options
46
-
47
- // 构建完整 URL
48
- let fullUrl = `${baseUrl}${url}`
49
- if (params) {
50
- const queryString = buildQueryString(params)
51
- fullUrl += `?${queryString}`
52
- }
53
-
54
- // 设置默认请求头
55
- const defaultHeaders: HeadersInit = {
56
- 'Content-Type': 'application/json',
57
- ...headers,
58
- }
59
-
60
- // 构建请求配置
61
- const requestOptions: RequestInit = {
62
- ...init,
63
- headers: defaultHeaders,
64
- }
65
-
66
- // 处理请求体
67
- if (data) {
68
- // 处理 FormData
69
- if (data instanceof FormData) {
70
- requestOptions.body = data
71
- const headers = requestOptions.headers as
72
- | Record<string, string>
73
- | undefined
74
- // 移除 Content-Type,避免 FormData 数据错误
75
- if (headers?.['Content-Type']) {
76
- delete headers['Content-Type']
77
- requestOptions.headers = headers
78
- }
79
- } else {
80
- requestOptions.body = JSON.stringify(data)
81
- }
82
- }
83
-
84
- // 发起请求
85
- const response = await fetch(fullUrl, requestOptions)
86
-
87
- // 解析响应
88
- const result: ResponseResult<T> = await response.json()
89
-
90
- // 处理业务错误
91
- // if (!response.ok || result.code !== 0) {
92
- // throw new Error(result.message || '请求失败')
93
- // }
94
-
95
- return result
96
- }
97
-
98
- /**
99
- * GET 请求
100
- */
101
- export function get<T = unknown>(
102
- url: string,
103
- params?: RequestOptions['params'],
104
- options?: Omit<RequestOptions, 'url' | 'params' | 'method'>
105
- ): Promise<ResponseResult<T>> {
106
- return request<T>({ ...options, url, params, method: 'GET' })
107
- }
108
-
109
- /**
110
- * POST 请求
111
- */
112
- export function post<T = unknown>(
113
- url: string,
114
- data?: RequestOptions['data'],
115
- options?: Omit<RequestOptions, 'url' | 'data'>
116
- ): Promise<ResponseResult<T>> {
117
- return request<T>({
118
- ...options,
119
- url,
120
- data,
121
- method: options?.method || 'POST',
122
- })
123
- }
@@ -1,42 +0,0 @@
1
- import { ISchema } from '@formily/react'
2
-
3
- export const FormButton: ISchema = {
4
- type: 'object',
5
- properties: {
6
- title: {
7
- type: 'string',
8
- 'x-decorator': 'FormItem',
9
- 'x-component': 'Input',
10
- 'x-component-props': {
11
- defaultValue: '按钮',
12
- },
13
- },
14
- type: {
15
- type: 'string',
16
- enum: ['primary', 'default', 'dashed', 'link', 'text'],
17
- 'x-decorator': 'FormItem',
18
- 'x-component': 'Select',
19
- 'x-component-props': {
20
- defaultValue: 'default',
21
- },
22
- },
23
- htmlType: {
24
- type: 'string',
25
- enum: ['submit', 'reset', 'button'],
26
- 'x-decorator': 'FormItem',
27
- 'x-component': 'Radio.Group',
28
- 'x-component-props': {
29
- defaultValue: 'button',
30
- optionType: 'button',
31
- },
32
- },
33
- noValidate: {
34
- type: 'boolean',
35
- 'x-decorator': 'FormItem',
36
- 'x-component': 'Switch',
37
- 'x-component-props': {
38
- defaultValue: false,
39
- },
40
- },
41
- },
42
- }
@@ -1,24 +0,0 @@
1
- import { ISchema } from '@formily/react'
2
-
3
- export const FormButtonGroup: ISchema = {
4
- type: 'object',
5
- properties: {
6
- gutter: {
7
- type: 'number',
8
- 'x-decorator': 'FormItem',
9
- 'x-component': 'NumberPicker',
10
- 'x-component-props': {
11
- defaultValue: 8,
12
- },
13
- },
14
- align: {
15
- type: 'string',
16
- enum: ['left', 'center', 'right'],
17
- 'x-decorator': 'FormItem',
18
- 'x-component': 'Select',
19
- 'x-component-props': {
20
- defaultValue: 'left',
21
- },
22
- },
23
- },
24
- }
@@ -1,14 +0,0 @@
1
- import { ISchema } from '@formily/react'
2
- import { AllSchemas } from '@formily-design/formily-antd'
3
-
4
- export const LocationPicker: ISchema = {
5
- type: 'object',
6
- properties: {
7
- ...(AllSchemas.Input.properties as any),
8
- mapApiKey: {
9
- type: 'string',
10
- 'x-decorator': 'FormItem',
11
- 'x-component': 'Input',
12
- },
13
- },
14
- }
@@ -1,3 +0,0 @@
1
- export * from './FormButtonGroup'
2
- export * from './FormButton'
3
- export * from './LocationPicker'
@@ -1,3 +0,0 @@
1
- import * as CustomSchemas from './all'
2
-
3
- export { CustomSchemas }
@@ -1 +0,0 @@
1
- export * from './schema'
@@ -1,22 +0,0 @@
1
- import { Engine } from '@formily-design/core'
2
- import {
3
- transformToSchema,
4
- transformToTreeNode,
5
- } from '@formily-design/formily-transformer'
6
- import { message } from 'antd'
7
-
8
- export const saveSchema = (designer: Engine) => {
9
- localStorage.setItem(
10
- 'formily-schema',
11
- JSON.stringify(transformToSchema(designer.getCurrentTree()))
12
- )
13
- message.success('Save Success')
14
- }
15
-
16
- export const loadInitialSchema = (designer: Engine) => {
17
- try {
18
- designer.setCurrentTree(
19
- transformToTreeNode(JSON.parse(localStorage.getItem('formily-schema')))
20
- )
21
- } catch {}
22
- }
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <head>
3
- <title>
4
- Designable Playground
5
- </title>
6
- <style>
7
- html,body{
8
- user-select: none;
9
- -webkit-user-select: none;
10
- }
11
- </style>
12
- </head>
13
- <body>
14
- <div id="root">
15
- </div>
16
- <!-- <script src="https://unpkg.com/moment/min/moment-with-locales.js"></script>-->
17
- <!-- <script src="https://unpkg.com/react/umd/react.production.min.js"></script>-->
18
- <!-- <script src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"></script>-->
19
- <!-- <script src="https://unpkg.com/antd/dist/antd-with-locales.min.js"></script>-->
20
- </body>