@volverjs/form-vue 1.1.0-beta.4 → 1.1.0-beta.5
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/index.es.js +606 -606
- package/dist/index.umd.js +1 -1
- package/dist/utils.d.ts +12 -0
- package/package.json +1 -1
- package/src/utils.ts +182 -30
package/dist/index.es.js
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { watchIgnorable as
|
|
3
|
-
import { ZodError as
|
|
4
|
-
import { safeParse as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const K = (e) => e._def.typeName === "ZodObject", Ve = (e) => e._def.typeName === "ZodDefault", Oe = (e) => e._def.typeName === "ZodNullable", we = (e) => e._def.typeName === "ZodRecord", De = (e) => e._def.typeName === "ZodArray", oe = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", z = (e) => {
|
|
1
|
+
import { ref as B, computed as O, readonly as F, defineComponent as U, h as z, withModifiers as re, toRaw as N, watch as Z, isProxy as me, onMounted as H, provide as Q, toRefs as Y, useId as ae, inject as G, onBeforeUnmount as L, unref as W, resolveComponent as $, defineAsyncComponent as pe, getCurrentInstance as ye } from "vue";
|
|
2
|
+
import { watchIgnorable as he, throttleFilter as be } from "@vueuse/core";
|
|
3
|
+
import { ZodError as je } from "zod/v3";
|
|
4
|
+
import { safeParse as Ve, safeParseAsync as ge, formatError as ne, $ZodError as we } from "zod/v4/core";
|
|
5
|
+
import { set as oe, get as P } from "ts-dot-prop";
|
|
6
|
+
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 || {});
|
|
7
|
+
const K = (e) => e._def.typeName === "ZodObject", T = (e) => e._zod.def.type === "object", De = (e) => e._def.typeName === "ZodDefault", Oe = (e) => e._zod.def.type === "default", _e = (e) => e._def.typeName === "ZodNullable", Re = (e) => e._zod.def.type === "nullable", Se = (e) => e._def.typeName === "ZodRecord", Ie = (e) => e._zod.def.type === "record", ze = (e) => e._def.typeName === "ZodArray", Ee = (e) => e._zod.def.type === "array", le = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", ie = (e) => e._zod.def.type === "optional", se = (e) => e._zod.def.type === "pipe", de = (e) => e._zod.def.type === "transform", C = (e) => {
|
|
9
8
|
let t = e;
|
|
10
|
-
for (;
|
|
9
|
+
for (; le(t); )
|
|
11
10
|
t = t.innerType();
|
|
12
11
|
return ue(t) && (t = t._def.innerType), t;
|
|
13
|
-
},
|
|
12
|
+
}, M = (e) => {
|
|
14
13
|
let t = e;
|
|
15
|
-
for (;
|
|
14
|
+
for (; se(t); )
|
|
15
|
+
de(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
|
|
16
|
+
return ie(t) && (t = t._zod.def.innerType), t;
|
|
17
|
+
}, xe = (e) => {
|
|
18
|
+
let t = e;
|
|
19
|
+
for (; le(t); )
|
|
16
20
|
t = t.innerType();
|
|
17
21
|
return !!ue(t);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (r.type !== "object" || !r.properties)
|
|
73
|
-
return t;
|
|
74
|
-
const u = ye(e, t);
|
|
75
|
-
return W(r, u.success ? u.data : t);
|
|
22
|
+
}, Ze = (e) => {
|
|
23
|
+
let t = e;
|
|
24
|
+
for (; se(t); )
|
|
25
|
+
de(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
|
|
26
|
+
return !!ie(t);
|
|
27
|
+
}, X = (e) => "_zod" in e;
|
|
28
|
+
function k(e, t = {}) {
|
|
29
|
+
if (X(e)) {
|
|
30
|
+
const a = M(e);
|
|
31
|
+
return T(a) ? {
|
|
32
|
+
...!(!a._zod.def.catchall || a._zod.def.catchall?._zod.def.type === "never") ? t : {},
|
|
33
|
+
...Object.fromEntries(
|
|
34
|
+
("shape" in a._zod.def ? Object.entries(a._zod.def.shape) : []).map(
|
|
35
|
+
([l, f]) => {
|
|
36
|
+
const r = t[l], v = Ze(f);
|
|
37
|
+
let o = M(f), d;
|
|
38
|
+
if (Oe(o) && (d = o._zod.def.defaultValue, o = o._zod.def.innerType), r === null && Re(o))
|
|
39
|
+
return [l, r];
|
|
40
|
+
if (r == null && v)
|
|
41
|
+
return [l, d];
|
|
42
|
+
if (o) {
|
|
43
|
+
const c = Ve(f, r);
|
|
44
|
+
if (c.success)
|
|
45
|
+
return [l, c.data ?? d];
|
|
46
|
+
}
|
|
47
|
+
if (Ee(o) && Array.isArray(r) && r.length) {
|
|
48
|
+
const c = M(o._zod.def.element);
|
|
49
|
+
if (T(c))
|
|
50
|
+
return [
|
|
51
|
+
l,
|
|
52
|
+
r.map(
|
|
53
|
+
(D) => k(
|
|
54
|
+
c,
|
|
55
|
+
D && typeof D == "object" ? D : void 0
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
if (Ie(o) && r) {
|
|
61
|
+
const c = M(o._zod.def.valueType);
|
|
62
|
+
if (T(c))
|
|
63
|
+
return [l, Object.keys(r).reduce((D, p) => (D[p] = k(c, r[p]), D), {})];
|
|
64
|
+
}
|
|
65
|
+
return T(o) ? [
|
|
66
|
+
l,
|
|
67
|
+
k(
|
|
68
|
+
o,
|
|
69
|
+
r && typeof r == "object" ? r : d
|
|
70
|
+
)
|
|
71
|
+
] : [l, d];
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
} : t;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
return K(
|
|
79
|
-
...
|
|
77
|
+
const u = C(e);
|
|
78
|
+
return K(u) ? {
|
|
79
|
+
...u._def.unknownKeys === "passthrough" ? t : {},
|
|
80
80
|
...Object.fromEntries(
|
|
81
|
-
("shape" in
|
|
82
|
-
([
|
|
83
|
-
const
|
|
84
|
-
let
|
|
85
|
-
if (
|
|
86
|
-
return [
|
|
87
|
-
if (
|
|
88
|
-
return [
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
return [
|
|
81
|
+
("shape" in u ? Object.entries(u.shape) : []).map(
|
|
82
|
+
([a, s]) => {
|
|
83
|
+
const l = t[a], f = xe(s);
|
|
84
|
+
let r = C(s), v;
|
|
85
|
+
if (De(r) && (v = r._def.defaultValue(), r = r._def.innerType), l === null && _e(r))
|
|
86
|
+
return [a, l];
|
|
87
|
+
if (l == null && f)
|
|
88
|
+
return [a, v];
|
|
89
|
+
if (r) {
|
|
90
|
+
const o = s.safeParse(l);
|
|
91
|
+
if (o.success)
|
|
92
|
+
return [a, o.data ?? v];
|
|
93
93
|
}
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
if (K(
|
|
94
|
+
if (ze(r) && Array.isArray(l) && l.length) {
|
|
95
|
+
const o = C(r._def.type);
|
|
96
|
+
if (K(o))
|
|
97
97
|
return [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
a,
|
|
99
|
+
l.map(
|
|
100
|
+
(d) => k(
|
|
101
|
+
o,
|
|
102
|
+
d && typeof d == "object" ? d : void 0
|
|
103
103
|
)
|
|
104
104
|
)
|
|
105
105
|
];
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
if (K(
|
|
110
|
-
return [
|
|
107
|
+
if (Se(r) && l) {
|
|
108
|
+
const o = C(r._def.valueType);
|
|
109
|
+
if (K(o))
|
|
110
|
+
return [a, Object.keys(l).reduce((d, c) => (d[c] = k(o, l[c]), d), {})];
|
|
111
111
|
}
|
|
112
|
-
return K(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
return K(r) ? [
|
|
113
|
+
a,
|
|
114
|
+
k(
|
|
115
|
+
r,
|
|
116
|
+
l && typeof l == "object" ? l : v
|
|
117
117
|
)
|
|
118
|
-
] : [
|
|
118
|
+
] : [a, v];
|
|
119
119
|
}
|
|
120
120
|
)
|
|
121
121
|
)
|
|
122
122
|
} : t;
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
function
|
|
126
|
-
const
|
|
127
|
-
let
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
132
|
-
return new
|
|
124
|
+
const Fe = (e, t) => X(e) ? ge(e, t) : e.safeParseAsync(t), Ae = (e, t) => X(e) ? ne(t) : t.format(), Ne = (e, t) => X(e) ? ne(new we(t)) : new je(t).format();
|
|
125
|
+
function $e(e, t, u, g, a) {
|
|
126
|
+
const s = B(), l = B(), f = O(() => l.value === S.invalid), r = B(), v = B(!1);
|
|
127
|
+
let o;
|
|
128
|
+
const d = (w) => {
|
|
129
|
+
const _ = k(e, w);
|
|
130
|
+
if (u?.class) {
|
|
131
|
+
const n = u.class;
|
|
132
|
+
return new n(_);
|
|
133
133
|
}
|
|
134
|
-
return
|
|
135
|
-
},
|
|
136
|
-
if (
|
|
134
|
+
return _;
|
|
135
|
+
}, c = async (w = r.value, _) => {
|
|
136
|
+
if (o = _?.fields, v.value)
|
|
137
137
|
return !0;
|
|
138
|
-
const
|
|
139
|
-
if (!
|
|
140
|
-
if (
|
|
141
|
-
return
|
|
142
|
-
const j =
|
|
143
|
-
(
|
|
138
|
+
const n = await Fe(e, w);
|
|
139
|
+
if (!n.success) {
|
|
140
|
+
if (l.value = S.invalid, !o?.size)
|
|
141
|
+
return s.value = Ae(e, n.error), !1;
|
|
142
|
+
const j = n.error.issues.filter(
|
|
143
|
+
(A) => o?.has(A.path.join("."))
|
|
144
144
|
);
|
|
145
|
-
return j.length ? (
|
|
145
|
+
return j.length ? (s.value = Ne(e, j), !1) : (s.value = void 0, !0);
|
|
146
146
|
}
|
|
147
|
-
return
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
},
|
|
153
|
-
|
|
147
|
+
return s.value = void 0, l.value = S.valid, r.value = d(n.data), !0;
|
|
148
|
+
}, D = () => {
|
|
149
|
+
s.value = void 0, l.value = void 0, o = void 0;
|
|
150
|
+
}, p = () => {
|
|
151
|
+
r.value = d(), D(), l.value = S.reset;
|
|
152
|
+
}, m = async (w) => v.value || !await c(void 0, w) ? !1 : (l.value = S.submitting, !0), { ignoreUpdates: y, stop: b } = he(
|
|
153
|
+
r,
|
|
154
154
|
() => {
|
|
155
|
-
|
|
155
|
+
l.value = S.updated;
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
158
|
deep: !0,
|
|
159
|
-
eventFilter:
|
|
159
|
+
eventFilter: be(u?.updateThrottle ?? 500)
|
|
160
160
|
}
|
|
161
|
-
),
|
|
161
|
+
), I = F(s), R = F(l), E = U({
|
|
162
162
|
name: "VvForm",
|
|
163
163
|
props: {
|
|
164
164
|
continuousValidation: {
|
|
@@ -171,7 +171,7 @@ function Ae(e, t, n, b, r) {
|
|
|
171
171
|
},
|
|
172
172
|
readonly: {
|
|
173
173
|
type: Boolean,
|
|
174
|
-
default:
|
|
174
|
+
default: u?.readonly
|
|
175
175
|
},
|
|
176
176
|
tag: {
|
|
177
177
|
type: String,
|
|
@@ -212,117 +212,117 @@ function Ae(e, t, n, b, r) {
|
|
|
212
212
|
"reset"
|
|
213
213
|
],
|
|
214
214
|
slots: Object,
|
|
215
|
-
setup(w, { emit:
|
|
216
|
-
return
|
|
215
|
+
setup(w, { emit: _ }) {
|
|
216
|
+
return r.value = d(N(w.modelValue)), Z(
|
|
217
217
|
() => w.modelValue,
|
|
218
|
-
(
|
|
219
|
-
if (
|
|
220
|
-
const j =
|
|
221
|
-
if (JSON.stringify(j) === JSON.stringify(
|
|
218
|
+
(n) => {
|
|
219
|
+
if (n) {
|
|
220
|
+
const j = me(n) ? N(n) : n;
|
|
221
|
+
if (JSON.stringify(j) === JSON.stringify(N(r.value)))
|
|
222
222
|
return;
|
|
223
|
-
|
|
223
|
+
r.value = typeof j?.clone == "function" ? j.clone() : JSON.parse(JSON.stringify(j));
|
|
224
224
|
}
|
|
225
225
|
},
|
|
226
226
|
{ deep: !0 }
|
|
227
|
-
),
|
|
228
|
-
if (
|
|
229
|
-
const j =
|
|
230
|
-
|
|
227
|
+
), Z(l, async (n) => {
|
|
228
|
+
if (n === S.invalid) {
|
|
229
|
+
const j = N(s.value);
|
|
230
|
+
_("invalid", j), u?.onInvalid?.(
|
|
231
231
|
j
|
|
232
232
|
);
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
if (
|
|
236
|
-
const j =
|
|
237
|
-
|
|
235
|
+
if (n === S.valid) {
|
|
236
|
+
const j = N(r.value);
|
|
237
|
+
_("valid", j), u?.onValid?.(j), _("update:modelValue", j), u?.onUpdate?.(j);
|
|
238
238
|
return;
|
|
239
239
|
}
|
|
240
|
-
if (
|
|
241
|
-
const j =
|
|
242
|
-
|
|
240
|
+
if (n === S.submitting) {
|
|
241
|
+
const j = N(r.value);
|
|
242
|
+
_("submit", j), u?.onSubmit?.(j);
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
|
-
if (
|
|
246
|
-
const j =
|
|
247
|
-
|
|
245
|
+
if (n === S.reset) {
|
|
246
|
+
const j = N(r.value);
|
|
247
|
+
_("reset", j), u?.onReset?.(j);
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
if (
|
|
251
|
-
if ((
|
|
250
|
+
if (n === S.updated) {
|
|
251
|
+
if ((s.value || u?.continuousValidation || w.continuousValidation) && await c(void 0, {
|
|
252
252
|
superRefine: w.superRefine,
|
|
253
|
-
fields:
|
|
254
|
-
}), !
|
|
255
|
-
const j =
|
|
256
|
-
|
|
253
|
+
fields: o ?? new Set(w.validateFields)
|
|
254
|
+
}), !r.value || !w.modelValue || JSON.stringify(r.value) !== JSON.stringify(w.modelValue)) {
|
|
255
|
+
const j = N(r.value);
|
|
256
|
+
_("update:modelValue", j), u?.onUpdate?.(j);
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
l.value === S.updated && (l.value = S.unknown);
|
|
259
259
|
}
|
|
260
|
-
}),
|
|
261
|
-
w.readonly !== void 0 && (
|
|
262
|
-
}),
|
|
260
|
+
}), H(() => {
|
|
261
|
+
w.readonly !== void 0 && (v.value = w.readonly);
|
|
262
|
+
}), Z(
|
|
263
263
|
() => w.readonly,
|
|
264
|
-
(
|
|
265
|
-
|
|
264
|
+
(n) => {
|
|
265
|
+
v.value = n;
|
|
266
266
|
}
|
|
267
|
-
),
|
|
268
|
-
|
|
269
|
-
}),
|
|
270
|
-
clear:
|
|
271
|
-
errors:
|
|
272
|
-
formData:
|
|
273
|
-
ignoreUpdates:
|
|
274
|
-
invalid:
|
|
275
|
-
readonly:
|
|
276
|
-
reset:
|
|
277
|
-
status:
|
|
278
|
-
stopUpdatesWatch:
|
|
279
|
-
submit:
|
|
280
|
-
validate:
|
|
281
|
-
wrappers:
|
|
267
|
+
), Z(v, (n) => {
|
|
268
|
+
n !== w.readonly && _("update:readonly", v.value);
|
|
269
|
+
}), Q(t, {
|
|
270
|
+
clear: D,
|
|
271
|
+
errors: I,
|
|
272
|
+
formData: r,
|
|
273
|
+
ignoreUpdates: y,
|
|
274
|
+
invalid: f,
|
|
275
|
+
readonly: v,
|
|
276
|
+
reset: p,
|
|
277
|
+
status: R,
|
|
278
|
+
stopUpdatesWatch: b,
|
|
279
|
+
submit: m,
|
|
280
|
+
validate: c,
|
|
281
|
+
wrappers: a
|
|
282
282
|
}), {
|
|
283
|
-
clear:
|
|
284
|
-
errors:
|
|
285
|
-
formData:
|
|
286
|
-
ignoreUpdates:
|
|
287
|
-
invalid:
|
|
288
|
-
isReadonly:
|
|
289
|
-
reset:
|
|
290
|
-
status:
|
|
291
|
-
stopUpdatesWatch:
|
|
292
|
-
submit: () =>
|
|
283
|
+
clear: D,
|
|
284
|
+
errors: I,
|
|
285
|
+
formData: r,
|
|
286
|
+
ignoreUpdates: y,
|
|
287
|
+
invalid: f,
|
|
288
|
+
isReadonly: v,
|
|
289
|
+
reset: p,
|
|
290
|
+
status: R,
|
|
291
|
+
stopUpdatesWatch: b,
|
|
292
|
+
submit: () => m({
|
|
293
293
|
superRefine: w.superRefine,
|
|
294
294
|
fields: new Set(w.validateFields)
|
|
295
295
|
}),
|
|
296
|
-
validate:
|
|
297
|
-
wrappers:
|
|
296
|
+
validate: c,
|
|
297
|
+
wrappers: a
|
|
298
298
|
};
|
|
299
299
|
},
|
|
300
300
|
render() {
|
|
301
301
|
const w = () => this.$slots?.default?.({
|
|
302
|
-
errors:
|
|
303
|
-
formData:
|
|
304
|
-
invalid:
|
|
305
|
-
readonly:
|
|
306
|
-
status:
|
|
307
|
-
wrappers:
|
|
308
|
-
clear:
|
|
309
|
-
ignoreUpdates:
|
|
310
|
-
reset:
|
|
311
|
-
stopUpdatesWatch:
|
|
312
|
-
submit:
|
|
313
|
-
validate:
|
|
302
|
+
errors: I.value,
|
|
303
|
+
formData: r.value,
|
|
304
|
+
invalid: f.value,
|
|
305
|
+
readonly: v.value,
|
|
306
|
+
status: R.value,
|
|
307
|
+
wrappers: a,
|
|
308
|
+
clear: D,
|
|
309
|
+
ignoreUpdates: y,
|
|
310
|
+
reset: p,
|
|
311
|
+
stopUpdatesWatch: b,
|
|
312
|
+
submit: m,
|
|
313
|
+
validate: c
|
|
314
314
|
}) ?? this.$slots.default;
|
|
315
|
-
return
|
|
315
|
+
return z(
|
|
316
316
|
this.tag,
|
|
317
317
|
{
|
|
318
|
-
onSubmit:
|
|
319
|
-
onReset:
|
|
318
|
+
onSubmit: re(this.submit, ["prevent"]),
|
|
319
|
+
onReset: re(this.reset, ["prevent"])
|
|
320
320
|
},
|
|
321
|
-
(this.template ??
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
(this.template ?? u?.template) && g ? [
|
|
322
|
+
z(
|
|
323
|
+
g,
|
|
324
324
|
{
|
|
325
|
-
schema: this.template ??
|
|
325
|
+
schema: this.template ?? u?.template
|
|
326
326
|
},
|
|
327
327
|
{
|
|
328
328
|
default: w
|
|
@@ -335,28 +335,28 @@ function Ae(e, t, n, b, r) {
|
|
|
335
335
|
}
|
|
336
336
|
});
|
|
337
337
|
return {
|
|
338
|
-
clear:
|
|
339
|
-
errors:
|
|
340
|
-
formData:
|
|
341
|
-
ignoreUpdates:
|
|
342
|
-
invalid:
|
|
343
|
-
readonly:
|
|
344
|
-
reset:
|
|
345
|
-
status:
|
|
346
|
-
wrappers:
|
|
347
|
-
stopUpdatesWatch:
|
|
348
|
-
submit:
|
|
349
|
-
validate:
|
|
350
|
-
VvForm:
|
|
338
|
+
clear: D,
|
|
339
|
+
errors: s,
|
|
340
|
+
formData: r,
|
|
341
|
+
ignoreUpdates: y,
|
|
342
|
+
invalid: f,
|
|
343
|
+
readonly: v,
|
|
344
|
+
reset: p,
|
|
345
|
+
status: l,
|
|
346
|
+
wrappers: a,
|
|
347
|
+
stopUpdatesWatch: b,
|
|
348
|
+
submit: m,
|
|
349
|
+
validate: c,
|
|
350
|
+
VvForm: E
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
return
|
|
353
|
+
function Ge(e, t, u, g) {
|
|
354
|
+
return U({
|
|
355
355
|
name: "VvFormField",
|
|
356
356
|
props: {
|
|
357
357
|
type: {
|
|
358
358
|
type: String,
|
|
359
|
-
validator: (
|
|
359
|
+
validator: (a) => Object.values(V).includes(a),
|
|
360
360
|
default: V.custom
|
|
361
361
|
},
|
|
362
362
|
is: {
|
|
@@ -404,71 +404,71 @@ function Fe(e, t, n, b) {
|
|
|
404
404
|
"type"
|
|
405
405
|
],
|
|
406
406
|
slots: Object,
|
|
407
|
-
setup(
|
|
408
|
-
const { props:
|
|
409
|
-
|
|
410
|
-
const
|
|
407
|
+
setup(a, { slots: s, emit: l }) {
|
|
408
|
+
const { props: f, name: r } = Y(a), v = ae(), o = G(t, void 0);
|
|
409
|
+
o && o.fields.value.set(v, a.name);
|
|
410
|
+
const d = G(e), c = O({
|
|
411
411
|
get() {
|
|
412
|
-
if (
|
|
413
|
-
return
|
|
414
|
-
new Object(
|
|
415
|
-
String(
|
|
412
|
+
if (d?.formData)
|
|
413
|
+
return P(
|
|
414
|
+
new Object(d.formData.value),
|
|
415
|
+
String(a.name)
|
|
416
416
|
);
|
|
417
417
|
},
|
|
418
|
-
set(
|
|
419
|
-
|
|
420
|
-
new Object(
|
|
421
|
-
String(
|
|
422
|
-
|
|
423
|
-
),
|
|
424
|
-
newValue:
|
|
425
|
-
formData:
|
|
418
|
+
set(n) {
|
|
419
|
+
d?.formData && (oe(
|
|
420
|
+
new Object(d.formData.value),
|
|
421
|
+
String(a.name),
|
|
422
|
+
n
|
|
423
|
+
), l("update:modelValue", {
|
|
424
|
+
newValue: c.value,
|
|
425
|
+
formData: d?.formData
|
|
426
426
|
}));
|
|
427
427
|
}
|
|
428
428
|
});
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}),
|
|
432
|
-
|
|
429
|
+
H(() => {
|
|
430
|
+
c.value === void 0 && a.defaultValue !== void 0 && (c.value = a.defaultValue);
|
|
431
|
+
}), L(() => {
|
|
432
|
+
o && o.fields.value.delete(v);
|
|
433
433
|
});
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
return
|
|
437
|
-
}),
|
|
438
|
-
if (
|
|
439
|
-
|
|
440
|
-
String(
|
|
441
|
-
|
|
434
|
+
const D = O(() => {
|
|
435
|
+
if (d?.errors.value)
|
|
436
|
+
return P(d.errors.value, String(a.name));
|
|
437
|
+
}), p = O(() => D.value?._errors), m = O(() => D.value !== void 0), y = Z(m, (n) => {
|
|
438
|
+
if (n) {
|
|
439
|
+
l("invalid", D.value), o && o.errors.value.set(
|
|
440
|
+
String(a.name),
|
|
441
|
+
D.value
|
|
442
442
|
);
|
|
443
443
|
return;
|
|
444
444
|
}
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
l("valid", c.value), o && o.errors.value.delete(
|
|
446
|
+
a.name
|
|
447
447
|
);
|
|
448
|
-
}),
|
|
449
|
-
() =>
|
|
448
|
+
}), b = Z(
|
|
449
|
+
() => d?.formData,
|
|
450
450
|
() => {
|
|
451
|
-
|
|
451
|
+
l("update:formData", d?.formData);
|
|
452
452
|
},
|
|
453
453
|
{ deep: !0 }
|
|
454
454
|
);
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
L(() => {
|
|
456
|
+
y(), b();
|
|
457
457
|
});
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
},
|
|
461
|
-
let
|
|
462
|
-
return typeof
|
|
463
|
-
(j,
|
|
458
|
+
const I = (n) => {
|
|
459
|
+
n instanceof InputEvent && (n = n.target.value), c.value = n;
|
|
460
|
+
}, R = O(() => {
|
|
461
|
+
let n = f.value;
|
|
462
|
+
return typeof n == "function" && (n = n(d?.formData)), Object.keys(n).reduce(
|
|
463
|
+
(j, A) => (j[A] = W(n[A]), j),
|
|
464
464
|
{}
|
|
465
465
|
);
|
|
466
|
-
}),
|
|
467
|
-
...
|
|
468
|
-
name:
|
|
469
|
-
invalid:
|
|
470
|
-
valid:
|
|
471
|
-
type: ((
|
|
466
|
+
}), E = O(() => d?.readonly.value || o?.readonly.value ? !0 : R.value.readonly ?? a.readonly), w = O(() => ({
|
|
467
|
+
...R.value,
|
|
468
|
+
name: R.value.name ?? a.name,
|
|
469
|
+
invalid: m.value,
|
|
470
|
+
valid: a.showValid ? !!(!m.value && c.value) : void 0,
|
|
471
|
+
type: ((n) => {
|
|
472
472
|
if ([
|
|
473
473
|
V.color,
|
|
474
474
|
V.date,
|
|
@@ -483,70 +483,70 @@ function Fe(e, t, n, b) {
|
|
|
483
483
|
V.time,
|
|
484
484
|
V.url,
|
|
485
485
|
V.week
|
|
486
|
-
].includes(
|
|
487
|
-
return
|
|
488
|
-
})(
|
|
489
|
-
invalidLabel:
|
|
490
|
-
modelValue:
|
|
491
|
-
readonly:
|
|
492
|
-
"onUpdate:modelValue":
|
|
486
|
+
].includes(n))
|
|
487
|
+
return n;
|
|
488
|
+
})(a.type),
|
|
489
|
+
invalidLabel: p.value,
|
|
490
|
+
modelValue: c.value,
|
|
491
|
+
readonly: E.value,
|
|
492
|
+
"onUpdate:modelValue": I
|
|
493
493
|
}));
|
|
494
|
-
return
|
|
495
|
-
name:
|
|
496
|
-
errors:
|
|
497
|
-
}), { component:
|
|
498
|
-
if (
|
|
494
|
+
return Q(u, {
|
|
495
|
+
name: F(r),
|
|
496
|
+
errors: F(D)
|
|
497
|
+
}), { component: O(() => {
|
|
498
|
+
if (a.type === V.custom)
|
|
499
499
|
return {
|
|
500
500
|
render() {
|
|
501
|
-
return
|
|
502
|
-
errors:
|
|
503
|
-
formData:
|
|
504
|
-
formErrors:
|
|
505
|
-
invalid:
|
|
506
|
-
invalidLabel:
|
|
507
|
-
modelValue:
|
|
508
|
-
readonly:
|
|
509
|
-
onUpdate:
|
|
510
|
-
submit:
|
|
511
|
-
validate:
|
|
512
|
-
}) ??
|
|
501
|
+
return s.default?.({
|
|
502
|
+
errors: D.value,
|
|
503
|
+
formData: d?.formData.value,
|
|
504
|
+
formErrors: d?.errors.value,
|
|
505
|
+
invalid: m.value,
|
|
506
|
+
invalidLabel: p.value,
|
|
507
|
+
modelValue: c.value,
|
|
508
|
+
readonly: E.value,
|
|
509
|
+
onUpdate: I,
|
|
510
|
+
submit: d?.submit,
|
|
511
|
+
validate: d?.validate
|
|
512
|
+
}) ?? s.default;
|
|
513
513
|
}
|
|
514
514
|
};
|
|
515
|
-
if (!(
|
|
516
|
-
let
|
|
517
|
-
switch (
|
|
515
|
+
if (!(g?.lazyLoad ?? a.lazyLoad)) {
|
|
516
|
+
let n;
|
|
517
|
+
switch (a.type) {
|
|
518
518
|
case V.select:
|
|
519
|
-
|
|
519
|
+
n = $("VvSelect");
|
|
520
520
|
break;
|
|
521
521
|
case V.checkbox:
|
|
522
|
-
|
|
522
|
+
n = $("VvCheckbox");
|
|
523
523
|
break;
|
|
524
524
|
case V.radio:
|
|
525
|
-
|
|
525
|
+
n = $("VvRadio");
|
|
526
526
|
break;
|
|
527
527
|
case V.textarea:
|
|
528
|
-
|
|
528
|
+
n = $("VvTextarea");
|
|
529
529
|
break;
|
|
530
530
|
case V.radioGroup:
|
|
531
|
-
|
|
531
|
+
n = $("VvRadioGroup");
|
|
532
532
|
break;
|
|
533
533
|
case V.checkboxGroup:
|
|
534
|
-
|
|
534
|
+
n = $("VvCheckboxGroup");
|
|
535
535
|
break;
|
|
536
536
|
case V.combobox:
|
|
537
|
-
|
|
537
|
+
n = $("VvCombobox");
|
|
538
538
|
break;
|
|
539
539
|
default:
|
|
540
|
-
|
|
540
|
+
n = $("VvInputText");
|
|
541
541
|
}
|
|
542
|
-
if (typeof
|
|
543
|
-
return
|
|
542
|
+
if (typeof n != "string")
|
|
543
|
+
return n;
|
|
544
544
|
console.warn(
|
|
545
|
-
`[@volverjs/form-vue]: ${
|
|
545
|
+
`[@volverjs/form-vue]: ${n} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
546
546
|
);
|
|
547
547
|
}
|
|
548
|
-
return
|
|
549
|
-
switch (
|
|
548
|
+
return pe(async () => {
|
|
549
|
+
switch (g?.sideEffects && await Promise.resolve(g.sideEffects(a.type)), a.type) {
|
|
550
550
|
case V.textarea:
|
|
551
551
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
552
552
|
case V.radio:
|
|
@@ -564,15 +564,15 @@ function Fe(e, t, n, b) {
|
|
|
564
564
|
}
|
|
565
565
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
566
566
|
});
|
|
567
|
-
}), hasProps: w, invalid:
|
|
567
|
+
}), hasProps: w, invalid: m };
|
|
568
568
|
},
|
|
569
569
|
render() {
|
|
570
|
-
return this.is ?
|
|
570
|
+
return this.is ? z(this.is, this.hasProps, this.$slots) : this.type === V.custom ? z(this.component, null, this.$slots) : z(this.component, this.hasProps, this.$slots);
|
|
571
571
|
}
|
|
572
572
|
});
|
|
573
573
|
}
|
|
574
|
-
function ke(e, t,
|
|
575
|
-
return
|
|
574
|
+
function ke(e, t, u) {
|
|
575
|
+
return U({
|
|
576
576
|
name: "VvFormFieldsGroup",
|
|
577
577
|
props: {
|
|
578
578
|
is: {
|
|
@@ -615,151 +615,151 @@ function ke(e, t, n) {
|
|
|
615
615
|
"is"
|
|
616
616
|
],
|
|
617
617
|
slots: Object,
|
|
618
|
-
setup(
|
|
619
|
-
const { props:
|
|
620
|
-
|
|
621
|
-
|
|
618
|
+
setup(g, { slots: a, emit: s }) {
|
|
619
|
+
const { props: l, names: f, defaultValues: r } = Y(g), v = ae(), o = O(() => Array.isArray(f.value) ? f.value : Object.values(f.value)), d = O(() => Array.isArray(f.value) ? f.value : Object.keys(f.value)), c = O(() => Array.isArray(f.value) ? f.value.reduce((i, h) => (i[String(h)] = h, i), {}) : f.value), D = O(() => Object.keys(c.value).reduce((i, h) => (i[String(c.value[h])] = h, i), {})), p = G(t, void 0);
|
|
620
|
+
p && o.value.forEach((i) => {
|
|
621
|
+
p.fields.value.set(`${v}-${i}`, i);
|
|
622
622
|
});
|
|
623
|
-
const
|
|
623
|
+
const m = G(e), y = O({
|
|
624
624
|
get() {
|
|
625
|
-
return
|
|
626
|
-
new Object(
|
|
627
|
-
|
|
628
|
-
),
|
|
625
|
+
return m?.formData ? d.value.reduce((i, h) => (i[h] = P(
|
|
626
|
+
new Object(m.formData.value),
|
|
627
|
+
c.value[h]
|
|
628
|
+
), i), {}) : {};
|
|
629
629
|
},
|
|
630
|
-
set(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
new Object(
|
|
634
|
-
|
|
635
|
-
|
|
630
|
+
set(i) {
|
|
631
|
+
m?.formData && (d.value.forEach((h) => {
|
|
632
|
+
oe(
|
|
633
|
+
new Object(m.formData.value),
|
|
634
|
+
c.value[h],
|
|
635
|
+
i?.[h]
|
|
636
636
|
);
|
|
637
|
-
}),
|
|
638
|
-
newValue:
|
|
639
|
-
formData:
|
|
637
|
+
}), s("update:modelValue", {
|
|
638
|
+
newValue: y.value,
|
|
639
|
+
formData: m?.formData
|
|
640
640
|
}));
|
|
641
641
|
}
|
|
642
642
|
});
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
...
|
|
647
|
-
[
|
|
643
|
+
H(() => {
|
|
644
|
+
r.value && o.value.forEach((i) => {
|
|
645
|
+
r.value?.[i] !== void 0 && y.value[i] === void 0 && (y.value = {
|
|
646
|
+
...y.value,
|
|
647
|
+
[i]: r.value?.[i]
|
|
648
648
|
});
|
|
649
649
|
});
|
|
650
|
-
}),
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
`${
|
|
650
|
+
}), L(() => {
|
|
651
|
+
p && o.value.forEach((i) => {
|
|
652
|
+
p.fields.value.delete(
|
|
653
|
+
`${v}-${i}`
|
|
654
654
|
);
|
|
655
655
|
});
|
|
656
656
|
});
|
|
657
|
-
const
|
|
658
|
-
if (!
|
|
657
|
+
const b = O(() => {
|
|
658
|
+
if (!m?.errors.value)
|
|
659
659
|
return;
|
|
660
|
-
const
|
|
661
|
-
if (!
|
|
662
|
-
return
|
|
663
|
-
const
|
|
664
|
-
return
|
|
660
|
+
const i = o.value.reduce((h, x) => {
|
|
661
|
+
if (!m.errors.value)
|
|
662
|
+
return h;
|
|
663
|
+
const te = P(m.errors.value, String(x));
|
|
664
|
+
return te === void 0 || (h[String(x)] = te), h;
|
|
665
665
|
}, {});
|
|
666
|
-
if (Object.keys(
|
|
667
|
-
return
|
|
668
|
-
}),
|
|
669
|
-
if (!
|
|
666
|
+
if (Object.keys(i).length !== 0)
|
|
667
|
+
return i;
|
|
668
|
+
}), I = O(() => {
|
|
669
|
+
if (!b.value)
|
|
670
670
|
return;
|
|
671
|
-
const
|
|
672
|
-
if (Object.keys(
|
|
673
|
-
return
|
|
674
|
-
}),
|
|
675
|
-
if (
|
|
676
|
-
|
|
677
|
-
if (!
|
|
678
|
-
|
|
679
|
-
|
|
671
|
+
const i = Object.keys(b.value).reduce((h, x) => (b.value?.[x] && (h[D.value[x]] = b.value[x]._errors), h), {});
|
|
672
|
+
if (Object.keys(i).length !== 0)
|
|
673
|
+
return i;
|
|
674
|
+
}), R = O(() => b.value !== void 0), E = O(() => d.value.reduce((i, h) => (i[h] = !!b.value?.[D.value[h]], i), {})), w = Z(R, () => {
|
|
675
|
+
if (R.value) {
|
|
676
|
+
s("invalid", b.value), p && o.value.forEach((i) => {
|
|
677
|
+
if (!b.value?.[i]) {
|
|
678
|
+
p.errors.value.delete(
|
|
679
|
+
i
|
|
680
680
|
);
|
|
681
681
|
return;
|
|
682
682
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
683
|
+
p.errors.value.set(
|
|
684
|
+
i,
|
|
685
|
+
b.value?.[i]
|
|
686
686
|
);
|
|
687
687
|
});
|
|
688
688
|
return;
|
|
689
689
|
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
690
|
+
s("valid", y.value), p && o.value.forEach((i) => {
|
|
691
|
+
p.errors.value.delete(
|
|
692
|
+
i
|
|
693
693
|
);
|
|
694
694
|
});
|
|
695
|
-
}),
|
|
696
|
-
() =>
|
|
695
|
+
}), _ = Z(
|
|
696
|
+
() => m?.formData,
|
|
697
697
|
() => {
|
|
698
|
-
|
|
698
|
+
s("update:formData", m?.formData);
|
|
699
699
|
},
|
|
700
700
|
{ deep: !0 }
|
|
701
701
|
);
|
|
702
|
-
|
|
703
|
-
w(),
|
|
702
|
+
L(() => {
|
|
703
|
+
w(), _();
|
|
704
704
|
});
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
}, j = (
|
|
708
|
-
|
|
709
|
-
...
|
|
710
|
-
[
|
|
705
|
+
const n = (i) => {
|
|
706
|
+
y.value = i;
|
|
707
|
+
}, j = (i, h) => {
|
|
708
|
+
h instanceof InputEvent && (h = h.target.value), d.value.includes(i) && (y.value = {
|
|
709
|
+
...y.value,
|
|
710
|
+
[i]: h
|
|
711
711
|
});
|
|
712
|
-
},
|
|
713
|
-
let
|
|
714
|
-
return typeof
|
|
715
|
-
(
|
|
712
|
+
}, A = O(() => {
|
|
713
|
+
let i = l.value;
|
|
714
|
+
return typeof i == "function" && (i = i(m?.formData)), Object.keys(i).reduce(
|
|
715
|
+
(h, x) => (h[x] = W(i[x]), h),
|
|
716
716
|
{}
|
|
717
717
|
);
|
|
718
|
-
}),
|
|
719
|
-
j(
|
|
720
|
-
},
|
|
721
|
-
"onUpdate:modelValue":
|
|
722
|
-
})),
|
|
723
|
-
...
|
|
724
|
-
|
|
725
|
-
...
|
|
726
|
-
modelValue:
|
|
727
|
-
names:
|
|
728
|
-
invalid:
|
|
729
|
-
invalids:
|
|
730
|
-
valid:
|
|
731
|
-
invalidLabels:
|
|
732
|
-
readonly:
|
|
718
|
+
}), ee = O(() => m?.readonly.value ? !0 : A.value.readonly ?? g.readonly), ve = O(() => d.value.reduce((i, h) => (i[`onUpdate:${h}`] = (x) => {
|
|
719
|
+
j(h, x);
|
|
720
|
+
}, i), {
|
|
721
|
+
"onUpdate:modelValue": n
|
|
722
|
+
})), ce = O(() => ({
|
|
723
|
+
...ve.value,
|
|
724
|
+
...A.value,
|
|
725
|
+
...y.value,
|
|
726
|
+
modelValue: y.value,
|
|
727
|
+
names: A.value.name ?? o.value,
|
|
728
|
+
invalid: R.value,
|
|
729
|
+
invalids: E.value,
|
|
730
|
+
valid: g.showValid ? !!(!R.value && y.value) : void 0,
|
|
731
|
+
invalidLabels: I.value,
|
|
732
|
+
readonly: ee.value
|
|
733
733
|
}));
|
|
734
|
-
return
|
|
735
|
-
names:
|
|
736
|
-
errors:
|
|
737
|
-
}), { component:
|
|
734
|
+
return Q(u, {
|
|
735
|
+
names: F(f),
|
|
736
|
+
errors: F(b)
|
|
737
|
+
}), { component: O(() => ({
|
|
738
738
|
render() {
|
|
739
|
-
return
|
|
740
|
-
errors:
|
|
741
|
-
formData:
|
|
742
|
-
formErrors:
|
|
743
|
-
invalid:
|
|
744
|
-
invalids:
|
|
745
|
-
invalidLabels:
|
|
746
|
-
modelValue:
|
|
747
|
-
onUpdate:
|
|
739
|
+
return a.default?.({
|
|
740
|
+
errors: b.value,
|
|
741
|
+
formData: m?.formData.value,
|
|
742
|
+
formErrors: m?.errors.value,
|
|
743
|
+
invalid: R.value,
|
|
744
|
+
invalids: E.value,
|
|
745
|
+
invalidLabels: I.value,
|
|
746
|
+
modelValue: y.value,
|
|
747
|
+
onUpdate: n,
|
|
748
748
|
onUpdateField: j,
|
|
749
|
-
readonly:
|
|
750
|
-
submit:
|
|
751
|
-
validate:
|
|
752
|
-
}) ??
|
|
749
|
+
readonly: ee.value,
|
|
750
|
+
submit: m?.submit,
|
|
751
|
+
validate: m?.validate
|
|
752
|
+
}) ?? a.default;
|
|
753
753
|
}
|
|
754
|
-
})), hasProps:
|
|
754
|
+
})), hasProps: ce, invalid: R };
|
|
755
755
|
},
|
|
756
756
|
render() {
|
|
757
|
-
return this.is ?
|
|
757
|
+
return this.is ? z(this.is, this.hasProps, this.$slots) : z(this.component, null, this.$slots);
|
|
758
758
|
}
|
|
759
759
|
});
|
|
760
760
|
}
|
|
761
|
-
function
|
|
762
|
-
return
|
|
761
|
+
function Be(e, t) {
|
|
762
|
+
return U({
|
|
763
763
|
name: "VvFormWrapper",
|
|
764
764
|
props: {
|
|
765
765
|
name: {
|
|
@@ -791,75 +791,75 @@ function Ne(e, t) {
|
|
|
791
791
|
"validateWrapper"
|
|
792
792
|
],
|
|
793
793
|
slots: Object,
|
|
794
|
-
setup(
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
if (
|
|
798
|
-
|
|
794
|
+
setup(u, { emit: g }) {
|
|
795
|
+
const a = G(e), s = G(t, void 0), l = B(/* @__PURE__ */ new Map()), f = B(/* @__PURE__ */ new Map()), { name: r } = Y(u), v = O(() => a?.invalid.value ? f.value.size > 0 : !1);
|
|
796
|
+
Z(v, (p) => {
|
|
797
|
+
if (p) {
|
|
798
|
+
g("invalid");
|
|
799
799
|
return;
|
|
800
800
|
}
|
|
801
|
-
|
|
801
|
+
g("valid");
|
|
802
802
|
});
|
|
803
|
-
const
|
|
804
|
-
name:
|
|
805
|
-
errors:
|
|
806
|
-
invalid:
|
|
807
|
-
readonly:
|
|
808
|
-
fields:
|
|
803
|
+
const o = O(() => a?.readonly.value || u.readonly), d = {
|
|
804
|
+
name: F(r),
|
|
805
|
+
errors: f,
|
|
806
|
+
invalid: F(v),
|
|
807
|
+
readonly: F(o),
|
|
808
|
+
fields: l
|
|
809
809
|
};
|
|
810
|
-
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
(
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}),
|
|
818
|
-
|
|
810
|
+
Q(t, d);
|
|
811
|
+
const c = O(() => new Map(l.value));
|
|
812
|
+
Z(
|
|
813
|
+
c,
|
|
814
|
+
(p, m) => {
|
|
815
|
+
s?.fields && (m.forEach((y, b) => {
|
|
816
|
+
p.has(b) || s?.fields.value.delete(b);
|
|
817
|
+
}), p.forEach((y, b) => {
|
|
818
|
+
s?.fields.value.has(b) || s?.fields.value.set(b, y);
|
|
819
819
|
}));
|
|
820
820
|
},
|
|
821
821
|
{ deep: !0 }
|
|
822
|
-
),
|
|
823
|
-
|
|
824
|
-
(
|
|
825
|
-
|
|
826
|
-
if (
|
|
827
|
-
const
|
|
828
|
-
|
|
822
|
+
), Z(
|
|
823
|
+
f,
|
|
824
|
+
(p) => {
|
|
825
|
+
s?.errors && l.value.forEach((m) => {
|
|
826
|
+
if (p.has(m) || s.errors.value.delete(m), p.has(m)) {
|
|
827
|
+
const y = p.get(m);
|
|
828
|
+
y && s.errors.value.set(m, y);
|
|
829
829
|
}
|
|
830
830
|
});
|
|
831
831
|
},
|
|
832
832
|
{ deep: !0 }
|
|
833
|
-
),
|
|
834
|
-
if (!
|
|
833
|
+
), H(() => {
|
|
834
|
+
if (!a?.wrappers || !r.value) {
|
|
835
835
|
console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");
|
|
836
836
|
return;
|
|
837
837
|
}
|
|
838
|
-
if (
|
|
839
|
-
console.warn(`[@volverjs/form-vue]: wrapper name "${
|
|
838
|
+
if (a.wrappers.has(r.value)) {
|
|
839
|
+
console.warn(`[@volverjs/form-vue]: wrapper name "${r.value}" is already used`);
|
|
840
840
|
return;
|
|
841
841
|
}
|
|
842
|
-
|
|
843
|
-
}),
|
|
844
|
-
|
|
842
|
+
a.wrappers.set(r.value, d);
|
|
843
|
+
}), L(() => {
|
|
844
|
+
a?.wrappers && r.value && a.wrappers.delete(r.value);
|
|
845
845
|
});
|
|
846
|
-
const
|
|
846
|
+
const D = () => a?.validate(void 0, { fields: new Set(l.value.values()) }) ?? Promise.resolve(!0);
|
|
847
847
|
return {
|
|
848
|
-
errors:
|
|
849
|
-
fields:
|
|
850
|
-
fieldsErrors:
|
|
851
|
-
formData:
|
|
852
|
-
invalid:
|
|
853
|
-
readonly:
|
|
854
|
-
clear:
|
|
855
|
-
reset:
|
|
856
|
-
submit:
|
|
857
|
-
validate:
|
|
858
|
-
validateWrapper:
|
|
848
|
+
errors: a?.errors,
|
|
849
|
+
fields: l,
|
|
850
|
+
fieldsErrors: f,
|
|
851
|
+
formData: a?.formData,
|
|
852
|
+
invalid: v,
|
|
853
|
+
readonly: o,
|
|
854
|
+
clear: a?.clear,
|
|
855
|
+
reset: a?.reset,
|
|
856
|
+
submit: a?.submit,
|
|
857
|
+
validate: a?.validate,
|
|
858
|
+
validateWrapper: D
|
|
859
859
|
};
|
|
860
860
|
},
|
|
861
861
|
render() {
|
|
862
|
-
const
|
|
862
|
+
const u = () => this.$slots.default?.({
|
|
863
863
|
errors: this.errors,
|
|
864
864
|
fieldsErrors: this.fieldsErrors,
|
|
865
865
|
formData: this.formData,
|
|
@@ -871,14 +871,14 @@ function Ne(e, t) {
|
|
|
871
871
|
validate: this.validate,
|
|
872
872
|
validateWrapper: this.validateWrapper
|
|
873
873
|
});
|
|
874
|
-
return this.tag ?
|
|
875
|
-
default:
|
|
876
|
-
}) :
|
|
874
|
+
return this.tag ? z(this.tag, null, {
|
|
875
|
+
default: u
|
|
876
|
+
}) : u();
|
|
877
877
|
}
|
|
878
878
|
});
|
|
879
879
|
}
|
|
880
|
-
function
|
|
881
|
-
const
|
|
880
|
+
function We(e, t) {
|
|
881
|
+
const u = U({
|
|
882
882
|
name: "VvFormTemplate",
|
|
883
883
|
props: {
|
|
884
884
|
schema: {
|
|
@@ -891,174 +891,174 @@ function $e(e, t) {
|
|
|
891
891
|
}
|
|
892
892
|
},
|
|
893
893
|
slots: Object,
|
|
894
|
-
setup(
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
894
|
+
setup(g, { slots: a }) {
|
|
895
|
+
const s = G(e);
|
|
896
|
+
if (s?.formData)
|
|
897
897
|
return () => {
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
) :
|
|
902
|
-
let
|
|
903
|
-
const
|
|
904
|
-
const
|
|
905
|
-
vvIs:
|
|
906
|
-
vvName:
|
|
907
|
-
vvSlots:
|
|
908
|
-
vvChildren:
|
|
909
|
-
vvIf:
|
|
910
|
-
vvElseIf:
|
|
911
|
-
vvType:
|
|
912
|
-
vvDefaultValue:
|
|
913
|
-
vvShowValid:
|
|
898
|
+
const l = typeof g.schema == "function" ? g.schema(
|
|
899
|
+
s,
|
|
900
|
+
g.scope
|
|
901
|
+
) : g.schema;
|
|
902
|
+
let f;
|
|
903
|
+
const r = l.reduce((v, o) => {
|
|
904
|
+
const d = typeof o == "function" ? o(s, g.scope) : o, {
|
|
905
|
+
vvIs: c,
|
|
906
|
+
vvName: D,
|
|
907
|
+
vvSlots: p,
|
|
908
|
+
vvChildren: m,
|
|
909
|
+
vvIf: y,
|
|
910
|
+
vvElseIf: b,
|
|
911
|
+
vvType: I,
|
|
912
|
+
vvDefaultValue: R,
|
|
913
|
+
vvShowValid: E,
|
|
914
914
|
vvContent: w,
|
|
915
|
-
...
|
|
916
|
-
} =
|
|
917
|
-
if (
|
|
918
|
-
if (typeof
|
|
919
|
-
new Object(
|
|
920
|
-
m
|
|
921
|
-
) : typeof m == "function" ? i = P(m(u)) : i = P(m), !i)
|
|
922
|
-
return f;
|
|
923
|
-
} else if (y !== void 0 && i !== void 0) {
|
|
924
|
-
if (i || (typeof y == "string" ? i = !!L(
|
|
925
|
-
new Object(u.formData.value),
|
|
915
|
+
..._
|
|
916
|
+
} = d;
|
|
917
|
+
if (y !== void 0) {
|
|
918
|
+
if (typeof y == "string" ? f = !!P(
|
|
919
|
+
new Object(s.formData.value),
|
|
926
920
|
y
|
|
927
|
-
) : typeof y == "function" ?
|
|
928
|
-
return
|
|
921
|
+
) : typeof y == "function" ? f = W(y(s)) : f = W(y), !f)
|
|
922
|
+
return v;
|
|
923
|
+
} else if (b !== void 0 && f !== void 0) {
|
|
924
|
+
if (f || (typeof b == "string" ? f = !!P(
|
|
925
|
+
new Object(s.formData.value),
|
|
926
|
+
b
|
|
927
|
+
) : typeof b == "function" ? f = W(b(s)) : f = W(b), !f))
|
|
928
|
+
return v;
|
|
929
929
|
} else
|
|
930
|
-
|
|
931
|
-
let
|
|
932
|
-
return
|
|
933
|
-
schema:
|
|
934
|
-
}) :
|
|
935
|
-
default: (j) =>
|
|
936
|
-
schema:
|
|
930
|
+
f = void 0;
|
|
931
|
+
let n;
|
|
932
|
+
return m && (typeof c == "string" ? n = z(u, {
|
|
933
|
+
schema: m
|
|
934
|
+
}) : n = {
|
|
935
|
+
default: (j) => z(u, {
|
|
936
|
+
schema: m,
|
|
937
937
|
scope: j
|
|
938
938
|
})
|
|
939
|
-
}),
|
|
940
|
-
|
|
939
|
+
}), D ? (v.push(
|
|
940
|
+
z(
|
|
941
941
|
t,
|
|
942
942
|
{
|
|
943
|
-
name:
|
|
944
|
-
is:
|
|
945
|
-
type:
|
|
946
|
-
defaultValue:
|
|
947
|
-
showValid:
|
|
948
|
-
props:
|
|
943
|
+
name: D,
|
|
944
|
+
is: c,
|
|
945
|
+
type: I,
|
|
946
|
+
defaultValue: R,
|
|
947
|
+
showValid: E,
|
|
948
|
+
props: _
|
|
949
949
|
},
|
|
950
|
-
|
|
950
|
+
p ?? n ?? w
|
|
951
951
|
)
|
|
952
|
-
),
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
952
|
+
), v) : c ? (v.push(
|
|
953
|
+
z(
|
|
954
|
+
c,
|
|
955
|
+
_,
|
|
956
|
+
p ?? n ?? w
|
|
957
957
|
)
|
|
958
|
-
),
|
|
958
|
+
), v) : (n && ("default" in n ? v.push(n.default(g.scope)) : v.push(n)), v);
|
|
959
959
|
}, []);
|
|
960
|
-
return
|
|
961
|
-
|
|
962
|
-
errors:
|
|
963
|
-
formData:
|
|
964
|
-
invalid:
|
|
965
|
-
status:
|
|
966
|
-
submit:
|
|
967
|
-
validate:
|
|
968
|
-
clear:
|
|
969
|
-
reset:
|
|
960
|
+
return r.push(
|
|
961
|
+
a?.default?.({
|
|
962
|
+
errors: s?.errors.value,
|
|
963
|
+
formData: s?.formData.value,
|
|
964
|
+
invalid: s?.invalid.value,
|
|
965
|
+
status: s?.status.value,
|
|
966
|
+
submit: s?.submit,
|
|
967
|
+
validate: s?.validate,
|
|
968
|
+
clear: s?.clear,
|
|
969
|
+
reset: s?.reset
|
|
970
970
|
})
|
|
971
|
-
),
|
|
971
|
+
), r;
|
|
972
972
|
};
|
|
973
973
|
}
|
|
974
974
|
});
|
|
975
|
-
return
|
|
975
|
+
return u;
|
|
976
976
|
}
|
|
977
|
-
function
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
),
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
977
|
+
function q(e, t = {}) {
|
|
978
|
+
const u = Symbol("formInjectionKey"), g = Symbol("formWrapperInjectionKey"), a = Symbol("formFieldInjectionKey"), s = Symbol("formFieldsGroupInjectionKey"), l = Be(
|
|
979
|
+
u,
|
|
980
|
+
g
|
|
981
|
+
), f = Ge(
|
|
982
|
+
u,
|
|
983
|
+
g,
|
|
984
|
+
a,
|
|
985
985
|
t
|
|
986
|
-
),
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
),
|
|
991
|
-
clear:
|
|
992
|
-
errors:
|
|
993
|
-
formData:
|
|
994
|
-
ignoreUpdates:
|
|
995
|
-
invalid:
|
|
996
|
-
readonly:
|
|
997
|
-
reset:
|
|
998
|
-
status:
|
|
999
|
-
stopUpdatesWatch:
|
|
1000
|
-
submit:
|
|
986
|
+
), r = ke(
|
|
987
|
+
u,
|
|
988
|
+
g,
|
|
989
|
+
s
|
|
990
|
+
), v = We(u, f), o = /* @__PURE__ */ new Map(), {
|
|
991
|
+
clear: d,
|
|
992
|
+
errors: c,
|
|
993
|
+
formData: D,
|
|
994
|
+
ignoreUpdates: p,
|
|
995
|
+
invalid: m,
|
|
996
|
+
readonly: y,
|
|
997
|
+
reset: b,
|
|
998
|
+
status: I,
|
|
999
|
+
stopUpdatesWatch: R,
|
|
1000
|
+
submit: E,
|
|
1001
1001
|
validate: w,
|
|
1002
|
-
VvForm:
|
|
1003
|
-
} =
|
|
1002
|
+
VvForm: _
|
|
1003
|
+
} = $e(e, u, t, v, o);
|
|
1004
1004
|
return {
|
|
1005
|
-
clear:
|
|
1006
|
-
errors:
|
|
1007
|
-
formData:
|
|
1008
|
-
formFieldInjectionKey:
|
|
1009
|
-
formInjectionKey:
|
|
1010
|
-
formWrapperInjectionKey:
|
|
1011
|
-
ignoreUpdates:
|
|
1012
|
-
invalid:
|
|
1013
|
-
readonly:
|
|
1014
|
-
reset:
|
|
1015
|
-
status:
|
|
1016
|
-
stopUpdatesWatch:
|
|
1017
|
-
submit:
|
|
1005
|
+
clear: d,
|
|
1006
|
+
errors: c,
|
|
1007
|
+
formData: D,
|
|
1008
|
+
formFieldInjectionKey: a,
|
|
1009
|
+
formInjectionKey: u,
|
|
1010
|
+
formWrapperInjectionKey: g,
|
|
1011
|
+
ignoreUpdates: p,
|
|
1012
|
+
invalid: m,
|
|
1013
|
+
readonly: y,
|
|
1014
|
+
reset: b,
|
|
1015
|
+
status: I,
|
|
1016
|
+
stopUpdatesWatch: R,
|
|
1017
|
+
submit: E,
|
|
1018
1018
|
validate: w,
|
|
1019
|
-
wrappers:
|
|
1020
|
-
VvForm:
|
|
1021
|
-
VvFormField:
|
|
1022
|
-
VvFormFieldsGroup:
|
|
1023
|
-
VvFormTemplate:
|
|
1024
|
-
VvFormWrapper:
|
|
1019
|
+
wrappers: o,
|
|
1020
|
+
VvForm: _,
|
|
1021
|
+
VvFormField: f,
|
|
1022
|
+
VvFormFieldsGroup: r,
|
|
1023
|
+
VvFormTemplate: v,
|
|
1024
|
+
VvFormWrapper: l
|
|
1025
1025
|
};
|
|
1026
1026
|
}
|
|
1027
|
-
const
|
|
1028
|
-
function
|
|
1027
|
+
const fe = Symbol("pluginInjectionKey");
|
|
1028
|
+
function Me(e) {
|
|
1029
1029
|
let t = {};
|
|
1030
|
-
return e.schema && (t =
|
|
1030
|
+
return e.schema && (t = q(e.schema, e)), {
|
|
1031
1031
|
...t,
|
|
1032
|
-
install(
|
|
1033
|
-
|
|
1032
|
+
install(u, { global: g = !1 } = {}) {
|
|
1033
|
+
u.provide(fe, e), g && (u.config.globalProperties.$vvForm = e, t?.VvForm && u.component("VvForm", t.VvForm), t?.VvFormWrapper && u.component("VvFormWrapper", t.VvFormWrapper), t?.VvFormField && u.component("VvFormField", t.VvFormField), t?.VvFormFieldsGroup && u.component("VvFormFieldsGroup", t.VvFormFieldsGroup), t?.VvFormTemplate && u.component("VvFormTemplate", t.VvFormTemplate));
|
|
1034
1034
|
}
|
|
1035
1035
|
};
|
|
1036
1036
|
}
|
|
1037
|
-
const
|
|
1038
|
-
function
|
|
1039
|
-
if (t.scope &&
|
|
1040
|
-
return
|
|
1041
|
-
if (!
|
|
1042
|
-
const
|
|
1043
|
-
return t.scope &&
|
|
1037
|
+
const J = /* @__PURE__ */ new Map();
|
|
1038
|
+
function Je(e, t = {}) {
|
|
1039
|
+
if (t.scope && J.has(t.scope))
|
|
1040
|
+
return J.get(t.scope);
|
|
1041
|
+
if (!ye()) {
|
|
1042
|
+
const g = q(e, t);
|
|
1043
|
+
return t.scope && J.set(t.scope, g), g;
|
|
1044
1044
|
}
|
|
1045
|
-
const
|
|
1045
|
+
const u = q(
|
|
1046
1046
|
e,
|
|
1047
1047
|
{
|
|
1048
|
-
...
|
|
1048
|
+
...G(fe, {}),
|
|
1049
1049
|
...t
|
|
1050
1050
|
}
|
|
1051
1051
|
);
|
|
1052
|
-
return t.scope &&
|
|
1052
|
+
return t.scope && J.set(t.scope, u), u;
|
|
1053
1053
|
}
|
|
1054
|
-
function
|
|
1055
|
-
return
|
|
1054
|
+
function qe(e, t = {}) {
|
|
1055
|
+
return q(e, t);
|
|
1056
1056
|
}
|
|
1057
1057
|
export {
|
|
1058
1058
|
V as FormFieldType,
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1059
|
+
Me as createForm,
|
|
1060
|
+
k as defaultObjectBySchema,
|
|
1061
|
+
qe as formType,
|
|
1062
|
+
fe as pluginInjectionKey,
|
|
1063
|
+
Je as useForm
|
|
1064
1064
|
};
|