@alea-design/ui 0.10.4 → 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.
@@ -1,131 +1,155 @@
1
1
  "use client";
2
- import { jsx as a, jsxs as N, Fragment as $ } from "react/jsx-runtime";
3
- import { useRef as y, useEffect as S, useState as K, useId as W, useLayoutEffect as H } from "react";
4
- import { Tab as U, SelectionIndicator as X, TabList as G, Link as J, TabPanel as Q, Tabs as V } from "react-aria-components";
5
- import { X as Y, ChevronLeft as j, ChevronRight as B } from "lucide-react";
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";
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 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 C } from "../../utils/scrollEdges.js";
9
- import { useStrings as F } from "../../i18n/strings.js";
10
- function ie({ variant: v = "underline", size: i, fitted: c, justify: h, className: l, ...g }) {
11
- const d = y(null);
12
- return H(() => {
13
- const o = d.current;
14
- if (!o) return;
15
- const u = () => o.querySelectorAll('[role="tab"][aria-controls]').forEach((n) => {
16
- document.getElementById(n.getAttribute("aria-controls")) || n.removeAttribute("aria-controls");
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
+ const r = p(null);
12
+ return R(() => {
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
- if (u(), typeof MutationObserver > "u") return;
19
- const e = new MutationObserver(u);
20
- return e.observe(o, { subtree: !0, childList: !0, attributes: !0, attributeFilter: ["aria-controls"] }), () => e.disconnect();
21
- }, []), /* @__PURE__ */ a(V, { ...g, ref: d, "data-variant": v, "data-size": i, "data-fitted": c || void 0, "data-justify": h, className: w("alea-tabs", l) });
18
+ if (v(), typeof MutationObserver > "u") return;
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 le({ className: v, extra: i, onReorder: c, ...h }) {
24
- const l = F(), g = y(null), { edges: d, scroll: o } = C(g, ".alea-tab-list"), [u, e] = K(""), n = W(), b = y(c);
25
- return b.current = c, S(() => {
26
- var P;
27
- const r = (P = g.current) == null ? void 0 : P.querySelector(".alea-tab-list");
28
- if (!r || !c) return;
29
- const m = () => Array.from(r.querySelectorAll('[role="tab"]')), L = () => m().forEach((t) => {
30
- t.setAttribute("draggable", "true"), t.setAttribute("aria-describedby", n), t.setAttribute("aria-keyshortcuts", "Alt+Shift+ArrowLeft Alt+Shift+ArrowRight");
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
+ }
27
+ function B(i, o) {
28
+ E(() => {
29
+ var v, s;
30
+ const a = (v = i.current) == null ? void 0 : v.querySelector(".alea-tab-list");
31
+ if (!a) return;
32
+ const u = () => {
33
+ const c = a.querySelector(o);
34
+ c && _(a, c);
35
+ };
36
+ u();
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();
42
+ });
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();
48
+ };
49
+ }, [i, o]);
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();
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");
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");
31
61
  });
32
- L();
33
- const x = new MutationObserver(L);
34
- x.observe(r, { childList: !0 });
35
- const E = () => r.getAttribute("aria-orientation") === "vertical", T = (t, s) => {
36
- var A;
37
- const k = m(), p = t.dataset.key;
38
- s = Math.max(0, Math.min(k.length - 1, s)), s !== k.indexOf(t) && ((A = b.current) == null || A.call(b, p, s), e(l.movedTo(t.textContent ?? p, s + 1, k.length)), requestAnimationFrame(() => {
39
- var M;
40
- return (M = r.querySelector(`[data-key="${CSS.escape(p)}"]`)) == null ? void 0 : M.focus();
62
+ S();
63
+ const x = new MutationObserver(S);
64
+ x.observe(d, { childList: !0 });
65
+ const A = () => d.getAttribute("aria-orientation") === "vertical", T = (e, f) => {
66
+ var N;
67
+ const L = y(), g = e.dataset.key;
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
+ var P;
70
+ return (P = d.querySelector(`[data-key="${CSS.escape(g)}"]`)) == null ? void 0 : P.focus();
41
71
  }));
42
- }, D = (t) => {
43
- const s = t.target.closest('[role="tab"]');
44
- if (!s || !t.altKey || !t.shiftKey) return;
45
- const k = E() ? "ArrowUp" : "ArrowLeft", p = E() ? "ArrowDown" : "ArrowRight";
46
- if (t.key !== k && t.key !== p) return;
47
- t.preventDefault(), t.stopPropagation();
48
- const A = getComputedStyle(r).direction === "rtl" && !E();
49
- T(s, m().indexOf(s) + (t.key === p !== A ? 1 : -1));
72
+ }, O = (e) => {
73
+ const f = e.target.closest('[role="tab"]');
74
+ if (!f || !e.altKey || !e.shiftKey) return;
75
+ const L = A() ? "ArrowUp" : "ArrowLeft", g = A() ? "ArrowDown" : "ArrowRight";
76
+ if (e.key !== L && e.key !== g) return;
77
+ e.preventDefault(), e.stopPropagation();
78
+ const N = getComputedStyle(d).direction === "rtl" && !A();
79
+ T(f, y().indexOf(f) + (e.key === g !== N ? 1 : -1));
50
80
  };
51
- let f = null;
52
- const I = (t) => {
53
- var s;
54
- f = t.target.closest('[role="tab"]'), f && ((s = t.dataTransfer) == null || s.setData("text/plain", f.dataset.key ?? ""), f.dataset.dragging = "true");
55
- }, q = (t) => {
56
- f && t.preventDefault();
57
- }, z = (t) => {
58
- const s = t.target.closest('[role="tab"]');
59
- f && s && s !== f && (t.preventDefault(), T(f, m().indexOf(s)));
60
- }, O = () => {
61
- f && delete f.dataset.dragging, f = null;
81
+ let m = null;
82
+ const D = (e) => {
83
+ var f;
84
+ m = e.target.closest('[role="tab"]'), m && ((f = e.dataTransfer) == null || f.setData("text/plain", m.dataset.key ?? ""), m.dataset.dragging = "true");
85
+ }, z = (e) => {
86
+ m && e.preventDefault();
87
+ }, I = (e) => {
88
+ const f = e.target.closest('[role="tab"]');
89
+ m && f && f !== m && (e.preventDefault(), T(m, y().indexOf(f)));
90
+ }, q = () => {
91
+ m && delete m.dataset.dragging, m = null;
62
92
  };
63
- return r.addEventListener("keydown", D, !0), r.addEventListener("dragstart", I), r.addEventListener("dragover", q), r.addEventListener("drop", z), r.addEventListener("dragend", O), () => {
64
- x.disconnect(), r.removeEventListener("keydown", D, !0), r.removeEventListener("dragstart", I), r.removeEventListener("dragover", q), r.removeEventListener("drop", z), r.removeEventListener("dragend", O), m().forEach((t) => {
65
- t.removeAttribute("draggable"), t.removeAttribute("aria-describedby"), t.removeAttribute("aria-keyshortcuts");
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) => {
95
+ e.removeAttribute("draggable"), e.removeAttribute("aria-describedby"), e.removeAttribute("aria-keyshortcuts");
66
96
  });
67
97
  };
68
- }, [!!c, n]), /* @__PURE__ */ N("div", { ref: g, className: "alea-tab-bar", "data-overflow-start": d.start || void 0, "data-overflow-end": d.end || void 0, "data-reorderable": c ? !0 : void 0, children: [
69
- d.start && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => o(-1), children: /* @__PURE__ */ a(j, { size: 16 }) }),
70
- /* @__PURE__ */ a(G, { ...h, "aria-label": h["aria-label"], className: w("alea-tab-list", v) }),
71
- d.end && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => o(1), children: /* @__PURE__ */ a(B, { size: 16 }) }),
72
- i && /* @__PURE__ */ a("div", { className: "alea-tab-extra", children: i }),
73
- c && /* @__PURE__ */ N($, { children: [
74
- /* @__PURE__ */ a("span", { id: n, hidden: !0, children: l.reorderHint }),
75
- /* @__PURE__ */ a("span", { className: "alea-visually-hidden", role: "status", children: u })
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 })
76
106
  ] })
77
107
  ] });
78
108
  }
79
- function oe({ className: v, children: i, icon: c, badge: h, onClose: l, ...g }) {
80
- const d = F(), o = y(null), u = y(l);
81
- return u.current = l, S(() => {
82
- const e = o.current;
83
- if (!e || !l) return;
84
- e.setAttribute("aria-keyshortcuts", "Delete");
85
- const n = (b) => {
86
- var r;
87
- (b.key === "Delete" || b.key === "Backspace") && (b.preventDefault(), (r = u.current) == null || r.call(u));
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) => {
116
+ var d;
117
+ (h.key === "Delete" || h.key === "Backspace") && (h.preventDefault(), (d = v.current) == null || d.call(v));
88
118
  };
89
- return e.addEventListener("keydown", n), () => e.removeEventListener("keydown", n);
90
- }, [!!l]), /* @__PURE__ */ a(U, { ...g, ref: o, className: w("alea-tab alea-focus-ring", v), "data-closable": l ? !0 : void 0, children: (e) => /* @__PURE__ */ N($, { children: [
91
- c && /* @__PURE__ */ a("span", { className: "alea-tab-icon", "aria-hidden": "true", ...Z(e.isSelected), children: c }),
92
- /* @__PURE__ */ a("span", { className: "alea-tab-label", children: typeof i == "function" ? i(e) : i }),
93
- h != null && /* @__PURE__ */ a("span", { className: "alea-tab-badge", children: h }),
94
- l && /* @__PURE__ */ a("span", { className: "alea-tab-close", "aria-hidden": "true", title: d.close, onPointerDown: (n) => n.stopPropagation(), onClick: (n) => {
95
- n.stopPropagation(), l();
96
- }, children: /* @__PURE__ */ a(Y, { size: 12 }) }),
97
- /* @__PURE__ */ a(X, { className: "alea-sel-indicator" })
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" })
98
128
  ] }) });
99
129
  }
100
- function ce({ className: v, ...i }) {
101
- return i.children == null || i.children === !1 ? null : /* @__PURE__ */ a(Q, { ...i, className: w("alea-tab-panel alea-focus-ring", v) });
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) });
102
132
  }
103
- function de({ items: v, current: i, variant: c = "underline", size: h, className: l, "aria-label": g }) {
104
- const d = y(null), { edges: o, scroll: u } = C(d, ".alea-tab-list");
105
- return S(() => {
106
- var L;
107
- const e = (L = d.current) == null ? void 0 : L.querySelector(".alea-tab-list"), n = e == null ? void 0 : e.querySelector('[aria-current="page"]');
108
- if (!e || !n) return;
109
- const b = n.offsetLeft - e.offsetLeft, r = b + n.offsetWidth, m = 56;
110
- r > e.scrollLeft + e.clientWidth - m ? e.scrollLeft = r - e.clientWidth + m : b < e.scrollLeft + m && (e.scrollLeft = Math.max(0, b - m));
111
- }, [i]), /* @__PURE__ */ a("nav", { "aria-label": g, className: ["alea-tabs alea-tab-nav", l].filter(Boolean).join(" "), "data-variant": c, "data-size": h, children: /* @__PURE__ */ N("div", { ref: d, className: "alea-tab-bar", "data-overflow-start": o.start || void 0, "data-overflow-end": o.end || void 0, children: [
112
- o.start && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "start", onClick: () => u(-1), children: /* @__PURE__ */ a(j, { size: 16 }) }),
113
- /* @__PURE__ */ a("div", { className: "alea-tab-list", children: v.map((e) => {
114
- const n = e.id === i;
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);
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);
121
145
  }) }),
122
- o.end && /* @__PURE__ */ a("button", { type: "button", tabIndex: -1, "aria-hidden": "true", className: "alea-tab-scroll", "data-side": "end", onClick: () => u(1), children: /* @__PURE__ */ a(B, { size: 16 }) })
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 }) })
123
147
  ] }) });
124
148
  }
125
149
  export {
126
- oe as Tab,
127
- le as TabList,
128
- de as TabNav,
129
- ce as TabPanel,
130
- ie as Tabs
150
+ de as Tab,
151
+ ce as TabList,
152
+ be as TabNav,
153
+ ue as TabPanel,
154
+ oe as Tabs
131
155
  };
@@ -269,6 +269,7 @@ export interface AleaStrings {
269
269
  schedulerBlocked: string;
270
270
  schedulerResource: (label: string) => string;
271
271
  allDay: string;
272
+ schedulerAgenda: string;
272
273
  previousPeriod: string;
273
274
  nextPeriod: string;
274
275
  nowLabel: string;
@@ -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.4",
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.4",
65
- "@alea-design/tokens": "0.10.4",
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",