@formily-design/formily-setters 1.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.
Files changed (108) hide show
  1. package/.umirc.js +44 -0
  2. package/LICENSE.md +20 -0
  3. package/README.md +7 -0
  4. package/copy.ts +6 -0
  5. package/esm/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
  6. package/esm/components/DataSourceSetter/DataSettingPanel.js +66 -0
  7. package/esm/components/DataSourceSetter/Header.d.ts +7 -0
  8. package/esm/components/DataSourceSetter/Header.js +10 -0
  9. package/esm/components/DataSourceSetter/Title.d.ts +7 -0
  10. package/esm/components/DataSourceSetter/Title.js +50 -0
  11. package/esm/components/DataSourceSetter/TreePanel.d.ts +12 -0
  12. package/esm/components/DataSourceSetter/TreePanel.js +98 -0
  13. package/esm/components/DataSourceSetter/index.d.ts +18 -0
  14. package/esm/components/DataSourceSetter/index.js +34 -0
  15. package/esm/components/DataSourceSetter/shared.d.ts +9 -0
  16. package/esm/components/DataSourceSetter/shared.js +47 -0
  17. package/esm/components/DataSourceSetter/styles.less +80 -0
  18. package/esm/components/DataSourceSetter/types.d.ts +18 -0
  19. package/esm/components/DataSourceSetter/types.js +1 -0
  20. package/esm/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
  21. package/esm/components/ReactionsSetter/FieldPropertySetter.js +83 -0
  22. package/esm/components/ReactionsSetter/PathSelector.d.ts +10 -0
  23. package/esm/components/ReactionsSetter/PathSelector.js +107 -0
  24. package/esm/components/ReactionsSetter/declarations.d.ts +5 -0
  25. package/esm/components/ReactionsSetter/declarations.js +51 -0
  26. package/esm/components/ReactionsSetter/helpers.d.ts +10 -0
  27. package/esm/components/ReactionsSetter/helpers.js +384 -0
  28. package/esm/components/ReactionsSetter/index.d.ts +8 -0
  29. package/esm/components/ReactionsSetter/index.js +282 -0
  30. package/esm/components/ReactionsSetter/properties.d.ts +11 -0
  31. package/esm/components/ReactionsSetter/properties.js +41 -0
  32. package/esm/components/ReactionsSetter/styles.less +103 -0
  33. package/esm/components/ReactionsSetter/types.d.ts +13 -0
  34. package/esm/components/ReactionsSetter/types.js +1 -0
  35. package/esm/components/RemoteDataSourceSetter/RemoteDataSourcePanel.d.ts +8 -0
  36. package/esm/components/RemoteDataSourceSetter/RemoteDataSourcePanel.js +103 -0
  37. package/esm/components/RemoteDataSourceSetter/index.d.ts +17 -0
  38. package/esm/components/RemoteDataSourceSetter/index.js +25 -0
  39. package/esm/components/RemoteDataSourceSetter/styles.less +33 -0
  40. package/esm/components/RemoteDataSourceSetter/types.d.ts +8 -0
  41. package/esm/components/RemoteDataSourceSetter/types.js +1 -0
  42. package/esm/components/ValidatorSetter/index.d.ts +6 -0
  43. package/esm/components/ValidatorSetter/index.js +140 -0
  44. package/esm/components/index.d.ts +4 -0
  45. package/esm/components/index.js +4 -0
  46. package/esm/index.d.ts +2 -0
  47. package/esm/index.js +2 -0
  48. package/esm/locales/en-US.d.ts +110 -0
  49. package/esm/locales/en-US.js +115 -0
  50. package/esm/locales/index.d.ts +1 -0
  51. package/esm/locales/index.js +5 -0
  52. package/esm/locales/ko-KR.d.ts +110 -0
  53. package/esm/locales/ko-KR.js +115 -0
  54. package/esm/locales/zh-CN.d.ts +110 -0
  55. package/esm/locales/zh-CN.js +115 -0
  56. package/lib/components/DataSourceSetter/DataSettingPanel.d.ts +10 -0
  57. package/lib/components/DataSourceSetter/DataSettingPanel.js +102 -0
  58. package/lib/components/DataSourceSetter/Header.d.ts +7 -0
  59. package/lib/components/DataSourceSetter/Header.js +16 -0
  60. package/lib/components/DataSourceSetter/Title.d.ts +7 -0
  61. package/lib/components/DataSourceSetter/Title.js +56 -0
  62. package/lib/components/DataSourceSetter/TreePanel.d.ts +12 -0
  63. package/lib/components/DataSourceSetter/TreePanel.js +134 -0
  64. package/lib/components/DataSourceSetter/index.d.ts +18 -0
  65. package/lib/components/DataSourceSetter/index.js +73 -0
  66. package/lib/components/DataSourceSetter/shared.d.ts +9 -0
  67. package/lib/components/DataSourceSetter/shared.js +53 -0
  68. package/lib/components/DataSourceSetter/styles.less +80 -0
  69. package/lib/components/DataSourceSetter/types.d.ts +18 -0
  70. package/lib/components/DataSourceSetter/types.js +2 -0
  71. package/lib/components/ReactionsSetter/FieldPropertySetter.d.ts +10 -0
  72. package/lib/components/ReactionsSetter/FieldPropertySetter.js +120 -0
  73. package/lib/components/ReactionsSetter/PathSelector.d.ts +10 -0
  74. package/lib/components/ReactionsSetter/PathSelector.js +114 -0
  75. package/lib/components/ReactionsSetter/declarations.d.ts +5 -0
  76. package/lib/components/ReactionsSetter/declarations.js +55 -0
  77. package/lib/components/ReactionsSetter/helpers.d.ts +10 -0
  78. package/lib/components/ReactionsSetter/helpers.js +387 -0
  79. package/lib/components/ReactionsSetter/index.d.ts +8 -0
  80. package/lib/components/ReactionsSetter/index.js +319 -0
  81. package/lib/components/ReactionsSetter/properties.d.ts +11 -0
  82. package/lib/components/ReactionsSetter/properties.js +44 -0
  83. package/lib/components/ReactionsSetter/styles.less +103 -0
  84. package/lib/components/ReactionsSetter/types.d.ts +13 -0
  85. package/lib/components/ReactionsSetter/types.js +2 -0
  86. package/lib/components/RemoteDataSourceSetter/RemoteDataSourcePanel.d.ts +8 -0
  87. package/lib/components/RemoteDataSourceSetter/RemoteDataSourcePanel.js +140 -0
  88. package/lib/components/RemoteDataSourceSetter/index.d.ts +17 -0
  89. package/lib/components/RemoteDataSourceSetter/index.js +64 -0
  90. package/lib/components/RemoteDataSourceSetter/styles.less +33 -0
  91. package/lib/components/RemoteDataSourceSetter/types.d.ts +8 -0
  92. package/lib/components/RemoteDataSourceSetter/types.js +2 -0
  93. package/lib/components/ValidatorSetter/index.d.ts +6 -0
  94. package/lib/components/ValidatorSetter/index.js +146 -0
  95. package/lib/components/index.d.ts +4 -0
  96. package/lib/components/index.js +20 -0
  97. package/lib/index.d.ts +2 -0
  98. package/lib/index.js +18 -0
  99. package/lib/locales/en-US.d.ts +110 -0
  100. package/lib/locales/en-US.js +117 -0
  101. package/lib/locales/index.d.ts +1 -0
  102. package/lib/locales/index.js +10 -0
  103. package/lib/locales/ko-KR.d.ts +110 -0
  104. package/lib/locales/ko-KR.js +117 -0
  105. package/lib/locales/zh-CN.d.ts +110 -0
  106. package/lib/locales/zh-CN.js +117 -0
  107. package/package.json +53 -0
  108. package/tsconfig.build.json +10 -0
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FulfillRunHelper = exports.DecoratorPropsHelper = exports.ComponentPropsHelper = exports.DataSourceHelper = exports.AnyHelper = exports.StringHelper = exports.PatternHelper = exports.DisplayHelper = exports.BooleanHelper = exports.GlobalHelper = void 0;
4
+ exports.GlobalHelper = `
5
+ /**
6
+ * You can use the built-in context variables
7
+ *
8
+ * 1. \`$self\` is the current Field Model
9
+ *
10
+ * 2. \`$form\` is the current Form Model
11
+ *
12
+ * 3. \`$deps\` is the dependencies value
13
+ *
14
+ * 4. \`$observable\` function is used to create an persistent observable state object
15
+ *
16
+ * 5. \`$memo\` function is is used to create a persistent data
17
+ *
18
+ * 6. \`$effect\` function is used to handle side-effect logic
19
+ *
20
+ * 7. \`$props\` function is used to set component props to current field
21
+ *
22
+ * Document Links
23
+ *
24
+ * https://react.formilyjs.org/api/shared/schema#%E5%86%85%E7%BD%AE%E8%A1%A8%E8%BE%BE%E5%BC%8F%E4%BD%9C%E7%94%A8%E5%9F%9F
25
+ **/
26
+ `;
27
+ exports.BooleanHelper = `
28
+ /**
29
+ * Example 1
30
+ * Static Boolean
31
+ **/
32
+
33
+ false
34
+
35
+ /**
36
+ * Example 2
37
+ * Equal Calculation
38
+ **/
39
+
40
+ $deps.VariableName === 'TARGET_VALUE'
41
+
42
+ /**
43
+ * Example 3
44
+ * Not Equal Calculation
45
+ **/
46
+
47
+ $deps.VariableName !== 'TARGET_VALUE'
48
+
49
+ /**
50
+ * Example 4
51
+ * And Logic Calculation
52
+ **/
53
+
54
+ $deps.VariableName1 && $deps.VariableName2
55
+
56
+ /**
57
+ * Example 5
58
+ * Grater Logic Calculation
59
+ **/
60
+
61
+ $deps.VariableName > 100
62
+
63
+ /**
64
+ * Example 6
65
+ * Not Logic Calculation
66
+ **/
67
+
68
+ !$deps.VariableName
69
+
70
+ ${exports.GlobalHelper}
71
+ `;
72
+ exports.DisplayHelper = `
73
+ /**
74
+ * Example 1
75
+ * Static Mode
76
+ **/
77
+
78
+ 'none'
79
+
80
+ /**
81
+ * Example 2
82
+ * Equal Condition Associated
83
+ **/
84
+
85
+ $deps.VariableName === 'TARGET_VALUE' ? 'visible' : 'none'
86
+
87
+ /**
88
+ * Example 3
89
+ * Not Equal Condition Associated
90
+ **/
91
+
92
+ $deps.VariableName !== 'TARGET_VALUE' ? 'visible' : 'hidden'
93
+
94
+ /**
95
+ * Example 4
96
+ * And Logic Condition Associated
97
+ **/
98
+
99
+ $deps.VariableName1 && $deps.VariableName2 ? 'visible' : 'none'
100
+
101
+ /**
102
+ * Example 5
103
+ * Grater Logic Condition Associated
104
+ **/
105
+
106
+ $deps.VariableName > 100 ? 'visible' : 'hidden'
107
+
108
+ /**
109
+ * Example 6
110
+ * Not Logic Condition Associated
111
+ **/
112
+
113
+ !$deps.VariableName ? 'visible' : 'none'
114
+
115
+ ${exports.GlobalHelper}
116
+ `;
117
+ exports.PatternHelper = `
118
+ /**
119
+ * Example 1
120
+ * Static Mode
121
+ **/
122
+
123
+ 'readPretty'
124
+
125
+ /**
126
+ * Example 2
127
+ * Equal Condition Associated
128
+ **/
129
+
130
+ $deps.VariableName === 'TARGET_VALUE' ? 'editable' : 'disabled'
131
+
132
+ /**
133
+ * Example 3
134
+ * Not Equal Condition Associated
135
+ **/
136
+
137
+ $deps.VariableName !== 'TARGET_VALUE' ? 'editable' : 'readOnly'
138
+
139
+ /**
140
+ * Example 4
141
+ * And Logic Condition Associated
142
+ **/
143
+
144
+ $deps.VariableName1 && $deps.VariableName2 ? 'editable' : 'readPretty'
145
+
146
+ /**
147
+ * Example 5
148
+ * Grater Logic Condition Associated
149
+ **/
150
+
151
+ $deps.VariableName > 100 ? 'editable' : 'readOnly'
152
+
153
+ /**
154
+ * Example 6
155
+ * Not Logic Condition Associated
156
+ **/
157
+
158
+ !$deps.VariableName ? 'editable' : 'disabled'
159
+
160
+ ${exports.GlobalHelper}
161
+ `;
162
+ exports.StringHelper = `
163
+ /**
164
+ * Example 1
165
+ * Static String
166
+ **/
167
+
168
+ 'Normal String Text'
169
+
170
+ /**
171
+ * Example 2
172
+ * Associated String
173
+ **/
174
+
175
+ $deps.VariableName === 'TARGET_VALUE' ? 'Associated String Text' : ''
176
+
177
+ ${exports.GlobalHelper}
178
+ `;
179
+ exports.AnyHelper = `
180
+ /**
181
+ * Example 1
182
+ * String Type
183
+ **/
184
+
185
+ 'String'
186
+
187
+ /**
188
+ * Example 2
189
+ * String Array
190
+ **/
191
+
192
+ ['StringArray']
193
+
194
+ /**
195
+ * Example 3
196
+ * Object Array
197
+ **/
198
+
199
+ [{ key: 'ObjectArray' }]
200
+
201
+ /**
202
+ * Example 4
203
+ * Boolean
204
+ **/
205
+
206
+ true
207
+
208
+ /**
209
+ * Example 5
210
+ * RegExp
211
+ **/
212
+
213
+ /\d+/
214
+
215
+ /**
216
+ * Example 1
217
+ * Associated String Value
218
+ **/
219
+
220
+ $deps.VariableName + 'Compose String'
221
+
222
+ /**
223
+ * Example 2
224
+ * Associated Array Value
225
+ **/
226
+
227
+ [ $deps.VariableName ]
228
+
229
+ /**
230
+ * Example 3
231
+ * Associated Object Value
232
+ **/
233
+
234
+ {
235
+ key : $deps.VariableName
236
+ }
237
+
238
+ /**
239
+ * Example 4
240
+ * Associated Boolean Value
241
+ **/
242
+
243
+ !$deps.VariableName
244
+
245
+ ${exports.GlobalHelper}
246
+ `;
247
+ exports.DataSourceHelper = `
248
+ /**
249
+ * Example 1
250
+ * Static DataSource
251
+ **/
252
+
253
+ [
254
+ { label : "item1", value: "1" },
255
+ { label : "item2", value: "2" }
256
+ ]
257
+
258
+ /**
259
+ * Example 2
260
+ * Associated DataSource
261
+ **/
262
+
263
+ [
264
+ { label : "item1", value: "1" },
265
+ { label : "item2", value: "2" },
266
+ ...$deps.VariableName
267
+ ]
268
+
269
+ ${exports.GlobalHelper}
270
+ `;
271
+ exports.ComponentPropsHelper = `
272
+ /**
273
+ * Example 1
274
+ * Static Props
275
+ **/
276
+
277
+ {
278
+ placeholder: "This is placeholder"
279
+ }
280
+
281
+ /**
282
+ * Example 2
283
+ * Associated Props
284
+ **/
285
+
286
+ {
287
+ placeholder: $deps.VariableName
288
+ }
289
+
290
+ ${exports.GlobalHelper}
291
+ `;
292
+ exports.DecoratorPropsHelper = `
293
+ /**
294
+ * Example 1
295
+ * Static Props
296
+ **/
297
+
298
+ {
299
+ labelCol:6
300
+ }
301
+
302
+ /**
303
+ * Example 2
304
+ * Associated Props
305
+ **/
306
+
307
+ {
308
+ labelCol: $deps.VariableName
309
+ }
310
+
311
+ ${exports.GlobalHelper}
312
+ `;
313
+ exports.FulfillRunHelper = `
314
+ /**
315
+ * Example 1
316
+ * Async Select
317
+ **/
318
+
319
+ $effect(()=>{
320
+ $self.loading = true
321
+ fetch('//some.domain/getSomething')
322
+ .then(response=>response.json())
323
+ .then(({ data })=>{
324
+ $self.loading = false
325
+ $self.dataSource = data
326
+ },()=>{
327
+ $self.loading = false
328
+ })
329
+ },[])
330
+
331
+
332
+ /**
333
+ * Example 2
334
+ * Async Search Select
335
+ **/
336
+
337
+ const state = $observable({
338
+ keyword:''
339
+ })
340
+
341
+ $props({
342
+ onSearch(keyword){
343
+ state.keyword = keyword
344
+ }
345
+ })
346
+
347
+ $effect(()=>{
348
+ $self.loading = true
349
+ fetch(\`//some.domain/getSomething?q=\${state.keyword}\`)
350
+ .then(response=>response.json())
351
+ .then(({ data })=>{
352
+ $self.loading = false
353
+ $self.dataSource = data
354
+ },()=>{
355
+ $self.loading = false
356
+ })
357
+ },[ state.keyword ])
358
+
359
+ /**
360
+ * Example 3
361
+ * Async Associated Select
362
+ **/
363
+
364
+ const state = $observable({
365
+ keyword:''
366
+ })
367
+
368
+ $props({
369
+ onSearch(keyword){
370
+ state.keyword = keyword
371
+ }
372
+ })
373
+
374
+ $effect(()=>{
375
+ $self.loading = true
376
+ fetch(\`//some.domain/getSomething?q=\${state.keyword}&other=\${$deps.VariableName}\`)
377
+ .then(response=>response.json())
378
+ .then(({ data })=>{
379
+ $self.loading = false
380
+ $self.dataSource = data
381
+ },()=>{
382
+ $self.loading = false
383
+ })
384
+ },[ state.keyword, $deps.VariableName ])
385
+
386
+ ${exports.GlobalHelper}
387
+ `;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { IReaction } from './types';
3
+ import './styles.less';
4
+ export interface IReactionsSetterProps {
5
+ value?: IReaction;
6
+ onChange?: (value: IReaction) => void;
7
+ }
8
+ export declare const ReactionsSetter: React.FC<IReactionsSetterProps>;