@alea-design/ui 0.6.1 → 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/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/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 +3 -1
- package/dist/components/page/PageParts.js +86 -86
- 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 +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/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;
|
|
@@ -77,14 +77,14 @@ export interface StepsProps {
|
|
|
77
77
|
'aria-label'?: string;
|
|
78
78
|
/** Extra class names for the root element. */
|
|
79
79
|
className?: string;
|
|
80
|
-
/** Horizontal steps turn vertical on phones (below 640 px). Default true. Use 'scroll' to keep them horizontal on phones: the row scrolls sideways (focusable for the keyboard) and opens with the current step in view. */
|
|
81
|
-
responsive?: boolean | 'scroll';
|
|
80
|
+
/** Horizontal steps turn vertical on phones (below 640 px). Default true. Use 'scroll' to keep them horizontal on phones: the row scrolls sideways (focusable for the keyboard) and opens with the current step in view. Use 'wrap' for long lists (eight or ten stages): the steps share the width in equal columns and wrap onto more lines when they do not fit, each with its own progress segment, so every step stays in view at any width and text size. */
|
|
81
|
+
responsive?: boolean | 'scroll' | 'wrap';
|
|
82
82
|
/** Writes each step's status in words under its title (Done, In progress, Pending, Skipped, Has an error, Needs attention), so the color and icon are never the only signal. */
|
|
83
83
|
showStatus?: boolean;
|
|
84
84
|
/** Your own words for this list's states, for the visible status and the hidden one read by screen readers (for example `{ done: 'Completed', current: 'Current stage', cancelled: 'Cancelled here' }`). A state you leave out keeps its default. */
|
|
85
85
|
stateLabels?: Partial<Record<StepStatus, string>>;
|
|
86
|
-
/** sm (24 px markers)
|
|
87
|
-
size?: 'sm' | 'md';
|
|
86
|
+
/** sm (24 px markers), md (28 px, default) or lg (40 px, for a public page where the steps are the focus). */
|
|
87
|
+
size?: 'sm' | 'md' | 'lg';
|
|
88
88
|
/** numbers (default), dots (small markers, for compact flows) or icons (each step's icon). */
|
|
89
89
|
variant?: 'numbers' | 'dots' | 'icons';
|
|
90
90
|
/** Horizontal only: the text beside the marker (end, default) or below it (centered). */
|