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