dynamicformdjx 0.4.1 → 0.4.3
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 +1 -6
- package/dist/elementPlus/EleDynamicCascadeInput.d.ts +3 -3
- package/dist/elementPlus/EleDynamicInput.d.ts +3 -3
- package/dist/elementPlus/hooks/renderForm.d.ts +42 -13
- package/dist/elementPlus/index.cjs +1 -1
- package/dist/elementPlus/index.mjs +563 -469
- package/dist/hooks/useDyForm.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.mjs +306 -252
- package/dist/naiveUi/NaiDynamicCascadeInput.d.ts +3 -3
- package/dist/naiveUi/NaiDynamicInput.d.ts +3 -3
- package/dist/naiveUi/hooks/renderForm.d.ts +19 -4
- package/dist/naiveUi/index.cjs +1 -1
- package/dist/naiveUi/index.mjs +542 -446
- package/dist/origin/DynamicCascadeInput.d.ts +3 -3
- package/dist/origin/DynamicInput.d.ts +3 -3
- package/dist/types/form.d.ts +2 -2
- package/dist/types/index.d.ts +38 -0
- package/dist/utils/tools.d.ts +3 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as O, ref as R, watch as L, toRaw as x, createVNode as a, createTextVNode as g, Fragment as k, nextTick as M, shallowReactive as D, unref as H, isRef as T } from "vue";
|
|
2
|
+
import { t as V, r as j, f as $, p as E, s as z, e as K } from "./index-MF72-iEr.js";
|
|
3
|
+
const P = /* @__PURE__ */ O({
|
|
4
4
|
name: "DynamicInput",
|
|
5
5
|
props: {
|
|
6
6
|
size: {
|
|
@@ -33,129 +33,146 @@ const H = /* @__PURE__ */ R({
|
|
|
33
33
|
emits: {
|
|
34
34
|
"update:modelValue": (t) => !0,
|
|
35
35
|
onReset: () => !0,
|
|
36
|
-
onMerge: (t,
|
|
36
|
+
onMerge: (t, c) => !0
|
|
37
37
|
},
|
|
38
|
+
slots: Object,
|
|
38
39
|
setup(t, {
|
|
39
|
-
emit:
|
|
40
|
-
expose:
|
|
40
|
+
emit: c,
|
|
41
|
+
expose: p,
|
|
42
|
+
slots: r
|
|
41
43
|
}) {
|
|
42
|
-
const
|
|
44
|
+
const f = {
|
|
43
45
|
resetTxt: "重置",
|
|
44
46
|
newTxt: "添加项",
|
|
45
47
|
mergeTxt: "合并",
|
|
46
48
|
...t.btnConfigs
|
|
47
|
-
},
|
|
49
|
+
}, m = {
|
|
48
50
|
hideReset: !1,
|
|
49
51
|
maxHeight: "300px",
|
|
50
52
|
autoScroll: !0,
|
|
51
53
|
allowFilter: !0,
|
|
54
|
+
hideArrayBtn: !1,
|
|
55
|
+
hideNumberBtn: !1,
|
|
52
56
|
...t.configs
|
|
53
|
-
},
|
|
57
|
+
}, v = {
|
|
54
58
|
arraySplitSymbol: ",",
|
|
55
59
|
...t.dyListConfigs
|
|
56
|
-
},
|
|
57
|
-
|
|
60
|
+
}, b = t.size, d = R(V(t.modelValue, t.randomFun, v.arraySplitSymbol)), h = R(null);
|
|
61
|
+
L(d, (e) => {
|
|
58
62
|
if (!t.isController) return;
|
|
59
|
-
const
|
|
60
|
-
|
|
63
|
+
const s = j(e, v.arraySplitSymbol);
|
|
64
|
+
c("update:modelValue", s), c("onMerge", s, x(d.value));
|
|
61
65
|
}, {
|
|
62
66
|
deep: !0
|
|
63
|
-
}),
|
|
67
|
+
}), p({
|
|
64
68
|
onSet: (e) => {
|
|
65
|
-
|
|
69
|
+
d.value = V(e ?? t.modelValue, t.randomFun, v.arraySplitSymbol);
|
|
66
70
|
},
|
|
67
|
-
getResult: (e = "res") => e === "ori" ?
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
getResult: (e = "res") => e === "ori" ? x(d.value) : j(d.value, v.arraySplitSymbol)
|
|
72
|
+
});
|
|
73
|
+
const y = () => d.value.push({
|
|
74
|
+
rId: t.randomFun(),
|
|
75
|
+
key: "",
|
|
76
|
+
value: ""
|
|
77
|
+
}), A = () => {
|
|
78
|
+
d.value = V(t.modelValue, t.randomFun, v.arraySplitSymbol), c("onReset");
|
|
79
|
+
}, o = () => {
|
|
80
|
+
d.value.sort((s, l) => +s.rId - +l.rId);
|
|
81
|
+
const e = j(d.value, v.arraySplitSymbol);
|
|
82
|
+
c("update:modelValue", e), c("onMerge", e, x(d.value)), d.value = V(e, t.randomFun, v.arraySplitSymbol);
|
|
83
|
+
};
|
|
84
|
+
return () => a("div", {
|
|
85
|
+
class: `dynamicForm ${b} ${t.dyCls}`
|
|
86
|
+
}, [a("div", {
|
|
87
|
+
class: `dyFormList ${d.value.length ? "" : "noList"}`,
|
|
88
|
+
ref: h,
|
|
73
89
|
style: {
|
|
74
|
-
maxHeight:
|
|
75
|
-
}
|
|
76
|
-
}, [o.value.map((e, u, l) => n("div", {
|
|
77
|
-
class: "dItem",
|
|
78
|
-
key: e.rId
|
|
79
|
-
}, [n("div", {
|
|
80
|
-
class: "input"
|
|
81
|
-
}, [n("input", {
|
|
82
|
-
size: v,
|
|
83
|
-
value: e.key,
|
|
84
|
-
class: "key nativeInput",
|
|
85
|
-
onInput: (s) => {
|
|
86
|
-
e.key = s.target.value;
|
|
87
|
-
}
|
|
88
|
-
}, null), m(":"), n("div", {
|
|
89
|
-
class: "vInput"
|
|
90
|
-
}, [n("div", {
|
|
91
|
-
class: "slot"
|
|
92
|
-
}, [n("button", {
|
|
93
|
-
class: [e.isArray ? "success" : "default", "small", "bt"],
|
|
94
|
-
onClick: () => {
|
|
95
|
-
e.isArray = !e.isArray;
|
|
96
|
-
}
|
|
97
|
-
}, [m("Array")]), m(" "), n("button", {
|
|
98
|
-
class: [e.isNumber ? "success" : "default", "small", "bt"],
|
|
99
|
-
onClick: () => {
|
|
100
|
-
e.isNumber = !e.isNumber;
|
|
90
|
+
maxHeight: m.maxHeight
|
|
101
91
|
}
|
|
102
|
-
}, [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
key: "",
|
|
119
|
-
value: ""
|
|
120
|
-
}), c.autoScroll && j(() => {
|
|
121
|
-
const s = b.value;
|
|
122
|
-
s?.scrollTo({
|
|
123
|
-
top: s.scrollHeight,
|
|
124
|
-
behavior: "smooth"
|
|
92
|
+
}, [d.value.map((e, s, l) => {
|
|
93
|
+
const u = {
|
|
94
|
+
row: e,
|
|
95
|
+
index: s,
|
|
96
|
+
isLast: s === l.length - 1,
|
|
97
|
+
addItem: () => {
|
|
98
|
+
d.value.push({
|
|
99
|
+
rId: t.randomFun(),
|
|
100
|
+
key: "",
|
|
101
|
+
value: ""
|
|
102
|
+
}), m.autoScroll && M(() => {
|
|
103
|
+
const i = h.value;
|
|
104
|
+
i?.scrollTo({
|
|
105
|
+
top: i.scrollHeight,
|
|
106
|
+
behavior: "smooth"
|
|
107
|
+
});
|
|
125
108
|
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
109
|
+
},
|
|
110
|
+
removeItem: () => {
|
|
111
|
+
d.value = d.value.filter((i) => i.rId !== e.rId);
|
|
112
|
+
},
|
|
113
|
+
toggleArray: () => e.isArray = !e.isArray,
|
|
114
|
+
toggleNumber: () => e.isNumber = !e.isNumber
|
|
115
|
+
};
|
|
116
|
+
return a("div", {
|
|
117
|
+
class: "dItem",
|
|
118
|
+
key: e.rId
|
|
119
|
+
}, [a("div", {
|
|
120
|
+
class: "input"
|
|
121
|
+
}, [a("input", {
|
|
122
|
+
size: b,
|
|
123
|
+
value: e.key,
|
|
124
|
+
class: "key nativeInput",
|
|
125
|
+
onInput: (i) => {
|
|
126
|
+
e.key = i.target.value;
|
|
127
|
+
}
|
|
128
|
+
}, null), g(":"), a("div", {
|
|
129
|
+
class: "vInput"
|
|
130
|
+
}, [a("div", {
|
|
131
|
+
class: "slot"
|
|
132
|
+
}, [r.typeTools ? r.typeTools(u) : a(k, null, [!m.hideArrayBtn && a("button", {
|
|
133
|
+
class: [e.isArray ? "success" : "default", "small", "bt"],
|
|
134
|
+
onClick: u.toggleArray
|
|
135
|
+
}, [g("Array")]), !m.hideNumberBtn && a("button", {
|
|
136
|
+
class: [e.isNumber ? "success" : "default", "small", "bt"],
|
|
137
|
+
onClick: u.toggleNumber
|
|
138
|
+
}, [g("Number")])])]), a("input", {
|
|
139
|
+
size: b,
|
|
140
|
+
value: e.value,
|
|
141
|
+
class: "value nativeV",
|
|
142
|
+
onInput: (i) => {
|
|
143
|
+
const n = i.target.value;
|
|
144
|
+
m.allowFilter && e.isNumber ? e.value = $(n, e.isArray, v.arraySplitSymbol) : e.value = n;
|
|
145
|
+
}
|
|
146
|
+
}, null)])]), a("div", {
|
|
147
|
+
class: "btn"
|
|
148
|
+
}, [r.rowActions ? r.rowActions(u) : a(k, null, [a("button", {
|
|
149
|
+
class: [b, "success", "bt"],
|
|
150
|
+
disabled: !u.isLast,
|
|
151
|
+
onClick: u.addItem
|
|
152
|
+
}, [g("+")]), a("button", {
|
|
153
|
+
class: ["danger", b, "bt"],
|
|
154
|
+
onClick: u.removeItem
|
|
155
|
+
}, [g("-")])])])]);
|
|
156
|
+
})]), a("div", {
|
|
157
|
+
class: `control ${d.value.length ? "" : "noList"}`
|
|
158
|
+
}, [!d.value.length && (r.newBtn ? r.newBtn({
|
|
159
|
+
newItem: y
|
|
160
|
+
}) : a("button", {
|
|
161
|
+
class: ["success", b, "bt"],
|
|
162
|
+
onClick: y
|
|
163
|
+
}, [f.newTxt])), !t.isController && a(k, null, [!m.hideReset && (r.resetBtn ? r.resetBtn({
|
|
164
|
+
reset: A
|
|
165
|
+
}) : a("button", {
|
|
166
|
+
class: ["default", b, "bt"],
|
|
167
|
+
onClick: A
|
|
168
|
+
}, [f.resetTxt])), r.mergeBtn ? r.mergeBtn({
|
|
169
|
+
merge: o
|
|
170
|
+
}) : a("button", {
|
|
171
|
+
class: ["info", b, "bt"],
|
|
172
|
+
onClick: o
|
|
173
|
+
}, [f.mergeTxt])])])]);
|
|
157
174
|
}
|
|
158
|
-
}),
|
|
175
|
+
}), q = /* @__PURE__ */ O({
|
|
159
176
|
name: "DynamicCascadeInput",
|
|
160
177
|
props: {
|
|
161
178
|
modelValue: {
|
|
@@ -194,217 +211,254 @@ const H = /* @__PURE__ */ R({
|
|
|
194
211
|
emits: {
|
|
195
212
|
"update:modelValue": (t) => !0,
|
|
196
213
|
onReset: () => !0,
|
|
197
|
-
onMerge: (t,
|
|
214
|
+
onMerge: (t, c) => !0
|
|
198
215
|
},
|
|
216
|
+
slots: Object,
|
|
199
217
|
setup(t, {
|
|
200
|
-
emit:
|
|
201
|
-
expose:
|
|
218
|
+
emit: c,
|
|
219
|
+
expose: p,
|
|
220
|
+
slots: r
|
|
202
221
|
}) {
|
|
203
|
-
const
|
|
222
|
+
const f = {
|
|
204
223
|
resetTxt: "重置",
|
|
205
224
|
newTxt: "添加项",
|
|
206
225
|
mergeTxt: "合并",
|
|
207
226
|
...t.btnConfigs
|
|
208
|
-
},
|
|
227
|
+
}, m = {
|
|
209
228
|
hideReset: !1,
|
|
210
229
|
maxHeight: "600px",
|
|
211
230
|
allowFilter: !0,
|
|
212
231
|
showBorder: !0,
|
|
213
232
|
showPad: !0,
|
|
233
|
+
hideArrayBtn: !1,
|
|
234
|
+
hideNumberBtn: !1,
|
|
214
235
|
retractLen: 0,
|
|
215
236
|
borderColors: [],
|
|
216
237
|
...t.configs
|
|
217
|
-
},
|
|
238
|
+
}, v = {
|
|
218
239
|
arraySplitSymbol: ",",
|
|
219
240
|
...t.dyListConfigs
|
|
220
|
-
},
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
return
|
|
241
|
+
}, b = (l) => ["string", "number"].includes(l), d = (l) => Object.keys(l).map((u, i) => {
|
|
242
|
+
let n = l[u];
|
|
243
|
+
const C = Array.isArray(n), B = C ? n.every((N) => typeof N == "number") : typeof n == "number", w = n === null;
|
|
244
|
+
return b(typeof n) && (n = l[u]), w && (n = ""), {
|
|
224
245
|
rId: t.randomFun(i),
|
|
225
|
-
key:
|
|
226
|
-
value: Object.prototype.toString.call(
|
|
227
|
-
isArray:
|
|
228
|
-
isNumber:
|
|
246
|
+
key: u,
|
|
247
|
+
value: Object.prototype.toString.call(n) === "[object Object]" ? d(l[u]) : C ? n.join(v.arraySplitSymbol) : n,
|
|
248
|
+
isArray: C || void 0,
|
|
249
|
+
isNumber: B || void 0
|
|
229
250
|
};
|
|
230
|
-
}),
|
|
231
|
-
const
|
|
232
|
-
return i.key.trim().length && (
|
|
233
|
-
}, {}),
|
|
234
|
-
class: [`depth-${
|
|
251
|
+
}), h = (l) => l.reduce((u, i) => {
|
|
252
|
+
const n = i.value;
|
|
253
|
+
return i.key.trim().length && (u[i.key] = Array.isArray(n) ? h(n) : E(i.value, i.isArray, i.isNumber, v.arraySplitSymbol)), u;
|
|
254
|
+
}, {}), y = R(d(t.modelValue)), A = (l, u = 1, i) => a("div", {
|
|
255
|
+
class: [`depth-${u}`, m.showBorder ? "" : "no-border", m.showPad ? "" : "no-pad"],
|
|
235
256
|
style: {
|
|
236
|
-
"--depth":
|
|
237
|
-
["--c" + [
|
|
257
|
+
"--depth": u,
|
|
258
|
+
["--c" + [u]]: z(m.borderColors, u)
|
|
238
259
|
}
|
|
239
|
-
}, [l.map((
|
|
240
|
-
const
|
|
241
|
-
|
|
260
|
+
}, [l.map((n, C, B) => {
|
|
261
|
+
const w = Array.isArray(n.value), N = b(typeof n.value), I = {
|
|
262
|
+
row: n,
|
|
263
|
+
index: C,
|
|
264
|
+
isLast: C === B.length - 1,
|
|
265
|
+
addItem: () => {
|
|
266
|
+
l.push({
|
|
267
|
+
rId: t.randomFun(),
|
|
268
|
+
key: "",
|
|
269
|
+
value: ""
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
addChild: () => {
|
|
273
|
+
N && (n.value = [], n.isArray = void 0), n.value.push({
|
|
274
|
+
rId: t.randomFun(),
|
|
275
|
+
key: "",
|
|
276
|
+
value: ""
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
removeItem: () => {
|
|
280
|
+
if (l.splice(C, 1), l.length < 1) {
|
|
281
|
+
if (i === void 0) return h([]);
|
|
282
|
+
const F = y.value.findIndex((S) => S.rId === i?.rId);
|
|
283
|
+
u < 1 ? y.value.splice(F, 1, {
|
|
284
|
+
...i,
|
|
285
|
+
value: ""
|
|
286
|
+
}) : i.value = "";
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
toggleArray: () => n.isArray = !n.isArray,
|
|
290
|
+
toggleNumber: () => n.isNumber = !n.isNumber
|
|
291
|
+
};
|
|
292
|
+
return a("div", {
|
|
242
293
|
class: "dItem",
|
|
243
|
-
key:
|
|
294
|
+
key: n.rId,
|
|
244
295
|
style: {
|
|
245
|
-
marginLeft:
|
|
296
|
+
marginLeft: u > 1 ? `${u * m.retractLen}px` : "0"
|
|
246
297
|
}
|
|
247
|
-
}, [
|
|
298
|
+
}, [a("div", {
|
|
248
299
|
class: "input"
|
|
249
|
-
}, [!
|
|
250
|
-
value:
|
|
300
|
+
}, [!w && a(k, null, [a("input", {
|
|
301
|
+
value: n.key,
|
|
251
302
|
class: "key nativeInput",
|
|
252
|
-
onInput: (
|
|
253
|
-
}, null),
|
|
303
|
+
onInput: (F) => n.key = F.target.value
|
|
304
|
+
}, null), g(":")]), a("div", {
|
|
254
305
|
class: "vInput"
|
|
255
|
-
}, [
|
|
306
|
+
}, [a("div", {
|
|
256
307
|
class: "slot"
|
|
257
|
-
}, [Array.isArray(
|
|
258
|
-
class: [
|
|
259
|
-
onClick:
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
onInput: (I) => {
|
|
271
|
-
const k = I.target.value;
|
|
272
|
-
if (C) {
|
|
273
|
-
a.key = k;
|
|
308
|
+
}, [Array.isArray(n.value) ? void 0 : r.typeTools ? r.typeTools(I) : a(k, null, [!m.hideArrayBtn && a("button", {
|
|
309
|
+
class: [n.isArray ? "success" : "default", "small", "bt"],
|
|
310
|
+
onClick: I.toggleArray
|
|
311
|
+
}, [g("Array")]), !m.hideNumberBtn && a("button", {
|
|
312
|
+
class: [n.isNumber ? "success" : "default", "small", "bt"],
|
|
313
|
+
onClick: I.toggleNumber
|
|
314
|
+
}, [g("Number")])])]), a("input", {
|
|
315
|
+
class: `value nativeV ${w ? "isKey" : ""}`,
|
|
316
|
+
value: N ? n.value : n.key,
|
|
317
|
+
onInput: (F) => {
|
|
318
|
+
const S = F.target.value;
|
|
319
|
+
if (w) {
|
|
320
|
+
n.key = S;
|
|
274
321
|
return;
|
|
275
322
|
}
|
|
276
|
-
|
|
323
|
+
m.allowFilter && n.isNumber ? n.value = $(S, n.isArray, v.arraySplitSymbol) : n.value = S;
|
|
277
324
|
}
|
|
278
|
-
}, null),
|
|
325
|
+
}, null), a("div", {
|
|
279
326
|
class: "surSlot"
|
|
280
|
-
}, [
|
|
327
|
+
}, [u < t.depth ? !w && (r.newChild ? r.newChild(I) : a("button", {
|
|
281
328
|
class: ["success", "bt"],
|
|
282
|
-
onClick:
|
|
283
|
-
|
|
284
|
-
rId: t.randomFun(),
|
|
285
|
-
key: "",
|
|
286
|
-
value: ""
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}, [t.newChildTxt(a)]) : null])])]), n("div", {
|
|
329
|
+
onClick: I.addChild
|
|
330
|
+
}, [t.newChildTxt(n)])) : null])])]), a("div", {
|
|
290
331
|
class: "btn"
|
|
291
|
-
}, [
|
|
332
|
+
}, [r.rowActions ? r.rowActions(I) : a(k, null, [a("button", {
|
|
292
333
|
class: ["success", "bt"],
|
|
293
|
-
disabled:
|
|
294
|
-
onClick:
|
|
295
|
-
|
|
296
|
-
rId: t.randomFun(),
|
|
297
|
-
key: "",
|
|
298
|
-
value: ""
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}, [m("+")]), n("button", {
|
|
334
|
+
disabled: !I.isLast,
|
|
335
|
+
onClick: I.addItem
|
|
336
|
+
}, [g("+")]), a("button", {
|
|
302
337
|
class: ["danger", "bt"],
|
|
303
|
-
onClick:
|
|
304
|
-
|
|
305
|
-
if (i === void 0) return b([]);
|
|
306
|
-
const I = e.value.findIndex((k) => k.rId === i?.rId);
|
|
307
|
-
s < 1 ? e.value.splice(I, 1, {
|
|
308
|
-
...i,
|
|
309
|
-
value: ""
|
|
310
|
-
}) : i.value = "";
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}, [m("-")])]), Array.isArray(a.value) && u(a.value, s + 1, a)]);
|
|
338
|
+
onClick: I.removeItem
|
|
339
|
+
}, [g("-")])])]), Array.isArray(n.value) && A(n.value, u + 1, n)]);
|
|
314
340
|
})]);
|
|
315
|
-
|
|
341
|
+
L(y, (l) => {
|
|
316
342
|
if (!t.isController) return;
|
|
317
|
-
const
|
|
318
|
-
|
|
343
|
+
const u = h(l);
|
|
344
|
+
c("update:modelValue", u), c("onMerge", u, x(y.value));
|
|
319
345
|
}, {
|
|
320
346
|
deep: !0
|
|
321
|
-
}),
|
|
347
|
+
}), p({
|
|
322
348
|
onSet: (l) => {
|
|
323
|
-
|
|
349
|
+
y.value = d(l ?? t.modelValue);
|
|
324
350
|
},
|
|
325
|
-
getResult: (l = "res") => l === "ori" ?
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
351
|
+
getResult: (l = "res") => l === "ori" ? x(y.value) : h(y.value)
|
|
352
|
+
});
|
|
353
|
+
const o = () => y.value.push({
|
|
354
|
+
rId: t.randomFun(),
|
|
355
|
+
key: "",
|
|
356
|
+
value: ""
|
|
357
|
+
}), e = () => {
|
|
358
|
+
y.value = d(t.modelValue), c("onReset");
|
|
359
|
+
}, s = () => {
|
|
360
|
+
const l = h(y.value);
|
|
361
|
+
c("update:modelValue", l), c("onMerge", l, x(y.value)), y.value = d(l);
|
|
362
|
+
};
|
|
363
|
+
return () => a("div", {
|
|
364
|
+
class: `dynamicCascadeForm ${t.dyCls}`
|
|
365
|
+
}, [a("div", {
|
|
366
|
+
class: `dyFormList ${y.value.length ? "" : "noObj"}`,
|
|
330
367
|
style: {
|
|
331
|
-
maxHeight:
|
|
368
|
+
maxHeight: m.maxHeight
|
|
332
369
|
}
|
|
333
|
-
}, [
|
|
334
|
-
class:
|
|
335
|
-
}, [!
|
|
370
|
+
}, [A(y.value)]), a("div", {
|
|
371
|
+
class: `control ${y.value.length ? "" : "noObj"}`
|
|
372
|
+
}, [!y.value.length && (r.newBtn ? r.newBtn({
|
|
373
|
+
newItem: o
|
|
374
|
+
}) : a("button", {
|
|
336
375
|
class: ["success", "bt"],
|
|
337
|
-
onClick:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
value: ""
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}, [d.newTxt]), !t.isController && n(x, null, [!c.hideReset && n("button", {
|
|
376
|
+
onClick: o
|
|
377
|
+
}, [f.newTxt])), !t.isController && a(k, null, [!m.hideReset && (r.resetBtn ? r.resetBtn({
|
|
378
|
+
reset: e
|
|
379
|
+
}) : a("button", {
|
|
345
380
|
class: ["default", "bt"],
|
|
346
|
-
onClick:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
381
|
+
onClick: e
|
|
382
|
+
}, [f.resetTxt])), r.mergeBtn ? r.mergeBtn({
|
|
383
|
+
merge: s
|
|
384
|
+
}) : a("button", {
|
|
350
385
|
class: ["info", "bt"],
|
|
351
|
-
onClick:
|
|
352
|
-
|
|
353
|
-
r("update:modelValue", l), r("onMerge", l, h(e.value)), e.value = o(l);
|
|
354
|
-
}
|
|
355
|
-
}, [d.mergeTxt])])])]);
|
|
386
|
+
onClick: s
|
|
387
|
+
}, [f.mergeTxt])])])]);
|
|
356
388
|
}
|
|
357
389
|
});
|
|
358
|
-
function
|
|
359
|
-
return t.map((
|
|
360
|
-
const
|
|
361
|
-
return
|
|
390
|
+
function J(t, c = !0) {
|
|
391
|
+
return t.map((p) => {
|
|
392
|
+
const r = p;
|
|
393
|
+
return r.value = K(p.value), c ? D(r) : r;
|
|
362
394
|
});
|
|
363
395
|
}
|
|
364
|
-
function
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
(!
|
|
396
|
+
function Q(t) {
|
|
397
|
+
const c = () => H(t), p = (o, e) => {
|
|
398
|
+
c().forEach((s) => {
|
|
399
|
+
const l = s.key;
|
|
400
|
+
(!e || e.includes(l)) && (s.disabled = o);
|
|
369
401
|
});
|
|
370
|
-
},
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
(!
|
|
402
|
+
}, r = (o, e) => {
|
|
403
|
+
c().forEach((s) => {
|
|
404
|
+
const l = s.key;
|
|
405
|
+
(!e || e.includes(l)) && (s.hidden = o);
|
|
374
406
|
});
|
|
375
|
-
},
|
|
376
|
-
const
|
|
377
|
-
|
|
407
|
+
}, f = (o, e) => {
|
|
408
|
+
const s = c().find((l) => l.key === o);
|
|
409
|
+
s && (T(s.value) ? s.value.value = e : s.value = e);
|
|
378
410
|
};
|
|
379
|
-
return { setDisabled:
|
|
380
|
-
Object.entries(
|
|
381
|
-
|
|
411
|
+
return { setDisabled: p, setHidden: r, setValue: f, setValues: (o) => {
|
|
412
|
+
Object.entries(o).forEach(([e, s]) => {
|
|
413
|
+
f(e, s);
|
|
382
414
|
});
|
|
383
|
-
}, getValue: (
|
|
384
|
-
const
|
|
385
|
-
return
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
388
|
-
const
|
|
389
|
-
|
|
415
|
+
}, getValue: (o) => c().find((e) => e.key === o), getValues: (o) => {
|
|
416
|
+
const e = o && o.length ? new Set(o) : null;
|
|
417
|
+
return c().reduce((s, l) => {
|
|
418
|
+
const u = l.key;
|
|
419
|
+
if (!e || e.has(u)) {
|
|
420
|
+
const i = T(l.value) ? l.value.value : l.value;
|
|
421
|
+
s[u] = i;
|
|
390
422
|
}
|
|
391
|
-
return
|
|
423
|
+
return s;
|
|
392
424
|
}, {});
|
|
393
|
-
}, onReset: (
|
|
394
|
-
|
|
395
|
-
|
|
425
|
+
}, onReset: (o = null) => {
|
|
426
|
+
c().forEach((e) => {
|
|
427
|
+
T(e.value) ? e.value.value = o : e.value = o;
|
|
428
|
+
});
|
|
429
|
+
}, setItem: (o, e) => {
|
|
430
|
+
c().forEach((s) => {
|
|
431
|
+
if (s.key === o) {
|
|
432
|
+
const { key: l, ...u } = e;
|
|
433
|
+
Object.assign(s, u);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}, setItems: (o) => {
|
|
437
|
+
const e = new Map(o);
|
|
438
|
+
c().forEach((s) => {
|
|
439
|
+
const l = e.get(s.key);
|
|
440
|
+
if (l) {
|
|
441
|
+
const { key: u, ...i } = l;
|
|
442
|
+
Object.assign(s, i);
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
}, updateKeys: (o) => {
|
|
446
|
+
const e = new Map(o);
|
|
447
|
+
c().forEach((s) => {
|
|
448
|
+
const l = e.get(s.key);
|
|
449
|
+
l && (s.key = l);
|
|
396
450
|
});
|
|
397
451
|
} };
|
|
398
452
|
}
|
|
399
|
-
const
|
|
453
|
+
const U = {
|
|
400
454
|
install(t) {
|
|
401
|
-
t.component("DynamicInput",
|
|
455
|
+
t.component("DynamicInput", P), t.component("DynamicCascadeInput", q);
|
|
402
456
|
}
|
|
403
457
|
};
|
|
404
458
|
export {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
459
|
+
q as DynamicCascadeInput,
|
|
460
|
+
P as DynamicInput,
|
|
461
|
+
U as DynamicInputPlugin,
|
|
462
|
+
Q as useDyForm,
|
|
463
|
+
J as useReactiveForm
|
|
410
464
|
};
|