@alea-design/ui 0.7.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/button/Button.d.ts +13 -2
- package/dist/components/button/Button.js +144 -111
- package/dist/components/celebrate/Celebrate.d.ts +31 -0
- package/dist/components/celebrate/Celebrate.js +50 -0
- package/dist/components/display/Display.d.ts +6 -1
- package/dist/components/display/Display.js +64 -63
- package/dist/components/feedback/Feedback.js +23 -23
- package/dist/components/field/Field.d.ts +15 -2
- package/dist/components/field/Field.js +165 -134
- package/dist/components/more/More.d.ts +3 -1
- package/dist/components/more/More.js +53 -53
- package/dist/components/notification/NotificationCenter.js +15 -15
- package/dist/components/picker/Picker.d.ts +5 -1
- package/dist/components/picker/Picker.js +212 -209
- package/dist/components/print/PrintSheet.d.ts +18 -0
- package/dist/components/print/PrintSheet.js +14 -0
- package/dist/components/shell/AccountFooter.d.ts +31 -0
- package/dist/components/shell/AccountFooter.js +43 -0
- package/dist/components/shell/AppShell.js +18 -18
- package/dist/components/shell/AppSidebar.js +31 -31
- package/dist/components/shell/sidebar-context.d.ts +5 -0
- package/dist/components/shell/sidebar-context.js +6 -0
- package/dist/css/base.css +1 -1
- package/dist/css/button.css +1 -1
- package/dist/css/celebrate.css +1 -0
- package/dist/css/choice.css +1 -1
- package/dist/css/display.css +1 -1
- package/dist/css/feedback.css +1 -1
- package/dist/css/field.css +1 -1
- package/dist/css/groups.json +28 -8
- package/dist/css/picker.css +1 -1
- package/dist/css/print.css +1 -0
- package/dist/css/shell.css +1 -1
- package/dist/i18n/strings.d.ts +17 -0
- package/dist/i18n/strings.js +41 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +276 -267
- package/dist/styles.css +1 -1
- package/dist/utils/announcer.d.ts +21 -0
- package/dist/utils/announcer.js +30 -0
- package/package.json +3 -3
|
@@ -1,294 +1,297 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as N, jsx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { DialogTrigger as
|
|
5
|
-
import { ChevronDown as
|
|
6
|
-
import { cx as
|
|
7
|
-
import { Popover as
|
|
8
|
-
import { ListView as me, ListItem as
|
|
9
|
-
import { Tree as
|
|
10
|
-
import { Button as
|
|
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
|
|
13
|
-
const Oe =
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const [
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
var
|
|
20
|
-
const
|
|
21
|
-
let
|
|
22
|
-
for (const
|
|
23
|
-
if (
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
},
|
|
28
|
-
var
|
|
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
|
|
32
|
-
|
|
33
|
-
} else t.key === "ArrowLeft" &&
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
|
73
|
-
const
|
|
74
|
-
let u =
|
|
75
|
-
for (const
|
|
76
|
-
const m = u.find((
|
|
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
|
-
|
|
81
|
+
s.push(m), u = m.children || [];
|
|
79
82
|
}
|
|
80
|
-
return
|
|
83
|
+
return s;
|
|
81
84
|
}
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const [
|
|
86
|
-
const
|
|
87
|
-
return
|
|
88
|
-
var
|
|
89
|
-
(
|
|
90
|
-
}),
|
|
91
|
-
}, [u,
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
95
|
-
|
|
96
|
-
/* @__PURE__ */ N(
|
|
97
|
-
|
|
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(
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
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__ */
|
|
104
|
-
var
|
|
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: (
|
|
109
|
-
|
|
111
|
+
ref: (e) => {
|
|
112
|
+
S.current[n] = e;
|
|
110
113
|
},
|
|
111
114
|
className: "alea-cascader-col",
|
|
112
|
-
onKeyDown: (
|
|
113
|
-
var
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
(
|
|
117
|
-
var W,
|
|
118
|
-
return (
|
|
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__ */
|
|
126
|
+
/* @__PURE__ */ l(
|
|
124
127
|
ne,
|
|
125
128
|
{
|
|
126
|
-
"aria-label":
|
|
127
|
-
items:
|
|
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:
|
|
130
|
-
disabledKeys:
|
|
131
|
-
autoFocus:
|
|
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: (
|
|
134
|
-
var
|
|
135
|
-
const
|
|
136
|
-
(
|
|
137
|
-
var
|
|
138
|
-
return (
|
|
139
|
-
}, 0)) :
|
|
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: (
|
|
142
|
-
var
|
|
143
|
-
return /* @__PURE__ */ N(ce, { id:
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
(
|
|
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
|
-
|
|
153
|
+
P && n > 0 && /* @__PURE__ */ N(H, { size: "sm", variant: "ghost", onPress: () => p(r.slice(0, n)), children: [
|
|
151
154
|
"Choose “",
|
|
152
|
-
(
|
|
155
|
+
(g = j(u, r)[n - 1]) == null ? void 0 : g.label,
|
|
153
156
|
"”"
|
|
154
157
|
] })
|
|
155
158
|
]
|
|
156
159
|
},
|
|
157
|
-
|
|
160
|
+
n
|
|
158
161
|
);
|
|
159
162
|
}) }) })
|
|
160
163
|
] }),
|
|
161
|
-
|
|
164
|
+
D && /* @__PURE__ */ l("span", { className: "alea-description", children: D })
|
|
162
165
|
] });
|
|
163
166
|
});
|
|
164
|
-
function se(
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
}),
|
|
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
|
|
170
|
-
return
|
|
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
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
const [
|
|
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 =
|
|
180
|
+
return (x = c.get(f)) == null ? void 0 : x.label;
|
|
178
181
|
}).filter(Boolean).join(", ");
|
|
179
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
180
|
-
|
|
181
|
-
/* @__PURE__ */ N(
|
|
182
|
-
/* @__PURE__ */ N(
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
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__ */
|
|
187
|
-
|
|
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
|
|
190
|
-
selectionMode:
|
|
191
|
-
selectionBehavior:
|
|
192
|
-
selectedKeys:
|
|
193
|
-
defaultExpandedKeys:
|
|
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" ? [...
|
|
197
|
-
m === void 0 &&
|
|
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:
|
|
202
|
+
children: ie(u)
|
|
200
203
|
}
|
|
201
204
|
) }) })
|
|
202
205
|
] })
|
|
203
206
|
] });
|
|
204
|
-
}),
|
|
205
|
-
const
|
|
206
|
-
m ?? (m = [
|
|
207
|
-
const [
|
|
208
|
-
|
|
209
|
-
}, f =
|
|
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__ */
|
|
212
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
215
|
-
/* @__PURE__ */
|
|
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:
|
|
218
|
-
|
|
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__ */
|
|
221
|
-
|
|
222
|
-
}, children: /* @__PURE__ */
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
-
|
|
225
|
-
}, children: /* @__PURE__ */
|
|
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
|
-
|
|
230
|
+
p(1, x, k, T)
|
|
228
231
|
] });
|
|
229
|
-
}), Ke =
|
|
230
|
-
const
|
|
231
|
-
u === void 0 &&
|
|
232
|
-
},
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
},
|
|
236
|
-
var
|
|
237
|
-
if (!
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
const
|
|
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
|
|
243
|
-
(
|
|
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
|
-
|
|
248
|
-
}, [
|
|
249
|
-
|
|
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__ */
|
|
254
|
+
/* @__PURE__ */ l(
|
|
252
255
|
"textarea",
|
|
253
256
|
{
|
|
254
|
-
ref:
|
|
257
|
+
ref: T,
|
|
255
258
|
id: `${f}-ta`,
|
|
256
259
|
className: "alea-input alea-textarea",
|
|
257
|
-
rows:
|
|
258
|
-
placeholder:
|
|
259
|
-
value:
|
|
260
|
+
rows: P,
|
|
261
|
+
placeholder: R,
|
|
262
|
+
value: k,
|
|
260
263
|
"aria-autocomplete": "list",
|
|
261
264
|
"aria-controls": `${f}-list`,
|
|
262
|
-
"aria-activedescendant":
|
|
263
|
-
"aria-describedby":
|
|
264
|
-
onChange: (
|
|
265
|
-
|
|
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: (
|
|
268
|
-
|
|
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(() =>
|
|
273
|
+
onBlur: () => setTimeout(() => c(null), 120)
|
|
271
274
|
}
|
|
272
275
|
),
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
|
|
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__ */
|
|
279
|
+
/* @__PURE__ */ l("span", { children: a.label }),
|
|
277
280
|
/* @__PURE__ */ N("span", { className: "alea-option-desc", children: [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
+
$,
|
|
282
|
+
a.id,
|
|
283
|
+
a.description ? ` · ${a.description}` : ""
|
|
281
284
|
] })
|
|
282
|
-
] }) },
|
|
285
|
+
] }) }, a.id)) })
|
|
283
286
|
] }),
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
|
|
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
|
-
|
|
292
|
+
ze as Cascader,
|
|
290
293
|
Ke as Mentions,
|
|
291
294
|
Oe as OTPField,
|
|
292
|
-
|
|
293
|
-
|
|
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
|
+
};
|