@teamnovu/kit-vue-forms 0.1.16 → 0.1.18

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.js CHANGED
@@ -1,17 +1,17 @@
1
- var H = Object.defineProperty;
2
- var Z = (t, e, r) => e in t ? H(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var S = (t, e, r) => Z(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { toValue as q, toRaw as Q, computed as p, unref as d, isRef as U, shallowRef as B, reactive as $, watch as P, toRefs as J, shallowReactive as X, toRef as O, onScopeDispose as Y, watchEffect as ee, triggerRef as re, ref as L, getCurrentScope as te, onBeforeUnmount as ae, defineComponent as k, renderSlot as b, normalizeProps as M, guardReactiveProps as z, resolveComponent as se, createBlock as K, openBlock as T, withCtx as j, resolveDynamicComponent as ne, mergeProps as oe, createSlots as ie, renderList as le } from "vue";
5
- import { cloneDeep as ce } from "lodash-es";
1
+ var Q = Object.defineProperty;
2
+ var X = (t, e, r) => e in t ? Q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var S = (t, e, r) => X(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { toValue as Y, toRaw as ee, computed as v, unref as d, isRef as k, shallowRef as j, reactive as _, watch as P, toRefs as T, shallowReactive as re, toRef as I, onScopeDispose as te, triggerRef as ae, ref as J, getCurrentScope as se, onBeforeUnmount as ne, defineComponent as x, renderSlot as $, normalizeProps as M, guardReactiveProps as N, resolveComponent as ie, createBlock as H, openBlock as K, withCtx as B, resolveDynamicComponent as oe, mergeProps as le, createSlots as ce, renderList as ue } from "vue";
5
+ import { cloneDeep as de } from "lodash-es";
6
6
  import "zod";
7
7
  function g(t) {
8
- const e = q(t), r = Q(e);
9
- return ce(r);
8
+ const e = Y(t), r = ee(e);
9
+ return de(r);
10
10
  }
11
11
  function W(t) {
12
12
  return t === "" ? [] : t.split(/\s*\.\s*/).filter(Boolean);
13
13
  }
14
- function ue(t, e) {
14
+ function fe(t, e) {
15
15
  const r = Array.isArray(e) ? e : W(e);
16
16
  return !!D(t, r.slice(0, -1));
17
17
  }
@@ -21,33 +21,33 @@ function D(t, e) {
21
21
  t
22
22
  );
23
23
  }
24
- function de(t, e, r) {
24
+ function he(t, e, r) {
25
25
  const a = Array.isArray(e) ? e : W(e), s = a.at(-1);
26
26
  if (s) {
27
27
  const n = a.slice(0, -1).reduce(
28
- (f, m) => ((f == null ? void 0 : f[m]) === void 0 && (f[m] = {}), f == null ? void 0 : f[m]),
28
+ (f, p) => ((f == null ? void 0 : f[p]) === void 0 && (f[p] = {}), f == null ? void 0 : f[p]),
29
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
30
  d(t)
31
31
  );
32
32
  n[s] = r;
33
33
  } else {
34
- if (!U(t))
34
+ if (!k(t))
35
35
  return;
36
36
  t.value = r;
37
37
  }
38
38
  }
39
- const x = (t, e) => p({
39
+ const L = (t, e) => v({
40
40
  get() {
41
41
  return D(d(t), d(e));
42
42
  },
43
43
  set(r) {
44
- de(t, d(e), r);
44
+ he(t, d(e), r);
45
45
  }
46
46
  });
47
- function _(t, e) {
47
+ function b(t, e) {
48
48
  return !t && !e ? "" : !t && e ? e : !e && t ? t : `${t}.${e}`;
49
49
  }
50
- function fe(t, e) {
50
+ function ve(t, e) {
51
51
  if (!e)
52
52
  return t;
53
53
  const r = `${e}.`, a = Object.fromEntries(
@@ -62,7 +62,7 @@ function fe(t, e) {
62
62
  propertyErrors: a
63
63
  };
64
64
  }
65
- class he {
65
+ class me {
66
66
  constructor(e) {
67
67
  S(this, "rc", 1);
68
68
  this.drop = e;
@@ -80,7 +80,7 @@ function pe(t) {
80
80
  existsInForm: !0
81
81
  },
82
82
  ...t
83
- }, a = B(Object.freeze(g(r.initialValue))), s = $({
83
+ }, a = j(Object.freeze(g(r.initialValue))), s = _({
84
84
  value: r.value,
85
85
  path: r.path,
86
86
  initialValue: a,
@@ -88,18 +88,18 @@ function pe(t) {
88
88
  touched: !1
89
89
  });
90
90
  P(
91
- B(r.initialValue),
91
+ j(r.initialValue),
92
92
  () => {
93
93
  a.value = Object.freeze(g(r.initialValue)), s.value = g(r.initialValue);
94
94
  },
95
95
  { flush: "sync" }
96
96
  );
97
- const n = p(() => JSON.stringify(s.value) !== JSON.stringify(s.initialValue)), f = (h) => {
97
+ const n = v(() => JSON.stringify(s.value) !== JSON.stringify(s.initialValue)), f = (h) => {
98
98
  s.value = h;
99
- }, m = () => {
99
+ }, p = () => {
100
100
  var h;
101
101
  s.touched = !0, s.errors = [], (h = r.onBlur) == null || h.call(r);
102
- }, y = () => {
102
+ }, F = () => {
103
103
  var h;
104
104
  (h = r.onFocus) == null || h.call(r);
105
105
  }, V = () => {
@@ -109,116 +109,118 @@ function pe(t) {
109
109
  n.value || f(g(h)), s.initialValue = h;
110
110
  }, c = (h) => {
111
111
  s.errors = h;
112
- }, i = () => {
112
+ }, o = () => {
113
113
  s.errors = [];
114
- }, o = J(s);
114
+ }, i = T(s);
115
115
  return {
116
- data: o.value,
117
- path: o.path,
118
- initialValue: o.initialValue,
119
- errors: o.errors,
120
- touched: o.touched,
116
+ data: i.value,
117
+ path: i.path,
118
+ initialValue: i.initialValue,
119
+ errors: i.errors,
120
+ touched: i.touched,
121
121
  dirty: n,
122
122
  setData: f,
123
123
  setInitialData: l,
124
- onBlur: m,
125
- onFocus: y,
124
+ onBlur: p,
125
+ onFocus: F,
126
126
  reset: V,
127
127
  setErrors: c,
128
- clearErrors: i
128
+ clearErrors: o
129
129
  };
130
130
  }
131
- const ve = {
131
+ const Ve = {
132
132
  keepValuesOnUnmount: !0
133
133
  };
134
- function me(t) {
135
- const e = B(t());
136
- return ee(
134
+ function Fe(t, e) {
135
+ const r = () => D(t.initialData, e), a = j(r());
136
+ return P(
137
+ () => t.initialData,
137
138
  () => {
138
- e.value = t(), re(e);
139
+ a.value = r(), ae(a);
139
140
  },
140
141
  { flush: "sync" }
141
- ), e;
142
+ ), a;
142
143
  }
143
- function Ve(t, e, r) {
144
- const a = /* @__PURE__ */ new Map(), s = X(/* @__PURE__ */ new Map()), n = {
145
- ...ve,
144
+ function ye(t, e, r) {
145
+ const a = /* @__PURE__ */ new Map(), s = re(/* @__PURE__ */ new Map()), n = {
146
+ ...Ve,
146
147
  ...r
147
- }, f = (i) => {
148
- const o = d(i.path);
149
- s.set(o, i);
150
- }, m = (i) => {
151
- var o;
152
- n != null && n.keepValuesOnUnmount || (o = s.get(i)) == null || o.reset(), s.delete(i);
153
- }, y = (i) => {
154
- var o;
155
- a.has(i) ? (o = a.get(i)) == null || o.inc() : a.set(i, new he(() => m(i)));
156
- }, V = (i) => {
157
- var o;
158
- a.has(i) && ((o = a.get(i)) == null || o.dec());
159
- }, l = (i) => {
160
- const { path: o } = i;
161
- if (!s.has(o)) {
162
- const N = pe({
163
- path: o,
164
- value: x(O(t, "data"), o),
165
- initialValue: me(() => D(t.initialData, o)),
166
- existsInForm: p(() => ue(t.data, d(o))),
167
- errors: p({
148
+ }, f = (o) => {
149
+ const i = d(o.path);
150
+ s.set(i, o);
151
+ }, p = (o) => {
152
+ var i;
153
+ n != null && n.keepValuesOnUnmount || (i = s.get(o)) == null || i.reset(), s.delete(o);
154
+ }, F = (o) => {
155
+ var i;
156
+ a.has(o) ? (i = a.get(o)) == null || i.inc() : a.set(o, new me(() => p(o)));
157
+ }, V = (o) => {
158
+ var i;
159
+ a.has(o) && ((i = a.get(o)) == null || i.dec());
160
+ }, l = (o) => {
161
+ const { path: i } = o;
162
+ if (!s.has(i)) {
163
+ const A = pe({
164
+ path: i,
165
+ value: L(I(t, "data"), i),
166
+ initialValue: Fe(t, i),
167
+ existsInForm: v(() => fe(t.data, d(i))),
168
+ errors: v({
168
169
  get() {
169
- return e.errors.value.propertyErrors[o] || [];
170
+ return e.errors.value.propertyErrors[i] || [];
170
171
  },
171
172
  set(E) {
172
- e.errors.value.propertyErrors[o] = E;
173
+ e.errors.value.propertyErrors[i] = E;
173
174
  }
174
175
  }),
175
176
  onBlur: async () => {
176
177
  var E, R;
177
- await Promise.all(
178
- [
179
- (E = n == null ? void 0 : n.onBlur) == null ? void 0 : E.call(n, d(o)),
180
- (R = i.onBlur) == null ? void 0 : R.call(i)
181
- ]
182
- );
178
+ await Promise.all([
179
+ (E = n == null ? void 0 : n.onBlur) == null ? void 0 : E.call(n, d(i)),
180
+ (R = o.onBlur) == null ? void 0 : R.call(o)
181
+ ]);
183
182
  },
184
183
  onFocus: async () => {
185
184
  var E, R;
186
- await Promise.all(
187
- [
188
- (E = n == null ? void 0 : n.onFocus) == null ? void 0 : E.call(n, d(o)),
189
- (R = i.onFocus) == null ? void 0 : R.call(i)
190
- ]
191
- );
185
+ await Promise.all([
186
+ (E = n == null ? void 0 : n.onFocus) == null ? void 0 : E.call(n, d(i)),
187
+ (R = o.onFocus) == null ? void 0 : R.call(o)
188
+ ]);
192
189
  }
193
190
  });
194
- f(N);
191
+ f(A);
195
192
  }
196
- const h = s.get(o);
197
- return y(o), Y(() => {
198
- V(o);
193
+ const h = s.get(i);
194
+ return F(i), te(() => {
195
+ V(i);
199
196
  }), h;
200
- }, c = (i) => l(i);
197
+ }, c = (o) => l(o);
201
198
  return {
202
- fields: p(() => [...s.values()]),
203
- getField: (i) => l({ path: i }),
199
+ fields: v(() => [...s.values()]),
200
+ getField: (o) => l({ path: o }),
204
201
  registerField: f,
205
- deregisterField: m,
202
+ deregisterField: p,
206
203
  defineField: c
207
204
  };
208
205
  }
209
- function ye(t) {
210
- const e = p(() => t.fields.value.some((a) => d(a.dirty))), r = p(() => t.fields.value.some((a) => d(a.touched)));
206
+ function ge(t) {
207
+ const e = v(() => t.fields.value.some((a) => d(a.dirty))), r = v(() => t.fields.value.some((a) => d(a.touched)));
211
208
  return {
212
209
  isDirty: e,
213
210
  isTouched: r
214
211
  };
215
212
  }
216
- function Fe(t) {
213
+ function G(t, e) {
214
+ return (r) => async (a) => {
215
+ a.preventDefault(), d(e.validationStrategy) !== "none" && await t.validateForm(), t.isValid.value && await r(t.data.value);
216
+ };
217
+ }
218
+ function Ee(t) {
217
219
  return t.filter(
218
220
  (e, r, a) => a.indexOf(e) === r
219
221
  );
220
222
  }
221
- function G(...t) {
223
+ function Z(...t) {
222
224
  return t.slice(1).reduce((e, r) => {
223
225
  if (!e && !r)
224
226
  return;
@@ -228,15 +230,15 @@ function G(...t) {
228
230
  if (!a)
229
231
  return e;
230
232
  const s = (e ?? []).concat(r);
231
- return Fe(s);
233
+ return Ee(s);
232
234
  }, t[0]);
233
235
  }
234
- function ge(...t) {
236
+ function we(...t) {
235
237
  return t.map((r) => Object.keys(r)).flat().reduce((r, a) => {
236
238
  const s = t.map((n) => n[a]).filter(Boolean);
237
239
  return {
238
240
  ...r,
239
- [a]: G(...s)
241
+ [a]: Z(...s)
240
242
  };
241
243
  }, {});
242
244
  }
@@ -249,18 +251,18 @@ function C(...t) {
249
251
  const e = t[0];
250
252
  return t.length === 1 ? e : t.slice(1).reduce(
251
253
  (r, a) => ({
252
- general: G(r.general, a.general),
253
- propertyErrors: ge(r.propertyErrors ?? {}, a.propertyErrors ?? {})
254
+ general: Z(r.general, a.general),
255
+ propertyErrors: we(r.propertyErrors ?? {}, a.propertyErrors ?? {})
254
256
  }),
255
257
  e
256
258
  );
257
259
  }
258
- function A(t) {
260
+ function O(t) {
259
261
  var a;
260
262
  const e = (((a = t.general) == null ? void 0 : a.length) ?? 0) > 0, r = Object.entries(t.propertyErrors).filter(([, s]) => s == null ? void 0 : s.length).length > 0;
261
263
  return e || r;
262
264
  }
263
- function Ee(t) {
265
+ function Re(t) {
264
266
  const e = t.issues.filter((a) => a.path.length === 0).map((a) => a.message), r = t.issues.filter((a) => a.path.length > 0).reduce((a, s) => {
265
267
  const n = s.path.join(".");
266
268
  return {
@@ -273,24 +275,24 @@ function Ee(t) {
273
275
  propertyErrors: r
274
276
  };
275
277
  }
276
- const F = {
278
+ const y = {
277
279
  isValid: !0,
278
280
  errors: {
279
281
  general: [],
280
282
  propertyErrors: {}
281
283
  }
282
284
  };
283
- class we {
285
+ class Pe {
284
286
  constructor(e) {
285
287
  this.schema = e;
286
288
  }
287
289
  async validate(e) {
288
290
  if (!this.schema)
289
- return F;
291
+ return y;
290
292
  const r = await this.schema.safeParseAsync(e);
291
293
  if (r.success)
292
- return F;
293
- const a = Ee(r.error);
294
+ return y;
295
+ const a = Re(r.error);
294
296
  return {
295
297
  isValid: !1,
296
298
  errors: {
@@ -300,16 +302,16 @@ class we {
300
302
  };
301
303
  }
302
304
  }
303
- class Re {
305
+ class De {
304
306
  constructor(e) {
305
307
  this.validateFn = e;
306
308
  }
307
309
  async validate(e) {
308
310
  if (!this.validateFn)
309
- return F;
311
+ return y;
310
312
  try {
311
313
  const r = await this.validateFn(e);
312
- return r.isValid ? F : r;
314
+ return r.isValid ? y : r;
313
315
  } catch (r) {
314
316
  return {
315
317
  isValid: !1,
@@ -321,11 +323,11 @@ class Re {
321
323
  }
322
324
  }
323
325
  }
324
- class Pe {
326
+ class Se {
325
327
  constructor(e, r) {
326
328
  S(this, "schemaValidator");
327
329
  S(this, "functionValidator");
328
- this.schema = e, this.validateFn = r, this.schemaValidator = new we(this.schema), this.functionValidator = new Re(this.validateFn);
330
+ this.schema = e, this.validateFn = r, this.schemaValidator = new Pe(this.schema), this.functionValidator = new De(this.validateFn);
329
331
  }
330
332
  async validate(e) {
331
333
  const [r, a] = await Promise.all([
@@ -338,19 +340,19 @@ class Pe {
338
340
  };
339
341
  }
340
342
  }
341
- function I(t) {
342
- return p(() => new Pe(
343
+ function U(t) {
344
+ return v(() => new Se(
343
345
  d(t.schema),
344
346
  d(t.validateFn)
345
347
  ));
346
348
  }
347
- function De(t, e) {
348
- const r = $({
349
- validators: L([I(e)]),
349
+ function be(t, e) {
350
+ const r = _({
351
+ validators: J([U(e)]),
350
352
  isValidated: !1,
351
- errors: d(e.errors) ?? F.errors
352
- }), a = (l = F.errors) => {
353
- r.errors = C(d(e.errors) ?? F.errors, l);
353
+ errors: d(e.errors) ?? y.errors
354
+ }), a = (l = y.errors) => {
355
+ r.errors = C(d(e.errors) ?? y.errors, l);
354
356
  };
355
357
  P(() => d(e.errors), async () => {
356
358
  if (r.isValidated) {
@@ -366,41 +368,41 @@ function De(t, e) {
366
368
  const c = await n();
367
369
  r.errors = c.errors;
368
370
  } else
369
- r.errors = F.errors;
371
+ r.errors = y.errors;
370
372
  },
371
373
  { immediate: !0 }
372
374
  ), P([() => t.data, () => d(e.schema)], () => {
373
375
  r.isValidated && f();
374
376
  });
375
377
  const s = (l) => {
376
- const c = U(l) ? l : I(l);
377
- return r.validators.push(c), te() && ae(() => {
378
+ const c = k(l) ? l : U(l);
379
+ return r.validators.push(c), se() && ne(() => {
378
380
  r.validators = r.validators.filter(
379
- (i) => i !== c
381
+ (o) => o !== c
380
382
  );
381
383
  }), c;
382
384
  };
383
385
  async function n() {
384
386
  const l = await Promise.all(
385
- r.validators.filter((o) => d(o) !== void 0).map((o) => d(o).validate(t.data))
386
- ), c = l.every((o) => o.isValid);
387
- let { errors: i } = F;
387
+ r.validators.filter((i) => d(i) !== void 0).map((i) => d(i).validate(t.data))
388
+ ), c = l.every((i) => i.isValid);
389
+ let { errors: o } = y;
388
390
  if (!c) {
389
- const o = l.map((h) => h.errors);
390
- i = C(...o);
391
+ const i = l.map((h) => h.errors);
392
+ o = C(...i);
391
393
  }
392
394
  return {
393
- errors: i,
395
+ errors: o,
394
396
  isValid: c
395
397
  };
396
398
  }
397
399
  const f = async () => {
398
400
  const l = await n();
399
401
  return a(l.errors), r.isValidated = !0, {
400
- isValid: !A(l.errors),
402
+ isValid: !O(l.errors),
401
403
  errors: r.errors
402
404
  };
403
- }, m = async (l) => {
405
+ }, p = async (l) => {
404
406
  const c = await n();
405
407
  return a({
406
408
  general: c.errors.general,
@@ -408,99 +410,105 @@ function De(t, e) {
408
410
  [l]: c.errors.propertyErrors[l]
409
411
  }
410
412
  }), {
411
- isValid: !A(c.errors),
413
+ isValid: !O(c.errors),
412
414
  errors: r.errors
413
415
  };
414
- }, y = p(() => !A(r.errors)), V = () => {
415
- r.isValidated = !1, r.errors = d(e.errors) ?? F.errors;
416
+ }, F = v(() => !O(r.errors)), V = () => {
417
+ r.isValidated = !1, r.errors = d(e.errors) ?? y.errors;
416
418
  };
417
419
  return {
418
- ...J(r),
420
+ ...T(r),
419
421
  validateForm: f,
420
- validateField: m,
422
+ validateField: p,
421
423
  defineValidator: s,
422
- isValid: y,
424
+ isValid: F,
423
425
  reset: V
424
426
  };
425
427
  }
426
- class Se {
428
+ class $e {
427
429
  constructor(e, r) {
428
430
  this.path = e, this.validator = r;
429
431
  }
430
432
  async validate(e) {
431
433
  const r = D(e, this.path);
432
434
  if (!this.validator)
433
- return F;
435
+ return y;
434
436
  const a = await this.validator.validate(r);
435
437
  return {
436
438
  isValid: a.isValid,
437
439
  errors: {
438
440
  general: a.errors.general || [],
439
441
  propertyErrors: a.errors.propertyErrors ? Object.fromEntries(
440
- Object.entries(a.errors.propertyErrors).map(([s, n]) => [
441
- _(this.path, s),
442
- n
443
- ])
442
+ Object.entries(a.errors.propertyErrors).map(
443
+ ([s, n]) => [b(this.path, s), n]
444
+ )
444
445
  ) : {}
445
446
  }
446
447
  };
447
448
  }
448
449
  }
449
- function _e(t, e, r) {
450
- const a = x(t.data, e), s = p(() => D(t.initialData.value, e)), n = (u) => ({
450
+ function _e(t, e, r, a) {
451
+ const s = L(t.data, e), n = v(() => D(t.initialData.value, e)), f = (u) => ({
451
452
  ...u,
452
- path: p(() => d(u.path).replace(e + ".", "")),
453
- setData: (v) => {
454
- u.setData(v);
453
+ path: v(() => d(u.path).replace(e + ".", "")),
454
+ setData: (m) => {
455
+ u.setData(m);
455
456
  }
456
- }), f = (u) => {
457
- const v = _(e, u), w = t.getField(v);
458
- return w ? n(w) : {};
459
- }, m = (u) => {
460
- const v = _(e, u.path), w = t.defineField({
457
+ }), p = (u) => {
458
+ const m = b(e, u), w = t.getField(m);
459
+ return w ? f(w) : {};
460
+ }, F = (u) => {
461
+ const m = b(e, u.path), w = t.defineField({
461
462
  ...u,
462
- path: v
463
+ path: m
463
464
  });
464
- return n(w);
465
- }, y = p(() => t.fields.value.filter((u) => {
466
- const v = u.path.value;
467
- return v.startsWith(e + ".") || v === e;
468
- }).map((u) => n(u))), V = () => t.fields.value.filter((u) => {
469
- const v = u.path.value;
470
- return v.startsWith(e + ".") || v === e;
471
- }), l = p(() => V().some((u) => u.dirty.value)), c = p(() => V().some((u) => u.touched.value)), i = p(() => t.isValid.value), o = p(() => t.isValidated.value), h = p(() => fe(d(t.errors), e));
472
- return {
473
- data: a,
474
- fields: y,
475
- initialData: s,
476
- defineField: m,
477
- getField: f,
478
- isDirty: l,
479
- isTouched: c,
465
+ return f(w);
466
+ }, V = v(() => t.fields.value.filter((u) => {
467
+ const m = u.path.value;
468
+ return m.startsWith(e + ".") || m === e;
469
+ }).map((u) => f(u))), l = () => t.fields.value.filter((u) => {
470
+ const m = u.path.value;
471
+ return m.startsWith(e + ".") || m === e;
472
+ }), c = v(
473
+ () => l().some((u) => u.dirty.value)
474
+ ), o = v(
475
+ () => l().some((u) => u.touched.value)
476
+ ), i = v(() => t.isValid.value), h = v(() => t.isValidated.value), A = v(
477
+ () => ve(d(t.errors), e)
478
+ ), z = {
479
+ data: s,
480
+ fields: V,
481
+ initialData: n,
482
+ defineField: F,
483
+ getField: p,
484
+ isDirty: c,
485
+ isTouched: o,
480
486
  isValid: i,
481
- isValidated: o,
482
- errors: h,
487
+ isValidated: h,
488
+ errors: A,
483
489
  defineValidator: (u) => {
484
- const v = U(u) ? u : I(u), w = p(
485
- () => new Se(e, d(v))
490
+ const m = k(u) ? u : U(u), w = v(
491
+ () => new $e(e, d(m))
486
492
  );
487
- return t.defineValidator(w), v;
493
+ return t.defineValidator(w), m;
488
494
  },
489
- reset: () => V().forEach((u) => u.reset()),
495
+ reset: () => l().forEach((u) => u.reset()),
490
496
  validateForm: () => t.validateForm(),
491
- getSubForm: (u, v) => {
492
- const w = _(e, u);
497
+ getSubForm: (u, m) => {
498
+ const w = b(e, u);
493
499
  return t.getSubForm(
494
500
  w,
495
- v
501
+ m
496
502
  );
497
503
  }
504
+ }, q = G(z, r ?? {});
505
+ return {
506
+ ...z,
507
+ submitHandler: q
498
508
  };
499
509
  }
500
- function Oe(t) {
501
- const e = p(
502
- () => Object.freeze(g(t.initialData))
503
- ), r = L(g(e)), a = $({
510
+ function Ue(t) {
511
+ const e = v(() => g(t.initialData)), r = J(g(e)), a = _({
504
512
  initialData: e,
505
513
  data: r
506
514
  });
@@ -511,34 +519,34 @@ function Oe(t) {
511
519
  },
512
520
  { flush: "sync" }
513
521
  );
514
- const s = De(a, t), n = Ve(a, s, {
522
+ const s = be(a, t), n = ye(a, s, {
515
523
  keepValuesOnUnmount: t.keepValuesOnUnmount,
516
524
  onBlur: async (c) => {
517
525
  d(t.validationStrategy) === "onTouch" && s.validateField(c);
518
526
  }
519
- }), f = ye(n), m = (c) => async (i) => {
520
- i.preventDefault(), d(t.validationStrategy) !== "none" && await s.validateForm(), s.isValid.value && await c(a.data);
521
- }, y = () => {
527
+ }), f = ge(n), p = () => {
522
528
  r.value = g(e), s.reset();
523
529
  for (const c of n.fields.value)
524
530
  c.reset();
525
531
  };
526
- function V(c, i) {
527
- return _e(l, c);
532
+ function F(c, o) {
533
+ return _e(V, c, t);
528
534
  }
529
- const l = {
535
+ const V = {
530
536
  ...n,
531
537
  ...s,
532
538
  ...f,
533
- reset: y,
534
- getSubForm: V,
535
- submitHandler: m,
536
- initialData: O(a, "initialData"),
537
- data: O(a, "data")
539
+ reset: p,
540
+ getSubForm: F,
541
+ initialData: I(a, "initialData"),
542
+ data: I(a, "data")
543
+ }, l = G(V, t);
544
+ return d(t.validationStrategy) === "onFormOpen" && s.validateForm(), {
545
+ ...V,
546
+ submitHandler: l
538
547
  };
539
- return d(t.validationStrategy) === "onFormOpen" && s.validateForm(), l;
540
548
  }
541
- const Ce = /* @__PURE__ */ k({
549
+ const ke = /* @__PURE__ */ x({
542
550
  __name: "Field",
543
551
  props: {
544
552
  form: {},
@@ -553,10 +561,10 @@ const Ce = /* @__PURE__ */ k({
553
561
  setup(t) {
554
562
  const e = t, r = e.form.defineField({
555
563
  path: e.path
556
- }), a = $(r);
557
- return (s, n) => b(s.$slots, "default", M(z(a)));
564
+ }), a = _(r);
565
+ return (s, n) => $(s.$slots, "default", M(N(a)));
558
566
  }
559
- }), Ie = /* @__PURE__ */ k({
567
+ }), xe = /* @__PURE__ */ x({
560
568
  inheritAttrs: !1,
561
569
  __name: "FormFieldWrapper",
562
570
  props: {
@@ -567,27 +575,27 @@ const Ce = /* @__PURE__ */ k({
567
575
  },
568
576
  setup(t) {
569
577
  return (e, r) => {
570
- const a = se("Field");
571
- return T(), K(a, {
572
- form: e.form,
573
- path: e.path
578
+ const a = ie("Field");
579
+ return K(), H(a, {
580
+ form: t.form,
581
+ path: t.path
574
582
  }, {
575
- default: j(({ errors: s, data: n, setData: f }) => [
576
- (T(), K(ne(e.component), oe({ ...e.componentProps, ...e.$attrs }, {
583
+ default: B(({ errors: s, data: n, setData: f }) => [
584
+ (K(), H(oe(t.component), le({ ...t.componentProps, ...e.$attrs }, {
577
585
  "model-value": n,
578
586
  errors: s,
579
- name: e.path,
587
+ name: t.path,
580
588
  "onUpdate:modelValue": f
581
- }), ie({
582
- default: j(() => [
583
- b(e.$slots, "default")
589
+ }), ce({
590
+ default: B(() => [
591
+ $(e.$slots, "default")
584
592
  ]),
585
593
  _: 2
586
594
  }, [
587
- le(e.$slots, (m, y) => ({
588
- name: y,
589
- fn: j((V) => [
590
- b(e.$slots, y, M(z(V ?? {})))
595
+ ue(e.$slots, (p, F) => ({
596
+ name: F,
597
+ fn: B((V) => [
598
+ $(e.$slots, F, M(N(V ?? {})))
591
599
  ])
592
600
  }))
593
601
  ]), 1040, ["model-value", "errors", "name", "onUpdate:modelValue"]))
@@ -596,20 +604,20 @@ const Ce = /* @__PURE__ */ k({
596
604
  }, 8, ["form", "path"]);
597
605
  };
598
606
  }
599
- }), Ue = /* @__PURE__ */ k({
607
+ }), Me = /* @__PURE__ */ x({
600
608
  __name: "FormPart",
601
609
  props: {
602
610
  form: {},
603
611
  path: {}
604
612
  },
605
613
  setup(t) {
606
- const e = t, r = p(() => e.form.getSubForm(e.path));
607
- return (a, s) => b(a.$slots, "default", M(z({ subform: r.value })));
614
+ const e = t, r = v(() => e.form.getSubForm(e.path));
615
+ return (a, s) => $(a.$slots, "default", M(N({ subform: r.value })));
608
616
  }
609
617
  });
610
618
  export {
611
- Ce as Field,
612
- Ie as FormFieldWrapper,
613
- Ue as FormPart,
614
- Oe as useForm
619
+ ke as Field,
620
+ xe as FormFieldWrapper,
621
+ Me as FormPart,
622
+ Ue as useForm
615
623
  };