@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.
- package/dist/components/data/nmorph-card/NmorphCard.vue2.js +19 -16
- package/dist/components/form/nmorph-autocomplete/NmorphAutocomplete.vue2.js +67 -65
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.css +1 -1
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.vue2.js +28 -26
- package/dist/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue2.js +25 -20
- package/dist/components/form/nmorph-color-picker/NmorphColorPicker.vue2.js +43 -42
- package/dist/components/form/nmorph-date-picker/NmorphDatePicker.vue2.js +52 -40
- package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue.js +20 -16
- package/dist/components/form/nmorph-file-upload/NmorphFileUpload.vue2.js +113 -86
- package/dist/components/form/nmorph-form/NmorphForm.vue2.js +9 -9
- package/dist/components/form/nmorph-form/components/nmorph-form-item/NmorphFormItem.vue2.js +33 -24
- package/dist/components/form/nmorph-form/use-form-item-input.js +29 -8
- package/dist/components/form/nmorph-number-input/NmorphNumberInput.vue2.js +41 -35
- package/dist/components/form/nmorph-otp-input/NmorphOTPInput.vue2.js +65 -61
- package/dist/components/form/nmorph-radio/NmorphRadio.css +1 -1
- package/dist/components/form/nmorph-radio-group/NmorphRadioGroup.vue2.js +24 -22
- package/dist/components/form/nmorph-select/NmorphSelect.css +1 -1
- package/dist/components/form/nmorph-select/NmorphSelect.vue2.js +91 -81
- package/dist/components/form/nmorph-select-button/NmorphSelectButton.vue2.js +28 -26
- package/dist/components/form/nmorph-slider/NmorphSlider.vue2.js +49 -48
- package/dist/components/form/nmorph-switch/NmorphSwitch.vue2.js +37 -36
- package/dist/components/form/nmorph-text-input/NmorphTextInput.css +1 -1
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue.js +1 -1
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue2.js +34 -30
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue.js +1 -1
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue2.js +29 -25
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue.js +1 -1
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue2.js +69 -68
- package/dist/hooks/use-field-validation.js +71 -42
- package/dist/hooks/use-form-validation.js +62 -24
- package/dist/index.umd.js +26 -26
- package/dist/package.json.js +1 -1
- package/dist/src/components/basic/nmorph-button/NmorphButton.vue.d.ts +1 -1
- package/dist/src/components/basic/nmorph-link/NmorphLink.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-avatar/NmorphAvatar.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-badge/NmorphBadge.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-empty/NmorphEmpty.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-progress/NmorphProgress.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-table/NmorphTable.vue.d.ts +1 -1
- package/dist/src/components/feedback/nmorph-callout/NmorphCallout.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue.d.ts +2 -2
- package/dist/src/components/form/nmorph-date-picker/NmorphDatePicker.vue.d.ts +2 -2
- package/dist/src/components/form/nmorph-file-upload/NmorphFileUpload.vue.d.ts +6 -3
- package/dist/src/components/form/nmorph-file-upload/types.d.ts +4 -0
- package/dist/src/components/form/nmorph-form/types.d.ts +15 -5
- package/dist/src/components/form/nmorph-form/use-form-item-input.d.ts +10 -0
- package/dist/src/components/form/nmorph-radio-group/NmorphRadioGroup.vue.d.ts +2 -2
- package/dist/src/hooks/use-field-validation.d.ts +15 -0
- package/dist/src/hooks/use-form-validation.d.ts +5 -0
- package/dist/style.css +1 -1
- package/dist/utils/common.js +6 -7
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import './NmorphTimePicker.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { NmorphComponentHeight as
|
|
4
|
-
import { useI18n as
|
|
5
|
-
import { useModifiers as
|
|
6
|
-
import { toCssSize as
|
|
7
|
-
import { useFormItemInput as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
const
|
|
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(
|
|
35
|
-
const t =
|
|
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]),
|
|
40
|
-
return r > 23 ||
|
|
41
|
-
},
|
|
42
|
-
const o = `${
|
|
43
|
-
return t.showSeconds ? `${o}:${
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
()
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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:
|
|
62
|
+
label: c(l),
|
|
62
63
|
value: l,
|
|
63
|
-
disabled:
|
|
64
|
+
disabled: S(w)
|
|
64
65
|
};
|
|
65
66
|
});
|
|
66
|
-
},
|
|
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
|
-
|
|
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
|
-
|
|
71
|
+
p(null), a.value = !1;
|
|
75
72
|
}, E = () => {
|
|
76
|
-
|
|
73
|
+
a.value = !1;
|
|
77
74
|
}, G = () => {
|
|
78
|
-
|
|
79
|
-
}, J = (
|
|
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 ||
|
|
82
|
-
},
|
|
83
|
-
() => t.showSeconds ?
|
|
84
|
-
),
|
|
85
|
-
() =>
|
|
86
|
-
nmorph: [
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
!
|
|
90
|
+
a.value && "open",
|
|
91
|
+
f.value && "focus",
|
|
92
|
+
!s.value && "placeholder"
|
|
92
93
|
]
|
|
93
94
|
})
|
|
94
|
-
),
|
|
95
|
-
() =>
|
|
96
|
-
nmorph: [
|
|
95
|
+
), Z = n(
|
|
96
|
+
() => H({
|
|
97
|
+
nmorph: [O[t.height]]
|
|
97
98
|
})
|
|
98
|
-
),
|
|
99
|
-
...t.width !== void 0 && { "--width":
|
|
99
|
+
), ee = n(() => ({
|
|
100
|
+
...t.width !== void 0 && { "--width": ne(t.width) }
|
|
100
101
|
}));
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
return
|
|
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
|
|
106
|
+
return ie;
|
|
106
107
|
}, get NmorphIconCircleClose() {
|
|
107
|
-
return
|
|
108
|
+
return ae;
|
|
108
109
|
}, get NmorphIconClock() {
|
|
109
|
-
return
|
|
110
|
+
return se;
|
|
110
111
|
} };
|
|
111
|
-
return Object.defineProperty(
|
|
112
|
+
return Object.defineProperty(V, "__isScriptSetup", { enumerable: !1, value: !0 }), V;
|
|
112
113
|
}
|
|
113
114
|
});
|
|
114
115
|
export {
|
|
115
|
-
|
|
116
|
+
Ne as default
|
|
116
117
|
};
|
|
@@ -1,74 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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:
|
|
6
|
-
valid:
|
|
27
|
+
touched: m,
|
|
28
|
+
valid: y,
|
|
7
29
|
errors: c,
|
|
8
30
|
validate: () => {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
|
|
31
|
+
const g = s?.length > 0;
|
|
32
|
+
if (c.value = [], !g) {
|
|
33
|
+
y.value = !0;
|
|
12
34
|
return;
|
|
13
35
|
}
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
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 (
|
|
21
|
-
const
|
|
22
|
-
c.value =
|
|
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 (
|
|
25
|
-
const
|
|
26
|
-
switch (
|
|
46
|
+
if (F) {
|
|
47
|
+
const a = (n, e, l) => {
|
|
48
|
+
switch (l) {
|
|
27
49
|
case "eq":
|
|
28
|
-
return
|
|
50
|
+
return n === e;
|
|
29
51
|
case "gt":
|
|
30
|
-
return
|
|
52
|
+
return n > e;
|
|
31
53
|
case "lt":
|
|
32
|
-
return
|
|
54
|
+
return n < e;
|
|
33
55
|
case "lte":
|
|
34
|
-
return
|
|
56
|
+
return n <= e;
|
|
35
57
|
case "gte":
|
|
36
|
-
return
|
|
58
|
+
return n >= e;
|
|
37
59
|
}
|
|
38
|
-
},
|
|
39
|
-
c.value =
|
|
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 (
|
|
42
|
-
const
|
|
43
|
-
c.value =
|
|
63
|
+
if (T) {
|
|
64
|
+
const a = s;
|
|
65
|
+
c.value = a.reduce((r, n) => {
|
|
44
66
|
let e = !1;
|
|
45
|
-
const { compareValue:
|
|
46
|
-
return
|
|
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 (
|
|
50
|
-
const
|
|
51
|
-
switch (
|
|
71
|
+
if (v) {
|
|
72
|
+
const a = s, r = (n, e, l) => {
|
|
73
|
+
switch (l) {
|
|
52
74
|
case "contains-one":
|
|
53
|
-
return
|
|
75
|
+
return n.some((p) => e.includes(p));
|
|
54
76
|
case "full-eq":
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
return
|
|
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 !
|
|
81
|
+
return !n.some((p) => e.includes(p));
|
|
60
82
|
}
|
|
61
83
|
};
|
|
62
|
-
c.value =
|
|
63
|
-
|
|
84
|
+
c.value = a.reduce((n, e) => (r(
|
|
85
|
+
i.map((f) => String(f)),
|
|
64
86
|
e.compareValue,
|
|
65
87
|
e.arrayCompareType
|
|
66
|
-
) ||
|
|
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
|
-
|
|
97
|
+
y.value = c.value.length === 0;
|
|
69
98
|
}
|
|
70
99
|
};
|
|
71
100
|
};
|
|
72
101
|
export {
|
|
73
|
-
|
|
102
|
+
P as useFieldValidation
|
|
74
103
|
};
|
|
@@ -1,30 +1,68 @@
|
|
|
1
|
-
import { reactive as
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
t[
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
67
|
+
H as useFormValidation
|
|
30
68
|
};
|