@alea-design/ui 0.10.4 → 0.10.5
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 +130 -108
- package/dist/i18n/strings.d.ts +1 -0
- package/dist/i18n/strings.js +2 -0
- package/package.json +3 -3
|
@@ -1,131 +1,153 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Tab as U, SelectionIndicator as
|
|
5
|
-
import { X as Y, ChevronLeft as
|
|
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";
|
|
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";
|
|
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
|
|
11
|
-
const
|
|
12
|
-
return
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
15
|
-
const
|
|
16
|
-
document.getElementById(
|
|
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 }) {
|
|
11
|
+
const r = p(null);
|
|
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");
|
|
17
17
|
});
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
}, []), /* @__PURE__ */
|
|
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) });
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
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;
|
|
32
|
+
const u = () => {
|
|
33
|
+
const n = a.querySelector(l);
|
|
34
|
+
n && _(a, n);
|
|
35
|
+
};
|
|
36
|
+
u();
|
|
37
|
+
let i = !0;
|
|
38
|
+
(v = document.fonts) == null || v.ready.then(() => {
|
|
39
|
+
i && u();
|
|
40
|
+
});
|
|
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();
|
|
46
|
+
};
|
|
47
|
+
}, [s, l]);
|
|
48
|
+
}
|
|
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");
|
|
31
59
|
});
|
|
32
|
-
|
|
33
|
-
const x = new MutationObserver(
|
|
34
|
-
x.observe(
|
|
35
|
-
const
|
|
36
|
-
var
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
return (
|
|
60
|
+
S();
|
|
61
|
+
const x = new MutationObserver(S);
|
|
62
|
+
x.observe(d, { childList: !0 });
|
|
63
|
+
const A = () => d.getAttribute("aria-orientation") === "vertical", T = (e, f) => {
|
|
64
|
+
var N;
|
|
65
|
+
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(() => {
|
|
67
|
+
var P;
|
|
68
|
+
return (P = d.querySelector(`[data-key="${CSS.escape(g)}"]`)) == null ? void 0 : P.focus();
|
|
41
69
|
}));
|
|
42
|
-
},
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
T(
|
|
70
|
+
}, O = (e) => {
|
|
71
|
+
const f = e.target.closest('[role="tab"]');
|
|
72
|
+
if (!f || !e.altKey || !e.shiftKey) return;
|
|
73
|
+
const L = A() ? "ArrowUp" : "ArrowLeft", g = A() ? "ArrowDown" : "ArrowRight";
|
|
74
|
+
if (e.key !== L && e.key !== g) return;
|
|
75
|
+
e.preventDefault(), e.stopPropagation();
|
|
76
|
+
const N = getComputedStyle(d).direction === "rtl" && !A();
|
|
77
|
+
T(f, y().indexOf(f) + (e.key === g !== N ? 1 : -1));
|
|
50
78
|
};
|
|
51
|
-
let
|
|
52
|
-
const
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
79
|
+
let h = null;
|
|
80
|
+
const D = (e) => {
|
|
81
|
+
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");
|
|
83
|
+
}, z = (e) => {
|
|
84
|
+
h && e.preventDefault();
|
|
85
|
+
}, I = (e) => {
|
|
86
|
+
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;
|
|
62
90
|
};
|
|
63
|
-
return
|
|
64
|
-
x.disconnect(),
|
|
65
|
-
|
|
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
|
+
e.removeAttribute("draggable"), e.removeAttribute("aria-describedby"), e.removeAttribute("aria-keyshortcuts");
|
|
66
94
|
});
|
|
67
95
|
};
|
|
68
|
-
}, [!!
|
|
69
|
-
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
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 })
|
|
76
104
|
] })
|
|
77
105
|
] });
|
|
78
106
|
}
|
|
79
|
-
function
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
var
|
|
87
|
-
(
|
|
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));
|
|
88
116
|
};
|
|
89
|
-
return
|
|
90
|
-
}, [!!
|
|
91
|
-
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, children: /* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
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" })
|
|
98
126
|
] }) });
|
|
99
127
|
}
|
|
100
|
-
function
|
|
101
|
-
return
|
|
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) });
|
|
102
130
|
}
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return /* @__PURE__ */ N(J, { href: e.href, "aria-current": n ? "page" : void 0, "data-selected": n || void 0, className: "alea-tab alea-focus-ring", children: [
|
|
116
|
-
e.icon && /* @__PURE__ */ a("span", { className: "alea-tab-icon", "aria-hidden": "true", children: e.icon }),
|
|
117
|
-
/* @__PURE__ */ a("span", { className: "alea-tab-label", children: e.label }),
|
|
118
|
-
e.badge != null && /* @__PURE__ */ a("span", { className: "alea-tab-badge", children: e.badge }),
|
|
119
|
-
n && /* @__PURE__ */ a("span", { className: "alea-sel-indicator" })
|
|
120
|
-
] }, e.id);
|
|
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);
|
|
121
143
|
}) }),
|
|
122
|
-
|
|
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 }) })
|
|
123
145
|
] }) });
|
|
124
146
|
}
|
|
125
147
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
148
|
+
de as Tab,
|
|
149
|
+
ce as TabList,
|
|
150
|
+
be as TabNav,
|
|
151
|
+
ue as TabPanel,
|
|
152
|
+
oe as Tabs
|
|
131
153
|
};
|
package/dist/i18n/strings.d.ts
CHANGED
package/dist/i18n/strings.js
CHANGED
|
@@ -270,6 +270,7 @@ const n = {
|
|
|
270
270
|
schedulerBlocked: "Not available",
|
|
271
271
|
schedulerResource: (e) => `Resource: ${e}`,
|
|
272
272
|
allDay: "All day",
|
|
273
|
+
schedulerAgenda: "Schedule",
|
|
273
274
|
previousPeriod: "Previous",
|
|
274
275
|
nextPeriod: "Next",
|
|
275
276
|
nowLabel: "Now",
|
|
@@ -722,6 +723,7 @@ const n = {
|
|
|
722
723
|
schedulerBlocked: "No disponible",
|
|
723
724
|
schedulerResource: (e) => `Recurso: ${e}`,
|
|
724
725
|
allDay: "Todo el día",
|
|
726
|
+
schedulerAgenda: "Agenda",
|
|
725
727
|
previousPeriod: "Anterior",
|
|
726
728
|
nextPeriod: "Siguiente",
|
|
727
729
|
nowLabel: "Ahora",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/ui",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
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.5",
|
|
65
|
+
"@alea-design/tokens": "0.10.5",
|
|
66
66
|
"@internationalized/date": "^3.8.0",
|
|
67
67
|
"lucide-react": "^0.525.0",
|
|
68
68
|
"qrcode-generator": "^1.5.2",
|