@volverjs/form-vue 0.0.13 → 0.0.14-beta.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/VvForm.d.ts +12 -12
- package/dist/VvFormField.d.ts +4 -4
- package/dist/VvFormWrapper.d.ts +7 -13
- package/dist/index.d.ts +46 -58
- package/dist/index.es.js +170 -159
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +52 -125
- package/package.json +17 -16
- package/src/VvForm.ts +1 -1
- package/src/VvFormField.ts +1 -1
- package/src/VvFormWrapper.ts +1 -1
- package/src/{types.d.ts → types.ts} +10 -7
- package/src/utils.ts +27 -4
package/dist/index.es.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as G, computed as y, onMounted as Y, onBeforeUnmount as D, inject as S, toRefs as P, watch as w, unref as I, provide as K, readonly as k, resolveComponent as g, defineAsyncComponent as j, h as x, ref as A, toRaw as U, isProxy as F, withModifiers as ee, getCurrentInstance as re } from "vue";
|
|
2
2
|
import { watchThrottled as te } from "@vueuse/core";
|
|
3
|
-
import { ZodObject as
|
|
4
|
-
function
|
|
3
|
+
import { ZodObject as W, ZodDefault as ae, ZodNullable as ne, ZodSchema as oe, ZodArray as se, ZodEffects as ue, ZodOptional as ie } from "zod";
|
|
4
|
+
function z(e) {
|
|
5
5
|
return Array.isArray(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function le(e) {
|
|
8
8
|
return typeof e < "u";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function q(e) {
|
|
11
11
|
return e === null;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function T(e) {
|
|
14
14
|
return typeof e == "object";
|
|
15
15
|
}
|
|
16
16
|
function H(e) {
|
|
17
17
|
return typeof e == "string";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function _(e) {
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
return
|
|
27
|
-
const n = R(
|
|
22
|
+
const fe = /^[0-9]+$/, ve = ["__proto__", "prototype", "constructor"];
|
|
23
|
+
function N(e, o, l) {
|
|
24
|
+
const i = le(l) ? l : void 0;
|
|
25
|
+
if (!T(e) || !H(o))
|
|
26
|
+
return i;
|
|
27
|
+
const n = R(o);
|
|
28
28
|
if (n.length !== 0) {
|
|
29
29
|
for (const r of n) {
|
|
30
30
|
if (r === "*")
|
|
31
31
|
continue;
|
|
32
|
-
const
|
|
33
|
-
return a.map((
|
|
32
|
+
const s = function(a) {
|
|
33
|
+
return a.map((u) => _(u) || q(u) ? u : z(u) ? s(u) : u[r]);
|
|
34
34
|
};
|
|
35
|
-
if (
|
|
35
|
+
if (z(e) && !fe.test(r) ? e = s(e) : e = e[r], _(e) || q(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return _(e) ? i : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function Q(e,
|
|
42
|
-
if (!
|
|
41
|
+
function Q(e, o, l) {
|
|
42
|
+
if (!T(e) || !H(o))
|
|
43
43
|
return;
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const i = R(o);
|
|
45
|
+
if (i.length === 0)
|
|
46
46
|
return;
|
|
47
|
-
const n =
|
|
47
|
+
const n = i.length;
|
|
48
48
|
for (let r = 0; r < n; r++) {
|
|
49
|
-
const
|
|
49
|
+
const s = i[r];
|
|
50
50
|
if (r === n - 1) {
|
|
51
|
-
e[
|
|
51
|
+
e[s] = l;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
const a =
|
|
56
|
-
for (const
|
|
57
|
-
Q(
|
|
54
|
+
if (s === "*" && z(e)) {
|
|
55
|
+
const a = i.slice(r + 1).join(".");
|
|
56
|
+
for (const u of e)
|
|
57
|
+
Q(u, a, l);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
_(e[s]) && (e[s] = {}), e = e[s];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
function R(e) {
|
|
64
|
-
const
|
|
65
|
-
return
|
|
64
|
+
const o = e.split(/[.]|(?:\[(\d|\*)\])/).filter((l) => !!l);
|
|
65
|
+
return o.some((l) => ve.indexOf(l) !== -1) ? [] : o;
|
|
66
66
|
}
|
|
67
|
-
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 || {}),
|
|
68
|
-
const
|
|
67
|
+
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 || {}), $ = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e))($ || {});
|
|
68
|
+
const de = (e, o, l, i) => G({
|
|
69
69
|
name: "FieldComponent",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
@@ -100,11 +100,11 @@ const ve = (e, s, l, u) => W({
|
|
|
100
100
|
},
|
|
101
101
|
emits: ["invalid", "valid", "update:formData", "update:modelValue"],
|
|
102
102
|
expose: ["invalid", "invalidLabel", "errors"],
|
|
103
|
-
setup(n, { slots: r, emit:
|
|
103
|
+
setup(n, { slots: r, emit: s }) {
|
|
104
104
|
const a = y({
|
|
105
105
|
get() {
|
|
106
106
|
if (t != null && t.formData)
|
|
107
|
-
return
|
|
107
|
+
return N(
|
|
108
108
|
Object(t.formData.value),
|
|
109
109
|
String(n.name)
|
|
110
110
|
);
|
|
@@ -114,51 +114,51 @@ const ve = (e, s, l, u) => W({
|
|
|
114
114
|
Object(t.formData.value),
|
|
115
115
|
String(n.name),
|
|
116
116
|
f
|
|
117
|
-
),
|
|
117
|
+
), s("update:modelValue", {
|
|
118
118
|
newValue: a.value,
|
|
119
119
|
formData: t == null ? void 0 : t.formData
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
Y(() => {
|
|
124
124
|
a.value === void 0 && n.defaultValue !== void 0 && (a.value = n.defaultValue);
|
|
125
125
|
}), D(() => {
|
|
126
126
|
E(), V();
|
|
127
127
|
});
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
const t = S(e), { props: m, name: h } =
|
|
128
|
+
const u = S(o, void 0);
|
|
129
|
+
u && u.fields.value.add(n.name);
|
|
130
|
+
const t = S(e), { props: m, name: h } = P(n), d = y(() => {
|
|
131
131
|
if (t != null && t.errors.value)
|
|
132
|
-
return
|
|
132
|
+
return N(t.errors.value, String(n.name));
|
|
133
133
|
}), c = y(() => {
|
|
134
134
|
var f;
|
|
135
135
|
return (f = d.value) == null ? void 0 : f._errors;
|
|
136
|
-
}), b = y(() => d.value !== void 0), E =
|
|
137
|
-
b.value ? (
|
|
136
|
+
}), b = y(() => d.value !== void 0), E = w(b, () => {
|
|
137
|
+
b.value ? (s("invalid", c.value), u && u.errors.value.set(
|
|
138
138
|
n.name,
|
|
139
139
|
{
|
|
140
140
|
_errors: c.value
|
|
141
141
|
}
|
|
142
|
-
)) : (
|
|
142
|
+
)) : (s("valid", a.value), u && u.errors.value.delete(
|
|
143
143
|
n.name
|
|
144
144
|
));
|
|
145
|
-
}), V =
|
|
145
|
+
}), V = w(
|
|
146
146
|
() => t == null ? void 0 : t.formData,
|
|
147
147
|
() => {
|
|
148
|
-
|
|
148
|
+
s("update:formData", t == null ? void 0 : t.formData);
|
|
149
149
|
},
|
|
150
150
|
{ deep: !0 }
|
|
151
151
|
), p = (f) => {
|
|
152
152
|
a.value = f;
|
|
153
|
-
},
|
|
153
|
+
}, C = y(() => {
|
|
154
154
|
let f = m.value;
|
|
155
155
|
return typeof f == "function" && (f = f(t == null ? void 0 : t.formData)), Object.keys(f).reduce(
|
|
156
|
-
(
|
|
156
|
+
(O, M) => (O[M] = I(f[M]), O),
|
|
157
157
|
{}
|
|
158
158
|
);
|
|
159
|
-
}),
|
|
160
|
-
|
|
161
|
-
name:
|
|
159
|
+
}), L = y(() => ({
|
|
160
|
+
...C.value,
|
|
161
|
+
name: C.value.name ?? n.name,
|
|
162
162
|
invalid: b.value,
|
|
163
163
|
valid: n.showValid ? !!(!b.value && a.value) : void 0,
|
|
164
164
|
type: ((f) => {
|
|
@@ -183,7 +183,7 @@ const ve = (e, s, l, u) => W({
|
|
|
183
183
|
modelValue: a.value,
|
|
184
184
|
"onUpdate:modelValue": p
|
|
185
185
|
}));
|
|
186
|
-
return
|
|
186
|
+
return K(l, {
|
|
187
187
|
name: k(h),
|
|
188
188
|
errors: k(d)
|
|
189
189
|
}), { component: y(() => {
|
|
@@ -204,7 +204,7 @@ const ve = (e, s, l, u) => W({
|
|
|
204
204
|
})) ?? r.defalut;
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
-
if (!((
|
|
207
|
+
if (!((i == null ? void 0 : i.lazyLoad) ?? n.lazyLoad)) {
|
|
208
208
|
let f;
|
|
209
209
|
switch (n.type) {
|
|
210
210
|
case v.select:
|
|
@@ -238,7 +238,7 @@ const ve = (e, s, l, u) => W({
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
return j(async () => {
|
|
241
|
-
switch (
|
|
241
|
+
switch (i != null && i.sideEffects && await Promise.resolve(i.sideEffects(n.type)), n.type) {
|
|
242
242
|
case v.textarea:
|
|
243
243
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
244
244
|
case v.radio:
|
|
@@ -256,47 +256,58 @@ const ve = (e, s, l, u) => W({
|
|
|
256
256
|
}
|
|
257
257
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
258
258
|
});
|
|
259
|
-
}), hasProps:
|
|
259
|
+
}), hasProps: L, invalid: b };
|
|
260
260
|
},
|
|
261
261
|
render() {
|
|
262
262
|
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === v.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
|
|
263
263
|
}
|
|
264
|
-
}),
|
|
264
|
+
}), Z = (e, o = {}) => {
|
|
265
265
|
const l = (r) => {
|
|
266
|
-
let
|
|
267
|
-
for (;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return o;
|
|
272
|
-
}, u = l(e);
|
|
266
|
+
let s = r;
|
|
267
|
+
for (; s instanceof ue; )
|
|
268
|
+
s = s.innerType();
|
|
269
|
+
return s instanceof ie && (s = s._def.innerType), s;
|
|
270
|
+
}, i = l(e);
|
|
273
271
|
return {
|
|
274
|
-
...(
|
|
272
|
+
...(i instanceof W ? i._def.unknownKeys === "passthrough" : !1) ? o : {},
|
|
275
273
|
...Object.fromEntries(
|
|
276
|
-
Object.entries(
|
|
277
|
-
([r,
|
|
278
|
-
const a =
|
|
279
|
-
let t;
|
|
280
|
-
if (
|
|
274
|
+
Object.entries(i.shape).map(
|
|
275
|
+
([r, s]) => {
|
|
276
|
+
const a = o[r];
|
|
277
|
+
let u = l(s), t;
|
|
278
|
+
if (u instanceof ae && (t = u._def.defaultValue(), u = u._def.innerType), a === null && u instanceof ne)
|
|
281
279
|
return [r, a];
|
|
282
|
-
if (
|
|
283
|
-
const m =
|
|
280
|
+
if (u instanceof oe) {
|
|
281
|
+
const m = s.safeParse(a);
|
|
284
282
|
if (m.success)
|
|
285
283
|
return [r, m.data ?? t];
|
|
286
284
|
}
|
|
287
|
-
|
|
285
|
+
if (u instanceof se && Array.isArray(a) && a.length) {
|
|
286
|
+
const m = l(u._def.type);
|
|
287
|
+
if (m instanceof W)
|
|
288
|
+
return [
|
|
289
|
+
r,
|
|
290
|
+
a.map(
|
|
291
|
+
(h) => Z(
|
|
292
|
+
m,
|
|
293
|
+
h && typeof h == "object" ? h : void 0
|
|
294
|
+
)
|
|
295
|
+
) ?? t
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
return u instanceof W ? [
|
|
288
299
|
r,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
a && typeof a == "object" ? a :
|
|
300
|
+
Z(
|
|
301
|
+
u,
|
|
302
|
+
a && typeof a == "object" ? a : t
|
|
292
303
|
)
|
|
293
304
|
] : [r, t];
|
|
294
305
|
}
|
|
295
306
|
)
|
|
296
307
|
)
|
|
297
308
|
};
|
|
298
|
-
},
|
|
299
|
-
const
|
|
309
|
+
}, ce = (e, o, l) => {
|
|
310
|
+
const i = A(), n = A(), r = A(), s = G({
|
|
300
311
|
name: "FormComponent",
|
|
301
312
|
props: {
|
|
302
313
|
modelValue: {
|
|
@@ -314,15 +325,15 @@ const ve = (e, s, l, u) => W({
|
|
|
314
325
|
},
|
|
315
326
|
emits: ["invalid", "valid", "submit", "update:modelValue"],
|
|
316
327
|
expose: ["submit", "validate", "errors", "status", "valid", "invalid"],
|
|
317
|
-
setup(a, { emit:
|
|
318
|
-
r.value =
|
|
328
|
+
setup(a, { emit: u }) {
|
|
329
|
+
r.value = Z(
|
|
319
330
|
e,
|
|
320
|
-
|
|
321
|
-
),
|
|
331
|
+
U(a.modelValue)
|
|
332
|
+
), w(
|
|
322
333
|
() => a.modelValue,
|
|
323
334
|
(d) => {
|
|
324
335
|
if (d) {
|
|
325
|
-
const c = F(d) ?
|
|
336
|
+
const c = F(d) ? U(d) : d;
|
|
326
337
|
r.value = typeof (c == null ? void 0 : c.clone) == "function" ? c.clone() : JSON.parse(JSON.stringify(c));
|
|
327
338
|
}
|
|
328
339
|
},
|
|
@@ -330,7 +341,7 @@ const ve = (e, s, l, u) => W({
|
|
|
330
341
|
), te(
|
|
331
342
|
r,
|
|
332
343
|
(d) => {
|
|
333
|
-
((
|
|
344
|
+
((i.value || (l == null ? void 0 : l.continuosValidation)) ?? a.continuosValidation) && t(), (!d || !a.modelValue || JSON.stringify(d) !== JSON.stringify(a.modelValue)) && u("update:modelValue", d);
|
|
334
345
|
},
|
|
335
346
|
{
|
|
336
347
|
deep: !0,
|
|
@@ -339,20 +350,20 @@ const ve = (e, s, l, u) => W({
|
|
|
339
350
|
);
|
|
340
351
|
const t = (d = r.value) => {
|
|
341
352
|
const c = e.safeParse(d);
|
|
342
|
-
return c.success ? (
|
|
343
|
-
}, m = () => t() ? (
|
|
344
|
-
return
|
|
353
|
+
return c.success ? (i.value = void 0, n.value = $.valid, r.value = c.data, u("update:modelValue", r.value), u("valid", c.data), !0) : (i.value = c.error.format(), n.value = $.invalid, u("invalid", i.value), !1);
|
|
354
|
+
}, m = () => t() ? (u("submit", r.value), !0) : !1, h = y(() => n.value === $.invalid);
|
|
355
|
+
return K(o, {
|
|
345
356
|
formData: r,
|
|
346
357
|
submit: m,
|
|
347
358
|
validate: t,
|
|
348
|
-
errors: k(
|
|
359
|
+
errors: k(i),
|
|
349
360
|
status: k(n),
|
|
350
361
|
invalid: h
|
|
351
362
|
}), {
|
|
352
363
|
formData: r,
|
|
353
364
|
submit: m,
|
|
354
365
|
validate: t,
|
|
355
|
-
errors: k(
|
|
366
|
+
errors: k(i),
|
|
356
367
|
status: k(n),
|
|
357
368
|
invalid: h
|
|
358
369
|
};
|
|
@@ -365,8 +376,8 @@ const ve = (e, s, l, u) => W({
|
|
|
365
376
|
},
|
|
366
377
|
{
|
|
367
378
|
default: () => {
|
|
368
|
-
var a,
|
|
369
|
-
return ((
|
|
379
|
+
var a, u;
|
|
380
|
+
return ((u = (a = this.$slots) == null ? void 0 : a.default) == null ? void 0 : u.call(a, {
|
|
370
381
|
formData: this.formData,
|
|
371
382
|
submit: this.submit,
|
|
372
383
|
validate: this.validate,
|
|
@@ -380,15 +391,15 @@ const ve = (e, s, l, u) => W({
|
|
|
380
391
|
}
|
|
381
392
|
});
|
|
382
393
|
return {
|
|
383
|
-
errors:
|
|
394
|
+
errors: i,
|
|
384
395
|
status: n,
|
|
385
396
|
formData: r,
|
|
386
397
|
/**
|
|
387
398
|
* An hack to add types to the default slot
|
|
388
399
|
*/
|
|
389
|
-
VvForm:
|
|
400
|
+
VvForm: s
|
|
390
401
|
};
|
|
391
|
-
},
|
|
402
|
+
}, me = (e, o) => G({
|
|
392
403
|
name: "WrapperComponent",
|
|
393
404
|
props: {
|
|
394
405
|
name: {
|
|
@@ -402,34 +413,34 @@ const ve = (e, s, l, u) => W({
|
|
|
402
413
|
},
|
|
403
414
|
emits: ["invalid", "valid"],
|
|
404
415
|
expose: ["fields", "invalid"],
|
|
405
|
-
setup(
|
|
406
|
-
const r = S(e),
|
|
407
|
-
|
|
416
|
+
setup(i, { emit: n }) {
|
|
417
|
+
const r = S(e), s = S(o, void 0), a = A(/* @__PURE__ */ new Set()), u = A(/* @__PURE__ */ new Map()), { name: t } = P(i);
|
|
418
|
+
K(o, {
|
|
408
419
|
name: k(t),
|
|
409
|
-
errors:
|
|
420
|
+
errors: u,
|
|
410
421
|
fields: a
|
|
411
|
-
}),
|
|
422
|
+
}), w(
|
|
412
423
|
a,
|
|
413
424
|
(h) => {
|
|
414
|
-
|
|
415
|
-
|
|
425
|
+
s != null && s.fields && h.forEach((d) => {
|
|
426
|
+
s == null || s.fields.value.add(d);
|
|
416
427
|
});
|
|
417
428
|
},
|
|
418
429
|
{ deep: !0 }
|
|
419
|
-
),
|
|
420
|
-
() => new Map(
|
|
430
|
+
), w(
|
|
431
|
+
() => new Map(u.value),
|
|
421
432
|
(h, d) => {
|
|
422
|
-
|
|
423
|
-
|
|
433
|
+
s != null && s.errors && (Array.from(d.keys()).forEach((c) => {
|
|
434
|
+
s.errors.value.delete(c);
|
|
424
435
|
}), Array.from(h.keys()).forEach((c) => {
|
|
425
436
|
const b = h.get(c);
|
|
426
|
-
b &&
|
|
437
|
+
b && s.errors.value.set(c, b);
|
|
427
438
|
}));
|
|
428
439
|
},
|
|
429
440
|
{ deep: !0 }
|
|
430
441
|
);
|
|
431
|
-
const m = y(() => r != null && r.invalid.value ?
|
|
432
|
-
return
|
|
442
|
+
const m = y(() => r != null && r.invalid.value ? u.value.size > 0 : !1);
|
|
443
|
+
return w(m, () => {
|
|
433
444
|
m.value ? n("invalid") : n("valid");
|
|
434
445
|
}), {
|
|
435
446
|
formData: r == null ? void 0 : r.formData,
|
|
@@ -438,15 +449,15 @@ const ve = (e, s, l, u) => W({
|
|
|
438
449
|
validate: r == null ? void 0 : r.validate,
|
|
439
450
|
invalid: m,
|
|
440
451
|
fields: a,
|
|
441
|
-
fieldsErrors:
|
|
452
|
+
fieldsErrors: u
|
|
442
453
|
};
|
|
443
454
|
},
|
|
444
455
|
render() {
|
|
445
|
-
var
|
|
456
|
+
var i, n;
|
|
446
457
|
return this.tag ? x(this.tag, null, {
|
|
447
458
|
default: () => {
|
|
448
|
-
var r,
|
|
449
|
-
return ((
|
|
459
|
+
var r, s;
|
|
460
|
+
return ((s = (r = this.$slots).default) == null ? void 0 : s.call(r, {
|
|
450
461
|
invalid: this.invalid,
|
|
451
462
|
formData: this.formData,
|
|
452
463
|
submit: this.submit,
|
|
@@ -455,7 +466,7 @@ const ve = (e, s, l, u) => W({
|
|
|
455
466
|
fieldsErrors: this.fieldsErrors
|
|
456
467
|
})) ?? this.$slots.defalut;
|
|
457
468
|
}
|
|
458
|
-
}) : ((n = (
|
|
469
|
+
}) : ((n = (i = this.$slots).default) == null ? void 0 : n.call(i, {
|
|
459
470
|
invalid: this.invalid,
|
|
460
471
|
formData: this.formData,
|
|
461
472
|
submit: this.submit,
|
|
@@ -464,23 +475,23 @@ const ve = (e, s, l, u) => W({
|
|
|
464
475
|
fieldsErrors: this.fieldsErrors
|
|
465
476
|
})) ?? this.$slots.defalut;
|
|
466
477
|
}
|
|
467
|
-
}),
|
|
468
|
-
const l =
|
|
478
|
+
}), he = (e, o) => {
|
|
479
|
+
const l = G({
|
|
469
480
|
props: {
|
|
470
481
|
schema: {
|
|
471
482
|
type: [Array, Function],
|
|
472
483
|
required: !0
|
|
473
484
|
}
|
|
474
485
|
},
|
|
475
|
-
setup(
|
|
486
|
+
setup(i, { slots: n }) {
|
|
476
487
|
const r = S(e);
|
|
477
488
|
if (!(r != null && r.formData))
|
|
478
489
|
return;
|
|
479
|
-
const
|
|
490
|
+
const s = typeof i.schema == "function" ? i.schema(r) : i.schema;
|
|
480
491
|
let a;
|
|
481
492
|
return () => {
|
|
482
|
-
var
|
|
483
|
-
return
|
|
493
|
+
var u;
|
|
494
|
+
return s.reduce(
|
|
484
495
|
(t, m) => {
|
|
485
496
|
const h = typeof m == "function" ? m(r) : m, {
|
|
486
497
|
vvIs: d,
|
|
@@ -489,51 +500,51 @@ const ve = (e, s, l, u) => W({
|
|
|
489
500
|
vvChildren: E,
|
|
490
501
|
vvIf: V,
|
|
491
502
|
vvElseIf: p,
|
|
492
|
-
vvType:
|
|
493
|
-
vvDefaultValue:
|
|
494
|
-
vvShowValid:
|
|
503
|
+
vvType: C,
|
|
504
|
+
vvDefaultValue: L,
|
|
505
|
+
vvShowValid: J,
|
|
495
506
|
...f
|
|
496
507
|
} = h;
|
|
497
508
|
if (V !== void 0) {
|
|
498
|
-
if (typeof V == "string" ? a = !!
|
|
509
|
+
if (typeof V == "string" ? a = !!N(
|
|
499
510
|
Object(r.formData.value),
|
|
500
511
|
V
|
|
501
512
|
) : typeof V == "function" ? a = I(V(r)) : a = I(V), !a)
|
|
502
513
|
return t;
|
|
503
514
|
} else if (p !== void 0 && a !== void 0) {
|
|
504
|
-
if (a || (typeof p == "string" ? a = !!
|
|
515
|
+
if (a || (typeof p == "string" ? a = !!N(
|
|
505
516
|
Object(r.formData.value),
|
|
506
517
|
p
|
|
507
518
|
) : typeof p == "function" ? a = I(p(r)) : a = I(p), !a))
|
|
508
519
|
return t;
|
|
509
520
|
} else
|
|
510
521
|
a = void 0;
|
|
511
|
-
const
|
|
522
|
+
const O = E ? x(l, {
|
|
512
523
|
schema: E
|
|
513
524
|
}) : void 0;
|
|
514
525
|
return c ? (t.push(
|
|
515
526
|
x(
|
|
516
|
-
|
|
527
|
+
o,
|
|
517
528
|
{
|
|
518
529
|
name: c,
|
|
519
530
|
is: d,
|
|
520
|
-
type:
|
|
521
|
-
defaultValue:
|
|
522
|
-
showValid:
|
|
531
|
+
type: C,
|
|
532
|
+
defaultValue: L,
|
|
533
|
+
showValid: J,
|
|
523
534
|
props: f
|
|
524
535
|
},
|
|
525
|
-
b ??
|
|
536
|
+
b ?? O
|
|
526
537
|
)
|
|
527
538
|
), t) : d ? (t.push(
|
|
528
539
|
x(
|
|
529
540
|
d,
|
|
530
541
|
f,
|
|
531
|
-
b ??
|
|
542
|
+
b ?? O
|
|
532
543
|
)
|
|
533
|
-
), t) : (E && t.push(
|
|
544
|
+
), t) : (E && t.push(O), t);
|
|
534
545
|
},
|
|
535
546
|
[
|
|
536
|
-
(
|
|
547
|
+
(u = n == null ? void 0 : n.default) == null ? void 0 : u.call(n, {
|
|
537
548
|
formData: r == null ? void 0 : r.formData.value,
|
|
538
549
|
submit: r == null ? void 0 : r.submit,
|
|
539
550
|
validate: r == null ? void 0 : r.validate,
|
|
@@ -547,49 +558,49 @@ const ve = (e, s, l, u) => W({
|
|
|
547
558
|
}
|
|
548
559
|
});
|
|
549
560
|
return l;
|
|
550
|
-
},
|
|
551
|
-
const l = Symbol(),
|
|
561
|
+
}, B = (e, o = {}) => {
|
|
562
|
+
const l = Symbol(), i = Symbol(), n = Symbol(), { VvForm: r, errors: s, status: a, formData: u } = ce(
|
|
552
563
|
e,
|
|
553
564
|
l,
|
|
554
|
-
|
|
555
|
-
), t =
|
|
565
|
+
o
|
|
566
|
+
), t = me(
|
|
556
567
|
l,
|
|
557
|
-
|
|
558
|
-
), m =
|
|
568
|
+
i
|
|
569
|
+
), m = de(
|
|
559
570
|
l,
|
|
560
|
-
|
|
571
|
+
i,
|
|
561
572
|
n,
|
|
562
|
-
|
|
563
|
-
), h =
|
|
573
|
+
o
|
|
574
|
+
), h = he(l, m);
|
|
564
575
|
return {
|
|
565
576
|
VvForm: r,
|
|
566
577
|
VvFormWrapper: t,
|
|
567
578
|
VvFormField: m,
|
|
568
579
|
VvFormTemplate: h,
|
|
569
580
|
formInjectionKey: l,
|
|
570
|
-
formWrapperInjectionKey:
|
|
581
|
+
formWrapperInjectionKey: i,
|
|
571
582
|
formFieldInjectionKey: n,
|
|
572
|
-
errors:
|
|
583
|
+
errors: s,
|
|
573
584
|
status: a,
|
|
574
|
-
formData:
|
|
585
|
+
formData: u
|
|
575
586
|
};
|
|
576
|
-
},
|
|
577
|
-
let
|
|
578
|
-
return e.schema && (
|
|
579
|
-
...
|
|
580
|
-
install(l, { global:
|
|
581
|
-
l.provide(
|
|
587
|
+
}, X = Symbol(), Ve = (e) => {
|
|
588
|
+
let o = {};
|
|
589
|
+
return e.schema && (o = B(e.schema, e)), {
|
|
590
|
+
...o,
|
|
591
|
+
install(l, { global: i = !1 } = {}) {
|
|
592
|
+
l.provide(X, e), i && (l.config.globalProperties.$vvForm = e, o != null && o.VvForm && l.component("VvForm", o.VvForm), o != null && o.VvFormWrapper && l.component("VvFormWrapper", o.VvFormWrapper), o != null && o.VvFormField && l.component("VvFormField", o.VvFormField), o != null && o.VvFormTemplate && l.component("VvFormTemplate", o.VvFormTemplate));
|
|
582
593
|
}
|
|
583
594
|
};
|
|
584
|
-
},
|
|
585
|
-
...S(
|
|
586
|
-
...
|
|
587
|
-
}) :
|
|
595
|
+
}, ge = (e, o = {}) => re() ? B(e, {
|
|
596
|
+
...S(X, {}),
|
|
597
|
+
...o
|
|
598
|
+
}) : B(e, o), xe = (e, o = {}) => B(e, o);
|
|
588
599
|
export {
|
|
589
600
|
v as FormFieldType,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
601
|
+
Ve as createForm,
|
|
602
|
+
Z as defaultObjectBySchema,
|
|
603
|
+
xe as formFactory,
|
|
604
|
+
X as pluginInjectionKey,
|
|
605
|
+
ge as useForm
|
|
595
606
|
};
|