@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.
@@ -1,131 +1,153 @@
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 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 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 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 (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 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 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 _(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
- 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();
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
- }, 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));
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 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;
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 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");
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
- }, [!!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 })
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 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));
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 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" })
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 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) });
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 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);
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
- 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 }) })
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
- oe as Tab,
127
- le as TabList,
128
- de as TabNav,
129
- ce as TabPanel,
130
- ie as Tabs
148
+ de as Tab,
149
+ ce as TabList,
150
+ be as TabNav,
151
+ ue as TabPanel,
152
+ oe as Tabs
131
153
  };
@@ -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.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.4",
65
- "@alea-design/tokens": "0.10.4",
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",