@alea-design/ui 0.10.9 → 0.10.11
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.js +25 -24
- package/dist/components/combobox/ComboBox.d.ts +3 -1
- package/dist/components/combobox/ComboBox.js +68 -65
- package/dist/components/more/More.d.ts +5 -1
- package/dist/components/more/More.js +108 -105
- package/dist/components/overlay/Overlay.d.ts +6 -0
- package/dist/components/overlay/Overlay.js +79 -64
- package/dist/components/select/Select.d.ts +3 -1
- package/dist/components/select/Select.js +104 -103
- package/dist/components/select/recent.d.ts +9 -0
- package/dist/components/select/recent.js +17 -0
- package/dist/css/groups.json +4 -3
- package/dist/css/more.css +1 -1
- package/dist/css/overlay.css +1 -1
- package/dist/css/select.css +1 -1
- package/dist/i18n/strings.d.ts +2 -0
- package/dist/i18n/strings.js +4 -0
- package/dist/styles.css +1 -1
- package/package.json +3 -3
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useState as
|
|
2
|
+
import { jsx as a, jsxs as u, Fragment as T } from "react/jsx-runtime";
|
|
3
|
+
import { useState as x, useRef as D, useEffect as z, useId as j, forwardRef as P } from "react";
|
|
4
4
|
import { Disclosure as A, Button as I, DisclosurePanel as K } from "react-aria-components";
|
|
5
|
-
import { X as
|
|
5
|
+
import { X as q, ChevronDown as O, Pencil as F, Check as M } from "lucide-react";
|
|
6
6
|
import { cx as m } from "../../utils/cx.js";
|
|
7
7
|
import { formatDecimal as H } from "../../utils/decimal.js";
|
|
8
8
|
import { Spinner as L } from "../feedback/Spinner.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
import { Button as R } from "../button/Button.js";
|
|
10
|
+
import { useStrings as C } from "../../i18n/strings.js";
|
|
11
|
+
import { inertProps as V } from "../../utils/inert.js";
|
|
12
|
+
const ta = P(function({ target: n = "main", children: t, className: s, ...c }, i) {
|
|
13
|
+
const o = C();
|
|
14
|
+
return t ?? (t = o.skipToContent), /* @__PURE__ */ a("a", { ref: i, href: `#${n}`, ...c, className: m("alea-skip-link", s), children: t });
|
|
15
|
+
}), la = P(function({ children: n, as: t = "span", className: s, ...c }, i) {
|
|
16
|
+
return /* @__PURE__ */ a(t, { ref: i, ...c, className: m("alea-visually-hidden", s), children: n });
|
|
16
17
|
});
|
|
17
|
-
function
|
|
18
|
-
return /* @__PURE__ */ u(A, { isExpanded:
|
|
18
|
+
function na({ title: e, children: n, isExpanded: t, defaultExpanded: s, onExpandedChange: c, className: i }) {
|
|
19
|
+
return /* @__PURE__ */ u(A, { isExpanded: t, defaultExpanded: s, onExpandedChange: c, className: m("alea-collapsible", i), children: [
|
|
19
20
|
/* @__PURE__ */ u(I, { slot: "trigger", className: "alea-collapsible-trigger alea-focus-ring", children: [
|
|
20
21
|
/* @__PURE__ */ a(O, { size: 16, "aria-hidden": "true", className: "alea-collapsible-chevron" }),
|
|
21
22
|
e
|
|
@@ -23,161 +24,163 @@ function la({ title: e, children: n, isExpanded: l, defaultExpanded: s, onExpand
|
|
|
23
24
|
/* @__PURE__ */ a(K, { className: "alea-collapsible-panel", children: /* @__PURE__ */ a("div", { className: "alea-collapsible-content", children: n }) })
|
|
24
25
|
] });
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
const p =
|
|
27
|
+
function sa({ value: e, defaultValue: n = "", onSave: t, label: s, placeholder: c = "Empty", multiline: i, className: o }) {
|
|
28
|
+
const p = C(), [b, h] = x(n), l = e ?? b, [r, f] = x(!1), [g, N] = x(l), [w, y] = x(!1), $ = D(null), v = D(null);
|
|
28
29
|
z(() => {
|
|
29
|
-
var d,
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
const
|
|
33
|
-
if ((
|
|
34
|
-
|
|
30
|
+
var d, B;
|
|
31
|
+
r && ((d = $.current) == null || d.focus(), (B = $.current) == null || B.select());
|
|
32
|
+
}, [r]);
|
|
33
|
+
const k = () => {
|
|
34
|
+
if ((t == null ? void 0 : t(g)) === !1) {
|
|
35
|
+
y(!0);
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
|
-
e === void 0 && h(
|
|
38
|
+
e === void 0 && h(g), f(!1), y(!1), requestAnimationFrame(() => {
|
|
38
39
|
var d;
|
|
39
|
-
return (d =
|
|
40
|
+
return (d = v.current) == null ? void 0 : d.focus();
|
|
40
41
|
});
|
|
41
42
|
}, S = () => {
|
|
42
|
-
|
|
43
|
+
f(!1), y(!1), requestAnimationFrame(() => {
|
|
43
44
|
var d;
|
|
44
|
-
return (d =
|
|
45
|
+
return (d = v.current) == null ? void 0 : d.focus();
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
|
-
if (!
|
|
48
|
-
return /* @__PURE__ */ u("button", { ref:
|
|
49
|
-
|
|
48
|
+
if (!r)
|
|
49
|
+
return /* @__PURE__ */ u("button", { ref: v, type: "button", className: m("alea-editable alea-focus-ring", o), "data-empty": !l || void 0, "aria-label": `${s}: ${l || c}. Edit`, onClick: () => {
|
|
50
|
+
N(l), f(!0);
|
|
50
51
|
}, children: [
|
|
51
|
-
/* @__PURE__ */ a("span", { className: "alea-editable-text", children:
|
|
52
|
+
/* @__PURE__ */ a("span", { className: "alea-editable-text", children: l || c }),
|
|
52
53
|
/* @__PURE__ */ a(F, { size: 14, "aria-hidden": "true", className: "alea-editable-icon" })
|
|
53
54
|
] });
|
|
54
|
-
const E =
|
|
55
|
+
const E = i ? "textarea" : "input";
|
|
55
56
|
return /* @__PURE__ */ u("span", { className: m("alea-editable-edit", o), children: [
|
|
56
57
|
/* @__PURE__ */ a(
|
|
57
58
|
E,
|
|
58
59
|
{
|
|
59
|
-
ref:
|
|
60
|
-
className:
|
|
60
|
+
ref: $,
|
|
61
|
+
className: i ? "alea-textarea" : "alea-input alea-editable-input",
|
|
61
62
|
"aria-label": s,
|
|
62
|
-
"aria-invalid":
|
|
63
|
-
value:
|
|
64
|
-
rows:
|
|
63
|
+
"aria-invalid": w || void 0,
|
|
64
|
+
value: g,
|
|
65
|
+
rows: i ? 3 : void 0,
|
|
65
66
|
onChange: (d) => {
|
|
66
|
-
|
|
67
|
+
N(d.target.value), y(!1);
|
|
67
68
|
},
|
|
68
69
|
onKeyDown: (d) => {
|
|
69
|
-
d.key === "Escape" && (d.preventDefault(), S()), d.key === "Enter" && (!
|
|
70
|
+
d.key === "Escape" && (d.preventDefault(), S()), d.key === "Enter" && (!i || d.metaKey || d.ctrlKey) && (d.preventDefault(), k());
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
),
|
|
73
|
-
/* @__PURE__ */ a("button", { type: "button", className: "alea-editable-btn alea-focus-ring", "aria-label": p.save, onClick:
|
|
74
|
-
/* @__PURE__ */ a("button", { type: "button", className: "alea-editable-btn alea-focus-ring", "aria-label": p.cancel, onClick: S, children: /* @__PURE__ */ a(
|
|
74
|
+
/* @__PURE__ */ a("button", { type: "button", className: "alea-editable-btn alea-focus-ring", "aria-label": p.save, onClick: k, children: /* @__PURE__ */ a(M, { size: 14 }) }),
|
|
75
|
+
/* @__PURE__ */ a("button", { type: "button", className: "alea-editable-btn alea-focus-ring", "aria-label": p.cancel, onClick: S, children: /* @__PURE__ */ a(q, { size: 14 }) })
|
|
75
76
|
] });
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
return /* @__PURE__ */ a(T, { children: H(e,
|
|
78
|
+
function ra({ value: e, format: n, locale: t }) {
|
|
79
|
+
return /* @__PURE__ */ a(T, { children: H(e, t, n) });
|
|
79
80
|
}
|
|
80
|
-
const
|
|
81
|
-
function
|
|
82
|
-
const
|
|
81
|
+
const X = (e) => String(e).padStart(2, "0");
|
|
82
|
+
function ia({ to: e, label: n, onEnd: t, showDays: s, className: c }) {
|
|
83
|
+
const i = C(), o = typeof e == "number" ? e : e.getTime(), [p, b] = x(() => Date.now()), h = D(!1);
|
|
83
84
|
z(() => {
|
|
84
|
-
const
|
|
85
|
-
return () => clearInterval(
|
|
85
|
+
const v = setInterval(() => b(Date.now()), 1e3);
|
|
86
|
+
return () => clearInterval(v);
|
|
86
87
|
}, []);
|
|
87
|
-
const
|
|
88
|
+
const l = Math.max(0, o - p);
|
|
88
89
|
z(() => {
|
|
89
|
-
|
|
90
|
-
}, [
|
|
91
|
-
const
|
|
90
|
+
l === 0 && !h.current && (h.current = !0, t == null || t());
|
|
91
|
+
}, [l, t]);
|
|
92
|
+
const r = Math.floor(l / 864e5), f = Math.floor(l / 36e5) % 24, g = Math.floor(l / 6e4) % 60, N = Math.floor(l / 1e3) % 60, w = s ?? r > 0, y = [...w ? [[r, "d"]] : [], [w ? f : f + r * 24, "h"], [g, "m"], [N, "s"]], $ = `${w ? `${r} days, ` : ""}${w ? f : f + r * 24} hours, ${g} minutes`;
|
|
92
93
|
return /* @__PURE__ */ u("div", { className: m("alea-stat alea-countdown", c), children: [
|
|
93
94
|
/* @__PURE__ */ a("span", { className: "alea-stat-label", children: n }),
|
|
94
|
-
/* @__PURE__ */ a("span", { className: "alea-stat-value alea-countdown-value", "aria-hidden": "true", children:
|
|
95
|
-
/* @__PURE__ */ a("b", { children:
|
|
96
|
-
/* @__PURE__ */ a("small", { children:
|
|
97
|
-
] },
|
|
98
|
-
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", "aria-live": "polite", children:
|
|
95
|
+
/* @__PURE__ */ a("span", { className: "alea-stat-value alea-countdown-value", "aria-hidden": "true", children: y.map(([v, k]) => /* @__PURE__ */ u("span", { children: [
|
|
96
|
+
/* @__PURE__ */ a("b", { children: k === "d" ? v : X(v) }),
|
|
97
|
+
/* @__PURE__ */ a("small", { children: k })
|
|
98
|
+
] }, k)) }),
|
|
99
|
+
/* @__PURE__ */ a("span", { className: "alea-visually-hidden", "aria-live": "polite", children: l === 0 ? i.ended : $ })
|
|
99
100
|
] });
|
|
100
101
|
}
|
|
101
|
-
function
|
|
102
|
+
function ca({ tone: e = "neutral", children: n, pulse: t, className: s }) {
|
|
102
103
|
return /* @__PURE__ */ u("span", { className: m("alea-status", s), "data-tone": e, children: [
|
|
103
|
-
/* @__PURE__ */ a("span", { className: "alea-status-dot", "data-pulse":
|
|
104
|
+
/* @__PURE__ */ a("span", { className: "alea-status-dot", "data-pulse": t || void 0, "aria-hidden": "true" }),
|
|
104
105
|
n
|
|
105
106
|
] });
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
const p = /* @__PURE__ */ a("span", { className: "alea-swatch", "data-shape": s, role: "img", "aria-label": n, style: { width:
|
|
109
|
-
return c ? /* @__PURE__ */ u("span", { className: m("alea-swatch-wrap",
|
|
108
|
+
function oa({ color: e, label: n, size: t = 28, shape: s = "circle", showValue: c, className: i, style: o }) {
|
|
109
|
+
const p = /* @__PURE__ */ a("span", { className: "alea-swatch", "data-shape": s, role: "img", "aria-label": n, style: { width: t, height: t, "--alea-swatch": e, ...o } });
|
|
110
|
+
return c ? /* @__PURE__ */ u("span", { className: m("alea-swatch-wrap", i), "data-labeled": !0, children: [
|
|
110
111
|
p,
|
|
111
112
|
/* @__PURE__ */ a("span", { className: "alea-swatch-name", "aria-hidden": "true", children: n }),
|
|
112
113
|
/* @__PURE__ */ a("code", { className: "alea-swatch-value", children: e })
|
|
113
|
-
] }) : /* @__PURE__ */ a("span", { className: m("alea-swatch-wrap",
|
|
114
|
+
] }) : /* @__PURE__ */ a("span", { className: m("alea-swatch-wrap", i), children: p });
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
-
const
|
|
117
|
-
return
|
|
118
|
-
/* @__PURE__ */ a("div", { className: "alea-loading-content", ...
|
|
119
|
-
e && /* @__PURE__ */ a("div", { className: "alea-loading-overlay", "data-blur": s || void 0, children: /* @__PURE__ */ a(L, { size: "md", "aria-label":
|
|
116
|
+
function da({ isLoading: e, children: n, label: t, blur: s = !0, className: c }) {
|
|
117
|
+
const i = C();
|
|
118
|
+
return t ?? (t = i.loading), /* @__PURE__ */ u("div", { className: m("alea-loading", c), "aria-busy": e || void 0, children: [
|
|
119
|
+
/* @__PURE__ */ a("div", { className: "alea-loading-content", ...V(e), children: n }),
|
|
120
|
+
e && /* @__PURE__ */ a("div", { className: "alea-loading-overlay", "data-blur": s || void 0, children: /* @__PURE__ */ a(L, { size: "md", "aria-label": t }) })
|
|
120
121
|
] });
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
-
const o = j(), p = n ?? e.reduce((
|
|
124
|
-
return /* @__PURE__ */ u("div", { className: m("alea-progress-seg",
|
|
123
|
+
function ua({ segments: e, total: n, label: t, valueFormat: s = (o) => String(o), showLegend: c = !0, className: i }) {
|
|
124
|
+
const o = j(), p = n ?? e.reduce((l, r) => l + r.value, 0), b = (l, r) => l.color || `var(--alea-chart-${r % 8 + 1})`, h = e.reduce((l, r) => l + r.value, 0);
|
|
125
|
+
return /* @__PURE__ */ u("div", { className: m("alea-progress-seg", i), children: [
|
|
125
126
|
/* @__PURE__ */ u("div", { className: "alea-progress-seg-head", children: [
|
|
126
|
-
/* @__PURE__ */ a("span", { id: o, className: "alea-label", children:
|
|
127
|
+
/* @__PURE__ */ a("span", { id: o, className: "alea-label", children: t }),
|
|
127
128
|
/* @__PURE__ */ u("span", { className: "alea-progress-seg-total", children: [
|
|
128
129
|
s(h),
|
|
129
130
|
" of ",
|
|
130
131
|
s(p)
|
|
131
132
|
] })
|
|
132
133
|
] }),
|
|
133
|
-
/* @__PURE__ */ a("div", { className: "alea-progress-seg-bar", role: "meter", "aria-labelledby": o, "aria-valuemin": 0, "aria-valuemax": p, "aria-valuenow": h, "aria-valuetext": e.map((
|
|
134
|
-
c && /* @__PURE__ */ a("ul", { className: "alea-progress-seg-legend", "aria-hidden": "true", children: e.map((
|
|
135
|
-
/* @__PURE__ */ a("span", { style: { background:
|
|
136
|
-
|
|
137
|
-
/* @__PURE__ */ a("b", { children: s(
|
|
138
|
-
] },
|
|
134
|
+
/* @__PURE__ */ a("div", { className: "alea-progress-seg-bar", role: "meter", "aria-labelledby": o, "aria-valuemin": 0, "aria-valuemax": p, "aria-valuenow": h, "aria-valuetext": e.map((l) => `${l.label} ${s(l.value)}`).join(", "), children: e.map((l, r) => /* @__PURE__ */ a("span", { className: "alea-progress-seg-part", style: { width: `${l.value / (p || 1) * 100}%`, background: b(l, r), animationDelay: `${r * 60}ms` } }, l.label)) }),
|
|
135
|
+
c && /* @__PURE__ */ a("ul", { className: "alea-progress-seg-legend", "aria-hidden": "true", children: e.map((l, r) => /* @__PURE__ */ u("li", { children: [
|
|
136
|
+
/* @__PURE__ */ a("span", { style: { background: b(l, r) } }),
|
|
137
|
+
l.label,
|
|
138
|
+
/* @__PURE__ */ a("b", { children: s(l.value) })
|
|
139
|
+
] }, l.label)) })
|
|
139
140
|
] });
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function ma({ children: e, cite: n, source: t, className: s }) {
|
|
142
143
|
return /* @__PURE__ */ u("figure", { className: m("alea-blockquote", s), children: [
|
|
143
|
-
/* @__PURE__ */ a("blockquote", { cite:
|
|
144
|
+
/* @__PURE__ */ a("blockquote", { cite: t, children: e }),
|
|
144
145
|
n && /* @__PURE__ */ a("figcaption", { children: n })
|
|
145
146
|
] });
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
-
return /* @__PURE__ */ a(n === "number" ? "ol" : "ul", { className: m("alea-text-list", s), "data-marker": n, "data-spacing":
|
|
149
|
-
n === "check" && /* @__PURE__ */ a(
|
|
150
|
-
/* @__PURE__ */ a("span", { children:
|
|
148
|
+
function pa({ items: e, marker: n = "bullet", spacing: t = "md", className: s }) {
|
|
149
|
+
return /* @__PURE__ */ a(n === "number" ? "ol" : "ul", { className: m("alea-text-list", s), "data-marker": n, "data-spacing": t, children: e.map((i, o) => /* @__PURE__ */ u("li", { children: [
|
|
150
|
+
n === "check" && /* @__PURE__ */ a(M, { size: 16, "aria-hidden": "true", className: "alea-text-list-check" }),
|
|
151
|
+
/* @__PURE__ */ a("span", { children: i })
|
|
151
152
|
] }, o)) });
|
|
152
153
|
}
|
|
153
|
-
function
|
|
154
|
-
return /* @__PURE__ */ a("div", { className: m("alea-prose alea-markdown",
|
|
154
|
+
function ha({ children: e, size: n = "base", className: t }) {
|
|
155
|
+
return /* @__PURE__ */ a("div", { className: m("alea-prose alea-markdown", t), "data-size": n, children: e });
|
|
155
156
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
-
o ?? (o =
|
|
159
|
-
const [
|
|
160
|
-
return
|
|
157
|
+
function fa({ children: e, tone: n, size: t, action: s, onDismiss: c, className: i, "aria-label": o, role: p, variant: b, onDiscard: h, "data-print": l }) {
|
|
158
|
+
const r = C();
|
|
159
|
+
o ?? (o = r.announcement);
|
|
160
|
+
const [f, g] = x(!0), N = b === "restored";
|
|
161
|
+
return n ?? (n = N ? "info" : "accent"), t ?? (t = N ? "sm" : "md"), p ?? (p = N ? "status" : "region"), N && h && !s && (s = /* @__PURE__ */ a(R, { size: "sm", variant: "ghost", onPress: () => {
|
|
162
|
+
g(!1), h();
|
|
163
|
+
}, children: r.discard })), f ? /* @__PURE__ */ u("div", { className: m("alea-banner", i), "data-tone": n, "data-size": t === "sm" ? t : void 0, "data-dismissible": c ? !0 : void 0, "data-print": l, "data-variant": b, role: p, "aria-label": o, children: [
|
|
161
164
|
/* @__PURE__ */ a("div", { className: "alea-banner-text", children: e }),
|
|
162
165
|
s && /* @__PURE__ */ a("span", { className: "alea-banner-action", children: s }),
|
|
163
|
-
c && /* @__PURE__ */ a("button", { type: "button", className: "alea-banner-close alea-focus-ring", "aria-label":
|
|
164
|
-
|
|
165
|
-
}, children: /* @__PURE__ */ a(
|
|
166
|
+
c && /* @__PURE__ */ a("button", { type: "button", className: "alea-banner-close alea-focus-ring", "aria-label": r.dismissAnnouncement, onClick: () => {
|
|
167
|
+
g(!1), c();
|
|
168
|
+
}, children: /* @__PURE__ */ a(q, { size: 16 }) })
|
|
166
169
|
] }) : null;
|
|
167
170
|
}
|
|
168
171
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
172
|
+
fa as Banner,
|
|
173
|
+
ma as Blockquote,
|
|
174
|
+
na as Collapsible,
|
|
175
|
+
oa as ColorSwatch,
|
|
176
|
+
ia as Countdown,
|
|
177
|
+
sa as Editable,
|
|
178
|
+
ra as FormattedNumber,
|
|
179
|
+
pa as List,
|
|
180
|
+
da as LoadingOverlay,
|
|
181
|
+
ua as ProgressSegments,
|
|
182
|
+
ha as Prose,
|
|
183
|
+
ta as SkipLink,
|
|
184
|
+
ca as Status,
|
|
185
|
+
la as VisuallyHidden
|
|
183
186
|
};
|
|
@@ -56,6 +56,12 @@ export interface DialogProps extends Omit<RACDialogProps, 'children'> {
|
|
|
56
56
|
footer?: ReactNode | ((opts: {
|
|
57
57
|
close: () => void;
|
|
58
58
|
}) => ReactNode);
|
|
59
|
+
/** A second primary action next to the footer buttons ("Save and new"). Ctrl+Enter (Command+Enter on a Mac) runs it from anywhere in the dialog, and the shortcut is written under the buttons. */
|
|
60
|
+
secondaryAction?: {
|
|
61
|
+
label: ReactNode;
|
|
62
|
+
onPress: () => void;
|
|
63
|
+
isDisabled?: boolean;
|
|
64
|
+
};
|
|
59
65
|
/** Hides the X button. */
|
|
60
66
|
hideClose?: boolean;
|
|
61
67
|
/** Size of the title: md (24 px display, default) or sm (16 px, semibold). Same as on Modal. */
|
|
@@ -1,81 +1,96 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as a, jsxs as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Dialog as
|
|
5
|
-
import { DialogTrigger as
|
|
6
|
-
import { X as
|
|
7
|
-
import { withMotionStyle as
|
|
8
|
-
import { cx as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { useStrings as
|
|
11
|
-
import { renamedValue as
|
|
12
|
-
import { surfaceAttrs as
|
|
13
|
-
import { useInitialFocus as
|
|
14
|
-
import { useModalRef as
|
|
15
|
-
const
|
|
16
|
-
return /* @__PURE__ */
|
|
17
|
-
o && /* @__PURE__ */ a(
|
|
18
|
-
|
|
2
|
+
import { jsx as a, jsxs as c, Fragment as B } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as v, useId as F, useState as S, useEffect as j } from "react";
|
|
4
|
+
import { Dialog as I, Heading as $, ModalOverlay as O, Modal as H, Popover as V, OverlayArrow as L, Button as X, Tooltip as q, TooltipTrigger as G } from "react-aria-components";
|
|
5
|
+
import { DialogTrigger as ya } from "react-aria-components";
|
|
6
|
+
import { X as R } from "lucide-react";
|
|
7
|
+
import { withMotionStyle as P } from "@alea-design/motion";
|
|
8
|
+
import { cx as E, withBase as w } from "../../utils/cx.js";
|
|
9
|
+
import { Button as D, IconButton as J } from "../button/Button.js";
|
|
10
|
+
import { useStrings as M } from "../../i18n/strings.js";
|
|
11
|
+
import { renamedValue as Q } from "../../utils/vocabulary.js";
|
|
12
|
+
import { surfaceAttrs as K } from "../surface/Surface.js";
|
|
13
|
+
import { useInitialFocus as U } from "../../utils/initialFocus.js";
|
|
14
|
+
import { useModalRef as W, useInModalLayer as Y, ModalLayer as Z } from "../../utils/modalLayer.js";
|
|
15
|
+
const ma = v(function({ children: l, showArrow: o, className: i, offset: r = 8, motion: e, style: t, size: n, surface: d, radius: m, ...s }, f) {
|
|
16
|
+
return /* @__PURE__ */ c(V, { ...s, ref: f, offset: o ? 12 : r, "data-size": n, ...K({ surface: d, radius: m }), className: w("alea-popover", i), style: P(t, e), children: [
|
|
17
|
+
o && /* @__PURE__ */ a(L, { className: "alea-arrow", children: /* @__PURE__ */ a("svg", { width: 12, height: 12, viewBox: "0 0 12 12", children: /* @__PURE__ */ a("path", { d: "M0 0 L6 6 L12 0" }) }) }),
|
|
18
|
+
l
|
|
19
19
|
] });
|
|
20
|
-
}),
|
|
21
|
-
const m =
|
|
22
|
-
return /* @__PURE__ */ a(
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
}), ua = v(function({ title: l, description: o, footer: i, showClose: r, children: e, className: t, ...n }, d) {
|
|
21
|
+
const m = M();
|
|
22
|
+
return /* @__PURE__ */ a(I, { ...n, ref: d, className: E("alea-popover-dialog", t), children: (s) => /* @__PURE__ */ c(B, { children: [
|
|
23
|
+
(l || r) && /* @__PURE__ */ c("div", { className: "alea-popover-head", children: [
|
|
24
|
+
l && /* @__PURE__ */ a($, { slot: "title", className: "alea-popover-title", children: l }),
|
|
25
|
+
r && /* @__PURE__ */ a(X, { className: "alea-popover-close alea-focus-ring", "aria-label": m.close, onPress: s.close, children: /* @__PURE__ */ a(R, { size: 16, "aria-hidden": "true" }) })
|
|
26
26
|
] }),
|
|
27
27
|
o && /* @__PURE__ */ a("p", { className: "alea-popover-desc", children: o }),
|
|
28
|
-
typeof
|
|
29
|
-
|
|
28
|
+
typeof e == "function" ? e(s) : e,
|
|
29
|
+
i && /* @__PURE__ */ a("div", { className: "alea-popover-footer", children: typeof i == "function" ? i(s.close) : i })
|
|
30
30
|
] }) });
|
|
31
31
|
});
|
|
32
|
-
function
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
!
|
|
35
|
-
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
|
|
32
|
+
function fa({ children: p, title: l, shortcut: o, hideArrow: i, className: r, offset: e = 8, motion: t, style: n, ...d }) {
|
|
33
|
+
return /* @__PURE__ */ c(q, { ...d, offset: e, className: w("alea-tooltip", r), "data-rich": l ? !0 : void 0, style: P(n, t), children: [
|
|
34
|
+
!i && /* @__PURE__ */ a(L, { className: "alea-arrow alea-tooltip-arrow", children: /* @__PURE__ */ a("svg", { width: 8, height: 8, viewBox: "0 0 8 8", children: /* @__PURE__ */ a("path", { d: "M0 0 L4 4 L8 0" }) }) }),
|
|
35
|
+
l && /* @__PURE__ */ a("span", { className: "alea-tooltip-title", children: l }),
|
|
36
|
+
/* @__PURE__ */ c("span", { className: "alea-tooltip-text", children: [
|
|
37
|
+
p,
|
|
38
38
|
o && /* @__PURE__ */ a("kbd", { className: "alea-tooltip-kbd", children: o })
|
|
39
39
|
] })
|
|
40
40
|
] });
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return /* @__PURE__ */ a(
|
|
42
|
+
function ga({ delay: p = 600, closeDelay: l = 200, ...o }) {
|
|
43
|
+
return /* @__PURE__ */ a(G, { ...o, delay: p, closeDelay: l });
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
return
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
45
|
+
const _ = () => typeof navigator < "u" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent), A = v(function({ title: l, description: o, children: i, footer: r, secondaryAction: e, hideClose: t, titleSize: n = "md", className: d, ...m }, s) {
|
|
46
|
+
const f = M(), N = W(s, Y()), h = F(), [y, b] = S(!1);
|
|
47
|
+
return j(() => {
|
|
48
|
+
b(_());
|
|
49
|
+
}, []), /* @__PURE__ */ a(I, { ...m, ref: N, className: E("alea-dialog", d), children: ({ close: g }) => (
|
|
50
|
+
// display: contents keeps the dialog's own layout; the wrapper only listens for Ctrl+Enter or Command+Enter from any field inside (plain Enter stays with the field)
|
|
51
|
+
/* @__PURE__ */ c("div", { style: { display: "contents" }, onKeyDown: e ? (u) => {
|
|
52
|
+
!e.isDisabled && u.key === "Enter" && (u.ctrlKey || u.metaKey) && !u.defaultPrevented && (u.preventDefault(), e.onPress());
|
|
53
|
+
} : void 0, children: [
|
|
54
|
+
(l || !t) && /* @__PURE__ */ c("div", { className: "alea-dialog-head", children: [
|
|
55
|
+
l && /* @__PURE__ */ a($, { slot: "title", className: "alea-dialog-title", "data-size": n === "sm" ? "sm" : void 0, children: l }),
|
|
56
|
+
!t && /* @__PURE__ */ a(J, { "aria-label": f.close, size: "sm", variant: "ghost", onPress: g, className: "alea-dialog-x", children: /* @__PURE__ */ a(R, {}) })
|
|
57
|
+
] }),
|
|
58
|
+
o && /* @__PURE__ */ a("p", { className: "alea-dialog-description", children: o }),
|
|
59
|
+
i && /* @__PURE__ */ a("div", { className: "alea-dialog-body", children: typeof i == "function" ? i({ close: g }) : i }),
|
|
60
|
+
(r || e) && /* @__PURE__ */ c("div", { className: "alea-dialog-footer", children: [
|
|
61
|
+
typeof r == "function" ? r({ close: g }) : r,
|
|
62
|
+
e && /* @__PURE__ */ a(D, { variant: "primary", isDisabled: e.isDisabled, onPress: e.onPress, "aria-describedby": h, children: e.label }),
|
|
63
|
+
e && /* @__PURE__ */ c("p", { id: h, className: "alea-dialog-shortcut", children: [
|
|
64
|
+
/* @__PURE__ */ a("kbd", { children: y ? "⌘" : "Ctrl" }),
|
|
65
|
+
"+",
|
|
66
|
+
/* @__PURE__ */ a("kbd", { children: "Enter" })
|
|
67
|
+
] })
|
|
68
|
+
] })
|
|
69
|
+
] })
|
|
70
|
+
) });
|
|
56
71
|
});
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
return /* @__PURE__ */ a(O, { ...s, isDismissable:
|
|
72
|
+
function C({ children: p, size: l = "md", fullscreenBelow: o, className: i, isDismissable: r = !0, motion: e, backdrop: t, initialFocus: n, surface: d, radius: m, ...s }) {
|
|
73
|
+
const f = U(n);
|
|
74
|
+
return /* @__PURE__ */ a(O, { ...s, isDismissable: r, className: w("alea-modal-overlay", i), "data-backdrop": t, "data-fullscreen-below": o, children: /* @__PURE__ */ a(H, { ref: f, className: "alea-modal", "data-size": l, "data-fullscreen-below": o, ...K({ surface: d, radius: m }), style: P(void 0, e), children: /* @__PURE__ */ a(Z, { value: !0, children: p }) }) });
|
|
60
75
|
}
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
n ?? (n =
|
|
64
|
-
const
|
|
65
|
-
return /* @__PURE__ */ a(
|
|
66
|
-
/* @__PURE__ */ a(
|
|
67
|
-
/* @__PURE__ */ a(
|
|
68
|
-
await (s == null ? void 0 : s()),
|
|
76
|
+
const ha = v(function({ motion: l, backdrop: o, initialFocus: i, titleSize: r, title: e, children: t, confirmLabel: n, cancelLabel: d, tone: m, onConfirm: s, isOpen: f, defaultOpen: N, onOpenChange: h, className: y, style: b }, g) {
|
|
77
|
+
const u = F(), T = Q("AlertDialog", "tone", m, { default: "neutral" }) ?? "neutral", x = M();
|
|
78
|
+
n ?? (n = x.confirm), d ?? (d = x.cancel);
|
|
79
|
+
const k = i ?? (T === "danger" ? "cancel" : "confirm");
|
|
80
|
+
return /* @__PURE__ */ a(C, { isOpen: f, defaultOpen: N, onOpenChange: h, isDismissable: !1, size: "sm", motion: l, backdrop: o, children: /* @__PURE__ */ a(A, { ref: g, className: y, style: b, role: "alertdialog", "aria-describedby": t ? u : void 0, title: e, titleSize: r, hideClose: !0, footer: ({ close: z }) => /* @__PURE__ */ c(B, { children: [
|
|
81
|
+
/* @__PURE__ */ a(D, { variant: "ghost", autoFocus: k === "cancel", onPress: z, children: d }),
|
|
82
|
+
/* @__PURE__ */ a(D, { variant: T === "danger" ? "danger" : "primary", autoFocus: k === "confirm", onPress: async () => {
|
|
83
|
+
await (s == null ? void 0 : s()), z();
|
|
69
84
|
}, children: n })
|
|
70
|
-
] }), children: t ? /* @__PURE__ */ a("div", { id:
|
|
85
|
+
] }), children: t ? /* @__PURE__ */ a("div", { id: u, style: { display: "contents" }, children: t }) : null }) });
|
|
71
86
|
});
|
|
72
87
|
export {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
ha as AlertDialog,
|
|
89
|
+
A as Dialog,
|
|
90
|
+
C as DialogModal,
|
|
91
|
+
ya as DialogTrigger,
|
|
92
|
+
ma as Popover,
|
|
93
|
+
ua as PopoverDialog,
|
|
94
|
+
fa as Tooltip,
|
|
95
|
+
ga as TooltipTrigger
|
|
81
96
|
};
|
|
@@ -48,6 +48,8 @@ export interface SelectProps<T extends object = SelectOption> extends Omit<RACSe
|
|
|
48
48
|
emptyText?: ReactNode;
|
|
49
49
|
/** Content under the list inside the popover, like an "Add option" button. */
|
|
50
50
|
footer?: ReactNode;
|
|
51
|
+
/** Ids of the options used last (at most 5), shown first under a "Recent" heading, then the rest without repeating them. Needs the options as items; it is not used together with virtualized. */
|
|
52
|
+
recent?: Array<string | number>;
|
|
51
53
|
/** Where the selected check shows: end (default) or start. */
|
|
52
54
|
checkPosition?: 'start' | 'end';
|
|
53
55
|
/** With selectionMode="multiple": how many tags show in the trigger before "+N". Default 2. */
|
|
@@ -60,7 +62,7 @@ export interface SelectProps<T extends object = SelectOption> extends Omit<RACSe
|
|
|
60
62
|
motion?: MotionProp;
|
|
61
63
|
}
|
|
62
64
|
/** Pick one or several options from a list in a popover; type to jump, arrows to move. Search, clear, tags, groups, a footer and virtualization when you need them. */
|
|
63
|
-
export declare function Select<T extends object = SelectOption>({ motion, label, description, errorMessage, warningMessage, showOptional, items, children, size, variant, labelPosition, prefix, isClearable, searchable, highlightMatch, matchStyle, isLoading, emptyText, footer, checkPosition, maxTags, renderValue, virtualized, className, placeholder, ...props }: SelectProps<T>): import("react").JSX.Element;
|
|
65
|
+
export declare function Select<T extends object = SelectOption>({ recent, motion, label, description, errorMessage, warningMessage, showOptional, items, children, size, variant, labelPosition, prefix, isClearable, searchable, highlightMatch, matchStyle, isLoading, emptyText, footer, checkPosition, maxTags, renderValue, virtualized, className, placeholder, ...props }: SelectProps<T>): import("react").JSX.Element;
|
|
64
66
|
export interface SelectItemProps extends Omit<ListBoxItemProps, 'children'> {
|
|
65
67
|
children: ReactNode;
|
|
66
68
|
/** A second line under the option. */
|