@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
|
@@ -1,67 +1,91 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as n, jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { cx as
|
|
5
|
-
import { useFilter as
|
|
6
|
-
import { Search as
|
|
7
|
-
import { DialogModal as
|
|
8
|
-
import { Kbd as
|
|
9
|
-
import { useStrings as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import { jsx as n, jsxs as m } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as $, useState as N, useEffect as C, useMemo as j, useRef as q } from "react";
|
|
4
|
+
import { cx as B } from "../../utils/cx.js";
|
|
5
|
+
import { useFilter as J, Autocomplete as P, SearchField as Y, Input as Z, Menu as Q, MenuSection as G, Header as ee, Collection as te, MenuItem as z, Keyboard as ne } from "react-aria-components";
|
|
6
|
+
import { Search as se } from "lucide-react";
|
|
7
|
+
import { DialogModal as ie, Dialog as ae } from "../overlay/Overlay.js";
|
|
8
|
+
import { Kbd as oe } from "../typography/Typography.js";
|
|
9
|
+
import { useStrings as le } from "../../i18n/strings.js";
|
|
10
|
+
const E = "__more:";
|
|
11
|
+
function re({ children: g }) {
|
|
12
|
+
const o = q(null), [u, w] = N(!1);
|
|
13
|
+
return C(() => {
|
|
13
14
|
const i = o.current;
|
|
14
15
|
if (!i) return;
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
}, []), /* @__PURE__ */ n("div", { ref: o, className: "alea-command-scroll", tabIndex:
|
|
16
|
+
const f = () => w(i.scrollHeight > i.clientHeight + 1);
|
|
17
|
+
if (f(), typeof ResizeObserver > "u") return;
|
|
18
|
+
const r = new ResizeObserver(f);
|
|
19
|
+
return r.observe(i), i.firstElementChild && r.observe(i.firstElementChild), () => r.disconnect();
|
|
20
|
+
}, []), /* @__PURE__ */ n("div", { ref: o, className: "alea-command-scroll", tabIndex: u ? 0 : void 0, children: g });
|
|
20
21
|
}
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const [
|
|
25
|
-
|
|
22
|
+
const we = $(function({ commands: o, isOpen: u, defaultOpen: w, onOpenChange: i, motion: f, hotkey: r = !0, slashHotkey: M, onQueryChange: b, filter: h, isLoading: p, maxPerGroup: c, placeholder: K, emptyText: R, className: D, style: F, surface: T, radius: V }, H) {
|
|
23
|
+
const a = le();
|
|
24
|
+
K ?? (K = a.commandPlaceholder), R ?? (R = a.noResults);
|
|
25
|
+
const [L, O] = N(w ?? !1), v = u ?? L, [d, _] = N(""), [I, k] = N(/* @__PURE__ */ new Set()), x = (s) => {
|
|
26
|
+
_(s), b == null || b(s);
|
|
27
|
+
}, S = (s) => {
|
|
28
|
+
s || (d && x(""), k(/* @__PURE__ */ new Set())), u === void 0 && O(s), i == null || i(s);
|
|
26
29
|
};
|
|
27
|
-
|
|
28
|
-
if (!
|
|
30
|
+
C(() => {
|
|
31
|
+
if (!r && !M) return;
|
|
29
32
|
const s = (t) => {
|
|
30
|
-
t.key.toLowerCase() === "k" && (t.metaKey || t.ctrlKey)
|
|
33
|
+
if (r && t.key.toLowerCase() === "k" && (t.metaKey || t.ctrlKey)) {
|
|
34
|
+
t.preventDefault(), S(!v);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (M && !v && t.key === "/" && !t.metaKey && !t.ctrlKey && !t.altKey) {
|
|
38
|
+
const e = t.target;
|
|
39
|
+
if (e && (e.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName))) return;
|
|
40
|
+
t.preventDefault(), S(!0);
|
|
41
|
+
}
|
|
31
42
|
};
|
|
32
43
|
return window.addEventListener("keydown", s), () => window.removeEventListener("keydown", s);
|
|
33
44
|
});
|
|
34
|
-
const { contains:
|
|
35
|
-
const s = [];
|
|
36
|
-
for (const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
const { contains: U } = J({ sensitivity: "base" }), A = j(() => {
|
|
46
|
+
const s = (e) => h === !1 || !d ? !0 : h ? h(e, d) : U([e.label, ...e.keywords || []].join(" "), d), t = [];
|
|
47
|
+
for (const e of o) {
|
|
48
|
+
if (!s(e)) continue;
|
|
49
|
+
const l = e.group || "";
|
|
50
|
+
let y = t.find((X) => X.id === l);
|
|
51
|
+
y || t.push(y = { id: l, title: l, items: [] }), y.items.push(e);
|
|
40
52
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
if (c && c > 0) for (const e of t) {
|
|
54
|
+
if (I.has(e.id) || e.items.length <= c) continue;
|
|
55
|
+
const l = e.items.length - c;
|
|
56
|
+
e.items = [...e.items.slice(0, c), { id: E + e.id, more: l, group: e.id }];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
}, [o, d, h, c, I]), W = j(() => new Map(o.map((s) => [s.id, s])), [o]);
|
|
60
|
+
return /* @__PURE__ */ n(ie, { isOpen: v, onOpenChange: S, size: "md", className: "alea-command-overlay", motion: f, surface: T, radius: V, children: /* @__PURE__ */ n(ae, { ref: H, style: F, "aria-label": a.commandPalette, hideClose: !0, className: B("alea-command", D), children: ({ close: s }) => /* @__PURE__ */ m(P, { inputValue: d, onInputChange: x, filter: () => !0, children: [
|
|
61
|
+
/* @__PURE__ */ m(Y, { "aria-label": a.searchCommands, autoFocus: !0, className: "alea-command-search", children: [
|
|
62
|
+
/* @__PURE__ */ n(se, { size: 18, "aria-hidden": "true" }),
|
|
63
|
+
/* @__PURE__ */ n(Z, { placeholder: K, className: "alea-command-input" }),
|
|
64
|
+
/* @__PURE__ */ n(oe, { children: a.esc })
|
|
48
65
|
] }),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
e
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
/* @__PURE__ */ m(re, { children: [
|
|
67
|
+
/* @__PURE__ */ n(Q, { items: A, className: "alea-command-list", "aria-busy": p || void 0, onAction: (t) => {
|
|
68
|
+
if (String(t).startsWith(E)) {
|
|
69
|
+
k((l) => new Set(l).add(String(t).slice(E.length)));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const e = W.get(t);
|
|
73
|
+
s(), e == null || e.onAction();
|
|
74
|
+
}, renderEmptyState: () => /* @__PURE__ */ n("p", { className: "alea-command-empty", role: p ? "status" : void 0, children: p ? a.loading : R }), children: (t) => /* @__PURE__ */ m(G, { id: t.id, className: "alea-option-section", children: [
|
|
75
|
+
t.title && /* @__PURE__ */ n(ee, { className: "alea-option-header", children: t.title }),
|
|
76
|
+
/* @__PURE__ */ n(te, { items: t.items, children: (e) => "more" in e ? /* @__PURE__ */ n(z, { id: e.id, textValue: a.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: a.showNMore(e.more) }) }) }) : /* @__PURE__ */ m(z, { id: e.id, textValue: [e.label, ...e.keywords || []].join(" "), className: "alea-option alea-command-item", children: [
|
|
77
|
+
e.icon && /* @__PURE__ */ n("span", { className: "alea-option-icon", "aria-hidden": "true", children: e.icon }),
|
|
78
|
+
/* @__PURE__ */ m("span", { className: "alea-option-text", children: [
|
|
79
|
+
/* @__PURE__ */ n("span", { slot: "label", children: e.label }),
|
|
80
|
+
e.description && /* @__PURE__ */ n("span", { className: "alea-option-desc", slot: "description", children: e.description })
|
|
81
|
+
] }),
|
|
82
|
+
e.shortcut && /* @__PURE__ */ n(ne, { className: "alea-menu-shortcut", children: e.shortcut })
|
|
83
|
+
] }) })
|
|
84
|
+
] }) }),
|
|
85
|
+
p && A.length > 0 && /* @__PURE__ */ n("p", { className: "alea-command-loading", role: "status", children: a.loading })
|
|
86
|
+
] })
|
|
63
87
|
] }) }) });
|
|
64
88
|
});
|
|
65
89
|
export {
|
|
66
|
-
|
|
90
|
+
we as CommandPalette
|
|
67
91
|
};
|
|
@@ -27,15 +27,17 @@ export declare function Descriptions({ items, columns, layout, bordered, size, t
|
|
|
27
27
|
export interface StatisticProps extends Omit<HTMLAttributes<HTMLDivElement>, 'prefix'> {
|
|
28
28
|
/** What the number is. */
|
|
29
29
|
label: ReactNode;
|
|
30
|
-
/** The number. */
|
|
31
|
-
value: number;
|
|
30
|
+
/** The number. Or ready-made text ("1.234,56 Bs", "n/a"), shown as it is: formatOptions does not apply to text, and animate swaps it with a short crossfade when it changes. With isDecimal, a string is an exact decimal that formatOptions formats. */
|
|
31
|
+
value: number | string;
|
|
32
|
+
/** Reads a string value as an exact decimal ("1234567.89") and formats it with formatOptions, without going through a float. With animate it counts up through the same number of decimals and ends on the exact string. */
|
|
33
|
+
isDecimal?: boolean;
|
|
32
34
|
/** Intl number format (currency, percent, compact). */
|
|
33
35
|
formatOptions?: Intl.NumberFormatOptions;
|
|
34
36
|
/** Change versus before, e.g. 0.12 for +12%. */
|
|
35
37
|
delta?: number;
|
|
36
38
|
/** Is up good? Default true (turns green); false flips the colors (costs, errors). */
|
|
37
39
|
higherIsBetter?: boolean;
|
|
38
|
-
/** Counts up from 0 when it appears (
|
|
40
|
+
/** Counts up from 0 when it appears, and from the old number to the new one when it changes (not with reduced motion: it shows the number at once). A decimal string counts up and ends exact; text crossfades instead. The screen reader text always holds the final value. */
|
|
39
41
|
animate?: boolean;
|
|
40
42
|
/** Before the number, e.g. "$". */
|
|
41
43
|
prefix?: ReactNode;
|
|
@@ -43,7 +45,7 @@ export interface StatisticProps extends Omit<HTMLAttributes<HTMLDivElement>, 'pr
|
|
|
43
45
|
suffix?: ReactNode;
|
|
44
46
|
}
|
|
45
47
|
/** A big number with its label and change. */
|
|
46
|
-
export declare function Statistic({ label, value, formatOptions, delta, higherIsBetter, animate, prefix, suffix, className, ...props }: StatisticProps): import("react").JSX.Element;
|
|
48
|
+
export declare function Statistic({ label, value, isDecimal, formatOptions, delta, higherIsBetter, animate, prefix, suffix, className, ...props }: StatisticProps): import("react").JSX.Element;
|
|
47
49
|
export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
48
50
|
/** What is empty, in a few words. */
|
|
49
51
|
title: ReactNode;
|
|
@@ -1,79 +1,89 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { createElement as
|
|
4
|
-
import { Inbox as
|
|
5
|
-
import { cx as
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { jsx as e, jsxs as r, Fragment as L } from "react/jsx-runtime";
|
|
3
|
+
import { createElement as U, useState as G, useRef as z, useEffect as O } from "react";
|
|
4
|
+
import { Inbox as D, 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 N } from "../../utils/cx.js";
|
|
6
|
+
import { isDecimalString as Q } from "../../utils/decimal.js";
|
|
7
|
+
import { useReducedMotion as V, TextSwap as Y } from "@alea-design/motion";
|
|
8
|
+
function ie({ items: c, columns: a = 2, layout: d = "stacked", bordered: l, size: n, title: o, extra: s, labelWidth: m, className: h, style: p, ...u }) {
|
|
9
|
+
const i = /* @__PURE__ */ e("dl", { className: "alea-descriptions", "data-columns": a, "data-layout": d, "data-bordered": l || void 0, "data-size": n, style: m ? { "--alea-desc-label": m } : void 0, children: c.map((t, v) => /* @__PURE__ */ r("div", { className: "alea-desc-item", "data-wide": t.wide || void 0, "data-span": t.span && t.span > 1 ? t.span : void 0, children: [
|
|
8
10
|
/* @__PURE__ */ e("dt", { children: t.label }),
|
|
9
11
|
/* @__PURE__ */ e("dd", { children: t.value })
|
|
10
|
-
] },
|
|
11
|
-
return !
|
|
12
|
-
/* @__PURE__ */
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
] }, v)) });
|
|
13
|
+
return !o && !s ? /* @__PURE__ */ e("div", { ...u, style: p, className: N("alea-descriptions-wrap", h), children: i }) : /* @__PURE__ */ r("section", { ...u, style: p, className: N("alea-descriptions-wrap", h), children: [
|
|
14
|
+
/* @__PURE__ */ r("header", { className: "alea-descriptions-head", children: [
|
|
15
|
+
o && /* @__PURE__ */ e("h3", { className: "alea-descriptions-title", children: o }),
|
|
16
|
+
s && /* @__PURE__ */ e("div", { className: "alea-descriptions-extra", children: s })
|
|
15
17
|
] }),
|
|
16
|
-
|
|
18
|
+
i
|
|
17
19
|
] });
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
21
|
+
function ce({ label: c, value: a, isDecimal: d, formatOptions: l, delta: n, higherIsBetter: o = !0, animate: s, prefix: m, suffix: h, className: p, ...u }) {
|
|
22
|
+
var C;
|
|
23
|
+
const i = !!d && Q(a), t = typeof a == "string" && !i, v = V(), f = t ? 0 : i ? Number(a) : a, E = i ? ((C = a.trim().split(".")[1]) == null ? void 0 : C.length) ?? 0 : 0, [w, I] = G(s && !t ? 0 : f), x = z(w), S = z(0);
|
|
24
|
+
O(() => {
|
|
25
|
+
if (t) return;
|
|
26
|
+
const y = (g) => {
|
|
27
|
+
x.current = g, I(g);
|
|
28
|
+
};
|
|
29
|
+
if (!s || v || typeof window > "u") {
|
|
30
|
+
y(f);
|
|
25
31
|
return;
|
|
26
32
|
}
|
|
27
|
-
const
|
|
28
|
-
const b = Math.min(1, (
|
|
29
|
-
|
|
33
|
+
const R = x.current, j = performance.now(), q = 900, k = (g) => {
|
|
34
|
+
const b = Math.min(1, (g - j) / q);
|
|
35
|
+
y(b < 1 ? R + (f - R) * (1 - Math.pow(1 - b, 3)) : f), b < 1 && (S.current = requestAnimationFrame(k));
|
|
30
36
|
};
|
|
31
|
-
return
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
34
|
-
return /* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */ e("div", { className: "alea-stat-label", children:
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
return S.current = requestAnimationFrame(k), () => cancelAnimationFrame(S.current);
|
|
38
|
+
}, [f, s, v, t]);
|
|
39
|
+
const M = new Intl.NumberFormat(void 0, l), F = (y) => M.format(y), T = t || w === f || !s ? a : i ? w.toFixed(E) : Math.round(w * 100) / 100, A = n === void 0 ? null : n >= 0 === o;
|
|
40
|
+
return /* @__PURE__ */ r("div", { ...u, className: N("alea-stat", p), children: [
|
|
41
|
+
/* @__PURE__ */ e("div", { className: "alea-stat-label", children: c }),
|
|
42
|
+
/* @__PURE__ */ e("div", { className: "alea-stat-value", children: t ? /* @__PURE__ */ r("span", { children: [
|
|
43
|
+
m,
|
|
44
|
+
s ? /* @__PURE__ */ e(Y, { children: String(a) }) : a,
|
|
45
|
+
h
|
|
46
|
+
] }) : /* @__PURE__ */ r(L, { children: [
|
|
47
|
+
/* @__PURE__ */ r("span", { "aria-hidden": "true", children: [
|
|
48
|
+
m,
|
|
49
|
+
F(T),
|
|
50
|
+
h
|
|
41
51
|
] }),
|
|
42
|
-
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", children:
|
|
43
|
-
] }),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
|
|
48
|
-
new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(
|
|
52
|
+
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", children: F(a) })
|
|
53
|
+
] }) }),
|
|
54
|
+
n !== void 0 && /* @__PURE__ */ r("div", { className: "alea-stat-delta", "data-good": A ? !0 : void 0, "data-bad": A === !1 ? !0 : void 0, children: [
|
|
55
|
+
n >= 0 ? /* @__PURE__ */ e(K, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ e(P, { size: 14, "aria-hidden": "true" }),
|
|
56
|
+
/* @__PURE__ */ r("span", { children: [
|
|
57
|
+
n >= 0 ? "+" : "",
|
|
58
|
+
new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(n)
|
|
49
59
|
] }),
|
|
50
|
-
/* @__PURE__ */
|
|
51
|
-
|
|
60
|
+
/* @__PURE__ */ r("span", { className: "alea-visually-hidden", children: [
|
|
61
|
+
n >= 0 ? "up" : "down",
|
|
52
62
|
" from before"
|
|
53
63
|
] })
|
|
54
64
|
] })
|
|
55
65
|
] });
|
|
56
66
|
}
|
|
57
|
-
function
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */ e("span", { className:
|
|
60
|
-
|
|
67
|
+
function Z({ title: c, description: a, icon: d, illustration: l, action: n, secondaryAction: o, footer: s, size: m, variant: h, headingAs: p = "h3", className: u, ...i }) {
|
|
68
|
+
return /* @__PURE__ */ r("div", { ...i, className: N("alea-empty", u), "data-size": m, "data-variant": h, children: [
|
|
69
|
+
/* @__PURE__ */ e("span", { className: l ? "alea-empty-art" : "alea-empty-icon", "aria-hidden": "true", children: d ?? /* @__PURE__ */ e(D, {}) }),
|
|
70
|
+
U(p, { className: "alea-empty-title" }, c),
|
|
61
71
|
a && /* @__PURE__ */ e("p", { className: "alea-empty-text", children: a }),
|
|
62
|
-
(
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
(n || o) && /* @__PURE__ */ r("div", { className: "alea-empty-action", children: [
|
|
73
|
+
n,
|
|
74
|
+
o
|
|
65
75
|
] }),
|
|
66
|
-
|
|
76
|
+
s && /* @__PURE__ */ e("p", { className: "alea-empty-footer", children: s })
|
|
67
77
|
] });
|
|
68
78
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
return /* @__PURE__ */ e(
|
|
79
|
+
const $ = { success: J, error: H, 404: B, 403: _, 500: X, info: D };
|
|
80
|
+
function de({ status: c, className: a, ...d }) {
|
|
81
|
+
const l = $[c];
|
|
82
|
+
return /* @__PURE__ */ e(Z, { ...d, headingAs: d.headingAs ?? "h2", icon: /* @__PURE__ */ e(l, {}), className: N("alea-result", a), "data-status": c });
|
|
73
83
|
}
|
|
74
84
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
ie as Descriptions,
|
|
86
|
+
Z as EmptyState,
|
|
87
|
+
de as Result,
|
|
88
|
+
ce as Statistic
|
|
79
89
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
import { type CalendarProps as RACCalendarProps, type RangeCalendarProps as RACRangeCalendarProps, type DatePickerProps as RACDatePickerProps, type DateRangePickerProps as RACDateRangePickerProps, type DateFieldProps as RACDateFieldProps, type TimeFieldProps as RACTimeFieldProps, type DateValue, type TimeValue, type ValidationResult } from 'react-aria-components';
|
|
3
3
|
import type { MotionProp } from '@alea-design/motion';
|
|
4
4
|
interface CalendarExtras {
|
|
@@ -39,10 +39,24 @@ export interface DatePickerProps<T extends DateValue> extends RACDatePickerProps
|
|
|
39
39
|
}
|
|
40
40
|
/** Type a date or pick it from a calendar. */
|
|
41
41
|
export declare function DatePicker<T extends DateValue>({ motion, label, description, errorMessage, isLoading, className, ...props }: DatePickerProps<T>): import("react").JSX.Element;
|
|
42
|
+
/** A shortcut of a DateRangePicker: a label and a function that returns the range it sets. */
|
|
43
|
+
export interface DateRangePreset {
|
|
44
|
+
/** The text of the shortcut button ("Today", "Last 7 days"). Translate it yourself. */
|
|
45
|
+
label: ReactNode;
|
|
46
|
+
/** Called when the shortcut is pressed (so "today" is today, not the day the page loaded). Return the start and end dates. */
|
|
47
|
+
range: () => {
|
|
48
|
+
start: DateValue;
|
|
49
|
+
end: DateValue;
|
|
50
|
+
};
|
|
51
|
+
/** Stable key, when the label is not text. */
|
|
52
|
+
id?: string;
|
|
53
|
+
}
|
|
42
54
|
export interface DateRangePickerProps<T extends DateValue> extends RACDateRangePickerProps<T>, Bits {
|
|
55
|
+
/** Shortcut buttons above the calendar that set the range in one press (Today, Last 7 days, This month). The popup closes after one is pressed. */
|
|
56
|
+
presets?: DateRangePreset[];
|
|
43
57
|
/** How the popup enters and leaves: a preset (fade, scale, pop, slide-down, blur...), false for none, or options. */
|
|
44
58
|
motion?: MotionProp;
|
|
45
59
|
}
|
|
46
60
|
/** Type or pick a start and end date. */
|
|
47
|
-
export declare function DateRangePicker<T extends DateValue>({ motion, label, description, errorMessage, isLoading, className, ...props }: DateRangePickerProps<T>): import("react").JSX.Element;
|
|
61
|
+
export declare function DateRangePicker<T extends DateValue>({ motion, presets, label, description, errorMessage, isLoading, className, ...props }: DateRangePickerProps<T>): import("react").JSX.Element;
|
|
48
62
|
export {};
|
|
@@ -1,109 +1,120 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as i, jsx as a, Fragment as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { jsxs as i, jsx as a, Fragment as S } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as $ } from "react";
|
|
4
|
+
import { Calendar as x, DateField as z, DatePicker as B, Group as b, Button as m, Dialog as P, DateRangePicker as G, DateInput as p, DateSegment as v, RangeCalendar as H, TimeField as T, CalendarMonthPicker as j, CalendarYearPicker as A, Heading as E, DateRangePickerStateContext as I, CalendarGrid as O, CalendarGridHeader as V, CalendarHeaderCell as Y, CalendarGridBody as _, CalendarCell as J } from "react-aria-components";
|
|
5
|
+
import { CalendarDays as k, ChevronLeft as K, ChevronRight as Q } from "lucide-react";
|
|
6
|
+
import { withBase as s } from "../../utils/cx.js";
|
|
7
|
+
import { Label as U, Description as W, FieldError as X } from "../field/Field.js";
|
|
7
8
|
import { Popover as w } from "../overlay/Overlay.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import { Button as Z } from "../button/Button.js";
|
|
10
|
+
import { FieldSpinner as u, loadingAttrs as h } from "../field/FieldLoading.js";
|
|
11
|
+
import { useStrings as C } from "../../i18n/strings.js";
|
|
12
|
+
function y({ pickers: r }) {
|
|
11
13
|
return /* @__PURE__ */ i("header", { className: "alea-cal-head", children: [
|
|
12
|
-
/* @__PURE__ */ a(
|
|
14
|
+
/* @__PURE__ */ a(m, { slot: "previous", className: "alea-cal-nav alea-focus-ring", children: /* @__PURE__ */ a(K, { size: 16 }) }),
|
|
13
15
|
r ? /* @__PURE__ */ i("div", { className: "alea-cal-pickers", children: [
|
|
14
|
-
/* @__PURE__ */ a(
|
|
15
|
-
/* @__PURE__ */ a(
|
|
16
|
-
] }) : /* @__PURE__ */ a(
|
|
17
|
-
/* @__PURE__ */ a(
|
|
16
|
+
/* @__PURE__ */ a(j, { children: (l) => /* @__PURE__ */ a("select", { className: "alea-cal-select alea-focus-ring", "aria-label": l["aria-label"], value: String(l.value), onChange: (e) => l.onChange(Number(e.target.value)), children: l.items.map((e) => /* @__PURE__ */ a("option", { value: e.id, children: e.formatted }, e.id)) }) }),
|
|
17
|
+
/* @__PURE__ */ a(A, { children: (l) => /* @__PURE__ */ a("select", { className: "alea-cal-select alea-focus-ring", "aria-label": l["aria-label"], value: String(l.value), onChange: (e) => l.onChange(Number(e.target.value)), children: l.items.map((e) => /* @__PURE__ */ a("option", { value: e.id, children: e.formatted }, e.id)) }) })
|
|
18
|
+
] }) : /* @__PURE__ */ a(E, { className: "alea-cal-title" }),
|
|
19
|
+
/* @__PURE__ */ a(m, { slot: "next", className: "alea-cal-nav alea-focus-ring", children: /* @__PURE__ */ a(Q, { size: 16 }) })
|
|
18
20
|
] });
|
|
19
21
|
}
|
|
20
|
-
function
|
|
21
|
-
return /* @__PURE__ */ i(
|
|
22
|
-
/* @__PURE__ */ a(
|
|
23
|
-
/* @__PURE__ */ a(
|
|
22
|
+
function R({ offset: r = 0 }) {
|
|
23
|
+
return /* @__PURE__ */ i(O, { className: "alea-cal-grid", weekdayStyle: "short", offset: r ? { months: r } : void 0, children: [
|
|
24
|
+
/* @__PURE__ */ a(V, { children: (l) => /* @__PURE__ */ a(Y, { className: "alea-cal-weekday", children: l }) }),
|
|
25
|
+
/* @__PURE__ */ a(_, { children: (l) => /* @__PURE__ */ a(J, { date: l, className: "alea-cal-cell alea-focus-ring" }) })
|
|
24
26
|
] });
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
return /* @__PURE__ */ i(
|
|
29
|
-
/* @__PURE__ */ a(
|
|
30
|
-
/* @__PURE__ */ a(
|
|
28
|
+
const F = ({ count: r }) => r > 1 ? /* @__PURE__ */ a("div", { className: "alea-cal-months", children: Array.from({ length: r }, (l, e) => /* @__PURE__ */ a(R, { offset: e }, e)) }) : /* @__PURE__ */ a(R, {});
|
|
29
|
+
function L({ className: r, pickers: l, visibleMonths: e = 1, ...n }) {
|
|
30
|
+
return /* @__PURE__ */ i(x, { ...n, visibleDuration: e > 1 ? { months: e } : n.visibleDuration, className: s("alea-calendar", r), "data-months": e > 1 ? e : void 0, children: [
|
|
31
|
+
/* @__PURE__ */ a(y, { pickers: l }),
|
|
32
|
+
/* @__PURE__ */ a(F, { count: e })
|
|
31
33
|
] });
|
|
32
34
|
}
|
|
33
|
-
function
|
|
34
|
-
return /* @__PURE__ */ i(
|
|
35
|
-
/* @__PURE__ */ a(
|
|
36
|
-
/* @__PURE__ */ a(
|
|
35
|
+
function M({ className: r, pickers: l, visibleMonths: e = 1, ...n }) {
|
|
36
|
+
return /* @__PURE__ */ i(H, { ...n, visibleDuration: e > 1 ? { months: e } : n.visibleDuration, className: s("alea-calendar alea-range-calendar", r), "data-months": e > 1 ? e : void 0, children: [
|
|
37
|
+
/* @__PURE__ */ a(y, { pickers: l }),
|
|
38
|
+
/* @__PURE__ */ a(F, { count: e })
|
|
37
39
|
] });
|
|
38
40
|
}
|
|
39
|
-
function
|
|
40
|
-
return r ? /* @__PURE__ */ i(
|
|
41
|
+
function f({ label: r, isRequired: l }) {
|
|
42
|
+
return r ? /* @__PURE__ */ i(U, { children: [
|
|
41
43
|
r,
|
|
42
44
|
l && /* @__PURE__ */ a("span", { className: "alea-label-required", "aria-hidden": "true", children: " *" })
|
|
43
45
|
] }) : null;
|
|
44
46
|
}
|
|
45
47
|
function N({ description: r, errorMessage: l }) {
|
|
46
|
-
return /* @__PURE__ */ i(
|
|
47
|
-
r && /* @__PURE__ */ a(
|
|
48
|
-
/* @__PURE__ */ a(
|
|
48
|
+
return /* @__PURE__ */ i(S, { children: [
|
|
49
|
+
r && /* @__PURE__ */ a(W, { children: r }),
|
|
50
|
+
/* @__PURE__ */ a(X, { children: l })
|
|
49
51
|
] });
|
|
50
52
|
}
|
|
51
|
-
function
|
|
52
|
-
return /* @__PURE__ */ a(
|
|
53
|
+
function D() {
|
|
54
|
+
return /* @__PURE__ */ a(p, { className: "alea-date-input", children: (r) => /* @__PURE__ */ a(v, { segment: r, className: "alea-date-segment" }) });
|
|
53
55
|
}
|
|
54
|
-
function
|
|
55
|
-
return /* @__PURE__ */ i(
|
|
56
|
-
/* @__PURE__ */ a(
|
|
56
|
+
function ma({ label: r, description: l, errorMessage: e, isLoading: n, className: t, ...c }) {
|
|
57
|
+
return /* @__PURE__ */ i(z, { ...c, className: s("alea-field", t), ...h(n), children: [
|
|
58
|
+
/* @__PURE__ */ a(f, { label: r, isRequired: c.isRequired }),
|
|
57
59
|
/* @__PURE__ */ i("div", { className: "alea-input-wrap alea-date-wrap", "aria-busy": n || void 0, children: [
|
|
58
|
-
/* @__PURE__ */ a(
|
|
59
|
-
n && /* @__PURE__ */ a(
|
|
60
|
+
/* @__PURE__ */ a(D, {}),
|
|
61
|
+
n && /* @__PURE__ */ a(u, {})
|
|
60
62
|
] }),
|
|
61
63
|
/* @__PURE__ */ a(N, { description: l, errorMessage: e })
|
|
62
64
|
] });
|
|
63
65
|
}
|
|
64
|
-
function
|
|
65
|
-
return /* @__PURE__ */ i(
|
|
66
|
-
/* @__PURE__ */ a(
|
|
66
|
+
function ua({ label: r, description: l, errorMessage: e, isLoading: n, className: t, ...c }) {
|
|
67
|
+
return /* @__PURE__ */ i(T, { ...c, className: s("alea-field", t), ...h(n), children: [
|
|
68
|
+
/* @__PURE__ */ a(f, { label: r, isRequired: c.isRequired }),
|
|
67
69
|
/* @__PURE__ */ i("div", { className: "alea-input-wrap alea-date-wrap", "aria-busy": n || void 0, children: [
|
|
68
|
-
/* @__PURE__ */ a(
|
|
69
|
-
n && /* @__PURE__ */ a(
|
|
70
|
+
/* @__PURE__ */ a(D, {}),
|
|
71
|
+
n && /* @__PURE__ */ a(u, {})
|
|
70
72
|
] }),
|
|
71
73
|
/* @__PURE__ */ a(N, { description: l, errorMessage: e })
|
|
72
74
|
] });
|
|
73
75
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
76
|
-
return /* @__PURE__ */ i(
|
|
77
|
-
/* @__PURE__ */ a(
|
|
78
|
-
/* @__PURE__ */ i(
|
|
79
|
-
/* @__PURE__ */ a(
|
|
80
|
-
t && /* @__PURE__ */ a(
|
|
81
|
-
/* @__PURE__ */ a(
|
|
76
|
+
function ha({ motion: r, label: l, description: e, errorMessage: n, isLoading: t, className: c, ...d }) {
|
|
77
|
+
const o = C();
|
|
78
|
+
return /* @__PURE__ */ i(B, { ...d, className: s("alea-field", c), ...h(t), children: [
|
|
79
|
+
/* @__PURE__ */ a(f, { label: l, isRequired: d.isRequired }),
|
|
80
|
+
/* @__PURE__ */ i(b, { className: "alea-input-wrap alea-date-wrap", "aria-busy": t || void 0, children: [
|
|
81
|
+
/* @__PURE__ */ a(D, {}),
|
|
82
|
+
t && /* @__PURE__ */ a(u, {}),
|
|
83
|
+
/* @__PURE__ */ a(m, { className: "alea-input-clear alea-focus-ring", "aria-label": o.openCalendar, children: /* @__PURE__ */ a(k, { size: 16 }) })
|
|
82
84
|
] }),
|
|
83
85
|
/* @__PURE__ */ a(N, { description: e, errorMessage: n }),
|
|
84
|
-
/* @__PURE__ */ a(w, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ a(
|
|
86
|
+
/* @__PURE__ */ a(w, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ a(P, { className: "alea-cal-dialog", children: /* @__PURE__ */ a(L, {}) }) })
|
|
85
87
|
] });
|
|
86
88
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
function aa({ presets: r }) {
|
|
90
|
+
const l = C(), e = $(I);
|
|
91
|
+
return /* @__PURE__ */ a("div", { className: "alea-cal-presets", role: "group", "aria-label": l.dateRangePresets, children: r.map((n, t) => /* @__PURE__ */ a(Z, { size: "sm", variant: "soft", onPress: () => {
|
|
92
|
+
e == null || e.setValue(n.range()), e == null || e.setOpen(!1);
|
|
93
|
+
}, children: n.label }, n.id ?? (typeof n.label == "string" ? n.label : t))) });
|
|
94
|
+
}
|
|
95
|
+
function fa({ motion: r, presets: l, label: e, description: n, errorMessage: t, isLoading: c, className: d, ...o }) {
|
|
96
|
+
const q = C();
|
|
97
|
+
return /* @__PURE__ */ i(G, { ...o, className: s("alea-field", d), ...h(c), children: [
|
|
98
|
+
/* @__PURE__ */ a(f, { label: e, isRequired: o.isRequired }),
|
|
99
|
+
/* @__PURE__ */ i(b, { className: "alea-input-wrap alea-date-wrap", "aria-busy": c || void 0, children: [
|
|
100
|
+
/* @__PURE__ */ a(p, { slot: "start", className: "alea-date-input", children: (g) => /* @__PURE__ */ a(v, { segment: g, className: "alea-date-segment" }) }),
|
|
93
101
|
/* @__PURE__ */ a("span", { className: "alea-date-dash", "aria-hidden": "true", children: "to" }),
|
|
94
|
-
/* @__PURE__ */ a(
|
|
95
|
-
|
|
96
|
-
/* @__PURE__ */ a(
|
|
102
|
+
/* @__PURE__ */ a(p, { slot: "end", className: "alea-date-input", children: (g) => /* @__PURE__ */ a(v, { segment: g, className: "alea-date-segment" }) }),
|
|
103
|
+
c && /* @__PURE__ */ a(u, {}),
|
|
104
|
+
/* @__PURE__ */ a(m, { className: "alea-input-clear alea-focus-ring", "aria-label": q.openCalendar, children: /* @__PURE__ */ a(k, { size: 16 }) })
|
|
97
105
|
] }),
|
|
98
|
-
/* @__PURE__ */ a(N, { description:
|
|
99
|
-
/* @__PURE__ */ a(w, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ a(N, { description: n, errorMessage: t }),
|
|
107
|
+
/* @__PURE__ */ a(w, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ i(P, { className: "alea-cal-dialog", children: [
|
|
108
|
+
l && l.length > 0 && /* @__PURE__ */ a(aa, { presets: l }),
|
|
109
|
+
/* @__PURE__ */ a(M, {})
|
|
110
|
+
] }) })
|
|
100
111
|
] });
|
|
101
112
|
}
|
|
102
113
|
export {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
L as Calendar,
|
|
115
|
+
ma as DateField,
|
|
116
|
+
ha as DatePicker,
|
|
117
|
+
fa as DateRangePicker,
|
|
118
|
+
M as RangeCalendar,
|
|
119
|
+
ua as TimeField
|
|
109
120
|
};
|
|
@@ -6,6 +6,8 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
6
6
|
tone?: Tone;
|
|
7
7
|
/** soft (tinted, default), solid, or outline. */
|
|
8
8
|
appearance?: 'soft' | 'solid' | 'outline';
|
|
9
|
+
/** Lets a long text break onto several lines (the badge grows from its normal height) instead of staying on one line and being cut. For narrow screens and large text. */
|
|
10
|
+
wrap?: boolean;
|
|
9
11
|
/** A dot before the text, for statuses. pulse makes it breathe, for live things. */
|
|
10
12
|
dot?: boolean | 'pulse';
|
|
11
13
|
/** An icon before the text. */
|
|
@@ -17,7 +19,7 @@ export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
17
19
|
children?: ReactNode;
|
|
18
20
|
}
|
|
19
21
|
/** A small status or count label: six tones, three looks, three sizes, a dot or an icon. Not interactive. */
|
|
20
|
-
export declare function Badge({ tone, appearance, dot, icon, size, shape, className, children, ...props }: BadgeProps): import("react").JSX.Element;
|
|
22
|
+
export declare function Badge({ tone, appearance, dot, icon, size, shape, wrap, className, children, ...props }: BadgeProps): import("react").JSX.Element;
|
|
21
23
|
/** The tone for common status words (lowercase). Extend or override it with StatusBadge's tones. */
|
|
22
24
|
export declare const STATUS_TONES: Record<string, Tone>;
|
|
23
25
|
export interface StatusBadgeProps extends Omit<BadgeProps, 'tone' | 'children'> {
|