@alea-design/ui 0.10.5 → 0.10.7

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,147 +1,149 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as k, Fragment as W } from "react/jsx-runtime";
3
- import { useRef as p, useEffect as E, useState as K, useId as H, useLayoutEffect as R } from "react";
2
+ import { jsx as a, jsxs as k, Fragment as F } from "react/jsx-runtime";
3
+ import { useRef as p, useEffect as A, useState as K, useId as H, useLayoutEffect as R } from "react";
4
4
  import { Tab as U, SelectionIndicator as V, TabList as X, Link as G, TabPanel as J, Tabs as Q } from "react-aria-components";
5
- import { X as Y, ChevronLeft as C, ChevronRight as $ } from "lucide-react";
5
+ import { X as Y, ChevronLeft as W, ChevronRight as C } from "lucide-react";
6
6
  import { withBase as w } from "../../utils/cx.js";
7
7
  import { tabIcon as Z } from "../icon/icon-contexts.js";
8
- import { useScrollEdges as j } from "../../utils/scrollEdges.js";
9
- import { useStrings as B } from "../../i18n/strings.js";
10
- function oe({ variant: s = "underline", size: l, fitted: a, justify: u, className: i, ...o }) {
8
+ import { useScrollEdges as $ } from "../../utils/scrollEdges.js";
9
+ import { useStrings as j } from "../../i18n/strings.js";
10
+ function oe({ variant: i = "underline", size: c, fitted: t, justify: u, className: l, ...b }) {
11
11
  const r = p(null);
12
12
  return R(() => {
13
- const c = r.current;
14
- if (!c) return;
15
- const v = () => c.querySelectorAll('[role="tab"][aria-controls]').forEach((b) => {
16
- document.getElementById(b.getAttribute("aria-controls")) || b.removeAttribute("aria-controls");
13
+ const n = r.current;
14
+ if (!n) return;
15
+ const v = () => n.querySelectorAll('[role="tab"][aria-controls]').forEach((d) => {
16
+ document.getElementById(d.getAttribute("aria-controls")) || d.removeAttribute("aria-controls");
17
17
  });
18
18
  if (v(), typeof MutationObserver > "u") return;
19
- const n = new MutationObserver(v);
20
- return n.observe(c, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-controls"] }), () => n.disconnect();
21
- }, []), /* @__PURE__ */ t(Q, { ...o, ref: r, "data-variant": s, "data-size": l, "data-fitted": a || void 0, "data-justify": u, className: w("alea-tabs", i) });
19
+ const s = new MutationObserver(v);
20
+ return s.observe(n, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-controls"] }), () => s.disconnect();
21
+ }, []), /* @__PURE__ */ a(Q, { ...b, ref: r, "data-variant": i, "data-size": c, "data-fitted": t || void 0, "data-justify": u, className: w("alea-tabs", l) });
22
22
  }
23
- function _(s, l) {
24
- const a = l.offsetLeft, u = a + l.offsetWidth, i = 56, o = l.offsetWidth, r = Math.max(0, a - i), c = u - s.clientWidth + i;
25
- c > r ? s.scrollLeft = o <= s.clientWidth ? a - (s.clientWidth - o) / 2 : r : u > s.scrollLeft + s.clientWidth - i ? s.scrollLeft = c : a < s.scrollLeft + i && (s.scrollLeft = r);
23
+ function _(i, c) {
24
+ const t = c.offsetLeft, u = t + c.offsetWidth, l = 56, b = c.offsetWidth, r = Math.max(0, t - l), n = u - i.clientWidth + l;
25
+ n > r ? i.scrollLeft = b <= i.clientWidth ? t - (i.clientWidth - b) / 2 : r : u > i.scrollLeft + i.clientWidth - l ? i.scrollLeft = n : t < i.scrollLeft + l && (i.scrollLeft = r);
26
26
  }
27
- function F(s, l) {
28
- E(() => {
29
- var c, v;
30
- const a = (c = s.current) == null ? void 0 : c.querySelector(".alea-tab-list");
31
- if (!a) return;
27
+ function B(i, c) {
28
+ A(() => {
29
+ var v, s;
30
+ const t = (v = i.current) == null ? void 0 : v.querySelector(".alea-tab-list");
31
+ if (!t) return;
32
32
  const u = () => {
33
- const n = a.querySelector(l);
34
- n && _(a, n);
33
+ const d = document.activeElement, o = (d && t.contains(d) ? d.closest(".alea-tab") : null) ?? t.querySelector(c);
34
+ o && _(t, o);
35
35
  };
36
36
  u();
37
- let i = !0;
38
- (v = document.fonts) == null || v.ready.then(() => {
39
- i && u();
37
+ const l = () => requestAnimationFrame(u);
38
+ t.addEventListener("focusin", l);
39
+ let b = !0;
40
+ (s = document.fonts) == null || s.ready.then(() => {
41
+ b && u();
40
42
  });
41
- const o = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(u);
42
- o == null || o.observe(a);
43
- const r = typeof MutationObserver > "u" ? void 0 : new MutationObserver(u);
44
- return r == null || r.observe(a, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-selected", "aria-current"] }), () => {
45
- i = !1, o == null || o.disconnect(), r == null || r.disconnect();
43
+ const r = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(u);
44
+ r == null || r.observe(t);
45
+ const n = typeof MutationObserver > "u" ? void 0 : new MutationObserver(u);
46
+ return n == null || n.observe(t, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-selected", "aria-current"] }), () => {
47
+ b = !1, t.removeEventListener("focusin", l), r == null || r.disconnect(), n == null || n.disconnect();
46
48
  };
47
- }, [s, l]);
49
+ }, [i, c]);
48
50
  }
49
- function ce({ className: s, extra: l, onReorder: a, ...u }) {
50
- const i = B(), o = p(null), { edges: r, scroll: c } = j(o, ".alea-tab-list"), [v, n] = K(""), b = H();
51
- F(o, '[role="tab"][aria-selected="true"]');
52
- const m = p(a);
53
- return m.current = a, E(() => {
54
- var q;
55
- const d = (q = o.current) == null ? void 0 : q.querySelector(".alea-tab-list");
56
- if (!d || !a) return;
57
- const y = () => Array.from(d.querySelectorAll('[role="tab"]')), S = () => y().forEach((e) => {
58
- e.setAttribute("draggable", "true"), e.setAttribute("aria-describedby", b), e.setAttribute("aria-keyshortcuts", "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight");
51
+ function ce({ className: i, extra: c, onReorder: t, ...u }) {
52
+ const l = j(), b = p(null), { edges: r, scroll: n } = $(b, ".alea-tab-list"), [v, s] = K(""), d = H();
53
+ B(b, '[role="tab"][aria-selected="true"]');
54
+ const h = p(t);
55
+ return h.current = t, A(() => {
56
+ var M;
57
+ const o = (M = b.current) == null ? void 0 : M.querySelector(".alea-tab-list");
58
+ if (!o || !t) return;
59
+ const y = () => Array.from(o.querySelectorAll('[role="tab"]')), S = () => y().forEach((e) => {
60
+ e.setAttribute("draggable", "true"), e.setAttribute("aria-describedby", d), e.setAttribute("aria-keyshortcuts", "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight");
59
61
  });
60
62
  S();
61
63
  const x = new MutationObserver(S);
62
- x.observe(d, { childList: !0 });
63
- const A = () => d.getAttribute("aria-orientation") === "vertical", T = (e, f) => {
64
+ x.observe(o, { childList: !0 });
65
+ const E = () => o.getAttribute("aria-orientation") === "vertical", T = (e, f) => {
64
66
  var N;
65
67
  const L = y(), g = e.dataset.key;
66
- f = Math.max(0, Math.min(L.length - 1, f)), f !== L.indexOf(e) && ((N = m.current) == null || N.call(m, g, f), n(i.movedTo(e.textContent ?? g, f + 1, L.length)), requestAnimationFrame(() => {
68
+ f = Math.max(0, Math.min(L.length - 1, f)), f !== L.indexOf(e) && ((N = h.current) == null || N.call(h, g, f), s(l.movedTo(e.textContent ?? g, f + 1, L.length)), requestAnimationFrame(() => {
67
69
  var P;
68
- return (P = d.querySelector(`[data-key="${CSS.escape(g)}"]`)) == null ? void 0 : P.focus();
70
+ return (P = o.querySelector(`[data-key="${CSS.escape(g)}"]`)) == null ? void 0 : P.focus();
69
71
  }));
70
72
  }, O = (e) => {
71
73
  const f = e.target.closest('[role="tab"]');
72
74
  if (!f || !e.altKey || !e.shiftKey) return;
73
- const L = A() ? "ArrowUp" : "ArrowLeft", g = A() ? "ArrowDown" : "ArrowRight";
75
+ const L = E() ? "ArrowUp" : "ArrowLeft", g = E() ? "ArrowDown" : "ArrowRight";
74
76
  if (e.key !== L && e.key !== g) return;
75
77
  e.preventDefault(), e.stopPropagation();
76
- const N = getComputedStyle(d).direction === "rtl" && !A();
78
+ const N = getComputedStyle(o).direction === "rtl" && !E();
77
79
  T(f, y().indexOf(f) + (e.key === g !== N ? 1 : -1));
78
80
  };
79
- let h = null;
81
+ let m = null;
80
82
  const D = (e) => {
81
83
  var f;
82
- h = e.target.closest('[role="tab"]'), h && ((f = e.dataTransfer) == null || f.setData("text/plain", h.dataset.key ?? ""), h.dataset.dragging = "true");
84
+ m = e.target.closest('[role="tab"]'), m && ((f = e.dataTransfer) == null || f.setData("text/plain", m.dataset.key ?? ""), m.dataset.dragging = "true");
83
85
  }, z = (e) => {
84
- h && e.preventDefault();
86
+ m && e.preventDefault();
85
87
  }, I = (e) => {
86
88
  const f = e.target.closest('[role="tab"]');
87
- h && f && f !== h && (e.preventDefault(), T(h, y().indexOf(f)));
88
- }, M = () => {
89
- h && delete h.dataset.dragging, h = null;
89
+ m && f && f !== m && (e.preventDefault(), T(m, y().indexOf(f)));
90
+ }, q = () => {
91
+ m && delete m.dataset.dragging, m = null;
90
92
  };
91
- return d.addEventListener("keydown", O, !0), d.addEventListener("dragstart", D), d.addEventListener("dragover", z), d.addEventListener("drop", I), d.addEventListener("dragend", M), () => {
92
- x.disconnect(), d.removeEventListener("keydown", O, !0), d.removeEventListener("dragstart", D), d.removeEventListener("dragover", z), d.removeEventListener("drop", I), d.removeEventListener("dragend", M), y().forEach((e) => {
93
+ return o.addEventListener("keydown", O, !0), o.addEventListener("dragstart", D), o.addEventListener("dragover", z), o.addEventListener("drop", I), o.addEventListener("dragend", q), () => {
94
+ x.disconnect(), o.removeEventListener("keydown", O, !0), o.removeEventListener("dragstart", D), o.removeEventListener("dragover", z), o.removeEventListener("drop", I), o.removeEventListener("dragend", q), y().forEach((e) => {
93
95
  e.removeAttribute("draggable"), e.removeAttribute("aria-describedby"), e.removeAttribute("aria-keyshortcuts");
94
96
  });
95
97
  };
96
- }, [!!a, b]), /* @__PURE__ */ k("div", { ref: o, className: "alea-tab-bar", "data-overflow-start": r.start || void 0, "data-overflow-end": r.end || void 0, "data-reorderable": a ? !0 : void 0, children: [
97
- r.start && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => c(-1), children: /* @__PURE__ */ t(C, { size: 16 }) }),
98
- /* @__PURE__ */ t(X, { ...u, "aria-label": u["aria-label"], className: w("alea-tab-list", s) }),
99
- r.end && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => c(1), children: /* @__PURE__ */ t($, { size: 16 }) }),
100
- l && /* @__PURE__ */ t("div", { className: "alea-tab-extra", children: l }),
101
- a && /* @__PURE__ */ k(W, { children: [
102
- /* @__PURE__ */ t("span", { id: b, hidden: !0, children: i.reorderHint }),
103
- /* @__PURE__ */ t("span", { className: "alea-visually-hidden", role: "status", children: v })
98
+ }, [!!t, d]), /* @__PURE__ */ k("div", { ref: b, className: "alea-tab-bar", "data-overflow-start": r.start || void 0, "data-overflow-end": r.end || void 0, "data-reorderable": t ? !0 : void 0, children: [
99
+ r.start && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => n(-1), children: /* @__PURE__ */ a(W, { size: 16 }) }),
100
+ /* @__PURE__ */ a(X, { ...u, "aria-label": u["aria-label"], className: w("alea-tab-list", i) }),
101
+ r.end && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => n(1), children: /* @__PURE__ */ a(C, { size: 16 }) }),
102
+ c && /* @__PURE__ */ a("div", { className: "alea-tab-extra", children: c }),
103
+ t && /* @__PURE__ */ k(F, { children: [
104
+ /* @__PURE__ */ a("span", { id: d, hidden: !0, children: l.reorderHint }),
105
+ /* @__PURE__ */ a("span", { className: "alea-visually-hidden", role: "status", children: v })
104
106
  ] })
105
107
  ] });
106
108
  }
107
- function de({ className: s, children: l, icon: a, badge: u, onClose: i, ...o }) {
108
- const r = B(), c = p(null), v = p(i);
109
- return v.current = i, E(() => {
110
- const n = c.current;
111
- if (!n || !i) return;
112
- n.setAttribute("aria-keyshortcuts", "Delete");
113
- const b = (m) => {
114
- var d;
115
- (m.key === "Delete" || m.key === "Backspace") && (m.preventDefault(), (d = v.current) == null || d.call(v));
109
+ function de({ className: i, children: c, icon: t, badge: u, onClose: l, ...b }) {
110
+ const r = j(), n = p(null), v = p(l);
111
+ return v.current = l, A(() => {
112
+ const s = n.current;
113
+ if (!s || !l) return;
114
+ s.setAttribute("aria-keyshortcuts", "Delete");
115
+ const d = (h) => {
116
+ var o;
117
+ (h.key === "Delete" || h.key === "Backspace") && (h.preventDefault(), (o = v.current) == null || o.call(v));
116
118
  };
117
- return n.addEventListener("keydown", b), () => n.removeEventListener("keydown", b);
118
- }, [!!i]), /* @__PURE__ */ t(U, { ...o, ref: c, className: w("alea-tab alea-focus-ring", s), "data-closable": i ? !0 : void 0, children: (n) => /* @__PURE__ */ k(W, { children: [
119
- a && /* @__PURE__ */ t("span", { className: "alea-tab-icon", "aria-hidden": "true", ...Z(n.isSelected), children: a }),
120
- /* @__PURE__ */ t("span", { className: "alea-tab-label", children: typeof l == "function" ? l(n) : l }),
121
- u != null && /* @__PURE__ */ t("span", { className: "alea-tab-badge", children: u }),
122
- i && /* @__PURE__ */ t("span", { className: "alea-tab-close", "aria-hidden": "true", title: r.close, onPointerDown: (b) => b.stopPropagation(), onClick: (b) => {
123
- b.stopPropagation(), i();
124
- }, children: /* @__PURE__ */ t(Y, { size: 12 }) }),
125
- /* @__PURE__ */ t(V, { className: "alea-sel-indicator" })
119
+ return s.addEventListener("keydown", d), () => s.removeEventListener("keydown", d);
120
+ }, [!!l]), /* @__PURE__ */ a(U, { ...b, ref: n, className: w("alea-tab alea-focus-ring", i), "data-closable": l ? !0 : void 0, children: (s) => /* @__PURE__ */ k(F, { children: [
121
+ t && /* @__PURE__ */ a("span", { className: "alea-tab-icon", "aria-hidden": "true", ...Z(s.isSelected), children: t }),
122
+ /* @__PURE__ */ a("span", { className: "alea-tab-label", children: typeof c == "function" ? c(s) : c }),
123
+ u != null && /* @__PURE__ */ a("span", { className: "alea-tab-badge", children: u }),
124
+ l && /* @__PURE__ */ a("span", { className: "alea-tab-close", "aria-hidden": "true", title: r.close, onPointerDown: (d) => d.stopPropagation(), onClick: (d) => {
125
+ d.stopPropagation(), l();
126
+ }, children: /* @__PURE__ */ a(Y, { size: 12 }) }),
127
+ /* @__PURE__ */ a(V, { className: "alea-sel-indicator" })
126
128
  ] }) });
127
129
  }
128
- function ue({ className: s, ...l }) {
129
- return l.children == null || l.children === !1 ? null : /* @__PURE__ */ t(J, { ...l, className: w("alea-tab-panel alea-focus-ring", s) });
130
+ function ue({ className: i, ...c }) {
131
+ return c.children == null || c.children === !1 ? null : /* @__PURE__ */ a(J, { ...c, className: w("alea-tab-panel alea-focus-ring", i) });
130
132
  }
131
- function be({ items: s, current: l, variant: a = "underline", size: u, className: i, "aria-label": o }) {
132
- const r = p(null), { edges: c, scroll: v } = j(r, ".alea-tab-list");
133
- return F(r, '[aria-current="page"]'), /* @__PURE__ */ t("nav", { "aria-label": o, className: ["alea-tabs alea-tab-nav", i].filter(Boolean).join(" "), "data-variant": a, "data-size": u, children: /* @__PURE__ */ k("div", { ref: r, className: "alea-tab-bar", "data-overflow-start": c.start || void 0, "data-overflow-end": c.end || void 0, children: [
134
- c.start && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => v(-1), children: /* @__PURE__ */ t(C, { size: 16 }) }),
135
- /* @__PURE__ */ t("div", { className: "alea-tab-list", children: s.map((n) => {
136
- const b = n.id === l;
137
- return /* @__PURE__ */ k(G, { href: n.href, "aria-current": b ? "page" : void 0, "data-selected": b || void 0, className: "alea-tab alea-focus-ring", children: [
138
- n.icon && /* @__PURE__ */ t("span", { className: "alea-tab-icon", "aria-hidden": "true", children: n.icon }),
139
- /* @__PURE__ */ t("span", { className: "alea-tab-label", children: n.label }),
140
- n.badge != null && /* @__PURE__ */ t("span", { className: "alea-tab-badge", children: n.badge }),
141
- b && /* @__PURE__ */ t("span", { className: "alea-sel-indicator" })
142
- ] }, n.id);
133
+ function be({ items: i, current: c, variant: t = "underline", size: u, className: l, "aria-label": b }) {
134
+ const r = p(null), { edges: n, scroll: v } = $(r, ".alea-tab-list");
135
+ return B(r, '[aria-current="page"]'), /* @__PURE__ */ a("nav", { "aria-label": b, className: ["alea-tabs alea-tab-nav", l].filter(Boolean).join(" "), "data-variant": t, "data-size": u, children: /* @__PURE__ */ k("div", { ref: r, className: "alea-tab-bar", "data-overflow-start": n.start || void 0, "data-overflow-end": n.end || void 0, children: [
136
+ n.start && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => v(-1), children: /* @__PURE__ */ a(W, { size: 16 }) }),
137
+ /* @__PURE__ */ a("div", { className: "alea-tab-list", children: i.map((s) => {
138
+ const d = s.id === c;
139
+ return /* @__PURE__ */ k(G, { href: s.href, "aria-current": d ? "page" : void 0, "data-selected": d || void 0, className: "alea-tab alea-focus-ring", children: [
140
+ s.icon && /* @__PURE__ */ a("span", { className: "alea-tab-icon", "aria-hidden": "true", children: s.icon }),
141
+ /* @__PURE__ */ a("span", { className: "alea-tab-label", children: s.label }),
142
+ s.badge != null && /* @__PURE__ */ a("span", { className: "alea-tab-badge", children: s.badge }),
143
+ d && /* @__PURE__ */ a("span", { className: "alea-sel-indicator" })
144
+ ] }, s.id);
143
145
  }) }),
144
- c.end && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => v(1), children: /* @__PURE__ */ t($, { size: 16 }) })
146
+ n.end && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => v(1), children: /* @__PURE__ */ a(C, { size: 16 }) })
145
147
  ] }) });
146
148
  }
147
149
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alea-design/ui",
3
- "version": "0.10.5",
3
+ "version": "0.10.7",
4
4
  "description": "Alea: the complete React design system. Accessible components from forms to AI, charts and editors, Alea Motion, and W3C design tokens for dark, light and high contrast.",
5
5
  "keywords": [
6
6
  "react",
@@ -61,8 +61,8 @@
61
61
  "react-dom": ">=18.3"
62
62
  },
63
63
  "dependencies": {
64
- "@alea-design/motion": "0.10.5",
65
- "@alea-design/tokens": "0.10.5",
64
+ "@alea-design/motion": "0.10.7",
65
+ "@alea-design/tokens": "0.10.7",
66
66
  "@internationalized/date": "^3.8.0",
67
67
  "lucide-react": "^0.525.0",
68
68
  "qrcode-generator": "^1.5.2",