@volverjs/form-vue 1.0.0-beta.7 → 1.0.0-beta.9
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/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/index.es.js +161 -164
- package/dist/index.umd.js +1 -1
- package/dist/src/VvForm.d.ts +86 -127
- package/dist/src/VvFormField.d.ts +5 -5
- package/dist/src/VvFormTemplate.d.ts +23 -55
- package/dist/src/VvFormWrapper.d.ts +46 -81
- package/dist/src/index.d.ts +491 -815
- package/dist/src/utils.d.ts +1 -1
- package/package.json +24 -24
- package/src/VvForm.ts +4 -6
- package/src/VvFormField.ts +5 -6
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as z, computed as w, onMounted as P, onBeforeUnmount as j, inject as B, toRefs as H, watch as
|
|
1
|
+
import { defineComponent as z, computed as w, onMounted as P, onBeforeUnmount as j, inject as B, toRefs as H, watch as p, unref as C, provide as M, readonly as E, resolveComponent as S, defineAsyncComponent as F, h as O, ref as $, toRaw as A, isProxy as ee, withModifiers as re, getCurrentInstance as te } from "vue";
|
|
2
2
|
import { watchIgnorable as ae, throttleFilter as ne } from "@vueuse/core";
|
|
3
3
|
import { ZodObject as Z, ZodDefault as ue, ZodNullable as le, ZodSchema as se, ZodArray as ie, ZodEffects as fe, ZodOptional as oe } from "zod";
|
|
4
4
|
function J(e) {
|
|
@@ -20,52 +20,52 @@ function G(e) {
|
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
22
|
const ve = /^[0-9]+$/, ce = ["__proto__", "prototype", "constructor"];
|
|
23
|
-
function L(e,
|
|
23
|
+
function L(e, s, t) {
|
|
24
24
|
const o = de(t) ? t : void 0;
|
|
25
|
-
if (!Q(e) || !X(
|
|
25
|
+
if (!Q(e) || !X(s))
|
|
26
26
|
return o;
|
|
27
|
-
const u = T(
|
|
27
|
+
const u = T(s);
|
|
28
28
|
if (u.length !== 0) {
|
|
29
29
|
for (const r of u) {
|
|
30
30
|
if (r === "*")
|
|
31
31
|
continue;
|
|
32
|
-
const
|
|
33
|
-
return n.map((f) => G(f) || q(f) ? f : J(f) ?
|
|
32
|
+
const l = function(n) {
|
|
33
|
+
return n.map((f) => G(f) || q(f) ? f : J(f) ? l(f) : f[r]);
|
|
34
34
|
};
|
|
35
|
-
if (J(e) && !ve.test(r) ? e =
|
|
35
|
+
if (J(e) && !ve.test(r) ? e = l(e) : e = e[r], G(e) || q(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
return G(e) ? o : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function Y(e,
|
|
42
|
-
if (!Q(e) || !X(
|
|
41
|
+
function Y(e, s, t) {
|
|
42
|
+
if (!Q(e) || !X(s))
|
|
43
43
|
return;
|
|
44
|
-
const o = T(
|
|
44
|
+
const o = T(s);
|
|
45
45
|
if (o.length === 0)
|
|
46
46
|
return;
|
|
47
47
|
const u = o.length;
|
|
48
48
|
for (let r = 0; r < u; r++) {
|
|
49
|
-
const
|
|
49
|
+
const l = o[r];
|
|
50
50
|
if (r === u - 1) {
|
|
51
|
-
e[
|
|
51
|
+
e[l] = t;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
54
|
+
if (l === "*" && J(e)) {
|
|
55
55
|
const n = o.slice(r + 1).join(".");
|
|
56
56
|
for (const f of e)
|
|
57
57
|
Y(f, n, t);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
G(e[
|
|
60
|
+
G(e[l]) && (e[l] = {}), e = e[l];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
function T(e) {
|
|
64
|
-
const
|
|
65
|
-
return
|
|
64
|
+
const s = e.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
|
|
65
|
+
return s.some((t) => ce.indexOf(t) !== -1) ? [] : s;
|
|
66
66
|
}
|
|
67
67
|
var d = /* @__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))(d || {}), k = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.updated = "updated", e.unknown = "unknown", e))(k || {});
|
|
68
|
-
const me = (e,
|
|
68
|
+
const me = (e, s, t, o) => z({
|
|
69
69
|
name: "VvFormField",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
@@ -104,7 +104,7 @@ const me = (e, i, t, o) => z({
|
|
|
104
104
|
},
|
|
105
105
|
emits: ["invalid", "valid", "update:formData", "update:modelValue"],
|
|
106
106
|
expose: ["invalid", "invalidLabel", "errors"],
|
|
107
|
-
setup(u, { slots: r, emit:
|
|
107
|
+
setup(u, { slots: r, emit: l }) {
|
|
108
108
|
const n = w({
|
|
109
109
|
get() {
|
|
110
110
|
if (a != null && a.formData)
|
|
@@ -113,12 +113,12 @@ const me = (e, i, t, o) => z({
|
|
|
113
113
|
String(u.name)
|
|
114
114
|
);
|
|
115
115
|
},
|
|
116
|
-
set(
|
|
116
|
+
set(i) {
|
|
117
117
|
a != null && a.formData && (Y(
|
|
118
118
|
Object(a.formData.value),
|
|
119
119
|
String(u.name),
|
|
120
|
-
|
|
121
|
-
),
|
|
120
|
+
i
|
|
121
|
+
), l("update:modelValue", {
|
|
122
122
|
newValue: n.value,
|
|
123
123
|
formData: a == null ? void 0 : a.formData
|
|
124
124
|
}));
|
|
@@ -129,46 +129,43 @@ const me = (e, i, t, o) => z({
|
|
|
129
129
|
}), j(() => {
|
|
130
130
|
h(), m();
|
|
131
131
|
});
|
|
132
|
-
const f = B(
|
|
132
|
+
const f = B(s, void 0);
|
|
133
133
|
f && f.fields.value.add(u.name);
|
|
134
|
-
const a = B(e), { props:
|
|
134
|
+
const a = B(e), { props: v, name: b } = H(u), g = w(() => {
|
|
135
135
|
if (a != null && a.errors.value)
|
|
136
136
|
return L(a.errors.value, String(u.name));
|
|
137
137
|
}), V = w(() => {
|
|
138
|
-
var
|
|
139
|
-
return (
|
|
140
|
-
}),
|
|
141
|
-
|
|
138
|
+
var i;
|
|
139
|
+
return (i = g.value) == null ? void 0 : i._errors;
|
|
140
|
+
}), c = w(() => g.value !== void 0), h = p(c, () => {
|
|
141
|
+
c.value ? (l("invalid", V.value), f && f.errors.value.set(
|
|
142
142
|
u.name,
|
|
143
143
|
{
|
|
144
144
|
_errors: V.value
|
|
145
145
|
}
|
|
146
|
-
)) : (
|
|
146
|
+
)) : (l("valid", n.value), f && f.errors.value.delete(
|
|
147
147
|
u.name
|
|
148
148
|
));
|
|
149
|
-
}), m =
|
|
149
|
+
}), m = p(
|
|
150
150
|
() => a == null ? void 0 : a.formData,
|
|
151
151
|
() => {
|
|
152
|
-
|
|
152
|
+
l("update:formData", a == null ? void 0 : a.formData);
|
|
153
153
|
},
|
|
154
154
|
{ deep: !0 }
|
|
155
|
-
), y = (
|
|
156
|
-
n.value =
|
|
155
|
+
), y = (i) => {
|
|
156
|
+
n.value = i;
|
|
157
157
|
}, x = w(() => {
|
|
158
|
-
let
|
|
159
|
-
return typeof
|
|
160
|
-
(_, W) => (_[W] = C(
|
|
158
|
+
let i = v.value;
|
|
159
|
+
return typeof i == "function" && (i = i(a == null ? void 0 : a.formData)), Object.keys(i).reduce(
|
|
160
|
+
(_, W) => (_[W] = C(i[W]), _),
|
|
161
161
|
{}
|
|
162
162
|
);
|
|
163
|
-
}), I = w(() => {
|
|
164
|
-
const l = x.value.readonly ?? u.readonly;
|
|
165
|
-
return l === void 0 ? a == null ? void 0 : a.readonly.value : l;
|
|
166
|
-
}), U = w(() => ({
|
|
163
|
+
}), I = w(() => a != null && a.readonly.value ? !0 : x.value.readonly ?? u.readonly), U = w(() => ({
|
|
167
164
|
...x.value,
|
|
168
165
|
name: x.value.name ?? u.name,
|
|
169
|
-
invalid:
|
|
170
|
-
valid: u.showValid ? !!(!
|
|
171
|
-
type: ((
|
|
166
|
+
invalid: c.value,
|
|
167
|
+
valid: u.showValid ? !!(!c.value && n.value) : void 0,
|
|
168
|
+
type: ((i) => {
|
|
172
169
|
if ([
|
|
173
170
|
d.text,
|
|
174
171
|
d.number,
|
|
@@ -183,8 +180,8 @@ const me = (e, i, t, o) => z({
|
|
|
183
180
|
d.month,
|
|
184
181
|
d.week,
|
|
185
182
|
d.color
|
|
186
|
-
].includes(
|
|
187
|
-
return
|
|
183
|
+
].includes(i))
|
|
184
|
+
return i;
|
|
188
185
|
})(u.type),
|
|
189
186
|
invalidLabel: V.value,
|
|
190
187
|
modelValue: n.value,
|
|
@@ -198,13 +195,13 @@ const me = (e, i, t, o) => z({
|
|
|
198
195
|
if (u.type === d.custom)
|
|
199
196
|
return {
|
|
200
197
|
render() {
|
|
201
|
-
var
|
|
202
|
-
return ((
|
|
198
|
+
var i;
|
|
199
|
+
return ((i = r.default) == null ? void 0 : i.call(r, {
|
|
203
200
|
modelValue: n.value,
|
|
204
201
|
onUpdate: y,
|
|
205
202
|
submit: a == null ? void 0 : a.submit,
|
|
206
203
|
validate: a == null ? void 0 : a.validate,
|
|
207
|
-
invalid:
|
|
204
|
+
invalid: c.value,
|
|
208
205
|
invalidLabel: V.value,
|
|
209
206
|
formData: a == null ? void 0 : a.formData.value,
|
|
210
207
|
formErrors: a == null ? void 0 : a.errors.value,
|
|
@@ -214,36 +211,36 @@ const me = (e, i, t, o) => z({
|
|
|
214
211
|
}
|
|
215
212
|
};
|
|
216
213
|
if (!((o == null ? void 0 : o.lazyLoad) ?? u.lazyLoad)) {
|
|
217
|
-
let
|
|
214
|
+
let i;
|
|
218
215
|
switch (u.type) {
|
|
219
216
|
case d.select:
|
|
220
|
-
|
|
217
|
+
i = S("VvSelect");
|
|
221
218
|
break;
|
|
222
219
|
case d.checkbox:
|
|
223
|
-
|
|
220
|
+
i = S("VvCheckbox");
|
|
224
221
|
break;
|
|
225
222
|
case d.radio:
|
|
226
|
-
|
|
223
|
+
i = S("VvRadio");
|
|
227
224
|
break;
|
|
228
225
|
case d.textarea:
|
|
229
|
-
|
|
226
|
+
i = S("VvTextarea");
|
|
230
227
|
break;
|
|
231
228
|
case d.radioGroup:
|
|
232
|
-
|
|
229
|
+
i = S("VvRadioGroup");
|
|
233
230
|
break;
|
|
234
231
|
case d.checkboxGroup:
|
|
235
|
-
|
|
232
|
+
i = S("VvCheckboxGroup");
|
|
236
233
|
break;
|
|
237
234
|
case d.combobox:
|
|
238
|
-
|
|
235
|
+
i = S("VvCombobox");
|
|
239
236
|
break;
|
|
240
237
|
default:
|
|
241
|
-
|
|
238
|
+
i = S("VvInputText");
|
|
242
239
|
}
|
|
243
|
-
if (typeof
|
|
244
|
-
return
|
|
240
|
+
if (typeof i != "string")
|
|
241
|
+
return i;
|
|
245
242
|
console.warn(
|
|
246
|
-
`[form-vue warn]: ${
|
|
243
|
+
`[form-vue warn]: ${i} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
247
244
|
);
|
|
248
245
|
}
|
|
249
246
|
return F(async () => {
|
|
@@ -265,40 +262,40 @@ const me = (e, i, t, o) => z({
|
|
|
265
262
|
}
|
|
266
263
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
267
264
|
});
|
|
268
|
-
}), hasProps: U, invalid:
|
|
265
|
+
}), hasProps: U, invalid: c };
|
|
269
266
|
},
|
|
270
267
|
render() {
|
|
271
|
-
return this.is ?
|
|
268
|
+
return this.is ? O(this.is, this.hasProps, this.$slots) : this.type === d.custom ? O(this.component, null, this.$slots) : O(this.component, this.hasProps, this.$slots);
|
|
272
269
|
}
|
|
273
|
-
}), K = (e,
|
|
270
|
+
}), K = (e, s = {}) => {
|
|
274
271
|
const t = (r) => {
|
|
275
|
-
let
|
|
276
|
-
for (;
|
|
277
|
-
|
|
278
|
-
return
|
|
272
|
+
let l = r;
|
|
273
|
+
for (; l instanceof fe; )
|
|
274
|
+
l = l.innerType();
|
|
275
|
+
return l instanceof oe && (l = l._def.innerType), l;
|
|
279
276
|
}, o = t(e);
|
|
280
277
|
return {
|
|
281
|
-
...(o instanceof Z ? o._def.unknownKeys === "passthrough" : !1) ?
|
|
278
|
+
...(o instanceof Z ? o._def.unknownKeys === "passthrough" : !1) ? s : {},
|
|
282
279
|
...Object.fromEntries(
|
|
283
280
|
Object.entries(o.shape).map(
|
|
284
|
-
([r,
|
|
285
|
-
const n =
|
|
286
|
-
let f = t(
|
|
281
|
+
([r, l]) => {
|
|
282
|
+
const n = s[r];
|
|
283
|
+
let f = t(l), a;
|
|
287
284
|
if (f instanceof ue && (a = f._def.defaultValue(), f = f._def.innerType), n === null && f instanceof le)
|
|
288
285
|
return [r, n];
|
|
289
286
|
if (f instanceof se) {
|
|
290
|
-
const
|
|
291
|
-
if (
|
|
292
|
-
return [r,
|
|
287
|
+
const v = l.safeParse(n);
|
|
288
|
+
if (v.success)
|
|
289
|
+
return [r, v.data ?? a];
|
|
293
290
|
}
|
|
294
291
|
if (f instanceof ie && Array.isArray(n) && n.length) {
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
292
|
+
const v = t(f._def.type);
|
|
293
|
+
if (v instanceof Z)
|
|
297
294
|
return [
|
|
298
295
|
r,
|
|
299
296
|
n.map(
|
|
300
297
|
(b) => K(
|
|
301
|
-
|
|
298
|
+
v,
|
|
302
299
|
b && typeof b == "object" ? b : void 0
|
|
303
300
|
)
|
|
304
301
|
) ?? a
|
|
@@ -315,13 +312,13 @@ const me = (e, i, t, o) => z({
|
|
|
315
312
|
)
|
|
316
313
|
)
|
|
317
314
|
};
|
|
318
|
-
}, he = (e,
|
|
319
|
-
const u = $(), r = $(),
|
|
315
|
+
}, he = (e, s, t, o) => {
|
|
316
|
+
const u = $(), r = $(), l = w(() => r.value === k.invalid), n = $(), f = $(!1), a = async (c = n.value) => {
|
|
320
317
|
if (f.value)
|
|
321
318
|
return !0;
|
|
322
|
-
const h = await e.safeParseAsync(
|
|
319
|
+
const h = await e.safeParseAsync(c);
|
|
323
320
|
return h.success ? (u.value = void 0, r.value = k.valid, n.value = h.data, !0) : (u.value = h.error.format(), r.value = k.invalid, !1);
|
|
324
|
-
},
|
|
321
|
+
}, v = async () => f.value || !await a() ? !1 : (r.value = k.submitting, !0), { ignoreUpdates: b, stop: g } = ae(
|
|
325
322
|
n,
|
|
326
323
|
() => {
|
|
327
324
|
r.value = k.updated;
|
|
@@ -370,12 +367,12 @@ const me = (e, i, t, o) => z({
|
|
|
370
367
|
"invalid",
|
|
371
368
|
"readonly"
|
|
372
369
|
],
|
|
373
|
-
setup(
|
|
370
|
+
setup(c, { emit: h }) {
|
|
374
371
|
return n.value = K(
|
|
375
372
|
e,
|
|
376
|
-
A(
|
|
377
|
-
),
|
|
378
|
-
() =>
|
|
373
|
+
A(c.modelValue)
|
|
374
|
+
), p(
|
|
375
|
+
() => c.modelValue,
|
|
379
376
|
(m) => {
|
|
380
377
|
if (m) {
|
|
381
378
|
const y = ee(m) ? A(m) : m;
|
|
@@ -385,66 +382,66 @@ const me = (e, i, t, o) => z({
|
|
|
385
382
|
}
|
|
386
383
|
},
|
|
387
384
|
{ deep: !0 }
|
|
388
|
-
),
|
|
385
|
+
), p(r, async (m) => {
|
|
389
386
|
var y, x, I, U, N;
|
|
390
387
|
if (m === k.invalid) {
|
|
391
|
-
const
|
|
388
|
+
const i = A(
|
|
392
389
|
u.value
|
|
393
390
|
);
|
|
394
|
-
h("invalid",
|
|
391
|
+
h("invalid", i), (y = t == null ? void 0 : t.onInvalid) == null || y.call(t, i);
|
|
395
392
|
return;
|
|
396
393
|
}
|
|
397
394
|
if (m === k.valid) {
|
|
398
|
-
const
|
|
399
|
-
h("valid",
|
|
395
|
+
const i = A(n.value);
|
|
396
|
+
h("valid", i), (x = t == null ? void 0 : t.onValid) == null || x.call(t, i), h("update:modelValue", i), (I = t == null ? void 0 : t.onUpdate) == null || I.call(t, i);
|
|
400
397
|
return;
|
|
401
398
|
}
|
|
402
399
|
if (m === k.submitting) {
|
|
403
|
-
const
|
|
404
|
-
h("submit",
|
|
400
|
+
const i = A(n.value);
|
|
401
|
+
h("submit", i), (U = t == null ? void 0 : t.onSubmit) == null || U.call(t, i);
|
|
405
402
|
}
|
|
406
403
|
if (m === k.updated) {
|
|
407
|
-
if ((u.value || t != null && t.continuosValidation ||
|
|
408
|
-
const
|
|
404
|
+
if ((u.value || t != null && t.continuosValidation || c.continuosValidation) && await a(), !n.value || !c.modelValue || JSON.stringify(n.value) !== JSON.stringify(c.modelValue)) {
|
|
405
|
+
const i = A(
|
|
409
406
|
n.value
|
|
410
407
|
);
|
|
411
|
-
h("update:modelValue",
|
|
408
|
+
h("update:modelValue", i), (N = t == null ? void 0 : t.onUpdate) == null || N.call(t, i);
|
|
412
409
|
}
|
|
413
410
|
r.value === k.updated && (r.value = k.unknown);
|
|
414
411
|
}
|
|
415
412
|
}), P(() => {
|
|
416
|
-
|
|
417
|
-
}),
|
|
418
|
-
() =>
|
|
413
|
+
f.value = c.readonly;
|
|
414
|
+
}), p(
|
|
415
|
+
() => c.readonly,
|
|
419
416
|
(m) => {
|
|
420
417
|
f.value = m;
|
|
421
418
|
}
|
|
422
|
-
),
|
|
423
|
-
m !==
|
|
424
|
-
}), M(
|
|
419
|
+
), p(f, (m) => {
|
|
420
|
+
m !== c.readonly && h("update:readonly", f.value);
|
|
421
|
+
}), M(s, {
|
|
425
422
|
formData: n,
|
|
426
|
-
submit:
|
|
423
|
+
submit: v,
|
|
427
424
|
validate: a,
|
|
428
425
|
ignoreUpdates: b,
|
|
429
426
|
stopUpdatesWatch: g,
|
|
430
427
|
errors: E(u),
|
|
431
428
|
status: E(r),
|
|
432
|
-
invalid:
|
|
429
|
+
invalid: l,
|
|
433
430
|
readonly: f
|
|
434
431
|
}), {
|
|
435
432
|
formData: n,
|
|
436
|
-
submit:
|
|
433
|
+
submit: v,
|
|
437
434
|
validate: a,
|
|
438
435
|
ignoreUpdates: b,
|
|
439
436
|
stopUpdatesWatch: g,
|
|
440
437
|
errors: E(u),
|
|
441
438
|
status: E(r),
|
|
442
|
-
invalid:
|
|
439
|
+
invalid: l,
|
|
443
440
|
isReadonly: f
|
|
444
441
|
};
|
|
445
442
|
},
|
|
446
443
|
render() {
|
|
447
|
-
const
|
|
444
|
+
const c = () => {
|
|
448
445
|
var h, m;
|
|
449
446
|
return ((m = (h = this.$slots) == null ? void 0 : h.default) == null ? void 0 : m.call(h, {
|
|
450
447
|
formData: this.formData,
|
|
@@ -458,23 +455,23 @@ const me = (e, i, t, o) => z({
|
|
|
458
455
|
readonly: this.isReadonly
|
|
459
456
|
})) ?? this.$slots.default;
|
|
460
457
|
};
|
|
461
|
-
return
|
|
458
|
+
return O(
|
|
462
459
|
this.tag,
|
|
463
460
|
{
|
|
464
461
|
onSubmit: re(this.submit, ["prevent"])
|
|
465
462
|
},
|
|
466
463
|
(this.template ?? (t == null ? void 0 : t.template)) && o ? [
|
|
467
|
-
|
|
464
|
+
O(
|
|
468
465
|
o,
|
|
469
466
|
{
|
|
470
467
|
schema: this.template ?? (t == null ? void 0 : t.template)
|
|
471
468
|
},
|
|
472
469
|
{
|
|
473
|
-
default:
|
|
470
|
+
default: c
|
|
474
471
|
}
|
|
475
472
|
)
|
|
476
473
|
] : {
|
|
477
|
-
default:
|
|
474
|
+
default: c
|
|
478
475
|
}
|
|
479
476
|
);
|
|
480
477
|
}
|
|
@@ -482,11 +479,11 @@ const me = (e, i, t, o) => z({
|
|
|
482
479
|
return {
|
|
483
480
|
errors: u,
|
|
484
481
|
status: r,
|
|
485
|
-
invalid:
|
|
482
|
+
invalid: l,
|
|
486
483
|
readonly: f,
|
|
487
484
|
formData: n,
|
|
488
485
|
validate: a,
|
|
489
|
-
submit:
|
|
486
|
+
submit: v,
|
|
490
487
|
ignoreUpdates: b,
|
|
491
488
|
stopUpdatesWatch: g,
|
|
492
489
|
/**
|
|
@@ -494,7 +491,7 @@ const me = (e, i, t, o) => z({
|
|
|
494
491
|
*/
|
|
495
492
|
VvForm: V
|
|
496
493
|
};
|
|
497
|
-
}, ye = (e,
|
|
494
|
+
}, ye = (e, s) => z({
|
|
498
495
|
name: "VvFormWrapper",
|
|
499
496
|
props: {
|
|
500
497
|
name: {
|
|
@@ -509,50 +506,50 @@ const me = (e, i, t, o) => z({
|
|
|
509
506
|
emits: ["invalid", "valid"],
|
|
510
507
|
expose: ["fields", "invalid"],
|
|
511
508
|
setup(o, { emit: u }) {
|
|
512
|
-
const r = B(e),
|
|
513
|
-
M(
|
|
509
|
+
const r = B(e), l = B(s, void 0), n = $(/* @__PURE__ */ new Set()), f = $(/* @__PURE__ */ new Map()), { name: a } = H(o);
|
|
510
|
+
M(s, {
|
|
514
511
|
name: E(a),
|
|
515
512
|
errors: f,
|
|
516
513
|
fields: n
|
|
517
|
-
}),
|
|
514
|
+
}), p(
|
|
518
515
|
n,
|
|
519
516
|
(b) => {
|
|
520
|
-
|
|
521
|
-
|
|
517
|
+
l != null && l.fields && b.forEach((g) => {
|
|
518
|
+
l == null || l.fields.value.add(g);
|
|
522
519
|
});
|
|
523
520
|
},
|
|
524
521
|
{ deep: !0 }
|
|
525
|
-
),
|
|
522
|
+
), p(
|
|
526
523
|
() => new Map(f.value),
|
|
527
524
|
(b, g) => {
|
|
528
|
-
|
|
529
|
-
|
|
525
|
+
l != null && l.errors && (Array.from(g.keys()).forEach((V) => {
|
|
526
|
+
l.errors.value.delete(V);
|
|
530
527
|
}), Array.from(b.keys()).forEach((V) => {
|
|
531
|
-
const
|
|
532
|
-
|
|
528
|
+
const c = b.get(V);
|
|
529
|
+
c && l.errors.value.set(V, c);
|
|
533
530
|
}));
|
|
534
531
|
},
|
|
535
532
|
{ deep: !0 }
|
|
536
533
|
);
|
|
537
|
-
const
|
|
538
|
-
return
|
|
539
|
-
|
|
534
|
+
const v = w(() => r != null && r.invalid.value ? f.value.size > 0 : !1);
|
|
535
|
+
return p(v, () => {
|
|
536
|
+
v.value ? u("invalid") : u("valid");
|
|
540
537
|
}), {
|
|
541
538
|
formData: r == null ? void 0 : r.formData,
|
|
542
539
|
errors: r == null ? void 0 : r.errors,
|
|
543
540
|
submit: r == null ? void 0 : r.submit,
|
|
544
541
|
validate: r == null ? void 0 : r.validate,
|
|
545
|
-
invalid:
|
|
542
|
+
invalid: v,
|
|
546
543
|
fields: n,
|
|
547
544
|
fieldsErrors: f
|
|
548
545
|
};
|
|
549
546
|
},
|
|
550
547
|
render() {
|
|
551
548
|
var o, u;
|
|
552
|
-
return this.tag ?
|
|
549
|
+
return this.tag ? O(this.tag, null, {
|
|
553
550
|
default: () => {
|
|
554
|
-
var r,
|
|
555
|
-
return ((
|
|
551
|
+
var r, l;
|
|
552
|
+
return ((l = (r = this.$slots).default) == null ? void 0 : l.call(r, {
|
|
556
553
|
invalid: this.invalid,
|
|
557
554
|
formData: this.formData,
|
|
558
555
|
submit: this.submit,
|
|
@@ -570,7 +567,7 @@ const me = (e, i, t, o) => z({
|
|
|
570
567
|
fieldsErrors: this.fieldsErrors
|
|
571
568
|
})) ?? this.$slots.defalut;
|
|
572
569
|
}
|
|
573
|
-
}), be = (e,
|
|
570
|
+
}), be = (e, s) => {
|
|
574
571
|
const t = z({
|
|
575
572
|
name: "VvFormTemplate",
|
|
576
573
|
props: {
|
|
@@ -584,12 +581,12 @@ const me = (e, i, t, o) => z({
|
|
|
584
581
|
if (r != null && r.formData)
|
|
585
582
|
return () => {
|
|
586
583
|
var a;
|
|
587
|
-
const
|
|
584
|
+
const l = typeof o.schema == "function" ? o.schema(r) : o.schema;
|
|
588
585
|
let n;
|
|
589
|
-
const f =
|
|
586
|
+
const f = l.reduce((v, b) => {
|
|
590
587
|
const g = typeof b == "function" ? b(r) : b, {
|
|
591
588
|
vvIs: V,
|
|
592
|
-
vvName:
|
|
589
|
+
vvName: c,
|
|
593
590
|
vvSlots: h,
|
|
594
591
|
vvChildren: m,
|
|
595
592
|
vvIf: y,
|
|
@@ -597,7 +594,7 @@ const me = (e, i, t, o) => z({
|
|
|
597
594
|
vvType: I,
|
|
598
595
|
vvDefaultValue: U,
|
|
599
596
|
vvShowValid: N,
|
|
600
|
-
vvContent:
|
|
597
|
+
vvContent: i,
|
|
601
598
|
..._
|
|
602
599
|
} = g;
|
|
603
600
|
if (y !== void 0) {
|
|
@@ -605,38 +602,38 @@ const me = (e, i, t, o) => z({
|
|
|
605
602
|
Object(r.formData.value),
|
|
606
603
|
y
|
|
607
604
|
) : typeof y == "function" ? n = C(y(r)) : n = C(y), !n)
|
|
608
|
-
return
|
|
605
|
+
return v;
|
|
609
606
|
} else if (x !== void 0 && n !== void 0) {
|
|
610
607
|
if (n || (typeof x == "string" ? n = !!L(
|
|
611
608
|
Object(r.formData.value),
|
|
612
609
|
x
|
|
613
610
|
) : typeof x == "function" ? n = C(x(r)) : n = C(x), !n))
|
|
614
|
-
return
|
|
611
|
+
return v;
|
|
615
612
|
} else
|
|
616
613
|
n = void 0;
|
|
617
|
-
const W = m ?
|
|
614
|
+
const W = m ? O(t, {
|
|
618
615
|
schema: m
|
|
619
616
|
}) : void 0;
|
|
620
|
-
return
|
|
621
|
-
|
|
622
|
-
|
|
617
|
+
return c ? (v.push(
|
|
618
|
+
O(
|
|
619
|
+
s,
|
|
623
620
|
{
|
|
624
|
-
name:
|
|
621
|
+
name: c,
|
|
625
622
|
is: V,
|
|
626
623
|
type: I,
|
|
627
624
|
defaultValue: U,
|
|
628
625
|
showValid: N,
|
|
629
626
|
props: _
|
|
630
627
|
},
|
|
631
|
-
h ?? W ??
|
|
628
|
+
h ?? W ?? i
|
|
632
629
|
)
|
|
633
|
-
),
|
|
634
|
-
|
|
630
|
+
), v) : V ? (v.push(
|
|
631
|
+
O(
|
|
635
632
|
V,
|
|
636
633
|
_,
|
|
637
|
-
h ?? W ??
|
|
634
|
+
h ?? W ?? i
|
|
638
635
|
)
|
|
639
|
-
),
|
|
636
|
+
), v) : (m && v.push(W), v);
|
|
640
637
|
}, []);
|
|
641
638
|
return f.push(
|
|
642
639
|
(a = u == null ? void 0 : u.default) == null ? void 0 : a.call(u, {
|
|
@@ -652,65 +649,65 @@ const me = (e, i, t, o) => z({
|
|
|
652
649
|
}
|
|
653
650
|
});
|
|
654
651
|
return t;
|
|
655
|
-
}, R = (e,
|
|
652
|
+
}, R = (e, s = {}) => {
|
|
656
653
|
const t = Symbol(), o = Symbol(), u = Symbol(), r = ye(
|
|
657
654
|
t,
|
|
658
655
|
o
|
|
659
|
-
),
|
|
656
|
+
), l = me(
|
|
660
657
|
t,
|
|
661
658
|
o,
|
|
662
659
|
u,
|
|
663
|
-
|
|
664
|
-
), n = be(t,
|
|
660
|
+
s
|
|
661
|
+
), n = be(t, l), {
|
|
665
662
|
VvForm: f,
|
|
666
663
|
errors: a,
|
|
667
|
-
status:
|
|
664
|
+
status: v,
|
|
668
665
|
invalid: b,
|
|
669
666
|
readonly: g,
|
|
670
667
|
formData: V,
|
|
671
|
-
validate:
|
|
668
|
+
validate: c,
|
|
672
669
|
submit: h,
|
|
673
670
|
ignoreUpdates: m,
|
|
674
671
|
stopUpdatesWatch: y
|
|
675
|
-
} = he(e, t,
|
|
672
|
+
} = he(e, t, s, n);
|
|
676
673
|
return {
|
|
677
674
|
VvForm: f,
|
|
678
675
|
VvFormWrapper: r,
|
|
679
|
-
VvFormField:
|
|
676
|
+
VvFormField: l,
|
|
680
677
|
VvFormTemplate: n,
|
|
681
678
|
formInjectionKey: t,
|
|
682
679
|
formWrapperInjectionKey: o,
|
|
683
680
|
formFieldInjectionKey: u,
|
|
684
681
|
errors: a,
|
|
685
|
-
status:
|
|
682
|
+
status: v,
|
|
686
683
|
invalid: b,
|
|
687
684
|
readonly: g,
|
|
688
685
|
formData: V,
|
|
689
|
-
validate:
|
|
686
|
+
validate: c,
|
|
690
687
|
submit: h,
|
|
691
688
|
ignoreUpdates: m,
|
|
692
689
|
stopUpdatesWatch: y
|
|
693
690
|
};
|
|
694
691
|
}, D = Symbol(), ke = (e) => {
|
|
695
|
-
let
|
|
696
|
-
return e.schema && (
|
|
697
|
-
...
|
|
692
|
+
let s = {};
|
|
693
|
+
return e.schema && (s = R(e.schema, e)), {
|
|
694
|
+
...s,
|
|
698
695
|
install(t, { global: o = !1 } = {}) {
|
|
699
|
-
t.provide(D, e), o && (t.config.globalProperties.$vvForm = e,
|
|
696
|
+
t.provide(D, e), o && (t.config.globalProperties.$vvForm = e, s != null && s.VvForm && t.component("VvForm", s.VvForm), s != null && s.VvFormWrapper && t.component("VvFormWrapper", s.VvFormWrapper), s != null && s.VvFormField && t.component("VvFormField", s.VvFormField), s != null && s.VvFormTemplate && t.component("VvFormTemplate", s.VvFormTemplate));
|
|
700
697
|
}
|
|
701
698
|
};
|
|
702
|
-
}, we = (e,
|
|
699
|
+
}, we = (e, s = {}) => te() ? R(
|
|
703
700
|
e,
|
|
704
701
|
{
|
|
705
702
|
...B(D, {}),
|
|
706
|
-
...
|
|
703
|
+
...s
|
|
707
704
|
}
|
|
708
|
-
) : R(e,
|
|
705
|
+
) : R(e, s), pe = (e, s = {}) => R(e, s);
|
|
709
706
|
export {
|
|
710
707
|
d as FormFieldType,
|
|
711
708
|
ke as createForm,
|
|
712
709
|
K as defaultObjectBySchema,
|
|
713
|
-
|
|
710
|
+
pe as formFactory,
|
|
714
711
|
D as pluginInjectionKey,
|
|
715
712
|
we as useForm
|
|
716
713
|
};
|