@nubisco/ui 5.19.0 → 5.20.0
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/{ActionGroup-CMuposow.cjs → ActionGroup-CUN48Qea.cjs} +1 -1
- package/dist/{ActionGroup-0u17QzT8.js → ActionGroup-lEopoloN.js} +1 -1
- package/dist/BarChart-Bnkibwcl.js +294 -0
- package/dist/BarChart-CjxY_3RM.cjs +1 -0
- package/dist/{Confirm-OMhu2Fuz.js → Confirm-Dh1H2PMh.js} +1 -1
- package/dist/{Confirm-DCkG5bUZ.cjs → Confirm-ue689l-w.cjs} +1 -1
- package/dist/DataTable-CQBI0wcg.js +412 -0
- package/dist/DataTable-DN4SbClx.cjs +1 -0
- package/dist/{DatePicker-MDaQ2l8I.js → DatePicker-ViTSDX6d.js} +162 -135
- package/dist/DatePicker-lv4wQxf8.cjs +1 -0
- package/dist/LineChart-Bol60gtX.cjs +1 -0
- package/dist/{LineChart-DG_ows6r.js → LineChart-CsBHPIUF.js} +25 -21
- package/dist/{Menu-D-zvh-SA.js → Menu-2Se8F81Q.js} +1 -1
- package/dist/Menu-CAZmNx60.cjs +1 -0
- package/dist/{MenuBarItem-BDqp9LzY.js → MenuBarItem-Cxxs8Dnr.js} +1 -1
- package/dist/{MenuBarItem-Dmutkr1p.cjs → MenuBarItem-dBEuTZ3Q.cjs} +1 -1
- package/dist/{Modal-C97dRTiP.js → Modal-BxSP1eyD.js} +2 -2
- package/dist/{Modal-BNgLfB88.cjs → Modal-sGlC__uQ.cjs} +1 -1
- package/dist/{Pagination-Br-k9zuG.js → Pagination-BveCRx-Z.js} +1 -1
- package/dist/{Pagination-CCMhqtoz.cjs → Pagination-DlTqW-zR.cjs} +1 -1
- package/dist/Select-D4Il1NaM.js +489 -0
- package/dist/Select-MwbDOqbP.cjs +1 -0
- package/dist/Tabs-Bmw1hFrN.cjs +1 -0
- package/dist/Tabs-CjXOZ3K6.js +196 -0
- package/dist/all.cjs +1 -1
- package/dist/all.mjs +12 -12
- package/dist/components/ActionGroup.cjs +1 -1
- package/dist/components/ActionGroup.mjs +1 -1
- package/dist/components/Charts/BarChart.cjs +1 -1
- package/dist/components/Charts/BarChart.d.ts +8 -1
- package/dist/components/Charts/BarChart.mjs +1 -1
- package/dist/components/Charts/BarChart.vue.d.ts.map +1 -1
- package/dist/components/Charts/LineChart.cjs +1 -1
- package/dist/components/Charts/LineChart.d.ts +8 -1
- package/dist/components/Charts/LineChart.mjs +1 -1
- package/dist/components/Charts/LineChart.vue.d.ts.map +1 -1
- package/dist/components/Charts/shared/types.d.ts +7 -0
- package/dist/components/Confirm.cjs +1 -1
- package/dist/components/Confirm.mjs +1 -1
- package/dist/components/DataTable.cjs +1 -1
- package/dist/components/DataTable.mjs +1 -1
- package/dist/components/DataTable.vue.d.ts.map +1 -1
- package/dist/components/DatePicker.cjs +1 -1
- package/dist/components/DatePicker.mjs +1 -1
- package/dist/components/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/Menu.cjs +1 -1
- package/dist/components/Menu.mjs +1 -1
- package/dist/components/MenuBarItem.cjs +1 -1
- package/dist/components/MenuBarItem.mjs +1 -1
- package/dist/components/Modal.cjs +1 -1
- package/dist/components/Modal.mjs +1 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/Pagination.cjs +1 -1
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/Select.cjs +1 -1
- package/dist/components/Select.d.ts +8 -0
- package/dist/components/Select.mjs +1 -1
- package/dist/components/Select.vue.d.ts +9 -7
- package/dist/components/Select.vue.d.ts.map +1 -1
- package/dist/components/Tabs.cjs +1 -1
- package/dist/components/Tabs.mjs +1 -1
- package/dist/components/Tabs.vue.d.ts.map +1 -1
- package/dist/composables/useConfirm.composable.cjs +1 -1
- package/dist/composables/useConfirm.composable.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +12 -12
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/styles/BarChart.css +1 -1
- package/dist/styles/DataTable.css +1 -1
- package/dist/styles/LineChart.css +1 -1
- package/dist/styles/Modal.css +1 -1
- package/dist/styles/Select.css +1 -1
- package/dist/styles/Tabs.css +1 -1
- package/dist/ui.css +6 -6
- package/package.json +1 -1
- package/dist/BarChart-DTStA9jd.js +0 -290
- package/dist/BarChart-Dvrl4xeX.cjs +0 -1
- package/dist/DataTable-CWMlmjMi.cjs +0 -1
- package/dist/DataTable-DaNZAixf.js +0 -389
- package/dist/DatePicker-BgMtkY76.cjs +0 -1
- package/dist/LineChart-C5bQNxQ-.cjs +0 -1
- package/dist/Menu-BALfMobG.cjs +0 -1
- package/dist/Select-ClkEzw5T.cjs +0 -1
- package/dist/Select-DIw08nte.js +0 -437
- package/dist/Tabs-CrrG1hvh.cjs +0 -1
- package/dist/Tabs-D3pdOieX.js +0 -180
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { t as e } from "./Icon-rREAqsu0.js";
|
|
2
|
+
import { t } from "./Label-DGK5nxFy.js";
|
|
3
|
+
import { t as n } from "./Message-CHkTWe0K.js";
|
|
4
|
+
import { t as r } from "./Grid-iox-7xyH.js";
|
|
5
|
+
import { useMenuSurface as i } from "./composables/useMenuSurface.composable.mjs";
|
|
6
|
+
import { Fragment as a, Teleport as ee, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, h as te, nextTick as m, normalizeClass as h, normalizeStyle as ne, onBeforeUnmount as re, openBlock as g, ref as _, renderList as v, renderSlot as y, toDisplayString as b, unref as x, useId as ie, vModelText as ae, watch as oe, withCtx as S, withDirectives as se, withKeys as C, withModifiers as w } from "vue";
|
|
7
|
+
import { regular as T } from "@nubisco/ui/icons/caret-down";
|
|
8
|
+
import { regular as E } from "@nubisco/ui/icons/x";
|
|
9
|
+
import { regular as ce } from "@nubisco/ui/icons/caret-up";
|
|
10
|
+
//#region src/components/Select.vue?vue&type=script&setup=true&lang.ts
|
|
11
|
+
var le = [
|
|
12
|
+
"id",
|
|
13
|
+
"aria-expanded",
|
|
14
|
+
"aria-disabled",
|
|
15
|
+
"aria-required",
|
|
16
|
+
"disabled"
|
|
17
|
+
], ue = {
|
|
18
|
+
key: 2,
|
|
19
|
+
class: "nb-select__clear-space",
|
|
20
|
+
"aria-hidden": "true"
|
|
21
|
+
}, de = ["aria-label"], fe = [
|
|
22
|
+
"id",
|
|
23
|
+
"aria-expanded",
|
|
24
|
+
"aria-disabled",
|
|
25
|
+
"aria-required",
|
|
26
|
+
"disabled"
|
|
27
|
+
], pe = {
|
|
28
|
+
key: 1,
|
|
29
|
+
class: "nb-select__inner-label"
|
|
30
|
+
}, me = {
|
|
31
|
+
key: 0,
|
|
32
|
+
class: "nb-select__asterisk",
|
|
33
|
+
"aria-hidden": "true"
|
|
34
|
+
}, he = {
|
|
35
|
+
key: 0,
|
|
36
|
+
class: "nb-select__clear-space",
|
|
37
|
+
"aria-hidden": "true"
|
|
38
|
+
}, ge = ["aria-label"], _e = ["aria-multiselectable"], ve = ["aria-labelledby"], ye = ["id"], be = [
|
|
39
|
+
"aria-selected",
|
|
40
|
+
"aria-disabled",
|
|
41
|
+
"onMouseenter",
|
|
42
|
+
"onClick"
|
|
43
|
+
], xe = {
|
|
44
|
+
key: 0,
|
|
45
|
+
class: "nb-select__option-check",
|
|
46
|
+
"aria-hidden": "true"
|
|
47
|
+
}, Se = {
|
|
48
|
+
key: 0,
|
|
49
|
+
viewBox: "0 0 10 8",
|
|
50
|
+
fill: "none",
|
|
51
|
+
width: "10",
|
|
52
|
+
height: "8"
|
|
53
|
+
}, Ce = { class: "nb-select__option-label" }, we = {
|
|
54
|
+
key: 0,
|
|
55
|
+
class: "nb-select__empty"
|
|
56
|
+
}, Te = ["placeholder", "onKeydown"], D = /* @__PURE__ */ p({
|
|
57
|
+
__name: "Select",
|
|
58
|
+
props: {
|
|
59
|
+
modelValue: { default: null },
|
|
60
|
+
options: { default: () => [] },
|
|
61
|
+
multiple: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: !1
|
|
64
|
+
},
|
|
65
|
+
creatable: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: !1
|
|
68
|
+
},
|
|
69
|
+
createPlaceholder: { default: "" },
|
|
70
|
+
clearable: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: !1
|
|
73
|
+
},
|
|
74
|
+
clearLabel: { default: "Clear selection" },
|
|
75
|
+
placeholder: { default: "Select…" },
|
|
76
|
+
name: { default: "" },
|
|
77
|
+
disabled: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: !1
|
|
80
|
+
},
|
|
81
|
+
required: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: !1
|
|
84
|
+
},
|
|
85
|
+
id: { default: void 0 },
|
|
86
|
+
label: { default: "" },
|
|
87
|
+
error: { default: "" },
|
|
88
|
+
warning: { default: "" },
|
|
89
|
+
helper: { default: "" },
|
|
90
|
+
variant: { default: "default" },
|
|
91
|
+
size: { default: "md" }
|
|
92
|
+
},
|
|
93
|
+
emits: [
|
|
94
|
+
"update:modelValue",
|
|
95
|
+
"change",
|
|
96
|
+
"create"
|
|
97
|
+
],
|
|
98
|
+
setup(p, { expose: D, emit: Ee }) {
|
|
99
|
+
let O = p, k = Ee, A = (e, { slots: t }) => e.wrap ? te("div", { class: "nb-select__control" }, t.default?.()) : t.default?.();
|
|
100
|
+
A.props = ["wrap"];
|
|
101
|
+
let j = _("");
|
|
102
|
+
function De() {
|
|
103
|
+
let e = j.value.trim();
|
|
104
|
+
e && (k("create", e), j.value = "");
|
|
105
|
+
}
|
|
106
|
+
let M = _(!1), N = _(!1), P = _(-1), F = _(null), I = _(null), L = _(null);
|
|
107
|
+
i(L);
|
|
108
|
+
let R = _({
|
|
109
|
+
position: "fixed",
|
|
110
|
+
top: "0px",
|
|
111
|
+
left: "0px",
|
|
112
|
+
width: "0px",
|
|
113
|
+
zIndex: "9999"
|
|
114
|
+
}), Oe = `nb-select-${ie()}`, z = o(() => O.id ?? Oe), B = o(() => O.modelValue == null ? [] : Array.isArray(O.modelValue) ? O.modelValue : [O.modelValue]), V = o(() => {
|
|
115
|
+
if (!(O.multiple || B.value.length !== 1)) return (O.options ?? []).find((e) => e.value === B.value[0])?.icon;
|
|
116
|
+
}), H = o(() => {
|
|
117
|
+
if (B.value.length === 0) return "";
|
|
118
|
+
let e = O.options ?? [];
|
|
119
|
+
return O.multiple ? B.value.length === 1 ? e.find((e) => e.value === B.value[0])?.label ?? String(B.value[0]) : B.value.length === 2 ? B.value.map((t) => e.find((e) => e.value === t)?.label ?? String(t)).join(", ") : `${B.value.length} selected` : e.find((e) => e.value === B.value[0])?.label ?? String(B.value[0]);
|
|
120
|
+
});
|
|
121
|
+
function U(e) {
|
|
122
|
+
return B.value.includes(e);
|
|
123
|
+
}
|
|
124
|
+
let ke = o(() => {
|
|
125
|
+
let e = [];
|
|
126
|
+
return (O.options ?? []).forEach((t, n) => {
|
|
127
|
+
let r = e[e.length - 1];
|
|
128
|
+
(!r || r.name !== t.group) && e.push({
|
|
129
|
+
key: `${e.length}:${t.group ?? ""}`,
|
|
130
|
+
name: t.group,
|
|
131
|
+
labelId: `${z.value}-group-${e.length}`,
|
|
132
|
+
entries: []
|
|
133
|
+
}), e[e.length - 1].entries.push({
|
|
134
|
+
option: t,
|
|
135
|
+
index: n
|
|
136
|
+
});
|
|
137
|
+
}), e;
|
|
138
|
+
});
|
|
139
|
+
function W(e, t) {
|
|
140
|
+
let n = O.options ?? [];
|
|
141
|
+
for (let r = e + t; r >= 0 && r < n.length; r += t) if (!n[r].disabled) return r;
|
|
142
|
+
return e;
|
|
143
|
+
}
|
|
144
|
+
function G(e) {
|
|
145
|
+
if (e.disabled) return;
|
|
146
|
+
let t;
|
|
147
|
+
if (O.multiple) {
|
|
148
|
+
let n = [...B.value], r = n.indexOf(e.value);
|
|
149
|
+
r >= 0 ? n.splice(r, 1) : n.push(e.value), t = n;
|
|
150
|
+
} else t = e.value, J();
|
|
151
|
+
k("update:modelValue", t), k("change", t);
|
|
152
|
+
}
|
|
153
|
+
function K() {
|
|
154
|
+
if (!I.value) return;
|
|
155
|
+
let e = I.value.getBoundingClientRect(), t = L.value?.offsetHeight ?? 0, n = window.innerHeight - e.bottom, r = e.top;
|
|
156
|
+
R.value = {
|
|
157
|
+
position: "fixed",
|
|
158
|
+
top: t > 0 && n < t && r > n ? `${e.top - t}px` : `${e.bottom}px`,
|
|
159
|
+
left: `${e.left}px`,
|
|
160
|
+
width: `${e.width}px`,
|
|
161
|
+
zIndex: "9999"
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function q() {
|
|
165
|
+
if (O.disabled) return;
|
|
166
|
+
M.value = !0, K();
|
|
167
|
+
let e = O.options ?? [];
|
|
168
|
+
P.value = B.value.length > 0 ? Math.max(0, e.findIndex((e) => e.value === B.value[0])) : -1, m(() => {
|
|
169
|
+
K(), Z();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function J() {
|
|
173
|
+
M.value = !1, P.value = -1;
|
|
174
|
+
}
|
|
175
|
+
function Ae() {
|
|
176
|
+
M.value ? J() : q();
|
|
177
|
+
}
|
|
178
|
+
function Y(e) {
|
|
179
|
+
let t = e.target, n = F.value?.contains(t) ?? !1, r = L.value?.contains(t) ?? !1;
|
|
180
|
+
!n && !r && J();
|
|
181
|
+
}
|
|
182
|
+
function X() {
|
|
183
|
+
M.value && K();
|
|
184
|
+
}
|
|
185
|
+
oe(M, (e) => {
|
|
186
|
+
e ? (document.addEventListener("mousedown", Y), window.addEventListener("scroll", X, !0), window.addEventListener("resize", X)) : (document.removeEventListener("mousedown", Y), window.removeEventListener("scroll", X, !0), window.removeEventListener("resize", X));
|
|
187
|
+
}), re(() => {
|
|
188
|
+
document.removeEventListener("mousedown", Y), window.removeEventListener("scroll", X, !0), window.removeEventListener("resize", X);
|
|
189
|
+
});
|
|
190
|
+
function je(e) {
|
|
191
|
+
let t = O.options ?? [];
|
|
192
|
+
if (!M.value) {
|
|
193
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), q());
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
e.key === "Escape" ? (J(), e.preventDefault()) : e.key === "Tab" ? J() : e.key === "ArrowDown" ? (e.preventDefault(), P.value = W(P.value, 1), Z()) : e.key === "ArrowUp" ? (e.preventDefault(), P.value > 0 && (P.value = W(P.value, -1)), Z()) : (e.key === "Enter" || e.key === " ") && P.value >= 0 && (e.preventDefault(), G(t[P.value]));
|
|
197
|
+
}
|
|
198
|
+
function Z() {
|
|
199
|
+
m(() => {
|
|
200
|
+
!L.value || P.value < 0 || L.value.querySelectorAll(".nb-select__option")[P.value]?.scrollIntoView({ block: "nearest" });
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
let Q = o(() => O.clearable && !O.disabled && B.value.length > 0);
|
|
204
|
+
function $() {
|
|
205
|
+
let e = O.multiple ? [] : null;
|
|
206
|
+
J(), k("update:modelValue", e), k("change", e), I.value?.focus();
|
|
207
|
+
}
|
|
208
|
+
let Me = o(() => [
|
|
209
|
+
"nb-select",
|
|
210
|
+
`nb-select--${O.variant}`,
|
|
211
|
+
`nb-select--${O.size}`,
|
|
212
|
+
{
|
|
213
|
+
"nb-select--open": M.value,
|
|
214
|
+
"nb-select--focused": N.value && !M.value,
|
|
215
|
+
"nb-select--error": !!O.error,
|
|
216
|
+
"nb-select--warning": !O.error && !!O.warning,
|
|
217
|
+
"nb-select--multiple": O.multiple
|
|
218
|
+
}
|
|
219
|
+
]);
|
|
220
|
+
return D({
|
|
221
|
+
open: q,
|
|
222
|
+
close: J
|
|
223
|
+
}), (i, o) => (g(), l(a, null, [u("div", {
|
|
224
|
+
ref_key: "rootRef",
|
|
225
|
+
ref: F,
|
|
226
|
+
class: h(Me.value),
|
|
227
|
+
onKeydown: je
|
|
228
|
+
}, [p.variant === "default" ? (g(), l(a, { key: 0 }, [
|
|
229
|
+
i.$slots.label ? y(i.$slots, "label", { key: 0 }) : p.label ? (g(), s(t, {
|
|
230
|
+
key: 1,
|
|
231
|
+
for: z.value,
|
|
232
|
+
required: p.required,
|
|
233
|
+
disabled: p.disabled
|
|
234
|
+
}, {
|
|
235
|
+
default: S(() => [d(b(p.label), 1)]),
|
|
236
|
+
_: 1
|
|
237
|
+
}, 8, [
|
|
238
|
+
"for",
|
|
239
|
+
"required",
|
|
240
|
+
"disabled"
|
|
241
|
+
])) : c("", !0),
|
|
242
|
+
f(A, { wrap: p.clearable }, {
|
|
243
|
+
default: S(() => [u("button", {
|
|
244
|
+
id: z.value,
|
|
245
|
+
ref_key: "triggerRef",
|
|
246
|
+
ref: I,
|
|
247
|
+
type: "button",
|
|
248
|
+
class: "nb-select__trigger",
|
|
249
|
+
role: "combobox",
|
|
250
|
+
"aria-expanded": M.value,
|
|
251
|
+
"aria-haspopup": "listbox",
|
|
252
|
+
"aria-disabled": p.disabled || void 0,
|
|
253
|
+
"aria-required": p.required || void 0,
|
|
254
|
+
disabled: p.disabled || void 0,
|
|
255
|
+
onClick: Ae,
|
|
256
|
+
onFocus: o[0] ||= (e) => N.value = !0,
|
|
257
|
+
onBlur: o[1] ||= (e) => N.value = !1
|
|
258
|
+
}, [
|
|
259
|
+
u("span", { class: h(["nb-select__value", {
|
|
260
|
+
"nb-select__value--placeholder": !H.value,
|
|
261
|
+
"nb-select__value--with-icon": !!V.value
|
|
262
|
+
}]) }, [V.value ? (g(), s(e, {
|
|
263
|
+
key: 0,
|
|
264
|
+
class: "nb-select__value-icon",
|
|
265
|
+
name: V.value,
|
|
266
|
+
size: 16
|
|
267
|
+
}, null, 8, ["name"])) : c("", !0), H.value ? y(i.$slots, "value", {
|
|
268
|
+
key: 1,
|
|
269
|
+
values: B.value
|
|
270
|
+
}, () => [d(b(H.value), 1)]) : (g(), l(a, { key: 2 }, [d(b(p.placeholder), 1)], 64))], 2),
|
|
271
|
+
p.error ? (g(), s(n, {
|
|
272
|
+
key: 0,
|
|
273
|
+
variant: "error",
|
|
274
|
+
"icon-only": !0,
|
|
275
|
+
class: "nb-select__status-icon"
|
|
276
|
+
}, {
|
|
277
|
+
default: S(() => [d(b(p.error), 1)]),
|
|
278
|
+
_: 1
|
|
279
|
+
})) : p.warning ? (g(), s(n, {
|
|
280
|
+
key: 1,
|
|
281
|
+
variant: "warning",
|
|
282
|
+
"icon-only": !0,
|
|
283
|
+
class: "nb-select__status-icon"
|
|
284
|
+
}, {
|
|
285
|
+
default: S(() => [d(b(p.warning), 1)]),
|
|
286
|
+
_: 1
|
|
287
|
+
})) : c("", !0),
|
|
288
|
+
Q.value ? (g(), l("span", ue)) : c("", !0),
|
|
289
|
+
f(r, {
|
|
290
|
+
align: "center",
|
|
291
|
+
justify: "center",
|
|
292
|
+
class: "nb-select__caret"
|
|
293
|
+
}, {
|
|
294
|
+
default: S(() => [f(e, {
|
|
295
|
+
name: M.value ? x(ce) : x(T),
|
|
296
|
+
size: 16
|
|
297
|
+
}, null, 8, ["name"])]),
|
|
298
|
+
_: 1
|
|
299
|
+
})
|
|
300
|
+
], 40, le), Q.value ? (g(), l("button", {
|
|
301
|
+
key: 0,
|
|
302
|
+
type: "button",
|
|
303
|
+
class: "nb-select__clear",
|
|
304
|
+
"aria-label": p.clearLabel,
|
|
305
|
+
onClick: $,
|
|
306
|
+
onKeydown: [o[2] ||= C(w(() => {}, ["stop"]), ["enter"]), o[3] ||= C(w(() => {}, ["stop"]), ["space"])]
|
|
307
|
+
}, [f(e, {
|
|
308
|
+
name: x(E),
|
|
309
|
+
size: 16
|
|
310
|
+
}, null, 8, ["name"])], 40, de)) : c("", !0)]),
|
|
311
|
+
_: 3
|
|
312
|
+
}, 8, ["wrap"]),
|
|
313
|
+
p.error ? (g(), s(n, {
|
|
314
|
+
key: 2,
|
|
315
|
+
variant: "error",
|
|
316
|
+
class: "nb-select__message"
|
|
317
|
+
}, {
|
|
318
|
+
default: S(() => [d(b(p.error), 1)]),
|
|
319
|
+
_: 1
|
|
320
|
+
})) : p.warning ? (g(), s(n, {
|
|
321
|
+
key: 3,
|
|
322
|
+
variant: "warning",
|
|
323
|
+
class: "nb-select__message"
|
|
324
|
+
}, {
|
|
325
|
+
default: S(() => [d(b(p.warning), 1)]),
|
|
326
|
+
_: 1
|
|
327
|
+
})) : p.helper ? (g(), s(n, {
|
|
328
|
+
key: 4,
|
|
329
|
+
variant: "helper",
|
|
330
|
+
class: "nb-select__message"
|
|
331
|
+
}, {
|
|
332
|
+
default: S(() => [d(b(p.helper), 1)]),
|
|
333
|
+
_: 1
|
|
334
|
+
})) : c("", !0)
|
|
335
|
+
], 64)) : p.variant === "fluid" ? (g(), l(a, { key: 1 }, [f(A, { wrap: p.clearable }, {
|
|
336
|
+
default: S(() => [u("button", {
|
|
337
|
+
id: z.value,
|
|
338
|
+
ref_key: "triggerRef",
|
|
339
|
+
ref: I,
|
|
340
|
+
type: "button",
|
|
341
|
+
class: "nb-select__trigger",
|
|
342
|
+
role: "combobox",
|
|
343
|
+
"aria-expanded": M.value,
|
|
344
|
+
"aria-haspopup": "listbox",
|
|
345
|
+
"aria-disabled": p.disabled || void 0,
|
|
346
|
+
"aria-required": p.required || void 0,
|
|
347
|
+
disabled: p.disabled || void 0,
|
|
348
|
+
onClick: Ae,
|
|
349
|
+
onFocus: o[4] ||= (e) => N.value = !0,
|
|
350
|
+
onBlur: o[5] ||= (e) => N.value = !1
|
|
351
|
+
}, [p.label || i.$slots.label ? (g(), s(r, {
|
|
352
|
+
key: 0,
|
|
353
|
+
dir: "row",
|
|
354
|
+
align: "center",
|
|
355
|
+
gap: "xs",
|
|
356
|
+
class: "nb-select__inner-header"
|
|
357
|
+
}, {
|
|
358
|
+
default: S(() => [i.$slots.label ? y(i.$slots, "label", { key: 0 }) : (g(), l("label", pe, [d(b(p.label) + " ", 1), p.required ? (g(), l("span", me, "*")) : c("", !0)])), p.helper && !p.error && !p.warning ? (g(), s(n, {
|
|
359
|
+
key: 2,
|
|
360
|
+
variant: "helper",
|
|
361
|
+
"icon-only": !0,
|
|
362
|
+
class: "nb-select__inner-message"
|
|
363
|
+
}, {
|
|
364
|
+
default: S(() => [d(b(p.helper), 1)]),
|
|
365
|
+
_: 1
|
|
366
|
+
})) : c("", !0)]),
|
|
367
|
+
_: 3
|
|
368
|
+
})) : c("", !0), f(r, {
|
|
369
|
+
dir: "row",
|
|
370
|
+
align: "end",
|
|
371
|
+
flex: "",
|
|
372
|
+
class: "nb-select__value-row"
|
|
373
|
+
}, {
|
|
374
|
+
default: S(() => [
|
|
375
|
+
u("span", { class: h(["nb-select__value", {
|
|
376
|
+
"nb-select__value--placeholder": !H.value,
|
|
377
|
+
"nb-select__value--with-icon": !!V.value
|
|
378
|
+
}]) }, [V.value ? (g(), s(e, {
|
|
379
|
+
key: 0,
|
|
380
|
+
class: "nb-select__value-icon",
|
|
381
|
+
name: V.value,
|
|
382
|
+
size: 16
|
|
383
|
+
}, null, 8, ["name"])) : c("", !0), H.value ? y(i.$slots, "value", {
|
|
384
|
+
key: 1,
|
|
385
|
+
values: B.value
|
|
386
|
+
}, () => [d(b(H.value), 1)]) : (g(), l(a, { key: 2 }, [d(b(p.placeholder), 1)], 64))], 2),
|
|
387
|
+
Q.value ? (g(), l("span", he)) : c("", !0),
|
|
388
|
+
f(r, {
|
|
389
|
+
align: "center",
|
|
390
|
+
justify: "center",
|
|
391
|
+
class: "nb-select__caret"
|
|
392
|
+
}, {
|
|
393
|
+
default: S(() => [f(e, {
|
|
394
|
+
name: M.value ? x(ce) : x(T),
|
|
395
|
+
size: 16
|
|
396
|
+
}, null, 8, ["name"])]),
|
|
397
|
+
_: 1
|
|
398
|
+
})
|
|
399
|
+
]),
|
|
400
|
+
_: 3
|
|
401
|
+
})], 40, fe), Q.value ? (g(), l("button", {
|
|
402
|
+
key: 0,
|
|
403
|
+
type: "button",
|
|
404
|
+
class: "nb-select__clear",
|
|
405
|
+
"aria-label": p.clearLabel,
|
|
406
|
+
onClick: $,
|
|
407
|
+
onKeydown: [o[6] ||= C(w(() => {}, ["stop"]), ["enter"]), o[7] ||= C(w(() => {}, ["stop"]), ["space"])]
|
|
408
|
+
}, [f(e, {
|
|
409
|
+
name: x(E),
|
|
410
|
+
size: 16
|
|
411
|
+
}, null, 8, ["name"])], 40, ge)) : c("", !0)]),
|
|
412
|
+
_: 3
|
|
413
|
+
}, 8, ["wrap"]), p.error ? (g(), s(n, {
|
|
414
|
+
key: 0,
|
|
415
|
+
variant: "error",
|
|
416
|
+
class: "nb-select__fluid-message"
|
|
417
|
+
}, {
|
|
418
|
+
default: S(() => [d(b(p.error), 1)]),
|
|
419
|
+
_: 1
|
|
420
|
+
})) : p.warning ? (g(), s(n, {
|
|
421
|
+
key: 1,
|
|
422
|
+
variant: "warning",
|
|
423
|
+
class: "nb-select__fluid-message"
|
|
424
|
+
}, {
|
|
425
|
+
default: S(() => [d(b(p.warning), 1)]),
|
|
426
|
+
_: 1
|
|
427
|
+
})) : c("", !0)], 64)) : c("", !0)], 34), (g(), s(ee, { to: "body" }, [M.value ? (g(), l("div", {
|
|
428
|
+
key: 0,
|
|
429
|
+
ref_key: "dropdownRef",
|
|
430
|
+
ref: L,
|
|
431
|
+
class: "nb-select__dropdown",
|
|
432
|
+
style: ne(R.value),
|
|
433
|
+
role: "listbox",
|
|
434
|
+
"aria-multiselectable": p.multiple || void 0
|
|
435
|
+
}, [
|
|
436
|
+
(g(!0), l(a, null, v(ke.value, (t) => (g(), l("div", {
|
|
437
|
+
key: t.key,
|
|
438
|
+
class: "nb-select__group",
|
|
439
|
+
role: "group",
|
|
440
|
+
"aria-labelledby": t.name ? t.labelId : void 0
|
|
441
|
+
}, [t.name ? (g(), l("div", {
|
|
442
|
+
key: 0,
|
|
443
|
+
id: t.labelId,
|
|
444
|
+
class: "nb-select__group-label"
|
|
445
|
+
}, b(t.name), 9, ye)) : c("", !0), (g(!0), l(a, null, v(t.entries, (t) => (g(), l("div", {
|
|
446
|
+
key: t.option.value,
|
|
447
|
+
class: h(["nb-select__option", {
|
|
448
|
+
"nb-select__option--selected": U(t.option.value),
|
|
449
|
+
"nb-select__option--highlighted": P.value === t.index,
|
|
450
|
+
"nb-select__option--disabled": t.option.disabled
|
|
451
|
+
}]),
|
|
452
|
+
role: "option",
|
|
453
|
+
"aria-selected": U(t.option.value),
|
|
454
|
+
"aria-disabled": t.option.disabled || void 0,
|
|
455
|
+
onMouseenter: (e) => P.value = t.index,
|
|
456
|
+
onClick: (e) => G(t.option)
|
|
457
|
+
}, [
|
|
458
|
+
p.multiple ? (g(), l("span", xe, [U(t.option.value) ? (g(), l("svg", Se, [...o[11] ||= [u("path", {
|
|
459
|
+
d: "M1 4l3 3 5-6",
|
|
460
|
+
stroke: "currentColor",
|
|
461
|
+
"stroke-width": "1.5",
|
|
462
|
+
"stroke-linecap": "round",
|
|
463
|
+
"stroke-linejoin": "round"
|
|
464
|
+
}, null, -1)]])) : c("", !0)])) : c("", !0),
|
|
465
|
+
t.option.icon ? (g(), s(e, {
|
|
466
|
+
key: 1,
|
|
467
|
+
class: "nb-select__option-icon",
|
|
468
|
+
name: t.option.icon,
|
|
469
|
+
size: 16
|
|
470
|
+
}, null, 8, ["name"])) : c("", !0),
|
|
471
|
+
u("span", Ce, [y(i.$slots, "option", { option: t.option }, () => [d(b(t.option.label), 1)])])
|
|
472
|
+
], 42, be))), 128))], 8, ve))), 128)),
|
|
473
|
+
!p.options || p.options.length === 0 ? (g(), l("div", we, " No options ")) : c("", !0),
|
|
474
|
+
p.creatable ? (g(), l("div", {
|
|
475
|
+
key: 1,
|
|
476
|
+
class: "nb-select__create",
|
|
477
|
+
onMousedown: o[10] ||= w(() => {}, ["prevent"])
|
|
478
|
+
}, [se(u("input", {
|
|
479
|
+
"onUpdate:modelValue": o[8] ||= (e) => j.value = e,
|
|
480
|
+
type: "text",
|
|
481
|
+
class: "nb-select__create-input",
|
|
482
|
+
placeholder: p.createPlaceholder || "Add new…",
|
|
483
|
+
onKeydown: [C(w(De, ["prevent"]), ["enter"]), o[9] ||= w(() => {}, ["stop"])]
|
|
484
|
+
}, null, 40, Te), [[ae, j.value]])], 32)) : c("", !0)
|
|
485
|
+
], 12, _e)) : c("", !0)]))], 64));
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
//#endregion
|
|
489
|
+
export { D as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./chunk-D-qHiVGv.cjs`);const e=require(`./Icon-C8R_r_In.cjs`),t=require(`./Label-CZhQEyoi.cjs`),n=require(`./Message-C44ftsaT.cjs`),r=require(`./Grid-DiCxrPaO.cjs`),i=require(`./composables/useMenuSurface.composable.cjs`);let a=require(`vue`),o=require(`@nubisco/ui/icons/caret-down`),s=require(`@nubisco/ui/icons/x`),c=require(`@nubisco/ui/icons/caret-up`);var l=[`id`,`aria-expanded`,`aria-disabled`,`aria-required`,`disabled`],u={key:2,class:`nb-select__clear-space`,"aria-hidden":`true`},d=[`aria-label`],f=[`id`,`aria-expanded`,`aria-disabled`,`aria-required`,`disabled`],p={key:1,class:`nb-select__inner-label`},m={key:0,class:`nb-select__asterisk`,"aria-hidden":`true`},h={key:0,class:`nb-select__clear-space`,"aria-hidden":`true`},g=[`aria-label`],_=[`aria-multiselectable`],v=[`aria-labelledby`],y=[`id`],b=[`aria-selected`,`aria-disabled`,`onMouseenter`,`onClick`],x={key:0,class:`nb-select__option-check`,"aria-hidden":`true`},ee={key:0,viewBox:`0 0 10 8`,fill:`none`,width:`10`,height:`8`},te={class:`nb-select__option-label`},ne={key:0,class:`nb-select__empty`},re=[`placeholder`,`onKeydown`],S=(0,a.defineComponent)({__name:`Select`,props:{modelValue:{default:null},options:{default:()=>[]},multiple:{type:Boolean,default:!1},creatable:{type:Boolean,default:!1},createPlaceholder:{default:``},clearable:{type:Boolean,default:!1},clearLabel:{default:`Clear selection`},placeholder:{default:`Select…`},name:{default:``},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},id:{default:void 0},label:{default:``},error:{default:``},warning:{default:``},helper:{default:``},variant:{default:`default`},size:{default:`md`}},emits:[`update:modelValue`,`change`,`create`],setup(S,{expose:C,emit:ie}){let w=S,T=ie,E=(e,{slots:t})=>e.wrap?(0,a.h)(`div`,{class:`nb-select__control`},t.default?.()):t.default?.();E.props=[`wrap`];let D=(0,a.ref)(``);function O(){let e=D.value.trim();e&&(T(`create`,e),D.value=``)}let k=(0,a.ref)(!1),A=(0,a.ref)(!1),j=(0,a.ref)(-1),M=(0,a.ref)(null),N=(0,a.ref)(null),P=(0,a.ref)(null);i.useMenuSurface(P);let F=(0,a.ref)({position:`fixed`,top:`0px`,left:`0px`,width:`0px`,zIndex:`9999`}),I=`nb-select-${(0,a.useId)()}`,L=(0,a.computed)(()=>w.id??I),R=(0,a.computed)(()=>w.modelValue==null?[]:Array.isArray(w.modelValue)?w.modelValue:[w.modelValue]),z=(0,a.computed)(()=>{if(!(w.multiple||R.value.length!==1))return(w.options??[]).find(e=>e.value===R.value[0])?.icon}),B=(0,a.computed)(()=>{if(R.value.length===0)return``;let e=w.options??[];return w.multiple?R.value.length===1?e.find(e=>e.value===R.value[0])?.label??String(R.value[0]):R.value.length===2?R.value.map(t=>e.find(e=>e.value===t)?.label??String(t)).join(`, `):`${R.value.length} selected`:e.find(e=>e.value===R.value[0])?.label??String(R.value[0])});function V(e){return R.value.includes(e)}let H=(0,a.computed)(()=>{let e=[];return(w.options??[]).forEach((t,n)=>{let r=e[e.length-1];(!r||r.name!==t.group)&&e.push({key:`${e.length}:${t.group??``}`,name:t.group,labelId:`${L.value}-group-${e.length}`,entries:[]}),e[e.length-1].entries.push({option:t,index:n})}),e});function U(e,t){let n=w.options??[];for(let r=e+t;r>=0&&r<n.length;r+=t)if(!n[r].disabled)return r;return e}function W(e){if(e.disabled)return;let t;if(w.multiple){let n=[...R.value],r=n.indexOf(e.value);r>=0?n.splice(r,1):n.push(e.value),t=n}else t=e.value,q();T(`update:modelValue`,t),T(`change`,t)}function G(){if(!N.value)return;let e=N.value.getBoundingClientRect(),t=P.value?.offsetHeight??0,n=window.innerHeight-e.bottom,r=e.top;F.value={position:`fixed`,top:t>0&&n<t&&r>n?`${e.top-t}px`:`${e.bottom}px`,left:`${e.left}px`,width:`${e.width}px`,zIndex:`9999`}}function K(){if(w.disabled)return;k.value=!0,G();let e=w.options??[];j.value=R.value.length>0?Math.max(0,e.findIndex(e=>e.value===R.value[0])):-1,(0,a.nextTick)(()=>{G(),Z()})}function q(){k.value=!1,j.value=-1}function J(){k.value?q():K()}function Y(e){let t=e.target,n=M.value?.contains(t)??!1,r=P.value?.contains(t)??!1;!n&&!r&&q()}function X(){k.value&&G()}(0,a.watch)(k,e=>{e?(document.addEventListener(`mousedown`,Y),window.addEventListener(`scroll`,X,!0),window.addEventListener(`resize`,X)):(document.removeEventListener(`mousedown`,Y),window.removeEventListener(`scroll`,X,!0),window.removeEventListener(`resize`,X))}),(0,a.onBeforeUnmount)(()=>{document.removeEventListener(`mousedown`,Y),window.removeEventListener(`scroll`,X,!0),window.removeEventListener(`resize`,X)});function ae(e){let t=w.options??[];if(!k.value){(e.key===`Enter`||e.key===` `||e.key===`ArrowDown`)&&(e.preventDefault(),K());return}e.key===`Escape`?(q(),e.preventDefault()):e.key===`Tab`?q():e.key===`ArrowDown`?(e.preventDefault(),j.value=U(j.value,1),Z()):e.key===`ArrowUp`?(e.preventDefault(),j.value>0&&(j.value=U(j.value,-1)),Z()):(e.key===`Enter`||e.key===` `)&&j.value>=0&&(e.preventDefault(),W(t[j.value]))}function Z(){(0,a.nextTick)(()=>{!P.value||j.value<0||P.value.querySelectorAll(`.nb-select__option`)[j.value]?.scrollIntoView({block:`nearest`})})}let Q=(0,a.computed)(()=>w.clearable&&!w.disabled&&R.value.length>0);function $(){let e=w.multiple?[]:null;q(),T(`update:modelValue`,e),T(`change`,e),N.value?.focus()}let oe=(0,a.computed)(()=>[`nb-select`,`nb-select--${w.variant}`,`nb-select--${w.size}`,{"nb-select--open":k.value,"nb-select--focused":A.value&&!k.value,"nb-select--error":!!w.error,"nb-select--warning":!w.error&&!!w.warning,"nb-select--multiple":w.multiple}]);return C({open:K,close:q}),(i,C)=>((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,null,[(0,a.createElementVNode)(`div`,{ref_key:`rootRef`,ref:M,class:(0,a.normalizeClass)(oe.value),onKeydown:ae},[S.variant===`default`?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:0},[i.$slots.label?(0,a.renderSlot)(i.$slots,`label`,{key:0}):S.label?((0,a.openBlock)(),(0,a.createBlock)(t.t,{key:1,for:L.value,required:S.required,disabled:S.disabled},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.label),1)]),_:1},8,[`for`,`required`,`disabled`])):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(E,{wrap:S.clearable},{default:(0,a.withCtx)(()=>[(0,a.createElementVNode)(`button`,{id:L.value,ref_key:`triggerRef`,ref:N,type:`button`,class:`nb-select__trigger`,role:`combobox`,"aria-expanded":k.value,"aria-haspopup":`listbox`,"aria-disabled":S.disabled||void 0,"aria-required":S.required||void 0,disabled:S.disabled||void 0,onClick:J,onFocus:C[0]||=e=>A.value=!0,onBlur:C[1]||=e=>A.value=!1},[(0,a.createElementVNode)(`span`,{class:(0,a.normalizeClass)([`nb-select__value`,{"nb-select__value--placeholder":!B.value,"nb-select__value--with-icon":!!z.value}])},[z.value?((0,a.openBlock)(),(0,a.createBlock)(e.t,{key:0,class:`nb-select__value-icon`,name:z.value,size:16},null,8,[`name`])):(0,a.createCommentVNode)(``,!0),B.value?(0,a.renderSlot)(i.$slots,`value`,{key:1,values:R.value},()=>[(0,a.createTextVNode)((0,a.toDisplayString)(B.value),1)]):((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:2},[(0,a.createTextVNode)((0,a.toDisplayString)(S.placeholder),1)],64))],2),S.error?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:0,variant:`error`,"icon-only":!0,class:`nb-select__status-icon`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.error),1)]),_:1})):S.warning?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:1,variant:`warning`,"icon-only":!0,class:`nb-select__status-icon`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.warning),1)]),_:1})):(0,a.createCommentVNode)(``,!0),Q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,u)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(r.t,{align:`center`,justify:`center`,class:`nb-select__caret`},{default:(0,a.withCtx)(()=>[(0,a.createVNode)(e.t,{name:k.value?(0,a.unref)(c.regular):(0,a.unref)(o.regular),size:16},null,8,[`name`])]),_:1})],40,l),Q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,type:`button`,class:`nb-select__clear`,"aria-label":S.clearLabel,onClick:$,onKeydown:[C[2]||=(0,a.withKeys)((0,a.withModifiers)(()=>{},[`stop`]),[`enter`]),C[3]||=(0,a.withKeys)((0,a.withModifiers)(()=>{},[`stop`]),[`space`])]},[(0,a.createVNode)(e.t,{name:(0,a.unref)(s.regular),size:16},null,8,[`name`])],40,d)):(0,a.createCommentVNode)(``,!0)]),_:3},8,[`wrap`]),S.error?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:2,variant:`error`,class:`nb-select__message`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.error),1)]),_:1})):S.warning?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:3,variant:`warning`,class:`nb-select__message`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.warning),1)]),_:1})):S.helper?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:4,variant:`helper`,class:`nb-select__message`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.helper),1)]),_:1})):(0,a.createCommentVNode)(``,!0)],64)):S.variant===`fluid`?((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:1},[(0,a.createVNode)(E,{wrap:S.clearable},{default:(0,a.withCtx)(()=>[(0,a.createElementVNode)(`button`,{id:L.value,ref_key:`triggerRef`,ref:N,type:`button`,class:`nb-select__trigger`,role:`combobox`,"aria-expanded":k.value,"aria-haspopup":`listbox`,"aria-disabled":S.disabled||void 0,"aria-required":S.required||void 0,disabled:S.disabled||void 0,onClick:J,onFocus:C[4]||=e=>A.value=!0,onBlur:C[5]||=e=>A.value=!1},[S.label||i.$slots.label?((0,a.openBlock)(),(0,a.createBlock)(r.t,{key:0,dir:`row`,align:`center`,gap:`xs`,class:`nb-select__inner-header`},{default:(0,a.withCtx)(()=>[i.$slots.label?(0,a.renderSlot)(i.$slots,`label`,{key:0}):((0,a.openBlock)(),(0,a.createElementBlock)(`label`,p,[(0,a.createTextVNode)((0,a.toDisplayString)(S.label)+` `,1),S.required?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,m,`*`)):(0,a.createCommentVNode)(``,!0)])),S.helper&&!S.error&&!S.warning?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:2,variant:`helper`,"icon-only":!0,class:`nb-select__inner-message`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.helper),1)]),_:1})):(0,a.createCommentVNode)(``,!0)]),_:3})):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(r.t,{dir:`row`,align:`end`,flex:``,class:`nb-select__value-row`},{default:(0,a.withCtx)(()=>[(0,a.createElementVNode)(`span`,{class:(0,a.normalizeClass)([`nb-select__value`,{"nb-select__value--placeholder":!B.value,"nb-select__value--with-icon":!!z.value}])},[z.value?((0,a.openBlock)(),(0,a.createBlock)(e.t,{key:0,class:`nb-select__value-icon`,name:z.value,size:16},null,8,[`name`])):(0,a.createCommentVNode)(``,!0),B.value?(0,a.renderSlot)(i.$slots,`value`,{key:1,values:R.value},()=>[(0,a.createTextVNode)((0,a.toDisplayString)(B.value),1)]):((0,a.openBlock)(),(0,a.createElementBlock)(a.Fragment,{key:2},[(0,a.createTextVNode)((0,a.toDisplayString)(S.placeholder),1)],64))],2),Q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,h)):(0,a.createCommentVNode)(``,!0),(0,a.createVNode)(r.t,{align:`center`,justify:`center`,class:`nb-select__caret`},{default:(0,a.withCtx)(()=>[(0,a.createVNode)(e.t,{name:k.value?(0,a.unref)(c.regular):(0,a.unref)(o.regular),size:16},null,8,[`name`])]),_:1})]),_:3})],40,f),Q.value?((0,a.openBlock)(),(0,a.createElementBlock)(`button`,{key:0,type:`button`,class:`nb-select__clear`,"aria-label":S.clearLabel,onClick:$,onKeydown:[C[6]||=(0,a.withKeys)((0,a.withModifiers)(()=>{},[`stop`]),[`enter`]),C[7]||=(0,a.withKeys)((0,a.withModifiers)(()=>{},[`stop`]),[`space`])]},[(0,a.createVNode)(e.t,{name:(0,a.unref)(s.regular),size:16},null,8,[`name`])],40,g)):(0,a.createCommentVNode)(``,!0)]),_:3},8,[`wrap`]),S.error?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:0,variant:`error`,class:`nb-select__fluid-message`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.error),1)]),_:1})):S.warning?((0,a.openBlock)(),(0,a.createBlock)(n.t,{key:1,variant:`warning`,class:`nb-select__fluid-message`},{default:(0,a.withCtx)(()=>[(0,a.createTextVNode)((0,a.toDisplayString)(S.warning),1)]),_:1})):(0,a.createCommentVNode)(``,!0)],64)):(0,a.createCommentVNode)(``,!0)],34),((0,a.openBlock)(),(0,a.createBlock)(a.Teleport,{to:`body`},[k.value?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,ref_key:`dropdownRef`,ref:P,class:`nb-select__dropdown`,style:(0,a.normalizeStyle)(F.value),role:`listbox`,"aria-multiselectable":S.multiple||void 0},[((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(H.value,t=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:t.key,class:`nb-select__group`,role:`group`,"aria-labelledby":t.name?t.labelId:void 0},[t.name?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:0,id:t.labelId,class:`nb-select__group-label`},(0,a.toDisplayString)(t.name),9,y)):(0,a.createCommentVNode)(``,!0),((0,a.openBlock)(!0),(0,a.createElementBlock)(a.Fragment,null,(0,a.renderList)(t.entries,t=>((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:t.option.value,class:(0,a.normalizeClass)([`nb-select__option`,{"nb-select__option--selected":V(t.option.value),"nb-select__option--highlighted":j.value===t.index,"nb-select__option--disabled":t.option.disabled}]),role:`option`,"aria-selected":V(t.option.value),"aria-disabled":t.option.disabled||void 0,onMouseenter:e=>j.value=t.index,onClick:e=>W(t.option)},[S.multiple?((0,a.openBlock)(),(0,a.createElementBlock)(`span`,x,[V(t.option.value)?((0,a.openBlock)(),(0,a.createElementBlock)(`svg`,ee,[...C[11]||=[(0,a.createElementVNode)(`path`,{d:`M1 4l3 3 5-6`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`},null,-1)]])):(0,a.createCommentVNode)(``,!0)])):(0,a.createCommentVNode)(``,!0),t.option.icon?((0,a.openBlock)(),(0,a.createBlock)(e.t,{key:1,class:`nb-select__option-icon`,name:t.option.icon,size:16},null,8,[`name`])):(0,a.createCommentVNode)(``,!0),(0,a.createElementVNode)(`span`,te,[(0,a.renderSlot)(i.$slots,`option`,{option:t.option},()=>[(0,a.createTextVNode)((0,a.toDisplayString)(t.option.label),1)])])],42,b))),128))],8,v))),128)),!S.options||S.options.length===0?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,ne,` No options `)):(0,a.createCommentVNode)(``,!0),S.creatable?((0,a.openBlock)(),(0,a.createElementBlock)(`div`,{key:1,class:`nb-select__create`,onMousedown:C[10]||=(0,a.withModifiers)(()=>{},[`prevent`])},[(0,a.withDirectives)((0,a.createElementVNode)(`input`,{"onUpdate:modelValue":C[8]||=e=>D.value=e,type:`text`,class:`nb-select__create-input`,placeholder:S.createPlaceholder||`Add new…`,onKeydown:[(0,a.withKeys)((0,a.withModifiers)(O,[`prevent`]),[`enter`]),C[9]||=(0,a.withModifiers)(()=>{},[`stop`])]},null,40,re),[[a.vModelText,D.value]])],32)):(0,a.createCommentVNode)(``,!0)],12,_)):(0,a.createCommentVNode)(``,!0)]))],64))}});Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return S}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./chunk-D-qHiVGv.cjs`);const e=require(`./_plugin-vue_export-helper-tagjRzOz.cjs`),t=require(`./Icon-C8R_r_In.cjs`),n=require(`./composables/useStableId.composable.cjs`),r=require(`./composables/usePhoneLayout.composable.cjs`),i=require(`./utils/slotContent.helper.cjs`),a=require(`./Badge-Dkm7PBJ8.cjs`);let o=require(`vue`);var s=function(e){return e.Line=`line`,e.Contained=`contained`,e}(s||{}),c=function(e){return e.Small=`sm`,e.Medium=`md`,e.Large=`lg`,e}(c||{}),l=[`aria-label`],u=[`id`,`data-tab-id`,`aria-selected`,`aria-controls`,`tabindex`,`disabled`,`onClick`],d={class:`nb-tabs__label`},f=[`id`,`aria-labelledby`],p=24,m=(0,o.defineComponent)({__name:`Tabs`,props:{items:{},ariaLabel:{default:void 0},modelValue:{default:void 0},variant:{default:s.Line},size:{default:c.Medium},disabled:{type:Boolean,default:!1},fullWidth:{type:Boolean,default:!1},id:{default:void 0}},emits:[`update:modelValue`,`change`],setup(e,{emit:s}){let m=e,h=s,g=(0,o.useSlots)(),_=n.useStableId(m),v=(0,o.ref)(null),y=(0,o.computed)(()=>m.items.filter(e=>!w(e))),b=(0,o.ref)(m.modelValue??y.value[0]?.id);(0,o.watch)(()=>m.modelValue,e=>{e!=null&&(b.value=e)});let x=(0,o.computed)(()=>{let e=m.modelValue??b.value,t=m.items.find(t=>t.id===e);return t&&!w(t)?t.id:y.value[0]?.id}),S=(0,o.computed)(()=>m.size===c.Large?18:16),C=(0,o.computed)(()=>[`nb-tabs`,`nb-tabs--${m.variant}`,`nb-tabs--${m.size}`,{"nb-tabs--full-width":m.fullWidth,"nb-tabs--disabled":m.disabled,"nb-tabs--overflow":P.value}]);function w(e){return m.disabled||!!e.disabled}function T(e){return`${_}-tab-${e}`}function E(e){return`${_}-panel-${e}`}function D(e){return i.hasSlotContent(g,e)}function O(e){w(e)||e.id===x.value||(b.value=e.id,h(`update:modelValue`,e.id),h(`change`,e.id,e))}function k(e){(v.value?.querySelectorAll(`[data-tab-id]`))?.forEach(t=>{t.dataset.tabId===e&&t.focus()})}function A(e){let t=y.value;if(!t.length)return;let n=t[(t.findIndex(e=>e.id===x.value)+e+t.length)%t.length];O(n),k(n.id)}function j(e){e&&(O(e),k(e.id))}let{phone:M}=r.usePhoneLayout(),N=(0,o.ref)(null),P=(0,o.ref)(!1),F=(0,o.computed)(()=>M.value||P.value);function I(){let e=N.value,t=v.value;!e||!t||(P.value=t.scrollWidth>e.clientWidth+1)}let L=(0,o.ref)(!1),R=(0,o.ref)(!1);function z(){let e=v.value;if(!F.value||!e)return;let t=e.scrollWidth-e.clientWidth;L.value=e.scrollLeft>1,R.value=e.scrollLeft<t-1}function B(){let e=v.value;if(!F.value||!e)return;let t=[...e.querySelectorAll(`[data-tab-id]`)].find(e=>e.dataset.tabId===x.value);if(t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.left-n.left+e.scrollLeft,a=i+r.width,o=t===e.firstElementChild,s=t===e.lastElementChild;i<e.scrollLeft+(o?0:p)?e.scrollLeft=Math.max(0,o?0:i-p):a>e.scrollLeft+e.clientWidth-(s?0:p)&&(e.scrollLeft=a-e.clientWidth+(s?0:p))}z()}(0,o.watch)([x,F],()=>(0,o.nextTick)(B));function V(){I(),B()}let H=null;function U(){!H||!N.value||!v.value||(H.disconnect(),H.observe(N.value),v.value.querySelectorAll(`[data-tab-id]`).forEach(e=>H?.observe(e)))}(0,o.watch)(()=>m.items,()=>(0,o.nextTick)(()=>{U(),V()}),{deep:!0}),(0,o.onMounted)(()=>{I(),B(),window.addEventListener(`resize`,V,{passive:!0}),typeof ResizeObserver<`u`&&(H=new ResizeObserver(V),U())}),(0,o.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,V),H?.disconnect(),H=null});function W(e){switch(e.key){case`ArrowRight`:A(1);break;case`ArrowLeft`:A(-1);break;case`Home`:j(y.value[0]);break;case`End`:j(y.value[y.value.length-1]);break;default:return}e.preventDefault()}return(n,r)=>((0,o.openBlock)(),(0,o.createElementBlock)(`div`,{ref_key:`rootRef`,ref:N,class:(0,o.normalizeClass)(C.value)},[(0,o.createElementVNode)(`div`,{ref_key:`listRef`,ref:v,class:(0,o.normalizeClass)([`nb-tabs__list`,{"nb-tabs__list--fade-start":F.value&&L.value,"nb-tabs__list--fade-end":F.value&&R.value}]),role:`tablist`,"aria-label":e.ariaLabel||void 0,onKeydown:W,onScrollPassive:z},[((0,o.openBlock)(!0),(0,o.createElementBlock)(o.Fragment,null,(0,o.renderList)(e.items,e=>((0,o.openBlock)(),(0,o.createElementBlock)(`button`,{id:T(e.id),key:e.id,"data-tab-id":e.id,type:`button`,role:`tab`,class:(0,o.normalizeClass)([`nb-tabs__tab`,{"nb-tabs__tab--active":e.id===x.value}]),"aria-selected":e.id===x.value,"aria-controls":D(e.id)?E(e.id):void 0,tabindex:e.id===x.value?0:-1,disabled:w(e),onClick:t=>O(e)},[e.icon?((0,o.openBlock)(),(0,o.createBlock)(t.t,{key:0,name:e.icon,size:S.value,class:`nb-tabs__icon`},null,8,[`name`,`size`])):(0,o.createCommentVNode)(``,!0),(0,o.createElementVNode)(`span`,d,(0,o.toDisplayString)(e.label),1),e.badge==null?(0,o.createCommentVNode)(``,!0):((0,o.openBlock)(),(0,o.createBlock)(a.t,{key:1,size:`sm`,class:`nb-tabs__badge`},{default:(0,o.withCtx)(()=>[(0,o.createTextVNode)((0,o.toDisplayString)(e.badge),1)]),_:2},1024))],10,u))),128))],42,l),((0,o.openBlock)(!0),(0,o.createElementBlock)(o.Fragment,null,(0,o.renderList)(e.items,e=>((0,o.openBlock)(),(0,o.createElementBlock)(o.Fragment,{key:`panel-${e.id}`},[e.id===x.value&&D(e.id)?((0,o.openBlock)(),(0,o.createElementBlock)(`div`,{key:0,id:E(e.id),class:`nb-tabs__panel`,role:`tabpanel`,"aria-labelledby":T(e.id),tabindex:`0`},[(0,o.renderSlot)(n.$slots,e.id,{item:e},void 0,!0)],8,f)):(0,o.createCommentVNode)(``,!0)],64))),128))],2))}}),h=e.t(m,[[`__scopeId`,`data-v-4367403c`]]);Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return h}});
|