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