@alea-design/ui 0.10.6 → 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,81 +1,81 @@
1
1
  "use client";
2
- import { jsx as t, jsxs as k, Fragment as F } 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
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
8
  import { useScrollEdges as $ } from "../../utils/scrollEdges.js";
9
9
  import { useStrings as j } from "../../i18n/strings.js";
10
- function oe({ variant: i = "underline", size: o, fitted: a, justify: u, className: l, ...b }) {
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
13
  const n = r.current;
14
14
  if (!n) return;
15
- const v = () => n.querySelectorAll('[role="tab"][aria-controls]').forEach((c) => {
16
- document.getElementById(c.getAttribute("aria-controls")) || c.removeAttribute("aria-controls");
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
19
  const s = new MutationObserver(v);
20
20
  return s.observe(n, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-controls"] }), () => s.disconnect();
21
- }, []), /* @__PURE__ */ t(Q, { ...b, ref: r, "data-variant": i, "data-size": o, "data-fitted": a || void 0, "data-justify": u, className: w("alea-tabs", l) });
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 _(i, o) {
24
- const a = o.offsetLeft, u = a + o.offsetWidth, l = 56, b = o.offsetWidth, r = Math.max(0, a - l), n = u - i.clientWidth + l;
25
- n > r ? i.scrollLeft = b <= i.clientWidth ? a - (i.clientWidth - b) / 2 : r : u > i.scrollLeft + i.clientWidth - l ? i.scrollLeft = n : a < i.scrollLeft + l && (i.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 B(i, o) {
28
- E(() => {
27
+ function B(i, c) {
28
+ A(() => {
29
29
  var v, s;
30
- const a = (v = i.current) == null ? void 0 : v.querySelector(".alea-tab-list");
31
- if (!a) return;
30
+ const t = (v = i.current) == null ? void 0 : v.querySelector(".alea-tab-list");
31
+ if (!t) return;
32
32
  const u = () => {
33
- const c = a.querySelector(o);
34
- c && _(a, c);
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
37
  const l = () => requestAnimationFrame(u);
38
- a.addEventListener("focusin", l);
38
+ t.addEventListener("focusin", l);
39
39
  let b = !0;
40
40
  (s = document.fonts) == null || s.ready.then(() => {
41
41
  b && u();
42
42
  });
43
43
  const r = typeof ResizeObserver > "u" ? void 0 : new ResizeObserver(u);
44
- r == null || r.observe(a);
44
+ r == null || r.observe(t);
45
45
  const n = typeof MutationObserver > "u" ? void 0 : new MutationObserver(u);
46
- return n == null || n.observe(a, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-selected", "aria-current"] }), () => {
47
- b = !1, a.removeEventListener("focusin", l), r == null || r.disconnect(), n == null || n.disconnect();
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();
48
48
  };
49
- }, [i, o]);
49
+ }, [i, c]);
50
50
  }
51
- function ce({ className: i, extra: o, onReorder: a, ...u }) {
52
- const l = j(), b = p(null), { edges: r, scroll: n } = $(b, ".alea-tab-list"), [v, s] = K(""), c = H();
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
53
  B(b, '[role="tab"][aria-selected="true"]');
54
- const h = p(a);
55
- return h.current = a, E(() => {
54
+ const h = p(t);
55
+ return h.current = t, A(() => {
56
56
  var M;
57
- const d = (M = b.current) == null ? void 0 : M.querySelector(".alea-tab-list");
58
- if (!d || !a) return;
59
- const y = () => Array.from(d.querySelectorAll('[role="tab"]')), S = () => y().forEach((e) => {
60
- e.setAttribute("draggable", "true"), e.setAttribute("aria-describedby", c), e.setAttribute("aria-keyshortcuts", "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight");
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");
61
61
  });
62
62
  S();
63
63
  const x = new MutationObserver(S);
64
- x.observe(d, { childList: !0 });
65
- 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) => {
66
66
  var N;
67
67
  const L = y(), g = e.dataset.key;
68
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(() => {
69
69
  var P;
70
- 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();
71
71
  }));
72
72
  }, O = (e) => {
73
73
  const f = e.target.closest('[role="tab"]');
74
74
  if (!f || !e.altKey || !e.shiftKey) return;
75
- const L = A() ? "ArrowUp" : "ArrowLeft", g = A() ? "ArrowDown" : "ArrowRight";
75
+ const L = E() ? "ArrowUp" : "ArrowLeft", g = E() ? "ArrowDown" : "ArrowRight";
76
76
  if (e.key !== L && e.key !== g) return;
77
77
  e.preventDefault(), e.stopPropagation();
78
- const N = getComputedStyle(d).direction === "rtl" && !A();
78
+ const N = getComputedStyle(o).direction === "rtl" && !E();
79
79
  T(f, y().indexOf(f) + (e.key === g !== N ? 1 : -1));
80
80
  };
81
81
  let m = null;
@@ -90,60 +90,60 @@ function ce({ className: i, extra: o, onReorder: a, ...u }) {
90
90
  }, q = () => {
91
91
  m && delete m.dataset.dragging, m = null;
92
92
  };
93
- return d.addEventListener("keydown", O, !0), d.addEventListener("dragstart", D), d.addEventListener("dragover", z), d.addEventListener("drop", I), d.addEventListener("dragend", q), () => {
94
- x.disconnect(), d.removeEventListener("keydown", O, !0), d.removeEventListener("dragstart", D), d.removeEventListener("dragover", z), d.removeEventListener("drop", I), d.removeEventListener("dragend", q), 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) => {
95
95
  e.removeAttribute("draggable"), e.removeAttribute("aria-describedby"), e.removeAttribute("aria-keyshortcuts");
96
96
  });
97
97
  };
98
- }, [!!a, c]), /* @__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": a ? !0 : void 0, children: [
99
- r.start && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => n(-1), children: /* @__PURE__ */ t(W, { size: 16 }) }),
100
- /* @__PURE__ */ t(X, { ...u, "aria-label": u["aria-label"], className: w("alea-tab-list", i) }),
101
- r.end && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => n(1), children: /* @__PURE__ */ t(C, { size: 16 }) }),
102
- o && /* @__PURE__ */ t("div", { className: "alea-tab-extra", children: o }),
103
- a && /* @__PURE__ */ k(F, { children: [
104
- /* @__PURE__ */ t("span", { id: c, hidden: !0, children: l.reorderHint }),
105
- /* @__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 })
106
106
  ] })
107
107
  ] });
108
108
  }
109
- function de({ className: i, children: o, icon: a, badge: u, onClose: l, ...b }) {
109
+ function de({ className: i, children: c, icon: t, badge: u, onClose: l, ...b }) {
110
110
  const r = j(), n = p(null), v = p(l);
111
- return v.current = l, E(() => {
111
+ return v.current = l, A(() => {
112
112
  const s = n.current;
113
113
  if (!s || !l) return;
114
114
  s.setAttribute("aria-keyshortcuts", "Delete");
115
- const c = (h) => {
116
- var d;
117
- (h.key === "Delete" || h.key === "Backspace") && (h.preventDefault(), (d = v.current) == null || d.call(v));
115
+ const d = (h) => {
116
+ var o;
117
+ (h.key === "Delete" || h.key === "Backspace") && (h.preventDefault(), (o = v.current) == null || o.call(v));
118
118
  };
119
- return s.addEventListener("keydown", c), () => s.removeEventListener("keydown", c);
120
- }, [!!l]), /* @__PURE__ */ t(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
- a && /* @__PURE__ */ t("span", { className: "alea-tab-icon", "aria-hidden": "true", ...Z(s.isSelected), children: a }),
122
- /* @__PURE__ */ t("span", { className: "alea-tab-label", children: typeof o == "function" ? o(s) : o }),
123
- u != null && /* @__PURE__ */ t("span", { className: "alea-tab-badge", children: u }),
124
- l && /* @__PURE__ */ t("span", { className: "alea-tab-close", "aria-hidden": "true", title: r.close, onPointerDown: (c) => c.stopPropagation(), onClick: (c) => {
125
- c.stopPropagation(), l();
126
- }, children: /* @__PURE__ */ t(Y, { size: 12 }) }),
127
- /* @__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" })
128
128
  ] }) });
129
129
  }
130
- function ue({ className: i, ...o }) {
131
- return o.children == null || o.children === !1 ? null : /* @__PURE__ */ t(J, { ...o, className: w("alea-tab-panel alea-focus-ring", i) });
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) });
132
132
  }
133
- function be({ items: i, current: o, variant: a = "underline", size: u, className: l, "aria-label": b }) {
133
+ function be({ items: i, current: c, variant: t = "underline", size: u, className: l, "aria-label": b }) {
134
134
  const r = p(null), { edges: n, scroll: v } = $(r, ".alea-tab-list");
135
- return B(r, '[aria-current="page"]'), /* @__PURE__ */ t("nav", { "aria-label": b, className: ["alea-tabs alea-tab-nav", l].filter(Boolean).join(" "), "data-variant": a, "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__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => v(-1), children: /* @__PURE__ */ t(W, { size: 16 }) }),
137
- /* @__PURE__ */ t("div", { className: "alea-tab-list", children: i.map((s) => {
138
- const c = s.id === o;
139
- return /* @__PURE__ */ k(G, { href: s.href, "aria-current": c ? "page" : void 0, "data-selected": c || void 0, className: "alea-tab alea-focus-ring", children: [
140
- s.icon && /* @__PURE__ */ t("span", { className: "alea-tab-icon", "aria-hidden": "true", children: s.icon }),
141
- /* @__PURE__ */ t("span", { className: "alea-tab-label", children: s.label }),
142
- s.badge != null && /* @__PURE__ */ t("span", { className: "alea-tab-badge", children: s.badge }),
143
- c && /* @__PURE__ */ t("span", { className: "alea-sel-indicator" })
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
144
  ] }, s.id);
145
145
  }) }),
146
- n.end && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => v(1), children: /* @__PURE__ */ t(C, { 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 }) })
147
147
  ] }) });
148
148
  }
149
149
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alea-design/ui",
3
- "version": "0.10.6",
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.6",
65
- "@alea-design/tokens": "0.10.6",
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",