@alea-design/ui 0.7.1 → 0.8.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 (44) hide show
  1. package/dist/components/button/Button.d.ts +13 -2
  2. package/dist/components/button/Button.js +126 -104
  3. package/dist/components/celebrate/Celebrate.d.ts +31 -0
  4. package/dist/components/celebrate/Celebrate.js +50 -0
  5. package/dist/components/display/Display.d.ts +7 -2
  6. package/dist/components/display/Display.js +64 -63
  7. package/dist/components/feedback/Feedback.js +23 -23
  8. package/dist/components/field/Field.d.ts +15 -2
  9. package/dist/components/field/Field.js +165 -134
  10. package/dist/components/more/More.d.ts +3 -1
  11. package/dist/components/more/More.js +53 -53
  12. package/dist/components/notification/NotificationCenter.js +15 -15
  13. package/dist/components/picker/Picker.d.ts +5 -1
  14. package/dist/components/picker/Picker.js +212 -209
  15. package/dist/components/print/PrintSheet.d.ts +18 -0
  16. package/dist/components/print/PrintSheet.js +14 -0
  17. package/dist/components/shell/AccountFooter.d.ts +31 -0
  18. package/dist/components/shell/AccountFooter.js +43 -0
  19. package/dist/components/shell/AppShell.js +18 -18
  20. package/dist/components/shell/AppSidebar.js +31 -31
  21. package/dist/components/shell/sidebar-context.d.ts +5 -0
  22. package/dist/components/shell/sidebar-context.js +6 -0
  23. package/dist/css/base.css +1 -1
  24. package/dist/css/button.css +1 -1
  25. package/dist/css/celebrate.css +1 -0
  26. package/dist/css/choice.css +1 -1
  27. package/dist/css/data.css +1 -1
  28. package/dist/css/display.css +1 -1
  29. package/dist/css/feedback.css +1 -1
  30. package/dist/css/field.css +1 -1
  31. package/dist/css/groups.json +31 -11
  32. package/dist/css/menu.css +1 -1
  33. package/dist/css/more.css +1 -1
  34. package/dist/css/picker.css +1 -1
  35. package/dist/css/print.css +1 -0
  36. package/dist/css/shell.css +1 -1
  37. package/dist/i18n/strings.d.ts +17 -0
  38. package/dist/i18n/strings.js +41 -7
  39. package/dist/index.d.ts +4 -0
  40. package/dist/index.js +276 -267
  41. package/dist/styles.css +1 -1
  42. package/dist/utils/announcer.d.ts +21 -0
  43. package/dist/utils/announcer.js +30 -0
  44. package/package.json +3 -3
@@ -1,294 +1,297 @@
1
1
  "use client";
2
- import { jsxs as N, jsx as s } from "react/jsx-runtime";
3
- import { forwardRef as M, useState as E, useId as _, useMemo as X, useRef as H, useEffect as re } from "react";
4
- import { DialogTrigger as Y, Button as Z, Dialog as C, ListBox as ne, ListBoxItem as ce, useFilter as ee } from "react-aria-components";
5
- import { ChevronDown as ae, ChevronRight as oe, Check as de, ChevronsRight as fe, ChevronsLeft as ue } from "lucide-react";
6
- import { cx as V } from "../../utils/cx.js";
7
- import { Popover as te } from "../overlay/Overlay.js";
8
- import { ListView as me, ListItem as pe } from "../list/List.js";
9
- import { Tree as he, TreeItem as ve } from "../tree/Tree.js";
10
- import { Button as G } from "../button/Button.js";
2
+ import { jsxs as N, jsx as l } from "react/jsx-runtime";
3
+ import { forwardRef as I, useState as L, useId as G, useMemo as Y, useRef as J, useEffect as re } from "react";
4
+ import { DialogTrigger as Z, Button as C, Dialog as ee, ListBox as ne, ListBoxItem as ce, useFilter as ae } from "react-aria-components";
5
+ import { ChevronDown as te, ChevronRight as oe, Check as de, ChevronsRight as fe, ChevronsLeft as ue } from "lucide-react";
6
+ import { cx as U } from "../../utils/cx.js";
7
+ import { Popover as le } from "../overlay/Overlay.js";
8
+ import { ListView as me, ListItem as he } from "../list/List.js";
9
+ import { Tree as pe, TreeItem as ve } from "../tree/Tree.js";
10
+ import { Button as H } from "../button/Button.js";
11
11
  import { SearchField as be } from "../field/Field.js";
12
- import { useStrings as Q } from "../../i18n/strings.js";
13
- const Oe = M(function({ length: i = 6, label: n, value: u, defaultValue: $ = "", onChange: m, onComplete: v, type: D = "numeric", mask: A, isInvalid: S, errorMessage: g, isDisabled: K, name: L, className: T, ...z }, P) {
14
- const y = Q();
15
- n ?? (n = y.verificationCode);
16
- const [k, p] = E($.slice(0, i)), w = (u ?? k).slice(0, i), c = H([]), b = _(), f = (l) => D === "numeric" ? /^\d$/.test(l) : /^[a-z0-9]$/i.test(l), x = (l) => {
17
- l = l.slice(0, i), u === void 0 && p(l), m == null || m(l), l.length === i && !l.includes(" ") && (v == null || v(l));
18
- }, h = (l, t) => {
19
- var d;
20
- const a = w.padEnd(i, " ").split("");
21
- let e = l;
22
- for (const r of t.split("").filter(f)) {
23
- if (e >= i) break;
24
- a[e++] = D === "alphanumeric" ? r.toUpperCase() : r;
12
+ import { useStrings as V } from "../../i18n/strings.js";
13
+ const Oe = I(function({ length: d, groups: s, accept: u, label: w, value: m, defaultValue: $ = "", onChange: R, onComplete: P, type: D = "numeric", mask: O, isInvalid: q, errorMessage: B, isDisabled: z, name: E, className: M, ...k }, T) {
14
+ const h = V();
15
+ w ?? (w = h.verificationCode);
16
+ const c = d ?? (Array.isArray(s) ? s.reduce((e, t) => e + t, 0) : 6), r = s == null ? null : Array.isArray(s) ? s : Array.from({ length: Math.ceil(c / Math.max(1, s)) }, (e, t) => Math.min(s, c - t * s)), [A, f] = L($.slice(0, c)), x = (m ?? A).slice(0, c), p = J([]), i = G(), S = (e) => u ? u.test(D === "alphanumeric" ? e.toUpperCase() : e) : D === "numeric" ? /^\d$/.test(e) : /^[a-z0-9]$/i.test(e), o = (e) => {
17
+ e = e.slice(0, c), m === void 0 && f(e), R == null || R(e), e.length === c && !e.includes(" ") && (P == null || P(e));
18
+ }, n = (e, t, y = !1) => {
19
+ var K;
20
+ const v = x.padEnd(c, " ").split("");
21
+ let b = y && t.split("").filter(S).length === c ? 0 : e;
22
+ for (const _ of t.split("").filter(S)) {
23
+ if (b >= c) break;
24
+ v[b++] = D === "alphanumeric" ? _.toUpperCase() : _;
25
25
  }
26
- x(a.join("").replace(/\s+$/, "")), (d = c.current[Math.min(e, i - 1)]) == null || d.focus();
27
- }, o = (l, t) => {
28
- var a, e, d;
26
+ o(v.join("").replace(/\s+$/, "")), (K = p.current[Math.min(b, c - 1)]) == null || K.focus();
27
+ }, a = (e, t) => {
28
+ var y, v, b;
29
29
  if (t.key === "Backspace") {
30
30
  t.preventDefault();
31
- const r = w.padEnd(i, " ").split("");
32
- r[l] && r[l] !== " " ? r[l] = " " : l > 0 && (r[l - 1] = " ", (a = c.current[l - 1]) == null || a.focus()), x(r.join("").replace(/\s+$/, ""));
33
- } else t.key === "ArrowLeft" && l > 0 ? (t.preventDefault(), (e = c.current[l - 1]) == null || e.focus()) : t.key === "ArrowRight" && l < i - 1 && (t.preventDefault(), (d = c.current[l + 1]) == null || d.focus());
34
- };
35
- return /* @__PURE__ */ N("div", { ref: P, ...z, className: V("alea-field alea-otp", T), "data-invalid": S || void 0, "data-disabled": K || void 0, children: [
36
- /* @__PURE__ */ s("span", { className: "alea-label", id: `${b}-label`, children: n }),
37
- /* @__PURE__ */ s("div", { role: "group", "aria-labelledby": `${b}-label`, "aria-describedby": S && g ? `${b}-err` : void 0, className: "alea-otp-boxes", children: Array.from({ length: i }, (l, t) => /* @__PURE__ */ s(
38
- "input",
39
- {
40
- ref: (a) => {
41
- c.current[t] = a;
42
- },
43
- className: "alea-otp-box",
44
- "aria-label": y.characterNOfTotal(t + 1, i),
45
- "aria-invalid": S || void 0,
46
- inputMode: D === "numeric" ? "numeric" : "text",
47
- autoComplete: t === 0 ? "one-time-code" : "off",
48
- type: A ? "password" : "text",
49
- maxLength: i,
50
- disabled: K,
51
- value: (w[t] || "").trim(),
52
- onChange: (a) => {
53
- const e = a.target.value;
54
- if (e.length > 2) h(t, e);
55
- else {
56
- const d = e.slice(-1);
57
- d && f(d) && h(t, d);
58
- }
59
- },
60
- onKeyDown: (a) => o(t, a),
61
- onPaste: (a) => {
62
- a.preventDefault(), h(t, a.clipboardData.getData("text"));
63
- },
64
- onFocus: (a) => a.target.select()
31
+ const K = x.padEnd(c, " ").split("");
32
+ K[e] && K[e] !== " " ? K[e] = " " : e > 0 && (K[e - 1] = " ", (y = p.current[e - 1]) == null || y.focus()), o(K.join("").replace(/\s+$/, ""));
33
+ } else t.key === "ArrowLeft" && e > 0 ? (t.preventDefault(), (v = p.current[e - 1]) == null || v.focus()) : t.key === "ArrowRight" && e < c - 1 && (t.preventDefault(), (b = p.current[e + 1]) == null || b.focus());
34
+ }, g = (e) => /* @__PURE__ */ l(
35
+ "input",
36
+ {
37
+ ref: (t) => {
38
+ p.current[e] = t;
39
+ },
40
+ className: "alea-otp-box",
41
+ "aria-label": h.characterNOfTotal(e + 1, c),
42
+ "aria-invalid": q || void 0,
43
+ inputMode: D === "numeric" ? "numeric" : "text",
44
+ autoComplete: e === 0 ? "one-time-code" : "off",
45
+ type: O ? "password" : "text",
46
+ maxLength: c,
47
+ disabled: z,
48
+ value: (x[e] || "").trim(),
49
+ onChange: (t) => {
50
+ const y = t.target.value;
51
+ if (y.length > 2) n(e, y);
52
+ else {
53
+ const v = y.slice(-1);
54
+ v && S(v) && n(e, v);
55
+ }
56
+ },
57
+ onKeyDown: (t) => a(e, t),
58
+ onPaste: (t) => {
59
+ t.preventDefault(), n(e, t.clipboardData.getData("text"), !0);
65
60
  },
66
- t
67
- )) }),
68
- L && /* @__PURE__ */ s("input", { type: "hidden", name: L, value: w.replace(/\s/g, "") }),
69
- S && g && /* @__PURE__ */ s("span", { id: `${b}-err`, className: "alea-field-error", children: g })
61
+ onFocus: (t) => t.target.select()
62
+ },
63
+ e
64
+ );
65
+ return /* @__PURE__ */ N("div", { ref: T, ...k, className: U("alea-field alea-otp", M), "data-invalid": q || void 0, "data-disabled": z || void 0, children: [
66
+ /* @__PURE__ */ l("span", { className: "alea-label", id: `${i}-label`, children: w }),
67
+ /* @__PURE__ */ l("div", { role: "group", "aria-labelledby": `${i}-label`, "aria-describedby": q && B ? `${i}-err` : void 0, className: "alea-otp-boxes", "data-grouped": r ? "" : void 0, children: r ? r.map((e, t) => {
68
+ const y = r.slice(0, t).reduce((v, b) => v + b, 0);
69
+ return /* @__PURE__ */ l("div", { role: "group", "aria-label": h.blockNOfTotal(t + 1, r.length), className: "alea-otp-block", children: Array.from({ length: e }, (v, b) => g(y + b)) }, t);
70
+ }) : Array.from({ length: c }, (e, t) => g(t)) }),
71
+ E && /* @__PURE__ */ l("input", { type: "hidden", name: E, value: x.replace(/\s/g, "") }),
72
+ q && B && /* @__PURE__ */ l("span", { id: `${i}-err`, className: "alea-field-error", children: B })
70
73
  ] });
71
74
  });
72
- function I(R, i) {
73
- const n = [];
74
- let u = R;
75
- for (const $ of i) {
76
- const m = u.find((v) => v.id === $);
75
+ function j(F, d) {
76
+ const s = [];
77
+ let u = F;
78
+ for (const w of d) {
79
+ const m = u.find(($) => $.id === w);
77
80
  if (!m) break;
78
- n.push(m), u = m.children || [];
81
+ s.push(m), u = m.children || [];
79
82
  }
80
- return n;
83
+ return s;
81
84
  }
82
- const Ee = M(function({ motion: i, label: n, options: u, value: $, defaultValue: m = [], onChange: v, placeholder: D, allowsParentSelection: A, description: S, isDisabled: g, className: K, ...L }, T) {
83
- const z = Q();
84
- D ?? (D = z.selectPlaceholder);
85
- const [P, y] = E(m), k = $ ?? P, [p, w] = E(!1), [c, b] = E(k), f = _(), x = X(() => {
86
- const t = [u];
87
- return I(u, c).forEach((a) => {
88
- var e;
89
- (e = a.children) != null && e.length && t.push(a.children);
90
- }), t;
91
- }, [u, c]), h = (t) => {
92
- $ === void 0 && y(t), v == null || v(t, I(u, t)), w(!1);
93
- }, o = I(u, k).map((t) => t.label).join(" / "), l = H([]);
94
- return /* @__PURE__ */ N("div", { ref: T, ...L, className: V("alea-field alea-cascader", K), "data-disabled": g || void 0, children: [
95
- n && /* @__PURE__ */ s("span", { className: "alea-label", id: `${f}-label`, children: n }),
96
- /* @__PURE__ */ N(Y, { isOpen: p, onOpenChange: (t) => {
97
- w(t), t && b(k);
85
+ const ze = I(function({ motion: d, label: s, options: u, value: w, defaultValue: m = [], onChange: $, placeholder: R, allowsParentSelection: P, description: D, isDisabled: O, className: q, ...B }, z) {
86
+ const E = V();
87
+ R ?? (R = E.selectPlaceholder);
88
+ const [M, k] = L(m), T = w ?? M, [h, c] = L(!1), [r, A] = L(T), f = G(), x = Y(() => {
89
+ const o = [u];
90
+ return j(u, r).forEach((n) => {
91
+ var a;
92
+ (a = n.children) != null && a.length && o.push(n.children);
93
+ }), o;
94
+ }, [u, r]), p = (o) => {
95
+ w === void 0 && k(o), $ == null || $(o, j(u, o)), c(!1);
96
+ }, i = j(u, T).map((o) => o.label).join(" / "), S = J([]);
97
+ return /* @__PURE__ */ N("div", { ref: z, ...B, className: U("alea-field alea-cascader", q), "data-disabled": O || void 0, children: [
98
+ s && /* @__PURE__ */ l("span", { className: "alea-label", id: `${f}-label`, children: s }),
99
+ /* @__PURE__ */ N(Z, { isOpen: h, onOpenChange: (o) => {
100
+ c(o), o && A(T);
98
101
  }, children: [
99
- /* @__PURE__ */ N(Z, { className: "alea-select-trigger alea-focus-ring", "aria-labelledby": n ? `${f}-label ${f}-value` : void 0, isDisabled: g, children: [
100
- /* @__PURE__ */ s("span", { id: `${f}-value`, className: "alea-select-value", "data-placeholder": !o || void 0, children: o || D }),
101
- /* @__PURE__ */ s(ae, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
102
+ /* @__PURE__ */ N(C, { className: "alea-select-trigger alea-focus-ring", "aria-labelledby": s ? `${f}-label ${f}-value` : void 0, isDisabled: O, children: [
103
+ /* @__PURE__ */ l("span", { id: `${f}-value`, className: "alea-select-value", "data-placeholder": !i || void 0, children: i || R }),
104
+ /* @__PURE__ */ l(te, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
102
105
  ] }),
103
- /* @__PURE__ */ s(te, { className: "alea-popover alea-cascader-popover", placement: "bottom start", motion: i, children: /* @__PURE__ */ s(C, { "aria-label": typeof n == "string" ? n : z.options, className: "alea-cascader-columns", children: x.map((t, a) => {
104
- var e, d;
106
+ /* @__PURE__ */ l(le, { className: "alea-popover alea-cascader-popover", placement: "bottom start", motion: d, children: /* @__PURE__ */ l(ee, { "aria-label": typeof s == "string" ? s : E.options, className: "alea-cascader-columns", children: x.map((o, n) => {
107
+ var a, g;
105
108
  return /* @__PURE__ */ N(
106
109
  "div",
107
110
  {
108
- ref: (r) => {
109
- l.current[a] = r;
111
+ ref: (e) => {
112
+ S.current[n] = e;
110
113
  },
111
114
  className: "alea-cascader-col",
112
- onKeyDown: (r) => {
113
- var O, B, F, q, j;
114
- if (r.key === "ArrowLeft" && a > 0 && ((B = (O = l.current[a - 1]) == null ? void 0 : O.querySelector("[aria-selected=true], [role=option]")) == null || B.focus()), r.key === "ArrowRight") {
115
- const ie = (q = (F = document.activeElement) == null ? void 0 : F.dataset) == null ? void 0 : q.key, U = t.find((W) => String(W.id) === ie);
116
- (j = U == null ? void 0 : U.children) != null && j.length && (b([...c.slice(0, a), U.id]), setTimeout(() => {
117
- var W, J;
118
- return (J = (W = l.current[a + 1]) == null ? void 0 : W.querySelector("[role=option]")) == null ? void 0 : J.focus();
115
+ onKeyDown: (e) => {
116
+ var t, y, v, b, K;
117
+ if (e.key === "ArrowLeft" && n > 0 && ((y = (t = S.current[n - 1]) == null ? void 0 : t.querySelector("[aria-selected=true], [role=option]")) == null || y.focus()), e.key === "ArrowRight") {
118
+ const _ = (b = (v = document.activeElement) == null ? void 0 : v.dataset) == null ? void 0 : b.key, Q = o.find((W) => String(W.id) === _);
119
+ (K = Q == null ? void 0 : Q.children) != null && K.length && (A([...r.slice(0, n), Q.id]), setTimeout(() => {
120
+ var W, X;
121
+ return (X = (W = S.current[n + 1]) == null ? void 0 : W.querySelector("[role=option]")) == null ? void 0 : X.focus();
119
122
  }, 0));
120
123
  }
121
124
  },
122
125
  children: [
123
- /* @__PURE__ */ s(
126
+ /* @__PURE__ */ l(
124
127
  ne,
125
128
  {
126
- "aria-label": a === 0 ? typeof n == "string" ? n : z.options : (e = I(u, c)[a - 1]) == null ? void 0 : e.label,
127
- items: t,
129
+ "aria-label": n === 0 ? typeof s == "string" ? s : E.options : (a = j(u, r)[n - 1]) == null ? void 0 : a.label,
130
+ items: o,
128
131
  selectionMode: "single",
129
- selectedKeys: c[a] !== void 0 ? [c[a]] : [],
130
- disabledKeys: t.filter((r) => r.isDisabled).map((r) => r.id),
131
- autoFocus: a === 0 ? "first" : void 0,
132
+ selectedKeys: r[n] !== void 0 ? [r[n]] : [],
133
+ disabledKeys: o.filter((e) => e.isDisabled).map((e) => e.id),
134
+ autoFocus: n === 0 ? "first" : void 0,
132
135
  className: "alea-listbox",
133
- onAction: (r) => {
134
- var F;
135
- const O = t.find((q) => q.id === r), B = [...c.slice(0, a), r];
136
- (F = O.children) != null && F.length ? (b(B), setTimeout(() => {
137
- var q, j;
138
- return (j = (q = l.current[a + 1]) == null ? void 0 : q.querySelector("[role=option]")) == null ? void 0 : j.focus();
139
- }, 0)) : h(B);
136
+ onAction: (e) => {
137
+ var v;
138
+ const t = o.find((b) => b.id === e), y = [...r.slice(0, n), e];
139
+ (v = t.children) != null && v.length ? (A(y), setTimeout(() => {
140
+ var b, K;
141
+ return (K = (b = S.current[n + 1]) == null ? void 0 : b.querySelector("[role=option]")) == null ? void 0 : K.focus();
142
+ }, 0)) : p(y);
140
143
  },
141
- children: (r) => {
142
- var O;
143
- return /* @__PURE__ */ N(ce, { id: r.id, textValue: r.label, className: "alea-option", children: [
144
- /* @__PURE__ */ s("span", { className: "alea-option-text", children: r.label }),
145
- (O = r.children) != null && O.length ? /* @__PURE__ */ s(oe, { size: 16, "aria-hidden": "true", className: "alea-menu-chevron" }) : /* @__PURE__ */ s(de, { size: 16, "aria-hidden": "true", className: "alea-option-check", "data-on": k[a] === r.id || void 0 })
144
+ children: (e) => {
145
+ var t;
146
+ return /* @__PURE__ */ N(ce, { id: e.id, textValue: e.label, className: "alea-option", children: [
147
+ /* @__PURE__ */ l("span", { className: "alea-option-text", children: e.label }),
148
+ (t = e.children) != null && t.length ? /* @__PURE__ */ l(oe, { size: 16, "aria-hidden": "true", className: "alea-menu-chevron" }) : /* @__PURE__ */ l(de, { size: 16, "aria-hidden": "true", className: "alea-option-check", "data-on": T[n] === e.id || void 0 })
146
149
  ] });
147
150
  }
148
151
  }
149
152
  ),
150
- A && a > 0 && /* @__PURE__ */ N(G, { size: "sm", variant: "ghost", onPress: () => h(c.slice(0, a)), children: [
153
+ P && n > 0 && /* @__PURE__ */ N(H, { size: "sm", variant: "ghost", onPress: () => p(r.slice(0, n)), children: [
151
154
  "Choose “",
152
- (d = I(u, c)[a - 1]) == null ? void 0 : d.label,
155
+ (g = j(u, r)[n - 1]) == null ? void 0 : g.label,
153
156
  "”"
154
157
  ] })
155
158
  ]
156
159
  },
157
- a
160
+ n
158
161
  );
159
162
  }) }) })
160
163
  ] }),
161
- S && /* @__PURE__ */ s("span", { className: "alea-description", children: S })
164
+ D && /* @__PURE__ */ l("span", { className: "alea-description", children: D })
162
165
  ] });
163
166
  });
164
- function se(R, i = /* @__PURE__ */ new Map()) {
165
- return R.forEach((n) => {
166
- i.set(n.id, n), n.children && se(n.children, i);
167
- }), i;
167
+ function se(F, d = /* @__PURE__ */ new Map()) {
168
+ return F.forEach((s) => {
169
+ d.set(s.id, s), s.children && se(s.children, d);
170
+ }), d;
168
171
  }
169
- function le(R) {
170
- return R.map((i) => /* @__PURE__ */ s(ve, { id: i.id, title: i.label, textValue: i.label, children: i.children ? le(i.children) : null }, String(i.id)));
172
+ function ie(F) {
173
+ return F.map((d) => /* @__PURE__ */ l(ve, { id: d.id, title: d.label, textValue: d.label, children: d.children ? ie(d.children) : null }, String(d.id)));
171
174
  }
172
- const Re = M(function({ motion: i, label: n, nodes: u, selectionMode: $ = "single", value: m, defaultValue: v = [], onChange: D, placeholder: A, isDisabled: S, className: g, ...K }, L) {
173
- const T = Q();
174
- A ?? (A = T.selectPlaceholder);
175
- const [z, P] = E(v), y = m ?? z, [k, p] = E(!1), w = X(() => se(u), [u]), c = _(), b = y.map((f) => {
175
+ const Ee = I(function({ motion: d, label: s, nodes: u, selectionMode: w = "single", value: m, defaultValue: $ = [], onChange: R, placeholder: P, isDisabled: D, className: O, ...q }, B) {
176
+ const z = V();
177
+ P ?? (P = z.selectPlaceholder);
178
+ const [E, M] = L($), k = m ?? E, [T, h] = L(!1), c = Y(() => se(u), [u]), r = G(), A = k.map((f) => {
176
179
  var x;
177
- return (x = w.get(f)) == null ? void 0 : x.label;
180
+ return (x = c.get(f)) == null ? void 0 : x.label;
178
181
  }).filter(Boolean).join(", ");
179
- return /* @__PURE__ */ N("div", { ref: L, ...K, className: V("alea-field alea-treeselect", g), "data-disabled": S || void 0, children: [
180
- n && /* @__PURE__ */ s("span", { className: "alea-label", id: `${c}-label`, children: n }),
181
- /* @__PURE__ */ N(Y, { isOpen: k, onOpenChange: p, children: [
182
- /* @__PURE__ */ N(Z, { className: "alea-select-trigger alea-focus-ring", "aria-labelledby": n ? `${c}-label ${c}-value` : void 0, isDisabled: S, children: [
183
- /* @__PURE__ */ s("span", { id: `${c}-value`, className: "alea-select-value", "data-placeholder": !b || void 0, children: b || A }),
184
- /* @__PURE__ */ s(ae, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
182
+ return /* @__PURE__ */ N("div", { ref: B, ...q, className: U("alea-field alea-treeselect", O), "data-disabled": D || void 0, children: [
183
+ s && /* @__PURE__ */ l("span", { className: "alea-label", id: `${r}-label`, children: s }),
184
+ /* @__PURE__ */ N(Z, { isOpen: T, onOpenChange: h, children: [
185
+ /* @__PURE__ */ N(C, { className: "alea-select-trigger alea-focus-ring", "aria-labelledby": s ? `${r}-label ${r}-value` : void 0, isDisabled: D, children: [
186
+ /* @__PURE__ */ l("span", { id: `${r}-value`, className: "alea-select-value", "data-placeholder": !A || void 0, children: A || P }),
187
+ /* @__PURE__ */ l(te, { size: 16, "aria-hidden": "true", className: "alea-select-chevron" })
185
188
  ] }),
186
- /* @__PURE__ */ s(te, { className: "alea-popover alea-select-popover", placement: "bottom start", motion: i, children: /* @__PURE__ */ s(C, { "aria-label": typeof n == "string" ? n : T.options, className: "alea-treeselect-dialog", children: /* @__PURE__ */ s(
187
- he,
189
+ /* @__PURE__ */ l(le, { className: "alea-popover alea-select-popover", placement: "bottom start", motion: d, children: /* @__PURE__ */ l(ee, { "aria-label": typeof s == "string" ? s : z.options, className: "alea-treeselect-dialog", children: /* @__PURE__ */ l(
190
+ pe,
188
191
  {
189
- "aria-label": typeof n == "string" ? n : T.options,
190
- selectionMode: $,
191
- selectionBehavior: $ === "multiple" ? "toggle" : "replace",
192
- selectedKeys: y,
193
- defaultExpandedKeys: y.length ? void 0 : u.map((f) => f.id),
192
+ "aria-label": typeof s == "string" ? s : z.options,
193
+ selectionMode: w,
194
+ selectionBehavior: w === "multiple" ? "toggle" : "replace",
195
+ selectedKeys: k,
196
+ defaultExpandedKeys: k.length ? void 0 : u.map((f) => f.id),
194
197
  autoFocus: !0,
195
198
  onSelectionChange: (f) => {
196
- const x = f === "all" ? [...w.keys()] : [...f];
197
- m === void 0 && P(x), D == null || D(x), $ === "single" && p(!1);
199
+ const x = f === "all" ? [...c.keys()] : [...f];
200
+ m === void 0 && M(x), R == null || R(x), w === "single" && h(!1);
198
201
  },
199
- children: le(u)
202
+ children: ie(u)
200
203
  }
201
204
  ) }) })
202
205
  ] })
203
206
  ] });
204
- }), Ae = M(function({ items: i, value: n, defaultValue: u = [], onChange: $, titles: m, searchable: v, className: D, ...A }, S) {
205
- const g = Q();
206
- m ?? (m = [g.available, g.chosen]);
207
- const [K, L] = E(u), T = n ?? K, [z, P] = E(/* @__PURE__ */ new Set()), [y, k] = E(/* @__PURE__ */ new Set()), [p, w] = E(["", ""]), { contains: c } = ee({ sensitivity: "base" }), b = (o) => {
208
- n === void 0 && L(o), $ == null || $(o);
209
- }, f = i.filter((o) => !T.includes(o.id) && c(o.label, p[0])), x = i.filter((o) => T.includes(o.id) && c(o.label, p[1])), h = (o, l, t, a) => /* @__PURE__ */ N("section", { className: "alea-transfer-side", "aria-labelledby": `alea-transfer-${o}`, children: [
207
+ }), Re = I(function({ items: d, value: s, defaultValue: u = [], onChange: w, titles: m, searchable: $, className: R, ...P }, D) {
208
+ const O = V();
209
+ m ?? (m = [O.available, O.chosen]);
210
+ const [q, B] = L(u), z = s ?? q, [E, M] = L(/* @__PURE__ */ new Set()), [k, T] = L(/* @__PURE__ */ new Set()), [h, c] = L(["", ""]), { contains: r } = ae({ sensitivity: "base" }), A = (i) => {
211
+ s === void 0 && B(i), w == null || w(i);
212
+ }, f = d.filter((i) => !z.includes(i.id) && r(i.label, h[0])), x = d.filter((i) => z.includes(i.id) && r(i.label, h[1])), p = (i, S, o, n) => /* @__PURE__ */ N("section", { className: "alea-transfer-side", "aria-labelledby": `alea-transfer-${i}`, children: [
210
213
  /* @__PURE__ */ N("header", { className: "alea-transfer-head", children: [
211
- /* @__PURE__ */ s("h3", { id: `alea-transfer-${o}`, children: m[o] }),
212
- /* @__PURE__ */ s("span", { children: t.size ? g.nOfTotal(t.size, l.length) : l.length })
214
+ /* @__PURE__ */ l("h3", { id: `alea-transfer-${i}`, children: m[i] }),
215
+ /* @__PURE__ */ l("span", { children: o.size ? O.nOfTotal(o.size, S.length) : S.length })
213
216
  ] }),
214
- v && /* @__PURE__ */ s(be, { "aria-label": g.searchIn(m[o]), size: "sm", value: p[o], onChange: (e) => w(o ? [p[0], e] : [e, p[1]]) }),
215
- /* @__PURE__ */ s(me, { "aria-label": m[o], selectionMode: "multiple", selectedKeys: t, onSelectionChange: (e) => a(e === "all" ? new Set(l.map((d) => d.id)) : new Set(e)), disabledKeys: l.filter((e) => e.isDisabled).map((e) => e.id), items: l, renderEmptyState: () => /* @__PURE__ */ s("p", { className: "alea-transfer-empty", children: "Nothing here" }), className: "alea-transfer-list", children: (e) => /* @__PURE__ */ s(pe, { id: e.id, description: e.description, children: e.label }) })
217
+ $ && /* @__PURE__ */ l(be, { "aria-label": O.searchIn(m[i]), size: "sm", value: h[i], onChange: (a) => c(i ? [h[0], a] : [a, h[1]]) }),
218
+ /* @__PURE__ */ l(me, { "aria-label": m[i], selectionMode: "multiple", selectedKeys: o, onSelectionChange: (a) => n(a === "all" ? new Set(S.map((g) => g.id)) : new Set(a)), disabledKeys: S.filter((a) => a.isDisabled).map((a) => a.id), items: S, renderEmptyState: () => /* @__PURE__ */ l("p", { className: "alea-transfer-empty", children: "Nothing here" }), className: "alea-transfer-list", children: (a) => /* @__PURE__ */ l(he, { id: a.id, description: a.description, children: a.label }) })
216
219
  ] });
217
- return /* @__PURE__ */ N("div", { ref: S, ...A, className: V("alea-transfer", D), children: [
218
- h(0, f, z, P),
220
+ return /* @__PURE__ */ N("div", { ref: D, ...P, className: U("alea-transfer", R), children: [
221
+ p(0, f, E, M),
219
222
  /* @__PURE__ */ N("div", { className: "alea-transfer-actions", children: [
220
- /* @__PURE__ */ s(G, { size: "sm", variant: "secondary", isDisabled: !z.size, "aria-label": g.moveTo(z.size, m[1]), onPress: () => {
221
- b([...T, ...z]), P(/* @__PURE__ */ new Set());
222
- }, children: /* @__PURE__ */ s(fe, {}) }),
223
- /* @__PURE__ */ s(G, { size: "sm", variant: "ghost", isDisabled: !y.size, "aria-label": g.moveTo(y.size, m[0]), onPress: () => {
224
- b(T.filter((o) => !y.has(o))), k(/* @__PURE__ */ new Set());
225
- }, children: /* @__PURE__ */ s(ue, {}) })
223
+ /* @__PURE__ */ l(H, { size: "sm", variant: "secondary", isDisabled: !E.size, "aria-label": O.moveTo(E.size, m[1]), onPress: () => {
224
+ A([...z, ...E]), M(/* @__PURE__ */ new Set());
225
+ }, children: /* @__PURE__ */ l(fe, {}) }),
226
+ /* @__PURE__ */ l(H, { size: "sm", variant: "ghost", isDisabled: !k.size, "aria-label": O.moveTo(k.size, m[0]), onPress: () => {
227
+ A(z.filter((i) => !k.has(i))), T(/* @__PURE__ */ new Set());
228
+ }, children: /* @__PURE__ */ l(ue, {}) })
226
229
  ] }),
227
- h(1, x, y, k)
230
+ p(1, x, k, T)
228
231
  ] });
229
- }), Ke = M(function({ label: i, options: n, value: u, defaultValue: $ = "", onChange: m, trigger: v = "@", placeholder: D, rows: A = 3, description: S, className: g, ...K }, L) {
230
- const T = Q(), [z, P] = E($), y = u ?? z, k = H(null), [p, w] = E(null), [c, b] = E(0), f = _(), { startsWith: x } = ee({ sensitivity: "base" }), h = p ? n.filter((e) => x(e.label, p.q) || x(e.id, p.q)).slice(0, 8) : [], o = !!p && h.length > 0, l = (e) => {
231
- u === void 0 && P(e), m == null || m(e);
232
- }, t = (e, d) => {
233
- const r = e.slice(0, d), O = new RegExp(`(^|\\s)${v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([\\w.-]*)$`).exec(r);
234
- w(O ? { start: d - O[2].length - v.length, q: O[2] } : null), b(0);
235
- }, a = (e) => {
236
- var B;
237
- if (!p) return;
238
- const d = ((B = k.current) == null ? void 0 : B.selectionStart) ?? y.length, r = y.slice(0, p.start) + v + e.id + " " + y.slice(d);
239
- l(r), w(null);
240
- const O = p.start + v.length + e.id.length + 1;
232
+ }), Ke = I(function({ label: d, options: s, value: u, defaultValue: w = "", onChange: m, trigger: $ = "@", placeholder: R, rows: P = 3, description: D, className: O, ...q }, B) {
233
+ const z = V(), [E, M] = L(w), k = u ?? E, T = J(null), [h, c] = L(null), [r, A] = L(0), f = G(), { startsWith: x } = ae({ sensitivity: "base" }), p = h ? s.filter((a) => x(a.label, h.q) || x(a.id, h.q)).slice(0, 8) : [], i = !!h && p.length > 0, S = (a) => {
234
+ u === void 0 && M(a), m == null || m(a);
235
+ }, o = (a, g) => {
236
+ const e = a.slice(0, g), t = new RegExp(`(^|\\s)${$.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([\\w.-]*)$`).exec(e);
237
+ c(t ? { start: g - t[2].length - $.length, q: t[2] } : null), A(0);
238
+ }, n = (a) => {
239
+ var y;
240
+ if (!h) return;
241
+ const g = ((y = T.current) == null ? void 0 : y.selectionStart) ?? k.length, e = k.slice(0, h.start) + $ + a.id + " " + k.slice(g);
242
+ S(e), c(null);
243
+ const t = h.start + $.length + a.id.length + 1;
241
244
  requestAnimationFrame(() => {
242
- var F, q;
243
- (F = k.current) == null || F.focus(), (q = k.current) == null || q.setSelectionRange(O, O);
245
+ var v, b;
246
+ (v = T.current) == null || v.focus(), (b = T.current) == null || b.setSelectionRange(t, t);
244
247
  });
245
248
  };
246
249
  return re(() => {
247
- c >= h.length && b(0);
248
- }, [h.length, c]), /* @__PURE__ */ N("div", { ref: L, ...K, className: V("alea-field alea-mentions", g), children: [
249
- i && /* @__PURE__ */ s("label", { className: "alea-label", htmlFor: `${f}-ta`, children: i }),
250
+ r >= p.length && A(0);
251
+ }, [p.length, r]), /* @__PURE__ */ N("div", { ref: B, ...q, className: U("alea-field alea-mentions", O), children: [
252
+ d && /* @__PURE__ */ l("label", { className: "alea-label", htmlFor: `${f}-ta`, children: d }),
250
253
  /* @__PURE__ */ N("div", { className: "alea-mentions-wrap", children: [
251
- /* @__PURE__ */ s(
254
+ /* @__PURE__ */ l(
252
255
  "textarea",
253
256
  {
254
- ref: k,
257
+ ref: T,
255
258
  id: `${f}-ta`,
256
259
  className: "alea-input alea-textarea",
257
- rows: A,
258
- placeholder: D,
259
- value: y,
260
+ rows: P,
261
+ placeholder: R,
262
+ value: k,
260
263
  "aria-autocomplete": "list",
261
264
  "aria-controls": `${f}-list`,
262
- "aria-activedescendant": o ? `${f}-opt-${c}` : void 0,
263
- "aria-describedby": S ? `${f}-desc` : void 0,
264
- onChange: (e) => {
265
- l(e.target.value), t(e.target.value, e.target.selectionStart);
265
+ "aria-activedescendant": i ? `${f}-opt-${r}` : void 0,
266
+ "aria-describedby": D ? `${f}-desc` : void 0,
267
+ onChange: (a) => {
268
+ S(a.target.value), o(a.target.value, a.target.selectionStart);
266
269
  },
267
- onKeyDown: (e) => {
268
- o && (e.key === "ArrowDown" ? (e.preventDefault(), b((d) => (d + 1) % h.length)) : e.key === "ArrowUp" ? (e.preventDefault(), b((d) => (d - 1 + h.length) % h.length)) : e.key === "Enter" || e.key === "Tab" ? (e.preventDefault(), a(h[c])) : e.key === "Escape" && (e.preventDefault(), w(null)));
270
+ onKeyDown: (a) => {
271
+ i && (a.key === "ArrowDown" ? (a.preventDefault(), A((g) => (g + 1) % p.length)) : a.key === "ArrowUp" ? (a.preventDefault(), A((g) => (g - 1 + p.length) % p.length)) : a.key === "Enter" || a.key === "Tab" ? (a.preventDefault(), n(p[r])) : a.key === "Escape" && (a.preventDefault(), c(null)));
269
272
  },
270
- onBlur: () => setTimeout(() => w(null), 120)
273
+ onBlur: () => setTimeout(() => c(null), 120)
271
274
  }
272
275
  ),
273
- /* @__PURE__ */ s("ul", { id: `${f}-list`, role: "listbox", "aria-label": T.suggestions, className: "alea-popover alea-mentions-list", hidden: !o, children: h.map((e, d) => /* @__PURE__ */ s("li", { id: `${f}-opt-${d}`, role: "option", "aria-selected": d === c, className: "alea-option", "data-focused": d === c || void 0, onMouseDown: (r) => {
274
- r.preventDefault(), a(e);
276
+ /* @__PURE__ */ l("ul", { id: `${f}-list`, role: "listbox", "aria-label": z.suggestions, className: "alea-popover alea-mentions-list", hidden: !i, children: p.map((a, g) => /* @__PURE__ */ l("li", { id: `${f}-opt-${g}`, role: "option", "aria-selected": g === r, className: "alea-option", "data-focused": g === r || void 0, onMouseDown: (e) => {
277
+ e.preventDefault(), n(a);
275
278
  }, children: /* @__PURE__ */ N("span", { className: "alea-option-text", children: [
276
- /* @__PURE__ */ s("span", { children: e.label }),
279
+ /* @__PURE__ */ l("span", { children: a.label }),
277
280
  /* @__PURE__ */ N("span", { className: "alea-option-desc", children: [
278
- v,
279
- e.id,
280
- e.description ? ` · ${e.description}` : ""
281
+ $,
282
+ a.id,
283
+ a.description ? ` · ${a.description}` : ""
281
284
  ] })
282
- ] }) }, e.id)) })
285
+ ] }) }, a.id)) })
283
286
  ] }),
284
- /* @__PURE__ */ s("span", { className: "alea-visually-hidden", role: "status", children: o ? `${h.length} suggestion${h.length === 1 ? "" : "s"}, arrows to choose, Enter to insert` : "" }),
285
- S && /* @__PURE__ */ s("span", { id: `${f}-desc`, className: "alea-description", children: S })
287
+ /* @__PURE__ */ l("span", { className: "alea-visually-hidden", role: "status", children: i ? `${p.length} suggestion${p.length === 1 ? "" : "s"}, arrows to choose, Enter to insert` : "" }),
288
+ D && /* @__PURE__ */ l("span", { id: `${f}-desc`, className: "alea-description", children: D })
286
289
  ] });
287
290
  });
288
291
  export {
289
- Ee as Cascader,
292
+ ze as Cascader,
290
293
  Ke as Mentions,
291
294
  Oe as OTPField,
292
- Ae as Transfer,
293
- Re as TreeSelect
295
+ Re as Transfer,
296
+ Ee as TreeSelect
294
297
  };
@@ -0,0 +1,18 @@
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
+ export interface PrintSheetProps extends HTMLAttributes<HTMLDivElement> {
3
+ /** The paper: a4 (default) or letter. */
4
+ size?: 'a4' | 'letter';
5
+ /** portrait (default) or landscape. */
6
+ orientation?: 'portrait' | 'landscape';
7
+ /** Draws the sheet only on paper: it is kept out of the screen and, when printing, everything else on the page is hidden. Use it when the app shows a Print button and the sheet is not part of the screen. Without it the sheet shows on screen as a page and the rest of the page is yours to hide. */
8
+ printOnly?: boolean;
9
+ /** What goes on the paper. */
10
+ children?: ReactNode;
11
+ }
12
+ /**
13
+ * One sheet of paper for a document that people print or save as PDF: a receipt, an invoice, a certificate, a sheet of recovery codes.
14
+ * On screen it is a white page at paper proportions that shrinks to fit a phone; on paper it is the page itself, always dark ink on white
15
+ * even when the app is in dark mode, with the size and orientation you chose. Two sheets one after the other are two pages, and a longer one
16
+ * runs on to the next page. A QRCode inside prints as it should (dark on white).
17
+ */
18
+ export declare const PrintSheet: import("react").ForwardRefExoticComponent<PrintSheetProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx as e } from "react/jsx-runtime";
3
+ import { forwardRef as d, useState as f, useEffect as u } from "react";
4
+ import { createPortal as p } from "react-dom";
5
+ import { cx as h } from "../../utils/cx.js";
6
+ const N = d(function({ size: r = "a4", orientation: a = "portrait", printOnly: o, className: i, children: n, ...s }, c) {
7
+ const [l, m] = f(!1);
8
+ u(() => m(!0), []);
9
+ const t = /* @__PURE__ */ e("div", { ref: c, ...s, className: h("alea-print-sheet", i), "data-theme": "light", "data-size": r, "data-orientation": a, children: n });
10
+ return o ? l ? p(/* @__PURE__ */ e("div", { className: "alea-root alea-print-root", children: t }), document.body) : null : t;
11
+ });
12
+ export {
13
+ N as PrintSheet
14
+ };