@alea-design/ui 0.10.9 → 0.10.10
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.
- package/dist/components/button/Button.js +25 -24
- package/package.json +3 -3
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { jsx as e, jsxs as h, Fragment as W } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef as C, useRef as E, useEffect as A, useState as X } from "react";
|
|
4
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
|
|
5
|
+
import { Link as ne, Button as te, composeRenderProps as ae, ToggleButtonGroup as oe, ToggleButton as J, SelectionIndicator as re } from "react-aria-components";
|
|
6
6
|
import { withBase as w } from "../../utils/cx.js";
|
|
7
|
-
import { useMergedRef as
|
|
7
|
+
import { useMergedRef as le } from "../../utils/refs.js";
|
|
8
8
|
import { Spinner as Y } from "../feedback/Spinner.js";
|
|
9
9
|
import { useStrings as Q } from "../../i18n/strings.js";
|
|
10
10
|
import { responsiveAttrs as q } from "../../utils/responsive.js";
|
|
@@ -12,20 +12,21 @@ import { TooltipTrigger as ie, Tooltip as se } from "../overlay/Overlay.js";
|
|
|
12
12
|
import { buttonIcon as $ } from "../icon/icon-contexts.js";
|
|
13
13
|
import { celebrate as ce } from "../celebrate/Celebrate.js";
|
|
14
14
|
function G() {
|
|
15
|
-
|
|
16
|
-
(
|
|
15
|
+
if (!(typeof document > "u"))
|
|
16
|
+
for (const r of document.querySelectorAll('[data-live-announcer] [role="img"][aria-labelledby]'))
|
|
17
|
+
(r.getAttribute("aria-labelledby") ?? "").split(/\s+/).filter(Boolean).some((a) => document.getElementById(a)) || r.remove();
|
|
17
18
|
}
|
|
18
19
|
function de() {
|
|
19
20
|
A(() => () => {
|
|
20
21
|
typeof document > "u" || (setTimeout(G, 0), setTimeout(G, 150));
|
|
21
22
|
}, []);
|
|
22
23
|
}
|
|
23
|
-
const Z = C(function({ variant: t = "primary", tone: a, size: i, shape: u, iconStart: s, iconEnd:
|
|
24
|
+
const Z = C(function({ variant: t = "primary", tone: a, size: i, shape: u, iconStart: s, iconEnd: l, 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
25
|
const x = Q();
|
|
25
26
|
p ?? (p = x.done);
|
|
26
27
|
const D = E(null);
|
|
27
28
|
de();
|
|
28
|
-
const M =
|
|
29
|
+
const M = le(_, D), { onPointerDown: P } = ee();
|
|
29
30
|
A(() => {
|
|
30
31
|
const o = D.current;
|
|
31
32
|
if (!v || !o) return;
|
|
@@ -40,7 +41,7 @@ const Z = C(function({ variant: t = "primary", tone: a, size: i, shape: u, iconS
|
|
|
40
41
|
] }) : /* @__PURE__ */ h("span", { className: "alea-button-content", "data-hidden": d && !N || void 0, children: [
|
|
41
42
|
N && c !== "end" ? F : s && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(t, a), children: s }),
|
|
42
43
|
(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 :
|
|
44
|
+
N && c === "end" ? F : l && /* @__PURE__ */ e("span", { className: "alea-button-icon", "aria-hidden": "true", ...$(t, a), children: l }),
|
|
44
45
|
f && /* @__PURE__ */ e("kbd", { className: "alea-button-kbd", "aria-hidden": "true", children: f })
|
|
45
46
|
] })
|
|
46
47
|
] }), O = {
|
|
@@ -79,14 +80,14 @@ const Z = C(function({ variant: t = "primary", tone: a, size: i, shape: u, iconS
|
|
|
79
80
|
);
|
|
80
81
|
}
|
|
81
82
|
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, ...
|
|
83
|
-
const n = /* @__PURE__ */ e(Z, { ...
|
|
83
|
+
}), Te = C(function({ shape: t = "circle", variant: a = "ghost", tooltip: i, children: u, className: s, ...l }, m) {
|
|
84
|
+
const n = /* @__PURE__ */ e(Z, { ...l, 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, l.tone), children: u }) });
|
|
84
85
|
return i ? /* @__PURE__ */ h(ie, { delay: 400, children: [
|
|
85
86
|
n,
|
|
86
|
-
/* @__PURE__ */ e(se, { children:
|
|
87
|
+
/* @__PURE__ */ e(se, { children: l["aria-label"] })
|
|
87
88
|
] }) : n;
|
|
88
89
|
});
|
|
89
|
-
function ke({ items:
|
|
90
|
+
function ke({ items: r, value: t, defaultValue: a, onChange: i, size: u = "md", wrap: s, className: l, ...m }) {
|
|
90
91
|
return /* @__PURE__ */ e(
|
|
91
92
|
oe,
|
|
92
93
|
{
|
|
@@ -94,41 +95,41 @@ function ke({ items: l, value: t, defaultValue: a, onChange: i, size: u = "md",
|
|
|
94
95
|
selectionMode: "single",
|
|
95
96
|
disallowEmptySelection: !0,
|
|
96
97
|
selectedKeys: t !== void 0 ? [t] : void 0,
|
|
97
|
-
defaultSelectedKeys: a !== void 0 ? [a] : t === void 0 &&
|
|
98
|
+
defaultSelectedKeys: a !== void 0 ? [a] : t === void 0 && r[0] ? [r[0].id] : void 0,
|
|
98
99
|
onSelectionChange: (n) => {
|
|
99
100
|
const c = [...n][0];
|
|
100
101
|
c !== void 0 && (i == null || i(c));
|
|
101
102
|
},
|
|
102
103
|
"data-size": u,
|
|
103
104
|
"data-wrap": s || void 0,
|
|
104
|
-
className: w("alea-segmented",
|
|
105
|
-
children:
|
|
105
|
+
className: w("alea-segmented", l),
|
|
106
|
+
children: r.map((n) => /* @__PURE__ */ h(J, { id: n.id, isDisabled: n.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
|
|
106
107
|
/* @__PURE__ */ e("span", { className: "alea-segmented-label", children: n.label }),
|
|
107
|
-
/* @__PURE__ */ e(
|
|
108
|
+
/* @__PURE__ */ e(re, { className: "alea-sel-indicator" })
|
|
108
109
|
] }, String(n.id)))
|
|
109
110
|
}
|
|
110
111
|
);
|
|
111
112
|
}
|
|
112
|
-
function Se({ size:
|
|
113
|
-
return /* @__PURE__ */ e(J, { ...a, "data-size":
|
|
113
|
+
function Se({ size: r = "md", className: t, ...a }) {
|
|
114
|
+
return /* @__PURE__ */ e(J, { ...a, "data-size": r, className: w("alea-toggle-button alea-focus-ring", t) });
|
|
114
115
|
}
|
|
115
|
-
function U(
|
|
116
|
+
function U(r) {
|
|
116
117
|
try {
|
|
117
|
-
typeof navigator < "u" && typeof navigator.vibrate == "function" && navigator.vibrate(
|
|
118
|
+
typeof navigator < "u" && typeof navigator.vibrate == "function" && navigator.vibrate(r);
|
|
118
119
|
} catch {
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
function Ae({ onConfirm:
|
|
122
|
+
function Ae({ onConfirm: r, duration: t = 1200, hint: a, holdingLabel: i, confirmedMessage: u, haptic: s, celebrate: l, variant: m = "danger", className: n, children: c, ...R }) {
|
|
122
123
|
const B = Q();
|
|
123
124
|
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(
|
|
125
|
-
v.current =
|
|
125
|
+
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(r);
|
|
126
|
+
v.current = r, A(() => {
|
|
126
127
|
if (!f) return;
|
|
127
128
|
const y = window.setTimeout(() => {
|
|
128
|
-
b(!1), s && U([30, 40, 30]),
|
|
129
|
+
b(!1), s && U([30, 40, 30]), l && g.current && ce(g.current), S(u), v.current();
|
|
129
130
|
}, t);
|
|
130
131
|
return () => window.clearTimeout(y);
|
|
131
|
-
}, [f, t, s,
|
|
132
|
+
}, [f, t, s, l, u]), A(() => {
|
|
132
133
|
if (!k) return;
|
|
133
134
|
const y = window.setTimeout(() => S(""), 3e3);
|
|
134
135
|
return () => window.clearTimeout(y);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/ui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.10",
|
|
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.10.
|
|
65
|
-
"@alea-design/tokens": "0.10.
|
|
64
|
+
"@alea-design/motion": "0.10.10",
|
|
65
|
+
"@alea-design/tokens": "0.10.10",
|
|
66
66
|
"@internationalized/date": "^3.8.0",
|
|
67
67
|
"lucide-react": "^0.525.0",
|
|
68
68
|
"qrcode-generator": "^1.5.2",
|