yy-forms 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.
- package/.fatherrc.js +37 -0
- package/CHANGELOG.md +254 -0
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.esm.js +4006 -0
- package/dist/index.js +4041 -0
- package/es/Provider.js +248 -0
- package/es/index.d.ts +145 -0
- package/es/index.js +44 -0
- package/es/settings/index.js +975 -0
- package/es/styles/atom.less +1134 -0
- package/es/styles/index.less +358 -0
- package/es/transformer/form-render.js +75 -0
- package/es/utils/context.js +3 -0
- package/es/utils/hooks.js +48 -0
- package/es/utils/index.js +706 -0
- package/es/utils/mapping.js +31 -0
- package/es/utils/serialize.js +276 -0
- package/es/widgets/htmlInput.js +20 -0
- package/es/widgets/idInput.js +23 -0
- package/es/widgets/index.js +5 -0
- package/es/widgets/jsonInput.js +24 -0
- package/es/widgets/list.js +24 -0
- package/es/widgets/percentSlider.js +89 -0
- package/package.json +53 -0
- package/src/Provider.jsx +239 -0
- package/src/components/Canvas/core/RenderChildren.jsx +18 -0
- package/src/components/Canvas/core/RenderField.jsx +129 -0
- package/src/components/Canvas/core/Wrapper.jsx +298 -0
- package/src/components/Canvas/core/Wrapper.less +57 -0
- package/src/components/Canvas/core/index.jsx +171 -0
- package/src/components/Canvas/index.jsx +178 -0
- package/src/components/Settings/GlobalSettings.jsx +48 -0
- package/src/components/Settings/ItemSettings.jsx +143 -0
- package/src/components/Settings/index.jsx +75 -0
- package/src/components/Settings/index.less +25 -0
- package/src/components/Sidebar/Element.jsx +80 -0
- package/src/components/Sidebar/Element.less +18 -0
- package/src/components/Sidebar/index.jsx +47 -0
- package/src/components/Sidebar/index.less +23 -0
- package/src/i18next/index.ts +14 -0
- package/src/i18next/locales/enUS.json +60 -0
- package/src/i18next/locales/resources.ts +7 -0
- package/src/i18next/locales/zhCN.json +3 -0
- package/src/index.d.ts +145 -0
- package/src/index.js +45 -0
- package/src/settings/index.js +1058 -0
- package/src/styles/atom.less +1134 -0
- package/src/styles/index.less +358 -0
- package/src/transformer/form-render.js +65 -0
- package/src/utils/context.js +4 -0
- package/src/utils/hooks.js +35 -0
- package/src/utils/index.js +678 -0
- package/src/utils/mapping.js +29 -0
- package/src/utils/serialize.js +368 -0
- package/src/widgets/htmlInput.jsx +24 -0
- package/src/widgets/idInput.jsx +27 -0
- package/src/widgets/index.js +6 -0
- package/src/widgets/jsonInput.jsx +29 -0
- package/src/widgets/list.jsx +28 -0
- package/src/widgets/percentSlider.jsx +74 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
@import './atom.less';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
用于原有样式的覆盖
|
|
5
|
+
*/
|
|
6
|
+
.fr-generator-container {
|
|
7
|
+
display: flex;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
height: 100%;
|
|
10
|
+
min-height: 30vh;
|
|
11
|
+
position: relative;
|
|
12
|
+
.mid-layout {
|
|
13
|
+
padding: 0 8px;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
flex-shrink: 1;
|
|
18
|
+
/* height: 100%; */
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
border-left: 1px solid #e0e0e0;
|
|
21
|
+
border-right: 1px solid #e0e0e0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.flex-center {
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.dnd-container {
|
|
31
|
+
flex-grow: 1;
|
|
32
|
+
overflow-y: auto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ant-tabs.ant-tabs-top {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
height: 100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ant-tabs-content-holder {
|
|
42
|
+
flex-grow: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ant-tabs-content.ant-tabs-content-top {
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ant-tabs-tabpane.ant-tabs-tabpane-active {
|
|
50
|
+
height: 100%;
|
|
51
|
+
overflow-y: auto;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.fr-generator-container .dnd-container.edit {
|
|
56
|
+
.top-upper {
|
|
57
|
+
top: -12px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.fr-set {
|
|
61
|
+
padding: 12px 14px 12px 12px;
|
|
62
|
+
margin-bottom: 12px;
|
|
63
|
+
border-radius: 4px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.fr-field {
|
|
67
|
+
margin-bottom: 24px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.fr-label {
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.fr-label-title {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
color: #333;
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
min-height: 22px; /* ""的标签页占位 */
|
|
79
|
+
line-height: 22px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.fr-label-required {
|
|
83
|
+
margin: 1px 4px 0 0;
|
|
84
|
+
color: #f5222d;
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
font-family: SimSun, sans-serif;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.fr-label-title::after {
|
|
90
|
+
content: ':';
|
|
91
|
+
position: relative;
|
|
92
|
+
top: -0.5px;
|
|
93
|
+
margin: 0 10px 0 2px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.fr-label-title.no-colon::after {
|
|
97
|
+
content: '';
|
|
98
|
+
margin: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.fr-label-object .fr-label-title {
|
|
102
|
+
font-size: 16px;
|
|
103
|
+
color: #222;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.fr-desc {
|
|
107
|
+
margin-top: 3px;
|
|
108
|
+
font-size: 12px;
|
|
109
|
+
word-break: break-all;
|
|
110
|
+
color: #888;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.fr-validate {
|
|
114
|
+
margin-left: 12px;
|
|
115
|
+
font-size: 12px;
|
|
116
|
+
word-break: break-all;
|
|
117
|
+
color: #f5222d;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Row */
|
|
121
|
+
|
|
122
|
+
.fr-validate-row {
|
|
123
|
+
margin: 3px 0 0 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.fr-label-row {
|
|
127
|
+
text-align: right;
|
|
128
|
+
flex-shrink: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.fr-field-row .fr-content {
|
|
132
|
+
flex: 1;
|
|
133
|
+
position: relative;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.fr-field-row .fr-tooltip-icon {
|
|
137
|
+
margin: 3px 2px 0 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* 自定义类 */
|
|
141
|
+
.hover-b--black-20:hover {
|
|
142
|
+
border-color: rgba(0, 0, 0, 0.3);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.pt44 {
|
|
146
|
+
padding-top: 46px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.pv12 {
|
|
150
|
+
padding-top: 12px;
|
|
151
|
+
padding-bottom: 12px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* 组件内部样式*/
|
|
155
|
+
.fr-color-picker {
|
|
156
|
+
width: 100%;
|
|
157
|
+
display: flex;
|
|
158
|
+
flex-direction: row;
|
|
159
|
+
align-items: center;
|
|
160
|
+
color: #666;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.fr-color-picker .rc-color-picker-trigger {
|
|
164
|
+
margin-right: 12px;
|
|
165
|
+
height: 30px;
|
|
166
|
+
width: 60px;
|
|
167
|
+
border: 1px solid #e5e5e5;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.fr-color-picker > p {
|
|
171
|
+
margin: 0;
|
|
172
|
+
font-size: 14px;
|
|
173
|
+
line-height: 28px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.fr-color-picker .rc-color-picker-wrap {
|
|
177
|
+
display: flex;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.next-input,
|
|
181
|
+
.next-number-picker {
|
|
182
|
+
width: 100%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.upload-img {
|
|
186
|
+
max-width: 200px;
|
|
187
|
+
max-height: 200px;
|
|
188
|
+
margin-right: 24px;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.fr-preview-image {
|
|
192
|
+
width: 160px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.fr-preview {
|
|
196
|
+
position: relative;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.fr-upload-mod,
|
|
201
|
+
.fr-upload-file {
|
|
202
|
+
display: flex;
|
|
203
|
+
}
|
|
204
|
+
.fr-upload-mod {
|
|
205
|
+
align-items: center;
|
|
206
|
+
}
|
|
207
|
+
.fr-upload-mod .fr-upload-preview {
|
|
208
|
+
margin: 0 12px;
|
|
209
|
+
}
|
|
210
|
+
.fr-upload-file .ant-upload-list-item {
|
|
211
|
+
margin: 5px 0 0 8px;
|
|
212
|
+
}
|
|
213
|
+
.fr-upload-file .ant-upload-list-item-name {
|
|
214
|
+
margin-right: 6px;
|
|
215
|
+
}
|
|
216
|
+
.fr-upload-file .ant-upload-list-item-info {
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
}
|
|
219
|
+
.fr-upload-file .next-upload-list-text .next-upload-list-item-done,
|
|
220
|
+
.fr-upload-file .next-upload-list-text .next-upload-list-item .next-icon {
|
|
221
|
+
height: 28px;
|
|
222
|
+
line-height: 28px;
|
|
223
|
+
margin-left: 12px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.fr-upload-file .next-upload-list-item-name-wrap {
|
|
227
|
+
margin-top: -4px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.fr-sort-help-class {
|
|
231
|
+
background: #fff;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* 其他样式 */
|
|
235
|
+
|
|
236
|
+
.fold-icon.fold-icon-active {
|
|
237
|
+
transform: rotate(0deg);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.fold-icon {
|
|
241
|
+
transform: rotate(-90deg);
|
|
242
|
+
transition: transform 0.24s;
|
|
243
|
+
cursor: pointer;
|
|
244
|
+
position: relative;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.fold-icon::after {
|
|
248
|
+
content: '';
|
|
249
|
+
position: absolute;
|
|
250
|
+
top: -20px;
|
|
251
|
+
right: -10px;
|
|
252
|
+
bottom: -5px;
|
|
253
|
+
left: -20px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.fr-tooltip-toggle {
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
position: relative;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.fr-tooltip-toggle:hover .fr-tooltip-container {
|
|
262
|
+
opacity: 1;
|
|
263
|
+
visibility: visible;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.fr-tooltip-icon {
|
|
267
|
+
height: 14px;
|
|
268
|
+
width: 14px;
|
|
269
|
+
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAEnUlEQVR42u1bS0iUURT+zd4Y9KDosSihNhYUaBE9YKpFDKKOOmOLahtJ2SoxA2fUdUoQJK5qU0ib6LlxUYJpkY0LE3tQZkU7y7A0e1jnA4Of8pz//5373/+BF44Oc+/c853v3nOf5xpup0QiMZ9kD8mxeDzeTHKXPveSvKXP3+j/GP1/h++QhzIoW1ZWthu/NYKYysvLN5EhKZJ7ZMQEye8ZyjjJfZIk6vS10YWFhcvI4FoC2wfwLkkf6aiBLt8YHovFNhCoFnRlgNQkY9BJbrLeS9uzqFueYAzXJV9ITgKLVsvBPCnuAAifSIe23kBd7zApHHUI8D3JBfptFUlialbYSJIDweep7+Iog7L4jUMdn4HNzeksmxRcdgColyRZWlq6NQOd21AH6rKrFxiBVanxxcXFS6jSdpsAHtLYUODC1FqAum0S0Q7Mqlp+ESlO2zD8DUmJBhcsgS4bJDwBdhUKb1ko+kll6qLR6AJDU4IuuAZ0W2C7kWnrJy1a/QONvjsNjxLp32VjsEzO1OcOkoJJoeJuGuBWGB4nYCCcD4RGmiSJOm35PIup7kokEplr+CQBCzAJeEeJqC22V3jE2IBQWVd+fv48w2cJmAhbp4C7H7bZaf1KoZJBbET8vCEDRgF/pdXGZim1/ifGl344WtTIJJ//B+ggts+K6t4BrAwBH2GjNKo2CuxVqzJeGLDqFemoFnQ0sq0vDHyP4D+KwI1ILqZqpyqsGmFjznStX8tNIzQlbjYUJasVnCo9wAzsjE1npyPgFQPqJvKDRYC8ioWt/200BFD7FRMwIu0nFBNwgNMFm80Fz0mAFIOqVz4IyoS/ZvQ1mQv1MYBqkO8GCSDXTDRjvAoCznAHrH/X0qu4FqE99Voj2AkErOPsg+3w/wqmwDMjHAkkPGdsPITMBqb7t4SFANjCjTkgoI0ZJY+Hwnp5f9MGdtIMOxF35n1ZXDrG38fYmDa48zWcs4eFANxesUtv+jPMZC4PCwE4NWL0DRvcehkHjyEhACdGCxl9vwBwggEyxw0wXhCAOANG34TsAi4k37kA/RliMnND1ANyGX1DGAMe89Og+uSjaRDSAwKucgeIYSEAcQzc8T4ISDGZrSFygVaml6dAQILJfBEiAl4yy/0KZK6WtsMBJwD+v0bcDk/tlp4yveB0cAmQj8hhs7lQE1NoIAQEPGdsazZ3k+3SoahOAvQfisoDBeR2QAmArjvcsbi2i5FMQ+Ay0Jvn6GIE10VWV2MBIiALmKWrMfFylJsRgkIAsAp1NojX47hCZn74HdfjficAAzp3PY6rf9g4GyBhw3/6Axoi0yW48IDtcQwBRVIUOHaQfguSAiYpvB42Od1Cxiz8s5tkpdfGAwOwSFhhy0xXUnV+DpSEbmCwwFiXKcPXbYTKpnSHykIndFsYf01JsDRJTxCDpUGU7nB5SKcfwuWLiooWK38wQXLJwcOFtIoHE/Bh5v6SE2DMdvNN4BE3nszQ93szfTJDclTbU7lAP5pSGIxY5eWzOdL/lXrkKW6Fp7M3XPTi4SR0zz6dnX087fOEq2k8hTc/nydJm57Pj3v5fP4PSqRR6oYkTaUAAAAASUVORK5CYII=');
|
|
270
|
+
background-size: cover;
|
|
271
|
+
display: block;
|
|
272
|
+
margin: 4px 0 0 4px;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.fr-tooltip-container {
|
|
276
|
+
position: absolute;
|
|
277
|
+
width: 160px;
|
|
278
|
+
left: 50%;
|
|
279
|
+
white-space: initial !important;
|
|
280
|
+
bottom: 30px;
|
|
281
|
+
text-align: center;
|
|
282
|
+
background: #2b222a;
|
|
283
|
+
padding: 4px;
|
|
284
|
+
margin-left: -77px;
|
|
285
|
+
border-radius: 4px;
|
|
286
|
+
color: #efefef;
|
|
287
|
+
font-size: 13px;
|
|
288
|
+
cursor: auto;
|
|
289
|
+
z-index: 99999;
|
|
290
|
+
transition: all 0.5s ease;
|
|
291
|
+
opacity: 0;
|
|
292
|
+
visibility: hidden;
|
|
293
|
+
word-wrap: break-word;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.fr-tooltip-triangle {
|
|
297
|
+
position: absolute;
|
|
298
|
+
left: 50%;
|
|
299
|
+
border-left: 5px solid transparent;
|
|
300
|
+
border-right: 5px solid transparent;
|
|
301
|
+
border-top: 5px solid #2b222a;
|
|
302
|
+
transition: all 0.5s ease;
|
|
303
|
+
content: ' ';
|
|
304
|
+
font-size: 0;
|
|
305
|
+
line-height: 0;
|
|
306
|
+
margin-left: -5px;
|
|
307
|
+
width: 0;
|
|
308
|
+
bottom: -5px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.fr-tooltip-toggle::before,
|
|
312
|
+
.fr-tooltip-toggle::after {
|
|
313
|
+
color: #efefef;
|
|
314
|
+
font-size: 13px;
|
|
315
|
+
opacity: 0;
|
|
316
|
+
pointer-events: none;
|
|
317
|
+
text-align: center;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.fr-tooltip-toggle:focus::before,
|
|
321
|
+
.fr-tooltip-toggle:focus::after,
|
|
322
|
+
.fr-tooltip-toggle:hover::before,
|
|
323
|
+
.fr-tooltip-toggle:hover::after {
|
|
324
|
+
opacity: 1;
|
|
325
|
+
transition: all 0.75s ease;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.fr-slider {
|
|
329
|
+
display: flex;
|
|
330
|
+
width: 100%;
|
|
331
|
+
align-items: center;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.fr-map {
|
|
335
|
+
display: flex;
|
|
336
|
+
flex-wrap: wrap;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.frg-options-list {
|
|
341
|
+
.fr-list-1 {
|
|
342
|
+
.fr-field.fr-field-object {
|
|
343
|
+
flex: 1;
|
|
344
|
+
}
|
|
345
|
+
.fr-field.fr-field-inline > div:first-child {
|
|
346
|
+
display: none;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
.frg-options-input {
|
|
350
|
+
&:first-child {
|
|
351
|
+
margin-right: 6px;
|
|
352
|
+
}
|
|
353
|
+
.fr-content.fr-content-inline {
|
|
354
|
+
max-width: 96px;
|
|
355
|
+
min-width: 96px;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { getChildren2 } from '../utils';
|
|
8
|
+
|
|
9
|
+
// Setting Schema => FR Schema
|
|
10
|
+
var transformFrom = function transformFrom(schema) {
|
|
11
|
+
var isObj = schema.type === 'object' && schema.properties;
|
|
12
|
+
var isList = schema.type === 'array' && schema.items && schema.items.properties;
|
|
13
|
+
var hasChildren = isObj || isList;
|
|
14
|
+
if (!hasChildren) {
|
|
15
|
+
if (Array.isArray(schema.enumList)) {
|
|
16
|
+
schema.enum = schema.enumList.filter(function (item) {
|
|
17
|
+
return item.value;
|
|
18
|
+
}).map(function (item) {
|
|
19
|
+
return item.value;
|
|
20
|
+
});
|
|
21
|
+
schema.enumNames = schema.enumList.filter(function (item) {
|
|
22
|
+
return item.value;
|
|
23
|
+
}).map(function (item) {
|
|
24
|
+
return item.label || item.value;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
delete schema.enumList;
|
|
28
|
+
} else {
|
|
29
|
+
var childrenList = getChildren2(schema);
|
|
30
|
+
childrenList.map(function (item) {
|
|
31
|
+
if (isObj) {
|
|
32
|
+
schema.properties[item.name] = transformTo(_objectSpread({}, item.schema));
|
|
33
|
+
}
|
|
34
|
+
if (isList) {
|
|
35
|
+
schema.items.properties[item.name] = transformTo(_objectSpread({}, item.schema));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return schema;
|
|
40
|
+
};
|
|
41
|
+
export var fromSetting = function fromSetting(schema) {
|
|
42
|
+
return transformFrom(_objectSpread({}, schema));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// FR Schema => Setting Schema
|
|
46
|
+
var transformTo = function transformTo(schema) {
|
|
47
|
+
var isObj = schema.type === 'object' && schema.properties;
|
|
48
|
+
var isList = schema.type === 'array' && schema.items && schema.items.properties;
|
|
49
|
+
var hasChildren = isObj || isList;
|
|
50
|
+
if (!hasChildren) {
|
|
51
|
+
if (Array.isArray(schema.enum) && Array.isArray(schema.enumNames)) {
|
|
52
|
+
var list = schema.enum.map(function (item, idx) {
|
|
53
|
+
return {
|
|
54
|
+
value: item,
|
|
55
|
+
label: schema.enumNames[idx]
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
schema.enumList = list;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
var childrenList = getChildren2(schema);
|
|
62
|
+
childrenList.map(function (item) {
|
|
63
|
+
if (isObj) {
|
|
64
|
+
schema.properties[item.name] = transformFrom(_objectSpread({}, item.schema));
|
|
65
|
+
}
|
|
66
|
+
if (isList) {
|
|
67
|
+
schema.items.properties[item.name] = transformFrom(_objectSpread({}, item.schema));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return schema;
|
|
72
|
+
};
|
|
73
|
+
export var toSetting = function toSetting(schema) {
|
|
74
|
+
return transformTo(_objectSpread({}, schema));
|
|
75
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
import { useContext, useReducer } from 'react';
|
|
14
|
+
import { Ctx, StoreCtx } from './context';
|
|
15
|
+
|
|
16
|
+
// 使用最顶层组件的 setState
|
|
17
|
+
export var useGlobal = function useGlobal() {
|
|
18
|
+
return useContext(Ctx);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// 组件最顶层传入的所有props
|
|
22
|
+
export var useStore = function useStore() {
|
|
23
|
+
return useContext(StoreCtx);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// 类似于 class component 的 setState
|
|
27
|
+
export var useSet = function useSet(initState) {
|
|
28
|
+
var _useReducer = useReducer(function (state, newState) {
|
|
29
|
+
var action = newState;
|
|
30
|
+
if (typeof newState === 'function') {
|
|
31
|
+
action = action(state);
|
|
32
|
+
}
|
|
33
|
+
if (newState.action && newState.payload) {
|
|
34
|
+
action = newState.payload;
|
|
35
|
+
if (typeof action === 'function') {
|
|
36
|
+
action = action(state);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return _objectSpread(_objectSpread({}, state), action);
|
|
40
|
+
}, initState),
|
|
41
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
42
|
+
state = _useReducer2[0],
|
|
43
|
+
setState = _useReducer2[1];
|
|
44
|
+
var setStateWithActionName = function setStateWithActionName(state, actionName) {
|
|
45
|
+
setState(state);
|
|
46
|
+
};
|
|
47
|
+
return [state, setStateWithActionName];
|
|
48
|
+
};
|