@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.
@@ -1,21 +1,22 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as a, Fragment as T } from "react/jsx-runtime";
3
- import { useState as k, useRef as D, useEffect as z, useId as j, forwardRef as M } from "react";
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 P, ChevronDown as O, Pencil as F, Check as B } from "lucide-react";
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 { useStrings as $ } from "../../i18n/strings.js";
10
- import { inertProps as R } from "../../utils/inert.js";
11
- const aa = M(function({ target: n = "main", children: l, className: s, ...c }, r) {
12
- const o = $();
13
- return l ?? (l = o.skipToContent), /* @__PURE__ */ a("a", { ref: r, href: `#${n}`, ...c, className: m("alea-skip-link", s), children: l });
14
- }), ea = M(function({ children: n, as: l = "span", className: s, ...c }, r) {
15
- return /* @__PURE__ */ a(l, { ref: r, ...c, className: m("alea-visually-hidden", s), children: n });
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 la({ title: e, children: n, isExpanded: l, defaultExpanded: s, onExpandedChange: c, className: r }) {
18
- return /* @__PURE__ */ u(A, { isExpanded: l, defaultExpanded: s, onExpandedChange: c, className: m("alea-collapsible", r), children: [
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 ta({ value: e, defaultValue: n = "", onSave: l, label: s, placeholder: c = "Empty", multiline: r, className: o }) {
27
- const p = $(), [f, h] = k(n), t = e ?? f, [i, b] = k(!1), [N, C] = k(t), [v, w] = k(!1), x = D(null), g = D(null);
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, q;
30
- i && ((d = x.current) == null || d.focus(), (q = x.current) == null || q.select());
31
- }, [i]);
32
- const y = () => {
33
- if ((l == null ? void 0 : l(N)) === !1) {
34
- w(!0);
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(N), b(!1), w(!1), requestAnimationFrame(() => {
38
+ e === void 0 && h(g), f(!1), y(!1), requestAnimationFrame(() => {
38
39
  var d;
39
- return (d = g.current) == null ? void 0 : d.focus();
40
+ return (d = v.current) == null ? void 0 : d.focus();
40
41
  });
41
42
  }, S = () => {
42
- b(!1), w(!1), requestAnimationFrame(() => {
43
+ f(!1), y(!1), requestAnimationFrame(() => {
43
44
  var d;
44
- return (d = g.current) == null ? void 0 : d.focus();
45
+ return (d = v.current) == null ? void 0 : d.focus();
45
46
  });
46
47
  };
47
- if (!i)
48
- return /* @__PURE__ */ u("button", { ref: g, type: "button", className: m("alea-editable alea-focus-ring", o), "data-empty": !t || void 0, "aria-label": `${s}: ${t || c}. Edit`, onClick: () => {
49
- C(t), b(!0);
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: t || c }),
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 = r ? "textarea" : "input";
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: x,
60
- className: r ? "alea-textarea" : "alea-input alea-editable-input",
60
+ ref: $,
61
+ className: i ? "alea-textarea" : "alea-input alea-editable-input",
61
62
  "aria-label": s,
62
- "aria-invalid": v || void 0,
63
- value: N,
64
- rows: r ? 3 : void 0,
63
+ "aria-invalid": w || void 0,
64
+ value: g,
65
+ rows: i ? 3 : void 0,
65
66
  onChange: (d) => {
66
- C(d.target.value), w(!1);
67
+ N(d.target.value), y(!1);
67
68
  },
68
69
  onKeyDown: (d) => {
69
- d.key === "Escape" && (d.preventDefault(), S()), d.key === "Enter" && (!r || d.metaKey || d.ctrlKey) && (d.preventDefault(), y());
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: y, children: /* @__PURE__ */ a(B, { size: 14 }) }),
74
- /* @__PURE__ */ a("button", { type: "button", className: "alea-editable-btn alea-focus-ring", "aria-label": p.cancel, onClick: S, children: /* @__PURE__ */ a(P, { size: 14 }) })
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 na({ value: e, format: n, locale: l }) {
78
- return /* @__PURE__ */ a(T, { children: H(e, l, n) });
78
+ function ra({ value: e, format: n, locale: t }) {
79
+ return /* @__PURE__ */ a(T, { children: H(e, t, n) });
79
80
  }
80
- const V = (e) => String(e).padStart(2, "0");
81
- function sa({ to: e, label: n, onEnd: l, showDays: s, className: c }) {
82
- const r = $(), o = typeof e == "number" ? e : e.getTime(), [p, f] = k(() => Date.now()), h = D(!1);
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 g = setInterval(() => f(Date.now()), 1e3);
85
- return () => clearInterval(g);
85
+ const v = setInterval(() => b(Date.now()), 1e3);
86
+ return () => clearInterval(v);
86
87
  }, []);
87
- const t = Math.max(0, o - p);
88
+ const l = Math.max(0, o - p);
88
89
  z(() => {
89
- t === 0 && !h.current && (h.current = !0, l == null || l());
90
- }, [t, l]);
91
- const i = Math.floor(t / 864e5), b = Math.floor(t / 36e5) % 24, N = Math.floor(t / 6e4) % 60, C = Math.floor(t / 1e3) % 60, v = s ?? i > 0, w = [...v ? [[i, "d"]] : [], [v ? b : b + i * 24, "h"], [N, "m"], [C, "s"]], x = `${v ? `${i} days, ` : ""}${v ? b : b + i * 24} hours, ${N} minutes`;
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: w.map(([g, y]) => /* @__PURE__ */ u("span", { children: [
95
- /* @__PURE__ */ a("b", { children: y === "d" ? g : V(g) }),
96
- /* @__PURE__ */ a("small", { children: y })
97
- ] }, y)) }),
98
- /* @__PURE__ */ a("span", { className: "alea-visually-hidden", "aria-live": "polite", children: t === 0 ? r.ended : x })
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 ra({ tone: e = "neutral", children: n, pulse: l, className: s }) {
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": l || void 0, "aria-hidden": "true" }),
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 ia({ color: e, label: n, size: l = 28, shape: s = "circle", showValue: c, className: r, style: o }) {
108
- const p = /* @__PURE__ */ a("span", { className: "alea-swatch", "data-shape": s, role: "img", "aria-label": n, style: { width: l, height: l, "--alea-swatch": e, ...o } });
109
- return c ? /* @__PURE__ */ u("span", { className: m("alea-swatch-wrap", r), "data-labeled": !0, children: [
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", r), children: p });
114
+ ] }) : /* @__PURE__ */ a("span", { className: m("alea-swatch-wrap", i), children: p });
114
115
  }
115
- function ca({ isLoading: e, children: n, label: l, blur: s = !0, className: c }) {
116
- const r = $();
117
- return l ?? (l = r.loading), /* @__PURE__ */ u("div", { className: m("alea-loading", c), "aria-busy": e || void 0, children: [
118
- /* @__PURE__ */ a("div", { className: "alea-loading-content", ...R(e), children: n }),
119
- e && /* @__PURE__ */ a("div", { className: "alea-loading-overlay", "data-blur": s || void 0, children: /* @__PURE__ */ a(L, { size: "md", "aria-label": l }) })
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 oa({ segments: e, total: n, label: l, valueFormat: s = (o) => String(o), showLegend: c = !0, className: r }) {
123
- const o = j(), p = n ?? e.reduce((t, i) => t + i.value, 0), f = (t, i) => t.color || `var(--alea-chart-${i % 8 + 1})`, h = e.reduce((t, i) => t + i.value, 0);
124
- return /* @__PURE__ */ u("div", { className: m("alea-progress-seg", r), children: [
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: l }),
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((t) => `${t.label} ${s(t.value)}`).join(", "), children: e.map((t, i) => /* @__PURE__ */ a("span", { className: "alea-progress-seg-part", style: { width: `${t.value / (p || 1) * 100}%`, background: f(t, i), animationDelay: `${i * 60}ms` } }, t.label)) }),
134
- c && /* @__PURE__ */ a("ul", { className: "alea-progress-seg-legend", "aria-hidden": "true", children: e.map((t, i) => /* @__PURE__ */ u("li", { children: [
135
- /* @__PURE__ */ a("span", { style: { background: f(t, i) } }),
136
- t.label,
137
- /* @__PURE__ */ a("b", { children: s(t.value) })
138
- ] }, t.label)) })
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 da({ children: e, cite: n, source: l, className: s }) {
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: l, children: e }),
144
+ /* @__PURE__ */ a("blockquote", { cite: t, children: e }),
144
145
  n && /* @__PURE__ */ a("figcaption", { children: n })
145
146
  ] });
146
147
  }
147
- function ua({ items: e, marker: n = "bullet", spacing: l = "md", className: s }) {
148
- return /* @__PURE__ */ a(n === "number" ? "ol" : "ul", { className: m("alea-text-list", s), "data-marker": n, "data-spacing": l, children: e.map((r, o) => /* @__PURE__ */ u("li", { children: [
149
- n === "check" && /* @__PURE__ */ a(B, { size: 16, "aria-hidden": "true", className: "alea-text-list-check" }),
150
- /* @__PURE__ */ a("span", { children: r })
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 ma({ children: e, size: n = "base", className: l }) {
154
- return /* @__PURE__ */ a("div", { className: m("alea-prose alea-markdown", l), "data-size": n, children: e });
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 pa({ children: e, tone: n = "accent", size: l = "md", action: s, onDismiss: c, className: r, "aria-label": o, role: p = "region", "data-print": f }) {
157
- const h = $();
158
- o ?? (o = h.announcement);
159
- const [t, i] = k(!0);
160
- return t ? /* @__PURE__ */ u("div", { className: m("alea-banner", r), "data-tone": n, "data-size": l === "sm" ? l : void 0, "data-dismissible": c ? !0 : void 0, "data-print": f, role: p, "aria-label": o, children: [
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": h.dismissAnnouncement, onClick: () => {
164
- i(!1), c();
165
- }, children: /* @__PURE__ */ a(P, { size: 16 }) })
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
- pa as Banner,
170
- da as Blockquote,
171
- la as Collapsible,
172
- ia as ColorSwatch,
173
- sa as Countdown,
174
- ta as Editable,
175
- na as FormattedNumber,
176
- ua as List,
177
- ca as LoadingOverlay,
178
- oa as ProgressSegments,
179
- ma as Prose,
180
- aa as SkipLink,
181
- ra as Status,
182
- ea as VisuallyHidden
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 p, Fragment as h } from "react/jsx-runtime";
3
- import { forwardRef as f, useId as j } from "react";
4
- import { Dialog as M, Heading as z, ModalOverlay as O, Modal as S, Popover as H, OverlayArrow as B, Button as V, Tooltip as X, TooltipTrigger as q } from "react-aria-components";
5
- import { DialogTrigger as ha } from "react-aria-components";
6
- import { X as F } from "lucide-react";
7
- import { withMotionStyle as v } from "@alea-design/motion";
8
- import { cx as I, withBase as N } from "../../utils/cx.js";
9
- import { Button as x, IconButton as E } from "../button/Button.js";
10
- import { useStrings as y } from "../../i18n/strings.js";
11
- import { renamedValue as G } from "../../utils/vocabulary.js";
12
- import { surfaceAttrs as $ } from "../surface/Surface.js";
13
- import { useInitialFocus as J } from "../../utils/initialFocus.js";
14
- import { useModalRef as K, useInModalLayer as Q, ModalLayer as U } from "../../utils/modalLayer.js";
15
- const ca = f(function({ children: e, showArrow: o, className: l, offset: i = 8, motion: r, style: t, size: n, surface: c, radius: m, ...s }, u) {
16
- return /* @__PURE__ */ p(H, { ...s, ref: u, offset: o ? 12 : i, "data-size": n, ...$({ surface: c, radius: m }), className: N("alea-popover", l), style: v(t, r), children: [
17
- o && /* @__PURE__ */ a(B, { 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
- e
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
- }), da = f(function({ title: e, description: o, footer: l, showClose: i, children: r, className: t, ...n }, c) {
21
- const m = y();
22
- return /* @__PURE__ */ a(M, { ...n, ref: c, className: I("alea-popover-dialog", t), children: (s) => /* @__PURE__ */ p(h, { children: [
23
- (e || i) && /* @__PURE__ */ p("div", { className: "alea-popover-head", children: [
24
- e && /* @__PURE__ */ a(z, { slot: "title", className: "alea-popover-title", children: e }),
25
- i && /* @__PURE__ */ a(V, { className: "alea-popover-close alea-focus-ring", "aria-label": m.close, onPress: s.close, children: /* @__PURE__ */ a(F, { size: 16, "aria-hidden": "true" }) })
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 r == "function" ? r(s) : r,
29
- l && /* @__PURE__ */ a("div", { className: "alea-popover-footer", children: typeof l == "function" ? l(s.close) : l })
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 ma({ children: d, title: e, shortcut: o, hideArrow: l, className: i, offset: r = 8, motion: t, style: n, ...c }) {
33
- return /* @__PURE__ */ p(X, { ...c, offset: r, className: N("alea-tooltip", i), "data-rich": e ? !0 : void 0, style: v(n, t), children: [
34
- !l && /* @__PURE__ */ a(B, { 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
- e && /* @__PURE__ */ a("span", { className: "alea-tooltip-title", children: e }),
36
- /* @__PURE__ */ p("span", { className: "alea-tooltip-text", children: [
37
- d,
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 pa({ delay: d = 600, closeDelay: e = 200, ...o }) {
43
- return /* @__PURE__ */ a(q, { ...o, delay: d, closeDelay: e });
42
+ function ga({ delay: p = 600, closeDelay: l = 200, ...o }) {
43
+ return /* @__PURE__ */ a(G, { ...o, delay: p, closeDelay: l });
44
44
  }
45
- const W = f(function({ title: e, description: o, children: l, footer: i, hideClose: r, titleSize: t = "md", className: n, ...c }, m) {
46
- const s = y(), u = K(m, Q());
47
- return /* @__PURE__ */ a(M, { ...c, ref: u, className: I("alea-dialog", n), children: ({ close: g }) => /* @__PURE__ */ p(h, { children: [
48
- (e || !r) && /* @__PURE__ */ p("div", { className: "alea-dialog-head", children: [
49
- e && /* @__PURE__ */ a(z, { slot: "title", className: "alea-dialog-title", "data-size": t === "sm" ? "sm" : void 0, children: e }),
50
- !r && /* @__PURE__ */ a(E, { "aria-label": s.close, size: "sm", variant: "ghost", onPress: g, className: "alea-dialog-x", children: /* @__PURE__ */ a(F, {}) })
51
- ] }),
52
- o && /* @__PURE__ */ a("p", { className: "alea-dialog-description", children: o }),
53
- l && /* @__PURE__ */ a("div", { className: "alea-dialog-body", children: typeof l == "function" ? l({ close: g }) : l }),
54
- i && /* @__PURE__ */ a("div", { className: "alea-dialog-footer", children: typeof i == "function" ? i({ close: g }) : i })
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 Y({ children: d, size: e = "md", fullscreenBelow: o, className: l, isDismissable: i = !0, motion: r, backdrop: t, initialFocus: n, surface: c, radius: m, ...s }) {
58
- const u = J(n);
59
- return /* @__PURE__ */ a(O, { ...s, isDismissable: i, className: N("alea-modal-overlay", l), "data-backdrop": t, "data-fullscreen-below": o, children: /* @__PURE__ */ a(S, { ref: u, className: "alea-modal", "data-size": e, "data-fullscreen-below": o, ...$({ surface: c, radius: m }), style: v(void 0, r), children: /* @__PURE__ */ a(U, { value: !0, children: d }) }) });
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 ua = f(function({ motion: e, backdrop: o, initialFocus: l, titleSize: i, title: r, children: t, confirmLabel: n, cancelLabel: c, tone: m, onConfirm: s, isOpen: u, defaultOpen: g, onOpenChange: A, className: L, style: R }, k) {
62
- const D = j(), w = G("AlertDialog", "tone", m, { default: "neutral" }) ?? "neutral", P = y();
63
- n ?? (n = P.confirm), c ?? (c = P.cancel);
64
- const T = l ?? (w === "danger" ? "cancel" : "confirm");
65
- return /* @__PURE__ */ a(Y, { isOpen: u, defaultOpen: g, onOpenChange: A, isDismissable: !1, size: "sm", motion: e, backdrop: o, children: /* @__PURE__ */ a(W, { ref: k, className: L, style: R, role: "alertdialog", "aria-describedby": t ? D : void 0, title: r, titleSize: i, hideClose: !0, footer: ({ close: b }) => /* @__PURE__ */ p(h, { children: [
66
- /* @__PURE__ */ a(x, { variant: "ghost", autoFocus: T === "cancel", onPress: b, children: c }),
67
- /* @__PURE__ */ a(x, { variant: w === "danger" ? "danger" : "primary", autoFocus: T === "confirm", onPress: async () => {
68
- await (s == null ? void 0 : s()), b();
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: D, style: { display: "contents" }, children: t }) : null }) });
85
+ ] }), children: t ? /* @__PURE__ */ a("div", { id: u, style: { display: "contents" }, children: t }) : null }) });
71
86
  });
72
87
  export {
73
- ua as AlertDialog,
74
- W as Dialog,
75
- Y as DialogModal,
76
- ha as DialogTrigger,
77
- ca as Popover,
78
- da as PopoverDialog,
79
- ma as Tooltip,
80
- pa as TooltipTrigger
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. */