@volverjs/form-vue 0.0.14-beta.3 → 0.0.14

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