@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.
- package/dist/components/tabs/Tabs.js +99 -97
- package/package.json +3 -3
|
@@ -1,147 +1,149 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as p, useEffect as
|
|
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
|
|
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
|
|
9
|
-
import { useStrings as
|
|
10
|
-
function oe({ variant:
|
|
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
|
|
14
|
-
if (!
|
|
15
|
-
const v = () =>
|
|
16
|
-
document.getElementById(
|
|
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
|
|
20
|
-
return
|
|
21
|
-
}, []), /* @__PURE__ */
|
|
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 _(
|
|
24
|
-
const
|
|
25
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
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
|
|
34
|
-
|
|
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
|
-
|
|
38
|
-
(
|
|
39
|
-
|
|
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
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
|
|
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
|
-
}, [
|
|
49
|
+
}, [i, c]);
|
|
48
50
|
}
|
|
49
|
-
function ce({ className:
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
return
|
|
54
|
-
var
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
const y = () => Array.from(
|
|
58
|
-
e.setAttribute("draggable", "true"), e.setAttribute("aria-describedby",
|
|
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(
|
|
63
|
-
const
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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
|
|
81
|
+
let m = null;
|
|
80
82
|
const D = (e) => {
|
|
81
83
|
var f;
|
|
82
|
-
|
|
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
|
-
|
|
86
|
+
m && e.preventDefault();
|
|
85
87
|
}, I = (e) => {
|
|
86
88
|
const f = e.target.closest('[role="tab"]');
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
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
|
|
92
|
-
x.disconnect(),
|
|
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
|
-
}, [!!
|
|
97
|
-
r.start && /* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
r.end && /* @__PURE__ */
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
/* @__PURE__ */
|
|
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:
|
|
108
|
-
const r =
|
|
109
|
-
return v.current =
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
var
|
|
115
|
-
(
|
|
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
|
|
118
|
-
}, [!!
|
|
119
|
-
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
u != null && /* @__PURE__ */
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}, children: /* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
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:
|
|
129
|
-
return
|
|
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:
|
|
132
|
-
const r = p(null), { edges:
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
const
|
|
137
|
-
return /* @__PURE__ */ k(G, { href:
|
|
138
|
-
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
] },
|
|
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
|
-
|
|
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.
|
|
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.
|
|
65
|
-
"@alea-design/tokens": "0.10.
|
|
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",
|