@alea-design/ui 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/components/button/Button.d.ts +13 -2
  2. package/dist/components/button/Button.js +126 -104
  3. package/dist/components/celebrate/Celebrate.d.ts +31 -0
  4. package/dist/components/celebrate/Celebrate.js +50 -0
  5. package/dist/components/display/Display.d.ts +7 -2
  6. package/dist/components/display/Display.js +64 -63
  7. package/dist/components/feedback/Feedback.js +23 -23
  8. package/dist/components/field/Field.d.ts +15 -2
  9. package/dist/components/field/Field.js +165 -134
  10. package/dist/components/more/More.d.ts +3 -1
  11. package/dist/components/more/More.js +53 -53
  12. package/dist/components/notification/NotificationCenter.js +15 -15
  13. package/dist/components/picker/Picker.d.ts +5 -1
  14. package/dist/components/picker/Picker.js +212 -209
  15. package/dist/components/print/PrintSheet.d.ts +18 -0
  16. package/dist/components/print/PrintSheet.js +14 -0
  17. package/dist/components/shell/AccountFooter.d.ts +31 -0
  18. package/dist/components/shell/AccountFooter.js +43 -0
  19. package/dist/components/shell/AppShell.js +18 -18
  20. package/dist/components/shell/AppSidebar.js +31 -31
  21. package/dist/components/shell/sidebar-context.d.ts +5 -0
  22. package/dist/components/shell/sidebar-context.js +6 -0
  23. package/dist/css/base.css +1 -1
  24. package/dist/css/button.css +1 -1
  25. package/dist/css/celebrate.css +1 -0
  26. package/dist/css/choice.css +1 -1
  27. package/dist/css/data.css +1 -1
  28. package/dist/css/display.css +1 -1
  29. package/dist/css/feedback.css +1 -1
  30. package/dist/css/field.css +1 -1
  31. package/dist/css/groups.json +31 -11
  32. package/dist/css/menu.css +1 -1
  33. package/dist/css/more.css +1 -1
  34. package/dist/css/picker.css +1 -1
  35. package/dist/css/print.css +1 -0
  36. package/dist/css/shell.css +1 -1
  37. package/dist/i18n/strings.d.ts +17 -0
  38. package/dist/i18n/strings.js +41 -7
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.js +276 -267
  41. package/dist/styles.css +1 -1
  42. package/dist/utils/announcer.d.ts +21 -0
  43. package/dist/utils/announcer.js +30 -0
  44. package/package.json +3 -3
@@ -94,6 +94,17 @@ export interface HoldButtonProps extends Omit<ButtonProps, 'onPress' | 'isLoadin
94
94
  duration?: number;
95
95
  /** Read by screen readers after the label. Default "Press and hold to confirm". */
96
96
  hint?: string;
97
+ /** The label shown while it is held, so the person knows to keep going. Default "Keep holding…". Pass null to keep the normal label. */
98
+ holdingLabel?: ReactNode;
99
+ /** Said to screen readers (politely) when the hold completes. Default "Confirmed"; name the result if you can ("Project deleted"). */
100
+ confirmedMessage?: string;
101
+ /** A short vibration when the press starts and a double pulse when it completes, on phones that support it. Default false. */
102
+ haptic?: boolean;
103
+ /** Throws confetti from the button when the hold completes (see Celebrate). Default false. With reduced motion it shows a still check instead. */
104
+ celebrate?: boolean;
97
105
  }
98
- /** Hold to confirm (the hold pattern): a fill grows while it is pressed, with pointer, Space or Enter, and the action runs when it is full. For destructive actions without a dialog. */
99
- export declare function HoldButton({ onConfirm, duration, hint, variant, className, children, ...props }: HoldButtonProps): import("react").JSX.Element;
106
+ /**
107
+ * Hold to confirm (the hold pattern): while it is pressed, with pointer, Space or Enter, a bar fills along the bottom edge (the finger covers the middle, never the edge)
108
+ * under a tint over the button, the label changes to "Keep holding…", and the action runs when the bar is full. Releasing early cancels. For destructive actions without a dialog.
109
+ */
110
+ export declare function HoldButton({ onConfirm, duration, hint, holdingLabel, confirmedMessage, haptic, celebrate: celebrates, variant, className, children, ...props }: HoldButtonProps): import("react").JSX.Element;
@@ -1,139 +1,161 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as h, Fragment as Y } from "react/jsx-runtime";
3
- import { forwardRef as G, useRef as A, useEffect as I, useState as _ } from "react";
4
- import { useRipple as C } from "@alea-design/motion";
5
- import { Link as V, Button as ee, composeRenderProps as te, ToggleButtonGroup as ne, ToggleButton as W, SelectionIndicator as ae } from "react-aria-components";
6
- import { withBase as b } from "../../utils/cx.js";
7
- import { useMergedRef as oe } from "../../utils/refs.js";
8
- import { Spinner as P } from "../feedback/Spinner.js";
9
- import { useStrings as q } from "../../i18n/strings.js";
10
- import { responsiveAttrs as X } from "../../utils/responsive.js";
11
- import { TooltipTrigger as re, Tooltip as le } from "../overlay/Overlay.js";
12
- import { buttonIcon as M } from "../icon/icon-contexts.js";
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
- const T = q();
15
- B ?? (B = T.done);
16
- const E = A(null), D = oe(Q, E), { onPointerDown: $ } = C();
17
- I(() => {
2
+ import { jsx as e, jsxs as h, Fragment as C } from "react/jsx-runtime";
3
+ import { forwardRef as J, useRef as I, useEffect as R, useState as Y } from "react";
4
+ import { useRipple as L } from "@alea-design/motion";
5
+ import { Link as ee, Button as te, composeRenderProps as ne, ToggleButtonGroup as ae, ToggleButton as O, SelectionIndicator as oe } from "react-aria-components";
6
+ import { withBase as y } from "../../utils/cx.js";
7
+ import { useMergedRef as le } from "../../utils/refs.js";
8
+ import { Spinner as G } from "../feedback/Spinner.js";
9
+ import { useStrings as Q } from "../../i18n/strings.js";
10
+ import { responsiveAttrs as W } from "../../utils/responsive.js";
11
+ import { TooltipTrigger as re, Tooltip as ie } from "../overlay/Overlay.js";
12
+ import { buttonIcon as $ } from "../icon/icon-contexts.js";
13
+ import { celebrate as se } from "../celebrate/Celebrate.js";
14
+ const U = J(function({ variant: a = "primary", tone: o, size: i, shape: u, iconStart: s, iconEnd: r, isLoading: m, loadingLabel: t, loadingPosition: c = "center", fullWidth: j, justify: B, wrap: T, shortcut: f, href: b, target: k, rel: S, isSuccess: g, successLabel: p, ripple: v, className: z, children: N, ...x }, Z) {
15
+ const D = Q();
16
+ p ?? (p = D.done);
17
+ const E = I(null), M = le(Z, E), { onPointerDown: F } = L();
18
+ R(() => {
18
19
  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
- }, [k, $]);
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: [
20
+ if (!v || !n) return;
21
+ const d = (A) => F({ currentTarget: n, clientX: A.clientX, clientY: A.clientY });
22
+ return n.addEventListener("pointerdown", d), () => n.removeEventListener("pointerdown", d);
23
+ }, [v, F]);
24
+ const w = m && (t != null || c !== "center"), K = /* @__PURE__ */ e("span", { className: "alea-button-icon alea-button-inline-spinner", children: /* @__PURE__ */ e(G, { size: "sm", "aria-label": D.loading }) }), P = (n, d) => /* @__PURE__ */ h(C, { children: [
25
+ d && !w && /* @__PURE__ */ e("span", { className: "alea-button-spinner", children: /* @__PURE__ */ e(G, { size: "sm", "aria-label": D.loading }) }),
26
+ g && !d ? /* @__PURE__ */ h("span", { className: "alea-button-content alea-success-in", "aria-live": "polite", children: [
26
27
  /* @__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
- B != null && B !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: B })
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 }),
28
+ p != null && p !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: p })
29
+ ] }) : /* @__PURE__ */ h("span", { className: "alea-button-content", "data-hidden": d && !w || void 0, children: [
30
+ w && c !== "end" ? K : s && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(a, o), children: s }),
31
+ (w && t != null ? t : n) != null && n !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: w && t != null ? t : n }),
32
+ w && c === "end" ? K : r && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(a, o), children: r }),
32
33
  f && /* @__PURE__ */ e("kbd", { className: "alea-button-kbd", "aria-hidden": "true", children: f })
33
34
  ] })
34
- ] }), K = {
35
- "data-success": R || void 0,
36
- "data-ripple": k || void 0,
37
- "data-variant": o,
38
- "data-tone": a,
39
- ...X("size", d, "md"),
40
- ...X("full-width", N),
41
- "data-shape": m,
42
- "data-justify": v,
43
- "data-wrap": g || void 0
44
- }, z = typeof f == "string" ? f.replace("⌘", "Meta+").replace("⇧", "Shift+").replace("⌥", "Alt+").replace("⌃", "Control+") : void 0;
45
- if (I(() => {
35
+ ] }), X = {
36
+ "data-success": g || void 0,
37
+ "data-ripple": v || void 0,
38
+ "data-variant": a,
39
+ "data-tone": o,
40
+ ...W("size", i, "md"),
41
+ ...W("full-width", j),
42
+ "data-shape": u,
43
+ "data-justify": B,
44
+ "data-wrap": T || void 0
45
+ }, H = typeof f == "string" ? f.replace("⌘", "Meta+").replace("⇧", "Shift+").replace("⌥", "Alt+").replace("⌃", "Control+") : void 0;
46
+ if (R(() => {
46
47
  const n = E.current;
47
- n && (z ? n.setAttribute("aria-keyshortcuts", z) : n.removeAttribute("aria-keyshortcuts"));
48
- }, [z]), y) {
49
- const { onPress: n, isDisabled: s, autoFocus: w, id: U, style: Z } = S;
48
+ n && (H ? n.setAttribute("aria-keyshortcuts", H) : n.removeAttribute("aria-keyshortcuts"));
49
+ }, [H]), b) {
50
+ const { onPress: n, isDisabled: d, autoFocus: A, id: _, style: V } = x;
50
51
  return /* @__PURE__ */ e(
51
- V,
52
+ ee,
52
53
  {
53
- href: y,
54
- target: L,
55
- rel: O,
54
+ href: b,
55
+ target: k,
56
+ rel: S,
56
57
  onPress: n,
57
- isDisabled: s,
58
- autoFocus: w,
59
- id: U,
60
- style: Z,
61
- ref: D,
62
- ...K,
63
- "aria-label": S["aria-label"],
64
- className: b("alea-button alea-focus-ring", j),
65
- children: F(x, !1)
58
+ isDisabled: d,
59
+ autoFocus: A,
60
+ id: _,
61
+ style: V,
62
+ ref: M,
63
+ ...X,
64
+ "aria-label": x["aria-label"],
65
+ className: y("alea-button alea-focus-ring", z),
66
+ children: P(N, !1)
66
67
  }
67
68
  );
68
69
  }
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: [
70
+ return /* @__PURE__ */ e(te, { ...x, ...X, ref: M, isPending: m, className: y("alea-button alea-focus-ring", z), children: ne(N, (n, { isPending: d }) => P(n, d)) });
71
+ }), ye = J(function({ shape: a = "circle", variant: o = "ghost", tooltip: i, children: u, className: s, ...r }, m) {
72
+ const t = /* @__PURE__ */ e(U, { ...r, ref: m, variant: o, "data-icon-shape": a, "data-icon-only": !0, className: y("alea-icon-button", s), children: /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(o, r.tone), children: u }) });
73
+ return i ? /* @__PURE__ */ h(re, { delay: 400, children: [
73
74
  t,
74
- /* @__PURE__ */ e(le, { children: l["aria-label"] })
75
+ /* @__PURE__ */ e(ie, { children: r["aria-label"] })
75
76
  ] }) : t;
76
77
  });
77
- function ve({ items: r, value: o, defaultValue: a, onChange: d, size: m = "md", wrap: c, className: l, ...u }) {
78
+ function Be({ items: l, value: a, defaultValue: o, onChange: i, size: u = "md", wrap: s, className: r, ...m }) {
78
79
  return /* @__PURE__ */ e(
79
- ne,
80
+ ae,
80
81
  {
81
- ...u,
82
+ ...m,
82
83
  selectionMode: "single",
83
84
  disallowEmptySelection: !0,
84
- selectedKeys: o !== void 0 ? [o] : void 0,
85
- defaultSelectedKeys: a !== void 0 ? [a] : o === void 0 && r[0] ? [r[0].id] : void 0,
85
+ selectedKeys: a !== void 0 ? [a] : void 0,
86
+ defaultSelectedKeys: o !== void 0 ? [o] : a === void 0 && l[0] ? [l[0].id] : void 0,
86
87
  onSelectionChange: (t) => {
87
- const i = [...t][0];
88
- i !== void 0 && (d == null || d(i));
88
+ const c = [...t][0];
89
+ c !== void 0 && (i == null || i(c));
89
90
  },
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: [
91
+ "data-size": u,
92
+ "data-wrap": s || void 0,
93
+ className: y("alea-segmented", r),
94
+ children: l.map((t) => /* @__PURE__ */ h(O, { id: t.id, isDisabled: t.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
94
95
  /* @__PURE__ */ e("span", { className: "alea-segmented-label", children: t.label }),
95
- /* @__PURE__ */ e(ae, { className: "alea-sel-indicator" })
96
+ /* @__PURE__ */ e(oe, { className: "alea-sel-indicator" })
96
97
  ] }, String(t.id)))
97
98
  }
98
99
  );
99
100
  }
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
+ function Te({ size: l = "md", className: a, ...o }) {
102
+ return /* @__PURE__ */ e(O, { ...o, "data-size": l, className: y("alea-toggle-button alea-focus-ring", a) });
102
103
  }
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;
107
- return I(() => {
108
- const g = N.current;
109
- if (!g) return;
110
- const f = (y) => {
111
- y.animationName === "alea-hold" && (i(!1), r());
112
- };
113
- return g.addEventListener("animationend", f), () => g.removeEventListener("animationend", f);
114
- }, [r]), /* @__PURE__ */ h(Y, { children: [
104
+ function q(l) {
105
+ try {
106
+ typeof navigator < "u" && typeof navigator.vibrate == "function" && navigator.vibrate(l);
107
+ } catch {
108
+ }
109
+ }
110
+ function ke({ onConfirm: l, duration: a = 1200, hint: o, holdingLabel: i, confirmedMessage: u, haptic: s, celebrate: r, variant: m = "danger", className: t, children: c, ...j }) {
111
+ const B = Q();
112
+ o ?? (o = B.pressAndHold), u ?? (u = B.holdConfirmed);
113
+ const T = i === void 0 ? B.keepHolding : i, [f, b] = Y(!1), [k, S] = Y(""), g = I(null), p = I(`alea-hold-${Math.random().toString(36).slice(2, 8)}`).current, v = I(l);
114
+ v.current = l, R(() => {
115
+ if (!f) return;
116
+ const N = window.setTimeout(() => {
117
+ b(!1), s && q([30, 40, 30]), r && g.current && se(g.current), S(u), v.current();
118
+ }, a);
119
+ return () => window.clearTimeout(N);
120
+ }, [f, a, s, r, u]), R(() => {
121
+ if (!k) return;
122
+ const N = window.setTimeout(() => S(""), 3e3);
123
+ return () => window.clearTimeout(N);
124
+ }, [k]);
125
+ const z = T != null && T !== !1 && typeof c != "function";
126
+ return /* @__PURE__ */ h(C, { children: [
115
127
  /* @__PURE__ */ e(
116
- J,
128
+ U,
117
129
  {
118
- ...l,
119
- ref: N,
120
- variant: d,
121
- "data-holding": t || void 0,
122
- "aria-describedby": v,
123
- onPressStart: () => i(!0),
124
- onPressEnd: () => i(!1),
125
- className: b("alea-hold", m),
126
- style: { "--alea-hold-duration": `${o}ms` },
127
- children: c
130
+ ...j,
131
+ ref: g,
132
+ variant: m,
133
+ "data-holding": f || void 0,
134
+ "aria-describedby": p,
135
+ onPressStart: () => {
136
+ S(""), b(!0), s && q(10);
137
+ },
138
+ onPressEnd: () => b(!1),
139
+ className: y("alea-hold", t),
140
+ style: { "--alea-hold-duration": `${a}ms` },
141
+ children: z ? (
142
+ // Both labels share one grid cell, so the button keeps the width of the longer one and nothing moves when they swap. The real label stays in the accessible name
143
+ // all the time; the "keep holding" text is for the eyes only (aria-hidden), the hint already tells a screen reader what to do.
144
+ /* @__PURE__ */ h("span", { className: "alea-hold-label", children: [
145
+ /* @__PURE__ */ e("span", { className: "alea-hold-idle", children: c }),
146
+ /* @__PURE__ */ e("span", { className: "alea-hold-active", "aria-hidden": "true", children: T })
147
+ ] })
148
+ ) : c
128
149
  }
129
150
  ),
130
- /* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children: a })
151
+ /* @__PURE__ */ e("span", { id: p, className: "alea-visually-hidden", children: o }),
152
+ /* @__PURE__ */ e("span", { role: "status", "aria-live": "polite", className: "alea-visually-hidden", children: k })
131
153
  ] });
132
154
  }
133
155
  export {
134
- J as Button,
135
- Be as HoldButton,
136
- Ne as IconButton,
137
- ve as SegmentedControl,
138
- ye as ToggleButton
156
+ U as Button,
157
+ ke as HoldButton,
158
+ ye as IconButton,
159
+ Be as SegmentedControl,
160
+ Te as ToggleButton
139
161
  };
@@ -0,0 +1,31 @@
1
+ import { type ReactNode } from 'react';
2
+ /** Where the pieces start, as a point in the viewport or an element to start from (its center). */
3
+ export type CelebrateOrigin = HTMLElement | {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ export interface CelebrateOptions {
8
+ /** How many pieces. Default 32, never more than 80. */
9
+ count?: number;
10
+ /** CSS colors for the pieces, used in turn. Default: the accent tokens and the success and warning colors. */
11
+ colors?: string[];
12
+ /** How long the pieces take to fall away, in ms. Default 1400. */
13
+ duration?: number;
14
+ /** Called when the confetti (or the still check) is gone. */
15
+ onDone?: () => void;
16
+ }
17
+ /**
18
+ * Confetti for a real success (an action that worked), thrown up from a point or an element and falling away. It lives in its own fixed layer, so it never moves
19
+ * anything on the page, takes no pointer events and no focus, and removes itself when it ends. It is decoration only: say the result in text (a status, a toast),
20
+ * never rely on the confetti. With reduced motion (or motion off) it shows a still check mark for a moment instead. Returns a function that ends it early.
21
+ */
22
+ export declare function celebrate(origin: CelebrateOrigin, { count, colors, duration, onDone }?: CelebrateOptions): () => void;
23
+ export interface CelebrateProps extends CelebrateOptions {
24
+ /** Throws the confetti when this turns true (or, for a number, each time it changes to a new value above 0): set it when the action succeeded. */
25
+ fire: boolean | number;
26
+ /** The element the confetti comes out of. */
27
+ children: ReactNode;
28
+ className?: string;
29
+ }
30
+ /** Wraps an element and throws confetti from it when `fire` turns true, once per success. Pair it with a visible or announced result: the confetti is decoration. */
31
+ export declare function Celebrate({ fire, children, className, ...options }: CelebrateProps): import("react").JSX.Element;
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { jsx as k } from "react/jsx-runtime";
3
+ import { useRef as m, useEffect as w } from "react";
4
+ import { cx as E } from "../../utils/cx.js";
5
+ const $ = ["var(--alea-accent)", "var(--alea-accent-second)", "var(--alea-accent-third)", "var(--alea-status-success)", "var(--alea-status-warning)"], R = 1600, h = () => {
6
+ };
7
+ function T() {
8
+ var r;
9
+ const e = document.documentElement, t = e.getAttribute("data-alea-motion"), s = e.getAttribute("data-alea-reduced");
10
+ return t === "off" || t === "reduced" || s === "always" || s !== "never" && !!((r = window.matchMedia) != null && r.call(window, "(prefers-reduced-motion: reduce)").matches);
11
+ }
12
+ const A = (e) => "getBoundingClientRect" in e ? (() => {
13
+ const t = e.getBoundingClientRect();
14
+ return { x: t.left + t.width / 2, y: t.top + t.height / 2, w: t.width, top: t.top, right: t.right };
15
+ })() : { x: e.x, y: e.y, w: 0, top: e.y, right: e.x };
16
+ function B(e, { count: t = 32, colors: s = $, duration: r = 1400, onDone: i } = {}) {
17
+ if (typeof document > "u") return h;
18
+ const l = A(e), a = document.createElement("div");
19
+ a.setAttribute("aria-hidden", "true");
20
+ let d = 0, u = !1;
21
+ const p = () => {
22
+ u || (u = !0, window.clearTimeout(d), a.remove(), i == null || i());
23
+ };
24
+ if (T()) {
25
+ a.className = "alea-celebrate alea-celebrate-still", a.innerHTML = '<span class="alea-celebrate-check"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg></span>';
26
+ const o = a.firstElementChild;
27
+ return o.style.left = `${l.right}px`, o.style.top = `${l.top}px`, document.body.appendChild(a), d = window.setTimeout(p, R), p;
28
+ }
29
+ if (typeof Element.prototype.animate != "function") return h;
30
+ a.className = "alea-celebrate";
31
+ const x = Math.max(1, Math.min(80, Math.round(t)));
32
+ for (let o = 0; o < x; o++) {
33
+ const c = document.createElement("i"), f = (-90 + (Math.random() - 0.5) * 110) * Math.PI / 180, g = 180 + Math.random() * 260, b = 720, M = (Math.random() - 0.5) * 900, y = r * (0.8 + Math.random() * 0.3) / 1e3, v = (n) => `translate(${Math.cos(f) * g * n}px, ${Math.sin(f) * g * n + 0.5 * b * n * n}px) rotate(${M * n}deg)`, C = [0, 0.15, 0.35, 0.6, 0.8, 1];
34
+ c.style.left = `${l.x}px`, c.style.top = `${l.y}px`, c.style.background = s[o % s.length], o % 3 === 0 && (c.style.borderRadius = "50%"), o % 3 === 1 && (c.style.width = "var(--alea-space-1)", c.style.height = "var(--alea-space-3)"), a.appendChild(c), c.animate(C.map((n) => ({ transform: v(n * y), opacity: n < 0.6 ? 1 : 1 - (n - 0.6) / 0.4, offset: n })), { duration: y * 1e3, easing: "linear", fill: "forwards" });
35
+ }
36
+ return document.body.appendChild(a), d = window.setTimeout(p, r * 1.15 + 50), p;
37
+ }
38
+ function j({ fire: e, children: t, className: s, ...r }) {
39
+ const i = m(null), l = m(!1), a = m(r);
40
+ a.current = r;
41
+ const d = m(h);
42
+ return w(() => {
43
+ const u = l.current;
44
+ l.current = e, !(!e || e === u || !i.current) && (d.current(), d.current = B(i.current, a.current));
45
+ }, [e]), w(() => () => d.current(), []), /* @__PURE__ */ k("span", { ref: i, className: E("alea-celebrate-host", s), children: t });
46
+ }
47
+ export {
48
+ j as Celebrate,
49
+ B as celebrate
50
+ };
@@ -6,7 +6,7 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
6
6
  tone?: Tone;
7
7
  /** soft (tinted, default), solid, or outline. */
8
8
  appearance?: 'soft' | 'solid' | 'outline';
9
- /** Lets a long text break onto several lines (the badge grows from its normal height) instead of staying on one line and being cut. For narrow screens and large text. */
9
+ /** A text longer than the room always breaks onto a second line (the badge grows from its normal height) instead of being cut. wrap also gives that tall badge its shape: rounded corners and vertical air, for narrow screens and large text where you expect it. */
10
10
  wrap?: boolean;
11
11
  /** A dot before the text, for statuses. pulse makes it breathe, for live things. */
12
12
  dot?: boolean | 'pulse';
@@ -79,6 +79,8 @@ export interface TagProps extends RACTagProps {
79
79
  }
80
80
  /** One tag in a TagGroup. */
81
81
  export declare function Tag({ tone, appearance, size, icon, children, className, ...props }: TagProps): import("react").JSX.Element;
82
+ /** What a person is doing right now: looking at it (active), changing it (editing), idle (away) or not here (offline). */
83
+ export type AvatarPresence = 'active' | 'editing' | 'away' | 'offline';
82
84
  export interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
83
85
  /** Image URL. Falls back to initials when missing or broken. */
84
86
  src?: string;
@@ -88,6 +90,8 @@ export interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
88
90
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
89
91
  /** A status dot in the corner. */
90
92
  status?: 'online' | 'away' | 'busy' | 'offline';
93
+ /** What the person is doing: active, editing, away or offline. Draws a small icon badge in the corner and adds the state to the accessible name ("Ana (editing)"), so it never relies on color. Wins over status when both are set. */
94
+ presence?: AvatarPresence;
91
95
  /** circle (default) or square. */
92
96
  shape?: 'circle' | 'square';
93
97
  /** What shows without a photo instead of initials: an icon, a logo. */
@@ -98,7 +102,7 @@ export interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
98
102
  count?: number;
99
103
  }
100
104
  /** A person: photo, or initials on a gradient. */
101
- export declare function Avatar({ src, name, size, status, shape, fallback, ring, count, className, style, ...props }: AvatarProps): import("react").JSX.Element;
105
+ export declare function Avatar({ src, name, size, status, presence, shape, fallback, ring, count, className, style, ...props }: AvatarProps): import("react").JSX.Element;
102
106
  export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
103
107
  /** Shows this many, then +N. Default 4. */
104
108
  max?: number;
@@ -108,6 +112,7 @@ export interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
108
112
  people: Array<{
109
113
  name: string;
110
114
  src?: string;
115
+ presence?: AvatarPresence;
111
116
  }>;
112
117
  /** The avatars spread apart on hover or focus (the fan pattern). */
113
118
  fan?: boolean;
@@ -1,89 +1,90 @@
1
1
  "use client";
2
- import { jsxs as m, jsx as r, Fragment as T } from "react/jsx-runtime";
3
- import { useState as k, useRef as f, useEffect as h, useContext as C, createContext as y } from "react";
4
- import { Tag as S, Button as $, TagGroup as z, Label as B, TagList as E } from "react-aria-components";
5
- import { X as G, ChevronLeft as j, ChevronRight as I } from "lucide-react";
6
- import { useScrollEdges as L } from "../../utils/scrollEdges.js";
7
- import { cx as g, withBase as A } from "../../utils/cx.js";
8
- import { chipIcon as v } from "../icon/icon-contexts.js";
9
- import { useStrings as b } from "../../i18n/strings.js";
10
- function R({ tone: a = "neutral", appearance: e = "soft", dot: t, icon: l, size: n = "md", shape: o, wrap: i, className: d, children: c, ...s }) {
11
- return /* @__PURE__ */ m("span", { ...s, className: g("alea-badge", d), "data-tone": a, "data-appearance": e, "data-size": n, "data-shape": o, "data-wrap": i || void 0, children: [
12
- t && /* @__PURE__ */ r("span", { className: "alea-badge-dot", "data-pulse": t === "pulse" || void 0, "aria-hidden": "true" }),
13
- l && /* @__PURE__ */ r("span", { className: "alea-badge-icon", "aria-hidden": "true", ...v("badge", e, a), children: l }),
14
- c
2
+ import { jsxs as m, jsx as e, Fragment as E } from "react/jsx-runtime";
3
+ import { useState as S, useRef as f, useEffect as b, useContext as $, createContext as z } from "react";
4
+ import { Tag as B, Button as I, TagGroup as G, Label as j, TagList as L } from "react-aria-components";
5
+ import { Minus as P, Clock as R, Pencil as A, Eye as M, X as O, ChevronLeft as U, ChevronRight as V } from "lucide-react";
6
+ import { useScrollEdges as _ } from "../../utils/scrollEdges.js";
7
+ import { cx as g, withBase as q } from "../../utils/cx.js";
8
+ import { chipIcon as w } from "../icon/icon-contexts.js";
9
+ import { useStrings as h } from "../../i18n/strings.js";
10
+ function F({ tone: a = "neutral", appearance: t = "soft", dot: n, icon: l, size: r = "md", shape: u, wrap: i, className: s, children: d, ...o }) {
11
+ return /* @__PURE__ */ m("span", { ...o, className: g("alea-badge", s), "data-tone": a, "data-appearance": t, "data-size": r, "data-shape": u, "data-wrap": i || void 0, children: [
12
+ n && /* @__PURE__ */ e("span", { className: "alea-badge-dot", "data-pulse": n === "pulse" || void 0, "aria-hidden": "true" }),
13
+ l && /* @__PURE__ */ e("span", { className: "alea-badge-icon", "aria-hidden": "true", ...w("badge", t, a), children: l }),
14
+ d
15
15
  ] });
16
16
  }
17
- const M = Object.fromEntries([
17
+ const X = Object.fromEntries([
18
18
  ...["published", "paid", "active", "done", "complete", "completed", "live", "delivered", "fulfilled", "shipped", "healthy", "operational", "online", "approved", "resolved", "in stock", "connected", "verified", "enabled", "succeeded", "ready"].map((a) => [a, "success"]),
19
19
  ...["draft", "pending", "scheduled", "review", "in review", "processing", "trial", "low stock", "degraded", "on hold", "unfulfilled", "due", "monitoring", "in progress", "queued", "building", "partially paid", "investigating"].map((a) => [a, "warning"]),
20
20
  ...["failed", "error", "canceled", "cancelled", "refunded", "out of stock", "down", "blocked", "overdue", "rejected", "expired", "firing", "rolled back", "disconnected"].map((a) => [a, "danger"]),
21
21
  ...["open", "todo", "new", "running", "invited"].map((a) => [a, "info"])
22
22
  ]);
23
- function J({ status: a, tones: e, tone: t, size: l = "sm", dot: n = !0, ...o }) {
24
- const i = a.trim().toLowerCase(), d = t ?? (e == null ? void 0 : e[i]) ?? M[i] ?? "neutral";
25
- return /* @__PURE__ */ r(R, { ...o, size: l, dot: n, tone: d, children: a });
23
+ function ra({ status: a, tones: t, tone: n, size: l = "sm", dot: r = !0, ...u }) {
24
+ const i = a.trim().toLowerCase(), s = n ?? (t == null ? void 0 : t[i]) ?? X[i] ?? "neutral";
25
+ return /* @__PURE__ */ e(F, { ...u, size: l, dot: r, tone: s, children: a });
26
26
  }
27
- function K({ count: a, max: e = 99, label: t, tone: l = "accent", appearance: n = "solid", showZero: o, dot: i, size: d, className: c, ...s }) {
28
- const u = f(!0);
29
- return h(() => {
30
- u.current = !1;
31
- }, []), a <= 0 && !o ? null : /* @__PURE__ */ r("span", { ...s, className: g("alea-count", c), "data-tone": l, "data-appearance": n === "solid" ? void 0 : n, "data-dot": i || void 0, "data-size": d, role: t || i ? "img" : void 0, "aria-label": t || i ? `${a}${t ? ` ${t}` : ""}` : void 0, children: !i && /* @__PURE__ */ r("span", { className: u.current ? void 0 : "alea-badge-pop", "aria-hidden": t ? !0 : void 0, children: a > e ? `${e}+` : a }, a) });
32
- }
33
- const N = y({ current: !1 });
34
- function Q({ label: a, items: e, children: t, renderEmptyState: l, overflow: n = "wrap", className: o, ...i }) {
35
- const d = f(null), c = f(!1);
36
- h(() => (c.current = !0, () => {
27
+ function na({ count: a, max: t = 99, label: n, tone: l = "accent", appearance: r = "solid", showZero: u, dot: i, size: s, className: d, ...o }) {
28
+ const c = f(!0);
29
+ return b(() => {
37
30
  c.current = !1;
31
+ }, []), a <= 0 && !u ? null : /* @__PURE__ */ e("span", { ...o, className: g("alea-count", d), "data-tone": l, "data-appearance": r === "solid" ? void 0 : r, "data-dot": i || void 0, "data-size": s, role: n || i ? "img" : void 0, "aria-label": n || i ? `${a}${n ? ` ${n}` : ""}` : void 0, children: !i && /* @__PURE__ */ e("span", { className: c.current ? void 0 : "alea-badge-pop", "aria-hidden": n ? !0 : void 0, children: a > t ? `${t}+` : a }, a) });
32
+ }
33
+ const C = z({ current: !1 });
34
+ function ia({ label: a, items: t, children: n, renderEmptyState: l, overflow: r = "wrap", className: u, ...i }) {
35
+ const s = f(null), d = f(!1);
36
+ b(() => (d.current = !0, () => {
37
+ d.current = !1;
38
38
  }), []);
39
- const { edges: s, scroll: u } = L(d, ".alea-tag-list", n === "scroll");
40
- return /* @__PURE__ */ r(N.Provider, { value: c, children: /* @__PURE__ */ m(z, { ...i, ref: d, "data-overflow": n, "data-overflow-start": s.start || void 0, "data-overflow-end": s.end || void 0, className: g("alea-tag-group", o), children: [
41
- a && /* @__PURE__ */ r(B, { className: "alea-label", children: a }),
39
+ const { edges: o, scroll: c } = _(s, ".alea-tag-list", r === "scroll");
40
+ return /* @__PURE__ */ e(C.Provider, { value: d, children: /* @__PURE__ */ m(G, { ...i, ref: s, "data-overflow": r, "data-overflow-start": o.start || void 0, "data-overflow-end": o.end || void 0, className: g("alea-tag-group", u), children: [
41
+ a && /* @__PURE__ */ e(j, { className: "alea-label", children: a }),
42
42
  /* @__PURE__ */ m("div", { className: "alea-tag-scroller", children: [
43
- s.start && /* @__PURE__ */ r("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => u(-1), children: /* @__PURE__ */ r(j, { size: 16 }) }),
44
- /* @__PURE__ */ r(E, { items: e, renderEmptyState: l, className: "alea-tag-list", children: t }),
45
- s.end && /* @__PURE__ */ r("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => u(1), children: /* @__PURE__ */ r(I, { size: 16 }) })
43
+ o.start && /* @__PURE__ */ e("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => c(-1), children: /* @__PURE__ */ e(U, { size: 16 }) }),
44
+ /* @__PURE__ */ e(L, { items: t, renderEmptyState: l, className: "alea-tag-list", children: n }),
45
+ o.end && /* @__PURE__ */ e("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => c(1), children: /* @__PURE__ */ e(V, { size: 16 }) })
46
46
  ] })
47
47
  ] }) });
48
48
  }
49
- function W({ tone: a = "neutral", appearance: e, size: t, icon: l, children: n, className: o, ...i }) {
50
- const d = b(), c = i.textValue ?? (typeof n == "string" ? n : void 0), s = C(N), u = f(s.current).current;
51
- return /* @__PURE__ */ r(S, { ...i, textValue: c, "data-added": u || void 0, "data-tone": a, "data-appearance": e, "data-size": t, className: A("alea-tag alea-focus-ring", o), children: (p) => /* @__PURE__ */ m(T, { children: [
52
- l && /* @__PURE__ */ r("span", { className: "alea-tag-icon", "aria-hidden": "true", ...v("tag", e, a, p.isSelected), children: l }),
53
- typeof n == "function" ? n(p) : n,
54
- p.allowsRemoving && /* @__PURE__ */ r($, { slot: "remove", className: "alea-tag-remove", "aria-label": d.remove, children: /* @__PURE__ */ r(G, { size: 12 }) })
49
+ function da({ tone: a = "neutral", appearance: t, size: n, icon: l, children: r, className: u, ...i }) {
50
+ const s = h(), d = i.textValue ?? (typeof r == "string" ? r : void 0), o = $(C), c = f(o.current).current;
51
+ return /* @__PURE__ */ e(B, { ...i, textValue: d, "data-added": c || void 0, "data-tone": a, "data-appearance": t, "data-size": n, className: q("alea-tag alea-focus-ring", u), children: (p) => /* @__PURE__ */ m(E, { children: [
52
+ l && /* @__PURE__ */ e("span", { className: "alea-tag-icon", "aria-hidden": "true", ...w("tag", t, a, p.isSelected), children: l }),
53
+ typeof r == "function" ? r(p) : r,
54
+ p.allowsRemoving && /* @__PURE__ */ e(I, { slot: "remove", className: "alea-tag-remove", "aria-label": s.remove, children: /* @__PURE__ */ e(O, { size: 12 }) })
55
55
  ] }) });
56
56
  }
57
- function O(a) {
58
- var t;
59
- const e = a.trim().split(/\s+/).filter(Boolean);
60
- return ((((t = e[0]) == null ? void 0 : t[0]) || "") + (e.length > 1 ? e[e.length - 1][0] : "")).toUpperCase() || "?";
57
+ const D = { active: M, editing: A, away: R, offline: P };
58
+ function H(a) {
59
+ var n;
60
+ const t = a.trim().split(/\s+/).filter(Boolean);
61
+ return ((((n = t[0]) == null ? void 0 : n[0]) || "") + (t.length > 1 ? t[t.length - 1][0] : "")).toUpperCase() || "?";
61
62
  }
62
- function U({ src: a, name: e, size: t = "md", status: l, shape: n = "circle", fallback: o, ring: i, count: d, className: c, style: s, ...u }) {
63
- const [p, w] = k(!1), x = a && !p;
64
- return /* @__PURE__ */ m("span", { ...u, className: g("alea-avatar", c), "data-size": t, "data-shape": n, "data-ring": i === !0 ? "accent" : i || void 0, role: "img", "aria-label": e + (l ? ` (${l})` : "") + (d ? `, ${d}` : ""), style: s, children: [
65
- x ? /* @__PURE__ */ r("img", { src: a, alt: "", onError: () => w(!0) }) : o ? /* @__PURE__ */ r("span", { className: "alea-avatar-fallback", "aria-hidden": "true", children: o }) : /* @__PURE__ */ r("span", { className: "alea-avatar-initials", "aria-hidden": "true", "data-initials": O(e) }),
66
- l && /* @__PURE__ */ r("span", { className: "alea-avatar-status", "data-status": l, "aria-hidden": "true" }),
67
- d ? /* @__PURE__ */ r("span", { className: "alea-avatar-count", "aria-hidden": "true", children: d > 99 ? "99+" : d }) : null
63
+ function J({ src: a, name: t, size: n = "md", status: l, presence: r, shape: u = "circle", fallback: i, ring: s, count: d, className: o, style: c, ...p }) {
64
+ const k = h(), [x, T] = S(!1), y = a && !x, v = r ? D[r] : null, N = r ? k.presence[r] : l;
65
+ return /* @__PURE__ */ m("span", { ...p, className: g("alea-avatar", o), "data-size": n, "data-shape": u, "data-ring": s === !0 ? "accent" : s || void 0, role: "img", "aria-label": t + (N ? ` (${N})` : "") + (d ? `, ${d}` : ""), style: c, children: [
66
+ y ? /* @__PURE__ */ e("img", { src: a, alt: "", onError: () => T(!0) }) : i ? /* @__PURE__ */ e("span", { className: "alea-avatar-fallback", "aria-hidden": "true", children: i }) : /* @__PURE__ */ e("span", { className: "alea-avatar-initials", "aria-hidden": "true", "data-initials": H(t) }),
67
+ v ? /* @__PURE__ */ e("span", { className: "alea-avatar-presence", "data-presence": r, "aria-hidden": "true", children: /* @__PURE__ */ e(v, {}) }) : l && /* @__PURE__ */ e("span", { className: "alea-avatar-status", "data-status": l, "aria-hidden": "true" }),
68
+ d ? /* @__PURE__ */ e("span", { className: "alea-avatar-count", "aria-hidden": "true", children: d > 99 ? "99+" : d }) : null
68
69
  ] });
69
70
  }
70
- function Y({ people: a, max: e = 4, size: t = "md", fan: l, spacing: n, className: o, ...i }) {
71
- const d = b(), c = a.slice(0, e), s = a.length - c.length;
72
- return /* @__PURE__ */ m("div", { ...i, className: g("alea-avatar-group", o), "data-fan": l || void 0, "data-spacing": n, role: "group", "aria-label": d.people(a.length), children: [
73
- c.map((u) => /* @__PURE__ */ r(U, { name: u.name, src: u.src, size: t }, u.name)),
74
- s > 0 && /* @__PURE__ */ r("span", { className: "alea-avatar alea-avatar-more", "data-size": t, role: "img", "aria-label": d.andMore(s), children: /* @__PURE__ */ m("span", { "aria-hidden": "true", children: [
71
+ function la({ people: a, max: t = 4, size: n = "md", fan: l, spacing: r, className: u, ...i }) {
72
+ const s = h(), d = a.slice(0, t), o = a.length - d.length;
73
+ return /* @__PURE__ */ m("div", { ...i, className: g("alea-avatar-group", u), "data-fan": l || void 0, "data-spacing": r, role: "group", "aria-label": s.people(a.length), children: [
74
+ d.map((c) => /* @__PURE__ */ e(J, { name: c.name, src: c.src, presence: c.presence, size: n }, c.name)),
75
+ o > 0 && /* @__PURE__ */ e("span", { className: "alea-avatar alea-avatar-more", "data-size": n, role: "img", "aria-label": s.andMore(o), children: /* @__PURE__ */ m("span", { "aria-hidden": "true", children: [
75
76
  "+",
76
- s
77
+ o
77
78
  ] }) })
78
79
  ] });
79
80
  }
80
81
  export {
81
- U as Avatar,
82
- Y as AvatarGroup,
83
- R as Badge,
84
- K as CountBadge,
85
- M as STATUS_TONES,
86
- J as StatusBadge,
87
- W as Tag,
88
- Q as TagGroup
82
+ J as Avatar,
83
+ la as AvatarGroup,
84
+ F as Badge,
85
+ na as CountBadge,
86
+ X as STATUS_TONES,
87
+ ra as StatusBadge,
88
+ da as Tag,
89
+ ia as TagGroup
89
90
  };