@volverjs/form-vue 1.0.0 → 1.0.2
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/dist/VvFormField.d.ts +4 -4
- package/dist/VvFormFieldsGroup.d.ts +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.es.js +681 -607
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +15 -15
- package/src/VvFormField.ts +14 -14
- package/src/VvFormFieldsGroup.ts +7 -6
- package/src/VvFormTemplate.ts +118 -118
- package/src/types.ts +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { watchIgnorable as pe, throttleFilter as
|
|
3
|
-
import { ZodObject as
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
let
|
|
8
|
-
for (;
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
},
|
|
12
|
-
let
|
|
13
|
-
for (;
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
},
|
|
1
|
+
import { ref as K, computed as I, readonly as G, defineComponent as _, h as R, withModifiers as ee, toRaw as W, watch as A, isProxy as ve, onMounted as J, provide as q, toRefs as Q, useId as ae, inject as B, onBeforeUnmount as U, unref as P, resolveComponent as $, defineAsyncComponent as ce, getCurrentInstance as me } from "vue";
|
|
2
|
+
import { watchIgnorable as pe, throttleFilter as he } from "@vueuse/core";
|
|
3
|
+
import { ZodObject as C, ZodDefault as ye, ZodNullable as be, ZodSchema as ge, ZodArray as we, ZodRecord as Ve, ZodEffects as re, ZodOptional as te, ZodError as xe } from "zod";
|
|
4
|
+
var V = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.tel = "tel", e.url = "url", e.search = "search", e.date = "date", e.time = "time", e.datetimeLocal = "datetime-local", e.month = "month", e.week = "week", e.color = "color", e.select = "select", e.checkbox = "checkbox", e.radio = "radio", e.textarea = "textarea", e.radioGroup = "radioGroup", e.checkboxGroup = "checkboxGroup", e.combobox = "combobox", e.custom = "custom", e))(V || {}), S = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(S || {});
|
|
5
|
+
function M(e, a = {}) {
|
|
6
|
+
const r = (d) => {
|
|
7
|
+
let l = d;
|
|
8
|
+
for (; l instanceof re; )
|
|
9
|
+
l = l.innerType();
|
|
10
|
+
return l instanceof te && (l = l._def.innerType), l;
|
|
11
|
+
}, i = (d) => {
|
|
12
|
+
let l = d;
|
|
13
|
+
for (; l instanceof re; )
|
|
14
|
+
l = l.innerType();
|
|
15
|
+
return l instanceof te;
|
|
16
|
+
}, t = r(e);
|
|
17
17
|
return {
|
|
18
|
-
...(
|
|
18
|
+
...(t instanceof C ? t._def.unknownKeys === "passthrough" : !1) ? a : {},
|
|
19
19
|
...Object.fromEntries(
|
|
20
|
-
Object.entries(
|
|
21
|
-
([
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
return [
|
|
26
|
-
if (
|
|
27
|
-
return [
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
return [
|
|
20
|
+
Object.entries(t.shape).map(
|
|
21
|
+
([d, l]) => {
|
|
22
|
+
const u = a[d], c = i(l);
|
|
23
|
+
let f = r(l), m;
|
|
24
|
+
if (f instanceof ye && (m = f._def.defaultValue(), f = f._def.innerType), u === null && f instanceof be)
|
|
25
|
+
return [d, u];
|
|
26
|
+
if (u == null && c)
|
|
27
|
+
return [d, m];
|
|
28
|
+
if (f instanceof ge) {
|
|
29
|
+
const p = l.safeParse(u);
|
|
30
|
+
if (p.success)
|
|
31
|
+
return [d, p.data ?? m];
|
|
32
32
|
}
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
33
|
+
if (f instanceof we && Array.isArray(u) && u.length) {
|
|
34
|
+
const p = r(f._def.type);
|
|
35
|
+
if (p instanceof C)
|
|
36
36
|
return [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
d,
|
|
38
|
+
u.map(
|
|
39
|
+
(D) => M(
|
|
40
|
+
p,
|
|
41
|
+
D && typeof D == "object" ? D : void 0
|
|
42
42
|
)
|
|
43
43
|
)
|
|
44
44
|
];
|
|
45
45
|
}
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
return [
|
|
46
|
+
if (f instanceof Ve && u) {
|
|
47
|
+
const p = r(f._def.valueType);
|
|
48
|
+
if (p instanceof C)
|
|
49
|
+
return [d, Object.keys(u).reduce((D, h) => (D[h] = M(p, u[h]), D), {})];
|
|
50
50
|
}
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
return f instanceof C ? [
|
|
52
|
+
d,
|
|
53
|
+
M(
|
|
54
|
+
f,
|
|
55
|
+
u && typeof u == "object" ? u : m
|
|
56
56
|
)
|
|
57
|
-
] : [
|
|
57
|
+
] : [d, m];
|
|
58
58
|
}
|
|
59
59
|
)
|
|
60
60
|
)
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
let
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
return new
|
|
63
|
+
function De(e, a, r, i, t) {
|
|
64
|
+
const o = K(), d = K(), l = I(() => d.value === S.invalid), u = K(), c = K(!1);
|
|
65
|
+
let f;
|
|
66
|
+
const m = (x) => {
|
|
67
|
+
const O = M(e, x);
|
|
68
|
+
if (r?.class) {
|
|
69
|
+
const n = r.class;
|
|
70
|
+
return new n(O);
|
|
71
71
|
}
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
if (
|
|
72
|
+
return O;
|
|
73
|
+
}, p = async (x = u.value, O) => {
|
|
74
|
+
if (f = O?.fields, c.value)
|
|
75
75
|
return !0;
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
80
|
-
const
|
|
81
|
-
(
|
|
76
|
+
const n = O?.superRefine ? await e.superRefine(O.superRefine).safeParseAsync(x) : await e.safeParseAsync(x);
|
|
77
|
+
if (!n.success) {
|
|
78
|
+
if (d.value = S.invalid, !f?.size)
|
|
79
|
+
return o.value = n.error.format(), !1;
|
|
80
|
+
const w = n.error.issues.filter(
|
|
81
|
+
(N) => f?.has(N.path.join("."))
|
|
82
82
|
);
|
|
83
|
-
return
|
|
83
|
+
return w.length ? (o.value = new xe(w).format(), !1) : (o.value = void 0, !0);
|
|
84
84
|
}
|
|
85
|
-
return
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
85
|
+
return o.value = void 0, d.value = S.valid, u.value = m(n.data), !0;
|
|
86
|
+
}, D = () => {
|
|
87
|
+
o.value = void 0, d.value = void 0, f = void 0;
|
|
88
|
+
}, h = () => {
|
|
89
|
+
u.value = m(), D(), d.value = S.reset;
|
|
90
|
+
}, v = async (x) => c.value || !await p(void 0, x) ? !1 : (d.value = S.submitting, !0), { ignoreUpdates: y, stop: g } = pe(
|
|
91
|
+
u,
|
|
92
92
|
() => {
|
|
93
|
-
|
|
93
|
+
d.value = S.updated;
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
deep: !0,
|
|
97
|
-
eventFilter:
|
|
97
|
+
eventFilter: he(r?.updateThrottle ?? 500)
|
|
98
98
|
}
|
|
99
|
-
),
|
|
99
|
+
), E = G(o), j = G(d), k = _({
|
|
100
100
|
name: "VvForm",
|
|
101
101
|
props: {
|
|
102
102
|
continuousValidation: {
|
|
@@ -109,7 +109,7 @@ function je(e, i, a, v, n) {
|
|
|
109
109
|
},
|
|
110
110
|
readonly: {
|
|
111
111
|
type: Boolean,
|
|
112
|
-
default:
|
|
112
|
+
default: r?.readonly ?? !1
|
|
113
113
|
},
|
|
114
114
|
tag: {
|
|
115
115
|
type: String,
|
|
@@ -150,215 +150,288 @@ function je(e, i, a, v, n) {
|
|
|
150
150
|
"reset"
|
|
151
151
|
],
|
|
152
152
|
slots: Object,
|
|
153
|
-
setup(
|
|
154
|
-
return
|
|
155
|
-
() =>
|
|
156
|
-
(
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
if (JSON.stringify(
|
|
153
|
+
setup(x, { emit: O }) {
|
|
154
|
+
return u.value = m(W(x.modelValue)), A(
|
|
155
|
+
() => x.modelValue,
|
|
156
|
+
(n) => {
|
|
157
|
+
if (n) {
|
|
158
|
+
const w = ve(n) ? W(n) : n;
|
|
159
|
+
if (JSON.stringify(w) === JSON.stringify(W(u.value)))
|
|
160
160
|
return;
|
|
161
|
-
|
|
161
|
+
u.value = typeof w?.clone == "function" ? w.clone() : JSON.parse(JSON.stringify(w));
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
164
|
{ deep: !0 }
|
|
165
|
-
), A(
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
), A(d, async (n) => {
|
|
166
|
+
if (n === S.invalid) {
|
|
167
|
+
const w = W(o.value);
|
|
168
|
+
O("invalid", w), r?.onInvalid?.(
|
|
169
|
+
w
|
|
170
170
|
);
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
|
|
173
|
+
if (n === S.valid) {
|
|
174
|
+
const w = W(u.value);
|
|
175
|
+
O("valid", w), r?.onValid?.(w), O("update:modelValue", w), r?.onUpdate?.(w);
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
|
|
178
|
+
if (n === S.submitting) {
|
|
179
|
+
const w = W(u.value);
|
|
180
|
+
O("submit", w), r?.onSubmit?.(w);
|
|
181
181
|
return;
|
|
182
182
|
}
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
|
|
183
|
+
if (n === S.reset) {
|
|
184
|
+
const w = W(u.value);
|
|
185
|
+
O("reset", w), r?.onReset?.(w);
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
|
-
if (
|
|
189
|
-
if ((
|
|
190
|
-
superRefine:
|
|
191
|
-
fields:
|
|
192
|
-
}), !
|
|
193
|
-
const
|
|
194
|
-
|
|
188
|
+
if (n === S.updated) {
|
|
189
|
+
if ((o.value || r?.continuousValidation || x.continuousValidation) && await p(void 0, {
|
|
190
|
+
superRefine: x.superRefine,
|
|
191
|
+
fields: f ?? new Set(x.validateFields)
|
|
192
|
+
}), !u.value || !x.modelValue || JSON.stringify(u.value) !== JSON.stringify(x.modelValue)) {
|
|
193
|
+
const w = W(u.value);
|
|
194
|
+
O("update:modelValue", w), r?.onUpdate?.(w);
|
|
195
195
|
}
|
|
196
|
-
|
|
196
|
+
d.value === S.updated && (d.value = S.unknown);
|
|
197
197
|
}
|
|
198
|
-
}),
|
|
199
|
-
|
|
198
|
+
}), J(() => {
|
|
199
|
+
c.value = x.readonly;
|
|
200
200
|
}), A(
|
|
201
|
-
() =>
|
|
202
|
-
(
|
|
203
|
-
|
|
201
|
+
() => x.readonly,
|
|
202
|
+
(n) => {
|
|
203
|
+
c.value = n;
|
|
204
204
|
}
|
|
205
|
-
), A(
|
|
206
|
-
|
|
207
|
-
}),
|
|
208
|
-
clear:
|
|
209
|
-
errors:
|
|
210
|
-
formData:
|
|
211
|
-
ignoreUpdates:
|
|
212
|
-
invalid:
|
|
213
|
-
readonly:
|
|
214
|
-
reset:
|
|
215
|
-
status:
|
|
205
|
+
), A(c, (n) => {
|
|
206
|
+
n !== x.readonly && O("update:readonly", c.value);
|
|
207
|
+
}), q(a, {
|
|
208
|
+
clear: D,
|
|
209
|
+
errors: E,
|
|
210
|
+
formData: u,
|
|
211
|
+
ignoreUpdates: y,
|
|
212
|
+
invalid: l,
|
|
213
|
+
readonly: c,
|
|
214
|
+
reset: h,
|
|
215
|
+
status: j,
|
|
216
216
|
stopUpdatesWatch: g,
|
|
217
|
-
submit:
|
|
218
|
-
validate:
|
|
219
|
-
wrappers:
|
|
217
|
+
submit: v,
|
|
218
|
+
validate: p,
|
|
219
|
+
wrappers: t
|
|
220
220
|
}), {
|
|
221
|
-
clear:
|
|
222
|
-
errors:
|
|
223
|
-
formData:
|
|
224
|
-
ignoreUpdates:
|
|
225
|
-
invalid:
|
|
226
|
-
isReadonly:
|
|
227
|
-
reset:
|
|
228
|
-
status:
|
|
221
|
+
clear: D,
|
|
222
|
+
errors: E,
|
|
223
|
+
formData: u,
|
|
224
|
+
ignoreUpdates: y,
|
|
225
|
+
invalid: l,
|
|
226
|
+
isReadonly: c,
|
|
227
|
+
reset: h,
|
|
228
|
+
status: j,
|
|
229
229
|
stopUpdatesWatch: g,
|
|
230
|
-
submit: () =>
|
|
231
|
-
superRefine:
|
|
232
|
-
fields: new Set(
|
|
230
|
+
submit: () => v({
|
|
231
|
+
superRefine: x.superRefine,
|
|
232
|
+
fields: new Set(x.validateFields)
|
|
233
233
|
}),
|
|
234
|
-
validate:
|
|
235
|
-
wrappers:
|
|
234
|
+
validate: p,
|
|
235
|
+
wrappers: t
|
|
236
236
|
};
|
|
237
237
|
},
|
|
238
238
|
render() {
|
|
239
|
-
const
|
|
240
|
-
errors:
|
|
241
|
-
formData:
|
|
242
|
-
invalid:
|
|
243
|
-
readonly:
|
|
244
|
-
status:
|
|
245
|
-
wrappers:
|
|
246
|
-
clear:
|
|
247
|
-
ignoreUpdates:
|
|
248
|
-
reset:
|
|
239
|
+
const x = () => this.$slots?.default?.({
|
|
240
|
+
errors: E.value,
|
|
241
|
+
formData: u.value,
|
|
242
|
+
invalid: l.value,
|
|
243
|
+
readonly: c.value,
|
|
244
|
+
status: j.value,
|
|
245
|
+
wrappers: t,
|
|
246
|
+
clear: D,
|
|
247
|
+
ignoreUpdates: y,
|
|
248
|
+
reset: h,
|
|
249
249
|
stopUpdatesWatch: g,
|
|
250
|
-
submit:
|
|
251
|
-
validate:
|
|
250
|
+
submit: v,
|
|
251
|
+
validate: p
|
|
252
252
|
}) ?? this.$slots.default;
|
|
253
|
-
return
|
|
253
|
+
return R(
|
|
254
254
|
this.tag,
|
|
255
255
|
{
|
|
256
|
-
onSubmit:
|
|
257
|
-
onReset:
|
|
256
|
+
onSubmit: ee(this.submit, ["prevent"]),
|
|
257
|
+
onReset: ee(this.reset, ["prevent"])
|
|
258
258
|
},
|
|
259
|
-
(this.template ??
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
(this.template ?? r?.template) && i ? [
|
|
260
|
+
R(
|
|
261
|
+
i,
|
|
262
262
|
{
|
|
263
|
-
schema: this.template ??
|
|
263
|
+
schema: this.template ?? r?.template
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
|
-
default:
|
|
266
|
+
default: x
|
|
267
267
|
}
|
|
268
268
|
)
|
|
269
269
|
] : {
|
|
270
|
-
default:
|
|
270
|
+
default: x
|
|
271
271
|
}
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
275
|
return {
|
|
276
|
-
clear:
|
|
277
|
-
errors:
|
|
278
|
-
formData:
|
|
279
|
-
ignoreUpdates:
|
|
280
|
-
invalid:
|
|
281
|
-
readonly:
|
|
282
|
-
reset:
|
|
283
|
-
status:
|
|
284
|
-
wrappers:
|
|
276
|
+
clear: D,
|
|
277
|
+
errors: o,
|
|
278
|
+
formData: u,
|
|
279
|
+
ignoreUpdates: y,
|
|
280
|
+
invalid: l,
|
|
281
|
+
readonly: c,
|
|
282
|
+
reset: h,
|
|
283
|
+
status: d,
|
|
284
|
+
wrappers: t,
|
|
285
285
|
stopUpdatesWatch: g,
|
|
286
|
-
submit:
|
|
287
|
-
validate:
|
|
286
|
+
submit: v,
|
|
287
|
+
validate: p,
|
|
288
288
|
VvForm: k
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
const H = (e) => {
|
|
292
|
+
const a = typeof e;
|
|
293
|
+
return e !== null && (a === "object" || a === "function");
|
|
294
|
+
}, T = /* @__PURE__ */ new Set([
|
|
295
|
+
"__proto__",
|
|
296
|
+
"prototype",
|
|
297
|
+
"constructor"
|
|
298
|
+
]), Ie = new Set("0123456789");
|
|
297
299
|
function ne(e) {
|
|
298
|
-
return e ===
|
|
299
|
-
}
|
|
300
|
-
function le(e) {
|
|
301
|
-
return typeof e == "object";
|
|
300
|
+
return typeof e == "string" && /^\d+$/.test(e) && Number.parseInt(e, 10) >= 0 && (e === "0" || !e.startsWith("0"));
|
|
302
301
|
}
|
|
303
|
-
function
|
|
304
|
-
return typeof e == "string";
|
|
302
|
+
function oe(e, a, r) {
|
|
303
|
+
return r > 0 && typeof e == "string" && Array.isArray(a) && ne(e) ? Number.parseInt(e, 10) : e;
|
|
305
304
|
}
|
|
306
|
-
function
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
305
|
+
function ie(e) {
|
|
306
|
+
const a = [];
|
|
307
|
+
let r = "", i = "start", t = !1;
|
|
308
|
+
for (const o of e)
|
|
309
|
+
switch (o) {
|
|
310
|
+
case "\\": {
|
|
311
|
+
if (i === "index")
|
|
312
|
+
throw new Error("Invalid character in an index");
|
|
313
|
+
if (i === "indexEnd")
|
|
314
|
+
throw new Error("Invalid character after an index");
|
|
315
|
+
t && (r += o), i = "property", t = !t;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
case ".": {
|
|
319
|
+
if (i === "index")
|
|
320
|
+
throw new Error("Invalid character in an index");
|
|
321
|
+
if (i === "indexEnd") {
|
|
322
|
+
i = "property";
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
if (t) {
|
|
326
|
+
t = !1, r += o;
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
if (T.has(r))
|
|
330
|
+
return [];
|
|
331
|
+
a.push(r), r = "", i = "property";
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case "[": {
|
|
335
|
+
if (i === "index")
|
|
336
|
+
throw new Error("Invalid character in an index");
|
|
337
|
+
if (i === "indexEnd") {
|
|
338
|
+
i = "index";
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
if (t) {
|
|
342
|
+
t = !1, r += o;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (i === "property") {
|
|
346
|
+
if (T.has(r))
|
|
347
|
+
return [];
|
|
348
|
+
a.push(r), r = "";
|
|
349
|
+
}
|
|
350
|
+
i = "index";
|
|
323
351
|
break;
|
|
352
|
+
}
|
|
353
|
+
case "]": {
|
|
354
|
+
if (i === "index") {
|
|
355
|
+
a.push(Number.parseInt(r, 10)), r = "", i = "indexEnd";
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
if (i === "indexEnd")
|
|
359
|
+
throw new Error("Invalid character after an index");
|
|
360
|
+
}
|
|
361
|
+
default: {
|
|
362
|
+
if (i === "index" && !Ie.has(o))
|
|
363
|
+
throw new Error("Invalid character in an index");
|
|
364
|
+
if (i === "indexEnd")
|
|
365
|
+
throw new Error("Invalid character after an index");
|
|
366
|
+
i === "start" && (i = "property"), t && (t = !1, r += "\\"), r += o;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
switch (t && (r += "\\"), i) {
|
|
370
|
+
case "property": {
|
|
371
|
+
if (T.has(r))
|
|
372
|
+
return [];
|
|
373
|
+
a.push(r);
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
case "index":
|
|
377
|
+
throw new Error("Index was not closed");
|
|
378
|
+
case "start": {
|
|
379
|
+
a.push("");
|
|
380
|
+
break;
|
|
324
381
|
}
|
|
325
|
-
return z(e) ? v : e;
|
|
326
382
|
}
|
|
383
|
+
return a;
|
|
327
384
|
}
|
|
328
|
-
function
|
|
329
|
-
if (!
|
|
330
|
-
return;
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
385
|
+
function le(e, a) {
|
|
386
|
+
if (!Array.isArray(e) || typeof a == "number")
|
|
387
|
+
return !1;
|
|
388
|
+
const r = Number.parseInt(a, 10);
|
|
389
|
+
return Number.isInteger(r) && String(r) === a;
|
|
390
|
+
}
|
|
391
|
+
function Oe(e, a) {
|
|
392
|
+
if (le(e, a))
|
|
393
|
+
throw new Error("Cannot use string index");
|
|
394
|
+
}
|
|
395
|
+
function L(e, a, r) {
|
|
396
|
+
if (!H(e) || typeof a != "string")
|
|
397
|
+
return r === void 0 ? e : r;
|
|
398
|
+
const i = ie(a);
|
|
399
|
+
if (i.length === 0)
|
|
400
|
+
return r;
|
|
401
|
+
for (let t = 0; t < i.length; t++) {
|
|
402
|
+
const o = i[t], d = oe(o, e, t);
|
|
403
|
+
if (d === o && le(e, o) ? e = t === i.length - 1 ? void 0 : null : e = e[d], e == null) {
|
|
404
|
+
if (t !== i.length - 1)
|
|
405
|
+
return r;
|
|
406
|
+
break;
|
|
346
407
|
}
|
|
347
|
-
z(e[u]) && (e[u] = {}), e = e[u];
|
|
348
408
|
}
|
|
409
|
+
return e === void 0 ? r : e;
|
|
349
410
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
411
|
+
function ue(e, a, r) {
|
|
412
|
+
if (!H(e) || typeof a != "string")
|
|
413
|
+
return e;
|
|
414
|
+
const i = e, t = ie(a);
|
|
415
|
+
for (let o = 0; o < t.length; o++) {
|
|
416
|
+
const d = t[o], l = oe(d, e, o);
|
|
417
|
+
if (l === d && Oe(e, d), o === t.length - 1)
|
|
418
|
+
e[l] = r;
|
|
419
|
+
else if (!H(e[l])) {
|
|
420
|
+
const u = t[o + 1], c = typeof u == "number" || typeof u == "string" && ne(u);
|
|
421
|
+
e[l] = c ? [] : {};
|
|
422
|
+
}
|
|
423
|
+
e = e[l];
|
|
424
|
+
}
|
|
425
|
+
return i;
|
|
353
426
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
427
|
+
function je(e, a, r, i) {
|
|
428
|
+
return _({
|
|
356
429
|
name: "VvFormField",
|
|
357
430
|
props: {
|
|
358
431
|
type: {
|
|
359
432
|
type: String,
|
|
360
|
-
validator: (
|
|
361
|
-
default:
|
|
433
|
+
validator: (t) => Object.values(V).includes(t),
|
|
434
|
+
default: V.custom
|
|
362
435
|
},
|
|
363
436
|
is: {
|
|
364
437
|
type: [Object, String],
|
|
@@ -405,175 +478,175 @@ function xe(e, i, a, v) {
|
|
|
405
478
|
"type"
|
|
406
479
|
],
|
|
407
480
|
slots: Object,
|
|
408
|
-
setup(
|
|
409
|
-
const { props:
|
|
410
|
-
|
|
411
|
-
const
|
|
481
|
+
setup(t, { slots: o, emit: d }) {
|
|
482
|
+
const { props: l, name: u } = Q(t), c = ae(), f = B(a, void 0);
|
|
483
|
+
f && f.fields.value.set(c, t.name);
|
|
484
|
+
const m = B(e), p = I({
|
|
412
485
|
get() {
|
|
413
|
-
if (
|
|
414
|
-
return
|
|
415
|
-
new Object(
|
|
416
|
-
String(
|
|
486
|
+
if (m?.formData)
|
|
487
|
+
return L(
|
|
488
|
+
new Object(m.formData.value),
|
|
489
|
+
String(t.name)
|
|
417
490
|
);
|
|
418
491
|
},
|
|
419
|
-
set(
|
|
420
|
-
|
|
421
|
-
new Object(
|
|
422
|
-
String(
|
|
423
|
-
|
|
424
|
-
),
|
|
425
|
-
newValue:
|
|
426
|
-
formData:
|
|
492
|
+
set(n) {
|
|
493
|
+
m?.formData && (ue(
|
|
494
|
+
new Object(m.formData.value),
|
|
495
|
+
String(t.name),
|
|
496
|
+
n
|
|
497
|
+
), d("update:modelValue", {
|
|
498
|
+
newValue: p.value,
|
|
499
|
+
formData: m?.formData
|
|
427
500
|
}));
|
|
428
501
|
}
|
|
429
502
|
});
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}),
|
|
433
|
-
|
|
503
|
+
J(() => {
|
|
504
|
+
p.value === void 0 && t.defaultValue !== void 0 && (p.value = t.defaultValue);
|
|
505
|
+
}), U(() => {
|
|
506
|
+
f && f.fields.value.delete(c);
|
|
434
507
|
});
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
return
|
|
438
|
-
}),
|
|
439
|
-
if (
|
|
440
|
-
|
|
441
|
-
String(
|
|
442
|
-
|
|
508
|
+
const D = I(() => {
|
|
509
|
+
if (m?.errors.value)
|
|
510
|
+
return L(m.errors.value, String(t.name));
|
|
511
|
+
}), h = I(() => D.value?._errors), v = I(() => D.value !== void 0), y = A(v, (n) => {
|
|
512
|
+
if (n) {
|
|
513
|
+
d("invalid", D.value), f && f.errors.value.set(
|
|
514
|
+
String(t.name),
|
|
515
|
+
D.value
|
|
443
516
|
);
|
|
444
517
|
return;
|
|
445
518
|
}
|
|
446
|
-
|
|
447
|
-
|
|
519
|
+
d("valid", p.value), f && f.errors.value.delete(
|
|
520
|
+
t.name
|
|
448
521
|
);
|
|
449
522
|
}), g = A(
|
|
450
|
-
() =>
|
|
523
|
+
() => m?.formData,
|
|
451
524
|
() => {
|
|
452
|
-
|
|
525
|
+
d("update:formData", m?.formData);
|
|
453
526
|
},
|
|
454
527
|
{ deep: !0 }
|
|
455
528
|
);
|
|
456
|
-
|
|
457
|
-
|
|
529
|
+
U(() => {
|
|
530
|
+
y(), g();
|
|
458
531
|
});
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
},
|
|
462
|
-
let
|
|
463
|
-
return typeof
|
|
464
|
-
(
|
|
532
|
+
const E = (n) => {
|
|
533
|
+
n instanceof InputEvent && (n = n.target.value), p.value = n;
|
|
534
|
+
}, j = I(() => {
|
|
535
|
+
let n = l.value;
|
|
536
|
+
return typeof n == "function" && (n = n(m?.formData)), Object.keys(n).reduce(
|
|
537
|
+
(w, N) => (w[N] = P(n[N]), w),
|
|
465
538
|
{}
|
|
466
539
|
);
|
|
467
|
-
}), k =
|
|
468
|
-
...
|
|
469
|
-
name:
|
|
470
|
-
invalid:
|
|
471
|
-
valid:
|
|
472
|
-
type: ((
|
|
540
|
+
}), k = I(() => m?.readonly.value || f?.readonly.value ? !0 : j.value.readonly ?? t.readonly), x = I(() => ({
|
|
541
|
+
...j.value,
|
|
542
|
+
name: j.value.name ?? t.name,
|
|
543
|
+
invalid: v.value,
|
|
544
|
+
valid: t.showValid ? !!(!v.value && p.value) : void 0,
|
|
545
|
+
type: ((n) => {
|
|
473
546
|
if ([
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
].includes(
|
|
488
|
-
return
|
|
489
|
-
})(
|
|
490
|
-
invalidLabel:
|
|
491
|
-
modelValue:
|
|
547
|
+
V.color,
|
|
548
|
+
V.date,
|
|
549
|
+
V.datetimeLocal,
|
|
550
|
+
V.email,
|
|
551
|
+
V.month,
|
|
552
|
+
V.number,
|
|
553
|
+
V.password,
|
|
554
|
+
V.search,
|
|
555
|
+
V.tel,
|
|
556
|
+
V.text,
|
|
557
|
+
V.time,
|
|
558
|
+
V.url,
|
|
559
|
+
V.week
|
|
560
|
+
].includes(n))
|
|
561
|
+
return n;
|
|
562
|
+
})(t.type),
|
|
563
|
+
invalidLabel: h.value,
|
|
564
|
+
modelValue: p.value,
|
|
492
565
|
readonly: k.value,
|
|
493
|
-
"onUpdate:modelValue":
|
|
566
|
+
"onUpdate:modelValue": E
|
|
494
567
|
}));
|
|
495
|
-
return
|
|
496
|
-
name: G(
|
|
497
|
-
errors: G(
|
|
498
|
-
}), { component:
|
|
499
|
-
if (
|
|
568
|
+
return q(r, {
|
|
569
|
+
name: G(u),
|
|
570
|
+
errors: G(D)
|
|
571
|
+
}), { component: I(() => {
|
|
572
|
+
if (t.type === V.custom)
|
|
500
573
|
return {
|
|
501
574
|
render() {
|
|
502
|
-
return
|
|
503
|
-
errors:
|
|
504
|
-
formData:
|
|
505
|
-
formErrors:
|
|
506
|
-
invalid:
|
|
507
|
-
invalidLabel:
|
|
508
|
-
modelValue:
|
|
575
|
+
return o.default?.({
|
|
576
|
+
errors: G(D).value,
|
|
577
|
+
formData: m?.formData.value,
|
|
578
|
+
formErrors: m?.errors.value,
|
|
579
|
+
invalid: v.value,
|
|
580
|
+
invalidLabel: h.value,
|
|
581
|
+
modelValue: p.value,
|
|
509
582
|
readonly: k.value,
|
|
510
|
-
onUpdate:
|
|
511
|
-
submit:
|
|
512
|
-
validate:
|
|
513
|
-
}) ??
|
|
583
|
+
onUpdate: E,
|
|
584
|
+
submit: m?.submit,
|
|
585
|
+
validate: m?.validate
|
|
586
|
+
}) ?? o.default;
|
|
514
587
|
}
|
|
515
588
|
};
|
|
516
|
-
if (!(
|
|
517
|
-
let
|
|
518
|
-
switch (
|
|
519
|
-
case
|
|
520
|
-
|
|
589
|
+
if (!(i?.lazyLoad ?? t.lazyLoad)) {
|
|
590
|
+
let n;
|
|
591
|
+
switch (t.type) {
|
|
592
|
+
case V.select:
|
|
593
|
+
n = $("VvSelect");
|
|
521
594
|
break;
|
|
522
|
-
case
|
|
523
|
-
|
|
595
|
+
case V.checkbox:
|
|
596
|
+
n = $("VvCheckbox");
|
|
524
597
|
break;
|
|
525
|
-
case
|
|
526
|
-
|
|
598
|
+
case V.radio:
|
|
599
|
+
n = $("VvRadio");
|
|
527
600
|
break;
|
|
528
|
-
case
|
|
529
|
-
|
|
601
|
+
case V.textarea:
|
|
602
|
+
n = $("VvTextarea");
|
|
530
603
|
break;
|
|
531
|
-
case
|
|
532
|
-
|
|
604
|
+
case V.radioGroup:
|
|
605
|
+
n = $("VvRadioGroup");
|
|
533
606
|
break;
|
|
534
|
-
case
|
|
535
|
-
|
|
607
|
+
case V.checkboxGroup:
|
|
608
|
+
n = $("VvCheckboxGroup");
|
|
536
609
|
break;
|
|
537
|
-
case
|
|
538
|
-
|
|
610
|
+
case V.combobox:
|
|
611
|
+
n = $("VvCombobox");
|
|
539
612
|
break;
|
|
540
613
|
default:
|
|
541
|
-
|
|
614
|
+
n = $("VvInputText");
|
|
542
615
|
}
|
|
543
|
-
if (typeof
|
|
544
|
-
return
|
|
616
|
+
if (typeof n != "string")
|
|
617
|
+
return n;
|
|
545
618
|
console.warn(
|
|
546
|
-
`[@volverjs/form-vue]: ${
|
|
619
|
+
`[@volverjs/form-vue]: ${n} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
547
620
|
);
|
|
548
621
|
}
|
|
549
622
|
return ce(async () => {
|
|
550
|
-
switch (
|
|
551
|
-
case
|
|
623
|
+
switch (i?.sideEffects && await Promise.resolve(i.sideEffects(t.type)), t.type) {
|
|
624
|
+
case V.textarea:
|
|
552
625
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
553
|
-
case
|
|
626
|
+
case V.radio:
|
|
554
627
|
return import("@volverjs/ui-vue/vv-radio");
|
|
555
|
-
case
|
|
628
|
+
case V.radioGroup:
|
|
556
629
|
return import("@volverjs/ui-vue/vv-radio-group");
|
|
557
|
-
case
|
|
630
|
+
case V.checkbox:
|
|
558
631
|
return import("@volverjs/ui-vue/vv-checkbox");
|
|
559
|
-
case
|
|
632
|
+
case V.checkboxGroup:
|
|
560
633
|
return import("@volverjs/ui-vue/vv-checkbox-group");
|
|
561
|
-
case
|
|
634
|
+
case V.select:
|
|
562
635
|
return import("@volverjs/ui-vue/vv-select");
|
|
563
|
-
case
|
|
636
|
+
case V.combobox:
|
|
564
637
|
return import("@volverjs/ui-vue/vv-combobox");
|
|
565
638
|
}
|
|
566
639
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
567
640
|
});
|
|
568
|
-
}), hasProps:
|
|
641
|
+
}), hasProps: x, invalid: v };
|
|
569
642
|
},
|
|
570
643
|
render() {
|
|
571
|
-
return this.is ?
|
|
644
|
+
return this.is ? R(this.is, this.hasProps, this.$slots) : this.type === V.custom ? R(this.component, null, this.$slots) : R(this.component, this.hasProps, this.$slots);
|
|
572
645
|
}
|
|
573
646
|
});
|
|
574
647
|
}
|
|
575
|
-
function
|
|
576
|
-
return
|
|
648
|
+
function Se(e, a, r) {
|
|
649
|
+
return _({
|
|
577
650
|
name: "VvFormFieldsGroup",
|
|
578
651
|
props: {
|
|
579
652
|
is: {
|
|
@@ -616,150 +689,151 @@ function Ie(e, i, a) {
|
|
|
616
689
|
"is"
|
|
617
690
|
],
|
|
618
691
|
slots: Object,
|
|
619
|
-
setup(
|
|
620
|
-
const { props:
|
|
621
|
-
|
|
622
|
-
|
|
692
|
+
setup(i, { slots: t, emit: o }) {
|
|
693
|
+
const { props: d, names: l, defaultValues: u } = Q(i), c = ae(), f = I(() => Array.isArray(l.value) ? l.value : Object.values(l.value)), m = I(() => Array.isArray(l.value) ? l.value : Object.keys(l.value)), p = I(() => Array.isArray(l.value) ? l.value.reduce((s, b) => (s[String(b)] = b, s), {}) : l.value), D = I(() => Object.keys(p.value).reduce((s, b) => (s[String(p.value[b])] = b, s), {})), h = B(a, void 0);
|
|
694
|
+
h && f.value.forEach((s) => {
|
|
695
|
+
h.fields.value.set(`${c}-${s}`, s);
|
|
623
696
|
});
|
|
624
|
-
const
|
|
697
|
+
const v = B(e), y = I({
|
|
625
698
|
get() {
|
|
626
|
-
return
|
|
627
|
-
new Object(
|
|
628
|
-
|
|
699
|
+
return v?.formData ? m.value.reduce((s, b) => (s[b] = L(
|
|
700
|
+
new Object(v.formData.value),
|
|
701
|
+
p.value[b]
|
|
629
702
|
), s), {}) : {};
|
|
630
703
|
},
|
|
631
704
|
set(s) {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
new Object(
|
|
635
|
-
|
|
636
|
-
s?.[
|
|
705
|
+
v?.formData && (m.value.forEach((b) => {
|
|
706
|
+
ue(
|
|
707
|
+
new Object(v.formData.value),
|
|
708
|
+
p.value[b],
|
|
709
|
+
s?.[b]
|
|
637
710
|
);
|
|
638
|
-
}),
|
|
639
|
-
newValue:
|
|
640
|
-
formData:
|
|
711
|
+
}), o("update:modelValue", {
|
|
712
|
+
newValue: y.value,
|
|
713
|
+
formData: v?.formData
|
|
641
714
|
}));
|
|
642
715
|
}
|
|
643
716
|
});
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
...
|
|
648
|
-
[s]:
|
|
717
|
+
J(() => {
|
|
718
|
+
u.value && f.value.forEach((s) => {
|
|
719
|
+
u.value?.[s] !== void 0 && y.value[s] === void 0 && (y.value = {
|
|
720
|
+
...y.value,
|
|
721
|
+
[s]: u.value?.[s]
|
|
649
722
|
});
|
|
650
723
|
});
|
|
651
|
-
}),
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
`${
|
|
724
|
+
}), U(() => {
|
|
725
|
+
h && f.value.forEach((s) => {
|
|
726
|
+
h.fields.value.delete(
|
|
727
|
+
`${c}-${s}`
|
|
655
728
|
);
|
|
656
729
|
});
|
|
657
730
|
});
|
|
658
|
-
const g =
|
|
659
|
-
if (!
|
|
731
|
+
const g = I(() => {
|
|
732
|
+
if (!v?.errors.value)
|
|
660
733
|
return;
|
|
661
|
-
const s =
|
|
662
|
-
if (!
|
|
663
|
-
return
|
|
664
|
-
const
|
|
665
|
-
return
|
|
734
|
+
const s = f.value.reduce((b, F) => {
|
|
735
|
+
if (!v.errors.value)
|
|
736
|
+
return b;
|
|
737
|
+
const Y = L(v.errors.value, String(F));
|
|
738
|
+
return Y === void 0 || (b[String(F)] = Y), b;
|
|
666
739
|
}, {});
|
|
667
740
|
if (Object.keys(s).length !== 0)
|
|
668
741
|
return s;
|
|
669
|
-
}),
|
|
742
|
+
}), E = I(() => {
|
|
670
743
|
if (!g.value)
|
|
671
744
|
return;
|
|
672
|
-
const s = Object.keys(g.value).reduce((
|
|
745
|
+
const s = Object.keys(g.value).reduce((b, F) => (g.value?.[F] && (b[D.value[F]] = g.value[F]._errors), b), {});
|
|
673
746
|
if (Object.keys(s).length !== 0)
|
|
674
747
|
return s;
|
|
675
|
-
}),
|
|
676
|
-
if (
|
|
677
|
-
|
|
748
|
+
}), j = I(() => g.value !== void 0), k = I(() => m.value.reduce((s, b) => (s[b] = !!g.value?.[D.value[b]], s), {})), x = A(j, () => {
|
|
749
|
+
if (j.value) {
|
|
750
|
+
o("invalid", g.value), h && f.value.forEach((s) => {
|
|
678
751
|
if (!g.value?.[s]) {
|
|
679
|
-
|
|
752
|
+
h.errors.value.delete(
|
|
680
753
|
s
|
|
681
754
|
);
|
|
682
755
|
return;
|
|
683
756
|
}
|
|
684
|
-
|
|
757
|
+
h.errors.value.set(
|
|
685
758
|
s,
|
|
686
759
|
g.value?.[s]
|
|
687
760
|
);
|
|
688
761
|
});
|
|
689
762
|
return;
|
|
690
763
|
}
|
|
691
|
-
|
|
692
|
-
|
|
764
|
+
o("valid", y.value), h && f.value.forEach((s) => {
|
|
765
|
+
h.errors.value.delete(
|
|
693
766
|
s
|
|
694
767
|
);
|
|
695
768
|
});
|
|
696
|
-
}),
|
|
697
|
-
() =>
|
|
769
|
+
}), O = A(
|
|
770
|
+
() => v?.formData,
|
|
698
771
|
() => {
|
|
699
|
-
|
|
772
|
+
o("update:formData", v?.formData);
|
|
700
773
|
},
|
|
701
774
|
{ deep: !0 }
|
|
702
775
|
);
|
|
703
|
-
|
|
704
|
-
|
|
776
|
+
U(() => {
|
|
777
|
+
x(), O();
|
|
705
778
|
});
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
},
|
|
709
|
-
|
|
710
|
-
...
|
|
711
|
-
[s]:
|
|
779
|
+
const n = (s) => {
|
|
780
|
+
y.value = s;
|
|
781
|
+
}, w = (s, b) => {
|
|
782
|
+
b instanceof InputEvent && (b = b.target.value), m.value.includes(s) && (y.value = {
|
|
783
|
+
...y.value,
|
|
784
|
+
[s]: b
|
|
712
785
|
});
|
|
713
|
-
},
|
|
714
|
-
let s =
|
|
715
|
-
return typeof s == "function" && (s = s(
|
|
716
|
-
(
|
|
786
|
+
}, N = I(() => {
|
|
787
|
+
let s = d.value;
|
|
788
|
+
return typeof s == "function" && (s = s(v?.formData)), Object.keys(s).reduce(
|
|
789
|
+
(b, F) => (b[F] = P(s[F]), b),
|
|
717
790
|
{}
|
|
718
791
|
);
|
|
719
|
-
}),
|
|
720
|
-
|
|
792
|
+
}), X = I(() => v?.readonly.value ? !0 : N.value.readonly ?? i.readonly), de = I(() => m.value.reduce((s, b) => (s[`onUpdate:${b}`] = (F) => {
|
|
793
|
+
w(b, F);
|
|
721
794
|
}, s), {
|
|
722
|
-
"onUpdate:modelValue":
|
|
723
|
-
})), fe =
|
|
795
|
+
"onUpdate:modelValue": n
|
|
796
|
+
})), fe = I(() => ({
|
|
724
797
|
...de.value,
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
798
|
+
...N.value,
|
|
799
|
+
...y.value,
|
|
800
|
+
modelValue: y.value,
|
|
801
|
+
names: N.value.name ?? f.value,
|
|
802
|
+
invalid: j.value,
|
|
728
803
|
invalids: k.value,
|
|
729
|
-
valid:
|
|
730
|
-
invalidLabels:
|
|
731
|
-
|
|
732
|
-
readonly: Y.value
|
|
804
|
+
valid: i.showValid ? !!(!j.value && y.value) : void 0,
|
|
805
|
+
invalidLabels: E.value,
|
|
806
|
+
readonly: X.value
|
|
733
807
|
}));
|
|
734
|
-
return
|
|
735
|
-
names: G(
|
|
808
|
+
return q(r, {
|
|
809
|
+
names: G(l),
|
|
736
810
|
errors: G(g)
|
|
737
|
-
}), { component:
|
|
811
|
+
}), { component: I(() => ({
|
|
738
812
|
render() {
|
|
739
|
-
return
|
|
813
|
+
return t.default?.({
|
|
740
814
|
errors: g.value,
|
|
741
|
-
formData:
|
|
742
|
-
formErrors:
|
|
743
|
-
invalid:
|
|
815
|
+
formData: v?.formData.value,
|
|
816
|
+
formErrors: v?.errors.value,
|
|
817
|
+
invalid: j.value,
|
|
744
818
|
invalids: k.value,
|
|
745
|
-
invalidLabels:
|
|
746
|
-
modelValue:
|
|
747
|
-
onUpdate:
|
|
748
|
-
onUpdateField:
|
|
749
|
-
readonly:
|
|
750
|
-
submit:
|
|
751
|
-
validate:
|
|
752
|
-
}) ??
|
|
819
|
+
invalidLabels: E.value,
|
|
820
|
+
modelValue: y.value,
|
|
821
|
+
onUpdate: n,
|
|
822
|
+
onUpdateField: w,
|
|
823
|
+
readonly: X.value,
|
|
824
|
+
submit: v?.submit,
|
|
825
|
+
validate: v?.validate
|
|
826
|
+
}) ?? t.default;
|
|
753
827
|
}
|
|
754
|
-
})), hasProps: fe, invalid:
|
|
828
|
+
})), hasProps: fe, invalid: j };
|
|
755
829
|
},
|
|
756
830
|
render() {
|
|
757
|
-
return this.is ?
|
|
831
|
+
return this.is ? R(this.is, this.hasProps, this.$slots) : R(this.component, null, this.$slots);
|
|
758
832
|
}
|
|
759
833
|
});
|
|
760
834
|
}
|
|
761
|
-
function
|
|
762
|
-
return
|
|
835
|
+
function Ee(e, a) {
|
|
836
|
+
return _({
|
|
763
837
|
name: "VvFormWrapper",
|
|
764
838
|
props: {
|
|
765
839
|
name: {
|
|
@@ -791,75 +865,75 @@ function Fe(e, i) {
|
|
|
791
865
|
"validateWrapper"
|
|
792
866
|
],
|
|
793
867
|
slots: Object,
|
|
794
|
-
setup(
|
|
795
|
-
const
|
|
796
|
-
A(
|
|
797
|
-
if (
|
|
798
|
-
|
|
868
|
+
setup(r, { emit: i }) {
|
|
869
|
+
const t = B(e), o = B(a, void 0), d = K(/* @__PURE__ */ new Map()), l = K(/* @__PURE__ */ new Map()), { name: u } = Q(r), c = I(() => t?.invalid.value ? l.value.size > 0 : !1);
|
|
870
|
+
A(c, (h) => {
|
|
871
|
+
if (h) {
|
|
872
|
+
i("invalid");
|
|
799
873
|
return;
|
|
800
874
|
}
|
|
801
|
-
|
|
875
|
+
i("valid");
|
|
802
876
|
});
|
|
803
|
-
const
|
|
804
|
-
name: G(
|
|
805
|
-
errors:
|
|
806
|
-
invalid: G(
|
|
807
|
-
readonly: G(
|
|
808
|
-
fields:
|
|
877
|
+
const f = I(() => t?.readonly.value || r.readonly), m = {
|
|
878
|
+
name: G(u),
|
|
879
|
+
errors: l,
|
|
880
|
+
invalid: G(c),
|
|
881
|
+
readonly: G(f),
|
|
882
|
+
fields: d
|
|
809
883
|
};
|
|
810
|
-
|
|
811
|
-
const
|
|
884
|
+
q(a, m);
|
|
885
|
+
const p = I(() => new Map(d.value));
|
|
812
886
|
A(
|
|
813
|
-
|
|
814
|
-
(
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}),
|
|
818
|
-
|
|
887
|
+
p,
|
|
888
|
+
(h, v) => {
|
|
889
|
+
o?.fields && (v.forEach((y, g) => {
|
|
890
|
+
h.has(g) || o?.fields.value.delete(g);
|
|
891
|
+
}), h.forEach((y, g) => {
|
|
892
|
+
o?.fields.value.has(g) || o?.fields.value.set(g, y);
|
|
819
893
|
}));
|
|
820
894
|
},
|
|
821
895
|
{ deep: !0 }
|
|
822
896
|
), A(
|
|
823
|
-
|
|
824
|
-
(
|
|
825
|
-
|
|
826
|
-
if (
|
|
827
|
-
const
|
|
828
|
-
|
|
897
|
+
l,
|
|
898
|
+
(h) => {
|
|
899
|
+
o?.errors && d.value.forEach((v) => {
|
|
900
|
+
if (h.has(v) || o.errors.value.delete(v), h.has(v)) {
|
|
901
|
+
const y = h.get(v);
|
|
902
|
+
y && o.errors.value.set(v, y);
|
|
829
903
|
}
|
|
830
904
|
});
|
|
831
905
|
},
|
|
832
906
|
{ deep: !0 }
|
|
833
|
-
),
|
|
834
|
-
if (!
|
|
907
|
+
), J(() => {
|
|
908
|
+
if (!t?.wrappers || !u.value) {
|
|
835
909
|
console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");
|
|
836
910
|
return;
|
|
837
911
|
}
|
|
838
|
-
if (
|
|
839
|
-
console.warn(`[@volverjs/form-vue]: wrapper name "${
|
|
912
|
+
if (t.wrappers.has(u.value)) {
|
|
913
|
+
console.warn(`[@volverjs/form-vue]: wrapper name "${u.value}" is already used`);
|
|
840
914
|
return;
|
|
841
915
|
}
|
|
842
|
-
|
|
843
|
-
}),
|
|
844
|
-
|
|
916
|
+
t.wrappers.set(u.value, m);
|
|
917
|
+
}), U(() => {
|
|
918
|
+
t?.wrappers && u.value && t.wrappers.delete(u.value);
|
|
845
919
|
});
|
|
846
|
-
const
|
|
920
|
+
const D = () => t?.validate(void 0, { fields: new Set(d.value.values()) }) ?? Promise.resolve(!0);
|
|
847
921
|
return {
|
|
848
|
-
errors:
|
|
849
|
-
fields:
|
|
850
|
-
fieldsErrors:
|
|
851
|
-
formData:
|
|
852
|
-
invalid:
|
|
853
|
-
readonly:
|
|
854
|
-
clear:
|
|
855
|
-
reset:
|
|
856
|
-
submit:
|
|
857
|
-
validate:
|
|
858
|
-
validateWrapper:
|
|
922
|
+
errors: t?.errors,
|
|
923
|
+
fields: d,
|
|
924
|
+
fieldsErrors: l,
|
|
925
|
+
formData: t?.formData,
|
|
926
|
+
invalid: c,
|
|
927
|
+
readonly: f,
|
|
928
|
+
clear: t?.clear,
|
|
929
|
+
reset: t?.reset,
|
|
930
|
+
submit: t?.submit,
|
|
931
|
+
validate: t?.validate,
|
|
932
|
+
validateWrapper: D
|
|
859
933
|
};
|
|
860
934
|
},
|
|
861
935
|
render() {
|
|
862
|
-
const
|
|
936
|
+
const r = () => this.$slots.default?.({
|
|
863
937
|
errors: this.errors,
|
|
864
938
|
fieldsErrors: this.fieldsErrors,
|
|
865
939
|
formData: this.formData,
|
|
@@ -871,14 +945,14 @@ function Fe(e, i) {
|
|
|
871
945
|
validate: this.validate,
|
|
872
946
|
validateWrapper: this.validateWrapper
|
|
873
947
|
});
|
|
874
|
-
return this.tag ?
|
|
875
|
-
default:
|
|
876
|
-
}) :
|
|
948
|
+
return this.tag ? R(this.tag, null, {
|
|
949
|
+
default: r
|
|
950
|
+
}) : r();
|
|
877
951
|
}
|
|
878
952
|
});
|
|
879
953
|
}
|
|
880
|
-
function
|
|
881
|
-
const
|
|
954
|
+
function Re(e, a) {
|
|
955
|
+
const r = _({
|
|
882
956
|
name: "VvFormTemplate",
|
|
883
957
|
props: {
|
|
884
958
|
schema: {
|
|
@@ -891,174 +965,174 @@ function ke(e, i) {
|
|
|
891
965
|
}
|
|
892
966
|
},
|
|
893
967
|
slots: Object,
|
|
894
|
-
setup(
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
968
|
+
setup(i, { slots: t }) {
|
|
969
|
+
const o = B(e);
|
|
970
|
+
if (o?.formData)
|
|
897
971
|
return () => {
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
) :
|
|
902
|
-
let
|
|
903
|
-
const
|
|
904
|
-
const
|
|
905
|
-
vvIs:
|
|
906
|
-
vvName:
|
|
907
|
-
vvSlots:
|
|
908
|
-
vvChildren:
|
|
909
|
-
vvIf:
|
|
972
|
+
const d = typeof i.schema == "function" ? i.schema(
|
|
973
|
+
o,
|
|
974
|
+
i.scope
|
|
975
|
+
) : i.schema;
|
|
976
|
+
let l;
|
|
977
|
+
const u = d.reduce((c, f) => {
|
|
978
|
+
const m = typeof f == "function" ? f(o, i.scope) : f, {
|
|
979
|
+
vvIs: p,
|
|
980
|
+
vvName: D,
|
|
981
|
+
vvSlots: h,
|
|
982
|
+
vvChildren: v,
|
|
983
|
+
vvIf: y,
|
|
910
984
|
vvElseIf: g,
|
|
911
|
-
vvType:
|
|
912
|
-
vvDefaultValue:
|
|
985
|
+
vvType: E,
|
|
986
|
+
vvDefaultValue: j,
|
|
913
987
|
vvShowValid: k,
|
|
914
|
-
vvContent:
|
|
915
|
-
...
|
|
916
|
-
} =
|
|
917
|
-
if (
|
|
918
|
-
if (typeof
|
|
919
|
-
new Object(
|
|
920
|
-
|
|
921
|
-
) : typeof
|
|
922
|
-
return
|
|
923
|
-
} else if (g !== void 0 &&
|
|
924
|
-
if (
|
|
925
|
-
new Object(
|
|
988
|
+
vvContent: x,
|
|
989
|
+
...O
|
|
990
|
+
} = m;
|
|
991
|
+
if (y !== void 0) {
|
|
992
|
+
if (typeof y == "string" ? l = !!L(
|
|
993
|
+
new Object(o.formData.value),
|
|
994
|
+
y
|
|
995
|
+
) : typeof y == "function" ? l = P(y(o)) : l = P(y), !l)
|
|
996
|
+
return c;
|
|
997
|
+
} else if (g !== void 0 && l !== void 0) {
|
|
998
|
+
if (l || (typeof g == "string" ? l = !!L(
|
|
999
|
+
new Object(o.formData.value),
|
|
926
1000
|
g
|
|
927
|
-
) : typeof g == "function" ?
|
|
928
|
-
return
|
|
1001
|
+
) : typeof g == "function" ? l = P(g(o)) : l = P(g), !l))
|
|
1002
|
+
return c;
|
|
929
1003
|
} else
|
|
930
|
-
|
|
931
|
-
let
|
|
932
|
-
return
|
|
933
|
-
schema:
|
|
934
|
-
}) :
|
|
935
|
-
default: (
|
|
936
|
-
schema:
|
|
937
|
-
scope:
|
|
1004
|
+
l = void 0;
|
|
1005
|
+
let n;
|
|
1006
|
+
return v && (typeof p == "string" ? n = R(r, {
|
|
1007
|
+
schema: v
|
|
1008
|
+
}) : n = {
|
|
1009
|
+
default: (w) => R(r, {
|
|
1010
|
+
schema: v,
|
|
1011
|
+
scope: w
|
|
938
1012
|
})
|
|
939
|
-
}),
|
|
940
|
-
|
|
941
|
-
|
|
1013
|
+
}), D ? (c.push(
|
|
1014
|
+
R(
|
|
1015
|
+
a,
|
|
942
1016
|
{
|
|
943
|
-
name:
|
|
944
|
-
is:
|
|
945
|
-
type:
|
|
946
|
-
defaultValue:
|
|
1017
|
+
name: D,
|
|
1018
|
+
is: p,
|
|
1019
|
+
type: E,
|
|
1020
|
+
defaultValue: j,
|
|
947
1021
|
showValid: k,
|
|
948
|
-
props:
|
|
1022
|
+
props: O
|
|
949
1023
|
},
|
|
950
|
-
|
|
1024
|
+
h ?? n ?? x
|
|
951
1025
|
)
|
|
952
|
-
),
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1026
|
+
), c) : p ? (c.push(
|
|
1027
|
+
R(
|
|
1028
|
+
p,
|
|
1029
|
+
O,
|
|
1030
|
+
h ?? n ?? x
|
|
957
1031
|
)
|
|
958
|
-
),
|
|
1032
|
+
), c) : (n && ("default" in n ? c.push(n.default(i.scope)) : c.push(n)), c);
|
|
959
1033
|
}, []);
|
|
960
|
-
return
|
|
961
|
-
|
|
962
|
-
errors:
|
|
963
|
-
formData:
|
|
964
|
-
invalid:
|
|
965
|
-
status:
|
|
966
|
-
submit:
|
|
967
|
-
validate:
|
|
968
|
-
clear:
|
|
969
|
-
reset:
|
|
1034
|
+
return u.push(
|
|
1035
|
+
t?.default?.({
|
|
1036
|
+
errors: o?.errors.value,
|
|
1037
|
+
formData: o?.formData.value,
|
|
1038
|
+
invalid: o?.invalid.value,
|
|
1039
|
+
status: o?.status.value,
|
|
1040
|
+
submit: o?.submit,
|
|
1041
|
+
validate: o?.validate,
|
|
1042
|
+
clear: o?.clear,
|
|
1043
|
+
reset: o?.reset
|
|
970
1044
|
})
|
|
971
|
-
),
|
|
1045
|
+
), u;
|
|
972
1046
|
};
|
|
973
1047
|
}
|
|
974
1048
|
});
|
|
975
|
-
return
|
|
1049
|
+
return r;
|
|
976
1050
|
}
|
|
977
|
-
function
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
v
|
|
981
|
-
), o = xe(
|
|
982
|
-
a,
|
|
983
|
-
v,
|
|
984
|
-
n,
|
|
1051
|
+
function Z(e, a = {}) {
|
|
1052
|
+
const r = Symbol("formInjectionKey"), i = Symbol("formWrapperInjectionKey"), t = Symbol("formFieldInjectionKey"), o = Symbol("formFieldsGroupInjectionKey"), d = Ee(
|
|
1053
|
+
r,
|
|
985
1054
|
i
|
|
986
|
-
),
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1055
|
+
), l = je(
|
|
1056
|
+
r,
|
|
1057
|
+
i,
|
|
1058
|
+
t,
|
|
1059
|
+
a
|
|
1060
|
+
), u = Se(
|
|
1061
|
+
r,
|
|
1062
|
+
i,
|
|
1063
|
+
o
|
|
1064
|
+
), c = Re(r, l), f = /* @__PURE__ */ new Map(), {
|
|
1065
|
+
clear: m,
|
|
1066
|
+
errors: p,
|
|
1067
|
+
formData: D,
|
|
1068
|
+
ignoreUpdates: h,
|
|
1069
|
+
invalid: v,
|
|
1070
|
+
readonly: y,
|
|
997
1071
|
reset: g,
|
|
998
|
-
status:
|
|
999
|
-
stopUpdatesWatch:
|
|
1072
|
+
status: E,
|
|
1073
|
+
stopUpdatesWatch: j,
|
|
1000
1074
|
submit: k,
|
|
1001
|
-
validate:
|
|
1002
|
-
VvForm:
|
|
1003
|
-
} =
|
|
1075
|
+
validate: x,
|
|
1076
|
+
VvForm: O
|
|
1077
|
+
} = De(e, r, a, c, f);
|
|
1004
1078
|
return {
|
|
1005
|
-
clear:
|
|
1006
|
-
errors:
|
|
1007
|
-
formData:
|
|
1008
|
-
formFieldInjectionKey:
|
|
1009
|
-
formInjectionKey:
|
|
1010
|
-
formWrapperInjectionKey:
|
|
1011
|
-
ignoreUpdates:
|
|
1012
|
-
invalid:
|
|
1013
|
-
readonly:
|
|
1079
|
+
clear: m,
|
|
1080
|
+
errors: p,
|
|
1081
|
+
formData: D,
|
|
1082
|
+
formFieldInjectionKey: t,
|
|
1083
|
+
formInjectionKey: r,
|
|
1084
|
+
formWrapperInjectionKey: i,
|
|
1085
|
+
ignoreUpdates: h,
|
|
1086
|
+
invalid: v,
|
|
1087
|
+
readonly: y,
|
|
1014
1088
|
reset: g,
|
|
1015
|
-
status:
|
|
1016
|
-
stopUpdatesWatch:
|
|
1089
|
+
status: E,
|
|
1090
|
+
stopUpdatesWatch: j,
|
|
1017
1091
|
submit: k,
|
|
1018
|
-
validate:
|
|
1019
|
-
wrappers:
|
|
1020
|
-
VvForm:
|
|
1021
|
-
VvFormField:
|
|
1022
|
-
VvFormFieldsGroup:
|
|
1023
|
-
VvFormTemplate:
|
|
1024
|
-
VvFormWrapper:
|
|
1092
|
+
validate: x,
|
|
1093
|
+
wrappers: f,
|
|
1094
|
+
VvForm: O,
|
|
1095
|
+
VvFormField: l,
|
|
1096
|
+
VvFormFieldsGroup: u,
|
|
1097
|
+
VvFormTemplate: c,
|
|
1098
|
+
VvFormWrapper: d
|
|
1025
1099
|
};
|
|
1026
1100
|
}
|
|
1027
1101
|
const se = Symbol("pluginInjectionKey");
|
|
1028
|
-
function
|
|
1029
|
-
let
|
|
1030
|
-
return e.schema && (
|
|
1031
|
-
...
|
|
1032
|
-
install(
|
|
1033
|
-
|
|
1102
|
+
function Ne(e) {
|
|
1103
|
+
let a = {};
|
|
1104
|
+
return e.schema && (a = Z(e.schema, e)), {
|
|
1105
|
+
...a,
|
|
1106
|
+
install(r, { global: i = !1 } = {}) {
|
|
1107
|
+
r.provide(se, e), i && (r.config.globalProperties.$vvForm = e, a?.VvForm && r.component("VvForm", a.VvForm), a?.VvFormWrapper && r.component("VvFormWrapper", a.VvFormWrapper), a?.VvFormField && r.component("VvFormField", a.VvFormField), a?.VvFormFieldsGroup && r.component("VvFormFieldsGroup", a.VvFormFieldsGroup), a?.VvFormTemplate && r.component("VvFormTemplate", a.VvFormTemplate));
|
|
1034
1108
|
}
|
|
1035
1109
|
};
|
|
1036
1110
|
}
|
|
1037
|
-
const
|
|
1038
|
-
function We(e,
|
|
1039
|
-
if (
|
|
1040
|
-
return
|
|
1111
|
+
const z = /* @__PURE__ */ new Map();
|
|
1112
|
+
function We(e, a = {}) {
|
|
1113
|
+
if (a.scope && z.has(a.scope))
|
|
1114
|
+
return z.get(a.scope);
|
|
1041
1115
|
if (!me()) {
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
1116
|
+
const i = Z(e, a);
|
|
1117
|
+
return a.scope && z.set(a.scope, i), i;
|
|
1044
1118
|
}
|
|
1045
|
-
const
|
|
1119
|
+
const r = Z(
|
|
1046
1120
|
e,
|
|
1047
1121
|
{
|
|
1048
|
-
...
|
|
1049
|
-
...
|
|
1122
|
+
...B(se, {}),
|
|
1123
|
+
...a
|
|
1050
1124
|
}
|
|
1051
1125
|
);
|
|
1052
|
-
return
|
|
1126
|
+
return a.scope && z.set(a.scope, r), r;
|
|
1053
1127
|
}
|
|
1054
|
-
function
|
|
1055
|
-
return
|
|
1128
|
+
function $e(e, a = {}) {
|
|
1129
|
+
return Z(e, a);
|
|
1056
1130
|
}
|
|
1057
1131
|
export {
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1132
|
+
V as FormFieldType,
|
|
1133
|
+
Ne as createForm,
|
|
1134
|
+
M as defaultObjectBySchema,
|
|
1135
|
+
$e as formType,
|
|
1062
1136
|
se as pluginInjectionKey,
|
|
1063
1137
|
We as useForm
|
|
1064
1138
|
};
|