@teamnovu/kit-vue-forms 0.2.8 → 0.2.9

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,14 +1,14 @@
1
1
  var X = Object.defineProperty;
2
2
  var Y = (r, t, e) => t in r ? X(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
3
  var R = (r, t, e) => Y(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { toValue as ee, toRaw as te, unref as h, shallowRef as b, watch as D, computed as v, isRef as O, reactive as A, toRefs as K, shallowReactive as re, toRef as _, onScopeDispose as ae, triggerRef as se, ref as L, getCurrentScope as ne, onBeforeUnmount as oe, defineComponent as C, renderSlot as k, normalizeProps as T, guardReactiveProps as x, resolveComponent as ie, createBlock as z, openBlock as H, withCtx as U, resolveDynamicComponent as le, mergeProps as ce, createSlots as ue, renderList as de } from "vue";
5
- import { cloneDeep as fe } from "lodash-es";
4
+ import { toValue as ee, toRaw as te, unref as h, shallowRef as b, watch as D, computed as m, isRef as _, reactive as A, toRefs as K, shallowReactive as re, toRef as j, onScopeDispose as ae, triggerRef as se, ref as L, getCurrentScope as ne, onBeforeUnmount as ie, defineComponent as T, renderSlot as k, normalizeProps as x, guardReactiveProps as C, createBlock as z, openBlock as H, withCtx as U, 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(r) {
8
8
  const t = ee(r), e = te(t);
9
- return fe(e);
9
+ return de(e);
10
10
  }
11
- function he(r) {
11
+ function fe(r) {
12
12
  return r.filter(
13
13
  (t, e, a) => a.indexOf(t) === e
14
14
  );
@@ -23,10 +23,10 @@ function J(...r) {
23
23
  if (!a)
24
24
  return t;
25
25
  const s = (t ?? []).concat(e);
26
- return he(s);
26
+ return fe(s);
27
27
  }, r[0]);
28
28
  }
29
- function pe(...r) {
29
+ function he(...r) {
30
30
  return r.map((e) => Object.keys(e)).flat().reduce((e, a) => {
31
31
  const s = r.map((n) => n[a]).filter(Boolean);
32
32
  return {
@@ -35,7 +35,7 @@ function pe(...r) {
35
35
  };
36
36
  }, {});
37
37
  }
38
- function j(...r) {
38
+ function B(...r) {
39
39
  if (!r.length)
40
40
  return {
41
41
  general: [],
@@ -45,7 +45,7 @@ function j(...r) {
45
45
  return r.length === 1 ? t : r.slice(1).reduce(
46
46
  (e, a) => ({
47
47
  general: J(e.general, a.general),
48
- propertyErrors: pe(e.propertyErrors ?? {}, a.propertyErrors ?? {})
48
+ propertyErrors: he(e.propertyErrors ?? {}, a.propertyErrors ?? {})
49
49
  }),
50
50
  t
51
51
  );
@@ -71,7 +71,7 @@ function Z(r, t) {
71
71
  await e(u);
72
72
  };
73
73
  }
74
- class ve {
74
+ class pe {
75
75
  constructor(t = (e) => e) {
76
76
  R(this, "weakMap", /* @__PURE__ */ new WeakMap());
77
77
  R(this, "map", /* @__PURE__ */ new Map());
@@ -94,30 +94,30 @@ class ve {
94
94
  this.isReferenceType(a) ? this.weakMap.set(a, e) : this.map.set(a, e);
95
95
  }
96
96
  }
97
- function me(r, t, e) {
97
+ function ve(r, t, e) {
98
98
  const a = /* @__PURE__ */ new Set();
99
99
  return t.map((s, n) => {
100
- const u = [...r.get(s) ?? []], m = u.findIndex((p) => !a.has(p)), c = (m === -1 ? [] : u.slice(m))[0];
100
+ const u = [...r.get(s) ?? []], v = u.findIndex((p) => !a.has(p)), c = (v === -1 ? [] : u.slice(v))[0];
101
101
  if (c)
102
102
  return a.add(c), {
103
103
  id: c,
104
104
  item: s,
105
105
  path: `${e}.${n}`
106
106
  };
107
- const o = crypto.randomUUID();
108
- return r.set(s, u.concat([o])), a.add(o), {
109
- id: o,
107
+ const i = crypto.randomUUID();
108
+ return r.set(s, u.concat([i])), a.add(i), {
109
+ id: i,
110
110
  item: s,
111
111
  path: `${e}.${n}`
112
112
  };
113
113
  });
114
114
  }
115
115
  function q(r, t, e) {
116
- const a = new ve(e == null ? void 0 : e.hashFn), s = r.getField(t), n = b([]);
116
+ const a = new pe(e == null ? void 0 : e.hashFn), s = r.getField(t), n = b([]);
117
117
  return D(
118
118
  s.data,
119
119
  (c) => {
120
- n.value = me(a, c, t);
120
+ n.value = ve(a, c, t);
121
121
  },
122
122
  {
123
123
  immediate: !0,
@@ -126,22 +126,22 @@ function q(r, t, e) {
126
126
  ), {
127
127
  items: n,
128
128
  push: (c) => {
129
- const o = s.data.value ?? [];
130
- return s.setData([...o, c]), n.value.at(-1);
129
+ const i = s.data.value ?? [];
130
+ return s.setData([...i, c]), n.value.at(-1);
131
131
  },
132
132
  remove: (c) => {
133
- const o = s.data.value ?? [], p = n.value.findIndex(
134
- ({ id: i }) => i === c
133
+ const i = s.data.value ?? [], p = n.value.findIndex(
134
+ ({ id: o }) => o === c
135
135
  );
136
136
  p !== -1 && s.setData(
137
- o.slice(0, p).concat(o.slice(p + 1))
137
+ i.slice(0, p).concat(i.slice(p + 1))
138
138
  );
139
139
  },
140
- insert: (c, o) => {
140
+ insert: (c, i) => {
141
141
  const p = s.data.value ?? [];
142
142
  return s.setData(
143
- p.slice(0, o).concat([c]).concat(p.slice(o))
144
- ), n.value[o];
143
+ p.slice(0, i).concat([c]).concat(p.slice(i))
144
+ ), n.value[i];
145
145
  },
146
146
  field: s
147
147
  };
@@ -149,7 +149,7 @@ function q(r, t, e) {
149
149
  function W(r) {
150
150
  return r === "" ? [] : r.split(/\s*\.\s*/).filter(Boolean);
151
151
  }
152
- function Fe(r, t) {
152
+ function me(r, t) {
153
153
  const e = Array.isArray(t) ? t : W(t);
154
154
  return !!I(r, e.slice(0, -1));
155
155
  }
@@ -163,18 +163,18 @@ function ye(r, t, e) {
163
163
  const a = Array.isArray(t) ? t : W(t), s = a.at(-1);
164
164
  if (s) {
165
165
  const n = a.slice(0, -1).reduce(
166
- (u, m) => ((u == null ? void 0 : u[m]) === void 0 && (u[m] = {}), u == null ? void 0 : u[m]),
166
+ (u, v) => ((u == null ? void 0 : u[v]) === void 0 && (u[v] = {}), u == null ? void 0 : u[v]),
167
167
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
168
  h(r)
169
169
  );
170
170
  n[s] = e;
171
171
  } else {
172
- if (!O(r))
172
+ if (!_(r))
173
173
  return;
174
174
  r.value = e;
175
175
  }
176
176
  }
177
- const Q = (r, t) => v({
177
+ const Q = (r, t) => m({
178
178
  get() {
179
179
  return I(h(r), h(t));
180
180
  },
@@ -185,7 +185,7 @@ const Q = (r, t) => v({
185
185
  function $(r, t) {
186
186
  return !r && !t ? "" : !r && t ? t : !t && r ? r : `${r}.${t}`;
187
187
  }
188
- function Ve(r, t) {
188
+ function Fe(r, t) {
189
189
  if (!t)
190
190
  return r;
191
191
  const e = `${t}.`, a = Object.fromEntries(
@@ -200,7 +200,7 @@ function Ve(r, t) {
200
200
  propertyErrors: a
201
201
  };
202
202
  }
203
- class ge {
203
+ class Ve {
204
204
  constructor(t) {
205
205
  R(this, "rc", 1);
206
206
  this.drop = t;
@@ -212,7 +212,7 @@ class ge {
212
212
  this.rc > 0 && (this.rc -= 1, this.rc === 0 && this.drop && this.drop());
213
213
  }
214
214
  }
215
- function we(r) {
215
+ function ge(r) {
216
216
  const e = {
217
217
  ...{
218
218
  existsInForm: !0
@@ -232,22 +232,22 @@ function we(r) {
232
232
  },
233
233
  { flush: "sync" }
234
234
  );
235
- const n = v(() => JSON.stringify(s.value) !== JSON.stringify(s.initialValue)), u = (f) => {
235
+ const n = m(() => JSON.stringify(s.value) !== JSON.stringify(s.initialValue)), u = (f) => {
236
236
  s.value = f;
237
- }, m = () => {
237
+ }, v = () => {
238
238
  var f;
239
239
  s.touched = !0, s.errors = [], (f = e.onBlur) == null || f.call(e);
240
- }, y = () => {
240
+ }, F = () => {
241
241
  var f;
242
242
  (f = e.onFocus) == null || f.call(e);
243
243
  }, c = () => {
244
244
  const f = s.path.split(".").at(-1) || "";
245
245
  h(e.existsInForm) && !/^\d+$/.test(f) && (s.value = g(s.initialValue)), s.touched = !1, s.errors = [];
246
- }, o = (f) => {
246
+ }, i = (f) => {
247
247
  n.value || u(g(f)), s.initialValue = f;
248
248
  }, p = (f) => {
249
249
  s.errors = f;
250
- }, i = () => {
250
+ }, o = () => {
251
251
  s.errors = [];
252
252
  }, l = K(s);
253
253
  return {
@@ -258,18 +258,18 @@ function we(r) {
258
258
  touched: l.touched,
259
259
  dirty: n,
260
260
  setData: u,
261
- setInitialData: o,
262
- onBlur: m,
263
- onFocus: y,
261
+ setInitialData: i,
262
+ onBlur: v,
263
+ onFocus: F,
264
264
  reset: c,
265
265
  setErrors: p,
266
- clearErrors: i
266
+ clearErrors: o
267
267
  };
268
268
  }
269
- const Ee = {
269
+ const we = {
270
270
  keepValuesOnUnmount: !0
271
271
  };
272
- function Re(r, t) {
272
+ function Ee(r, t) {
273
273
  const e = () => I(r.initialData, t), a = b(e());
274
274
  return D(
275
275
  () => r.initialData,
@@ -279,31 +279,31 @@ function Re(r, t) {
279
279
  { flush: "sync" }
280
280
  ), a;
281
281
  }
282
- function De(r, t, e) {
282
+ function Re(r, t, e) {
283
283
  const a = /* @__PURE__ */ new Map(), s = re(/* @__PURE__ */ new Map()), n = {
284
- ...Ee,
284
+ ...we,
285
285
  ...e
286
- }, u = (i) => {
287
- const l = h(i.path);
288
- s.set(l, i);
289
- }, m = (i) => {
286
+ }, u = (o) => {
287
+ const l = h(o.path);
288
+ s.set(l, o);
289
+ }, v = (o) => {
290
290
  var l;
291
- n != null && n.keepValuesOnUnmount || (l = s.get(i)) == null || l.reset(), s.delete(i);
292
- }, y = (i) => {
291
+ n != null && n.keepValuesOnUnmount || (l = s.get(o)) == null || l.reset(), s.delete(o);
292
+ }, F = (o) => {
293
293
  var l;
294
- a.has(i) ? (l = a.get(i)) == null || l.inc() : a.set(i, new ge(() => m(i)));
295
- }, c = (i) => {
294
+ a.has(o) ? (l = a.get(o)) == null || l.inc() : a.set(o, new Ve(() => v(o)));
295
+ }, c = (o) => {
296
296
  var l;
297
- a.has(i) && ((l = a.get(i)) == null || l.dec());
298
- }, o = (i) => {
299
- const { path: l } = i;
297
+ a.has(o) && ((l = a.get(o)) == null || l.dec());
298
+ }, i = (o) => {
299
+ const { path: l } = o;
300
300
  if (!s.has(l)) {
301
- const S = we({
301
+ const S = ge({
302
302
  path: l,
303
- value: Q(_(r, "data"), l),
304
- initialValue: Re(r, l),
305
- existsInForm: v(() => Fe(r.data, h(l))),
306
- errors: v({
303
+ value: Q(j(r, "data"), l),
304
+ initialValue: Ee(r, l),
305
+ existsInForm: m(() => me(r.data, h(l))),
306
+ errors: m({
307
307
  get() {
308
308
  return t.errors.value.propertyErrors[l] || [];
309
309
  },
@@ -315,40 +315,40 @@ function De(r, t, e) {
315
315
  var w, P;
316
316
  await Promise.all([
317
317
  (w = n == null ? void 0 : n.onBlur) == null ? void 0 : w.call(n, h(l)),
318
- (P = i.onBlur) == null ? void 0 : P.call(i)
318
+ (P = o.onBlur) == null ? void 0 : P.call(o)
319
319
  ]);
320
320
  },
321
321
  onFocus: async () => {
322
322
  var w, P;
323
323
  await Promise.all([
324
324
  (w = n == null ? void 0 : n.onFocus) == null ? void 0 : w.call(n, h(l)),
325
- (P = i.onFocus) == null ? void 0 : P.call(i)
325
+ (P = o.onFocus) == null ? void 0 : P.call(o)
326
326
  ]);
327
327
  }
328
328
  });
329
329
  u(S);
330
330
  }
331
331
  const f = s.get(l);
332
- return y(l), ae(() => {
332
+ return F(l), ae(() => {
333
333
  c(l);
334
334
  }), f;
335
- }, p = (i) => o(i);
335
+ }, p = (o) => i(o);
336
336
  return {
337
- fields: v(() => [...s.values()]),
338
- getField: (i) => o({ path: i }),
337
+ fields: m(() => [...s.values()]),
338
+ getField: (o) => i({ path: o }),
339
339
  registerField: u,
340
- deregisterField: m,
340
+ deregisterField: v,
341
341
  defineField: p
342
342
  };
343
343
  }
344
- function Pe(r) {
345
- const t = v(() => r.fields.value.some((a) => h(a.dirty))), e = v(() => r.fields.value.some((a) => h(a.touched)));
344
+ function De(r) {
345
+ const t = m(() => r.fields.value.some((a) => h(a.dirty))), e = m(() => r.fields.value.some((a) => h(a.touched)));
346
346
  return {
347
347
  isDirty: t,
348
348
  isTouched: e
349
349
  };
350
350
  }
351
- function Se(r) {
351
+ function Pe(r) {
352
352
  const t = r.issues.filter((a) => a.path.length === 0).map((a) => a.message), e = r.issues.filter((a) => a.path.length > 0).reduce((a, s) => {
353
353
  const n = s.path.join(".");
354
354
  return {
@@ -367,7 +367,7 @@ const V = {
367
367
  propertyErrors: {}
368
368
  }
369
369
  };
370
- class Ie {
370
+ class Se {
371
371
  constructor(t) {
372
372
  this.schema = t;
373
373
  }
@@ -377,7 +377,7 @@ class Ie {
377
377
  const e = await this.schema.safeParseAsync(t);
378
378
  if (e.success)
379
379
  return V;
380
- const a = Se(e.error);
380
+ const a = Pe(e.error);
381
381
  return {
382
382
  data: e.data,
383
383
  errors: {
@@ -387,7 +387,7 @@ class Ie {
387
387
  };
388
388
  }
389
389
  }
390
- class $e {
390
+ class Ie {
391
391
  constructor(t) {
392
392
  this.validateFn = t;
393
393
  }
@@ -407,11 +407,11 @@ class $e {
407
407
  }
408
408
  }
409
409
  }
410
- class be {
410
+ class $e {
411
411
  constructor(t, e) {
412
412
  R(this, "schemaValidator");
413
413
  R(this, "functionValidator");
414
- this.schema = t, this.validateFn = e, this.schemaValidator = new Ie(this.schema), this.functionValidator = new $e(this.validateFn);
414
+ this.schema = t, this.validateFn = e, this.schemaValidator = new Se(this.schema), this.functionValidator = new Ie(this.validateFn);
415
415
  }
416
416
  async validate(t) {
417
417
  const [e, a] = await Promise.all([
@@ -420,35 +420,35 @@ class be {
420
420
  ]);
421
421
  return {
422
422
  data: e.data,
423
- errors: j(e.errors, a.errors)
423
+ errors: B(e.errors, a.errors)
424
424
  };
425
425
  }
426
426
  }
427
- function B(r) {
428
- return v(() => new be(
427
+ function O(r) {
428
+ return m(() => new $e(
429
429
  h(r.schema),
430
430
  h(r.validateFn)
431
431
  ));
432
432
  }
433
- function ke(r, t) {
433
+ function be(r, t) {
434
434
  const e = A({
435
- validators: L([B(t)]),
435
+ validators: L([O(t)]),
436
436
  isValidated: !1,
437
437
  errors: h(t.errors) ?? V.errors
438
- }), a = (o = V.errors) => {
439
- e.errors = j(h(t.errors) ?? V.errors, o);
438
+ }), a = (i = V.errors) => {
439
+ e.errors = B(h(t.errors) ?? V.errors, i);
440
440
  };
441
441
  D(() => h(t.errors), async () => {
442
442
  if (e.isValidated) {
443
- const o = await n();
444
- a(o.errors);
443
+ const i = await n();
444
+ a(i.errors);
445
445
  } else
446
446
  a();
447
447
  }, { immediate: !0 }), D(
448
448
  [() => e.validators],
449
- async (o) => {
449
+ async (i) => {
450
450
  if (e.isValidated)
451
- if (o) {
451
+ if (i) {
452
452
  const p = await n();
453
453
  e.errors = p.errors;
454
454
  } else
@@ -458,59 +458,59 @@ function ke(r, t) {
458
458
  ), D([() => r.data, () => h(t.schema)], () => {
459
459
  e.isValidated && u();
460
460
  });
461
- const s = (o) => {
462
- const p = O(o) ? o : B(o);
463
- return e.validators.push(p), ne() && oe(() => {
461
+ const s = (i) => {
462
+ const p = _(i) ? i : O(i);
463
+ return e.validators.push(p), ne() && ie(() => {
464
464
  e.validators = e.validators.filter(
465
- (i) => i !== p
465
+ (o) => o !== p
466
466
  );
467
467
  }), p;
468
468
  };
469
469
  async function n() {
470
470
  var l;
471
- const o = await Promise.all(
471
+ const i = await Promise.all(
472
472
  e.validators.filter((f) => h(f) !== void 0).map((f) => h(f).validate(r.data))
473
- ), p = o.every((f) => N(f));
474
- let { errors: i } = V;
473
+ ), p = i.every((f) => N(f));
474
+ let { errors: o } = V;
475
475
  if (!p) {
476
- const f = o.map((S) => S.errors);
477
- i = j(...f);
476
+ const f = i.map((S) => S.errors);
477
+ o = B(...f);
478
478
  }
479
479
  return {
480
- errors: i,
480
+ errors: o,
481
481
  // TODO: Implement data disambiguation strategy
482
- data: (l = o.findLast((f) => !!f.data)) == null ? void 0 : l.data
482
+ data: (l = i.findLast((f) => !!f.data)) == null ? void 0 : l.data
483
483
  };
484
484
  }
485
485
  const u = async () => {
486
- const o = await n();
487
- return a(o.errors), e.isValidated = !0, {
486
+ const i = await n();
487
+ return a(i.errors), e.isValidated = !0, {
488
488
  errors: e.errors
489
489
  };
490
- }, m = async (o) => {
490
+ }, v = async (i) => {
491
491
  const p = await n();
492
492
  return a({
493
493
  general: p.errors.general,
494
494
  propertyErrors: {
495
- [o]: p.errors.propertyErrors[o]
495
+ [i]: p.errors.propertyErrors[i]
496
496
  }
497
497
  }), {
498
498
  data: p.data,
499
499
  errors: e.errors
500
500
  };
501
- }, y = v(() => !G(e.errors)), c = () => {
501
+ }, F = m(() => !G(e.errors)), c = () => {
502
502
  e.isValidated = !1, e.errors = h(t.errors) ?? V.errors;
503
503
  };
504
504
  return {
505
505
  ...K(e),
506
506
  validateForm: u,
507
- validateField: m,
507
+ validateField: v,
508
508
  defineValidator: s,
509
- isValid: y,
509
+ isValid: F,
510
510
  reset: c
511
511
  };
512
512
  }
513
- class Ae {
513
+ class ke {
514
514
  constructor(t, e) {
515
515
  this.path = t, this.validator = e;
516
516
  }
@@ -531,61 +531,61 @@ class Ae {
531
531
  };
532
532
  }
533
533
  }
534
- function Me(r, t, e, a) {
535
- const s = Q(r.data, t), n = v(() => I(r.initialData.value, t)), u = (d) => ({
534
+ function Ae(r, t, e, a) {
535
+ const s = Q(r.data, t), n = m(() => I(r.initialData.value, t)), u = (d) => ({
536
536
  ...d,
537
- path: v(() => h(d.path).replace(t + ".", "")),
538
- setData: (F) => {
539
- d.setData(F);
537
+ path: m(() => h(d.path).replace(t + ".", "")),
538
+ setData: (y) => {
539
+ d.setData(y);
540
540
  }
541
- }), m = (d) => {
542
- const F = $(t, d), E = r.getField(F);
541
+ }), v = (d) => {
542
+ const y = $(t, d), E = r.getField(y);
543
543
  return E ? u(E) : {};
544
- }, y = (d) => {
545
- const F = $(t, d.path), E = r.defineField({
544
+ }, F = (d) => {
545
+ const y = $(t, d.path), E = r.defineField({
546
546
  ...d,
547
- path: F
547
+ path: y
548
548
  });
549
549
  return u(E);
550
- }, c = v(() => r.fields.value.filter((d) => {
551
- const F = d.path.value;
552
- return F.startsWith(t + ".") || F === t;
553
- }).map((d) => u(d))), o = () => r.fields.value.filter((d) => {
554
- const F = d.path.value;
555
- return F.startsWith(t + ".") || F === t;
556
- }), p = v(() => o().some((d) => d.dirty.value)), i = v(() => o().some((d) => d.touched.value)), l = v(() => r.isValid.value), f = v(() => r.isValidated.value), S = v(() => Ve(h(r.errors), t)), M = {
550
+ }, c = m(() => r.fields.value.filter((d) => {
551
+ const y = d.path.value;
552
+ return y.startsWith(t + ".") || y === t;
553
+ }).map((d) => u(d))), i = () => r.fields.value.filter((d) => {
554
+ const y = d.path.value;
555
+ return y.startsWith(t + ".") || y === t;
556
+ }), p = m(() => i().some((d) => d.dirty.value)), o = m(() => i().some((d) => d.touched.value)), l = m(() => r.isValid.value), f = m(() => r.isValidated.value), S = m(() => Fe(h(r.errors), t)), M = {
557
557
  data: s,
558
558
  fields: c,
559
559
  initialData: n,
560
- defineField: y,
561
- getField: m,
560
+ defineField: F,
561
+ getField: v,
562
562
  isDirty: p,
563
- isTouched: i,
563
+ isTouched: o,
564
564
  isValid: l,
565
565
  isValidated: f,
566
566
  errors: S,
567
567
  defineValidator: (d) => {
568
- const F = O(d) ? d : B(d), E = v(
569
- () => new Ae(t, h(F))
568
+ const y = _(d) ? d : O(d), E = m(
569
+ () => new ke(t, h(y))
570
570
  );
571
- return r.defineValidator(E), F;
571
+ return r.defineValidator(E), y;
572
572
  },
573
- reset: () => o().forEach((d) => d.reset()),
573
+ reset: () => i().forEach((d) => d.reset()),
574
574
  validateForm: () => r.validateForm(),
575
- getSubForm: (d, F) => {
575
+ getSubForm: (d, y) => {
576
576
  const E = $(t, d);
577
577
  return r.getSubForm(
578
578
  E,
579
- F
579
+ y
580
580
  );
581
581
  },
582
582
  submitHandler: (d) => Z(M, e ?? {})(d),
583
- getFieldArray: (d, F) => q(M, d, F)
583
+ getFieldArray: (d, y) => q(M, d, y)
584
584
  };
585
585
  return M;
586
586
  }
587
- function Te(r) {
588
- const t = v(() => g(r.initialData)), e = L(g(t)), a = A({
587
+ function xe(r) {
588
+ const t = m(() => g(r.initialData)), e = L(g(t)), a = A({
589
589
  initialData: t,
590
590
  data: e
591
591
  });
@@ -596,32 +596,32 @@ function Te(r) {
596
596
  },
597
597
  { flush: "sync" }
598
598
  );
599
- const s = ke(a, r), n = De(a, s, {
599
+ const s = be(a, r), n = Re(a, s, {
600
600
  keepValuesOnUnmount: r.keepValuesOnUnmount,
601
601
  onBlur: async (c) => {
602
602
  h(r.validationStrategy) === "onTouch" && s.validateField(c);
603
603
  }
604
- }), u = Pe(n), m = () => {
604
+ }), u = De(n), v = () => {
605
605
  e.value = g(t), s.reset();
606
606
  for (const c of n.fields.value)
607
607
  c.reset();
608
608
  };
609
609
  h(r.validationStrategy) === "onFormOpen" && s.validateForm();
610
- const y = {
610
+ const F = {
611
611
  ...n,
612
612
  ...s,
613
613
  ...u,
614
- reset: m,
615
- initialData: _(a, "initialData"),
616
- data: _(a, "data"),
614
+ reset: v,
615
+ initialData: j(a, "initialData"),
616
+ data: j(a, "data"),
617
617
  validateForm: s.validateForm,
618
- submitHandler: (c) => Z(y, r)(c),
619
- getSubForm: (c, o) => Me(y, c, r),
620
- getFieldArray: (c, o) => q(y, c, o)
618
+ submitHandler: (c) => Z(F, r)(c),
619
+ getSubForm: (c, i) => Ae(F, c, r),
620
+ getFieldArray: (c, i) => q(F, c, i)
621
621
  };
622
- return y;
622
+ return F;
623
623
  }
624
- const xe = /* @__PURE__ */ C({
624
+ const Me = /* @__PURE__ */ T({
625
625
  __name: "Field",
626
626
  props: {
627
627
  form: {},
@@ -637,9 +637,9 @@ const xe = /* @__PURE__ */ C({
637
637
  const t = r, e = t.form.defineField({
638
638
  path: t.path
639
639
  }), a = A(e);
640
- return (s, n) => k(s.$slots, "default", T(x(a)));
640
+ return (s, n) => k(s.$slots, "default", x(C(a)));
641
641
  }
642
- }), Ne = /* @__PURE__ */ C({
642
+ }), Ce = /* @__PURE__ */ T({
643
643
  inheritAttrs: !1,
644
644
  __name: "FormFieldWrapper",
645
645
  props: {
@@ -649,50 +649,47 @@ const xe = /* @__PURE__ */ C({
649
649
  path: {}
650
650
  },
651
651
  setup(r) {
652
- return (t, e) => {
653
- const a = ie("Field");
654
- return H(), z(a, {
655
- form: r.form,
656
- path: r.path
657
- }, {
658
- default: U(({ errors: s, data: n, setData: u }) => [
659
- (H(), z(le(r.component), ce({ ...r.componentProps, ...t.$attrs }, {
660
- "model-value": n,
661
- errors: s,
662
- name: r.path,
663
- "onUpdate:modelValue": u
664
- }), ue({
665
- default: U(() => [
666
- k(t.$slots, "default")
667
- ]),
668
- _: 2
669
- }, [
670
- de(t.$slots, (m, y) => ({
671
- name: y,
672
- fn: U((c) => [
673
- k(t.$slots, y, T(x(c ?? {})))
674
- ])
675
- }))
676
- ]), 1040, ["model-value", "errors", "name", "onUpdate:modelValue"]))
677
- ]),
678
- _: 3
679
- }, 8, ["form", "path"]);
680
- };
652
+ return (t, e) => (H(), z(Me, {
653
+ form: r.form,
654
+ path: r.path
655
+ }, {
656
+ default: U(({ errors: a, data: s, setData: n }) => [
657
+ (H(), z(oe(r.component), le({ ...r.componentProps, ...t.$attrs }, {
658
+ "model-value": s,
659
+ errors: a,
660
+ name: r.path,
661
+ "onUpdate:modelValue": n
662
+ }), ce({
663
+ default: U(() => [
664
+ k(t.$slots, "default")
665
+ ]),
666
+ _: 2
667
+ }, [
668
+ ue(t.$slots, (u, v) => ({
669
+ name: v,
670
+ fn: U((F) => [
671
+ k(t.$slots, v, x(C(F ?? {})))
672
+ ])
673
+ }))
674
+ ]), 1040, ["model-value", "errors", "name", "onUpdate:modelValue"]))
675
+ ]),
676
+ _: 3
677
+ }, 8, ["form", "path"]));
681
678
  }
682
- }), We = /* @__PURE__ */ C({
679
+ }), Ne = /* @__PURE__ */ T({
683
680
  __name: "FormPart",
684
681
  props: {
685
682
  form: {},
686
683
  path: {}
687
684
  },
688
685
  setup(r) {
689
- const t = r, e = v(() => t.form.getSubForm(t.path));
690
- return (a, s) => k(a.$slots, "default", T(x({ subform: e.value })));
686
+ const t = r, e = m(() => t.form.getSubForm(t.path));
687
+ return (a, s) => k(a.$slots, "default", x(C({ subform: e.value })));
691
688
  }
692
689
  });
693
690
  export {
694
- xe as Field,
695
- Ne as FormFieldWrapper,
696
- We as FormPart,
697
- Te as useForm
691
+ Me as Field,
692
+ Ce as FormFieldWrapper,
693
+ Ne as FormPart,
694
+ xe as useForm
698
695
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnovu/kit-vue-forms",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -39,6 +39,7 @@ import { type Component } from 'vue'
39
39
  import type { ComponentProps } from 'vue-component-type-helpers'
40
40
  import type { Paths } from '../types/util.ts'
41
41
  import type { Form, FormDataDefault } from '../types/form.ts'
42
+ import Field from './Field.vue'
42
43
 
43
44
  export interface FormFieldWrapperProps<
44
45
  TData extends FormDataDefault,