@tomny-dev/uzi 0.5.0 → 0.6.0-pr.60.171.1.16c745f
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 +5 -2
- package/dist/components/card/Card.d.ts +7 -5
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/page-container/PageContainer.d.ts +2 -1
- package/dist/components/page-container/PageContainer.d.ts.map +1 -1
- package/dist/components/surface/Surface.d.ts +16 -0
- package/dist/components/surface/Surface.d.ts.map +1 -0
- package/dist/components/toolbar/Toolbar.d.ts +13 -0
- package/dist/components/toolbar/Toolbar.d.ts.map +1 -0
- package/dist/index.cjs +36 -31
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -32
- package/dist/index10.cjs.map +1 -1
- package/dist/index10.js +19 -15
- package/dist/index10.js.map +1 -1
- package/dist/index11.cjs +21 -18
- package/dist/index11.cjs.map +1 -1
- package/dist/index11.js +8 -15
- package/dist/index11.js.map +1 -1
- package/dist/index12.cjs +7 -14
- package/dist/index12.cjs.map +1 -1
- package/dist/index12.js +15 -37
- package/dist/index12.js.map +1 -1
- package/dist/index13.cjs +18 -52
- package/dist/index13.cjs.map +1 -1
- package/dist/index13.js +15 -77
- package/dist/index13.js.map +1 -1
- package/dist/index14.cjs +15 -80
- package/dist/index14.cjs.map +1 -1
- package/dist/index14.js +37 -13
- package/dist/index14.js.map +1 -1
- package/dist/index15.cjs +52 -18
- package/dist/index15.cjs.map +1 -1
- package/dist/index15.js +77 -9
- package/dist/index15.js.map +1 -1
- package/dist/index16.cjs +79 -8
- package/dist/index16.cjs.map +1 -1
- package/dist/index16.js +13 -41
- package/dist/index16.js.map +1 -1
- package/dist/index17.cjs +18 -60
- package/dist/index17.cjs.map +1 -1
- package/dist/index17.js +9 -428
- package/dist/index17.js.map +1 -1
- package/dist/index18.cjs +8 -430
- package/dist/index18.cjs.map +1 -1
- package/dist/index18.js +42 -4
- package/dist/index18.js.map +1 -1
- package/dist/index19.cjs +61 -5
- package/dist/index19.cjs.map +1 -1
- package/dist/index19.js +430 -13
- package/dist/index19.js.map +1 -1
- package/dist/index20.cjs +430 -12
- package/dist/index20.cjs.map +1 -1
- package/dist/index20.js +4 -4
- package/dist/index20.js.map +1 -1
- package/dist/index21.cjs +5 -5
- package/dist/index21.cjs.map +1 -1
- package/dist/index21.js +12 -9
- package/dist/index21.js.map +1 -1
- package/dist/index22.cjs +12 -9
- package/dist/index22.cjs.map +1 -1
- package/dist/index22.js +4 -4
- package/dist/index22.js.map +1 -1
- package/dist/index23.cjs +5 -5
- package/dist/index23.cjs.map +1 -1
- package/dist/index23.js +9 -12
- package/dist/index23.js.map +1 -1
- package/dist/index24.cjs +9 -12
- package/dist/index24.cjs.map +1 -1
- package/dist/index24.js +4 -38
- package/dist/index24.js.map +1 -1
- package/dist/index25.cjs +5 -55
- package/dist/index25.cjs.map +1 -1
- package/dist/index25.js +11 -116
- package/dist/index25.js.map +1 -1
- package/dist/index26.cjs +10 -116
- package/dist/index26.cjs.map +1 -1
- package/dist/index26.js +31 -19
- package/dist/index26.js.map +1 -1
- package/dist/index27.cjs +42 -24
- package/dist/index27.cjs.map +1 -1
- package/dist/index27.js +106 -93
- package/dist/index27.js.map +1 -1
- package/dist/index28.cjs +106 -93
- package/dist/index28.cjs.map +1 -1
- package/dist/index28.js +26 -23
- package/dist/index28.js.map +1 -1
- package/dist/index29.cjs +37 -25
- package/dist/index29.cjs.map +1 -1
- package/dist/index29.js +107 -26
- package/dist/index29.js.map +1 -1
- package/dist/index30.cjs +110 -37
- package/dist/index30.cjs.map +1 -1
- package/dist/index30.js +21 -113
- package/dist/index30.js.map +1 -1
- package/dist/index31.cjs +19 -125
- package/dist/index31.cjs.map +1 -1
- package/dist/index31.js +26 -17
- package/dist/index31.js.map +1 -1
- package/dist/index32.cjs +37 -20
- package/dist/index32.cjs.map +1 -1
- package/dist/index32.js +108 -104
- package/dist/index32.js.map +1 -1
- package/dist/index33.cjs +122 -103
- package/dist/index33.cjs.map +1 -1
- package/dist/index33.js +17 -4
- package/dist/index33.js.map +1 -1
- package/dist/index34.cjs +20 -5
- package/dist/index34.cjs.map +1 -1
- package/dist/index34.js +106 -58
- package/dist/index34.js.map +1 -1
- package/dist/index35.cjs +106 -57
- package/dist/index35.cjs.map +1 -1
- package/dist/index35.js +4 -22
- package/dist/index35.js.map +1 -1
- package/dist/index36.cjs +5 -31
- package/dist/index36.cjs.map +1 -1
- package/dist/index36.js +55 -44
- package/dist/index36.js.map +1 -1
- package/dist/index37.cjs +55 -44
- package/dist/index37.cjs.map +1 -1
- package/dist/index37.js +21 -31
- package/dist/index37.js.map +1 -1
- package/dist/index38.cjs +30 -45
- package/dist/index38.cjs.map +1 -1
- package/dist/index38.js +46 -141
- package/dist/index38.js.map +1 -1
- package/dist/index39.cjs +46 -141
- package/dist/index39.cjs.map +1 -1
- package/dist/index39.js +31 -41
- package/dist/index39.js.map +1 -1
- package/dist/index40.cjs +45 -60
- package/dist/index40.cjs.map +1 -1
- package/dist/index40.js +139 -163
- package/dist/index40.js.map +1 -1
- package/dist/index41.cjs +137 -161
- package/dist/index41.cjs.map +1 -1
- package/dist/index41.js +41 -12
- package/dist/index41.js.map +1 -1
- package/dist/index42.cjs +60 -14
- package/dist/index42.cjs.map +1 -1
- package/dist/index42.js +167 -15
- package/dist/index42.js.map +1 -1
- package/dist/index43.cjs +166 -14
- package/dist/index43.cjs.map +1 -1
- package/dist/index43.js +12 -15
- package/dist/index43.js.map +1 -1
- package/dist/index44.cjs +14 -21
- package/dist/index44.cjs.map +1 -1
- package/dist/index44.js +15 -28
- package/dist/index44.js.map +1 -1
- package/dist/index45.cjs +14 -27
- package/dist/index45.cjs.map +1 -1
- package/dist/index45.js +10 -8
- package/dist/index45.js.map +1 -1
- package/dist/index46.cjs +11 -8
- package/dist/index46.cjs.map +1 -1
- package/dist/index46.js +22 -15
- package/dist/index46.js.map +1 -1
- package/dist/index47.cjs +22 -15
- package/dist/index47.cjs.map +1 -1
- package/dist/index47.js +9 -13
- package/dist/index47.js.map +1 -1
- package/dist/index48.cjs +10 -16
- package/dist/index48.cjs.map +1 -1
- package/dist/index48.js +18 -25
- package/dist/index48.js.map +1 -1
- package/dist/index49.cjs +18 -25
- package/dist/index49.cjs.map +1 -1
- package/dist/index49.js +17 -14
- package/dist/index49.js.map +1 -1
- package/dist/index50.cjs +24 -17
- package/dist/index50.cjs.map +1 -1
- package/dist/index50.js +28 -28
- package/dist/index50.js.map +1 -1
- package/dist/index51.cjs +27 -28
- package/dist/index51.cjs.map +1 -1
- package/dist/index51.js +14 -17
- package/dist/index51.js.map +1 -1
- package/dist/index52.cjs +17 -22
- package/dist/index52.cjs.map +1 -1
- package/dist/index52.js +23 -23
- package/dist/index52.js.map +1 -1
- package/dist/index53.cjs +23 -23
- package/dist/index53.cjs.map +1 -1
- package/dist/index53.js +17 -10
- package/dist/index53.js.map +1 -1
- package/dist/index54.cjs +22 -11
- package/dist/index54.cjs.map +1 -1
- package/dist/index54.js +28 -14
- package/dist/index54.js.map +1 -1
- package/dist/index55.cjs +28 -13
- package/dist/index55.cjs.map +1 -1
- package/dist/index55.js +17 -11
- package/dist/index55.js.map +1 -1
- package/dist/index56.cjs +23 -13
- package/dist/index56.cjs.map +1 -1
- package/dist/index56.js +24 -16
- package/dist/index56.js.map +1 -1
- package/dist/index57.cjs +24 -15
- package/dist/index57.cjs.map +1 -1
- package/dist/index57.js +10 -9
- package/dist/index57.js.map +1 -1
- package/dist/index58.cjs +11 -12
- package/dist/index58.cjs.map +1 -1
- package/dist/index58.js +12 -87
- package/dist/index58.js.map +1 -1
- package/dist/index59.cjs +12 -89
- package/dist/index59.cjs.map +1 -1
- package/dist/index59.js +11 -21
- package/dist/index59.js.map +1 -1
- package/dist/index60.cjs +13 -30
- package/dist/index60.cjs.map +1 -1
- package/dist/index60.js +17 -43
- package/dist/index60.js.map +1 -1
- package/dist/index61.cjs +16 -44
- package/dist/index61.cjs.map +1 -1
- package/dist/index61.js +9 -57
- package/dist/index61.js.map +1 -1
- package/dist/index62.cjs +11 -83
- package/dist/index62.cjs.map +1 -1
- package/dist/index62.js +83 -426
- package/dist/index62.js.map +1 -1
- package/dist/index63.cjs +82 -427
- package/dist/index63.cjs.map +1 -1
- package/dist/index63.js +21 -59
- package/dist/index63.js.map +1 -1
- package/dist/index64.cjs +30 -87
- package/dist/index64.cjs.map +1 -1
- package/dist/index64.js +44 -240
- package/dist/index64.js.map +1 -1
- package/dist/index65.cjs +43 -239
- package/dist/index65.cjs.map +1 -1
- package/dist/index65.js +57 -43
- package/dist/index65.js.map +1 -1
- package/dist/index66.cjs +84 -63
- package/dist/index66.cjs.map +1 -1
- package/dist/index66.js +426 -73
- package/dist/index66.js.map +1 -1
- package/dist/index67.cjs +426 -71
- package/dist/index67.cjs.map +1 -1
- package/dist/index67.js +59 -21
- package/dist/index67.js.map +1 -1
- package/dist/index68.cjs +87 -30
- package/dist/index68.cjs.map +1 -1
- package/dist/index68.js +233 -88
- package/dist/index68.js.map +1 -1
- package/dist/index69.cjs +232 -89
- package/dist/index69.cjs.map +1 -1
- package/dist/index69.js +40 -16
- package/dist/index69.js.map +1 -1
- package/dist/index70.cjs +56 -20
- package/dist/index70.cjs.map +1 -1
- package/dist/index70.js +72 -145
- package/dist/index70.js.map +1 -1
- package/dist/index71.cjs +72 -145
- package/dist/index71.cjs.map +1 -1
- package/dist/index71.js +25 -0
- package/dist/index71.js.map +1 -0
- package/dist/index72.cjs +34 -0
- package/dist/index72.cjs.map +1 -0
- package/dist/index72.js +101 -0
- package/dist/index72.js.map +1 -0
- package/dist/index73.cjs +105 -0
- package/dist/index73.cjs.map +1 -0
- package/dist/index73.js +23 -0
- package/dist/index73.js.map +1 -0
- package/dist/index74.cjs +31 -0
- package/dist/index74.cjs.map +1 -0
- package/dist/index74.js +159 -0
- package/dist/index74.js.map +1 -0
- package/dist/index75.cjs +161 -0
- package/dist/index75.cjs.map +1 -0
- package/dist/index8.js.map +1 -1
- package/dist/index9.cjs.map +1 -1
- package/dist/index9.js.map +1 -1
- package/dist/style.css +216 -45
- package/package.json +2 -2
package/dist/index42.js
CHANGED
|
@@ -1,22 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { cx } from "./index3.js";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import sidebar_nav_module_default from "./index41.js";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/sidebar-nav/SidebarNav.tsx
|
|
7
|
+
var isActivePrefix = (item, path) => {
|
|
8
|
+
if (item.active !== void 0) return item.active;
|
|
9
|
+
if (!item.href) return false;
|
|
10
|
+
if (!path) return false;
|
|
11
|
+
if (item.href === "/") return path === "/";
|
|
12
|
+
return path.startsWith(item.href);
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var isActiveExact = (item, path) => {
|
|
15
|
+
if (item.active !== void 0) return item.active;
|
|
16
|
+
if (!item.href) return false;
|
|
17
|
+
if (!path) return false;
|
|
18
|
+
if (item.href === "/") return path === "/";
|
|
19
|
+
const normalizedHref = item.href.endsWith("/") ? item.href.slice(0, -1) : item.href;
|
|
20
|
+
return normalizedHref === path || path.startsWith(`${normalizedHref}/`);
|
|
21
|
+
};
|
|
22
|
+
var isNaturalPrefixMatch = (href, path) => {
|
|
23
|
+
if (href === "/") return path === "/";
|
|
24
|
+
return path.startsWith(href);
|
|
25
|
+
};
|
|
26
|
+
var isNaturalExactMatch = (href, path) => {
|
|
27
|
+
if (href === "/") return path === "/";
|
|
28
|
+
return (href.endsWith("/") ? href.slice(0, -1) : href) === path;
|
|
29
|
+
};
|
|
30
|
+
var hrefLength = (href) => href.endsWith("/") ? href.length - 1 : href.length;
|
|
31
|
+
var findMostSpecific = (items, currentPath) => {
|
|
32
|
+
const result = /* @__PURE__ */ new Set();
|
|
33
|
+
if (!currentPath) return result;
|
|
34
|
+
const matchingItems = items.filter((item) => {
|
|
35
|
+
if (item.disabled || !item.href) return false;
|
|
36
|
+
return item.exact ? isNaturalExactMatch(item.href, currentPath) : isNaturalPrefixMatch(item.href, currentPath);
|
|
37
|
+
});
|
|
38
|
+
if (matchingItems.length === 0) return result;
|
|
39
|
+
let maxLen = 0;
|
|
40
|
+
for (const item of matchingItems) {
|
|
41
|
+
if (!item.href) continue;
|
|
42
|
+
const len = hrefLength(item.href);
|
|
43
|
+
if (len > maxLen) maxLen = len;
|
|
44
|
+
}
|
|
45
|
+
for (const item of matchingItems) {
|
|
46
|
+
if (!item.href) continue;
|
|
47
|
+
if (hrefLength(item.href) === maxLen) result.add(item.href);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
function SidebarNav({ items = [], sections, currentPath, getIsActive, matchStrategy = "prefix", onItemClick, header, footer, ariaLabel = "Sidebar navigation", collapsed = false, iconSize, className, itemClassName, sectionClassName }) {
|
|
52
|
+
const resolvedSections = useMemo(() => {
|
|
53
|
+
return sections?.length ? sections : [{
|
|
54
|
+
id: "default",
|
|
55
|
+
items
|
|
56
|
+
}];
|
|
57
|
+
}, [sections, items]);
|
|
58
|
+
const allItems = useMemo(() => resolvedSections.flatMap((section) => section.items), [resolvedSections]);
|
|
59
|
+
const defaultIsActiveFn = useMemo(() => {
|
|
60
|
+
if (matchStrategy === "most-specific") {
|
|
61
|
+
const mostSpecificHrefs = findMostSpecific(allItems, currentPath);
|
|
62
|
+
return (item) => {
|
|
63
|
+
if (item.active !== void 0) return item.active;
|
|
64
|
+
if (!item.href) return false;
|
|
65
|
+
return mostSpecificHrefs.has(item.href);
|
|
66
|
+
};
|
|
67
|
+
} else return (item, path) => {
|
|
68
|
+
if (item.active !== void 0) return item.active;
|
|
69
|
+
if (item.exact) return isActiveExact(item, path);
|
|
70
|
+
return isActivePrefix(item, path);
|
|
71
|
+
};
|
|
72
|
+
}, [
|
|
73
|
+
matchStrategy,
|
|
74
|
+
allItems,
|
|
75
|
+
currentPath
|
|
76
|
+
]);
|
|
77
|
+
const resolvedGetIsActive = getIsActive ?? defaultIsActiveFn;
|
|
78
|
+
const style = iconSize !== void 0 ? { ["--sidebar-nav-icon-size"]: typeof iconSize === "number" ? `${iconSize}px` : iconSize } : void 0;
|
|
79
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
80
|
+
className: cx(sidebar_nav_module_default.sidebarNav, collapsed && sidebar_nav_module_default.sidebarNavCollapsed, className),
|
|
81
|
+
"aria-label": ariaLabel,
|
|
82
|
+
style,
|
|
83
|
+
children: [
|
|
84
|
+
header ? /* @__PURE__ */ jsx("div", {
|
|
85
|
+
className: sidebar_nav_module_default.header,
|
|
86
|
+
children: header
|
|
87
|
+
}) : null,
|
|
88
|
+
/* @__PURE__ */ jsx("div", {
|
|
89
|
+
className: sidebar_nav_module_default.sections,
|
|
90
|
+
children: resolvedSections.map((section, sectionIndex) => /* @__PURE__ */ jsxs("div", {
|
|
91
|
+
className: cx(sidebar_nav_module_default.section, sectionClassName),
|
|
92
|
+
children: [section.label && !collapsed ? /* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: sidebar_nav_module_default.sectionLabel,
|
|
94
|
+
children: section.label
|
|
95
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
96
|
+
className: sidebar_nav_module_default.sectionItems,
|
|
97
|
+
children: section.items.map((item, itemIndex) => /* @__PURE__ */ jsx(SidebarNavEntry, {
|
|
98
|
+
item,
|
|
99
|
+
active: resolvedGetIsActive(item, currentPath),
|
|
100
|
+
collapsed,
|
|
101
|
+
itemClassName,
|
|
102
|
+
onItemClick
|
|
103
|
+
}, `${section.id ?? sectionIndex}-${item.href ?? item.title ?? itemIndex}`))
|
|
104
|
+
})]
|
|
105
|
+
}, section.id ?? `section-${sectionIndex}`))
|
|
106
|
+
}),
|
|
107
|
+
footer ? /* @__PURE__ */ jsx("div", {
|
|
108
|
+
className: sidebar_nav_module_default.footer,
|
|
109
|
+
children: footer
|
|
110
|
+
}) : null
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function SidebarNavEntry({ item, active, collapsed, itemClassName, onItemClick }) {
|
|
115
|
+
const rel = item.rel ?? (item.target === "_blank" ? "noreferrer" : void 0);
|
|
116
|
+
const title = item.title ?? (typeof item.label === "string" ? item.label : void 0);
|
|
117
|
+
const hasIcon = Boolean(item.icon);
|
|
118
|
+
const classes = cx(sidebar_nav_module_default.item, !hasIcon && sidebar_nav_module_default.itemWithoutIcon, active && sidebar_nav_module_default.itemActive, collapsed && sidebar_nav_module_default.itemCollapsed, item.disabled && sidebar_nav_module_default.itemDisabled, itemClassName);
|
|
119
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [hasIcon ? /* @__PURE__ */ jsx("span", {
|
|
120
|
+
className: sidebar_nav_module_default.icon,
|
|
121
|
+
children: item.icon
|
|
122
|
+
}) : null, !collapsed ? /* @__PURE__ */ jsxs("span", {
|
|
123
|
+
className: sidebar_nav_module_default.itemBody,
|
|
124
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
125
|
+
className: sidebar_nav_module_default.labelRow,
|
|
126
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
127
|
+
className: sidebar_nav_module_default.label,
|
|
128
|
+
children: item.label
|
|
129
|
+
}), item.badge && /* @__PURE__ */ jsx("span", {
|
|
130
|
+
className: sidebar_nav_module_default.badge,
|
|
131
|
+
children: item.badge
|
|
132
|
+
})]
|
|
133
|
+
}), item.description ? /* @__PURE__ */ jsx("span", {
|
|
134
|
+
className: sidebar_nav_module_default.description,
|
|
135
|
+
children: item.description
|
|
136
|
+
}) : null]
|
|
137
|
+
}) : null] });
|
|
138
|
+
const handleClick = () => {
|
|
139
|
+
if (item.disabled) return;
|
|
140
|
+
item.onClick?.();
|
|
141
|
+
onItemClick?.(item);
|
|
142
|
+
};
|
|
143
|
+
if (!item.href) return /* @__PURE__ */ jsx("button", {
|
|
144
|
+
type: "button",
|
|
145
|
+
className: classes,
|
|
146
|
+
"aria-current": active ? "page" : void 0,
|
|
147
|
+
"aria-disabled": item.disabled ? "true" : void 0,
|
|
148
|
+
disabled: item.disabled,
|
|
149
|
+
title: collapsed ? title : void 0,
|
|
150
|
+
onClick: handleClick,
|
|
151
|
+
children: content
|
|
152
|
+
});
|
|
153
|
+
if (item.disabled) return /* @__PURE__ */ jsx("div", {
|
|
154
|
+
className: classes,
|
|
155
|
+
"aria-current": active ? "page" : void 0,
|
|
156
|
+
"aria-disabled": "true",
|
|
157
|
+
title: collapsed ? title : void 0,
|
|
158
|
+
children: content
|
|
159
|
+
});
|
|
160
|
+
return /* @__PURE__ */ jsx("a", {
|
|
161
|
+
className: classes,
|
|
162
|
+
href: item.href,
|
|
163
|
+
target: item.target,
|
|
164
|
+
rel,
|
|
165
|
+
"aria-current": active ? "page" : void 0,
|
|
166
|
+
title: collapsed ? title : void 0,
|
|
167
|
+
onClick: handleClick,
|
|
168
|
+
children: content
|
|
17
169
|
});
|
|
18
170
|
}
|
|
19
171
|
//#endregion
|
|
20
|
-
export {
|
|
172
|
+
export { SidebarNav };
|
|
21
173
|
|
|
22
174
|
//# sourceMappingURL=index42.js.map
|
package/dist/index42.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index42.js","names":[],"sources":["../src/components/page-container/PageContainer.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport styles from \"./page-container.module.css\";\n\nexport type PageContainerWidth = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nexport type PageContainerProps = HTMLAttributes<HTMLDivElement> & {\n /** Maximum content width. Defaults to `lg`. */\n maxWidth?: PageContainerWidth;\n /** Removes the responsive horizontal gutters. */\n bleed?: boolean;\n};\n\nconst WIDTH_CLASS: Record<PageContainerWidth, string> = {\n sm: \"width-sm\",\n md: \"width-md\",\n lg: \"width-lg\",\n xl: \"width-xl\",\n full: \"width-full\",\n};\n\nexport function PageContainer({\n maxWidth = \"lg\",\n bleed = false,\n className,\n children,\n ...rest\n}: PageContainerProps) {\n return (\n <div\n className={cx(styles.container, styles[WIDTH_CLASS[maxWidth]], bleed && styles.bleed, className)}\n {...rest}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAaA,IAAM,cAAkD;CACtD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;AACR;AAEA,SAAgB,cAAc,EAC5B,WAAW,MACX,QAAQ,OACR,WACA,UACA,GAAG,QACkB;CACrB,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,8BAAO,WAAW,8BAAO,YAAY,YAAY,SAAS,8BAAO,OAAO,SAAS;EAC/F,GAAI;EAEH;CACE,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"index42.js","names":[],"sources":["../src/components/sidebar-nav/SidebarNav.tsx"],"sourcesContent":["\"use client\";\n\nimport { type AnchorHTMLAttributes, type CSSProperties, type ReactNode, useMemo } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport styles from \"./sidebar-nav.module.css\";\n\nexport type SidebarNavItem = {\n label: string;\n href?: string;\n icon?: ReactNode;\n description?: ReactNode;\n badge?: ReactNode;\n active?: boolean;\n disabled?: boolean;\n /**\n * When `true`, this item uses exact matching (matches its own path and paths starting with `{href}/`)\n * instead of prefix matching. This flag takes precedence over the global `matchStrategy` prop on a\n * per-item basis — even when `matchStrategy=\"prefix\"`, an item with `exact: true` will use exact matching.\n * When `matchStrategy=\"most-specific\"`, exact-flagged items participate in the length-based tiebreaker\n * like all other candidates, provided they pass their own match check first.\n */\n exact?: boolean;\n title?: string;\n target?: AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"];\n rel?: AnchorHTMLAttributes<HTMLAnchorElement>[\"rel\"];\n onClick?: () => void;\n};\n\nexport type SidebarNavSection = {\n id?: string;\n label?: ReactNode;\n items: SidebarNavItem[];\n};\n\nexport type SidebarNavProps = {\n items?: SidebarNavItem[];\n sections?: SidebarNavSection[];\n currentPath?: string;\n getIsActive?: (item: SidebarNavItem, currentPath?: string) => boolean;\n matchStrategy?: \"prefix\" | \"most-specific\";\n onItemClick?: (item: SidebarNavItem) => void;\n header?: ReactNode;\n footer?: ReactNode;\n ariaLabel?: string;\n collapsed?: boolean;\n iconSize?: number | string;\n className?: string;\n itemClassName?: string;\n sectionClassName?: string;\n};\n\nconst isActivePrefix = (item: SidebarNavItem, path?: string) => {\n if (item.active !== undefined) return item.active;\n if (!item.href) return false;\n if (!path) return false;\n if (item.href === \"/\") return path === \"/\";\n return path.startsWith(item.href);\n};\n\nconst isActiveExact = (item: SidebarNavItem, path?: string) => {\n if (item.active !== undefined) return item.active;\n if (!item.href) return false;\n if (!path) return false;\n // Root href \"/\" must match exactly — otherwise every path would match.\n if (item.href === \"/\") return path === \"/\";\n // Normalize trailing slashes for consistent matching with findMostSpecific length computation.\n const normalizedHref = item.href.endsWith(\"/\") ? item.href.slice(0, -1) : item.href;\n return normalizedHref === path || path.startsWith(`${normalizedHref}/`);\n};\n\n// Natural matching helpers that ignore manual `active` overrides — used inside findMostSpecific\n// so that manually-set active flags don't hijack the length-based tiebreaker.\nconst isNaturalPrefixMatch = (href: string, path: string) => {\n if (href === \"/\") return path === \"/\";\n return path.startsWith(href);\n};\n\nconst isNaturalExactMatch = (href: string, path: string) => {\n if (href === \"/\") return path === \"/\";\n const normalizedHref = href.endsWith(\"/\") ? href.slice(0, -1) : href;\n return normalizedHref === path;\n};\n\nconst hrefLength = (href: string) => (href.endsWith(\"/\") ? href.length - 1 : href.length);\n\nconst findMostSpecific = (items: SidebarNavItem[], currentPath?: string): Set<string> => {\n const result = new Set<string>();\n if (!currentPath) return result;\n\n // Collect all items that naturally match the path — use natural matching helpers so that\n // manually-set `active` flags don't participate in the length-based tiebreaker.\n // Exclude disabled items from matching since they are not interactive targets.\n const matchingItems = items.filter(item => {\n if (item.disabled || !item.href) return false;\n return item.exact\n ? isNaturalExactMatch(item.href, currentPath)\n : isNaturalPrefixMatch(item.href, currentPath);\n });\n\n if (matchingItems.length === 0) return result;\n\n // Find the longest href among prefix matches.\n let maxLen = 0;\n for (const item of matchingItems) {\n if (!item.href) continue;\n const len = hrefLength(item.href);\n if (len > maxLen) maxLen = len;\n }\n\n // Only the items with the longest href are active.\n for (const item of matchingItems) {\n if (!item.href) continue;\n if (hrefLength(item.href) === maxLen) result.add(item.href);\n }\n\n return result;\n};\n\nexport function SidebarNav({\n items = [],\n sections,\n currentPath,\n getIsActive,\n matchStrategy = \"prefix\",\n onItemClick,\n header,\n footer,\n ariaLabel = \"Sidebar navigation\",\n collapsed = false,\n iconSize,\n className,\n itemClassName,\n sectionClassName,\n}: SidebarNavProps) {\n const resolvedSections = useMemo(() => {\n return sections?.length ? sections : [{ id: \"default\", items }];\n }, [sections, items]);\n\n // Stable reference to all items — avoids recreating on every render when `sections` is falsy.\n const allItems = useMemo(() => resolvedSections.flatMap(section => section.items), [resolvedSections]);\n\n // Build the default isActive function based on matchStrategy.\n const defaultIsActiveFn = useMemo<(item: SidebarNavItem, path?: string) => boolean>(() => {\n if (matchStrategy === \"most-specific\") {\n const mostSpecificHrefs = findMostSpecific(allItems, currentPath);\n return (item: SidebarNavItem) => {\n if (item.active !== undefined) return item.active;\n if (!item.href) return false;\n // Exact-flagged items participate in the length-based tiebreaker like all other candidates.\n return mostSpecificHrefs.has(item.href);\n };\n } else {\n return (item: SidebarNavItem, path?: string) => {\n if (item.active !== undefined) return item.active;\n if (item.exact) return isActiveExact(item, path);\n return isActivePrefix(item, path);\n };\n }\n }, [matchStrategy, allItems, currentPath]);\n\n const resolvedGetIsActive = getIsActive ?? defaultIsActiveFn;\n\n const style =\n iconSize !== undefined\n ? ({\n [\"--sidebar-nav-icon-size\" as string]:\n typeof iconSize === \"number\" ? `${iconSize}px` : iconSize,\n } satisfies CSSProperties)\n : undefined;\n\n return (\n <nav\n className={cx(\n styles.sidebarNav,\n collapsed && styles.sidebarNavCollapsed,\n className,\n )}\n aria-label={ariaLabel}\n style={style}\n >\n {header ? <div className={styles.header}>{header}</div> : null}\n <div className={styles.sections}>\n {resolvedSections.map((section, sectionIndex) => (\n <div\n key={section.id ?? `section-${sectionIndex}`}\n className={cx(styles.section, sectionClassName)}\n >\n {section.label && !collapsed ? (\n <div className={styles.sectionLabel}>{section.label}</div>\n ) : null}\n <div className={styles.sectionItems}>\n {section.items.map((item, itemIndex) => (\n <SidebarNavEntry\n key={`${section.id ?? sectionIndex}-${item.href ?? item.title ?? itemIndex}`}\n item={item}\n active={resolvedGetIsActive(item, currentPath)}\n collapsed={collapsed}\n itemClassName={itemClassName}\n onItemClick={onItemClick}\n />\n ))}\n </div>\n </div>\n ))}\n </div>\n {footer ? <div className={styles.footer}>{footer}</div> : null}\n </nav>\n );\n}\n\ntype SidebarNavEntryProps = {\n item: SidebarNavItem;\n active: boolean;\n collapsed: boolean;\n itemClassName?: string;\n onItemClick?: (item: SidebarNavItem) => void;\n};\n\nfunction SidebarNavEntry({\n item,\n active,\n collapsed,\n itemClassName,\n onItemClick,\n}: SidebarNavEntryProps) {\n const rel = item.rel ?? (item.target === \"_blank\" ? \"noreferrer\" : undefined);\n const title = item.title ?? (typeof item.label === \"string\" ? item.label : undefined);\n const hasIcon = Boolean(item.icon);\n const classes = cx(\n styles.item,\n !hasIcon && styles.itemWithoutIcon,\n active && styles.itemActive,\n collapsed && styles.itemCollapsed,\n item.disabled && styles.itemDisabled,\n itemClassName,\n );\n const content = (\n <>\n {hasIcon ? <span className={styles.icon}>{item.icon}</span> : null}\n {!collapsed ? (\n <span className={styles.itemBody}>\n <span className={styles.labelRow}>\n <span className={styles.label}>{item.label}</span>\n {item.badge && <span className={styles.badge}>{item.badge}</span>}\n </span>\n {item.description ? <span className={styles.description}>{item.description}</span> : null}\n </span>\n ) : null}\n </>\n );\n\n const handleClick = () => {\n if (item.disabled) return;\n item.onClick?.();\n onItemClick?.(item);\n };\n\n if (!item.href) {\n return (\n <button\n type=\"button\"\n className={classes}\n aria-current={active ? \"page\" : undefined}\n aria-disabled={item.disabled ? \"true\" : undefined}\n disabled={item.disabled}\n title={collapsed ? title : undefined}\n onClick={handleClick}\n >\n {content}\n </button>\n );\n }\n\n if (item.disabled) {\n return (\n <div\n className={classes}\n aria-current={active ? \"page\" : undefined}\n aria-disabled=\"true\"\n title={collapsed ? title : undefined}\n >\n {content}\n </div>\n );\n }\n\n return (\n <a\n className={classes}\n href={item.href}\n target={item.target}\n rel={rel}\n aria-current={active ? \"page\" : undefined}\n title={collapsed ? title : undefined}\n onClick={handleClick}\n >\n {content}\n </a>\n );\n}\n"],"mappings":";;;;;;AAmDA,IAAM,kBAAkB,MAAsB,SAAkB;CAC9D,IAAI,KAAK,WAAW,KAAA,GAAW,OAAO,KAAK;CAC3C,IAAI,CAAC,KAAK,MAAM,OAAO;CACvB,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,KAAK,SAAS,KAAK,OAAO,SAAS;CACvC,OAAO,KAAK,WAAW,KAAK,IAAI;AAClC;AAEA,IAAM,iBAAiB,MAAsB,SAAkB;CAC7D,IAAI,KAAK,WAAW,KAAA,GAAW,OAAO,KAAK;CAC3C,IAAI,CAAC,KAAK,MAAM,OAAO;CACvB,IAAI,CAAC,MAAM,OAAO;CAElB,IAAI,KAAK,SAAS,KAAK,OAAO,SAAS;CAEvC,MAAM,iBAAiB,KAAK,KAAK,SAAS,GAAG,IAAI,KAAK,KAAK,MAAM,GAAG,EAAE,IAAI,KAAK;CAC/E,OAAO,mBAAmB,QAAQ,KAAK,WAAW,GAAG,eAAe,EAAE;AACxE;AAIA,IAAM,wBAAwB,MAAc,SAAiB;CAC3D,IAAI,SAAS,KAAK,OAAO,SAAS;CAClC,OAAO,KAAK,WAAW,IAAI;AAC7B;AAEA,IAAM,uBAAuB,MAAc,SAAiB;CAC1D,I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EACX,gBAAc,SAAS,SAAS,KAAA;EAChC,iBAAc;EACd,OAAO,YAAY,QAAQ,KAAA;YAE1B;CACE,CAAA;CAIT,OACE,oBAAC,KAAD;EACE,WAAW;EACX,MAAM,KAAK;EACX,QAAQ,KAAK;EACR;EACL,gBAAc,SAAS,SAAS,KAAA;EAChC,OAAO,YAAY,QAAQ,KAAA;EAC3B,SAAS;YAER;CACA,CAAA;AAEP"}
|
package/dist/index43.cjs
CHANGED
|
@@ -1,22 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
const require_cx = require("./index4.cjs");
|
|
2
|
-
const
|
|
3
|
+
const require_sidebar_nav_module = require("./index42.cjs");
|
|
4
|
+
let react = require("react");
|
|
3
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
-
//#region src/components/
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
//#region src/components/sidebar-nav/SidebarNav.tsx
|
|
7
|
+
var isActivePrefix = (item, path) => {
|
|
8
|
+
if (item.active !== void 0) return item.active;
|
|
9
|
+
if (!item.href) return false;
|
|
10
|
+
if (!path) return false;
|
|
11
|
+
if (item.href === "/") return path === "/";
|
|
12
|
+
return path.startsWith(item.href);
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var isActiveExact = (item, path) => {
|
|
15
|
+
if (item.active !== void 0) return item.active;
|
|
16
|
+
if (!item.href) return false;
|
|
17
|
+
if (!path) return false;
|
|
18
|
+
if (item.href === "/") return path === "/";
|
|
19
|
+
const normalizedHref = item.href.endsWith("/") ? item.href.slice(0, -1) : item.href;
|
|
20
|
+
return normalizedHref === path || path.startsWith(`${normalizedHref}/`);
|
|
21
|
+
};
|
|
22
|
+
var isNaturalPrefixMatch = (href, path) => {
|
|
23
|
+
if (href === "/") return path === "/";
|
|
24
|
+
return path.startsWith(href);
|
|
25
|
+
};
|
|
26
|
+
var isNaturalExactMatch = (href, path) => {
|
|
27
|
+
if (href === "/") return path === "/";
|
|
28
|
+
return (href.endsWith("/") ? href.slice(0, -1) : href) === path;
|
|
29
|
+
};
|
|
30
|
+
var hrefLength = (href) => href.endsWith("/") ? href.length - 1 : href.length;
|
|
31
|
+
var findMostSpecific = (items, currentPath) => {
|
|
32
|
+
const result = /* @__PURE__ */ new Set();
|
|
33
|
+
if (!currentPath) return result;
|
|
34
|
+
const matchingItems = items.filter((item) => {
|
|
35
|
+
if (item.disabled || !item.href) return false;
|
|
36
|
+
return item.exact ? isNaturalExactMatch(item.href, currentPath) : isNaturalPrefixMatch(item.href, currentPath);
|
|
37
|
+
});
|
|
38
|
+
if (matchingItems.length === 0) return result;
|
|
39
|
+
let maxLen = 0;
|
|
40
|
+
for (const item of matchingItems) {
|
|
41
|
+
if (!item.href) continue;
|
|
42
|
+
const len = hrefLength(item.href);
|
|
43
|
+
if (len > maxLen) maxLen = len;
|
|
44
|
+
}
|
|
45
|
+
for (const item of matchingItems) {
|
|
46
|
+
if (!item.href) continue;
|
|
47
|
+
if (hrefLength(item.href) === maxLen) result.add(item.href);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
function SidebarNav({ items = [], sections, currentPath, getIsActive, matchStrategy = "prefix", onItemClick, header, footer, ariaLabel = "Sidebar navigation", collapsed = false, iconSize, className, itemClassName, sectionClassName }) {
|
|
52
|
+
const resolvedSections = (0, react.useMemo)(() => {
|
|
53
|
+
return sections?.length ? sections : [{
|
|
54
|
+
id: "default",
|
|
55
|
+
items
|
|
56
|
+
}];
|
|
57
|
+
}, [sections, items]);
|
|
58
|
+
const allItems = (0, react.useMemo)(() => resolvedSections.flatMap((section) => section.items), [resolvedSections]);
|
|
59
|
+
const defaultIsActiveFn = (0, react.useMemo)(() => {
|
|
60
|
+
if (matchStrategy === "most-specific") {
|
|
61
|
+
const mostSpecificHrefs = findMostSpecific(allItems, currentPath);
|
|
62
|
+
return (item) => {
|
|
63
|
+
if (item.active !== void 0) return item.active;
|
|
64
|
+
if (!item.href) return false;
|
|
65
|
+
return mostSpecificHrefs.has(item.href);
|
|
66
|
+
};
|
|
67
|
+
} else return (item, path) => {
|
|
68
|
+
if (item.active !== void 0) return item.active;
|
|
69
|
+
if (item.exact) return isActiveExact(item, path);
|
|
70
|
+
return isActivePrefix(item, path);
|
|
71
|
+
};
|
|
72
|
+
}, [
|
|
73
|
+
matchStrategy,
|
|
74
|
+
allItems,
|
|
75
|
+
currentPath
|
|
76
|
+
]);
|
|
77
|
+
const resolvedGetIsActive = getIsActive ?? defaultIsActiveFn;
|
|
78
|
+
const style = iconSize !== void 0 ? { ["--sidebar-nav-icon-size"]: typeof iconSize === "number" ? `${iconSize}px` : iconSize } : void 0;
|
|
79
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
80
|
+
className: require_cx.cx(require_sidebar_nav_module.default.sidebarNav, collapsed && require_sidebar_nav_module.default.sidebarNavCollapsed, className),
|
|
81
|
+
"aria-label": ariaLabel,
|
|
82
|
+
style,
|
|
83
|
+
children: [
|
|
84
|
+
header ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
85
|
+
className: require_sidebar_nav_module.default.header,
|
|
86
|
+
children: header
|
|
87
|
+
}) : null,
|
|
88
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
89
|
+
className: require_sidebar_nav_module.default.sections,
|
|
90
|
+
children: resolvedSections.map((section, sectionIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
91
|
+
className: require_cx.cx(require_sidebar_nav_module.default.section, sectionClassName),
|
|
92
|
+
children: [section.label && !collapsed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
93
|
+
className: require_sidebar_nav_module.default.sectionLabel,
|
|
94
|
+
children: section.label
|
|
95
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
96
|
+
className: require_sidebar_nav_module.default.sectionItems,
|
|
97
|
+
children: section.items.map((item, itemIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SidebarNavEntry, {
|
|
98
|
+
item,
|
|
99
|
+
active: resolvedGetIsActive(item, currentPath),
|
|
100
|
+
collapsed,
|
|
101
|
+
itemClassName,
|
|
102
|
+
onItemClick
|
|
103
|
+
}, `${section.id ?? sectionIndex}-${item.href ?? item.title ?? itemIndex}`))
|
|
104
|
+
})]
|
|
105
|
+
}, section.id ?? `section-${sectionIndex}`))
|
|
106
|
+
}),
|
|
107
|
+
footer ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
108
|
+
className: require_sidebar_nav_module.default.footer,
|
|
109
|
+
children: footer
|
|
110
|
+
}) : null
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function SidebarNavEntry({ item, active, collapsed, itemClassName, onItemClick }) {
|
|
115
|
+
const rel = item.rel ?? (item.target === "_blank" ? "noreferrer" : void 0);
|
|
116
|
+
const title = item.title ?? (typeof item.label === "string" ? item.label : void 0);
|
|
117
|
+
const hasIcon = Boolean(item.icon);
|
|
118
|
+
const classes = require_cx.cx(require_sidebar_nav_module.default.item, !hasIcon && require_sidebar_nav_module.default.itemWithoutIcon, active && require_sidebar_nav_module.default.itemActive, collapsed && require_sidebar_nav_module.default.itemCollapsed, item.disabled && require_sidebar_nav_module.default.itemDisabled, itemClassName);
|
|
119
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [hasIcon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
120
|
+
className: require_sidebar_nav_module.default.icon,
|
|
121
|
+
children: item.icon
|
|
122
|
+
}) : null, !collapsed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
123
|
+
className: require_sidebar_nav_module.default.itemBody,
|
|
124
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
125
|
+
className: require_sidebar_nav_module.default.labelRow,
|
|
126
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
127
|
+
className: require_sidebar_nav_module.default.label,
|
|
128
|
+
children: item.label
|
|
129
|
+
}), item.badge && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
130
|
+
className: require_sidebar_nav_module.default.badge,
|
|
131
|
+
children: item.badge
|
|
132
|
+
})]
|
|
133
|
+
}), item.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
134
|
+
className: require_sidebar_nav_module.default.description,
|
|
135
|
+
children: item.description
|
|
136
|
+
}) : null]
|
|
137
|
+
}) : null] });
|
|
138
|
+
const handleClick = () => {
|
|
139
|
+
if (item.disabled) return;
|
|
140
|
+
item.onClick?.();
|
|
141
|
+
onItemClick?.(item);
|
|
142
|
+
};
|
|
143
|
+
if (!item.href) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
144
|
+
type: "button",
|
|
145
|
+
className: classes,
|
|
146
|
+
"aria-current": active ? "page" : void 0,
|
|
147
|
+
"aria-disabled": item.disabled ? "true" : void 0,
|
|
148
|
+
disabled: item.disabled,
|
|
149
|
+
title: collapsed ? title : void 0,
|
|
150
|
+
onClick: handleClick,
|
|
151
|
+
children: content
|
|
152
|
+
});
|
|
153
|
+
if (item.disabled) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
154
|
+
className: classes,
|
|
155
|
+
"aria-current": active ? "page" : void 0,
|
|
156
|
+
"aria-disabled": "true",
|
|
157
|
+
title: collapsed ? title : void 0,
|
|
158
|
+
children: content
|
|
159
|
+
});
|
|
160
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
161
|
+
className: classes,
|
|
162
|
+
href: item.href,
|
|
163
|
+
target: item.target,
|
|
164
|
+
rel,
|
|
165
|
+
"aria-current": active ? "page" : void 0,
|
|
166
|
+
title: collapsed ? title : void 0,
|
|
167
|
+
onClick: handleClick,
|
|
168
|
+
children: content
|
|
17
169
|
});
|
|
18
170
|
}
|
|
19
171
|
//#endregion
|
|
20
|
-
exports.
|
|
172
|
+
exports.SidebarNav = SidebarNav;
|
|
21
173
|
|
|
22
174
|
//# sourceMappingURL=index43.cjs.map
|
package/dist/index43.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index43.cjs","names":[],"sources":["../src/components/page-container/PageContainer.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport styles from \"./page-container.module.css\";\n\nexport type PageContainerWidth = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nexport type PageContainerProps = HTMLAttributes<HTMLDivElement> & {\n /** Maximum content width. Defaults to `lg`. */\n maxWidth?: PageContainerWidth;\n /** Removes the responsive horizontal gutters. */\n bleed?: boolean;\n};\n\nconst WIDTH_CLASS: Record<PageContainerWidth, string> = {\n sm: \"width-sm\",\n md: \"width-md\",\n lg: \"width-lg\",\n xl: \"width-xl\",\n full: \"width-full\",\n};\n\nexport function PageContainer({\n maxWidth = \"lg\",\n bleed = false,\n className,\n children,\n ...rest\n}: PageContainerProps) {\n return (\n <div\n className={cx(styles.container, styles[WIDTH_CLASS[maxWidth]], bleed && styles.bleed, className)}\n {...rest}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAaA,IAAM,cAAkD;CACtD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;AACR;AAEA,SAAgB,cAAc,EAC5B,WAAW,MACX,QAAQ,OACR,WACA,UACA,GAAG,QACkB;CACrB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAW,WAAA,GAAG,8BAAA,QAAO,WAAW,8BAAA,QAAO,YAAY,YAAY,SAAS,8BAAA,QAAO,OAAO,SAAS;EAC/F,GAAI;EAEH;CACE,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"index43.cjs","names":[],"sources":["../src/components/sidebar-nav/SidebarNav.tsx"],"sourcesContent":["\"use client\";\n\nimport { type AnchorHTMLAttributes, type CSSProperties, type ReactNode, useMemo } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport styles from \"./sidebar-nav.module.css\";\n\nexport type SidebarNavItem = {\n label: string;\n href?: string;\n icon?: ReactNode;\n description?: ReactNode;\n badge?: ReactNode;\n active?: boolean;\n disabled?: boolean;\n /**\n * When `true`, this item uses exact matching (matches its own path and paths starting with `{href}/`)\n * instead of prefix matching. This flag takes precedence over the global `matchStrategy` prop on a\n * per-item basis — even when `matchStrategy=\"prefix\"`, an item with `exact: true` will use exact matching.\n * When `matchStrategy=\"most-specific\"`, exact-flagged items participate in the length-based tiebreaker\n * like all other candidates, provided they pass their own match check first.\n */\n exact?: boolean;\n title?: string;\n target?: AnchorHTMLAttributes<HTMLAnchorElement>[\"target\"];\n rel?: AnchorHTMLAttributes<HTMLAnchorElement>[\"rel\"];\n onClick?: () => void;\n};\n\nexport type SidebarNavSection = {\n id?: string;\n label?: ReactNode;\n items: SidebarNavItem[];\n};\n\nexport type SidebarNavProps = {\n items?: SidebarNavItem[];\n sections?: SidebarNavSection[];\n currentPath?: string;\n getIsActive?: (item: SidebarNavItem, currentPath?: string) => boolean;\n matchStrategy?: \"prefix\" | \"most-specific\";\n onItemClick?: (item: SidebarNavItem) => void;\n header?: ReactNode;\n footer?: ReactNode;\n ariaLabel?: string;\n collapsed?: boolean;\n iconSize?: number | string;\n className?: string;\n itemClassName?: string;\n sectionClassName?: string;\n};\n\nconst isActivePrefix = (item: SidebarNavItem, path?: string) => {\n if (item.active !== undefined) return item.active;\n if (!item.href) return false;\n if (!path) return false;\n if (item.href === \"/\") return path === \"/\";\n return path.startsWith(item.href);\n};\n\nconst isActiveExact = (item: SidebarNavItem, path?: string) => {\n if (item.active !== undefined) return item.active;\n if (!item.href) return false;\n if (!path) return false;\n // Root href \"/\" must match exactly — otherwise every path would match.\n if (item.href === \"/\") return path === \"/\";\n // Normalize trailing slashes for consistent matching with findMostSpecific length computation.\n const normalizedHref = item.href.endsWith(\"/\") ? item.href.slice(0, -1) : item.href;\n return normalizedHref === path || path.startsWith(`${normalizedHref}/`);\n};\n\n// Natural matching helpers that ignore manual `active` overrides — used inside findMostSpecific\n// so that manually-set active flags don't hijack the length-based tiebreaker.\nconst isNaturalPrefixMatch = (href: string, path: string) => {\n if (href === \"/\") return path === \"/\";\n return path.startsWith(href);\n};\n\nconst isNaturalExactMatch = (href: string, path: string) => {\n if (href === \"/\") return path === \"/\";\n const normalizedHref = href.endsWith(\"/\") ? href.slice(0, -1) : href;\n return normalizedHref === path;\n};\n\nconst hrefLength = (href: string) => (href.endsWith(\"/\") ? href.length - 1 : href.length);\n\nconst findMostSpecific = (items: SidebarNavItem[], currentPath?: string): Set<string> => {\n const result = new Set<string>();\n if (!currentPath) return result;\n\n // Collect all items that naturally match the path — use natural matching helpers so that\n // manually-set `active` flags don't participate in the length-based tiebreaker.\n // Exclude disabled items from matching since they are not interactive targets.\n const matchingItems = items.filter(item => {\n if (item.disabled || !item.href) return false;\n return item.exact\n ? isNaturalExactMatch(item.href, currentPath)\n : isNaturalPrefixMatch(item.href, currentPath);\n });\n\n if (matchingItems.length === 0) return result;\n\n // Find the longest href among prefix matches.\n let maxLen = 0;\n for (const item of matchingItems) {\n if (!item.href) continue;\n const len = hrefLength(item.href);\n if (len > maxLen) maxLen = len;\n }\n\n // Only the items with the longest href are active.\n for (const item of matchingItems) {\n if (!item.href) continue;\n if (hrefLength(item.href) === maxLen) result.add(item.href);\n }\n\n return result;\n};\n\nexport function SidebarNav({\n items = [],\n sections,\n currentPath,\n getIsActive,\n matchStrategy = \"prefix\",\n onItemClick,\n header,\n footer,\n ariaLabel = \"Sidebar navigation\",\n collapsed = false,\n iconSize,\n className,\n itemClassName,\n sectionClassName,\n}: SidebarNavProps) {\n const resolvedSections = useMemo(() => {\n return sections?.length ? sections : [{ id: \"default\", items }];\n }, [sections, items]);\n\n // Stable reference to all items — avoids recreating on every render when `sections` is falsy.\n const allItems = useMemo(() => resolvedSections.flatMap(section => section.items), [resolvedSections]);\n\n // Build the default isActive function based on matchStrategy.\n const defaultIsActiveFn = useMemo<(item: SidebarNavItem, path?: string) => boolean>(() => {\n if (matchStrategy === \"most-specific\") {\n const mostSpecificHrefs = findMostSpecific(allItems, currentPath);\n return (item: SidebarNavItem) => {\n if (item.active !== undefined) return item.active;\n if (!item.href) return false;\n // Exact-flagged items participate in the length-based tiebreaker like all other candidates.\n return mostSpecificHrefs.has(item.href);\n };\n } else {\n return (item: SidebarNavItem, path?: string) => {\n if (item.active !== undefined) return item.active;\n if (item.exact) return isActiveExact(item, path);\n return isActivePrefix(item, path);\n };\n }\n }, [matchStrategy, allItems, currentPath]);\n\n const resolvedGetIsActive = getIsActive ?? defaultIsActiveFn;\n\n const style =\n iconSize !== undefined\n ? ({\n [\"--sidebar-nav-icon-size\" as string]:\n typeof iconSize === \"number\" ? `${iconSize}px` : iconSize,\n } satisfies CSSProperties)\n : undefined;\n\n return (\n <nav\n className={cx(\n styles.sidebarNav,\n collapsed && styles.sidebarNavCollapsed,\n className,\n )}\n aria-label={ariaLabel}\n style={style}\n >\n {header ? <div className={styles.header}>{header}</div> : null}\n <div className={styles.sections}>\n {resolvedSections.map((section, sectionIndex) => (\n <div\n key={section.id ?? `section-${sectionIndex}`}\n className={cx(styles.section, sectionClassName)}\n >\n {section.label && !collapsed ? (\n <div className={styles.sectionLabel}>{section.label}</div>\n ) : null}\n <div className={styles.sectionItems}>\n {section.items.map((item, itemIndex) => (\n <SidebarNavEntry\n key={`${section.id ?? sectionIndex}-${item.href ?? item.title ?? itemIndex}`}\n item={item}\n active={resolvedGetIsActive(item, currentPath)}\n collapsed={collapsed}\n itemClassName={itemClassName}\n onItemClick={onItemClick}\n />\n ))}\n </div>\n </div>\n ))}\n </div>\n {footer ? <div className={styles.footer}>{footer}</div> : null}\n </nav>\n );\n}\n\ntype SidebarNavEntryProps = {\n item: SidebarNavItem;\n active: boolean;\n collapsed: boolean;\n itemClassName?: string;\n onItemClick?: (item: SidebarNavItem) => void;\n};\n\nfunction SidebarNavEntry({\n item,\n active,\n collapsed,\n itemClassName,\n onItemClick,\n}: SidebarNavEntryProps) {\n const rel = item.rel ?? (item.target === \"_blank\" ? \"noreferrer\" : undefined);\n const title = item.title ?? (typeof item.label === \"string\" ? item.label : undefined);\n const hasIcon = Boolean(item.icon);\n const classes = cx(\n styles.item,\n !hasIcon && styles.itemWithoutIcon,\n active && styles.itemActive,\n collapsed && styles.itemCollapsed,\n item.disabled && styles.itemDisabled,\n itemClassName,\n );\n const content = (\n <>\n {hasIcon ? <span className={styles.icon}>{item.icon}</span> : null}\n {!collapsed ? (\n <span className={styles.itemBody}>\n <span className={styles.labelRow}>\n <span className={styles.label}>{item.label}</span>\n {item.badge && <span className={styles.badge}>{item.badge}</span>}\n </span>\n {item.description ? <span className={styles.description}>{item.description}</span> : null}\n </span>\n ) : null}\n </>\n );\n\n const handleClick = () => {\n if (item.disabled) return;\n item.onClick?.();\n onItemClick?.(item);\n };\n\n if (!item.href) {\n return (\n <button\n type=\"button\"\n className={classes}\n aria-current={active ? \"page\" : undefined}\n aria-disabled={item.disabled ? \"true\" : undefined}\n disabled={item.disabled}\n title={collapsed ? title : undefined}\n onClick={handleClick}\n >\n {content}\n </button>\n );\n }\n\n if (item.disabled) {\n return (\n <div\n className={classes}\n aria-current={active ? \"page\" : undefined}\n aria-disabled=\"true\"\n title={collapsed ? title : undefined}\n >\n {content}\n </div>\n );\n }\n\n return (\n <a\n className={classes}\n href={item.href}\n target={item.target}\n rel={rel}\n aria-current={active ? \"page\" : undefined}\n title={collapsed ? title : undefined}\n onClick={handleClick}\n >\n {content}\n </a>\n );\n}\n"],"mappings":";;;;;;AAmDA,IAAM,kBAAkB,MAAsB,SAAkB;CAC9D,IAAI,KAAK,WAAW,KAAA,GAAW,OAAO,KAAK;CAC3C,I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,kBAAA,IAAA,CAAC,OAAD;EACE,WAAW;EACX,gBAAc,SAAS,SAAS,KAAA;EAChC,iBAAc;EACd,OAAO,YAAY,QAAQ,KAAA;YAE1B;CACE,CAAA;CAIT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACE,WAAW;EACX,MAAM,KAAK;EACX,QAAQ,KAAK;EACR;EACL,gBAAc,SAAS,SAAS,KAAA;EAChC,OAAO,YAAY,QAAQ,KAAA;EAC3B,SAAS;YAER;CACA,CAAA;AAEP"}
|
package/dist/index43.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
//#region src/components/page-
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
title,
|
|
13
|
-
description,
|
|
14
|
-
actions
|
|
1
|
+
//#region src/components/page-container/page-container.module.css
|
|
2
|
+
var container = "uzi-page-container-module__container__o7e1A";
|
|
3
|
+
var bleed = "uzi-page-container-module__bleed__8rKR8";
|
|
4
|
+
var page_container_module_default = {
|
|
5
|
+
container,
|
|
6
|
+
"width-sm": "uzi-page-container-module__width-sm__8Mpln",
|
|
7
|
+
"width-md": "uzi-page-container-module__width-md__KSmd5",
|
|
8
|
+
"width-lg": "uzi-page-container-module__width-lg__GpJ-B",
|
|
9
|
+
"width-xl": "uzi-page-container-module__width-xl__S2q8u",
|
|
10
|
+
"width-full": "uzi-page-container-module__width-full__eHJdY",
|
|
11
|
+
bleed
|
|
15
12
|
};
|
|
16
13
|
//#endregion
|
|
17
|
-
export {
|
|
14
|
+
export { bleed, container, page_container_module_default as default };
|
|
18
15
|
|
|
19
16
|
//# sourceMappingURL=index43.js.map
|
package/dist/index43.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index43.js","names":[],"sources":["../src/components/page-
|
|
1
|
+
{"version":3,"file":"index43.js","names":[],"sources":["../src/components/page-container/page-container.module.css"],"sourcesContent":[".container {\n width: 100%;\n margin-inline: auto;\n padding-inline: var(--uzi-page-gutter, clamp(1rem, 3vw, 2rem));\n padding-block: var(--uzi-page-padding-block, clamp(1.5rem, 3vw, 2rem));\n}\n\n.width-sm { max-width: 48rem; }\n.width-md { max-width: 64rem; }\n.width-lg { max-width: 75rem; }\n.width-xl { max-width: 90rem; }\n.width-full { max-width: none; }\n\n.bleed {\n padding-inline: 0;\n}\n"],"mappings":""}
|
package/dist/index44.cjs
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
//#region src/components/page-
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
title,
|
|
13
|
-
description,
|
|
14
|
-
actions
|
|
1
|
+
//#region src/components/page-container/page-container.module.css
|
|
2
|
+
var container = "uzi-page-container-module__container__o7e1A";
|
|
3
|
+
var bleed = "uzi-page-container-module__bleed__8rKR8";
|
|
4
|
+
var page_container_module_default = {
|
|
5
|
+
container,
|
|
6
|
+
"width-sm": "uzi-page-container-module__width-sm__8Mpln",
|
|
7
|
+
"width-md": "uzi-page-container-module__width-md__KSmd5",
|
|
8
|
+
"width-lg": "uzi-page-container-module__width-lg__GpJ-B",
|
|
9
|
+
"width-xl": "uzi-page-container-module__width-xl__S2q8u",
|
|
10
|
+
"width-full": "uzi-page-container-module__width-full__eHJdY",
|
|
11
|
+
bleed
|
|
15
12
|
};
|
|
16
13
|
//#endregion
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.default =
|
|
20
|
-
exports.description = description;
|
|
21
|
-
exports.eyebrow = eyebrow;
|
|
22
|
-
exports.header = header;
|
|
23
|
-
exports.title = title;
|
|
14
|
+
exports.bleed = bleed;
|
|
15
|
+
exports.container = container;
|
|
16
|
+
exports.default = page_container_module_default;
|
|
24
17
|
|
|
25
18
|
//# sourceMappingURL=index44.cjs.map
|
package/dist/index44.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index44.cjs","names":[],"sources":["../src/components/page-
|
|
1
|
+
{"version":3,"file":"index44.cjs","names":[],"sources":["../src/components/page-container/page-container.module.css"],"sourcesContent":[".container {\n width: 100%;\n margin-inline: auto;\n padding-inline: var(--uzi-page-gutter, clamp(1rem, 3vw, 2rem));\n padding-block: var(--uzi-page-padding-block, clamp(1.5rem, 3vw, 2rem));\n}\n\n.width-sm { max-width: 48rem; }\n.width-md { max-width: 64rem; }\n.width-lg { max-width: 75rem; }\n.width-xl { max-width: 90rem; }\n.width-full { max-width: none; }\n\n.bleed {\n padding-inline: 0;\n}\n"],"mappings":""}
|
package/dist/index44.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import { cx } from "./index3.js";
|
|
2
|
-
import
|
|
3
|
-
import { jsx
|
|
4
|
-
//#region src/components/page-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import page_container_module_default from "./index43.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/page-container/PageContainer.tsx
|
|
5
|
+
var WIDTH_CLASS = {
|
|
6
|
+
sm: "width-sm",
|
|
7
|
+
md: "width-md",
|
|
8
|
+
lg: "width-lg",
|
|
9
|
+
xl: "width-xl",
|
|
10
|
+
full: "width-full"
|
|
11
|
+
};
|
|
12
|
+
function PageContainer({ maxWidth = "lg", bleed = false, className, children, ...rest }) {
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
className: cx(page_container_module_default.container, page_container_module_default[WIDTH_CLASS[maxWidth]], bleed && page_container_module_default.bleed, className),
|
|
9
15
|
...rest,
|
|
10
|
-
children
|
|
11
|
-
className: page_header_module_default.content,
|
|
12
|
-
children: [
|
|
13
|
-
eyebrow != null && /* @__PURE__ */ jsx("div", {
|
|
14
|
-
className: page_header_module_default.eyebrow,
|
|
15
|
-
children: eyebrow
|
|
16
|
-
}),
|
|
17
|
-
/* @__PURE__ */ jsx(Heading, {
|
|
18
|
-
className: page_header_module_default.title,
|
|
19
|
-
children: title
|
|
20
|
-
}),
|
|
21
|
-
description != null && /* @__PURE__ */ jsx("div", {
|
|
22
|
-
className: page_header_module_default.description,
|
|
23
|
-
children: description
|
|
24
|
-
})
|
|
25
|
-
]
|
|
26
|
-
}), actions != null && /* @__PURE__ */ jsx("div", {
|
|
27
|
-
className: page_header_module_default.actions,
|
|
28
|
-
children: actions
|
|
29
|
-
})]
|
|
16
|
+
children
|
|
30
17
|
});
|
|
31
18
|
}
|
|
32
19
|
//#endregion
|
|
33
|
-
export {
|
|
20
|
+
export { PageContainer };
|
|
34
21
|
|
|
35
22
|
//# sourceMappingURL=index44.js.map
|
package/dist/index44.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index44.js","names":[],"sources":["../src/components/page-
|
|
1
|
+
{"version":3,"file":"index44.js","names":[],"sources":["../src/components/page-container/PageContainer.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\nimport { cx } from \"../../utils/cx\";\nimport styles from \"./page-container.module.css\";\n\nexport type PageContainerWidth = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\n/** Standard page container with responsive horizontal and vertical gutters. */\nexport type PageContainerProps = HTMLAttributes<HTMLDivElement> & {\n /** Maximum content width. Defaults to `lg`. */\n maxWidth?: PageContainerWidth;\n /** Removes only the responsive horizontal gutters; standard vertical page spacing remains. */\n bleed?: boolean;\n};\n\nconst WIDTH_CLASS: Record<PageContainerWidth, string> = {\n sm: \"width-sm\",\n md: \"width-md\",\n lg: \"width-lg\",\n xl: \"width-xl\",\n full: \"width-full\",\n};\n\nexport function PageContainer({\n maxWidth = \"lg\",\n bleed = false,\n className,\n children,\n ...rest\n}: PageContainerProps) {\n return (\n <div\n className={cx(styles.container, styles[WIDTH_CLASS[maxWidth]], bleed && styles.bleed, className)}\n {...rest}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;AAcA,IAAM,cAAkD;CACtD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;AACR;AAEA,SAAgB,cAAc,EAC5B,WAAW,MACX,QAAQ,OACR,WACA,UACA,GAAG,QACkB;CACrB,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,8BAAO,WAAW,8BAAO,YAAY,YAAY,SAAS,8BAAO,OAAO,SAAS;EAC/F,GAAI;EAEH;CACE,CAAA;AAET"}
|