@nmorph/nmorph-ui-kit 2.2.37 → 2.2.38

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.
Files changed (52) hide show
  1. package/dist/components/data/nmorph-card/NmorphCard.vue2.js +19 -16
  2. package/dist/components/form/nmorph-autocomplete/NmorphAutocomplete.vue2.js +67 -65
  3. package/dist/components/form/nmorph-checkbox/NmorphCheckbox.css +1 -1
  4. package/dist/components/form/nmorph-checkbox/NmorphCheckbox.vue2.js +28 -26
  5. package/dist/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue2.js +25 -20
  6. package/dist/components/form/nmorph-color-picker/NmorphColorPicker.vue2.js +43 -42
  7. package/dist/components/form/nmorph-date-picker/NmorphDatePicker.vue2.js +52 -40
  8. package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue.js +20 -16
  9. package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue2.js +113 -86
  10. package/dist/components/form/nmorph-form/NmorphForm.vue2.js +9 -9
  11. package/dist/components/form/nmorph-form/components/nmorph-form-item/NmorphFormItem.vue2.js +33 -24
  12. package/dist/components/form/nmorph-form/use-form-item-input.js +29 -8
  13. package/dist/components/form/nmorph-number-input/NmorphNumberInput.vue2.js +41 -35
  14. package/dist/components/form/nmorph-otp-input/NmorphOTPInput.vue2.js +65 -61
  15. package/dist/components/form/nmorph-radio/NmorphRadio.css +1 -1
  16. package/dist/components/form/nmorph-radio-group/NmorphRadioGroup.vue2.js +24 -22
  17. package/dist/components/form/nmorph-select/NmorphSelect.css +1 -1
  18. package/dist/components/form/nmorph-select/NmorphSelect.vue2.js +91 -81
  19. package/dist/components/form/nmorph-select-button/NmorphSelectButton.vue2.js +28 -26
  20. package/dist/components/form/nmorph-slider/NmorphSlider.vue2.js +49 -48
  21. package/dist/components/form/nmorph-switch/NmorphSwitch.vue2.js +37 -36
  22. package/dist/components/form/nmorph-text-input/NmorphTextInput.css +1 -1
  23. package/dist/components/form/nmorph-text-input/NmorphTextInput.vue.js +1 -1
  24. package/dist/components/form/nmorph-text-input/NmorphTextInput.vue2.js +34 -30
  25. package/dist/components/form/nmorph-textarea/NmorphTextarea.vue.js +1 -1
  26. package/dist/components/form/nmorph-textarea/NmorphTextarea.vue2.js +29 -25
  27. package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue.js +1 -1
  28. package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue2.js +69 -68
  29. package/dist/hooks/use-field-validation.js +71 -42
  30. package/dist/hooks/use-form-validation.js +62 -24
  31. package/dist/index.umd.js +26 -26
  32. package/dist/package.json.js +1 -1
  33. package/dist/src/components/basic/nmorph-button/NmorphButton.vue.d.ts +1 -1
  34. package/dist/src/components/basic/nmorph-link/NmorphLink.vue.d.ts +1 -1
  35. package/dist/src/components/data/nmorph-avatar/NmorphAvatar.vue.d.ts +1 -1
  36. package/dist/src/components/data/nmorph-badge/NmorphBadge.vue.d.ts +1 -1
  37. package/dist/src/components/data/nmorph-empty/NmorphEmpty.vue.d.ts +1 -1
  38. package/dist/src/components/data/nmorph-progress/NmorphProgress.vue.d.ts +1 -1
  39. package/dist/src/components/data/nmorph-table/NmorphTable.vue.d.ts +1 -1
  40. package/dist/src/components/feedback/nmorph-callout/NmorphCallout.vue.d.ts +1 -1
  41. package/dist/src/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue.d.ts +2 -2
  42. package/dist/src/components/form/nmorph-date-picker/NmorphDatePicker.vue.d.ts +2 -2
  43. package/dist/src/components/form/nmorph-file-upload/NmorphFileUpload.vue.d.ts +6 -3
  44. package/dist/src/components/form/nmorph-file-upload/types.d.ts +4 -0
  45. package/dist/src/components/form/nmorph-form/types.d.ts +15 -5
  46. package/dist/src/components/form/nmorph-form/use-form-item-input.d.ts +10 -0
  47. package/dist/src/components/form/nmorph-radio-group/NmorphRadioGroup.vue.d.ts +2 -2
  48. package/dist/src/hooks/use-field-validation.d.ts +15 -0
  49. package/dist/src/hooks/use-form-validation.d.ts +5 -0
  50. package/dist/style.css +1 -1
  51. package/dist/utils/common.js +6 -7
  52. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
1
  import './NmorphTimePicker.css';
2
- import { defineComponent as Z, ref as v, computed as n, watch as ee } from "vue";
3
- import { NmorphComponentHeight as C } from "../../../types/index.js";
4
- import { useI18n as te } from "vue-i18n";
5
- import { useModifiers as _ } from "../../../utils/create-modifiers.js";
6
- import { toCssSize as oe } from "../../../utils/common.js";
7
- import { useFormItemInput as re } from "../nmorph-form/use-form-item-input.js";
8
- import ne from "../../../assets/icons/clock.svg.js";
9
- import le from "../../../assets/icons/circle-close.svg.js";
10
- import ue from "../../basic/nmorph-icon/NmorphIcon.vue.js";
11
- import ae from "../../navigation/nmorph-dropdown/NmorphDropdown.vue.js";
12
- const ve = /* @__PURE__ */ Z({
2
+ import { defineComponent as te, ref as y, computed as n, watch as oe } from "vue";
3
+ import { NmorphComponentHeight as O } from "../../../types/index.js";
4
+ import { useI18n as re } from "vue-i18n";
5
+ import { useModifiers as H } from "../../../utils/create-modifiers.js";
6
+ import { toCssSize as ne } from "../../../utils/common.js";
7
+ import { useFormItemInput as le, useFormItemModel as ue } from "../nmorph-form/use-form-item-input.js";
8
+ import se from "../../../assets/icons/clock.svg.js";
9
+ import ae from "../../../assets/icons/circle-close.svg.js";
10
+ import ie from "../../basic/nmorph-icon/NmorphIcon.vue.js";
11
+ import de from "../../navigation/nmorph-dropdown/NmorphDropdown.vue.js";
12
+ const Ne = /* @__PURE__ */ te({
13
13
  __name: "NmorphTimePicker",
14
14
  props: {
15
15
  modelValue: { type: [String, null], required: !1, default: null },
@@ -31,86 +31,87 @@ const ve = /* @__PURE__ */ Z({
31
31
  tabindex: { type: Number, required: !1 }
32
32
  },
33
33
  emits: ["update:model-value", "focus", "blur"],
34
- setup(O, { expose: H, emit: k }) {
35
- const t = O, a = k, { t: T } = te(), { id: B, name: M, autocomplete: P, tabindex: $ } = re(t), s = v(!1), c = v(!1), w = v(null), m = (e) => String(e).padStart(2, "0"), p = (e) => Math.max(1, Math.floor(Number.isFinite(e) ? e : 1)), i = (e) => {
34
+ setup(M, { expose: k, emit: B }) {
35
+ const t = M, m = B, { t: I } = re(), { id: P, name: $, autocomplete: z, tabindex: D } = le(t), { modelValue: s, updateModelValue: p } = ue(
36
+ t,
37
+ (e) => m("update:model-value", e),
38
+ null
39
+ ), a = y(!1), f = y(!1), x = y(null), c = (e) => String(e).padStart(2, "0"), h = (e) => Math.max(1, Math.floor(Number.isFinite(e) ? e : 1)), i = (e) => {
36
40
  if (!e) return null;
37
41
  const o = e.match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);
38
42
  if (!o) return null;
39
- const r = Number(o[1]), b = Number(o[2]), d = Number(o[3] || 0);
40
- return r > 23 || b > 59 || d > 59 ? null : { hour: r, minute: b, second: d };
41
- }, g = (e) => {
42
- const o = `${m(e.hour)}:${m(e.minute)}`;
43
- return t.showSeconds ? `${o}:${m(e.second)}` : o;
44
- }, f = (e) => e.hour * 3600 + e.minute * 60 + e.second, y = n(() => i(t.minTime)), N = n(() => i(t.maxTime)), V = n(() => i(t.modelValue)), u = v(V.value || { hour: 0, minute: 0, second: 0 }), x = n(() => t.placeholder || T("pickATime"));
45
- ee(
46
- () => t.modelValue,
47
- (e) => {
48
- const o = i(e);
49
- o && (u.value = o);
50
- }
51
- );
52
- const h = (e) => {
53
- const o = f(e);
54
- return !!(y.value && o < f(y.value) || N.value && o > f(N.value));
55
- }, S = (e, o, r) => {
56
- const b = p(r), d = /* @__PURE__ */ new Set();
57
- for (let l = 0; l <= o; l += b) d.add(l);
58
- return d.add(u.value[e]), Array.from(d).filter((l) => l >= 0 && l <= o).sort((l, q) => l - q).map((l) => {
59
- const q = { ...u.value, [e]: l };
43
+ const r = Number(o[1]), g = Number(o[2]), d = Number(o[3] || 0);
44
+ return r > 23 || g > 59 || d > 59 ? null : { hour: r, minute: g, second: d };
45
+ }, N = (e) => {
46
+ const o = `${c(e.hour)}:${c(e.minute)}`;
47
+ return t.showSeconds ? `${o}:${c(e.second)}` : o;
48
+ }, v = (e) => e.hour * 3600 + e.minute * 60 + e.second, q = n(() => i(t.minTime)), T = n(() => i(t.maxTime)), C = n(() => i(s.value)), u = y(C.value || { hour: 0, minute: 0, second: 0 }), _ = n(() => t.placeholder || I("pickATime"));
49
+ oe(s, (e) => {
50
+ const o = i(e);
51
+ o && (u.value = o);
52
+ });
53
+ const S = (e) => {
54
+ const o = v(e);
55
+ return !!(q.value && o < v(q.value) || T.value && o > v(T.value));
56
+ }, b = (e, o, r) => {
57
+ const g = h(r), d = /* @__PURE__ */ new Set();
58
+ for (let l = 0; l <= o; l += g) d.add(l);
59
+ return d.add(u.value[e]), Array.from(d).filter((l) => l >= 0 && l <= o).sort((l, w) => l - w).map((l) => {
60
+ const w = { ...u.value, [e]: l };
60
61
  return {
61
- label: m(l),
62
+ label: c(l),
62
63
  value: l,
63
- disabled: h(q)
64
+ disabled: S(w)
64
65
  };
65
66
  });
66
- }, z = n(() => S("hour", 23, t.hourStep)), D = n(() => S("minute", 59, t.minuteStep)), A = n(() => S("second", 59, t.secondStep)), F = (e, o) => {
67
+ }, F = n(() => b("hour", 23, t.hourStep)), A = n(() => b("minute", 59, t.minuteStep)), R = n(() => b("second", 59, t.secondStep)), U = (e, o) => {
67
68
  const r = { ...u.value, [e]: o };
68
- h(r) || (u.value = r, a("update:model-value", g(r)));
69
- }, R = () => {
70
- a("update:model-value", null), s.value = !1;
71
- }, U = () => {
72
- s.value = !1;
69
+ S(r) || (u.value = r, p(N(r)));
73
70
  }, j = () => {
74
- t.disabled || (s.value = !s.value);
71
+ p(null), a.value = !1;
75
72
  }, E = () => {
76
- c.value = !0, a("focus");
73
+ a.value = !1;
77
74
  }, G = () => {
78
- c.value = !1, a("blur");
79
- }, J = (e) => {
75
+ t.disabled || (a.value = !a.value);
76
+ }, J = () => {
77
+ f.value = !0, m("focus");
78
+ }, K = () => {
79
+ f.value = !1, m("blur");
80
+ }, L = (e) => {
80
81
  const o = e.target, r = i(o.value);
81
- !r || h(r) || (u.value = r, a("update:model-value", g(r)));
82
- }, K = n(() => t.modelValue || x.value), L = n(
83
- () => t.showSeconds ? p(t.secondStep) : p(t.minuteStep) * 60
84
- ), Q = n(() => t.clearable && !!t.modelValue && !t.disabled), W = n(
85
- () => _({
86
- nmorph: [C[t.height]],
82
+ !r || S(r) || (u.value = r, p(N(r)));
83
+ }, Q = n(() => s.value || _.value), W = n(
84
+ () => t.showSeconds ? h(t.secondStep) : h(t.minuteStep) * 60
85
+ ), X = n(() => t.clearable && !!s.value && !t.disabled), Y = n(
86
+ () => H({
87
+ nmorph: [O[t.height]],
87
88
  "nmorph-time-picker": [
88
89
  t.disabled && "disabled",
89
- s.value && "open",
90
- c.value && "focus",
91
- !t.modelValue && "placeholder"
90
+ a.value && "open",
91
+ f.value && "focus",
92
+ !s.value && "placeholder"
92
93
  ]
93
94
  })
94
- ), X = n(
95
- () => _({
96
- nmorph: [C[t.height]]
95
+ ), Z = n(
96
+ () => H({
97
+ nmorph: [O[t.height]]
97
98
  })
98
- ), Y = n(() => ({
99
- ...t.width !== void 0 && { "--width": oe(t.width) }
99
+ ), ee = n(() => ({
100
+ ...t.width !== void 0 && { "--width": ne(t.width) }
100
101
  }));
101
- H({ inputDOMRef: w });
102
- const I = { props: t, emit: a, t: T, id: B, name: M, autocomplete: P, tabindex: $, open: s, focused: c, inputDOMRef: w, pad: m, normalizeStep: p, parseTime: i, formatTime: g, timeToSeconds: f, minTimeParts: y, maxTimeParts: N, modelTimeParts: V, pickerValue: u, placeholderText: x, isOutsideRange: h, getUnitOptions: S, hourOptions: z, minuteOptions: D, secondOptions: A, selectUnit: F, clearHandler: R, closeHandler: U, toggleOpen: j, focusHandler: E, blurHandler: G, nativeInputHandler: J, displayValue: K, inputStep: L, showClearButton: Q, modifiers: W, optionHeightModifiers: X, styles: Y, get NmorphDropdown() {
103
- return ae;
102
+ k({ inputDOMRef: x });
103
+ const V = { props: t, emit: m, t: I, id: P, name: $, autocomplete: z, tabindex: D, modelValue: s, updateModelValue: p, open: a, focused: f, inputDOMRef: x, pad: c, normalizeStep: h, parseTime: i, formatTime: N, timeToSeconds: v, minTimeParts: q, maxTimeParts: T, modelTimeParts: C, pickerValue: u, placeholderText: _, isOutsideRange: S, getUnitOptions: b, hourOptions: F, minuteOptions: A, secondOptions: R, selectUnit: U, clearHandler: j, closeHandler: E, toggleOpen: G, focusHandler: J, blurHandler: K, nativeInputHandler: L, displayValue: Q, inputStep: W, showClearButton: X, modifiers: Y, optionHeightModifiers: Z, styles: ee, get NmorphDropdown() {
104
+ return de;
104
105
  }, get NmorphIcon() {
105
- return ue;
106
+ return ie;
106
107
  }, get NmorphIconCircleClose() {
107
- return le;
108
+ return ae;
108
109
  }, get NmorphIconClock() {
109
- return ne;
110
+ return se;
110
111
  } };
111
- return Object.defineProperty(I, "__isScriptSetup", { enumerable: !1, value: !0 }), I;
112
+ return Object.defineProperty(V, "__isScriptSetup", { enumerable: !1, value: !0 }), V;
112
113
  }
113
114
  });
114
115
  export {
115
- ve as default
116
+ Ne as default
116
117
  };
@@ -1,74 +1,103 @@
1
- import { ref as p } from "vue";
2
- const I = (b) => {
3
- const { inputValue: h, rules: a } = b, c = p([]), f = p(!1), d = p(!1);
1
+ import { resolution as L } from "../components/form/nmorph-file-upload/types.js";
2
+ import { ref as h } from "vue";
3
+ const S = Object.entries(L), z = (t) => t.split("/")[1]?.toLowerCase() || "", B = (t) => {
4
+ const o = t.split(".").pop()?.toLowerCase();
5
+ return o && o !== t.toLowerCase() ? o : "";
6
+ }, I = (t) => S.find(([, o]) => o.toLowerCase() === t.toLowerCase())?.[0] || "", M = (t) => Array.from(
7
+ new Set(
8
+ [
9
+ t.type.toLowerCase(),
10
+ I(t.type),
11
+ B(t.name),
12
+ z(t.type)
13
+ ].filter(Boolean).map((o) => o.toLowerCase())
14
+ )
15
+ ), w = (t) => typeof File < "u" && t instanceof File, q = (t) => !!t && typeof t == "object" && "data" in t && w(t.data), E = (t) => {
16
+ if (w(t)) return [t];
17
+ if (!Array.isArray(t)) return null;
18
+ const o = t;
19
+ return o.length === 0 ? [] : o.every(w) ? o : o.every(q) ? o.map((s) => s.data) : null;
20
+ }, j = (t, o) => {
21
+ if (o.length === 0) return !0;
22
+ const s = M(t);
23
+ return o.some((c) => s.includes(String(c).toLowerCase()));
24
+ }, P = (t) => {
25
+ const { inputValue: o, rules: s } = t, c = h([]), y = h(!1), m = h(!1);
4
26
  return {
5
- touched: d,
6
- valid: f,
27
+ touched: m,
28
+ valid: y,
7
29
  errors: c,
8
30
  validate: () => {
9
- const y = a?.length > 0;
10
- if (!y) {
11
- f.value = !0;
31
+ const g = s?.length > 0;
32
+ if (c.value = [], !g) {
33
+ y.value = !0;
12
34
  return;
13
35
  }
14
- if (h === null) return;
15
- const t = h, u = (n) => y && n in a[0], m = typeof t == "string" && u("pattern"), v = typeof t == "number" && u("numberCompareType"), g = (typeof t == "string" || typeof t == "boolean") && u("booleanCompareType"), T = Array.isArray(t) && u("arrayCompareType");
16
- if (!v && !m && !g && !T) {
36
+ if (o === null) return;
37
+ const i = o, u = (a) => g && s.some((r) => a in r), C = typeof i == "string" && u("pattern"), F = typeof i == "number" && u("numberCompareType"), T = (typeof i == "string" || typeof i == "boolean") && u("booleanCompareType"), v = Array.isArray(i) && u("arrayCompareType"), x = u("fileMaxSize") || u("maxFileSize") || u("fileAllowedTypes") || u("allowedTypes") || u("fileMaxCount") || u("maxFiles"), b = x ? E(i) : null, A = x && b !== null;
38
+ if (!F && !C && !T && !v && !A) {
17
39
  console.warn("The input value and the provided rules do not match");
18
40
  return;
19
41
  }
20
- if (d.value || (d.value = !0), m) {
21
- const n = a;
22
- c.value = n.reduce((o, r) => (t.match(r.pattern) || o.push(r.error), o), []);
42
+ if (m.value || (m.value = !0), C) {
43
+ const a = s;
44
+ c.value = a.reduce((r, n) => (i.match(n.pattern) || r.push(n.error), r), []);
23
45
  }
24
- if (v) {
25
- const n = (r, e, s) => {
26
- switch (s) {
46
+ if (F) {
47
+ const a = (n, e, l) => {
48
+ switch (l) {
27
49
  case "eq":
28
- return r === e;
50
+ return n === e;
29
51
  case "gt":
30
- return r > e;
52
+ return n > e;
31
53
  case "lt":
32
- return r < e;
54
+ return n < e;
33
55
  case "lte":
34
- return r <= e;
56
+ return n <= e;
35
57
  case "gte":
36
- return r >= e;
58
+ return n >= e;
37
59
  }
38
- }, o = a;
39
- c.value = o.reduce((r, e) => (n(t, e.compareValue, e.numberCompareType) && r.push(e.error), r), []);
60
+ }, r = s;
61
+ c.value = r.reduce((n, e) => (a(i, e.compareValue, e.numberCompareType) && n.push(e.error), n), []);
40
62
  }
41
- if (g) {
42
- const n = a;
43
- c.value = n.reduce((o, r) => {
63
+ if (T) {
64
+ const a = s;
65
+ c.value = a.reduce((r, n) => {
44
66
  let e = !1;
45
- const { compareValue: s, booleanCompareType: i } = r;
46
- return i === "not-eq" && (e = t === s), i === "eq" && (e = t !== s), e || o.push(r.error), o;
67
+ const { compareValue: l, booleanCompareType: f } = n;
68
+ return f === "not-eq" && (e = i === l), f === "eq" && (e = i !== l), e || r.push(n.error), r;
47
69
  }, []);
48
70
  }
49
- if (T) {
50
- const n = a, o = (r, e, s) => {
51
- switch (s) {
71
+ if (v) {
72
+ const a = s, r = (n, e, l) => {
73
+ switch (l) {
52
74
  case "contains-one":
53
- return r.some((l) => e.includes(l));
75
+ return n.some((p) => e.includes(p));
54
76
  case "full-eq":
55
- if (r.length !== e.length) return !1;
56
- const i = [...r].sort(), C = [...e].sort();
57
- return i.every((l, w) => l === C[w]);
77
+ if (n.length !== e.length) return !1;
78
+ const f = [...n].sort(), d = [...e].sort();
79
+ return f.every((p, R) => p === d[R]);
58
80
  case "not-contains":
59
- return !r.some((l) => e.includes(l));
81
+ return !n.some((p) => e.includes(p));
60
82
  }
61
83
  };
62
- c.value = n.reduce((r, e) => (o(
63
- t.map((i) => String(i)),
84
+ c.value = a.reduce((n, e) => (r(
85
+ i.map((f) => String(f)),
64
86
  e.compareValue,
65
87
  e.arrayCompareType
66
- ) || r.push(e.error), r), []);
88
+ ) || n.push(e.error), n), []);
89
+ }
90
+ if (A) {
91
+ const a = s, r = b || [];
92
+ c.value = a.reduce((n, e) => {
93
+ const l = e.fileMaxSize ?? e.maxFileSize, f = e.fileAllowedTypes ?? e.allowedTypes, d = e.fileMaxCount ?? e.maxFiles;
94
+ return typeof l == "number" && r.some((p) => p.size > l) && n.push(e.error), f && r.some((p) => !j(p, f)) && n.push(e.error), typeof d == "number" && r.length > d && n.push(e.error), n;
95
+ }, []);
67
96
  }
68
- f.value = c.value.length === 0;
97
+ y.value = c.value.length === 0;
69
98
  }
70
99
  };
71
100
  };
72
101
  export {
73
- I as useFieldValidation
102
+ P as useFieldValidation
74
103
  };
@@ -1,30 +1,68 @@
1
- import { reactive as i, ref as p, watch as b, readonly as v } from "vue";
2
- import { deepClone as F } from "../utils/common.js";
1
+ import { reactive as f, ref as h, watch as w, readonly as b } from "vue";
3
2
  import { useFieldValidation as c } from "./use-field-validation.js";
4
- const T = (n, f = !1) => {
5
- const t = i({}), o = i({}), u = i(F(n)), a = p(!1), d = p(!1), h = () => {
6
- Object.entries(n).forEach(([e, s]) => {
7
- o[e] = c({ inputValue: s.value, rules: s.rules }), o[e].validate();
8
- }), a.value = Object.values(o).every((e) => e.valid);
9
- }, V = () => {
10
- Object.entries(n).forEach(([e, s]) => {
11
- t[e] = c({ inputValue: s.value, rules: s.rules }), t[e].validate();
3
+ const z = (e) => typeof File < "u" && e instanceof File, p = (e) => z(e) ? {
4
+ name: e.name,
5
+ size: e.size,
6
+ type: e.type,
7
+ lastModified: e.lastModified
8
+ } : e instanceof Date ? e.toISOString() : e instanceof RegExp ? e.toString() : typeof e == "function" ? String(e) : Array.isArray(e) ? e.map(p) : e && typeof e == "object" ? Object.fromEntries(
9
+ Object.entries(e).map(([s, i]) => [
10
+ s,
11
+ p(i)
12
+ ])
13
+ ) : e, m = (e) => Object.fromEntries(
14
+ Object.entries(e).map(([s, i]) => [
15
+ s,
16
+ JSON.stringify(p(i))
17
+ ])
18
+ ), O = (e) => {
19
+ const s = e.valid;
20
+ return typeof s == "boolean" ? s : s.value;
21
+ }, H = (e, s = !1) => {
22
+ const i = f({}), a = f({}), F = f(m(e)), V = h(!1), d = h(!1), j = () => {
23
+ const t = Object.values(a).every(O), n = Object.values(i).every(O);
24
+ V.value = t && n;
25
+ }, u = () => {
26
+ Object.entries(e).forEach(([t, n]) => {
27
+ a[t] = c({ inputValue: n.value, rules: n.rules }), a[t].validate();
28
+ }), j();
29
+ }, g = () => {
30
+ Object.entries(e).forEach(([t, n]) => {
31
+ i[t] = c({ inputValue: n.value, rules: n.rules }), i[t].validate();
32
+ }), u();
33
+ }, y = (t, n) => {
34
+ const r = e[t];
35
+ if (!r) return;
36
+ const o = c({
37
+ inputValue: n ?? r.value,
38
+ rules: r.rules
12
39
  });
13
- }, m = (e, s) => Object.keys(s).filter((l) => {
14
- const g = e[l] ? JSON.stringify(e[l]) : null, O = JSON.stringify(s[l]);
15
- return g !== O;
16
- });
17
- return b(n, (e) => {
18
- m(u, e).forEach((r) => {
19
- const l = e[r];
20
- t[r] = c({ inputValue: l.value, rules: l.rules }), t[r].validate();
21
- }), Object.assign(u, F(e)), h(), d.value = !0;
22
- }, { deep: !0 }), f && V(), {
23
- fields: t,
24
- isFormValid: v(a),
25
- isAnyTouched: v(d)
40
+ return o.validate(), i[t] = o, u(), d.value = !0, o;
41
+ }, S = (t, n) => {
42
+ const r = e[t];
43
+ r && (r.value = n, y(t, n));
44
+ }, v = (t, n) => {
45
+ const r = m(n);
46
+ return { changedFields: Object.keys(n).filter((l) => {
47
+ const E = t[l] ?? null, A = r[l];
48
+ return E !== A;
49
+ }), newSnapshot: r };
50
+ };
51
+ return w(e, (t) => {
52
+ const { changedFields: n, newSnapshot: r } = v(F, t);
53
+ n.forEach((o) => {
54
+ const l = t[o];
55
+ i[o] = c({ inputValue: l.value, rules: l.rules }), i[o].validate();
56
+ }), Object.assign(F, r), u(), d.value = !0;
57
+ }, { deep: !0 }), s && g(), {
58
+ formValue: e,
59
+ fields: i,
60
+ updateFieldValue: S,
61
+ validateField: y,
62
+ isFormValid: b(V),
63
+ isAnyTouched: b(d)
26
64
  };
27
65
  };
28
66
  export {
29
- T as useFormValidation
67
+ H as useFormValidation
30
68
  };