@alea-design/ui 0.6.0 → 0.7.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 +58 -57
- package/dist/components/button/Groups.js +41 -41
- package/dist/components/command/CommandPalette.js +63 -61
- package/dist/components/data/Data.d.ts +10 -6
- package/dist/components/data/Data.js +53 -53
- 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/media/Media.d.ts +5 -1
- package/dist/components/media/Media.js +113 -111
- package/dist/components/navigation/Navigation.d.ts +11 -7
- package/dist/components/navigation/Navigation.js +97 -97
- package/dist/components/navigation/Navigation2.d.ts +4 -2
- package/dist/components/navigation/Navigation2.js +219 -211
- package/dist/components/overlay/Overlay.d.ts +4 -0
- package/dist/components/overlay/Overlay.js +52 -52
- package/dist/components/page/PageParts.d.ts +8 -2
- package/dist/components/page/PageParts.js +95 -87
- package/dist/components/shell/AppShell.d.ts +3 -1
- package/dist/components/shell/AppShell.js +33 -32
- package/dist/components/table/Table.d.ts +6 -3
- package/dist/components/table/Table.js +45 -45
- 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/feedback.css +1 -1
- package/dist/css/groups.json +11 -11
- 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/typography.css +1 -1
- package/dist/i18n/strings.d.ts +4 -1
- package/dist/i18n/strings.js +8 -2
- 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/package.json +3 -3
|
@@ -1,85 +1,85 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
3
|
-
import { createElement as U, useState as G, useRef as
|
|
4
|
-
import { Inbox as
|
|
5
|
-
import { cx as
|
|
2
|
+
import { jsx as e, jsxs as s, Fragment as L } from "react/jsx-runtime";
|
|
3
|
+
import { createElement as U, useState as G, useRef as D, useEffect as O } from "react";
|
|
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 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, layout:
|
|
9
|
-
const
|
|
10
|
-
/* @__PURE__ */ e("dt", { children:
|
|
11
|
-
/* @__PURE__ */ e("dd", { children:
|
|
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
12
|
] }, v)) });
|
|
13
|
-
return !
|
|
14
|
-
/* @__PURE__ */
|
|
15
|
-
|
|
16
|
-
|
|
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:
|
|
22
|
-
var
|
|
23
|
-
const i = !!
|
|
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
|
+
var R;
|
|
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
|
-
|
|
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
|
|
34
|
-
const
|
|
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
|
-
return
|
|
38
|
-
}, [
|
|
39
|
-
const M = new Intl.NumberFormat(void 0,
|
|
40
|
-
return /* @__PURE__ */
|
|
37
|
+
return b.current = requestAnimationFrame(z), () => cancelAnimationFrame(b.current);
|
|
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:
|
|
42
|
+
/* @__PURE__ */ e("div", { className: "alea-stat-value", children: d ? /* @__PURE__ */ s("span", { children: [
|
|
43
43
|
m,
|
|
44
|
-
|
|
44
|
+
r ? /* @__PURE__ */ e(Y, { children: String(a) }) : a,
|
|
45
45
|
h
|
|
46
|
-
] }) : /* @__PURE__ */
|
|
47
|
-
/* @__PURE__ */
|
|
46
|
+
] }) : /* @__PURE__ */ s(L, { children: [
|
|
47
|
+
/* @__PURE__ */ s("span", { "aria-hidden": "true", children: [
|
|
48
48
|
m,
|
|
49
|
-
|
|
49
|
+
A(T),
|
|
50
50
|
h
|
|
51
51
|
] }),
|
|
52
|
-
/* @__PURE__ */ e("span", { className: "alea-visually-hidden", children:
|
|
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
|
-
const $ = { success: J, error: H, 404: B, 403: _, 500: X, info:
|
|
80
|
-
function de({ status: c, className: a, ...
|
|
81
|
-
const
|
|
82
|
-
return /* @__PURE__ */ e(Z, { ...
|
|
79
|
+
const $ = { success: J, error: H, 404: B, 403: _, 500: X, info: E };
|
|
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 {};
|
|
@@ -1,120 +1,120 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as i, jsx as a, Fragment as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { Calendar as
|
|
5
|
-
import { CalendarDays as
|
|
2
|
+
import { jsxs as i, jsx as a, Fragment as $ } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as x } from "react";
|
|
4
|
+
import { Calendar as z, DateField as B, DatePicker as G, Group as k, Button as o, Dialog as w, DateRangePicker as T, DateInput as p, DateSegment as v, RangeCalendar as H, TimeField as j, CalendarMonthPicker as A, CalendarYearPicker as E, Heading as I, DateRangePickerStateContext as O, CalendarGrid as V, CalendarGridHeader as Y, CalendarHeaderCell as _, CalendarGridBody as J, CalendarCell as K } from "react-aria-components";
|
|
5
|
+
import { CalendarDays as y, ChevronLeft as Q, ChevronRight as U } from "lucide-react";
|
|
6
6
|
import { withBase as s } from "../../utils/cx.js";
|
|
7
|
-
import { Label as
|
|
8
|
-
import { Popover as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { FieldSpinner as
|
|
7
|
+
import { Label as W, Description as X, FieldError as Z } from "../field/Field.js";
|
|
8
|
+
import { Popover as F } from "../overlay/Overlay.js";
|
|
9
|
+
import { Button as L } from "../button/Button.js";
|
|
10
|
+
import { FieldSpinner as m, loadingAttrs as u } from "../field/FieldLoading.js";
|
|
11
11
|
import { useStrings as C } from "../../i18n/strings.js";
|
|
12
|
-
function
|
|
12
|
+
function q({ pickers: r }) {
|
|
13
13
|
return /* @__PURE__ */ i("header", { className: "alea-cal-head", children: [
|
|
14
|
-
/* @__PURE__ */ a(
|
|
14
|
+
/* @__PURE__ */ a(o, { slot: "previous", className: "alea-cal-nav alea-focus-ring", children: /* @__PURE__ */ a(Q, { size: 16 }) }),
|
|
15
15
|
r ? /* @__PURE__ */ i("div", { className: "alea-cal-pickers", children: [
|
|
16
|
-
/* @__PURE__ */ a(
|
|
17
|
-
/* @__PURE__ */ a(
|
|
18
|
-
] }) : /* @__PURE__ */ a(
|
|
19
|
-
/* @__PURE__ */ a(
|
|
16
|
+
/* @__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)) }) }),
|
|
17
|
+
/* @__PURE__ */ a(E, { 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(I, { className: "alea-cal-title" }),
|
|
19
|
+
/* @__PURE__ */ a(o, { slot: "next", className: "alea-cal-nav alea-focus-ring", children: /* @__PURE__ */ a(U, { size: 16 }) })
|
|
20
20
|
] });
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return /* @__PURE__ */ i(
|
|
24
|
-
/* @__PURE__ */ a(
|
|
25
|
-
/* @__PURE__ */ a(
|
|
22
|
+
function P({ offset: r = 0 }) {
|
|
23
|
+
return /* @__PURE__ */ i(V, { className: "alea-cal-grid", weekdayStyle: "short", offset: r ? { months: r } : void 0, children: [
|
|
24
|
+
/* @__PURE__ */ a(Y, { children: (l) => /* @__PURE__ */ a(_, { className: "alea-cal-weekday", children: l }) }),
|
|
25
|
+
/* @__PURE__ */ a(J, { children: (l) => /* @__PURE__ */ a(K, { date: l, className: "alea-cal-cell alea-focus-ring" }) })
|
|
26
26
|
] });
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return /* @__PURE__ */ i(
|
|
31
|
-
/* @__PURE__ */ a(
|
|
32
|
-
/* @__PURE__ */ a(
|
|
28
|
+
const S = ({ count: r }) => r > 1 ? /* @__PURE__ */ a("div", { className: "alea-cal-months", children: Array.from({ length: r }, (l, e) => /* @__PURE__ */ a(P, { offset: e }, e)) }) : /* @__PURE__ */ a(P, {});
|
|
29
|
+
function M({ className: r, pickers: l, visibleMonths: e = 1, ...n }) {
|
|
30
|
+
return /* @__PURE__ */ i(z, { ...n, visibleDuration: e > 1 ? { months: e } : n.visibleDuration, className: s("alea-calendar", r), "data-months": e > 1 ? e : void 0, children: [
|
|
31
|
+
/* @__PURE__ */ a(q, { pickers: l }),
|
|
32
|
+
/* @__PURE__ */ a(S, { count: e })
|
|
33
33
|
] });
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function aa({ className: r, pickers: l, visibleMonths: e = 1, ...n }) {
|
|
36
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(
|
|
38
|
-
/* @__PURE__ */ a(
|
|
37
|
+
/* @__PURE__ */ a(q, { pickers: l }),
|
|
38
|
+
/* @__PURE__ */ a(S, { count: e })
|
|
39
39
|
] });
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return r ? /* @__PURE__ */ i(
|
|
41
|
+
function h({ label: r, isRequired: l }) {
|
|
42
|
+
return r ? /* @__PURE__ */ i(W, { children: [
|
|
43
43
|
r,
|
|
44
44
|
l && /* @__PURE__ */ a("span", { className: "alea-label-required", "aria-hidden": "true", children: " *" })
|
|
45
45
|
] }) : null;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return /* @__PURE__ */ i(
|
|
49
|
-
r && /* @__PURE__ */ a(
|
|
50
|
-
/* @__PURE__ */ a(
|
|
47
|
+
function f({ description: r, errorMessage: l }) {
|
|
48
|
+
return /* @__PURE__ */ i($, { children: [
|
|
49
|
+
r && /* @__PURE__ */ a(X, { children: r }),
|
|
50
|
+
/* @__PURE__ */ a(Z, { children: l })
|
|
51
51
|
] });
|
|
52
52
|
}
|
|
53
53
|
function D() {
|
|
54
54
|
return /* @__PURE__ */ a(p, { className: "alea-date-input", children: (r) => /* @__PURE__ */ a(v, { segment: r, className: "alea-date-segment" }) });
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return /* @__PURE__ */ i(
|
|
58
|
-
/* @__PURE__ */ a(
|
|
56
|
+
function ua({ label: r, description: l, errorMessage: e, isLoading: n, className: t, ...c }) {
|
|
57
|
+
return /* @__PURE__ */ i(B, { ...c, className: s("alea-field", t), ...u(n), children: [
|
|
58
|
+
/* @__PURE__ */ a(h, { label: r, isRequired: c.isRequired }),
|
|
59
59
|
/* @__PURE__ */ i("div", { className: "alea-input-wrap alea-date-wrap", "aria-busy": n || void 0, children: [
|
|
60
60
|
/* @__PURE__ */ a(D, {}),
|
|
61
|
-
n && /* @__PURE__ */ a(
|
|
61
|
+
n && /* @__PURE__ */ a(m, {})
|
|
62
62
|
] }),
|
|
63
|
-
/* @__PURE__ */ a(
|
|
63
|
+
/* @__PURE__ */ a(f, { description: l, errorMessage: e })
|
|
64
64
|
] });
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
return /* @__PURE__ */ i(
|
|
68
|
-
/* @__PURE__ */ a(
|
|
66
|
+
function ha({ label: r, description: l, errorMessage: e, isLoading: n, className: t, ...c }) {
|
|
67
|
+
return /* @__PURE__ */ i(j, { ...c, className: s("alea-field", t), ...u(n), children: [
|
|
68
|
+
/* @__PURE__ */ a(h, { label: r, isRequired: c.isRequired }),
|
|
69
69
|
/* @__PURE__ */ i("div", { className: "alea-input-wrap alea-date-wrap", "aria-busy": n || void 0, children: [
|
|
70
70
|
/* @__PURE__ */ a(D, {}),
|
|
71
|
-
n && /* @__PURE__ */ a(
|
|
71
|
+
n && /* @__PURE__ */ a(m, {})
|
|
72
72
|
] }),
|
|
73
|
-
/* @__PURE__ */ a(
|
|
73
|
+
/* @__PURE__ */ a(f, { description: l, errorMessage: e })
|
|
74
74
|
] });
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
return /* @__PURE__ */ i(
|
|
79
|
-
/* @__PURE__ */ a(
|
|
80
|
-
/* @__PURE__ */ i(
|
|
76
|
+
function fa({ motion: r, label: l, description: e, errorMessage: n, isLoading: t, className: c, ...d }) {
|
|
77
|
+
const g = C();
|
|
78
|
+
return /* @__PURE__ */ i(G, { ...d, className: s("alea-field", c), ...u(t), children: [
|
|
79
|
+
/* @__PURE__ */ a(h, { label: l, isRequired: d.isRequired }),
|
|
80
|
+
/* @__PURE__ */ i(k, { className: "alea-input-wrap alea-date-wrap", "aria-busy": t || void 0, children: [
|
|
81
81
|
/* @__PURE__ */ a(D, {}),
|
|
82
|
-
t && /* @__PURE__ */ a(
|
|
83
|
-
/* @__PURE__ */ a(
|
|
82
|
+
t && /* @__PURE__ */ a(m, {}),
|
|
83
|
+
/* @__PURE__ */ a(o, { className: "alea-input-clear alea-focus-ring", "aria-label": g.openCalendar, children: /* @__PURE__ */ a(y, { size: 16 }) })
|
|
84
84
|
] }),
|
|
85
|
-
/* @__PURE__ */ a(
|
|
86
|
-
/* @__PURE__ */ a(
|
|
85
|
+
/* @__PURE__ */ a(f, { description: e, errorMessage: n }),
|
|
86
|
+
/* @__PURE__ */ a(F, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ a(w, { className: "alea-cal-dialog", children: /* @__PURE__ */ a(M, {}) }) })
|
|
87
87
|
] });
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
const l = C(), e =
|
|
91
|
-
return /* @__PURE__ */ a("div", { className: "alea-cal-presets", role: "group", "aria-label": l.dateRangePresets, children: r.map((n, t) => /* @__PURE__ */ a(
|
|
89
|
+
function ea({ presets: r }) {
|
|
90
|
+
const l = C(), e = x(O);
|
|
91
|
+
return /* @__PURE__ */ a("div", { className: "alea-cal-presets", role: "group", "aria-label": l.dateRangePresets, children: r.map((n, t) => /* @__PURE__ */ a(L, { size: "sm", variant: "soft", onPress: () => {
|
|
92
92
|
e == null || e.setValue(n.range()), e == null || e.setOpen(!1);
|
|
93
93
|
}, children: n.label }, n.id ?? (typeof n.label == "string" ? n.label : t))) });
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
return /* @__PURE__ */ i(
|
|
98
|
-
/* @__PURE__ */ a(
|
|
99
|
-
/* @__PURE__ */ i(
|
|
100
|
-
/* @__PURE__ */ a(p, { slot: "start", className: "alea-date-input", children: (
|
|
101
|
-
/* @__PURE__ */ a("span", { className: "alea-date-dash", "aria-hidden": "true", children:
|
|
102
|
-
/* @__PURE__ */ a(p, { slot: "end", className: "alea-date-input", children: (
|
|
103
|
-
|
|
104
|
-
/* @__PURE__ */ a(
|
|
95
|
+
function ga({ motion: r, presets: l, separator: e, label: n, description: t, errorMessage: c, isLoading: d, className: g, ...R }) {
|
|
96
|
+
const b = C();
|
|
97
|
+
return /* @__PURE__ */ i(T, { ...R, className: s("alea-field", g), ...u(d), children: [
|
|
98
|
+
/* @__PURE__ */ a(h, { label: n, isRequired: R.isRequired }),
|
|
99
|
+
/* @__PURE__ */ i(k, { className: "alea-input-wrap alea-date-wrap alea-date-range", "aria-busy": d || void 0, children: [
|
|
100
|
+
/* @__PURE__ */ a(p, { slot: "start", className: "alea-date-input", children: (N) => /* @__PURE__ */ a(v, { segment: N, className: "alea-date-segment" }) }),
|
|
101
|
+
/* @__PURE__ */ a("span", { className: "alea-date-dash", "aria-hidden": "true", children: e ?? b.dateRangeTo }),
|
|
102
|
+
/* @__PURE__ */ a(p, { slot: "end", className: "alea-date-input", children: (N) => /* @__PURE__ */ a(v, { segment: N, className: "alea-date-segment" }) }),
|
|
103
|
+
d && /* @__PURE__ */ a(m, {}),
|
|
104
|
+
/* @__PURE__ */ a(o, { className: "alea-input-clear alea-focus-ring", "aria-label": b.openCalendar, children: /* @__PURE__ */ a(y, { size: 16 }) })
|
|
105
105
|
] }),
|
|
106
|
-
/* @__PURE__ */ a(
|
|
107
|
-
/* @__PURE__ */ a(
|
|
108
|
-
l && l.length > 0 && /* @__PURE__ */ a(
|
|
109
|
-
/* @__PURE__ */ a(
|
|
106
|
+
/* @__PURE__ */ a(f, { description: t, errorMessage: c }),
|
|
107
|
+
/* @__PURE__ */ a(F, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ i(w, { className: "alea-cal-dialog", children: [
|
|
108
|
+
l && l.length > 0 && /* @__PURE__ */ a(ea, { presets: l }),
|
|
109
|
+
/* @__PURE__ */ a(aa, {})
|
|
110
110
|
] }) })
|
|
111
111
|
] });
|
|
112
112
|
}
|
|
113
113
|
export {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
M as Calendar,
|
|
115
|
+
ua as DateField,
|
|
116
|
+
fa as DatePicker,
|
|
117
|
+
ga as DateRangePicker,
|
|
118
|
+
aa as RangeCalendar,
|
|
119
|
+
ha as TimeField
|
|
120
120
|
};
|
|
@@ -7,10 +7,12 @@ export interface FormProps extends Omit<RACFormProps, 'onSubmit'> {
|
|
|
7
7
|
gap?: number;
|
|
8
8
|
/** After the server returns field errors, moves focus to the first field marked invalid (inputs, pickers, date fields). Default true. Fields that fail validation before submit already take focus on their own. */
|
|
9
9
|
focusInvalid?: boolean;
|
|
10
|
+
/** Keeps controls from being announced as invalid on arrival (Chrome does that for any field that fails native validation, such as an empty required one). The error still shows and is announced once it is displayed. Default true. */
|
|
11
|
+
quietValidity?: boolean;
|
|
10
12
|
children: ReactNode;
|
|
11
13
|
}
|
|
12
14
|
/** A form that validates on submit, moves focus to the first problem, and shows server errors on their fields. */
|
|
13
|
-
export declare function Form({ onSubmit, gap, focusInvalid, children, className, validationBehavior, style, ...props }: FormProps): import("react").JSX.Element;
|
|
15
|
+
export declare function Form({ onSubmit, gap, focusInvalid, quietValidity, children, className, validationBehavior, style, ...props }: FormProps): import("react").JSX.Element;
|
|
14
16
|
export interface FormActionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
15
17
|
/** The submit button text. Default "Save". */
|
|
16
18
|
submitLabel?: ReactNode;
|
|
@@ -1,66 +1,58 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Form as
|
|
5
|
-
import { cx as
|
|
6
|
-
import { spaceFromPx as
|
|
7
|
-
import { Alert as
|
|
8
|
-
import { Button as
|
|
9
|
-
import { useStrings as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
(t = e.querySelector('[data-invalid] :is(input, button, [tabindex="0"]):not([disabled]):not([type="hidden"])')) == null || t.focus();
|
|
19
|
-
}
|
|
20
|
-
function P({ onSubmit: e, gap: r = 20, focusInvalid: t = !0, children: u, className: s, validationBehavior: n = "native", style: i, ...o }) {
|
|
21
|
-
const [c, m] = v({}), [l, y] = v(!1), h = b(null), d = b(!1);
|
|
22
|
-
return j(() => {
|
|
23
|
-
d.current && (d.current = !1, T(h.current));
|
|
24
|
-
}, [c]), /* @__PURE__ */ a(
|
|
25
|
-
N,
|
|
2
|
+
import { jsx as t, jsxs as N } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as g, useState as E, useRef as F, useEffect as S } from "react";
|
|
4
|
+
import { Form as w } from "react-aria-components";
|
|
5
|
+
import { cx as x } from "../../utils/cx.js";
|
|
6
|
+
import { spaceFromPx as A } from "../../utils/space.js";
|
|
7
|
+
import { Alert as O } from "../feedback/Feedback.js";
|
|
8
|
+
import { Button as B } from "../button/Button.js";
|
|
9
|
+
import { useStrings as b } from "../../i18n/strings.js";
|
|
10
|
+
import { useQuietNativeValidity as D, focusFirstInvalid as R } from "./validity.js";
|
|
11
|
+
function q({ onSubmit: l, gap: e = 20, focusInvalid: o = !0, quietValidity: c = !0, children: s, className: r, validationBehavior: n = "native", style: a, ...i }) {
|
|
12
|
+
const [m, u] = E({}), [h, v] = E(!1), f = F(null), d = F(!1);
|
|
13
|
+
return D(f, c), S(() => {
|
|
14
|
+
d.current && (d.current = !1, R(f.current));
|
|
15
|
+
}, [m]), /* @__PURE__ */ t(
|
|
16
|
+
w,
|
|
26
17
|
{
|
|
27
|
-
...
|
|
18
|
+
...i,
|
|
19
|
+
ref: f,
|
|
28
20
|
validationBehavior: n,
|
|
29
|
-
validationErrors: { ...
|
|
30
|
-
className:
|
|
31
|
-
style: { gap:
|
|
32
|
-
"data-busy":
|
|
33
|
-
"aria-busy":
|
|
34
|
-
onSubmit: async (
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
|
|
21
|
+
validationErrors: { ...m, ...i.validationErrors || {} },
|
|
22
|
+
className: x("alea-form", r),
|
|
23
|
+
style: { gap: A(e), ...a },
|
|
24
|
+
"data-busy": h || void 0,
|
|
25
|
+
"aria-busy": h || void 0,
|
|
26
|
+
onSubmit: async (p) => {
|
|
27
|
+
if (p.preventDefault(), !l) return;
|
|
28
|
+
const j = Object.fromEntries(new FormData(p.currentTarget));
|
|
29
|
+
v(!0);
|
|
38
30
|
try {
|
|
39
|
-
const
|
|
40
|
-
d.current =
|
|
31
|
+
const y = await l(j, p);
|
|
32
|
+
d.current = o && !!y && Object.keys(y).length > 0, u(y || {});
|
|
41
33
|
} finally {
|
|
42
|
-
|
|
34
|
+
v(!1);
|
|
43
35
|
}
|
|
44
36
|
},
|
|
45
|
-
children:
|
|
37
|
+
children: s
|
|
46
38
|
}
|
|
47
39
|
);
|
|
48
40
|
}
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/* @__PURE__ */
|
|
41
|
+
const z = g(function({ submitLabel: e, secondary: o, isLoading: c, align: s = "start", destructive: r, form: n, className: a, ...i }, m) {
|
|
42
|
+
const u = b();
|
|
43
|
+
return e ?? (e = u.save), /* @__PURE__ */ N("div", { ref: m, ...i, className: x("alea-form-actions", a), "data-align": r ? "end" : s, "data-split": r ? !0 : void 0, children: [
|
|
44
|
+
r && /* @__PURE__ */ t("span", { className: "alea-form-actions-start", children: r }),
|
|
45
|
+
o,
|
|
46
|
+
/* @__PURE__ */ t(B, { type: "submit", form: n, isLoading: c, fullWidth: s === "stretch", children: e })
|
|
55
47
|
] });
|
|
56
|
-
}),
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
return
|
|
48
|
+
}), G = g(function({ errors: e, title: o, ...c }, s) {
|
|
49
|
+
const r = b();
|
|
50
|
+
o ?? (o = r.fixToContinue);
|
|
51
|
+
const n = Object.entries(e);
|
|
52
|
+
return n.length ? /* @__PURE__ */ t(O, { ref: s, ...c, tone: "danger", title: o, live: !0, children: /* @__PURE__ */ t("ul", { className: "alea-error-summary", children: n.map(([a, i]) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t("a", { href: `#${a}`, children: i }) }, a)) }) }) : null;
|
|
61
53
|
});
|
|
62
54
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
G as ErrorSummary,
|
|
56
|
+
q as Form,
|
|
57
|
+
z as FormActions
|
|
66
58
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Moves focus to the first invalid control inside `root`: the control itself (aria-invalid) or, failing that, the first
|
|
4
|
+
* focusable thing inside an invalid field. If focus is already on it (Enter pressed inside the field) it is released
|
|
5
|
+
* and taken again, because focus that does not move announces nothing and the reader would never hear the error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function focusFirstInvalid(root: ParentNode | null | undefined): void;
|
|
8
|
+
/**
|
|
9
|
+
* For validating by hand on submit: store your messages, then call `request()` and focus goes to the first invalid
|
|
10
|
+
* control inside the element that has `ref`. Every call counts, even when the errors are the same as last time.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useFirstInvalidFocus<T extends HTMLElement = HTMLDivElement>(): {
|
|
13
|
+
ref: RefObject<T | null>;
|
|
14
|
+
request: () => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Chrome exposes every control that fails native validation as invalid, before anyone touches it: an empty required
|
|
18
|
+
* field is read "invalid entry" on arrival. While no error is on screen the control is marked aria-invalid="false";
|
|
19
|
+
* when the interface shows the error React sets "true" and that wins. Pass the element that contains the controls
|
|
20
|
+
* (a form, a dialog); new controls added later are covered too.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useQuietNativeValidity(ref: RefObject<HTMLElement | null>, enabled?: boolean): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef as l, useState as f, useEffect as d, useCallback as b } from "react";
|
|
3
|
+
const c = 'input:not([type="hidden"]), textarea, select', v = '[aria-invalid="true"]:not([disabled]):not([type="hidden"])', h = '[data-invalid] :is(input, button, [tabindex="0"]):not([disabled]):not([type="hidden"])';
|
|
4
|
+
function p(e) {
|
|
5
|
+
if (!e) return;
|
|
6
|
+
const t = e.querySelector(v) ?? e.querySelector(h);
|
|
7
|
+
t && (document.activeElement === t && t.blur(), t.focus());
|
|
8
|
+
}
|
|
9
|
+
function I() {
|
|
10
|
+
const e = l(null), [t, n] = f(0);
|
|
11
|
+
d(() => {
|
|
12
|
+
t > 0 && p(e.current);
|
|
13
|
+
}, [t]);
|
|
14
|
+
const r = b(() => n((s) => s + 1), []);
|
|
15
|
+
return { ref: e, request: r };
|
|
16
|
+
}
|
|
17
|
+
function m(e, t = !0) {
|
|
18
|
+
d(() => {
|
|
19
|
+
const n = e.current;
|
|
20
|
+
if (!n || !t) return;
|
|
21
|
+
const r = (i) => {
|
|
22
|
+
i.matches(c) && !i.hasAttribute("aria-invalid") && i.setAttribute("aria-invalid", "false");
|
|
23
|
+
}, s = (i) => i.querySelectorAll(c).forEach(r);
|
|
24
|
+
s(n);
|
|
25
|
+
const o = new MutationObserver((i) => {
|
|
26
|
+
for (const u of i)
|
|
27
|
+
u.type === "attributes" ? r(u.target) : u.addedNodes.forEach((a) => {
|
|
28
|
+
a instanceof Element && (r(a), s(a));
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return o.observe(n, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["aria-invalid"] }), () => o.disconnect();
|
|
32
|
+
}, [e, t]);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
p as focusFirstInvalid,
|
|
36
|
+
I as useFirstInvalidFocus,
|
|
37
|
+
m as useQuietNativeValidity
|
|
38
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import { type GridListProps, type GridListItemProps, type Key, type DropIndicatorProps } from 'react-aria-components';
|
|
3
3
|
import { type SurfaceProps } from '../surface/Surface.js';
|
|
4
|
+
import type { RowMotion } from '@alea-design/motion';
|
|
4
5
|
type WithId = {
|
|
5
6
|
id: Key;
|
|
6
7
|
};
|
|
@@ -18,8 +19,8 @@ export interface ListViewProps<T extends object> extends GridListProps<T>, Surfa
|
|
|
18
19
|
onItemsChange?: (items: T[]) => void;
|
|
19
20
|
/** Lists with the same dragGroup accept each other's rows. Items must be plain data (they travel as JSON). */
|
|
20
21
|
dragGroup?: string;
|
|
21
|
-
/** Rows added to `items` rise in (staggered), and rows removed dissolve and give their space back before they leave. Needs items with an id. The removed row is disabled while it leaves. Off by default; reduced motion keeps only the fades. */
|
|
22
|
-
animateRows?:
|
|
22
|
+
/** Rows added to `items` rise in (staggered), and rows removed dissolve and give their space back before they leave. Needs items with an id. The removed row is disabled while it leaves. Off by default; reduced motion keeps only the fades. Pass an object to decide when: `max` rows above which nothing animates, `resetOn` values (search, filter, page) whose change is not news, `enter` and `leave` to animate only one of the two. */
|
|
23
|
+
animateRows?: RowMotion;
|
|
23
24
|
}
|
|
24
25
|
/** A list of rich items people can select, open or act on, with keyboard navigation. Rows can be dragged to reorder, or between lists; cards can sit in a grid. */
|
|
25
26
|
export declare function ListView<T extends object>({ variant, layout, onItemsChange, dragGroup, animateRows, items: itemsIn, surface, radius, className, children: childrenIn, dependencies: depsIn, ...props }: ListViewProps<T>): import("react").JSX.Element;
|
|
@@ -27,11 +27,15 @@ export interface TimelineProps {
|
|
|
27
27
|
reverse?: boolean;
|
|
28
28
|
/** sm (tighter, for side panels) or md (default). */
|
|
29
29
|
size?: 'sm' | 'md';
|
|
30
|
+
/** Where the time sits: above the title (default) or right under it. */
|
|
31
|
+
timePlacement?: 'above' | 'below';
|
|
32
|
+
/** Name of the list for screen readers ("Order history"). */
|
|
33
|
+
'aria-label'?: string;
|
|
30
34
|
/** Extra class names for the root element. */
|
|
31
35
|
className?: string;
|
|
32
36
|
}
|
|
33
37
|
/** Events in order: a changelog, an order's progress, an activity feed. Content on one side, the other, or alternating; reversed; two sizes. */
|
|
34
|
-
export declare function Timeline({ items, pending, mode, reverse, size, className }: TimelineProps): import("react").JSX.Element;
|
|
38
|
+
export declare function Timeline({ items, pending, mode, reverse, size, timePlacement, className, 'aria-label': label }: TimelineProps): import("react").JSX.Element;
|
|
35
39
|
export interface CarouselProps {
|
|
36
40
|
/** The slides. */
|
|
37
41
|
children: ReactNode[];
|