dynamicformdjx 0.2.0 → 0.3.1
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/README.md +228 -5
- package/dist/hooks/useDyForm.d.ts +14 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +210 -169
- package/dist/naiveUi/NaiDynamicForm.d.ts +66 -0
- package/dist/naiveUi/hooks/rOld.d.ts +1 -0
- package/dist/naiveUi/hooks/renderForm.d.ts +36 -0
- package/dist/naiveUi/index.cjs +1 -1
- package/dist/naiveUi/index.d.ts +7 -4
- package/dist/naiveUi/index.mjs +448 -166
- package/dist/types/form.d.ts +34 -0
- package/dist/types/index.d.ts +7 -1
- package/package.json +3 -3
package/dist/naiveUi/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { NInput as
|
|
3
|
-
import { t as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as V, ref as R, watch as O, toRaw as S, createVNode as r, createTextVNode as C, Fragment as F, nextTick as $, isVNode as D, computed as I, mergeProps as M, h as p } from "vue";
|
|
2
|
+
import { NInput as N, NButton as b, NForm as U, NGrid as G, NFormItemGridItem as B, NFormItem as H, NSelect as q, NPopselect as _, NTreeSelect as E, NRadioGroup as z, NRadio as K, NRadioButton as J, NCheckboxGroup as Q, NSpace as W, NCheckbox as X, NSwitch as Y, NDatePicker as Z, NTimePicker as ee } from "naive-ui";
|
|
3
|
+
import { t as A, r as j, f as P, p as le, s as te } from "../index-BqKRE4oH.js";
|
|
4
|
+
const oe = /* @__PURE__ */ V({
|
|
5
5
|
name: "NaiDynamicInput",
|
|
6
6
|
props: {
|
|
7
7
|
size: {
|
|
@@ -34,151 +34,151 @@ const _ = /* @__PURE__ */ T({
|
|
|
34
34
|
emits: {
|
|
35
35
|
"update:modelValue": (e) => !0,
|
|
36
36
|
onReset: () => !0,
|
|
37
|
-
onMerge: (e,
|
|
37
|
+
onMerge: (e, o) => !0
|
|
38
38
|
},
|
|
39
39
|
setup(e, {
|
|
40
|
-
emit:
|
|
41
|
-
expose:
|
|
40
|
+
emit: o,
|
|
41
|
+
expose: d
|
|
42
42
|
}) {
|
|
43
|
-
const
|
|
43
|
+
const t = {
|
|
44
44
|
resetTxt: "重置",
|
|
45
45
|
newTxt: "添加项",
|
|
46
46
|
mergeTxt: "合并",
|
|
47
47
|
...e.btnConfigs
|
|
48
|
-
},
|
|
48
|
+
}, s = {
|
|
49
49
|
hideReset: !1,
|
|
50
50
|
maxHeight: "300px",
|
|
51
51
|
autoScroll: !0,
|
|
52
52
|
allowFilter: !0,
|
|
53
53
|
...e.configs
|
|
54
|
-
},
|
|
54
|
+
}, c = {
|
|
55
55
|
arraySplitSymbol: ",",
|
|
56
56
|
...e.dyListConfigs
|
|
57
|
-
},
|
|
58
|
-
return
|
|
57
|
+
}, y = e.size, i = R(A(e.modelValue, e.randomFun, c.arraySplitSymbol)), m = R(null);
|
|
58
|
+
return O(i, (u) => {
|
|
59
59
|
if (!e.isController) return;
|
|
60
|
-
const v =
|
|
61
|
-
|
|
60
|
+
const v = j(u, c.arraySplitSymbol);
|
|
61
|
+
o("update:modelValue", v), o("onMerge", v, S(i.value));
|
|
62
62
|
}, {
|
|
63
63
|
deep: !0
|
|
64
|
-
}),
|
|
65
|
-
onSet: (
|
|
66
|
-
|
|
64
|
+
}), d({
|
|
65
|
+
onSet: (u) => {
|
|
66
|
+
i.value = A(u ?? e.modelValue, e.randomFun, c.arraySplitSymbol);
|
|
67
67
|
},
|
|
68
|
-
getResult: (
|
|
69
|
-
}), () =>
|
|
70
|
-
class: e.dyCls ?? `dynamicForm ${
|
|
71
|
-
}, [
|
|
72
|
-
class:
|
|
73
|
-
ref:
|
|
68
|
+
getResult: (u = "res") => u === "ori" ? S(i.value) : j(i.value, c.arraySplitSymbol)
|
|
69
|
+
}), () => r("div", {
|
|
70
|
+
class: e.dyCls ?? `dynamicForm ${y}`
|
|
71
|
+
}, [r("div", {
|
|
72
|
+
class: `dyFormList ${i.value.length ? "" : "noList"}`,
|
|
73
|
+
ref: m,
|
|
74
74
|
style: {
|
|
75
|
-
maxHeight:
|
|
75
|
+
maxHeight: s.maxHeight
|
|
76
76
|
}
|
|
77
|
-
}, [
|
|
77
|
+
}, [i.value.map((u, v, l) => r("div", {
|
|
78
78
|
class: "dItem",
|
|
79
|
-
key:
|
|
80
|
-
}, [
|
|
79
|
+
key: u.rId
|
|
80
|
+
}, [r("div", {
|
|
81
81
|
class: "input"
|
|
82
|
-
}, [
|
|
83
|
-
size:
|
|
84
|
-
value:
|
|
82
|
+
}, [r(N, {
|
|
83
|
+
size: y,
|
|
84
|
+
value: u.key,
|
|
85
85
|
class: "key",
|
|
86
|
-
onInput: (
|
|
87
|
-
|
|
86
|
+
onInput: (a) => {
|
|
87
|
+
u.key = a;
|
|
88
88
|
}
|
|
89
|
-
}, null),
|
|
90
|
-
size:
|
|
91
|
-
value:
|
|
89
|
+
}, null), C(":"), r(N, {
|
|
90
|
+
size: y,
|
|
91
|
+
value: u.value,
|
|
92
92
|
class: "value",
|
|
93
|
-
onInput: (
|
|
94
|
-
|
|
93
|
+
onInput: (a) => {
|
|
94
|
+
s.allowFilter && u.isNumber ? u.value = P(a, u.isArray, c.arraySplitSymbol) : u.value = a;
|
|
95
95
|
}
|
|
96
96
|
}, {
|
|
97
|
-
prefix: () =>
|
|
98
|
-
type:
|
|
97
|
+
prefix: () => r(F, null, [r(b, {
|
|
98
|
+
type: u.isArray ? "success" : "default",
|
|
99
99
|
size: "tiny",
|
|
100
100
|
onClick: () => {
|
|
101
|
-
|
|
101
|
+
u.isArray = !u.isArray;
|
|
102
102
|
}
|
|
103
103
|
}, {
|
|
104
|
-
default: () => [
|
|
105
|
-
}),
|
|
106
|
-
type:
|
|
104
|
+
default: () => [C("Array")]
|
|
105
|
+
}), C(" "), r(b, {
|
|
106
|
+
type: u.isNumber ? "success" : "default",
|
|
107
107
|
size: "tiny",
|
|
108
108
|
onClick: () => {
|
|
109
|
-
|
|
109
|
+
u.isNumber = !u.isNumber;
|
|
110
110
|
}
|
|
111
111
|
}, {
|
|
112
|
-
default: () => [
|
|
112
|
+
default: () => [C("Number")]
|
|
113
113
|
})])
|
|
114
|
-
})]),
|
|
114
|
+
})]), r("div", {
|
|
115
115
|
class: "btn"
|
|
116
|
-
}, [
|
|
116
|
+
}, [r(b, {
|
|
117
117
|
type: "success",
|
|
118
|
-
size:
|
|
119
|
-
disabled: v !==
|
|
118
|
+
size: y,
|
|
119
|
+
disabled: v !== l.length - 1,
|
|
120
120
|
onClick: () => {
|
|
121
|
-
|
|
121
|
+
i.value.push({
|
|
122
122
|
rId: e.randomFun(),
|
|
123
123
|
key: "",
|
|
124
124
|
value: ""
|
|
125
|
-
}),
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
top:
|
|
125
|
+
}), s.autoScroll && $(() => {
|
|
126
|
+
const a = m.value;
|
|
127
|
+
a?.scrollTo({
|
|
128
|
+
top: a.scrollHeight,
|
|
129
129
|
behavior: "smooth"
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
}, {
|
|
134
|
-
default: () => [
|
|
135
|
-
}),
|
|
136
|
-
size:
|
|
134
|
+
default: () => [C("+")]
|
|
135
|
+
}), r(b, {
|
|
136
|
+
size: y,
|
|
137
137
|
type: "error",
|
|
138
138
|
onClick: () => {
|
|
139
|
-
|
|
139
|
+
i.value = i.value.filter((a) => a.rId !== u.rId);
|
|
140
140
|
}
|
|
141
141
|
}, {
|
|
142
|
-
default: () => [
|
|
143
|
-
})])]))]),
|
|
144
|
-
class:
|
|
145
|
-
}, [!
|
|
146
|
-
size:
|
|
142
|
+
default: () => [C("-")]
|
|
143
|
+
})])]))]), r("div", {
|
|
144
|
+
class: `control ${i.value.length ? "" : "noList"}`
|
|
145
|
+
}, [!i.value.length && r(b, {
|
|
146
|
+
size: y,
|
|
147
147
|
type: "success",
|
|
148
148
|
onClick: () => {
|
|
149
|
-
|
|
149
|
+
i.value.push({
|
|
150
150
|
rId: e.randomFun(),
|
|
151
151
|
key: "",
|
|
152
152
|
value: ""
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
}, {
|
|
156
|
-
default: () => [
|
|
157
|
-
}), !e.isController &&
|
|
158
|
-
size:
|
|
156
|
+
default: () => [t.newTxt]
|
|
157
|
+
}), !e.isController && r(F, null, [!s.hideReset && r(b, {
|
|
158
|
+
size: y,
|
|
159
159
|
type: "default",
|
|
160
160
|
onClick: () => {
|
|
161
|
-
|
|
161
|
+
i.value = A(e.modelValue, e.randomFun, c.arraySplitSymbol), o("onReset");
|
|
162
162
|
}
|
|
163
163
|
}, {
|
|
164
|
-
default: () => [
|
|
165
|
-
}),
|
|
166
|
-
size:
|
|
164
|
+
default: () => [t.resetTxt]
|
|
165
|
+
}), r(b, {
|
|
166
|
+
size: y,
|
|
167
167
|
type: "info",
|
|
168
168
|
onClick: () => {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
169
|
+
i.value.sort((v, l) => +v.rId - +l.rId);
|
|
170
|
+
const u = j(i.value, c.arraySplitSymbol);
|
|
171
|
+
o("update:modelValue", u), o("onMerge", u, S(i.value)), i.value = A(u, e.randomFun, c.arraySplitSymbol);
|
|
172
172
|
}
|
|
173
173
|
}, {
|
|
174
|
-
default: () => [
|
|
174
|
+
default: () => [t.mergeTxt]
|
|
175
175
|
})])])]);
|
|
176
176
|
}
|
|
177
177
|
});
|
|
178
|
-
function
|
|
179
|
-
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !
|
|
178
|
+
function ae(e) {
|
|
179
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !D(e);
|
|
180
180
|
}
|
|
181
|
-
const
|
|
181
|
+
const se = /* @__PURE__ */ V({
|
|
182
182
|
name: "NaiveUiDynamicCascadeInput",
|
|
183
183
|
props: {
|
|
184
184
|
modelValue: {
|
|
@@ -217,18 +217,18 @@ const q = /* @__PURE__ */ T({
|
|
|
217
217
|
emits: {
|
|
218
218
|
"update:modelValue": (e) => !0,
|
|
219
219
|
onReset: () => !0,
|
|
220
|
-
onMerge: (e,
|
|
220
|
+
onMerge: (e, o) => !0
|
|
221
221
|
},
|
|
222
222
|
setup(e, {
|
|
223
|
-
emit:
|
|
224
|
-
expose:
|
|
223
|
+
emit: o,
|
|
224
|
+
expose: d
|
|
225
225
|
}) {
|
|
226
|
-
const
|
|
226
|
+
const t = {
|
|
227
227
|
resetTxt: "重置",
|
|
228
228
|
newTxt: "添加项",
|
|
229
229
|
mergeTxt: "合并",
|
|
230
230
|
...e.btnConfigs
|
|
231
|
-
},
|
|
231
|
+
}, s = {
|
|
232
232
|
hideReset: !1,
|
|
233
233
|
maxHeight: "600px",
|
|
234
234
|
allowFilter: !0,
|
|
@@ -237,166 +237,448 @@ const q = /* @__PURE__ */ T({
|
|
|
237
237
|
retractLen: 0,
|
|
238
238
|
borderColors: [],
|
|
239
239
|
...e.configs
|
|
240
|
-
},
|
|
240
|
+
}, c = {
|
|
241
241
|
arraySplitSymbol: ",",
|
|
242
242
|
...e.dyListConfigs
|
|
243
|
-
},
|
|
244
|
-
let
|
|
245
|
-
const
|
|
246
|
-
return
|
|
247
|
-
rId: e.randomFun(
|
|
248
|
-
key:
|
|
249
|
-
value: Object.prototype.toString.call(
|
|
250
|
-
isArray:
|
|
251
|
-
isNumber:
|
|
243
|
+
}, y = (l) => ["string", "number"].includes(l), i = (l) => Object.keys(l).map((a, f) => {
|
|
244
|
+
let n = l[a];
|
|
245
|
+
const h = Array.isArray(n), T = h ? n.every((x) => typeof x == "number") : typeof n == "number", k = n === null;
|
|
246
|
+
return y(typeof n) && (n = l[a]), k && (n = ""), {
|
|
247
|
+
rId: e.randomFun(f),
|
|
248
|
+
key: a,
|
|
249
|
+
value: Object.prototype.toString.call(n) === "[object Object]" ? i(l[a]) : h ? n.join(c.arraySplitSymbol) : n,
|
|
250
|
+
isArray: h || void 0,
|
|
251
|
+
isNumber: T || void 0
|
|
252
252
|
};
|
|
253
|
-
}),
|
|
254
|
-
const
|
|
255
|
-
return
|
|
256
|
-
}, {}),
|
|
257
|
-
class: [`depth-${
|
|
253
|
+
}), m = (l) => l.reduce((a, f) => {
|
|
254
|
+
const n = f.value;
|
|
255
|
+
return f.key.trim().length && (a[f.key] = Array.isArray(n) ? m(n) : le(f.value, f.isArray, f.isNumber, c.arraySplitSymbol)), a;
|
|
256
|
+
}, {}), u = R(i(e.modelValue)), v = (l, a = 1, f) => r("div", {
|
|
257
|
+
class: [`depth-${a}`, s.showBorder ? "" : "no-border", s.showPad ? "" : "no-pad"],
|
|
258
258
|
style: {
|
|
259
|
-
"--depth":
|
|
260
|
-
["--c" + [
|
|
259
|
+
"--depth": a,
|
|
260
|
+
["--c" + [a]]: te(s.borderColors, a)
|
|
261
261
|
}
|
|
262
|
-
}, [
|
|
263
|
-
const
|
|
264
|
-
return
|
|
262
|
+
}, [l.map((n, h, T) => {
|
|
263
|
+
const k = Array.isArray(n.value), x = y(typeof n.value);
|
|
264
|
+
return r("div", {
|
|
265
265
|
class: "dItem",
|
|
266
|
-
key:
|
|
266
|
+
key: n.rId,
|
|
267
267
|
style: {
|
|
268
|
-
marginLeft:
|
|
268
|
+
marginLeft: a > 1 ? `${a * s.retractLen}px` : "0"
|
|
269
269
|
}
|
|
270
|
-
}, [
|
|
270
|
+
}, [r("div", {
|
|
271
271
|
class: "input"
|
|
272
|
-
}, [!
|
|
273
|
-
value:
|
|
272
|
+
}, [!k && r(F, null, [r(N, {
|
|
273
|
+
value: n.key,
|
|
274
274
|
class: "key",
|
|
275
|
-
onInput: (
|
|
276
|
-
}, null),
|
|
277
|
-
class: `value ${
|
|
278
|
-
value: x ?
|
|
279
|
-
onInput: (
|
|
280
|
-
if (
|
|
281
|
-
|
|
275
|
+
onInput: (g) => n.key = g
|
|
276
|
+
}, null), C(":")]), r(N, {
|
|
277
|
+
class: `value ${k ? "isKey" : ""}`,
|
|
278
|
+
value: x ? n.value : n.key,
|
|
279
|
+
onInput: (g) => {
|
|
280
|
+
if (k) {
|
|
281
|
+
n.key = g;
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
|
|
284
|
+
s.allowFilter && n.isNumber ? n.value = P(g, n.isArray, c.arraySplitSymbol) : n.value = g;
|
|
285
285
|
}
|
|
286
286
|
}, {
|
|
287
|
-
prefix: Array.isArray(
|
|
288
|
-
type:
|
|
287
|
+
prefix: Array.isArray(n.value) ? void 0 : () => r(F, null, [r(b, {
|
|
288
|
+
type: n.isArray ? "success" : "default",
|
|
289
289
|
size: "tiny",
|
|
290
290
|
onClick: () => {
|
|
291
|
-
|
|
291
|
+
n.isArray = !n.isArray;
|
|
292
292
|
}
|
|
293
293
|
}, {
|
|
294
|
-
default: () => [
|
|
295
|
-
}),
|
|
296
|
-
type:
|
|
294
|
+
default: () => [C("Array")]
|
|
295
|
+
}), C(" "), r(b, {
|
|
296
|
+
type: n.isNumber ? "success" : "default",
|
|
297
297
|
size: "tiny",
|
|
298
298
|
onClick: () => {
|
|
299
|
-
|
|
299
|
+
n.isNumber = !n.isNumber;
|
|
300
300
|
}
|
|
301
301
|
}, {
|
|
302
|
-
default: () => [
|
|
302
|
+
default: () => [C("Number")]
|
|
303
303
|
})]),
|
|
304
304
|
suffix: () => {
|
|
305
|
-
let
|
|
306
|
-
return
|
|
305
|
+
let g;
|
|
306
|
+
return a < e.depth ? !k && r(b, {
|
|
307
307
|
type: "success",
|
|
308
308
|
size: "tiny",
|
|
309
309
|
onClick: () => {
|
|
310
|
-
x && (
|
|
310
|
+
x && (n.value = [], n.isArray = void 0), n.value.push({
|
|
311
311
|
rId: e.randomFun(),
|
|
312
312
|
key: "",
|
|
313
313
|
value: ""
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
|
-
},
|
|
317
|
-
default: () => [
|
|
316
|
+
}, ae(g = e.newChildTxt(n)) ? g : {
|
|
317
|
+
default: () => [g]
|
|
318
318
|
}) : null;
|
|
319
319
|
}
|
|
320
|
-
})]),
|
|
320
|
+
})]), r("div", {
|
|
321
321
|
class: "btn"
|
|
322
|
-
}, [
|
|
322
|
+
}, [r(b, {
|
|
323
323
|
type: "success",
|
|
324
|
-
disabled:
|
|
324
|
+
disabled: h !== T.length - 1,
|
|
325
325
|
onClick: () => {
|
|
326
|
-
|
|
326
|
+
l.push({
|
|
327
327
|
rId: e.randomFun(),
|
|
328
328
|
key: "",
|
|
329
329
|
value: ""
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
}, {
|
|
333
|
-
default: () => [
|
|
334
|
-
}),
|
|
333
|
+
default: () => [C("+")]
|
|
334
|
+
}), r(b, {
|
|
335
335
|
type: "error",
|
|
336
336
|
onClick: () => {
|
|
337
|
-
if (
|
|
338
|
-
if (
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
...
|
|
337
|
+
if (l.splice(h, 1), l.length < 1) {
|
|
338
|
+
if (f === void 0) return m([]);
|
|
339
|
+
const g = u.value.findIndex((L) => L.rId === f?.rId);
|
|
340
|
+
a < 1 ? u.value.splice(g, 1, {
|
|
341
|
+
...f,
|
|
342
342
|
value: ""
|
|
343
|
-
}) :
|
|
343
|
+
}) : f.value = "";
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}, {
|
|
347
|
-
default: () => [
|
|
348
|
-
})]), Array.isArray(
|
|
347
|
+
default: () => [C("-")]
|
|
348
|
+
})]), Array.isArray(n.value) && v(n.value, a + 1, n)]);
|
|
349
349
|
})]);
|
|
350
|
-
return
|
|
350
|
+
return O(u, (l) => {
|
|
351
351
|
if (!e.isController) return;
|
|
352
|
-
const
|
|
353
|
-
|
|
352
|
+
const a = m(l);
|
|
353
|
+
o("update:modelValue", a), o("onMerge", a, S(u.value));
|
|
354
354
|
}, {
|
|
355
355
|
deep: !0
|
|
356
|
-
}),
|
|
357
|
-
onSet: (
|
|
358
|
-
|
|
356
|
+
}), d({
|
|
357
|
+
onSet: (l) => {
|
|
358
|
+
u.value = i(l ?? e.modelValue);
|
|
359
359
|
},
|
|
360
|
-
getResult: (
|
|
361
|
-
}), () =>
|
|
360
|
+
getResult: (l = "res") => l === "ori" ? S(u.value) : m(u.value)
|
|
361
|
+
}), () => r("div", {
|
|
362
362
|
class: e.dyCls ?? "dynamicCascadeForm"
|
|
363
|
-
}, [
|
|
363
|
+
}, [r("div", {
|
|
364
364
|
class: "dyFormList",
|
|
365
365
|
style: {
|
|
366
|
-
maxHeight:
|
|
366
|
+
maxHeight: s.maxHeight
|
|
367
367
|
}
|
|
368
|
-
}, [v(
|
|
368
|
+
}, [v(u.value)]), r("div", {
|
|
369
369
|
class: "control"
|
|
370
|
-
}, [!
|
|
370
|
+
}, [!u.value.length && r(b, {
|
|
371
371
|
type: "success",
|
|
372
372
|
onClick: () => {
|
|
373
|
-
|
|
373
|
+
u.value.push({
|
|
374
374
|
rId: e.randomFun(),
|
|
375
375
|
key: "",
|
|
376
376
|
value: ""
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
}, {
|
|
380
|
-
default: () => [
|
|
381
|
-
}), !e.isController &&
|
|
380
|
+
default: () => [t.newTxt]
|
|
381
|
+
}), !e.isController && r(F, null, [!s.hideReset && r(b, {
|
|
382
382
|
type: "default",
|
|
383
383
|
onClick: () => {
|
|
384
|
-
|
|
384
|
+
u.value = i(e.modelValue), o("onReset");
|
|
385
385
|
}
|
|
386
386
|
}, {
|
|
387
|
-
default: () => [
|
|
388
|
-
}),
|
|
387
|
+
default: () => [t.resetTxt]
|
|
388
|
+
}), r(b, {
|
|
389
389
|
type: "info",
|
|
390
390
|
onClick: () => {
|
|
391
|
-
const
|
|
392
|
-
|
|
391
|
+
const l = m(u.value);
|
|
392
|
+
o("update:modelValue", l), o("onMerge", l, S(u.value)), u.value = i(l);
|
|
393
393
|
}
|
|
394
394
|
}, {
|
|
395
|
-
default: () => [
|
|
395
|
+
default: () => [t.mergeTxt]
|
|
396
396
|
})])])]);
|
|
397
397
|
}
|
|
398
|
+
}), ie = /* @__PURE__ */ V({
|
|
399
|
+
name: "NaiDynamicForm",
|
|
400
|
+
props: {
|
|
401
|
+
formConfig: {
|
|
402
|
+
type: Object,
|
|
403
|
+
default: () => ({
|
|
404
|
+
labelPlacement: "left",
|
|
405
|
+
size: "medium"
|
|
406
|
+
})
|
|
407
|
+
},
|
|
408
|
+
gridConfig: {
|
|
409
|
+
type: Object,
|
|
410
|
+
default: () => ({
|
|
411
|
+
responsive: "screen",
|
|
412
|
+
cols: "xs:1 s:2 m:3 l:3 xl:4 2xl:4",
|
|
413
|
+
xGap: 10
|
|
414
|
+
})
|
|
415
|
+
},
|
|
416
|
+
rules: {
|
|
417
|
+
type: Object
|
|
418
|
+
},
|
|
419
|
+
preset: {
|
|
420
|
+
type: String,
|
|
421
|
+
default: "fullRow",
|
|
422
|
+
validator: (e) => ["fullRow", "grid"].includes(e) ? !0 : (console.error("preset value must be `fullRow` or `grid`, the default value is `fullRow`"), !1)
|
|
423
|
+
},
|
|
424
|
+
items: {
|
|
425
|
+
type: Array,
|
|
426
|
+
require: !0
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
setup(e, {
|
|
430
|
+
emit: o,
|
|
431
|
+
expose: d
|
|
432
|
+
}) {
|
|
433
|
+
const t = R(null), s = I(() => (e.items ?? []).filter((v) => !v.hidden)), c = I(() => s.value ? s.value.reduce((v, l) => (v[l.key] = l.value.value, v), {}) : {}), y = I(() => ({
|
|
434
|
+
...s.value?.reduce((l, a) => {
|
|
435
|
+
let f = a.rule;
|
|
436
|
+
return a.required && !a.rule && (f = {
|
|
437
|
+
required: !0,
|
|
438
|
+
message: `${a.label}不能为空`,
|
|
439
|
+
trigger: ["blur"]
|
|
440
|
+
}), l[a.key] = f, l;
|
|
441
|
+
}, {}),
|
|
442
|
+
...e.rules
|
|
443
|
+
})), i = I(() => [...s.value].sort((l, a) => {
|
|
444
|
+
const f = l.sort ?? 1 / 0, n = a.sort ?? 1 / 0;
|
|
445
|
+
return Number(f) - Number(n);
|
|
446
|
+
}));
|
|
447
|
+
function m(v = null) {
|
|
448
|
+
s.value && s.value.forEach((l) => {
|
|
449
|
+
l.reset ? l.reset(l) : l.value.value = v;
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function u() {
|
|
453
|
+
return new Promise((v, l) => {
|
|
454
|
+
t.value?.validate((a) => {
|
|
455
|
+
a ? l(a) : v(c.value);
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (d({
|
|
460
|
+
reset: m,
|
|
461
|
+
validator: u,
|
|
462
|
+
getResult: (v = "res") => v === "ori" ? s.value : c.value
|
|
463
|
+
}), !e.items) throw new Error("prop items must be not null");
|
|
464
|
+
return () => r("div", {
|
|
465
|
+
class: "naiDynamicForm"
|
|
466
|
+
}, [r(U, M({
|
|
467
|
+
ref: t
|
|
468
|
+
}, e.formConfig, {
|
|
469
|
+
model: c.value,
|
|
470
|
+
rules: y.value
|
|
471
|
+
}), {
|
|
472
|
+
default() {
|
|
473
|
+
const v = i.value;
|
|
474
|
+
return e.preset === "grid" ? p(G, {
|
|
475
|
+
...e.gridConfig
|
|
476
|
+
}, {
|
|
477
|
+
default: () => v?.map((l) => p(B, {
|
|
478
|
+
label: l.label,
|
|
479
|
+
path: l.path || l.key
|
|
480
|
+
}, {
|
|
481
|
+
default: w(l)
|
|
482
|
+
}))
|
|
483
|
+
}) : v?.map((l) => p(H, {
|
|
484
|
+
label: l.label,
|
|
485
|
+
path: l.path || l.key
|
|
486
|
+
}, {
|
|
487
|
+
default: w(l)
|
|
488
|
+
}));
|
|
489
|
+
}
|
|
490
|
+
})]);
|
|
491
|
+
}
|
|
398
492
|
});
|
|
493
|
+
function w(e) {
|
|
494
|
+
return function() {
|
|
495
|
+
return e.render2 ? e.render2(e) : null;
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function de(e, o = {}, d) {
|
|
499
|
+
return p(N, {
|
|
500
|
+
...d,
|
|
501
|
+
value: e.value,
|
|
502
|
+
onUpdateValue: (t) => {
|
|
503
|
+
e.value = t, d?.onChange?.(t, d);
|
|
504
|
+
},
|
|
505
|
+
...o
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function ce(e, o, d = {}, t) {
|
|
509
|
+
return p(q, {
|
|
510
|
+
...t,
|
|
511
|
+
value: e.value,
|
|
512
|
+
options: o,
|
|
513
|
+
onUpdateValue: (s) => {
|
|
514
|
+
e.value = s, t?.onChange?.(s, t, o);
|
|
515
|
+
},
|
|
516
|
+
...d
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function ye(e, o, d = {}, t, s) {
|
|
520
|
+
const { value: c, labelField: y, valueField: i, ...m } = t, u = y ?? "label", v = i ?? "value", l = m.options ?? o;
|
|
521
|
+
return r(
|
|
522
|
+
_,
|
|
523
|
+
{
|
|
524
|
+
...m,
|
|
525
|
+
value: e.value,
|
|
526
|
+
onUpdateValue: (a) => {
|
|
527
|
+
e.value = a, t?.onChange?.(a, t, l);
|
|
528
|
+
},
|
|
529
|
+
options: l.map((a) => ({ ...a, label: a[u], value: a[v] })),
|
|
530
|
+
...d
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
default: () => s ?? r(b, null, {
|
|
534
|
+
default: () => e.value || "请选择"
|
|
535
|
+
})
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
function ve(e, o, d = {}, t) {
|
|
540
|
+
const { valueField: s = "value", ...c } = t;
|
|
541
|
+
return p(E, {
|
|
542
|
+
...c,
|
|
543
|
+
value: e.value,
|
|
544
|
+
options: o,
|
|
545
|
+
onUpdateValue: (y) => {
|
|
546
|
+
e.value = y, t?.onChange?.(y, t, o);
|
|
547
|
+
},
|
|
548
|
+
keyField: s,
|
|
549
|
+
...d
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
function me(e, o, d = {}, t) {
|
|
553
|
+
return p(
|
|
554
|
+
z,
|
|
555
|
+
{
|
|
556
|
+
...t,
|
|
557
|
+
value: e.value,
|
|
558
|
+
onUpdateValue: (s) => {
|
|
559
|
+
e.value = s, t?.onChange?.(s, t, o);
|
|
560
|
+
},
|
|
561
|
+
...d
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
default: () => (t?.options ?? o).map((c) => {
|
|
565
|
+
const y = t, i = c[y?.labelField ?? "label"], m = c[y?.valueField ?? "value"];
|
|
566
|
+
return p(
|
|
567
|
+
K,
|
|
568
|
+
{
|
|
569
|
+
...c,
|
|
570
|
+
label: i,
|
|
571
|
+
value: m
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
default: () => c.label
|
|
575
|
+
}
|
|
576
|
+
);
|
|
577
|
+
})
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
function fe(e, o, d = {}, t) {
|
|
582
|
+
return r(
|
|
583
|
+
z,
|
|
584
|
+
{
|
|
585
|
+
...t,
|
|
586
|
+
value: e.value,
|
|
587
|
+
onUpdateValue: (s) => {
|
|
588
|
+
e.value = s, t?.onChange?.(s, t, o);
|
|
589
|
+
},
|
|
590
|
+
...d
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
default: () => (t?.options ?? o).map((c) => {
|
|
594
|
+
const y = t, i = c[y?.labelField ?? "label"], m = c[y?.valueField ?? "value"];
|
|
595
|
+
return r(
|
|
596
|
+
J,
|
|
597
|
+
{
|
|
598
|
+
...c,
|
|
599
|
+
label: i,
|
|
600
|
+
value: m
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
default: () => c.label
|
|
604
|
+
}
|
|
605
|
+
);
|
|
606
|
+
})
|
|
607
|
+
}
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function be(e, o, d = {}, t) {
|
|
611
|
+
return p(
|
|
612
|
+
Q,
|
|
613
|
+
{
|
|
614
|
+
...t,
|
|
615
|
+
value: e.value,
|
|
616
|
+
onUpdateValue: (s) => {
|
|
617
|
+
e.value = s, t?.onChange?.(s, t, o);
|
|
618
|
+
},
|
|
619
|
+
...d
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
default: () => p(
|
|
623
|
+
W,
|
|
624
|
+
{
|
|
625
|
+
itemStyle: "display: flex"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
default: () => (t?.options ?? o).map((c) => {
|
|
629
|
+
const y = t, i = c[y?.labelField ?? "label"], m = c[y?.valueField ?? "value"];
|
|
630
|
+
return p(X, {
|
|
631
|
+
value: m,
|
|
632
|
+
label: i
|
|
633
|
+
});
|
|
634
|
+
})
|
|
635
|
+
}
|
|
636
|
+
)
|
|
637
|
+
}
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
function pe(e, o = {}, d) {
|
|
641
|
+
return p(Y, {
|
|
642
|
+
...d,
|
|
643
|
+
value: e.value,
|
|
644
|
+
onUpdateValue: (t) => {
|
|
645
|
+
e.value = t, d?.onChange?.(t, d);
|
|
646
|
+
},
|
|
647
|
+
...o
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
function ge(e, o = {}, d) {
|
|
651
|
+
return p(Z, {
|
|
652
|
+
...d,
|
|
653
|
+
value: e.value,
|
|
654
|
+
onUpdateValue: (t) => {
|
|
655
|
+
e.value = t, d?.onChange?.(t, d);
|
|
656
|
+
},
|
|
657
|
+
...o
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
function Ce(e, o = {}, d) {
|
|
661
|
+
return p(ee, {
|
|
662
|
+
...d,
|
|
663
|
+
value: e.value,
|
|
664
|
+
onUpdateValue: (t) => {
|
|
665
|
+
e.value = t, d?.onChange?.(t, d);
|
|
666
|
+
},
|
|
667
|
+
...o
|
|
668
|
+
});
|
|
669
|
+
}
|
|
399
670
|
export {
|
|
400
|
-
|
|
401
|
-
|
|
671
|
+
se as NaiDynamicCascadeInput,
|
|
672
|
+
ie as NaiDynamicForm,
|
|
673
|
+
oe as NaiDynamicInput,
|
|
674
|
+
be as renderCheckboxGroup,
|
|
675
|
+
ge as renderDatePicker,
|
|
676
|
+
de as renderInput,
|
|
677
|
+
ye as renderPopSelect,
|
|
678
|
+
fe as renderRadioButtonGroup,
|
|
679
|
+
me as renderRadioGroup,
|
|
680
|
+
ce as renderSelect,
|
|
681
|
+
pe as renderSwitch,
|
|
682
|
+
Ce as renderTimePicker,
|
|
683
|
+
ve as renderTreeSelect
|
|
402
684
|
};
|