@alea-design/ui 0.6.1 → 0.7.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.
- package/dist/components/button/Button.d.ts +3 -1
- package/dist/components/button/Button.js +58 -57
- package/dist/components/button/Groups.js +41 -41
- package/dist/components/data/Data.d.ts +6 -4
- package/dist/components/data/Data.js +49 -49
- package/dist/components/date/Date.d.ts +3 -1
- package/dist/components/date/Date.js +74 -74
- package/dist/components/form/Form.d.ts +3 -1
- package/dist/components/form/Form.js +44 -52
- package/dist/components/form/validity.d.ts +22 -0
- package/dist/components/form/validity.js +38 -0
- package/dist/components/list/List.d.ts +3 -2
- package/dist/components/more/More.d.ts +3 -1
- package/dist/components/more/More.js +46 -46
- package/dist/components/navigation/Navigation.d.ts +4 -4
- package/dist/components/navigation/Navigation.js +94 -94
- package/dist/components/navigation/Navigation2.d.ts +3 -1
- package/dist/components/navigation/Navigation2.js +218 -210
- package/dist/components/page/PageParts.d.ts +6 -2
- package/dist/components/page/PageParts.js +85 -85
- package/dist/components/shell/AppShell.d.ts +3 -1
- package/dist/components/shell/AppShell.js +33 -32
- package/dist/components/table/Table.d.ts +8 -3
- package/dist/components/table/Table.js +58 -57
- package/dist/components/theme/Theme.d.ts +5 -1
- package/dist/components/theme/Theme.js +63 -63
- package/dist/css/base.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/data.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/groups.json +13 -13
- package/dist/css/more.css +1 -1
- package/dist/css/navigation.css +1 -1
- package/dist/css/page.css +1 -1
- package/dist/css/shell.css +1 -1
- package/dist/css/table.css +1 -1
- package/dist/css/tabs.css +1 -1
- package/dist/css/typography.css +1 -1
- package/dist/i18n/strings.d.ts +1 -0
- package/dist/i18n/strings.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +279 -275
- package/dist/styles.css +1 -1
- package/dist/utils/animateRows.d.ts +3 -2
- package/dist/utils/animateRows.js +15 -15
- package/dist/utils/measure.d.ts +12 -0
- package/dist/utils/measure.js +20 -0
- package/dist/utils/scrollEdges.d.ts +1 -1
- package/dist/utils/scrollEdges.js +23 -22
- package/package.json +3 -3
|
@@ -74,11 +74,13 @@ export interface SegmentedControlProps extends Omit<ToggleButtonGroupProps, 'sel
|
|
|
74
74
|
onChange?: (value: Key) => void;
|
|
75
75
|
/** sm (28 px) or md (34 px, default). */
|
|
76
76
|
size?: 'sm' | 'md';
|
|
77
|
+
/** Lets the options flow onto more lines when they do not fit (a preference switch with long words, large text), instead of scrolling sideways inside the control. */
|
|
78
|
+
wrap?: boolean;
|
|
77
79
|
/** Label for screen readers. */
|
|
78
80
|
'aria-label'?: string;
|
|
79
81
|
}
|
|
80
82
|
/** One choice among a few, as a row of pills. */
|
|
81
|
-
export declare function SegmentedControl({ items, value, defaultValue, onChange, size, className, ...props }: SegmentedControlProps): import("react").JSX.Element;
|
|
83
|
+
export declare function SegmentedControl({ items, value, defaultValue, onChange, size, wrap, className, ...props }: SegmentedControlProps): import("react").JSX.Element;
|
|
82
84
|
export interface ToggleButtonProps extends RACToggleButtonProps {
|
|
83
85
|
/** sm (32 px) or md (40 px, default). */
|
|
84
86
|
size?: 'sm' | 'md';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
2
|
+
import { jsx as e, jsxs as h, Fragment as Y } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef as G, useRef as A, useEffect as I, useState as _ } from "react";
|
|
4
4
|
import { useRipple as C } from "@alea-design/motion";
|
|
5
5
|
import { Link as V, Button as ee, composeRenderProps as te, ToggleButtonGroup as ne, ToggleButton as W, SelectionIndicator as ae } from "react-aria-components";
|
|
@@ -10,50 +10,50 @@ import { useStrings as q } from "../../i18n/strings.js";
|
|
|
10
10
|
import { responsiveAttrs as X } from "../../utils/responsive.js";
|
|
11
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:
|
|
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
14
|
const T = q();
|
|
15
15
|
B ?? (B = T.done);
|
|
16
16
|
const E = A(null), D = oe(Q, E), { onPointerDown: $ } = C();
|
|
17
17
|
I(() => {
|
|
18
|
-
const
|
|
19
|
-
if (!k || !
|
|
20
|
-
const s = (w) => $({ currentTarget:
|
|
21
|
-
return
|
|
18
|
+
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
22
|
}, [k, $]);
|
|
23
|
-
const
|
|
24
|
-
s && !
|
|
25
|
-
R && !s ? /* @__PURE__ */
|
|
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: [
|
|
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
|
-
] }) : /* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
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 }),
|
|
32
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
36
|
"data-ripple": k || void 0,
|
|
37
|
-
"data-variant":
|
|
38
|
-
"data-tone":
|
|
39
|
-
...X("size",
|
|
37
|
+
"data-variant": o,
|
|
38
|
+
"data-tone": a,
|
|
39
|
+
...X("size", d, "md"),
|
|
40
40
|
...X("full-width", N),
|
|
41
|
-
"data-shape":
|
|
41
|
+
"data-shape": m,
|
|
42
42
|
"data-justify": v,
|
|
43
43
|
"data-wrap": g || void 0
|
|
44
44
|
}, z = typeof f == "string" ? f.replace("⌘", "Meta+").replace("⇧", "Shift+").replace("⌥", "Alt+").replace("⌃", "Control+") : void 0;
|
|
45
45
|
if (I(() => {
|
|
46
|
-
const
|
|
47
|
-
|
|
46
|
+
const n = E.current;
|
|
47
|
+
n && (z ? n.setAttribute("aria-keyshortcuts", z) : n.removeAttribute("aria-keyshortcuts"));
|
|
48
48
|
}, [z]), y) {
|
|
49
|
-
const { onPress:
|
|
49
|
+
const { onPress: n, isDisabled: s, autoFocus: w, id: U, style: Z } = S;
|
|
50
50
|
return /* @__PURE__ */ e(
|
|
51
51
|
V,
|
|
52
52
|
{
|
|
53
53
|
href: y,
|
|
54
54
|
target: L,
|
|
55
55
|
rel: O,
|
|
56
|
-
onPress:
|
|
56
|
+
onPress: n,
|
|
57
57
|
isDisabled: s,
|
|
58
58
|
autoFocus: w,
|
|
59
59
|
id: U,
|
|
@@ -66,67 +66,68 @@ const J = G(function({ variant: a = "primary", tone: n, size: c, shape: u, iconS
|
|
|
66
66
|
}
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
|
-
return /* @__PURE__ */ e(ee, { ...S, ...K, ref: D, isPending:
|
|
70
|
-
}), Ne = G(function({ shape:
|
|
71
|
-
const
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
/* @__PURE__ */ e(le, { children:
|
|
75
|
-
] }) :
|
|
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: [
|
|
73
|
+
t,
|
|
74
|
+
/* @__PURE__ */ e(le, { children: l["aria-label"] })
|
|
75
|
+
] }) : t;
|
|
76
76
|
});
|
|
77
|
-
function ve({ items:
|
|
77
|
+
function ve({ items: r, value: o, defaultValue: a, onChange: d, size: m = "md", wrap: c, className: l, ...u }) {
|
|
78
78
|
return /* @__PURE__ */ e(
|
|
79
79
|
ne,
|
|
80
80
|
{
|
|
81
|
-
...
|
|
81
|
+
...u,
|
|
82
82
|
selectionMode: "single",
|
|
83
83
|
disallowEmptySelection: !0,
|
|
84
|
-
selectedKeys:
|
|
85
|
-
defaultSelectedKeys:
|
|
86
|
-
onSelectionChange: (
|
|
87
|
-
const
|
|
88
|
-
|
|
84
|
+
selectedKeys: o !== void 0 ? [o] : void 0,
|
|
85
|
+
defaultSelectedKeys: a !== void 0 ? [a] : o === void 0 && r[0] ? [r[0].id] : void 0,
|
|
86
|
+
onSelectionChange: (t) => {
|
|
87
|
+
const i = [...t][0];
|
|
88
|
+
i !== void 0 && (d == null || d(i));
|
|
89
89
|
},
|
|
90
|
-
"data-size":
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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: [
|
|
94
|
+
/* @__PURE__ */ e("span", { className: "alea-segmented-label", children: t.label }),
|
|
94
95
|
/* @__PURE__ */ e(ae, { className: "alea-sel-indicator" })
|
|
95
|
-
] }, String(
|
|
96
|
+
] }, String(t.id)))
|
|
96
97
|
}
|
|
97
98
|
);
|
|
98
99
|
}
|
|
99
|
-
function ye({ size:
|
|
100
|
-
return /* @__PURE__ */ e(W, { ...
|
|
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
102
|
}
|
|
102
|
-
function Be({ onConfirm:
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const [
|
|
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;
|
|
106
107
|
return I(() => {
|
|
107
108
|
const g = N.current;
|
|
108
109
|
if (!g) return;
|
|
109
110
|
const f = (y) => {
|
|
110
|
-
y.animationName === "alea-hold" && (
|
|
111
|
+
y.animationName === "alea-hold" && (i(!1), r());
|
|
111
112
|
};
|
|
112
113
|
return g.addEventListener("animationend", f), () => g.removeEventListener("animationend", f);
|
|
113
|
-
}, [
|
|
114
|
+
}, [r]), /* @__PURE__ */ h(Y, { children: [
|
|
114
115
|
/* @__PURE__ */ e(
|
|
115
116
|
J,
|
|
116
117
|
{
|
|
117
|
-
...
|
|
118
|
+
...l,
|
|
118
119
|
ref: N,
|
|
119
|
-
variant:
|
|
120
|
-
"data-holding":
|
|
120
|
+
variant: d,
|
|
121
|
+
"data-holding": t || void 0,
|
|
121
122
|
"aria-describedby": v,
|
|
122
|
-
onPressStart: () =>
|
|
123
|
-
onPressEnd: () =>
|
|
124
|
-
className: b("alea-hold",
|
|
125
|
-
style: { "--alea-hold-duration": `${
|
|
126
|
-
children:
|
|
123
|
+
onPressStart: () => i(!0),
|
|
124
|
+
onPressEnd: () => i(!1),
|
|
125
|
+
className: b("alea-hold", m),
|
|
126
|
+
style: { "--alea-hold-duration": `${o}ms` },
|
|
127
|
+
children: c
|
|
127
128
|
}
|
|
128
129
|
),
|
|
129
|
-
/* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children:
|
|
130
|
+
/* @__PURE__ */ e("span", { id: v, className: "alea-visually-hidden", children: a })
|
|
130
131
|
] });
|
|
131
132
|
}
|
|
132
133
|
export {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as r, jsxs as S } from "react/jsx-runtime";
|
|
3
|
-
import { useState as P, useRef as F,
|
|
3
|
+
import { useState as P, useRef as F, Fragment as K } from "react";
|
|
4
|
+
import { useIsoLayoutEffect as O } from "../../utils/measure.js";
|
|
4
5
|
import { Group as R, ToggleButtonGroup as j, Toolbar as z, ToggleButton as k, SelectionIndicator as q } from "react-aria-components";
|
|
5
|
-
import { ChevronDown as W, MoreHorizontal as
|
|
6
|
+
import { ChevronDown as W, MoreHorizontal as E } from "lucide-react";
|
|
6
7
|
import { cx as N, withBase as x } from "../../utils/cx.js";
|
|
7
8
|
import { Button as w, IconButton as D } from "./Button.js";
|
|
8
9
|
import { DropdownMenu as A, MenuItem as G } from "../menu/Menu.js";
|
|
9
|
-
import { useStrings as
|
|
10
|
-
import { inertProps as
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return /* @__PURE__ */ r(R, { "aria-label": t, className: N("alea-btn-group", s), "data-attached": l || void 0, "data-orientation": n, children: i });
|
|
10
|
+
import { useStrings as I } from "../../i18n/strings.js";
|
|
11
|
+
import { inertProps as H } from "../../utils/inert.js";
|
|
12
|
+
function $({ children: n, attached: l = !0, orientation: i = "horizontal", className: s, "aria-label": t }) {
|
|
13
|
+
return /* @__PURE__ */ r(R, { "aria-label": t, className: N("alea-btn-group", s), "data-attached": l || void 0, "data-orientation": i, children: n });
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const f =
|
|
17
|
-
return s ?? (s = f.moreOptions), /* @__PURE__ */ S(
|
|
18
|
-
/* @__PURE__ */ r(w, { variant: t, size: d, ...m, children:
|
|
19
|
-
/* @__PURE__ */ r(A, { trigger: /* @__PURE__ */ r(D, { variant: t, size: d, shape: "square", "aria-label": s, isDisabled: m.isDisabled, children: /* @__PURE__ */ r(W, {}) }), placement: "bottom end", menuProps: { onAction: (c) =>
|
|
15
|
+
function ee({ children: n, actions: l, onAction: i, menuLabel: s, variant: t = "primary", size: d = "md", className: u, ...m }) {
|
|
16
|
+
const f = I();
|
|
17
|
+
return s ?? (s = f.moreOptions), /* @__PURE__ */ S($, { className: N("alea-split-btn", u), children: [
|
|
18
|
+
/* @__PURE__ */ r(w, { variant: t, size: d, ...m, children: n }),
|
|
19
|
+
/* @__PURE__ */ r(A, { trigger: /* @__PURE__ */ r(D, { variant: t, size: d, shape: "square", "aria-label": s, isDisabled: m.isDisabled, children: /* @__PURE__ */ r(W, {}) }), placement: "bottom end", menuProps: { onAction: (c) => i == null ? void 0 : i(c) }, "aria-label": s, children: l.map((c) => /* @__PURE__ */ r(G, { id: c.id, icon: c.icon, description: c.description, children: c.label }, String(c.id))) })
|
|
20
20
|
] });
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
const [c, v] = P(s ?? []), p =
|
|
22
|
+
function ae({ items: n, selectionMode: l = "single", value: i, defaultValue: s, onChange: t, iconOnly: d, size: u = "md", className: m, "aria-label": f }) {
|
|
23
|
+
const [c, v] = P(s ?? []), p = i ?? c, e = (a, o) => /* @__PURE__ */ S(k, { id: a.id, isDisabled: a.isDisabled, "aria-label": d ? a.label : void 0, className: "alea-toggle-item alea-focus-ring", "data-icon-only": d || void 0, ...o, children: [
|
|
24
24
|
a.icon && /* @__PURE__ */ r("span", { className: "alea-toggle-icon", "aria-hidden": "true", children: a.icon }),
|
|
25
25
|
!d && /* @__PURE__ */ r("span", { className: "alea-toggle-label", children: a.label }),
|
|
26
26
|
!o && /* @__PURE__ */ r(q, { className: "alea-sel-indicator" })
|
|
@@ -28,65 +28,65 @@ function re({ items: i, selectionMode: l = "single", value: n, defaultValue: s,
|
|
|
28
28
|
if (l === "multiple") {
|
|
29
29
|
const a = (o, b) => {
|
|
30
30
|
const g = b ? [...p, o] : p.filter((B) => B !== o);
|
|
31
|
-
|
|
31
|
+
i === void 0 && v(g), t == null || t(g);
|
|
32
32
|
};
|
|
33
|
-
return /* @__PURE__ */ r("div", { role: "group", "aria-label": f, className: N("alea-toggle-group", m), "data-size": u, "data-multiple": !0, children:
|
|
33
|
+
return /* @__PURE__ */ r("div", { role: "group", "aria-label": f, className: N("alea-toggle-group", m), "data-size": u, "data-multiple": !0, children: n.map((o) => e(o, { isSelected: p.includes(o.id), onChange: (b) => a(o.id, b) })) });
|
|
34
34
|
}
|
|
35
35
|
return /* @__PURE__ */ r(
|
|
36
36
|
j,
|
|
37
37
|
{
|
|
38
38
|
"aria-label": f,
|
|
39
39
|
selectionMode: "single",
|
|
40
|
-
selectedKeys:
|
|
40
|
+
selectedKeys: i,
|
|
41
41
|
defaultSelectedKeys: s,
|
|
42
|
-
onSelectionChange: (a) => t == null ? void 0 : t(a === "all" ?
|
|
42
|
+
onSelectionChange: (a) => t == null ? void 0 : t(a === "all" ? n.map((o) => o.id) : [...a]),
|
|
43
43
|
className: x("alea-toggle-group", m),
|
|
44
44
|
"data-size": u,
|
|
45
|
-
children:
|
|
45
|
+
children: n.map((a) => e(a))
|
|
46
46
|
}
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const d =
|
|
51
|
-
if (
|
|
49
|
+
function re({ className: n, items: l, itemStyle: i = "icon", children: s, ...t }) {
|
|
50
|
+
const d = I(), u = F(null), [m, f] = P((l == null ? void 0 : l.length) ?? 0);
|
|
51
|
+
if (O(() => {
|
|
52
52
|
const e = u.current;
|
|
53
53
|
if (!l || !e) return;
|
|
54
54
|
const a = () => {
|
|
55
55
|
const b = e.querySelector(".alea-toolbar-probe");
|
|
56
56
|
if (!b) return;
|
|
57
57
|
const g = Array.from(b.children).map((h) => h.getBoundingClientRect().width + 4);
|
|
58
|
-
if (g.reduce((h,
|
|
58
|
+
if (g.reduce((h, M) => h + M, 0) <= e.clientWidth) {
|
|
59
59
|
f(g.length);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
let
|
|
62
|
+
let T = 0, y = 0;
|
|
63
63
|
for (const h of g) {
|
|
64
|
-
if (
|
|
65
|
-
|
|
64
|
+
if (T + h > e.clientWidth - 44) break;
|
|
65
|
+
T += h, y++;
|
|
66
66
|
}
|
|
67
|
-
f(
|
|
67
|
+
f(y);
|
|
68
68
|
};
|
|
69
69
|
a();
|
|
70
70
|
const o = new ResizeObserver(a);
|
|
71
71
|
return o.observe(e), () => o.disconnect();
|
|
72
|
-
}, [l]), !l) return /* @__PURE__ */ r(z, { ...t, className: x("alea-toolbar",
|
|
72
|
+
}, [l]), !l) return /* @__PURE__ */ r(z, { ...t, className: x("alea-toolbar", n), children: s });
|
|
73
73
|
const c = (e, a = !1) => {
|
|
74
|
-
const o =
|
|
75
|
-
return e.separatorBefore ? /* @__PURE__ */ S(
|
|
74
|
+
const o = i === "label" ? /* @__PURE__ */ r(w, { size: "sm", variant: e.isSelected ? "soft" : "text", iconStart: e.icon, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.label }, String(e.id)) : /* @__PURE__ */ r(D, { size: "sm", variant: e.isSelected ? "soft" : "text", "aria-label": e.label, tooltip: !a, isDisabled: e.isDisabled, onPress: e.onAction, "aria-pressed": e.isSelected, excludeFromTabOrder: a, children: e.icon }, String(e.id));
|
|
75
|
+
return e.separatorBefore ? /* @__PURE__ */ S(K, { children: [
|
|
76
76
|
/* @__PURE__ */ r("span", { className: "alea-toolbar-sep", "aria-hidden": "true" }),
|
|
77
77
|
o
|
|
78
78
|
] }, String(e.id)) : o;
|
|
79
79
|
}, v = l.slice(0, m), p = l.slice(m);
|
|
80
80
|
return /* @__PURE__ */ S("div", { ref: u, className: "alea-toolbar-fit", children: [
|
|
81
|
-
/* @__PURE__ */ r("div", { className: "alea-toolbar-probe", "aria-hidden": "true",
|
|
82
|
-
/* @__PURE__ */ S(z, { ...t, className: x("alea-toolbar",
|
|
81
|
+
/* @__PURE__ */ r("div", { className: "alea-toolbar-probe", "aria-hidden": "true", ...H(!0), children: l.map((e) => c(e, !0)) }),
|
|
82
|
+
/* @__PURE__ */ S(z, { ...t, className: x("alea-toolbar", n), children: [
|
|
83
83
|
v.map((e) => c(e)),
|
|
84
84
|
p.length > 0 && /* @__PURE__ */ r(
|
|
85
85
|
A,
|
|
86
86
|
{
|
|
87
87
|
"aria-label": d.moreActions,
|
|
88
88
|
placement: "bottom end",
|
|
89
|
-
trigger: /* @__PURE__ */ r(D, { size: "sm", variant: "text", "aria-label": d.moreActions, children: /* @__PURE__ */ r(
|
|
89
|
+
trigger: /* @__PURE__ */ r(D, { size: "sm", variant: "text", "aria-label": d.moreActions, children: /* @__PURE__ */ r(E, {}) }),
|
|
90
90
|
menuProps: { onAction: (e) => {
|
|
91
91
|
var a, o;
|
|
92
92
|
return (o = (a = p.find((b) => b.id === e)) == null ? void 0 : a.onAction) == null ? void 0 : o.call(a);
|
|
@@ -97,16 +97,16 @@ function oe({ className: i, items: l, itemStyle: n = "icon", children: s, ...t }
|
|
|
97
97
|
] })
|
|
98
98
|
] });
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return /* @__PURE__ */ r(w, { ...u, size: t, variant: d, className: N("alea-compound-button", s), iconStart:
|
|
102
|
-
/* @__PURE__ */ r("span", { className: "alea-compound-title", children:
|
|
100
|
+
function oe({ children: n, description: l, icon: i, className: s, size: t = "lg", variant: d = "ghost", ...u }) {
|
|
101
|
+
return /* @__PURE__ */ r(w, { ...u, size: t, variant: d, className: N("alea-compound-button", s), iconStart: i, children: /* @__PURE__ */ S("span", { className: "alea-compound-text", children: [
|
|
102
|
+
/* @__PURE__ */ r("span", { className: "alea-compound-title", children: n }),
|
|
103
103
|
l && /* @__PURE__ */ r("span", { className: "alea-compound-desc", children: l })
|
|
104
104
|
] }) });
|
|
105
105
|
}
|
|
106
106
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
$ as ButtonGroup,
|
|
108
|
+
oe as CompoundButton,
|
|
109
|
+
ee as SplitButton,
|
|
110
|
+
ae as ToggleGroup,
|
|
111
|
+
re as Toolbar
|
|
112
112
|
};
|
|
@@ -13,10 +13,12 @@ export interface DescriptionsProps extends Omit<HTMLAttributes<HTMLElement>, 'ti
|
|
|
13
13
|
hideEmpty?: boolean;
|
|
14
14
|
/** stacked (label above the value, default) or inline (label and value side by side). */
|
|
15
15
|
layout?: 'stacked' | 'inline';
|
|
16
|
-
/** Draws
|
|
16
|
+
/** Draws a box around the items, with a line between them. */
|
|
17
17
|
bordered?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** plain (default) or lines: a thin rule under each row, with no box around the list, like a statement or a receipt. */
|
|
19
|
+
variant?: 'plain' | 'lines';
|
|
20
|
+
/** sm (tighter, 13 px values), md (default) or lg (larger text, for a page people read rather than scan). */
|
|
21
|
+
size?: 'sm' | 'md' | 'lg';
|
|
20
22
|
/** A title above the list (an h3). */
|
|
21
23
|
title?: ReactNode;
|
|
22
24
|
/** Something at the end of the title row: an Edit button or link. */
|
|
@@ -25,7 +27,7 @@ export interface DescriptionsProps extends Omit<HTMLAttributes<HTMLElement>, 'ti
|
|
|
25
27
|
labelWidth?: string;
|
|
26
28
|
}
|
|
27
29
|
/** Key and value pairs: order details, profile facts, settings summaries. A title with an action, one to four columns, item spans, stacked or inline, two sizes. */
|
|
28
|
-
export declare function Descriptions({ items, columns, hideEmpty, layout, bordered, size, title, extra, labelWidth, className, style, ...props }: DescriptionsProps): import("react").JSX.Element;
|
|
30
|
+
export declare function Descriptions({ items, columns, hideEmpty, layout, bordered, variant, size, title, extra, labelWidth, className, style, ...props }: DescriptionsProps): import("react").JSX.Element;
|
|
29
31
|
export interface StatisticProps extends Omit<HTMLAttributes<HTMLDivElement>, 'prefix'> {
|
|
30
32
|
/** What the number is. */
|
|
31
33
|
label: ReactNode;
|
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
2
|
+
import { jsx as e, jsxs as s, Fragment as L } from "react/jsx-runtime";
|
|
3
3
|
import { createElement as U, useState as G, useRef as D, useEffect as O } from "react";
|
|
4
4
|
import { Inbox as E, ServerCrash as X, Lock as _, SearchX as B, CircleAlert as H, CircleCheck as J, TrendingUp as K, TrendingDown as P } from "lucide-react";
|
|
5
|
-
import { cx as
|
|
5
|
+
import { cx as w } from "../../utils/cx.js";
|
|
6
6
|
import { isDecimalString as Q } from "../../utils/decimal.js";
|
|
7
7
|
import { useReducedMotion as V, TextSwap as Y } from "@alea-design/motion";
|
|
8
|
-
function ie({ items: c, columns: a = 2, hideEmpty:
|
|
9
|
-
const
|
|
10
|
-
/* @__PURE__ */ e("dt", { children:
|
|
11
|
-
/* @__PURE__ */ e("dd", { children:
|
|
12
|
-
] },
|
|
13
|
-
return !
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
function ie({ items: c, columns: a = 2, hideEmpty: o, layout: u = "stacked", bordered: t, variant: p, size: r, title: m, extra: h, labelWidth: f, className: N, style: i, ...d }) {
|
|
9
|
+
const y = o ? c.filter((n) => n.value != null && n.value !== !1 && n.value !== "") : c, l = /* @__PURE__ */ e("dl", { className: "alea-descriptions", "data-columns": a, "data-layout": u, "data-bordered": t || void 0, "data-variant": p !== "plain" ? p : void 0, "data-size": r, style: f ? { "--alea-desc-label": f } : void 0, children: y.map((n, v) => /* @__PURE__ */ s("div", { className: "alea-desc-item", "data-wide": n.wide || void 0, "data-span": n.span && n.span > 1 ? n.span : void 0, children: [
|
|
10
|
+
/* @__PURE__ */ e("dt", { children: n.label }),
|
|
11
|
+
/* @__PURE__ */ e("dd", { children: n.value })
|
|
12
|
+
] }, v)) });
|
|
13
|
+
return !m && !h ? /* @__PURE__ */ e("div", { ...d, style: i, className: w("alea-descriptions-wrap", N), children: l }) : /* @__PURE__ */ s("section", { ...d, style: i, className: w("alea-descriptions-wrap", N), children: [
|
|
14
|
+
/* @__PURE__ */ s("header", { className: "alea-descriptions-head", children: [
|
|
15
|
+
m && /* @__PURE__ */ e("h3", { className: "alea-descriptions-title", children: m }),
|
|
16
|
+
h && /* @__PURE__ */ e("div", { className: "alea-descriptions-extra", children: h })
|
|
17
17
|
] }),
|
|
18
|
-
|
|
18
|
+
l
|
|
19
19
|
] });
|
|
20
20
|
}
|
|
21
|
-
function ce({ label: c, value: a, isDecimal:
|
|
21
|
+
function ce({ label: c, value: a, isDecimal: o, formatOptions: u, delta: t, higherIsBetter: p = !0, animate: r, prefix: m, suffix: h, className: f, ...N }) {
|
|
22
22
|
var R;
|
|
23
|
-
const i = !!
|
|
23
|
+
const i = !!o && Q(a), d = typeof a == "string" && !i, y = V(), l = d ? 0 : i ? Number(a) : a, n = i ? ((R = a.trim().split(".")[1]) == null ? void 0 : R.length) ?? 0 : 0, [v, I] = G(r && !d ? 0 : l), F = D(v), b = D(0);
|
|
24
24
|
O(() => {
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
F.current =
|
|
25
|
+
if (d) return;
|
|
26
|
+
const g = (S) => {
|
|
27
|
+
F.current = S, I(S);
|
|
28
28
|
};
|
|
29
|
-
if (!
|
|
30
|
-
|
|
29
|
+
if (!r || y || typeof window > "u") {
|
|
30
|
+
g(l);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const k = F.current, j = performance.now(), q = 900, z = (
|
|
34
|
-
const x = Math.min(1, (
|
|
35
|
-
|
|
33
|
+
const k = F.current, j = performance.now(), q = 900, z = (S) => {
|
|
34
|
+
const x = Math.min(1, (S - j) / q);
|
|
35
|
+
g(x < 1 ? k + (l - k) * (1 - Math.pow(1 - x, 3)) : l), x < 1 && (b.current = requestAnimationFrame(z));
|
|
36
36
|
};
|
|
37
37
|
return b.current = requestAnimationFrame(z), () => cancelAnimationFrame(b.current);
|
|
38
|
-
}, [
|
|
39
|
-
const M = new Intl.NumberFormat(void 0,
|
|
40
|
-
return /* @__PURE__ */
|
|
38
|
+
}, [l, r, y, d]);
|
|
39
|
+
const M = new Intl.NumberFormat(void 0, u), A = (g) => M.format(g), T = d || v === l || !r ? a : i ? v.toFixed(n) : Math.round(v * 100) / 100, C = t === void 0 ? null : t >= 0 === p;
|
|
40
|
+
return /* @__PURE__ */ s("div", { ...N, className: w("alea-stat", f), children: [
|
|
41
41
|
/* @__PURE__ */ e("div", { className: "alea-stat-label", children: c }),
|
|
42
|
-
/* @__PURE__ */ e("div", { className: "alea-stat-value", children:
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
/* @__PURE__ */ e("div", { className: "alea-stat-value", children: d ? /* @__PURE__ */ s("span", { children: [
|
|
43
|
+
m,
|
|
44
|
+
r ? /* @__PURE__ */ e(Y, { children: String(a) }) : a,
|
|
45
45
|
h
|
|
46
|
-
] }) : /* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
|
|
46
|
+
] }) : /* @__PURE__ */ s(L, { children: [
|
|
47
|
+
/* @__PURE__ */ s("span", { "aria-hidden": "true", children: [
|
|
48
|
+
m,
|
|
49
49
|
A(T),
|
|
50
50
|
h
|
|
51
51
|
] }),
|
|
52
52
|
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", children: A(a) })
|
|
53
53
|
] }) }),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/* @__PURE__ */
|
|
57
|
-
|
|
58
|
-
new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(
|
|
54
|
+
t !== void 0 && /* @__PURE__ */ s("div", { className: "alea-stat-delta", "data-good": C ? !0 : void 0, "data-bad": C === !1 ? !0 : void 0, children: [
|
|
55
|
+
t >= 0 ? /* @__PURE__ */ e(K, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ e(P, { size: 14, "aria-hidden": "true" }),
|
|
56
|
+
/* @__PURE__ */ s("span", { children: [
|
|
57
|
+
t >= 0 ? "+" : "",
|
|
58
|
+
new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(t)
|
|
59
59
|
] }),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
60
|
+
/* @__PURE__ */ s("span", { className: "alea-visually-hidden", children: [
|
|
61
|
+
t >= 0 ? "up" : "down",
|
|
62
62
|
" from before"
|
|
63
63
|
] })
|
|
64
64
|
] })
|
|
65
65
|
] });
|
|
66
66
|
}
|
|
67
|
-
function Z({ title: c, description: a, icon:
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */ e("span", { className:
|
|
70
|
-
U(
|
|
67
|
+
function Z({ title: c, description: a, icon: o, illustration: u, action: t, secondaryAction: p, footer: r, size: m, variant: h, headingAs: f = "h3", className: N, ...i }) {
|
|
68
|
+
return /* @__PURE__ */ s("div", { ...i, className: w("alea-empty", N), "data-size": m, "data-variant": h, children: [
|
|
69
|
+
/* @__PURE__ */ e("span", { className: u ? "alea-empty-art" : "alea-empty-icon", "aria-hidden": "true", children: o ?? /* @__PURE__ */ e(E, {}) }),
|
|
70
|
+
U(f, { className: "alea-empty-title" }, c),
|
|
71
71
|
a && /* @__PURE__ */ e("p", { className: "alea-empty-text", children: a }),
|
|
72
|
-
(
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
(t || p) && /* @__PURE__ */ s("div", { className: "alea-empty-action", children: [
|
|
73
|
+
t,
|
|
74
|
+
p
|
|
75
75
|
] }),
|
|
76
|
-
|
|
76
|
+
r && /* @__PURE__ */ e("p", { className: "alea-empty-footer", children: r })
|
|
77
77
|
] });
|
|
78
78
|
}
|
|
79
79
|
const $ = { success: J, error: H, 404: B, 403: _, 500: X, info: E };
|
|
80
|
-
function de({ status: c, className: a, ...
|
|
81
|
-
const
|
|
82
|
-
return /* @__PURE__ */ e(Z, { ...
|
|
80
|
+
function de({ status: c, className: a, ...o }) {
|
|
81
|
+
const u = $[c];
|
|
82
|
+
return /* @__PURE__ */ e(Z, { ...o, headingAs: o.headingAs ?? "h2", icon: /* @__PURE__ */ e(u, {}), className: w("alea-result", a), "data-status": c });
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
85
|
ie as Descriptions,
|
|
@@ -56,7 +56,9 @@ export interface DateRangePickerProps<T extends DateValue> extends RACDateRangeP
|
|
|
56
56
|
presets?: DateRangePreset[];
|
|
57
57
|
/** How the popup enters and leaves: a preset (fade, scale, pop, slide-down, blur...), false for none, or options. */
|
|
58
58
|
motion?: MotionProp;
|
|
59
|
+
/** What sits between the two dates. Default: the word "to" in the language of the interface ("a" in Spanish). */
|
|
60
|
+
separator?: ReactNode;
|
|
59
61
|
}
|
|
60
62
|
/** Type or pick a start and end date. */
|
|
61
|
-
export declare function DateRangePicker<T extends DateValue>({ motion, presets, label, description, errorMessage, isLoading, className, ...props }: DateRangePickerProps<T>): import("react").JSX.Element;
|
|
63
|
+
export declare function DateRangePicker<T extends DateValue>({ motion, presets, separator, label, description, errorMessage, isLoading, className, ...props }: DateRangePickerProps<T>): import("react").JSX.Element;
|
|
62
64
|
export {};
|