@volverjs/form-vue 1.1.0-beta.5 → 1.1.0

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,102 +1,107 @@
1
- import { ref as B, computed as O, readonly as F, defineComponent as U, h as z, withModifiers as re, toRaw as N, watch as Z, isProxy as me, onMounted as H, provide as Q, toRefs as Y, useId as ae, inject as G, onBeforeUnmount as L, unref as W, resolveComponent as $, defineAsyncComponent as pe, getCurrentInstance as ye } from "vue";
2
- import { watchIgnorable as he, throttleFilter as be } from "@vueuse/core";
3
- import { ZodError as je } from "zod/v3";
4
- import { safeParse as Ve, safeParseAsync as ge, formatError as ne, $ZodError as we } from "zod/v4/core";
5
- import { set as oe, get as P } from "ts-dot-prop";
1
+ import { ref as B, computed as D, readonly as F, defineComponent as U, h as E, withModifiers as re, toRaw as N, watch as z, isProxy as ce, onMounted as H, provide as Q, toRefs as Y, useId as ae, inject as G, onBeforeUnmount as L, unref as P, resolveComponent as $, defineAsyncComponent as me, getCurrentInstance as pe } from "vue";
2
+ import { watchIgnorable as ye, throttleFilter as he } from "@vueuse/core";
3
+ import { ZodError as be } from "zod/v3";
4
+ import { safeParse as je, safeParseAsync as Ve, formatError as ne, $ZodError as ge } from "zod/v4/core";
5
+ import { set as oe, get as W } from "ts-dot-prop";
6
6
  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 || {}), S = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(S || {});
7
- const K = (e) => e._def.typeName === "ZodObject", T = (e) => e._zod.def.type === "object", De = (e) => e._def.typeName === "ZodDefault", Oe = (e) => e._zod.def.type === "default", _e = (e) => e._def.typeName === "ZodNullable", Re = (e) => e._zod.def.type === "nullable", Se = (e) => e._def.typeName === "ZodRecord", Ie = (e) => e._zod.def.type === "record", ze = (e) => e._def.typeName === "ZodArray", Ee = (e) => e._zod.def.type === "array", le = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", ie = (e) => e._zod.def.type === "optional", se = (e) => e._zod.def.type === "pipe", de = (e) => e._zod.def.type === "transform", C = (e) => {
7
+ const K = (e) => e._def.typeName === "ZodObject", C = (e) => e._zod.def.type === "object", Oe = (e) => e._def.typeName === "ZodDefault", we = (e) => e._zod.def.type === "default", De = (e) => e._def.typeName === "ZodNullable", _e = (e) => e._zod.def.type === "nullable", Re = (e) => e._def.typeName === "ZodRecord", Se = (e) => e._zod.def.type === "record", Ie = (e) => e._def.typeName === "ZodArray", Ee = (e) => e._zod.def.type === "array", Ze = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", le = (e) => e._zod.def.type === "optional", xe = (e) => e._zod.def.type === "pipe", ze = (e) => e._zod.def.type === "transform";
8
+ function se(e) {
8
9
  let t = e;
9
- for (; le(t); )
10
+ for (; Ze(t); )
10
11
  t = t.innerType();
12
+ return t;
13
+ }
14
+ function ie(e) {
15
+ let t = e;
16
+ for (; xe(t); )
17
+ ze(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
18
+ return t;
19
+ }
20
+ const T = (e) => {
21
+ let t = se(e);
11
22
  return ue(t) && (t = t._def.innerType), t;
12
23
  }, M = (e) => {
13
- let t = e;
14
- for (; se(t); )
15
- de(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
16
- return ie(t) && (t = t._zod.def.innerType), t;
17
- }, xe = (e) => {
18
- let t = e;
19
- for (; le(t); )
20
- t = t.innerType();
24
+ let t = ie(e);
25
+ return le(t) && (t = t._zod.def.innerType), t;
26
+ }, Fe = (e) => {
27
+ const t = se(e);
21
28
  return !!ue(t);
22
- }, Ze = (e) => {
23
- let t = e;
24
- for (; se(t); )
25
- de(t._zod.def.out) ? t = t._zod.def.in : t = t._zod.def.out;
26
- return !!ie(t);
29
+ }, Ae = (e) => {
30
+ const t = ie(e);
31
+ return !!le(t);
27
32
  }, X = (e) => "_zod" in e;
28
33
  function k(e, t = {}) {
29
34
  if (X(e)) {
30
35
  const a = M(e);
31
- return T(a) ? {
32
- ...!(!a._zod.def.catchall || a._zod.def.catchall?._zod.def.type === "never") ? t : {},
36
+ return C(a) ? {
37
+ ...a._zod.def.catchall && a._zod.def.catchall._zod.def.type !== "never" ? t : {},
33
38
  ...Object.fromEntries(
34
39
  ("shape" in a._zod.def ? Object.entries(a._zod.def.shape) : []).map(
35
- ([l, f]) => {
36
- const r = t[l], v = Ze(f);
40
+ ([u, f]) => {
41
+ const r = t[u], v = Ae(f);
37
42
  let o = M(f), d;
38
- if (Oe(o) && (d = o._zod.def.defaultValue, o = o._zod.def.innerType), r === null && Re(o))
39
- return [l, r];
43
+ if (we(o) && (d = o._zod.def.defaultValue, o = o._zod.def.innerType), r === null && _e(o))
44
+ return [u, r];
40
45
  if (r == null && v)
41
- return [l, d];
46
+ return [u, d];
42
47
  if (o) {
43
- const c = Ve(f, r);
48
+ const c = je(f, r);
44
49
  if (c.success)
45
- return [l, c.data ?? d];
50
+ return [u, c.data ?? d];
46
51
  }
47
52
  if (Ee(o) && Array.isArray(r) && r.length) {
48
53
  const c = M(o._zod.def.element);
49
- if (T(c))
54
+ if (C(c))
50
55
  return [
51
- l,
56
+ u,
52
57
  r.map(
53
- (D) => k(
58
+ (w) => k(
54
59
  c,
55
- D && typeof D == "object" ? D : void 0
60
+ w && typeof w == "object" ? w : void 0
56
61
  )
57
62
  )
58
63
  ];
59
64
  }
60
- if (Ie(o) && r) {
65
+ if (Se(o) && r) {
61
66
  const c = M(o._zod.def.valueType);
62
- if (T(c))
63
- return [l, Object.keys(r).reduce((D, p) => (D[p] = k(c, r[p]), D), {})];
67
+ if (C(c))
68
+ return [u, Object.keys(r).reduce((w, p) => (w[p] = k(c, r[p]), w), {})];
64
69
  }
65
- return T(o) ? [
66
- l,
70
+ return C(o) ? [
71
+ u,
67
72
  k(
68
73
  o,
69
74
  r && typeof r == "object" ? r : d
70
75
  )
71
- ] : [l, d];
76
+ ] : [u, d];
72
77
  }
73
78
  )
74
79
  )
75
80
  } : t;
76
81
  }
77
- const u = C(e);
78
- return K(u) ? {
79
- ...u._def.unknownKeys === "passthrough" ? t : {},
82
+ const l = T(e);
83
+ return K(l) ? {
84
+ ...l._def.unknownKeys === "passthrough" ? t : {},
80
85
  ...Object.fromEntries(
81
- ("shape" in u ? Object.entries(u.shape) : []).map(
82
- ([a, s]) => {
83
- const l = t[a], f = xe(s);
84
- let r = C(s), v;
85
- if (De(r) && (v = r._def.defaultValue(), r = r._def.innerType), l === null && _e(r))
86
- return [a, l];
87
- if (l == null && f)
86
+ ("shape" in l ? Object.entries(l.shape) : []).map(
87
+ ([a, i]) => {
88
+ const u = t[a], f = Fe(i);
89
+ let r = T(i), v;
90
+ if (Oe(r) && (v = r._def.defaultValue(), r = r._def.innerType), u === null && De(r))
91
+ return [a, u];
92
+ if (u == null && f)
88
93
  return [a, v];
89
94
  if (r) {
90
- const o = s.safeParse(l);
95
+ const o = i.safeParse(u);
91
96
  if (o.success)
92
97
  return [a, o.data ?? v];
93
98
  }
94
- if (ze(r) && Array.isArray(l) && l.length) {
95
- const o = C(r._def.type);
99
+ if (Ie(r) && Array.isArray(u) && u.length) {
100
+ const o = T(r._def.type);
96
101
  if (K(o))
97
102
  return [
98
103
  a,
99
- l.map(
104
+ u.map(
100
105
  (d) => k(
101
106
  o,
102
107
  d && typeof d == "object" ? d : void 0
@@ -104,16 +109,16 @@ function k(e, t = {}) {
104
109
  )
105
110
  ];
106
111
  }
107
- if (Se(r) && l) {
108
- const o = C(r._def.valueType);
112
+ if (Re(r) && u) {
113
+ const o = T(r._def.valueType);
109
114
  if (K(o))
110
- return [a, Object.keys(l).reduce((d, c) => (d[c] = k(o, l[c]), d), {})];
115
+ return [a, Object.keys(u).reduce((d, c) => (d[c] = k(o, u[c]), d), {})];
111
116
  }
112
117
  return K(r) ? [
113
118
  a,
114
119
  k(
115
120
  r,
116
- l && typeof l == "object" ? l : v
121
+ u && typeof u == "object" ? u : v
117
122
  )
118
123
  ] : [a, v];
119
124
  }
@@ -121,44 +126,44 @@ function k(e, t = {}) {
121
126
  )
122
127
  } : t;
123
128
  }
124
- const Fe = (e, t) => X(e) ? ge(e, t) : e.safeParseAsync(t), Ae = (e, t) => X(e) ? ne(t) : t.format(), Ne = (e, t) => X(e) ? ne(new we(t)) : new je(t).format();
125
- function $e(e, t, u, g, a) {
126
- const s = B(), l = B(), f = O(() => l.value === S.invalid), r = B(), v = B(!1);
129
+ const Ne = (e, t) => X(e) ? Ve(e, t) : e.safeParseAsync(t), $e = (e, t) => X(e) ? ne(t) : t.format(), Ge = (e, t) => X(e) ? ne(new ge(t)) : new be(t).format();
130
+ function ke(e, t, l, g, a) {
131
+ const i = B(), u = B(), f = D(() => u.value === S.invalid), r = B(), v = B(!1);
127
132
  let o;
128
- const d = (w) => {
129
- const _ = k(e, w);
130
- if (u?.class) {
131
- const n = u.class;
133
+ const d = (O) => {
134
+ const _ = k(e, O);
135
+ if (l?.class) {
136
+ const n = l.class;
132
137
  return new n(_);
133
138
  }
134
139
  return _;
135
- }, c = async (w = r.value, _) => {
140
+ }, c = async (O = r.value, _) => {
136
141
  if (o = _?.fields, v.value)
137
142
  return !0;
138
- const n = await Fe(e, w);
143
+ const n = await Ne(e, O);
139
144
  if (!n.success) {
140
- if (l.value = S.invalid, !o?.size)
141
- return s.value = Ae(e, n.error), !1;
145
+ if (u.value = S.invalid, !o?.size)
146
+ return i.value = $e(e, n.error), !1;
142
147
  const j = n.error.issues.filter(
143
148
  (A) => o?.has(A.path.join("."))
144
149
  );
145
- return j.length ? (s.value = Ne(e, j), !1) : (s.value = void 0, !0);
150
+ return j.length ? (i.value = Ge(e, j), !1) : (i.value = void 0, !0);
146
151
  }
147
- return s.value = void 0, l.value = S.valid, r.value = d(n.data), !0;
148
- }, D = () => {
149
- s.value = void 0, l.value = void 0, o = void 0;
152
+ return i.value = void 0, u.value = S.valid, r.value = d(n.data), !0;
153
+ }, w = () => {
154
+ i.value = void 0, u.value = void 0, o = void 0;
150
155
  }, p = () => {
151
- r.value = d(), D(), l.value = S.reset;
152
- }, m = async (w) => v.value || !await c(void 0, w) ? !1 : (l.value = S.submitting, !0), { ignoreUpdates: y, stop: b } = he(
156
+ r.value = d(), w(), u.value = S.reset;
157
+ }, m = async (O) => v.value || !await c(void 0, O) ? !1 : (u.value = S.submitting, !0), { ignoreUpdates: y, stop: b } = ye(
153
158
  r,
154
159
  () => {
155
- l.value = S.updated;
160
+ u.value = S.updated;
156
161
  },
157
162
  {
158
163
  deep: !0,
159
- eventFilter: be(u?.updateThrottle ?? 500)
164
+ eventFilter: he(l?.updateThrottle ?? 500)
160
165
  }
161
- ), I = F(s), R = F(l), E = U({
166
+ ), I = F(i), R = F(u), Z = U({
162
167
  name: "VvForm",
163
168
  props: {
164
169
  continuousValidation: {
@@ -171,7 +176,7 @@ function $e(e, t, u, g, a) {
171
176
  },
172
177
  readonly: {
173
178
  type: Boolean,
174
- default: u?.readonly
179
+ default: l?.readonly
175
180
  },
176
181
  tag: {
177
182
  type: String,
@@ -212,62 +217,62 @@ function $e(e, t, u, g, a) {
212
217
  "reset"
213
218
  ],
214
219
  slots: Object,
215
- setup(w, { emit: _ }) {
216
- return r.value = d(N(w.modelValue)), Z(
217
- () => w.modelValue,
220
+ setup(O, { emit: _ }) {
221
+ return r.value = d(N(O.modelValue)), z(
222
+ () => O.modelValue,
218
223
  (n) => {
219
224
  if (n) {
220
- const j = me(n) ? N(n) : n;
225
+ const j = ce(n) ? N(n) : n;
221
226
  if (JSON.stringify(j) === JSON.stringify(N(r.value)))
222
227
  return;
223
228
  r.value = typeof j?.clone == "function" ? j.clone() : JSON.parse(JSON.stringify(j));
224
229
  }
225
230
  },
226
231
  { deep: !0 }
227
- ), Z(l, async (n) => {
232
+ ), z(u, async (n) => {
228
233
  if (n === S.invalid) {
229
- const j = N(s.value);
230
- _("invalid", j), u?.onInvalid?.(
234
+ const j = N(i.value);
235
+ _("invalid", j), l?.onInvalid?.(
231
236
  j
232
237
  );
233
238
  return;
234
239
  }
235
240
  if (n === S.valid) {
236
241
  const j = N(r.value);
237
- _("valid", j), u?.onValid?.(j), _("update:modelValue", j), u?.onUpdate?.(j);
242
+ _("valid", j), l?.onValid?.(j), _("update:modelValue", j), l?.onUpdate?.(j);
238
243
  return;
239
244
  }
240
245
  if (n === S.submitting) {
241
246
  const j = N(r.value);
242
- _("submit", j), u?.onSubmit?.(j);
247
+ _("submit", j), l?.onSubmit?.(j);
243
248
  return;
244
249
  }
245
250
  if (n === S.reset) {
246
251
  const j = N(r.value);
247
- _("reset", j), u?.onReset?.(j);
252
+ _("reset", j), l?.onReset?.(j);
248
253
  return;
249
254
  }
250
255
  if (n === S.updated) {
251
- if ((s.value || u?.continuousValidation || w.continuousValidation) && await c(void 0, {
252
- superRefine: w.superRefine,
253
- fields: o ?? new Set(w.validateFields)
254
- }), !r.value || !w.modelValue || JSON.stringify(r.value) !== JSON.stringify(w.modelValue)) {
256
+ if ((i.value || l?.continuousValidation || O.continuousValidation) && await c(void 0, {
257
+ superRefine: O.superRefine,
258
+ fields: o ?? new Set(O.validateFields)
259
+ }), !r.value || !O.modelValue || JSON.stringify(r.value) !== JSON.stringify(O.modelValue)) {
255
260
  const j = N(r.value);
256
- _("update:modelValue", j), u?.onUpdate?.(j);
261
+ _("update:modelValue", j), l?.onUpdate?.(j);
257
262
  }
258
- l.value === S.updated && (l.value = S.unknown);
263
+ u.value === S.updated && (u.value = S.unknown);
259
264
  }
260
265
  }), H(() => {
261
- w.readonly !== void 0 && (v.value = w.readonly);
262
- }), Z(
263
- () => w.readonly,
266
+ O.readonly !== void 0 && (v.value = O.readonly);
267
+ }), z(
268
+ () => O.readonly,
264
269
  (n) => {
265
270
  v.value = n;
266
271
  }
267
- ), Z(v, (n) => {
268
- n !== w.readonly && _("update:readonly", v.value);
272
+ ), z(v, (n) => {
273
+ n !== O.readonly && _("update:readonly", v.value);
269
274
  }), Q(t, {
270
- clear: D,
275
+ clear: w,
271
276
  errors: I,
272
277
  formData: r,
273
278
  ignoreUpdates: y,
@@ -280,7 +285,7 @@ function $e(e, t, u, g, a) {
280
285
  validate: c,
281
286
  wrappers: a
282
287
  }), {
283
- clear: D,
288
+ clear: w,
284
289
  errors: I,
285
290
  formData: r,
286
291
  ignoreUpdates: y,
@@ -290,67 +295,67 @@ function $e(e, t, u, g, a) {
290
295
  status: R,
291
296
  stopUpdatesWatch: b,
292
297
  submit: () => m({
293
- superRefine: w.superRefine,
294
- fields: new Set(w.validateFields)
298
+ superRefine: O.superRefine,
299
+ fields: new Set(O.validateFields)
295
300
  }),
296
301
  validate: c,
297
302
  wrappers: a
298
303
  };
299
304
  },
300
305
  render() {
301
- const w = () => this.$slots?.default?.({
306
+ const O = () => this.$slots?.default?.({
302
307
  errors: I.value,
303
308
  formData: r.value,
304
309
  invalid: f.value,
305
310
  readonly: v.value,
306
311
  status: R.value,
307
312
  wrappers: a,
308
- clear: D,
313
+ clear: w,
309
314
  ignoreUpdates: y,
310
315
  reset: p,
311
316
  stopUpdatesWatch: b,
312
317
  submit: m,
313
318
  validate: c
314
319
  }) ?? this.$slots.default;
315
- return z(
320
+ return E(
316
321
  this.tag,
317
322
  {
318
323
  onSubmit: re(this.submit, ["prevent"]),
319
324
  onReset: re(this.reset, ["prevent"])
320
325
  },
321
- (this.template ?? u?.template) && g ? [
322
- z(
326
+ (this.template ?? l?.template) && g ? [
327
+ E(
323
328
  g,
324
329
  {
325
- schema: this.template ?? u?.template
330
+ schema: this.template ?? l?.template
326
331
  },
327
332
  {
328
- default: w
333
+ default: O
329
334
  }
330
335
  )
331
336
  ] : {
332
- default: w
337
+ default: O
333
338
  }
334
339
  );
335
340
  }
336
341
  });
337
342
  return {
338
- clear: D,
339
- errors: s,
343
+ clear: w,
344
+ errors: i,
340
345
  formData: r,
341
346
  ignoreUpdates: y,
342
347
  invalid: f,
343
348
  readonly: v,
344
349
  reset: p,
345
- status: l,
350
+ status: u,
346
351
  wrappers: a,
347
352
  stopUpdatesWatch: b,
348
353
  submit: m,
349
354
  validate: c,
350
- VvForm: E
355
+ VvForm: Z
351
356
  };
352
357
  }
353
- function Ge(e, t, u, g) {
358
+ function Be(e, t, l, g) {
354
359
  return U({
355
360
  name: "VvFormField",
356
361
  props: {
@@ -404,13 +409,13 @@ function Ge(e, t, u, g) {
404
409
  "type"
405
410
  ],
406
411
  slots: Object,
407
- setup(a, { slots: s, emit: l }) {
412
+ setup(a, { slots: i, emit: u }) {
408
413
  const { props: f, name: r } = Y(a), v = ae(), o = G(t, void 0);
409
414
  o && o.fields.value.set(v, a.name);
410
- const d = G(e), c = O({
415
+ const d = G(e), c = D({
411
416
  get() {
412
417
  if (d?.formData)
413
- return P(
418
+ return W(
414
419
  new Object(d.formData.value),
415
420
  String(a.name)
416
421
  );
@@ -420,7 +425,7 @@ function Ge(e, t, u, g) {
420
425
  new Object(d.formData.value),
421
426
  String(a.name),
422
427
  n
423
- ), l("update:modelValue", {
428
+ ), u("update:modelValue", {
424
429
  newValue: c.value,
425
430
  formData: d?.formData
426
431
  }));
@@ -431,24 +436,24 @@ function Ge(e, t, u, g) {
431
436
  }), L(() => {
432
437
  o && o.fields.value.delete(v);
433
438
  });
434
- const D = O(() => {
439
+ const w = D(() => {
435
440
  if (d?.errors.value)
436
- return P(d.errors.value, String(a.name));
437
- }), p = O(() => D.value?._errors), m = O(() => D.value !== void 0), y = Z(m, (n) => {
441
+ return W(d.errors.value, String(a.name));
442
+ }), p = D(() => w.value?._errors), m = D(() => w.value !== void 0), y = z(m, (n) => {
438
443
  if (n) {
439
- l("invalid", D.value), o && o.errors.value.set(
444
+ u("invalid", w.value), o && o.errors.value.set(
440
445
  String(a.name),
441
- D.value
446
+ w.value
442
447
  );
443
448
  return;
444
449
  }
445
- l("valid", c.value), o && o.errors.value.delete(
450
+ u("valid", c.value), o && o.errors.value.delete(
446
451
  a.name
447
452
  );
448
- }), b = Z(
453
+ }), b = z(
449
454
  () => d?.formData,
450
455
  () => {
451
- l("update:formData", d?.formData);
456
+ u("update:formData", d?.formData);
452
457
  },
453
458
  { deep: !0 }
454
459
  );
@@ -457,13 +462,13 @@ function Ge(e, t, u, g) {
457
462
  });
458
463
  const I = (n) => {
459
464
  n instanceof InputEvent && (n = n.target.value), c.value = n;
460
- }, R = O(() => {
465
+ }, R = D(() => {
461
466
  let n = f.value;
462
467
  return typeof n == "function" && (n = n(d?.formData)), Object.keys(n).reduce(
463
- (j, A) => (j[A] = W(n[A]), j),
468
+ (j, A) => (j[A] = P(n[A]), j),
464
469
  {}
465
470
  );
466
- }), E = O(() => d?.readonly.value || o?.readonly.value ? !0 : R.value.readonly ?? a.readonly), w = O(() => ({
471
+ }), Z = D(() => d?.readonly.value || o?.readonly.value ? !0 : R.value.readonly ?? a.readonly), O = D(() => ({
467
472
  ...R.value,
468
473
  name: R.value.name ?? a.name,
469
474
  invalid: m.value,
@@ -488,28 +493,28 @@ function Ge(e, t, u, g) {
488
493
  })(a.type),
489
494
  invalidLabel: p.value,
490
495
  modelValue: c.value,
491
- readonly: E.value,
496
+ readonly: Z.value,
492
497
  "onUpdate:modelValue": I
493
498
  }));
494
- return Q(u, {
499
+ return Q(l, {
495
500
  name: F(r),
496
- errors: F(D)
497
- }), { component: O(() => {
501
+ errors: F(w)
502
+ }), { component: D(() => {
498
503
  if (a.type === V.custom)
499
504
  return {
500
505
  render() {
501
- return s.default?.({
502
- errors: D.value,
506
+ return i.default?.({
507
+ errors: w.value,
503
508
  formData: d?.formData.value,
504
509
  formErrors: d?.errors.value,
505
510
  invalid: m.value,
506
511
  invalidLabel: p.value,
507
512
  modelValue: c.value,
508
- readonly: E.value,
513
+ readonly: Z.value,
509
514
  onUpdate: I,
510
515
  submit: d?.submit,
511
516
  validate: d?.validate
512
- }) ?? s.default;
517
+ }) ?? i.default;
513
518
  }
514
519
  };
515
520
  if (!(g?.lazyLoad ?? a.lazyLoad)) {
@@ -545,7 +550,7 @@ function Ge(e, t, u, g) {
545
550
  `[@volverjs/form-vue]: ${n} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
546
551
  );
547
552
  }
548
- return pe(async () => {
553
+ return me(async () => {
549
554
  switch (g?.sideEffects && await Promise.resolve(g.sideEffects(a.type)), a.type) {
550
555
  case V.textarea:
551
556
  return import("@volverjs/ui-vue/vv-textarea");
@@ -564,14 +569,14 @@ function Ge(e, t, u, g) {
564
569
  }
565
570
  return import("@volverjs/ui-vue/vv-input-text");
566
571
  });
567
- }), hasProps: w, invalid: m };
572
+ }), hasProps: O, invalid: m };
568
573
  },
569
574
  render() {
570
- return this.is ? z(this.is, this.hasProps, this.$slots) : this.type === V.custom ? z(this.component, null, this.$slots) : z(this.component, this.hasProps, this.$slots);
575
+ return this.is ? E(this.is, this.hasProps, this.$slots) : this.type === V.custom ? E(this.component, null, this.$slots) : E(this.component, this.hasProps, this.$slots);
571
576
  }
572
577
  });
573
578
  }
574
- function ke(e, t, u) {
579
+ function Pe(e, t, l) {
575
580
  return U({
576
581
  name: "VvFormFieldsGroup",
577
582
  props: {
@@ -615,133 +620,133 @@ function ke(e, t, u) {
615
620
  "is"
616
621
  ],
617
622
  slots: Object,
618
- setup(g, { slots: a, emit: s }) {
619
- const { props: l, names: f, defaultValues: r } = Y(g), v = ae(), o = O(() => Array.isArray(f.value) ? f.value : Object.values(f.value)), d = O(() => Array.isArray(f.value) ? f.value : Object.keys(f.value)), c = O(() => Array.isArray(f.value) ? f.value.reduce((i, h) => (i[String(h)] = h, i), {}) : f.value), D = O(() => Object.keys(c.value).reduce((i, h) => (i[String(c.value[h])] = h, i), {})), p = G(t, void 0);
620
- p && o.value.forEach((i) => {
621
- p.fields.value.set(`${v}-${i}`, i);
623
+ setup(g, { slots: a, emit: i }) {
624
+ const { props: u, names: f, defaultValues: r } = Y(g), v = ae(), o = D(() => Array.isArray(f.value) ? f.value : Object.values(f.value)), d = D(() => Array.isArray(f.value) ? f.value : Object.keys(f.value)), c = D(() => Array.isArray(f.value) ? f.value.reduce((s, h) => (s[String(h)] = h, s), {}) : f.value), w = D(() => Object.keys(c.value).reduce((s, h) => (s[String(c.value[h])] = h, s), {})), p = G(t, void 0);
625
+ p && o.value.forEach((s) => {
626
+ p.fields.value.set(`${v}-${s}`, s);
622
627
  });
623
- const m = G(e), y = O({
628
+ const m = G(e), y = D({
624
629
  get() {
625
- return m?.formData ? d.value.reduce((i, h) => (i[h] = P(
630
+ return m?.formData ? d.value.reduce((s, h) => (s[h] = W(
626
631
  new Object(m.formData.value),
627
632
  c.value[h]
628
- ), i), {}) : {};
633
+ ), s), {}) : {};
629
634
  },
630
- set(i) {
635
+ set(s) {
631
636
  m?.formData && (d.value.forEach((h) => {
632
637
  oe(
633
638
  new Object(m.formData.value),
634
639
  c.value[h],
635
- i?.[h]
640
+ s?.[h]
636
641
  );
637
- }), s("update:modelValue", {
642
+ }), i("update:modelValue", {
638
643
  newValue: y.value,
639
644
  formData: m?.formData
640
645
  }));
641
646
  }
642
647
  });
643
648
  H(() => {
644
- r.value && o.value.forEach((i) => {
645
- r.value?.[i] !== void 0 && y.value[i] === void 0 && (y.value = {
649
+ r.value && o.value.forEach((s) => {
650
+ r.value?.[s] !== void 0 && y.value[s] === void 0 && (y.value = {
646
651
  ...y.value,
647
- [i]: r.value?.[i]
652
+ [s]: r.value?.[s]
648
653
  });
649
654
  });
650
655
  }), L(() => {
651
- p && o.value.forEach((i) => {
656
+ p && o.value.forEach((s) => {
652
657
  p.fields.value.delete(
653
- `${v}-${i}`
658
+ `${v}-${s}`
654
659
  );
655
660
  });
656
661
  });
657
- const b = O(() => {
662
+ const b = D(() => {
658
663
  if (!m?.errors.value)
659
664
  return;
660
- const i = o.value.reduce((h, x) => {
665
+ const s = o.value.reduce((h, x) => {
661
666
  if (!m.errors.value)
662
667
  return h;
663
- const te = P(m.errors.value, String(x));
668
+ const te = W(m.errors.value, String(x));
664
669
  return te === void 0 || (h[String(x)] = te), h;
665
670
  }, {});
666
- if (Object.keys(i).length !== 0)
667
- return i;
668
- }), I = O(() => {
671
+ if (Object.keys(s).length !== 0)
672
+ return s;
673
+ }), I = D(() => {
669
674
  if (!b.value)
670
675
  return;
671
- const i = Object.keys(b.value).reduce((h, x) => (b.value?.[x] && (h[D.value[x]] = b.value[x]._errors), h), {});
672
- if (Object.keys(i).length !== 0)
673
- return i;
674
- }), R = O(() => b.value !== void 0), E = O(() => d.value.reduce((i, h) => (i[h] = !!b.value?.[D.value[h]], i), {})), w = Z(R, () => {
676
+ const s = Object.keys(b.value).reduce((h, x) => (b.value?.[x] && (h[w.value[x]] = b.value[x]._errors), h), {});
677
+ if (Object.keys(s).length !== 0)
678
+ return s;
679
+ }), R = D(() => b.value !== void 0), Z = D(() => d.value.reduce((s, h) => (s[h] = !!b.value?.[w.value[h]], s), {})), O = z(R, () => {
675
680
  if (R.value) {
676
- s("invalid", b.value), p && o.value.forEach((i) => {
677
- if (!b.value?.[i]) {
681
+ i("invalid", b.value), p && o.value.forEach((s) => {
682
+ if (!b.value?.[s]) {
678
683
  p.errors.value.delete(
679
- i
684
+ s
680
685
  );
681
686
  return;
682
687
  }
683
688
  p.errors.value.set(
684
- i,
685
- b.value?.[i]
689
+ s,
690
+ b.value?.[s]
686
691
  );
687
692
  });
688
693
  return;
689
694
  }
690
- s("valid", y.value), p && o.value.forEach((i) => {
695
+ i("valid", y.value), p && o.value.forEach((s) => {
691
696
  p.errors.value.delete(
692
- i
697
+ s
693
698
  );
694
699
  });
695
- }), _ = Z(
700
+ }), _ = z(
696
701
  () => m?.formData,
697
702
  () => {
698
- s("update:formData", m?.formData);
703
+ i("update:formData", m?.formData);
699
704
  },
700
705
  { deep: !0 }
701
706
  );
702
707
  L(() => {
703
- w(), _();
708
+ O(), _();
704
709
  });
705
- const n = (i) => {
706
- y.value = i;
707
- }, j = (i, h) => {
708
- h instanceof InputEvent && (h = h.target.value), d.value.includes(i) && (y.value = {
710
+ const n = (s) => {
711
+ y.value = s;
712
+ }, j = (s, h) => {
713
+ h instanceof InputEvent && (h = h.target.value), d.value.includes(s) && (y.value = {
709
714
  ...y.value,
710
- [i]: h
715
+ [s]: h
711
716
  });
712
- }, A = O(() => {
713
- let i = l.value;
714
- return typeof i == "function" && (i = i(m?.formData)), Object.keys(i).reduce(
715
- (h, x) => (h[x] = W(i[x]), h),
717
+ }, A = D(() => {
718
+ let s = u.value;
719
+ return typeof s == "function" && (s = s(m?.formData)), Object.keys(s).reduce(
720
+ (h, x) => (h[x] = P(s[x]), h),
716
721
  {}
717
722
  );
718
- }), ee = O(() => m?.readonly.value ? !0 : A.value.readonly ?? g.readonly), ve = O(() => d.value.reduce((i, h) => (i[`onUpdate:${h}`] = (x) => {
723
+ }), ee = D(() => m?.readonly.value ? !0 : A.value.readonly ?? g.readonly), fe = D(() => d.value.reduce((s, h) => (s[`onUpdate:${h}`] = (x) => {
719
724
  j(h, x);
720
- }, i), {
725
+ }, s), {
721
726
  "onUpdate:modelValue": n
722
- })), ce = O(() => ({
723
- ...ve.value,
727
+ })), ve = D(() => ({
728
+ ...fe.value,
724
729
  ...A.value,
725
730
  ...y.value,
726
731
  modelValue: y.value,
727
732
  names: A.value.name ?? o.value,
728
733
  invalid: R.value,
729
- invalids: E.value,
734
+ invalids: Z.value,
730
735
  valid: g.showValid ? !!(!R.value && y.value) : void 0,
731
736
  invalidLabels: I.value,
732
737
  readonly: ee.value
733
738
  }));
734
- return Q(u, {
739
+ return Q(l, {
735
740
  names: F(f),
736
741
  errors: F(b)
737
- }), { component: O(() => ({
742
+ }), { component: D(() => ({
738
743
  render() {
739
744
  return a.default?.({
740
745
  errors: b.value,
741
746
  formData: m?.formData.value,
742
747
  formErrors: m?.errors.value,
743
748
  invalid: R.value,
744
- invalids: E.value,
749
+ invalids: Z.value,
745
750
  invalidLabels: I.value,
746
751
  modelValue: y.value,
747
752
  onUpdate: n,
@@ -751,14 +756,14 @@ function ke(e, t, u) {
751
756
  validate: m?.validate
752
757
  }) ?? a.default;
753
758
  }
754
- })), hasProps: ce, invalid: R };
759
+ })), hasProps: ve, invalid: R };
755
760
  },
756
761
  render() {
757
- return this.is ? z(this.is, this.hasProps, this.$slots) : z(this.component, null, this.$slots);
762
+ return this.is ? E(this.is, this.hasProps, this.$slots) : E(this.component, null, this.$slots);
758
763
  }
759
764
  });
760
765
  }
761
- function Be(e, t) {
766
+ function We(e, t) {
762
767
  return U({
763
768
  name: "VvFormWrapper",
764
769
  props: {
@@ -791,41 +796,41 @@ function Be(e, t) {
791
796
  "validateWrapper"
792
797
  ],
793
798
  slots: Object,
794
- setup(u, { emit: g }) {
795
- const a = G(e), s = G(t, void 0), l = B(/* @__PURE__ */ new Map()), f = B(/* @__PURE__ */ new Map()), { name: r } = Y(u), v = O(() => a?.invalid.value ? f.value.size > 0 : !1);
796
- Z(v, (p) => {
799
+ setup(l, { emit: g }) {
800
+ const a = G(e), i = G(t, void 0), u = B(/* @__PURE__ */ new Map()), f = B(/* @__PURE__ */ new Map()), { name: r } = Y(l), v = D(() => a?.invalid.value ? f.value.size > 0 : !1);
801
+ z(v, (p) => {
797
802
  if (p) {
798
803
  g("invalid");
799
804
  return;
800
805
  }
801
806
  g("valid");
802
807
  });
803
- const o = O(() => a?.readonly.value || u.readonly), d = {
808
+ const o = D(() => a?.readonly.value || l.readonly), d = {
804
809
  name: F(r),
805
810
  errors: f,
806
811
  invalid: F(v),
807
812
  readonly: F(o),
808
- fields: l
813
+ fields: u
809
814
  };
810
815
  Q(t, d);
811
- const c = O(() => new Map(l.value));
812
- Z(
816
+ const c = D(() => new Map(u.value));
817
+ z(
813
818
  c,
814
819
  (p, m) => {
815
- s?.fields && (m.forEach((y, b) => {
816
- p.has(b) || s?.fields.value.delete(b);
820
+ i?.fields && (m.forEach((y, b) => {
821
+ p.has(b) || i?.fields.value.delete(b);
817
822
  }), p.forEach((y, b) => {
818
- s?.fields.value.has(b) || s?.fields.value.set(b, y);
823
+ i?.fields.value.has(b) || i?.fields.value.set(b, y);
819
824
  }));
820
825
  },
821
826
  { deep: !0 }
822
- ), Z(
827
+ ), z(
823
828
  f,
824
829
  (p) => {
825
- s?.errors && l.value.forEach((m) => {
826
- if (p.has(m) || s.errors.value.delete(m), p.has(m)) {
830
+ i?.errors && u.value.forEach((m) => {
831
+ if (p.has(m) || i.errors.value.delete(m), p.has(m)) {
827
832
  const y = p.get(m);
828
- y && s.errors.value.set(m, y);
833
+ y && i.errors.value.set(m, y);
829
834
  }
830
835
  });
831
836
  },
@@ -843,10 +848,10 @@ function Be(e, t) {
843
848
  }), L(() => {
844
849
  a?.wrappers && r.value && a.wrappers.delete(r.value);
845
850
  });
846
- const D = () => a?.validate(void 0, { fields: new Set(l.value.values()) }) ?? Promise.resolve(!0);
851
+ const w = () => a?.validate(void 0, { fields: new Set(u.value.values()) }) ?? Promise.resolve(!0);
847
852
  return {
848
853
  errors: a?.errors,
849
- fields: l,
854
+ fields: u,
850
855
  fieldsErrors: f,
851
856
  formData: a?.formData,
852
857
  invalid: v,
@@ -855,11 +860,11 @@ function Be(e, t) {
855
860
  reset: a?.reset,
856
861
  submit: a?.submit,
857
862
  validate: a?.validate,
858
- validateWrapper: D
863
+ validateWrapper: w
859
864
  };
860
865
  },
861
866
  render() {
862
- const u = () => this.$slots.default?.({
867
+ const l = () => this.$slots.default?.({
863
868
  errors: this.errors,
864
869
  fieldsErrors: this.fieldsErrors,
865
870
  formData: this.formData,
@@ -871,14 +876,14 @@ function Be(e, t) {
871
876
  validate: this.validate,
872
877
  validateWrapper: this.validateWrapper
873
878
  });
874
- return this.tag ? z(this.tag, null, {
875
- default: u
876
- }) : u();
879
+ return this.tag ? E(this.tag, null, {
880
+ default: l
881
+ }) : l();
877
882
  }
878
883
  });
879
884
  }
880
- function We(e, t) {
881
- const u = U({
885
+ function Le(e, t) {
886
+ const l = U({
882
887
  name: "VvFormTemplate",
883
888
  props: {
884
889
  schema: {
@@ -892,121 +897,121 @@ function We(e, t) {
892
897
  },
893
898
  slots: Object,
894
899
  setup(g, { slots: a }) {
895
- const s = G(e);
896
- if (s?.formData)
900
+ const i = G(e);
901
+ if (i?.formData)
897
902
  return () => {
898
- const l = typeof g.schema == "function" ? g.schema(
899
- s,
903
+ const u = typeof g.schema == "function" ? g.schema(
904
+ i,
900
905
  g.scope
901
906
  ) : g.schema;
902
907
  let f;
903
- const r = l.reduce((v, o) => {
904
- const d = typeof o == "function" ? o(s, g.scope) : o, {
908
+ const r = u.reduce((v, o) => {
909
+ const d = typeof o == "function" ? o(i, g.scope) : o, {
905
910
  vvIs: c,
906
- vvName: D,
911
+ vvName: w,
907
912
  vvSlots: p,
908
913
  vvChildren: m,
909
914
  vvIf: y,
910
915
  vvElseIf: b,
911
916
  vvType: I,
912
917
  vvDefaultValue: R,
913
- vvShowValid: E,
914
- vvContent: w,
918
+ vvShowValid: Z,
919
+ vvContent: O,
915
920
  ..._
916
921
  } = d;
917
922
  if (y !== void 0) {
918
- if (typeof y == "string" ? f = !!P(
919
- new Object(s.formData.value),
923
+ if (typeof y == "string" ? f = !!W(
924
+ new Object(i.formData.value),
920
925
  y
921
- ) : typeof y == "function" ? f = W(y(s)) : f = W(y), !f)
926
+ ) : typeof y == "function" ? f = P(y(i)) : f = P(y), !f)
922
927
  return v;
923
928
  } else if (b !== void 0 && f !== void 0) {
924
- if (f || (typeof b == "string" ? f = !!P(
925
- new Object(s.formData.value),
929
+ if (f || (typeof b == "string" ? f = !!W(
930
+ new Object(i.formData.value),
926
931
  b
927
- ) : typeof b == "function" ? f = W(b(s)) : f = W(b), !f))
932
+ ) : typeof b == "function" ? f = P(b(i)) : f = P(b), !f))
928
933
  return v;
929
934
  } else
930
935
  f = void 0;
931
936
  let n;
932
- return m && (typeof c == "string" ? n = z(u, {
937
+ return m && (typeof c == "string" ? n = E(l, {
933
938
  schema: m
934
939
  }) : n = {
935
- default: (j) => z(u, {
940
+ default: (j) => E(l, {
936
941
  schema: m,
937
942
  scope: j
938
943
  })
939
- }), D ? (v.push(
940
- z(
944
+ }), w ? (v.push(
945
+ E(
941
946
  t,
942
947
  {
943
- name: D,
948
+ name: w,
944
949
  is: c,
945
950
  type: I,
946
951
  defaultValue: R,
947
- showValid: E,
952
+ showValid: Z,
948
953
  props: _
949
954
  },
950
- p ?? n ?? w
955
+ p ?? n ?? O
951
956
  )
952
957
  ), v) : c ? (v.push(
953
- z(
958
+ E(
954
959
  c,
955
960
  _,
956
- p ?? n ?? w
961
+ p ?? n ?? O
957
962
  )
958
963
  ), v) : (n && ("default" in n ? v.push(n.default(g.scope)) : v.push(n)), v);
959
964
  }, []);
960
965
  return r.push(
961
966
  a?.default?.({
962
- errors: s?.errors.value,
963
- formData: s?.formData.value,
964
- invalid: s?.invalid.value,
965
- status: s?.status.value,
966
- submit: s?.submit,
967
- validate: s?.validate,
968
- clear: s?.clear,
969
- reset: s?.reset
967
+ errors: i?.errors.value,
968
+ formData: i?.formData.value,
969
+ invalid: i?.invalid.value,
970
+ status: i?.status.value,
971
+ submit: i?.submit,
972
+ validate: i?.validate,
973
+ clear: i?.clear,
974
+ reset: i?.reset
970
975
  })
971
976
  ), r;
972
977
  };
973
978
  }
974
979
  });
975
- return u;
980
+ return l;
976
981
  }
977
982
  function q(e, t = {}) {
978
- const u = Symbol("formInjectionKey"), g = Symbol("formWrapperInjectionKey"), a = Symbol("formFieldInjectionKey"), s = Symbol("formFieldsGroupInjectionKey"), l = Be(
979
- u,
983
+ const l = Symbol("formInjectionKey"), g = Symbol("formWrapperInjectionKey"), a = Symbol("formFieldInjectionKey"), i = Symbol("formFieldsGroupInjectionKey"), u = We(
984
+ l,
980
985
  g
981
- ), f = Ge(
982
- u,
986
+ ), f = Be(
987
+ l,
983
988
  g,
984
989
  a,
985
990
  t
986
- ), r = ke(
987
- u,
991
+ ), r = Pe(
992
+ l,
988
993
  g,
989
- s
990
- ), v = We(u, f), o = /* @__PURE__ */ new Map(), {
994
+ i
995
+ ), v = Le(l, f), o = /* @__PURE__ */ new Map(), {
991
996
  clear: d,
992
997
  errors: c,
993
- formData: D,
998
+ formData: w,
994
999
  ignoreUpdates: p,
995
1000
  invalid: m,
996
1001
  readonly: y,
997
1002
  reset: b,
998
1003
  status: I,
999
1004
  stopUpdatesWatch: R,
1000
- submit: E,
1001
- validate: w,
1005
+ submit: Z,
1006
+ validate: O,
1002
1007
  VvForm: _
1003
- } = $e(e, u, t, v, o);
1008
+ } = ke(e, l, t, v, o);
1004
1009
  return {
1005
1010
  clear: d,
1006
1011
  errors: c,
1007
- formData: D,
1012
+ formData: w,
1008
1013
  formFieldInjectionKey: a,
1009
- formInjectionKey: u,
1014
+ formInjectionKey: l,
1010
1015
  formWrapperInjectionKey: g,
1011
1016
  ignoreUpdates: p,
1012
1017
  invalid: m,
@@ -1014,51 +1019,51 @@ function q(e, t = {}) {
1014
1019
  reset: b,
1015
1020
  status: I,
1016
1021
  stopUpdatesWatch: R,
1017
- submit: E,
1018
- validate: w,
1022
+ submit: Z,
1023
+ validate: O,
1019
1024
  wrappers: o,
1020
1025
  VvForm: _,
1021
1026
  VvFormField: f,
1022
1027
  VvFormFieldsGroup: r,
1023
1028
  VvFormTemplate: v,
1024
- VvFormWrapper: l
1029
+ VvFormWrapper: u
1025
1030
  };
1026
1031
  }
1027
- const fe = Symbol("pluginInjectionKey");
1028
- function Me(e) {
1032
+ const de = Symbol("pluginInjectionKey");
1033
+ function qe(e) {
1029
1034
  let t = {};
1030
1035
  return e.schema && (t = q(e.schema, e)), {
1031
1036
  ...t,
1032
- install(u, { global: g = !1 } = {}) {
1033
- u.provide(fe, e), g && (u.config.globalProperties.$vvForm = e, t?.VvForm && u.component("VvForm", t.VvForm), t?.VvFormWrapper && u.component("VvFormWrapper", t.VvFormWrapper), t?.VvFormField && u.component("VvFormField", t.VvFormField), t?.VvFormFieldsGroup && u.component("VvFormFieldsGroup", t.VvFormFieldsGroup), t?.VvFormTemplate && u.component("VvFormTemplate", t.VvFormTemplate));
1037
+ install(l, { global: g = !1 } = {}) {
1038
+ l.provide(de, e), g && (l.config.globalProperties.$vvForm = e, t?.VvForm && l.component("VvForm", t.VvForm), t?.VvFormWrapper && l.component("VvFormWrapper", t.VvFormWrapper), t?.VvFormField && l.component("VvFormField", t.VvFormField), t?.VvFormFieldsGroup && l.component("VvFormFieldsGroup", t.VvFormFieldsGroup), t?.VvFormTemplate && l.component("VvFormTemplate", t.VvFormTemplate));
1034
1039
  }
1035
1040
  };
1036
1041
  }
1037
1042
  const J = /* @__PURE__ */ new Map();
1038
- function Je(e, t = {}) {
1043
+ function He(e, t = {}) {
1039
1044
  if (t.scope && J.has(t.scope))
1040
1045
  return J.get(t.scope);
1041
- if (!ye()) {
1046
+ if (!pe()) {
1042
1047
  const g = q(e, t);
1043
1048
  return t.scope && J.set(t.scope, g), g;
1044
1049
  }
1045
- const u = q(
1050
+ const l = q(
1046
1051
  e,
1047
1052
  {
1048
- ...G(fe, {}),
1053
+ ...G(de, {}),
1049
1054
  ...t
1050
1055
  }
1051
1056
  );
1052
- return t.scope && J.set(t.scope, u), u;
1057
+ return t.scope && J.set(t.scope, l), l;
1053
1058
  }
1054
- function qe(e, t = {}) {
1059
+ function Qe(e, t = {}) {
1055
1060
  return q(e, t);
1056
1061
  }
1057
1062
  export {
1058
1063
  V as FormFieldType,
1059
- Me as createForm,
1064
+ qe as createForm,
1060
1065
  k as defaultObjectBySchema,
1061
- qe as formType,
1062
- fe as pluginInjectionKey,
1063
- Je as useForm
1066
+ Qe as formType,
1067
+ de as pluginInjectionKey,
1068
+ He as useForm
1064
1069
  };