@ac-design/design-system 2.7.0 → 2.8.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/lib/compat.css +49 -10
- package/dist/lib/components/AcCard.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/lib/components/AcCheckBox.vue_vue_type_script_setup_true_lang.js +46 -43
- package/dist/lib/components/AcCheckRadio.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/lib/components/AcColorInput.vue.d.ts +4 -0
- package/dist/lib/components/AcColorInput.vue_vue_type_script_setup_true_lang.js +12 -2
- package/dist/lib/components/AcDatePicker.vue.d.ts +3 -0
- package/dist/lib/components/AcDatePicker.vue_vue_type_script_setup_true_lang.js +12 -2
- package/dist/lib/components/AcHeader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/lib/components/AcInput.vue.d.ts +2 -0
- package/dist/lib/components/AcInput.vue_vue_type_script_setup_true_lang.js +18 -8
- package/dist/lib/components/AcModal.vue_vue_type_script_setup_true_lang.js +12 -8
- package/dist/lib/components/AcMonthPicker.vue.d.ts +3 -0
- package/dist/lib/components/AcMonthPicker.vue_vue_type_script_setup_true_lang.js +12 -2
- package/dist/lib/components/AcNumberInput.vue.d.ts +3 -0
- package/dist/lib/components/AcNumberInput.vue_vue_type_script_setup_true_lang.js +11 -1
- package/dist/lib/components/AcSelect.vue.d.ts +3 -0
- package/dist/lib/components/AcSelect.vue_vue_type_script_setup_true_lang.js +241 -218
- package/dist/lib/components/AcSidePanel.vue_vue_type_script_setup_true_lang.js +11 -7
- package/dist/lib/components/AcSidebar.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/lib/components/AcSteps.vue.d.ts +3 -0
- package/dist/lib/components/AcSteps.vue_vue_type_script_setup_true_lang.js +33 -29
- package/dist/lib/components/AcSwitch.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/lib/components/AcTable.vue_vue_type_script_setup_true_lang.js +83 -72
- package/dist/lib/components/AcTextarea.vue.d.ts +3 -0
- package/dist/lib/components/AcTextarea.vue_vue_type_script_setup_true_lang.js +11 -1
- package/dist/lib/components/AcTimePicker.vue.d.ts +3 -0
- package/dist/lib/components/AcTimePicker.vue_vue_type_script_setup_true_lang.js +12 -2
- package/dist/lib/components/AcToaster.vue.d.ts +3 -0
- package/dist/lib/components/AcToaster.vue_vue_type_script_setup_true_lang.js +71 -68
- package/dist/lib/theme.css +11 -0
- package/package.json +1 -1
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import e from "./AcSpinner.js";
|
|
2
2
|
import { fixedFrame as t } from "./fixedFrame.js";
|
|
3
|
-
import { Fragment as n, Teleport as r, Transition as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as
|
|
4
|
-
import { Check as
|
|
3
|
+
import { Fragment as n, Teleport as r, Transition as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, mergeModels as p, mergeProps as ee, nextTick as te, normalizeClass as m, normalizeStyle as ne, onBeforeUnmount as re, onMounted as ie, openBlock as h, ref as g, renderList as _, renderSlot as v, resolveDynamicComponent as ae, toDisplayString as y, unref as b, useAttrs as oe, useId as se, useModel as ce, useSlots as le, vModelText as ue, watch as x, withCtx as de, withDirectives as fe, withModifiers as S } from "vue";
|
|
4
|
+
import { Check as pe, ChevronDown as me, ChevronUp as he, Plus as ge, RefreshCw as _e, X as ve } from "@lucide/vue";
|
|
5
5
|
//#region src/lib/components/AcSelect.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var
|
|
7
|
-
key: 0,
|
|
8
|
-
class: "mb-2 flex items-center gap-1 text-base font-medium text-heading"
|
|
9
|
-
}, xe = {
|
|
6
|
+
var ye = {
|
|
10
7
|
key: 1,
|
|
11
8
|
class: "text-muted"
|
|
12
|
-
},
|
|
9
|
+
}, be = {
|
|
13
10
|
key: 2,
|
|
14
11
|
class: "text-danger",
|
|
15
12
|
"aria-hidden": "true"
|
|
16
|
-
},
|
|
13
|
+
}, xe = [
|
|
17
14
|
"id",
|
|
18
15
|
"tabindex",
|
|
19
16
|
"aria-expanded",
|
|
@@ -26,49 +23,59 @@ var be = {
|
|
|
26
23
|
"aria-required",
|
|
27
24
|
"aria-activedescendant",
|
|
28
25
|
"aria-busy"
|
|
29
|
-
],
|
|
26
|
+
], Se = { class: "flex min-w-0 flex-1 flex-wrap items-center gap-2" }, Ce = { class: "truncate" }, we = [
|
|
30
27
|
"aria-label",
|
|
31
28
|
"disabled",
|
|
32
29
|
"onClick"
|
|
33
|
-
],
|
|
30
|
+
], Te = {
|
|
34
31
|
key: 2,
|
|
35
32
|
class: "truncate"
|
|
36
|
-
},
|
|
33
|
+
}, Ee = {
|
|
37
34
|
key: 3,
|
|
38
35
|
class: "truncate text-muted"
|
|
39
|
-
},
|
|
36
|
+
}, De = { class: "flex shrink-0 items-center gap-1 text-muted" }, Oe = ["disabled"], ke = {
|
|
40
37
|
class: "inline-flex rounded-full p-1 transition-colors hover:bg-accent-hover hover:text-primary",
|
|
41
38
|
"aria-hidden": "true"
|
|
42
|
-
},
|
|
39
|
+
}, Ae = {
|
|
43
40
|
key: 0,
|
|
44
41
|
class: "border-b border-border p-3"
|
|
45
|
-
},
|
|
42
|
+
}, je = ["aria-activedescendant"], Me = ["aria-multiselectable", "aria-labelledby"], Ne = {
|
|
46
43
|
key: 0,
|
|
47
44
|
role: "presentation",
|
|
48
45
|
class: "px-4 pt-2 pb-1 text-sm font-semibold tracking-[0.08em] text-muted uppercase"
|
|
49
|
-
},
|
|
46
|
+
}, Pe = [
|
|
50
47
|
"id",
|
|
51
48
|
"aria-selected",
|
|
52
49
|
"aria-disabled",
|
|
53
50
|
"onMouseenter",
|
|
54
51
|
"onClick"
|
|
55
|
-
],
|
|
52
|
+
], Fe = { class: "min-w-0 flex-1" }, Ie = {
|
|
56
53
|
key: 0,
|
|
57
54
|
class: "block truncate text-xs font-normal text-muted"
|
|
58
|
-
},
|
|
55
|
+
}, Le = ["id"], Re = { class: "min-w-0 flex-1 truncate" }, ze = {
|
|
59
56
|
key: 1,
|
|
60
57
|
role: "presentation",
|
|
61
58
|
class: "px-4 py-3 text-center text-base text-muted"
|
|
62
|
-
},
|
|
59
|
+
}, Be = 320, Ve = /*@__PURE__*/ f({
|
|
63
60
|
inheritAttrs: !1,
|
|
64
61
|
__name: "AcSelect",
|
|
65
|
-
props: /*@__PURE__*/
|
|
62
|
+
props: /*@__PURE__*/ p({
|
|
66
63
|
options: {},
|
|
67
64
|
by: {
|
|
68
65
|
type: [String, Function],
|
|
69
66
|
default: void 0
|
|
70
67
|
},
|
|
71
68
|
label: { default: "" },
|
|
69
|
+
labelClass: {
|
|
70
|
+
type: [
|
|
71
|
+
Boolean,
|
|
72
|
+
null,
|
|
73
|
+
String,
|
|
74
|
+
Object,
|
|
75
|
+
Array
|
|
76
|
+
],
|
|
77
|
+
default: void 0
|
|
78
|
+
},
|
|
72
79
|
placeholder: { default: "Select…" },
|
|
73
80
|
multiple: {
|
|
74
81
|
type: Boolean,
|
|
@@ -152,7 +159,7 @@ var be = {
|
|
|
152
159
|
},
|
|
153
160
|
openModifiers: {}
|
|
154
161
|
}),
|
|
155
|
-
emits: /*@__PURE__*/
|
|
162
|
+
emits: /*@__PURE__*/ p([
|
|
156
163
|
"select",
|
|
157
164
|
"create",
|
|
158
165
|
"remove",
|
|
@@ -160,8 +167,8 @@ var be = {
|
|
|
160
167
|
"refresh",
|
|
161
168
|
"change"
|
|
162
169
|
], ["update:modelValue", "update:open"]),
|
|
163
|
-
setup(
|
|
164
|
-
let
|
|
170
|
+
setup(f, { expose: p, emit: Ve }) {
|
|
171
|
+
let C = f, w = Ve, T = le(), E = ce(f, "modelValue"), D = (e) => E.value = e, O = ce(f, "open"), He = {
|
|
165
172
|
xs: {
|
|
166
173
|
field: "min-h-[26px] pr-1 pl-2 text-xs",
|
|
167
174
|
chips: ["py-0", "py-1"],
|
|
@@ -197,50 +204,51 @@ var be = {
|
|
|
197
204
|
chips: ["py-1.5", "py-3"],
|
|
198
205
|
custom: "py-3"
|
|
199
206
|
}
|
|
200
|
-
},
|
|
201
|
-
class:
|
|
202
|
-
style:
|
|
203
|
-
})),
|
|
204
|
-
let { class: e, style: t, ...n } =
|
|
207
|
+
}, k = se(), A = oe(), Ue = a(() => ({
|
|
208
|
+
class: A.class,
|
|
209
|
+
style: A.style
|
|
210
|
+
})), We = a(() => {
|
|
211
|
+
let { class: e, style: t, ...n } = A;
|
|
205
212
|
return n;
|
|
206
|
-
}),
|
|
213
|
+
}), Ge = `${k}-list`, j = `${k}-label`, Ke = `${k}-hint`, qe = `${k}-msg`, Je = g(null), M = g(null), N = g(null), Ye = g(null), P = g(""), F = g(-1), I = g({
|
|
207
214
|
left: 0,
|
|
208
|
-
|
|
215
|
+
minWidth: 0,
|
|
216
|
+
maxWidth: 320,
|
|
209
217
|
maxHeight: 288
|
|
210
|
-
}),
|
|
211
|
-
let e =
|
|
212
|
-
if (e == null || e === "") return [];
|
|
218
|
+
}), L = a(() => {
|
|
219
|
+
let e = E.value;
|
|
220
|
+
if (e == null || e === "" && (C.multiple || !C.options.some((t) => R(t.value, e)))) return [];
|
|
213
221
|
let t = Array.isArray(e) ? e : [e];
|
|
214
|
-
return
|
|
215
|
-
}),
|
|
216
|
-
let n =
|
|
222
|
+
return C.hideUnknownValues ? t.filter((e) => C.options.some((t) => R(t.value, e))) : t;
|
|
223
|
+
}), R = (e, t) => {
|
|
224
|
+
let n = C.by;
|
|
217
225
|
return typeof n == "function" ? n(e, t) : n && e && t && typeof e == "object" && typeof t == "object" ? e[n] === t[n] : e === t;
|
|
218
|
-
},
|
|
219
|
-
let t =
|
|
226
|
+
}, z = (e) => {
|
|
227
|
+
let t = C.by;
|
|
220
228
|
return String(typeof t == "string" && e && typeof e == "object" ? e[t] : e);
|
|
221
|
-
},
|
|
222
|
-
let n =
|
|
229
|
+
}, Xe = (e, t) => {
|
|
230
|
+
let n = C.by;
|
|
223
231
|
return e && typeof e == "object" ? typeof n == "string" ? String(e[n]) : `i${t}` : String(e);
|
|
224
|
-
},
|
|
232
|
+
}, B = (e) => L.value.some((t) => R(t, e.value)), V = a(() => L.value.map((e) => C.options.find((t) => R(t.value, e)) ?? {
|
|
225
233
|
value: e,
|
|
226
|
-
label:
|
|
227
|
-
})),
|
|
228
|
-
function
|
|
229
|
-
|
|
234
|
+
label: z(e)
|
|
235
|
+
})), H = a(() => L.value.length > 0), Ze = a(() => H.value && (C.multiple || C.emptyValue === null || !R(L.value[0], C.emptyValue))), U = g(""), W = a(() => U.value || C.errorMsg);
|
|
236
|
+
function Qe() {
|
|
237
|
+
C.validateRequired && C.required && !H.value ? U.value = `This field is required. Please select ${C.multiple ? "at least one option" : "an option"}.` : U.value = "";
|
|
230
238
|
}
|
|
231
|
-
let
|
|
239
|
+
let $e = (e) => {
|
|
232
240
|
if (!e.some((e) => e.group)) return e;
|
|
233
241
|
let t = [];
|
|
234
242
|
return e.forEach((e) => {
|
|
235
243
|
let n = e.group ?? "";
|
|
236
244
|
t.includes(n) || t.push(n);
|
|
237
245
|
}), [...e].sort((e, n) => t.indexOf(e.group ?? "") - t.indexOf(n.group ?? ""));
|
|
238
|
-
},
|
|
239
|
-
let e =
|
|
240
|
-
return
|
|
241
|
-
}),
|
|
246
|
+
}, G = a(() => {
|
|
247
|
+
let e = P.value.trim().toLowerCase();
|
|
248
|
+
return $e(e ? C.options.filter((t) => t.label.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e) || t.group?.toLowerCase().includes(e)) : C.options);
|
|
249
|
+
}), et = a(() => {
|
|
242
250
|
let e = [];
|
|
243
|
-
return
|
|
251
|
+
return G.value.forEach((t, n) => {
|
|
244
252
|
let r = t.group ?? "", i = e.find((e) => e.name === r);
|
|
245
253
|
i || e.push(i = {
|
|
246
254
|
name: r,
|
|
@@ -250,297 +258,312 @@ var be = {
|
|
|
250
258
|
index: n
|
|
251
259
|
});
|
|
252
260
|
}), e;
|
|
253
|
-
}),
|
|
254
|
-
let e =
|
|
255
|
-
if (!
|
|
256
|
-
let t =
|
|
261
|
+
}), K = (e) => `${k}-opt-${e}`, q = a(() => P.value.trim()), J = a(() => {
|
|
262
|
+
let e = q.value.toLowerCase();
|
|
263
|
+
if (!C.creatable || !C.searchable || !e) return !1;
|
|
264
|
+
let t = C.options.some((t) => t.label.toLowerCase() === e || z(t.value).toLowerCase() === e), n = L.value.some((t) => z(t).toLowerCase() === e);
|
|
257
265
|
return !t && !n;
|
|
258
|
-
}),
|
|
259
|
-
let e =
|
|
266
|
+
}), Y = a(() => G.value.length + +!!J.value - 1), tt = a(() => G.value.length), nt = () => {
|
|
267
|
+
let e = M.value;
|
|
260
268
|
if (!e) return;
|
|
261
|
-
let n = e.getBoundingClientRect(), r = t(), i = r.bottom - n.bottom - 4 - 8, a = n.top - r.top - 4 - 8, [o, s] =
|
|
262
|
-
|
|
269
|
+
let n = e.getBoundingClientRect(), r = t(), i = r.bottom - n.bottom - 4 - 8, a = n.top - r.top - 4 - 8, [o, s] = C.placement === "top" ? [a, i] : [i, a], c = o < 180 && s > o, l = C.placement === "top" ? !c : c, u = Math.max(n.width, Math.min(Be, r.width - 16)), d = Math.min(Math.max(N.value?.offsetWidth ?? n.width, n.width), u), f = n.left - r.left, p = {
|
|
270
|
+
left: f + d > r.width - 8 ? Math.max(8, n.right - r.left - d) : f,
|
|
271
|
+
minWidth: n.width,
|
|
272
|
+
maxWidth: u
|
|
273
|
+
};
|
|
274
|
+
I.value = l ? {
|
|
275
|
+
...p,
|
|
263
276
|
bottom: r.bottom - n.top + 4,
|
|
264
|
-
left: n.left - r.left,
|
|
265
|
-
width: n.width,
|
|
266
277
|
maxHeight: Math.min(288, a)
|
|
267
278
|
} : {
|
|
279
|
+
...p,
|
|
268
280
|
top: n.bottom + 4 - r.top,
|
|
269
|
-
left: n.left - r.left,
|
|
270
|
-
width: n.width,
|
|
271
281
|
maxHeight: Math.min(288, i)
|
|
272
282
|
};
|
|
273
283
|
}, X = (e = 0, t = 1) => {
|
|
274
|
-
for (let n = e; n >= 0 && n <=
|
|
284
|
+
for (let n = e; n >= 0 && n <= Y.value; n += t) if (!G.value[n]?.disabled) return n;
|
|
275
285
|
return -1;
|
|
276
286
|
}, rt = () => {
|
|
277
|
-
|
|
287
|
+
C.disabled || C.loading || C.readonly || O.value || (O.value = !0);
|
|
278
288
|
}, it = async () => {
|
|
279
|
-
|
|
280
|
-
let e =
|
|
281
|
-
|
|
289
|
+
P.value = "", nt();
|
|
290
|
+
let e = G.value.findIndex((e) => B(e));
|
|
291
|
+
F.value = e >= 0 ? e : X(), document.addEventListener("pointerdown", mt, !0), window.addEventListener("scroll", $, !0), window.addEventListener("resize", $), await te(), nt(), C.searchable && Ye.value?.focus(), Q();
|
|
282
292
|
}, Z = (e = !0) => {
|
|
283
|
-
|
|
284
|
-
}, at = () =>
|
|
293
|
+
O.value && (O.value = !1, F.value = -1, e && M.value?.focus());
|
|
294
|
+
}, at = () => O.value ? Z() : rt(), ot = (e) => {
|
|
285
295
|
if (!e.disabled) {
|
|
286
|
-
if (
|
|
287
|
-
let t = [...
|
|
288
|
-
n >= 0 ? (t.splice(n, 1),
|
|
289
|
-
} else
|
|
296
|
+
if (C.multiple) {
|
|
297
|
+
let t = [...L.value], n = t.findIndex((t) => R(t, e.value));
|
|
298
|
+
n >= 0 ? (t.splice(n, 1), w("remove", e)) : (t.push(e.value), w("select", e)), D(t);
|
|
299
|
+
} else D(e.value), w("select", e), Z();
|
|
290
300
|
}
|
|
291
301
|
}, st = (e) => {
|
|
292
|
-
|
|
302
|
+
D(C.multiple ? L.value.filter((t) => !R(t, e.value)) : C.emptyValue), w("remove", e);
|
|
293
303
|
}, ct = () => {
|
|
294
|
-
let e =
|
|
295
|
-
if (!
|
|
304
|
+
let e = q.value;
|
|
305
|
+
if (!J.value || !e) return;
|
|
296
306
|
let t = e, n = {
|
|
297
307
|
value: t,
|
|
298
308
|
label: e
|
|
299
309
|
};
|
|
300
|
-
|
|
310
|
+
C.multiple ? (D([...L.value, t]), P.value = "") : (D(t), Z()), w("select", n), w("create", e);
|
|
301
311
|
}, lt = () => {
|
|
302
|
-
|
|
303
|
-
}, ut = "", dt, Q = () =>
|
|
304
|
-
let t =
|
|
312
|
+
V.value.forEach((e) => w("remove", e)), D(C.multiple ? [] : C.emptyValue), M.value?.focus();
|
|
313
|
+
}, ut = "", dt, Q = () => te(() => N.value?.querySelector(`#${CSS.escape(K(F.value))}`)?.scrollIntoView({ block: "nearest" })), ft = (e) => {
|
|
314
|
+
let t = Y.value + 1;
|
|
305
315
|
if (!t) return;
|
|
306
|
-
let n =
|
|
307
|
-
for (let r = 0; r < t && (n = (n + e + t) % t,
|
|
308
|
-
|
|
316
|
+
let n = F.value;
|
|
317
|
+
for (let r = 0; r < t && (n = (n + e + t) % t, G.value[n]?.disabled); r++);
|
|
318
|
+
F.value = n, Q();
|
|
309
319
|
}, pt = (e) => {
|
|
310
|
-
if (
|
|
320
|
+
if (C.disabled || C.readonly) return;
|
|
311
321
|
let t = e.key;
|
|
312
|
-
if (!
|
|
322
|
+
if (!O.value) {
|
|
313
323
|
[
|
|
314
324
|
"Enter",
|
|
315
325
|
" ",
|
|
316
326
|
"ArrowDown",
|
|
317
327
|
"ArrowUp"
|
|
318
|
-
].includes(t) ? (e.preventDefault(), rt()) : t === "Backspace" &&
|
|
328
|
+
].includes(t) ? (e.preventDefault(), rt()) : t === "Backspace" && C.multiple && H.value && e.target === M.value && st(V.value[V.value.length - 1]);
|
|
319
329
|
return;
|
|
320
330
|
}
|
|
321
331
|
if (t === "ArrowDown") e.preventDefault(), ft(1);
|
|
322
332
|
else if (t === "ArrowUp") e.preventDefault(), ft(-1);
|
|
323
|
-
else if (t === "Home") e.preventDefault(),
|
|
324
|
-
else if (t === "End") e.preventDefault(),
|
|
325
|
-
else if (t === "Enter" || t === " " && !
|
|
333
|
+
else if (t === "Home") e.preventDefault(), F.value = X(), Q();
|
|
334
|
+
else if (t === "End") e.preventDefault(), F.value = X(Y.value, -1), Q();
|
|
335
|
+
else if (t === "Enter" || t === " " && !C.searchable) {
|
|
326
336
|
e.preventDefault();
|
|
327
|
-
let t =
|
|
328
|
-
t ? ot(t) :
|
|
337
|
+
let t = G.value[F.value];
|
|
338
|
+
t ? ot(t) : J.value && ct();
|
|
329
339
|
} else if (t === "Escape") e.preventDefault(), Z();
|
|
330
340
|
else if (t === "Tab") Z(!1);
|
|
331
|
-
else if (!
|
|
341
|
+
else if (!C.searchable && t.length === 1 && !e.metaKey && !e.ctrlKey) {
|
|
332
342
|
ut += t.toLowerCase(), clearTimeout(dt), dt = setTimeout(() => ut = "", 500);
|
|
333
|
-
let e =
|
|
334
|
-
e >= 0 && (
|
|
343
|
+
let e = G.value.findIndex((e) => !e.disabled && e.label.toLowerCase().startsWith(ut));
|
|
344
|
+
e >= 0 && (F.value = e, Q());
|
|
335
345
|
}
|
|
336
346
|
}, mt = (e) => {
|
|
337
347
|
let t = e.target;
|
|
338
|
-
|
|
348
|
+
Je.value?.contains(t) || N.value?.contains(t) || Z(!1);
|
|
339
349
|
}, $ = (e) => {
|
|
340
|
-
e?.target instanceof Node &&
|
|
350
|
+
e?.target instanceof Node && N.value?.contains(e.target) || nt();
|
|
341
351
|
}, ht = () => {
|
|
342
352
|
document.removeEventListener("pointerdown", mt, !0), window.removeEventListener("scroll", $, !0), window.removeEventListener("resize", $);
|
|
343
353
|
};
|
|
344
|
-
|
|
354
|
+
x(O, (e) => {
|
|
345
355
|
if (e) return it();
|
|
346
|
-
|
|
347
|
-
}),
|
|
348
|
-
|
|
349
|
-
}),
|
|
350
|
-
|
|
351
|
-
}),
|
|
352
|
-
|
|
353
|
-
}),
|
|
354
|
-
let gt =
|
|
355
|
-
return
|
|
356
|
+
F.value = -1, ht(), Qe();
|
|
357
|
+
}), x(() => E.value, (e) => {
|
|
358
|
+
Qe(), w("change", e);
|
|
359
|
+
}), x(P, (e) => {
|
|
360
|
+
w("search", e), F.value = X();
|
|
361
|
+
}), ie(() => {
|
|
362
|
+
C.initEmptyArray && C.multiple && !E.value && D([]), O.value && it();
|
|
363
|
+
}), re(ht);
|
|
364
|
+
let gt = g(!1), _t = a(() => O.value || gt.value), vt = a(() => [C.hint && Ke, W.value && qe].filter(Boolean).join(" ") || void 0), yt = a(() => !C.multiple && V.value[0]?.label || ""), bt = a(() => !C.multiple && (T.selected || T.content) && V.value[0] || null), xt = a(() => !!(C.label || C.readonly || T["label-icon"] || T["label-extra"])), St = a(() => He[C.size] ?? He.normal), Ct = a(() => C.readonly ? "bg-surface-muted" : C.variant === "soft" ? "bg-accent" : C.variant === "ghost" ? "bg-transparent" : "bg-background"), wt = a(() => C.variant !== "outline");
|
|
365
|
+
return p({ focus: () => M.value?.focus() }), (t, a) => (h(), c("div", ee({
|
|
356
366
|
ref_key: "root",
|
|
357
|
-
ref:
|
|
358
|
-
},
|
|
359
|
-
class: ["w-full",
|
|
367
|
+
ref: Je
|
|
368
|
+
}, Ue.value, {
|
|
369
|
+
class: ["[:where(&)]:w-full", f.disabled && "opacity-50"],
|
|
360
370
|
"data-ac-ds": "",
|
|
361
371
|
"data-testid": "ac-select"
|
|
362
372
|
}), [
|
|
363
|
-
xt.value ? (
|
|
364
|
-
|
|
365
|
-
|
|
373
|
+
xt.value ? (h(), c("div", {
|
|
374
|
+
key: 0,
|
|
375
|
+
class: m(["mb-2 flex items-center gap-1 text-base font-medium text-heading", f.labelClass])
|
|
376
|
+
}, [
|
|
377
|
+
v(t.$slots, "label-icon"),
|
|
378
|
+
f.label ? (h(), c("label", {
|
|
366
379
|
key: 0,
|
|
367
|
-
id:
|
|
368
|
-
onClick: a[0] ||= (e) =>
|
|
369
|
-
},
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
])) : s("", !0),
|
|
374
|
-
|
|
380
|
+
id: j,
|
|
381
|
+
onClick: a[0] ||= (e) => M.value?.focus()
|
|
382
|
+
}, y(f.label), 1)) : s("", !0),
|
|
383
|
+
f.readonly ? (h(), c("span", ye, "(read only)")) : s("", !0),
|
|
384
|
+
v(t.$slots, "label-extra"),
|
|
385
|
+
f.required ? (h(), c("span", be, "*")) : s("", !0)
|
|
386
|
+
], 2)) : s("", !0),
|
|
387
|
+
f.hint ? (h(), c("p", {
|
|
375
388
|
key: 1,
|
|
376
|
-
id:
|
|
389
|
+
id: Ke,
|
|
377
390
|
class: "mb-2 text-base text-muted"
|
|
378
|
-
},
|
|
379
|
-
l("div",
|
|
380
|
-
id: `${
|
|
391
|
+
}, y(f.hint), 1)) : s("", !0),
|
|
392
|
+
l("div", ee({
|
|
393
|
+
id: `${b(k)}-trigger`,
|
|
381
394
|
ref_key: "trigger",
|
|
382
|
-
ref:
|
|
383
|
-
},
|
|
395
|
+
ref: M
|
|
396
|
+
}, We.value, {
|
|
384
397
|
role: "combobox",
|
|
385
|
-
tabindex:
|
|
398
|
+
tabindex: f.disabled ? -1 : 0,
|
|
386
399
|
"aria-haspopup": "listbox",
|
|
387
|
-
"aria-expanded":
|
|
388
|
-
"aria-controls":
|
|
389
|
-
"aria-labelledby":
|
|
390
|
-
"aria-label":
|
|
400
|
+
"aria-expanded": O.value,
|
|
401
|
+
"aria-controls": Ge,
|
|
402
|
+
"aria-labelledby": f.label ? j : void 0,
|
|
403
|
+
"aria-label": f.label ? void 0 : b(A)["aria-label"] ?? f.placeholder,
|
|
391
404
|
"aria-describedby": vt.value,
|
|
392
|
-
"aria-disabled":
|
|
393
|
-
"aria-invalid": !!
|
|
394
|
-
"aria-readonly":
|
|
395
|
-
"aria-required":
|
|
396
|
-
"aria-activedescendant":
|
|
397
|
-
"aria-busy":
|
|
405
|
+
"aria-disabled": f.disabled || void 0,
|
|
406
|
+
"aria-invalid": !!W.value || void 0,
|
|
407
|
+
"aria-readonly": f.readonly || void 0,
|
|
408
|
+
"aria-required": f.required || void 0,
|
|
409
|
+
"aria-activedescendant": O.value && !f.searchable && F.value >= 0 ? K(F.value) : void 0,
|
|
410
|
+
"aria-busy": f.refreshing || void 0,
|
|
398
411
|
class: ["group flex w-full items-center gap-2 rounded-10 border text-left font-medium text-heading transition-[color,background-color,border-color,box-shadow] duration-200 outline-none", [
|
|
399
412
|
St.value.field,
|
|
400
413
|
Ct.value,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
414
|
+
f.multiple && H.value && St.value.chips[+!!f.looseChips],
|
|
415
|
+
f.disabled || f.loading || f.readonly ? "cursor-not-allowed" : "cursor-pointer",
|
|
416
|
+
f.highlight && "ring-2 ring-primary/20 ring-offset-2 ring-offset-surface",
|
|
417
|
+
W.value ? ["border-danger/50", _t.value && "border-danger shadow-[0_0_0_2px_color-mix(in_srgb,var(--color-danger)_20%,transparent)]"] : wt.value ? [
|
|
405
418
|
"border-transparent",
|
|
406
419
|
_t.value && "shadow-[0_0_0_2px_color-mix(in_srgb,var(--color-primary)_20%,transparent)]",
|
|
407
|
-
|
|
408
|
-
] : _t.value ? "focus-ring" : ["border-border", !
|
|
420
|
+
f.variant === "soft" && !f.disabled && "hover:bg-accent-hover"
|
|
421
|
+
] : _t.value ? "focus-ring" : ["border-border", !f.disabled && !f.readonly && "hover:border-accent-active"]
|
|
409
422
|
]],
|
|
410
423
|
onClick: at,
|
|
411
424
|
onKeydown: pt,
|
|
412
425
|
onFocus: a[2] ||= (e) => gt.value = !0,
|
|
413
426
|
onBlur: a[3] ||= (e) => gt.value = !1
|
|
414
|
-
}), [l("div",
|
|
415
|
-
key:
|
|
427
|
+
}), [l("div", Se, [f.multiple && H.value ? (h(!0), c(n, { key: 0 }, _(V.value, (e, t) => (h(), c("span", {
|
|
428
|
+
key: Xe(e.value, t),
|
|
416
429
|
class: "inline-flex max-w-full items-center gap-2 rounded-10 bg-accent px-2 text-xs text-heading"
|
|
417
|
-
}, [l("span",
|
|
430
|
+
}, [l("span", Ce, y(e.label), 1), l("button", {
|
|
418
431
|
type: "button",
|
|
419
432
|
class: "inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full p-1 transition-colors hover:bg-accent-hover hover:text-primary focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
420
433
|
"aria-label": `Remove ${e.label}`,
|
|
421
|
-
disabled:
|
|
422
|
-
onClick:
|
|
423
|
-
}, [
|
|
434
|
+
disabled: f.disabled,
|
|
435
|
+
onClick: S((t) => st(e), ["stop"])
|
|
436
|
+
}, [d(b(ve), {
|
|
424
437
|
class: "size-4",
|
|
425
438
|
"aria-hidden": "true"
|
|
426
|
-
})], 8,
|
|
439
|
+
})], 8, we)]))), 128)) : bt.value ? (h(), c("span", {
|
|
427
440
|
key: 1,
|
|
428
|
-
class:
|
|
429
|
-
}, [
|
|
430
|
-
|
|
441
|
+
class: m(["min-w-0 flex-1", St.value.custom])
|
|
442
|
+
}, [v(t.$slots, "selected", { option: bt.value }, () => [v(t.$slots, "content", { option: bt.value })])], 2)) : yt.value ? (h(), c("span", Te, y(yt.value), 1)) : (h(), c("span", Ee, y(f.placeholder), 1))]), l("span", De, [
|
|
443
|
+
f.loading ? (h(), o(e, {
|
|
431
444
|
key: 0,
|
|
432
445
|
class: "text-primary"
|
|
433
|
-
})) :
|
|
446
|
+
})) : f.refreshable && !(f.disabled && f.hideRefreshWhenDisabled) ? (h(), c("button", {
|
|
434
447
|
key: 1,
|
|
435
448
|
type: "button",
|
|
436
449
|
class: "inline-flex size-6 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-accent-hover hover:text-primary focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
437
450
|
"aria-label": "Refresh options",
|
|
438
|
-
disabled:
|
|
439
|
-
onClick: a[1] ||=
|
|
440
|
-
}, [
|
|
441
|
-
class:
|
|
451
|
+
disabled: f.disabled,
|
|
452
|
+
onClick: a[1] ||= S((e) => w("refresh"), ["stop"])
|
|
453
|
+
}, [d(b(_e), {
|
|
454
|
+
class: m(["size-4", f.refreshing && "motion-safe:animate-spin"]),
|
|
442
455
|
"aria-hidden": "true"
|
|
443
|
-
}, null, 8, ["class"])], 8,
|
|
444
|
-
|
|
456
|
+
}, null, 8, ["class"])], 8, Oe)) : s("", !0),
|
|
457
|
+
f.clearable && Ze.value && !f.disabled && !f.loading && !f.readonly ? (h(), c("button", {
|
|
445
458
|
key: 2,
|
|
446
459
|
type: "button",
|
|
447
460
|
class: "inline-flex size-6 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-accent-hover hover:text-primary focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
448
461
|
"aria-label": "Clear selection",
|
|
449
|
-
onClick:
|
|
450
|
-
}, [
|
|
462
|
+
onClick: S(lt, ["stop"])
|
|
463
|
+
}, [d(b(ve), {
|
|
451
464
|
class: "size-4",
|
|
452
465
|
"aria-hidden": "true"
|
|
453
466
|
})])) : s("", !0),
|
|
454
|
-
l("span",
|
|
455
|
-
])], 16,
|
|
456
|
-
|
|
467
|
+
l("span", ke, [(h(), o(ae(O.value ? b(he) : b(me)), { class: "size-4" }))])
|
|
468
|
+
])], 16, xe),
|
|
469
|
+
W.value ? (h(), c("p", {
|
|
457
470
|
key: 2,
|
|
458
|
-
id:
|
|
471
|
+
id: qe,
|
|
459
472
|
class: "mt-1 text-base text-danger-strong",
|
|
460
473
|
role: "alert"
|
|
461
|
-
},
|
|
462
|
-
(
|
|
474
|
+
}, y(W.value), 1)) : s("", !0),
|
|
475
|
+
(h(), o(r, { to: "body" }, [d(i, {
|
|
463
476
|
"enter-active-class": "transition-opacity duration-100 ease-out motion-reduce:transition-none",
|
|
464
477
|
"enter-from-class": "opacity-0",
|
|
465
478
|
"leave-active-class": "transition-opacity duration-75 ease-in motion-reduce:transition-none",
|
|
466
479
|
"leave-to-class": "opacity-0"
|
|
467
480
|
}, {
|
|
468
|
-
default:
|
|
481
|
+
default: de(() => [O.value ? (h(), c("div", {
|
|
469
482
|
key: 0,
|
|
470
483
|
ref_key: "panel",
|
|
471
|
-
ref:
|
|
472
|
-
class: "fixed z-[90] flex flex-col overflow-hidden rounded-10 border border-border bg-background shadow-lg",
|
|
473
|
-
style:
|
|
474
|
-
top:
|
|
475
|
-
bottom:
|
|
476
|
-
left: `${
|
|
477
|
-
|
|
478
|
-
|
|
484
|
+
ref: N,
|
|
485
|
+
class: "fixed z-[90] flex w-max flex-col overflow-hidden rounded-10 border border-border bg-background shadow-lg",
|
|
486
|
+
style: ne({
|
|
487
|
+
top: I.value.top === void 0 ? void 0 : `${I.value.top}px`,
|
|
488
|
+
bottom: I.value.bottom === void 0 ? void 0 : `${I.value.bottom}px`,
|
|
489
|
+
left: `${I.value.left}px`,
|
|
490
|
+
minWidth: `${I.value.minWidth}px`,
|
|
491
|
+
maxWidth: `${I.value.maxWidth}px`,
|
|
492
|
+
maxHeight: `${I.value.maxHeight}px`
|
|
479
493
|
}),
|
|
480
494
|
"data-ac-ds": "",
|
|
481
495
|
"data-testid": "ac-select-panel"
|
|
482
|
-
}, [
|
|
496
|
+
}, [f.searchable ? (h(), c("div", Ae, [fe(l("input", {
|
|
483
497
|
ref_key: "searchInput",
|
|
484
|
-
ref:
|
|
485
|
-
"onUpdate:modelValue": a[4] ||= (e) =>
|
|
498
|
+
ref: Ye,
|
|
499
|
+
"onUpdate:modelValue": a[4] ||= (e) => P.value = e,
|
|
486
500
|
type: "text",
|
|
487
501
|
placeholder: "Search…",
|
|
488
502
|
"aria-label": "Search options",
|
|
489
|
-
"aria-controls":
|
|
490
|
-
"aria-activedescendant":
|
|
503
|
+
"aria-controls": Ge,
|
|
504
|
+
"aria-activedescendant": F.value >= 0 ? K(F.value) : void 0,
|
|
491
505
|
class: "h-9.5 w-full rounded-10 border border-border bg-background px-3 text-base text-heading transition-[border-color,box-shadow] duration-200 outline-none placeholder:text-muted/80 hover:border-accent-active focus:focus-ring",
|
|
492
506
|
onKeydown: pt
|
|
493
|
-
}, null, 40,
|
|
494
|
-
id:
|
|
507
|
+
}, null, 40, je), [[ue, P.value]])])) : s("", !0), l("ul", {
|
|
508
|
+
id: Ge,
|
|
495
509
|
role: "listbox",
|
|
496
|
-
"aria-multiselectable":
|
|
497
|
-
"aria-labelledby":
|
|
510
|
+
"aria-multiselectable": f.multiple || void 0,
|
|
511
|
+
"aria-labelledby": f.label ? j : void 0,
|
|
498
512
|
class: "ac-scrollbar max-h-60 min-h-0 flex-1 p-1"
|
|
499
513
|
}, [
|
|
500
|
-
(
|
|
501
|
-
id:
|
|
502
|
-
key:
|
|
514
|
+
(h(!0), c(n, null, _(et.value, (e) => (h(), c(n, { key: e.name }, [e.name ? (h(), c("li", Ne, y(e.name), 1)) : s("", !0), (h(!0), c(n, null, _(e.items, ({ option: e, index: n }) => (h(), c("li", {
|
|
515
|
+
id: K(n),
|
|
516
|
+
key: Xe(e.value, n),
|
|
503
517
|
role: "option",
|
|
504
|
-
"aria-selected":
|
|
518
|
+
"aria-selected": B(e),
|
|
505
519
|
"aria-disabled": e.disabled || void 0,
|
|
506
|
-
class:
|
|
507
|
-
onMouseenter: (t) => !e.disabled && (
|
|
508
|
-
onMousedown: a[5] ||=
|
|
520
|
+
class: m(["flex cursor-pointer items-start gap-2.5 rounded-6 px-4 py-2 text-base text-heading transition-colors", [e.disabled && "cursor-not-allowed opacity-50", n === F.value ? "bg-accent-hover" : B(e) && "bg-accent"]]),
|
|
521
|
+
onMouseenter: (t) => !e.disabled && (F.value = n),
|
|
522
|
+
onMousedown: a[5] ||= S(() => {}, ["prevent"]),
|
|
509
523
|
onClick: (t) => ot(e)
|
|
510
|
-
}, [
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
524
|
+
}, [
|
|
525
|
+
f.multiple ? (h(), c("span", {
|
|
526
|
+
key: 0,
|
|
527
|
+
class: m(["mt-0.5 inline-flex size-4 shrink-0 items-center justify-center rounded-4 border transition-colors", B(e) ? "border-primary bg-primary text-white" : "border-muted/70 bg-surface"]),
|
|
528
|
+
"aria-hidden": "true"
|
|
529
|
+
}, [B(e) ? (h(), o(b(pe), {
|
|
530
|
+
key: 0,
|
|
531
|
+
class: "size-3",
|
|
532
|
+
"stroke-width": 3,
|
|
533
|
+
"aria-hidden": "true"
|
|
534
|
+
})) : s("", !0)], 2)) : s("", !0),
|
|
535
|
+
l("span", Fe, [v(t.$slots, "option", {
|
|
536
|
+
option: e,
|
|
537
|
+
selected: B(e),
|
|
538
|
+
active: n === F.value
|
|
539
|
+
}, () => [v(t.$slots, "content", { option: e }, () => [l("span", { class: m(["block truncate", !f.multiple && B(e) && "font-medium text-primary-strong"]) }, y(e.label), 3), e.description ? (h(), c("span", Ie, y(e.description), 1)) : s("", !0)])])]),
|
|
540
|
+
!f.multiple && !t.$slots.option && B(e) ? (h(), o(b(pe), {
|
|
541
|
+
key: 1,
|
|
542
|
+
class: "mt-0.5 size-4 shrink-0 text-primary",
|
|
543
|
+
"aria-hidden": "true",
|
|
544
|
+
"data-testid": "ac-select-check"
|
|
545
|
+
})) : s("", !0)
|
|
546
|
+
], 42, Pe))), 128))], 64))), 128)),
|
|
547
|
+
J.value ? (h(), c("li", {
|
|
525
548
|
key: 0,
|
|
526
|
-
id:
|
|
549
|
+
id: K(tt.value),
|
|
527
550
|
role: "option",
|
|
528
551
|
"aria-selected": "false",
|
|
529
|
-
class:
|
|
552
|
+
class: m(["flex cursor-pointer items-center gap-2.5 rounded-6 px-4 py-2 text-base text-heading transition-colors", tt.value === F.value && "bg-accent-hover"]),
|
|
530
553
|
"data-testid": "ac-select-create",
|
|
531
|
-
onMouseenter: a[6] ||= (e) =>
|
|
532
|
-
onMousedown: a[7] ||=
|
|
554
|
+
onMouseenter: a[6] ||= (e) => F.value = tt.value,
|
|
555
|
+
onMousedown: a[7] ||= S(() => {}, ["prevent"]),
|
|
533
556
|
onClick: ct
|
|
534
|
-
}, [
|
|
557
|
+
}, [d(b(ge), {
|
|
535
558
|
class: "size-4 shrink-0 text-primary-strong",
|
|
536
559
|
"aria-hidden": "true"
|
|
537
|
-
}), l("span",
|
|
538
|
-
!
|
|
539
|
-
], 8,
|
|
560
|
+
}), l("span", Re, y(f.createText) + " “" + y(q.value) + "”", 1)], 42, Le)) : s("", !0),
|
|
561
|
+
!G.value.length && !J.value ? (h(), c("li", ze, [v(t.$slots, "empty", { query: P.value }, () => [u(y(f.emptyText || (P.value ? `${f.noResultText} for “${P.value}”` : "No options")), 1)])])) : s("", !0)
|
|
562
|
+
], 8, Me)], 4)) : s("", !0)]),
|
|
540
563
|
_: 3
|
|
541
564
|
})]))
|
|
542
565
|
], 16));
|
|
543
566
|
}
|
|
544
567
|
});
|
|
545
568
|
//#endregion
|
|
546
|
-
export {
|
|
569
|
+
export { Ve as default };
|