@alea-design/ui 0.10.5 → 0.10.6
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 +84 -82
- package/package.json +3 -3
|
@@ -1,61 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as k, Fragment as
|
|
2
|
+
import { jsx as t, jsxs as k, Fragment as F } from "react/jsx-runtime";
|
|
3
3
|
import { useRef as p, useEffect as E, 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: o, fitted: a, 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((c) => {
|
|
16
|
+
document.getElementById(c.getAttribute("aria-controls")) || c.removeAttribute("aria-controls");
|
|
17
17
|
});
|
|
18
18
|
if (v(), typeof MutationObserver > "u") return;
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
}, []), /* @__PURE__ */ t(Q, { ...
|
|
19
|
+
const s = new MutationObserver(v);
|
|
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) });
|
|
22
22
|
}
|
|
23
|
-
function _(
|
|
24
|
-
const a =
|
|
25
|
-
|
|
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);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function B(i, o) {
|
|
28
28
|
E(() => {
|
|
29
|
-
var
|
|
30
|
-
const a = (
|
|
29
|
+
var v, s;
|
|
30
|
+
const a = (v = i.current) == null ? void 0 : v.querySelector(".alea-tab-list");
|
|
31
31
|
if (!a) return;
|
|
32
32
|
const u = () => {
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const c = a.querySelector(o);
|
|
34
|
+
c && _(a, c);
|
|
35
35
|
};
|
|
36
36
|
u();
|
|
37
|
-
|
|
38
|
-
(
|
|
39
|
-
|
|
37
|
+
const l = () => requestAnimationFrame(u);
|
|
38
|
+
a.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(a);
|
|
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
48
|
};
|
|
47
|
-
}, [
|
|
49
|
+
}, [i, o]);
|
|
48
50
|
}
|
|
49
|
-
function ce({ className:
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
return
|
|
54
|
-
var
|
|
55
|
-
const d = (
|
|
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();
|
|
53
|
+
B(b, '[role="tab"][aria-selected="true"]');
|
|
54
|
+
const h = p(a);
|
|
55
|
+
return h.current = a, E(() => {
|
|
56
|
+
var M;
|
|
57
|
+
const d = (M = b.current) == null ? void 0 : M.querySelector(".alea-tab-list");
|
|
56
58
|
if (!d || !a) return;
|
|
57
59
|
const y = () => Array.from(d.querySelectorAll('[role="tab"]')), S = () => y().forEach((e) => {
|
|
58
|
-
e.setAttribute("draggable", "true"), e.setAttribute("aria-describedby",
|
|
60
|
+
e.setAttribute("draggable", "true"), e.setAttribute("aria-describedby", c), e.setAttribute("aria-keyshortcuts", "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight");
|
|
59
61
|
});
|
|
60
62
|
S();
|
|
61
63
|
const x = new MutationObserver(S);
|
|
@@ -63,7 +65,7 @@ function ce({ className: s, extra: l, onReorder: a, ...u }) {
|
|
|
63
65
|
const A = () => d.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
70
|
return (P = d.querySelector(`[data-key="${CSS.escape(g)}"]`)) == null ? void 0 : P.focus();
|
|
69
71
|
}));
|
|
@@ -76,72 +78,72 @@ function ce({ className: s, extra: l, onReorder: a, ...u }) {
|
|
|
76
78
|
const N = getComputedStyle(d).direction === "rtl" && !A();
|
|
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 d.addEventListener("keydown", O, !0), d.addEventListener("dragstart", D), d.addEventListener("dragover", z), d.addEventListener("drop", I), d.addEventListener("dragend",
|
|
92
|
-
x.disconnect(), d.removeEventListener("keydown", O, !0), d.removeEventListener("dragstart", D), d.removeEventListener("dragover", z), d.removeEventListener("drop", I), d.removeEventListener("dragend",
|
|
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
95
|
e.removeAttribute("draggable"), e.removeAttribute("aria-describedby"), e.removeAttribute("aria-keyshortcuts");
|
|
94
96
|
});
|
|
95
97
|
};
|
|
96
|
-
}, [!!a,
|
|
97
|
-
r.start && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () =>
|
|
98
|
-
/* @__PURE__ */ t(X, { ...u, "aria-label": u["aria-label"], className: w("alea-tab-list",
|
|
99
|
-
r.end && /* @__PURE__ */ t("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () =>
|
|
100
|
-
|
|
101
|
-
a && /* @__PURE__ */ k(
|
|
102
|
-
/* @__PURE__ */ t("span", { id:
|
|
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 }),
|
|
103
105
|
/* @__PURE__ */ t("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
|
|
109
|
+
function de({ className: i, children: o, icon: a, badge: u, onClose: l, ...b }) {
|
|
110
|
+
const r = j(), n = p(null), v = p(l);
|
|
111
|
+
return v.current = l, E(() => {
|
|
112
|
+
const s = n.current;
|
|
113
|
+
if (!s || !l) return;
|
|
114
|
+
s.setAttribute("aria-keyshortcuts", "Delete");
|
|
115
|
+
const c = (h) => {
|
|
114
116
|
var d;
|
|
115
|
-
(
|
|
117
|
+
(h.key === "Delete" || h.key === "Backspace") && (h.preventDefault(), (d = v.current) == null || d.call(v));
|
|
116
118
|
};
|
|
117
|
-
return
|
|
118
|
-
}, [!!
|
|
119
|
-
a && /* @__PURE__ */ t("span", { className: "alea-tab-icon", "aria-hidden": "true", ...Z(
|
|
120
|
-
/* @__PURE__ */ t("span", { className: "alea-tab-label", children: typeof
|
|
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 }),
|
|
121
123
|
u != null && /* @__PURE__ */ t("span", { className: "alea-tab-badge", children: u }),
|
|
122
|
-
|
|
123
|
-
|
|
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();
|
|
124
126
|
}, children: /* @__PURE__ */ t(Y, { size: 12 }) }),
|
|
125
127
|
/* @__PURE__ */ t(V, { className: "alea-sel-indicator" })
|
|
126
128
|
] }) });
|
|
127
129
|
}
|
|
128
|
-
function ue({ className:
|
|
129
|
-
return
|
|
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
132
|
}
|
|
131
|
-
function be({ items:
|
|
132
|
-
const r = p(null), { edges:
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
/* @__PURE__ */ t("div", { className: "alea-tab-list", children:
|
|
136
|
-
const
|
|
137
|
-
return /* @__PURE__ */ k(G, { href:
|
|
138
|
-
|
|
139
|
-
/* @__PURE__ */ t("span", { className: "alea-tab-label", children:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
] },
|
|
133
|
+
function be({ items: i, current: o, variant: a = "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__ */ 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" })
|
|
144
|
+
] }, s.id);
|
|
143
145
|
}) }),
|
|
144
|
-
|
|
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 }) })
|
|
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.6",
|
|
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.6",
|
|
65
|
+
"@alea-design/tokens": "0.10.6",
|
|
66
66
|
"@internationalized/date": "^3.8.0",
|
|
67
67
|
"lucide-react": "^0.525.0",
|
|
68
68
|
"qrcode-generator": "^1.5.2",
|