@teamnovu/kit-vue-forms 0.1.22 → 0.1.24

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