@thienvu18/designable-formily-setters 2.0.0
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/LICENSE.md +20 -0
- package/README.md +7 -0
- package/esm/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
- package/esm/components/DataSourceSetter/DataSettingPanel.js +54 -0
- package/esm/components/DataSourceSetter/Header.d.ts +7 -0
- package/esm/components/DataSourceSetter/Header.js +8 -0
- package/esm/components/DataSourceSetter/Title.d.ts +7 -0
- package/esm/components/DataSourceSetter/Title.js +46 -0
- package/esm/components/DataSourceSetter/TreePanel.d.ts +12 -0
- package/esm/components/DataSourceSetter/TreePanel.js +94 -0
- package/esm/components/DataSourceSetter/index.d.ts +18 -0
- package/esm/components/DataSourceSetter/index.js +27 -0
- package/esm/components/DataSourceSetter/shared.d.ts +9 -0
- package/esm/components/DataSourceSetter/shared.js +45 -0
- package/esm/components/DataSourceSetter/styles.less +81 -0
- package/esm/components/DataSourceSetter/types.d.ts +18 -0
- package/esm/components/DataSourceSetter/types.js +1 -0
- package/esm/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
- package/esm/components/ReactionsSetter/FieldPropertySetter.js +65 -0
- package/esm/components/ReactionsSetter/PathSelector.d.ts +10 -0
- package/esm/components/ReactionsSetter/PathSelector.js +103 -0
- package/esm/components/ReactionsSetter/declarations.d.ts +5 -0
- package/esm/components/ReactionsSetter/declarations.js +51 -0
- package/esm/components/ReactionsSetter/helpers.d.ts +10 -0
- package/esm/components/ReactionsSetter/helpers.js +384 -0
- package/esm/components/ReactionsSetter/index.d.ts +8 -0
- package/esm/components/ReactionsSetter/index.js +251 -0
- package/esm/components/ReactionsSetter/properties.d.ts +11 -0
- package/esm/components/ReactionsSetter/properties.js +41 -0
- package/esm/components/ReactionsSetter/styles.less +105 -0
- package/esm/components/ReactionsSetter/types.d.ts +13 -0
- package/esm/components/ReactionsSetter/types.js +1 -0
- package/esm/components/ValidatorSetter/index.d.ts +6 -0
- package/esm/components/ValidatorSetter/index.js +135 -0
- package/esm/components/index.d.ts +3 -0
- package/esm/components/index.js +3 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/locales/en-US.d.ts +93 -0
- package/esm/locales/en-US.js +98 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +5 -0
- package/esm/locales/ko-KR.d.ts +93 -0
- package/esm/locales/ko-KR.js +98 -0
- package/esm/locales/zh-CN.d.ts +93 -0
- package/esm/locales/zh-CN.js +98 -0
- package/lib/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
- package/lib/components/DataSourceSetter/DataSettingPanel.js +57 -0
- package/lib/components/DataSourceSetter/Header.d.ts +7 -0
- package/lib/components/DataSourceSetter/Header.js +11 -0
- package/lib/components/DataSourceSetter/Title.d.ts +7 -0
- package/lib/components/DataSourceSetter/Title.js +49 -0
- package/lib/components/DataSourceSetter/TreePanel.d.ts +12 -0
- package/lib/components/DataSourceSetter/TreePanel.js +97 -0
- package/lib/components/DataSourceSetter/index.d.ts +18 -0
- package/lib/components/DataSourceSetter/index.js +33 -0
- package/lib/components/DataSourceSetter/shared.d.ts +9 -0
- package/lib/components/DataSourceSetter/shared.js +51 -0
- package/lib/components/DataSourceSetter/styles.less +81 -0
- package/lib/components/DataSourceSetter/types.d.ts +18 -0
- package/lib/components/DataSourceSetter/types.js +2 -0
- package/lib/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
- package/lib/components/ReactionsSetter/FieldPropertySetter.js +69 -0
- package/lib/components/ReactionsSetter/PathSelector.d.ts +10 -0
- package/lib/components/ReactionsSetter/PathSelector.js +107 -0
- package/lib/components/ReactionsSetter/declarations.d.ts +5 -0
- package/lib/components/ReactionsSetter/declarations.js +55 -0
- package/lib/components/ReactionsSetter/helpers.d.ts +10 -0
- package/lib/components/ReactionsSetter/helpers.js +387 -0
- package/lib/components/ReactionsSetter/index.d.ts +8 -0
- package/lib/components/ReactionsSetter/index.js +255 -0
- package/lib/components/ReactionsSetter/properties.d.ts +11 -0
- package/lib/components/ReactionsSetter/properties.js +44 -0
- package/lib/components/ReactionsSetter/styles.less +105 -0
- package/lib/components/ReactionsSetter/types.d.ts +13 -0
- package/lib/components/ReactionsSetter/types.js +2 -0
- package/lib/components/ValidatorSetter/index.d.ts +6 -0
- package/lib/components/ValidatorSetter/index.js +138 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +19 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +18 -0
- package/lib/locales/en-US.d.ts +93 -0
- package/lib/locales/en-US.js +100 -0
- package/lib/locales/index.d.ts +1 -0
- package/lib/locales/index.js +10 -0
- package/lib/locales/ko-KR.d.ts +93 -0
- package/lib/locales/ko-KR.js +100 -0
- package/lib/locales/zh-CN.d.ts +93 -0
- package/lib/locales/zh-CN.js +100 -0
- package/package.json +64 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { clone, uid } from '@formily/shared';
|
|
4
|
+
import { createForm, isVoidField } from '@formily/core';
|
|
5
|
+
import { createSchemaField } from '@formily/react';
|
|
6
|
+
import { GlobalRegistry } from '@thienvu18/designable-core';
|
|
7
|
+
import { requestIdle } from '@thienvu18/designable-shared';
|
|
8
|
+
import { usePrefix, TextWidget } from '@thienvu18/designable-react';
|
|
9
|
+
import { MonacoInput } from '@thienvu18/designable-react-settings-form';
|
|
10
|
+
import { Form, ArrayTable, Input, Select, FormItem, FormCollapse, } from '@thienvu18/formily-antd-v6';
|
|
11
|
+
import { Modal, Card, Button, Tag, Tooltip } from 'antd';
|
|
12
|
+
import { PathSelector } from './PathSelector';
|
|
13
|
+
import { FieldPropertySetter } from './FieldPropertySetter';
|
|
14
|
+
import { FulfillRunHelper } from './helpers';
|
|
15
|
+
import { initDeclaration } from './declarations';
|
|
16
|
+
import './styles.less';
|
|
17
|
+
const TypeView = ({ value }) => {
|
|
18
|
+
const text = String(value);
|
|
19
|
+
if (text.length <= 26)
|
|
20
|
+
return _jsx(Tag, { children: text });
|
|
21
|
+
return (_jsx(Tag, { children: _jsxs(Tooltip, { title: _jsx("div", { style: { fontSize: 12 }, children: _jsx("code", { children: _jsx("pre", { style: { whiteSpace: 'pre-wrap', padding: 0, margin: 0 }, children: text }) }) }), children: [text.substring(0, 24), "..."] }) }));
|
|
22
|
+
};
|
|
23
|
+
const SchemaField = createSchemaField({
|
|
24
|
+
components: {
|
|
25
|
+
Card,
|
|
26
|
+
FormCollapse,
|
|
27
|
+
Input,
|
|
28
|
+
TypeView,
|
|
29
|
+
Select,
|
|
30
|
+
FormItem,
|
|
31
|
+
PathSelector,
|
|
32
|
+
FieldPropertySetter,
|
|
33
|
+
ArrayTable,
|
|
34
|
+
MonacoInput,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const FieldStateProperties = [
|
|
38
|
+
'value',
|
|
39
|
+
'initialValue',
|
|
40
|
+
'inputValue',
|
|
41
|
+
'inputValues',
|
|
42
|
+
'modified',
|
|
43
|
+
'initialized',
|
|
44
|
+
'title',
|
|
45
|
+
'description',
|
|
46
|
+
'mounted',
|
|
47
|
+
'unmounted',
|
|
48
|
+
'active',
|
|
49
|
+
'visited',
|
|
50
|
+
'loading',
|
|
51
|
+
'errors',
|
|
52
|
+
'warnings',
|
|
53
|
+
'successes',
|
|
54
|
+
'feedbacks',
|
|
55
|
+
'valid',
|
|
56
|
+
'invalid',
|
|
57
|
+
'pattern',
|
|
58
|
+
'display',
|
|
59
|
+
'disabled',
|
|
60
|
+
'readOnly',
|
|
61
|
+
'readPretty',
|
|
62
|
+
'visible',
|
|
63
|
+
'hidden',
|
|
64
|
+
'editable',
|
|
65
|
+
'validateStatus',
|
|
66
|
+
'validating',
|
|
67
|
+
];
|
|
68
|
+
const FieldStateValueTypes = {
|
|
69
|
+
modified: 'boolean',
|
|
70
|
+
initialized: 'boolean',
|
|
71
|
+
title: 'string',
|
|
72
|
+
description: 'string',
|
|
73
|
+
mounted: 'boolean',
|
|
74
|
+
unmounted: 'boolean',
|
|
75
|
+
active: 'boolean',
|
|
76
|
+
visited: 'boolean',
|
|
77
|
+
loading: 'boolean',
|
|
78
|
+
errors: 'string[]',
|
|
79
|
+
warnings: 'string[]',
|
|
80
|
+
successes: 'string[]',
|
|
81
|
+
feedbacks: `Array<
|
|
82
|
+
triggerType?: 'onInput' | 'onFocus' | 'onBlur'
|
|
83
|
+
type?: 'error' | 'success' | 'warning'
|
|
84
|
+
code?:
|
|
85
|
+
| 'ValidateError'
|
|
86
|
+
| 'ValidateSuccess'
|
|
87
|
+
| 'ValidateWarning'
|
|
88
|
+
| 'EffectError'
|
|
89
|
+
| 'EffectSuccess'
|
|
90
|
+
| 'EffectWarning'
|
|
91
|
+
messages?: string[]
|
|
92
|
+
>
|
|
93
|
+
`,
|
|
94
|
+
valid: 'boolean',
|
|
95
|
+
invalid: 'boolean',
|
|
96
|
+
pattern: "'editable' | 'disabled' | 'readOnly' | 'readPretty'",
|
|
97
|
+
display: "'visible' | 'hidden' | 'none'",
|
|
98
|
+
disabled: 'boolean',
|
|
99
|
+
readOnly: 'boolean',
|
|
100
|
+
readPretty: 'boolean',
|
|
101
|
+
visible: 'boolean',
|
|
102
|
+
hidden: 'boolean',
|
|
103
|
+
editable: 'boolean',
|
|
104
|
+
validateStatus: "'error' | 'warning' | 'success' | 'validating'",
|
|
105
|
+
validating: 'boolean',
|
|
106
|
+
};
|
|
107
|
+
export const ReactionsSetter = (props) => {
|
|
108
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
109
|
+
const [innerVisible, setInnerVisible] = useState(false);
|
|
110
|
+
const prefix = usePrefix('reactions-setter');
|
|
111
|
+
const form = useMemo(() => {
|
|
112
|
+
return createForm({
|
|
113
|
+
values: clone(props.value),
|
|
114
|
+
});
|
|
115
|
+
}, [modalVisible, props.value]);
|
|
116
|
+
const formCollapse = useMemo(() => FormCollapse.createFormCollapse(['deps', 'state']), [modalVisible]);
|
|
117
|
+
const openModal = () => setModalVisible(true);
|
|
118
|
+
const closeModal = () => setModalVisible(false);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (modalVisible) {
|
|
121
|
+
requestIdle(() => {
|
|
122
|
+
initDeclaration().then(() => {
|
|
123
|
+
setInnerVisible(true);
|
|
124
|
+
});
|
|
125
|
+
}, {
|
|
126
|
+
timeout: 400,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
setInnerVisible(false);
|
|
131
|
+
}
|
|
132
|
+
}, [modalVisible]);
|
|
133
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { block: true, onClick: openModal, children: _jsx(TextWidget, { token: "SettingComponents.ReactionsSetter.configureReactions" }) }), _jsx(Modal, { title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.configureReactions'), width: "70%", centered: true, styles: { body: { padding: 10 } }, transitionName: "", maskTransitionName: "", open: modalVisible, onCancel: closeModal, destroyOnHidden: true, onOk: () => {
|
|
134
|
+
form.submit((values) => {
|
|
135
|
+
props.onChange?.(values);
|
|
136
|
+
});
|
|
137
|
+
closeModal();
|
|
138
|
+
}, children: _jsx("div", { className: prefix, children: innerVisible && (_jsx(Form, { form: form, children: _jsx(SchemaField, { children: _jsxs(SchemaField.Void, { "x-component": "FormCollapse", "x-component-props": {
|
|
139
|
+
formCollapse,
|
|
140
|
+
defaultActiveKey: ['deps', 'state'],
|
|
141
|
+
style: { marginBottom: 10 },
|
|
142
|
+
}, children: [_jsx(SchemaField.Void, { "x-component": "FormCollapse.CollapsePanel", "x-component-props": {
|
|
143
|
+
key: 'deps',
|
|
144
|
+
header: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.relationsFields'),
|
|
145
|
+
}, children: _jsxs(SchemaField.Array, { name: "dependencies", default: [{}], "x-component": "ArrayTable", children: [_jsxs(SchemaField.Object, { children: [_jsx(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
|
|
146
|
+
title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.sourceField'),
|
|
147
|
+
width: 240,
|
|
148
|
+
}, children: _jsx(SchemaField.String, { name: "source", "x-decorator": "FormItem", "x-component": "PathSelector", "x-component-props": {
|
|
149
|
+
placeholder: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.pleaseSelect'),
|
|
150
|
+
} }) }), _jsx(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
|
|
151
|
+
title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.sourceProperty'),
|
|
152
|
+
width: 200,
|
|
153
|
+
}, children: _jsx(SchemaField.String, { name: "property", default: "value", "x-decorator": "FormItem", "x-component": "Select", "x-component-props": { showSearch: true }, enum: FieldStateProperties }) }), _jsx(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
|
|
154
|
+
title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.variableName'),
|
|
155
|
+
width: 200,
|
|
156
|
+
}, children: _jsx(SchemaField.String, { name: "name", "x-decorator": "FormItem", "x-validator": {
|
|
157
|
+
pattern: /^[$_a-zA-Z]+[$_a-zA-Z0-9]*$/,
|
|
158
|
+
message: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.variableNameValidateMessage'),
|
|
159
|
+
}, "x-component": "Input", "x-component-props": {
|
|
160
|
+
addonBefore: '$deps.',
|
|
161
|
+
placeholder: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.pleaseInput'),
|
|
162
|
+
}, "x-reactions": (field) => {
|
|
163
|
+
if (isVoidField(field))
|
|
164
|
+
return;
|
|
165
|
+
field.query('.source').take((source) => {
|
|
166
|
+
if (isVoidField(source))
|
|
167
|
+
return;
|
|
168
|
+
if (source.value &&
|
|
169
|
+
!field.value &&
|
|
170
|
+
!field.modified) {
|
|
171
|
+
field.value =
|
|
172
|
+
source.inputValues[1]?.props?.name ||
|
|
173
|
+
`v_${uid()}`;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
} }) }), _jsx(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
|
|
177
|
+
title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.variableType'),
|
|
178
|
+
ellipsis: {
|
|
179
|
+
showTitle: false,
|
|
180
|
+
},
|
|
181
|
+
width: 200,
|
|
182
|
+
align: 'center',
|
|
183
|
+
}, children: _jsx(SchemaField.String, { name: "type", default: "any", "x-decorator": "FormItem", "x-component": "TypeView", "x-reactions": (field) => {
|
|
184
|
+
if (isVoidField(field))
|
|
185
|
+
return;
|
|
186
|
+
const property = field
|
|
187
|
+
.query('.property')
|
|
188
|
+
.get('inputValues');
|
|
189
|
+
if (!property)
|
|
190
|
+
return;
|
|
191
|
+
property[0] = property[0] || 'value';
|
|
192
|
+
field.query('.source').take((source) => {
|
|
193
|
+
if (isVoidField(source))
|
|
194
|
+
return;
|
|
195
|
+
if (source.value) {
|
|
196
|
+
if (property[0] === 'value' ||
|
|
197
|
+
property[0] === 'initialValue' ||
|
|
198
|
+
property[0] === 'inputValue') {
|
|
199
|
+
field.value =
|
|
200
|
+
source.inputValues[1]?.props?.type ||
|
|
201
|
+
'any';
|
|
202
|
+
}
|
|
203
|
+
else if (property[0] === 'inputValues') {
|
|
204
|
+
field.value = `any[]`;
|
|
205
|
+
}
|
|
206
|
+
else if (property[0]) {
|
|
207
|
+
field.value =
|
|
208
|
+
FieldStateValueTypes[property[0]];
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
field.value = 'any';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
} }) }), _jsx(SchemaField.Void, { "x-component": "ArrayTable.Column", "x-component-props": {
|
|
216
|
+
title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.operations'),
|
|
217
|
+
align: 'center',
|
|
218
|
+
width: 80,
|
|
219
|
+
}, children: _jsx(SchemaField.Markup, { type: "void", "x-component": "ArrayTable.Remove" }) })] }), _jsx(SchemaField.Void, { title: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.addRelationField'), "x-component": "ArrayTable.Addition", "x-component-props": { style: { marginTop: 8 } } })] }) }), _jsx(SchemaField.Void, { "x-component": "FormCollapse.CollapsePanel", "x-component-props": {
|
|
220
|
+
header: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.propertyReactions'),
|
|
221
|
+
key: 'state',
|
|
222
|
+
className: 'reaction-state',
|
|
223
|
+
}, children: _jsx(SchemaField.Markup, { name: "fulfill.state", "x-component": "FieldPropertySetter" }) }), _jsx(SchemaField.Void, { "x-component": "FormCollapse.CollapsePanel", "x-component-props": {
|
|
224
|
+
key: 'run',
|
|
225
|
+
header: GlobalRegistry.getDesignerMessage('SettingComponents.ReactionsSetter.actionReactions'),
|
|
226
|
+
className: 'reaction-runner',
|
|
227
|
+
}, children: _jsx(SchemaField.String, { name: "fulfill.run", "x-component": "MonacoInput", "x-component-props": {
|
|
228
|
+
width: '100%',
|
|
229
|
+
height: 400,
|
|
230
|
+
language: 'typescript',
|
|
231
|
+
helpCode: FulfillRunHelper,
|
|
232
|
+
options: {
|
|
233
|
+
minimap: {
|
|
234
|
+
enabled: false,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
}, "x-reactions": (field) => {
|
|
238
|
+
const deps = field.query('dependencies').value();
|
|
239
|
+
if (Array.isArray(deps)) {
|
|
240
|
+
field.componentProps.extraLib = `
|
|
241
|
+
declare var $deps : {
|
|
242
|
+
${deps.map(({ name, type }) => {
|
|
243
|
+
if (!name)
|
|
244
|
+
return '';
|
|
245
|
+
return `${name}?:${type || 'any'},`;
|
|
246
|
+
})}
|
|
247
|
+
}
|
|
248
|
+
`;
|
|
249
|
+
}
|
|
250
|
+
} }) })] }) }) })) }) })] }));
|
|
251
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BooleanHelper, PatternHelper, StringHelper, AnyHelper, DataSourceHelper, DecoratorPropsHelper, DisplayHelper, ComponentPropsHelper, } from './helpers';
|
|
2
|
+
export const FieldProperties = [
|
|
3
|
+
{
|
|
4
|
+
key: 'visible',
|
|
5
|
+
type: 'boolean',
|
|
6
|
+
helpCode: BooleanHelper,
|
|
7
|
+
},
|
|
8
|
+
{ key: 'hidden', type: 'boolean', helpCode: BooleanHelper },
|
|
9
|
+
{
|
|
10
|
+
key: 'display',
|
|
11
|
+
type: '"visible" | "hidden" | "none"',
|
|
12
|
+
helpCode: DisplayHelper,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: 'pattern',
|
|
16
|
+
type: '"editable" | "disabled" | "readOnly" | "readPretty"',
|
|
17
|
+
helpCode: PatternHelper,
|
|
18
|
+
},
|
|
19
|
+
{ key: 'title', type: 'string', helpCode: StringHelper },
|
|
20
|
+
{ key: 'description', type: 'string', helpCode: StringHelper },
|
|
21
|
+
{ key: 'value', type: 'any', helpCode: AnyHelper },
|
|
22
|
+
{ key: 'initialValue', type: 'any', helpCode: AnyHelper },
|
|
23
|
+
{ key: 'required', type: 'boolean', helpCode: BooleanHelper },
|
|
24
|
+
{
|
|
25
|
+
key: 'dataSource',
|
|
26
|
+
type: 'Array<{label?:string,value?:any}>',
|
|
27
|
+
helpCode: DataSourceHelper,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'componentProps',
|
|
31
|
+
token: 'componentProps',
|
|
32
|
+
type: 'object',
|
|
33
|
+
helpCode: ComponentPropsHelper,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: 'decoratorProps',
|
|
37
|
+
token: 'decoratorProps',
|
|
38
|
+
type: 'object',
|
|
39
|
+
helpCode: DecoratorPropsHelper,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
.dn-reactions-setter {
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-height: 623px;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
::-webkit-scrollbar {
|
|
8
|
+
width: 5px;
|
|
9
|
+
height: 5px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
::-webkit-scrollbar-thumb {
|
|
13
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
14
|
+
border-radius: 0;
|
|
15
|
+
transition: all 0.25s ease-in-out;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
::-webkit-scrollbar-thumb:hover {
|
|
19
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.@{ant-prefix}-collapse {
|
|
23
|
+
border: 1px solid var(--dn-color-border-secondary, rgba(5, 5, 5, 0.06));
|
|
24
|
+
|
|
25
|
+
&-header {
|
|
26
|
+
padding: 8px 10px !important;
|
|
27
|
+
background-color: var(--dn-color-bg-container, #fff) !important;
|
|
28
|
+
border-bottom: 1px solid var(--dn-color-border-secondary, rgba(5, 5, 5, 0.06)) !important;
|
|
29
|
+
font-weight: 500 !important;
|
|
30
|
+
|
|
31
|
+
.@{ant-prefix}-collapse-arrow {
|
|
32
|
+
margin-right: 4px !important;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&-item {
|
|
37
|
+
border: none !important;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&-content {
|
|
41
|
+
border: none !important;
|
|
42
|
+
transition: none !important;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&-content-box {
|
|
46
|
+
padding: 12px !important;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.reaction-runner {
|
|
51
|
+
.@{ant-prefix}-collapse-content-box {
|
|
52
|
+
padding: 12px 0 !important;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.reaction-state {
|
|
57
|
+
.@{ant-prefix}-collapse-content-box {
|
|
58
|
+
padding: 12px 0 !important;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.dn-field-property-setter {
|
|
63
|
+
display: flex;
|
|
64
|
+
height: 300px;
|
|
65
|
+
|
|
66
|
+
&-coder-wrapper {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-grow: 2;
|
|
69
|
+
height: 100%;
|
|
70
|
+
padding-left: 10px;
|
|
71
|
+
position: relative;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&-coder-start {
|
|
76
|
+
font-size: 18px;
|
|
77
|
+
line-height: 30px;
|
|
78
|
+
margin-bottom: 4px;
|
|
79
|
+
color: var(--dn-color-text, rgba(0, 0, 0, 0.88));
|
|
80
|
+
font-weight: 300;
|
|
81
|
+
flex-grow: 0;
|
|
82
|
+
opacity: 0.96;
|
|
83
|
+
height: 31px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&-coder-end {
|
|
87
|
+
font-size: 18px;
|
|
88
|
+
height: 31px;
|
|
89
|
+
color: var(--dn-color-text, rgba(0, 0, 0, 0.88));
|
|
90
|
+
margin-top: 4px;
|
|
91
|
+
margin-bottom: 4px;
|
|
92
|
+
line-height: 30px;
|
|
93
|
+
font-weight: 300;
|
|
94
|
+
flex-grow: 0;
|
|
95
|
+
opacity: 0.96;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&-coder {
|
|
99
|
+
min-width: 0;
|
|
100
|
+
flex-grow: 2;
|
|
101
|
+
padding-left: 10px;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
@ant-prefix: ant;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { observer, useField, SchemaContext, Schema, } from '@formily/react';
|
|
3
|
+
import { GlobalRegistry } from '@thienvu18/designable-core';
|
|
4
|
+
import { ArrayItems } from '@thienvu18/formily-antd-v6';
|
|
5
|
+
import { FoldItem } from '@thienvu18/designable-react-settings-form';
|
|
6
|
+
import { Select } from 'antd';
|
|
7
|
+
const ValidatorSchema = {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
'x-decorator': 'ArrayItems.Item',
|
|
12
|
+
'x-decorator-props': {
|
|
13
|
+
style: {
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
borderRadius: 3,
|
|
16
|
+
paddingTop: 6,
|
|
17
|
+
paddingBottom: 6,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
properties: {
|
|
21
|
+
sortable: {
|
|
22
|
+
type: 'void',
|
|
23
|
+
'x-component': 'ArrayItems.SortHandle',
|
|
24
|
+
'x-component-props': { style: { marginRight: 10 } },
|
|
25
|
+
},
|
|
26
|
+
drawer: {
|
|
27
|
+
type: 'void',
|
|
28
|
+
'x-component': 'DrawerSetter',
|
|
29
|
+
properties: {
|
|
30
|
+
triggerType: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: ['onInput', 'onFocus', 'onBlur'],
|
|
33
|
+
'x-decorator': 'FormItem',
|
|
34
|
+
'x-component': 'Select',
|
|
35
|
+
},
|
|
36
|
+
validator: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
'x-decorator': 'FormItem',
|
|
39
|
+
'x-component': 'ValueInput',
|
|
40
|
+
'x-component-props': {
|
|
41
|
+
include: ['EXPRESSION'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
message: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
'x-decorator': 'FormItem',
|
|
47
|
+
'x-component': 'Input.TextArea',
|
|
48
|
+
},
|
|
49
|
+
format: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
'x-decorator': 'FormItem',
|
|
52
|
+
'x-component': 'Select',
|
|
53
|
+
'x-component-props': {
|
|
54
|
+
allowClear: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
pattern: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
'x-decorator': 'FormItem',
|
|
60
|
+
'x-component': 'Input',
|
|
61
|
+
'x-component-props': {
|
|
62
|
+
prefix: '/',
|
|
63
|
+
suffix: '/',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
len: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
'x-decorator': 'FormItem',
|
|
69
|
+
'x-component': 'NumberPicker',
|
|
70
|
+
},
|
|
71
|
+
max: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
'x-decorator': 'FormItem',
|
|
74
|
+
'x-component': 'NumberPicker',
|
|
75
|
+
},
|
|
76
|
+
min: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
'x-decorator': 'FormItem',
|
|
79
|
+
'x-component': 'NumberPicker',
|
|
80
|
+
},
|
|
81
|
+
exclusiveMaximum: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
'x-decorator': 'FormItem',
|
|
84
|
+
'x-component': 'NumberPicker',
|
|
85
|
+
},
|
|
86
|
+
exclusiveMinimum: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
'x-decorator': 'FormItem',
|
|
89
|
+
'x-component': 'NumberPicker',
|
|
90
|
+
},
|
|
91
|
+
whitespace: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
'x-decorator': 'FormItem',
|
|
94
|
+
'x-component': 'Switch',
|
|
95
|
+
},
|
|
96
|
+
required: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
'x-decorator': 'FormItem',
|
|
99
|
+
'x-component': 'Switch',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
moveDown: {
|
|
104
|
+
type: 'void',
|
|
105
|
+
'x-component': 'ArrayItems.MoveDown',
|
|
106
|
+
'x-component-props': { style: { marginLeft: 10 } },
|
|
107
|
+
},
|
|
108
|
+
moveUp: {
|
|
109
|
+
type: 'void',
|
|
110
|
+
'x-component': 'ArrayItems.MoveUp',
|
|
111
|
+
'x-component-props': { style: { marginLeft: 5 } },
|
|
112
|
+
},
|
|
113
|
+
remove: {
|
|
114
|
+
type: 'void',
|
|
115
|
+
'x-component': 'ArrayItems.Remove',
|
|
116
|
+
'x-component-props': { style: { marginLeft: 5 } },
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
properties: {
|
|
121
|
+
addValidatorRules: {
|
|
122
|
+
type: 'void',
|
|
123
|
+
'x-component': 'ArrayItems.Addition',
|
|
124
|
+
'x-component-props': {
|
|
125
|
+
style: {
|
|
126
|
+
marginBottom: 10,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
export const ValidatorSetter = observer((props) => {
|
|
133
|
+
const field = useField();
|
|
134
|
+
return (_jsxs(FoldItem, { label: field.title, children: [_jsx(FoldItem.Base, { children: _jsx(Select, { value: Array.isArray(props.value) ? undefined : props.value, onChange: props.onChange, allowClear: true, placeholder: GlobalRegistry.getDesignerMessage('SettingComponents.ValidatorSetter.pleaseSelect'), options: GlobalRegistry.getDesignerMessage('SettingComponents.ValidatorSetter.formats') }) }), _jsx(FoldItem.Extra, { children: _jsx(SchemaContext.Provider, { value: new Schema(ValidatorSchema), children: _jsx(ArrayItems, {}) }) })] }));
|
|
135
|
+
});
|
package/esm/index.d.ts
ADDED
package/esm/index.js
ADDED