@volverjs/form-vue 0.0.14-beta.3 → 0.0.14-beta.4
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.d.ts +1 -1904
- package/dist/index.es.js +248 -242
- package/dist/index.umd.js +1 -1
- package/dist/{VvForm.d.ts → src/VvForm.d.ts} +6 -1
- package/dist/src/index.d.ts +1919 -0
- package/dist/test-playwright/VvForm.spec.d.ts +1 -0
- package/dist/test-playwright/VvFormField.spec.d.ts +1 -0
- package/dist/test-playwright/VvFormWrapper.spec.d.ts +1 -0
- package/dist/test-vitest/defaultObjectBySchema.test.d.ts +1 -0
- package/dist/test-vitest/useForm.test.d.ts +1 -0
- package/package.json +12 -11
- package/src/VvForm.ts +20 -12
- package/src/VvFormTemplate.ts +99 -101
- package/src/index.ts +1 -0
- /package/dist/{VvFormField.d.ts → src/VvFormField.d.ts} +0 -0
- /package/dist/{VvFormTemplate.d.ts → src/VvFormTemplate.d.ts} +0 -0
- /package/dist/{VvFormWrapper.d.ts → src/VvFormWrapper.d.ts} +0 -0
- /package/dist/{enums.d.ts → src/enums.d.ts} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
- /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
package/dist/index.es.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { defineComponent as W, computed as g, onMounted as
|
|
2
|
-
import { watchThrottled as
|
|
3
|
-
import { ZodObject as
|
|
4
|
-
function
|
|
1
|
+
import { defineComponent as W, computed as g, onMounted as D, onBeforeUnmount as j, inject as I, toRefs as R, watch as E, unref as _, provide as M, readonly as p, resolveComponent as O, defineAsyncComponent as F, h as x, ref as $, toRaw as S, isProxy as ee, withModifiers as re, getCurrentInstance as te } from "vue";
|
|
2
|
+
import { watchThrottled as ae } from "@vueuse/core";
|
|
3
|
+
import { ZodObject as K, ZodDefault as ue, ZodNullable as ne, ZodSchema as le, ZodArray as se, ZodEffects as ie, ZodOptional as fe } from "zod";
|
|
4
|
+
function U(e) {
|
|
5
5
|
return Array.isArray(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function oe(e) {
|
|
8
8
|
return typeof e < "u";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function P(e) {
|
|
11
11
|
return e === null;
|
|
12
12
|
}
|
|
13
13
|
function H(e) {
|
|
@@ -19,29 +19,29 @@ function Q(e) {
|
|
|
19
19
|
function N(e) {
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
function G(e,
|
|
24
|
-
const f =
|
|
25
|
-
if (!H(e) || !Q(
|
|
22
|
+
const de = /^[0-9]+$/, ve = ["__proto__", "prototype", "constructor"];
|
|
23
|
+
function G(e, l, t) {
|
|
24
|
+
const f = oe(t) ? t : void 0;
|
|
25
|
+
if (!H(e) || !Q(l))
|
|
26
26
|
return f;
|
|
27
|
-
const n =
|
|
27
|
+
const n = X(l);
|
|
28
28
|
if (n.length !== 0) {
|
|
29
29
|
for (const r of n) {
|
|
30
30
|
if (r === "*")
|
|
31
31
|
continue;
|
|
32
32
|
const u = function(i) {
|
|
33
|
-
return i.map((
|
|
33
|
+
return i.map((s) => N(s) || P(s) ? s : U(s) ? u(s) : s[r]);
|
|
34
34
|
};
|
|
35
|
-
if (
|
|
35
|
+
if (U(e) && !de.test(r) ? e = u(e) : e = e[r], N(e) || P(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
return N(e) ? f : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (!H(e) || !Q(
|
|
41
|
+
function T(e, l, t) {
|
|
42
|
+
if (!H(e) || !Q(l))
|
|
43
43
|
return;
|
|
44
|
-
const f =
|
|
44
|
+
const f = X(l);
|
|
45
45
|
if (f.length === 0)
|
|
46
46
|
return;
|
|
47
47
|
const n = f.length;
|
|
@@ -51,21 +51,21 @@ function R(e, s, t) {
|
|
|
51
51
|
e[u] = t;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (u === "*" &&
|
|
54
|
+
if (u === "*" && U(e)) {
|
|
55
55
|
const i = f.slice(r + 1).join(".");
|
|
56
|
-
for (const
|
|
57
|
-
|
|
56
|
+
for (const s of e)
|
|
57
|
+
T(s, i, t);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
N(e[u]) && (e[u] = {}), e = e[u];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
return
|
|
63
|
+
function X(e) {
|
|
64
|
+
const l = e.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
|
|
65
|
+
return l.some((t) => ve.indexOf(t) !== -1) ? [] : l;
|
|
66
66
|
}
|
|
67
67
|
var v = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.tel = "tel", e.url = "url", e.search = "search", e.date = "date", e.time = "time", e.datetimeLocal = "datetime-local", e.month = "month", e.week = "week", e.color = "color", e.select = "select", e.checkbox = "checkbox", e.radio = "radio", e.textarea = "textarea", e.radioGroup = "radioGroup", e.checkboxGroup = "checkboxGroup", e.combobox = "combobox", e.custom = "custom", e))(v || {}), B = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e))(B || {});
|
|
68
|
-
const
|
|
68
|
+
const ce = (e, l, t, f) => W({
|
|
69
69
|
name: "FieldComponent",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
@@ -109,59 +109,59 @@ const de = (e, s, t, f) => W({
|
|
|
109
109
|
String(n.name)
|
|
110
110
|
);
|
|
111
111
|
},
|
|
112
|
-
set(
|
|
113
|
-
a != null && a.formData && (
|
|
112
|
+
set(d) {
|
|
113
|
+
a != null && a.formData && (T(
|
|
114
114
|
Object(a.formData.value),
|
|
115
115
|
String(n.name),
|
|
116
|
-
|
|
116
|
+
d
|
|
117
117
|
), u("update:modelValue", {
|
|
118
118
|
newValue: i.value,
|
|
119
119
|
formData: a == null ? void 0 : a.formData
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
D(() => {
|
|
124
124
|
i.value === void 0 && n.defaultValue !== void 0 && (i.value = n.defaultValue);
|
|
125
|
-
}),
|
|
126
|
-
|
|
125
|
+
}), j(() => {
|
|
126
|
+
w(), k();
|
|
127
127
|
});
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
const a = I(e), { props:
|
|
128
|
+
const s = I(l, void 0);
|
|
129
|
+
s && s.fields.value.add(n.name);
|
|
130
|
+
const a = I(e), { props: o, name: h } = R(n), b = g(() => {
|
|
131
131
|
if (a != null && a.errors.value)
|
|
132
132
|
return G(a.errors.value, String(n.name));
|
|
133
|
-
}),
|
|
134
|
-
var
|
|
135
|
-
return (
|
|
136
|
-
}),
|
|
137
|
-
|
|
133
|
+
}), c = g(() => {
|
|
134
|
+
var d;
|
|
135
|
+
return (d = b.value) == null ? void 0 : d._errors;
|
|
136
|
+
}), m = g(() => b.value !== void 0), w = E(m, () => {
|
|
137
|
+
m.value ? (u("invalid", c.value), s && s.errors.value.set(
|
|
138
138
|
n.name,
|
|
139
139
|
{
|
|
140
|
-
_errors:
|
|
140
|
+
_errors: c.value
|
|
141
141
|
}
|
|
142
|
-
)) : (u("valid", i.value),
|
|
142
|
+
)) : (u("valid", i.value), s && s.errors.value.delete(
|
|
143
143
|
n.name
|
|
144
144
|
));
|
|
145
|
-
}),
|
|
145
|
+
}), k = E(
|
|
146
146
|
() => a == null ? void 0 : a.formData,
|
|
147
147
|
() => {
|
|
148
148
|
u("update:formData", a == null ? void 0 : a.formData);
|
|
149
149
|
},
|
|
150
150
|
{ deep: !0 }
|
|
151
|
-
), y = (
|
|
152
|
-
i.value =
|
|
153
|
-
},
|
|
154
|
-
let
|
|
155
|
-
return typeof
|
|
156
|
-
(A,
|
|
151
|
+
), y = (d) => {
|
|
152
|
+
i.value = d;
|
|
153
|
+
}, V = g(() => {
|
|
154
|
+
let d = o.value;
|
|
155
|
+
return typeof d == "function" && (d = d(a == null ? void 0 : a.formData)), Object.keys(d).reduce(
|
|
156
|
+
(A, C) => (A[C] = _(d[C]), A),
|
|
157
157
|
{}
|
|
158
158
|
);
|
|
159
159
|
}), z = g(() => ({
|
|
160
|
-
|
|
161
|
-
name:
|
|
162
|
-
invalid:
|
|
163
|
-
valid: n.showValid ? !!(!
|
|
164
|
-
type: ((
|
|
160
|
+
...V.value,
|
|
161
|
+
name: V.value.name ?? n.name,
|
|
162
|
+
invalid: m.value,
|
|
163
|
+
valid: n.showValid ? !!(!m.value && i.value) : void 0,
|
|
164
|
+
type: ((d) => {
|
|
165
165
|
if ([
|
|
166
166
|
v.text,
|
|
167
167
|
v.number,
|
|
@@ -176,28 +176,28 @@ const de = (e, s, t, f) => W({
|
|
|
176
176
|
v.month,
|
|
177
177
|
v.week,
|
|
178
178
|
v.color
|
|
179
|
-
].includes(
|
|
180
|
-
return
|
|
179
|
+
].includes(d))
|
|
180
|
+
return d;
|
|
181
181
|
})(n.type),
|
|
182
|
-
invalidLabel:
|
|
182
|
+
invalidLabel: c.value,
|
|
183
183
|
modelValue: i.value,
|
|
184
184
|
"onUpdate:modelValue": y
|
|
185
185
|
}));
|
|
186
|
-
return
|
|
187
|
-
name:
|
|
188
|
-
errors:
|
|
186
|
+
return M(t, {
|
|
187
|
+
name: p(h),
|
|
188
|
+
errors: p(b)
|
|
189
189
|
}), { component: g(() => {
|
|
190
190
|
if (n.type === v.custom)
|
|
191
191
|
return {
|
|
192
192
|
render() {
|
|
193
|
-
var
|
|
194
|
-
return ((
|
|
193
|
+
var d;
|
|
194
|
+
return ((d = r.default) == null ? void 0 : d.call(r, {
|
|
195
195
|
modelValue: i.value,
|
|
196
196
|
onUpdate: y,
|
|
197
197
|
submit: a == null ? void 0 : a.submit,
|
|
198
198
|
validate: a == null ? void 0 : a.validate,
|
|
199
|
-
invalid:
|
|
200
|
-
invalidLabel:
|
|
199
|
+
invalid: m.value,
|
|
200
|
+
invalidLabel: c.value,
|
|
201
201
|
formData: a == null ? void 0 : a.formData.value,
|
|
202
202
|
formErrors: a == null ? void 0 : a.errors.value,
|
|
203
203
|
errors: b.value
|
|
@@ -205,39 +205,39 @@ const de = (e, s, t, f) => W({
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
if (!((f == null ? void 0 : f.lazyLoad) ?? n.lazyLoad)) {
|
|
208
|
-
let
|
|
208
|
+
let d;
|
|
209
209
|
switch (n.type) {
|
|
210
210
|
case v.select:
|
|
211
|
-
|
|
211
|
+
d = O("VvSelect");
|
|
212
212
|
break;
|
|
213
213
|
case v.checkbox:
|
|
214
|
-
|
|
214
|
+
d = O("VvCheckbox");
|
|
215
215
|
break;
|
|
216
216
|
case v.radio:
|
|
217
|
-
|
|
217
|
+
d = O("VvRadio");
|
|
218
218
|
break;
|
|
219
219
|
case v.textarea:
|
|
220
|
-
|
|
220
|
+
d = O("VvTextarea");
|
|
221
221
|
break;
|
|
222
222
|
case v.radioGroup:
|
|
223
|
-
|
|
223
|
+
d = O("VvRadioGroup");
|
|
224
224
|
break;
|
|
225
225
|
case v.checkboxGroup:
|
|
226
|
-
|
|
226
|
+
d = O("VvCheckboxGroup");
|
|
227
227
|
break;
|
|
228
228
|
case v.combobox:
|
|
229
|
-
|
|
229
|
+
d = O("VvCombobox");
|
|
230
230
|
break;
|
|
231
231
|
default:
|
|
232
|
-
|
|
232
|
+
d = O("VvInputText");
|
|
233
233
|
}
|
|
234
|
-
if (typeof
|
|
235
|
-
return
|
|
234
|
+
if (typeof d != "string")
|
|
235
|
+
return d;
|
|
236
236
|
console.warn(
|
|
237
|
-
`[form-vue warn]: ${
|
|
237
|
+
`[form-vue warn]: ${d} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
|
-
return
|
|
240
|
+
return F(async () => {
|
|
241
241
|
switch (f != null && f.sideEffects && await Promise.resolve(f.sideEffects(n.type)), n.type) {
|
|
242
242
|
case v.textarea:
|
|
243
243
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
@@ -256,49 +256,49 @@ const de = (e, s, t, f) => W({
|
|
|
256
256
|
}
|
|
257
257
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
258
258
|
});
|
|
259
|
-
}), hasProps: z, invalid:
|
|
259
|
+
}), hasProps: z, invalid: m };
|
|
260
260
|
},
|
|
261
261
|
render() {
|
|
262
262
|
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === v.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
|
|
263
263
|
}
|
|
264
|
-
}),
|
|
264
|
+
}), J = (e, l = {}) => {
|
|
265
265
|
const t = (r) => {
|
|
266
266
|
let u = r;
|
|
267
|
-
for (; u instanceof
|
|
267
|
+
for (; u instanceof ie; )
|
|
268
268
|
u = u.innerType();
|
|
269
|
-
return u instanceof
|
|
269
|
+
return u instanceof fe && (u = u._def.innerType), u;
|
|
270
270
|
}, f = t(e);
|
|
271
271
|
return {
|
|
272
|
-
...(f instanceof
|
|
272
|
+
...(f instanceof K ? f._def.unknownKeys === "passthrough" : !1) ? l : {},
|
|
273
273
|
...Object.fromEntries(
|
|
274
274
|
Object.entries(f.shape).map(
|
|
275
275
|
([r, u]) => {
|
|
276
|
-
const i =
|
|
277
|
-
let
|
|
278
|
-
if (
|
|
276
|
+
const i = l[r];
|
|
277
|
+
let s = t(u), a;
|
|
278
|
+
if (s instanceof ue && (a = s._def.defaultValue(), s = s._def.innerType), i === null && s instanceof ne)
|
|
279
279
|
return [r, i];
|
|
280
|
-
if (
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
return [r,
|
|
280
|
+
if (s instanceof le) {
|
|
281
|
+
const o = u.safeParse(i);
|
|
282
|
+
if (o.success)
|
|
283
|
+
return [r, o.data ?? a];
|
|
284
284
|
}
|
|
285
|
-
if (
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
285
|
+
if (s instanceof se && Array.isArray(i) && i.length) {
|
|
286
|
+
const o = t(s._def.type);
|
|
287
|
+
if (o instanceof K)
|
|
288
288
|
return [
|
|
289
289
|
r,
|
|
290
290
|
i.map(
|
|
291
|
-
(h) =>
|
|
292
|
-
|
|
291
|
+
(h) => J(
|
|
292
|
+
o,
|
|
293
293
|
h && typeof h == "object" ? h : void 0
|
|
294
294
|
)
|
|
295
295
|
) ?? a
|
|
296
296
|
];
|
|
297
297
|
}
|
|
298
|
-
return
|
|
298
|
+
return s instanceof K ? [
|
|
299
299
|
r,
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
J(
|
|
301
|
+
s,
|
|
302
302
|
i && typeof i == "object" ? i : a
|
|
303
303
|
)
|
|
304
304
|
] : [r, a];
|
|
@@ -306,8 +306,8 @@ const de = (e, s, t, f) => W({
|
|
|
306
306
|
)
|
|
307
307
|
)
|
|
308
308
|
};
|
|
309
|
-
},
|
|
310
|
-
const n =
|
|
309
|
+
}, me = (e, l, t, f) => {
|
|
310
|
+
const n = $(), r = $(), u = $(), i = W({
|
|
311
311
|
name: "FormComponent",
|
|
312
312
|
props: {
|
|
313
313
|
modelValue: {
|
|
@@ -323,81 +323,89 @@ const de = (e, s, t, f) => W({
|
|
|
323
323
|
default: !1
|
|
324
324
|
},
|
|
325
325
|
template: {
|
|
326
|
-
type: [Array, Function]
|
|
326
|
+
type: [Array, Function],
|
|
327
|
+
default: void 0
|
|
327
328
|
}
|
|
328
329
|
},
|
|
329
330
|
emits: ["invalid", "valid", "submit", "update:modelValue"],
|
|
330
331
|
expose: ["submit", "validate", "errors", "status", "valid", "invalid"],
|
|
331
|
-
setup(
|
|
332
|
-
u.value =
|
|
332
|
+
setup(s, { emit: a }) {
|
|
333
|
+
u.value = J(
|
|
333
334
|
e,
|
|
334
|
-
|
|
335
|
+
S(s.modelValue)
|
|
335
336
|
), E(
|
|
336
|
-
() =>
|
|
337
|
-
(
|
|
338
|
-
if (
|
|
339
|
-
const
|
|
340
|
-
u.value = typeof (
|
|
337
|
+
() => s.modelValue,
|
|
338
|
+
(c) => {
|
|
339
|
+
if (c) {
|
|
340
|
+
const m = ee(c) ? S(c) : c;
|
|
341
|
+
u.value = typeof (m == null ? void 0 : m.clone) == "function" ? m.clone() : JSON.parse(JSON.stringify(m));
|
|
341
342
|
}
|
|
342
343
|
},
|
|
343
344
|
{ deep: !0 }
|
|
344
|
-
),
|
|
345
|
+
), ae(
|
|
345
346
|
u,
|
|
346
|
-
(
|
|
347
|
-
var
|
|
348
|
-
((n.value || (t == null ? void 0 : t.continuosValidation)) ??
|
|
347
|
+
(c) => {
|
|
348
|
+
var m;
|
|
349
|
+
((n.value || (t == null ? void 0 : t.continuosValidation)) ?? s.continuosValidation) && o(), (!c || !s.modelValue || JSON.stringify(c) !== JSON.stringify(s.modelValue)) && (a("update:modelValue", c), (m = t == null ? void 0 : t.onUpdate) == null || m.call(t, S(c)));
|
|
349
350
|
},
|
|
350
351
|
{
|
|
351
352
|
deep: !0,
|
|
352
|
-
throttle: (t == null ? void 0 : t.updateThrottle) ??
|
|
353
|
+
throttle: (t == null ? void 0 : t.updateThrottle) ?? s.updateThrottle
|
|
353
354
|
}
|
|
354
355
|
);
|
|
355
|
-
const
|
|
356
|
-
var
|
|
357
|
-
const
|
|
358
|
-
return
|
|
356
|
+
const o = (c = u.value) => {
|
|
357
|
+
var w, k, y;
|
|
358
|
+
const m = e.safeParse(c);
|
|
359
|
+
return m.success ? (n.value = void 0, r.value = B.valid, u.value = m.data, a("update:modelValue", u.value), (k = t == null ? void 0 : t.onUpdate) == null || k.call(t, S(u.value)), a("valid", m.data), (y = t == null ? void 0 : t.onValid) == null || y.call(t, S(u.value)), !0) : (n.value = m.error.format(), r.value = B.invalid, a("invalid", n.value), (w = t == null ? void 0 : t.onInvalid) == null || w.call(t, S(n.value)), !1);
|
|
359
360
|
}, h = () => {
|
|
360
|
-
var
|
|
361
|
-
return
|
|
361
|
+
var c;
|
|
362
|
+
return o() ? (a("submit", u.value), (c = t == null ? void 0 : t.onSubmit) == null || c.call(t, S(u.value)), !0) : !1;
|
|
362
363
|
}, b = g(() => r.value === B.invalid);
|
|
363
|
-
return
|
|
364
|
+
return M(l, {
|
|
364
365
|
formData: u,
|
|
365
366
|
submit: h,
|
|
366
|
-
validate:
|
|
367
|
-
errors:
|
|
368
|
-
status:
|
|
367
|
+
validate: o,
|
|
368
|
+
errors: p(n),
|
|
369
|
+
status: p(r),
|
|
369
370
|
invalid: b
|
|
370
371
|
}), {
|
|
371
372
|
formData: u,
|
|
372
373
|
submit: h,
|
|
373
|
-
validate:
|
|
374
|
-
errors:
|
|
375
|
-
status:
|
|
374
|
+
validate: o,
|
|
375
|
+
errors: p(n),
|
|
376
|
+
status: p(r),
|
|
376
377
|
invalid: b
|
|
377
378
|
};
|
|
378
379
|
},
|
|
379
380
|
render() {
|
|
381
|
+
const s = () => {
|
|
382
|
+
var a, o;
|
|
383
|
+
return ((o = (a = this.$slots) == null ? void 0 : a.default) == null ? void 0 : o.call(a, {
|
|
384
|
+
formData: this.formData,
|
|
385
|
+
submit: this.submit,
|
|
386
|
+
validate: this.validate,
|
|
387
|
+
errors: this.errors,
|
|
388
|
+
status: this.status,
|
|
389
|
+
invalid: this.invalid
|
|
390
|
+
})) ?? this.$slots.default;
|
|
391
|
+
};
|
|
380
392
|
return x(
|
|
381
393
|
"form",
|
|
382
394
|
{
|
|
383
|
-
onSubmit:
|
|
395
|
+
onSubmit: re(this.submit, ["prevent"])
|
|
384
396
|
},
|
|
385
397
|
(this.template ?? (t == null ? void 0 : t.template)) && f ? [
|
|
386
|
-
x(
|
|
387
|
-
|
|
388
|
-
|
|
398
|
+
x(
|
|
399
|
+
f,
|
|
400
|
+
{
|
|
401
|
+
schema: this.template ?? (t == null ? void 0 : t.template)
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
default: s
|
|
405
|
+
}
|
|
406
|
+
)
|
|
389
407
|
] : {
|
|
390
|
-
default:
|
|
391
|
-
var l, a;
|
|
392
|
-
return ((a = (l = this.$slots) == null ? void 0 : l.default) == null ? void 0 : a.call(l, {
|
|
393
|
-
formData: this.formData,
|
|
394
|
-
submit: this.submit,
|
|
395
|
-
validate: this.validate,
|
|
396
|
-
errors: this.errors,
|
|
397
|
-
status: this.status,
|
|
398
|
-
invalid: this.invalid
|
|
399
|
-
})) ?? this.$slots.default;
|
|
400
|
-
}
|
|
408
|
+
default: s
|
|
401
409
|
}
|
|
402
410
|
);
|
|
403
411
|
}
|
|
@@ -411,7 +419,7 @@ const de = (e, s, t, f) => W({
|
|
|
411
419
|
*/
|
|
412
420
|
VvForm: i
|
|
413
421
|
};
|
|
414
|
-
},
|
|
422
|
+
}, he = (e, l) => W({
|
|
415
423
|
name: "WrapperComponent",
|
|
416
424
|
props: {
|
|
417
425
|
name: {
|
|
@@ -426,10 +434,10 @@ const de = (e, s, t, f) => W({
|
|
|
426
434
|
emits: ["invalid", "valid"],
|
|
427
435
|
expose: ["fields", "invalid"],
|
|
428
436
|
setup(f, { emit: n }) {
|
|
429
|
-
const r = I(e), u = I(
|
|
430
|
-
|
|
431
|
-
name:
|
|
432
|
-
errors:
|
|
437
|
+
const r = I(e), u = I(l, void 0), i = $(/* @__PURE__ */ new Set()), s = $(/* @__PURE__ */ new Map()), { name: a } = R(f);
|
|
438
|
+
M(l, {
|
|
439
|
+
name: p(a),
|
|
440
|
+
errors: s,
|
|
433
441
|
fields: i
|
|
434
442
|
}), E(
|
|
435
443
|
i,
|
|
@@ -440,28 +448,28 @@ const de = (e, s, t, f) => W({
|
|
|
440
448
|
},
|
|
441
449
|
{ deep: !0 }
|
|
442
450
|
), E(
|
|
443
|
-
() => new Map(
|
|
451
|
+
() => new Map(s.value),
|
|
444
452
|
(h, b) => {
|
|
445
|
-
u != null && u.errors && (Array.from(b.keys()).forEach((
|
|
446
|
-
u.errors.value.delete(
|
|
447
|
-
}), Array.from(h.keys()).forEach((
|
|
448
|
-
const
|
|
449
|
-
|
|
453
|
+
u != null && u.errors && (Array.from(b.keys()).forEach((c) => {
|
|
454
|
+
u.errors.value.delete(c);
|
|
455
|
+
}), Array.from(h.keys()).forEach((c) => {
|
|
456
|
+
const m = h.get(c);
|
|
457
|
+
m && u.errors.value.set(c, m);
|
|
450
458
|
}));
|
|
451
459
|
},
|
|
452
460
|
{ deep: !0 }
|
|
453
461
|
);
|
|
454
|
-
const
|
|
455
|
-
return E(
|
|
456
|
-
|
|
462
|
+
const o = g(() => r != null && r.invalid.value ? s.value.size > 0 : !1);
|
|
463
|
+
return E(o, () => {
|
|
464
|
+
o.value ? n("invalid") : n("valid");
|
|
457
465
|
}), {
|
|
458
466
|
formData: r == null ? void 0 : r.formData,
|
|
459
467
|
errors: r == null ? void 0 : r.errors,
|
|
460
468
|
submit: r == null ? void 0 : r.submit,
|
|
461
469
|
validate: r == null ? void 0 : r.validate,
|
|
462
|
-
invalid:
|
|
470
|
+
invalid: o,
|
|
463
471
|
fields: i,
|
|
464
|
-
fieldsErrors:
|
|
472
|
+
fieldsErrors: s
|
|
465
473
|
};
|
|
466
474
|
},
|
|
467
475
|
render() {
|
|
@@ -487,7 +495,7 @@ const de = (e, s, t, f) => W({
|
|
|
487
495
|
fieldsErrors: this.fieldsErrors
|
|
488
496
|
})) ?? this.$slots.defalut;
|
|
489
497
|
}
|
|
490
|
-
}),
|
|
498
|
+
}), be = (e, l) => {
|
|
491
499
|
const t = W({
|
|
492
500
|
props: {
|
|
493
501
|
schema: {
|
|
@@ -499,94 +507,92 @@ const de = (e, s, t, f) => W({
|
|
|
499
507
|
const r = I(e);
|
|
500
508
|
if (r != null && r.formData)
|
|
501
509
|
return () => {
|
|
502
|
-
var
|
|
510
|
+
var a;
|
|
503
511
|
const u = typeof f.schema == "function" ? f.schema(r) : f.schema;
|
|
504
512
|
let i;
|
|
505
|
-
|
|
506
|
-
(
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
]
|
|
568
|
-
);
|
|
513
|
+
const s = u.reduce((o, h) => {
|
|
514
|
+
const b = typeof h == "function" ? h(r) : h, {
|
|
515
|
+
vvIs: c,
|
|
516
|
+
vvName: m,
|
|
517
|
+
vvSlots: w,
|
|
518
|
+
vvChildren: k,
|
|
519
|
+
vvIf: y,
|
|
520
|
+
vvElseIf: V,
|
|
521
|
+
vvType: z,
|
|
522
|
+
vvDefaultValue: q,
|
|
523
|
+
vvShowValid: d,
|
|
524
|
+
vvContent: A,
|
|
525
|
+
...C
|
|
526
|
+
} = b;
|
|
527
|
+
if (y !== void 0) {
|
|
528
|
+
if (typeof y == "string" ? i = !!G(
|
|
529
|
+
Object(r.formData.value),
|
|
530
|
+
y
|
|
531
|
+
) : typeof y == "function" ? i = _(y(r)) : i = _(y), !i)
|
|
532
|
+
return o;
|
|
533
|
+
} else if (V !== void 0 && i !== void 0) {
|
|
534
|
+
if (i || (typeof V == "string" ? i = !!G(
|
|
535
|
+
Object(r.formData.value),
|
|
536
|
+
V
|
|
537
|
+
) : typeof V == "function" ? i = _(V(r)) : i = _(V), !i))
|
|
538
|
+
return o;
|
|
539
|
+
} else
|
|
540
|
+
i = void 0;
|
|
541
|
+
const Z = k ? x(t, {
|
|
542
|
+
schema: k
|
|
543
|
+
}) : void 0;
|
|
544
|
+
return m ? (o.push(
|
|
545
|
+
x(
|
|
546
|
+
l,
|
|
547
|
+
{
|
|
548
|
+
name: m,
|
|
549
|
+
is: c,
|
|
550
|
+
type: z,
|
|
551
|
+
defaultValue: q,
|
|
552
|
+
showValid: d,
|
|
553
|
+
props: C
|
|
554
|
+
},
|
|
555
|
+
w ?? Z ?? A
|
|
556
|
+
)
|
|
557
|
+
), o) : c ? (o.push(
|
|
558
|
+
x(
|
|
559
|
+
c,
|
|
560
|
+
C,
|
|
561
|
+
w ?? Z ?? A
|
|
562
|
+
)
|
|
563
|
+
), o) : (k && o.push(Z), o);
|
|
564
|
+
}, []);
|
|
565
|
+
return s.push(
|
|
566
|
+
(a = n == null ? void 0 : n.default) == null ? void 0 : a.call(n, {
|
|
567
|
+
formData: r == null ? void 0 : r.formData.value,
|
|
568
|
+
submit: r == null ? void 0 : r.submit,
|
|
569
|
+
validate: r == null ? void 0 : r.validate,
|
|
570
|
+
errors: r == null ? void 0 : r.errors.value,
|
|
571
|
+
status: r == null ? void 0 : r.status.value,
|
|
572
|
+
invalid: r == null ? void 0 : r.invalid.value
|
|
573
|
+
})
|
|
574
|
+
), s;
|
|
569
575
|
};
|
|
570
576
|
}
|
|
571
577
|
});
|
|
572
578
|
return t;
|
|
573
|
-
}, L = (e,
|
|
574
|
-
const t = Symbol(), f = Symbol(), n = Symbol(), r =
|
|
579
|
+
}, L = (e, l = {}) => {
|
|
580
|
+
const t = Symbol(), f = Symbol(), n = Symbol(), r = he(
|
|
575
581
|
t,
|
|
576
582
|
f
|
|
577
|
-
), u =
|
|
583
|
+
), u = ce(
|
|
578
584
|
t,
|
|
579
585
|
f,
|
|
580
586
|
n,
|
|
581
|
-
|
|
582
|
-
), i =
|
|
587
|
+
l
|
|
588
|
+
), i = be(t, u), { VvForm: s, errors: a, status: o, formData: h } = me(
|
|
583
589
|
e,
|
|
584
590
|
t,
|
|
585
|
-
|
|
591
|
+
l,
|
|
586
592
|
i
|
|
587
593
|
);
|
|
588
594
|
return {
|
|
589
|
-
VvForm:
|
|
595
|
+
VvForm: s,
|
|
590
596
|
VvFormWrapper: r,
|
|
591
597
|
VvFormField: u,
|
|
592
598
|
VvFormTemplate: i,
|
|
@@ -594,29 +600,29 @@ const de = (e, s, t, f) => W({
|
|
|
594
600
|
formWrapperInjectionKey: f,
|
|
595
601
|
formFieldInjectionKey: n,
|
|
596
602
|
errors: a,
|
|
597
|
-
status:
|
|
603
|
+
status: o,
|
|
598
604
|
formData: h
|
|
599
605
|
};
|
|
600
|
-
},
|
|
601
|
-
let
|
|
602
|
-
return e.schema && (
|
|
603
|
-
...
|
|
606
|
+
}, Y = Symbol(), xe = (e) => {
|
|
607
|
+
let l = {};
|
|
608
|
+
return e.schema && (l = L(e.schema, e)), {
|
|
609
|
+
...l,
|
|
604
610
|
install(t, { global: f = !1 } = {}) {
|
|
605
|
-
t.provide(
|
|
611
|
+
t.provide(Y, e), f && (t.config.globalProperties.$vvForm = e, l != null && l.VvForm && t.component("VvForm", l.VvForm), l != null && l.VvFormWrapper && t.component("VvFormWrapper", l.VvFormWrapper), l != null && l.VvFormField && t.component("VvFormField", l.VvFormField), l != null && l.VvFormTemplate && t.component("VvFormTemplate", l.VvFormTemplate));
|
|
606
612
|
}
|
|
607
613
|
};
|
|
608
|
-
},
|
|
614
|
+
}, ke = (e, l = {}) => te() ? L(
|
|
609
615
|
e,
|
|
610
616
|
{
|
|
611
|
-
...I(
|
|
612
|
-
...
|
|
617
|
+
...I(Y, {}),
|
|
618
|
+
...l
|
|
613
619
|
}
|
|
614
|
-
) : L(e,
|
|
620
|
+
) : L(e, l), Oe = (e, l = {}) => L(e, l);
|
|
615
621
|
export {
|
|
616
622
|
v as FormFieldType,
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
623
|
+
xe as createForm,
|
|
624
|
+
J as defaultObjectBySchema,
|
|
625
|
+
Oe as formFactory,
|
|
626
|
+
Y as pluginInjectionKey,
|
|
627
|
+
ke as useForm
|
|
622
628
|
};
|