@alea-design/ui 0.8.1 → 0.9.0

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,57 +1,77 @@
1
1
  "use client";
2
- import { jsxs as d, jsx as a, Fragment as C } from "react/jsx-runtime";
3
- import { useState as M, forwardRef as O } from "react";
4
- import { Link as j } from "react-aria-components";
5
- import { Menu as D } from "lucide-react";
6
- import { cx as u, withBase as G } from "../../utils/cx.js";
7
- import { useMediaQuery as I } from "../layout/Responsive.js";
8
- import { IconButton as $ } from "../button/Button.js";
9
- import { Drawer as A } from "../overlay/Drawer.js";
10
- import { Dialog as F } from "../overlay/Overlay.js";
11
- import { useStrings as g } from "../../i18n/strings.js";
12
- import { SkipLink as P } from "../more/More.js";
13
- function X({ brand: r, headerEnd: l, sidebar: e, children: s, sidebarWidth: t = 248, collapseBelow: n = 900, mainAs: c = "main", layout: o = "header", contentSize: m, skipLink: i, bottomBar: p, className: b }) {
14
- const f = g(), x = c, [S, h] = M(!1), w = I(`(max-width: ${n - 0.02}px)`), v = /* @__PURE__ */ d("header", { className: "alea-shell-header", children: [
15
- e && /* @__PURE__ */ a($, { "aria-label": f.openNavigation, className: "alea-shell-menu", onPress: () => h(!0), children: /* @__PURE__ */ a(D, {}) }),
16
- r && /* @__PURE__ */ a("div", { className: "alea-shell-brand", children: r }),
17
- l && /* @__PURE__ */ a("div", { className: "alea-shell-end", children: l })
18
- ] }), N = /* @__PURE__ */ a(x, { id: "alea-main", className: "alea-shell-main", tabIndex: -1, children: m && m !== "full" ? /* @__PURE__ */ a("div", { className: "alea-shell-content", "data-size": m, children: s }) : s });
19
- return /* @__PURE__ */ d("div", { className: u("alea-shell", b), style: { "--alea-shell-sidebar": `${t}px` }, "data-layout": o, "data-collapse": n, "data-collapsed": w || void 0, "data-custom-collapse": n !== 900 || void 0, children: [
20
- i !== !1 && /* @__PURE__ */ a(P, { target: (i == null ? void 0 : i.target) ?? "alea-main", children: i == null ? void 0 : i.label }),
21
- o === "header" && v,
22
- /* @__PURE__ */ d("div", { className: "alea-shell-body", children: [
23
- e && /* @__PURE__ */ a("aside", { className: "alea-shell-sidebar", children: e }),
24
- o === "sidebar" ? /* @__PURE__ */ d("div", { className: "alea-shell-panel", children: [
25
- v,
26
- N
27
- ] }) : N
2
+ import { jsxs as c, jsx as e, Fragment as R } from "react/jsx-runtime";
3
+ import { useState as $, useRef as D, useEffect as P, forwardRef as Q } from "react";
4
+ import { Link as z } from "react-aria-components";
5
+ import { Menu as E } from "lucide-react";
6
+ import { cx as g, withBase as H } from "../../utils/cx.js";
7
+ import { useMediaQuery as J } from "../layout/Responsive.js";
8
+ import { IconButton as K } from "../button/Button.js";
9
+ import { Drawer as T } from "../overlay/Drawer.js";
10
+ import { Dialog as U } from "../overlay/Overlay.js";
11
+ import { useStrings as M } from "../../i18n/strings.js";
12
+ import { SkipLink as V } from "../more/More.js";
13
+ function re({ brand: n, headerEnd: l, sidebar: a, children: r, sidebarWidth: o = 248, collapseBelow: s = 900, mainAs: u = "main", layout: h = "header", contentSize: f, skipLink: t, bottomBar: x, focusAfterNavigate: S = "heading", className: O }) {
14
+ const q = M(), j = u, [p, v] = $(!1), N = D(null), b = D(!1);
15
+ P(() => {
16
+ if (p || !b.current || (b.current = !1, S !== "heading")) return;
17
+ let i = 0, I = 0;
18
+ const w = () => {
19
+ var F;
20
+ if ((F = N.current) != null && F.ownerDocument.querySelector(".alea-drawer") && I++ < 90) {
21
+ i = requestAnimationFrame(w);
22
+ return;
23
+ }
24
+ i = requestAnimationFrame(() => {
25
+ i = requestAnimationFrame(() => {
26
+ var C;
27
+ const d = (C = N.current) == null ? void 0 : C.querySelector(".alea-shell-main"), m = (d == null ? void 0 : d.querySelector("h1")) ?? d;
28
+ m && (m.hasAttribute("tabindex") || m.setAttribute("tabindex", "-1"), m.focus());
29
+ });
30
+ });
31
+ };
32
+ return i = requestAnimationFrame(w), () => cancelAnimationFrame(i);
33
+ }, [p, S]);
34
+ const G = J(`(max-width: ${s - 0.02}px)`), y = /* @__PURE__ */ c("header", { className: "alea-shell-header", children: [
35
+ a && /* @__PURE__ */ e(K, { "aria-label": q.openNavigation, className: "alea-shell-menu", onPress: () => v(!0), children: /* @__PURE__ */ e(E, {}) }),
36
+ n && /* @__PURE__ */ e("div", { className: "alea-shell-brand", children: n }),
37
+ l && /* @__PURE__ */ e("div", { className: "alea-shell-end", children: l })
38
+ ] }), A = /* @__PURE__ */ e(j, { id: "alea-main", className: "alea-shell-main", tabIndex: -1, children: f && f !== "full" ? /* @__PURE__ */ e("div", { className: "alea-shell-content", "data-size": f, children: r }) : r });
39
+ return /* @__PURE__ */ c("div", { ref: N, className: g("alea-shell", O), style: { "--alea-shell-sidebar": `${o}px` }, "data-layout": h, "data-collapse": s, "data-collapsed": G || void 0, "data-custom-collapse": s !== 900 || void 0, children: [
40
+ t !== !1 && /* @__PURE__ */ e(V, { target: (t == null ? void 0 : t.target) ?? "alea-main", children: t == null ? void 0 : t.label }),
41
+ h === "header" && y,
42
+ /* @__PURE__ */ c("div", { className: "alea-shell-body", children: [
43
+ a && /* @__PURE__ */ e("aside", { className: "alea-shell-sidebar", children: a }),
44
+ h === "sidebar" ? /* @__PURE__ */ c("div", { className: "alea-shell-panel", children: [
45
+ y,
46
+ A
47
+ ] }) : A
28
48
  ] }),
29
- p && /* @__PURE__ */ a("div", { className: "alea-shell-bottom", children: p }),
30
- e && /* @__PURE__ */ a(A, { isOpen: S, onOpenChange: h, placement: "start", size: 300, children: /* @__PURE__ */ a(F, { "aria-label": f.navigation, hideClose: !0, className: "alea-shell-drawer", children: () => /* @__PURE__ */ a("div", { className: "alea-shell-drawer-body", onClickCapture: (y) => {
31
- y.target.closest("a") && h(!1);
32
- }, children: e }) }) })
49
+ x && /* @__PURE__ */ e("div", { className: "alea-shell-bottom", children: x }),
50
+ a && /* @__PURE__ */ e(T, { isOpen: p, onOpenChange: v, placement: "start", size: 300, children: /* @__PURE__ */ e(U, { "aria-label": q.navigation, hideClose: !0, className: "alea-shell-drawer", children: () => /* @__PURE__ */ e("div", { className: "alea-shell-drawer-body", onClickCapture: (i) => {
51
+ i.target.closest("a") && (b.current = !0, v(!1));
52
+ }, children: a }) }) })
33
53
  ] });
34
54
  }
35
- function Y({ children: r, className: l, "aria-label": e }) {
36
- const s = g();
37
- return e ?? (e = s.mainNav), /* @__PURE__ */ a("nav", { "aria-label": e, className: u("alea-sidenav", l), children: r });
55
+ function ne({ children: n, className: l, "aria-label": a }) {
56
+ const r = M();
57
+ return a ?? (a = r.mainNav), /* @__PURE__ */ e("nav", { "aria-label": a, className: g("alea-sidenav", l), children: n });
38
58
  }
39
- const Z = O(function({ title: l, children: e, className: s, ...t }, n) {
40
- return /* @__PURE__ */ d("div", { ref: n, ...t, className: u("alea-sidenav-group", s), children: [
41
- l && /* @__PURE__ */ a("p", { className: "alea-sidenav-title", children: l }),
42
- /* @__PURE__ */ a("ul", { children: e })
59
+ const se = Q(function({ title: l, children: a, className: r, ...o }, s) {
60
+ return /* @__PURE__ */ c("div", { ref: s, ...o, className: g("alea-sidenav-group", r), children: [
61
+ l && /* @__PURE__ */ e("p", { className: "alea-sidenav-title", children: l }),
62
+ /* @__PURE__ */ e("ul", { children: a })
43
63
  ] });
44
64
  });
45
- function _({ isCurrent: r, icon: l, end: e, children: s, className: t, ...n }) {
46
- return /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(j, { ...n, "aria-current": r ? "page" : void 0, className: G("alea-sidenav-link alea-focus-ring", t), children: (c) => /* @__PURE__ */ d(C, { children: [
47
- l && /* @__PURE__ */ a("span", { className: "alea-sidenav-icon", "aria-hidden": "true", children: l }),
48
- /* @__PURE__ */ a("span", { className: "alea-sidenav-label", children: typeof s == "function" ? s(c) : s }),
49
- e && /* @__PURE__ */ a("span", { className: "alea-sidenav-end", children: e })
65
+ function te({ isCurrent: n, icon: l, end: a, children: r, className: o, ...s }) {
66
+ return /* @__PURE__ */ e("li", { children: /* @__PURE__ */ e(z, { ...s, "aria-current": n ? "page" : void 0, className: H("alea-sidenav-link alea-focus-ring", o), children: (u) => /* @__PURE__ */ c(R, { children: [
67
+ l && /* @__PURE__ */ e("span", { className: "alea-sidenav-icon", "aria-hidden": "true", children: l }),
68
+ /* @__PURE__ */ e("span", { className: "alea-sidenav-label", children: typeof r == "function" ? r(u) : r }),
69
+ a && /* @__PURE__ */ e("span", { className: "alea-sidenav-end", children: a })
50
70
  ] }) }) });
51
71
  }
52
72
  export {
53
- X as AppShell,
54
- Z as SidebarGroup,
55
- _ as SidebarLink,
56
- Y as SidebarNav
73
+ re as AppShell,
74
+ se as SidebarGroup,
75
+ te as SidebarLink,
76
+ ne as SidebarNav
57
77
  };