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