@alea-design/ui 0.8.0 → 0.8.2
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
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { useRipple as
|
|
5
|
-
import { Link as
|
|
6
|
-
import { withBase as
|
|
7
|
-
import { useMergedRef as
|
|
8
|
-
import { Spinner as
|
|
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
|
|
11
|
-
import { TooltipTrigger as
|
|
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
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
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 && !
|
|
30
|
-
|
|
31
|
-
(
|
|
32
|
-
|
|
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
|
-
] }),
|
|
46
|
+
] }), O = {
|
|
36
47
|
"data-success": g || void 0,
|
|
37
48
|
"data-ripple": v || void 0,
|
|
38
|
-
"data-variant":
|
|
39
|
-
"data-tone":
|
|
40
|
-
...
|
|
41
|
-
...
|
|
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 (
|
|
47
|
-
const
|
|
48
|
-
|
|
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:
|
|
61
|
+
const { onPress: o, isDisabled: d, autoFocus: I, id: V, style: L } = j;
|
|
51
62
|
return /* @__PURE__ */ e(
|
|
52
|
-
|
|
63
|
+
ne,
|
|
53
64
|
{
|
|
54
65
|
href: b,
|
|
55
66
|
target: k,
|
|
56
67
|
rel: S,
|
|
57
|
-
onPress:
|
|
68
|
+
onPress: o,
|
|
58
69
|
isDisabled: d,
|
|
59
|
-
autoFocus:
|
|
60
|
-
id:
|
|
61
|
-
style:
|
|
70
|
+
autoFocus: I,
|
|
71
|
+
id: V,
|
|
72
|
+
style: L,
|
|
62
73
|
ref: M,
|
|
63
|
-
...
|
|
64
|
-
"aria-label":
|
|
65
|
-
className:
|
|
66
|
-
children:
|
|
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, { ...
|
|
71
|
-
}),
|
|
72
|
-
const
|
|
73
|
-
return i ? /* @__PURE__ */ h(
|
|
74
|
-
|
|
75
|
-
/* @__PURE__ */ e(
|
|
76
|
-
] }) :
|
|
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
|
|
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
|
-
|
|
91
|
+
oe,
|
|
81
92
|
{
|
|
82
93
|
...m,
|
|
83
94
|
selectionMode: "single",
|
|
84
95
|
disallowEmptySelection: !0,
|
|
85
|
-
selectedKeys:
|
|
86
|
-
defaultSelectedKeys:
|
|
87
|
-
onSelectionChange: (
|
|
88
|
-
const c = [...
|
|
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:
|
|
94
|
-
children: l.map((
|
|
95
|
-
/* @__PURE__ */ e("span", { className: "alea-segmented-label", children:
|
|
96
|
-
/* @__PURE__ */ e(
|
|
97
|
-
] }, String(
|
|
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
|
|
102
|
-
return /* @__PURE__ */ e(
|
|
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
|
|
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
|
|
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
|
-
|
|
113
|
-
const T = i === void 0 ? B.keepHolding : i, [f, b] =
|
|
114
|
-
v.current = l,
|
|
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
|
|
117
|
-
b(!1), s &&
|
|
118
|
-
},
|
|
119
|
-
return () => window.clearTimeout(
|
|
120
|
-
}, [f,
|
|
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
|
|
123
|
-
return () => window.clearTimeout(
|
|
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(
|
|
137
|
+
return /* @__PURE__ */ h(W, { children: [
|
|
127
138
|
/* @__PURE__ */ e(
|
|
128
|
-
|
|
139
|
+
Z,
|
|
129
140
|
{
|
|
130
|
-
...
|
|
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 &&
|
|
147
|
+
S(""), b(!0), s && U(10);
|
|
137
148
|
},
|
|
138
149
|
onPressEnd: () => b(!1),
|
|
139
|
-
className:
|
|
140
|
-
style: { "--alea-hold-duration": `${
|
|
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:
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
167
|
+
Z as Button,
|
|
168
|
+
Ae as HoldButton,
|
|
169
|
+
Te as IconButton,
|
|
170
|
+
ke as SegmentedControl,
|
|
171
|
+
Se as ToggleButton
|
|
161
172
|
};
|
|
@@ -1,93 +1,118 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as n, jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { cx as
|
|
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
|
|
6
|
-
import { Search as
|
|
7
|
-
import { DialogModal as
|
|
8
|
-
import { Kbd as
|
|
2
|
+
import { jsx as n, jsxs as b } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as $, useState as y, useEffect as K, useMemo as x, useRef as B } from "react";
|
|
4
|
+
import { cx as J } from "../../utils/cx.js";
|
|
5
|
+
import { useFilter as Y, Autocomplete as Z, SearchField as Q, Input as G, Menu as ee, MenuSection as te, Header as ne, Collection as ie, MenuItem as D, Keyboard as ae } from "react-aria-components";
|
|
6
|
+
import { Search as se } from "lucide-react";
|
|
7
|
+
import { DialogModal as oe, Dialog as re } from "../overlay/Overlay.js";
|
|
8
|
+
import { Kbd as le } from "../typography/Typography.js";
|
|
9
9
|
import { useStrings as ce } from "../../i18n/strings.js";
|
|
10
|
-
const
|
|
11
|
-
function de({ children:
|
|
12
|
-
const
|
|
13
|
-
return
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const c = new ResizeObserver(
|
|
19
|
-
return c.observe(
|
|
20
|
-
}, []),
|
|
10
|
+
const A = "__more:";
|
|
11
|
+
function de({ children: C }) {
|
|
12
|
+
const d = B(null), [N, g] = y(!1);
|
|
13
|
+
return K(() => {
|
|
14
|
+
const o = d.current;
|
|
15
|
+
if (!o) return;
|
|
16
|
+
const r = () => g(o.scrollHeight > o.clientHeight + 1);
|
|
17
|
+
if (r(), typeof ResizeObserver > "u") return;
|
|
18
|
+
const c = new ResizeObserver(r);
|
|
19
|
+
return c.observe(o), o.firstElementChild && c.observe(o.firstElementChild), () => c.disconnect();
|
|
20
|
+
}, []), K(() => {
|
|
21
|
+
var h;
|
|
22
|
+
const o = d.current;
|
|
23
|
+
if (!o) return;
|
|
24
|
+
const r = (h = o.closest(".alea-command")) == null ? void 0 : h.querySelector(".alea-command-input");
|
|
25
|
+
if (!r) return;
|
|
26
|
+
const c = () => o.querySelector('[role="menuitem"][data-focused]'), v = () => {
|
|
27
|
+
var m;
|
|
28
|
+
const i = ((m = c()) == null ? void 0 : m.id) ?? null;
|
|
29
|
+
r.getAttribute("aria-activedescendant") !== i && (i ? r.setAttribute("aria-activedescendant", i) : r.removeAttribute("aria-activedescendant"));
|
|
30
|
+
}, u = new MutationObserver(v);
|
|
31
|
+
u.observe(o, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["data-focused"] }), u.observe(r, { attributes: !0, attributeFilter: ["aria-activedescendant"] });
|
|
32
|
+
const f = (i) => {
|
|
33
|
+
var m;
|
|
34
|
+
if (i.key === "Enter") {
|
|
35
|
+
if (i.isComposing || i.keyCode === 229) {
|
|
36
|
+
i.stopPropagation();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
i.preventDefault(), i.stopPropagation(), (m = c()) == null || m.click();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return r.addEventListener("keydown", f), v(), () => {
|
|
43
|
+
u.disconnect(), r.removeEventListener("keydown", f);
|
|
44
|
+
};
|
|
45
|
+
}, []), /* @__PURE__ */ n("div", { ref: d, className: "alea-command-scroll", tabIndex: N ? 0 : void 0, children: C });
|
|
21
46
|
}
|
|
22
|
-
const
|
|
47
|
+
const Ne = $(function({ commands: d, isOpen: N, defaultOpen: g, onOpenChange: o, motion: r, hotkey: c = !0, slashHotkey: v, onQueryChange: u, filter: f, isLoading: h, maxPerGroup: i, placeholder: m, emptyText: R, className: j, style: z, surface: O, radius: T }, V) {
|
|
23
48
|
const l = ce();
|
|
24
|
-
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
|
|
49
|
+
m ?? (m = l.commandPlaceholder), R ?? (R = l.noResults);
|
|
50
|
+
const [q, H] = y(g ?? !1), S = N ?? q, [p, P] = y(""), [F, I] = y(/* @__PURE__ */ new Set()), L = (s) => {
|
|
51
|
+
P(s), u == null || u(s);
|
|
52
|
+
}, E = (s) => {
|
|
53
|
+
s || (p && L(""), I(/* @__PURE__ */ new Set())), N === void 0 && H(s), o == null || o(s);
|
|
29
54
|
};
|
|
30
|
-
|
|
31
|
-
if (!c && !
|
|
32
|
-
const
|
|
55
|
+
K(() => {
|
|
56
|
+
if (!c && !v) return;
|
|
57
|
+
const s = (t) => {
|
|
33
58
|
if (c && t.key.toLowerCase() === "k" && (t.metaKey || t.ctrlKey)) {
|
|
34
|
-
t.preventDefault(),
|
|
59
|
+
t.preventDefault(), E(!S);
|
|
35
60
|
return;
|
|
36
61
|
}
|
|
37
|
-
if (
|
|
62
|
+
if (v && !S && t.key === "/" && !t.metaKey && !t.ctrlKey && !t.altKey) {
|
|
38
63
|
const e = t.target;
|
|
39
64
|
if (e && (e.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))) return;
|
|
40
|
-
t.preventDefault(),
|
|
65
|
+
t.preventDefault(), E(!0);
|
|
41
66
|
}
|
|
42
67
|
};
|
|
43
|
-
return window.addEventListener("keydown",
|
|
68
|
+
return window.addEventListener("keydown", s), () => window.removeEventListener("keydown", s);
|
|
44
69
|
});
|
|
45
|
-
const { contains: W } = Y({ sensitivity: "base" }), { groups:
|
|
46
|
-
const
|
|
70
|
+
const { contains: W } = Y({ sensitivity: "base" }), { groups: k, total: _ } = x(() => {
|
|
71
|
+
const s = (a) => f === !1 || !p ? !0 : f ? f(a, p) : W([a.label, ...a.keywords || []].join(" "), p), t = [];
|
|
47
72
|
let e = 0;
|
|
48
|
-
for (const
|
|
49
|
-
if (!
|
|
73
|
+
for (const a of d) {
|
|
74
|
+
if (!s(a)) continue;
|
|
50
75
|
e++;
|
|
51
|
-
const
|
|
52
|
-
let
|
|
53
|
-
|
|
76
|
+
const w = a.group || "";
|
|
77
|
+
let M = t.find((X) => X.id === w);
|
|
78
|
+
M || t.push(M = { id: w, title: w, items: [] }), M.items.push(a);
|
|
54
79
|
}
|
|
55
|
-
if (
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
80
|
+
if (i && i > 0) for (const a of t) {
|
|
81
|
+
if (F.has(a.id) || a.items.length <= i) continue;
|
|
82
|
+
const w = a.items.length - i;
|
|
83
|
+
a.items = [...a.items.slice(0, i), { id: A + a.id, more: w, group: a.id }];
|
|
59
84
|
}
|
|
60
85
|
return { groups: t, total: e };
|
|
61
|
-
}, [
|
|
62
|
-
return /* @__PURE__ */ n(
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
/* @__PURE__ */ n(
|
|
65
|
-
/* @__PURE__ */ n(G, { placeholder:
|
|
66
|
-
/* @__PURE__ */ n(
|
|
86
|
+
}, [d, p, f, i, F]), U = x(() => new Map(d.map((s) => [s.id, s])), [d]);
|
|
87
|
+
return /* @__PURE__ */ n(oe, { isOpen: S, onOpenChange: E, size: "md", className: "alea-command-overlay", motion: r, surface: O, radius: T, children: /* @__PURE__ */ n(re, { ref: V, style: z, "aria-label": l.commandPalette, hideClose: !0, className: J("alea-command", j), children: ({ close: s }) => /* @__PURE__ */ b(Z, { inputValue: p, onInputChange: L, filter: () => !0, children: [
|
|
88
|
+
/* @__PURE__ */ b(Q, { "aria-label": l.searchCommands, autoFocus: !0, className: "alea-command-search", children: [
|
|
89
|
+
/* @__PURE__ */ n(se, { size: 18, "aria-hidden": "true" }),
|
|
90
|
+
/* @__PURE__ */ n(G, { placeholder: m, className: "alea-command-input" }),
|
|
91
|
+
/* @__PURE__ */ n(le, { children: l.esc })
|
|
67
92
|
] }),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
|
|
70
|
-
if (String(t).startsWith(
|
|
71
|
-
|
|
93
|
+
/* @__PURE__ */ b(de, { children: [
|
|
94
|
+
k.length > 0 && /* @__PURE__ */ n(ee, { shouldFocusWrap: !1, items: k, className: "alea-command-list", "aria-busy": h || void 0, onAction: (t) => {
|
|
95
|
+
if (String(t).startsWith(A)) {
|
|
96
|
+
I((a) => new Set(a).add(String(t).slice(A.length)));
|
|
72
97
|
return;
|
|
73
98
|
}
|
|
74
|
-
const e =
|
|
75
|
-
|
|
76
|
-
}, children: (t) => /* @__PURE__ */
|
|
99
|
+
const e = U.get(t);
|
|
100
|
+
s(), e == null || e.onAction();
|
|
101
|
+
}, children: (t) => /* @__PURE__ */ b(te, { id: t.id, className: "alea-option-section", children: [
|
|
77
102
|
t.title && /* @__PURE__ */ n(ne, { className: "alea-option-header", children: t.title }),
|
|
78
|
-
/* @__PURE__ */ n(
|
|
103
|
+
/* @__PURE__ */ n(ie, { items: t.items, children: (e) => "more" in e ? /* @__PURE__ */ n(D, { id: e.id, textValue: l.showNMore(e.more), className: "alea-option alea-command-item alea-command-more", children: /* @__PURE__ */ n("span", { className: "alea-option-text", children: /* @__PURE__ */ n("span", { slot: "label", children: l.showNMore(e.more) }) }) }) : /* @__PURE__ */ b(D, { id: e.id, textValue: [e.label, ...e.keywords || []].join(" "), className: "alea-option alea-command-item", children: [
|
|
79
104
|
e.icon && /* @__PURE__ */ n("span", { className: "alea-option-icon", "aria-hidden": "true", children: e.icon }),
|
|
80
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ b("span", { className: "alea-option-text", children: [
|
|
81
106
|
/* @__PURE__ */ n("span", { slot: "label", children: e.label }),
|
|
82
107
|
e.description && /* @__PURE__ */ n("span", { className: "alea-option-desc", slot: "description", children: e.description })
|
|
83
108
|
] }),
|
|
84
|
-
e.shortcut && /* @__PURE__ */ n(
|
|
109
|
+
e.shortcut && /* @__PURE__ */ n(ae, { className: "alea-menu-shortcut", children: e.shortcut })
|
|
85
110
|
] }) })
|
|
86
111
|
] }) }),
|
|
87
|
-
/* @__PURE__ */ n("div", { role: "status", children:
|
|
112
|
+
/* @__PURE__ */ n("div", { role: "status", children: k.length === 0 ? /* @__PURE__ */ n("p", { className: "alea-command-empty", children: h ? l.loading : R }) : h ? /* @__PURE__ */ n("p", { className: "alea-command-loading", children: l.loading }) : p ? /* @__PURE__ */ n("span", { className: "alea-visually-hidden", children: l.resultsCount(_) }) : null })
|
|
88
113
|
] })
|
|
89
114
|
] }) }) });
|
|
90
115
|
});
|
|
91
116
|
export {
|
|
92
|
-
|
|
117
|
+
Ne as CommandPalette
|
|
93
118
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
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.
|
|
65
|
-
"@alea-design/tokens": "0.8.
|
|
64
|
+
"@alea-design/motion": "0.8.2",
|
|
65
|
+
"@alea-design/tokens": "0.8.2",
|
|
66
66
|
"@internationalized/date": "^3.8.0",
|
|
67
67
|
"lucide-react": "^0.525.0",
|
|
68
68
|
"qrcode-generator": "^1.5.2",
|