@alea-design/ui 0.10.10 → 0.10.11
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/combobox/ComboBox.d.ts +3 -1
- package/dist/components/combobox/ComboBox.js +68 -65
- package/dist/components/more/More.d.ts +5 -1
- package/dist/components/more/More.js +108 -105
- package/dist/components/overlay/Overlay.d.ts +6 -0
- package/dist/components/overlay/Overlay.js +79 -64
- package/dist/components/select/Select.d.ts +3 -1
- package/dist/components/select/Select.js +104 -103
- package/dist/components/select/recent.d.ts +9 -0
- package/dist/components/select/recent.js +17 -0
- package/dist/css/groups.json +4 -3
- package/dist/css/more.css +1 -1
- package/dist/css/overlay.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/i18n/strings.d.ts +2 -0
- package/dist/i18n/strings.js +4 -0
- package/dist/styles.css +1 -1
- package/package.json +3 -3
|
@@ -1,81 +1,96 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as a, jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Dialog as
|
|
5
|
-
import { DialogTrigger as
|
|
6
|
-
import { X as
|
|
7
|
-
import { withMotionStyle as
|
|
8
|
-
import { cx as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { useStrings as
|
|
11
|
-
import { renamedValue as
|
|
12
|
-
import { surfaceAttrs as
|
|
13
|
-
import { useInitialFocus as
|
|
14
|
-
import { useModalRef as
|
|
15
|
-
const
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
o && /* @__PURE__ */ a(
|
|
18
|
-
|
|
2
|
+
import { jsx as a, jsxs as c, Fragment as B } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as v, useId as F, useState as S, useEffect as j } from "react";
|
|
4
|
+
import { Dialog as I, Heading as $, ModalOverlay as O, Modal as H, Popover as V, OverlayArrow as L, Button as X, Tooltip as q, TooltipTrigger as G } from "react-aria-components";
|
|
5
|
+
import { DialogTrigger as ya } from "react-aria-components";
|
|
6
|
+
import { X as R } from "lucide-react";
|
|
7
|
+
import { withMotionStyle as P } from "@alea-design/motion";
|
|
8
|
+
import { cx as E, withBase as w } from "../../utils/cx.js";
|
|
9
|
+
import { Button as D, IconButton as J } from "../button/Button.js";
|
|
10
|
+
import { useStrings as M } from "../../i18n/strings.js";
|
|
11
|
+
import { renamedValue as Q } from "../../utils/vocabulary.js";
|
|
12
|
+
import { surfaceAttrs as K } from "../surface/Surface.js";
|
|
13
|
+
import { useInitialFocus as U } from "../../utils/initialFocus.js";
|
|
14
|
+
import { useModalRef as W, useInModalLayer as Y, ModalLayer as Z } from "../../utils/modalLayer.js";
|
|
15
|
+
const ma = v(function({ children: l, showArrow: o, className: i, offset: r = 8, motion: e, style: t, size: n, surface: d, radius: m, ...s }, f) {
|
|
16
|
+
return /* @__PURE__ */ c(V, { ...s, ref: f, offset: o ? 12 : r, "data-size": n, ...K({ surface: d, radius: m }), className: w("alea-popover", i), style: P(t, e), children: [
|
|
17
|
+
o && /* @__PURE__ */ a(L, { className: "alea-arrow", children: /* @__PURE__ */ a("svg", { width: 12, height: 12, viewBox: "0 0 12 12", children: /* @__PURE__ */ a("path", { d: "M0 0 L6 6 L12 0" }) }) }),
|
|
18
|
+
l
|
|
19
19
|
] });
|
|
20
|
-
}),
|
|
21
|
-
const m =
|
|
22
|
-
return /* @__PURE__ */ a(
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
}), ua = v(function({ title: l, description: o, footer: i, showClose: r, children: e, className: t, ...n }, d) {
|
|
21
|
+
const m = M();
|
|
22
|
+
return /* @__PURE__ */ a(I, { ...n, ref: d, className: E("alea-popover-dialog", t), children: (s) => /* @__PURE__ */ c(B, { children: [
|
|
23
|
+
(l || r) && /* @__PURE__ */ c("div", { className: "alea-popover-head", children: [
|
|
24
|
+
l && /* @__PURE__ */ a($, { slot: "title", className: "alea-popover-title", children: l }),
|
|
25
|
+
r && /* @__PURE__ */ a(X, { className: "alea-popover-close alea-focus-ring", "aria-label": m.close, onPress: s.close, children: /* @__PURE__ */ a(R, { size: 16, "aria-hidden": "true" }) })
|
|
26
26
|
] }),
|
|
27
27
|
o && /* @__PURE__ */ a("p", { className: "alea-popover-desc", children: o }),
|
|
28
|
-
typeof
|
|
29
|
-
|
|
28
|
+
typeof e == "function" ? e(s) : e,
|
|
29
|
+
i && /* @__PURE__ */ a("div", { className: "alea-popover-footer", children: typeof i == "function" ? i(s.close) : i })
|
|
30
30
|
] }) });
|
|
31
31
|
});
|
|
32
|
-
function
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
!
|
|
35
|
-
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
|
|
32
|
+
function fa({ children: p, title: l, shortcut: o, hideArrow: i, className: r, offset: e = 8, motion: t, style: n, ...d }) {
|
|
33
|
+
return /* @__PURE__ */ c(q, { ...d, offset: e, className: w("alea-tooltip", r), "data-rich": l ? !0 : void 0, style: P(n, t), children: [
|
|
34
|
+
!i && /* @__PURE__ */ a(L, { className: "alea-arrow alea-tooltip-arrow", children: /* @__PURE__ */ a("svg", { width: 8, height: 8, viewBox: "0 0 8 8", children: /* @__PURE__ */ a("path", { d: "M0 0 L4 4 L8 0" }) }) }),
|
|
35
|
+
l && /* @__PURE__ */ a("span", { className: "alea-tooltip-title", children: l }),
|
|
36
|
+
/* @__PURE__ */ c("span", { className: "alea-tooltip-text", children: [
|
|
37
|
+
p,
|
|
38
38
|
o && /* @__PURE__ */ a("kbd", { className: "alea-tooltip-kbd", children: o })
|
|
39
39
|
] })
|
|
40
40
|
] });
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return /* @__PURE__ */ a(
|
|
42
|
+
function ga({ delay: p = 600, closeDelay: l = 200, ...o }) {
|
|
43
|
+
return /* @__PURE__ */ a(G, { ...o, delay: p, closeDelay: l });
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
const _ = () => typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent), A = v(function({ title: l, description: o, children: i, footer: r, secondaryAction: e, hideClose: t, titleSize: n = "md", className: d, ...m }, s) {
|
|
46
|
+
const f = M(), N = W(s, Y()), h = F(), [y, b] = S(!1);
|
|
47
|
+
return j(() => {
|
|
48
|
+
b(_());
|
|
49
|
+
}, []), /* @__PURE__ */ a(I, { ...m, ref: N, className: E("alea-dialog", d), children: ({ close: g }) => (
|
|
50
|
+
// display: contents keeps the dialog's own layout; the wrapper only listens for Ctrl+Enter or Command+Enter from any field inside (plain Enter stays with the field)
|
|
51
|
+
/* @__PURE__ */ c("div", { style: { display: "contents" }, onKeyDown: e ? (u) => {
|
|
52
|
+
!e.isDisabled && u.key === "Enter" && (u.ctrlKey || u.metaKey) && !u.defaultPrevented && (u.preventDefault(), e.onPress());
|
|
53
|
+
} : void 0, children: [
|
|
54
|
+
(l || !t) && /* @__PURE__ */ c("div", { className: "alea-dialog-head", children: [
|
|
55
|
+
l && /* @__PURE__ */ a($, { slot: "title", className: "alea-dialog-title", "data-size": n === "sm" ? "sm" : void 0, children: l }),
|
|
56
|
+
!t && /* @__PURE__ */ a(J, { "aria-label": f.close, size: "sm", variant: "ghost", onPress: g, className: "alea-dialog-x", children: /* @__PURE__ */ a(R, {}) })
|
|
57
|
+
] }),
|
|
58
|
+
o && /* @__PURE__ */ a("p", { className: "alea-dialog-description", children: o }),
|
|
59
|
+
i && /* @__PURE__ */ a("div", { className: "alea-dialog-body", children: typeof i == "function" ? i({ close: g }) : i }),
|
|
60
|
+
(r || e) && /* @__PURE__ */ c("div", { className: "alea-dialog-footer", children: [
|
|
61
|
+
typeof r == "function" ? r({ close: g }) : r,
|
|
62
|
+
e && /* @__PURE__ */ a(D, { variant: "primary", isDisabled: e.isDisabled, onPress: e.onPress, "aria-describedby": h, children: e.label }),
|
|
63
|
+
e && /* @__PURE__ */ c("p", { id: h, className: "alea-dialog-shortcut", children: [
|
|
64
|
+
/* @__PURE__ */ a("kbd", { children: y ? "⌘" : "Ctrl" }),
|
|
65
|
+
"+",
|
|
66
|
+
/* @__PURE__ */ a("kbd", { children: "Enter" })
|
|
67
|
+
] })
|
|
68
|
+
] })
|
|
69
|
+
] })
|
|
70
|
+
) });
|
|
56
71
|
});
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
return /* @__PURE__ */ a(O, { ...s, isDismissable:
|
|
72
|
+
function C({ children: p, size: l = "md", fullscreenBelow: o, className: i, isDismissable: r = !0, motion: e, backdrop: t, initialFocus: n, surface: d, radius: m, ...s }) {
|
|
73
|
+
const f = U(n);
|
|
74
|
+
return /* @__PURE__ */ a(O, { ...s, isDismissable: r, className: w("alea-modal-overlay", i), "data-backdrop": t, "data-fullscreen-below": o, children: /* @__PURE__ */ a(H, { ref: f, className: "alea-modal", "data-size": l, "data-fullscreen-below": o, ...K({ surface: d, radius: m }), style: P(void 0, e), children: /* @__PURE__ */ a(Z, { value: !0, children: p }) }) });
|
|
60
75
|
}
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
n ?? (n =
|
|
64
|
-
const
|
|
65
|
-
return /* @__PURE__ */ a(
|
|
66
|
-
/* @__PURE__ */ a(
|
|
67
|
-
/* @__PURE__ */ a(
|
|
68
|
-
await (s == null ? void 0 : s()),
|
|
76
|
+
const ha = v(function({ motion: l, backdrop: o, initialFocus: i, titleSize: r, title: e, children: t, confirmLabel: n, cancelLabel: d, tone: m, onConfirm: s, isOpen: f, defaultOpen: N, onOpenChange: h, className: y, style: b }, g) {
|
|
77
|
+
const u = F(), T = Q("AlertDialog", "tone", m, { default: "neutral" }) ?? "neutral", x = M();
|
|
78
|
+
n ?? (n = x.confirm), d ?? (d = x.cancel);
|
|
79
|
+
const k = i ?? (T === "danger" ? "cancel" : "confirm");
|
|
80
|
+
return /* @__PURE__ */ a(C, { isOpen: f, defaultOpen: N, onOpenChange: h, isDismissable: !1, size: "sm", motion: l, backdrop: o, children: /* @__PURE__ */ a(A, { ref: g, className: y, style: b, role: "alertdialog", "aria-describedby": t ? u : void 0, title: e, titleSize: r, hideClose: !0, footer: ({ close: z }) => /* @__PURE__ */ c(B, { children: [
|
|
81
|
+
/* @__PURE__ */ a(D, { variant: "ghost", autoFocus: k === "cancel", onPress: z, children: d }),
|
|
82
|
+
/* @__PURE__ */ a(D, { variant: T === "danger" ? "danger" : "primary", autoFocus: k === "confirm", onPress: async () => {
|
|
83
|
+
await (s == null ? void 0 : s()), z();
|
|
69
84
|
}, children: n })
|
|
70
|
-
] }), children: t ? /* @__PURE__ */ a("div", { id:
|
|
85
|
+
] }), children: t ? /* @__PURE__ */ a("div", { id: u, style: { display: "contents" }, children: t }) : null }) });
|
|
71
86
|
});
|
|
72
87
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
ha as AlertDialog,
|
|
89
|
+
A as Dialog,
|
|
90
|
+
C as DialogModal,
|
|
91
|
+
ya as DialogTrigger,
|
|
92
|
+
ma as Popover,
|
|
93
|
+
ua as PopoverDialog,
|
|
94
|
+
fa as Tooltip,
|
|
95
|
+
ga as TooltipTrigger
|
|
81
96
|
};
|
|
@@ -48,6 +48,8 @@ export interface SelectProps<T extends object = SelectOption> extends Omit<RACSe
|
|
|
48
48
|
emptyText?: ReactNode;
|
|
49
49
|
/** Content under the list inside the popover, like an "Add option" button. */
|
|
50
50
|
footer?: ReactNode;
|
|
51
|
+
/** Ids of the options used last (at most 5), shown first under a "Recent" heading, then the rest without repeating them. Needs the options as items; it is not used together with virtualized. */
|
|
52
|
+
recent?: Array<string | number>;
|
|
51
53
|
/** Where the selected check shows: end (default) or start. */
|
|
52
54
|
checkPosition?: 'start' | 'end';
|
|
53
55
|
/** With selectionMode="multiple": how many tags show in the trigger before "+N". Default 2. */
|
|
@@ -60,7 +62,7 @@ export interface SelectProps<T extends object = SelectOption> extends Omit<RACSe
|
|
|
60
62
|
motion?: MotionProp;
|
|
61
63
|
}
|
|
62
64
|
/** Pick one or several options from a list in a popover; type to jump, arrows to move. Search, clear, tags, groups, a footer and virtualization when you need them. */
|
|
63
|
-
export declare function Select<T extends object = SelectOption>({ motion, label, description, errorMessage, warningMessage, showOptional, items, children, size, variant, labelPosition, prefix, isClearable, searchable, highlightMatch, matchStyle, isLoading, emptyText, footer, checkPosition, maxTags, renderValue, virtualized, className, placeholder, ...props }: SelectProps<T>): import("react").JSX.Element;
|
|
65
|
+
export declare function Select<T extends object = SelectOption>({ recent, motion, label, description, errorMessage, warningMessage, showOptional, items, children, size, variant, labelPosition, prefix, isClearable, searchable, highlightMatch, matchStyle, isLoading, emptyText, footer, checkPosition, maxTags, renderValue, virtualized, className, placeholder, ...props }: SelectProps<T>): import("react").JSX.Element;
|
|
64
66
|
export interface SelectItemProps extends Omit<ListBoxItemProps, 'children'> {
|
|
65
67
|
children: ReactNode;
|
|
66
68
|
/** A second line under the option. */
|
|
@@ -1,151 +1,152 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { ListBox as
|
|
5
|
-
import { ChevronDown as
|
|
6
|
-
import { withBase as
|
|
7
|
-
import { useAriaInvalid as
|
|
8
|
-
import { Label as
|
|
9
|
-
import { Spinner as
|
|
10
|
-
import { useBusy as
|
|
11
|
-
import { responsiveAttrs as
|
|
12
|
-
import { Popover as
|
|
13
|
-
import { useStrings as
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { jsx as e, jsxs as o, Fragment as Z } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as R, useContext as V, useMemo as _ } from "react";
|
|
4
|
+
import { ListBox as C, useFilter as ee, Select as ae, SelectValue as le, Autocomplete as te, SearchField as re, Input as se, ListBoxItem as ne, ListBoxSection as oe, Header as ie, SelectStateContext as E, Button as M, Virtualizer as ce, ListLayout as de, AutocompleteStateContext as ue, Text as pe } from "react-aria-components";
|
|
5
|
+
import { ChevronDown as he, Search as me, Check as fe, X as ye } from "lucide-react";
|
|
6
|
+
import { withBase as B, cx as Se } from "../../utils/cx.js";
|
|
7
|
+
import { useAriaInvalid as be } from "../../utils/refs.js";
|
|
8
|
+
import { Label as ve, Description as Ne, FieldError as xe } from "../field/Field.js";
|
|
9
|
+
import { Spinner as ge } from "../feedback/Spinner.js";
|
|
10
|
+
import { useBusy as Ve, loadingAttrs as Be } from "../field/FieldLoading.js";
|
|
11
|
+
import { responsiveAttrs as Ae } from "../../utils/responsive.js";
|
|
12
|
+
import { Popover as De } from "../overlay/Overlay.js";
|
|
13
|
+
import { useStrings as S } from "../../i18n/strings.js";
|
|
14
|
+
import { recentGroups as ke } from "./recent.js";
|
|
15
|
+
import { OptionMatchContext as qe, useOptionMatch as Le, Highlight as Oe } from "../combobox/Highlight.js";
|
|
16
|
+
function we({ style: s, children: a }) {
|
|
17
|
+
const t = V(ue), r = (t == null ? void 0 : t.inputValue) ?? "", l = _(() => ({ query: r, style: s ?? "tint", match: "phrase" }), [r, s]);
|
|
18
|
+
return /* @__PURE__ */ e(qe.Provider, { value: l, children: a });
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
return /* @__PURE__ */ e(
|
|
20
|
+
const ze = R(function(a, t) {
|
|
21
|
+
const r = V(E), l = be(!!(r != null && r.displayValidation.isInvalid), t);
|
|
22
|
+
return /* @__PURE__ */ e(M, { ...a, ref: l });
|
|
22
23
|
});
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
return !
|
|
24
|
+
function Fe() {
|
|
25
|
+
const s = S(), a = V(E), t = a && (Array.isArray(a.value) ? a.value.length > 0 : a.value != null);
|
|
26
|
+
return !a || !t ? null : /* @__PURE__ */ e(M, { slot: null, className: "alea-input-clear alea-select-clear alea-focus-ring", "aria-label": s.clear, onPress: () => a.setValue(a.selectionManager.selectionMode === "multiple" ? [] : null), children: /* @__PURE__ */ e(ye, { size: 14 }) });
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
const m =
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
|
|
28
|
+
function Ie({ recent: s, motion: a, label: t, description: r, errorMessage: l, warningMessage: n, showOptional: h, items: i, children: d, size: b, variant: u = "outline", labelPosition: A = "top", prefix: D, isClearable: G, searchable: k, highlightMatch: j, matchStyle: H, isLoading: v, emptyText: K, footer: q, checkPosition: T = "end", maxTags: N = 2, renderValue: L, virtualized: x, className: $, placeholder: O, ...f }) {
|
|
29
|
+
const m = S();
|
|
30
|
+
O ?? (O = m.selectPlaceholder);
|
|
31
|
+
const X = Ve(v), { contains: J } = ee({ sensitivity: "base" }), Q = f.selectionMode === "multiple", w = (c) => typeof d == "function" ? d(c) : /* @__PURE__ */ e(P, { id: c.id, textValue: c.textValue ?? (typeof c.label == "string" ? c.label : String(c.id)), isDisabled: c.isDisabled, description: c.description, icon: c.icon, children: c.label }, c.id), z = x ? null : ke(i, s, m.recentGroup, m.otherGroup, w), F = /* @__PURE__ */ e(C, { items: z ? void 0 : i, className: "alea-listbox", "data-check": T, renderEmptyState: () => /* @__PURE__ */ e("div", { className: "alea-listbox-empty", children: K ?? m.noResults }), children: z ?? d ?? w }), g = x ? /* @__PURE__ */ e(ce, { layout: de, layoutOptions: { rowHeight: x }, children: F }) : F;
|
|
32
|
+
return /* @__PURE__ */ o(
|
|
33
|
+
ae,
|
|
33
34
|
{
|
|
34
35
|
...f,
|
|
35
|
-
placeholder:
|
|
36
|
+
placeholder: O,
|
|
36
37
|
allowsEmptyCollection: !0,
|
|
37
|
-
className:
|
|
38
|
-
...
|
|
39
|
-
"data-variant":
|
|
40
|
-
"data-label-position":
|
|
41
|
-
"data-warning":
|
|
42
|
-
...
|
|
38
|
+
className: B("alea-field alea-select", $),
|
|
39
|
+
...Ae("size", b, "md"),
|
|
40
|
+
"data-variant": u !== "outline" ? u : void 0,
|
|
41
|
+
"data-label-position": A !== "top" ? A : void 0,
|
|
42
|
+
"data-warning": n ? !0 : void 0,
|
|
43
|
+
...Be(v),
|
|
43
44
|
children: [
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
t && /* @__PURE__ */ o(ve, { children: [
|
|
46
|
+
t,
|
|
46
47
|
f.isRequired && /* @__PURE__ */ e("span", { className: "alea-label-required", "aria-hidden": "true", children: " *" }),
|
|
47
|
-
|
|
48
|
+
h && !f.isRequired && /* @__PURE__ */ o("span", { className: "alea-label-optional", children: [
|
|
48
49
|
" (",
|
|
49
50
|
m.optional,
|
|
50
51
|
")"
|
|
51
52
|
] })
|
|
52
53
|
] }),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
56
|
-
/* @__PURE__ */ e(
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
60
|
-
if (!
|
|
61
|
-
const
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
/* @__PURE__ */ o("div", { className: "alea-select-control", children: [
|
|
55
|
+
/* @__PURE__ */ o(ze, { ref: X, className: "alea-select-trigger alea-focus-ring", children: [
|
|
56
|
+
D && /* @__PURE__ */ e("span", { className: "alea-input-affix alea-select-prefix", "aria-hidden": "true", children: D }),
|
|
57
|
+
/* @__PURE__ */ e(le, { className: "alea-select-value", children: ({ selectedItems: c, isPlaceholder: U, defaultChildren: I }) => {
|
|
58
|
+
const y = c.filter(Boolean);
|
|
59
|
+
if (U) return I;
|
|
60
|
+
if (L) return L(y);
|
|
61
|
+
if (!Q) return I;
|
|
62
|
+
const W = (p) => (p == null ? void 0 : p.textValue) ?? (typeof (p == null ? void 0 : p.label) == "string" ? p.label : String((p == null ? void 0 : p.id) ?? ""));
|
|
63
|
+
return /* @__PURE__ */ o("span", { className: "alea-select-tags", children: [
|
|
64
|
+
y.slice(0, N).map((p, Y) => /* @__PURE__ */ e("span", { className: "alea-select-tag", children: W(p) }, Y)),
|
|
65
|
+
y.length > N && /* @__PURE__ */ o("span", { className: "alea-select-tag", "data-more": !0, children: [
|
|
65
66
|
"+",
|
|
66
|
-
|
|
67
|
+
y.length - N
|
|
67
68
|
] })
|
|
68
69
|
] });
|
|
69
70
|
} }),
|
|
70
|
-
v ? /* @__PURE__ */ e(
|
|
71
|
+
v ? /* @__PURE__ */ e(ge, { size: "sm", "aria-label": m.loading }) : /* @__PURE__ */ e(he, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
|
|
71
72
|
] }),
|
|
72
|
-
|
|
73
|
+
G && !f.isDisabled && /* @__PURE__ */ e(Fe, {})
|
|
73
74
|
] }),
|
|
74
|
-
(
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
(r || n) && /* @__PURE__ */ o(Ne, { children: [
|
|
76
|
+
r,
|
|
77
|
+
n && /* @__PURE__ */ e("span", { className: "alea-field-warning", children: n })
|
|
77
78
|
] }),
|
|
78
|
-
/* @__PURE__ */ e(
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */ e(
|
|
83
|
-
/* @__PURE__ */ e(
|
|
79
|
+
/* @__PURE__ */ e(xe, { children: l }),
|
|
80
|
+
/* @__PURE__ */ o(De, { className: "alea-popover alea-select-popover", motion: a, "data-searchable": k || void 0, children: [
|
|
81
|
+
k ? /* @__PURE__ */ o(te, { filter: J, children: [
|
|
82
|
+
/* @__PURE__ */ o(re, { "aria-label": m.filterOptions, autoFocus: !0, className: "alea-select-search", children: [
|
|
83
|
+
/* @__PURE__ */ e(me, { size: 14, "aria-hidden": "true" }),
|
|
84
|
+
/* @__PURE__ */ e(se, { className: "alea-select-search-input", placeholder: m.search })
|
|
84
85
|
] }),
|
|
85
|
-
|
|
86
|
-
] }) :
|
|
87
|
-
|
|
86
|
+
j ? /* @__PURE__ */ e(we, { style: H, children: g }) : g
|
|
87
|
+
] }) : g,
|
|
88
|
+
q && /* @__PURE__ */ e("div", { className: "alea-select-footer", children: q })
|
|
88
89
|
] })
|
|
89
90
|
]
|
|
90
91
|
}
|
|
91
92
|
);
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
-
const
|
|
95
|
-
return /* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */ e("span", { children:
|
|
97
|
-
|
|
94
|
+
function Re({ label: s, description: a, matchQuery: t, matchStyle: r }) {
|
|
95
|
+
const l = Le(), n = t ?? (l == null ? void 0 : l.query) ?? "", h = (i) => n && typeof i == "string" ? /* @__PURE__ */ e(Oe, { text: i, query: n, match: (l == null ? void 0 : l.match) ?? "phrase", matchStyle: r ?? (l == null ? void 0 : l.style) }) : i;
|
|
96
|
+
return /* @__PURE__ */ o(pe, { slot: "label", className: "alea-option-text", children: [
|
|
97
|
+
/* @__PURE__ */ e("span", { children: h(s) }),
|
|
98
|
+
a && /* @__PURE__ */ e("span", { className: "alea-option-desc", children: h(a) })
|
|
98
99
|
] });
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
-
return /* @__PURE__ */ e(
|
|
101
|
+
function P({ children: s, description: a, icon: t, matchQuery: r, matchStyle: l, className: n, textValue: h, ...i }) {
|
|
102
|
+
return /* @__PURE__ */ e(ne, { ...i, textValue: h ?? (typeof s == "string" || typeof s == "number" ? String(s) : void 0), className: B("alea-option", n), children: ({ isSelected: d }) => /* @__PURE__ */ o(Z, { children: [
|
|
102
103
|
t && /* @__PURE__ */ e("span", { className: "alea-option-icon", "aria-hidden": "true", children: t }),
|
|
103
|
-
/* @__PURE__ */ e(
|
|
104
|
-
/* @__PURE__ */ e(
|
|
104
|
+
/* @__PURE__ */ e(Re, { label: s, description: a, matchQuery: r, matchStyle: l }),
|
|
105
|
+
/* @__PURE__ */ e(fe, { size: 16, className: "alea-option-check", "aria-hidden": "true", "data-on": d || void 0 })
|
|
105
106
|
] }) });
|
|
106
107
|
}
|
|
107
|
-
const
|
|
108
|
-
return /* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */ e(
|
|
108
|
+
const We = R(function({ title: a, children: t, className: r, ...l }, n) {
|
|
109
|
+
return /* @__PURE__ */ o(oe, { ...l, ref: n, className: Se("alea-option-section", r), children: [
|
|
110
|
+
/* @__PURE__ */ e(ie, { className: "alea-option-header", children: a }),
|
|
110
111
|
t
|
|
111
112
|
] });
|
|
112
113
|
});
|
|
113
|
-
function
|
|
114
|
-
const
|
|
114
|
+
function Ye({ items: s, children: a, emptyText: t, checkPosition: r = "end", variant: l = "card", maxHeight: n, className: h, style: i, ...d }) {
|
|
115
|
+
const b = S();
|
|
115
116
|
return /* @__PURE__ */ e(
|
|
116
|
-
|
|
117
|
+
C,
|
|
117
118
|
{
|
|
118
|
-
...
|
|
119
|
-
items:
|
|
120
|
-
"data-check":
|
|
121
|
-
"data-variant":
|
|
122
|
-
renderEmptyState: () => /* @__PURE__ */ e("div", { className: "alea-listbox-empty", children: t ??
|
|
123
|
-
className:
|
|
124
|
-
style: { ...n ? { maxHeight: n, overflow: "auto" } : {}, ...
|
|
125
|
-
children:
|
|
119
|
+
...d,
|
|
120
|
+
items: s,
|
|
121
|
+
"data-check": r,
|
|
122
|
+
"data-variant": l,
|
|
123
|
+
renderEmptyState: () => /* @__PURE__ */ e("div", { className: "alea-listbox-empty", children: t ?? b.noResults }),
|
|
124
|
+
className: B("alea-listbox alea-listbox-standalone", h),
|
|
125
|
+
style: { ...n ? { maxHeight: n, overflow: "auto" } : {}, ...i },
|
|
126
|
+
children: a ?? ((u) => /* @__PURE__ */ e(P, { id: u.id, textValue: u.textValue ?? (typeof u.label == "string" ? u.label : String(u.id)), isDisabled: u.isDisabled, description: u.description, icon: u.icon, children: u.label }))
|
|
126
127
|
}
|
|
127
128
|
);
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
130
|
+
function Ze({ periods: s = ["24h", "7d", "30d", "12m"], value: a, defaultValue: t = "30d", onChange: r, label: l, size: n, className: h }) {
|
|
131
|
+
const i = S();
|
|
131
132
|
return /* @__PURE__ */ e(
|
|
132
|
-
|
|
133
|
+
Ie,
|
|
133
134
|
{
|
|
134
|
-
"aria-label":
|
|
135
|
-
label:
|
|
135
|
+
"aria-label": l ? void 0 : i.period,
|
|
136
|
+
label: l,
|
|
136
137
|
size: n,
|
|
137
|
-
className:
|
|
138
|
-
selectedKey:
|
|
139
|
-
defaultSelectedKey:
|
|
140
|
-
onSelectionChange: (
|
|
141
|
-
items:
|
|
138
|
+
className: h,
|
|
139
|
+
selectedKey: a,
|
|
140
|
+
defaultSelectedKey: a === void 0 ? t : void 0,
|
|
141
|
+
onSelectionChange: (d) => r == null ? void 0 : r(d),
|
|
142
|
+
items: s.map((d) => ({ id: d, label: i.periods[d] }))
|
|
142
143
|
}
|
|
143
144
|
);
|
|
144
145
|
}
|
|
145
146
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
Ye as ListBox,
|
|
148
|
+
Ze as PeriodSelect,
|
|
149
|
+
Ie as Select,
|
|
150
|
+
P as SelectItem,
|
|
151
|
+
We as SelectSection
|
|
151
152
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The options of a ComboBox or Select with the recent ones on top: a "Recent" group, then the rest without repeating them. Returns null when
|
|
4
|
+
* there is nothing to group (no recent ids, or none of them is among the options), so the list renders as before.
|
|
5
|
+
* `render` draws one option; the groups are SelectSections, so a screen reader says "Recent, group" before them.
|
|
6
|
+
*/
|
|
7
|
+
export declare function recentGroups<T extends {
|
|
8
|
+
id?: unknown;
|
|
9
|
+
}>(items: Iterable<T> | undefined, recent: ReadonlyArray<string | number> | undefined, recentLabel: string, otherLabel: string, render: (item: T) => ReactNode): ReactNode[] | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
3
|
+
import { SelectSection as s } from "./Select.js";
|
|
4
|
+
const d = 5;
|
|
5
|
+
function S(i, n, c, a, r) {
|
|
6
|
+
if (!i || !(n != null && n.length)) return null;
|
|
7
|
+
const l = [...i], m = new Map(l.map((t) => [String(t.id), t])), e = [...new Set(n.map(String))].slice(0, d).map((t) => m.get(t)).filter((t) => !!t);
|
|
8
|
+
if (!e.length) return null;
|
|
9
|
+
const _ = new Set(e.map((t) => String(t.id))), o = l.filter((t) => !_.has(String(t.id)));
|
|
10
|
+
return [
|
|
11
|
+
/* @__PURE__ */ p(s, { id: "__recent", title: c, children: e.map(r) }, "__recent"),
|
|
12
|
+
...o.length ? [/* @__PURE__ */ p(s, { id: "__rest", title: a, children: o.map(r) }, "__rest")] : []
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
S as recentGroups
|
|
17
|
+
};
|
package/dist/css/groups.json
CHANGED
|
@@ -439,9 +439,10 @@
|
|
|
439
439
|
]
|
|
440
440
|
},
|
|
441
441
|
"more": {
|
|
442
|
-
"bytes":
|
|
442
|
+
"bytes": 14528,
|
|
443
443
|
"requires": [
|
|
444
444
|
"base",
|
|
445
|
+
"button",
|
|
445
446
|
"feedback"
|
|
446
447
|
],
|
|
447
448
|
"components": [
|
|
@@ -496,7 +497,7 @@
|
|
|
496
497
|
]
|
|
497
498
|
},
|
|
498
499
|
"overlay": {
|
|
499
|
-
"bytes":
|
|
500
|
+
"bytes": 14247,
|
|
500
501
|
"requires": [
|
|
501
502
|
"base",
|
|
502
503
|
"button",
|
|
@@ -582,7 +583,7 @@
|
|
|
582
583
|
]
|
|
583
584
|
},
|
|
584
585
|
"select": {
|
|
585
|
-
"bytes":
|
|
586
|
+
"bytes": 9521,
|
|
586
587
|
"requires": [
|
|
587
588
|
"base",
|
|
588
589
|
"combobox",
|