@jxyszb/jxy-form-designer 0.1.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/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/chunks/RuntimePreviewPanel-3704c8f8.js +1991 -0
- package/dist/chunks/compositeField-98c1b192.js +588 -0
- package/dist/chunks/dataSourceUrl-4b17feb8.js +55 -0
- package/dist/designer.js +3023 -0
- package/dist/index.js +45 -0
- package/dist/runtime.js +67 -0
- package/dist/schema.js +266 -0
- package/dist/style.css +1 -0
- package/dist/testing.js +1026 -0
- package/docs/field-suffix-extension.md +289 -0
- package/package.json +100 -0
- package/types/designer.d.ts +12 -0
- package/types/index.d.ts +345 -0
- package/types/runtime.d.ts +22 -0
- package/types/schema.d.ts +31 -0
- package/types/testing.d.ts +3 -0
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
const A = "jxy-form-schema@1.0.0", u = "jxy-form-schema@1.1.0", f = "jxy-form-schema@1.2.0", p = "jxy-form-schema@1.3.0", T = [
|
|
2
|
+
"text",
|
|
3
|
+
"password",
|
|
4
|
+
"textarea",
|
|
5
|
+
"number",
|
|
6
|
+
"floatNum",
|
|
7
|
+
"date",
|
|
8
|
+
"month",
|
|
9
|
+
"year",
|
|
10
|
+
"daterange",
|
|
11
|
+
"datetimerange",
|
|
12
|
+
"editor"
|
|
13
|
+
], h = ["select", "cascader", "checkBox", "radio"], N = ["file", "dragFile", "imgFile"], z = ["title", "grid"], _ = ["addressSelector", "integerUppercase", "linkedSelectList"], B = ["custom"], W = [
|
|
14
|
+
...T,
|
|
15
|
+
...h,
|
|
16
|
+
...N,
|
|
17
|
+
..._,
|
|
18
|
+
"editor",
|
|
19
|
+
"custom"
|
|
20
|
+
].filter((e, t, r) => r.indexOf(e) === t), q = [...h, "addressSelector", "linkedSelectList"], K = ["field", "title", "grid"], J = ["always", "eq", "neq", "in", "notIn", "empty", "notEmpty"], G = ["clearValue", "setValue", "setHidden", "setDisabled", "setRequired", "reloadOptions"], X = ["pattern", "minLength", "maxLength", "min", "max", "email", "url"], Q = ["static", "dict", "api"];
|
|
21
|
+
function D() {
|
|
22
|
+
const e = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", t = new Uint8Array(8);
|
|
23
|
+
if (typeof crypto < "u" && crypto.getRandomValues)
|
|
24
|
+
crypto.getRandomValues(t);
|
|
25
|
+
else
|
|
26
|
+
for (let n = 0; n < 8; n++)
|
|
27
|
+
t[n] = Math.floor(Math.random() * 256);
|
|
28
|
+
let r = "";
|
|
29
|
+
for (let n = 0; n < 8; n++)
|
|
30
|
+
r += e[t[n] % e.length];
|
|
31
|
+
return r;
|
|
32
|
+
}
|
|
33
|
+
function a(e) {
|
|
34
|
+
return `${e}_${D()}`;
|
|
35
|
+
}
|
|
36
|
+
const C = {
|
|
37
|
+
text: { max: void 0 },
|
|
38
|
+
password: { max: void 0 },
|
|
39
|
+
textarea: { rows: 3, max: void 0 },
|
|
40
|
+
number: { max: void 0 },
|
|
41
|
+
floatNum: { max: void 0, decimal: 2 },
|
|
42
|
+
date: { format: "YYYY-MM-DD", valueFormat: "YYYY-MM-DD" },
|
|
43
|
+
month: { format: "YYYY-MM", valueFormat: "YYYY-MM" },
|
|
44
|
+
year: { format: "YYYY", valueFormat: "YYYY" },
|
|
45
|
+
daterange: { format: "YYYY-MM-DD", valueFormat: "YYYY-MM-DD", startPlaceholder: "开始日期", endPlaceholder: "结束日期" },
|
|
46
|
+
datetimerange: { format: "YYYY-MM-DD HH:mm:ss", valueFormat: "YYYY-MM-DD HH:mm:ss", startPlaceholder: "开始时间", endPlaceholder: "结束时间" },
|
|
47
|
+
select: { multiple: !1, clearable: !0 },
|
|
48
|
+
cascader: { multiple: !1, checkStrictly: !1 },
|
|
49
|
+
checkBox: {},
|
|
50
|
+
radio: {},
|
|
51
|
+
file: { fileType: ["docx", "xlsx", "pdf"], fileSize: 60, limit: void 0 },
|
|
52
|
+
dragFile: { fileType: ["docx", "xlsx", "pdf"], fileSize: 60, limit: void 0 },
|
|
53
|
+
imgFile: { fileType: ["jpg", "jpeg", "png"], fileSize: 60, limit: void 0 },
|
|
54
|
+
editor: { height: 200 },
|
|
55
|
+
addressSelector: {
|
|
56
|
+
provinceProp: "province",
|
|
57
|
+
cityProp: "city",
|
|
58
|
+
countyProp: "county",
|
|
59
|
+
detailAddressProp: "detailAddress",
|
|
60
|
+
provincePlaceholder: "请选择省份",
|
|
61
|
+
cityPlaceholder: "请选择城市",
|
|
62
|
+
countyPlaceholder: "请选择区县",
|
|
63
|
+
detailPlaceholder: "请输入详细地址",
|
|
64
|
+
detailRequired: !0
|
|
65
|
+
},
|
|
66
|
+
integerUppercase: { suffixText: "", maxLength: 16 },
|
|
67
|
+
linkedSelectList: {
|
|
68
|
+
parentValueProp: "parentValue",
|
|
69
|
+
childValueProp: "childValue",
|
|
70
|
+
firstPlaceholder: "请选择一级选项",
|
|
71
|
+
secondPlaceholder: "请选择二级选项",
|
|
72
|
+
addText: "点击新增",
|
|
73
|
+
minItems: 1,
|
|
74
|
+
maxItems: 5,
|
|
75
|
+
allowDuplicate: !0,
|
|
76
|
+
addButtonAlign: "center"
|
|
77
|
+
},
|
|
78
|
+
custom: {}
|
|
79
|
+
};
|
|
80
|
+
function x(e) {
|
|
81
|
+
const t = C[e];
|
|
82
|
+
return t ? JSON.parse(JSON.stringify(t)) : {};
|
|
83
|
+
}
|
|
84
|
+
const I = {
|
|
85
|
+
text: "",
|
|
86
|
+
password: "",
|
|
87
|
+
textarea: "",
|
|
88
|
+
number: null,
|
|
89
|
+
floatNum: null,
|
|
90
|
+
date: "",
|
|
91
|
+
month: "",
|
|
92
|
+
year: "",
|
|
93
|
+
daterange: [],
|
|
94
|
+
datetimerange: [],
|
|
95
|
+
select: "",
|
|
96
|
+
cascader: [],
|
|
97
|
+
checkBox: [],
|
|
98
|
+
radio: "",
|
|
99
|
+
file: [],
|
|
100
|
+
dragFile: [],
|
|
101
|
+
imgFile: [],
|
|
102
|
+
editor: "",
|
|
103
|
+
addressSelector: { province: "", city: "", county: "", detailAddress: "" },
|
|
104
|
+
integerUppercase: "",
|
|
105
|
+
linkedSelectList: [],
|
|
106
|
+
custom: ""
|
|
107
|
+
};
|
|
108
|
+
function O(e) {
|
|
109
|
+
const t = I[e];
|
|
110
|
+
return t === void 0 ? "" : t && typeof t == "object" ? JSON.parse(JSON.stringify(t)) : t;
|
|
111
|
+
}
|
|
112
|
+
function L() {
|
|
113
|
+
return {
|
|
114
|
+
schemaVersion: p,
|
|
115
|
+
meta: {
|
|
116
|
+
formCode: "",
|
|
117
|
+
formName: "",
|
|
118
|
+
description: ""
|
|
119
|
+
},
|
|
120
|
+
config: {
|
|
121
|
+
customClass: "",
|
|
122
|
+
labelPosition: "right",
|
|
123
|
+
labelWidth: 120,
|
|
124
|
+
suffixWidth: 60,
|
|
125
|
+
size: "default",
|
|
126
|
+
disabled: !1,
|
|
127
|
+
gutter: 16
|
|
128
|
+
},
|
|
129
|
+
dataSourceConfig: {
|
|
130
|
+
dictUrl: ""
|
|
131
|
+
},
|
|
132
|
+
dataSources: [],
|
|
133
|
+
reactions: [],
|
|
134
|
+
nodes: []
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function F(e = "text") {
|
|
138
|
+
return {
|
|
139
|
+
id: a("field"),
|
|
140
|
+
nodeType: "field",
|
|
141
|
+
sort: 0,
|
|
142
|
+
prop: "",
|
|
143
|
+
label: "",
|
|
144
|
+
type: e,
|
|
145
|
+
defaultValue: O(e),
|
|
146
|
+
placeholder: "",
|
|
147
|
+
required: !1,
|
|
148
|
+
disabled: !1,
|
|
149
|
+
hidden: !1,
|
|
150
|
+
labelWidth: "",
|
|
151
|
+
customClass: "",
|
|
152
|
+
dataSourceId: "",
|
|
153
|
+
componentKey: "",
|
|
154
|
+
componentProps: {},
|
|
155
|
+
props: x(e),
|
|
156
|
+
validations: [],
|
|
157
|
+
extensions: {
|
|
158
|
+
suffix: {
|
|
159
|
+
enabled: !1,
|
|
160
|
+
width: ""
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function M() {
|
|
166
|
+
return {
|
|
167
|
+
id: a("title"),
|
|
168
|
+
nodeType: "title",
|
|
169
|
+
sort: 0,
|
|
170
|
+
title: "",
|
|
171
|
+
description: "",
|
|
172
|
+
level: 2,
|
|
173
|
+
customClass: ""
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function U(e = 12) {
|
|
177
|
+
return {
|
|
178
|
+
id: a("col"),
|
|
179
|
+
sort: 0,
|
|
180
|
+
span: e,
|
|
181
|
+
labelWidth: "",
|
|
182
|
+
customClass: "",
|
|
183
|
+
children: []
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function v(e = 2) {
|
|
187
|
+
const t = Math.floor(24 / e), r = [];
|
|
188
|
+
for (let i = 0; i < e; i++) {
|
|
189
|
+
const o = U(t);
|
|
190
|
+
o.sort = i, r.push(o);
|
|
191
|
+
}
|
|
192
|
+
const n = t * e;
|
|
193
|
+
return n < 24 && (r[r.length - 1].span += 24 - n), {
|
|
194
|
+
id: a("grid"),
|
|
195
|
+
nodeType: "grid",
|
|
196
|
+
sort: 0,
|
|
197
|
+
columnCount: e,
|
|
198
|
+
gutter: 16,
|
|
199
|
+
labelWidth: "",
|
|
200
|
+
customClass: "",
|
|
201
|
+
columns: r
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function Z() {
|
|
205
|
+
return {
|
|
206
|
+
id: a("ds"),
|
|
207
|
+
name: "",
|
|
208
|
+
type: "static",
|
|
209
|
+
options: [
|
|
210
|
+
{ label: "选项1", value: "1", disabled: !1 },
|
|
211
|
+
{ label: "选项2", value: "2", disabled: !1 }
|
|
212
|
+
]
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function ee() {
|
|
216
|
+
return {
|
|
217
|
+
id: a("ds"),
|
|
218
|
+
name: "",
|
|
219
|
+
type: "dict",
|
|
220
|
+
dictType: ""
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function te() {
|
|
224
|
+
return {
|
|
225
|
+
id: a("ds"),
|
|
226
|
+
name: "",
|
|
227
|
+
type: "api",
|
|
228
|
+
url: "",
|
|
229
|
+
params: []
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function re() {
|
|
233
|
+
return {
|
|
234
|
+
key: "",
|
|
235
|
+
valueType: "constant",
|
|
236
|
+
field: "",
|
|
237
|
+
value: "",
|
|
238
|
+
required: !1
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function ie() {
|
|
242
|
+
return {
|
|
243
|
+
id: a("reaction"),
|
|
244
|
+
sourceField: "",
|
|
245
|
+
condition: {
|
|
246
|
+
type: "always",
|
|
247
|
+
value: ""
|
|
248
|
+
},
|
|
249
|
+
effects: []
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function ne(e = "setHidden") {
|
|
253
|
+
return {
|
|
254
|
+
type: e,
|
|
255
|
+
targetField: "",
|
|
256
|
+
value: e === "setHidden" || e === "setDisabled" || e === "setRequired" ? !0 : ""
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const ae = [
|
|
260
|
+
{
|
|
261
|
+
groupName: "基础组件",
|
|
262
|
+
items: [
|
|
263
|
+
{ label: "单行文本", type: "text", icon: "Edit" },
|
|
264
|
+
{ label: "密码", type: "password", icon: "Lock" },
|
|
265
|
+
{ label: "多行文本", type: "textarea", icon: "Document" },
|
|
266
|
+
{ label: "数字", type: "number", icon: "Odometer" },
|
|
267
|
+
{ label: "小数", type: "floatNum", icon: "Coin" },
|
|
268
|
+
{ label: "日期", type: "date", icon: "Calendar" },
|
|
269
|
+
{ label: "月份", type: "month", icon: "Calendar" },
|
|
270
|
+
{ label: "年份", type: "year", icon: "Calendar" },
|
|
271
|
+
{ label: "日期范围", type: "daterange", icon: "Calendar" },
|
|
272
|
+
{ label: "日期时间范围", type: "datetimerange", icon: "Calendar" },
|
|
273
|
+
{ label: "富文本", type: "editor", icon: "Notebook" }
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
groupName: "选择型组件",
|
|
278
|
+
items: [
|
|
279
|
+
{ label: "下拉选择", type: "select", icon: "ArrowDown" },
|
|
280
|
+
{ label: "级联选择", type: "cascader", icon: "Share" },
|
|
281
|
+
{ label: "多选框", type: "checkBox", icon: "Finished" },
|
|
282
|
+
{ label: "单选框", type: "radio", icon: "Open" },
|
|
283
|
+
{ label: "普通上传", type: "file", icon: "Upload" },
|
|
284
|
+
{ label: "拖拽上传", type: "dragFile", icon: "UploadFilled" },
|
|
285
|
+
{ label: "图片上传", type: "imgFile", icon: "Picture" }
|
|
286
|
+
]
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
groupName: "布局组件",
|
|
290
|
+
items: [
|
|
291
|
+
{ label: "标题", type: "title", icon: "Memo", isLayout: !0 },
|
|
292
|
+
{ label: "栅格", type: "grid", icon: "Grid", isLayout: !0 }
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
groupName: "扩展组件",
|
|
297
|
+
items: [
|
|
298
|
+
{ label: "地址选择", type: "addressSelector", icon: "Location" },
|
|
299
|
+
{ label: "整数大写", type: "integerUppercase", icon: "Tickets" },
|
|
300
|
+
{ label: "关联选择列表", type: "linkedSelectList", icon: "List" }
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
groupName: "自定义组件",
|
|
305
|
+
items: [
|
|
306
|
+
{ label: "自定义组件", type: "custom", icon: "SetUp" }
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
];
|
|
310
|
+
function oe(e) {
|
|
311
|
+
if (e.type === "title") {
|
|
312
|
+
const r = M();
|
|
313
|
+
return r.title = e.label, r;
|
|
314
|
+
}
|
|
315
|
+
if (e.type === "grid")
|
|
316
|
+
return v(2);
|
|
317
|
+
const t = F(e.type);
|
|
318
|
+
return t.label = e.label, t;
|
|
319
|
+
}
|
|
320
|
+
function w(e) {
|
|
321
|
+
return !e || !Array.isArray(e.nodes) || (E(e.nodes), Array.isArray(e.dataSources) && e.dataSources.forEach((t, r) => {
|
|
322
|
+
t.sort = r;
|
|
323
|
+
})), e;
|
|
324
|
+
}
|
|
325
|
+
function E(e) {
|
|
326
|
+
Array.isArray(e) && e.forEach((t, r) => {
|
|
327
|
+
t.sort = r, t.nodeType === "grid" && Array.isArray(t.columns) && t.columns.forEach((n, i) => {
|
|
328
|
+
n.sort = i, Array.isArray(n.children) && E(n.children);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
function se(e) {
|
|
333
|
+
const t = [];
|
|
334
|
+
return b(e.nodes, t), Array.isArray(e.dataSources) && e.dataSources.forEach((r) => {
|
|
335
|
+
r.id && t.push(r.id);
|
|
336
|
+
}), Array.isArray(e.reactions) && e.reactions.forEach((r) => {
|
|
337
|
+
r.id && t.push(r.id);
|
|
338
|
+
}), t;
|
|
339
|
+
}
|
|
340
|
+
function b(e, t) {
|
|
341
|
+
Array.isArray(e) && e.forEach((r) => {
|
|
342
|
+
r.id && t.push(r.id), r.nodeType === "grid" && Array.isArray(r.columns) && r.columns.forEach((n) => {
|
|
343
|
+
n.id && t.push(n.id), b(n.children, t);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function k(e) {
|
|
348
|
+
const t = /* @__PURE__ */ new Set();
|
|
349
|
+
let r = 0;
|
|
350
|
+
function n(i, o) {
|
|
351
|
+
(!i.id || t.has(i.id)) && (i.id = a(o), r++), t.add(i.id);
|
|
352
|
+
}
|
|
353
|
+
return S(e.nodes, (i) => {
|
|
354
|
+
const o = i.nodeType || "node";
|
|
355
|
+
n(i, o);
|
|
356
|
+
}, (i) => {
|
|
357
|
+
n(i, "col");
|
|
358
|
+
}), Array.isArray(e.dataSources) && e.dataSources.forEach((i) => n(i, "ds")), Array.isArray(e.reactions) && e.reactions.forEach((i) => n(i, "reaction")), { schema: e, fixedCount: r };
|
|
359
|
+
}
|
|
360
|
+
function ce(e) {
|
|
361
|
+
if (S(e.nodes, (t) => {
|
|
362
|
+
t.id = a(t.nodeType || "node");
|
|
363
|
+
}, (t) => {
|
|
364
|
+
t.id = a("col");
|
|
365
|
+
}), Array.isArray(e.dataSources)) {
|
|
366
|
+
const t = {};
|
|
367
|
+
e.dataSources.forEach((r) => {
|
|
368
|
+
const n = r.id;
|
|
369
|
+
r.id = a("ds"), t[n] = r.id;
|
|
370
|
+
}), g(e.nodes, (r) => {
|
|
371
|
+
r.dataSourceId && t[r.dataSourceId] && (r.dataSourceId = t[r.dataSourceId]);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
return Array.isArray(e.reactions) && e.reactions.forEach((t) => {
|
|
375
|
+
t.id = a("reaction");
|
|
376
|
+
}), e;
|
|
377
|
+
}
|
|
378
|
+
function S(e, t, r) {
|
|
379
|
+
Array.isArray(e) && e.forEach((n) => {
|
|
380
|
+
t(n), n.nodeType === "grid" && Array.isArray(n.columns) && n.columns.forEach((i) => {
|
|
381
|
+
r && r(i), S(i.children, t, r);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
function g(e, t) {
|
|
386
|
+
S(e, (r) => {
|
|
387
|
+
r.nodeType === "field" && t(r);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
function R(e) {
|
|
391
|
+
const t = [];
|
|
392
|
+
let r = !1;
|
|
393
|
+
if (!e || typeof e != "object")
|
|
394
|
+
return { schema: e, warnings: t, migrated: r };
|
|
395
|
+
(!e.config || typeof e.config != "object") && (e.config = {}, r = !0);
|
|
396
|
+
const n = !Object.prototype.hasOwnProperty.call(e.config, "suffixWidth");
|
|
397
|
+
return n && (e.config.suffixWidth = 60, r = !0), !e.dataSourceConfig || typeof e.dataSourceConfig != "object" ? (e.dataSourceConfig = { dictUrl: "" }, r = !0) : typeof e.dataSourceConfig.dictUrl != "string" && (e.dataSourceConfig.dictUrl = "", r = !0), Array.isArray(e.dataSources) && e.dataSources.forEach((i) => {
|
|
398
|
+
(i == null ? void 0 : i.type) === "api" && (typeof i.url != "string" && (i.url = "", r = !0), i.apiKey && !i.url && t.push(`API 数据源“${i.name || i.id || i.apiKey}”仍使用旧 apiKey“${i.apiKey}”,请重新配置接口地址`));
|
|
399
|
+
}), j(e).forEach((i) => {
|
|
400
|
+
const o = x(i.type), c = i.props && typeof i.props == "object" ? i.props : {}, y = { ...o, ...c };
|
|
401
|
+
JSON.stringify(y) !== JSON.stringify(c) && (i.props = y, r = !0), (!i.extensions || typeof i.extensions != "object") && (i.extensions = {}, r = !0), !i.extensions.suffix || typeof i.extensions.suffix != "object" ? (i.extensions.suffix = { enabled: !1, width: "" }, r = !0) : (i.extensions.suffix.enabled === void 0 && (i.extensions.suffix.enabled = !1, r = !0), (i.extensions.suffix.width === void 0 || n && i.extensions.suffix.width === 60) && (i.extensions.suffix.width = "", r = !0));
|
|
402
|
+
}), e.schemaVersion === A && (e.schemaVersion = u, r = !0, t.unshift(`schema 已从 ${A} 迁移到 ${u}`)), e.schemaVersion === u && (e.schemaVersion = f, r = !0, t.push(`schema 已从 ${u} 迁移到 ${f}`)), e.schemaVersion === f && (e.schemaVersion = p, r = !0, t.push(`schema 已从 ${f} 迁移到 ${p}`)), { schema: e, warnings: t, migrated: r };
|
|
403
|
+
}
|
|
404
|
+
function le(e) {
|
|
405
|
+
const t = { schema: null, errors: [], warnings: [], fixedCount: 0 };
|
|
406
|
+
let r;
|
|
407
|
+
if (typeof e == "string")
|
|
408
|
+
try {
|
|
409
|
+
r = JSON.parse(e);
|
|
410
|
+
} catch (y) {
|
|
411
|
+
return t.errors.push("JSON 解析失败:" + y.message), t;
|
|
412
|
+
}
|
|
413
|
+
else if (typeof e == "object" && e !== null)
|
|
414
|
+
r = JSON.parse(JSON.stringify(e));
|
|
415
|
+
else
|
|
416
|
+
return t.errors.push("导入内容无效"), t;
|
|
417
|
+
if (!r.schemaVersion)
|
|
418
|
+
return t.errors.push("缺少 schemaVersion"), t;
|
|
419
|
+
if (![p, f, u, A].includes(r.schemaVersion))
|
|
420
|
+
return t.errors.push(`schema 版本不支持:${r.schemaVersion}`), t;
|
|
421
|
+
const n = R(r);
|
|
422
|
+
t.warnings.push(...n.warnings);
|
|
423
|
+
const i = L(), o = {
|
|
424
|
+
schemaVersion: p,
|
|
425
|
+
meta: { ...i.meta, ...r.meta || {} },
|
|
426
|
+
config: { ...i.config, ...r.config || {} },
|
|
427
|
+
dataSourceConfig: { ...i.dataSourceConfig, ...r.dataSourceConfig || {} },
|
|
428
|
+
dataSources: Array.isArray(r.dataSources) ? r.dataSources : [],
|
|
429
|
+
reactions: Array.isArray(r.reactions) ? r.reactions : [],
|
|
430
|
+
nodes: Array.isArray(r.nodes) ? r.nodes : []
|
|
431
|
+
}, { fixedCount: c } = k(o);
|
|
432
|
+
return t.fixedCount = c, c > 0 && t.warnings.push(`自动修复了 ${c} 个重复 id`), w(o), t.schema = o, t;
|
|
433
|
+
}
|
|
434
|
+
function de(e, t) {
|
|
435
|
+
return !e || !t ? null : Y(e.nodes, t);
|
|
436
|
+
}
|
|
437
|
+
function Y(e, t) {
|
|
438
|
+
if (!Array.isArray(e))
|
|
439
|
+
return null;
|
|
440
|
+
for (const r of e) {
|
|
441
|
+
if (r.id === t)
|
|
442
|
+
return r;
|
|
443
|
+
if (r.nodeType === "grid" && Array.isArray(r.columns))
|
|
444
|
+
for (const n of r.columns) {
|
|
445
|
+
if (n.id === t)
|
|
446
|
+
return n;
|
|
447
|
+
const i = Y(n.children, t);
|
|
448
|
+
if (i)
|
|
449
|
+
return i;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
function ue(e) {
|
|
455
|
+
const t = [];
|
|
456
|
+
return g(e.nodes, (r) => {
|
|
457
|
+
r.prop && t.push(r.prop);
|
|
458
|
+
}), t;
|
|
459
|
+
}
|
|
460
|
+
function j(e) {
|
|
461
|
+
const t = [];
|
|
462
|
+
return g(e.nodes, (r) => {
|
|
463
|
+
t.push(r);
|
|
464
|
+
}), t;
|
|
465
|
+
}
|
|
466
|
+
function fe(e, t) {
|
|
467
|
+
return !e || !t ? !1 : P(e.nodes, t);
|
|
468
|
+
}
|
|
469
|
+
function P(e, t) {
|
|
470
|
+
if (!Array.isArray(e))
|
|
471
|
+
return !1;
|
|
472
|
+
const r = e.findIndex((n) => n.id === t);
|
|
473
|
+
if (r !== -1)
|
|
474
|
+
return e.splice(r, 1), !0;
|
|
475
|
+
for (const n of e)
|
|
476
|
+
if (n.nodeType === "grid" && Array.isArray(n.columns)) {
|
|
477
|
+
for (const i of n.columns)
|
|
478
|
+
if (P(i.children, t))
|
|
479
|
+
return !0;
|
|
480
|
+
}
|
|
481
|
+
return !1;
|
|
482
|
+
}
|
|
483
|
+
const s = {
|
|
484
|
+
province: "province",
|
|
485
|
+
city: "city",
|
|
486
|
+
county: "county",
|
|
487
|
+
detailAddress: "detailAddress"
|
|
488
|
+
}, m = {
|
|
489
|
+
parentValue: "parentValue",
|
|
490
|
+
childValue: "childValue"
|
|
491
|
+
}, V = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
492
|
+
function l(e, t) {
|
|
493
|
+
const r = typeof e == "string" ? e.trim() : "";
|
|
494
|
+
return r && !V.has(r) ? r : t;
|
|
495
|
+
}
|
|
496
|
+
function H(e = {}) {
|
|
497
|
+
const t = e.props || e;
|
|
498
|
+
return {
|
|
499
|
+
province: l(t.provinceProp, s.province),
|
|
500
|
+
city: l(t.cityProp, s.city),
|
|
501
|
+
county: l(t.countyProp, s.county),
|
|
502
|
+
detailAddress: l(t.detailAddressProp, s.detailAddress)
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function $(e = {}) {
|
|
506
|
+
const t = e.props || e;
|
|
507
|
+
return {
|
|
508
|
+
parentValue: l(t.parentValueProp, m.parentValue),
|
|
509
|
+
childValue: l(t.childValueProp, m.childValue)
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function d(e, t, r) {
|
|
513
|
+
return !e || typeof e != "object" ? "" : e[t] !== void 0 && e[t] !== null ? e[t] : t !== r && e[r] !== void 0 && e[r] !== null ? e[r] : "";
|
|
514
|
+
}
|
|
515
|
+
function pe(e, t) {
|
|
516
|
+
const r = t && typeof t == "object" && !Array.isArray(t) ? t : {}, n = H(e);
|
|
517
|
+
return {
|
|
518
|
+
[n.province]: d(r, n.province, s.province),
|
|
519
|
+
[n.city]: d(r, n.city, s.city),
|
|
520
|
+
[n.county]: d(r, n.county, s.county),
|
|
521
|
+
[n.detailAddress]: d(r, n.detailAddress, s.detailAddress)
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
function ye(e, t) {
|
|
525
|
+
if (!Array.isArray(t))
|
|
526
|
+
return [];
|
|
527
|
+
const r = $(e);
|
|
528
|
+
return t.map((n) => ({
|
|
529
|
+
[r.parentValue]: d(n, r.parentValue, m.parentValue),
|
|
530
|
+
[r.childValue]: d(n, r.childValue, m.childValue)
|
|
531
|
+
}));
|
|
532
|
+
}
|
|
533
|
+
function me(e) {
|
|
534
|
+
return V.has(typeof e == "string" ? e.trim() : "");
|
|
535
|
+
}
|
|
536
|
+
export {
|
|
537
|
+
J as A,
|
|
538
|
+
u as B,
|
|
539
|
+
ae as C,
|
|
540
|
+
q as D,
|
|
541
|
+
G as E,
|
|
542
|
+
f as F,
|
|
543
|
+
T as G,
|
|
544
|
+
h as H,
|
|
545
|
+
z as I,
|
|
546
|
+
_ as J,
|
|
547
|
+
B as K,
|
|
548
|
+
A as L,
|
|
549
|
+
x as M,
|
|
550
|
+
K as N,
|
|
551
|
+
O,
|
|
552
|
+
se as P,
|
|
553
|
+
k as Q,
|
|
554
|
+
ce as R,
|
|
555
|
+
p as S,
|
|
556
|
+
ue as T,
|
|
557
|
+
N as U,
|
|
558
|
+
X as V,
|
|
559
|
+
s as W,
|
|
560
|
+
m as X,
|
|
561
|
+
l as Y,
|
|
562
|
+
F as a,
|
|
563
|
+
M as b,
|
|
564
|
+
L as c,
|
|
565
|
+
v as d,
|
|
566
|
+
oe as e,
|
|
567
|
+
$ as f,
|
|
568
|
+
H as g,
|
|
569
|
+
j as h,
|
|
570
|
+
pe as i,
|
|
571
|
+
ye as j,
|
|
572
|
+
de as k,
|
|
573
|
+
w as l,
|
|
574
|
+
R as m,
|
|
575
|
+
le as n,
|
|
576
|
+
a as o,
|
|
577
|
+
U as p,
|
|
578
|
+
re as q,
|
|
579
|
+
fe as r,
|
|
580
|
+
Z as s,
|
|
581
|
+
ee as t,
|
|
582
|
+
te as u,
|
|
583
|
+
ie as v,
|
|
584
|
+
ne as w,
|
|
585
|
+
W as x,
|
|
586
|
+
me as y,
|
|
587
|
+
Q as z
|
|
588
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const o = [
|
|
2
|
+
"/form-datasource/"
|
|
3
|
+
];
|
|
4
|
+
function c(t, e = {}) {
|
|
5
|
+
const u = e.required === !0, l = Array.isArray(e.allowedPrefixes) ? e.allowedPrefixes : o, a = typeof t == "string" ? t.trim() : "";
|
|
6
|
+
if (!a)
|
|
7
|
+
return u ? r("接口地址不能为空") : { valid: !0, value: "", message: "" };
|
|
8
|
+
if (!a.startsWith("/") || a.includes("//"))
|
|
9
|
+
return r("接口地址必须以单个 / 开头");
|
|
10
|
+
if (a.includes("://"))
|
|
11
|
+
return r("接口地址不能使用绝对协议地址");
|
|
12
|
+
const d = f(a);
|
|
13
|
+
if (!d.valid)
|
|
14
|
+
return r("接口地址包含无效的 URL 编码");
|
|
15
|
+
const n = d.value;
|
|
16
|
+
if (n.includes("//"))
|
|
17
|
+
return r("接口地址不能包含连续的 //");
|
|
18
|
+
if (n.includes("\\"))
|
|
19
|
+
return r("接口地址不能包含反斜杠");
|
|
20
|
+
if (/[\u0000-\u001f\u007f]/.test(n))
|
|
21
|
+
return r("接口地址不能包含控制字符");
|
|
22
|
+
if (n.includes("?") || n.includes("#"))
|
|
23
|
+
return r("接口地址不能包含 query 或 hash,请通过请求参数传值");
|
|
24
|
+
if (n.split("/").some((i) => i === ".."))
|
|
25
|
+
return r("接口地址不能包含 .. 路径段");
|
|
26
|
+
const s = l.filter((i) => typeof i == "string").map((i) => i.trim()).filter(Boolean);
|
|
27
|
+
return s.length > 0 && !s.some((i) => a.startsWith(i) && n.startsWith(i)) ? r(`接口地址必须使用允许的前缀:${s.join("、")}`) : { valid: !0, value: a, message: "" };
|
|
28
|
+
}
|
|
29
|
+
function v(t, e = {}) {
|
|
30
|
+
const u = c(t, { ...e, required: !0 });
|
|
31
|
+
if (!u.valid)
|
|
32
|
+
throw new Error(u.message);
|
|
33
|
+
return u.value;
|
|
34
|
+
}
|
|
35
|
+
function r(t) {
|
|
36
|
+
return { valid: !1, value: "", message: t };
|
|
37
|
+
}
|
|
38
|
+
function f(t) {
|
|
39
|
+
let e = t;
|
|
40
|
+
try {
|
|
41
|
+
for (let u = 0; u < 5; u++) {
|
|
42
|
+
const l = decodeURIComponent(e);
|
|
43
|
+
if (l === e)
|
|
44
|
+
return { valid: !0, value: e };
|
|
45
|
+
e = l;
|
|
46
|
+
}
|
|
47
|
+
return decodeURIComponent(e) === e ? { valid: !0, value: e } : { valid: !1, value: "" };
|
|
48
|
+
} catch {
|
|
49
|
+
return { valid: !1, value: "" };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
v as a,
|
|
54
|
+
c as v
|
|
55
|
+
};
|