@volverjs/form-vue 0.0.10-beta.3 → 0.0.10-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VvFormWrapper.d.ts +120 -19
- package/dist/index.d.ts +236 -34
- package/dist/index.es.js +228 -219
- package/dist/index.umd.js +1 -1
- package/package.json +8 -8
- package/src/VvFormField.ts +28 -24
- package/src/VvFormWrapper.ts +52 -15
package/dist/index.es.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { watchThrottled as
|
|
3
|
-
import { ZodObject as
|
|
1
|
+
import { defineComponent as E, computed as b, onMounted as R, onBeforeUnmount as q, inject as S, toRefs as I, watch as y, provide as $, readonly as w, resolveComponent as p, defineAsyncComponent as H, h as x, ref as g, isProxy as Q, toRaw as X, withModifiers as Y } from "vue";
|
|
2
|
+
import { watchThrottled as D } from "@vueuse/core";
|
|
3
|
+
import { ZodObject as L, ZodDefault as T, ZodNullable as j, ZodSchema as F, ZodEffects as ee } from "zod";
|
|
4
4
|
function O(e) {
|
|
5
5
|
return Array.isArray(e);
|
|
6
6
|
}
|
|
7
7
|
function te(e) {
|
|
8
8
|
return typeof e < "u";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function N(e) {
|
|
11
11
|
return e === null;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function W(e) {
|
|
14
14
|
return typeof e == "object";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function _(e) {
|
|
17
17
|
return typeof e == "string";
|
|
18
18
|
}
|
|
19
19
|
function k(e) {
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
|
-
const re = /^[0-9]+$/,
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
return
|
|
27
|
-
const a =
|
|
22
|
+
const re = /^[0-9]+$/, ne = ["__proto__", "prototype", "constructor"];
|
|
23
|
+
function A(e, o, s) {
|
|
24
|
+
const u = te(s) ? s : void 0;
|
|
25
|
+
if (!W(e) || !_(o))
|
|
26
|
+
return u;
|
|
27
|
+
const a = K(o);
|
|
28
28
|
if (a.length !== 0) {
|
|
29
29
|
for (const t of a) {
|
|
30
30
|
if (t === "*")
|
|
31
31
|
continue;
|
|
32
|
-
const
|
|
33
|
-
return
|
|
32
|
+
const r = function(c) {
|
|
33
|
+
return c.map((l) => k(l) || N(l) ? l : O(l) ? r(l) : l[t]);
|
|
34
34
|
};
|
|
35
|
-
if (O(e) && !re.test(t) ? e =
|
|
35
|
+
if (O(e) && !re.test(t) ? e = r(e) : e = e[t], k(e) || N(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
|
-
return k(e) ?
|
|
38
|
+
return k(e) ? u : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (!
|
|
41
|
+
function B(e, o, s) {
|
|
42
|
+
if (!W(e) || !_(o))
|
|
43
43
|
return;
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
44
|
+
const u = K(o);
|
|
45
|
+
if (u.length === 0)
|
|
46
46
|
return;
|
|
47
|
-
const a =
|
|
47
|
+
const a = u.length;
|
|
48
48
|
for (let t = 0; t < a; t++) {
|
|
49
|
-
const
|
|
49
|
+
const r = u[t];
|
|
50
50
|
if (t === a - 1) {
|
|
51
|
-
e[
|
|
51
|
+
e[r] = s;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
|
|
54
|
+
if (r === "*" && O(e)) {
|
|
55
|
+
const c = u.slice(t + 1).join(".");
|
|
56
|
+
for (const l of e)
|
|
57
|
+
B(l, c, s);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
k(e[
|
|
60
|
+
k(e[r]) && (e[r] = {}), e = e[r];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
return
|
|
63
|
+
function K(e) {
|
|
64
|
+
const o = e.split(/[.]|(?:\[(\d|\*)\])/).filter((s) => !!s);
|
|
65
|
+
return o.some((s) => ne.indexOf(s) !== -1) ? [] : o;
|
|
66
66
|
}
|
|
67
|
-
var
|
|
68
|
-
const
|
|
67
|
+
var i = /* @__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 = "datetimeLocal", 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))(i || {});
|
|
68
|
+
const oe = (e, o, s, u = {}) => E({
|
|
69
69
|
name: "FieldComponent",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
72
72
|
type: String,
|
|
73
|
-
validator: (a) => Object.values(
|
|
74
|
-
default:
|
|
73
|
+
validator: (a) => Object.values(i).includes(a),
|
|
74
|
+
default: i.custom
|
|
75
75
|
},
|
|
76
76
|
is: {
|
|
77
77
|
type: [Object, String],
|
|
@@ -96,126 +96,129 @@ const ne = (e, n, o, l = {}) => $({
|
|
|
96
96
|
},
|
|
97
97
|
emits: ["invalid", "valid", "update:formData", "update:modelValue"],
|
|
98
98
|
expose: ["invalid", "invalidLabel", "errors"],
|
|
99
|
-
setup(a, { slots: t, emit:
|
|
100
|
-
const
|
|
99
|
+
setup(a, { slots: t, emit: r }) {
|
|
100
|
+
const c = b({
|
|
101
101
|
get() {
|
|
102
|
-
if (
|
|
103
|
-
return
|
|
104
|
-
Object(
|
|
102
|
+
if (n != null && n.modelValue)
|
|
103
|
+
return A(
|
|
104
|
+
Object(n.modelValue.value),
|
|
105
105
|
String(a.name)
|
|
106
106
|
);
|
|
107
107
|
},
|
|
108
108
|
set(f) {
|
|
109
|
-
|
|
110
|
-
Object(
|
|
109
|
+
n != null && n.modelValue && (B(
|
|
110
|
+
Object(n.modelValue.value),
|
|
111
111
|
String(a.name),
|
|
112
112
|
f
|
|
113
|
-
),
|
|
114
|
-
newValue:
|
|
115
|
-
formData:
|
|
113
|
+
), r("update:modelValue", {
|
|
114
|
+
newValue: c.value,
|
|
115
|
+
formData: n == null ? void 0 : n.modelValue
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
R(() => {
|
|
120
|
+
c.value === void 0 && a.defaultValue !== void 0 && (c.value = a.defaultValue);
|
|
121
121
|
}), q(() => {
|
|
122
|
-
|
|
122
|
+
J(), U();
|
|
123
123
|
});
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
return
|
|
129
|
-
}),
|
|
124
|
+
const l = S(o, void 0);
|
|
125
|
+
l && l.fields.value.add(a.name);
|
|
126
|
+
const n = S(e), { props: m, name: v } = I(a), d = b(() => {
|
|
127
|
+
if (n != null && n.errors.value)
|
|
128
|
+
return A(n.errors.value, String(a.name));
|
|
129
|
+
}), h = b(() => {
|
|
130
130
|
var f;
|
|
131
131
|
return (f = d.value) == null ? void 0 : f._errors;
|
|
132
|
-
}),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
}), V = b(() => d.value !== void 0), J = y(V, () => {
|
|
133
|
+
V.value ? (r("invalid", h.value), l && l.errors.value.set(
|
|
134
|
+
a.name,
|
|
135
|
+
{
|
|
136
|
+
_errors: h.value
|
|
137
|
+
}
|
|
138
|
+
)) : (r("valid", c.value), l && l.errors.value.delete(
|
|
136
139
|
a.name
|
|
137
140
|
));
|
|
138
|
-
}),
|
|
139
|
-
() =>
|
|
141
|
+
}), U = y(
|
|
142
|
+
() => n == null ? void 0 : n.modelValue,
|
|
140
143
|
() => {
|
|
141
|
-
|
|
144
|
+
r("update:formData", n == null ? void 0 : n.modelValue);
|
|
142
145
|
},
|
|
143
146
|
{ deep: !0 }
|
|
144
|
-
),
|
|
145
|
-
|
|
146
|
-
},
|
|
147
|
-
...
|
|
148
|
-
name:
|
|
149
|
-
invalid:
|
|
150
|
-
valid: a.showValid ? !!(!
|
|
147
|
+
), G = (f) => {
|
|
148
|
+
c.value = f;
|
|
149
|
+
}, C = b(() => typeof m.value == "function" ? m.value(n == null ? void 0 : n.modelValue) : m.value), z = b(() => ({
|
|
150
|
+
...C.value,
|
|
151
|
+
name: C.value.name ?? a.name,
|
|
152
|
+
invalid: V.value,
|
|
153
|
+
valid: a.showValid ? !!(!V.value && c.value) : void 0,
|
|
151
154
|
type: ((f) => {
|
|
152
155
|
if ([
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
156
|
+
i.text,
|
|
157
|
+
i.number,
|
|
158
|
+
i.email,
|
|
159
|
+
i.password,
|
|
160
|
+
i.tel,
|
|
161
|
+
i.url,
|
|
162
|
+
i.search,
|
|
163
|
+
i.date,
|
|
164
|
+
i.time,
|
|
165
|
+
i.datetimeLocal,
|
|
166
|
+
i.month,
|
|
167
|
+
i.week,
|
|
168
|
+
i.color
|
|
166
169
|
].includes(f))
|
|
167
170
|
return f;
|
|
168
171
|
})(a.type),
|
|
169
|
-
invalidLabel:
|
|
170
|
-
modelValue:
|
|
172
|
+
invalidLabel: h.value,
|
|
173
|
+
modelValue: c.value,
|
|
171
174
|
errors: a.is ? d.value : void 0,
|
|
172
|
-
"onUpdate:modelValue":
|
|
175
|
+
"onUpdate:modelValue": G
|
|
173
176
|
}));
|
|
174
|
-
return
|
|
177
|
+
return $(s, {
|
|
175
178
|
name: w(v),
|
|
176
179
|
errors: w(d)
|
|
177
|
-
}), { component:
|
|
178
|
-
if (a.type ===
|
|
180
|
+
}), { component: b(() => {
|
|
181
|
+
if (a.type === i.custom)
|
|
179
182
|
return {
|
|
180
183
|
render() {
|
|
181
184
|
var f;
|
|
182
185
|
return ((f = t.default) == null ? void 0 : f.call(t, {
|
|
183
|
-
modelValue:
|
|
184
|
-
onUpdate:
|
|
185
|
-
invalid:
|
|
186
|
-
invalidLabel:
|
|
187
|
-
formData:
|
|
188
|
-
formErrors:
|
|
186
|
+
modelValue: c.value,
|
|
187
|
+
onUpdate: G,
|
|
188
|
+
invalid: V.value,
|
|
189
|
+
invalidLabel: h.value,
|
|
190
|
+
formData: n == null ? void 0 : n.modelValue.value,
|
|
191
|
+
formErrors: n == null ? void 0 : n.errors.value,
|
|
189
192
|
errors: d.value
|
|
190
193
|
})) ?? t.defalut;
|
|
191
194
|
}
|
|
192
195
|
};
|
|
193
|
-
if (!
|
|
196
|
+
if (!u.lazyLoad) {
|
|
194
197
|
let f;
|
|
195
198
|
switch (a.type) {
|
|
196
|
-
case
|
|
197
|
-
f =
|
|
199
|
+
case i.select:
|
|
200
|
+
f = p("VvSelect");
|
|
198
201
|
break;
|
|
199
|
-
case
|
|
200
|
-
f =
|
|
202
|
+
case i.checkbox:
|
|
203
|
+
f = p("VvCheckbox");
|
|
201
204
|
break;
|
|
202
|
-
case
|
|
203
|
-
f =
|
|
205
|
+
case i.radio:
|
|
206
|
+
f = p("VvRadio");
|
|
204
207
|
break;
|
|
205
|
-
case
|
|
206
|
-
f =
|
|
208
|
+
case i.textarea:
|
|
209
|
+
f = p("VvTextarea");
|
|
207
210
|
break;
|
|
208
|
-
case
|
|
209
|
-
f =
|
|
211
|
+
case i.radioGroup:
|
|
212
|
+
f = p("VvRadioGroup");
|
|
210
213
|
break;
|
|
211
|
-
case
|
|
212
|
-
f =
|
|
214
|
+
case i.checkboxGroup:
|
|
215
|
+
f = p("VvCheckboxGroup");
|
|
213
216
|
break;
|
|
214
|
-
case
|
|
215
|
-
f =
|
|
217
|
+
case i.combobox:
|
|
218
|
+
f = p("VvCombobox");
|
|
216
219
|
break;
|
|
217
220
|
default:
|
|
218
|
-
f =
|
|
221
|
+
f = p("VvInputText");
|
|
219
222
|
}
|
|
220
223
|
if (typeof f != "string")
|
|
221
224
|
return f;
|
|
@@ -223,65 +226,65 @@ const ne = (e, n, o, l = {}) => $({
|
|
|
223
226
|
`[form-vue warn]: ${f} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
224
227
|
);
|
|
225
228
|
}
|
|
226
|
-
return
|
|
227
|
-
switch (
|
|
228
|
-
case
|
|
229
|
+
return H(async () => {
|
|
230
|
+
switch (u.sideEffects && await Promise.resolve(u.sideEffects(a.type)), a.type) {
|
|
231
|
+
case i.textarea:
|
|
229
232
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
230
|
-
case
|
|
233
|
+
case i.radio:
|
|
231
234
|
return import("@volverjs/ui-vue/vv-radio");
|
|
232
|
-
case
|
|
235
|
+
case i.radioGroup:
|
|
233
236
|
return import("@volverjs/ui-vue/vv-radio-group");
|
|
234
|
-
case
|
|
237
|
+
case i.checkbox:
|
|
235
238
|
return import("@volverjs/ui-vue/vv-checkbox");
|
|
236
|
-
case
|
|
239
|
+
case i.checkboxGroup:
|
|
237
240
|
return import("@volverjs/ui-vue/vv-checkbox-group");
|
|
238
|
-
case
|
|
241
|
+
case i.combobox:
|
|
239
242
|
return import("@volverjs/ui-vue/vv-combobox");
|
|
240
243
|
}
|
|
241
244
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
242
245
|
});
|
|
243
|
-
}), hasProps:
|
|
246
|
+
}), hasProps: z, invalid: V };
|
|
244
247
|
},
|
|
245
248
|
render() {
|
|
246
|
-
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type ===
|
|
249
|
+
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === i.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
|
|
247
250
|
}
|
|
248
|
-
}),
|
|
249
|
-
const
|
|
250
|
-
let
|
|
251
|
-
for (;
|
|
252
|
-
|
|
253
|
-
return
|
|
254
|
-
},
|
|
251
|
+
}), M = (e, o = {}) => {
|
|
252
|
+
const s = (t) => {
|
|
253
|
+
let r = t;
|
|
254
|
+
for (; r instanceof ee; )
|
|
255
|
+
r = r.innerType();
|
|
256
|
+
return r;
|
|
257
|
+
}, u = s(e);
|
|
255
258
|
return {
|
|
256
|
-
...(
|
|
259
|
+
...(u instanceof L ? u._def.unknownKeys === "passthrough" : !1) ? o : {},
|
|
257
260
|
...Object.fromEntries(
|
|
258
|
-
Object.entries(
|
|
259
|
-
const
|
|
260
|
-
let
|
|
261
|
-
if (
|
|
262
|
-
return [t,
|
|
263
|
-
if (
|
|
264
|
-
const m =
|
|
261
|
+
Object.entries(u.shape).map(([t, r]) => {
|
|
262
|
+
const c = o[t], l = s(r);
|
|
263
|
+
let n;
|
|
264
|
+
if (l instanceof T && (n = l._def.defaultValue()), c === null && l instanceof j)
|
|
265
|
+
return [t, c];
|
|
266
|
+
if (l instanceof F) {
|
|
267
|
+
const m = l.safeParse(o[t]);
|
|
265
268
|
if (m.success)
|
|
266
|
-
return [t, m.data ??
|
|
269
|
+
return [t, m.data ?? n];
|
|
267
270
|
}
|
|
268
|
-
return
|
|
271
|
+
return l instanceof L ? [
|
|
269
272
|
t,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
+
M(
|
|
274
|
+
l,
|
|
275
|
+
c && typeof c == "object" ? c : {}
|
|
273
276
|
)
|
|
274
|
-
] : [t,
|
|
277
|
+
] : [t, n];
|
|
275
278
|
})
|
|
276
279
|
)
|
|
277
280
|
};
|
|
278
|
-
},
|
|
279
|
-
const
|
|
281
|
+
}, ae = (e, o, s) => {
|
|
282
|
+
const u = g(), a = g(), t = g();
|
|
280
283
|
return {
|
|
281
|
-
errors:
|
|
284
|
+
errors: u,
|
|
282
285
|
status: a,
|
|
283
286
|
formData: t,
|
|
284
|
-
component:
|
|
287
|
+
component: E({
|
|
285
288
|
name: "FormComponent",
|
|
286
289
|
props: {
|
|
287
290
|
modelValue: {
|
|
@@ -295,50 +298,50 @@ const ne = (e, n, o, l = {}) => $({
|
|
|
295
298
|
},
|
|
296
299
|
emits: ["invalid", "valid", "submit", "update:modelValue"],
|
|
297
300
|
expose: ["submit", "errors", "status"],
|
|
298
|
-
setup(
|
|
299
|
-
t.value =
|
|
301
|
+
setup(r, { emit: c }) {
|
|
302
|
+
t.value = M(
|
|
300
303
|
e,
|
|
301
|
-
|
|
304
|
+
r.modelValue
|
|
302
305
|
);
|
|
303
|
-
const
|
|
306
|
+
const l = (s == null ? void 0 : s.continuosValidation) || r.continuosValidation;
|
|
304
307
|
y(
|
|
305
|
-
() =>
|
|
308
|
+
() => r.modelValue,
|
|
306
309
|
(v) => {
|
|
307
310
|
if (v) {
|
|
308
|
-
const d =
|
|
311
|
+
const d = Q(v) ? X(v) : v;
|
|
309
312
|
t.value = typeof (d == null ? void 0 : d.clone) == "function" ? d.clone() : JSON.parse(JSON.stringify(d));
|
|
310
313
|
}
|
|
311
314
|
},
|
|
312
315
|
{ deep: !0 }
|
|
313
|
-
),
|
|
316
|
+
), D(
|
|
314
317
|
t,
|
|
315
318
|
(v) => {
|
|
316
|
-
(
|
|
319
|
+
(u.value || l) && n(), (!v || !r.modelValue || JSON.stringify(v) !== JSON.stringify(r.modelValue)) && c("update:modelValue", v);
|
|
317
320
|
},
|
|
318
|
-
{ deep: !0, throttle: (
|
|
321
|
+
{ deep: !0, throttle: (s == null ? void 0 : s.updateThrottle) ?? 500 }
|
|
319
322
|
);
|
|
320
|
-
const
|
|
323
|
+
const n = (v = t.value) => {
|
|
321
324
|
const d = e.safeParse(v);
|
|
322
|
-
return d.success ? (
|
|
323
|
-
}, m = () =>
|
|
324
|
-
return
|
|
325
|
+
return d.success ? (u.value = void 0, a.value = "valid", t.value = d.data, c("update:modelValue", t.value), c("valid", d.data), !0) : (u.value = d.error.format(), a.value = "invalid", c("invalid", u.value), !1);
|
|
326
|
+
}, m = () => n() ? (c("submit", t.value), !0) : !1;
|
|
327
|
+
return $(o, {
|
|
325
328
|
modelValue: t,
|
|
326
329
|
submit: m,
|
|
327
|
-
errors: w(
|
|
330
|
+
errors: w(u)
|
|
328
331
|
}), { submit: m };
|
|
329
332
|
},
|
|
330
333
|
render() {
|
|
331
334
|
return x(
|
|
332
335
|
"form",
|
|
333
336
|
{
|
|
334
|
-
onSubmit:
|
|
337
|
+
onSubmit: Y(this.submit, ["prevent"])
|
|
335
338
|
},
|
|
336
339
|
this.$slots
|
|
337
340
|
);
|
|
338
341
|
}
|
|
339
342
|
})
|
|
340
343
|
};
|
|
341
|
-
},
|
|
344
|
+
}, se = (e, o) => E({
|
|
342
345
|
name: "WrapperComponent",
|
|
343
346
|
props: {
|
|
344
347
|
name: {
|
|
@@ -352,98 +355,104 @@ const ne = (e, n, o, l = {}) => $({
|
|
|
352
355
|
},
|
|
353
356
|
emits: ["invalid", "valid"],
|
|
354
357
|
expose: ["fields", "invalid"],
|
|
355
|
-
setup(
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
name: w(
|
|
359
|
-
errors:
|
|
360
|
-
fields:
|
|
358
|
+
setup(u, { emit: a }) {
|
|
359
|
+
const t = S(e), r = S(o, void 0), c = g(/* @__PURE__ */ new Set()), l = g(/* @__PURE__ */ new Map()), { name: n } = I(u);
|
|
360
|
+
$(o, {
|
|
361
|
+
name: w(n),
|
|
362
|
+
errors: l,
|
|
363
|
+
fields: c
|
|
361
364
|
}), y(
|
|
362
|
-
|
|
363
|
-
(
|
|
364
|
-
|
|
365
|
-
|
|
365
|
+
c,
|
|
366
|
+
(v) => {
|
|
367
|
+
r != null && r.fields && v.forEach((d) => {
|
|
368
|
+
r == null || r.fields.value.add(d);
|
|
366
369
|
});
|
|
367
370
|
},
|
|
368
371
|
{ deep: !0 }
|
|
369
372
|
), y(
|
|
370
|
-
() => new Map(
|
|
371
|
-
(
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}), Array.from(
|
|
375
|
-
const
|
|
376
|
-
|
|
373
|
+
() => new Map(l.value),
|
|
374
|
+
(v, d) => {
|
|
375
|
+
r != null && r.errors && (Array.from(d.keys()).forEach((h) => {
|
|
376
|
+
r.errors.value.delete(h);
|
|
377
|
+
}), Array.from(v.keys()).forEach((h) => {
|
|
378
|
+
const V = v.get(h);
|
|
379
|
+
V && r.errors.value.set(h, V);
|
|
377
380
|
}));
|
|
378
381
|
},
|
|
379
382
|
{ deep: !0 }
|
|
380
383
|
);
|
|
381
|
-
const
|
|
382
|
-
return y(
|
|
383
|
-
|
|
384
|
-
}), {
|
|
384
|
+
const m = b(() => t != null && t.errors.value ? l.value.size > 0 : !1);
|
|
385
|
+
return y(m, () => {
|
|
386
|
+
m.value ? a("invalid") : a("valid");
|
|
387
|
+
}), {
|
|
388
|
+
formData: t == null ? void 0 : t.modelValue,
|
|
389
|
+
errors: t == null ? void 0 : t.errors,
|
|
390
|
+
invalid: m,
|
|
391
|
+
fields: c,
|
|
392
|
+
fieldsErrors: l
|
|
393
|
+
};
|
|
385
394
|
},
|
|
386
395
|
render() {
|
|
387
|
-
var
|
|
396
|
+
var u, a, t, r;
|
|
388
397
|
return this.tag ? x(
|
|
389
398
|
this.tag,
|
|
390
399
|
null,
|
|
391
|
-
((
|
|
400
|
+
((a = (u = this.$slots).default) == null ? void 0 : a.call(u, {
|
|
392
401
|
invalid: this.invalid,
|
|
393
|
-
formData:
|
|
394
|
-
errors:
|
|
395
|
-
fieldsErrors: this.
|
|
402
|
+
formData: this.formData,
|
|
403
|
+
errors: this.errors,
|
|
404
|
+
fieldsErrors: this.fieldsErrors
|
|
396
405
|
})) ?? this.$slots.defalut
|
|
397
|
-
) : ((r = (
|
|
406
|
+
) : ((r = (t = this.$slots).default) == null ? void 0 : r.call(t, {
|
|
398
407
|
invalid: this.invalid,
|
|
399
|
-
formData:
|
|
400
|
-
errors:
|
|
401
|
-
fieldsErrors: this.
|
|
408
|
+
formData: this.formData,
|
|
409
|
+
errors: this.errors,
|
|
410
|
+
fieldsErrors: this.fieldsErrors
|
|
402
411
|
})) ?? this.$slots.defalut;
|
|
403
412
|
}
|
|
404
|
-
}),
|
|
405
|
-
const
|
|
413
|
+
}), P = (e, o = {}) => {
|
|
414
|
+
const s = Symbol(), u = Symbol(), a = Symbol(), {
|
|
406
415
|
component: t,
|
|
407
|
-
errors:
|
|
408
|
-
status:
|
|
409
|
-
formData:
|
|
410
|
-
} =
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
), m =
|
|
414
|
-
|
|
415
|
-
|
|
416
|
+
errors: r,
|
|
417
|
+
status: c,
|
|
418
|
+
formData: l
|
|
419
|
+
} = ae(e, s, o), n = se(
|
|
420
|
+
s,
|
|
421
|
+
u
|
|
422
|
+
), m = oe(
|
|
423
|
+
s,
|
|
424
|
+
u,
|
|
416
425
|
a,
|
|
417
|
-
|
|
426
|
+
o
|
|
418
427
|
);
|
|
419
428
|
return {
|
|
420
429
|
VvForm: t,
|
|
421
|
-
VvFormWrapper:
|
|
430
|
+
VvFormWrapper: n,
|
|
422
431
|
VvFormField: m,
|
|
423
|
-
formInjectionKey:
|
|
424
|
-
formWrapperInjectionKey:
|
|
432
|
+
formInjectionKey: s,
|
|
433
|
+
formWrapperInjectionKey: u,
|
|
425
434
|
formFieldInjectionKey: a,
|
|
426
|
-
errors:
|
|
427
|
-
status:
|
|
428
|
-
formData:
|
|
435
|
+
errors: r,
|
|
436
|
+
status: c,
|
|
437
|
+
formData: l
|
|
429
438
|
};
|
|
430
439
|
}, Z = Symbol(), fe = (e) => {
|
|
431
|
-
let
|
|
432
|
-
return e.schema && (
|
|
433
|
-
...
|
|
434
|
-
install(
|
|
435
|
-
|
|
440
|
+
let o = {};
|
|
441
|
+
return e.schema && (o = P(e.schema, e)), {
|
|
442
|
+
...o,
|
|
443
|
+
install(s, { global: u = !1 } = {}) {
|
|
444
|
+
s.provide(Z, e), u && (s.config.globalProperties.$vvForm = e, o != null && o.VvForm && s.component("VvForm", o.VvForm), o != null && o.VvFormWrapper && s.component("VvFormWrapper", o.VvFormWrapper), o != null && o.VvFormField && s.component("VvFormField", o.VvFormField));
|
|
436
445
|
}
|
|
437
446
|
};
|
|
438
|
-
}, de = (e,
|
|
439
|
-
const
|
|
440
|
-
return
|
|
447
|
+
}, de = (e, o = {}) => {
|
|
448
|
+
const s = { ...S(Z, {}), ...o };
|
|
449
|
+
return P(e, s);
|
|
441
450
|
};
|
|
442
451
|
export {
|
|
443
|
-
|
|
452
|
+
i as FormFieldType,
|
|
444
453
|
fe as createForm,
|
|
445
|
-
|
|
446
|
-
|
|
454
|
+
M as defaultObjectBySchema,
|
|
455
|
+
P as formFactory,
|
|
447
456
|
Z as pluginInjectionKey,
|
|
448
457
|
de as useForm
|
|
449
458
|
};
|