@volverjs/form-vue 0.0.10-beta.6 → 0.0.10-beta.7
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/README.md +232 -153
- package/dist/VvForm.d.ts +20 -1
- package/dist/VvFormField.d.ts +2 -2
- package/dist/index.d.ts +44 -6
- package/dist/index.es.js +207 -192
- package/dist/index.umd.js +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +11 -11
- package/src/VvForm.ts +9 -2
- package/src/VvFormField.ts +0 -1
- package/src/VvFormTemplate.ts +27 -9
- package/src/types.d.ts +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as W, computed as V, onMounted as X, onBeforeUnmount as Y, inject as O, toRefs as Z, watch as w, provide as _, readonly as k, resolveComponent as g, defineAsyncComponent as R, h as x, ref as E, isProxy as T, toRaw as j, withModifiers as F, unref as $ } from "vue";
|
|
2
2
|
import { watchThrottled as ee } from "@vueuse/core";
|
|
3
|
-
import { ZodObject as
|
|
3
|
+
import { ZodObject as z, ZodDefault as re, ZodNullable as te, ZodSchema as ne, ZodEffects as ae } from "zod";
|
|
4
4
|
function L(e) {
|
|
5
5
|
return Array.isArray(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function oe(e) {
|
|
8
8
|
return typeof e < "u";
|
|
9
9
|
}
|
|
10
10
|
function M(e) {
|
|
11
11
|
return e === null;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function J(e) {
|
|
14
14
|
return typeof e == "object";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function U(e) {
|
|
17
17
|
return typeof e == "string";
|
|
18
18
|
}
|
|
19
19
|
function C(e) {
|
|
20
20
|
return typeof e > "u";
|
|
21
21
|
}
|
|
22
22
|
const se = /^[0-9]+$/, ue = ["__proto__", "prototype", "constructor"];
|
|
23
|
-
function
|
|
24
|
-
const l =
|
|
25
|
-
if (!
|
|
23
|
+
function G(e, o, i) {
|
|
24
|
+
const l = oe(i) ? i : void 0;
|
|
25
|
+
if (!J(e) || !U(o))
|
|
26
26
|
return l;
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
for (const r of
|
|
27
|
+
const a = P(o);
|
|
28
|
+
if (a.length !== 0) {
|
|
29
|
+
for (const r of a) {
|
|
30
30
|
if (r === "*")
|
|
31
31
|
continue;
|
|
32
|
-
const
|
|
33
|
-
return
|
|
32
|
+
const u = function(n) {
|
|
33
|
+
return n.map((s) => C(s) || M(s) ? s : L(s) ? u(s) : s[r]);
|
|
34
34
|
};
|
|
35
|
-
if (L(e) && !se.test(r) ? e =
|
|
35
|
+
if (L(e) && !se.test(r) ? e = u(e) : e = e[r], C(e) || M(e))
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
return C(e) ? l : e;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
if (!
|
|
41
|
+
function q(e, o, i) {
|
|
42
|
+
if (!J(e) || !U(o))
|
|
43
43
|
return;
|
|
44
44
|
const l = P(o);
|
|
45
45
|
if (l.length === 0)
|
|
46
46
|
return;
|
|
47
|
-
const
|
|
48
|
-
for (let r = 0; r <
|
|
49
|
-
const
|
|
50
|
-
if (r ===
|
|
51
|
-
e[
|
|
47
|
+
const a = l.length;
|
|
48
|
+
for (let r = 0; r < a; r++) {
|
|
49
|
+
const u = l[r];
|
|
50
|
+
if (r === a - 1) {
|
|
51
|
+
e[u] = i;
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
const
|
|
56
|
-
for (const
|
|
57
|
-
|
|
54
|
+
if (u === "*" && L(e)) {
|
|
55
|
+
const n = l.slice(r + 1).join(".");
|
|
56
|
+
for (const s of e)
|
|
57
|
+
q(s, n, i);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
C(e[
|
|
60
|
+
C(e[u]) && (e[u] = {}), e = e[u];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
function P(e) {
|
|
64
64
|
const o = e.split(/[.]|(?:\[(\d|\*)\])/).filter((i) => !!i);
|
|
65
65
|
return o.some((i) => ue.indexOf(i) !== -1) ? [] : o;
|
|
66
66
|
}
|
|
67
|
-
var f = /* @__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))(f || {}),
|
|
68
|
-
const ie = (e, o, i, l = {}) =>
|
|
67
|
+
var f = /* @__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))(f || {}), N = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e))(N || {});
|
|
68
|
+
const ie = (e, o, i, l = {}) => W({
|
|
69
69
|
name: "FieldComponent",
|
|
70
70
|
props: {
|
|
71
71
|
type: {
|
|
72
72
|
type: String,
|
|
73
|
-
validator: (
|
|
73
|
+
validator: (a) => Object.values(f).includes(a),
|
|
74
74
|
default: f.custom
|
|
75
75
|
},
|
|
76
76
|
is: {
|
|
@@ -96,61 +96,61 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
96
96
|
},
|
|
97
97
|
emits: ["invalid", "valid", "update:formData", "update:modelValue"],
|
|
98
98
|
expose: ["invalid", "invalidLabel", "errors"],
|
|
99
|
-
setup(
|
|
100
|
-
const
|
|
99
|
+
setup(a, { slots: r, emit: u }) {
|
|
100
|
+
const n = V({
|
|
101
101
|
get() {
|
|
102
102
|
if (t != null && t.formData)
|
|
103
|
-
return
|
|
103
|
+
return G(
|
|
104
104
|
Object(t.formData.value),
|
|
105
|
-
String(
|
|
105
|
+
String(a.name)
|
|
106
106
|
);
|
|
107
107
|
},
|
|
108
108
|
set(c) {
|
|
109
|
-
t != null && t.formData && (
|
|
109
|
+
t != null && t.formData && (q(
|
|
110
110
|
Object(t.formData.value),
|
|
111
|
-
String(
|
|
111
|
+
String(a.name),
|
|
112
112
|
c
|
|
113
|
-
),
|
|
114
|
-
newValue:
|
|
113
|
+
), u("update:modelValue", {
|
|
114
|
+
newValue: n.value,
|
|
115
115
|
formData: t == null ? void 0 : t.formData
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}),
|
|
122
|
-
S(),
|
|
119
|
+
X(() => {
|
|
120
|
+
n.value === void 0 && a.defaultValue !== void 0 && (n.value = a.defaultValue);
|
|
121
|
+
}), Y(() => {
|
|
122
|
+
S(), y();
|
|
123
123
|
});
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const t = O(e), { props: m, name: p } =
|
|
124
|
+
const s = O(o, void 0);
|
|
125
|
+
s && s.fields.value.add(a.name);
|
|
126
|
+
const t = O(e), { props: m, name: p } = Z(a), h = V(() => {
|
|
127
127
|
if (t != null && t.errors.value)
|
|
128
|
-
return
|
|
129
|
-
}),
|
|
128
|
+
return G(t.errors.value, String(a.name));
|
|
129
|
+
}), d = V(() => {
|
|
130
130
|
var c;
|
|
131
131
|
return (c = h.value) == null ? void 0 : c._errors;
|
|
132
|
-
}),
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
}), v = V(() => h.value !== void 0), S = w(v, () => {
|
|
133
|
+
v.value ? (u("invalid", d.value), s && s.errors.value.set(
|
|
134
|
+
a.name,
|
|
135
135
|
{
|
|
136
|
-
_errors:
|
|
136
|
+
_errors: d.value
|
|
137
137
|
}
|
|
138
|
-
)) : (
|
|
139
|
-
|
|
138
|
+
)) : (u("valid", n.value), s && s.errors.value.delete(
|
|
139
|
+
a.name
|
|
140
140
|
));
|
|
141
|
-
}),
|
|
141
|
+
}), y = w(
|
|
142
142
|
() => t == null ? void 0 : t.formData,
|
|
143
143
|
() => {
|
|
144
|
-
|
|
144
|
+
u("update:formData", t == null ? void 0 : t.formData);
|
|
145
145
|
},
|
|
146
146
|
{ deep: !0 }
|
|
147
|
-
),
|
|
148
|
-
|
|
149
|
-
}, I = V(() => typeof m.value == "function" ? m.value(t == null ? void 0 : t.formData) : m.value),
|
|
147
|
+
), b = (c) => {
|
|
148
|
+
n.value = c;
|
|
149
|
+
}, I = V(() => typeof m.value == "function" ? m.value(t == null ? void 0 : t.formData) : m.value), A = V(() => ({
|
|
150
150
|
...I.value,
|
|
151
|
-
name: I.value.name ??
|
|
152
|
-
invalid:
|
|
153
|
-
valid:
|
|
151
|
+
name: I.value.name ?? a.name,
|
|
152
|
+
invalid: v.value,
|
|
153
|
+
valid: a.showValid ? !!(!v.value && n.value) : void 0,
|
|
154
154
|
type: ((c) => {
|
|
155
155
|
if ([
|
|
156
156
|
f.text,
|
|
@@ -168,25 +168,24 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
168
168
|
f.color
|
|
169
169
|
].includes(c))
|
|
170
170
|
return c;
|
|
171
|
-
})(
|
|
172
|
-
invalidLabel:
|
|
173
|
-
modelValue:
|
|
174
|
-
|
|
175
|
-
"onUpdate:modelValue": x
|
|
171
|
+
})(a.type),
|
|
172
|
+
invalidLabel: d.value,
|
|
173
|
+
modelValue: n.value,
|
|
174
|
+
"onUpdate:modelValue": b
|
|
176
175
|
}));
|
|
177
176
|
return _(i, {
|
|
178
|
-
name:
|
|
179
|
-
errors:
|
|
177
|
+
name: k(p),
|
|
178
|
+
errors: k(h)
|
|
180
179
|
}), { component: V(() => {
|
|
181
|
-
if (
|
|
180
|
+
if (a.type === f.custom)
|
|
182
181
|
return {
|
|
183
182
|
render() {
|
|
184
183
|
var c;
|
|
185
184
|
return ((c = r.default) == null ? void 0 : c.call(r, {
|
|
186
|
-
modelValue:
|
|
187
|
-
onUpdate:
|
|
188
|
-
invalid:
|
|
189
|
-
invalidLabel:
|
|
185
|
+
modelValue: n.value,
|
|
186
|
+
onUpdate: b,
|
|
187
|
+
invalid: v.value,
|
|
188
|
+
invalidLabel: d.value,
|
|
190
189
|
formData: t == null ? void 0 : t.formData.value,
|
|
191
190
|
formErrors: t == null ? void 0 : t.errors.value,
|
|
192
191
|
errors: h.value
|
|
@@ -195,30 +194,30 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
195
194
|
};
|
|
196
195
|
if (!l.lazyLoad) {
|
|
197
196
|
let c;
|
|
198
|
-
switch (
|
|
197
|
+
switch (a.type) {
|
|
199
198
|
case f.select:
|
|
200
|
-
c =
|
|
199
|
+
c = g("VvSelect");
|
|
201
200
|
break;
|
|
202
201
|
case f.checkbox:
|
|
203
|
-
c =
|
|
202
|
+
c = g("VvCheckbox");
|
|
204
203
|
break;
|
|
205
204
|
case f.radio:
|
|
206
|
-
c =
|
|
205
|
+
c = g("VvRadio");
|
|
207
206
|
break;
|
|
208
207
|
case f.textarea:
|
|
209
|
-
c =
|
|
208
|
+
c = g("VvTextarea");
|
|
210
209
|
break;
|
|
211
210
|
case f.radioGroup:
|
|
212
|
-
c =
|
|
211
|
+
c = g("VvRadioGroup");
|
|
213
212
|
break;
|
|
214
213
|
case f.checkboxGroup:
|
|
215
|
-
c =
|
|
214
|
+
c = g("VvCheckboxGroup");
|
|
216
215
|
break;
|
|
217
216
|
case f.combobox:
|
|
218
|
-
c =
|
|
217
|
+
c = g("VvCombobox");
|
|
219
218
|
break;
|
|
220
219
|
default:
|
|
221
|
-
c =
|
|
220
|
+
c = g("VvInputText");
|
|
222
221
|
}
|
|
223
222
|
if (typeof c != "string")
|
|
224
223
|
return c;
|
|
@@ -227,7 +226,7 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
227
226
|
);
|
|
228
227
|
}
|
|
229
228
|
return R(async () => {
|
|
230
|
-
switch (l.sideEffects && await Promise.resolve(l.sideEffects(
|
|
229
|
+
switch (l.sideEffects && await Promise.resolve(l.sideEffects(a.type)), a.type) {
|
|
231
230
|
case f.textarea:
|
|
232
231
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
233
232
|
case f.radio:
|
|
@@ -243,49 +242,53 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
243
242
|
}
|
|
244
243
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
245
244
|
});
|
|
246
|
-
}), hasProps:
|
|
245
|
+
}), hasProps: A, invalid: v };
|
|
247
246
|
},
|
|
248
247
|
render() {
|
|
249
|
-
return this.is ?
|
|
248
|
+
return this.is ? x(this.is, this.hasProps, this.$slots) : this.type === f.custom ? x(this.component, null, this.$slots) : x(this.component, this.hasProps, this.$slots);
|
|
250
249
|
}
|
|
251
|
-
}),
|
|
250
|
+
}), D = (e, o = {}) => {
|
|
252
251
|
const i = (r) => {
|
|
253
|
-
let
|
|
254
|
-
for (;
|
|
255
|
-
|
|
256
|
-
return
|
|
252
|
+
let u = r;
|
|
253
|
+
for (; u instanceof ae; )
|
|
254
|
+
u = u.innerType();
|
|
255
|
+
return u;
|
|
257
256
|
}, l = i(e);
|
|
258
257
|
return {
|
|
259
|
-
...(l instanceof
|
|
258
|
+
...(l instanceof z ? l._def.unknownKeys === "passthrough" : !1) ? o : {},
|
|
260
259
|
...Object.fromEntries(
|
|
261
|
-
Object.entries(l.shape).map(([r,
|
|
262
|
-
const
|
|
260
|
+
Object.entries(l.shape).map(([r, u]) => {
|
|
261
|
+
const n = o[r], s = i(u);
|
|
263
262
|
let t;
|
|
264
|
-
if (
|
|
265
|
-
return [r,
|
|
266
|
-
if (
|
|
267
|
-
const m =
|
|
263
|
+
if (s instanceof re && (t = s._def.defaultValue()), n === null && s instanceof te)
|
|
264
|
+
return [r, n];
|
|
265
|
+
if (s instanceof ne) {
|
|
266
|
+
const m = s.safeParse(o[r]);
|
|
268
267
|
if (m.success)
|
|
269
268
|
return [r, m.data ?? t];
|
|
270
269
|
}
|
|
271
|
-
return
|
|
270
|
+
return s instanceof z ? [
|
|
272
271
|
r,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
272
|
+
D(
|
|
273
|
+
s,
|
|
274
|
+
n && typeof n == "object" ? n : {}
|
|
276
275
|
)
|
|
277
276
|
] : [r, t];
|
|
278
277
|
})
|
|
279
278
|
)
|
|
280
279
|
};
|
|
281
280
|
}, le = (e, o, i) => {
|
|
282
|
-
const l = E(),
|
|
281
|
+
const l = E(), a = E(), r = E(), u = W({
|
|
283
282
|
name: "FormComponent",
|
|
284
283
|
props: {
|
|
285
284
|
modelValue: {
|
|
286
285
|
type: Object,
|
|
287
286
|
default: () => ({})
|
|
288
287
|
},
|
|
288
|
+
updateThrottle: {
|
|
289
|
+
type: Number,
|
|
290
|
+
default: 500
|
|
291
|
+
},
|
|
289
292
|
continuosValidation: {
|
|
290
293
|
type: Boolean,
|
|
291
294
|
default: !1
|
|
@@ -293,53 +296,56 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
293
296
|
},
|
|
294
297
|
emits: ["invalid", "valid", "submit", "update:modelValue"],
|
|
295
298
|
expose: ["submit", "errors", "status"],
|
|
296
|
-
setup(
|
|
297
|
-
r.value =
|
|
298
|
-
const t = (i == null ? void 0 : i.continuosValidation)
|
|
299
|
+
setup(n, { emit: s }) {
|
|
300
|
+
r.value = D(e, n.modelValue);
|
|
301
|
+
const t = (i == null ? void 0 : i.continuosValidation) ?? n.continuosValidation;
|
|
299
302
|
w(
|
|
300
|
-
() =>
|
|
301
|
-
(
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
r.value = typeof (
|
|
303
|
+
() => n.modelValue,
|
|
304
|
+
(d) => {
|
|
305
|
+
if (d) {
|
|
306
|
+
const v = T(d) ? j(d) : d;
|
|
307
|
+
r.value = typeof (v == null ? void 0 : v.clone) == "function" ? v.clone() : JSON.parse(JSON.stringify(v));
|
|
305
308
|
}
|
|
306
309
|
},
|
|
307
310
|
{ deep: !0 }
|
|
308
311
|
), ee(
|
|
309
312
|
r,
|
|
310
|
-
(
|
|
311
|
-
(l.value || t) && m(), (!
|
|
313
|
+
(d) => {
|
|
314
|
+
(l.value || t) && m(), (!d || !n.modelValue || JSON.stringify(d) !== JSON.stringify(n.modelValue)) && s("update:modelValue", d);
|
|
312
315
|
},
|
|
313
|
-
{
|
|
316
|
+
{
|
|
317
|
+
deep: !0,
|
|
318
|
+
throttle: (i == null ? void 0 : i.updateThrottle) ?? n.updateThrottle
|
|
319
|
+
}
|
|
314
320
|
);
|
|
315
|
-
const m = (
|
|
316
|
-
const
|
|
317
|
-
return
|
|
318
|
-
}, p = () => m() ? (
|
|
321
|
+
const m = (d = r.value) => {
|
|
322
|
+
const v = e.safeParse(d);
|
|
323
|
+
return v.success ? (l.value = void 0, a.value = N.valid, r.value = v.data, s("update:modelValue", r.value), s("valid", v.data), !0) : (l.value = v.error.format(), a.value = N.invalid, s("invalid", l.value), !1);
|
|
324
|
+
}, p = () => m() ? (s("submit", r.value), !0) : !1, h = V(() => a.value === N.invalid);
|
|
319
325
|
return _(o, {
|
|
320
326
|
formData: r,
|
|
321
327
|
submit: p,
|
|
322
|
-
errors:
|
|
323
|
-
status:
|
|
328
|
+
errors: k(l),
|
|
329
|
+
status: k(a),
|
|
324
330
|
invalid: h
|
|
325
331
|
}), {
|
|
326
332
|
formData: r,
|
|
327
333
|
submit: p,
|
|
328
|
-
errors:
|
|
329
|
-
status:
|
|
334
|
+
errors: k(l),
|
|
335
|
+
status: k(a),
|
|
330
336
|
invalid: h
|
|
331
337
|
};
|
|
332
338
|
},
|
|
333
339
|
render() {
|
|
334
|
-
return
|
|
340
|
+
return x(
|
|
335
341
|
"form",
|
|
336
342
|
{
|
|
337
343
|
onSubmit: F(this.submit, ["prevent"])
|
|
338
344
|
},
|
|
339
345
|
{
|
|
340
346
|
default: () => {
|
|
341
|
-
var
|
|
342
|
-
return ((
|
|
347
|
+
var n, s;
|
|
348
|
+
return ((s = (n = this.$slots) == null ? void 0 : n.default) == null ? void 0 : s.call(n, {
|
|
343
349
|
formData: this.formData,
|
|
344
350
|
submit: this.submit,
|
|
345
351
|
errors: this.errors,
|
|
@@ -353,14 +359,14 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
353
359
|
});
|
|
354
360
|
return {
|
|
355
361
|
errors: l,
|
|
356
|
-
status:
|
|
362
|
+
status: a,
|
|
357
363
|
formData: r,
|
|
358
364
|
/**
|
|
359
365
|
* An hack to add types to the default slot
|
|
360
366
|
*/
|
|
361
|
-
VvForm:
|
|
367
|
+
VvForm: u
|
|
362
368
|
};
|
|
363
|
-
}, fe = (e, o) =>
|
|
369
|
+
}, fe = (e, o) => W({
|
|
364
370
|
name: "WrapperComponent",
|
|
365
371
|
props: {
|
|
366
372
|
name: {
|
|
@@ -374,56 +380,56 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
374
380
|
},
|
|
375
381
|
emits: ["invalid", "valid"],
|
|
376
382
|
expose: ["fields", "invalid"],
|
|
377
|
-
setup(l, { emit:
|
|
378
|
-
const r = O(e),
|
|
383
|
+
setup(l, { emit: a }) {
|
|
384
|
+
const r = O(e), u = O(o, void 0), n = E(/* @__PURE__ */ new Set()), s = E(/* @__PURE__ */ new Map()), { name: t } = Z(l);
|
|
379
385
|
_(o, {
|
|
380
|
-
name:
|
|
381
|
-
errors:
|
|
382
|
-
fields:
|
|
386
|
+
name: k(t),
|
|
387
|
+
errors: s,
|
|
388
|
+
fields: n
|
|
383
389
|
}), w(
|
|
384
|
-
|
|
390
|
+
n,
|
|
385
391
|
(p) => {
|
|
386
|
-
|
|
387
|
-
|
|
392
|
+
u != null && u.fields && p.forEach((h) => {
|
|
393
|
+
u == null || u.fields.value.add(h);
|
|
388
394
|
});
|
|
389
395
|
},
|
|
390
396
|
{ deep: !0 }
|
|
391
397
|
), w(
|
|
392
|
-
() => new Map(
|
|
398
|
+
() => new Map(s.value),
|
|
393
399
|
(p, h) => {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}), Array.from(p.keys()).forEach((
|
|
397
|
-
const
|
|
398
|
-
|
|
400
|
+
u != null && u.errors && (Array.from(h.keys()).forEach((d) => {
|
|
401
|
+
u.errors.value.delete(d);
|
|
402
|
+
}), Array.from(p.keys()).forEach((d) => {
|
|
403
|
+
const v = p.get(d);
|
|
404
|
+
v && u.errors.value.set(d, v);
|
|
399
405
|
}));
|
|
400
406
|
},
|
|
401
407
|
{ deep: !0 }
|
|
402
408
|
);
|
|
403
|
-
const m = V(() => r != null && r.invalid.value ?
|
|
409
|
+
const m = V(() => r != null && r.invalid.value ? s.value.size > 0 : !1);
|
|
404
410
|
return w(m, () => {
|
|
405
|
-
m.value ?
|
|
411
|
+
m.value ? a("invalid") : a("valid");
|
|
406
412
|
}), {
|
|
407
413
|
formData: r == null ? void 0 : r.formData,
|
|
408
414
|
errors: r == null ? void 0 : r.errors,
|
|
409
415
|
invalid: m,
|
|
410
|
-
fields:
|
|
411
|
-
fieldsErrors:
|
|
416
|
+
fields: n,
|
|
417
|
+
fieldsErrors: s
|
|
412
418
|
};
|
|
413
419
|
},
|
|
414
420
|
render() {
|
|
415
|
-
var l,
|
|
416
|
-
return this.tag ?
|
|
421
|
+
var l, a;
|
|
422
|
+
return this.tag ? x(this.tag, null, {
|
|
417
423
|
default: () => {
|
|
418
|
-
var r,
|
|
419
|
-
return ((
|
|
424
|
+
var r, u;
|
|
425
|
+
return ((u = (r = this.$slots).default) == null ? void 0 : u.call(r, {
|
|
420
426
|
invalid: this.invalid,
|
|
421
427
|
formData: this.formData,
|
|
422
428
|
errors: this.errors,
|
|
423
429
|
fieldsErrors: this.fieldsErrors
|
|
424
430
|
})) ?? this.$slots.defalut;
|
|
425
431
|
}
|
|
426
|
-
}) : ((
|
|
432
|
+
}) : ((a = (l = this.$slots).default) == null ? void 0 : a.call(l, {
|
|
427
433
|
invalid: this.invalid,
|
|
428
434
|
formData: this.formData,
|
|
429
435
|
errors: this.errors,
|
|
@@ -431,66 +437,75 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
431
437
|
})) ?? this.$slots.defalut;
|
|
432
438
|
}
|
|
433
439
|
}), ce = (e, o) => {
|
|
434
|
-
const i =
|
|
440
|
+
const i = W({
|
|
435
441
|
props: {
|
|
436
442
|
schema: {
|
|
437
443
|
type: [Array, Function],
|
|
438
444
|
required: !0
|
|
439
445
|
}
|
|
440
446
|
},
|
|
441
|
-
setup(l, { slots:
|
|
442
|
-
const r = O(e)
|
|
443
|
-
|
|
447
|
+
setup(l, { slots: a }) {
|
|
448
|
+
const r = O(e);
|
|
449
|
+
if (!(r != null && r.formData))
|
|
450
|
+
return;
|
|
451
|
+
const u = typeof l.schema == "function" ? l.schema(r) : l.schema;
|
|
452
|
+
let n;
|
|
444
453
|
return () => {
|
|
445
|
-
var
|
|
446
|
-
return
|
|
454
|
+
var s;
|
|
455
|
+
return u.reduce(
|
|
447
456
|
(t, m) => {
|
|
448
457
|
const p = typeof m == "function" ? m(r) : m, {
|
|
449
458
|
vvIs: h,
|
|
450
|
-
vvName:
|
|
451
|
-
vvSlots:
|
|
459
|
+
vvName: d,
|
|
460
|
+
vvSlots: v,
|
|
452
461
|
vvChildren: S,
|
|
453
|
-
vvIf:
|
|
454
|
-
vvElseIf:
|
|
462
|
+
vvIf: y,
|
|
463
|
+
vvElseIf: b,
|
|
455
464
|
vvType: I,
|
|
456
|
-
vvDefaultValue:
|
|
457
|
-
vvShowValid:
|
|
465
|
+
vvDefaultValue: A,
|
|
466
|
+
vvShowValid: K,
|
|
458
467
|
...c
|
|
459
468
|
} = p;
|
|
460
|
-
if (
|
|
461
|
-
if (
|
|
469
|
+
if (y !== void 0) {
|
|
470
|
+
if (typeof y == "string" ? n = !!G(
|
|
471
|
+
Object(r.formData.value),
|
|
472
|
+
y
|
|
473
|
+
) : typeof y == "function" ? n = $(y(r)) : n = $(y), !n)
|
|
462
474
|
return t;
|
|
463
|
-
} else if (
|
|
464
|
-
if (
|
|
475
|
+
} else if (b !== void 0 && n !== void 0) {
|
|
476
|
+
if (n || (typeof b == "string" ? n = !!G(
|
|
477
|
+
Object(r.formData.value),
|
|
478
|
+
b
|
|
479
|
+
) : typeof b == "function" ? n = $(b(r)) : n = $(b), !n))
|
|
465
480
|
return t;
|
|
466
481
|
} else
|
|
467
|
-
|
|
468
|
-
const
|
|
482
|
+
n = void 0;
|
|
483
|
+
const B = S ? x(i, {
|
|
469
484
|
schema: S
|
|
470
485
|
}) : void 0;
|
|
471
|
-
return
|
|
472
|
-
|
|
486
|
+
return d ? (t.push(
|
|
487
|
+
x(
|
|
473
488
|
o,
|
|
474
489
|
{
|
|
475
|
-
name:
|
|
490
|
+
name: d,
|
|
476
491
|
is: h,
|
|
477
492
|
type: I,
|
|
478
|
-
defaultValue:
|
|
479
|
-
showValid:
|
|
493
|
+
defaultValue: A,
|
|
494
|
+
showValid: K,
|
|
480
495
|
props: c
|
|
481
496
|
},
|
|
482
|
-
|
|
497
|
+
v ?? B
|
|
483
498
|
)
|
|
484
499
|
), t) : h ? (t.push(
|
|
485
|
-
|
|
500
|
+
x(
|
|
486
501
|
h,
|
|
487
502
|
c,
|
|
488
|
-
|
|
503
|
+
v ?? B
|
|
489
504
|
)
|
|
490
|
-
), t) : (S && t.push(
|
|
505
|
+
), t) : (S && t.push(B), t);
|
|
491
506
|
},
|
|
492
507
|
[
|
|
493
|
-
(
|
|
508
|
+
(s = a == null ? void 0 : a.default) == null ? void 0 : s.call(a, {
|
|
494
509
|
formData: r == null ? void 0 : r.formData.value,
|
|
495
510
|
submit: r == null ? void 0 : r.submit,
|
|
496
511
|
errors: r == null ? void 0 : r.errors.value,
|
|
@@ -503,8 +518,8 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
503
518
|
}
|
|
504
519
|
});
|
|
505
520
|
return i;
|
|
506
|
-
},
|
|
507
|
-
const i = Symbol(), l = Symbol(),
|
|
521
|
+
}, H = (e, o = {}) => {
|
|
522
|
+
const i = Symbol(), l = Symbol(), a = Symbol(), { VvForm: r, errors: u, status: n, formData: s } = le(
|
|
508
523
|
e,
|
|
509
524
|
i,
|
|
510
525
|
o
|
|
@@ -514,7 +529,7 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
514
529
|
), m = ie(
|
|
515
530
|
i,
|
|
516
531
|
l,
|
|
517
|
-
|
|
532
|
+
a,
|
|
518
533
|
o
|
|
519
534
|
), p = ce(i, m);
|
|
520
535
|
return {
|
|
@@ -524,28 +539,28 @@ const ie = (e, o, i, l = {}) => N({
|
|
|
524
539
|
VvFormTemplate: p,
|
|
525
540
|
formInjectionKey: i,
|
|
526
541
|
formWrapperInjectionKey: l,
|
|
527
|
-
formFieldInjectionKey:
|
|
528
|
-
errors:
|
|
529
|
-
status:
|
|
530
|
-
formData:
|
|
542
|
+
formFieldInjectionKey: a,
|
|
543
|
+
errors: u,
|
|
544
|
+
status: n,
|
|
545
|
+
formData: s
|
|
531
546
|
};
|
|
532
|
-
},
|
|
547
|
+
}, Q = Symbol(), he = (e) => {
|
|
533
548
|
let o = {};
|
|
534
|
-
return e.schema && (o =
|
|
549
|
+
return e.schema && (o = H(e.schema, e)), {
|
|
535
550
|
...o,
|
|
536
551
|
install(i, { global: l = !1 } = {}) {
|
|
537
|
-
i.provide(
|
|
552
|
+
i.provide(Q, e), l && (i.config.globalProperties.$vvForm = e, o != null && o.VvForm && i.component("VvForm", o.VvForm), o != null && o.VvFormWrapper && i.component("VvFormWrapper", o.VvFormWrapper), o != null && o.VvFormField && i.component("VvFormField", o.VvFormField), o != null && o.VvFormTemplate && i.component("VvFormTemplate", o.VvFormTemplate));
|
|
538
553
|
}
|
|
539
554
|
};
|
|
540
555
|
}, pe = (e, o = {}) => {
|
|
541
|
-
const i = { ...O(
|
|
542
|
-
return
|
|
556
|
+
const i = { ...O(Q, {}), ...o };
|
|
557
|
+
return H(e, i);
|
|
543
558
|
};
|
|
544
559
|
export {
|
|
545
560
|
f as FormFieldType,
|
|
546
561
|
he as createForm,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
562
|
+
D as defaultObjectBySchema,
|
|
563
|
+
H as formFactory,
|
|
564
|
+
Q as pluginInjectionKey,
|
|
550
565
|
pe as useForm
|
|
551
566
|
};
|