@alea-design/ui 0.6.0 → 0.7.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.
Files changed (51) hide show
  1. package/dist/components/button/Button.d.ts +3 -1
  2. package/dist/components/button/Button.js +58 -57
  3. package/dist/components/button/Groups.js +41 -41
  4. package/dist/components/command/CommandPalette.js +63 -61
  5. package/dist/components/data/Data.d.ts +10 -6
  6. package/dist/components/data/Data.js +53 -53
  7. package/dist/components/date/Date.d.ts +3 -1
  8. package/dist/components/date/Date.js +74 -74
  9. package/dist/components/form/Form.d.ts +3 -1
  10. package/dist/components/form/Form.js +44 -52
  11. package/dist/components/form/validity.d.ts +22 -0
  12. package/dist/components/form/validity.js +38 -0
  13. package/dist/components/list/List.d.ts +3 -2
  14. package/dist/components/media/Media.d.ts +5 -1
  15. package/dist/components/media/Media.js +113 -111
  16. package/dist/components/navigation/Navigation.d.ts +11 -7
  17. package/dist/components/navigation/Navigation.js +97 -97
  18. package/dist/components/navigation/Navigation2.d.ts +4 -2
  19. package/dist/components/navigation/Navigation2.js +219 -211
  20. package/dist/components/overlay/Overlay.d.ts +4 -0
  21. package/dist/components/overlay/Overlay.js +52 -52
  22. package/dist/components/page/PageParts.d.ts +8 -2
  23. package/dist/components/page/PageParts.js +95 -87
  24. package/dist/components/shell/AppShell.d.ts +3 -1
  25. package/dist/components/shell/AppShell.js +33 -32
  26. package/dist/components/table/Table.d.ts +6 -3
  27. package/dist/components/table/Table.js +45 -45
  28. package/dist/components/theme/Theme.d.ts +5 -1
  29. package/dist/components/theme/Theme.js +63 -63
  30. package/dist/css/base.css +1 -1
  31. package/dist/css/button.css +1 -1
  32. package/dist/css/data.css +1 -1
  33. package/dist/css/date.css +1 -1
  34. package/dist/css/feedback.css +1 -1
  35. package/dist/css/groups.json +11 -11
  36. package/dist/css/more.css +1 -1
  37. package/dist/css/navigation.css +1 -1
  38. package/dist/css/page.css +1 -1
  39. package/dist/css/shell.css +1 -1
  40. package/dist/css/table.css +1 -1
  41. package/dist/css/typography.css +1 -1
  42. package/dist/i18n/strings.d.ts +4 -1
  43. package/dist/i18n/strings.js +8 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +279 -275
  46. package/dist/styles.css +1 -1
  47. package/dist/utils/animateRows.d.ts +3 -2
  48. package/dist/utils/animateRows.js +15 -15
  49. package/dist/utils/measure.d.ts +12 -0
  50. package/dist/utils/measure.js +20 -0
  51. package/package.json +3 -3
@@ -74,11 +74,13 @@ export interface SegmentedControlProps extends Omit<ToggleButtonGroupProps, 'sel
74
74
  onChange?: (value: Key) => void;
75
75
  /** sm (28 px) or md (34 px, default). */
76
76
  size?: 'sm' | 'md';
77
+ /** Lets the options flow onto more lines when they do not fit (a preference switch with long words, large text), instead of scrolling sideways inside the control. */
78
+ wrap?: boolean;
77
79
  /** Label for screen readers. */
78
80
  'aria-label'?: string;
79
81
  }
80
82
  /** One choice among a few, as a row of pills. */
81
- export declare function SegmentedControl({ items, value, defaultValue, onChange, size, className, ...props }: SegmentedControlProps): import("react").JSX.Element;
83
+ export declare function SegmentedControl({ items, value, defaultValue, onChange, size, wrap, className, ...props }: SegmentedControlProps): import("react").JSX.Element;
82
84
  export interface ToggleButtonProps extends RACToggleButtonProps {
83
85
  /** sm (32 px) or md (40 px, default). */
84
86
  size?: 'sm' | 'md';
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as p, Fragment as Y } from "react/jsx-runtime";
2
+ import { jsx as e, jsxs as h, Fragment as Y } from "react/jsx-runtime";
3
3
  import { forwardRef as G, useRef as A, useEffect as I, useState as _ } from "react";
4
4
  import { useRipple as C } from "@alea-design/motion";
5
5
  import { Link as V, Button as ee, composeRenderProps as te, ToggleButtonGroup as ne, ToggleButton as W, SelectionIndicator as ae } from "react-aria-components";
@@ -10,50 +10,50 @@ import { useStrings as q } from "../../i18n/strings.js";
10
10
  import { responsiveAttrs as X } from "../../utils/responsive.js";
11
11
  import { TooltipTrigger as re, Tooltip as le } from "../overlay/Overlay.js";
12
12
  import { buttonIcon as M } from "../icon/icon-contexts.js";
13
- const J = G(function({ variant: a = "primary", tone: n, size: c, shape: u, iconStart: d, iconEnd: i, isLoading: o, loadingLabel: r, loadingPosition: m = "center", fullWidth: N, justify: v, wrap: g, shortcut: f, href: y, target: L, rel: O, isSuccess: R, successLabel: B, ripple: k, className: j, children: x, ...S }, Q) {
13
+ const J = G(function({ variant: o = "primary", tone: a, size: d, shape: m, iconStart: c, iconEnd: l, isLoading: u, loadingLabel: t, loadingPosition: i = "center", fullWidth: N, justify: v, wrap: g, shortcut: f, href: y, target: L, rel: O, isSuccess: R, successLabel: B, ripple: k, className: j, children: x, ...S }, Q) {
14
14
  const T = q();
15
15
  B ?? (B = T.done);
16
16
  const E = A(null), D = oe(Q, E), { onPointerDown: $ } = C();
17
17
  I(() => {
18
- const t = E.current;
19
- if (!k || !t) return;
20
- const s = (w) => $({ currentTarget: t, clientX: w.clientX, clientY: w.clientY });
21
- return t.addEventListener("pointerdown", s), () => t.removeEventListener("pointerdown", s);
18
+ const n = E.current;
19
+ if (!k || !n) return;
20
+ const s = (w) => $({ currentTarget: n, clientX: w.clientX, clientY: w.clientY });
21
+ return n.addEventListener("pointerdown", s), () => n.removeEventListener("pointerdown", s);
22
22
  }, [k, $]);
23
- const h = o && (r != null || m !== "center"), H = /* @__PURE__ */ e("span", { className: "alea-button-icon alea-button-inline-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }), F = (t, s) => /* @__PURE__ */ p(Y, { children: [
24
- s && !h && /* @__PURE__ */ e("span", { className: "alea-button-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }),
25
- R && !s ? /* @__PURE__ */ p("span", { className: "alea-button-content alea-success-in", "aria-live": "polite", children: [
23
+ const p = u && (t != null || i !== "center"), H = /* @__PURE__ */ e("span", { className: "alea-button-icon alea-button-inline-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }), F = (n, s) => /* @__PURE__ */ h(Y, { children: [
24
+ s && !p && /* @__PURE__ */ e("span", { className: "alea-button-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }),
25
+ R && !s ? /* @__PURE__ */ h("span", { className: "alea-button-content alea-success-in", "aria-live": "polite", children: [
26
26
  /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", children: /* @__PURE__ */ e("svg", { className: "alea-success-check", viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("path", { d: "M5 12.5l4.5 4.5L19 7.5" }) }) }),
27
27
  B != null && B !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: B })
28
- ] }) : /* @__PURE__ */ p("span", { className: "alea-button-content", "data-hidden": s && !h || void 0, children: [
29
- h && m !== "end" ? H : d && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(a, n), children: d }),
30
- (h && r != null ? r : t) != null && t !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: h && r != null ? r : t }),
31
- h && m === "end" ? H : i && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(a, n), children: i }),
28
+ ] }) : /* @__PURE__ */ h("span", { className: "alea-button-content", "data-hidden": s && !p || void 0, children: [
29
+ p && i !== "end" ? H : c && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(o, a), children: c }),
30
+ (p && t != null ? t : n) != null && n !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: p && t != null ? t : n }),
31
+ p && i === "end" ? H : l && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(o, a), children: l }),
32
32
  f && /* @__PURE__ */ e("kbd", { className: "alea-button-kbd", "aria-hidden": "true", children: f })
33
33
  ] })
34
34
  ] }), K = {
35
35
  "data-success": R || void 0,
36
36
  "data-ripple": k || void 0,
37
- "data-variant": a,
38
- "data-tone": n,
39
- ...X("size", c, "md"),
37
+ "data-variant": o,
38
+ "data-tone": a,
39
+ ...X("size", d, "md"),
40
40
  ...X("full-width", N),
41
- "data-shape": u,
41
+ "data-shape": m,
42
42
  "data-justify": v,
43
43
  "data-wrap": g || void 0
44
44
  }, z = typeof f == "string" ? f.replace("⌘", "Meta+").replace("⇧", "Shift+").replace("⌥", "Alt+").replace("⌃", "Control+") : void 0;
45
45
  if (I(() => {
46
- const t = E.current;
47
- t && (z ? t.setAttribute("aria-keyshortcuts", z) : t.removeAttribute("aria-keyshortcuts"));
46
+ const n = E.current;
47
+ n && (z ? n.setAttribute("aria-keyshortcuts", z) : n.removeAttribute("aria-keyshortcuts"));
48
48
  }, [z]), y) {
49
- const { onPress: t, isDisabled: s, autoFocus: w, id: U, style: Z } = S;
49
+ const { onPress: n, isDisabled: s, autoFocus: w, id: U, style: Z } = S;
50
50
  return /* @__PURE__ */ e(
51
51
  V,
52
52
  {
53
53
  href: y,
54
54
  target: L,
55
55
  rel: O,
56
- onPress: t,
56
+ onPress: n,
57
57
  isDisabled: s,
58
58
  autoFocus: w,
59
59
  id: U,
@@ -66,67 +66,68 @@ const J = G(function({ variant: a = "primary", tone: n, size: c, shape: u, iconS
66
66
  }
67
67
  );
68
68
  }
69
- return /* @__PURE__ */ e(ee, { ...S, ...K, ref: D, isPending: o, className: b("alea-button alea-focus-ring", j), children: te(x, (t, { isPending: s }) => F(t, s)) });
70
- }), Ne = G(function({ shape: a = "circle", variant: n = "ghost", tooltip: c, children: u, className: d, ...i }, o) {
71
- const r = /* @__PURE__ */ e(J, { ...i, ref: o, variant: n, "data-icon-shape": a, "data-icon-only": !0, className: b("alea-icon-button", d), children: /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(n, i.tone), children: u }) });
72
- return c ? /* @__PURE__ */ p(re, { delay: 400, children: [
73
- r,
74
- /* @__PURE__ */ e(le, { children: i["aria-label"] })
75
- ] }) : r;
69
+ return /* @__PURE__ */ e(ee, { ...S, ...K, ref: D, isPending: u, className: b("alea-button alea-focus-ring", j), children: te(x, (n, { isPending: s }) => F(n, s)) });
70
+ }), Ne = G(function({ shape: o = "circle", variant: a = "ghost", tooltip: d, children: m, className: c, ...l }, u) {
71
+ const t = /* @__PURE__ */ e(J, { ...l, ref: u, variant: a, "data-icon-shape": o, "data-icon-only": !0, className: b("alea-icon-button", c), children: /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...M(a, l.tone), children: m }) });
72
+ return d ? /* @__PURE__ */ h(re, { delay: 400, children: [
73
+ t,
74
+ /* @__PURE__ */ e(le, { children: l["aria-label"] })
75
+ ] }) : t;
76
76
  });
77
- function ve({ items: l, value: a, defaultValue: n, onChange: c, size: u = "md", className: d, ...i }) {
77
+ function ve({ items: r, value: o, defaultValue: a, onChange: d, size: m = "md", wrap: c, className: l, ...u }) {
78
78
  return /* @__PURE__ */ e(
79
79
  ne,
80
80
  {
81
- ...i,
81
+ ...u,
82
82
  selectionMode: "single",
83
83
  disallowEmptySelection: !0,
84
- selectedKeys: a !== void 0 ? [a] : void 0,
85
- defaultSelectedKeys: n !== void 0 ? [n] : a === void 0 && l[0] ? [l[0].id] : void 0,
86
- onSelectionChange: (o) => {
87
- const r = [...o][0];
88
- r !== void 0 && (c == null || c(r));
84
+ selectedKeys: o !== void 0 ? [o] : void 0,
85
+ defaultSelectedKeys: a !== void 0 ? [a] : o === void 0 && r[0] ? [r[0].id] : void 0,
86
+ onSelectionChange: (t) => {
87
+ const i = [...t][0];
88
+ i !== void 0 && (d == null || d(i));
89
89
  },
90
- "data-size": u,
91
- className: b("alea-segmented", d),
92
- children: l.map((o) => /* @__PURE__ */ p(W, { id: o.id, isDisabled: o.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
93
- /* @__PURE__ */ e("span", { className: "alea-segmented-label", children: o.label }),
90
+ "data-size": m,
91
+ "data-wrap": c || void 0,
92
+ className: b("alea-segmented", l),
93
+ children: r.map((t) => /* @__PURE__ */ h(W, { id: t.id, isDisabled: t.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
94
+ /* @__PURE__ */ e("span", { className: "alea-segmented-label", children: t.label }),
94
95
  /* @__PURE__ */ e(ae, { className: "alea-sel-indicator" })
95
- ] }, String(o.id)))
96
+ ] }, String(t.id)))
96
97
  }
97
98
  );
98
99
  }
99
- function ye({ size: l = "md", className: a, ...n }) {
100
- return /* @__PURE__ */ e(W, { ...n, "data-size": l, className: b("alea-toggle-button alea-focus-ring", a) });
100
+ function ye({ size: r = "md", className: o, ...a }) {
101
+ return /* @__PURE__ */ e(W, { ...a, "data-size": r, className: b("alea-toggle-button alea-focus-ring", o) });
101
102
  }
102
- function Be({ onConfirm: l, duration: a = 1200, hint: n, variant: c = "danger", className: u, children: d, ...i }) {
103
- const o = q();
104
- n ?? (n = o.pressAndHold);
105
- const [r, m] = _(!1), N = A(null), v = A(`alea-hold-${Math.random().toString(36).slice(2, 8)}`).current;
103
+ function Be({ onConfirm: r, duration: o = 1200, hint: a, variant: d = "danger", className: m, children: c, ...l }) {
104
+ const u = q();
105
+ a ?? (a = u.pressAndHold);
106
+ const [t, i] = _(!1), N = A(null), v = A(`alea-hold-${Math.random().toString(36).slice(2, 8)}`).current;
106
107
  return I(() => {
107
108
  const g = N.current;
108
109
  if (!g) return;
109
110
  const f = (y) => {
110
- y.animationName === "alea-hold" && (m(!1), l());
111
+ y.animationName === "alea-hold" && (i(!1), r());
111
112
  };
112
113
  return g.addEventListener("animationend", f), () => g.removeEventListener("animationend", f);
113
- }, [l]), /* @__PURE__ */ p(Y, { children: [
114
+ }, [r]), /* @__PURE__ */ h(Y, { children: [
114
115
  /* @__PURE__ */ e(
115
116
  J,
116
117
  {
117
- ...i,
118
+ ...l,
118
119
  ref: N,
119
- variant: c,
120
- "data-holding": r || void 0,
120
+ variant: d,
121
+ "data-holding": t || void 0,
121
122
  "aria-describedby": v,
122
- onPressStart: () => m(!0),
123
- onPressEnd: () => m(!1),
124
- className: b("alea-hold", u),
125
- style: { "--alea-hold-duration": `${a}ms` },
126
- children: d
123
+ onPressStart: () => i(!0),
124
+ onPressEnd: () => i(!1),
125
+ className: b("alea-hold", m),
126
+ style: { "--alea-hold-duration": `${o}ms` },
127
+ children: c
127
128
  }
128
129
  ),
129
- /* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children: n })
130
+ /* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children: a })
130
131
  ] });
131
132
  }
132
133
  export {
@@ -1,26 +1,26 @@
1
1
  "use client";
2
2
  import { jsx as r, jsxs as S } from "react/jsx-runtime";
3
- import { useState as P, useRef as F, useLayoutEffect as I, useEffect as K, Fragment as O } from "react";
3
+ import { useState as P, useRef as F, Fragment as K } from "react";
4
+ import { useIsoLayoutEffect as O } from "../../utils/measure.js";
4
5
  import { Group as R, ToggleButtonGroup as j, Toolbar as z, ToggleButton as k, SelectionIndicator as q } from "react-aria-components";
5
- import { ChevronDown as W, MoreHorizontal as H } from "lucide-react";
6
+ import { ChevronDown as W, MoreHorizontal as E } from "lucide-react";
6
7
  import { cx as N, withBase as x } from "../../utils/cx.js";
7
8
  import { Button as w, IconButton as D } from "./Button.js";
8
9
  import { DropdownMenu as A, MenuItem as G } from "../menu/Menu.js";
9
- import { useStrings as M } from "../../i18n/strings.js";
10
- import { inertProps as $ } from "../../utils/inert.js";
11
- const J = typeof document < "u" ? I : K;
12
- function L({ children: i, attached: l = !0, orientation: n = "horizontal", className: s, "aria-label": t }) {
13
- return /* @__PURE__ */ r(R, { "aria-label": t, className: N("alea-btn-group", s), "data-attached": l || void 0, "data-orientation": n, children: i });
10
+ import { useStrings as I } from "../../i18n/strings.js";
11
+ import { inertProps as H } from "../../utils/inert.js";
12
+ function $({ children: n, attached: l = !0, orientation: i = "horizontal", className: s, "aria-label": t }) {
13
+ return /* @__PURE__ */ r(R, { "aria-label": t, className: N("alea-btn-group", s), "data-attached": l || void 0, "data-orientation": i, children: n });
14
14
  }
15
- function ae({ children: i, actions: l, onAction: n, menuLabel: s, variant: t = "primary", size: d = "md", className: u, ...m }) {
16
- const f = M();
17
- return s ?? (s = f.moreOptions), /* @__PURE__ */ S(L, { className: N("alea-split-btn", u), children: [
18
- /* @__PURE__ */ r(w, { variant: t, size: d, ...m, children: i }),
19
- /* @__PURE__ */ r(A, { trigger: /* @__PURE__ */ r(D, { variant: t, size: d, shape: "square", "aria-label": s, isDisabled: m.isDisabled, children: /* @__PURE__ */ r(W, {}) }), placement: "bottom end", menuProps: { onAction: (c) => n == null ? void 0 : n(c) }, "aria-label": s, children: l.map((c) => /* @__PURE__ */ r(G, { id: c.id, icon: c.icon, description: c.description, children: c.label }, String(c.id))) })
15
+ function ee({ children: n, actions: l, onAction: i, menuLabel: s, variant: t = "primary", size: d = "md", className: u, ...m }) {
16
+ const f = I();
17
+ return s ?? (s = f.moreOptions), /* @__PURE__ */ S($, { className: N("alea-split-btn", u), children: [
18
+ /* @__PURE__ */ r(w, { variant: t, size: d, ...m, children: n }),
19
+ /* @__PURE__ */ r(A, { trigger: /* @__PURE__ */ r(D, { variant: t, size: d, shape: "square", "aria-label": s, isDisabled: m.isDisabled, children: /* @__PURE__ */ r(W, {}) }), placement: "bottom end", menuProps: { onAction: (c) => i == null ? void 0 : i(c) }, "aria-label": s, children: l.map((c) => /* @__PURE__ */ r(G, { id: c.id, icon: c.icon, description: c.description, children: c.label }, String(c.id))) })
20
20
  ] });
21
21
  }
22
- function re({ items: i, selectionMode: l = "single", value: n, defaultValue: s, onChange: t, iconOnly: d, size: u = "md", className: m, "aria-label": f }) {
23
- const [c, v] = P(s ?? []), p = n ?? c, e = (a, o) => /* @__PURE__ */ S(k, { id: a.id, isDisabled: a.isDisabled, "aria-label": d ? a.label : void 0, className: "alea-toggle-item alea-focus-ring", "data-icon-only": d || void 0, ...o, children: [
22
+ function ae({ items: n, selectionMode: l = "single", value: i, defaultValue: s, onChange: t, iconOnly: d, size: u = "md", className: m, "aria-label": f }) {
23
+ const [c, v] = P(s ?? []), p = i ?? c, e = (a, o) => /* @__PURE__ */ S(k, { id: a.id, isDisabled: a.isDisabled, "aria-label": d ? a.label : void 0, className: "alea-toggle-item alea-focus-ring", "data-icon-only": d || void 0, ...o, children: [
24
24
  a.icon && /* @__PURE__ */ r("span", { className: "alea-toggle-icon", "aria-hidden": "true", children: a.icon }),
25
25
  !d && /* @__PURE__ */ r("span", { className: "alea-toggle-label", children: a.label }),
26
26
  !o && /* @__PURE__ */ r(q, { className: "alea-sel-indicator" })
@@ -28,65 +28,65 @@ function re({ items: i, selectionMode: l = "single", value: n, defaultValue: s,
28
28
  if (l === "multiple") {
29
29
  const a = (o, b) => {
30
30
  const g = b ? [...p, o] : p.filter((B) => B !== o);
31
- n === void 0 && v(g), t == null || t(g);
31
+ i === void 0 && v(g), t == null || t(g);
32
32
  };
33
- return /* @__PURE__ */ r("div", { role: "group", "aria-label": f, className: N("alea-toggle-group", m), "data-size": u, "data-multiple": !0, children: i.map((o) => e(o, { isSelected: p.includes(o.id), onChange: (b) => a(o.id, b) })) });
33
+ return /* @__PURE__ */ r("div", { role: "group", "aria-label": f, className: N("alea-toggle-group", m), "data-size": u, "data-multiple": !0, children: n.map((o) => e(o, { isSelected: p.includes(o.id), onChange: (b) => a(o.id, b) })) });
34
34
  }
35
35
  return /* @__PURE__ */ r(
36
36
  j,
37
37
  {
38
38
  "aria-label": f,
39
39
  selectionMode: "single",
40
- selectedKeys: n,
40
+ selectedKeys: i,
41
41
  defaultSelectedKeys: s,
42
- onSelectionChange: (a) => t == null ? void 0 : t(a === "all" ? i.map((o) => o.id) : [...a]),
42
+ onSelectionChange: (a) => t == null ? void 0 : t(a === "all" ? n.map((o) => o.id) : [...a]),
43
43
  className: x("alea-toggle-group", m),
44
44
  "data-size": u,
45
- children: i.map((a) => e(a))
45
+ children: n.map((a) => e(a))
46
46
  }
47
47
  );
48
48
  }
49
- function oe({ className: i, items: l, itemStyle: n = "icon", children: s, ...t }) {
50
- const d = M(), u = F(null), [m, f] = P((l == null ? void 0 : l.length) ?? 0);
51
- if (J(() => {
49
+ function re({ className: n, items: l, itemStyle: i = "icon", children: s, ...t }) {
50
+ const d = I(), u = F(null), [m, f] = P((l == null ? void 0 : l.length) ?? 0);
51
+ if (O(() => {
52
52
  const e = u.current;
53
53
  if (!l || !e) return;
54
54
  const a = () => {
55
55
  const b = e.querySelector(".alea-toolbar-probe");
56
56
  if (!b) return;
57
57
  const g = Array.from(b.children).map((h) => h.getBoundingClientRect().width + 4);
58
- if (g.reduce((h, E) => h + E, 0) <= e.clientWidth) {
58
+ if (g.reduce((h, M) => h + M, 0) <= e.clientWidth) {
59
59
  f(g.length);
60
60
  return;
61
61
  }
62
- let y = 0, T = 0;
62
+ let T = 0, y = 0;
63
63
  for (const h of g) {
64
- if (y + h > e.clientWidth - 44) break;
65
- y += h, T++;
64
+ if (T + h > e.clientWidth - 44) break;
65
+ T += h, y++;
66
66
  }
67
- f(T);
67
+ f(y);
68
68
  };
69
69
  a();
70
70
  const o = new ResizeObserver(a);
71
71
  return o.observe(e), () => o.disconnect();
72
- }, [l]), !l) return /* @__PURE__ */ r(z, { ...t, className: x("alea-toolbar", i), children: s });
72
+ }, [l]), !l) return /* @__PURE__ */ r(z, { ...t, className: x("alea-toolbar", n), children: s });
73
73
  const c = (e, a = !1) => {
74
- const o = n === "label" ? /* @__PURE__ */ r(w, { size: "sm", variant: e.isSelected ? "soft" : "text", iconStart: e.icon, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.label }, String(e.id)) : /* @__PURE__ */ r(D, { size: "sm", variant: e.isSelected ? "soft" : "text", "aria-label": e.label, tooltip: !a, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.icon }, String(e.id));
75
- return e.separatorBefore ? /* @__PURE__ */ S(O, { children: [
74
+ const o = i === "label" ? /* @__PURE__ */ r(w, { size: "sm", variant: e.isSelected ? "soft" : "text", iconStart: e.icon, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.label }, String(e.id)) : /* @__PURE__ */ r(D, { size: "sm", variant: e.isSelected ? "soft" : "text", "aria-label": e.label, tooltip: !a, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.icon }, String(e.id));
75
+ return e.separatorBefore ? /* @__PURE__ */ S(K, { children: [
76
76
  /* @__PURE__ */ r("span", { className: "alea-toolbar-sep", "aria-hidden": "true" }),
77
77
  o
78
78
  ] }, String(e.id)) : o;
79
79
  }, v = l.slice(0, m), p = l.slice(m);
80
80
  return /* @__PURE__ */ S("div", { ref: u, className: "alea-toolbar-fit", children: [
81
- /* @__PURE__ */ r("div", { className: "alea-toolbar-probe", "aria-hidden": "true", ...$(!0), children: l.map((e) => c(e, !0)) }),
82
- /* @__PURE__ */ S(z, { ...t, className: x("alea-toolbar", i), children: [
81
+ /* @__PURE__ */ r("div", { className: "alea-toolbar-probe", "aria-hidden": "true", ...H(!0), children: l.map((e) => c(e, !0)) }),
82
+ /* @__PURE__ */ S(z, { ...t, className: x("alea-toolbar", n), children: [
83
83
  v.map((e) => c(e)),
84
84
  p.length > 0 && /* @__PURE__ */ r(
85
85
  A,
86
86
  {
87
87
  "aria-label": d.moreActions,
88
88
  placement: "bottom end",
89
- trigger: /* @__PURE__ */ r(D, { size: "sm", variant: "text", "aria-label": d.moreActions, children: /* @__PURE__ */ r(H, {}) }),
89
+ trigger: /* @__PURE__ */ r(D, { size: "sm", variant: "text", "aria-label": d.moreActions, children: /* @__PURE__ */ r(E, {}) }),
90
90
  menuProps: { onAction: (e) => {
91
91
  var a, o;
92
92
  return (o = (a = p.find((b) => b.id === e)) == null ? void 0 : a.onAction) == null ? void 0 : o.call(a);
@@ -97,16 +97,16 @@ function oe({ className: i, items: l, itemStyle: n = "icon", children: s, ...t }
97
97
  ] })
98
98
  ] });
99
99
  }
100
- function le({ children: i, description: l, icon: n, className: s, size: t = "lg", variant: d = "ghost", ...u }) {
101
- return /* @__PURE__ */ r(w, { ...u, size: t, variant: d, className: N("alea-compound-button", s), iconStart: n, children: /* @__PURE__ */ S("span", { className: "alea-compound-text", children: [
102
- /* @__PURE__ */ r("span", { className: "alea-compound-title", children: i }),
100
+ function oe({ children: n, description: l, icon: i, className: s, size: t = "lg", variant: d = "ghost", ...u }) {
101
+ return /* @__PURE__ */ r(w, { ...u, size: t, variant: d, className: N("alea-compound-button", s), iconStart: i, children: /* @__PURE__ */ S("span", { className: "alea-compound-text", children: [
102
+ /* @__PURE__ */ r("span", { className: "alea-compound-title", children: n }),
103
103
  l && /* @__PURE__ */ r("span", { className: "alea-compound-desc", children: l })
104
104
  ] }) });
105
105
  }
106
106
  export {
107
- L as ButtonGroup,
108
- le as CompoundButton,
109
- ae as SplitButton,
110
- re as ToggleGroup,
111
- oe as Toolbar
107
+ $ as ButtonGroup,
108
+ oe as CompoundButton,
109
+ ee as SplitButton,
110
+ ae as ToggleGroup,
111
+ re as Toolbar
112
112
  };
@@ -1,91 +1,93 @@
1
1
  "use client";
2
2
  import { jsx as n, jsxs as m } from "react/jsx-runtime";
3
- import { forwardRef as $, useState as N, useEffect as C, useMemo as j, useRef as q } from "react";
4
- import { cx as B } from "../../utils/cx.js";
5
- import { useFilter as J, Autocomplete as P, SearchField as Y, Input as Z, Menu as Q, MenuSection as G, Header as ee, Collection as te, MenuItem as z, Keyboard as ne } from "react-aria-components";
6
- import { Search as se } from "lucide-react";
7
- import { DialogModal as ie, Dialog as ae } from "../overlay/Overlay.js";
8
- import { Kbd as oe } from "../typography/Typography.js";
9
- import { useStrings as le } from "../../i18n/strings.js";
10
- const E = "__more:";
11
- function re({ children: g }) {
12
- const o = q(null), [u, w] = N(!1);
13
- return C(() => {
14
- const i = o.current;
15
- if (!i) return;
16
- const f = () => w(i.scrollHeight > i.clientHeight + 1);
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";
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
17
  if (f(), typeof ResizeObserver > "u") return;
18
- const r = new ResizeObserver(f);
19
- return r.observe(i), i.firstElementChild && r.observe(i.firstElementChild), () => r.disconnect();
20
- }, []), /* @__PURE__ */ n("div", { ref: o, className: "alea-command-scroll", tabIndex: u ? 0 : void 0, children: g });
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 });
21
21
  }
22
- const we = $(function({ commands: o, isOpen: u, defaultOpen: w, onOpenChange: i, motion: f, hotkey: r = !0, slashHotkey: M, onQueryChange: b, filter: h, isLoading: p, maxPerGroup: c, placeholder: K, emptyText: R, className: D, style: F, surface: T, radius: V }, H) {
23
- const a = le();
24
- K ?? (K = a.commandPlaceholder), R ?? (R = a.noResults);
25
- const [L, O] = N(w ?? !1), v = u ?? L, [d, _] = N(""), [I, k] = N(/* @__PURE__ */ new Set()), x = (s) => {
26
- _(s), b == null || b(s);
27
- }, S = (s) => {
28
- s || (d && x(""), k(/* @__PURE__ */ new Set())), u === void 0 && O(s), i == null || i(s);
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) {
23
+ 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);
29
29
  };
30
- C(() => {
31
- if (!r && !M) return;
32
- const s = (t) => {
33
- if (r && t.key.toLowerCase() === "k" && (t.metaKey || t.ctrlKey)) {
34
- t.preventDefault(), S(!v);
30
+ D(() => {
31
+ if (!c && !R) return;
32
+ const i = (t) => {
33
+ if (c && t.key.toLowerCase() === "k" && (t.metaKey || t.ctrlKey)) {
34
+ t.preventDefault(), S(!g);
35
35
  return;
36
36
  }
37
- if (M && !v && t.key === "/" && !t.metaKey && !t.ctrlKey && !t.altKey) {
37
+ if (R && !g && t.key === "/" && !t.metaKey && !t.ctrlKey && !t.altKey) {
38
38
  const e = t.target;
39
39
  if (e && (e.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))) return;
40
40
  t.preventDefault(), S(!0);
41
41
  }
42
42
  };
43
- return window.addEventListener("keydown", s), () => window.removeEventListener("keydown", s);
43
+ return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
44
44
  });
45
- const { contains: U } = J({ sensitivity: "base" }), A = j(() => {
46
- const s = (e) => h === !1 || !d ? !0 : h ? h(e, d) : U([e.label, ...e.keywords || []].join(" "), d), t = [];
47
- for (const e of o) {
48
- if (!s(e)) continue;
49
- const l = e.group || "";
50
- let y = t.find((X) => X.id === l);
51
- y || t.push(y = { id: l, title: l, items: [] }), y.items.push(e);
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 = [];
47
+ let e = 0;
48
+ for (const s of o) {
49
+ if (!i(s)) continue;
50
+ 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);
52
54
  }
53
- if (c && c > 0) for (const e of t) {
54
- if (I.has(e.id) || e.items.length <= c) continue;
55
- const l = e.items.length - c;
56
- e.items = [...e.items.slice(0, c), { id: E + e.id, more: l, group: e.id }];
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 }];
57
59
  }
58
- return t;
59
- }, [o, d, h, c, I]), W = j(() => new Map(o.map((s) => [s.id, s])), [o]);
60
- return /* @__PURE__ */ n(ie, { isOpen: v, onOpenChange: S, size: "md", className: "alea-command-overlay", motion: f, surface: T, radius: V, children: /* @__PURE__ */ n(ae, { ref: H, style: F, "aria-label": a.commandPalette, hideClose: !0, className: B("alea-command", D), children: ({ close: s }) => /* @__PURE__ */ m(P, { inputValue: d, onInputChange: x, filter: () => !0, children: [
61
- /* @__PURE__ */ m(Y, { "aria-label": a.searchCommands, autoFocus: !0, className: "alea-command-search", children: [
62
- /* @__PURE__ */ n(se, { size: 18, "aria-hidden": "true" }),
63
- /* @__PURE__ */ n(Z, { placeholder: K, className: "alea-command-input" }),
64
- /* @__PURE__ */ n(oe, { children: a.esc })
60
+ 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 })
65
67
  ] }),
66
- /* @__PURE__ */ m(re, { children: [
67
- /* @__PURE__ */ n(Q, { items: A, className: "alea-command-list", "aria-busy": p || void 0, onAction: (t) => {
68
- if (String(t).startsWith(E)) {
69
- k((l) => new Set(l).add(String(t).slice(E.length)));
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)));
70
72
  return;
71
73
  }
72
- const e = W.get(t);
73
- s(), e == null || e.onAction();
74
- }, renderEmptyState: () => /* @__PURE__ */ n("p", { className: "alea-command-empty", role: p ? "status" : void 0, children: p ? a.loading : R }), children: (t) => /* @__PURE__ */ m(G, { id: t.id, className: "alea-option-section", children: [
75
- t.title && /* @__PURE__ */ n(ee, { className: "alea-option-header", children: t.title }),
76
- /* @__PURE__ */ n(te, { items: t.items, children: (e) => "more" in e ? /* @__PURE__ */ n(z, { id: e.id, textValue: a.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: a.showNMore(e.more) }) }) }) : /* @__PURE__ */ m(z, { id: e.id, textValue: [e.label, ...e.keywords || []].join(" "), className: "alea-option alea-command-item", children: [
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: [
77
+ 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: [
77
79
  e.icon && /* @__PURE__ */ n("span", { className: "alea-option-icon", "aria-hidden": "true", children: e.icon }),
78
80
  /* @__PURE__ */ m("span", { className: "alea-option-text", children: [
79
81
  /* @__PURE__ */ n("span", { slot: "label", children: e.label }),
80
82
  e.description && /* @__PURE__ */ n("span", { className: "alea-option-desc", slot: "description", children: e.description })
81
83
  ] }),
82
- e.shortcut && /* @__PURE__ */ n(ne, { className: "alea-menu-shortcut", children: e.shortcut })
84
+ e.shortcut && /* @__PURE__ */ n(ie, { className: "alea-menu-shortcut", children: e.shortcut })
83
85
  ] }) })
84
86
  ] }) }),
85
- p && A.length > 0 && /* @__PURE__ */ n("p", { className: "alea-command-loading", role: "status", children: a.loading })
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 })
86
88
  ] })
87
89
  ] }) }) });
88
90
  });
89
91
  export {
90
- we as CommandPalette
92
+ ve as CommandPalette
91
93
  };
@@ -7,14 +7,18 @@ export interface DescriptionsProps extends Omit<HTMLAttributes<HTMLElement>, 'ti
7
7
  span?: 1 | 2 | 3 | 4; /** Spans the whole row. */
8
8
  wide?: boolean;
9
9
  }>;
10
- /** Columns on wide screens: 1 to 4. Default 2. Three and four columns drop to two below 1024 px; everything is one column on phones. */
11
- columns?: 1 | 2 | 3 | 4;
10
+ /** Columns on wide screens: 1 to 4. Default 2. Three and four columns drop to two below 1024 px; everything is one column on phones. 'auto' fits as many columns of at least 14 rem as the width allows (item spans count as one). */
11
+ columns?: 1 | 2 | 3 | 4 | 'auto';
12
+ /** Leaves out the items whose value is empty (null, undefined, false or an empty string), so a record with optional facts shows no blank rows. */
13
+ hideEmpty?: boolean;
12
14
  /** stacked (label above the value, default) or inline (label and value side by side). */
13
15
  layout?: 'stacked' | 'inline';
14
- /** Draws lines between items. */
16
+ /** Draws a box around the items, with a line between them. */
15
17
  bordered?: boolean;
16
- /** sm (tighter, 13 px values) or md (default). */
17
- size?: 'sm' | 'md';
18
+ /** plain (default) or lines: a thin rule under each row, with no box around the list, like a statement or a receipt. */
19
+ variant?: 'plain' | 'lines';
20
+ /** sm (tighter, 13 px values), md (default) or lg (larger text, for a page people read rather than scan). */
21
+ size?: 'sm' | 'md' | 'lg';
18
22
  /** A title above the list (an h3). */
19
23
  title?: ReactNode;
20
24
  /** Something at the end of the title row: an Edit button or link. */
@@ -23,7 +27,7 @@ export interface DescriptionsProps extends Omit<HTMLAttributes<HTMLElement>, 'ti
23
27
  labelWidth?: string;
24
28
  }
25
29
  /** Key and value pairs: order details, profile facts, settings summaries. A title with an action, one to four columns, item spans, stacked or inline, two sizes. */
26
- export declare function Descriptions({ items, columns, layout, bordered, size, title, extra, labelWidth, className, style, ...props }: DescriptionsProps): import("react").JSX.Element;
30
+ export declare function Descriptions({ items, columns, hideEmpty, layout, bordered, variant, size, title, extra, labelWidth, className, style, ...props }: DescriptionsProps): import("react").JSX.Element;
27
31
  export interface StatisticProps extends Omit<HTMLAttributes<HTMLDivElement>, 'prefix'> {
28
32
  /** What the number is. */
29
33
  label: ReactNode;