dynamicformdjx 0.2.0 → 0.3.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/README.md +80 -4
- package/dist/hooks/useDyForm.d.ts +13 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +186 -149
- 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 +446 -164
- package/dist/types/form.d.ts +34 -0
- package/dist/types/index.d.ts +7 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as p, r as F, f as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as N, ref as V, watch as T, toRaw as I, createVNode as a, createTextVNode as m, nextTick as j, Fragment as x, shallowReactive as O, unref as D, isRef as w } from "vue";
|
|
2
|
+
import { t as p, r as F, f as R, p as L, s as M } from "./index-BqKRE4oH.js";
|
|
3
|
+
const $ = /* @__PURE__ */ N({
|
|
4
4
|
name: "DynamicInput",
|
|
5
5
|
props: {
|
|
6
6
|
size: {
|
|
@@ -14,7 +14,7 @@ const L = /* @__PURE__ */ V({
|
|
|
14
14
|
},
|
|
15
15
|
randomFun: {
|
|
16
16
|
type: Function,
|
|
17
|
-
default: (
|
|
17
|
+
default: (t) => `${Date.now()}_${t ?? 0}`
|
|
18
18
|
},
|
|
19
19
|
btnConfigs: {
|
|
20
20
|
type: Object
|
|
@@ -31,131 +31,131 @@ const L = /* @__PURE__ */ V({
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
emits: {
|
|
34
|
-
"update:modelValue": (
|
|
34
|
+
"update:modelValue": (t) => !0,
|
|
35
35
|
onReset: () => !0,
|
|
36
|
-
onMerge: (
|
|
36
|
+
onMerge: (t, i) => !0
|
|
37
37
|
},
|
|
38
|
-
setup(
|
|
39
|
-
emit:
|
|
40
|
-
expose:
|
|
38
|
+
setup(t, {
|
|
39
|
+
emit: i,
|
|
40
|
+
expose: f
|
|
41
41
|
}) {
|
|
42
42
|
const b = {
|
|
43
43
|
resetTxt: "重置",
|
|
44
44
|
newTxt: "添加项",
|
|
45
45
|
mergeTxt: "合并",
|
|
46
|
-
...
|
|
47
|
-
},
|
|
46
|
+
...t.btnConfigs
|
|
47
|
+
}, d = {
|
|
48
48
|
hideReset: !1,
|
|
49
49
|
maxHeight: "300px",
|
|
50
50
|
autoScroll: !0,
|
|
51
51
|
allowFilter: !0,
|
|
52
|
-
...
|
|
53
|
-
},
|
|
52
|
+
...t.configs
|
|
53
|
+
}, y = {
|
|
54
54
|
arraySplitSymbol: ",",
|
|
55
|
-
...
|
|
56
|
-
},
|
|
57
|
-
return
|
|
58
|
-
if (!
|
|
59
|
-
const
|
|
60
|
-
|
|
55
|
+
...t.dyListConfigs
|
|
56
|
+
}, v = t.size, o = V(p(t.modelValue, t.randomFun, y.arraySplitSymbol)), r = V(null);
|
|
57
|
+
return T(o, (e) => {
|
|
58
|
+
if (!t.isController) return;
|
|
59
|
+
const u = F(e, y.arraySplitSymbol);
|
|
60
|
+
i("update:modelValue", u), i("onMerge", u, I(o.value));
|
|
61
61
|
}, {
|
|
62
62
|
deep: !0
|
|
63
|
-
}),
|
|
64
|
-
onSet: (
|
|
65
|
-
|
|
63
|
+
}), f({
|
|
64
|
+
onSet: (e) => {
|
|
65
|
+
o.value = p(e ?? t.modelValue, t.randomFun, y.arraySplitSymbol);
|
|
66
66
|
},
|
|
67
|
-
getResult: (
|
|
67
|
+
getResult: (e = "res") => e === "ori" ? I(o.value) : F(o.value, y.arraySplitSymbol)
|
|
68
68
|
}), () => a("div", {
|
|
69
|
-
class:
|
|
69
|
+
class: t.dyCls ?? `dynamicForm ${v}`
|
|
70
70
|
}, [a("div", {
|
|
71
71
|
class: "dyFormList",
|
|
72
|
-
ref:
|
|
72
|
+
ref: r,
|
|
73
73
|
style: {
|
|
74
|
-
maxHeight:
|
|
74
|
+
maxHeight: d.maxHeight
|
|
75
75
|
}
|
|
76
|
-
}, [
|
|
76
|
+
}, [o.value.map((e, u, n) => a("div", {
|
|
77
77
|
class: "dItem",
|
|
78
|
-
key:
|
|
78
|
+
key: e.rId
|
|
79
79
|
}, [a("div", {
|
|
80
80
|
class: "input"
|
|
81
81
|
}, [a("input", {
|
|
82
|
-
size:
|
|
83
|
-
value:
|
|
82
|
+
size: v,
|
|
83
|
+
value: e.key,
|
|
84
84
|
class: "key nativeInput",
|
|
85
|
-
onInput: (
|
|
86
|
-
|
|
85
|
+
onInput: (s) => {
|
|
86
|
+
e.key = s.target.value;
|
|
87
87
|
}
|
|
88
|
-
}, null),
|
|
88
|
+
}, null), m(":"), a("div", {
|
|
89
89
|
class: "vInput"
|
|
90
90
|
}, [a("div", {
|
|
91
91
|
class: "slot"
|
|
92
92
|
}, [a("button", {
|
|
93
|
-
class: [
|
|
93
|
+
class: [e.isArray ? "success" : "default", "small", "bt"],
|
|
94
94
|
onClick: () => {
|
|
95
|
-
|
|
95
|
+
e.isArray = !e.isArray;
|
|
96
96
|
}
|
|
97
|
-
}, [
|
|
98
|
-
class: [
|
|
97
|
+
}, [m("Array")]), m(" "), a("button", {
|
|
98
|
+
class: [e.isNumber ? "success" : "default", "small", "bt"],
|
|
99
99
|
onClick: () => {
|
|
100
|
-
|
|
100
|
+
e.isNumber = !e.isNumber;
|
|
101
101
|
}
|
|
102
|
-
}, [
|
|
103
|
-
size:
|
|
104
|
-
value:
|
|
102
|
+
}, [m("Number")])]), a("input", {
|
|
103
|
+
size: v,
|
|
104
|
+
value: e.value,
|
|
105
105
|
class: "value nativeV",
|
|
106
|
-
onInput: (
|
|
107
|
-
const
|
|
108
|
-
|
|
106
|
+
onInput: (s) => {
|
|
107
|
+
const c = s.target.value;
|
|
108
|
+
d.allowFilter && e.isNumber ? e.value = R(c, e.isArray, y.arraySplitSymbol) : e.value = c;
|
|
109
109
|
}
|
|
110
110
|
}, null)])]), a("div", {
|
|
111
111
|
class: "btn"
|
|
112
112
|
}, [a("button", {
|
|
113
|
-
class: [
|
|
114
|
-
disabled:
|
|
113
|
+
class: [v, "success", "bt"],
|
|
114
|
+
disabled: u !== n.length - 1,
|
|
115
115
|
onClick: () => {
|
|
116
|
-
|
|
117
|
-
rId:
|
|
116
|
+
o.value.push({
|
|
117
|
+
rId: t.randomFun(),
|
|
118
118
|
key: "",
|
|
119
119
|
value: ""
|
|
120
|
-
}),
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
top:
|
|
120
|
+
}), d.autoScroll && j(() => {
|
|
121
|
+
const s = r.value;
|
|
122
|
+
s?.scrollTo({
|
|
123
|
+
top: s.scrollHeight,
|
|
124
124
|
behavior: "smooth"
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
}, [
|
|
129
|
-
class: ["danger",
|
|
128
|
+
}, [m("+")]), a("button", {
|
|
129
|
+
class: ["danger", v, "bt"],
|
|
130
130
|
onClick: () => {
|
|
131
|
-
|
|
131
|
+
o.value = o.value.filter((s) => s.rId !== e.rId);
|
|
132
132
|
}
|
|
133
|
-
}, [
|
|
133
|
+
}, [m("-")])])]))]), a("div", {
|
|
134
134
|
class: "control"
|
|
135
|
-
}, [!
|
|
136
|
-
class: ["success",
|
|
135
|
+
}, [!o.value.length && a("button", {
|
|
136
|
+
class: ["success", v, "bt"],
|
|
137
137
|
onClick: () => {
|
|
138
|
-
|
|
139
|
-
rId:
|
|
138
|
+
o.value.push({
|
|
139
|
+
rId: t.randomFun(),
|
|
140
140
|
key: "",
|
|
141
141
|
value: ""
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
}, [b.newTxt]), !
|
|
145
|
-
class: ["default",
|
|
144
|
+
}, [b.newTxt]), !t.isController && a(x, null, [!d.hideReset && a("button", {
|
|
145
|
+
class: ["default", v, "bt"],
|
|
146
146
|
onClick: () => {
|
|
147
|
-
|
|
147
|
+
o.value = p(t.modelValue, t.randomFun, y.arraySplitSymbol), i("onReset");
|
|
148
148
|
}
|
|
149
149
|
}, [b.resetTxt]), a("button", {
|
|
150
|
-
class: ["info",
|
|
150
|
+
class: ["info", v, "bt"],
|
|
151
151
|
onClick: () => {
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
152
|
+
o.value.sort((u, n) => +u.rId - +n.rId);
|
|
153
|
+
const e = F(o.value, y.arraySplitSymbol);
|
|
154
|
+
i("update:modelValue", e), i("onMerge", e, I(o.value)), o.value = p(e, t.randomFun, y.arraySplitSymbol);
|
|
155
155
|
}
|
|
156
156
|
}, [b.mergeTxt])])])]);
|
|
157
157
|
}
|
|
158
|
-
}),
|
|
158
|
+
}), H = /* @__PURE__ */ N({
|
|
159
159
|
name: "DynamicCascadeInput",
|
|
160
160
|
props: {
|
|
161
161
|
modelValue: {
|
|
@@ -170,7 +170,7 @@ const L = /* @__PURE__ */ V({
|
|
|
170
170
|
},
|
|
171
171
|
randomFun: {
|
|
172
172
|
type: Function,
|
|
173
|
-
default: (
|
|
173
|
+
default: (t) => `${Date.now()}_${t ?? 0}`
|
|
174
174
|
},
|
|
175
175
|
// 子层深度 (超过则不再出现添加选项)
|
|
176
176
|
depth: {
|
|
@@ -188,24 +188,24 @@ const L = /* @__PURE__ */ V({
|
|
|
188
188
|
},
|
|
189
189
|
newChildTxt: {
|
|
190
190
|
type: Function,
|
|
191
|
-
default: (
|
|
191
|
+
default: (t) => `添加 '${t.key}' 子项`
|
|
192
192
|
}
|
|
193
193
|
},
|
|
194
194
|
emits: {
|
|
195
|
-
"update:modelValue": (
|
|
195
|
+
"update:modelValue": (t) => !0,
|
|
196
196
|
onReset: () => !0,
|
|
197
|
-
onMerge: (
|
|
197
|
+
onMerge: (t, i) => !0
|
|
198
198
|
},
|
|
199
|
-
setup(
|
|
200
|
-
emit:
|
|
201
|
-
expose:
|
|
199
|
+
setup(t, {
|
|
200
|
+
emit: i,
|
|
201
|
+
expose: f
|
|
202
202
|
}) {
|
|
203
203
|
const b = {
|
|
204
204
|
resetTxt: "重置",
|
|
205
205
|
newTxt: "添加项",
|
|
206
206
|
mergeTxt: "合并",
|
|
207
|
-
...
|
|
208
|
-
},
|
|
207
|
+
...t.btnConfigs
|
|
208
|
+
}, d = {
|
|
209
209
|
hideReset: !1,
|
|
210
210
|
maxHeight: "600px",
|
|
211
211
|
allowFilter: !0,
|
|
@@ -213,44 +213,44 @@ const L = /* @__PURE__ */ V({
|
|
|
213
213
|
showPad: !0,
|
|
214
214
|
retractLen: 0,
|
|
215
215
|
borderColors: [],
|
|
216
|
-
...
|
|
217
|
-
},
|
|
216
|
+
...t.configs
|
|
217
|
+
}, y = {
|
|
218
218
|
arraySplitSymbol: ",",
|
|
219
|
-
...
|
|
220
|
-
},
|
|
221
|
-
let l = s
|
|
222
|
-
const
|
|
223
|
-
return
|
|
224
|
-
rId:
|
|
225
|
-
key:
|
|
226
|
-
value: Object.prototype.toString.call(l) === "[object Object]" ?
|
|
227
|
-
isArray:
|
|
219
|
+
...t.dyListConfigs
|
|
220
|
+
}, v = (n) => ["string", "number"].includes(n), o = (n) => Object.keys(n).map((s, c) => {
|
|
221
|
+
let l = n[s];
|
|
222
|
+
const g = Array.isArray(l), A = g ? l.every((h) => typeof h == "number") : typeof l == "number", C = l === null;
|
|
223
|
+
return v(typeof l) && (l = n[s]), C && (l = ""), {
|
|
224
|
+
rId: t.randomFun(c),
|
|
225
|
+
key: s,
|
|
226
|
+
value: Object.prototype.toString.call(l) === "[object Object]" ? o(n[s]) : g ? l.join(y.arraySplitSymbol) : l,
|
|
227
|
+
isArray: g || void 0,
|
|
228
228
|
isNumber: A || void 0
|
|
229
229
|
};
|
|
230
|
-
}),
|
|
231
|
-
const l =
|
|
232
|
-
return
|
|
233
|
-
}, {}),
|
|
234
|
-
class: [`depth-${
|
|
230
|
+
}), r = (n) => n.reduce((s, c) => {
|
|
231
|
+
const l = c.value;
|
|
232
|
+
return c.key.trim().length && (s[c.key] = Array.isArray(l) ? r(l) : L(c.value, c.isArray, c.isNumber, y.arraySplitSymbol)), s;
|
|
233
|
+
}, {}), e = V(o(t.modelValue)), u = (n, s = 1, c) => a("div", {
|
|
234
|
+
class: [`depth-${s}`, d.showBorder ? "" : "no-border", d.showPad ? "" : "no-pad"],
|
|
235
235
|
style: {
|
|
236
|
-
"--depth":
|
|
237
|
-
["--c" + [
|
|
236
|
+
"--depth": s,
|
|
237
|
+
["--c" + [s]]: M(d.borderColors, s)
|
|
238
238
|
}
|
|
239
|
-
}, [
|
|
240
|
-
const
|
|
239
|
+
}, [n.map((l, g, A) => {
|
|
240
|
+
const C = Array.isArray(l.value), h = v(typeof l.value);
|
|
241
241
|
return a("div", {
|
|
242
242
|
class: "dItem",
|
|
243
243
|
key: l.rId,
|
|
244
244
|
style: {
|
|
245
|
-
marginLeft:
|
|
245
|
+
marginLeft: s > 1 ? `${s * d.retractLen}px` : "0"
|
|
246
246
|
}
|
|
247
247
|
}, [a("div", {
|
|
248
248
|
class: "input"
|
|
249
|
-
}, [!
|
|
249
|
+
}, [!C && a(x, null, [a("input", {
|
|
250
250
|
value: l.key,
|
|
251
251
|
class: "key nativeInput",
|
|
252
|
-
onInput: (
|
|
253
|
-
}, null),
|
|
252
|
+
onInput: (S) => l.key = S.target.value
|
|
253
|
+
}, null), m(":")]), a("div", {
|
|
254
254
|
class: "vInput"
|
|
255
255
|
}, [a("div", {
|
|
256
256
|
class: "slot"
|
|
@@ -259,108 +259,145 @@ const L = /* @__PURE__ */ V({
|
|
|
259
259
|
onClick: () => {
|
|
260
260
|
l.isArray = !l.isArray;
|
|
261
261
|
}
|
|
262
|
-
}, [
|
|
262
|
+
}, [m("Array")]), m(" "), a("button", {
|
|
263
263
|
class: [l.isNumber ? "success" : "default", "small", "bt"],
|
|
264
264
|
onClick: () => {
|
|
265
265
|
l.isNumber = !l.isNumber;
|
|
266
266
|
}
|
|
267
|
-
}, [
|
|
268
|
-
class: `value nativeV ${
|
|
269
|
-
value:
|
|
270
|
-
onInput: (
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
l.key =
|
|
267
|
+
}, [m("Number")])])]), a("input", {
|
|
268
|
+
class: `value nativeV ${C ? "isKey" : ""}`,
|
|
269
|
+
value: h ? l.value : l.key,
|
|
270
|
+
onInput: (S) => {
|
|
271
|
+
const k = S.target.value;
|
|
272
|
+
if (C) {
|
|
273
|
+
l.key = k;
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
|
|
276
|
+
d.allowFilter && l.isNumber ? l.value = R(k, l.isArray, y.arraySplitSymbol) : l.value = k;
|
|
277
277
|
}
|
|
278
278
|
}, null), a("div", {
|
|
279
279
|
class: "surSlot"
|
|
280
|
-
}, [
|
|
280
|
+
}, [s < t.depth ? !C && a("button", {
|
|
281
281
|
class: ["success", "bt"],
|
|
282
282
|
onClick: () => {
|
|
283
|
-
|
|
284
|
-
rId:
|
|
283
|
+
h && (l.value = [], l.isArray = void 0), l.value.push({
|
|
284
|
+
rId: t.randomFun(),
|
|
285
285
|
key: "",
|
|
286
286
|
value: ""
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
}, [
|
|
289
|
+
}, [t.newChildTxt(l)]) : null])])]), a("div", {
|
|
290
290
|
class: "btn"
|
|
291
291
|
}, [a("button", {
|
|
292
292
|
class: ["success", "bt"],
|
|
293
|
-
disabled:
|
|
293
|
+
disabled: g !== A.length - 1,
|
|
294
294
|
onClick: () => {
|
|
295
|
-
|
|
296
|
-
rId:
|
|
295
|
+
n.push({
|
|
296
|
+
rId: t.randomFun(),
|
|
297
297
|
key: "",
|
|
298
298
|
value: ""
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
}, [
|
|
301
|
+
}, [m("+")]), a("button", {
|
|
302
302
|
class: ["danger", "bt"],
|
|
303
303
|
onClick: () => {
|
|
304
|
-
if (
|
|
305
|
-
if (
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
...
|
|
304
|
+
if (n.splice(g, 1), n.length < 1) {
|
|
305
|
+
if (c === void 0) return r([]);
|
|
306
|
+
const S = e.value.findIndex((k) => k.rId === c?.rId);
|
|
307
|
+
s < 1 ? e.value.splice(S, 1, {
|
|
308
|
+
...c,
|
|
309
309
|
value: ""
|
|
310
|
-
}) :
|
|
310
|
+
}) : c.value = "";
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
}, [
|
|
313
|
+
}, [m("-")])]), Array.isArray(l.value) && u(l.value, s + 1, l)]);
|
|
314
314
|
})]);
|
|
315
|
-
return
|
|
316
|
-
if (!
|
|
317
|
-
const
|
|
318
|
-
|
|
315
|
+
return T(e, (n) => {
|
|
316
|
+
if (!t.isController) return;
|
|
317
|
+
const s = r(n);
|
|
318
|
+
i("update:modelValue", s), i("onMerge", s, I(e.value));
|
|
319
319
|
}, {
|
|
320
320
|
deep: !0
|
|
321
|
-
}),
|
|
322
|
-
onSet: (
|
|
323
|
-
|
|
321
|
+
}), f({
|
|
322
|
+
onSet: (n) => {
|
|
323
|
+
e.value = o(n ?? t.modelValue);
|
|
324
324
|
},
|
|
325
|
-
getResult: (
|
|
325
|
+
getResult: (n = "res") => n === "ori" ? I(e.value) : r(e.value)
|
|
326
326
|
}), () => a("div", {
|
|
327
|
-
class:
|
|
327
|
+
class: t.dyCls ?? "dynamicCascadeForm"
|
|
328
328
|
}, [a("div", {
|
|
329
329
|
class: "dyFormList",
|
|
330
330
|
style: {
|
|
331
|
-
maxHeight:
|
|
331
|
+
maxHeight: d.maxHeight
|
|
332
332
|
}
|
|
333
|
-
}, [
|
|
333
|
+
}, [u(e.value)]), a("div", {
|
|
334
334
|
class: "control"
|
|
335
|
-
}, [!
|
|
335
|
+
}, [!e.value.length && a("button", {
|
|
336
336
|
class: ["success", "bt"],
|
|
337
337
|
onClick: () => {
|
|
338
|
-
|
|
339
|
-
rId:
|
|
338
|
+
e.value.push({
|
|
339
|
+
rId: t.randomFun(),
|
|
340
340
|
key: "",
|
|
341
341
|
value: ""
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
|
-
}, [b.newTxt]), !
|
|
344
|
+
}, [b.newTxt]), !t.isController && a(x, null, [!d.hideReset && a("button", {
|
|
345
345
|
class: ["default", "bt"],
|
|
346
346
|
onClick: () => {
|
|
347
|
-
|
|
347
|
+
e.value = o(t.modelValue), i("onReset");
|
|
348
348
|
}
|
|
349
349
|
}, [b.resetTxt]), a("button", {
|
|
350
350
|
class: ["info", "bt"],
|
|
351
351
|
onClick: () => {
|
|
352
|
-
const
|
|
353
|
-
|
|
352
|
+
const n = r(e.value);
|
|
353
|
+
i("update:modelValue", n), i("onMerge", n, I(e.value)), e.value = o(n);
|
|
354
354
|
}
|
|
355
355
|
}, [b.mergeTxt])])])]);
|
|
356
356
|
}
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
});
|
|
358
|
+
function E(t, i = !0) {
|
|
359
|
+
return i ? t.map((f) => O(f)) : t;
|
|
360
|
+
}
|
|
361
|
+
function P(t) {
|
|
362
|
+
const i = () => D(t), f = (r, e) => {
|
|
363
|
+
i().forEach((u) => {
|
|
364
|
+
const n = u.key;
|
|
365
|
+
(!e || e.includes(n)) && (u.disabled = r);
|
|
366
|
+
});
|
|
367
|
+
}, b = (r, e) => {
|
|
368
|
+
i().forEach((u) => {
|
|
369
|
+
const n = u.key;
|
|
370
|
+
(!e || e.includes(n)) && (u.hidden = r);
|
|
371
|
+
});
|
|
372
|
+
}, d = (r, e) => {
|
|
373
|
+
const u = i().find((n) => n.key === r);
|
|
374
|
+
u && (w(u.value) ? u.value.value = e : u.value = e);
|
|
375
|
+
};
|
|
376
|
+
return { setDisabled: f, setHidden: b, setValue: d, setValues: (r) => {
|
|
377
|
+
Object.entries(r).forEach(([e, u]) => {
|
|
378
|
+
d(e, u);
|
|
379
|
+
});
|
|
380
|
+
}, getValue: (r) => i().find((e) => e.key === r), getValues: (r) => {
|
|
381
|
+
const e = r && r.length ? new Set(r) : null;
|
|
382
|
+
return i().reduce((u, n) => {
|
|
383
|
+
const s = n.key;
|
|
384
|
+
if (!e || e.has(s)) {
|
|
385
|
+
const c = w(n.value) ? n.value.value : n.value;
|
|
386
|
+
u[s] = c;
|
|
387
|
+
}
|
|
388
|
+
return u;
|
|
389
|
+
}, {});
|
|
390
|
+
} };
|
|
391
|
+
}
|
|
392
|
+
const q = {
|
|
393
|
+
install(t) {
|
|
394
|
+
t.component("DynamicInput", $), t.component("DynamicCascadeInput", H);
|
|
360
395
|
}
|
|
361
396
|
};
|
|
362
397
|
export {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
398
|
+
H as DynamicCascadeInput,
|
|
399
|
+
$ as DynamicInput,
|
|
400
|
+
q as DynamicInputPlugin,
|
|
401
|
+
P as useDyForm,
|
|
402
|
+
E as useReactiveForm
|
|
366
403
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { FormProps, GridProps } from 'naive-ui';
|
|
3
|
+
import { DyFormItem } from '../types/form';
|
|
4
|
+
import { FormRules } from 'naive-ui/es/form/src/interface';
|
|
5
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
6
|
+
formConfig: {
|
|
7
|
+
type: PropType<FormProps>;
|
|
8
|
+
default: () => {
|
|
9
|
+
labelPlacement: string;
|
|
10
|
+
size: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
gridConfig: {
|
|
14
|
+
type: PropType<GridProps>;
|
|
15
|
+
default: () => {
|
|
16
|
+
responsive: string;
|
|
17
|
+
cols: string;
|
|
18
|
+
xGap: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
rules: {
|
|
22
|
+
type: PropType<FormRules>;
|
|
23
|
+
};
|
|
24
|
+
preset: {
|
|
25
|
+
type: PropType<"fullRow" | "grid">;
|
|
26
|
+
default: string;
|
|
27
|
+
validator: (value: string) => boolean;
|
|
28
|
+
};
|
|
29
|
+
items: {
|
|
30
|
+
type: PropType<Array<DyFormItem>>;
|
|
31
|
+
require: boolean;
|
|
32
|
+
};
|
|
33
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
34
|
+
formConfig: {
|
|
35
|
+
type: PropType<FormProps>;
|
|
36
|
+
default: () => {
|
|
37
|
+
labelPlacement: string;
|
|
38
|
+
size: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
gridConfig: {
|
|
42
|
+
type: PropType<GridProps>;
|
|
43
|
+
default: () => {
|
|
44
|
+
responsive: string;
|
|
45
|
+
cols: string;
|
|
46
|
+
xGap: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
rules: {
|
|
50
|
+
type: PropType<FormRules>;
|
|
51
|
+
};
|
|
52
|
+
preset: {
|
|
53
|
+
type: PropType<"fullRow" | "grid">;
|
|
54
|
+
default: string;
|
|
55
|
+
validator: (value: string) => boolean;
|
|
56
|
+
};
|
|
57
|
+
items: {
|
|
58
|
+
type: PropType<Array<DyFormItem>>;
|
|
59
|
+
require: boolean;
|
|
60
|
+
};
|
|
61
|
+
}>> & Readonly<{}>, {
|
|
62
|
+
formConfig: FormProps;
|
|
63
|
+
gridConfig: GridProps;
|
|
64
|
+
preset: "fullRow" | "grid";
|
|
65
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
66
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RadioProps, CheckboxGroupProps, CheckboxProps, DatePickerProps, InputProps, PopselectProps, RadioButtonProps, RadioGroupProps, SelectOption, SelectProps, SwitchProps, TimePickerProps, TreeSelectProps } from 'naive-ui';
|
|
2
|
+
import { Value as DatePickerValue } from 'naive-ui/lib/date-picker/src/interface';
|
|
3
|
+
import { SelectGroupOption, Value as SelectValue } from 'naive-ui/lib/select/src/interface';
|
|
4
|
+
import { TreeSelectOption, Value } from 'naive-ui/lib/tree-select/src/interface';
|
|
5
|
+
import { AllowedComponentProps, Ref, VNode } from 'vue';
|
|
6
|
+
import { DyFormItem } from '../../types/form.ts';
|
|
7
|
+
export declare function renderInput(model: Ref<string>, optionProps?: InputProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function renderSelect(model: Ref<SelectValue>, options: SelectOption[], optionProps?: SelectProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function renderPopSelect(model: Ref<string | number | Array<string | number> | null>, options: Array<SelectOption | SelectGroupOption>, optionProps?: PopselectProps | AllowedComponentProps, rf?: DyFormItem, defaultRender?: VNode): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function renderTreeSelect(model: Ref<Value>, options: TreeSelectOption[], optionProps?: TreeSelectProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function renderRadioGroup(value: Ref<string | number | null | undefined>, options: RadioProps[], optionProps?: RadioGroupProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function renderRadioButtonGroup(value: Ref<string | number | null | undefined>, options: RadioButtonProps[], optionProps?: RadioGroupProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}>;
|
|
25
|
+
export declare function renderCheckboxGroup(model: Ref<(string | number)[]>, options: CheckboxProps[], optionProps?: CheckboxGroupProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function renderSwitch(value: Ref<boolean>, optionProps?: SwitchProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function renderDatePicker(value: Ref<DatePickerValue>, optionProps?: DatePickerProps | AllowedComponentProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function renderTimePicker(value: Ref<number | null>, optionProps?: TimePickerProps, rf?: DyFormItem): VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}>;
|