@thienvu18/designable-formily-setters 2.0.0 → 2.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 (89) hide show
  1. package/esm/components/DataSourceSetter/DataSettingPanel.d.ts +8 -8
  2. package/esm/components/DataSourceSetter/DataSettingPanel.js +124 -52
  3. package/esm/components/DataSourceSetter/Header.d.ts +5 -5
  4. package/esm/components/DataSourceSetter/Header.js +16 -7
  5. package/esm/components/DataSourceSetter/Title.d.ts +5 -5
  6. package/esm/components/DataSourceSetter/Title.js +57 -44
  7. package/esm/components/DataSourceSetter/TreePanel.d.ts +10 -10
  8. package/esm/components/DataSourceSetter/TreePanel.js +129 -89
  9. package/esm/components/DataSourceSetter/index.d.ts +16 -16
  10. package/esm/components/DataSourceSetter/index.js +81 -24
  11. package/esm/components/DataSourceSetter/shared.d.ts +14 -7
  12. package/esm/components/DataSourceSetter/shared.js +39 -41
  13. package/esm/components/DataSourceSetter/styles.less +4 -3
  14. package/esm/components/DataSourceSetter/types.d.ts +12 -12
  15. package/esm/components/DataSourceSetter/types.js +1 -1
  16. package/esm/components/ReactionsSetter/FieldPropertySetter.d.ts +6 -6
  17. package/esm/components/ReactionsSetter/FieldPropertySetter.js +140 -63
  18. package/esm/components/ReactionsSetter/PathSelector.d.ts +10 -9
  19. package/esm/components/ReactionsSetter/PathSelector.js +97 -100
  20. package/esm/components/ReactionsSetter/declarations.d.ts +3 -3
  21. package/esm/components/ReactionsSetter/declarations.js +31 -18
  22. package/esm/components/ReactionsSetter/helpers.d.ts +20 -10
  23. package/esm/components/ReactionsSetter/helpers.js +10 -10
  24. package/esm/components/ReactionsSetter/index.d.ts +6 -6
  25. package/esm/components/ReactionsSetter/index.js +412 -230
  26. package/esm/components/ReactionsSetter/properties.d.ts +14 -11
  27. package/esm/components/ReactionsSetter/properties.js +49 -40
  28. package/esm/components/ReactionsSetter/styles.less +2 -2
  29. package/esm/components/ReactionsSetter/types.d.ts +11 -11
  30. package/esm/components/ReactionsSetter/types.js +1 -1
  31. package/esm/components/ValidatorSetter/index.d.ts +4 -4
  32. package/esm/components/ValidatorSetter/index.js +148 -125
  33. package/esm/components/index.d.ts +3 -3
  34. package/esm/components/index.js +3 -3
  35. package/esm/index.d.ts +2 -2
  36. package/esm/index.js +2 -2
  37. package/esm/locales/en-US.d.ts +92 -92
  38. package/esm/locales/en-US.js +96 -93
  39. package/esm/locales/index.d.ts +1 -1
  40. package/esm/locales/index.js +5 -5
  41. package/esm/locales/ko-KR.d.ts +92 -92
  42. package/esm/locales/ko-KR.js +94 -93
  43. package/esm/locales/zh-CN.d.ts +92 -92
  44. package/esm/locales/zh-CN.js +94 -93
  45. package/lib/components/DataSourceSetter/DataSettingPanel.d.ts +8 -8
  46. package/lib/components/DataSourceSetter/DataSettingPanel.js +129 -55
  47. package/lib/components/DataSourceSetter/Header.d.ts +5 -5
  48. package/lib/components/DataSourceSetter/Header.js +19 -10
  49. package/lib/components/DataSourceSetter/Title.d.ts +5 -5
  50. package/lib/components/DataSourceSetter/Title.js +70 -47
  51. package/lib/components/DataSourceSetter/TreePanel.d.ts +10 -10
  52. package/lib/components/DataSourceSetter/TreePanel.js +134 -92
  53. package/lib/components/DataSourceSetter/index.d.ts +16 -16
  54. package/lib/components/DataSourceSetter/index.js +94 -30
  55. package/lib/components/DataSourceSetter/shared.d.ts +14 -7
  56. package/lib/components/DataSourceSetter/shared.js +48 -47
  57. package/lib/components/DataSourceSetter/styles.less +4 -3
  58. package/lib/components/DataSourceSetter/types.d.ts +12 -12
  59. package/lib/components/DataSourceSetter/types.js +2 -2
  60. package/lib/components/ReactionsSetter/FieldPropertySetter.d.ts +6 -6
  61. package/lib/components/ReactionsSetter/FieldPropertySetter.js +150 -67
  62. package/lib/components/ReactionsSetter/PathSelector.d.ts +10 -9
  63. package/lib/components/ReactionsSetter/PathSelector.js +101 -104
  64. package/lib/components/ReactionsSetter/declarations.d.ts +3 -3
  65. package/lib/components/ReactionsSetter/declarations.js +35 -22
  66. package/lib/components/ReactionsSetter/helpers.d.ts +20 -10
  67. package/lib/components/ReactionsSetter/helpers.js +23 -13
  68. package/lib/components/ReactionsSetter/index.d.ts +6 -6
  69. package/lib/components/ReactionsSetter/index.js +434 -234
  70. package/lib/components/ReactionsSetter/properties.d.ts +14 -11
  71. package/lib/components/ReactionsSetter/properties.js +43 -43
  72. package/lib/components/ReactionsSetter/styles.less +2 -2
  73. package/lib/components/ReactionsSetter/types.d.ts +11 -11
  74. package/lib/components/ReactionsSetter/types.js +2 -2
  75. package/lib/components/ValidatorSetter/index.d.ts +4 -4
  76. package/lib/components/ValidatorSetter/index.js +151 -128
  77. package/lib/components/index.d.ts +3 -3
  78. package/lib/components/index.js +35 -19
  79. package/lib/index.d.ts +2 -2
  80. package/lib/index.js +34 -18
  81. package/lib/locales/en-US.d.ts +92 -92
  82. package/lib/locales/en-US.js +98 -95
  83. package/lib/locales/index.d.ts +1 -1
  84. package/lib/locales/index.js +16 -10
  85. package/lib/locales/ko-KR.d.ts +92 -92
  86. package/lib/locales/ko-KR.js +96 -95
  87. package/lib/locales/zh-CN.d.ts +92 -92
  88. package/lib/locales/zh-CN.js +96 -95
  89. package/package.json +25 -25
@@ -1,84 +1,107 @@
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';
1
+ import { createForm, isVoidField } from '@formily/core'
2
+ import { createSchemaField } from '@formily/react'
3
+ import { clone, uid } from '@formily/shared'
4
+ import { GlobalRegistry } from '@thienvu18/designable-core'
5
+ import { TextWidget, usePrefix } from '@thienvu18/designable-react'
6
+ import { MonacoInput } from '@thienvu18/designable-react-settings-form'
7
+ import { requestIdle } from '@thienvu18/designable-shared'
8
+ import {
9
+ ArrayTable,
10
+ Form,
11
+ FormCollapse,
12
+ FormItem,
13
+ Input,
14
+ Select,
15
+ } from '@thienvu18/formily-antd-v6'
16
+ import { Button, Card, Modal, Tag, Tooltip } from 'antd'
17
+ import { useEffect, useMemo, useState } from 'react'
18
+ import {
19
+ Fragment as _Fragment,
20
+ jsx as _jsx,
21
+ jsxs as _jsxs,
22
+ } from 'react/jsx-runtime'
23
+ import { FieldPropertySetter } from './FieldPropertySetter'
24
+ import { PathSelector } from './PathSelector'
25
+ import { initDeclaration } from './declarations'
26
+ import { FulfillRunHelper } from './helpers'
27
+ import './styles.less'
17
28
  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
- };
29
+ const text = String(value)
30
+ if (text.length <= 26) return _jsx(Tag, { children: text })
31
+ return _jsx(Tag, {
32
+ children: _jsxs(Tooltip, {
33
+ title: _jsx('div', {
34
+ style: { fontSize: 12 },
35
+ children: _jsx('code', {
36
+ children: _jsx('pre', {
37
+ style: { whiteSpace: 'pre-wrap', padding: 0, margin: 0 },
38
+ children: text,
39
+ }),
40
+ }),
41
+ }),
42
+ children: [text.substring(0, 24), '...'],
43
+ }),
44
+ })
45
+ }
23
46
  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
- });
47
+ components: {
48
+ Card,
49
+ FormCollapse,
50
+ Input,
51
+ TypeView,
52
+ Select,
53
+ FormItem,
54
+ PathSelector,
55
+ FieldPropertySetter,
56
+ ArrayTable,
57
+ MonacoInput,
58
+ },
59
+ })
37
60
  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
- ];
61
+ 'value',
62
+ 'initialValue',
63
+ 'inputValue',
64
+ 'inputValues',
65
+ 'modified',
66
+ 'initialized',
67
+ 'title',
68
+ 'description',
69
+ 'mounted',
70
+ 'unmounted',
71
+ 'active',
72
+ 'visited',
73
+ 'loading',
74
+ 'errors',
75
+ 'warnings',
76
+ 'successes',
77
+ 'feedbacks',
78
+ 'valid',
79
+ 'invalid',
80
+ 'pattern',
81
+ 'display',
82
+ 'disabled',
83
+ 'readOnly',
84
+ 'readPretty',
85
+ 'visible',
86
+ 'hidden',
87
+ 'editable',
88
+ 'validateStatus',
89
+ 'validating',
90
+ ]
68
91
  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<
92
+ modified: 'boolean',
93
+ initialized: 'boolean',
94
+ title: 'string',
95
+ description: 'string',
96
+ mounted: 'boolean',
97
+ unmounted: 'boolean',
98
+ active: 'boolean',
99
+ visited: 'boolean',
100
+ loading: 'boolean',
101
+ errors: 'string[]',
102
+ warnings: 'string[]',
103
+ successes: 'string[]',
104
+ feedbacks: `Array<
82
105
  triggerType?: 'onInput' | 'onFocus' | 'onBlur'
83
106
  type?: 'error' | 'success' | 'warning'
84
107
  code?:
@@ -91,161 +114,320 @@ const FieldStateValueTypes = {
91
114
  messages?: string[]
92
115
  >
93
116
  `,
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
- };
117
+ valid: 'boolean',
118
+ invalid: 'boolean',
119
+ pattern: "'editable' | 'disabled' | 'readOnly' | 'readPretty'",
120
+ display: "'visible' | 'hidden' | 'none'",
121
+ disabled: 'boolean',
122
+ readOnly: 'boolean',
123
+ readPretty: 'boolean',
124
+ visible: 'boolean',
125
+ hidden: 'boolean',
126
+ editable: 'boolean',
127
+ validateStatus: "'error' | 'warning' | 'success' | 'validating'",
128
+ validating: 'boolean',
129
+ }
107
130
  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
- });
131
+ const [modalVisible, setModalVisible] = useState(false)
132
+ const [innerVisible, setInnerVisible] = useState(false)
133
+ const prefix = usePrefix('reactions-setter')
134
+ const form = useMemo(() => {
135
+ return createForm({
136
+ values: clone(props.value),
137
+ })
138
+ }, [modalVisible, props.value])
139
+ const formCollapse = useMemo(
140
+ () => FormCollapse.createFormCollapse(['deps', 'state']),
141
+ [modalVisible]
142
+ )
143
+ const openModal = () => setModalVisible(true)
144
+ const closeModal = () => setModalVisible(false)
145
+ useEffect(() => {
146
+ if (modalVisible) {
147
+ requestIdle(
148
+ () => {
149
+ initDeclaration().then(() => {
150
+ setInnerVisible(true)
151
+ })
152
+ },
153
+ {
154
+ timeout: 400,
128
155
  }
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 = `
156
+ )
157
+ } else {
158
+ setInnerVisible(false)
159
+ }
160
+ }, [modalVisible])
161
+ return _jsxs(_Fragment, {
162
+ children: [
163
+ _jsx(Button, {
164
+ block: true,
165
+ onClick: openModal,
166
+ children: _jsx(TextWidget, {
167
+ token: 'SettingComponents.ReactionsSetter.configureReactions',
168
+ }),
169
+ }),
170
+ _jsx(Modal, {
171
+ title: GlobalRegistry.getDesignerMessage(
172
+ 'SettingComponents.ReactionsSetter.configureReactions'
173
+ ),
174
+ width: '70%',
175
+ centered: true,
176
+ styles: { body: { padding: 10 } },
177
+ transitionName: '',
178
+ maskTransitionName: '',
179
+ open: modalVisible,
180
+ onCancel: closeModal,
181
+ destroyOnHidden: true,
182
+ onOk: () => {
183
+ form.submit((values) => {
184
+ props.onChange?.(values)
185
+ })
186
+ closeModal()
187
+ },
188
+ children: _jsx('div', {
189
+ className: prefix,
190
+ children:
191
+ innerVisible &&
192
+ _jsx(Form, {
193
+ form: form,
194
+ children: _jsx(SchemaField, {
195
+ children: _jsxs(SchemaField.Void, {
196
+ 'x-component': 'FormCollapse',
197
+ 'x-component-props': {
198
+ formCollapse,
199
+ defaultActiveKey: ['deps', 'state'],
200
+ style: { marginBottom: 10 },
201
+ },
202
+ children: [
203
+ _jsx(SchemaField.Void, {
204
+ 'x-component': 'FormCollapse.CollapsePanel',
205
+ 'x-component-props': {
206
+ key: 'deps',
207
+ header: GlobalRegistry.getDesignerMessage(
208
+ 'SettingComponents.ReactionsSetter.relationsFields'
209
+ ),
210
+ },
211
+ children: _jsxs(SchemaField.Array, {
212
+ name: 'dependencies',
213
+ default: [{}],
214
+ 'x-component': 'ArrayTable',
215
+ children: [
216
+ _jsxs(SchemaField.Object, {
217
+ children: [
218
+ _jsx(SchemaField.Void, {
219
+ 'x-component': 'ArrayTable.Column',
220
+ 'x-component-props': {
221
+ title: GlobalRegistry.getDesignerMessage(
222
+ 'SettingComponents.ReactionsSetter.sourceField'
223
+ ),
224
+ width: 240,
225
+ },
226
+ children: _jsx(SchemaField.String, {
227
+ name: 'source',
228
+ 'x-decorator': 'FormItem',
229
+ 'x-component': 'PathSelector',
230
+ 'x-component-props': {
231
+ placeholder:
232
+ GlobalRegistry.getDesignerMessage(
233
+ 'SettingComponents.ReactionsSetter.pleaseSelect'
234
+ ),
235
+ },
236
+ }),
237
+ }),
238
+ _jsx(SchemaField.Void, {
239
+ 'x-component': 'ArrayTable.Column',
240
+ 'x-component-props': {
241
+ title: GlobalRegistry.getDesignerMessage(
242
+ 'SettingComponents.ReactionsSetter.sourceProperty'
243
+ ),
244
+ width: 200,
245
+ },
246
+ children: _jsx(SchemaField.String, {
247
+ name: 'property',
248
+ default: 'value',
249
+ 'x-decorator': 'FormItem',
250
+ 'x-component': 'Select',
251
+ 'x-component-props': { showSearch: true },
252
+ enum: FieldStateProperties,
253
+ }),
254
+ }),
255
+ _jsx(SchemaField.Void, {
256
+ 'x-component': 'ArrayTable.Column',
257
+ 'x-component-props': {
258
+ title: GlobalRegistry.getDesignerMessage(
259
+ 'SettingComponents.ReactionsSetter.variableName'
260
+ ),
261
+ width: 200,
262
+ },
263
+ children: _jsx(SchemaField.String, {
264
+ name: 'name',
265
+ 'x-decorator': 'FormItem',
266
+ 'x-validator': {
267
+ pattern: /^[$_a-zA-Z]+[$_a-zA-Z0-9]*$/,
268
+ message: GlobalRegistry.getDesignerMessage(
269
+ 'SettingComponents.ReactionsSetter.variableNameValidateMessage'
270
+ ),
271
+ },
272
+ 'x-component': 'Input',
273
+ 'x-component-props': {
274
+ addonBefore: '$deps.',
275
+ placeholder:
276
+ GlobalRegistry.getDesignerMessage(
277
+ 'SettingComponents.ReactionsSetter.pleaseInput'
278
+ ),
279
+ },
280
+ 'x-reactions': (field) => {
281
+ if (isVoidField(field)) return
282
+ field.query('.source').take((source) => {
283
+ if (isVoidField(source)) return
284
+ if (
285
+ source.value &&
286
+ !field.value &&
287
+ !field.modified
288
+ ) {
289
+ field.value =
290
+ source.inputValues[1]?.props?.name ||
291
+ `v_${uid()}`
292
+ }
293
+ })
294
+ },
295
+ }),
296
+ }),
297
+ _jsx(SchemaField.Void, {
298
+ 'x-component': 'ArrayTable.Column',
299
+ 'x-component-props': {
300
+ title: GlobalRegistry.getDesignerMessage(
301
+ 'SettingComponents.ReactionsSetter.variableType'
302
+ ),
303
+ ellipsis: {
304
+ showTitle: false,
305
+ },
306
+ width: 200,
307
+ align: 'center',
308
+ },
309
+ children: _jsx(SchemaField.String, {
310
+ name: 'type',
311
+ default: 'any',
312
+ 'x-decorator': 'FormItem',
313
+ 'x-component': 'TypeView',
314
+ 'x-reactions': (field) => {
315
+ if (isVoidField(field)) return
316
+ const property = field
317
+ .query('.property')
318
+ .get('inputValues')
319
+ if (!property) return
320
+ property[0] = property[0] || 'value'
321
+ field.query('.source').take((source) => {
322
+ if (isVoidField(source)) return
323
+ if (source.value) {
324
+ if (
325
+ property[0] === 'value' ||
326
+ property[0] === 'initialValue' ||
327
+ property[0] === 'inputValue'
328
+ ) {
329
+ field.value =
330
+ source.inputValues[1]?.props
331
+ ?.type || 'any'
332
+ } else if (
333
+ property[0] === 'inputValues'
334
+ ) {
335
+ field.value = `any[]`
336
+ } else if (property[0]) {
337
+ field.value =
338
+ FieldStateValueTypes[property[0]]
339
+ } else {
340
+ field.value = 'any'
341
+ }
342
+ }
343
+ })
344
+ },
345
+ }),
346
+ }),
347
+ _jsx(SchemaField.Void, {
348
+ 'x-component': 'ArrayTable.Column',
349
+ 'x-component-props': {
350
+ title: GlobalRegistry.getDesignerMessage(
351
+ 'SettingComponents.ReactionsSetter.operations'
352
+ ),
353
+ align: 'center',
354
+ width: 80,
355
+ },
356
+ children: _jsx(SchemaField.Markup, {
357
+ type: 'void',
358
+ 'x-component': 'ArrayTable.Remove',
359
+ }),
360
+ }),
361
+ ],
362
+ }),
363
+ _jsx(SchemaField.Void, {
364
+ title: GlobalRegistry.getDesignerMessage(
365
+ 'SettingComponents.ReactionsSetter.addRelationField'
366
+ ),
367
+ 'x-component': 'ArrayTable.Addition',
368
+ 'x-component-props': { style: { marginTop: 8 } },
369
+ }),
370
+ ],
371
+ }),
372
+ }),
373
+ _jsx(SchemaField.Void, {
374
+ 'x-component': 'FormCollapse.CollapsePanel',
375
+ 'x-component-props': {
376
+ header: GlobalRegistry.getDesignerMessage(
377
+ 'SettingComponents.ReactionsSetter.propertyReactions'
378
+ ),
379
+ key: 'state',
380
+ className: 'reaction-state',
381
+ },
382
+ children: _jsx(SchemaField.Markup, {
383
+ name: 'fulfill.state',
384
+ 'x-component': 'FieldPropertySetter',
385
+ }),
386
+ }),
387
+ _jsx(SchemaField.Void, {
388
+ 'x-component': 'FormCollapse.CollapsePanel',
389
+ 'x-component-props': {
390
+ key: 'run',
391
+ header: GlobalRegistry.getDesignerMessage(
392
+ 'SettingComponents.ReactionsSetter.actionReactions'
393
+ ),
394
+ className: 'reaction-runner',
395
+ },
396
+ children: _jsx(SchemaField.String, {
397
+ name: 'fulfill.run',
398
+ 'x-component': 'MonacoInput',
399
+ 'x-component-props': {
400
+ width: '100%',
401
+ height: 400,
402
+ language: 'typescript',
403
+ helpCode: FulfillRunHelper,
404
+ options: {
405
+ minimap: {
406
+ enabled: false,
407
+ },
408
+ },
409
+ },
410
+ 'x-reactions': (field) => {
411
+ const deps = field.query('dependencies').value()
412
+ if (Array.isArray(deps)) {
413
+ field.componentProps.extraLib = `
241
414
  declare var $deps : {
242
415
  ${deps.map(({ name, type }) => {
243
- if (!name)
244
- return '';
245
- return `${name}?:${type || 'any'},`;
246
- })}
416
+ if (!name) return ''
417
+ return `${name}?:${type || 'any'},`
418
+ })}
419
+ }
420
+ `
247
421
  }
248
- `;
249
- }
250
- } }) })] }) }) })) }) })] }));
251
- };
422
+ },
423
+ }),
424
+ }),
425
+ ],
426
+ }),
427
+ }),
428
+ }),
429
+ }),
430
+ }),
431
+ ],
432
+ })
433
+ }