@alea-design/ui 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/components/accordion/Accordion.js +29 -0
- package/dist/components/ai/AI.d.ts +5 -1
- package/dist/components/ai/AI.js +187 -0
- package/dist/components/app/AppParts.d.ts +16 -4
- package/dist/components/app/AppParts.js +134 -0
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.js +137 -0
- package/dist/components/button/Groups.d.ts +1 -1
- package/dist/components/button/Groups.js +112 -0
- package/dist/components/card/Card.d.ts +3 -2
- package/dist/components/card/Card.js +47 -0
- package/dist/components/chat/Chat.d.ts +4 -2
- package/dist/components/chat/Chat.js +275 -0
- package/dist/components/choice/Choice.js +69 -0
- package/dist/components/color/Color.d.ts +3 -3
- package/dist/components/color/Color.js +98 -0
- package/dist/components/combobox/Autocomplete.d.ts +5 -5
- package/dist/components/combobox/Autocomplete.js +126 -0
- package/dist/components/combobox/ComboBox.d.ts +4 -4
- package/dist/components/combobox/ComboBox.js +112 -0
- package/dist/components/combobox/Highlight.js +50 -0
- package/dist/components/command/CommandPalette.d.ts +10 -3
- package/dist/components/command/CommandPalette.js +56 -0
- package/dist/components/content/Content.d.ts +1 -1
- package/dist/components/content/Content.js +125 -0
- package/dist/components/data/Data.js +79 -0
- package/dist/components/date/Date.js +109 -0
- package/dist/components/display/Display.d.ts +5 -3
- package/dist/components/display/Display.js +89 -0
- package/dist/components/display/Display2.d.ts +3 -1
- package/dist/components/display/Display2.js +75 -0
- package/dist/components/emoji/EmojiPicker.js +52 -0
- package/dist/components/emoji/emoji-data.js +27 -0
- package/dist/components/extras/CodeSteps.d.ts +3 -0
- package/dist/components/extras/CodeSteps.js +19 -0
- package/dist/components/extras/Extras.d.ts +1 -1
- package/dist/components/extras/Extras.js +116 -0
- package/dist/components/feedback/Feedback.d.ts +11 -8
- package/dist/components/feedback/Feedback.js +185 -0
- package/dist/components/feedback/Spinner.js +18 -0
- package/dist/components/feedback/Status.d.ts +6 -2
- package/dist/components/feedback/Status.js +48 -0
- package/dist/components/field/Field.d.ts +1 -1
- package/dist/components/field/Field.js +187 -0
- package/dist/components/field/FieldLoading.d.ts +1 -1
- package/dist/components/field/FieldLoading.js +18 -0
- package/dist/components/filter/FilterBar.js +96 -0
- package/dist/components/form/Form.d.ts +5 -5
- package/dist/components/form/Form.js +53 -0
- package/dist/components/icon/Icon.d.ts +2 -2
- package/dist/components/icon/Icon.js +66 -0
- package/dist/components/icon/icon-cells.js +39 -0
- package/dist/components/icon/icon-contexts.d.ts +1 -1
- package/dist/components/icon/icon-contexts.js +38 -0
- package/dist/components/icon/icon-names.d.ts +1 -1
- package/dist/components/icon/icon-names.js +376 -0
- package/dist/components/layout/Bento.d.ts +1 -1
- package/dist/components/layout/Bento.js +38 -0
- package/dist/components/layout/Layout.d.ts +1 -1
- package/dist/components/layout/Layout.js +54 -0
- package/dist/components/layout/Layout2.d.ts +36 -6
- package/dist/components/layout/Layout2.js +105 -0
- package/dist/components/layout/Layout3.js +35 -0
- package/dist/components/layout/Responsive.d.ts +1 -1
- package/dist/components/layout/Responsive.js +32 -0
- package/dist/components/list/List.d.ts +3 -2
- package/dist/components/list/List.js +82 -0
- package/dist/components/list/Lists2.d.ts +6 -4
- package/dist/components/list/Lists2.js +60 -0
- package/dist/components/media/Media.d.ts +8 -4
- package/dist/components/media/Media.js +188 -0
- package/dist/components/menu/Menu.d.ts +23 -12
- package/dist/components/menu/Menu.js +68 -0
- package/dist/components/more/More.d.ts +7 -7
- package/dist/components/more/More.js +182 -0
- package/dist/components/navigation/Navbar.d.ts +1 -1
- package/dist/components/navigation/Navbar.js +27 -0
- package/dist/components/navigation/Navigation.js +121 -0
- package/dist/components/navigation/Navigation2.d.ts +6 -2
- package/dist/components/navigation/Navigation2.js +355 -0
- package/dist/components/overlay/Drawer.d.ts +11 -6
- package/dist/components/overlay/Drawer.js +39 -0
- package/dist/components/overlay/Modal.d.ts +6 -3
- package/dist/components/overlay/Modal.js +27 -0
- package/dist/components/overlay/Overlay.d.ts +14 -9
- package/dist/components/overlay/Overlay.js +76 -0
- package/dist/components/overlay/Sheet.d.ts +11 -5
- package/dist/components/overlay/Sheet.js +52 -0
- package/dist/components/page/Page.d.ts +5 -5
- package/dist/components/page/Page.js +132 -0
- package/dist/components/page/PageParts.d.ts +5 -5
- package/dist/components/page/PageParts.js +109 -0
- package/dist/components/picker/Picker.d.ts +11 -11
- package/dist/components/picker/Picker.js +294 -0
- package/dist/components/picker/Wheel.js +132 -0
- package/dist/components/rating/Rating.d.ts +2 -1
- package/dist/components/rating/Rating.js +66 -0
- package/dist/components/select/Select.d.ts +8 -6
- package/dist/components/select/Select.js +146 -0
- package/dist/components/shell/AppShell.d.ts +3 -3
- package/dist/components/shell/AppShell.js +56 -0
- package/dist/components/shell/AppSidebar.d.ts +5 -5
- package/dist/components/shell/AppSidebar.js +62 -0
- package/dist/components/slider/Slider.d.ts +2 -1
- package/dist/components/slider/Slider.js +36 -0
- package/dist/components/surface/Surface.d.ts +16 -0
- package/dist/components/surface/Surface.js +7 -0
- package/dist/components/table/Table.d.ts +4 -3
- package/dist/components/table/Table.js +58 -0
- package/dist/components/tabs/Tabs.d.ts +1 -0
- package/dist/components/tabs/Tabs.js +120 -0
- package/dist/components/theme/Theme.d.ts +11 -6
- package/dist/components/theme/Theme.js +186 -0
- package/dist/components/theme/lens.js +104 -0
- package/dist/components/tree/Tree.js +303 -0
- package/dist/components/typography/Typography.js +43 -0
- package/dist/components/upload/Upload.js +71 -0
- package/dist/components/work/Ops.js +24 -0
- package/dist/components/work/Work.d.ts +4 -2
- package/dist/components/work/Work.js +241 -0
- package/dist/css/accordion.css +1 -0
- package/dist/css/ai.css +1 -0
- package/dist/css/app.css +1 -0
- package/dist/css/base.css +1 -0
- package/dist/css/button.css +1 -0
- package/dist/css/card.css +1 -0
- package/dist/css/chat.css +1 -0
- package/dist/css/choice.css +1 -0
- package/dist/css/color.css +1 -0
- package/dist/css/combobox.css +1 -0
- package/dist/css/command.css +1 -0
- package/dist/css/content.css +1 -0
- package/dist/css/data.css +1 -0
- package/dist/css/date.css +1 -0
- package/dist/css/display.css +1 -0
- package/dist/css/emoji.css +1 -0
- package/dist/css/extras.css +1 -0
- package/dist/css/feedback.css +1 -0
- package/dist/css/field.css +1 -0
- package/dist/css/filter.css +1 -0
- package/dist/css/form.css +1 -0
- package/dist/css/groups.json +346 -0
- package/dist/css/icon.css +1 -0
- package/dist/css/layout.css +1 -0
- package/dist/css/list.css +1 -0
- package/dist/css/media.css +1 -0
- package/dist/css/menu.css +1 -0
- package/dist/css/more.css +1 -0
- package/dist/css/navigation.css +1 -0
- package/dist/css/overlay.css +1 -0
- package/dist/css/page.css +1 -0
- package/dist/css/picker.css +1 -0
- package/dist/css/rating.css +1 -0
- package/dist/css/select.css +1 -0
- package/dist/css/shell.css +1 -0
- package/dist/css/slider.css +1 -0
- package/dist/css/surface.css +1 -0
- package/dist/css/table.css +1 -0
- package/dist/css/tabs.css +1 -0
- package/dist/css/tree.css +1 -0
- package/dist/css/typography.css +1 -0
- package/dist/css/upload.css +1 -0
- package/dist/css/work.css +1 -0
- package/dist/i18n/strings.js +842 -0
- package/dist/index.d.ts +71 -70
- package/dist/index.js +398 -7436
- package/dist/styles.css +1 -1
- package/dist/utils/Blueprint.js +131 -0
- package/dist/utils/DotField.js +32 -0
- package/dist/utils/attr.d.ts +1 -1
- package/dist/utils/attr.js +18 -0
- package/dist/utils/blueprintScene.js +161 -0
- package/dist/utils/controlled.js +11 -0
- package/dist/utils/cx.js +11 -0
- package/dist/utils/inert.js +9 -0
- package/dist/utils/refs.d.ts +3 -0
- package/dist/utils/refs.js +11 -0
- package/dist/utils/responsive.js +12 -0
- package/dist/utils/scrollEdges.js +31 -0
- package/dist/utils/space.js +10 -0
- package/dist/utils/vocabulary.d.ts +6 -0
- package/dist/utils/vocabulary.js +17 -0
- package/package.json +12 -8
|
@@ -0,0 +1,294 @@
|
|
|
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";
|
|
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;
|
|
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;
|
|
29
|
+
if (t.key === "Backspace") {
|
|
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()
|
|
65
|
+
},
|
|
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 })
|
|
70
|
+
] });
|
|
71
|
+
});
|
|
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 === $);
|
|
77
|
+
if (!m) break;
|
|
78
|
+
n.push(m), u = m.children || [];
|
|
79
|
+
}
|
|
80
|
+
return n;
|
|
81
|
+
}
|
|
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);
|
|
98
|
+
}, 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
|
+
] }),
|
|
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;
|
|
105
|
+
return /* @__PURE__ */ N(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
ref: (r) => {
|
|
109
|
+
l.current[a] = r;
|
|
110
|
+
},
|
|
111
|
+
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();
|
|
119
|
+
}, 0));
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ s(
|
|
124
|
+
ne,
|
|
125
|
+
{
|
|
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,
|
|
128
|
+
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
|
+
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);
|
|
140
|
+
},
|
|
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 })
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
A && a > 0 && /* @__PURE__ */ N(G, { size: "sm", variant: "ghost", onPress: () => h(c.slice(0, a)), children: [
|
|
151
|
+
"Choose “",
|
|
152
|
+
(d = I(u, c)[a - 1]) == null ? void 0 : d.label,
|
|
153
|
+
"”"
|
|
154
|
+
] })
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
a
|
|
158
|
+
);
|
|
159
|
+
}) }) })
|
|
160
|
+
] }),
|
|
161
|
+
S && /* @__PURE__ */ s("span", { className: "alea-description", children: S })
|
|
162
|
+
] });
|
|
163
|
+
});
|
|
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;
|
|
168
|
+
}
|
|
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)));
|
|
171
|
+
}
|
|
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) => {
|
|
176
|
+
var x;
|
|
177
|
+
return (x = w.get(f)) == null ? void 0 : x.label;
|
|
178
|
+
}).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" })
|
|
185
|
+
] }),
|
|
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,
|
|
188
|
+
{
|
|
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),
|
|
194
|
+
autoFocus: !0,
|
|
195
|
+
onSelectionChange: (f) => {
|
|
196
|
+
const x = f === "all" ? [...w.keys()] : [...f];
|
|
197
|
+
m === void 0 && P(x), D == null || D(x), $ === "single" && p(!1);
|
|
198
|
+
},
|
|
199
|
+
children: le(u)
|
|
200
|
+
}
|
|
201
|
+
) }) })
|
|
202
|
+
] })
|
|
203
|
+
] });
|
|
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: [
|
|
210
|
+
/* @__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 })
|
|
213
|
+
] }),
|
|
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 }) })
|
|
216
|
+
] });
|
|
217
|
+
return /* @__PURE__ */ N("div", { ref: S, ...A, className: V("alea-transfer", D), children: [
|
|
218
|
+
h(0, f, z, P),
|
|
219
|
+
/* @__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, {}) })
|
|
226
|
+
] }),
|
|
227
|
+
h(1, x, y, k)
|
|
228
|
+
] });
|
|
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;
|
|
241
|
+
requestAnimationFrame(() => {
|
|
242
|
+
var F, q;
|
|
243
|
+
(F = k.current) == null || F.focus(), (q = k.current) == null || q.setSelectionRange(O, O);
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
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
|
+
/* @__PURE__ */ N("div", { className: "alea-mentions-wrap", children: [
|
|
251
|
+
/* @__PURE__ */ s(
|
|
252
|
+
"textarea",
|
|
253
|
+
{
|
|
254
|
+
ref: k,
|
|
255
|
+
id: `${f}-ta`,
|
|
256
|
+
className: "alea-input alea-textarea",
|
|
257
|
+
rows: A,
|
|
258
|
+
placeholder: D,
|
|
259
|
+
value: y,
|
|
260
|
+
"aria-autocomplete": "list",
|
|
261
|
+
"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);
|
|
266
|
+
},
|
|
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)));
|
|
269
|
+
},
|
|
270
|
+
onBlur: () => setTimeout(() => w(null), 120)
|
|
271
|
+
}
|
|
272
|
+
),
|
|
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);
|
|
275
|
+
}, children: /* @__PURE__ */ N("span", { className: "alea-option-text", children: [
|
|
276
|
+
/* @__PURE__ */ s("span", { children: e.label }),
|
|
277
|
+
/* @__PURE__ */ N("span", { className: "alea-option-desc", children: [
|
|
278
|
+
v,
|
|
279
|
+
e.id,
|
|
280
|
+
e.description ? ` · ${e.description}` : ""
|
|
281
|
+
] })
|
|
282
|
+
] }) }, e.id)) })
|
|
283
|
+
] }),
|
|
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 })
|
|
286
|
+
] });
|
|
287
|
+
});
|
|
288
|
+
export {
|
|
289
|
+
Ee as Cascader,
|
|
290
|
+
Ke as Mentions,
|
|
291
|
+
Oe as OTPField,
|
|
292
|
+
Ae as Transfer,
|
|
293
|
+
Re as TreeSelect
|
|
294
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as y, jsx as n, Fragment as O } from "react/jsx-runtime";
|
|
3
|
+
import { useState as W, useRef as D, useEffect as _ } from "react";
|
|
4
|
+
import { DialogTrigger as j, Button as z, Dialog as R } from "react-aria-components";
|
|
5
|
+
import { Clock as V } from "lucide-react";
|
|
6
|
+
import { cx as B } from "../../utils/cx.js";
|
|
7
|
+
import { useControlled as E } from "../../utils/controlled.js";
|
|
8
|
+
import { Popover as F } from "../overlay/Overlay.js";
|
|
9
|
+
import { SegmentedControl as L, Button as U } from "../button/Button.js";
|
|
10
|
+
import { useStrings as K } from "../../i18n/strings.js";
|
|
11
|
+
const q = 40;
|
|
12
|
+
function G({ col: t, value: b, onChange: d, rows: k, rowHeight: u }) {
|
|
13
|
+
const m = D(null), h = Math.max(0, t.items.findIndex((a) => a.value === b)), v = D(!1);
|
|
14
|
+
_(() => {
|
|
15
|
+
const a = m.current;
|
|
16
|
+
if (!a || v.current) return;
|
|
17
|
+
const o = h * u;
|
|
18
|
+
Math.abs(a.scrollTop - o) > 1 && a.scrollTo({ top: o, behavior: a.dataset.ready ? "smooth" : "auto" }), a.dataset.ready = "1";
|
|
19
|
+
}, [h, u]), _(() => {
|
|
20
|
+
const a = m.current;
|
|
21
|
+
if (!a) return;
|
|
22
|
+
let o = 0;
|
|
23
|
+
const s = () => {
|
|
24
|
+
const r = Math.min(t.items.length - 1, Math.max(0, Math.round(a.scrollTop / u)));
|
|
25
|
+
v.current = !1, t.items[r] && t.items[r].value !== b && d(t.items[r].value);
|
|
26
|
+
}, N = () => {
|
|
27
|
+
v.current = !0, clearTimeout(o), o = window.setTimeout(s, 120);
|
|
28
|
+
};
|
|
29
|
+
return a.addEventListener("scroll", N, { passive: !0 }), () => {
|
|
30
|
+
a.removeEventListener("scroll", N), clearTimeout(o);
|
|
31
|
+
};
|
|
32
|
+
}, [t.items, b, u, d]);
|
|
33
|
+
const p = (a) => {
|
|
34
|
+
let o = h + a;
|
|
35
|
+
t.loop ? o = (o + t.items.length) % t.items.length : o = Math.min(t.items.length - 1, Math.max(0, o)), d(t.items[o].value);
|
|
36
|
+
}, M = (a) => {
|
|
37
|
+
const o = { ArrowUp: () => p(-1), ArrowDown: () => p(1), PageUp: () => p(-5), PageDown: () => p(5), Home: () => d(t.items[0].value), End: () => d(t.items[t.items.length - 1].value) };
|
|
38
|
+
o[a.key] && (a.preventDefault(), o[a.key]());
|
|
39
|
+
}, i = t.items[h], l = Math.floor(k / 2) * u;
|
|
40
|
+
return /* @__PURE__ */ n(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
className: "alea-wheel-col",
|
|
44
|
+
role: "spinbutton",
|
|
45
|
+
tabIndex: 0,
|
|
46
|
+
"aria-label": t.label,
|
|
47
|
+
"aria-valuenow": h,
|
|
48
|
+
"aria-valuemin": 0,
|
|
49
|
+
"aria-valuemax": t.items.length - 1,
|
|
50
|
+
"aria-valuetext": (i == null ? void 0 : i.textValue) ?? (typeof (i == null ? void 0 : i.label) == "string" ? i.label : String((i == null ? void 0 : i.value) ?? "")),
|
|
51
|
+
onKeyDown: M,
|
|
52
|
+
children: /* @__PURE__ */ n("div", { ref: m, className: "alea-wheel-scroll", style: { height: k * u, paddingBlock: l, scrollPaddingBlock: l }, "aria-hidden": "true", children: t.items.map((a, o) => /* @__PURE__ */ n("div", { className: "alea-wheel-item", "data-selected": o === h || void 0, style: { height: u }, onClick: () => d(a.value), children: a.label }, String(a.value))) })
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
function J({ columns: t, value: b, defaultValue: d, onChange: k, visibleRows: u = 5, rowHeight: m = q, className: h, "aria-label": v }) {
|
|
57
|
+
const p = Object.fromEntries(t.map((l) => {
|
|
58
|
+
var a;
|
|
59
|
+
return [l.id, (a = l.items[0]) == null ? void 0 : a.value];
|
|
60
|
+
})), [M, i] = E(b, { ...p, ...d }, k);
|
|
61
|
+
return /* @__PURE__ */ y("div", { className: B("alea-wheel", h), role: "group", "aria-label": v, style: { "--alea-wheel-row": `${m}px` }, children: [
|
|
62
|
+
/* @__PURE__ */ n("span", { className: "alea-wheel-band", "aria-hidden": "true" }),
|
|
63
|
+
t.map((l) => /* @__PURE__ */ n(G, { col: l, value: M[l.id], rows: u, rowHeight: m, onChange: (a) => i({ ...M, [l.id]: a }) }, l.id))
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
const g = (t) => String(t).padStart(2, "0");
|
|
67
|
+
function le({ label: t, value: b, defaultValue: d = null, onChange: k, hourCycle: u, minuteStep: m = 5, input: h = "dial", description: v, isDisabled: p, className: M }) {
|
|
68
|
+
var C;
|
|
69
|
+
const i = K(), l = u ?? ((C = new Intl.DateTimeFormat(void 0, { hour: "numeric" }).resolvedOptions().hourCycle) != null && C.startsWith("h1") ? 12 : 24), [a, o] = E(b, d, k), [s, N] = W("hour"), r = a ?? { hour: 9, minute: 0 }, w = r.hour >= 12, $ = a ? l === 12 ? `${(r.hour + 11) % 12 + 1}:${g(r.minute)} ${w ? "PM" : "AM"}` : `${g(r.hour)}:${g(r.minute)}` : "", I = (c) => o({ hour: l === 12 ? c % 12 + (w ? 12 : 0) : c, minute: r.minute }), A = s === "hour" ? l === 12 ? Array.from({ length: 12 }, (c, e) => e + 1) : Array.from({ length: 24 }, (c, e) => e) : Array.from({ length: 60 / m }, (c, e) => e * m), T = s === "hour" ? l === 12 ? (r.hour + 11) % 12 + 1 : r.hour : r.minute, S = (c, e, f = !1) => {
|
|
70
|
+
const x = c / e * 2 * Math.PI - Math.PI / 2, P = f ? 30 : 42;
|
|
71
|
+
return { left: `${50 + P * Math.cos(x)}%`, top: `${50 + P * Math.sin(x)}%` };
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ y("div", { className: B("alea-field alea-time-picker", M), "data-disabled": p || void 0, children: [
|
|
74
|
+
t && /* @__PURE__ */ n("span", { className: "alea-label", "aria-hidden": "true", children: t }),
|
|
75
|
+
/* @__PURE__ */ y(j, { onOpenChange: (c) => c && N("hour"), children: [
|
|
76
|
+
/* @__PURE__ */ y(z, { className: "alea-input-wrap alea-time-trigger alea-focus-ring", isDisabled: p, "aria-label": `${typeof t == "string" ? t + ", " : ""}${$ || i.pickTime}`, children: [
|
|
77
|
+
/* @__PURE__ */ n("span", { className: "alea-input alea-time-value", "data-placeholder": !a || void 0, children: $ || "--:--" }),
|
|
78
|
+
/* @__PURE__ */ n("span", { className: "alea-input-affix", "data-side": "end", "aria-hidden": "true", children: /* @__PURE__ */ n(V, { size: 16 }) })
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ n(F, { placement: "bottom start", className: "alea-popover alea-time-popover", children: /* @__PURE__ */ n(R, { className: "alea-time-dialog", "aria-label": i.pickTime, children: ({ close: c }) => /* @__PURE__ */ y(O, { children: [
|
|
81
|
+
/* @__PURE__ */ y("div", { className: "alea-time-head", children: [
|
|
82
|
+
/* @__PURE__ */ n("button", { type: "button", className: "alea-time-part alea-focus-ring", "data-active": s === "hour" || void 0, onClick: () => N("hour"), children: l === 12 ? (r.hour + 11) % 12 + 1 : g(r.hour) }),
|
|
83
|
+
/* @__PURE__ */ n("span", { "aria-hidden": "true", children: ":" }),
|
|
84
|
+
/* @__PURE__ */ n("button", { type: "button", className: "alea-time-part alea-focus-ring", "data-active": s === "minute" || void 0, onClick: () => N("minute"), children: g(r.minute) }),
|
|
85
|
+
l === 12 && /* @__PURE__ */ n(L, { size: "sm", "aria-label": "AM or PM", items: [{ id: "am", label: "AM" }, { id: "pm", label: "PM" }], value: w ? "pm" : "am", onChange: (e) => o({ hour: r.hour % 12 + (e === "pm" ? 12 : 0), minute: r.minute }) })
|
|
86
|
+
] }),
|
|
87
|
+
h === "dial" ? /* @__PURE__ */ y("div", { className: "alea-clock", role: "group", "aria-label": s === "hour" ? i.hours : i.minutes, children: [
|
|
88
|
+
/* @__PURE__ */ n("span", { className: "alea-clock-center", "aria-hidden": "true" }),
|
|
89
|
+
/* @__PURE__ */ n("span", { className: "alea-clock-hand", "aria-hidden": "true", style: { transform: `rotate(${s === "hour" ? T % 12 / 12 * 360 : r.minute / 60 * 360}deg)`, height: l === 24 && s === "hour" && (r.hour === 0 || r.hour > 12) ? "30%" : "42%" } }),
|
|
90
|
+
A.map((e, f) => {
|
|
91
|
+
const x = l === 24 && s === "hour" && (e === 0 || e > 12), P = s === "hour" ? (l === 24 && x ? e === 0 ? 0 : e - 12 : e) % 12 : f;
|
|
92
|
+
return /* @__PURE__ */ n(
|
|
93
|
+
"button",
|
|
94
|
+
{
|
|
95
|
+
type: "button",
|
|
96
|
+
className: "alea-clock-num alea-focus-ring",
|
|
97
|
+
"data-inner": x || void 0,
|
|
98
|
+
"data-selected": e === T || void 0,
|
|
99
|
+
style: S(P, s === "hour" ? 12 : A.length, x),
|
|
100
|
+
"aria-pressed": e === T,
|
|
101
|
+
"aria-label": s === "hour" ? i.hourN(e) : i.minuteN(e),
|
|
102
|
+
onClick: () => {
|
|
103
|
+
s === "hour" ? (I(e), N("minute")) : o({ hour: r.hour, minute: e });
|
|
104
|
+
},
|
|
105
|
+
children: s === "minute" ? g(e) : e
|
|
106
|
+
},
|
|
107
|
+
e
|
|
108
|
+
);
|
|
109
|
+
})
|
|
110
|
+
] }) : /* @__PURE__ */ n(
|
|
111
|
+
J,
|
|
112
|
+
{
|
|
113
|
+
"aria-label": i.pickTime,
|
|
114
|
+
visibleRows: 5,
|
|
115
|
+
columns: [
|
|
116
|
+
{ id: "h", label: i.hours, loop: !0, items: (l === 12 ? Array.from({ length: 12 }, (e, f) => f + 1) : Array.from({ length: 24 }, (e, f) => f)).map((e) => ({ value: e, label: l === 12 ? e : g(e) })) },
|
|
117
|
+
{ id: "m", label: i.minutes, loop: !0, items: Array.from({ length: 60 / m }, (e, f) => f * m).map((e) => ({ value: e, label: g(e) })) }
|
|
118
|
+
],
|
|
119
|
+
value: { h: l === 12 ? (r.hour + 11) % 12 + 1 : r.hour, m: r.minute },
|
|
120
|
+
onChange: (e) => o({ hour: l === 12 ? Number(e.h) % 12 + (w ? 12 : 0) : Number(e.h), minute: Number(e.m) })
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ n("div", { className: "alea-time-foot", children: /* @__PURE__ */ n(U, { size: "sm", onPress: c, children: i.done }) })
|
|
124
|
+
] }) }) })
|
|
125
|
+
] }),
|
|
126
|
+
v && /* @__PURE__ */ n("span", { className: "alea-description", children: v })
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
le as TimePicker,
|
|
131
|
+
J as WheelPicker
|
|
132
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Tone } from '../display/Display.js';
|
|
1
2
|
import { type ReactNode } from 'react';
|
|
2
3
|
export interface RatingProps {
|
|
3
4
|
/** Name of the rating ("Rate this plugin"). */
|
|
@@ -17,7 +18,7 @@ export interface RatingProps {
|
|
|
17
18
|
/** The icon: a star by default, or any icon (a heart, a flame). */
|
|
18
19
|
icon?: ReactNode;
|
|
19
20
|
/** The color of the filled icons: warning (amber, default), accent, danger or success. */
|
|
20
|
-
tone?:
|
|
21
|
+
tone?: Tone;
|
|
21
22
|
/** Shows the number after the icons ("4.5"), or the value's words with "label". */
|
|
22
23
|
showValue?: boolean | 'label';
|
|
23
24
|
/** Shows the value without letting people change it. */
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as i, jsxs as o } from "react/jsx-runtime";
|
|
3
|
+
import { RadioGroup as q, Label as w, Radio as B } from "react-aria-components";
|
|
4
|
+
import { Star as D } from "lucide-react";
|
|
5
|
+
import { useState as R } from "react";
|
|
6
|
+
import { cx as j } from "../../utils/cx.js";
|
|
7
|
+
import { ratingIcon as x } from "../icon/icon-contexts.js";
|
|
8
|
+
import { useStrings as E } from "../../i18n/strings.js";
|
|
9
|
+
function z({ fill: s, icon: c, tone: f }) {
|
|
10
|
+
const n = c ?? /* @__PURE__ */ i(D, {});
|
|
11
|
+
return /* @__PURE__ */ o("span", { className: "alea-rating-glyph", "aria-hidden": "true", children: [
|
|
12
|
+
/* @__PURE__ */ i("span", { className: "alea-rating-base", ...x("empty"), children: n }),
|
|
13
|
+
s > 0 && /* @__PURE__ */ i("span", { className: "alea-rating-fill", ...x("filled", f), "data-half": s < 1 || void 0, children: n })
|
|
14
|
+
] });
|
|
15
|
+
}
|
|
16
|
+
function X({ label: s, value: c, defaultValue: f = 0, onChange: n, max: l = 5, allowHalf: p, allowClear: h = !0, icon: u, tone: m, showValue: v, isReadOnly: G, isDisabled: I, size: N = "md", getValueLabel: d, className: y }) {
|
|
17
|
+
const g = E();
|
|
18
|
+
d ?? (d = g.starsN);
|
|
19
|
+
const [F, M] = R(f), e = c ?? F, [P, S] = R(0), b = P || e, A = (a) => b >= a + 1 ? 1 : b >= a + 0.5 ? 0.5 : 0, _ = (a) => {
|
|
20
|
+
const r = h && a === e ? 0 : a;
|
|
21
|
+
c === void 0 && M(r), n == null || n(r);
|
|
22
|
+
}, O = v ? /* @__PURE__ */ i("span", { className: "alea-rating-value", children: v === "label" ? e ? d(e) : "" : ((a) => Number.isInteger(a) ? String(a) : a.toFixed(1))(e) }) : null;
|
|
23
|
+
if (G)
|
|
24
|
+
return /* @__PURE__ */ o("span", { role: "img", "aria-label": g.outOf(d(e), l), className: j("alea-rating", y), "data-size": N, "data-tone": m, "data-readonly": !0, children: [
|
|
25
|
+
Array.from({ length: l }, (a, r) => /* @__PURE__ */ i(z, { fill: A(r), icon: u, tone: m }, r)),
|
|
26
|
+
O
|
|
27
|
+
] });
|
|
28
|
+
const k = p ? Array.from({ length: l * 2 }, (a, r) => (r + 1) / 2) : Array.from({ length: l }, (a, r) => r + 1);
|
|
29
|
+
return /* @__PURE__ */ o(
|
|
30
|
+
q,
|
|
31
|
+
{
|
|
32
|
+
value: e ? String(e) : null,
|
|
33
|
+
onChange: (a) => _(Number(a)),
|
|
34
|
+
isDisabled: I,
|
|
35
|
+
orientation: "horizontal",
|
|
36
|
+
className: j("alea-rating-group", y),
|
|
37
|
+
"aria-label": s ? void 0 : g.ratingLabel,
|
|
38
|
+
children: [
|
|
39
|
+
s && /* @__PURE__ */ i(w, { className: "alea-label", children: s }),
|
|
40
|
+
/* @__PURE__ */ o("div", { className: "alea-rating", "data-size": N, "data-tone": m, "data-half": p || void 0, onMouseLeave: () => S(0), children: [
|
|
41
|
+
Array.from({ length: l }, (a, r) => /* @__PURE__ */ o("span", { className: "alea-rating-cell", children: [
|
|
42
|
+
/* @__PURE__ */ i(z, { fill: A(r), icon: u, tone: m }),
|
|
43
|
+
k.filter((t) => t > r && t <= r + 1).map((t) => /* @__PURE__ */ i(
|
|
44
|
+
B,
|
|
45
|
+
{
|
|
46
|
+
value: String(t),
|
|
47
|
+
"aria-label": d(t),
|
|
48
|
+
className: "alea-rating-item",
|
|
49
|
+
"data-part": p ? t === r + 0.5 ? "left" : "right" : "whole",
|
|
50
|
+
onHoverStart: () => S(t),
|
|
51
|
+
onPress: () => {
|
|
52
|
+
t === e && h && _(t);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
t
|
|
56
|
+
))
|
|
57
|
+
] }, r)),
|
|
58
|
+
O
|
|
59
|
+
] })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
X as Rating
|
|
66
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type SelectProps as RACSelectProps, type ListBoxProps as RACListBoxProps, type ListBoxItemProps, type ValidationResult, type Key } from 'react-aria-components';
|
|
2
|
+
import { type SectionProps, type SelectProps as RACSelectProps, type ListBoxProps as RACListBoxProps, type ListBoxItemProps, type ValidationResult, type Key } from 'react-aria-components';
|
|
3
3
|
import type { MotionProp } from '@alea-design/motion';
|
|
4
|
-
import { type FieldSize, type FieldVariant } from '../field/Field';
|
|
5
|
-
import type { Responsive } from '../../utils/responsive';
|
|
6
|
-
import { type MatchStyle } from '../combobox/Highlight';
|
|
4
|
+
import { type FieldSize, type FieldVariant } from '../field/Field.js';
|
|
5
|
+
import type { Responsive } from '../../utils/responsive.js';
|
|
6
|
+
import { type MatchStyle } from '../combobox/Highlight.js';
|
|
7
7
|
export interface SelectOption {
|
|
8
8
|
id: Key;
|
|
9
9
|
label: ReactNode;
|
|
@@ -74,13 +74,15 @@ export interface SelectItemProps extends Omit<ListBoxItemProps, 'children'> {
|
|
|
74
74
|
}
|
|
75
75
|
/** An option in a Select (or any listbox). Marks the part that matches matchQuery, with a mark element. */
|
|
76
76
|
export declare function SelectItem({ children, description, icon, matchQuery, matchStyle, className, textValue, ...props }: SelectItemProps): import("react").JSX.Element;
|
|
77
|
-
export interface SelectSectionProps {
|
|
77
|
+
export interface SelectSectionProps extends Omit<SectionProps<object>, 'children' | 'title' | 'className'> {
|
|
78
|
+
/** Extra class names for the section. */
|
|
79
|
+
className?: string;
|
|
78
80
|
/** The section heading. */
|
|
79
81
|
title: ReactNode;
|
|
80
82
|
children: ReactNode;
|
|
81
83
|
}
|
|
82
84
|
/** A titled group of options. */
|
|
83
|
-
export declare
|
|
85
|
+
export declare const SelectSection: import("react").ForwardRefExoticComponent<SelectSectionProps & import("react").RefAttributes<HTMLElement>>;
|
|
84
86
|
export interface ListBoxProps<T extends object = SelectOption> extends Omit<RACListBoxProps<T>, 'children'> {
|
|
85
87
|
/** The options as data, or SelectItem and SelectSection children. */
|
|
86
88
|
items?: Iterable<T>;
|