@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
|
@@ -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;
|
|
@@ -164,6 +164,8 @@ export interface BannerProps {
|
|
|
164
164
|
children: ReactNode;
|
|
165
165
|
/** accent (default, gradient), neutral, success, info, warning or danger. */
|
|
166
166
|
tone?: 'accent' | 'neutral' | 'success' | 'info' | 'warning' | 'danger';
|
|
167
|
+
/** md (default) or sm: a compact bar with smaller text and padding, for notes that sit above a page without pushing it down (an environment notice). */
|
|
168
|
+
size?: 'sm' | 'md';
|
|
167
169
|
/** A link or button after the message. */
|
|
168
170
|
action?: ReactNode;
|
|
169
171
|
/** Shows a close button; called when closed. */
|
|
@@ -173,4 +175,4 @@ export interface BannerProps {
|
|
|
173
175
|
className?: string;
|
|
174
176
|
}
|
|
175
177
|
/** A site-wide announcement bar above the header: launches, sales, outages. */
|
|
176
|
-
export declare function Banner({ children, tone, action, onDismiss, className, 'aria-label': label }: BannerProps): import("react").JSX.Element | null;
|
|
178
|
+
export declare function Banner({ children, tone, size, action, onDismiss, className, 'aria-label': label }: BannerProps): import("react").JSX.Element | null;
|
|
@@ -8,14 +8,14 @@ import { formatDecimal as H } from "../../utils/decimal.js";
|
|
|
8
8
|
import { Spinner as L } from "../feedback/Spinner.js";
|
|
9
9
|
import { useStrings as $ } from "../../i18n/strings.js";
|
|
10
10
|
import { inertProps as R } from "../../utils/inert.js";
|
|
11
|
-
const aa = M(function({ target: t = "main", children: l, className: s, ...
|
|
11
|
+
const aa = M(function({ target: t = "main", children: l, className: s, ...i }, r) {
|
|
12
12
|
const o = $();
|
|
13
|
-
return l ?? (l = o.skipToContent), /* @__PURE__ */ a("a", { ref: r, href: `#${t}`, ...
|
|
14
|
-
}), ea = M(function({ children: t, as: l = "span", className: s, ...
|
|
15
|
-
return /* @__PURE__ */ a(l, { ref: r, ...
|
|
13
|
+
return l ?? (l = o.skipToContent), /* @__PURE__ */ a("a", { ref: r, href: `#${t}`, ...i, className: m("alea-skip-link", s), children: l });
|
|
14
|
+
}), ea = M(function({ children: t, as: l = "span", className: s, ...i }, r) {
|
|
15
|
+
return /* @__PURE__ */ a(l, { ref: r, ...i, className: m("alea-visually-hidden", s), children: t });
|
|
16
16
|
});
|
|
17
|
-
function la({ title: e, children: t, isExpanded: l, defaultExpanded: s, onExpandedChange:
|
|
18
|
-
return /* @__PURE__ */ u(A, { isExpanded: l, defaultExpanded: s, onExpandedChange:
|
|
17
|
+
function la({ title: e, children: t, isExpanded: l, defaultExpanded: s, onExpandedChange: i, className: r }) {
|
|
18
|
+
return /* @__PURE__ */ u(A, { isExpanded: l, defaultExpanded: s, onExpandedChange: i, className: m("alea-collapsible", r), children: [
|
|
19
19
|
/* @__PURE__ */ u(I, { slot: "trigger", className: "alea-collapsible-trigger alea-focus-ring", children: [
|
|
20
20
|
/* @__PURE__ */ a(O, { size: 16, "aria-hidden": "true", className: "alea-collapsible-chevron" }),
|
|
21
21
|
e
|
|
@@ -23,32 +23,32 @@ function la({ title: e, children: t, isExpanded: l, defaultExpanded: s, onExpand
|
|
|
23
23
|
/* @__PURE__ */ a(K, { className: "alea-collapsible-panel", children: /* @__PURE__ */ a("div", { className: "alea-collapsible-content", children: t }) })
|
|
24
24
|
] });
|
|
25
25
|
}
|
|
26
|
-
function ta({ value: e, defaultValue: t = "", onSave: l, label: s, placeholder:
|
|
27
|
-
const p = $(), [
|
|
26
|
+
function ta({ value: e, defaultValue: t = "", onSave: l, label: s, placeholder: i = "Empty", multiline: r, className: o }) {
|
|
27
|
+
const p = $(), [f, h] = k(t), n = e ?? f, [c, b] = k(!1), [N, C] = k(n), [v, w] = k(!1), x = D(null), g = D(null);
|
|
28
28
|
z(() => {
|
|
29
29
|
var d, q;
|
|
30
|
-
|
|
31
|
-
}, [
|
|
30
|
+
c && ((d = x.current) == null || d.focus(), (q = x.current) == null || q.select());
|
|
31
|
+
}, [c]);
|
|
32
32
|
const y = () => {
|
|
33
33
|
if ((l == null ? void 0 : l(N)) === !1) {
|
|
34
34
|
w(!0);
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
e === void 0 &&
|
|
37
|
+
e === void 0 && h(N), b(!1), w(!1), requestAnimationFrame(() => {
|
|
38
38
|
var d;
|
|
39
|
-
return (d =
|
|
39
|
+
return (d = g.current) == null ? void 0 : d.focus();
|
|
40
40
|
});
|
|
41
41
|
}, S = () => {
|
|
42
|
-
|
|
42
|
+
b(!1), w(!1), requestAnimationFrame(() => {
|
|
43
43
|
var d;
|
|
44
|
-
return (d =
|
|
44
|
+
return (d = g.current) == null ? void 0 : d.focus();
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
-
if (!
|
|
48
|
-
return /* @__PURE__ */ u("button", { ref:
|
|
49
|
-
C(n),
|
|
47
|
+
if (!c)
|
|
48
|
+
return /* @__PURE__ */ u("button", { ref: g, type: "button", className: m("alea-editable alea-focus-ring", o), "data-empty": !n || void 0, "aria-label": `${s}: ${n || i}. Edit`, onClick: () => {
|
|
49
|
+
C(n), b(!0);
|
|
50
50
|
}, children: [
|
|
51
|
-
/* @__PURE__ */ a("span", { className: "alea-editable-text", children: n ||
|
|
51
|
+
/* @__PURE__ */ a("span", { className: "alea-editable-text", children: n || i }),
|
|
52
52
|
/* @__PURE__ */ a(F, { size: 14, "aria-hidden": "true", className: "alea-editable-icon" })
|
|
53
53
|
] });
|
|
54
54
|
const E = r ? "textarea" : "input";
|
|
@@ -78,21 +78,21 @@ function na({ value: e, format: t, locale: l }) {
|
|
|
78
78
|
return /* @__PURE__ */ a(T, { children: H(e, l, t) });
|
|
79
79
|
}
|
|
80
80
|
const V = (e) => String(e).padStart(2, "0");
|
|
81
|
-
function sa({ to: e, label: t, onEnd: l, showDays: s, className:
|
|
82
|
-
const r = $(), o = typeof e == "number" ? e : e.getTime(), [p,
|
|
81
|
+
function sa({ to: e, label: t, onEnd: l, showDays: s, className: i }) {
|
|
82
|
+
const r = $(), o = typeof e == "number" ? e : e.getTime(), [p, f] = k(() => Date.now()), h = D(!1);
|
|
83
83
|
z(() => {
|
|
84
|
-
const
|
|
85
|
-
return () => clearInterval(
|
|
84
|
+
const g = setInterval(() => f(Date.now()), 1e3);
|
|
85
|
+
return () => clearInterval(g);
|
|
86
86
|
}, []);
|
|
87
87
|
const n = Math.max(0, o - p);
|
|
88
88
|
z(() => {
|
|
89
|
-
n === 0 && !
|
|
89
|
+
n === 0 && !h.current && (h.current = !0, l == null || l());
|
|
90
90
|
}, [n, l]);
|
|
91
|
-
const
|
|
92
|
-
return /* @__PURE__ */ u("div", { className: m("alea-stat alea-countdown",
|
|
91
|
+
const c = Math.floor(n / 864e5), b = Math.floor(n / 36e5) % 24, N = Math.floor(n / 6e4) % 60, C = Math.floor(n / 1e3) % 60, v = s ?? c > 0, w = [...v ? [[c, "d"]] : [], [v ? b : b + c * 24, "h"], [N, "m"], [C, "s"]], x = `${v ? `${c} days, ` : ""}${v ? b : b + c * 24} hours, ${N} minutes`;
|
|
92
|
+
return /* @__PURE__ */ u("div", { className: m("alea-stat alea-countdown", i), children: [
|
|
93
93
|
/* @__PURE__ */ a("span", { className: "alea-stat-label", children: t }),
|
|
94
|
-
/* @__PURE__ */ a("span", { className: "alea-stat-value alea-countdown-value", "aria-hidden": "true", children: w.map(([
|
|
95
|
-
/* @__PURE__ */ a("b", { children: y === "d" ?
|
|
94
|
+
/* @__PURE__ */ a("span", { className: "alea-stat-value alea-countdown-value", "aria-hidden": "true", children: w.map(([g, y]) => /* @__PURE__ */ u("span", { children: [
|
|
95
|
+
/* @__PURE__ */ a("b", { children: y === "d" ? g : V(g) }),
|
|
96
96
|
/* @__PURE__ */ a("small", { children: y })
|
|
97
97
|
] }, y)) }),
|
|
98
98
|
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", "aria-live": "polite", children: n === 0 ? r.ended : x })
|
|
@@ -104,35 +104,35 @@ function ra({ tone: e = "neutral", children: t, pulse: l, className: s }) {
|
|
|
104
104
|
t
|
|
105
105
|
] });
|
|
106
106
|
}
|
|
107
|
-
function ia({ color: e, label: t, size: l = 28, shape: s = "circle", showValue:
|
|
107
|
+
function ia({ color: e, label: t, size: l = 28, shape: s = "circle", showValue: i, className: r, style: o }) {
|
|
108
108
|
const p = /* @__PURE__ */ a("span", { className: "alea-swatch", "data-shape": s, role: "img", "aria-label": t, style: { width: l, height: l, "--alea-swatch": e, ...o } });
|
|
109
|
-
return
|
|
109
|
+
return i ? /* @__PURE__ */ u("span", { className: m("alea-swatch-wrap", r), "data-labeled": !0, children: [
|
|
110
110
|
p,
|
|
111
111
|
/* @__PURE__ */ a("span", { className: "alea-swatch-name", "aria-hidden": "true", children: t }),
|
|
112
112
|
/* @__PURE__ */ a("code", { className: "alea-swatch-value", children: e })
|
|
113
113
|
] }) : /* @__PURE__ */ a("span", { className: m("alea-swatch-wrap", r), children: p });
|
|
114
114
|
}
|
|
115
|
-
function ca({ isLoading: e, children: t, label: l, blur: s = !0, className:
|
|
115
|
+
function ca({ isLoading: e, children: t, label: l, blur: s = !0, className: i }) {
|
|
116
116
|
const r = $();
|
|
117
|
-
return l ?? (l = r.loading), /* @__PURE__ */ u("div", { className: m("alea-loading",
|
|
117
|
+
return l ?? (l = r.loading), /* @__PURE__ */ u("div", { className: m("alea-loading", i), "aria-busy": e || void 0, children: [
|
|
118
118
|
/* @__PURE__ */ a("div", { className: "alea-loading-content", ...R(e), children: t }),
|
|
119
119
|
e && /* @__PURE__ */ a("div", { className: "alea-loading-overlay", "data-blur": s || void 0, children: /* @__PURE__ */ a(L, { size: "md", "aria-label": l }) })
|
|
120
120
|
] });
|
|
121
121
|
}
|
|
122
|
-
function oa({ segments: e, total: t, label: l, valueFormat: s = (o) => String(o), showLegend:
|
|
123
|
-
const o = j(), p = t ?? e.reduce((n,
|
|
122
|
+
function oa({ segments: e, total: t, label: l, valueFormat: s = (o) => String(o), showLegend: i = !0, className: r }) {
|
|
123
|
+
const o = j(), p = t ?? e.reduce((n, c) => n + c.value, 0), f = (n, c) => n.color || `var(--alea-chart-${c % 8 + 1})`, h = e.reduce((n, c) => n + c.value, 0);
|
|
124
124
|
return /* @__PURE__ */ u("div", { className: m("alea-progress-seg", r), children: [
|
|
125
125
|
/* @__PURE__ */ u("div", { className: "alea-progress-seg-head", children: [
|
|
126
126
|
/* @__PURE__ */ a("span", { id: o, className: "alea-label", children: l }),
|
|
127
127
|
/* @__PURE__ */ u("span", { className: "alea-progress-seg-total", children: [
|
|
128
|
-
s(
|
|
128
|
+
s(h),
|
|
129
129
|
" of ",
|
|
130
130
|
s(p)
|
|
131
131
|
] })
|
|
132
132
|
] }),
|
|
133
|
-
/* @__PURE__ */ a("div", { className: "alea-progress-seg-bar", role: "meter", "aria-labelledby": o, "aria-valuemin": 0, "aria-valuemax": p, "aria-valuenow":
|
|
134
|
-
|
|
135
|
-
/* @__PURE__ */ a("span", { style: { background:
|
|
133
|
+
/* @__PURE__ */ a("div", { className: "alea-progress-seg-bar", role: "meter", "aria-labelledby": o, "aria-valuemin": 0, "aria-valuemax": p, "aria-valuenow": h, "aria-valuetext": e.map((n) => `${n.label} ${s(n.value)}`).join(", "), children: e.map((n, c) => /* @__PURE__ */ a("span", { className: "alea-progress-seg-part", style: { width: `${n.value / (p || 1) * 100}%`, background: f(n, c), animationDelay: `${c * 60}ms` } }, n.label)) }),
|
|
134
|
+
i && /* @__PURE__ */ a("ul", { className: "alea-progress-seg-legend", "aria-hidden": "true", children: e.map((n, c) => /* @__PURE__ */ u("li", { children: [
|
|
135
|
+
/* @__PURE__ */ a("span", { style: { background: f(n, c) } }),
|
|
136
136
|
n.label,
|
|
137
137
|
/* @__PURE__ */ a("b", { children: s(n.value) })
|
|
138
138
|
] }, n.label)) })
|
|
@@ -153,15 +153,15 @@ function ua({ items: e, marker: t = "bullet", spacing: l = "md", className: s })
|
|
|
153
153
|
function ma({ children: e, size: t = "base", className: l }) {
|
|
154
154
|
return /* @__PURE__ */ a("div", { className: m("alea-prose alea-markdown", l), "data-size": t, children: e });
|
|
155
155
|
}
|
|
156
|
-
function pa({ children: e, tone: t = "accent",
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const [
|
|
160
|
-
return
|
|
161
|
-
/* @__PURE__ */ a("
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
h(!1),
|
|
156
|
+
function pa({ children: e, tone: t = "accent", size: l = "md", action: s, onDismiss: i, className: r, "aria-label": o }) {
|
|
157
|
+
const p = $();
|
|
158
|
+
o ?? (o = p.announcement);
|
|
159
|
+
const [f, h] = k(!0);
|
|
160
|
+
return f ? /* @__PURE__ */ u("div", { className: m("alea-banner", r), "data-tone": t, "data-size": l === "sm" ? l : void 0, "data-dismissible": i ? !0 : void 0, role: "region", "aria-label": o, children: [
|
|
161
|
+
/* @__PURE__ */ a("div", { className: "alea-banner-text", children: e }),
|
|
162
|
+
s && /* @__PURE__ */ a("span", { className: "alea-banner-action", children: s }),
|
|
163
|
+
i && /* @__PURE__ */ a("button", { type: "button", className: "alea-banner-close alea-focus-ring", "aria-label": p.dismissAnnouncement, onClick: () => {
|
|
164
|
+
h(!1), i();
|
|
165
165
|
}, children: /* @__PURE__ */ a(P, { size: 16 }) })
|
|
166
166
|
] }) : null;
|
|
167
167
|
}
|