@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.
Files changed (51) hide show
  1. package/dist/components/button/Button.d.ts +3 -1
  2. package/dist/components/button/Button.js +58 -57
  3. package/dist/components/button/Groups.js +41 -41
  4. package/dist/components/command/CommandPalette.js +63 -61
  5. package/dist/components/data/Data.d.ts +10 -6
  6. package/dist/components/data/Data.js +53 -53
  7. package/dist/components/date/Date.d.ts +3 -1
  8. package/dist/components/date/Date.js +74 -74
  9. package/dist/components/form/Form.d.ts +3 -1
  10. package/dist/components/form/Form.js +44 -52
  11. package/dist/components/form/validity.d.ts +22 -0
  12. package/dist/components/form/validity.js +38 -0
  13. package/dist/components/list/List.d.ts +3 -2
  14. package/dist/components/media/Media.d.ts +5 -1
  15. package/dist/components/media/Media.js +113 -111
  16. package/dist/components/navigation/Navigation.d.ts +11 -7
  17. package/dist/components/navigation/Navigation.js +97 -97
  18. package/dist/components/navigation/Navigation2.d.ts +4 -2
  19. package/dist/components/navigation/Navigation2.js +219 -211
  20. package/dist/components/overlay/Overlay.d.ts +4 -0
  21. package/dist/components/overlay/Overlay.js +52 -52
  22. package/dist/components/page/PageParts.d.ts +8 -2
  23. package/dist/components/page/PageParts.js +95 -87
  24. package/dist/components/shell/AppShell.d.ts +3 -1
  25. package/dist/components/shell/AppShell.js +33 -32
  26. package/dist/components/table/Table.d.ts +6 -3
  27. package/dist/components/table/Table.js +45 -45
  28. package/dist/components/theme/Theme.d.ts +5 -1
  29. package/dist/components/theme/Theme.js +63 -63
  30. package/dist/css/base.css +1 -1
  31. package/dist/css/button.css +1 -1
  32. package/dist/css/data.css +1 -1
  33. package/dist/css/date.css +1 -1
  34. package/dist/css/feedback.css +1 -1
  35. package/dist/css/groups.json +11 -11
  36. package/dist/css/more.css +1 -1
  37. package/dist/css/navigation.css +1 -1
  38. package/dist/css/page.css +1 -1
  39. package/dist/css/shell.css +1 -1
  40. package/dist/css/table.css +1 -1
  41. package/dist/css/typography.css +1 -1
  42. package/dist/i18n/strings.d.ts +4 -1
  43. package/dist/i18n/strings.js +8 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +279 -275
  46. package/dist/styles.css +1 -1
  47. package/dist/utils/animateRows.d.ts +3 -2
  48. package/dist/utils/animateRows.js +15 -15
  49. package/dist/utils/measure.d.ts +12 -0
  50. package/dist/utils/measure.js +20 -0
  51. package/package.json +3 -3
@@ -1,85 +1,85 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as r, Fragment as L } from "react/jsx-runtime";
3
- import { createElement as U, useState as G, useRef as z, useEffect as O } from "react";
4
- import { Inbox as D, ServerCrash as X, Lock as _, SearchX as B, CircleAlert as H, CircleCheck as J, TrendingUp as K, TrendingDown as P } from "lucide-react";
5
- import { cx as N } from "../../utils/cx.js";
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: d = "stacked", bordered: l, size: n, title: o, extra: s, labelWidth: m, className: h, style: p, ...u }) {
9
- const i = /* @__PURE__ */ e("dl", { className: "alea-descriptions", "data-columns": a, "data-layout": d, "data-bordered": l || void 0, "data-size": n, style: m ? { "--alea-desc-label": m } : void 0, children: c.map((t, v) => /* @__PURE__ */ r("div", { className: "alea-desc-item", "data-wide": t.wide || void 0, "data-span": t.span && t.span > 1 ? t.span : void 0, children: [
10
- /* @__PURE__ */ e("dt", { children: t.label }),
11
- /* @__PURE__ */ e("dd", { children: t.value })
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 !o && !s ? /* @__PURE__ */ e("div", { ...u, style: p, className: N("alea-descriptions-wrap", h), children: i }) : /* @__PURE__ */ r("section", { ...u, style: p, className: N("alea-descriptions-wrap", h), children: [
14
- /* @__PURE__ */ r("header", { className: "alea-descriptions-head", children: [
15
- o && /* @__PURE__ */ e("h3", { className: "alea-descriptions-title", children: o }),
16
- s && /* @__PURE__ */ e("div", { className: "alea-descriptions-extra", children: s })
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
- i
18
+ l
19
19
  ] });
20
20
  }
21
- function ce({ label: c, value: a, isDecimal: d, formatOptions: l, delta: n, higherIsBetter: o = !0, animate: s, prefix: m, suffix: h, className: p, ...u }) {
22
- var C;
23
- const i = !!d && Q(a), t = typeof a == "string" && !i, v = V(), f = t ? 0 : i ? Number(a) : a, E = i ? ((C = a.trim().split(".")[1]) == null ? void 0 : C.length) ?? 0 : 0, [w, I] = G(s && !t ? 0 : f), x = z(w), S = z(0);
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 (t) return;
26
- const y = (g) => {
27
- x.current = g, I(g);
25
+ if (d) return;
26
+ const g = (S) => {
27
+ F.current = S, I(S);
28
28
  };
29
- if (!s || v || typeof window > "u") {
30
- y(f);
29
+ if (!r || y || typeof window > "u") {
30
+ g(l);
31
31
  return;
32
32
  }
33
- const R = x.current, j = performance.now(), q = 900, k = (g) => {
34
- const b = Math.min(1, (g - j) / q);
35
- y(b < 1 ? R + (f - R) * (1 - Math.pow(1 - b, 3)) : f), b < 1 && (S.current = requestAnimationFrame(k));
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 S.current = requestAnimationFrame(k), () => cancelAnimationFrame(S.current);
38
- }, [f, s, v, t]);
39
- const M = new Intl.NumberFormat(void 0, l), F = (y) => M.format(y), T = t || w === f || !s ? a : i ? w.toFixed(E) : Math.round(w * 100) / 100, A = n === void 0 ? null : n >= 0 === o;
40
- return /* @__PURE__ */ r("div", { ...u, className: N("alea-stat", p), children: [
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: t ? /* @__PURE__ */ r("span", { children: [
42
+ /* @__PURE__ */ e("div", { className: "alea-stat-value", children: d ? /* @__PURE__ */ s("span", { children: [
43
43
  m,
44
- s ? /* @__PURE__ */ e(Y, { children: String(a) }) : a,
44
+ r ? /* @__PURE__ */ e(Y, { children: String(a) }) : a,
45
45
  h
46
- ] }) : /* @__PURE__ */ r(L, { children: [
47
- /* @__PURE__ */ r("span", { "aria-hidden": "true", children: [
46
+ ] }) : /* @__PURE__ */ s(L, { children: [
47
+ /* @__PURE__ */ s("span", { "aria-hidden": "true", children: [
48
48
  m,
49
- F(T),
49
+ A(T),
50
50
  h
51
51
  ] }),
52
- /* @__PURE__ */ e("span", { className: "alea-visually-hidden", children: F(a) })
52
+ /* @__PURE__ */ e("span", { className: "alea-visually-hidden", children: A(a) })
53
53
  ] }) }),
54
- n !== void 0 && /* @__PURE__ */ r("div", { className: "alea-stat-delta", "data-good": A ? !0 : void 0, "data-bad": A === !1 ? !0 : void 0, children: [
55
- n >= 0 ? /* @__PURE__ */ e(K, { size: 14, "aria-hidden": "true" }) : /* @__PURE__ */ e(P, { size: 14, "aria-hidden": "true" }),
56
- /* @__PURE__ */ r("span", { children: [
57
- n >= 0 ? "+" : "",
58
- new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 }).format(n)
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__ */ r("span", { className: "alea-visually-hidden", children: [
61
- n >= 0 ? "up" : "down",
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: d, illustration: l, action: n, secondaryAction: o, footer: s, size: m, variant: h, headingAs: p = "h3", className: u, ...i }) {
68
- return /* @__PURE__ */ r("div", { ...i, className: N("alea-empty", u), "data-size": m, "data-variant": h, children: [
69
- /* @__PURE__ */ e("span", { className: l ? "alea-empty-art" : "alea-empty-icon", "aria-hidden": "true", children: d ?? /* @__PURE__ */ e(D, {}) }),
70
- U(p, { className: "alea-empty-title" }, c),
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
- (n || o) && /* @__PURE__ */ r("div", { className: "alea-empty-action", children: [
73
- n,
74
- o
72
+ (t || p) && /* @__PURE__ */ s("div", { className: "alea-empty-action", children: [
73
+ t,
74
+ p
75
75
  ] }),
76
- s && /* @__PURE__ */ e("p", { className: "alea-empty-footer", children: s })
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: D };
80
- function de({ status: c, className: a, ...d }) {
81
- const l = $[c];
82
- return /* @__PURE__ */ e(Z, { ...d, headingAs: d.headingAs ?? "h2", icon: /* @__PURE__ */ e(l, {}), className: N("alea-result", a), "data-status": c });
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 S } from "react/jsx-runtime";
3
- import { useContext as $ } from "react";
4
- import { Calendar as x, DateField as z, DatePicker as B, Group as b, Button as m, Dialog as P, DateRangePicker as G, DateInput as p, DateSegment as v, RangeCalendar as H, TimeField as T, CalendarMonthPicker as j, CalendarYearPicker as A, Heading as E, DateRangePickerStateContext as I, CalendarGrid as O, CalendarGridHeader as V, CalendarHeaderCell as Y, CalendarGridBody as _, CalendarCell as J } from "react-aria-components";
5
- import { CalendarDays as k, ChevronLeft as K, ChevronRight as Q } from "lucide-react";
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 U, Description as W, FieldError as X } from "../field/Field.js";
8
- import { Popover as w } from "../overlay/Overlay.js";
9
- import { Button as Z } from "../button/Button.js";
10
- import { FieldSpinner as u, loadingAttrs as h } from "../field/FieldLoading.js";
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 y({ pickers: r }) {
12
+ function q({ pickers: r }) {
13
13
  return /* @__PURE__ */ i("header", { className: "alea-cal-head", children: [
14
- /* @__PURE__ */ a(m, { slot: "previous", className: "alea-cal-nav alea-focus-ring", children: /* @__PURE__ */ a(K, { size: 16 }) }),
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(j, { children: (l) => /* @__PURE__ */ a("select", { className: "alea-cal-select alea-focus-ring", "aria-label": l["aria-label"], value: String(l.value), onChange: (e) => l.onChange(Number(e.target.value)), children: l.items.map((e) => /* @__PURE__ */ a("option", { value: e.id, children: e.formatted }, e.id)) }) }),
17
- /* @__PURE__ */ a(A, { children: (l) => /* @__PURE__ */ a("select", { className: "alea-cal-select alea-focus-ring", "aria-label": l["aria-label"], value: String(l.value), onChange: (e) => l.onChange(Number(e.target.value)), children: l.items.map((e) => /* @__PURE__ */ a("option", { value: e.id, children: e.formatted }, e.id)) }) })
18
- ] }) : /* @__PURE__ */ a(E, { className: "alea-cal-title" }),
19
- /* @__PURE__ */ a(m, { slot: "next", className: "alea-cal-nav alea-focus-ring", children: /* @__PURE__ */ a(Q, { size: 16 }) })
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 R({ offset: r = 0 }) {
23
- return /* @__PURE__ */ i(O, { className: "alea-cal-grid", weekdayStyle: "short", offset: r ? { months: r } : void 0, children: [
24
- /* @__PURE__ */ a(V, { children: (l) => /* @__PURE__ */ a(Y, { className: "alea-cal-weekday", children: l }) }),
25
- /* @__PURE__ */ a(_, { children: (l) => /* @__PURE__ */ a(J, { date: l, className: "alea-cal-cell alea-focus-ring" }) })
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 F = ({ count: r }) => r > 1 ? /* @__PURE__ */ a("div", { className: "alea-cal-months", children: Array.from({ length: r }, (l, e) => /* @__PURE__ */ a(R, { offset: e }, e)) }) : /* @__PURE__ */ a(R, {});
29
- function L({ className: r, pickers: l, visibleMonths: e = 1, ...n }) {
30
- return /* @__PURE__ */ i(x, { ...n, visibleDuration: e > 1 ? { months: e } : n.visibleDuration, className: s("alea-calendar", r), "data-months": e > 1 ? e : void 0, children: [
31
- /* @__PURE__ */ a(y, { pickers: l }),
32
- /* @__PURE__ */ a(F, { count: e })
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 M({ className: r, pickers: l, visibleMonths: e = 1, ...n }) {
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(y, { pickers: l }),
38
- /* @__PURE__ */ a(F, { count: e })
37
+ /* @__PURE__ */ a(q, { pickers: l }),
38
+ /* @__PURE__ */ a(S, { count: e })
39
39
  ] });
40
40
  }
41
- function f({ label: r, isRequired: l }) {
42
- return r ? /* @__PURE__ */ i(U, { children: [
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 N({ description: r, errorMessage: l }) {
48
- return /* @__PURE__ */ i(S, { children: [
49
- r && /* @__PURE__ */ a(W, { children: r }),
50
- /* @__PURE__ */ a(X, { children: l })
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 ma({ label: r, description: l, errorMessage: e, isLoading: n, className: t, ...c }) {
57
- return /* @__PURE__ */ i(z, { ...c, className: s("alea-field", t), ...h(n), children: [
58
- /* @__PURE__ */ a(f, { label: r, isRequired: c.isRequired }),
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(u, {})
61
+ n && /* @__PURE__ */ a(m, {})
62
62
  ] }),
63
- /* @__PURE__ */ a(N, { description: l, errorMessage: e })
63
+ /* @__PURE__ */ a(f, { description: l, errorMessage: e })
64
64
  ] });
65
65
  }
66
- function ua({ label: r, description: l, errorMessage: e, isLoading: n, className: t, ...c }) {
67
- return /* @__PURE__ */ i(T, { ...c, className: s("alea-field", t), ...h(n), children: [
68
- /* @__PURE__ */ a(f, { label: r, isRequired: c.isRequired }),
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(u, {})
71
+ n && /* @__PURE__ */ a(m, {})
72
72
  ] }),
73
- /* @__PURE__ */ a(N, { description: l, errorMessage: e })
73
+ /* @__PURE__ */ a(f, { description: l, errorMessage: e })
74
74
  ] });
75
75
  }
76
- function ha({ motion: r, label: l, description: e, errorMessage: n, isLoading: t, className: c, ...d }) {
77
- const o = C();
78
- return /* @__PURE__ */ i(B, { ...d, className: s("alea-field", c), ...h(t), children: [
79
- /* @__PURE__ */ a(f, { label: l, isRequired: d.isRequired }),
80
- /* @__PURE__ */ i(b, { className: "alea-input-wrap alea-date-wrap", "aria-busy": t || void 0, children: [
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(u, {}),
83
- /* @__PURE__ */ a(m, { className: "alea-input-clear alea-focus-ring", "aria-label": o.openCalendar, children: /* @__PURE__ */ a(k, { size: 16 }) })
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(N, { description: e, errorMessage: n }),
86
- /* @__PURE__ */ a(w, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ a(P, { className: "alea-cal-dialog", children: /* @__PURE__ */ a(L, {}) }) })
85
+ /* @__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 aa({ presets: r }) {
90
- const l = C(), e = $(I);
91
- return /* @__PURE__ */ a("div", { className: "alea-cal-presets", role: "group", "aria-label": l.dateRangePresets, children: r.map((n, t) => /* @__PURE__ */ a(Z, { size: "sm", variant: "soft", onPress: () => {
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 fa({ motion: r, presets: l, label: e, description: n, errorMessage: t, isLoading: c, className: d, ...o }) {
96
- const q = C();
97
- return /* @__PURE__ */ i(G, { ...o, className: s("alea-field", d), ...h(c), children: [
98
- /* @__PURE__ */ a(f, { label: e, isRequired: o.isRequired }),
99
- /* @__PURE__ */ i(b, { className: "alea-input-wrap alea-date-wrap", "aria-busy": c || void 0, children: [
100
- /* @__PURE__ */ a(p, { slot: "start", className: "alea-date-input", children: (g) => /* @__PURE__ */ a(v, { segment: g, className: "alea-date-segment" }) }),
101
- /* @__PURE__ */ a("span", { className: "alea-date-dash", "aria-hidden": "true", children: "to" }),
102
- /* @__PURE__ */ a(p, { slot: "end", className: "alea-date-input", children: (g) => /* @__PURE__ */ a(v, { segment: g, className: "alea-date-segment" }) }),
103
- c && /* @__PURE__ */ a(u, {}),
104
- /* @__PURE__ */ a(m, { className: "alea-input-clear alea-focus-ring", "aria-label": q.openCalendar, children: /* @__PURE__ */ a(k, { size: 16 }) })
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(N, { description: n, errorMessage: t }),
107
- /* @__PURE__ */ a(w, { className: "alea-popover alea-cal-popover", placement: "bottom start", motion: r, children: /* @__PURE__ */ i(P, { className: "alea-cal-dialog", children: [
108
- l && l.length > 0 && /* @__PURE__ */ a(aa, { presets: l }),
109
- /* @__PURE__ */ a(M, {})
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
- L as Calendar,
115
- ma as DateField,
116
- ha as DatePicker,
117
- fa as DateRangePicker,
118
- M as RangeCalendar,
119
- ua as TimeField
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 a, jsxs as S } from "react/jsx-runtime";
3
- import { forwardRef as E, useState as v, useRef as b, useEffect as j } from "react";
4
- import { Form as N } from "react-aria-components";
5
- import { cx as F } from "../../utils/cx.js";
6
- import { spaceFromPx as w } from "../../utils/space.js";
7
- import { Alert as A } from "../feedback/Feedback.js";
8
- import { Button as O } from "../button/Button.js";
9
- import { useStrings as g } from "../../i18n/strings.js";
10
- function T(e) {
11
- var t;
12
- if (!e) return;
13
- const r = e.querySelector('[aria-invalid="true"]:not([disabled]):not([type="hidden"])');
14
- if (r) {
15
- r.focus();
16
- return;
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
- ...o,
18
+ ...i,
19
+ ref: f,
28
20
  validationBehavior: n,
29
- validationErrors: { ...c, ...o.validationErrors || {} },
30
- className: F("alea-form", s),
31
- style: { gap: w(r), ...i },
32
- "data-busy": l || void 0,
33
- "aria-busy": l || void 0,
34
- onSubmit: async (f) => {
35
- if (f.preventDefault(), !e) return;
36
- const x = Object.fromEntries(new FormData(f.currentTarget));
37
- y(!0), h.current = f.currentTarget;
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 p = await e(x, f);
40
- d.current = t && !!p && Object.keys(p).length > 0, m(p || {});
31
+ const y = await l(j, p);
32
+ d.current = o && !!y && Object.keys(y).length > 0, u(y || {});
41
33
  } finally {
42
- y(!1);
34
+ v(!1);
43
35
  }
44
36
  },
45
- children: u
37
+ children: s
46
38
  }
47
39
  );
48
40
  }
49
- const W = E(function({ submitLabel: r, secondary: t, isLoading: u, align: s = "start", destructive: n, form: i, className: o, ...c }, m) {
50
- const l = g();
51
- return r ?? (r = l.save), /* @__PURE__ */ S("div", { ref: m, ...c, className: F("alea-form-actions", o), "data-align": n ? "end" : s, "data-split": n ? !0 : void 0, children: [
52
- n && /* @__PURE__ */ a("span", { className: "alea-form-actions-start", children: n }),
53
- t,
54
- /* @__PURE__ */ a(O, { type: "submit", form: i, isLoading: u, fullWidth: s === "stretch", children: r })
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
- }), z = E(function({ errors: r, title: t, ...u }, s) {
57
- const n = g();
58
- t ?? (t = n.fixToContinue);
59
- const i = Object.entries(r);
60
- return i.length ? /* @__PURE__ */ a(A, { ref: s, ...u, tone: "danger", title: t, live: !0, children: /* @__PURE__ */ a("ul", { className: "alea-error-summary", children: i.map(([o, c]) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a("a", { href: `#${o}`, children: c }) }, o)) }) }) : null;
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
- z as ErrorSummary,
64
- P as Form,
65
- W as FormActions
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?: boolean;
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[];