@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,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: [
|
|
47
|
+
const E = c(
|
|
48
|
+
() => ue({
|
|
49
|
+
nmorph: [oe[l.height], d.value && "focused"],
|
|
46
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}
|
|
@@ -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,18 +1,18 @@
|
|
|
1
1
|
import './NmorphSelect.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { NmorphComponentHeight as
|
|
4
|
-
import { useModifiers as
|
|
5
|
-
import { toCssSize as
|
|
6
|
-
import { useI18n as
|
|
7
|
-
import { useFormItemInput as
|
|
8
|
-
import { useVirtualList as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
const
|
|
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({
|
|
16
16
|
__name: "NmorphSelect",
|
|
17
17
|
props: {
|
|
18
18
|
noElementPlaceholder: { type: String, required: !1, default: "" },
|
|
@@ -39,103 +39,113 @@ const Ue = /* @__PURE__ */ ne({
|
|
|
39
39
|
tabindex: { type: Number, required: !1 }
|
|
40
40
|
},
|
|
41
41
|
emits: ["update:model-value"],
|
|
42
|
-
setup(
|
|
43
|
-
|
|
44
|
-
const { t:
|
|
45
|
-
() =>
|
|
46
|
-
),
|
|
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) => {
|
|
47
51
|
if (!v.value) {
|
|
48
|
-
if (r.value = !1, typeof
|
|
49
|
-
const n =
|
|
50
|
-
if (
|
|
51
|
-
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];
|
|
52
56
|
}
|
|
53
|
-
|
|
57
|
+
h(t.value);
|
|
54
58
|
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
() =>
|
|
61
|
-
nmorph: [
|
|
59
|
+
}, m = d(!1), U = () => {
|
|
60
|
+
m.value = !0;
|
|
61
|
+
}, z = () => {
|
|
62
|
+
m.value = !1;
|
|
63
|
+
}, j = a(
|
|
64
|
+
() => ce({
|
|
65
|
+
nmorph: [ve[l.height]],
|
|
62
66
|
"nmorph-select": [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
l.disabled && "disabled",
|
|
68
|
+
p.value ? "on" : "off",
|
|
69
|
+
l.loading && "loading",
|
|
66
70
|
r.value && !v.value && "open",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
l.fill && "fill",
|
|
72
|
+
g.value && "options-auto-width",
|
|
73
|
+
y.value ? "selected-line-outset" : "selected-line-inset",
|
|
74
|
+
m.value && "focus"
|
|
71
75
|
]
|
|
72
76
|
})
|
|
73
|
-
),
|
|
74
|
-
...
|
|
75
|
-
})),
|
|
77
|
+
), G = a(() => ({
|
|
78
|
+
...l.width !== void 0 && { "--base-width": C(l.width) }
|
|
79
|
+
})), J = () => {
|
|
76
80
|
v.value || (r.value = !r.value);
|
|
77
81
|
};
|
|
78
|
-
|
|
82
|
+
c(
|
|
79
83
|
r,
|
|
80
84
|
(e) => {
|
|
81
|
-
e && (
|
|
85
|
+
e && (y.value = !1);
|
|
82
86
|
},
|
|
83
87
|
{ immediate: !0 }
|
|
84
88
|
);
|
|
85
|
-
const
|
|
89
|
+
const q = () => {
|
|
86
90
|
r.value = !1;
|
|
87
91
|
};
|
|
88
|
-
|
|
89
|
-
() =>
|
|
92
|
+
c(
|
|
93
|
+
() => l.loading,
|
|
90
94
|
(e) => {
|
|
91
95
|
e && (r.value = !1);
|
|
92
96
|
}
|
|
97
|
+
), c(
|
|
98
|
+
p,
|
|
99
|
+
(e) => {
|
|
100
|
+
t.value = e;
|
|
101
|
+
},
|
|
102
|
+
{ deep: !0 }
|
|
93
103
|
);
|
|
94
|
-
const i = a(() =>
|
|
95
|
-
enabled:
|
|
96
|
-
itemHeight:
|
|
97
|
-
overscan:
|
|
98
|
-
dynamic:
|
|
99
|
-
}),
|
|
100
|
-
i.value.length > 0 || !
|
|
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,
|
|
106
|
+
itemHeight: E,
|
|
107
|
+
overscan: V,
|
|
108
|
+
dynamic: _
|
|
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));
|
|
101
111
|
}, o = a(
|
|
102
|
-
() => i.value.length > 0 ? i.value.map((e) => e.value) :
|
|
103
|
-
),
|
|
104
|
-
|
|
105
|
-
r.value &&
|
|
106
|
-
}),
|
|
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(
|
|
107
117
|
o,
|
|
108
118
|
(e) => {
|
|
109
119
|
u.value >= e.length && (u.value = Math.max(e.length - 1, 0));
|
|
110
120
|
},
|
|
111
121
|
{ immediate: !0 }
|
|
112
|
-
),
|
|
122
|
+
), c(r, async (e) => {
|
|
113
123
|
if (e) {
|
|
114
|
-
if (await
|
|
115
|
-
const n = o.value.indexOf(
|
|
124
|
+
if (await R(), O(), typeof t.value == "string") {
|
|
125
|
+
const n = o.value.indexOf(t.value);
|
|
116
126
|
n !== -1 && (u.value = n);
|
|
117
127
|
}
|
|
118
|
-
s.refresh(),
|
|
128
|
+
s.refresh(), f.value && s.scrollToIndex(u.value);
|
|
119
129
|
}
|
|
120
|
-
}),
|
|
121
|
-
await
|
|
122
|
-
}),
|
|
123
|
-
document.removeEventListener("click",
|
|
130
|
+
}), ie(async () => {
|
|
131
|
+
await R(), O(), document.addEventListener("click", q);
|
|
132
|
+
}), se(() => {
|
|
133
|
+
document.removeEventListener("click", q);
|
|
124
134
|
});
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
() =>
|
|
129
|
-
),
|
|
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"));
|
|
137
|
+
const B = d(null), re = a(
|
|
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: () => {
|
|
130
140
|
v.value || (r.value = !r.value);
|
|
131
141
|
}, arrowDownHandler: () => {
|
|
132
142
|
v.value || o.value.length !== 0 && (r.value || (r.value = !0), u.value = (u.value + 1) % o.value.length);
|
|
133
143
|
}, arrowUpHandler: () => {
|
|
134
144
|
v.value || o.value.length !== 0 && (r.value || (r.value = !0), u.value = (u.value - 1 + o.value.length) % o.value.length);
|
|
135
145
|
}, enterHandler: () => {
|
|
136
|
-
r.value &&
|
|
146
|
+
r.value && S.value && b(S.value);
|
|
137
147
|
}, setVirtualOptionRef: (e, n) => {
|
|
138
|
-
s.measureElement(n,
|
|
148
|
+
s.measureElement(n, pe(e));
|
|
139
149
|
}, escapeHandler: () => {
|
|
140
150
|
r.value = !1;
|
|
141
151
|
}, homeHandler: () => {
|
|
@@ -143,21 +153,21 @@ const Ue = /* @__PURE__ */ ne({
|
|
|
143
153
|
}, endHandler: () => {
|
|
144
154
|
u.value = Math.max(o.value.length - 1, 0);
|
|
145
155
|
}, get NmorphTagItem() {
|
|
146
|
-
return
|
|
156
|
+
return Ie;
|
|
147
157
|
}, get NmorphIcon() {
|
|
148
|
-
return
|
|
158
|
+
return qe;
|
|
149
159
|
}, get NmorphSelectOption() {
|
|
150
|
-
return
|
|
160
|
+
return be;
|
|
151
161
|
}, get NmorphDropdown() {
|
|
152
|
-
return
|
|
162
|
+
return He;
|
|
153
163
|
}, get NmorphIconLoaderDots() {
|
|
154
|
-
return
|
|
164
|
+
return Ne;
|
|
155
165
|
}, get NmorphIconChevronDown() {
|
|
156
|
-
return
|
|
166
|
+
return xe;
|
|
157
167
|
} };
|
|
158
|
-
return Object.defineProperty(
|
|
168
|
+
return Object.defineProperty(L, "__isScriptSetup", { enumerable: !1, value: !0 }), L;
|
|
159
169
|
}
|
|
160
170
|
});
|
|
161
171
|
export {
|
|
162
|
-
|
|
172
|
+
je as default
|
|
163
173
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import './NmorphSelectButton.css';
|
|
2
|
-
import { defineComponent as
|
|
3
|
-
import { useModifiers as
|
|
4
|
-
import { toCssSize as
|
|
5
|
-
import
|
|
6
|
-
|
|
2
|
+
import { defineComponent as g, ref as y, watch as b, computed as u, provide as n } from "vue";
|
|
3
|
+
import { useModifiers as v } from "../../../utils/create-modifiers.js";
|
|
4
|
+
import { toCssSize as s } from "../../../utils/common.js";
|
|
5
|
+
import { useFormItemModel as h } from "../nmorph-form/use-form-item-input.js";
|
|
6
|
+
import q from "./components/nmorph-select-button-item/NmorphSelectButtonItem.vue.js";
|
|
7
|
+
const F = /* @__PURE__ */ g({
|
|
7
8
|
__name: "NmorphSelectButton",
|
|
8
9
|
props: {
|
|
9
10
|
modelValue: { type: String, required: !1, default: "" },
|
|
@@ -20,33 +21,34 @@ const z = /* @__PURE__ */ c({
|
|
|
20
21
|
tabindex: { type: Number, required: !1 }
|
|
21
22
|
},
|
|
22
23
|
emits: ["update:model-value"],
|
|
23
|
-
setup(
|
|
24
|
-
|
|
25
|
-
const e =
|
|
26
|
-
|
|
27
|
-
() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
setup(m, { expose: f, emit: p }) {
|
|
25
|
+
f();
|
|
26
|
+
const e = m, l = p, { modelValue: r, updateModelValue: a } = h(
|
|
27
|
+
e,
|
|
28
|
+
(t) => l("update:model-value", t),
|
|
29
|
+
""
|
|
30
|
+
), i = y(r.value);
|
|
31
|
+
b(r, (t) => {
|
|
32
|
+
i.value = t;
|
|
33
|
+
});
|
|
34
|
+
const c = u(
|
|
35
|
+
() => v({
|
|
34
36
|
"nmorph-select-button": [e.disabled && "disabled", e.fill && "fill", e.height]
|
|
35
37
|
})
|
|
36
|
-
),
|
|
37
|
-
...e.trackPadding !== void 0 && { "--track-padding":
|
|
38
|
-
...e.itemSize !== void 0 && { "--item-size":
|
|
38
|
+
), S = u(() => ({
|
|
39
|
+
...e.trackPadding !== void 0 && { "--track-padding": s(e.trackPadding) },
|
|
40
|
+
...e.itemSize !== void 0 && { "--item-size": s(e.itemSize) },
|
|
39
41
|
...e.itemFontSize !== void 0 && { "--item-font-size": e.itemFontSize }
|
|
40
|
-
})),
|
|
41
|
-
e.disabled || (
|
|
42
|
+
})), o = (t) => {
|
|
43
|
+
e.disabled || (i.value = t, a(t));
|
|
42
44
|
};
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
return
|
|
45
|
+
n("select-button-selected-value", i), n("select-button-change-handler", o);
|
|
46
|
+
const d = { props: e, emit: l, modelValue: r, updateModelValue: a, initialValue: i, modifiers: c, styles: S, changeHandler: o, get NmorphSelectButtonItem() {
|
|
47
|
+
return q;
|
|
46
48
|
} };
|
|
47
|
-
return Object.defineProperty(
|
|
49
|
+
return Object.defineProperty(d, "__isScriptSetup", { enumerable: !1, value: !0 }), d;
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
export {
|
|
51
|
-
|
|
53
|
+
F as default
|
|
52
54
|
};
|