@alea-design/ui 0.5.0 → 0.6.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.
- package/dist/components/button/Button.d.ts +3 -1
- package/dist/components/button/Button.js +64 -63
- package/dist/components/card/Card.d.ts +6 -2
- package/dist/components/card/Card.js +20 -20
- package/dist/components/combobox/Autocomplete.d.ts +4 -0
- package/dist/components/combobox/Autocomplete.js +89 -87
- package/dist/components/command/CommandPalette.d.ts +10 -0
- package/dist/components/command/CommandPalette.js +76 -52
- package/dist/components/data/Data.d.ts +6 -4
- package/dist/components/data/Data.js +66 -56
- package/dist/components/date/Date.d.ts +16 -2
- package/dist/components/date/Date.js +80 -69
- package/dist/components/display/Display.d.ts +3 -1
- package/dist/components/display/Display.js +27 -27
- package/dist/components/display/Display2.d.ts +2 -2
- package/dist/components/display/Display2.js +28 -27
- package/dist/components/feedback/Feedback.d.ts +3 -1
- package/dist/components/feedback/Feedback.js +102 -102
- package/dist/components/feedback/PageSkeleton.d.ts +19 -0
- package/dist/components/feedback/PageSkeleton.js +58 -0
- package/dist/components/field/Field.d.ts +3 -1
- package/dist/components/field/Field.js +82 -82
- package/dist/components/filter/FilterBar.d.ts +5 -2
- package/dist/components/filter/FilterBar.js +97 -66
- package/dist/components/form/Form.d.ts +8 -2
- package/dist/components/form/Form.js +53 -40
- package/dist/components/icon/icon-names.d.ts +2 -2
- package/dist/components/icon/icon-names.js +4 -2
- package/dist/components/list/List.d.ts +6 -2
- package/dist/components/list/List.js +65 -62
- package/dist/components/list/Lists2.d.ts +4 -0
- package/dist/components/list/Lists2.js +35 -35
- package/dist/components/media/Media.js +27 -27
- package/dist/components/more/More.d.ts +2 -2
- package/dist/components/more/More.js +46 -45
- package/dist/components/navigation/Navigation.d.ts +7 -5
- package/dist/components/navigation/Navigation.js +91 -74
- package/dist/components/navigation/Navigation2.d.ts +9 -3
- package/dist/components/navigation/Navigation2.js +209 -195
- package/dist/components/notification/NotificationCenter.js +70 -70
- package/dist/components/overlay/Drawer.d.ts +6 -1
- package/dist/components/overlay/Drawer.js +27 -25
- package/dist/components/overlay/Modal.d.ts +5 -0
- package/dist/components/overlay/Modal.js +16 -15
- package/dist/components/overlay/Overlay.d.ts +10 -1
- package/dist/components/overlay/Overlay.js +54 -52
- package/dist/components/overlay/Sheet.d.ts +2 -0
- package/dist/components/overlay/Sheet.js +30 -30
- package/dist/components/page/PageParts.js +20 -20
- package/dist/components/select/Select.js +75 -70
- package/dist/components/settings/Settings.d.ts +29 -0
- package/dist/components/settings/Settings.js +31 -0
- package/dist/components/shell/AccountMenu.d.ts +20 -0
- package/dist/components/shell/AccountMenu.js +32 -0
- package/dist/components/shell/AppShell.d.ts +9 -2
- package/dist/components/shell/AppShell.js +37 -37
- package/dist/components/shell/AppSidebar.d.ts +9 -3
- package/dist/components/shell/AppSidebar.js +45 -39
- package/dist/components/table/Table.d.ts +18 -4
- package/dist/components/table/Table.js +70 -46
- package/dist/components/tabs/Tabs.js +105 -94
- package/dist/components/theme/Theme.d.ts +7 -4
- package/dist/components/theme/Theme.js +127 -130
- package/dist/components/upload/Upload.js +62 -54
- package/dist/css/base.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/card.css +1 -1
- package/dist/css/command.css +1 -1
- package/dist/css/date.css +1 -1
- package/dist/css/display.css +1 -1
- package/dist/css/feedback.css +1 -1
- package/dist/css/field.css +1 -1
- package/dist/css/form.css +1 -1
- package/dist/css/groups.json +393 -21
- package/dist/css/list.css +1 -1
- package/dist/css/menu.css +1 -1
- package/dist/css/navigation.css +1 -1
- package/dist/css/notification.css +1 -1
- package/dist/css/overlay.css +1 -1
- package/dist/css/page.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/css/settings.css +1 -0
- package/dist/css/shell.css +1 -1
- package/dist/css/table.css +1 -1
- package/dist/css/tabs.css +1 -1
- package/dist/css/upload.css +1 -1
- package/dist/i18n/strings.d.ts +8 -0
- package/dist/i18n/strings.js +16 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +318 -306
- package/dist/styles.css +1 -1
- package/dist/utils/animateRows.d.ts +11 -0
- package/dist/utils/animateRows.js +23 -0
- package/dist/utils/decimal.d.ts +12 -0
- package/dist/utils/decimal.js +48 -0
- package/dist/utils/initialFocus.d.ts +6 -0
- package/dist/utils/initialFocus.js +24 -0
- package/dist/utils/refs.d.ts +2 -0
- package/dist/utils/refs.js +14 -6
- package/package.json +3 -3
|
@@ -26,6 +26,8 @@ export interface ButtonProps extends Omit<RACButtonProps, 'isPending'> {
|
|
|
26
26
|
loadingPosition?: 'center' | 'start' | 'end';
|
|
27
27
|
/** Stretches to the width of its container. Can change per breakpoint: { base: true, md: false } is full width on phones only. */
|
|
28
28
|
fullWidth?: Responsive<boolean>;
|
|
29
|
+
/** Lets a long label break onto several lines (the button grows, keeping its minimum height) instead of staying on one line with an ellipsis. For narrow screens and large text. */
|
|
30
|
+
wrap?: boolean;
|
|
29
31
|
/** How the content sits in a wide button: center (default), start, or between (label left, end icon right). */
|
|
30
32
|
justify?: 'center' | 'start' | 'between';
|
|
31
33
|
/** A keyboard shortcut shown at the end, like ⌘S (also set as aria-keyshortcuts when it is text). */
|
|
@@ -45,7 +47,7 @@ export interface ButtonProps extends Omit<RACButtonProps, 'isPending'> {
|
|
|
45
47
|
}
|
|
46
48
|
/** The action button: eight looks, six tones, five sizes, three shapes, icons, a shortcut, loading and success states, and links that look like buttons. */
|
|
47
49
|
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
48
|
-
export interface IconButtonProps extends Omit<ButtonProps, 'iconStart' | 'iconEnd' | 'children' | 'fullWidth' | 'shape' | 'loadingLabel' | 'loadingPosition' | 'justify' | 'shortcut'> {
|
|
50
|
+
export interface IconButtonProps extends Omit<ButtonProps, 'iconStart' | 'iconEnd' | 'children' | 'fullWidth' | 'shape' | 'loadingLabel' | 'loadingPosition' | 'justify' | 'wrap' | 'shortcut'> {
|
|
49
51
|
/** What the button does, for screen readers (the icon has no text). */
|
|
50
52
|
'aria-label': string;
|
|
51
53
|
/** The icon. */
|
|
@@ -1,62 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e, jsxs as p, Fragment as Y } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef as G, useRef as A, useEffect as I, useState as
|
|
4
|
-
import { useRipple as
|
|
5
|
-
import { Link as
|
|
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
6
|
import { withBase as b } from "../../utils/cx.js";
|
|
7
|
-
import { useMergedRef as
|
|
7
|
+
import { useMergedRef as oe } from "../../utils/refs.js";
|
|
8
8
|
import { Spinner as P } from "../feedback/Spinner.js";
|
|
9
9
|
import { useStrings as q } from "../../i18n/strings.js";
|
|
10
10
|
import { responsiveAttrs as X } from "../../utils/responsive.js";
|
|
11
|
-
import { TooltipTrigger as
|
|
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:
|
|
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) {
|
|
14
14
|
const T = q();
|
|
15
|
-
|
|
16
|
-
const E = A(null), D =
|
|
15
|
+
B ?? (B = T.done);
|
|
16
|
+
const E = A(null), D = oe(Q, E), { onPointerDown: $ } = C();
|
|
17
17
|
I(() => {
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
const s = (
|
|
21
|
-
return
|
|
22
|
-
}, [
|
|
23
|
-
const h = o && (r != null ||
|
|
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);
|
|
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
24
|
s && !h && /* @__PURE__ */ e("span", { className: "alea-button-spinner", children: /* @__PURE__ */ e(P, { size: "sm", "aria-label": T.loading }) }),
|
|
25
25
|
R && !s ? /* @__PURE__ */ p("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
28
|
] }) : /* @__PURE__ */ p("span", { className: "alea-button-content", "data-hidden": s && !h || void 0, children: [
|
|
29
|
-
h &&
|
|
30
|
-
(h && r != null ? r :
|
|
31
|
-
h &&
|
|
32
|
-
|
|
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 }),
|
|
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
|
-
"data-ripple":
|
|
36
|
+
"data-ripple": k || void 0,
|
|
37
37
|
"data-variant": a,
|
|
38
|
-
"data-tone":
|
|
38
|
+
"data-tone": n,
|
|
39
39
|
...X("size", c, "md"),
|
|
40
40
|
...X("full-width", N),
|
|
41
|
-
"data-shape":
|
|
42
|
-
"data-justify": v
|
|
43
|
-
|
|
41
|
+
"data-shape": u,
|
|
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;
|
|
44
45
|
if (I(() => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}, [z]),
|
|
48
|
-
const { onPress:
|
|
46
|
+
const t = E.current;
|
|
47
|
+
t && (z ? t.setAttribute("aria-keyshortcuts", z) : t.removeAttribute("aria-keyshortcuts"));
|
|
48
|
+
}, [z]), y) {
|
|
49
|
+
const { onPress: t, isDisabled: s, autoFocus: w, id: U, style: Z } = S;
|
|
49
50
|
return /* @__PURE__ */ e(
|
|
50
|
-
|
|
51
|
+
V,
|
|
51
52
|
{
|
|
52
|
-
href:
|
|
53
|
-
target:
|
|
54
|
-
rel:
|
|
55
|
-
onPress:
|
|
53
|
+
href: y,
|
|
54
|
+
target: L,
|
|
55
|
+
rel: O,
|
|
56
|
+
onPress: t,
|
|
56
57
|
isDisabled: s,
|
|
57
|
-
autoFocus:
|
|
58
|
-
id:
|
|
59
|
-
style:
|
|
58
|
+
autoFocus: w,
|
|
59
|
+
id: U,
|
|
60
|
+
style: Z,
|
|
60
61
|
ref: D,
|
|
61
62
|
...K,
|
|
62
63
|
"aria-label": S["aria-label"],
|
|
@@ -65,15 +66,15 @@ const J = G(function({ variant: a = "primary", tone: t, size: c, shape: m, iconS
|
|
|
65
66
|
}
|
|
66
67
|
);
|
|
67
68
|
}
|
|
68
|
-
return /* @__PURE__ */ e(
|
|
69
|
-
}),
|
|
70
|
-
const r = /* @__PURE__ */ e(J, { ...i, ref: o, variant:
|
|
71
|
-
return c ? /* @__PURE__ */ p(
|
|
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: [
|
|
72
73
|
r,
|
|
73
|
-
/* @__PURE__ */ e(
|
|
74
|
+
/* @__PURE__ */ e(le, { children: i["aria-label"] })
|
|
74
75
|
] }) : r;
|
|
75
76
|
});
|
|
76
|
-
function
|
|
77
|
+
function ve({ items: l, value: a, defaultValue: n, onChange: c, size: u = "md", className: d, ...i }) {
|
|
77
78
|
return /* @__PURE__ */ e(
|
|
78
79
|
ne,
|
|
79
80
|
{
|
|
@@ -81,34 +82,34 @@ function Ne({ items: l, value: a, defaultValue: t, onChange: c, size: m = "md",
|
|
|
81
82
|
selectionMode: "single",
|
|
82
83
|
disallowEmptySelection: !0,
|
|
83
84
|
selectedKeys: a !== void 0 ? [a] : void 0,
|
|
84
|
-
defaultSelectedKeys:
|
|
85
|
+
defaultSelectedKeys: n !== void 0 ? [n] : a === void 0 && l[0] ? [l[0].id] : void 0,
|
|
85
86
|
onSelectionChange: (o) => {
|
|
86
87
|
const r = [...o][0];
|
|
87
88
|
r !== void 0 && (c == null || c(r));
|
|
88
89
|
},
|
|
89
|
-
"data-size":
|
|
90
|
+
"data-size": u,
|
|
90
91
|
className: b("alea-segmented", d),
|
|
91
92
|
children: l.map((o) => /* @__PURE__ */ p(W, { id: o.id, isDisabled: o.isDisabled, className: "alea-segmented-item alea-focus-ring", children: [
|
|
92
93
|
/* @__PURE__ */ e("span", { className: "alea-segmented-label", children: o.label }),
|
|
93
|
-
/* @__PURE__ */ e(
|
|
94
|
+
/* @__PURE__ */ e(ae, { className: "alea-sel-indicator" })
|
|
94
95
|
] }, String(o.id)))
|
|
95
96
|
}
|
|
96
97
|
);
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
return /* @__PURE__ */ e(W, { ...
|
|
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
101
|
}
|
|
101
|
-
function
|
|
102
|
+
function Be({ onConfirm: l, duration: a = 1200, hint: n, variant: c = "danger", className: u, children: d, ...i }) {
|
|
102
103
|
const o = q();
|
|
103
|
-
|
|
104
|
-
const [r,
|
|
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;
|
|
105
106
|
return I(() => {
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
108
|
-
const
|
|
109
|
-
|
|
107
|
+
const g = N.current;
|
|
108
|
+
if (!g) return;
|
|
109
|
+
const f = (y) => {
|
|
110
|
+
y.animationName === "alea-hold" && (m(!1), l());
|
|
110
111
|
};
|
|
111
|
-
return
|
|
112
|
+
return g.addEventListener("animationend", f), () => g.removeEventListener("animationend", f);
|
|
112
113
|
}, [l]), /* @__PURE__ */ p(Y, { children: [
|
|
113
114
|
/* @__PURE__ */ e(
|
|
114
115
|
J,
|
|
@@ -118,20 +119,20 @@ function ye({ onConfirm: l, duration: a = 1200, hint: t, variant: c = "danger",
|
|
|
118
119
|
variant: c,
|
|
119
120
|
"data-holding": r || void 0,
|
|
120
121
|
"aria-describedby": v,
|
|
121
|
-
onPressStart: () =>
|
|
122
|
-
onPressEnd: () =>
|
|
123
|
-
className: b("alea-hold",
|
|
122
|
+
onPressStart: () => m(!0),
|
|
123
|
+
onPressEnd: () => m(!1),
|
|
124
|
+
className: b("alea-hold", u),
|
|
124
125
|
style: { "--alea-hold-duration": `${a}ms` },
|
|
125
126
|
children: d
|
|
126
127
|
}
|
|
127
128
|
),
|
|
128
|
-
/* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children:
|
|
129
|
+
/* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children: n })
|
|
129
130
|
] });
|
|
130
131
|
}
|
|
131
132
|
export {
|
|
132
133
|
J as Button,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
Be as HoldButton,
|
|
135
|
+
Ne as IconButton,
|
|
136
|
+
ve as SegmentedControl,
|
|
137
|
+
ye as ToggleButton
|
|
137
138
|
};
|
|
@@ -20,9 +20,11 @@ export declare function Card({ variant, padding, interactive, as, orientation, i
|
|
|
20
20
|
export interface CardTitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
21
21
|
/** The heading element. Default h3; match the page outline. */
|
|
22
22
|
as?: ElementType;
|
|
23
|
+
/** md (default): the large display title. sm: the compact title of a card header (16 px, semibold), for cards in a settings page or a dense layout. */
|
|
24
|
+
size?: 'sm' | 'md';
|
|
23
25
|
}
|
|
24
26
|
/** Card title in Crimson Pro. */
|
|
25
|
-
export declare function CardTitle({ as, className, ...props }: CardTitleProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
27
|
+
export declare function CardTitle({ as, size, className, ...props }: CardTitleProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
26
28
|
/** Card body text, muted. */
|
|
27
29
|
export declare function CardDescription({ className, ...props }: HTMLAttributes<HTMLParagraphElement>): import("react").JSX.Element;
|
|
28
30
|
/** Makes the whole card clickable through one real link (keeps one tab stop and the link text as the name). */
|
|
@@ -38,10 +40,12 @@ export interface CardHeaderProps {
|
|
|
38
40
|
actions?: ReactNode;
|
|
39
41
|
/** Heading level of the title. Default 3. */
|
|
40
42
|
headingLevel?: 2 | 3 | 4 | 5;
|
|
43
|
+
/** Size of the title: sm (14 px), md (16 px, default) or lg (20 px). All semibold. */
|
|
44
|
+
titleSize?: 'sm' | 'md' | 'lg';
|
|
41
45
|
className?: string;
|
|
42
46
|
}
|
|
43
47
|
/** The top of a card: media, title, subtitle and actions. */
|
|
44
|
-
export declare function CardHeader({ title, subtitle, media, actions, headingLevel, className }: CardHeaderProps): import("react").JSX.Element;
|
|
48
|
+
export declare function CardHeader({ title, subtitle, media, actions, headingLevel, titleSize, className }: CardHeaderProps): import("react").JSX.Element;
|
|
45
49
|
export interface CardMediaProps {
|
|
46
50
|
/** The image URL, or your own media as children. */
|
|
47
51
|
src?: string;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { createElement as
|
|
4
|
-
import { cx as
|
|
2
|
+
import { jsx as r, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
import { createElement as o } from "react";
|
|
4
|
+
import { cx as s } from "../../utils/cx.js";
|
|
5
5
|
import { surfaceAttrs as f } from "../surface/Surface.js";
|
|
6
|
-
function g({ variant: e = "default", padding: a = "normal", interactive:
|
|
7
|
-
const N =
|
|
6
|
+
function g({ variant: e = "default", padding: a = "normal", interactive: d, as: t = "div", orientation: c, isLoading: i, surface: l, radius: m, className: h, children: u, ...p }) {
|
|
7
|
+
const N = i ? /* @__PURE__ */ n("div", { className: "alea-card-loading", "aria-hidden": "true", children: [
|
|
8
8
|
/* @__PURE__ */ r("span", { className: "alea-skeleton", "data-shape": "rect", style: { height: 120 } }),
|
|
9
9
|
/* @__PURE__ */ r("span", { className: "alea-skeleton", "data-shape": "text", style: { width: "70%" } }),
|
|
10
10
|
/* @__PURE__ */ r("span", { className: "alea-skeleton", "data-shape": "text", style: { width: "45%" } })
|
|
11
11
|
] }) : u;
|
|
12
|
-
return
|
|
12
|
+
return o(t, { ...p, "aria-busy": i || void 0, className: s("alea-card", h), "data-variant": e, "data-padding": a, "data-interactive": d || void 0, "data-orientation": c, ...f({ surface: l, radius: m }) }, N);
|
|
13
13
|
}
|
|
14
|
-
function k({ as: e = "h3",
|
|
15
|
-
return
|
|
14
|
+
function k({ as: e = "h3", size: a, className: d, ...t }) {
|
|
15
|
+
return o(e, { ...t, className: s("alea-card-title", d), "data-size": a === "sm" ? "sm" : void 0 });
|
|
16
16
|
}
|
|
17
17
|
function j({ className: e, ...a }) {
|
|
18
|
-
return /* @__PURE__ */ r("p", { ...a, className:
|
|
18
|
+
return /* @__PURE__ */ r("p", { ...a, className: s("alea-card-description", e) });
|
|
19
19
|
}
|
|
20
20
|
function w({ className: e, ...a }) {
|
|
21
|
-
return /* @__PURE__ */ r("a", { ...a, className:
|
|
21
|
+
return /* @__PURE__ */ r("a", { ...a, className: s("alea-card-link alea-focus-ring", e) });
|
|
22
22
|
}
|
|
23
|
-
function b({ title: e, subtitle: a, media:
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
-
|
|
26
|
-
/* @__PURE__ */
|
|
27
|
-
|
|
23
|
+
function b({ title: e, subtitle: a, media: d, actions: t, headingLevel: c = 3, titleSize: i, className: l }) {
|
|
24
|
+
return /* @__PURE__ */ n("div", { className: s("alea-card-header", l), children: [
|
|
25
|
+
d && /* @__PURE__ */ r("span", { className: "alea-card-header-media", children: d }),
|
|
26
|
+
/* @__PURE__ */ n("div", { className: "alea-card-header-text", children: [
|
|
27
|
+
o(`h${c}`, { className: "alea-card-title", "data-size": i && i !== "md" ? i : void 0 }, e),
|
|
28
28
|
a && /* @__PURE__ */ r("p", { className: "alea-card-description", children: a })
|
|
29
29
|
] }),
|
|
30
|
-
|
|
30
|
+
t && /* @__PURE__ */ r("div", { className: "alea-card-header-actions", children: t })
|
|
31
31
|
] });
|
|
32
32
|
}
|
|
33
|
-
function z({ src: e, alt: a = "", ratio:
|
|
34
|
-
return /* @__PURE__ */ r("div", { className:
|
|
33
|
+
function z({ src: e, alt: a = "", ratio: d = 16 / 9, children: t, className: c }) {
|
|
34
|
+
return /* @__PURE__ */ r("div", { className: s("alea-card-media", c), style: { aspectRatio: String(d) }, children: t ?? /* @__PURE__ */ r("img", { src: e, alt: a, loading: "lazy" }) });
|
|
35
35
|
}
|
|
36
|
-
function A({ children: e, className: a, divider:
|
|
37
|
-
return /* @__PURE__ */ r("div", { className:
|
|
36
|
+
function A({ children: e, className: a, divider: d = !0 }) {
|
|
37
|
+
return /* @__PURE__ */ r("div", { className: s("alea-card-footer", a), "data-divider": d || void 0, children: e });
|
|
38
38
|
}
|
|
39
39
|
export {
|
|
40
40
|
g as Card,
|
|
@@ -69,6 +69,10 @@ export interface MultiSelectProps extends Omit<HTMLAttributes<HTMLDivElement>, '
|
|
|
69
69
|
showActions?: boolean;
|
|
70
70
|
/** Disables every part of it. */
|
|
71
71
|
isDisabled?: boolean;
|
|
72
|
+
/** Marks the field invalid: the trigger gets aria-invalid and the error text is its description. */
|
|
73
|
+
isInvalid?: boolean;
|
|
74
|
+
/** The error text, shown under the field while isInvalid. */
|
|
75
|
+
errorMessage?: ReactNode;
|
|
72
76
|
/** How the popup enters and leaves: a preset (fade, scale, pop, slide-down, blur...), false for none, or options. */
|
|
73
77
|
motion?: MotionProp;
|
|
74
78
|
}
|
|
@@ -1,85 +1,86 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useFilter as
|
|
2
|
+
import { jsxs as i, jsx as a, Fragment as X } from "react/jsx-runtime";
|
|
3
|
+
import { useState as k, useRef as G, useEffect as J, useMemo as V, forwardRef as U, useId as Y } from "react";
|
|
4
|
+
import { useFilter as K, ComboBox as Z, Input as _, Button as O, ListBox as P, ListBoxSection as ee, Header as ae, Collection as te, ListBoxItem as q, DialogTrigger as le, Dialog as se } from "react-aria-components";
|
|
5
5
|
import { Search as ie, X as ne, Clock as oe, ChevronDown as re, Check as ce } from "lucide-react";
|
|
6
|
-
import { cx as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { cx as H } from "../../utils/cx.js";
|
|
7
|
+
import { useAriaInvalid as de } from "../../utils/refs.js";
|
|
8
|
+
import { Label as pe, Description as me, SearchField as ue } from "../field/Field.js";
|
|
9
|
+
import { Popover as I } from "../overlay/Overlay.js";
|
|
10
|
+
import { Spinner as he } from "../feedback/Spinner.js";
|
|
11
|
+
import { loadingAttrs as fe } from "../field/FieldLoading.js";
|
|
11
12
|
import { useStrings as Q } from "../../i18n/strings.js";
|
|
12
|
-
import { OptionMatchContext as
|
|
13
|
-
import { Highlight as
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const [
|
|
13
|
+
import { OptionMatchContext as ge, MatchedText as D } from "./Highlight.js";
|
|
14
|
+
import { Highlight as Me, getMatchRanges as Ee } from "./Highlight.js";
|
|
15
|
+
function $e({ motion: j, label: A, description: o, placeholder: x, items: N, loadItems: h, debounce: z = 250, recent: p, isLoading: S, highlightMatch: T = !0, matchStyle: $, onSelect: b, onSubmit: m, minChars: f = 1, className: M }) {
|
|
16
|
+
const r = Q();
|
|
17
|
+
x ?? (x = r.search);
|
|
18
|
+
const [l, s] = k(""), [E, B] = k([]), [w, g] = k(!1), v = w || !!S, { contains: F } = K({ sensitivity: "base" }), y = G(null);
|
|
18
19
|
J(() => {
|
|
19
|
-
if (!
|
|
20
|
-
if (
|
|
21
|
-
|
|
20
|
+
if (!h) return;
|
|
21
|
+
if (l.trim().length < f) {
|
|
22
|
+
B([]), g(!1);
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
var
|
|
27
|
-
(
|
|
28
|
-
const
|
|
29
|
-
|
|
25
|
+
g(!0);
|
|
26
|
+
const t = setTimeout(async () => {
|
|
27
|
+
var d;
|
|
28
|
+
(d = y.current) == null || d.abort();
|
|
29
|
+
const e = new AbortController();
|
|
30
|
+
y.current = e;
|
|
30
31
|
try {
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const C = await h(l, e.signal);
|
|
33
|
+
e.signal.aborted || B(C);
|
|
33
34
|
} catch {
|
|
34
35
|
} finally {
|
|
35
|
-
|
|
36
|
+
e.signal.aborted || g(!1);
|
|
36
37
|
}
|
|
37
|
-
},
|
|
38
|
-
return () => clearTimeout(
|
|
39
|
-
}, [
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
for (const
|
|
43
|
-
const
|
|
44
|
-
let
|
|
45
|
-
|
|
38
|
+
}, z);
|
|
39
|
+
return () => clearTimeout(t);
|
|
40
|
+
}, [l, h, z, f]);
|
|
41
|
+
const c = !l && (p == null ? void 0 : p.length), n = c ? p : h ? E : l.trim().length < f ? [] : (N || []).filter((t) => F(t.label, l) || t.description && F(t.description, l)), R = V(() => {
|
|
42
|
+
const t = [];
|
|
43
|
+
for (const e of n) {
|
|
44
|
+
const d = c ? r.recent : e.group || "";
|
|
45
|
+
let C = t.find((W) => W.id === d);
|
|
46
|
+
C || t.push(C = { id: d, items: [] }), C.items.push(e);
|
|
46
47
|
}
|
|
47
|
-
return
|
|
48
|
-
}, [
|
|
49
|
-
return /* @__PURE__ */
|
|
48
|
+
return t;
|
|
49
|
+
}, [n, c]), L = V(() => new Map(n.map((t) => [t.id, t])), [n]), u = V(() => ({ query: c ? "" : l, style: $ ?? "tint", match: "words" }), [l, $, c]);
|
|
50
|
+
return /* @__PURE__ */ i(
|
|
50
51
|
Z,
|
|
51
52
|
{
|
|
52
|
-
className:
|
|
53
|
-
...
|
|
54
|
-
items:
|
|
55
|
-
inputValue:
|
|
56
|
-
onInputChange:
|
|
53
|
+
className: H("alea-field alea-autocomplete", M),
|
|
54
|
+
...fe(v),
|
|
55
|
+
items: R,
|
|
56
|
+
inputValue: l,
|
|
57
|
+
onInputChange: s,
|
|
57
58
|
selectedKey: null,
|
|
58
59
|
allowsCustomValue: !0,
|
|
59
60
|
allowsEmptyCollection: !0,
|
|
60
61
|
menuTrigger: "focus",
|
|
61
|
-
onSelectionChange: (
|
|
62
|
-
const
|
|
63
|
-
|
|
62
|
+
onSelectionChange: (t) => {
|
|
63
|
+
const e = t != null ? L.get(t) : void 0;
|
|
64
|
+
e && (s(e.label), b == null || b(e));
|
|
64
65
|
},
|
|
65
|
-
onKeyDown: (
|
|
66
|
-
|
|
66
|
+
onKeyDown: (t) => {
|
|
67
|
+
t.key === "Enter" && !t.target.getAttribute("aria-activedescendant") && (m == null || m(l));
|
|
67
68
|
},
|
|
68
69
|
children: [
|
|
69
|
-
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
|
|
70
|
+
A && /* @__PURE__ */ a(pe, { children: A }),
|
|
71
|
+
/* @__PURE__ */ i("div", { className: "alea-input-wrap", children: [
|
|
72
|
+
/* @__PURE__ */ a("span", { className: "alea-input-affix", "data-side": "start", "aria-hidden": "true", children: /* @__PURE__ */ a(ie, { size: 16 }) }),
|
|
73
|
+
/* @__PURE__ */ a(_, { className: "alea-input", placeholder: x, "aria-busy": v || void 0 }),
|
|
74
|
+
v ? /* @__PURE__ */ a("span", { className: "alea-autocomplete-spin", children: /* @__PURE__ */ a(he, { size: "sm", "aria-label": r.loadingSuggestions }) }) : l ? /* @__PURE__ */ a(O, { className: "alea-input-clear alea-focus-ring", "aria-label": r.clear, onPress: () => s(""), children: /* @__PURE__ */ a(ne, { size: 14 }) }) : null
|
|
74
75
|
] }),
|
|
75
|
-
o && /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
|
|
76
|
+
o && /* @__PURE__ */ a(me, { children: o }),
|
|
77
|
+
/* @__PURE__ */ a(I, { className: "alea-popover alea-select-popover", motion: j, children: /* @__PURE__ */ a(ge.Provider, { value: u, children: /* @__PURE__ */ a(P, { className: "alea-listbox", renderEmptyState: () => /* @__PURE__ */ a("p", { className: "alea-listbox-empty", children: v ? r.searching : l ? r.nothingFor(l) : r.startTyping }), children: (t) => /* @__PURE__ */ i(ee, { id: t.id, className: "alea-option-section", children: [
|
|
78
|
+
t.id && /* @__PURE__ */ a(ae, { className: "alea-option-header", children: t.id }),
|
|
79
|
+
/* @__PURE__ */ a(te, { items: t.items, children: (e) => /* @__PURE__ */ i(q, { id: e.id, textValue: e.label, className: "alea-option", children: [
|
|
80
|
+
c ? /* @__PURE__ */ a(oe, { size: 16, className: "alea-option-icon", "aria-hidden": "true" }) : e.icon && /* @__PURE__ */ a("span", { className: "alea-option-icon", "aria-hidden": "true", children: e.icon }),
|
|
81
|
+
/* @__PURE__ */ i("span", { className: "alea-option-text", children: [
|
|
82
|
+
/* @__PURE__ */ a("span", { children: T ? /* @__PURE__ */ a(D, { text: e.label }) : e.label }),
|
|
83
|
+
e.description && /* @__PURE__ */ a("span", { className: "alea-option-desc", children: T ? /* @__PURE__ */ a(D, { text: e.description }) : e.description })
|
|
83
84
|
] })
|
|
84
85
|
] }) })
|
|
85
86
|
] }) }) }) })
|
|
@@ -87,40 +88,41 @@ function Ae({ motion: D, label: T, description: o, placeholder: b, items: h, loa
|
|
|
87
88
|
}
|
|
88
89
|
);
|
|
89
90
|
}
|
|
90
|
-
const
|
|
91
|
+
const Be = U(function({ motion: A, label: o, description: x, items: N, value: h, defaultValue: z = [], onChange: p, placeholder: S, searchable: T, showActions: $ = !0, isDisabled: b, isInvalid: m, errorMessage: f, className: M, ...r }, l) {
|
|
91
92
|
const s = Q();
|
|
92
|
-
|
|
93
|
-
const [
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
o && /* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
93
|
+
S ?? (S = s.selectPlaceholder);
|
|
94
|
+
const [E, B] = k(z), w = h ?? E, [g, v] = k(""), { contains: F } = K({ sensitivity: "base" }), y = (e) => {
|
|
95
|
+
h === void 0 && B(e), p == null || p(e);
|
|
96
|
+
}, c = N.filter((e) => F(e.label, g)), n = N.filter((e) => w.includes(e.id)).map((e) => e.label), R = n.length ? n.length <= 2 ? n.join(", ") : `${n.slice(0, 2).join(", ")} +${n.length - 2}` : S, L = T ?? N.length > 8, u = "alea-ms" + Y().replace(/:/g, ""), t = de(!!m);
|
|
97
|
+
return /* @__PURE__ */ i("div", { ref: l, ...r, className: H("alea-field alea-multiselect", M), "data-disabled": b || void 0, "data-invalid": m || void 0, children: [
|
|
98
|
+
o && /* @__PURE__ */ a("span", { className: "alea-label", id: u, children: o }),
|
|
99
|
+
/* @__PURE__ */ i(le, { children: [
|
|
100
|
+
/* @__PURE__ */ i(O, { ref: t, className: "alea-select-trigger alea-focus-ring", "aria-labelledby": o ? `${u} ${u}-v` : void 0, "aria-describedby": m && f ? `${u}-err` : void 0, isDisabled: b, children: [
|
|
101
|
+
/* @__PURE__ */ a("span", { id: `${u}-v`, className: "alea-select-value", "data-placeholder": !n.length || void 0, children: R }),
|
|
102
|
+
/* @__PURE__ */ a(re, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
|
|
102
103
|
] }),
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ a(I, { className: "alea-popover alea-select-popover", placement: "bottom start", motion: A, children: /* @__PURE__ */ i(se, { "aria-label": typeof o == "string" ? o : s.options, className: "alea-multiselect-dialog", children: [
|
|
105
|
+
L && /* @__PURE__ */ a(ue, { "aria-label": s.filterOptions, size: "sm", value: g, onChange: v, autoFocus: !0 }),
|
|
106
|
+
$ && /* @__PURE__ */ i("div", { className: "alea-multiselect-actions", children: [
|
|
107
|
+
/* @__PURE__ */ a("button", { type: "button", className: "alea-link alea-focus-ring", "data-variant": "standalone", onClick: () => y(Array.from(/* @__PURE__ */ new Set([...w, ...c.map((e) => e.id)]))), children: g ? s.selectAllShown : s.selectAll }),
|
|
108
|
+
/* @__PURE__ */ a("button", { type: "button", className: "alea-link alea-focus-ring", "data-variant": "muted", onClick: () => y([]), children: s.clear })
|
|
108
109
|
] }),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
|
|
110
|
+
/* @__PURE__ */ a(P, { "aria-label": typeof o == "string" ? o : s.options, escapeKeyBehavior: "none", items: c, selectionMode: "multiple", selectedKeys: w, onSelectionChange: (e) => y(e === "all" ? N.map((d) => d.id) : [...e]), className: "alea-listbox alea-multiselect-list", autoFocus: !L, renderEmptyState: () => /* @__PURE__ */ a("p", { className: "alea-listbox-empty", children: s.noMatches }), children: (e) => /* @__PURE__ */ a(q, { id: e.id, textValue: e.label, className: "alea-option", children: ({ isSelected: d }) => /* @__PURE__ */ i(X, { children: [
|
|
111
|
+
/* @__PURE__ */ a("span", { className: "alea-check-box alea-ms-box", "data-on": d || void 0, "aria-hidden": "true", children: /* @__PURE__ */ a(ce, { size: 12, strokeWidth: 3 }) }),
|
|
112
|
+
/* @__PURE__ */ i("span", { className: "alea-option-text", children: [
|
|
113
|
+
/* @__PURE__ */ a("span", { children: e.label }),
|
|
114
|
+
e.description && /* @__PURE__ */ a("span", { className: "alea-option-desc", children: e.description })
|
|
114
115
|
] })
|
|
115
116
|
] }) }) })
|
|
116
117
|
] }) })
|
|
117
118
|
] }),
|
|
118
|
-
|
|
119
|
+
x && /* @__PURE__ */ a("span", { className: "alea-description", children: x }),
|
|
120
|
+
m && f && /* @__PURE__ */ a("span", { id: `${u}-err`, className: "alea-field-error", children: f })
|
|
119
121
|
] });
|
|
120
122
|
});
|
|
121
123
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
$e as Autocomplete,
|
|
125
|
+
Me as Highlight,
|
|
126
|
+
Be as MultiSelect,
|
|
127
|
+
Ee as getMatchRanges
|
|
126
128
|
};
|
|
@@ -27,6 +27,16 @@ export interface CommandPaletteProps extends SurfaceProps {
|
|
|
27
27
|
onOpenChange?: (open: boolean) => void;
|
|
28
28
|
/** Opens with ⌘K / Ctrl+K anywhere. Default true. */
|
|
29
29
|
hotkey?: boolean;
|
|
30
|
+
/** Also opens with the "/" key, unless the person is typing in a field. Default false. */
|
|
31
|
+
slashHotkey?: boolean;
|
|
32
|
+
/** Called with the text in the search field on every change (and with "" when the palette closes). Use it to search a server: update `commands` with the results, show `isLoading` meanwhile and set `filter={false}`. */
|
|
33
|
+
onQueryChange?: (query: string) => void;
|
|
34
|
+
/** Your own match for the typed text. Default: the label and keywords contain the text, ignoring case and accents ("operacion" finds "Operación"). `false` shows every command as given, for results that are already filtered. */
|
|
35
|
+
filter?: ((command: Command, query: string) => boolean) | false;
|
|
36
|
+
/** Shows a loading line in the list (and marks it busy for screen readers) while results are on their way. */
|
|
37
|
+
isLoading?: boolean;
|
|
38
|
+
/** Shows at most this many commands per group, followed by a "Show N more" row that opens the rest of that group. */
|
|
39
|
+
maxPerGroup?: number;
|
|
30
40
|
/** Shown in the search field. Default "Type a command or search…". */
|
|
31
41
|
placeholder?: string;
|
|
32
42
|
/** Shown when nothing matches. */
|