@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.
- package/package.json +8 -8
- package/.umirc.js +0 -44
- package/copy.ts +0 -6
- package/playground/components/AsyncSelect/AsyncSelect.tsx +0 -38
- package/playground/components/AsyncSelect/index.tsx +0 -1
- package/playground/components/AsyncSelect/preview.tsx +0 -36
- package/playground/components/ClickEventSetter/ActionConfigModal.tsx +0 -173
- package/playground/components/ClickEventSetter/ActionList.tsx +0 -67
- package/playground/components/ClickEventSetter/DownloadPanel.tsx +0 -24
- package/playground/components/ClickEventSetter/NavigationPanel.tsx +0 -42
- package/playground/components/ClickEventSetter/RequestPanel.tsx +0 -190
- package/playground/components/ClickEventSetter/index.tsx +0 -90
- package/playground/components/ClickEventSetter/styles.less +0 -89
- package/playground/components/ClickEventSetter/types.ts +0 -43
- package/playground/components/FormButton/FormButton.tsx +0 -189
- package/playground/components/FormButton/hooks/useEventActionExecutor.ts +0 -65
- package/playground/components/FormButton/index.ts +0 -1
- package/playground/components/FormButton/preview.tsx +0 -60
- package/playground/components/FormButton/utils/actionExecutors.ts +0 -96
- package/playground/components/FormButtonGroup/FormButtonGroup.tsx +0 -21
- package/playground/components/FormButtonGroup/index.ts +0 -1
- package/playground/components/FormButtonGroup/preview.tsx +0 -66
- package/playground/components/FormList/FormList.tsx +0 -164
- package/playground/components/FormList/index.tsx +0 -1
- package/playground/components/FormList/preview.tsx +0 -429
- package/playground/components/LocationPicker/LocationModal.tsx +0 -328
- package/playground/components/LocationPicker/LocationPicker.tsx +0 -163
- package/playground/components/LocationPicker/SearchBox.tsx +0 -122
- package/playground/components/LocationPicker/api.ts +0 -77
- package/playground/components/LocationPicker/constants.ts +0 -2
- package/playground/components/LocationPicker/index.tsx +0 -44
- package/playground/components/LocationPicker/types.ts +0 -160
- package/playground/components/LocationPicker/utils.ts +0 -46
- package/playground/components/ResourceIcon/index.module.less +0 -10
- package/playground/components/ResourceIcon/index.tsx +0 -10
- package/playground/designerLocales/en-US.ts +0 -38
- package/playground/designerLocales/index.ts +0 -6
- package/playground/designerLocales/ko-KR.ts +0 -10
- package/playground/designerLocales/zh-CN.ts +0 -38
- package/playground/locales/FormButton.ts +0 -38
- package/playground/locales/FormButtonGroup.ts +0 -29
- package/playground/locales/LocationPicker.ts +0 -30
- package/playground/locales/all.ts +0 -3
- package/playground/locales/index.ts +0 -3
- package/playground/main.tsx +0 -222
- package/playground/react-app-env.d.ts +0 -4
- package/playground/request.ts +0 -123
- package/playground/schemas/FormButton.ts +0 -42
- package/playground/schemas/FormButtonGroup.ts +0 -24
- package/playground/schemas/LocationPicker.ts +0 -14
- package/playground/schemas/all.ts +0 -3
- package/playground/schemas/index.ts +0 -3
- package/playground/service/index.ts +0 -1
- package/playground/service/schema.ts +0 -22
- package/playground/template.ejs +0 -20
- package/playground/utils.ts +0 -744
- package/playground/webpack.base.ts +0 -123
- package/playground/webpack.dev.ts +0 -64
- package/playground/webpack.prod.ts +0 -46
- package/playground/widgets/ActionsWidget.tsx +0 -58
- package/playground/widgets/LogoWidget.tsx +0 -20
- package/playground/widgets/MarkupSchemaWidget.tsx +0 -164
- package/playground/widgets/PreviewWidget.tsx +0 -188
- package/playground/widgets/SchemaEditorWidget.tsx +0 -27
- package/playground/widgets/index.ts +0 -5
- package/tsconfig.build.json +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formily-design/formily-antd",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"module": "esm",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"start": "webpack-dev-server --config playground/webpack.dev.ts"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@formily-design/react-settings-form": "1.0.
|
|
27
|
+
"@formily-design/react-settings-form": "1.0.2",
|
|
28
28
|
"@formily/antd-v5": "^1.2.4",
|
|
29
29
|
"@formily/core": "^2.0.2",
|
|
30
30
|
"@formily/react": "^2.0.2",
|
|
@@ -62,14 +62,14 @@
|
|
|
62
62
|
"react-is": ">=16.8.0 || >=17.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@formily-design/core": "1.0.
|
|
66
|
-
"@formily-design/formily-setters": "1.0.
|
|
67
|
-
"@formily-design/formily-transformer": "1.0.
|
|
68
|
-
"@formily-design/react": "1.0.
|
|
69
|
-
"@formily-design/shared": "1.0.
|
|
65
|
+
"@formily-design/core": "1.0.2",
|
|
66
|
+
"@formily-design/formily-setters": "1.0.2",
|
|
67
|
+
"@formily-design/formily-transformer": "1.0.2",
|
|
68
|
+
"@formily-design/react": "1.0.2",
|
|
69
|
+
"@formily-design/shared": "1.0.2"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "c705befab75f6f60346a8d931480ada43a4081e1"
|
|
75
75
|
}
|
package/.umirc.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
export default {
|
|
3
|
-
mode: 'site',
|
|
4
|
-
logo: '//img.alicdn.com/imgextra/i2/O1CN01Kq3OHU1fph6LGqjIz_!!6000000004056-55-tps-1141-150.svg',
|
|
5
|
-
title: 'Formily',
|
|
6
|
-
hash: true,
|
|
7
|
-
favicon:
|
|
8
|
-
'//img.alicdn.com/imgextra/i3/O1CN01XtT3Tv1Wd1b5hNVKy_!!6000000002810-55-tps-360-360.svg',
|
|
9
|
-
outputPath: './doc-site',
|
|
10
|
-
navs: [
|
|
11
|
-
{
|
|
12
|
-
title: 'Ant Design',
|
|
13
|
-
path: '/components',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
title: '主站',
|
|
17
|
-
path: 'https://v2.formilyjs.org',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
title: 'GITHUB',
|
|
21
|
-
path: 'https://github.com/alibaba/formily',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
styles: [
|
|
25
|
-
`.__dumi-default-navbar-logo{
|
|
26
|
-
height: 60px !important;
|
|
27
|
-
width: 150px !important;
|
|
28
|
-
padding-left:0 !important;
|
|
29
|
-
color: transparent !important;
|
|
30
|
-
}
|
|
31
|
-
.__dumi-default-navbar{
|
|
32
|
-
padding: 0 28px !important;
|
|
33
|
-
}
|
|
34
|
-
.__dumi-default-layout-hero{
|
|
35
|
-
background-image: url(//img.alicdn.com/imgextra/i4/O1CN01ZcvS4e26XMsdsCkf9_!!6000000007671-2-tps-6001-4001.png);
|
|
36
|
-
background-size: cover;
|
|
37
|
-
background-repeat: no-repeat;
|
|
38
|
-
}
|
|
39
|
-
nav a{
|
|
40
|
-
text-decoration: none !important;
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
],
|
|
44
|
-
}
|
package/copy.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LoadingOutlined } from '@ant-design/icons'
|
|
2
|
-
import { PreviewText } from '@formily/antd-v5'
|
|
3
|
-
import { isField } from '@formily/core'
|
|
4
|
-
import { connect, mapProps, mapReadPretty, useField } from '@formily/react'
|
|
5
|
-
import { Select, SelectProps } from 'antd'
|
|
6
|
-
import React from 'react'
|
|
7
|
-
|
|
8
|
-
export type AsyncSelectProps = SelectProps
|
|
9
|
-
function AsyncSelectComponent(props: AsyncSelectProps) {
|
|
10
|
-
const field = useField()
|
|
11
|
-
console.info('AsyncSelectComponent', props, field)
|
|
12
|
-
return <Select {...props} />
|
|
13
|
-
}
|
|
14
|
-
export const AsyncSelect: React.FC<AsyncSelectProps> = connect(
|
|
15
|
-
AsyncSelectComponent,
|
|
16
|
-
mapProps(
|
|
17
|
-
{
|
|
18
|
-
dataSource: 'options',
|
|
19
|
-
data: true,
|
|
20
|
-
loading: true,
|
|
21
|
-
},
|
|
22
|
-
(props, field) => {
|
|
23
|
-
if (isField(field)) {
|
|
24
|
-
return {
|
|
25
|
-
...props,
|
|
26
|
-
suffixIcon:
|
|
27
|
-
field?.loading || field?.validating ? (
|
|
28
|
-
<LoadingOutlined />
|
|
29
|
-
) : (
|
|
30
|
-
props.suffixIcon
|
|
31
|
-
),
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return props
|
|
35
|
-
}
|
|
36
|
-
),
|
|
37
|
-
mapReadPretty(PreviewText.Select)
|
|
38
|
-
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './preview'
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { createBehavior, createResource } from '@formily-design/core'
|
|
3
|
-
import { DnFC } from '@formily-design/react'
|
|
4
|
-
import { AsyncSelect as SelectComponent } from './AsyncSelect'
|
|
5
|
-
import {
|
|
6
|
-
AllLocales,
|
|
7
|
-
AllSchemas,
|
|
8
|
-
createFieldSchema,
|
|
9
|
-
} from '@formily-design/formily-antd'
|
|
10
|
-
|
|
11
|
-
export const AsyncSelect: DnFC<React.ComponentProps<typeof SelectComponent>> =
|
|
12
|
-
SelectComponent
|
|
13
|
-
|
|
14
|
-
AsyncSelect.Behavior = createBehavior({
|
|
15
|
-
name: 'AsyncSelect',
|
|
16
|
-
extends: ['Field'],
|
|
17
|
-
selector: (node) => node.props?.['x-component'] === 'AsyncSelect',
|
|
18
|
-
designerProps: {
|
|
19
|
-
propsSchema: createFieldSchema(AllSchemas.Select),
|
|
20
|
-
},
|
|
21
|
-
designerLocales: AllLocales.Select,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
AsyncSelect.Resource = createResource({
|
|
25
|
-
icon: 'SelectSource',
|
|
26
|
-
elements: [
|
|
27
|
-
{
|
|
28
|
-
componentName: 'Field',
|
|
29
|
-
props: {
|
|
30
|
-
title: 'AsyncSelect',
|
|
31
|
-
'x-decorator': 'FormItem',
|
|
32
|
-
'x-component': 'AsyncSelect',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
})
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import { Form, Tabs, Button, Input, Select } from 'antd'
|
|
3
|
-
import { TextWidget } from '@formily-design/react'
|
|
4
|
-
import { IEventAction, EventActionType, IRequestAction } from './types'
|
|
5
|
-
import { RequestPanel } from './RequestPanel'
|
|
6
|
-
import { NavigationPanel } from './NavigationPanel'
|
|
7
|
-
import { DownloadPanel } from './DownloadPanel'
|
|
8
|
-
import './styles.less'
|
|
9
|
-
|
|
10
|
-
export interface IActionConfigModalProps {
|
|
11
|
-
editingAction: IEventAction | null
|
|
12
|
-
onSave: (action: IEventAction) => void
|
|
13
|
-
onCancel: () => void
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
type IActionConfigFormValues =
|
|
17
|
-
| Exclude<IEventAction, IRequestAction>
|
|
18
|
-
| (Omit<IRequestAction, 'headers' | 'params'> & {
|
|
19
|
-
headers: { key: string; value: string }[]
|
|
20
|
-
params: { key: string; value: string }[]
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
/** 转换配置数据为表单数据 */
|
|
24
|
-
function toFormValues(action: IEventAction): IActionConfigFormValues {
|
|
25
|
-
if (action.type === 'request') {
|
|
26
|
-
const { headers, params } = action
|
|
27
|
-
let headersValue: { key: string; value: string }[] = []
|
|
28
|
-
let paramsValue: { key: string; value: string }[] = []
|
|
29
|
-
if (headers) {
|
|
30
|
-
headersValue = Object.entries(headers).map(([key, value]) => ({
|
|
31
|
-
key,
|
|
32
|
-
value,
|
|
33
|
-
}))
|
|
34
|
-
}
|
|
35
|
-
if (params) {
|
|
36
|
-
paramsValue = Object.entries(params).map(([key, value]) => ({
|
|
37
|
-
key,
|
|
38
|
-
value,
|
|
39
|
-
}))
|
|
40
|
-
}
|
|
41
|
-
return { ...action, headers: headersValue, params: paramsValue }
|
|
42
|
-
}
|
|
43
|
-
return action
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** 转换表单数据为配置数据 */
|
|
47
|
-
function toActionData(values: IActionConfigFormValues): IEventAction {
|
|
48
|
-
if (values.type === 'request') {
|
|
49
|
-
const { headers, params } = values
|
|
50
|
-
let headersValue: Record<string, string> = {}
|
|
51
|
-
let paramsValue: Record<string, string> = {}
|
|
52
|
-
// 转换为对象
|
|
53
|
-
if (headers) {
|
|
54
|
-
headersValue = headers.reduce((pre, cur) => {
|
|
55
|
-
pre[cur.key] = cur.value
|
|
56
|
-
return pre
|
|
57
|
-
}, {} as Record<string, string>)
|
|
58
|
-
}
|
|
59
|
-
// 转换为对象
|
|
60
|
-
if (params) {
|
|
61
|
-
paramsValue = params.reduce((pre, cur) => {
|
|
62
|
-
pre[cur.key] = cur.value
|
|
63
|
-
return pre
|
|
64
|
-
}, {} as Record<string, string>)
|
|
65
|
-
}
|
|
66
|
-
return { ...values, headers: headersValue, params: paramsValue }
|
|
67
|
-
}
|
|
68
|
-
return values
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const ActionConfigModal: React.FC<IActionConfigModalProps> = (props) => {
|
|
72
|
-
const { editingAction, onSave, onCancel } = props
|
|
73
|
-
const [form] = Form.useForm()
|
|
74
|
-
const [actionType, setActionType] = useState<EventActionType>('request')
|
|
75
|
-
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
if (editingAction) {
|
|
78
|
-
setActionType(editingAction.type)
|
|
79
|
-
form.setFieldsValue(toFormValues(editingAction))
|
|
80
|
-
} else {
|
|
81
|
-
setActionType('request')
|
|
82
|
-
form.resetFields()
|
|
83
|
-
}
|
|
84
|
-
}, [editingAction])
|
|
85
|
-
|
|
86
|
-
const handleActionTypeChange = (value: EventActionType) => {
|
|
87
|
-
setActionType(value)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const handleSubmit = () => {
|
|
91
|
-
const values = toActionData(form.getFieldsValue())
|
|
92
|
-
onSave({
|
|
93
|
-
...values,
|
|
94
|
-
id: editingAction?.id || `action-${Date.now()}`,
|
|
95
|
-
type: actionType,
|
|
96
|
-
} as IEventAction)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const tabsItems = [
|
|
100
|
-
{
|
|
101
|
-
key: 'basic',
|
|
102
|
-
label: (
|
|
103
|
-
<TextWidget token="SettingComponents.ClickEventSetter.basicConfig" />
|
|
104
|
-
),
|
|
105
|
-
children: (
|
|
106
|
-
<div className="action-config-basic">
|
|
107
|
-
<Form.Item
|
|
108
|
-
label={
|
|
109
|
-
<TextWidget token="SettingComponents.ClickEventSetter.actionType" />
|
|
110
|
-
}
|
|
111
|
-
name="type"
|
|
112
|
-
initialValue="request"
|
|
113
|
-
>
|
|
114
|
-
<Select
|
|
115
|
-
options={[
|
|
116
|
-
{
|
|
117
|
-
label: '服务请求',
|
|
118
|
-
value: 'request',
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
label: '页面跳转',
|
|
122
|
-
value: 'navigation',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
label: '下载文件',
|
|
126
|
-
value: 'download',
|
|
127
|
-
},
|
|
128
|
-
]}
|
|
129
|
-
onChange={handleActionTypeChange}
|
|
130
|
-
/>
|
|
131
|
-
</Form.Item>
|
|
132
|
-
<Form.Item
|
|
133
|
-
label={
|
|
134
|
-
<TextWidget token="SettingComponents.ClickEventSetter.description" />
|
|
135
|
-
}
|
|
136
|
-
name="description"
|
|
137
|
-
>
|
|
138
|
-
<Input placeholder="请输入动作描述(可选)" />
|
|
139
|
-
</Form.Item>
|
|
140
|
-
</div>
|
|
141
|
-
),
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
key: 'action',
|
|
145
|
-
label: (
|
|
146
|
-
<TextWidget token="SettingComponents.ClickEventSetter.actionConfig" />
|
|
147
|
-
),
|
|
148
|
-
children: (
|
|
149
|
-
<div className="action-config-panel">
|
|
150
|
-
{actionType === 'request' && <RequestPanel />}
|
|
151
|
-
{actionType === 'navigation' && <NavigationPanel />}
|
|
152
|
-
{actionType === 'download' && <DownloadPanel />}
|
|
153
|
-
</div>
|
|
154
|
-
),
|
|
155
|
-
},
|
|
156
|
-
]
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<div className="action-config-modal">
|
|
160
|
-
<Form form={form} layout="vertical" onFinish={handleSubmit}>
|
|
161
|
-
<Tabs items={tabsItems} defaultActiveKey="basic" size="small" />
|
|
162
|
-
<div className="action-config-footer">
|
|
163
|
-
<Button onClick={onCancel}>
|
|
164
|
-
<TextWidget token="SettingComponents.ClickEventSetter.cancel" />
|
|
165
|
-
</Button>
|
|
166
|
-
<Button type="primary" htmlType="submit">
|
|
167
|
-
<TextWidget token="SettingComponents.ClickEventSetter.confirm" />
|
|
168
|
-
</Button>
|
|
169
|
-
</div>
|
|
170
|
-
</Form>
|
|
171
|
-
</div>
|
|
172
|
-
)
|
|
173
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { List, Button, Tag } from 'antd'
|
|
3
|
-
import { TextWidget } from '@formily-design/react'
|
|
4
|
-
import { IEventAction } from './types'
|
|
5
|
-
import './styles.less'
|
|
6
|
-
|
|
7
|
-
export interface IActionListProps {
|
|
8
|
-
actions: IEventAction[]
|
|
9
|
-
onEdit: (action: IEventAction, index: number) => void
|
|
10
|
-
onDelete: (index: number) => void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const actionTypeLabels: Record<string, { label: string; color: string }> = {
|
|
14
|
-
navigation: { label: '页面跳转', color: 'blue' },
|
|
15
|
-
request: { label: '服务请求', color: 'green' },
|
|
16
|
-
download: { label: '下载文件', color: 'orange' },
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const ActionList: React.FC<IActionListProps> = (props) => {
|
|
20
|
-
const { actions, onEdit, onDelete } = props
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<List
|
|
24
|
-
className="click-event-action-list"
|
|
25
|
-
dataSource={actions}
|
|
26
|
-
renderItem={(action, index) => {
|
|
27
|
-
const typeInfo = actionTypeLabels[action.type] || {
|
|
28
|
-
label: action.type,
|
|
29
|
-
color: 'default',
|
|
30
|
-
}
|
|
31
|
-
return (
|
|
32
|
-
<List.Item
|
|
33
|
-
className="click-event-action-item"
|
|
34
|
-
actions={[
|
|
35
|
-
<Button
|
|
36
|
-
type="text"
|
|
37
|
-
onClick={() => onEdit(action, index)}
|
|
38
|
-
key="edit"
|
|
39
|
-
size="small"
|
|
40
|
-
>
|
|
41
|
-
<TextWidget token="SettingComponents.ClickEventSetter.edit" />
|
|
42
|
-
</Button>,
|
|
43
|
-
<Button
|
|
44
|
-
type="text"
|
|
45
|
-
danger
|
|
46
|
-
onClick={() => onDelete(index)}
|
|
47
|
-
key="delete"
|
|
48
|
-
size="small"
|
|
49
|
-
>
|
|
50
|
-
<TextWidget token="SettingComponents.ClickEventSetter.delete" />
|
|
51
|
-
</Button>,
|
|
52
|
-
]}
|
|
53
|
-
>
|
|
54
|
-
<List.Item.Meta
|
|
55
|
-
title={
|
|
56
|
-
<div className="click-event-action-title">
|
|
57
|
-
<Tag color={typeInfo.color}>{typeInfo.label}</Tag>
|
|
58
|
-
</div>
|
|
59
|
-
}
|
|
60
|
-
description={action.description || ''}
|
|
61
|
-
/>
|
|
62
|
-
</List.Item>
|
|
63
|
-
)
|
|
64
|
-
}}
|
|
65
|
-
/>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Form, Input } from 'antd'
|
|
3
|
-
import { TextWidget } from '@formily-design/react'
|
|
4
|
-
import './styles.less'
|
|
5
|
-
|
|
6
|
-
export interface IDownloadPanelProps {
|
|
7
|
-
form?: any
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const DownloadPanel: React.FC<IDownloadPanelProps> = () => {
|
|
11
|
-
return (
|
|
12
|
-
<div className="download-panel">
|
|
13
|
-
<Form.Item
|
|
14
|
-
label={
|
|
15
|
-
<TextWidget token="SettingComponents.ClickEventSetter.downloadUrl" />
|
|
16
|
-
}
|
|
17
|
-
name="url"
|
|
18
|
-
rules={[{ required: true, message: '请输入下载文件地址' }]}
|
|
19
|
-
>
|
|
20
|
-
<Input placeholder="https://example.com/file/download" />
|
|
21
|
-
</Form.Item>
|
|
22
|
-
</div>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Form, Input, Select } from 'antd'
|
|
3
|
-
import { TextWidget } from '@formily-design/react'
|
|
4
|
-
import './styles.less'
|
|
5
|
-
|
|
6
|
-
export interface INavigationPanelProps {
|
|
7
|
-
form?: any
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const NavigationPanel: React.FC<INavigationPanelProps> = () => {
|
|
11
|
-
return (
|
|
12
|
-
<div className="navigation-panel">
|
|
13
|
-
<Form.Item
|
|
14
|
-
label={<TextWidget token="SettingComponents.ClickEventSetter.url" />}
|
|
15
|
-
name="url"
|
|
16
|
-
rules={[{ required: true, message: '请输入跳转地址' }]}
|
|
17
|
-
>
|
|
18
|
-
<Input placeholder="https://example.com/page" />
|
|
19
|
-
</Form.Item>
|
|
20
|
-
<Form.Item
|
|
21
|
-
label={
|
|
22
|
-
<TextWidget token="SettingComponents.ClickEventSetter.openMode" />
|
|
23
|
-
}
|
|
24
|
-
name="target"
|
|
25
|
-
initialValue="_self"
|
|
26
|
-
>
|
|
27
|
-
<Select
|
|
28
|
-
options={[
|
|
29
|
-
{
|
|
30
|
-
label: '当前窗口',
|
|
31
|
-
value: '_self',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: '新窗口',
|
|
35
|
-
value: '_blank',
|
|
36
|
-
},
|
|
37
|
-
]}
|
|
38
|
-
/>
|
|
39
|
-
</Form.Item>
|
|
40
|
-
</div>
|
|
41
|
-
)
|
|
42
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Form, Input, Select, Tabs, Button } from 'antd'
|
|
3
|
-
import { MonacoInput } from '@formily-design/react-settings-form'
|
|
4
|
-
import { TextWidget } from '@formily-design/react'
|
|
5
|
-
import './styles.less'
|
|
6
|
-
|
|
7
|
-
export interface IRequestPanelProps {
|
|
8
|
-
form?: any
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const RequestPanel: React.FC<IRequestPanelProps> = () => {
|
|
12
|
-
const tabsItems = [
|
|
13
|
-
{
|
|
14
|
-
key: 'basic',
|
|
15
|
-
label: <TextWidget token="SettingComponents.RemoteDataSource.basic" />,
|
|
16
|
-
children: (
|
|
17
|
-
<div className="request-panel-section">
|
|
18
|
-
<Form.Item
|
|
19
|
-
label={
|
|
20
|
-
<TextWidget token="SettingComponents.RemoteDataSource.url" />
|
|
21
|
-
}
|
|
22
|
-
name="url"
|
|
23
|
-
rules={[{ required: true, message: '请输入请求地址' }]}
|
|
24
|
-
>
|
|
25
|
-
<Input placeholder="https://api.example.com/data" />
|
|
26
|
-
</Form.Item>
|
|
27
|
-
<Form.Item
|
|
28
|
-
label={
|
|
29
|
-
<TextWidget token="SettingComponents.RemoteDataSource.method" />
|
|
30
|
-
}
|
|
31
|
-
name="method"
|
|
32
|
-
initialValue="POST"
|
|
33
|
-
>
|
|
34
|
-
<Select
|
|
35
|
-
options={[
|
|
36
|
-
{ label: 'GET', value: 'GET' },
|
|
37
|
-
{ label: 'POST', value: 'POST' },
|
|
38
|
-
{ label: 'PUT', value: 'PUT' },
|
|
39
|
-
{ label: 'DELETE', value: 'DELETE' },
|
|
40
|
-
{ label: 'PATCH', value: 'PATCH' },
|
|
41
|
-
]}
|
|
42
|
-
/>
|
|
43
|
-
</Form.Item>
|
|
44
|
-
<Form.Item
|
|
45
|
-
label={
|
|
46
|
-
<TextWidget token="SettingComponents.ClickEventSetter.successMessage" />
|
|
47
|
-
}
|
|
48
|
-
name="successMessage"
|
|
49
|
-
>
|
|
50
|
-
<Input placeholder="请输入成功提示文案(可选)" />
|
|
51
|
-
</Form.Item>
|
|
52
|
-
</div>
|
|
53
|
-
),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
key: 'headers',
|
|
57
|
-
label: <TextWidget token="SettingComponents.RemoteDataSource.headers" />,
|
|
58
|
-
children: (
|
|
59
|
-
<div className="request-panel-section">
|
|
60
|
-
<Form.List name="headers">
|
|
61
|
-
{(fields, { add, remove }) => (
|
|
62
|
-
<>
|
|
63
|
-
{fields.map((field) => (
|
|
64
|
-
<div key={field.key} className="request-panel-row">
|
|
65
|
-
<Form.Item
|
|
66
|
-
{...field}
|
|
67
|
-
label=""
|
|
68
|
-
style={{ marginBottom: 0 }}
|
|
69
|
-
name={[field.name, 'key']}
|
|
70
|
-
>
|
|
71
|
-
<Input placeholder="Key" style={{ width: '45%' }} />
|
|
72
|
-
</Form.Item>
|
|
73
|
-
<span style={{ margin: '0 8px' }}>-</span>
|
|
74
|
-
<Form.Item
|
|
75
|
-
style={{ marginBottom: 0 }}
|
|
76
|
-
name={[field.name, 'value']}
|
|
77
|
-
>
|
|
78
|
-
<Input placeholder="Value" style={{ width: '45%' }} />
|
|
79
|
-
</Form.Item>
|
|
80
|
-
<Button
|
|
81
|
-
type="text"
|
|
82
|
-
danger
|
|
83
|
-
onClick={() => remove(field.name)}
|
|
84
|
-
style={{ marginLeft: 8 }}
|
|
85
|
-
>
|
|
86
|
-
X
|
|
87
|
-
</Button>
|
|
88
|
-
</div>
|
|
89
|
-
))}
|
|
90
|
-
<Button
|
|
91
|
-
type="dashed"
|
|
92
|
-
onClick={() => add({ key: '', value: '' })}
|
|
93
|
-
block
|
|
94
|
-
>
|
|
95
|
-
<TextWidget token="SettingComponents.RemoteDataSource.addHeader" />
|
|
96
|
-
</Button>
|
|
97
|
-
</>
|
|
98
|
-
)}
|
|
99
|
-
</Form.List>
|
|
100
|
-
</div>
|
|
101
|
-
),
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
key: 'params',
|
|
105
|
-
label: <TextWidget token="SettingComponents.RemoteDataSource.params" />,
|
|
106
|
-
children: (
|
|
107
|
-
<div className="request-panel-section">
|
|
108
|
-
<Form.List name="params">
|
|
109
|
-
{(fields, { add, remove }) => (
|
|
110
|
-
<>
|
|
111
|
-
{fields.map((field) => (
|
|
112
|
-
<div key={field.key} className="request-panel-row">
|
|
113
|
-
<Form.Item
|
|
114
|
-
{...field}
|
|
115
|
-
label=""
|
|
116
|
-
style={{ marginBottom: 0 }}
|
|
117
|
-
name={[field.name, 'key']}
|
|
118
|
-
>
|
|
119
|
-
<Input placeholder="参数名" style={{ width: '45%' }} />
|
|
120
|
-
</Form.Item>
|
|
121
|
-
<span style={{ margin: '0 8px' }}>-</span>
|
|
122
|
-
<Form.Item
|
|
123
|
-
style={{ marginBottom: 0 }}
|
|
124
|
-
name={[field.name, 'value']}
|
|
125
|
-
>
|
|
126
|
-
<Input placeholder="表单字段" style={{ width: '45%' }} />
|
|
127
|
-
</Form.Item>
|
|
128
|
-
<Button
|
|
129
|
-
type="text"
|
|
130
|
-
danger
|
|
131
|
-
onClick={() => remove(field.name)}
|
|
132
|
-
style={{ marginLeft: 8 }}
|
|
133
|
-
>
|
|
134
|
-
X
|
|
135
|
-
</Button>
|
|
136
|
-
</div>
|
|
137
|
-
))}
|
|
138
|
-
<Button
|
|
139
|
-
type="dashed"
|
|
140
|
-
onClick={() => add({ key: '', field: '' })}
|
|
141
|
-
block
|
|
142
|
-
>
|
|
143
|
-
<TextWidget token="SettingComponents.RemoteDataSource.addParam" />
|
|
144
|
-
</Button>
|
|
145
|
-
</>
|
|
146
|
-
)}
|
|
147
|
-
</Form.List>
|
|
148
|
-
</div>
|
|
149
|
-
),
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
key: 'handlers',
|
|
153
|
-
label: <TextWidget token="SettingComponents.RemoteDataSource.handlers" />,
|
|
154
|
-
children: (
|
|
155
|
-
<div className="request-panel-section">
|
|
156
|
-
<Form.Item
|
|
157
|
-
label={
|
|
158
|
-
<TextWidget token="SettingComponents.RemoteDataSource.beforeRequest" />
|
|
159
|
-
}
|
|
160
|
-
name="beforeRequest"
|
|
161
|
-
>
|
|
162
|
-
<MonacoInput
|
|
163
|
-
language="javascript.expression"
|
|
164
|
-
height={120}
|
|
165
|
-
helpLink={false}
|
|
166
|
-
/>
|
|
167
|
-
</Form.Item>
|
|
168
|
-
<Form.Item
|
|
169
|
-
label={
|
|
170
|
-
<TextWidget token="SettingComponents.RemoteDataSource.dataHandler" />
|
|
171
|
-
}
|
|
172
|
-
name="dataHandler"
|
|
173
|
-
>
|
|
174
|
-
<MonacoInput
|
|
175
|
-
language="javascript.expression"
|
|
176
|
-
height={120}
|
|
177
|
-
helpLink={false}
|
|
178
|
-
/>
|
|
179
|
-
</Form.Item>
|
|
180
|
-
</div>
|
|
181
|
-
),
|
|
182
|
-
},
|
|
183
|
-
]
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<div className="request-panel">
|
|
187
|
-
<Tabs items={tabsItems} defaultActiveKey="basic" size="small" />
|
|
188
|
-
</div>
|
|
189
|
-
)
|
|
190
|
-
}
|