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/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { t as p, r as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as N, ref as w, watch as R, toRaw as h, createVNode as n, createTextVNode as v, nextTick as j, Fragment as x, shallowReactive as O, unref as D, isRef as F } from "vue";
|
|
2
|
+
import { t as p, r as V, f as T, 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, r) => !0
|
|
37
37
|
},
|
|
38
|
-
setup(
|
|
39
|
-
emit:
|
|
40
|
-
expose:
|
|
38
|
+
setup(t, {
|
|
39
|
+
emit: r,
|
|
40
|
+
expose: f
|
|
41
41
|
}) {
|
|
42
|
-
const
|
|
42
|
+
const m = {
|
|
43
43
|
resetTxt: "重置",
|
|
44
44
|
newTxt: "添加项",
|
|
45
45
|
mergeTxt: "合并",
|
|
46
|
-
...
|
|
47
|
-
},
|
|
46
|
+
...t.btnConfigs
|
|
47
|
+
}, c = {
|
|
48
48
|
hideReset: !1,
|
|
49
49
|
maxHeight: "300px",
|
|
50
50
|
autoScroll: !0,
|
|
51
51
|
allowFilter: !0,
|
|
52
|
-
...
|
|
53
|
-
},
|
|
52
|
+
...t.configs
|
|
53
|
+
}, d = {
|
|
54
54
|
arraySplitSymbol: ",",
|
|
55
|
-
...
|
|
56
|
-
}, y =
|
|
57
|
-
return
|
|
58
|
-
if (!
|
|
59
|
-
const
|
|
60
|
-
|
|
55
|
+
...t.dyListConfigs
|
|
56
|
+
}, y = t.size, o = w(p(t.modelValue, t.randomFun, d.arraySplitSymbol)), b = w(null);
|
|
57
|
+
return R(o, (e) => {
|
|
58
|
+
if (!t.isController) return;
|
|
59
|
+
const u = V(e, d.arraySplitSymbol);
|
|
60
|
+
r("update:modelValue", u), r("onMerge", u, h(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, d.arraySplitSymbol);
|
|
66
66
|
},
|
|
67
|
-
getResult: (
|
|
68
|
-
}), () =>
|
|
69
|
-
class:
|
|
70
|
-
}, [
|
|
67
|
+
getResult: (e = "res") => e === "ori" ? h(o.value) : V(o.value, d.arraySplitSymbol)
|
|
68
|
+
}), () => n("div", {
|
|
69
|
+
class: t.dyCls ?? `dynamicForm ${y}`
|
|
70
|
+
}, [n("div", {
|
|
71
71
|
class: "dyFormList",
|
|
72
|
-
ref:
|
|
72
|
+
ref: b,
|
|
73
73
|
style: {
|
|
74
|
-
maxHeight:
|
|
74
|
+
maxHeight: c.maxHeight
|
|
75
75
|
}
|
|
76
|
-
}, [
|
|
76
|
+
}, [o.value.map((e, u, l) => n("div", {
|
|
77
77
|
class: "dItem",
|
|
78
|
-
key:
|
|
79
|
-
}, [
|
|
78
|
+
key: e.rId
|
|
79
|
+
}, [n("div", {
|
|
80
80
|
class: "input"
|
|
81
|
-
}, [
|
|
81
|
+
}, [n("input", {
|
|
82
82
|
size: y,
|
|
83
|
-
value:
|
|
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), v(":"), n("div", {
|
|
89
89
|
class: "vInput"
|
|
90
|
-
}, [
|
|
90
|
+
}, [n("div", {
|
|
91
91
|
class: "slot"
|
|
92
|
-
}, [
|
|
93
|
-
class: [
|
|
92
|
+
}, [n("button", {
|
|
93
|
+
class: [e.isArray ? "success" : "default", "small", "bt"],
|
|
94
94
|
onClick: () => {
|
|
95
|
-
|
|
95
|
+
e.isArray = !e.isArray;
|
|
96
96
|
}
|
|
97
|
-
}, [
|
|
98
|
-
class: [
|
|
97
|
+
}, [v("Array")]), v(" "), n("button", {
|
|
98
|
+
class: [e.isNumber ? "success" : "default", "small", "bt"],
|
|
99
99
|
onClick: () => {
|
|
100
|
-
|
|
100
|
+
e.isNumber = !e.isNumber;
|
|
101
101
|
}
|
|
102
|
-
}, [
|
|
102
|
+
}, [v("Number")])]), n("input", {
|
|
103
103
|
size: y,
|
|
104
|
-
value:
|
|
104
|
+
value: e.value,
|
|
105
105
|
class: "value nativeV",
|
|
106
|
-
onInput: (
|
|
107
|
-
const
|
|
108
|
-
|
|
106
|
+
onInput: (s) => {
|
|
107
|
+
const i = s.target.value;
|
|
108
|
+
c.allowFilter && e.isNumber ? e.value = T(i, e.isArray, d.arraySplitSymbol) : e.value = i;
|
|
109
109
|
}
|
|
110
|
-
}, null)])]),
|
|
110
|
+
}, null)])]), n("div", {
|
|
111
111
|
class: "btn"
|
|
112
|
-
}, [
|
|
112
|
+
}, [n("button", {
|
|
113
113
|
class: [y, "success", "bt"],
|
|
114
|
-
disabled:
|
|
114
|
+
disabled: u !== l.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
|
+
}), c.autoScroll && j(() => {
|
|
121
|
+
const s = b.value;
|
|
122
|
+
s?.scrollTo({
|
|
123
|
+
top: s.scrollHeight,
|
|
124
124
|
behavior: "smooth"
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
}, [
|
|
128
|
+
}, [v("+")]), n("button", {
|
|
129
129
|
class: ["danger", y, "bt"],
|
|
130
130
|
onClick: () => {
|
|
131
|
-
|
|
131
|
+
o.value = o.value.filter((s) => s.rId !== e.rId);
|
|
132
132
|
}
|
|
133
|
-
}, [
|
|
133
|
+
}, [v("-")])])]))]), n("div", {
|
|
134
134
|
class: "control"
|
|
135
|
-
}, [!
|
|
135
|
+
}, [!o.value.length && n("button", {
|
|
136
136
|
class: ["success", y, "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
|
-
}, [
|
|
144
|
+
}, [m.newTxt]), !t.isController && n(x, null, [!c.hideReset && n("button", {
|
|
145
145
|
class: ["default", y, "bt"],
|
|
146
146
|
onClick: () => {
|
|
147
|
-
|
|
147
|
+
o.value = p(t.modelValue, t.randomFun, d.arraySplitSymbol), r("onReset");
|
|
148
148
|
}
|
|
149
|
-
}, [
|
|
149
|
+
}, [m.resetTxt]), n("button", {
|
|
150
150
|
class: ["info", y, "bt"],
|
|
151
151
|
onClick: () => {
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
152
|
+
o.value.sort((u, l) => +u.rId - +l.rId);
|
|
153
|
+
const e = V(o.value, d.arraySplitSymbol);
|
|
154
|
+
r("update:modelValue", e), r("onMerge", e, h(o.value)), o.value = p(e, t.randomFun, d.arraySplitSymbol);
|
|
155
155
|
}
|
|
156
|
-
}, [
|
|
156
|
+
}, [m.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, r) => !0
|
|
198
198
|
},
|
|
199
|
-
setup(
|
|
200
|
-
emit:
|
|
201
|
-
expose:
|
|
199
|
+
setup(t, {
|
|
200
|
+
emit: r,
|
|
201
|
+
expose: f
|
|
202
202
|
}) {
|
|
203
|
-
const
|
|
203
|
+
const m = {
|
|
204
204
|
resetTxt: "重置",
|
|
205
205
|
newTxt: "添加项",
|
|
206
206
|
mergeTxt: "合并",
|
|
207
|
-
...
|
|
208
|
-
},
|
|
207
|
+
...t.btnConfigs
|
|
208
|
+
}, c = {
|
|
209
209
|
hideReset: !1,
|
|
210
210
|
maxHeight: "600px",
|
|
211
211
|
allowFilter: !0,
|
|
@@ -213,154 +213,195 @@ const L = /* @__PURE__ */ V({
|
|
|
213
213
|
showPad: !0,
|
|
214
214
|
retractLen: 0,
|
|
215
215
|
borderColors: [],
|
|
216
|
-
...
|
|
217
|
-
},
|
|
216
|
+
...t.configs
|
|
217
|
+
}, d = {
|
|
218
218
|
arraySplitSymbol: ",",
|
|
219
|
-
...
|
|
220
|
-
}, y = (
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
return y(typeof
|
|
224
|
-
rId:
|
|
225
|
-
key:
|
|
226
|
-
value: Object.prototype.toString.call(
|
|
227
|
-
isArray:
|
|
219
|
+
...t.dyListConfigs
|
|
220
|
+
}, y = (l) => ["string", "number"].includes(l), o = (l) => Object.keys(l).map((s, i) => {
|
|
221
|
+
let a = l[s];
|
|
222
|
+
const g = Array.isArray(a), A = g ? a.every((S) => typeof S == "number") : typeof a == "number", C = a === null;
|
|
223
|
+
return y(typeof a) && (a = l[s]), C && (a = ""), {
|
|
224
|
+
rId: t.randomFun(i),
|
|
225
|
+
key: s,
|
|
226
|
+
value: Object.prototype.toString.call(a) === "[object Object]" ? o(l[s]) : g ? a.join(d.arraySplitSymbol) : a,
|
|
227
|
+
isArray: g || void 0,
|
|
228
228
|
isNumber: A || void 0
|
|
229
229
|
};
|
|
230
|
-
}),
|
|
231
|
-
const
|
|
232
|
-
return
|
|
233
|
-
}, {}),
|
|
234
|
-
class: [`depth-${
|
|
230
|
+
}), b = (l) => l.reduce((s, i) => {
|
|
231
|
+
const a = i.value;
|
|
232
|
+
return i.key.trim().length && (s[i.key] = Array.isArray(a) ? b(a) : L(i.value, i.isArray, i.isNumber, d.arraySplitSymbol)), s;
|
|
233
|
+
}, {}), e = w(o(t.modelValue)), u = (l, s = 1, i) => n("div", {
|
|
234
|
+
class: [`depth-${s}`, c.showBorder ? "" : "no-border", c.showPad ? "" : "no-pad"],
|
|
235
235
|
style: {
|
|
236
|
-
"--depth":
|
|
237
|
-
["--c" + [
|
|
236
|
+
"--depth": s,
|
|
237
|
+
["--c" + [s]]: M(c.borderColors, s)
|
|
238
238
|
}
|
|
239
|
-
}, [
|
|
240
|
-
const
|
|
241
|
-
return
|
|
239
|
+
}, [l.map((a, g, A) => {
|
|
240
|
+
const C = Array.isArray(a.value), S = y(typeof a.value);
|
|
241
|
+
return n("div", {
|
|
242
242
|
class: "dItem",
|
|
243
|
-
key:
|
|
243
|
+
key: a.rId,
|
|
244
244
|
style: {
|
|
245
|
-
marginLeft:
|
|
245
|
+
marginLeft: s > 1 ? `${s * c.retractLen}px` : "0"
|
|
246
246
|
}
|
|
247
|
-
}, [
|
|
247
|
+
}, [n("div", {
|
|
248
248
|
class: "input"
|
|
249
|
-
}, [!
|
|
250
|
-
value:
|
|
249
|
+
}, [!C && n(x, null, [n("input", {
|
|
250
|
+
value: a.key,
|
|
251
251
|
class: "key nativeInput",
|
|
252
|
-
onInput: (I) =>
|
|
253
|
-
}, null),
|
|
252
|
+
onInput: (I) => a.key = I.target.value
|
|
253
|
+
}, null), v(":")]), n("div", {
|
|
254
254
|
class: "vInput"
|
|
255
|
-
}, [
|
|
255
|
+
}, [n("div", {
|
|
256
256
|
class: "slot"
|
|
257
|
-
}, [Array.isArray(
|
|
258
|
-
class: [
|
|
257
|
+
}, [Array.isArray(a.value) ? void 0 : n(x, null, [n("button", {
|
|
258
|
+
class: [a.isArray ? "success" : "default", "small", "bt"],
|
|
259
259
|
onClick: () => {
|
|
260
|
-
|
|
260
|
+
a.isArray = !a.isArray;
|
|
261
261
|
}
|
|
262
|
-
}, [
|
|
263
|
-
class: [
|
|
262
|
+
}, [v("Array")]), v(" "), n("button", {
|
|
263
|
+
class: [a.isNumber ? "success" : "default", "small", "bt"],
|
|
264
264
|
onClick: () => {
|
|
265
|
-
|
|
265
|
+
a.isNumber = !a.isNumber;
|
|
266
266
|
}
|
|
267
|
-
}, [
|
|
268
|
-
class: `value nativeV ${
|
|
269
|
-
value: S ?
|
|
267
|
+
}, [v("Number")])])]), n("input", {
|
|
268
|
+
class: `value nativeV ${C ? "isKey" : ""}`,
|
|
269
|
+
value: S ? a.value : a.key,
|
|
270
270
|
onInput: (I) => {
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
|
|
271
|
+
const k = I.target.value;
|
|
272
|
+
if (C) {
|
|
273
|
+
a.key = k;
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
|
|
276
|
+
c.allowFilter && a.isNumber ? a.value = T(k, a.isArray, d.arraySplitSymbol) : a.value = k;
|
|
277
277
|
}
|
|
278
|
-
}, null),
|
|
278
|
+
}, null), n("div", {
|
|
279
279
|
class: "surSlot"
|
|
280
|
-
}, [
|
|
280
|
+
}, [s < t.depth ? !C && n("button", {
|
|
281
281
|
class: ["success", "bt"],
|
|
282
282
|
onClick: () => {
|
|
283
|
-
S && (
|
|
284
|
-
rId:
|
|
283
|
+
S && (a.value = [], a.isArray = void 0), a.value.push({
|
|
284
|
+
rId: t.randomFun(),
|
|
285
285
|
key: "",
|
|
286
286
|
value: ""
|
|
287
287
|
});
|
|
288
288
|
}
|
|
289
|
-
}, [
|
|
289
|
+
}, [t.newChildTxt(a)]) : null])])]), n("div", {
|
|
290
290
|
class: "btn"
|
|
291
|
-
}, [
|
|
291
|
+
}, [n("button", {
|
|
292
292
|
class: ["success", "bt"],
|
|
293
|
-
disabled:
|
|
293
|
+
disabled: g !== A.length - 1,
|
|
294
294
|
onClick: () => {
|
|
295
|
-
|
|
296
|
-
rId:
|
|
295
|
+
l.push({
|
|
296
|
+
rId: t.randomFun(),
|
|
297
297
|
key: "",
|
|
298
298
|
value: ""
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
}, [
|
|
301
|
+
}, [v("+")]), n("button", {
|
|
302
302
|
class: ["danger", "bt"],
|
|
303
303
|
onClick: () => {
|
|
304
|
-
if (
|
|
305
|
-
if (
|
|
306
|
-
const I =
|
|
307
|
-
|
|
308
|
-
...
|
|
304
|
+
if (l.splice(g, 1), l.length < 1) {
|
|
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
309
|
value: ""
|
|
310
|
-
}) :
|
|
310
|
+
}) : i.value = "";
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
-
}, [
|
|
313
|
+
}, [v("-")])]), Array.isArray(a.value) && u(a.value, s + 1, a)]);
|
|
314
314
|
})]);
|
|
315
|
-
return
|
|
316
|
-
if (!
|
|
317
|
-
const
|
|
318
|
-
|
|
315
|
+
return R(e, (l) => {
|
|
316
|
+
if (!t.isController) return;
|
|
317
|
+
const s = b(l);
|
|
318
|
+
r("update:modelValue", s), r("onMerge", s, h(e.value));
|
|
319
319
|
}, {
|
|
320
320
|
deep: !0
|
|
321
|
-
}),
|
|
322
|
-
onSet: (
|
|
323
|
-
|
|
321
|
+
}), f({
|
|
322
|
+
onSet: (l) => {
|
|
323
|
+
e.value = o(l ?? t.modelValue);
|
|
324
324
|
},
|
|
325
|
-
getResult: (
|
|
326
|
-
}), () =>
|
|
327
|
-
class:
|
|
328
|
-
}, [
|
|
325
|
+
getResult: (l = "res") => l === "ori" ? h(e.value) : b(e.value)
|
|
326
|
+
}), () => n("div", {
|
|
327
|
+
class: t.dyCls ?? "dynamicCascadeForm"
|
|
328
|
+
}, [n("div", {
|
|
329
329
|
class: "dyFormList",
|
|
330
330
|
style: {
|
|
331
|
-
maxHeight:
|
|
331
|
+
maxHeight: c.maxHeight
|
|
332
332
|
}
|
|
333
|
-
}, [
|
|
333
|
+
}, [u(e.value)]), n("div", {
|
|
334
334
|
class: "control"
|
|
335
|
-
}, [!
|
|
335
|
+
}, [!e.value.length && n("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
|
-
}, [
|
|
344
|
+
}, [m.newTxt]), !t.isController && n(x, null, [!c.hideReset && n("button", {
|
|
345
345
|
class: ["default", "bt"],
|
|
346
346
|
onClick: () => {
|
|
347
|
-
|
|
347
|
+
e.value = o(t.modelValue), r("onReset");
|
|
348
348
|
}
|
|
349
|
-
}, [
|
|
349
|
+
}, [m.resetTxt]), n("button", {
|
|
350
350
|
class: ["info", "bt"],
|
|
351
351
|
onClick: () => {
|
|
352
|
-
const
|
|
353
|
-
|
|
352
|
+
const l = b(e.value);
|
|
353
|
+
r("update:modelValue", l), r("onMerge", l, h(e.value)), e.value = o(l);
|
|
354
354
|
}
|
|
355
|
-
}, [
|
|
355
|
+
}, [m.mergeTxt])])])]);
|
|
356
356
|
}
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
});
|
|
358
|
+
function E(t, r = !0) {
|
|
359
|
+
return r ? t.map((f) => O(f)) : t;
|
|
360
|
+
}
|
|
361
|
+
function P(t) {
|
|
362
|
+
const r = () => D(t), f = (e, u) => {
|
|
363
|
+
r().forEach((l) => {
|
|
364
|
+
const s = l.key;
|
|
365
|
+
(!u || u.includes(s)) && (l.disabled = e);
|
|
366
|
+
});
|
|
367
|
+
}, m = (e, u) => {
|
|
368
|
+
r().forEach((l) => {
|
|
369
|
+
const s = l.key;
|
|
370
|
+
(!u || u.includes(s)) && (l.hidden = e);
|
|
371
|
+
});
|
|
372
|
+
}, c = (e, u) => {
|
|
373
|
+
const l = r().find((s) => s.key === e);
|
|
374
|
+
l && (F(l.value) ? l.value.value = u : l.value = u);
|
|
375
|
+
};
|
|
376
|
+
return { setDisabled: f, setHidden: m, setValue: c, setValues: (e) => {
|
|
377
|
+
Object.entries(e).forEach(([u, l]) => {
|
|
378
|
+
c(u, l);
|
|
379
|
+
});
|
|
380
|
+
}, getValue: (e) => r().find((u) => u.key === e), getValues: (e) => {
|
|
381
|
+
const u = e && e.length ? new Set(e) : null;
|
|
382
|
+
return r().reduce((l, s) => {
|
|
383
|
+
const i = s.key;
|
|
384
|
+
if (!u || u.has(i)) {
|
|
385
|
+
const a = F(s.value) ? s.value.value : s.value;
|
|
386
|
+
l[i] = a;
|
|
387
|
+
}
|
|
388
|
+
return l;
|
|
389
|
+
}, {});
|
|
390
|
+
}, onReset: (e = null) => {
|
|
391
|
+
r().forEach((u) => {
|
|
392
|
+
F(u.value) ? u.value.value = e : u.value = e;
|
|
393
|
+
});
|
|
394
|
+
} };
|
|
395
|
+
}
|
|
396
|
+
const q = {
|
|
397
|
+
install(t) {
|
|
398
|
+
t.component("DynamicInput", $), t.component("DynamicCascadeInput", H);
|
|
360
399
|
}
|
|
361
400
|
};
|
|
362
401
|
export {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
402
|
+
H as DynamicCascadeInput,
|
|
403
|
+
$ as DynamicInput,
|
|
404
|
+
q as DynamicInputPlugin,
|
|
405
|
+
P as useDyForm,
|
|
406
|
+
E as useReactiveForm
|
|
366
407
|
};
|
|
@@ -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
|
+
}>;
|