@volverjs/form-vue 1.0.0-beta.25 → 1.0.0-beta.26

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