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