@volverjs/form-vue 1.0.0-beta.33 → 1.0.0-beta.34

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,15 +1,15 @@
1
- import { ref as C, computed as I, readonly as N, defineComponent as J, toRaw as L, watch as U, isProxy as ce, onMounted as j, provide as F, h as R, withModifiers as ae, toRefs as te, useId as ie, inject as P, onBeforeUnmount as W, unref as K, resolveComponent as _, defineAsyncComponent as he, getCurrentInstance as ye } from "vue";
1
+ import { ref as C, computed as I, readonly as L, defineComponent as W, h as $, withModifiers as ae, toRaw as _, watch as U, isProxy as ce, onMounted as j, provide as F, toRefs as te, useId as ie, inject as P, onBeforeUnmount as J, unref as K, resolveComponent as N, defineAsyncComponent as ye, getCurrentInstance as he } from "vue";
2
2
  import { watchIgnorable as me, throttleFilter as be } from "@vueuse/core";
3
3
  import { ZodObject as H, ZodDefault as pe, ZodNullable as Ve, ZodSchema as ge, ZodArray as we, ZodRecord as Oe, ZodEffects as le, ZodOptional as ne, ZodError as xe } from "zod";
4
4
  var p = /* @__PURE__ */ ((r) => (r.text = "text", r.number = "number", r.email = "email", r.password = "password", r.tel = "tel", r.url = "url", r.search = "search", r.date = "date", r.time = "time", r.datetimeLocal = "datetime-local", r.month = "month", r.week = "week", r.color = "color", r.select = "select", r.checkbox = "checkbox", r.radio = "radio", r.textarea = "textarea", r.radioGroup = "radioGroup", r.checkboxGroup = "checkboxGroup", r.combobox = "combobox", r.custom = "custom", r))(p || {}), G = /* @__PURE__ */ ((r) => (r.invalid = "invalid", r.valid = "valid", r.submitting = "submitting", r.reset = "reset", r.updated = "updated", r.unknown = "unknown", r))(G || {});
5
5
  function X(r, i = {}) {
6
- const e = (v) => {
7
- let f = v;
6
+ const e = (d) => {
7
+ let f = d;
8
8
  for (; f instanceof le; )
9
9
  f = f.innerType();
10
10
  return f instanceof ne && (f = f._def.innerType), f;
11
- }, c = (v) => {
12
- let f = v;
11
+ }, c = (d) => {
12
+ let f = d;
13
13
  for (; f instanceof le; )
14
14
  f = f.innerType();
15
15
  return f instanceof ne;
@@ -18,51 +18,51 @@ function X(r, i = {}) {
18
18
  ...(t instanceof H ? t._def.unknownKeys === "passthrough" : !1) ? i : {},
19
19
  ...Object.fromEntries(
20
20
  Object.entries(t.shape).map(
21
- ([v, f]) => {
22
- const o = i[v], g = c(f);
23
- let d = e(f), n;
24
- if (d instanceof pe && (n = d._def.defaultValue(), d = d._def.innerType), o === null && d instanceof Ve)
25
- return [v, o];
26
- if (o == null && g)
27
- return [v, n];
28
- if (d instanceof ge) {
29
- const m = f.safeParse(o);
30
- if (m.success)
31
- return [v, m.data ?? n];
21
+ ([d, f]) => {
22
+ const o = i[d], w = c(f);
23
+ let v = e(f), n;
24
+ if (v instanceof pe && (n = v._def.defaultValue(), v = v._def.innerType), o === null && v instanceof Ve)
25
+ return [d, o];
26
+ if (o == null && w)
27
+ return [d, n];
28
+ if (v instanceof ge) {
29
+ const h = f.safeParse(o);
30
+ if (h.success)
31
+ return [d, h.data ?? n];
32
32
  }
33
- if (d instanceof we && Array.isArray(o) && o.length) {
34
- const m = e(d._def.type);
35
- if (m instanceof H)
33
+ if (v instanceof we && Array.isArray(o) && o.length) {
34
+ const h = e(v._def.type);
35
+ if (h instanceof H)
36
36
  return [
37
- v,
37
+ d,
38
38
  o.map(
39
- (y) => X(
40
- m,
41
- y && typeof y == "object" ? y : void 0
39
+ (V) => X(
40
+ h,
41
+ V && typeof V == "object" ? V : void 0
42
42
  )
43
43
  )
44
44
  ];
45
45
  }
46
- if (d instanceof Oe && o) {
47
- const m = e(d._def.valueType);
48
- if (m instanceof H)
49
- return [v, Object.keys(o).reduce((y, b) => (y[b] = X(m, o[b]), y), {})];
46
+ if (v instanceof Oe && o) {
47
+ const h = e(v._def.valueType);
48
+ if (h instanceof H)
49
+ return [d, Object.keys(o).reduce((V, m) => (V[m] = X(h, o[m]), V), {})];
50
50
  }
51
- return d instanceof H ? [
52
- v,
51
+ return v instanceof H ? [
52
+ d,
53
53
  X(
54
- d,
54
+ v,
55
55
  o && typeof o == "object" ? o : n
56
56
  )
57
- ] : [v, n];
57
+ ] : [d, n];
58
58
  }
59
59
  )
60
60
  )
61
61
  };
62
62
  }
63
63
  function Ie(r, i, e, c, t) {
64
- const u = C(), v = C(), f = I(() => v.value === G.invalid), o = C(), g = C(!1);
65
- let d;
64
+ const u = C(), d = C(), f = I(() => d.value === G.invalid), o = C(), w = C(!1);
65
+ let v;
66
66
  const n = (S) => {
67
67
  const O = X(r, S);
68
68
  if (e != null && e.class) {
@@ -70,31 +70,31 @@ function Ie(r, i, e, c, t) {
70
70
  return new l(O);
71
71
  }
72
72
  return O;
73
- }, m = async (S = o.value, O) => {
74
- if (d = O, g.value)
73
+ }, h = async (S = o.value, O) => {
74
+ if (v = O, w.value)
75
75
  return !0;
76
76
  const l = await r.safeParseAsync(S);
77
77
  if (!l.success) {
78
- if (v.value = G.invalid, !O)
78
+ if (d.value = G.invalid, !O)
79
79
  return u.value = l.error.format(), !1;
80
- const x = l.error.issues.filter(($) => O.has($.path.join(".")));
80
+ const x = l.error.issues.filter((R) => O.has(R.path.join(".")));
81
81
  return x.length ? (u.value = new xe(x).format(), !1) : (u.value = void 0, !0);
82
82
  }
83
- return u.value = void 0, v.value = G.valid, o.value = n(l.data), !0;
84
- }, y = () => {
85
- u.value = void 0, v.value = void 0, d = void 0;
86
- }, b = () => {
87
- o.value = n(), y(), v.value = G.reset;
88
- }, s = async () => g.value || !await m() ? !1 : (v.value = G.submitting, !0), { ignoreUpdates: V, stop: w } = me(
83
+ return u.value = void 0, d.value = G.valid, o.value = n(l.data), !0;
84
+ }, V = () => {
85
+ u.value = void 0, d.value = void 0, v = void 0;
86
+ }, m = () => {
87
+ o.value = n(), V(), d.value = G.reset;
88
+ }, s = async () => w.value || !await h() ? !1 : (d.value = G.submitting, !0), { ignoreUpdates: g, stop: b } = me(
89
89
  o,
90
90
  () => {
91
- v.value = G.updated;
91
+ d.value = G.updated;
92
92
  },
93
93
  {
94
94
  deep: !0,
95
95
  eventFilter: be((e == null ? void 0 : e.updateThrottle) ?? 500)
96
96
  }
97
- ), E = N(u), A = N(v), B = J({
97
+ ), E = L(u), A = L(d), B = W({
98
98
  name: "VvForm",
99
99
  props: {
100
100
  continuousValidation: {
@@ -141,21 +141,21 @@ function Ie(r, i, e, c, t) {
141
141
  ],
142
142
  slots: Object,
143
143
  setup(S, { emit: O }) {
144
- return o.value = n(L(S.modelValue)), U(
144
+ return o.value = n(_(S.modelValue)), U(
145
145
  () => S.modelValue,
146
146
  (l) => {
147
147
  if (l) {
148
- const x = ce(l) ? L(l) : l;
149
- if (JSON.stringify(x) === JSON.stringify(L(o.value)))
148
+ const x = ce(l) ? _(l) : l;
149
+ if (JSON.stringify(x) === JSON.stringify(_(o.value)))
150
150
  return;
151
151
  o.value = typeof (x == null ? void 0 : x.clone) == "function" ? x.clone() : JSON.parse(JSON.stringify(x));
152
152
  }
153
153
  },
154
154
  { deep: !0 }
155
- ), U(v, async (l) => {
156
- var x, $, Z, q, T, ee;
155
+ ), U(d, async (l) => {
156
+ var x, R, Z, q, T, ee;
157
157
  if (l === G.invalid) {
158
- const a = L(u.value);
158
+ const a = _(u.value);
159
159
  O("invalid", a), (x = e == null ? void 0 : e.onInvalid) == null || x.call(
160
160
  e,
161
161
  a
@@ -163,61 +163,61 @@ function Ie(r, i, e, c, t) {
163
163
  return;
164
164
  }
165
165
  if (l === G.valid) {
166
- const a = L(o.value);
167
- O("valid", a), ($ = e == null ? void 0 : e.onValid) == null || $.call(e, a), O("update:modelValue", a), (Z = e == null ? void 0 : e.onUpdate) == null || Z.call(e, a);
166
+ const a = _(o.value);
167
+ O("valid", a), (R = e == null ? void 0 : e.onValid) == null || R.call(e, a), O("update:modelValue", a), (Z = e == null ? void 0 : e.onUpdate) == null || Z.call(e, a);
168
168
  return;
169
169
  }
170
170
  if (l === G.submitting) {
171
- const a = L(o.value);
171
+ const a = _(o.value);
172
172
  O("submit", a), (q = e == null ? void 0 : e.onSubmit) == null || q.call(e, a);
173
173
  return;
174
174
  }
175
175
  if (l === G.reset) {
176
- const a = L(o.value);
176
+ const a = _(o.value);
177
177
  O("reset", a), (T = e == null ? void 0 : e.onReset) == null || T.call(e, a);
178
178
  return;
179
179
  }
180
180
  if (l === G.updated) {
181
- if ((u.value || e != null && e.continuousValidation || S.continuousValidation) && await m(void 0, d), !o.value || !S.modelValue || JSON.stringify(o.value) !== JSON.stringify(S.modelValue)) {
182
- const a = L(o.value);
181
+ if ((u.value || e != null && e.continuousValidation || S.continuousValidation) && await h(void 0, v), !o.value || !S.modelValue || JSON.stringify(o.value) !== JSON.stringify(S.modelValue)) {
182
+ const a = _(o.value);
183
183
  O("update:modelValue", a), (ee = e == null ? void 0 : e.onUpdate) == null || ee.call(e, a);
184
184
  }
185
- v.value === G.updated && (v.value = G.unknown);
185
+ d.value === G.updated && (d.value = G.unknown);
186
186
  }
187
187
  }), j(() => {
188
- g.value = S.readonly;
188
+ w.value = S.readonly;
189
189
  }), U(
190
190
  () => S.readonly,
191
191
  (l) => {
192
- g.value = l;
192
+ w.value = l;
193
193
  }
194
- ), U(g, (l) => {
195
- l !== S.readonly && O("update:readonly", g.value);
194
+ ), U(w, (l) => {
195
+ l !== S.readonly && O("update:readonly", w.value);
196
196
  }), F(i, {
197
- clear: y,
197
+ clear: V,
198
198
  errors: E,
199
199
  formData: o,
200
- ignoreUpdates: V,
200
+ ignoreUpdates: g,
201
201
  invalid: f,
202
- readonly: g,
203
- reset: b,
202
+ readonly: w,
203
+ reset: m,
204
204
  status: A,
205
- stopUpdatesWatch: w,
205
+ stopUpdatesWatch: b,
206
206
  submit: s,
207
- validate: m,
207
+ validate: h,
208
208
  wrappers: t
209
209
  }), {
210
- clear: y,
210
+ clear: V,
211
211
  errors: E,
212
212
  formData: o,
213
- ignoreUpdates: V,
213
+ ignoreUpdates: g,
214
214
  invalid: f,
215
- isReadonly: g,
216
- reset: b,
215
+ isReadonly: w,
216
+ reset: m,
217
217
  status: A,
218
- stopUpdatesWatch: w,
218
+ stopUpdatesWatch: b,
219
219
  submit: s,
220
- validate: m,
220
+ validate: h,
221
221
  wrappers: t
222
222
  };
223
223
  },
@@ -228,25 +228,25 @@ function Ie(r, i, e, c, t) {
228
228
  errors: E.value,
229
229
  formData: o.value,
230
230
  invalid: f.value,
231
- readonly: g.value,
231
+ readonly: w.value,
232
232
  status: A.value,
233
233
  wrappers: t,
234
- clear: y,
235
- ignoreUpdates: V,
236
- reset: b,
237
- stopUpdatesWatch: w,
234
+ clear: V,
235
+ ignoreUpdates: g,
236
+ reset: m,
237
+ stopUpdatesWatch: b,
238
238
  submit: s,
239
- validate: m
239
+ validate: h
240
240
  })) ?? this.$slots.default;
241
241
  };
242
- return R(
242
+ return $(
243
243
  this.tag,
244
244
  {
245
245
  onSubmit: ae(this.submit, ["prevent"]),
246
246
  onReset: ae(this.reset, ["prevent"])
247
247
  },
248
248
  (this.template ?? (e == null ? void 0 : e.template)) && c ? [
249
- R(
249
+ $(
250
250
  c,
251
251
  {
252
252
  schema: this.template ?? (e == null ? void 0 : e.template)
@@ -262,18 +262,18 @@ function Ie(r, i, e, c, t) {
262
262
  }
263
263
  });
264
264
  return {
265
- clear: y,
265
+ clear: V,
266
266
  errors: u,
267
267
  formData: o,
268
- ignoreUpdates: V,
268
+ ignoreUpdates: g,
269
269
  invalid: f,
270
- readonly: g,
271
- reset: b,
272
- status: v,
270
+ readonly: w,
271
+ reset: m,
272
+ status: d,
273
273
  wrappers: t,
274
- stopUpdatesWatch: w,
274
+ stopUpdatesWatch: b,
275
275
  submit: s,
276
- validate: m,
276
+ validate: h,
277
277
  VvForm: B
278
278
  };
279
279
  }
@@ -281,7 +281,7 @@ function re(r) {
281
281
  return Array.isArray(r);
282
282
  }
283
283
  function Se(r) {
284
- return typeof r < "u";
284
+ return !1;
285
285
  }
286
286
  function se(r) {
287
287
  return r === null;
@@ -297,7 +297,7 @@ function Y(r) {
297
297
  }
298
298
  const ke = /^[0-9]+$/, Ee = ["__proto__", "prototype", "constructor"];
299
299
  function M(r, i, e) {
300
- const c = Se(e) ? e : void 0;
300
+ const c = Se() ? e : void 0;
301
301
  if (!oe(r) || !fe(i))
302
302
  return c;
303
303
  const t = ve(i);
@@ -305,10 +305,10 @@ function M(r, i, e) {
305
305
  for (const u of t) {
306
306
  if (u === "*")
307
307
  continue;
308
- const v = function(f) {
309
- return f.map((o) => Y(o) || se(o) ? o : re(o) ? v(o) : o[u]);
308
+ const d = function(f) {
309
+ return f.map((o) => Y(o) || se(o) ? o : re(o) ? d(o) : o[u]);
310
310
  };
311
- if (re(r) && !ke.test(u) ? r = v(r) : r = r[u], Y(r) || se(r))
311
+ if (re(r) && !ke.test(u) ? r = d(r) : r = r[u], Y(r) || se(r))
312
312
  break;
313
313
  }
314
314
  return Y(r) ? c : r;
@@ -322,18 +322,18 @@ function ue(r, i, e) {
322
322
  return;
323
323
  const t = c.length;
324
324
  for (let u = 0; u < t; u++) {
325
- const v = c[u];
325
+ const d = c[u];
326
326
  if (u === t - 1) {
327
- r[v] = e;
327
+ r[d] = e;
328
328
  return;
329
329
  }
330
- if (v === "*" && re(r)) {
330
+ if (d === "*" && re(r)) {
331
331
  const f = c.slice(u + 1).join(".");
332
332
  for (const o of r)
333
333
  ue(o, f, e);
334
334
  return;
335
335
  }
336
- Y(r[v]) && (r[v] = {}), r = r[v];
336
+ Y(r[d]) && (r[d] = {}), r = r[d];
337
337
  }
338
338
  }
339
339
  function ve(r) {
@@ -341,7 +341,7 @@ function ve(r) {
341
341
  return i.some((e) => Ee.indexOf(e) !== -1) ? [] : i;
342
342
  }
343
343
  function Ae(r, i, e, c) {
344
- return J({
344
+ return W({
345
345
  name: "VvFormField",
346
346
  props: {
347
347
  type: {
@@ -394,10 +394,10 @@ function Ae(r, i, e, c) {
394
394
  "type"
395
395
  ],
396
396
  slots: Object,
397
- setup(t, { slots: u, emit: v }) {
398
- const { props: f, name: o } = te(t), g = ie(), d = P(i, void 0);
399
- d && d.fields.value.set(g, t.name);
400
- const n = P(r), m = I({
397
+ setup(t, { slots: u, emit: d }) {
398
+ const { props: f, name: o } = te(t), w = ie(), v = P(i, void 0);
399
+ v && v.fields.value.set(w, t.name);
400
+ const n = P(r), h = I({
401
401
  get() {
402
402
  if (n != null && n.formData)
403
403
  return M(
@@ -410,57 +410,57 @@ function Ae(r, i, e, c) {
410
410
  new Object(n.formData.value),
411
411
  String(t.name),
412
412
  l
413
- ), v("update:modelValue", {
414
- newValue: m.value,
413
+ ), d("update:modelValue", {
414
+ newValue: h.value,
415
415
  formData: n == null ? void 0 : n.formData
416
416
  }));
417
417
  }
418
418
  });
419
419
  j(() => {
420
- m.value === void 0 && t.defaultValue !== void 0 && (m.value = t.defaultValue);
421
- }), W(() => {
422
- d && d.fields.value.delete(g);
420
+ h.value === void 0 && t.defaultValue !== void 0 && (h.value = t.defaultValue);
421
+ }), J(() => {
422
+ v && v.fields.value.delete(w);
423
423
  });
424
- const y = I(() => {
424
+ const V = I(() => {
425
425
  if (n != null && n.errors.value)
426
426
  return M(n.errors.value, String(t.name));
427
- }), b = I(() => {
427
+ }), m = I(() => {
428
428
  var l;
429
- return (l = y.value) == null ? void 0 : l._errors;
430
- }), s = I(() => y.value !== void 0), V = U(s, () => {
431
- if (s.value) {
432
- v("invalid", y.value), d && d.errors.value.set(
429
+ return (l = V.value) == null ? void 0 : l._errors;
430
+ }), s = I(() => V.value !== void 0), g = U(s, (l) => {
431
+ if (l) {
432
+ d("invalid", V.value), v && v.errors.value.set(
433
433
  String(t.name),
434
- y.value
434
+ V.value
435
435
  );
436
436
  return;
437
437
  }
438
- v("valid", m.value), d && d.errors.value.delete(
438
+ d("valid", h.value), v && v.errors.value.delete(
439
439
  t.name
440
440
  );
441
- }), w = U(
441
+ }), b = U(
442
442
  () => n == null ? void 0 : n.formData,
443
443
  () => {
444
- v("update:formData", n == null ? void 0 : n.formData);
444
+ d("update:formData", n == null ? void 0 : n.formData);
445
445
  },
446
446
  { deep: !0 }
447
447
  );
448
- W(() => {
449
- V(), w();
448
+ J(() => {
449
+ g(), b();
450
450
  });
451
451
  const E = (l) => {
452
- l instanceof InputEvent && (l = l.target.value), m.value = l;
452
+ l instanceof InputEvent && (l = l.target.value), h.value = l;
453
453
  }, A = I(() => {
454
454
  let l = f.value;
455
455
  return typeof l == "function" && (l = l(n == null ? void 0 : n.formData)), Object.keys(l).reduce(
456
- (x, $) => (x[$] = K(l[$]), x),
456
+ (x, R) => (x[R] = K(l[R]), x),
457
457
  {}
458
458
  );
459
- }), B = I(() => n != null && n.readonly.value ? !0 : A.value.readonly ?? t.readonly), S = I(() => ({
459
+ }), B = I(() => n != null && n.readonly.value || v != null && v.readonly.value ? !0 : A.value.readonly ?? t.readonly), S = I(() => ({
460
460
  ...A.value,
461
461
  name: A.value.name ?? t.name,
462
462
  invalid: s.value,
463
- valid: t.showValid ? !!(!s.value && m.value) : void 0,
463
+ valid: t.showValid ? !!(!s.value && h.value) : void 0,
464
464
  type: ((l) => {
465
465
  if ([
466
466
  p.color,
@@ -479,26 +479,26 @@ function Ae(r, i, e, c) {
479
479
  ].includes(l))
480
480
  return l;
481
481
  })(t.type),
482
- invalidLabel: b.value,
483
- modelValue: m.value,
482
+ invalidLabel: m.value,
483
+ modelValue: h.value,
484
484
  readonly: B.value,
485
485
  "onUpdate:modelValue": E
486
486
  }));
487
487
  return F(e, {
488
- name: N(o),
489
- errors: N(y)
488
+ name: L(o),
489
+ errors: L(V)
490
490
  }), { component: I(() => {
491
491
  if (t.type === p.custom)
492
492
  return {
493
493
  render() {
494
494
  var l;
495
495
  return ((l = u.default) == null ? void 0 : l.call(u, {
496
- errors: y.value,
496
+ errors: V.value,
497
497
  formData: n == null ? void 0 : n.formData.value,
498
498
  formErrors: n == null ? void 0 : n.errors.value,
499
499
  invalid: s.value,
500
- invalidLabel: b.value,
501
- modelValue: m.value,
500
+ invalidLabel: m.value,
501
+ modelValue: h.value,
502
502
  readonly: B.value,
503
503
  onUpdate: E,
504
504
  submit: n == null ? void 0 : n.submit,
@@ -510,28 +510,28 @@ function Ae(r, i, e, c) {
510
510
  let l;
511
511
  switch (t.type) {
512
512
  case p.select:
513
- l = _("VvSelect");
513
+ l = N("VvSelect");
514
514
  break;
515
515
  case p.checkbox:
516
- l = _("VvCheckbox");
516
+ l = N("VvCheckbox");
517
517
  break;
518
518
  case p.radio:
519
- l = _("VvRadio");
519
+ l = N("VvRadio");
520
520
  break;
521
521
  case p.textarea:
522
- l = _("VvTextarea");
522
+ l = N("VvTextarea");
523
523
  break;
524
524
  case p.radioGroup:
525
- l = _("VvRadioGroup");
525
+ l = N("VvRadioGroup");
526
526
  break;
527
527
  case p.checkboxGroup:
528
- l = _("VvCheckboxGroup");
528
+ l = N("VvCheckboxGroup");
529
529
  break;
530
530
  case p.combobox:
531
- l = _("VvCombobox");
531
+ l = N("VvCombobox");
532
532
  break;
533
533
  default:
534
- l = _("VvInputText");
534
+ l = N("VvInputText");
535
535
  }
536
536
  if (typeof l != "string")
537
537
  return l;
@@ -539,7 +539,7 @@ function Ae(r, i, e, c) {
539
539
  `[@volverjs/form-vue]: ${l} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
540
540
  );
541
541
  }
542
- return he(async () => {
542
+ return ye(async () => {
543
543
  switch (c != null && c.sideEffects && await Promise.resolve(c.sideEffects(t.type)), t.type) {
544
544
  case p.textarea:
545
545
  return import("@volverjs/ui-vue/vv-textarea");
@@ -561,12 +561,12 @@ function Ae(r, i, e, c) {
561
561
  }), hasProps: S, invalid: s };
562
562
  },
563
563
  render() {
564
- return this.is ? R(this.is, this.hasProps, this.$slots) : this.type === p.custom ? R(this.component, null, this.$slots) : R(this.component, this.hasProps, this.$slots);
564
+ return this.is ? $(this.is, this.hasProps, this.$slots) : this.type === p.custom ? $(this.component, null, this.$slots) : $(this.component, this.hasProps, this.$slots);
565
565
  }
566
566
  });
567
567
  }
568
568
  function Ge(r, i, e) {
569
- return J({
569
+ return W({
570
570
  name: "VvFormFieldsGroup",
571
571
  props: {
572
572
  is: {
@@ -610,87 +610,87 @@ function Ge(r, i, e) {
610
610
  ],
611
611
  slots: Object,
612
612
  setup(c, { slots: t, emit: u }) {
613
- const { props: v, names: f, defaultValues: o } = te(c), g = ie(), d = I(() => Array.isArray(f.value) ? f.value : Object.values(f.value)), n = I(() => Array.isArray(f.value) ? f.value : Object.keys(f.value)), m = I(() => Array.isArray(f.value) ? f.value.reduce((a, h) => (a[String(h)] = h, a), {}) : f.value), y = I(() => Object.keys(m.value).reduce((a, h) => (a[String(m.value[h])] = h, a), {})), b = P(i, void 0);
614
- b && d.value.forEach((a) => {
615
- b.fields.value.set(`${g}-${a}`, a);
613
+ const { props: d, names: f, defaultValues: o } = te(c), w = ie(), v = I(() => Array.isArray(f.value) ? f.value : Object.values(f.value)), n = I(() => Array.isArray(f.value) ? f.value : Object.keys(f.value)), h = I(() => Array.isArray(f.value) ? f.value.reduce((a, y) => (a[String(y)] = y, a), {}) : f.value), V = I(() => Object.keys(h.value).reduce((a, y) => (a[String(h.value[y])] = y, a), {})), m = P(i, void 0);
614
+ m && v.value.forEach((a) => {
615
+ m.fields.value.set(`${w}-${a}`, a);
616
616
  });
617
- const s = P(r), V = I({
617
+ const s = P(r), g = I({
618
618
  get() {
619
- return s != null && s.formData ? n.value.reduce((a, h) => (a[h] = M(
619
+ return s != null && s.formData ? n.value.reduce((a, y) => (a[y] = M(
620
620
  new Object(s.formData.value),
621
- m.value[h]
621
+ h.value[y]
622
622
  ), a), {}) : {};
623
623
  },
624
624
  set(a) {
625
- s != null && s.formData && (n.value.forEach((h) => {
625
+ s != null && s.formData && (n.value.forEach((y) => {
626
626
  ue(
627
627
  new Object(s.formData.value),
628
- m.value[h],
629
- a == null ? void 0 : a[h]
628
+ h.value[y],
629
+ a == null ? void 0 : a[y]
630
630
  );
631
631
  }), u("update:modelValue", {
632
- newValue: V.value,
632
+ newValue: g.value,
633
633
  formData: s == null ? void 0 : s.formData
634
634
  }));
635
635
  }
636
636
  });
637
637
  j(() => {
638
- o.value && d.value.forEach((a) => {
639
- var h, k;
640
- ((h = o.value) == null ? void 0 : h[a]) !== void 0 && V.value[a] === void 0 && (V.value = {
641
- ...V.value,
638
+ o.value && v.value.forEach((a) => {
639
+ var y, k;
640
+ ((y = o.value) == null ? void 0 : y[a]) !== void 0 && g.value[a] === void 0 && (g.value = {
641
+ ...g.value,
642
642
  [a]: (k = o.value) == null ? void 0 : k[a]
643
643
  });
644
644
  });
645
- }), W(() => {
646
- b && d.value.forEach((a) => {
647
- b.fields.value.delete(
648
- `${g}-${a}`
645
+ }), J(() => {
646
+ m && v.value.forEach((a) => {
647
+ m.fields.value.delete(
648
+ `${w}-${a}`
649
649
  );
650
650
  });
651
651
  });
652
- const w = I(() => {
652
+ const b = I(() => {
653
653
  if (!(s != null && s.errors.value))
654
654
  return;
655
- const a = d.value.reduce((h, k) => {
655
+ const a = v.value.reduce((y, k) => {
656
656
  if (!s.errors.value)
657
- return h;
657
+ return y;
658
658
  const z = M(s.errors.value, String(k));
659
- return z === void 0 || (h[String(k)] = z), h;
659
+ return z === void 0 || (y[String(k)] = z), y;
660
660
  }, {});
661
661
  if (Object.keys(a).length !== 0)
662
662
  return a;
663
663
  }), E = I(() => {
664
- if (!w.value)
664
+ if (!b.value)
665
665
  return;
666
- const a = Object.keys(w.value).reduce((h, k) => {
666
+ const a = Object.keys(b.value).reduce((y, k) => {
667
667
  var z;
668
- return (z = w.value) != null && z[k] && (h[y.value[k]] = w.value[k]._errors), h;
668
+ return (z = b.value) != null && z[k] && (y[V.value[k]] = b.value[k]._errors), y;
669
669
  }, {});
670
670
  if (Object.keys(a).length !== 0)
671
671
  return a;
672
- }), A = I(() => w.value !== void 0), B = I(() => n.value.reduce((a, h) => {
672
+ }), A = I(() => b.value !== void 0), B = I(() => n.value.reduce((a, y) => {
673
673
  var k;
674
- return a[h] = !!((k = w.value) != null && k[y.value[h]]), a;
674
+ return a[y] = !!((k = b.value) != null && k[V.value[y]]), a;
675
675
  }, {})), S = U(A, () => {
676
676
  if (A.value) {
677
- u("invalid", w.value), b && d.value.forEach((a) => {
678
- var h, k;
679
- if (!((h = w.value) != null && h[a])) {
680
- b.errors.value.delete(
677
+ u("invalid", b.value), m && v.value.forEach((a) => {
678
+ var y, k;
679
+ if (!((y = b.value) != null && y[a])) {
680
+ m.errors.value.delete(
681
681
  a
682
682
  );
683
683
  return;
684
684
  }
685
- b.errors.value.set(
685
+ m.errors.value.set(
686
686
  a,
687
- (k = w.value) == null ? void 0 : k[a]
687
+ (k = b.value) == null ? void 0 : k[a]
688
688
  );
689
689
  });
690
690
  return;
691
691
  }
692
- u("valid", V.value), b && d.value.forEach((a) => {
693
- b.errors.value.delete(
692
+ u("valid", g.value), m && v.value.forEach((a) => {
693
+ m.errors.value.delete(
694
694
  a
695
695
  );
696
696
  });
@@ -701,51 +701,51 @@ function Ge(r, i, e) {
701
701
  },
702
702
  { deep: !0 }
703
703
  );
704
- W(() => {
704
+ J(() => {
705
705
  S(), O();
706
706
  });
707
707
  const l = (a) => {
708
- V.value = a;
709
- }, x = (a, h) => {
710
- h instanceof InputEvent && (h = h.target.value), n.value.includes(a) && (V.value = {
711
- ...V.value,
712
- [a]: h
708
+ g.value = a;
709
+ }, x = (a, y) => {
710
+ y instanceof InputEvent && (y = y.target.value), n.value.includes(a) && (g.value = {
711
+ ...g.value,
712
+ [a]: y
713
713
  });
714
- }, $ = I(() => {
715
- let a = v.value;
714
+ }, R = I(() => {
715
+ let a = d.value;
716
716
  return typeof a == "function" && (a = a(s == null ? void 0 : s.formData)), Object.keys(a).reduce(
717
- (h, k) => (h[k] = K(a[k]), h),
717
+ (y, k) => (y[k] = K(a[k]), y),
718
718
  {}
719
719
  );
720
- }), Z = I(() => s != null && s.readonly.value ? !0 : $.value.readonly ?? c.readonly), q = I(() => n.value.reduce((a, h) => (a[`onUpdate:${h}`] = (k) => {
721
- x(h, k);
720
+ }), Z = I(() => s != null && s.readonly.value ? !0 : R.value.readonly ?? c.readonly), q = I(() => n.value.reduce((a, y) => (a[`onUpdate:${y}`] = (k) => {
721
+ x(y, k);
722
722
  }, a), {
723
723
  "onUpdate:modelValue": l
724
724
  })), T = I(() => ({
725
725
  ...q.value,
726
- ...$.value,
727
- names: $.value.name ?? d.value,
726
+ ...R.value,
727
+ names: R.value.name ?? v.value,
728
728
  invalid: A.value,
729
729
  invalids: B.value,
730
- valid: c.showValid ? !!(!A.value && V.value) : void 0,
730
+ valid: c.showValid ? !!(!A.value && g.value) : void 0,
731
731
  invalidLabels: E.value,
732
- modelValue: V.value,
732
+ modelValue: g.value,
733
733
  readonly: Z.value
734
734
  }));
735
735
  return F(e, {
736
- names: N(f),
737
- errors: N(w)
736
+ names: L(f),
737
+ errors: L(b)
738
738
  }), { component: I(() => ({
739
739
  render() {
740
740
  var a;
741
741
  return ((a = t.default) == null ? void 0 : a.call(t, {
742
- errors: w.value,
742
+ errors: b.value,
743
743
  formData: s == null ? void 0 : s.formData.value,
744
744
  formErrors: s == null ? void 0 : s.errors.value,
745
745
  invalid: A.value,
746
746
  invalids: B.value,
747
747
  invalidLabels: E.value,
748
- modelValue: V.value,
748
+ modelValue: g.value,
749
749
  onUpdate: l,
750
750
  onUpdateField: x,
751
751
  readonly: Z.value,
@@ -756,12 +756,12 @@ function Ge(r, i, e) {
756
756
  })), hasProps: T, invalid: A };
757
757
  },
758
758
  render() {
759
- return this.is ? R(this.is, this.hasProps, this.$slots) : R(this.component, null, this.$slots);
759
+ return this.is ? $(this.is, this.hasProps, this.$slots) : $(this.component, null, this.$slots);
760
760
  }
761
761
  });
762
762
  }
763
- function $e(r, i) {
764
- return J({
763
+ function Re(r, i) {
764
+ return W({
765
765
  name: "VvFormWrapper",
766
766
  props: {
767
767
  name: {
@@ -771,6 +771,10 @@ function $e(r, i) {
771
771
  tag: {
772
772
  type: String,
773
773
  default: void 0
774
+ },
775
+ readonly: {
776
+ type: Boolean,
777
+ default: !1
774
778
  }
775
779
  },
776
780
  emits: ["invalid", "valid"],
@@ -781,6 +785,7 @@ function $e(r, i) {
781
785
  "fieldsErrors",
782
786
  "formData",
783
787
  "invalid",
788
+ "readonly",
784
789
  "reset",
785
790
  "submit",
786
791
  "tag",
@@ -789,39 +794,40 @@ function $e(r, i) {
789
794
  ],
790
795
  slots: Object,
791
796
  setup(e, { emit: c }) {
792
- const t = P(r), u = P(i, void 0), v = C(/* @__PURE__ */ new Map()), f = C(/* @__PURE__ */ new Map()), { name: o } = te(e), g = I(() => t != null && t.invalid.value ? f.value.size > 0 : !1);
793
- U(g, () => {
794
- if (g.value) {
797
+ const t = P(r), u = P(i, void 0), d = C(/* @__PURE__ */ new Map()), f = C(/* @__PURE__ */ new Map()), { name: o } = te(e), w = I(() => t != null && t.invalid.value ? f.value.size > 0 : !1);
798
+ U(w, (m) => {
799
+ if (m) {
795
800
  c("invalid");
796
801
  return;
797
802
  }
798
803
  c("valid");
799
804
  });
800
- const d = {
801
- name: N(o),
805
+ const v = I(() => (t == null ? void 0 : t.readonly.value) || e.readonly), n = {
806
+ name: L(o),
802
807
  errors: f,
803
- invalid: N(g),
804
- fields: v
808
+ invalid: L(w),
809
+ readonly: L(v),
810
+ fields: d
805
811
  };
806
- F(i, d);
807
- const n = I(() => new Map(v.value));
812
+ F(i, n);
813
+ const h = I(() => new Map(d.value));
808
814
  U(
809
- n,
810
- (y, b) => {
811
- u != null && u.fields && (b.forEach((s, V) => {
812
- y.has(V) || u == null || u.fields.value.delete(V);
813
- }), y.forEach((s, V) => {
814
- u != null && u.fields.value.has(V) || u == null || u.fields.value.set(V, s);
815
+ h,
816
+ (m, s) => {
817
+ u != null && u.fields && (s.forEach((g, b) => {
818
+ m.has(b) || u == null || u.fields.value.delete(b);
819
+ }), m.forEach((g, b) => {
820
+ u != null && u.fields.value.has(b) || u == null || u.fields.value.set(b, g);
815
821
  }));
816
822
  },
817
823
  { deep: !0 }
818
824
  ), U(
819
825
  f,
820
- (y) => {
821
- u != null && u.errors && v.value.forEach((b) => {
822
- if (y.has(b) || u.errors.value.delete(b), y.has(b)) {
823
- const s = y.get(b);
824
- s && u.errors.value.set(b, s);
826
+ (m) => {
827
+ u != null && u.errors && d.value.forEach((s) => {
828
+ if (m.has(s) || u.errors.value.delete(s), m.has(s)) {
829
+ const g = m.get(s);
830
+ g && u.errors.value.set(s, g);
825
831
  }
826
832
  });
827
833
  },
@@ -835,22 +841,23 @@ function $e(r, i) {
835
841
  console.warn(`[@volverjs/form-vue]: wrapper name "${o.value}" is already used`);
836
842
  return;
837
843
  }
838
- t.wrappers.set(o.value, d);
839
- }), W(() => {
844
+ t.wrappers.set(o.value, n);
845
+ }), J(() => {
840
846
  t != null && t.wrappers && o.value && t.wrappers.delete(o.value);
841
847
  });
842
- const m = () => (t == null ? void 0 : t.validate(void 0, new Set(v.value.values()))) ?? Promise.resolve(!0);
848
+ const V = () => (t == null ? void 0 : t.validate(void 0, new Set(d.value.values()))) ?? Promise.resolve(!0);
843
849
  return {
844
850
  errors: t == null ? void 0 : t.errors,
845
- fields: v,
851
+ fields: d,
846
852
  fieldsErrors: f,
847
853
  formData: t == null ? void 0 : t.formData,
848
- invalid: g,
854
+ invalid: w,
855
+ readonly: v,
849
856
  clear: t == null ? void 0 : t.clear,
850
857
  reset: t == null ? void 0 : t.reset,
851
858
  submit: t == null ? void 0 : t.submit,
852
859
  validate: t == null ? void 0 : t.validate,
853
- validateWrapper: m
860
+ validateWrapper: V
854
861
  };
855
862
  },
856
863
  render() {
@@ -861,6 +868,7 @@ function $e(r, i) {
861
868
  fieldsErrors: this.fieldsErrors,
862
869
  formData: this.formData,
863
870
  invalid: this.invalid,
871
+ readonly: this.readonly,
864
872
  clear: this.clear,
865
873
  reset: this.reset,
866
874
  submit: this.submit,
@@ -868,14 +876,14 @@ function $e(r, i) {
868
876
  validateWrapper: this.validateWrapper
869
877
  });
870
878
  };
871
- return this.tag ? R(this.tag, null, {
879
+ return this.tag ? $(this.tag, null, {
872
880
  default: e
873
881
  }) : e();
874
882
  }
875
883
  });
876
884
  }
877
- function Re(r, i) {
878
- const e = J({
885
+ function $e(r, i) {
886
+ const e = W({
879
887
  name: "VvFormTemplate",
880
888
  props: {
881
889
  schema: {
@@ -892,54 +900,54 @@ function Re(r, i) {
892
900
  const u = P(r);
893
901
  if (u != null && u.formData)
894
902
  return () => {
895
- var g;
896
- const v = typeof c.schema == "function" ? c.schema(
903
+ var w;
904
+ const d = typeof c.schema == "function" ? c.schema(
897
905
  u,
898
906
  c.scope
899
907
  ) : c.schema;
900
908
  let f;
901
- const o = v.reduce((d, n) => {
902
- const m = typeof n == "function" ? n(u, c.scope) : n, {
903
- vvIs: y,
904
- vvName: b,
909
+ const o = d.reduce((v, n) => {
910
+ const h = typeof n == "function" ? n(u, c.scope) : n, {
911
+ vvIs: V,
912
+ vvName: m,
905
913
  vvSlots: s,
906
- vvChildren: V,
907
- vvIf: w,
914
+ vvChildren: g,
915
+ vvIf: b,
908
916
  vvElseIf: E,
909
917
  vvType: A,
910
918
  vvDefaultValue: B,
911
919
  vvShowValid: S,
912
920
  vvContent: O,
913
921
  ...l
914
- } = m;
915
- if (w !== void 0) {
916
- if (typeof w == "string" ? f = !!M(
922
+ } = h;
923
+ if (b !== void 0) {
924
+ if (typeof b == "string" ? f = !!M(
917
925
  new Object(u.formData.value),
918
- w
919
- ) : typeof w == "function" ? f = K(w(u)) : f = K(w), !f)
920
- return d;
926
+ b
927
+ ) : typeof b == "function" ? f = K(b(u)) : f = K(b), !f)
928
+ return v;
921
929
  } else if (E !== void 0 && f !== void 0) {
922
930
  if (f || (typeof E == "string" ? f = !!M(
923
931
  new Object(u.formData.value),
924
932
  E
925
933
  ) : typeof E == "function" ? f = K(E(u)) : f = K(E), !f))
926
- return d;
934
+ return v;
927
935
  } else
928
936
  f = void 0;
929
937
  let x;
930
- return V && (typeof y == "string" ? x = R(e, {
931
- schema: V
938
+ return g && (typeof V == "string" ? x = $(e, {
939
+ schema: g
932
940
  }) : x = {
933
- default: ($) => R(e, {
934
- schema: V,
935
- scope: $
941
+ default: (R) => $(e, {
942
+ schema: g,
943
+ scope: R
936
944
  })
937
- }), b ? (d.push(
938
- R(
945
+ }), m ? (v.push(
946
+ $(
939
947
  i,
940
948
  {
941
- name: b,
942
- is: y,
949
+ name: m,
950
+ is: V,
943
951
  type: A,
944
952
  defaultValue: B,
945
953
  showValid: S,
@@ -947,16 +955,16 @@ function Re(r, i) {
947
955
  },
948
956
  s ?? x ?? O
949
957
  )
950
- ), d) : y ? (d.push(
951
- R(
952
- y,
958
+ ), v) : V ? (v.push(
959
+ $(
960
+ V,
953
961
  l,
954
962
  s ?? x ?? O
955
963
  )
956
- ), d) : (x && ("default" in x ? d.push(x.default(c.scope)) : d.push(x)), d);
964
+ ), v) : (x && ("default" in x ? v.push(x.default(c.scope)) : v.push(x)), v);
957
965
  }, []);
958
966
  return o.push(
959
- (g = t == null ? void 0 : t.default) == null ? void 0 : g.call(t, {
967
+ (w = t == null ? void 0 : t.default) == null ? void 0 : w.call(t, {
960
968
  errors: u == null ? void 0 : u.errors.value,
961
969
  formData: u == null ? void 0 : u.formData.value,
962
970
  invalid: u == null ? void 0 : u.invalid.value,
@@ -973,7 +981,7 @@ function Re(r, i) {
973
981
  return e;
974
982
  }
975
983
  function D(r, i = {}) {
976
- const e = Symbol("formInjectionKey"), c = Symbol("formWrapperInjectionKey"), t = Symbol("formFieldInjectionKey"), u = Symbol("formFieldsGroupInjectionKey"), v = $e(
984
+ const e = Symbol("formInjectionKey"), c = Symbol("formWrapperInjectionKey"), t = Symbol("formFieldInjectionKey"), u = Symbol("formFieldsGroupInjectionKey"), d = Re(
977
985
  e,
978
986
  c
979
987
  ), f = Ae(
@@ -985,41 +993,41 @@ function D(r, i = {}) {
985
993
  e,
986
994
  c,
987
995
  u
988
- ), g = Re(e, f), d = /* @__PURE__ */ new Map(), {
996
+ ), w = $e(e, f), v = /* @__PURE__ */ new Map(), {
989
997
  clear: n,
990
- errors: m,
991
- formData: y,
992
- ignoreUpdates: b,
998
+ errors: h,
999
+ formData: V,
1000
+ ignoreUpdates: m,
993
1001
  invalid: s,
994
- readonly: V,
995
- reset: w,
1002
+ readonly: g,
1003
+ reset: b,
996
1004
  status: E,
997
1005
  stopUpdatesWatch: A,
998
1006
  submit: B,
999
1007
  validate: S,
1000
1008
  VvForm: O
1001
- } = Ie(r, e, i, g, d);
1009
+ } = Ie(r, e, i, w, v);
1002
1010
  return {
1003
1011
  clear: n,
1004
- errors: m,
1005
- formData: y,
1012
+ errors: h,
1013
+ formData: V,
1006
1014
  formFieldInjectionKey: t,
1007
1015
  formInjectionKey: e,
1008
1016
  formWrapperInjectionKey: c,
1009
- ignoreUpdates: b,
1017
+ ignoreUpdates: m,
1010
1018
  invalid: s,
1011
- readonly: V,
1012
- reset: w,
1019
+ readonly: g,
1020
+ reset: b,
1013
1021
  status: E,
1014
1022
  stopUpdatesWatch: A,
1015
1023
  submit: B,
1016
1024
  validate: S,
1017
- wrappers: d,
1025
+ wrappers: v,
1018
1026
  VvForm: O,
1019
1027
  VvFormField: f,
1020
1028
  VvFormFieldsGroup: o,
1021
- VvFormTemplate: g,
1022
- VvFormWrapper: v
1029
+ VvFormTemplate: w,
1030
+ VvFormWrapper: d
1023
1031
  };
1024
1032
  }
1025
1033
  const de = Symbol("pluginInjectionKey");
@@ -1036,7 +1044,7 @@ const Q = /* @__PURE__ */ new Map();
1036
1044
  function Ne(r, i = {}) {
1037
1045
  if (i.scope && Q.has(i.scope))
1038
1046
  return Q.get(i.scope);
1039
- if (!ye()) {
1047
+ if (!he()) {
1040
1048
  const c = D(r, i);
1041
1049
  return i.scope && Q.set(i.scope, c), c;
1042
1050
  }