@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.
@@ -1,81 +1,96 @@
1
1
  "use client";
2
- import { jsx as a, jsxs as p, Fragment as h } from "react/jsx-runtime";
3
- import { forwardRef as f, useId as j } from "react";
4
- import { Dialog as M, Heading as z, ModalOverlay as O, Modal as S, Popover as H, OverlayArrow as B, Button as V, Tooltip as X, TooltipTrigger as q } from "react-aria-components";
5
- import { DialogTrigger as ha } from "react-aria-components";
6
- import { X as F } from "lucide-react";
7
- import { withMotionStyle as v } from "@alea-design/motion";
8
- import { cx as I, withBase as N } from "../../utils/cx.js";
9
- import { Button as x, IconButton as E } from "../button/Button.js";
10
- import { useStrings as y } from "../../i18n/strings.js";
11
- import { renamedValue as G } from "../../utils/vocabulary.js";
12
- import { surfaceAttrs as $ } from "../surface/Surface.js";
13
- import { useInitialFocus as J } from "../../utils/initialFocus.js";
14
- import { useModalRef as K, useInModalLayer as Q, ModalLayer as U } from "../../utils/modalLayer.js";
15
- const ca = f(function({ children: e, showArrow: o, className: l, offset: i = 8, motion: r, style: t, size: n, surface: c, radius: m, ...s }, u) {
16
- return /* @__PURE__ */ p(H, { ...s, ref: u, offset: o ? 12 : i, "data-size": n, ...$({ surface: c, radius: m }), className: N("alea-popover", l), style: v(t, r), children: [
17
- o && /* @__PURE__ */ a(B, { 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
- e
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
- }), da = f(function({ title: e, description: o, footer: l, showClose: i, children: r, className: t, ...n }, c) {
21
- const m = y();
22
- return /* @__PURE__ */ a(M, { ...n, ref: c, className: I("alea-popover-dialog", t), children: (s) => /* @__PURE__ */ p(h, { children: [
23
- (e || i) && /* @__PURE__ */ p("div", { className: "alea-popover-head", children: [
24
- e && /* @__PURE__ */ a(z, { slot: "title", className: "alea-popover-title", children: e }),
25
- i && /* @__PURE__ */ a(V, { className: "alea-popover-close alea-focus-ring", "aria-label": m.close, onPress: s.close, children: /* @__PURE__ */ a(F, { size: 16, "aria-hidden": "true" }) })
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 r == "function" ? r(s) : r,
29
- l && /* @__PURE__ */ a("div", { className: "alea-popover-footer", children: typeof l == "function" ? l(s.close) : l })
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 ma({ children: d, title: e, shortcut: o, hideArrow: l, className: i, offset: r = 8, motion: t, style: n, ...c }) {
33
- return /* @__PURE__ */ p(X, { ...c, offset: r, className: N("alea-tooltip", i), "data-rich": e ? !0 : void 0, style: v(n, t), children: [
34
- !l && /* @__PURE__ */ a(B, { 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
- e && /* @__PURE__ */ a("span", { className: "alea-tooltip-title", children: e }),
36
- /* @__PURE__ */ p("span", { className: "alea-tooltip-text", children: [
37
- d,
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 pa({ delay: d = 600, closeDelay: e = 200, ...o }) {
43
- return /* @__PURE__ */ a(q, { ...o, delay: d, closeDelay: e });
42
+ function ga({ delay: p = 600, closeDelay: l = 200, ...o }) {
43
+ return /* @__PURE__ */ a(G, { ...o, delay: p, closeDelay: l });
44
44
  }
45
- const W = f(function({ title: e, description: o, children: l, footer: i, hideClose: r, titleSize: t = "md", className: n, ...c }, m) {
46
- const s = y(), u = K(m, Q());
47
- return /* @__PURE__ */ a(M, { ...c, ref: u, className: I("alea-dialog", n), children: ({ close: g }) => /* @__PURE__ */ p(h, { children: [
48
- (e || !r) && /* @__PURE__ */ p("div", { className: "alea-dialog-head", children: [
49
- e && /* @__PURE__ */ a(z, { slot: "title", className: "alea-dialog-title", "data-size": t === "sm" ? "sm" : void 0, children: e }),
50
- !r && /* @__PURE__ */ a(E, { "aria-label": s.close, size: "sm", variant: "ghost", onPress: g, className: "alea-dialog-x", children: /* @__PURE__ */ a(F, {}) })
51
- ] }),
52
- o && /* @__PURE__ */ a("p", { className: "alea-dialog-description", children: o }),
53
- l && /* @__PURE__ */ a("div", { className: "alea-dialog-body", children: typeof l == "function" ? l({ close: g }) : l }),
54
- i && /* @__PURE__ */ a("div", { className: "alea-dialog-footer", children: typeof i == "function" ? i({ close: g }) : i })
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 Y({ children: d, size: e = "md", fullscreenBelow: o, className: l, isDismissable: i = !0, motion: r, backdrop: t, initialFocus: n, surface: c, radius: m, ...s }) {
58
- const u = J(n);
59
- return /* @__PURE__ */ a(O, { ...s, isDismissable: i, className: N("alea-modal-overlay", l), "data-backdrop": t, "data-fullscreen-below": o, children: /* @__PURE__ */ a(S, { ref: u, className: "alea-modal", "data-size": e, "data-fullscreen-below": o, ...$({ surface: c, radius: m }), style: v(void 0, r), children: /* @__PURE__ */ a(U, { value: !0, children: d }) }) });
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 ua = f(function({ motion: e, backdrop: o, initialFocus: l, titleSize: i, title: r, children: t, confirmLabel: n, cancelLabel: c, tone: m, onConfirm: s, isOpen: u, defaultOpen: g, onOpenChange: A, className: L, style: R }, k) {
62
- const D = j(), w = G("AlertDialog", "tone", m, { default: "neutral" }) ?? "neutral", P = y();
63
- n ?? (n = P.confirm), c ?? (c = P.cancel);
64
- const T = l ?? (w === "danger" ? "cancel" : "confirm");
65
- return /* @__PURE__ */ a(Y, { isOpen: u, defaultOpen: g, onOpenChange: A, isDismissable: !1, size: "sm", motion: e, backdrop: o, children: /* @__PURE__ */ a(W, { ref: k, className: L, style: R, role: "alertdialog", "aria-describedby": t ? D : void 0, title: r, titleSize: i, hideClose: !0, footer: ({ close: b }) => /* @__PURE__ */ p(h, { children: [
66
- /* @__PURE__ */ a(x, { variant: "ghost", autoFocus: T === "cancel", onPress: b, children: c }),
67
- /* @__PURE__ */ a(x, { variant: w === "danger" ? "danger" : "primary", autoFocus: T === "confirm", onPress: async () => {
68
- await (s == null ? void 0 : s()), b();
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: D, style: { display: "contents" }, children: t }) : null }) });
85
+ ] }), children: t ? /* @__PURE__ */ a("div", { id: u, style: { display: "contents" }, children: t }) : null }) });
71
86
  });
72
87
  export {
73
- ua as AlertDialog,
74
- W as Dialog,
75
- Y as DialogModal,
76
- ha as DialogTrigger,
77
- ca as Popover,
78
- da as PopoverDialog,
79
- ma as Tooltip,
80
- pa as TooltipTrigger
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 i, Fragment as U } from "react/jsx-runtime";
3
- import { forwardRef as F, useContext as g, useMemo as W } from "react";
4
- import { ListBox as I, useFilter as Y, Select as Z, SelectValue as _, Autocomplete as ee, SearchField as ae, Input as le, ListBoxItem as te, ListBoxSection as se, Header as re, SelectStateContext as O, Button as R, Virtualizer as ie, ListLayout as ne, AutocompleteStateContext as oe, Text as ce } from "react-aria-components";
5
- import { ChevronDown as de, Search as ue, Check as pe, X as he } from "lucide-react";
6
- import { withBase as V, cx as me } from "../../utils/cx.js";
7
- import { useAriaInvalid as fe } from "../../utils/refs.js";
8
- import { Label as Se, Description as be, FieldError as ye } from "../field/Field.js";
9
- import { Spinner as ve } from "../feedback/Spinner.js";
10
- import { useBusy as Ne, loadingAttrs as xe } from "../field/FieldLoading.js";
11
- import { responsiveAttrs as ge } from "../../utils/responsive.js";
12
- import { Popover as Ve } from "../overlay/Overlay.js";
13
- import { useStrings as y } from "../../i18n/strings.js";
14
- import { OptionMatchContext as Be, useOptionMatch as Ae, Highlight as De } from "../combobox/Highlight.js";
15
- function ke({ style: r, children: l }) {
16
- const t = g(oe), s = (t == null ? void 0 : t.inputValue) ?? "", a = W(() => ({ query: s, style: r ?? "tint", match: "phrase" }), [s, r]);
17
- return /* @__PURE__ */ e(Be.Provider, { value: a, children: l });
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 qe = F(function(l, t) {
20
- const s = g(O), a = fe(!!(s != null && s.displayValidation.isInvalid), t);
21
- return /* @__PURE__ */ e(R, { ...l, ref: a });
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 ze() {
24
- const r = y(), l = g(O), t = l && (Array.isArray(l.value) ? l.value.length > 0 : l.value != null);
25
- return !l || !t ? null : /* @__PURE__ */ e(R, { slot: null, className: "alea-input-clear alea-select-clear alea-focus-ring", "aria-label": r.clear, onPress: () => l.setValue(l.selectionManager.selectionMode === "multiple" ? [] : null), children: /* @__PURE__ */ e(he, { size: 14 }) });
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 Le({ motion: r, label: l, description: t, errorMessage: s, warningMessage: a, showOptional: n, items: p, children: o, size: h, variant: S = "outline", labelPosition: c = "top", prefix: B, isClearable: E, searchable: A, highlightMatch: M, matchStyle: P, isLoading: v, emptyText: j, footer: D, checkPosition: H = "end", maxTags: N = 2, renderValue: k, virtualized: q, className: K, placeholder: z, ...f }) {
28
- const m = y();
29
- z ?? (z = m.selectPlaceholder);
30
- const T = Ne(v), { contains: $ } = Y({ sensitivity: "base" }), X = f.selectionMode === "multiple", L = /* @__PURE__ */ e(I, { items: p, className: "alea-listbox", "data-check": H, renderEmptyState: () => /* @__PURE__ */ e("div", { className: "alea-listbox-empty", children: j ?? m.noResults }), children: o ?? ((u) => /* @__PURE__ */ e(C, { 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 })) }), x = q ? /* @__PURE__ */ e(ie, { layout: ne, layoutOptions: { rowHeight: q }, children: L }) : L;
31
- return /* @__PURE__ */ i(
32
- Z,
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: z,
36
+ placeholder: O,
36
37
  allowsEmptyCollection: !0,
37
- className: V("alea-field alea-select", K),
38
- ...ge("size", h, "md"),
39
- "data-variant": S !== "outline" ? S : void 0,
40
- "data-label-position": c !== "top" ? c : void 0,
41
- "data-warning": a ? !0 : void 0,
42
- ...xe(v),
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
- l && /* @__PURE__ */ i(Se, { children: [
45
- l,
45
+ t && /* @__PURE__ */ o(ve, { children: [
46
+ t,
46
47
  f.isRequired && /* @__PURE__ */ e("span", { className: "alea-label-required", "aria-hidden": "true", children: " *" }),
47
- n && !f.isRequired && /* @__PURE__ */ i("span", { className: "alea-label-optional", children: [
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__ */ i("div", { className: "alea-select-control", children: [
54
- /* @__PURE__ */ i(qe, { ref: T, className: "alea-select-trigger alea-focus-ring", children: [
55
- B && /* @__PURE__ */ e("span", { className: "alea-input-affix alea-select-prefix", "aria-hidden": "true", children: B }),
56
- /* @__PURE__ */ e(_, { className: "alea-select-value", children: ({ selectedItems: u, isPlaceholder: G, defaultChildren: w }) => {
57
- const b = u.filter(Boolean);
58
- if (G) return w;
59
- if (k) return k(b);
60
- if (!X) return w;
61
- const J = (d) => (d == null ? void 0 : d.textValue) ?? (typeof (d == null ? void 0 : d.label) == "string" ? d.label : String((d == null ? void 0 : d.id) ?? ""));
62
- return /* @__PURE__ */ i("span", { className: "alea-select-tags", children: [
63
- b.slice(0, N).map((d, Q) => /* @__PURE__ */ e("span", { className: "alea-select-tag", children: J(d) }, Q)),
64
- b.length > N && /* @__PURE__ */ i("span", { className: "alea-select-tag", "data-more": !0, children: [
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
- b.length - N
67
+ y.length - N
67
68
  ] })
68
69
  ] });
69
70
  } }),
70
- v ? /* @__PURE__ */ e(ve, { size: "sm", "aria-label": m.loading }) : /* @__PURE__ */ e(de, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
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
- E && !f.isDisabled && /* @__PURE__ */ e(ze, {})
73
+ G && !f.isDisabled && /* @__PURE__ */ e(Fe, {})
73
74
  ] }),
74
- (t || a) && /* @__PURE__ */ i(be, { children: [
75
- t,
76
- a && /* @__PURE__ */ e("span", { className: "alea-field-warning", children: a })
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(ye, { children: s }),
79
- /* @__PURE__ */ i(Ve, { className: "alea-popover alea-select-popover", motion: r, "data-searchable": A || void 0, children: [
80
- A ? /* @__PURE__ */ i(ee, { filter: $, children: [
81
- /* @__PURE__ */ i(ae, { "aria-label": m.filterOptions, autoFocus: !0, className: "alea-select-search", children: [
82
- /* @__PURE__ */ e(ue, { size: 14, "aria-hidden": "true" }),
83
- /* @__PURE__ */ e(le, { className: "alea-select-search-input", placeholder: m.search })
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
- M ? /* @__PURE__ */ e(ke, { style: P, children: x }) : x
86
- ] }) : x,
87
- D && /* @__PURE__ */ e("div", { className: "alea-select-footer", children: D })
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 we({ label: r, description: l, matchQuery: t, matchStyle: s }) {
94
- const a = Ae(), n = t ?? (a == null ? void 0 : a.query) ?? "", p = (o) => n && typeof o == "string" ? /* @__PURE__ */ e(De, { text: o, query: n, match: (a == null ? void 0 : a.match) ?? "phrase", matchStyle: s ?? (a == null ? void 0 : a.style) }) : o;
95
- return /* @__PURE__ */ i(ce, { slot: "label", className: "alea-option-text", children: [
96
- /* @__PURE__ */ e("span", { children: p(r) }),
97
- l && /* @__PURE__ */ e("span", { className: "alea-option-desc", children: p(l) })
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 C({ children: r, description: l, icon: t, matchQuery: s, matchStyle: a, className: n, textValue: p, ...o }) {
101
- return /* @__PURE__ */ e(te, { ...o, textValue: p ?? (typeof r == "string" || typeof r == "number" ? String(r) : void 0), className: V("alea-option", n), children: ({ isSelected: h }) => /* @__PURE__ */ i(U, { children: [
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(we, { label: r, description: l, matchQuery: s, matchStyle: a }),
104
- /* @__PURE__ */ e(pe, { size: 16, className: "alea-option-check", "aria-hidden": "true", "data-on": h || void 0 })
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 Xe = F(function({ title: l, children: t, className: s, ...a }, n) {
108
- return /* @__PURE__ */ i(se, { ...a, ref: n, className: me("alea-option-section", s), children: [
109
- /* @__PURE__ */ e(re, { className: "alea-option-header", children: l }),
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 Ge({ items: r, children: l, emptyText: t, checkPosition: s = "end", variant: a = "card", maxHeight: n, className: p, style: o, ...h }) {
114
- const S = y();
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
- I,
117
+ C,
117
118
  {
118
- ...h,
119
- items: r,
120
- "data-check": s,
121
- "data-variant": a,
122
- renderEmptyState: () => /* @__PURE__ */ e("div", { className: "alea-listbox-empty", children: t ?? S.noResults }),
123
- className: V("alea-listbox alea-listbox-standalone", p),
124
- style: { ...n ? { maxHeight: n, overflow: "auto" } : {}, ...o },
125
- children: l ?? ((c) => /* @__PURE__ */ e(C, { 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 }))
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 Je({ periods: r = ["24h", "7d", "30d", "12m"], value: l, defaultValue: t = "30d", onChange: s, label: a, size: n, className: p }) {
130
- const o = y();
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
- Le,
133
+ Ie,
133
134
  {
134
- "aria-label": a ? void 0 : o.period,
135
- label: a,
135
+ "aria-label": l ? void 0 : i.period,
136
+ label: l,
136
137
  size: n,
137
- className: p,
138
- selectedKey: l,
139
- defaultSelectedKey: l === void 0 ? t : void 0,
140
- onSelectionChange: (h) => s == null ? void 0 : s(h),
141
- items: r.map((h) => ({ id: h, label: o.periods[h] }))
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
- Ge as ListBox,
147
- Je as PeriodSelect,
148
- Le as Select,
149
- C as SelectItem,
150
- Xe as SelectSection
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
+ };
@@ -439,9 +439,10 @@
439
439
  ]
440
440
  },
441
441
  "more": {
442
- "bytes": 14461,
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": 13908,
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": 9373,
586
+ "bytes": 9521,
586
587
  "requires": [
587
588
  "base",
588
589
  "combobox",