@cascivo/react 0.6.3 → 0.7.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.
- package/README.md +13 -4
- package/dist/breadcrumb/breadcrumb.js +15 -15
- package/dist/card/card.css +1 -1
- package/dist/card/card.module.js +5 -5
- package/dist/dock/dock.js +21 -21
- package/dist/header/header.js +20 -20
- package/dist/index.d.ts +26 -1
- package/dist/layouts/src/columns/columns.css +1 -1
- package/dist/layouts/src/columns/columns.js +7 -3
- package/dist/layouts/src/columns/columns.module.js +4 -1
- package/dist/layouts/src/grid/grid.css +1 -1
- package/dist/layouts/src/grid/grid.js +6 -3
- package/dist/layouts/src/grid/grid.module.js +3 -2
- package/dist/navigation-menu/navigation-menu.js +54 -50
- package/dist/relative-time/relative-time.js +2 -1
- package/dist/search/search.css +1 -1
- package/dist/search/search.module.js +5 -5
- package/dist/shell-header/shell-header.js +63 -63
- package/dist/side-nav/side-nav.js +127 -120
- package/dist/styles.css +5 -5
- package/dist/switcher/switcher.js +13 -11
- package/dist/toast/toast.css +1 -1
- package/dist/toast/toast.module.js +7 -7
- package/dist/toc/use-toc-from-region.js +8 -7
- package/package.json +3 -3
- package/readme.body.md +13 -4
|
@@ -2,51 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
import { usePopover as e } from "../popover/use-popover.js";
|
|
4
4
|
import t from "./shell-header.module.js";
|
|
5
|
-
import { cn as n,
|
|
6
|
-
import { builtin as
|
|
7
|
-
import { jsx as
|
|
5
|
+
import { cn as n, getLinkComponent as r, useSignal as i, useSignalEffect as a, useSignals as o } from "@cascivo/core";
|
|
6
|
+
import { builtin as s, t as c } from "@cascivo/i18n";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
8
|
//#region ../components/src/shell-header/shell-header.tsx
|
|
9
|
-
function
|
|
9
|
+
function d(e) {
|
|
10
10
|
return typeof e == "object" && !!e && "name" in e;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function f(e) {
|
|
13
13
|
return "items" in e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
let { triggerRef:
|
|
18
|
-
|
|
19
|
-
if (!
|
|
20
|
-
|
|
21
|
-
let e =
|
|
15
|
+
function p({ item: n }) {
|
|
16
|
+
o();
|
|
17
|
+
let s = r(), { triggerRef: c, popoverRef: d, isOpen: f, anchorName: p, toggle: m, close: h } = e(), g = n.items.some((e) => e.active), _ = i(!1);
|
|
18
|
+
a(() => {
|
|
19
|
+
if (!_.value || !f.value) return;
|
|
20
|
+
_.value = !1;
|
|
21
|
+
let e = d.current;
|
|
22
22
|
e && e.querySelector("[role=\"menuitem\"]")?.focus();
|
|
23
23
|
});
|
|
24
|
-
function
|
|
25
|
-
e.key === "ArrowDown" ? (e.preventDefault(),
|
|
24
|
+
function v(e) {
|
|
25
|
+
e.key === "ArrowDown" ? (e.preventDefault(), f.value ? d.current?.querySelector("[role=\"menuitem\"]")?.focus() : (_.value = !0, m())) : e.key === "Escape" && (e.preventDefault(), h());
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
let t = Array.from(
|
|
29
|
-
e.key === "ArrowDown" ? (e.preventDefault(), t[(n + 1) % t.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus()) : e.key === "Escape" && (
|
|
27
|
+
function y(e) {
|
|
28
|
+
let t = Array.from(d.current?.querySelectorAll("[role=\"menuitem\"]") ?? []), n = t.indexOf(document.activeElement);
|
|
29
|
+
e.key === "ArrowDown" ? (e.preventDefault(), t[(n + 1) % t.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus()) : e.key === "Escape" && (h(), c.current?.focus());
|
|
30
30
|
}
|
|
31
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ u("li", {
|
|
32
32
|
className: t.navMenuWrapper,
|
|
33
|
-
children: [/* @__PURE__ */
|
|
34
|
-
ref:
|
|
33
|
+
children: [/* @__PURE__ */ u("button", {
|
|
34
|
+
ref: c,
|
|
35
35
|
type: "button",
|
|
36
36
|
"aria-haspopup": "menu",
|
|
37
|
-
"aria-expanded":
|
|
38
|
-
"data-state":
|
|
39
|
-
style: { anchorName:
|
|
37
|
+
"aria-expanded": f.value,
|
|
38
|
+
"data-state": g ? "active" : void 0,
|
|
39
|
+
style: { anchorName: p },
|
|
40
40
|
className: t.navMenuTrigger,
|
|
41
|
-
onClick:
|
|
42
|
-
onKeyDown:
|
|
43
|
-
children: [n.label, /* @__PURE__ */
|
|
41
|
+
onClick: m,
|
|
42
|
+
onKeyDown: v,
|
|
43
|
+
children: [n.label, /* @__PURE__ */ l("svg", {
|
|
44
44
|
viewBox: "0 0 16 16",
|
|
45
45
|
width: "12",
|
|
46
46
|
height: "12",
|
|
47
47
|
"aria-hidden": "true",
|
|
48
48
|
className: t.chevron,
|
|
49
|
-
children: /* @__PURE__ */
|
|
49
|
+
children: /* @__PURE__ */ l("path", {
|
|
50
50
|
d: "M4 6l4 4 4-4",
|
|
51
51
|
fill: "none",
|
|
52
52
|
stroke: "currentColor",
|
|
@@ -55,51 +55,51 @@ function f({ item: n }) {
|
|
|
55
55
|
strokeLinejoin: "round"
|
|
56
56
|
})
|
|
57
57
|
})]
|
|
58
|
-
}), /* @__PURE__ */
|
|
59
|
-
ref:
|
|
58
|
+
}), /* @__PURE__ */ l("div", {
|
|
59
|
+
ref: d,
|
|
60
60
|
popover: "auto",
|
|
61
61
|
role: "menu",
|
|
62
62
|
"aria-label": n.label,
|
|
63
|
-
"data-state":
|
|
64
|
-
style: { positionAnchor:
|
|
63
|
+
"data-state": f.value ? "open" : "closed",
|
|
64
|
+
style: { positionAnchor: p },
|
|
65
65
|
className: t.navMenuPanel,
|
|
66
|
-
onKeyDown:
|
|
67
|
-
children: n.items.map((e, n) => /* @__PURE__ */
|
|
66
|
+
onKeyDown: y,
|
|
67
|
+
children: n.items.map((e, n) => /* @__PURE__ */ l(s, {
|
|
68
68
|
href: e.href,
|
|
69
69
|
role: "menuitem",
|
|
70
70
|
"aria-current": e.active ? "page" : void 0,
|
|
71
71
|
"data-state": e.active ? "active" : void 0,
|
|
72
72
|
className: t.navMenuItem,
|
|
73
|
-
onClick:
|
|
73
|
+
onClick: h,
|
|
74
74
|
children: e.label
|
|
75
75
|
}, e.id ?? `${n}-${e.href}`))
|
|
76
76
|
})]
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
let
|
|
82
|
-
return /* @__PURE__ */
|
|
79
|
+
function m({ brand: e, nav: i, actions: a, end: m, onMenuClick: h, menuExpanded: g, skipToContentHref: _ = "#cascade-main", labels: v, className: y }) {
|
|
80
|
+
o();
|
|
81
|
+
let b = r(), x = v?.nav ?? c(s.shellHeader.nav), S = g ? v?.closeMenu ?? c(s.shellHeader.closeMenu) : v?.openMenu ?? c(s.shellHeader.openMenu);
|
|
82
|
+
return /* @__PURE__ */ u("header", {
|
|
83
83
|
role: "banner",
|
|
84
|
-
className: n(t.header,
|
|
84
|
+
className: n(t.header, y),
|
|
85
85
|
children: [
|
|
86
|
-
|
|
87
|
-
href:
|
|
86
|
+
_ !== !1 && /* @__PURE__ */ l("a", {
|
|
87
|
+
href: _,
|
|
88
88
|
className: t.skipLink,
|
|
89
|
-
children:
|
|
89
|
+
children: v?.skipToContent ?? c(s.shellHeader.skipToContent)
|
|
90
90
|
}),
|
|
91
|
-
|
|
91
|
+
h && /* @__PURE__ */ l("button", {
|
|
92
92
|
type: "button",
|
|
93
|
-
"aria-label":
|
|
94
|
-
"aria-expanded":
|
|
93
|
+
"aria-label": S,
|
|
94
|
+
"aria-expanded": g ?? !1,
|
|
95
95
|
className: t.menuButton,
|
|
96
|
-
onClick:
|
|
97
|
-
children: /* @__PURE__ */
|
|
96
|
+
onClick: h,
|
|
97
|
+
children: /* @__PURE__ */ l("svg", {
|
|
98
98
|
viewBox: "0 0 16 16",
|
|
99
99
|
width: "16",
|
|
100
100
|
height: "16",
|
|
101
101
|
"aria-hidden": "true",
|
|
102
|
-
children: /* @__PURE__ */
|
|
102
|
+
children: /* @__PURE__ */ l("path", {
|
|
103
103
|
d: "M2 4h12M2 8h12M2 12h12",
|
|
104
104
|
stroke: "currentColor",
|
|
105
105
|
strokeWidth: "1.5",
|
|
@@ -107,27 +107,27 @@ function p({ brand: e, nav: r, actions: i, end: p, onMenuClick: m, menuExpanded:
|
|
|
107
107
|
})
|
|
108
108
|
})
|
|
109
109
|
}),
|
|
110
|
-
e != null && (
|
|
110
|
+
e != null && (d(e) ? /* @__PURE__ */ u(b, {
|
|
111
111
|
href: e.href ?? "/",
|
|
112
112
|
"aria-label": [e.prefix, e.name].filter(Boolean).join(" "),
|
|
113
113
|
className: t.brand,
|
|
114
|
-
children: [e.prefix && /* @__PURE__ */
|
|
114
|
+
children: [e.prefix && /* @__PURE__ */ l("span", {
|
|
115
115
|
className: t.brandPrefix,
|
|
116
116
|
children: e.prefix
|
|
117
|
-
}), /* @__PURE__ */
|
|
117
|
+
}), /* @__PURE__ */ l("span", {
|
|
118
118
|
className: t.brandName,
|
|
119
119
|
children: e.name
|
|
120
120
|
})]
|
|
121
|
-
}) : /* @__PURE__ */
|
|
121
|
+
}) : /* @__PURE__ */ l("div", {
|
|
122
122
|
className: t.brand,
|
|
123
123
|
children: e
|
|
124
124
|
})),
|
|
125
|
-
|
|
126
|
-
"aria-label":
|
|
125
|
+
i && i.length > 0 && /* @__PURE__ */ l("nav", {
|
|
126
|
+
"aria-label": x,
|
|
127
127
|
className: t.nav,
|
|
128
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ l("ul", {
|
|
129
129
|
className: t.navList,
|
|
130
|
-
children:
|
|
130
|
+
children: i.map((e, n) => f(e) ? /* @__PURE__ */ l(p, { item: e }, e.id ?? `${n}-${e.label}`) : /* @__PURE__ */ l("li", { children: /* @__PURE__ */ l(b, {
|
|
131
131
|
href: e.href,
|
|
132
132
|
"aria-current": e.active ? "page" : void 0,
|
|
133
133
|
"data-state": e.active ? "active" : void 0,
|
|
@@ -137,10 +137,10 @@ function p({ brand: e, nav: r, actions: i, end: p, onMenuClick: m, menuExpanded:
|
|
|
137
137
|
}) }, e.id ?? `${n}-${e.href}`))
|
|
138
138
|
})
|
|
139
139
|
}),
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
|
|
140
|
+
/* @__PURE__ */ l("div", { className: t.spacer }),
|
|
141
|
+
a && a.length > 0 && /* @__PURE__ */ l("div", {
|
|
142
142
|
className: t.actions,
|
|
143
|
-
children:
|
|
143
|
+
children: a.map((e) => /* @__PURE__ */ l("button", {
|
|
144
144
|
type: "button",
|
|
145
145
|
"aria-label": e.label,
|
|
146
146
|
"aria-pressed": e.active ?? !1,
|
|
@@ -148,19 +148,19 @@ function p({ brand: e, nav: r, actions: i, end: p, onMenuClick: m, menuExpanded:
|
|
|
148
148
|
"data-state": e.active ? "active" : void 0,
|
|
149
149
|
className: t.action,
|
|
150
150
|
onClick: e.onClick,
|
|
151
|
-
children: /* @__PURE__ */
|
|
151
|
+
children: /* @__PURE__ */ l("span", {
|
|
152
152
|
className: t.actionIcon,
|
|
153
153
|
"aria-hidden": "true",
|
|
154
154
|
children: e.icon
|
|
155
155
|
})
|
|
156
156
|
}, e.id))
|
|
157
157
|
}),
|
|
158
|
-
|
|
158
|
+
m && /* @__PURE__ */ l("div", {
|
|
159
159
|
className: t.end,
|
|
160
|
-
children:
|
|
160
|
+
children: m
|
|
161
161
|
})
|
|
162
162
|
]
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
//#endregion
|
|
166
|
-
export {
|
|
166
|
+
export { m as ShellHeader };
|