@alea-design/ui 0.8.1 → 0.9.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.
@@ -1,93 +1,118 @@
1
1
  "use client";
2
- import { jsx as n, jsxs as m } from "react/jsx-runtime";
3
- import { forwardRef as B, useState as N, useEffect as D, useMemo as j, useRef as J } from "react";
4
- import { cx as P } from "../../utils/cx.js";
5
- import { useFilter as Y, Autocomplete as Z, SearchField as Q, Input as G, Menu as ee, MenuSection as te, Header as ne, Collection as se, MenuItem as z, Keyboard as ie } from "react-aria-components";
6
- import { Search as ae } from "lucide-react";
7
- import { DialogModal as le, Dialog as oe } from "../overlay/Overlay.js";
8
- import { Kbd as re } from "../typography/Typography.js";
2
+ import { jsx as n, jsxs as b } from "react/jsx-runtime";
3
+ import { forwardRef as $, useState as y, useEffect as K, useMemo as x, useRef as B } from "react";
4
+ import { cx as J } from "../../utils/cx.js";
5
+ import { useFilter as Y, Autocomplete as Z, SearchField as Q, Input as G, Menu as ee, MenuSection as te, Header as ne, Collection as ie, MenuItem as D, Keyboard as ae } from "react-aria-components";
6
+ import { Search as se } from "lucide-react";
7
+ import { DialogModal as oe, Dialog as re } from "../overlay/Overlay.js";
8
+ import { Kbd as le } from "../typography/Typography.js";
9
9
  import { useStrings as ce } from "../../i18n/strings.js";
10
- const M = "__more:";
11
- function de({ children: K }) {
12
- const o = J(null), [h, w] = N(!1);
13
- return D(() => {
14
- const a = o.current;
15
- if (!a) return;
16
- const f = () => w(a.scrollHeight > a.clientHeight + 1);
17
- if (f(), typeof ResizeObserver > "u") return;
18
- const c = new ResizeObserver(f);
19
- return c.observe(a), a.firstElementChild && c.observe(a.firstElementChild), () => c.disconnect();
20
- }, []), /* @__PURE__ */ n("div", { ref: o, className: "alea-command-scroll", tabIndex: h ? 0 : void 0, children: K });
10
+ const A = "__more:";
11
+ function de({ children: C }) {
12
+ const d = B(null), [N, g] = y(!1);
13
+ return K(() => {
14
+ const o = d.current;
15
+ if (!o) return;
16
+ const r = () => g(o.scrollHeight > o.clientHeight + 1);
17
+ if (r(), typeof ResizeObserver > "u") return;
18
+ const c = new ResizeObserver(r);
19
+ return c.observe(o), o.firstElementChild && c.observe(o.firstElementChild), () => c.disconnect();
20
+ }, []), K(() => {
21
+ var h;
22
+ const o = d.current;
23
+ if (!o) return;
24
+ const r = (h = o.closest(".alea-command")) == null ? void 0 : h.querySelector(".alea-command-input");
25
+ if (!r) return;
26
+ const c = () => o.querySelector('[role="menuitem"][data-focused]'), v = () => {
27
+ var m;
28
+ const i = ((m = c()) == null ? void 0 : m.id) ?? null;
29
+ r.getAttribute("aria-activedescendant") !== i && (i ? r.setAttribute("aria-activedescendant", i) : r.removeAttribute("aria-activedescendant"));
30
+ }, u = new MutationObserver(v);
31
+ u.observe(o, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["data-focused"] }), u.observe(r, { attributes: !0, attributeFilter: ["aria-activedescendant"] });
32
+ const f = (i) => {
33
+ var m;
34
+ if (i.key === "Enter") {
35
+ if (i.isComposing || i.keyCode === 229) {
36
+ i.stopPropagation();
37
+ return;
38
+ }
39
+ i.preventDefault(), i.stopPropagation(), (m = c()) == null || m.click();
40
+ }
41
+ };
42
+ return r.addEventListener("keydown", f), v(), () => {
43
+ u.disconnect(), r.removeEventListener("keydown", f);
44
+ };
45
+ }, []), /* @__PURE__ */ n("div", { ref: d, className: "alea-command-scroll", tabIndex: N ? 0 : void 0, children: C });
21
46
  }
22
- const ve = B(function({ commands: o, isOpen: h, defaultOpen: w, onOpenChange: a, motion: f, hotkey: c = !0, slashHotkey: R, onQueryChange: b, filter: p, isLoading: v, maxPerGroup: d, placeholder: I, emptyText: k, className: F, style: L, surface: T, radius: V }, H) {
47
+ const Ne = $(function({ commands: d, isOpen: N, defaultOpen: g, onOpenChange: o, motion: r, hotkey: c = !0, slashHotkey: v, onQueryChange: u, filter: f, isLoading: h, maxPerGroup: i, placeholder: m, emptyText: R, className: j, style: z, surface: O, radius: T }, V) {
23
48
  const l = ce();
24
- I ?? (I = l.commandPlaceholder), k ?? (k = l.noResults);
25
- const [O, _] = N(w ?? !1), g = h ?? O, [r, U] = N(""), [x, A] = N(/* @__PURE__ */ new Set()), C = (i) => {
26
- U(i), b == null || b(i);
27
- }, S = (i) => {
28
- i || (r && C(""), A(/* @__PURE__ */ new Set())), h === void 0 && _(i), a == null || a(i);
49
+ m ?? (m = l.commandPlaceholder), R ?? (R = l.noResults);
50
+ const [q, H] = y(g ?? !1), S = N ?? q, [p, P] = y(""), [F, I] = y(/* @__PURE__ */ new Set()), L = (s) => {
51
+ P(s), u == null || u(s);
52
+ }, E = (s) => {
53
+ s || (p && L(""), I(/* @__PURE__ */ new Set())), N === void 0 && H(s), o == null || o(s);
29
54
  };
30
- D(() => {
31
- if (!c && !R) return;
32
- const i = (t) => {
55
+ K(() => {
56
+ if (!c && !v) return;
57
+ const s = (t) => {
33
58
  if (c && t.key.toLowerCase() === "k" && (t.metaKey || t.ctrlKey)) {
34
- t.preventDefault(), S(!g);
59
+ t.preventDefault(), E(!S);
35
60
  return;
36
61
  }
37
- if (R && !g && t.key === "/" && !t.metaKey && !t.ctrlKey && !t.altKey) {
62
+ if (v && !S && t.key === "/" && !t.metaKey && !t.ctrlKey && !t.altKey) {
38
63
  const e = t.target;
39
64
  if (e && (e.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))) return;
40
- t.preventDefault(), S(!0);
65
+ t.preventDefault(), E(!0);
41
66
  }
42
67
  };
43
- return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
68
+ return window.addEventListener("keydown", s), () => window.removeEventListener("keydown", s);
44
69
  });
45
- const { contains: W } = Y({ sensitivity: "base" }), { groups: y, total: X } = j(() => {
46
- const i = (s) => p === !1 || !r ? !0 : p ? p(s, r) : W([s.label, ...s.keywords || []].join(" "), r), t = [];
70
+ const { contains: W } = Y({ sensitivity: "base" }), { groups: k, total: _ } = x(() => {
71
+ const s = (a) => f === !1 || !p ? !0 : f ? f(a, p) : W([a.label, ...a.keywords || []].join(" "), p), t = [];
47
72
  let e = 0;
48
- for (const s of o) {
49
- if (!i(s)) continue;
73
+ for (const a of d) {
74
+ if (!s(a)) continue;
50
75
  e++;
51
- const u = s.group || "";
52
- let E = t.find((q) => q.id === u);
53
- E || t.push(E = { id: u, title: u, items: [] }), E.items.push(s);
76
+ const w = a.group || "";
77
+ let M = t.find((X) => X.id === w);
78
+ M || t.push(M = { id: w, title: w, items: [] }), M.items.push(a);
54
79
  }
55
- if (d && d > 0) for (const s of t) {
56
- if (x.has(s.id) || s.items.length <= d) continue;
57
- const u = s.items.length - d;
58
- s.items = [...s.items.slice(0, d), { id: M + s.id, more: u, group: s.id }];
80
+ if (i && i > 0) for (const a of t) {
81
+ if (F.has(a.id) || a.items.length <= i) continue;
82
+ const w = a.items.length - i;
83
+ a.items = [...a.items.slice(0, i), { id: A + a.id, more: w, group: a.id }];
59
84
  }
60
85
  return { groups: t, total: e };
61
- }, [o, r, p, d, x]), $ = j(() => new Map(o.map((i) => [i.id, i])), [o]);
62
- return /* @__PURE__ */ n(le, { isOpen: g, onOpenChange: S, size: "md", className: "alea-command-overlay", motion: f, surface: T, radius: V, children: /* @__PURE__ */ n(oe, { ref: H, style: L, "aria-label": l.commandPalette, hideClose: !0, className: P("alea-command", F), children: ({ close: i }) => /* @__PURE__ */ m(Z, { inputValue: r, onInputChange: C, filter: () => !0, children: [
63
- /* @__PURE__ */ m(Q, { "aria-label": l.searchCommands, autoFocus: !0, className: "alea-command-search", children: [
64
- /* @__PURE__ */ n(ae, { size: 18, "aria-hidden": "true" }),
65
- /* @__PURE__ */ n(G, { placeholder: I, className: "alea-command-input" }),
66
- /* @__PURE__ */ n(re, { children: l.esc })
86
+ }, [d, p, f, i, F]), U = x(() => new Map(d.map((s) => [s.id, s])), [d]);
87
+ return /* @__PURE__ */ n(oe, { isOpen: S, onOpenChange: E, size: "md", className: "alea-command-overlay", motion: r, surface: O, radius: T, children: /* @__PURE__ */ n(re, { ref: V, style: z, "aria-label": l.commandPalette, hideClose: !0, className: J("alea-command", j), children: ({ close: s }) => /* @__PURE__ */ b(Z, { inputValue: p, onInputChange: L, filter: () => !0, children: [
88
+ /* @__PURE__ */ b(Q, { "aria-label": l.searchCommands, autoFocus: !0, className: "alea-command-search", children: [
89
+ /* @__PURE__ */ n(se, { size: 18, "aria-hidden": "true" }),
90
+ /* @__PURE__ */ n(G, { placeholder: m, className: "alea-command-input" }),
91
+ /* @__PURE__ */ n(le, { children: l.esc })
67
92
  ] }),
68
- /* @__PURE__ */ m(de, { children: [
69
- y.length > 0 && /* @__PURE__ */ n(ee, { items: y, className: "alea-command-list", "aria-busy": v || void 0, onAction: (t) => {
70
- if (String(t).startsWith(M)) {
71
- A((s) => new Set(s).add(String(t).slice(M.length)));
93
+ /* @__PURE__ */ b(de, { children: [
94
+ k.length > 0 && /* @__PURE__ */ n(ee, { shouldFocusWrap: !1, items: k, className: "alea-command-list", "aria-busy": h || void 0, onAction: (t) => {
95
+ if (String(t).startsWith(A)) {
96
+ I((a) => new Set(a).add(String(t).slice(A.length)));
72
97
  return;
73
98
  }
74
- const e = $.get(t);
75
- i(), e == null || e.onAction();
76
- }, children: (t) => /* @__PURE__ */ m(te, { id: t.id, className: "alea-option-section", children: [
99
+ const e = U.get(t);
100
+ s(), e == null || e.onAction();
101
+ }, children: (t) => /* @__PURE__ */ b(te, { id: t.id, className: "alea-option-section", children: [
77
102
  t.title && /* @__PURE__ */ n(ne, { className: "alea-option-header", children: t.title }),
78
- /* @__PURE__ */ n(se, { items: t.items, children: (e) => "more" in e ? /* @__PURE__ */ n(z, { id: e.id, textValue: l.showNMore(e.more), className: "alea-option alea-command-item alea-command-more", children: /* @__PURE__ */ n("span", { className: "alea-option-text", children: /* @__PURE__ */ n("span", { slot: "label", children: l.showNMore(e.more) }) }) }) : /* @__PURE__ */ m(z, { id: e.id, textValue: [e.label, ...e.keywords || []].join(" "), className: "alea-option alea-command-item", children: [
103
+ /* @__PURE__ */ n(ie, { items: t.items, children: (e) => "more" in e ? /* @__PURE__ */ n(D, { id: e.id, textValue: l.showNMore(e.more), className: "alea-option alea-command-item alea-command-more", children: /* @__PURE__ */ n("span", { className: "alea-option-text", children: /* @__PURE__ */ n("span", { slot: "label", children: l.showNMore(e.more) }) }) }) : /* @__PURE__ */ b(D, { id: e.id, textValue: [e.label, ...e.keywords || []].join(" "), className: "alea-option alea-command-item", children: [
79
104
  e.icon && /* @__PURE__ */ n("span", { className: "alea-option-icon", "aria-hidden": "true", children: e.icon }),
80
- /* @__PURE__ */ m("span", { className: "alea-option-text", children: [
105
+ /* @__PURE__ */ b("span", { className: "alea-option-text", children: [
81
106
  /* @__PURE__ */ n("span", { slot: "label", children: e.label }),
82
107
  e.description && /* @__PURE__ */ n("span", { className: "alea-option-desc", slot: "description", children: e.description })
83
108
  ] }),
84
- e.shortcut && /* @__PURE__ */ n(ie, { className: "alea-menu-shortcut", children: e.shortcut })
109
+ e.shortcut && /* @__PURE__ */ n(ae, { className: "alea-menu-shortcut", children: e.shortcut })
85
110
  ] }) })
86
111
  ] }) }),
87
- /* @__PURE__ */ n("div", { role: "status", children: y.length === 0 ? /* @__PURE__ */ n("p", { className: "alea-command-empty", children: v ? l.loading : k }) : v ? /* @__PURE__ */ n("p", { className: "alea-command-loading", children: l.loading }) : r ? /* @__PURE__ */ n("span", { className: "alea-visually-hidden", children: l.resultsCount(X) }) : null })
112
+ /* @__PURE__ */ n("div", { role: "status", children: k.length === 0 ? /* @__PURE__ */ n("p", { className: "alea-command-empty", children: h ? l.loading : R }) : h ? /* @__PURE__ */ n("p", { className: "alea-command-loading", children: l.loading }) : p ? /* @__PURE__ */ n("span", { className: "alea-visually-hidden", children: l.resultsCount(_) }) : null })
88
113
  ] })
89
114
  ] }) }) });
90
115
  });
91
116
  export {
92
- ve as CommandPalette
117
+ Ne as CommandPalette
93
118
  };
@@ -35,6 +35,8 @@ export interface PopconfirmProps {
35
35
  cancelLabel?: ReactNode;
36
36
  /** danger turns the confirm button red. */
37
37
  tone?: 'neutral' | 'danger' | /** @deprecated Use neutral. */ 'default';
38
+ /** Which button has focus when it opens: confirm or cancel. Default: cancel when tone is danger, so Enter never confirms a destructive action by accident, and confirm otherwise. */
39
+ initialFocus?: 'confirm' | 'cancel';
38
40
  /** Called when the person confirms. */
39
41
  onConfirm: () => unknown;
40
42
  /** Where it opens relative to its trigger. */
@@ -1,41 +1,44 @@
1
1
  "use client";
2
- import { jsx as r, jsxs as d, Fragment as y } from "react/jsx-runtime";
3
- import { forwardRef as x } from "react";
4
- import { ModalOverlay as D, Modal as P, DialogTrigger as N } from "react-aria-components";
5
- import { DialogTrigger as Y } from "react-aria-components";
6
- import { withMotionStyle as F } from "@alea-design/motion";
7
- import { withBase as M, cx as T } from "../../utils/cx.js";
8
- import { Button as g } from "../button/Button.js";
9
- import { Dialog as j, Popover as A, PopoverDialog as B } from "./Overlay.js";
10
- import { useStrings as R } from "../../i18n/strings.js";
11
- import { renamedValue as S } from "../../utils/vocabulary.js";
12
- import { surfaceAttrs as k } from "../surface/Surface.js";
13
- import { useInitialFocus as z } from "../../utils/initialFocus.js";
14
- function K({ children: o, placement: a = "end", size: e = 420, className: l, isDismissable: t = !0, motion: n, backdrop: i, initialFocus: m, surface: s, ...c }) {
15
- const p = z(m);
16
- return /* @__PURE__ */ r(D, { ...c, isDismissable: t, className: M("alea-modal-overlay alea-drawer-overlay", l), "data-placement": a, "data-backdrop": i, children: /* @__PURE__ */ r(P, { ref: p, className: "alea-drawer", "data-placement": a, ...k({ surface: s }), style: F({ "--alea-drawer-size": typeof e == "number" ? `${e}px` : e }, n), children: o }) });
2
+ import { jsx as r, jsxs as d, Fragment as D } from "react/jsx-runtime";
3
+ import { forwardRef as P } from "react";
4
+ import { ModalOverlay as F, Modal as N, DialogTrigger as M } from "react-aria-components";
5
+ import { DialogTrigger as rr } from "react-aria-components";
6
+ import { withMotionStyle as T } from "@alea-design/motion";
7
+ import { withBase as j, cx as A } from "../../utils/cx.js";
8
+ import { Button as w } from "../button/Button.js";
9
+ import { Dialog as B, Popover as R, PopoverDialog as S } from "./Overlay.js";
10
+ import { useStrings as k } from "../../i18n/strings.js";
11
+ import { renamedValue as z } from "../../utils/vocabulary.js";
12
+ import { surfaceAttrs as C } from "../surface/Surface.js";
13
+ import { useInitialFocus as I } from "../../utils/initialFocus.js";
14
+ import { ModalLayer as O } from "../../utils/modalLayer.js";
15
+ function X({ children: a, placement: e = "end", size: o = 420, className: l, isDismissable: t = !0, motion: n, backdrop: i, initialFocus: c, surface: m, ...s }) {
16
+ const p = I(c);
17
+ return /* @__PURE__ */ r(F, { ...s, isDismissable: t, className: j("alea-modal-overlay alea-drawer-overlay", l), "data-placement": e, "data-backdrop": i, children: /* @__PURE__ */ r(N, { ref: p, className: "alea-drawer", "data-placement": e, ...C({ surface: m }), style: T({ "--alea-drawer-size": typeof o == "number" ? `${o}px` : o }, n), children: /* @__PURE__ */ r(O, { value: !0, children: a }) }) });
17
18
  }
18
- function Q(o) {
19
- return /* @__PURE__ */ r(j, { ...o, className: "alea-drawer-content" });
19
+ function Y(a) {
20
+ return /* @__PURE__ */ r(B, { ...a, className: "alea-drawer-content" });
20
21
  }
21
- const U = x(function({ motion: a, children: e, title: l, description: t, confirmLabel: n, cancelLabel: i, tone: m, onConfirm: s, placement: c = "top", className: p, style: h }, w) {
22
- const v = S("Popconfirm", "tone", m, { default: "neutral" }) ?? "neutral", f = R();
23
- return n ?? (n = f.yes), i ?? (i = f.cancel), /* @__PURE__ */ d(N, { children: [
24
- e,
25
- /* @__PURE__ */ r(A, { showArrow: !0, placement: c, motion: a, children: /* @__PURE__ */ r(B, { ref: w, style: h, role: "alertdialog", title: l, className: T("alea-popover-dialog alea-popconfirm", p), children: ({ close: u }) => /* @__PURE__ */ d(y, { children: [
22
+ const Z = P(function({ motion: e, children: o, title: l, description: t, confirmLabel: n, cancelLabel: i, tone: c, initialFocus: m, onConfirm: s, placement: p = "top", className: v, style: y }, x) {
23
+ const f = z("Popconfirm", "tone", c, { default: "neutral" }) ?? "neutral", u = k();
24
+ n ?? (n = u.yes), i ?? (i = u.cancel);
25
+ const g = m ?? (f === "danger" ? "cancel" : "confirm");
26
+ return /* @__PURE__ */ d(M, { children: [
27
+ o,
28
+ /* @__PURE__ */ r(R, { showArrow: !0, placement: p, motion: e, children: /* @__PURE__ */ r(S, { ref: x, style: y, role: "alertdialog", title: l, className: A("alea-popover-dialog alea-popconfirm", v), children: ({ close: h }) => /* @__PURE__ */ d(D, { children: [
26
29
  t && /* @__PURE__ */ r("p", { className: "alea-popconfirm-text", children: t }),
27
30
  /* @__PURE__ */ d("div", { className: "alea-popconfirm-actions", children: [
28
- /* @__PURE__ */ r(g, { size: "sm", variant: "ghost", onPress: u, children: i }),
29
- /* @__PURE__ */ r(g, { size: "sm", variant: v === "danger" ? "danger" : "primary", autoFocus: !0, onPress: async () => {
30
- await s(), u();
31
+ /* @__PURE__ */ r(w, { size: "sm", variant: "ghost", autoFocus: g === "cancel", onPress: h, children: i }),
32
+ /* @__PURE__ */ r(w, { size: "sm", variant: f === "danger" ? "danger" : "primary", autoFocus: g === "confirm", onPress: async () => {
33
+ await s(), h();
31
34
  }, children: n })
32
35
  ] })
33
36
  ] }) }) })
34
37
  ] });
35
38
  });
36
39
  export {
37
- K as Drawer,
38
- Q as DrawerContent,
39
- Y as DrawerTrigger,
40
- U as Popconfirm
40
+ X as Drawer,
41
+ Y as DrawerContent,
42
+ rr as DrawerTrigger,
43
+ Z as Popconfirm
41
44
  };
@@ -1,28 +1,29 @@
1
1
  "use client";
2
- import { jsx as a, jsxs as i, Fragment as X } from "react/jsx-runtime";
3
- import { forwardRef as $ } from "react";
4
- import { ModalOverlay as q, Modal as E, Dialog as G, Heading as J, DialogTrigger as K } from "react-aria-components";
2
+ import { jsx as a, jsxs as i, Fragment as $ } from "react/jsx-runtime";
3
+ import { forwardRef as q } from "react";
4
+ import { ModalOverlay as E, Modal as G, Dialog as J, Heading as K, DialogTrigger as L } from "react-aria-components";
5
5
  import { X as v } from "lucide-react";
6
- import { withMotionStyle as L } from "@alea-design/motion";
7
- import { cx as Q } from "../../utils/cx.js";
8
- import { IconButton as N } from "../button/Button.js";
9
- import { useStrings as U } from "../../i18n/strings.js";
10
- import { surfaceAttrs as V } from "../surface/Surface.js";
11
- import { useInitialFocus as W } from "../../utils/initialFocus.js";
12
- const b = (l, e) => typeof l == "function" ? l({ close: e }) : l, ra = $(function({ children: e, trigger: r, title: d, "aria-label": g, header: m, footer: s, size: y = "md", titleSize: M = "md", placement: z = "center", scrollBehavior: t = "inside", padding: j = "normal", backdrop: w = "dim", showClose: c = !0, fullscreenBelow: n, motion: D, initialFocus: F, className: I, isDismissable: P = !0, isOpen: f, defaultOpen: u, onOpenChange: x, style: R, surface: S, radius: k, ...A }, H) {
13
- const p = U(), T = W(F), h = /* @__PURE__ */ a(q, { ...A, ...r ? {} : { isOpen: f, defaultOpen: u, onOpenChange: x }, isDismissable: P, className: "alea-modal-overlay alea-xmodal-overlay", "data-placement": z, "data-scroll": t, "data-backdrop": w, "data-fullscreen-below": n, children: /* @__PURE__ */ a(E, { ref: T, className: "alea-modal alea-xmodal", ...V({ surface: S, radius: k }), "data-size": y, "data-scroll": t, "data-fullscreen-below": n, style: L(void 0, D), children: /* @__PURE__ */ a(G, { ref: H, "aria-modal": "true", "aria-label": d ? void 0 : g, className: Q("alea-xmodal-dialog", I), style: R, "data-padding": j, children: ({ close: o }) => /* @__PURE__ */ i(X, { children: [
14
- m || d ? /* @__PURE__ */ i("div", { className: "alea-xmodal-head", children: [
15
- m ?? /* @__PURE__ */ a(J, { slot: "title", className: "alea-dialog-title", "data-size": M === "sm" ? "sm" : void 0, children: d }),
16
- c && /* @__PURE__ */ a(N, { "aria-label": p.close, size: "sm", variant: "ghost", onPress: o, className: "alea-dialog-x", children: /* @__PURE__ */ a(v, {}) })
17
- ] }) : c && /* @__PURE__ */ a(N, { "aria-label": p.close, size: "sm", variant: "ghost", onPress: o, className: "alea-xmodal-x", children: /* @__PURE__ */ a(v, {}) }),
18
- /* @__PURE__ */ a("div", { className: "alea-xmodal-body", children: b(e, o) }),
19
- s && /* @__PURE__ */ a("div", { className: "alea-xmodal-footer", children: b(s, o) })
6
+ import { withMotionStyle as Q } from "@alea-design/motion";
7
+ import { cx as U } from "../../utils/cx.js";
8
+ import { IconButton as g } from "../button/Button.js";
9
+ import { useStrings as V } from "../../i18n/strings.js";
10
+ import { surfaceAttrs as W } from "../surface/Surface.js";
11
+ import { useInitialFocus as Y } from "../../utils/initialFocus.js";
12
+ import { useModalRef as Z } from "../../utils/modalLayer.js";
13
+ const N = (l, e) => typeof l == "function" ? l({ close: e }) : l, sa = q(function({ children: e, trigger: r, title: d, "aria-label": b, header: s, footer: m, size: y = "md", titleSize: M = "md", placement: z = "center", scrollBehavior: t = "inside", padding: R = "normal", backdrop: j = "dim", showClose: c = !0, fullscreenBelow: n, motion: w, initialFocus: D, className: F, isDismissable: I = !0, isOpen: f, defaultOpen: u, onOpenChange: p, style: P, surface: S, radius: k, ...A }, H) {
14
+ const x = V(), T = Y(D), X = Z(H, !0), h = /* @__PURE__ */ a(E, { ...A, ...r ? {} : { isOpen: f, defaultOpen: u, onOpenChange: p }, isDismissable: I, className: "alea-modal-overlay alea-xmodal-overlay", "data-placement": z, "data-scroll": t, "data-backdrop": j, "data-fullscreen-below": n, children: /* @__PURE__ */ a(G, { ref: T, className: "alea-modal alea-xmodal", ...W({ surface: S, radius: k }), "data-size": y, "data-scroll": t, "data-fullscreen-below": n, style: Q(void 0, w), children: /* @__PURE__ */ a(J, { ref: X, "aria-label": d ? void 0 : b, className: U("alea-xmodal-dialog", F), style: P, "data-padding": R, children: ({ close: o }) => /* @__PURE__ */ i($, { children: [
15
+ s || d ? /* @__PURE__ */ i("div", { className: "alea-xmodal-head", children: [
16
+ s ?? /* @__PURE__ */ a(K, { slot: "title", className: "alea-dialog-title", "data-size": M === "sm" ? "sm" : void 0, children: d }),
17
+ c && /* @__PURE__ */ a(g, { "aria-label": x.close, size: "sm", variant: "ghost", onPress: o, className: "alea-dialog-x", children: /* @__PURE__ */ a(v, {}) })
18
+ ] }) : c && /* @__PURE__ */ a(g, { "aria-label": x.close, size: "sm", variant: "ghost", onPress: o, className: "alea-xmodal-x", children: /* @__PURE__ */ a(v, {}) }),
19
+ /* @__PURE__ */ a("div", { className: "alea-xmodal-body", children: N(e, o) }),
20
+ m && /* @__PURE__ */ a("div", { className: "alea-xmodal-footer", children: N(m, o) })
20
21
  ] }) }) }) });
21
- return r ? /* @__PURE__ */ i(K, { isOpen: f, defaultOpen: u, onOpenChange: x, children: [
22
+ return r ? /* @__PURE__ */ i(L, { isOpen: f, defaultOpen: u, onOpenChange: p, children: [
22
23
  r,
23
24
  h
24
25
  ] }) : h;
25
26
  });
26
27
  export {
27
- ra as Modal
28
+ sa as Modal
28
29
  };
@@ -102,7 +102,7 @@ export interface AlertDialogProps {
102
102
  backdrop?: 'blur' | 'dim';
103
103
  /** Size of the title: md (24 px display, default) or sm (16 px, semibold), for long questions or large text. */
104
104
  titleSize?: 'sm' | 'md';
105
- /** Which control has focus when it opens: confirm (default), cancel (the safe choice for a destructive action) or content (the dialog itself, so a screen reader reads the title and text first; use it when the dialog has a required field). */
105
+ /** Which control has focus when it opens: confirm, cancel (the safe choice for a destructive action) or content (the dialog itself, so a screen reader reads the title and text first; use it when the dialog has a required field). Default: cancel when tone is danger, so Enter never deletes by accident, and confirm otherwise. */
106
106
  initialFocus?: 'confirm' | 'cancel' | 'content';
107
107
  /** Extra class names for the dialog. */
108
108
  className?: string;
@@ -1,78 +1,81 @@
1
1
  "use client";
2
- import { jsx as a, jsxs as u, Fragment as h } from "react/jsx-runtime";
3
- import { forwardRef as g, useId as L } from "react";
4
- import { Dialog as T, Heading as b, ModalOverlay as O, Modal as R, Popover as S, OverlayArrow as x, Button as H, Tooltip as V, TooltipTrigger as X } from "react-aria-components";
5
- import { DialogTrigger as pa } from "react-aria-components";
6
- import { X as z } from "lucide-react";
7
- import { withMotionStyle as f } from "@alea-design/motion";
8
- import { cx as B, withBase as v } from "../../utils/cx.js";
9
- import { Button as P, IconButton as q } from "../button/Button.js";
10
- import { useStrings as N } from "../../i18n/strings.js";
11
- import { renamedValue as E } from "../../utils/vocabulary.js";
12
- import { surfaceAttrs as M } from "../surface/Surface.js";
13
- import { useInitialFocus as G } from "../../utils/initialFocus.js";
14
- const ra = g(function({ children: e, showArrow: o, className: l, offset: r = 8, motion: i, style: t, size: n, surface: c, radius: p, ...s }, m) {
15
- return /* @__PURE__ */ u(S, { ...s, ref: m, offset: o ? 12 : r, "data-size": n, ...M({ surface: c, radius: p }), className: v("alea-popover", l), style: f(t, i), children: [
16
- o && /* @__PURE__ */ a(x, { 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" }) }) }),
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" }) }) }),
17
18
  e
18
19
  ] });
19
- }), ia = g(function({ title: e, description: o, footer: l, showClose: r, children: i, className: t, ...n }, c) {
20
- const p = N();
21
- return /* @__PURE__ */ a(T, { ...n, ref: c, className: B("alea-popover-dialog", t), children: (s) => /* @__PURE__ */ u(h, { children: [
22
- (e || r) && /* @__PURE__ */ u("div", { className: "alea-popover-head", children: [
23
- e && /* @__PURE__ */ a(b, { slot: "title", className: "alea-popover-title", children: e }),
24
- r && /* @__PURE__ */ a(H, { className: "alea-popover-close alea-focus-ring", "aria-label": p.close, onPress: s.close, children: /* @__PURE__ */ a(z, { size: 16, "aria-hidden": "true" }) })
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" }) })
25
26
  ] }),
26
27
  o && /* @__PURE__ */ a("p", { className: "alea-popover-desc", children: o }),
27
- typeof i == "function" ? i(s) : i,
28
+ typeof r == "function" ? r(s) : r,
28
29
  l && /* @__PURE__ */ a("div", { className: "alea-popover-footer", children: typeof l == "function" ? l(s.close) : l })
29
30
  ] }) });
30
31
  });
31
- function ta({ children: d, title: e, shortcut: o, hideArrow: l, className: r, offset: i = 8, motion: t, style: n, ...c }) {
32
- return /* @__PURE__ */ u(V, { ...c, offset: i, className: v("alea-tooltip", r), "data-rich": e ? !0 : void 0, style: f(n, t), children: [
33
- !l && /* @__PURE__ */ a(x, { 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" }) }) }),
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" }) }) }),
34
35
  e && /* @__PURE__ */ a("span", { className: "alea-tooltip-title", children: e }),
35
- /* @__PURE__ */ u("span", { className: "alea-tooltip-text", children: [
36
+ /* @__PURE__ */ p("span", { className: "alea-tooltip-text", children: [
36
37
  d,
37
38
  o && /* @__PURE__ */ a("kbd", { className: "alea-tooltip-kbd", children: o })
38
39
  ] })
39
40
  ] });
40
41
  }
41
- function sa({ delay: d = 600, closeDelay: e = 200, ...o }) {
42
- return /* @__PURE__ */ a(X, { ...o, delay: d, closeDelay: e });
42
+ function pa({ delay: d = 600, closeDelay: e = 200, ...o }) {
43
+ return /* @__PURE__ */ a(q, { ...o, delay: d, closeDelay: e });
43
44
  }
44
- const J = g(function({ title: e, description: o, children: l, footer: r, hideClose: i, titleSize: t = "md", className: n, ...c }, p) {
45
- const s = N();
46
- return /* @__PURE__ */ a(T, { ...c, ref: p, className: B("alea-dialog", n), children: ({ close: m }) => /* @__PURE__ */ u(h, { children: [
47
- (e || !i) && /* @__PURE__ */ u("div", { className: "alea-dialog-head", children: [
48
- e && /* @__PURE__ */ a(b, { slot: "title", className: "alea-dialog-title", "data-size": t === "sm" ? "sm" : void 0, children: e }),
49
- !i && /* @__PURE__ */ a(q, { "aria-label": s.close, size: "sm", variant: "ghost", onPress: m, className: "alea-dialog-x", children: /* @__PURE__ */ a(z, {}) })
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, {}) })
50
51
  ] }),
51
52
  o && /* @__PURE__ */ a("p", { className: "alea-dialog-description", children: o }),
52
- l && /* @__PURE__ */ a("div", { className: "alea-dialog-body", children: typeof l == "function" ? l({ close: m }) : l }),
53
- r && /* @__PURE__ */ a("div", { className: "alea-dialog-footer", children: typeof r == "function" ? r({ close: m }) : r })
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 })
54
55
  ] }) });
55
56
  });
56
- function K({ children: d, size: e = "md", fullscreenBelow: o, className: l, isDismissable: r = !0, motion: i, backdrop: t, initialFocus: n, surface: c, radius: p, ...s }) {
57
- const m = G(n);
58
- return /* @__PURE__ */ a(O, { ...s, isDismissable: r, className: v("alea-modal-overlay", l), "data-backdrop": t, "data-fullscreen-below": o, children: /* @__PURE__ */ a(R, { ref: m, className: "alea-modal", "data-size": e, "data-fullscreen-below": o, ...M({ surface: c, radius: p }), style: f(void 0, i), children: d }) });
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 }) }) });
59
60
  }
60
- const na = g(function({ motion: e, backdrop: o, initialFocus: l = "confirm", titleSize: r, title: i, children: t, confirmLabel: n, cancelLabel: c, tone: p, onConfirm: s, isOpen: m, defaultOpen: $, onOpenChange: A, className: I, style: k }, F) {
61
- const y = L(), j = E("AlertDialog", "tone", p, { default: "neutral" }) ?? "neutral", D = N();
62
- return n ?? (n = D.confirm), c ?? (c = D.cancel), /* @__PURE__ */ a(K, { isOpen: m, defaultOpen: $, onOpenChange: A, isDismissable: !1, size: "sm", motion: e, backdrop: o, children: /* @__PURE__ */ a(J, { ref: F, className: I, style: k, role: "alertdialog", "aria-describedby": t ? y : void 0, title: i, titleSize: r, hideClose: !0, footer: ({ close: w }) => /* @__PURE__ */ u(h, { children: [
63
- /* @__PURE__ */ a(P, { variant: "ghost", autoFocus: l === "cancel", onPress: w, children: c }),
64
- /* @__PURE__ */ a(P, { variant: j === "danger" ? "danger" : "primary", autoFocus: l === "confirm", onPress: async () => {
65
- await (s == null ? void 0 : s()), w();
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();
66
69
  }, children: n })
67
- ] }), children: t ? /* @__PURE__ */ a("div", { id: y, style: { display: "contents" }, children: t }) : null }) });
70
+ ] }), children: t ? /* @__PURE__ */ a("div", { id: D, style: { display: "contents" }, children: t }) : null }) });
68
71
  });
69
72
  export {
70
- na as AlertDialog,
71
- J as Dialog,
72
- K as DialogModal,
73
- pa as DialogTrigger,
74
- ra as Popover,
75
- ia as PopoverDialog,
76
- ta as Tooltip,
77
- sa as TooltipTrigger
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
78
81
  };
@@ -26,11 +26,13 @@ export interface AppShellProps {
26
26
  };
27
27
  /** A bar along the bottom of the screen, usually a BottomNavigation on phones (render it only where it applies). It sticks to the bottom edge and takes its own space under the content, so the end of the page is never hidden behind it, at any text size. A fixed BottomNavigation is laid out in flow here; no extra spacing is needed. */
28
28
  bottomBar?: ReactNode;
29
+ /** Where focus goes after a link in the mobile menu is chosen. heading (default): to the first h1 of the page (or the page itself when it has none), so a screen reader starts on the new screen and a keyboard user does not land back on the menu button. restore: back to the button that opened the menu. */
30
+ focusAfterNavigate?: 'heading' | 'restore';
29
31
  /** Extra class names for the root element. */
30
32
  className?: string;
31
33
  }
32
34
  /** The app frame: sticky header, sidebar, scrollable content and a skip link. */
33
- export declare function AppShell({ brand, headerEnd, sidebar, children, sidebarWidth, collapseBelow, mainAs, layout, contentSize, skipLink, bottomBar, className }: AppShellProps): import("react").JSX.Element;
35
+ export declare function AppShell({ brand, headerEnd, sidebar, children, sidebarWidth, collapseBelow, mainAs, layout, contentSize, skipLink, bottomBar, focusAfterNavigate, className }: AppShellProps): import("react").JSX.Element;
34
36
  export interface SidebarNavProps {
35
37
  children: ReactNode;
36
38
  /** Name of the navigation. Default "Sidebar". */