@nmorph/nmorph-ui-kit 2.2.36 → 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/basic/nmorph-button/NmorphButton.vue2.js +8 -8
- package/dist/components/basic/nmorph-icon/NmorphIcon.vue2.js +3 -3
- package/dist/components/basic/nmorph-layout/NmorphLayout.vue2.js +14 -13
- package/dist/components/basic/nmorph-link/NmorphLink.vue2.js +1 -1
- package/dist/components/basic/nmorph-scroll/NmorphScroll.css +1 -0
- package/dist/components/basic/nmorph-scroll/NmorphScroll.vue.js +6 -4
- package/dist/components/basic/nmorph-scroll/NmorphScroll.vue2.js +1 -0
- package/dist/components/basic/nmorph-space/NmorphSpace.vue2.js +15 -19
- package/dist/components/data/nmorph-avatar/NmorphAvatar.css +1 -1
- package/dist/components/data/nmorph-avatar/NmorphAvatar.vue2.js +5 -5
- package/dist/components/data/nmorph-badge/NmorphBadge.vue2.js +37 -36
- package/dist/components/data/nmorph-calendar/NmorphCalendar.vue2.js +41 -40
- package/dist/components/data/nmorph-card/NmorphCard.vue2.js +19 -15
- package/dist/components/data/nmorph-collapse/components/nmorph-collapse-item/NmorphCollapseItem.vue2.js +5 -9
- package/dist/components/data/nmorph-empty/NmorphEmpty.vue.js +3 -3
- package/dist/components/data/nmorph-empty/NmorphEmpty.vue2.js +17 -14
- package/dist/components/data/nmorph-image/NmorphImage.css +1 -0
- package/dist/components/data/nmorph-image/NmorphImage.vue.js +14 -12
- package/dist/components/data/nmorph-image/NmorphImage.vue2.js +3 -2
- package/dist/components/data/nmorph-image-preview/NmorphImagePreview.vue2.js +36 -35
- package/dist/components/data/nmorph-pagination/NmorphPagination.vue2.js +1 -1
- package/dist/components/data/nmorph-progress/NmorphProgress.vue2.js +19 -18
- package/dist/components/data/nmorph-qr-code/NmorphQRCode.vue2.js +20 -19
- package/dist/components/data/nmorph-skeleton/NmorphSkeleton.vue2.js +1 -1
- package/dist/components/data/nmorph-table/NmorphTable.vue2.js +39 -43
- package/dist/components/data/nmorph-virtual-list/NmorphVirtualList.vue2.js +34 -33
- package/dist/components/feedback/nmorph-alert/NmorphAlert.vue2.js +1 -1
- package/dist/components/feedback/nmorph-callout/NmorphCallout.vue2.js +7 -6
- package/dist/components/feedback/nmorph-dialog/NmorphDialog.css +1 -1
- package/dist/components/feedback/nmorph-dialog/NmorphDialog.vue.js +25 -20
- package/dist/components/feedback/nmorph-dialog/NmorphDialog.vue2.js +37 -37
- package/dist/components/feedback/nmorph-drawer/NmorphDrawer.vue2.js +22 -21
- package/dist/components/feedback/nmorph-tooltip/NmorphTooltip.vue2.js +26 -25
- package/dist/components/form/nmorph-autocomplete/NmorphAutocomplete.vue2.js +65 -71
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.css +1 -1
- package/dist/components/form/nmorph-checkbox/NmorphCheckbox.vue2.js +30 -28
- 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 +53 -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/components/nmorph-form-item/inner-components/nmorph-error-box/NmorphErrorBox.vue2.js +1 -1
- package/dist/components/form/nmorph-form/use-form-item-input.js +29 -8
- package/dist/components/form/nmorph-number-input/NmorphNumberInput.vue2.js +42 -39
- package/dist/components/form/nmorph-otp-input/NmorphOTPInput.vue2.js +66 -62
- package/dist/components/form/nmorph-radio/NmorphRadio.css +1 -1
- package/dist/components/form/nmorph-radio/NmorphRadio.vue2.js +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 +83 -81
- package/dist/components/form/nmorph-select/components/nmorph-select-option/NmorphSelectOption.vue2.js +4 -4
- package/dist/components/form/nmorph-select-button/NmorphSelectButton.vue2.js +28 -25
- package/dist/components/form/nmorph-select-button/components/nmorph-select-button-item/NmorphSelectButtonItem.vue2.js +1 -1
- package/dist/components/form/nmorph-slider/NmorphSlider.vue2.js +51 -49
- package/dist/components/form/nmorph-switch/NmorphSwitch.vue2.js +35 -33
- package/dist/components/form/nmorph-text-input/NmorphTextInput.css +1 -0
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue.js +5 -3
- package/dist/components/form/nmorph-text-input/NmorphTextInput.vue2.js +37 -35
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue.js +1 -1
- package/dist/components/form/nmorph-textarea/NmorphTextarea.vue2.js +30 -26
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue.js +1 -1
- package/dist/components/form/nmorph-time-picker/NmorphTimePicker.vue2.js +68 -66
- package/dist/components/navigation/nmorph-backtop/NmorphBacktop.vue2.js +1 -1
- package/dist/components/navigation/nmorph-dropdown/NmorphDropdown.vue2.js +32 -31
- package/dist/components/navigation/nmorph-tabs/NmorphTabs.vue2.js +1 -1
- package/dist/components/others/nmorph-overlay/NmorphOverlay.vue2.js +1 -1
- package/dist/hooks/use-common-styles.js +18 -278
- package/dist/hooks/use-field-validation.js +71 -42
- package/dist/hooks/use-form-validation.js +62 -24
- package/dist/hooks/use-virtual-list.js +38 -32
- package/dist/index.umd.js +26 -286
- package/dist/package.json.js +1 -1
- package/dist/src/components/basic/nmorph-button/NmorphButton.vue.d.ts +2 -2
- 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-collapse/components/nmorph-collapse-item/NmorphCollapseItem.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-empty/NmorphEmpty.vue.d.ts +1 -1
- package/dist/src/components/data/nmorph-pagination/NmorphPagination.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/data/nmorph-tag-list/components/nmorph-tag-item/NmorphTagItem.vue.d.ts +1 -1
- package/dist/src/components/feedback/nmorph-callout/NmorphCallout.vue.d.ts +1 -1
- package/dist/src/components/feedback/nmorph-dialog/NmorphDialog.vue.d.ts +4 -4
- package/dist/src/components/form/nmorph-autocomplete/NmorphAutocomplete.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-checkbox-group/NmorphCheckboxGroup.vue.d.ts +3 -3
- package/dist/src/components/form/nmorph-color-picker/NmorphColorPicker.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-date-picker/NmorphDatePicker.vue.d.ts +3 -3
- 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/components/nmorph-form-item/NmorphFormItem.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-form/components/nmorph-form-item/inner-components/nmorph-error-box/NmorphErrorBox.vue.d.ts +1 -1
- 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-number-input/NmorphNumberInput.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-otp-input/NmorphOTPInput.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-radio-group/NmorphRadioGroup.vue.d.ts +3 -3
- package/dist/src/components/form/nmorph-select/NmorphSelect.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-select-button/NmorphSelectButton.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-text-input/NmorphTextInput.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-textarea/NmorphTextarea.vue.d.ts +1 -1
- package/dist/src/components/form/nmorph-time-picker/NmorphTimePicker.vue.d.ts +1 -1
- package/dist/src/hooks/use-field-validation.d.ts +15 -0
- package/dist/src/hooks/use-form-validation.d.ts +5 -0
- package/dist/src/hooks/use-virtual-list.d.ts +6 -0
- package/dist/src/types/index.d.ts +2 -1
- package/dist/src/utils/common.d.ts +5 -0
- package/dist/src/utils/create-modifiers.d.ts +4 -2
- package/dist/style.css +1 -1
- package/dist/utils/common.js +9 -3
- package/dist/utils/create-modifiers.js +6 -6
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import './NmorphOTPInput.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useModifiers as
|
|
4
|
-
import { NmorphComponentHeight as
|
|
5
|
-
import { useFormItemInput as
|
|
6
|
-
import
|
|
7
|
-
const
|
|
2
|
+
import { defineComponent as le, ref as M, computed as c, watch as O, nextTick as R } from "vue";
|
|
3
|
+
import { useModifiers as ue } from "../../../utils/create-modifiers.js";
|
|
4
|
+
import { NmorphComponentHeight as oe } from "../../../types/index.js";
|
|
5
|
+
import { useFormItemInput as re, useFormItemModel as ne } from "../nmorph-form/use-form-item-input.js";
|
|
6
|
+
import se from "../nmorph-text-input/NmorphTextInput.vue.js";
|
|
7
|
+
const pe = /* @__PURE__ */ le({
|
|
8
8
|
__name: "NmorphOTPInput",
|
|
9
9
|
props: {
|
|
10
10
|
modelValue: { type: String, required: !1, default: "" },
|
|
@@ -20,128 +20,132 @@ const de = /* @__PURE__ */ te({
|
|
|
20
20
|
tabindex: { type: Number, required: !1 }
|
|
21
21
|
},
|
|
22
22
|
emits: ["update:model-value", "focus", "blur", "complete"],
|
|
23
|
-
setup(
|
|
24
|
-
const l =
|
|
23
|
+
setup(j, { expose: w, emit: N }) {
|
|
24
|
+
const l = j, f = N, { id: V, name: T, autocomplete: A, tabindex: p } = re(l), { modelValue: v, updateModelValue: F } = ne(
|
|
25
|
+
l,
|
|
26
|
+
(e) => f("update:model-value", e),
|
|
27
|
+
""
|
|
28
|
+
), i = M([]), n = M([]), d = M(!1), o = M([]), u = c(() => Math.max(1, l.length)), g = (e = "") => {
|
|
25
29
|
const t = `${e ?? ""}`;
|
|
26
30
|
return l.mode === "numeric" ? Array.from(t.replace(/\D/g, "")) : l.mode === "alphanumeric" ? Array.from(t.replace(/[^a-zA-Z0-9]/g, "")) : Array.from(t);
|
|
27
|
-
},
|
|
28
|
-
const t =
|
|
31
|
+
}, S = (e = v.value) => {
|
|
32
|
+
const t = g(e).slice(0, u.value);
|
|
29
33
|
return Array.from({ length: u.value }, (a, s) => t[s] || "");
|
|
30
|
-
},
|
|
31
|
-
if (o.value = Array.from({ length: u.value }, (s,
|
|
34
|
+
}, h = (e, t = !1) => {
|
|
35
|
+
if (o.value = Array.from({ length: u.value }, (s, b) => e[b] || ""), !t) return;
|
|
32
36
|
const a = o.value.join("");
|
|
33
|
-
|
|
37
|
+
F(a), o.value.includes("") || f("complete", a);
|
|
34
38
|
};
|
|
35
|
-
|
|
36
|
-
[
|
|
39
|
+
O(
|
|
40
|
+
[v, () => l.mode, u],
|
|
37
41
|
() => {
|
|
38
|
-
const e =
|
|
39
|
-
(e.join("") !== o.value.join("") || e.length !== o.value.length) &&
|
|
42
|
+
const e = S(v.value);
|
|
43
|
+
(e.join("") !== o.value.join("") || e.length !== o.value.length) && h(e);
|
|
40
44
|
},
|
|
41
45
|
{ immediate: !0 }
|
|
42
46
|
);
|
|
43
|
-
const
|
|
44
|
-
() =>
|
|
45
|
-
nmorph: [
|
|
46
|
-
"nmorph-otp-input": [
|
|
47
|
+
const E = c(
|
|
48
|
+
() => ue({
|
|
49
|
+
nmorph: [oe[l.height], d.value && "focused"],
|
|
50
|
+
"nmorph-otp-input": [l.disabled && "disabled"]
|
|
47
51
|
})
|
|
48
|
-
),
|
|
52
|
+
), B = c(
|
|
49
53
|
() => Array.from({ length: u.value }, (e, t) => t === 0 ? V.value : `${V.value}-${t + 1}`)
|
|
50
|
-
),
|
|
54
|
+
), C = c(() => l.mode === "numeric" ? "numeric" : "text"), P = c(() => A.value || "one-time-code"), $ = c(() => {
|
|
51
55
|
if (l.mode === "numeric") return "[0-9]*";
|
|
52
56
|
if (l.mode === "alphanumeric") return "[A-Za-z0-9]*";
|
|
53
|
-
}),
|
|
57
|
+
}), y = (e) => {
|
|
54
58
|
n.value[e] = i.value[e]?.inputDOMRef ?? null;
|
|
55
|
-
},
|
|
56
|
-
i.value[t] = e,
|
|
57
|
-
|
|
59
|
+
}, x = (e, t) => {
|
|
60
|
+
i.value[t] = e, R(() => {
|
|
61
|
+
y(t);
|
|
58
62
|
});
|
|
59
63
|
}, _ = (e) => {
|
|
60
|
-
|
|
64
|
+
y(e), i.value[e]?.select?.(), n.value[e]?.select();
|
|
61
65
|
}, r = (e = 0) => {
|
|
62
|
-
|
|
66
|
+
R(() => {
|
|
63
67
|
const t = Math.min(Math.max(e, 0), u.value - 1);
|
|
64
|
-
|
|
68
|
+
y(t), i.value[t]?.focus?.(), n.value[t]?.focus(), _(t);
|
|
65
69
|
});
|
|
66
|
-
},
|
|
70
|
+
}, k = () => {
|
|
67
71
|
i.value.forEach((e, t) => {
|
|
68
72
|
e?.blur?.(), n.value[t]?.blur();
|
|
69
73
|
});
|
|
70
74
|
};
|
|
71
|
-
|
|
75
|
+
w({
|
|
72
76
|
inputDOMRefs: n,
|
|
73
77
|
focus: r,
|
|
74
|
-
blur:
|
|
78
|
+
blur: k
|
|
75
79
|
});
|
|
76
80
|
const m = (e, t = "") => {
|
|
77
81
|
const a = [...o.value];
|
|
78
|
-
a[e] = t,
|
|
82
|
+
a[e] = t, h(a, !0);
|
|
79
83
|
}, H = (e, t) => {
|
|
80
|
-
const a =
|
|
84
|
+
const a = g(e).slice(0, u.value - t);
|
|
81
85
|
if (!a.length) {
|
|
82
86
|
m(t, "");
|
|
83
87
|
return;
|
|
84
88
|
}
|
|
85
89
|
const s = [...o.value];
|
|
86
|
-
a.forEach((
|
|
87
|
-
s[t +
|
|
88
|
-
}),
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
},
|
|
90
|
+
a.forEach((te, ae) => {
|
|
91
|
+
s[t + ae] = te;
|
|
92
|
+
}), h(s, !0);
|
|
93
|
+
const b = t + a.length;
|
|
94
|
+
b < u.value ? r(b) : r(u.value - 1);
|
|
95
|
+
}, z = (e, t) => {
|
|
92
96
|
H(e, t);
|
|
93
|
-
},
|
|
94
|
-
const t =
|
|
97
|
+
}, q = /* @__PURE__ */ new Map(), L = (e) => {
|
|
98
|
+
const t = q.get(e);
|
|
95
99
|
if (t) return t;
|
|
96
100
|
const a = c({
|
|
97
101
|
get: () => o.value[e] || "",
|
|
98
|
-
set: (s) =>
|
|
102
|
+
set: (s) => z(s, e)
|
|
99
103
|
});
|
|
100
|
-
return
|
|
101
|
-
},
|
|
104
|
+
return q.set(e, a), a;
|
|
105
|
+
}, D = (e) => {
|
|
102
106
|
if (o.value[e]) {
|
|
103
107
|
m(e);
|
|
104
108
|
return;
|
|
105
109
|
}
|
|
106
110
|
e > 0 && (m(e - 1), r(e - 1));
|
|
107
|
-
},
|
|
111
|
+
}, Z = (e, t) => {
|
|
108
112
|
if (e.key === "Backspace") {
|
|
109
|
-
|
|
113
|
+
D(t);
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
116
|
m(t);
|
|
113
|
-
},
|
|
117
|
+
}, K = (e) => {
|
|
114
118
|
r(e - 1);
|
|
115
|
-
},
|
|
119
|
+
}, G = (e) => {
|
|
116
120
|
r(e + 1);
|
|
117
|
-
},
|
|
121
|
+
}, J = () => {
|
|
118
122
|
r(0);
|
|
119
|
-
},
|
|
123
|
+
}, Q = () => {
|
|
120
124
|
r(u.value - 1);
|
|
121
|
-
},
|
|
122
|
-
e.key.length === 1 && !
|
|
123
|
-
},
|
|
125
|
+
}, U = (e) => {
|
|
126
|
+
e.key.length === 1 && !g(e.key).length && e.preventDefault();
|
|
127
|
+
}, W = (e, t) => {
|
|
124
128
|
const a = e.clipboardData?.getData("text") || "";
|
|
125
129
|
H(a, t);
|
|
126
|
-
},
|
|
130
|
+
}, X = (e) => {
|
|
127
131
|
d.value || (d.value = !0, f("focus")), _(e);
|
|
128
|
-
},
|
|
132
|
+
}, Y = () => {
|
|
129
133
|
setTimeout(() => {
|
|
130
134
|
const e = document.activeElement;
|
|
131
135
|
!n.value.some((a) => a === e) && d.value && (d.value = !1, f("blur"));
|
|
132
136
|
});
|
|
133
|
-
},
|
|
134
|
-
|
|
137
|
+
}, ee = (e) => p.value > 0 ? p.value + e : p.value;
|
|
138
|
+
O(
|
|
135
139
|
() => l.autofocus,
|
|
136
140
|
(e) => {
|
|
137
141
|
e && !l.disabled && r(0);
|
|
138
142
|
},
|
|
139
143
|
{ immediate: !0 }
|
|
140
144
|
);
|
|
141
|
-
const
|
|
142
|
-
return Object.defineProperty(
|
|
145
|
+
const I = { props: l, emit: f, id: V, name: T, autocomplete: A, tabindex: p, modelValue: v, updateModelValue: F, inputRefs: i, inputDOMRefs: n, focused: d, otpValue: o, normalizedLength: u, sanitizeValue: g, normalizeOtpValue: S, syncOtpValue: h, modifiers: E, fieldIds: B, inputMode: C, resolvedAutocomplete: P, inputPattern: $, syncInputDOMRef: y, setInputRef: x, selectField: _, focusField: r, blurFields: k, updateCharAt: m, insertValue: H, inputHandler: z, fieldModels: q, getFieldModel: L, backspaceHandler: D, deleteKeyHandler: Z, arrowLeftHandler: K, arrowRightHandler: G, homeHandler: J, endHandler: Q, keydownHandler: U, pasteHandler: W, focusHandler: X, blurHandler: Y, getFieldTabindex: ee, NmorphTextInput: se };
|
|
146
|
+
return Object.defineProperty(I, "__isScriptSetup", { enumerable: !1, value: !0 }), I;
|
|
143
147
|
}
|
|
144
148
|
});
|
|
145
149
|
export {
|
|
146
|
-
|
|
150
|
+
pe as default
|
|
147
151
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.nmorph-radio{--size: var(--height);display:inline-flex;align-items:center;cursor:pointer}.nmorph-radio .nmorph-radio__content{position:relative;display:flex;justify-content:center;align-items:center}.nmorph-radio span{margin-top:2px}.nmorph-radio .nmorph-radio__input-wrapper{position:relative;width:var(--size);height:var(--size)}.nmorph-radio input{position:absolute;top:0;left:0;width:100%;height:100%}.nmorph-radio input:focus-visible{background:var(--nmorph-main-color);box-shadow:var(--base-shadow-width) var(--base-shadow-width) var(--base-shadow-blur) var(--nmorph-dark-shade-color),calc(-1 * var(--base-shadow-width)) calc(-1 * var(--base-shadow-width)) var(--base-shadow-blur) var(--nmorph-light-shade-color)}.nmorph-radio .nmorph-radio__fake{position:absolute;top:0;left:0;width:100%;height:100%;background:var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:inset var(--base-shadow-width) var(--base-shadow-width) var(--base-shadow-blur) var(--nmorph-dark-shade-color),inset calc(-1 * var(--base-shadow-width)) calc(-1 * var(--base-shadow-width)) var(--base-shadow-blur) var(--nmorph-light-shade-color)}.nmorph-radio .nmorph-radio__fake span,.nmorph-radio .nmorph-radio__label{font-weight:400;font-size:var(--font-size
|
|
1
|
+
.nmorph-radio{--size: var(--height);--nmorph-selection-control-font-size: var(--font-size-small);--nmorph-selection-control-line-height: var(--line-height-regular);--nmorph-selection-control-inline-padding: var(--indentation-03);display:inline-flex;align-items:center;cursor:pointer}.nmorph-radio.nmorph{height:auto;min-height:var(--size)}.nmorph-radio .nmorph-radio__content{position:relative;display:flex;justify-content:center;align-items:center;min-height:var(--size)}.nmorph-radio span{margin-top:2px}.nmorph-radio .nmorph-radio__input-wrapper{position:relative;width:var(--size);height:var(--size)}.nmorph-radio input{position:absolute;top:0;left:0;width:100%;height:100%}.nmorph-radio input:focus-visible{background:var(--nmorph-main-color);box-shadow:var(--base-shadow-width) var(--base-shadow-width) var(--base-shadow-blur) var(--nmorph-dark-shade-color),calc(-1 * var(--base-shadow-width)) calc(-1 * var(--base-shadow-width)) var(--base-shadow-blur) var(--nmorph-light-shade-color)}.nmorph-radio .nmorph-radio__fake{position:absolute;top:0;left:0;width:100%;height:100%;background:var(--nmorph-main-color);border-radius:var(--border-radius-circular);box-shadow:inset var(--base-shadow-width) var(--base-shadow-width) var(--base-shadow-blur) var(--nmorph-dark-shade-color),inset calc(-1 * var(--base-shadow-width)) calc(-1 * var(--base-shadow-width)) var(--base-shadow-blur) var(--nmorph-light-shade-color)}.nmorph-radio .nmorph-radio__fake span,.nmorph-radio .nmorph-radio__label{font-weight:400;font-size:var(--nmorph-selection-control-font-size);line-height:var(--nmorph-selection-control-line-height)}.nmorph-radio .nmorph-radio__fake-checked{position:absolute;top:50%;left:50%;width:50%;height:50%;background:var(--nmorph-accent-color);border-radius:var(--border-radius-circular);transform:translate(-50%,-50%)}.nmorph-radio .nmorph-radio__label{margin-left:var(--indentation-02)}.nmorph-radio.nmorph-radio--button .nmorph-radio__fake{position:relative;display:flex;justify-content:center;align-items:center;height:var(--size);padding:var(--nmorph-selection-control-inline-padding);white-space:nowrap;background:var(--nmorph-main-color);border-radius:var(--default-border-radius);box-shadow:var(--base-shadow-width) var(--base-shadow-width) var(--base-shadow-blur) var(--nmorph-dark-shade-color),calc(-1 * var(--base-shadow-width)) calc(-1 * var(--base-shadow-width)) var(--base-shadow-blur) var(--nmorph-light-shade-color)}.nmorph-radio.nmorph--extra-thin-component{--nmorph-selection-control-font-size: var(--font-size-tiny);--nmorph-selection-control-line-height: var(--line-height-line);--nmorph-selection-control-inline-padding: var(--indentation-02)}.nmorph-radio.nmorph--thin-component{--nmorph-selection-control-font-size: var(--font-size-extra-small)}.nmorph-radio.nmorph--basic-component{--nmorph-selection-control-font-size: var(--font-size-small)}.nmorph-radio.nmorph--thick-component{--nmorph-selection-control-font-size: var(--font-size-base)}.nmorph-radio.nmorph-radio--checked .nmorph-radio__fake{background:var(--nmorph-main-color);box-shadow:inset var(--base-shadow-width) var(--base-shadow-width) var(--base-shadow-blur) var(--nmorph-dark-shade-color),inset calc(-1 * var(--base-shadow-width)) calc(-1 * var(--base-shadow-width)) var(--base-shadow-blur) var(--nmorph-light-shade-color)}.nmorph-radio.nmorph-radio--disabled{cursor:not-allowed;opacity:.6}
|
|
@@ -25,7 +25,7 @@ const q = /* @__PURE__ */ h({
|
|
|
25
25
|
}, d = l(() => o?.value === e.value || e.checked), i = l(() => e.height || a?.value || "thin"), f = l(
|
|
26
26
|
() => g({
|
|
27
27
|
nmorph: [v[i.value]],
|
|
28
|
-
"nmorph-radio": [
|
|
28
|
+
"nmorph-radio": [e.disabled && "disabled", d.value && "checked", e.styleType]
|
|
29
29
|
})
|
|
30
30
|
), u = m(null);
|
|
31
31
|
p({ inputDOMRef: u });
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import './NmorphRadioGroup.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useModifiers as
|
|
4
|
-
import
|
|
5
|
-
|
|
2
|
+
import { defineComponent as h, ref as y, watch as g, computed as n, provide as a } from "vue";
|
|
3
|
+
import { useModifiers as q } from "../../../utils/create-modifiers.js";
|
|
4
|
+
import { useFormItemModel as v } from "../nmorph-form/use-form-item-input.js";
|
|
5
|
+
import _ from "../nmorph-radio/NmorphRadio.vue.js";
|
|
6
|
+
const x = /* @__PURE__ */ h({
|
|
6
7
|
__name: "NmorphRadioGroup",
|
|
7
8
|
props: {
|
|
8
|
-
modelValue: { type: String, required: !
|
|
9
|
+
modelValue: { type: String, required: !1, default: "" },
|
|
9
10
|
options: { type: Array, required: !1, default: () => [] },
|
|
10
11
|
styleType: { type: null, required: !1, default: "button" },
|
|
11
12
|
direction: { type: null, required: !1, default: "row" },
|
|
@@ -17,25 +18,26 @@ const b = /* @__PURE__ */ m({
|
|
|
17
18
|
tabindex: { type: Number, required: !1 }
|
|
18
19
|
},
|
|
19
20
|
emits: ["update:model-value"],
|
|
20
|
-
setup(
|
|
21
|
-
|
|
22
|
-
const e =
|
|
23
|
-
|
|
24
|
-
() =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
setup(s, { expose: m, emit: f }) {
|
|
22
|
+
m();
|
|
23
|
+
const e = s, i = f, { modelValue: o, updateModelValue: l } = v(
|
|
24
|
+
e,
|
|
25
|
+
(r) => i("update:model-value", r),
|
|
26
|
+
""
|
|
27
|
+
), t = y(o.value);
|
|
28
|
+
g(o, (r) => {
|
|
29
|
+
t.value = r;
|
|
30
|
+
});
|
|
31
|
+
const u = (r) => {
|
|
32
|
+
t.value = r, l(t.value);
|
|
33
|
+
}, c = n(() => q({ "nmorph-radio-group": [e.styleType, e.direction] })), d = n(() => e.height);
|
|
34
|
+
a("radio-group-selected-value", t), a("change-radio-button-value-handler", u), a("radio-group-height", d);
|
|
35
|
+
const p = { props: e, emit: i, modelValue: o, updateModelValue: l, initialValue: t, changeHandler: u, modifiers: c, height: d, get NmorphRadio() {
|
|
36
|
+
return _;
|
|
35
37
|
} };
|
|
36
|
-
return Object.defineProperty(
|
|
38
|
+
return Object.defineProperty(p, "__isScriptSetup", { enumerable: !1, value: !0 }), p;
|
|
37
39
|
}
|
|
38
40
|
});
|
|
39
41
|
export {
|
|
40
|
-
|
|
42
|
+
x as default
|
|
41
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.nmorph-select{--base-width: 200px;width:var(--base-width);height:var(--height);cursor:pointer}.nmorph-select .nmorph-select__content{position:relative;height:100%;background:var(--nmorph-main-color);box-shadow:var(--nmorph-shadow-outset)}.nmorph-select .nmorph-select__selected-values-line{display:flex;justify-content:space-between;align-items:center;height:100%;padding:var(--indentation-00) var(--default-indentation-input);border-radius:
|
|
1
|
+
.nmorph-select{--base-width: 200px;width:var(--base-width);height:var(--height);border-radius:var(--default-border-radius);cursor:pointer}.nmorph-select .nmorph-select__content{position:relative;height:100%;background:var(--nmorph-main-color);border-radius:inherit;box-shadow:var(--nmorph-shadow-outset)}.nmorph-select .nmorph-select__selected-values-line{display:flex;justify-content:space-between;align-items:center;height:100%;padding:var(--indentation-00) var(--default-indentation-input);border-radius:inherit}.nmorph-select .nmorph-select__selected-value{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.nmorph-select select,.nmorph-select option{position:absolute;width:0;height:0;padding:0;border:none;opacity:0}.nmorph-select.nmorph-select--loading .nmorph-select__options{display:flex;justify-content:center;padding:16px}.nmorph-select.nmorph-select--disabled{cursor:not-allowed;opacity:.6}.nmorph-select.nmorph-select--fill{width:100%}.nmorph-select.nmorph-select--options-auto-width .nmorph-select__options{width:max-content;max-width:calc(100vw - var(--indentation-02) * 2)}.nmorph-select .nmorph-select__virtual-list{overflow-y:auto}.nmorph-select .nmorph-select__virtual-spacer{position:relative}.nmorph-select .nmorph-select__virtual-content{position:absolute;top:0;right:0;left:0}.nmorph-select.nmorph-select--open .nmorph-select__chevron{transform:rotate(180deg)}.nmorph-select.nmorph-select--open .nmorph-select__content{background:var(--nmorph-main-color);box-shadow:var(--nmorph-shadow-inset)}.nmorph-select.nmorph-select--selected-line-outset .nmorph-select__content{background:var(--nmorph-main-color);box-shadow:var(--nmorph-shadow-outset)}.nmorph-select.nmorph-select--focus{outline:2px solid var(--nmorph-accent-color)}.nmorph-select.nmorph-select--focus .nmorph-select__content{box-shadow:none}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import './NmorphSelect.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { NmorphComponentHeight as
|
|
4
|
-
import { useModifiers as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
2
|
+
import { defineComponent as oe, computed as a, ref as d, watch as c, nextTick as R, onMounted as ie, onUnmounted as se, provide as w, toRef as de } from "vue";
|
|
3
|
+
import { NmorphComponentHeight as ve } from "../../../types/index.js";
|
|
4
|
+
import { useModifiers as ce } from "../../../utils/create-modifiers.js";
|
|
5
|
+
import { toCssSize as C, getNmorphOptionHeight as fe, resolveDomElement as pe } from "../../../utils/common.js";
|
|
6
|
+
import { useI18n as me } from "vue-i18n";
|
|
7
|
+
import { useFormItemModel as he, useFormItemInput as ge } from "../nmorph-form/use-form-item-input.js";
|
|
8
|
+
import { useVirtualList as ye } from "../../../hooks/use-virtual-list.js";
|
|
9
|
+
import He from "../../navigation/nmorph-dropdown/NmorphDropdown.vue.js";
|
|
10
|
+
import be from "./components/nmorph-select-option/NmorphSelectOption.vue.js";
|
|
11
|
+
import qe from "../../basic/nmorph-icon/NmorphIcon.vue.js";
|
|
12
|
+
import Ie from "../../data/nmorph-tag-list/components/nmorph-tag-item/NmorphTagItem.vue.js";
|
|
13
|
+
import xe from "../../../assets/icons/chevron-down.svg.js";
|
|
14
|
+
import Ne from "../../../assets/icons/loader.svg.js";
|
|
15
|
+
const je = /* @__PURE__ */ oe({
|
|
15
16
|
__name: "NmorphSelect",
|
|
16
17
|
props: {
|
|
17
18
|
noElementPlaceholder: { type: String, required: !1, default: "" },
|
|
@@ -38,112 +39,113 @@ const ke = /* @__PURE__ */ ue({
|
|
|
38
39
|
tabindex: { type: Number, required: !1 }
|
|
39
40
|
},
|
|
40
41
|
emits: ["update:model-value"],
|
|
41
|
-
setup(
|
|
42
|
-
|
|
43
|
-
const { t:
|
|
44
|
-
() =>
|
|
45
|
-
),
|
|
42
|
+
setup(P, { expose: T, emit: W }) {
|
|
43
|
+
T();
|
|
44
|
+
const { t: M } = me(), l = P, D = a(
|
|
45
|
+
() => l.noElementPlaceholder ? l.noElementPlaceholder : M("noElementPlaceholder")
|
|
46
|
+
), A = W, { modelValue: p, updateModelValue: h } = he(
|
|
47
|
+
l,
|
|
48
|
+
(e) => A("update:model-value", e),
|
|
49
|
+
""
|
|
50
|
+
), t = d(p.value), r = d(l.open), v = a(() => l.disabled || l.loading), g = a(() => l.optionsWidth === "auto"), y = d(!0), { id: H, name: k, autocomplete: $, tabindex: F } = ge(l), b = (e) => {
|
|
46
51
|
if (!v.value) {
|
|
47
|
-
if (r.value = !1, typeof
|
|
48
|
-
const n =
|
|
49
|
-
if (
|
|
50
|
-
n ?
|
|
52
|
+
if (r.value = !1, typeof t.value == "string" && (!l.valueRequired && t.value === e ? t.value = "" : t.value = e, h(t.value)), Array.isArray(t.value)) {
|
|
53
|
+
const n = t.value.includes(e), ne = t.value.length === 1 && n;
|
|
54
|
+
if (l.valueRequired && ne) return;
|
|
55
|
+
n ? t.value = t.value.filter((ue) => ue !== e) : t.value = [...t.value, e];
|
|
51
56
|
}
|
|
52
|
-
|
|
57
|
+
h(t.value);
|
|
53
58
|
}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
59
|
+
}, m = d(!1), U = () => {
|
|
60
|
+
m.value = !0;
|
|
61
|
+
}, z = () => {
|
|
62
|
+
m.value = !1;
|
|
58
63
|
}, j = a(
|
|
59
|
-
() =>
|
|
60
|
-
nmorph: [
|
|
64
|
+
() => ce({
|
|
65
|
+
nmorph: [ve[l.height]],
|
|
61
66
|
"nmorph-select": [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
l.disabled && "disabled",
|
|
68
|
+
p.value ? "on" : "off",
|
|
69
|
+
l.loading && "loading",
|
|
70
|
+
r.value && !v.value && "open",
|
|
71
|
+
l.fill && "fill",
|
|
72
|
+
g.value && "options-auto-width",
|
|
73
|
+
y.value ? "selected-line-outset" : "selected-line-inset",
|
|
74
|
+
m.value && "focus"
|
|
70
75
|
]
|
|
71
76
|
})
|
|
72
|
-
),
|
|
73
|
-
...
|
|
74
|
-
})),
|
|
77
|
+
), G = a(() => ({
|
|
78
|
+
...l.width !== void 0 && { "--base-width": C(l.width) }
|
|
79
|
+
})), J = () => {
|
|
75
80
|
v.value || (r.value = !r.value);
|
|
76
81
|
};
|
|
77
|
-
|
|
82
|
+
c(
|
|
78
83
|
r,
|
|
79
84
|
(e) => {
|
|
80
|
-
e && (
|
|
85
|
+
e && (y.value = !1);
|
|
81
86
|
},
|
|
82
87
|
{ immediate: !0 }
|
|
83
88
|
);
|
|
84
89
|
const q = () => {
|
|
85
90
|
r.value = !1;
|
|
86
91
|
};
|
|
87
|
-
|
|
88
|
-
() =>
|
|
92
|
+
c(
|
|
93
|
+
() => l.loading,
|
|
89
94
|
(e) => {
|
|
90
95
|
e && (r.value = !1);
|
|
91
96
|
}
|
|
97
|
+
), c(
|
|
98
|
+
p,
|
|
99
|
+
(e) => {
|
|
100
|
+
t.value = e;
|
|
101
|
+
},
|
|
102
|
+
{ deep: !0 }
|
|
92
103
|
);
|
|
93
|
-
const i = a(() =>
|
|
94
|
-
|
|
95
|
-
thick: 38,
|
|
96
|
-
thin: 22
|
|
97
|
-
})[t.height || "basic"]), E = a(() => t.virtualItemHeight || A.value), V = a(() => t.virtualOverscan), _ = a(() => t.virtualDynamicHeight), s = pe(N, {
|
|
98
|
-
enabled: c,
|
|
104
|
+
const i = a(() => l.options.length > 0 ? l.options : l.optionsMap), I = d(null), x = d([]), N = a(() => l.options), f = a(() => l.virtual && N.value.length > 0), E = a(() => l.virtualItemHeight || fe(l.height)), V = a(() => l.virtualOverscan), _ = a(() => l.virtualDynamicHeight), s = ye(N, {
|
|
105
|
+
enabled: f,
|
|
99
106
|
itemHeight: E,
|
|
100
107
|
overscan: V,
|
|
101
108
|
dynamic: _
|
|
102
|
-
}),
|
|
103
|
-
|
|
104
|
-
})), Q = a(() => ({
|
|
105
|
-
transform: `translateY(${s.offsetTop.value}px)`
|
|
106
|
-
})), X = a(() => b(t.virtualMaxHeight)), O = () => {
|
|
107
|
-
i.value.length > 0 || !x.value || (I.value = Array.from(x.value.querySelectorAll(".nmorph-select-option")).map((e) => e.getAttribute("value")).filter((e) => !!e));
|
|
109
|
+
}), K = a(() => s.virtualItems.value), Q = s.spacerStyle, X = s.contentStyle, Y = a(() => C(l.virtualMaxHeight)), O = () => {
|
|
110
|
+
i.value.length > 0 || !I.value || (x.value = Array.from(I.value.querySelectorAll(".nmorph-select-option")).map((e) => e.getAttribute("value")).filter((e) => !!e));
|
|
108
111
|
}, o = a(
|
|
109
|
-
() => i.value.length > 0 ? i.value.map((e) => e.value) :
|
|
110
|
-
), Z = a(() =>
|
|
111
|
-
|
|
112
|
-
r.value &&
|
|
113
|
-
}),
|
|
112
|
+
() => i.value.length > 0 ? i.value.map((e) => e.value) : x.value
|
|
113
|
+
), Z = a(() => f.value ? Array.isArray(t.value) ? t.value : t.value ? [t.value] : [] : o.value), u = d(0), S = a(() => o.value[u.value] || ""), ee = a(() => `${H.value}-listbox`), te = (e) => `${H.value}-option-${e.replace(/\s+/g, "-")}`;
|
|
114
|
+
c(u, (e) => {
|
|
115
|
+
r.value && f.value && s.scrollToIndex(e);
|
|
116
|
+
}), c(
|
|
114
117
|
o,
|
|
115
118
|
(e) => {
|
|
116
119
|
u.value >= e.length && (u.value = Math.max(e.length - 1, 0));
|
|
117
120
|
},
|
|
118
121
|
{ immediate: !0 }
|
|
119
|
-
),
|
|
122
|
+
), c(r, async (e) => {
|
|
120
123
|
if (e) {
|
|
121
|
-
if (await R(), O(), typeof
|
|
122
|
-
const n = o.value.indexOf(
|
|
124
|
+
if (await R(), O(), typeof t.value == "string") {
|
|
125
|
+
const n = o.value.indexOf(t.value);
|
|
123
126
|
n !== -1 && (u.value = n);
|
|
124
127
|
}
|
|
125
|
-
s.refresh(),
|
|
128
|
+
s.refresh(), f.value && s.scrollToIndex(u.value);
|
|
126
129
|
}
|
|
127
|
-
}),
|
|
130
|
+
}), ie(async () => {
|
|
128
131
|
await R(), O(), document.addEventListener("click", q);
|
|
129
|
-
}),
|
|
132
|
+
}), se(() => {
|
|
130
133
|
document.removeEventListener("click", q);
|
|
131
134
|
});
|
|
132
|
-
const le = a(() => typeof
|
|
133
|
-
|
|
135
|
+
const le = a(() => typeof t.value == "string" ? t.value === "" ? D.value : i.value.find((e) => e.value === t.value)?.label : i.value.find((e) => e.value === t.value)?.label), ae = a(() => i.value.length > 0 ? i.value.filter((n) => t.value.includes(n.value)).map((n) => ({ text: n.label, value: n.value })) : Array.isArray(t.value) ? t.value.map((n) => ({ text: n, value: n })) : [{ text: t.value, value: t.value }]);
|
|
136
|
+
w("select-selected-value", t), w("select-change-selected-value", b), w("select-height", de(l, "height"));
|
|
134
137
|
const B = d(null), re = a(
|
|
135
|
-
() =>
|
|
136
|
-
), L = { t:
|
|
138
|
+
() => g.value ? `${B.value?.clientWidth || 0}px` : void 0
|
|
139
|
+
), L = { t: M, props: l, computedNoElementPlaceholder: D, emit: A, modelValue: p, updateModelValue: h, initialValue: t, open: r, disabledInput: v, autoOptionsWidth: g, selectedLineOutset: y, id: H, name: k, autocomplete: $, tabindex: F, changeHandler: b, focus: m, focusHandler: U, blurHandler: z, modifiers: j, styles: G, clickHandler: J, closeHandler: q, optionsMap: i, optionsDOMRef: I, slotDomOptions: x, renderedOptions: N, virtualEnabled: f, virtualItemHeight: E, virtualOverscan: V, virtualDynamicHeight: _, virtualList: s, virtualOptions: K, virtualSpacerStyle: Q, virtualContentStyle: X, virtualMaxHeight: Y, refreshDomOptions: O, domOptions: o, nativeOptions: Z, currentIndex: u, currentFocusedEl: S, listboxId: ee, getOptionId: te, selectedValueTitle: le, tags: ae, nmorphSelectDOMRef: B, optionsMinWidth: re, spaceHandler: () => {
|
|
137
140
|
v.value || (r.value = !r.value);
|
|
138
141
|
}, arrowDownHandler: () => {
|
|
139
142
|
v.value || o.value.length !== 0 && (r.value || (r.value = !0), u.value = (u.value + 1) % o.value.length);
|
|
140
143
|
}, arrowUpHandler: () => {
|
|
141
144
|
v.value || o.value.length !== 0 && (r.value || (r.value = !0), u.value = (u.value - 1 + o.value.length) % o.value.length);
|
|
142
145
|
}, enterHandler: () => {
|
|
143
|
-
r.value && S.value &&
|
|
146
|
+
r.value && S.value && b(S.value);
|
|
144
147
|
}, setVirtualOptionRef: (e, n) => {
|
|
145
|
-
|
|
146
|
-
s.measureElement(n, w);
|
|
148
|
+
s.measureElement(n, pe(e));
|
|
147
149
|
}, escapeHandler: () => {
|
|
148
150
|
r.value = !1;
|
|
149
151
|
}, homeHandler: () => {
|
|
@@ -151,21 +153,21 @@ const ke = /* @__PURE__ */ ue({
|
|
|
151
153
|
}, endHandler: () => {
|
|
152
154
|
u.value = Math.max(o.value.length - 1, 0);
|
|
153
155
|
}, get NmorphTagItem() {
|
|
154
|
-
return
|
|
156
|
+
return Ie;
|
|
155
157
|
}, get NmorphIcon() {
|
|
156
|
-
return
|
|
158
|
+
return qe;
|
|
157
159
|
}, get NmorphSelectOption() {
|
|
158
|
-
return
|
|
160
|
+
return be;
|
|
159
161
|
}, get NmorphDropdown() {
|
|
160
|
-
return
|
|
162
|
+
return He;
|
|
161
163
|
}, get NmorphIconLoaderDots() {
|
|
162
|
-
return
|
|
164
|
+
return Ne;
|
|
163
165
|
}, get NmorphIconChevronDown() {
|
|
164
|
-
return
|
|
166
|
+
return xe;
|
|
165
167
|
} };
|
|
166
168
|
return Object.defineProperty(L, "__isScriptSetup", { enumerable: !1, value: !0 }), L;
|
|
167
169
|
}
|
|
168
170
|
});
|
|
169
171
|
export {
|
|
170
|
-
|
|
172
|
+
je as default
|
|
171
173
|
};
|
|
@@ -31,10 +31,10 @@ const I = /* @__PURE__ */ g({
|
|
|
31
31
|
() => S({
|
|
32
32
|
nmorph: [y[s.value]],
|
|
33
33
|
"nmorph-select-option": [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
e.disabled && "disabled",
|
|
35
|
+
e.label && "with-label",
|
|
36
|
+
u.value && "checked",
|
|
37
|
+
e.focused && "focused"
|
|
38
38
|
]
|
|
39
39
|
})
|
|
40
40
|
), m = t(() => ({
|