@alea-design/ui 0.8.0 → 0.8.1

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,143 +1,154 @@
1
1
  "use client";
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";
2
+ import { jsx as e, jsxs as h, Fragment as W } from "react/jsx-runtime";
3
+ import { forwardRef as C, useRef as E, useEffect as A, useState as X } from "react";
4
+ import { useRipple as ee } from "@alea-design/motion";
5
+ import { Link as ne, Button as te, composeRenderProps as ae, ToggleButtonGroup as oe, ToggleButton as J, SelectionIndicator as le } from "react-aria-components";
6
+ import { withBase as w } from "../../utils/cx.js";
7
+ import { useMergedRef as re } from "../../utils/refs.js";
8
+ import { Spinner as Y } from "../feedback/Spinner.js";
9
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";
10
+ import { responsiveAttrs as q } from "../../utils/responsive.js";
11
+ import { TooltipTrigger as ie, Tooltip as se } from "../overlay/Overlay.js";
12
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(() => {
19
- const n = E.current;
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 }) }),
13
+ import { celebrate as ce } from "../celebrate/Celebrate.js";
14
+ function G() {
15
+ for (const l of document.querySelectorAll('[data-live-announcer] [role="img"][aria-labelledby]'))
16
+ (l.getAttribute("aria-labelledby") ?? "").split(/\s+/).filter(Boolean).some((a) => document.getElementById(a)) || l.remove();
17
+ }
18
+ function de() {
19
+ A(() => () => {
20
+ typeof document > "u" || (setTimeout(G, 0), setTimeout(G, 150));
21
+ }, []);
22
+ }
23
+ const Z = C(function({ variant: t = "primary", tone: a, size: i, shape: u, iconStart: s, iconEnd: r, isLoading: m, loadingLabel: n, loadingPosition: c = "center", fullWidth: R, justify: B, wrap: T, shortcut: f, href: b, target: k, rel: S, isSuccess: g, successLabel: p, ripple: v, className: z, children: y, ...j }, _) {
24
+ const x = Q();
25
+ p ?? (p = x.done);
26
+ const D = E(null);
27
+ de();
28
+ const M = re(_, D), { onPointerDown: P } = ee();
29
+ A(() => {
30
+ const o = D.current;
31
+ if (!v || !o) return;
32
+ const d = (I) => P({ currentTarget: o, clientX: I.clientX, clientY: I.clientY });
33
+ return o.addEventListener("pointerdown", d), () => o.removeEventListener("pointerdown", d);
34
+ }, [v, P]);
35
+ const N = m && (n != null || c !== "center"), F = /* @__PURE__ */ e("span", { className: "alea-button-icon alea-button-inline-spinner", children: /* @__PURE__ */ e(Y, { size: "sm", "aria-label": x.loading }) }), K = (o, d) => /* @__PURE__ */ h(W, { children: [
36
+ d && !N && /* @__PURE__ */ e("span", { className: "alea-button-spinner", children: /* @__PURE__ */ e(Y, { size: "sm", "aria-label": x.loading }) }),
26
37
  g && !d ? /* @__PURE__ */ h("span", { className: "alea-button-content alea-success-in", "aria-live": "polite", children: [
27
38
  /* @__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" }) }) }),
28
39
  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 }),
40
+ ] }) : /* @__PURE__ */ h("span", { className: "alea-button-content", "data-hidden": d && !N || void 0, children: [
41
+ N && c !== "end" ? F : s && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(t, a), children: s }),
42
+ (N && n != null ? n : o) != null && o !== !1 && /* @__PURE__ */ e("span", { className: "alea-button-label", children: N && n != null ? n : o }),
43
+ N && c === "end" ? F : r && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(t, a), children: r }),
33
44
  f && /* @__PURE__ */ e("kbd", { className: "alea-button-kbd", "aria-hidden": "true", children: f })
34
45
  ] })
35
- ] }), X = {
46
+ ] }), O = {
36
47
  "data-success": g || void 0,
37
48
  "data-ripple": v || void 0,
38
- "data-variant": a,
39
- "data-tone": o,
40
- ...W("size", i, "md"),
41
- ...W("full-width", j),
49
+ "data-variant": t,
50
+ "data-tone": a,
51
+ ...q("size", i, "md"),
52
+ ...q("full-width", R),
42
53
  "data-shape": u,
43
54
  "data-justify": B,
44
55
  "data-wrap": T || void 0
45
56
  }, H = typeof f == "string" ? f.replace("⌘", "Meta+").replace("⇧", "Shift+").replace("⌥", "Alt+").replace("⌃", "Control+") : void 0;
46
- if (R(() => {
47
- const n = E.current;
48
- n && (H ? n.setAttribute("aria-keyshortcuts", H) : n.removeAttribute("aria-keyshortcuts"));
57
+ if (A(() => {
58
+ const o = D.current;
59
+ o && (H ? o.setAttribute("aria-keyshortcuts", H) : o.removeAttribute("aria-keyshortcuts"));
49
60
  }, [H]), b) {
50
- const { onPress: n, isDisabled: d, autoFocus: A, id: _, style: V } = x;
61
+ const { onPress: o, isDisabled: d, autoFocus: I, id: V, style: L } = j;
51
62
  return /* @__PURE__ */ e(
52
- ee,
63
+ ne,
53
64
  {
54
65
  href: b,
55
66
  target: k,
56
67
  rel: S,
57
- onPress: n,
68
+ onPress: o,
58
69
  isDisabled: d,
59
- autoFocus: A,
60
- id: _,
61
- style: V,
70
+ autoFocus: I,
71
+ id: V,
72
+ style: L,
62
73
  ref: M,
63
- ...X,
64
- "aria-label": x["aria-label"],
65
- className: y("alea-button alea-focus-ring", z),
66
- children: P(N, !1)
74
+ ...O,
75
+ "aria-label": j["aria-label"],
76
+ className: w("alea-button alea-focus-ring", z),
77
+ children: K(y, !1)
67
78
  }
68
79
  );
69
80
  }
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: [
74
- t,
75
- /* @__PURE__ */ e(ie, { children: r["aria-label"] })
76
- ] }) : t;
81
+ return /* @__PURE__ */ e(te, { ...j, ...O, ref: M, isPending: m, className: w("alea-button alea-focus-ring", z), children: ae(y, (o, { isPending: d }) => K(o, d)) });
82
+ }), Te = C(function({ shape: t = "circle", variant: a = "ghost", tooltip: i, children: u, className: s, ...r }, m) {
83
+ const n = /* @__PURE__ */ e(Z, { ...r, ref: m, variant: a, "data-icon-shape": t, "data-icon-only": !0, className: w("alea-icon-button", s), children: /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(a, r.tone), children: u }) });
84
+ return i ? /* @__PURE__ */ h(ie, { delay: 400, children: [
85
+ n,
86
+ /* @__PURE__ */ e(se, { children: r["aria-label"] })
87
+ ] }) : n;
77
88
  });
78
- function Be({ items: l, value: a, defaultValue: o, onChange: i, size: u = "md", wrap: s, className: r, ...m }) {
89
+ function ke({ items: l, value: t, defaultValue: a, onChange: i, size: u = "md", wrap: s, className: r, ...m }) {
79
90
  return /* @__PURE__ */ e(
80
- ae,
91
+ oe,
81
92
  {
82
93
  ...m,
83
94
  selectionMode: "single",
84
95
  disallowEmptySelection: !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,
87
- onSelectionChange: (t) => {
88
- const c = [...t][0];
96
+ selectedKeys: t !== void 0 ? [t] : void 0,
97
+ defaultSelectedKeys: a !== void 0 ? [a] : t === void 0 && l[0] ? [l[0].id] : void 0,
98
+ onSelectionChange: (n) => {
99
+ const c = [...n][0];
89
100
  c !== void 0 && (i == null || i(c));
90
101
  },
91
102
  "data-size": u,
92
103
  "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: [
95
- /* @__PURE__ */ e("span", { className: "alea-segmented-label", children: t.label }),
96
- /* @__PURE__ */ e(oe, { className: "alea-sel-indicator" })
97
- ] }, String(t.id)))
104
+ className: w("alea-segmented", r),
105
+ children: l.map((n) => /* @__PURE__ */ h(J, { id: n.id, isDisabled: n.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
106
+ /* @__PURE__ */ e("span", { className: "alea-segmented-label", children: n.label }),
107
+ /* @__PURE__ */ e(le, { className: "alea-sel-indicator" })
108
+ ] }, String(n.id)))
98
109
  }
99
110
  );
100
111
  }
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) });
112
+ function Se({ size: l = "md", className: t, ...a }) {
113
+ return /* @__PURE__ */ e(J, { ...a, "data-size": l, className: w("alea-toggle-button alea-focus-ring", t) });
103
114
  }
104
- function q(l) {
115
+ function U(l) {
105
116
  try {
106
117
  typeof navigator < "u" && typeof navigator.vibrate == "function" && navigator.vibrate(l);
107
118
  } catch {
108
119
  }
109
120
  }
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 }) {
121
+ function Ae({ onConfirm: l, duration: t = 1200, hint: a, holdingLabel: i, confirmedMessage: u, haptic: s, celebrate: r, variant: m = "danger", className: n, children: c, ...R }) {
111
122
  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(() => {
123
+ a ?? (a = B.pressAndHold), u ?? (u = B.holdConfirmed);
124
+ const T = i === void 0 ? B.keepHolding : i, [f, b] = X(!1), [k, S] = X(""), g = E(null), p = E(`alea-hold-${Math.random().toString(36).slice(2, 8)}`).current, v = E(l);
125
+ v.current = l, A(() => {
115
126
  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(() => {
127
+ const y = window.setTimeout(() => {
128
+ b(!1), s && U([30, 40, 30]), r && g.current && ce(g.current), S(u), v.current();
129
+ }, t);
130
+ return () => window.clearTimeout(y);
131
+ }, [f, t, s, r, u]), A(() => {
121
132
  if (!k) return;
122
- const N = window.setTimeout(() => S(""), 3e3);
123
- return () => window.clearTimeout(N);
133
+ const y = window.setTimeout(() => S(""), 3e3);
134
+ return () => window.clearTimeout(y);
124
135
  }, [k]);
125
136
  const z = T != null && T !== !1 && typeof c != "function";
126
- return /* @__PURE__ */ h(C, { children: [
137
+ return /* @__PURE__ */ h(W, { children: [
127
138
  /* @__PURE__ */ e(
128
- U,
139
+ Z,
129
140
  {
130
- ...j,
141
+ ...R,
131
142
  ref: g,
132
143
  variant: m,
133
144
  "data-holding": f || void 0,
134
145
  "aria-describedby": p,
135
146
  onPressStart: () => {
136
- S(""), b(!0), s && q(10);
147
+ S(""), b(!0), s && U(10);
137
148
  },
138
149
  onPressEnd: () => b(!1),
139
- className: y("alea-hold", t),
140
- style: { "--alea-hold-duration": `${a}ms` },
150
+ className: w("alea-hold", n),
151
+ style: { "--alea-hold-duration": `${t}ms` },
141
152
  children: z ? (
142
153
  // 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
154
  // all the time; the "keep holding" text is for the eyes only (aria-hidden), the hint already tells a screen reader what to do.
@@ -148,14 +159,14 @@ function ke({ onConfirm: l, duration: a = 1200, hint: o, holdingLabel: i, confir
148
159
  ) : c
149
160
  }
150
161
  ),
151
- /* @__PURE__ */ e("span", { id: p, className: "alea-visually-hidden", children: o }),
162
+ /* @__PURE__ */ e("span", { id: p, className: "alea-visually-hidden", children: a }),
152
163
  /* @__PURE__ */ e("span", { role: "status", "aria-live": "polite", className: "alea-visually-hidden", children: k })
153
164
  ] });
154
165
  }
155
166
  export {
156
- U as Button,
157
- ke as HoldButton,
158
- ye as IconButton,
159
- Be as SegmentedControl,
160
- Te as ToggleButton
167
+ Z as Button,
168
+ Ae as HoldButton,
169
+ Te as IconButton,
170
+ ke as SegmentedControl,
171
+ Se as ToggleButton
161
172
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alea-design/ui",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Alea: the complete React design system. Accessible components from forms to AI, charts and editors, Alea Motion, and W3C design tokens for dark, light and high contrast.",
5
5
  "keywords": [
6
6
  "react",
@@ -61,8 +61,8 @@
61
61
  "react-dom": ">=18.3"
62
62
  },
63
63
  "dependencies": {
64
- "@alea-design/motion": "0.8.0",
65
- "@alea-design/tokens": "0.8.0",
64
+ "@alea-design/motion": "0.8.1",
65
+ "@alea-design/tokens": "0.8.1",
66
66
  "@internationalized/date": "^3.8.0",
67
67
  "lucide-react": "^0.525.0",
68
68
  "qrcode-generator": "^1.5.2",