pixelize-design-library 2.4.2-beta.58 → 2.4.2-beta.59
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/CHANGELOG.md +75 -0
- package/COMPONENT-GOTCHAS.md +88 -2
- package/DESIGN-GUIDE.md +26 -3
- package/dist/Components/AppSwitcher/AppSwitcher.js +5 -1
- package/dist/Components/AppSwitcher/AppSwitcherProps.d.ts +2 -0
- package/dist/Components/AppSwitcher/AppSwitcherProps.js +7 -4
- package/dist/Components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Components/Breadcrumbs/Breadcrumbs.js +33 -10
- package/dist/Components/Breadcrumbs/BreadcrumbsProps.d.ts +16 -2
- package/dist/Components/Card/Card.d.ts +3 -1
- package/dist/Components/Card/Card.js +12 -2
- package/dist/Components/Card/CardProps.d.ts +5 -1
- package/dist/Components/Editor/Editor.js +50 -2
- package/dist/Components/Editor/EditorFieldBar.d.ts +15 -0
- package/dist/Components/Editor/EditorFieldBar.js +19 -0
- package/dist/Components/Editor/EditorProps.d.ts +74 -1
- package/dist/Components/Editor/MakeDynamicDialog.d.ts +12 -0
- package/dist/Components/Editor/MakeDynamicDialog.js +59 -0
- package/dist/Components/Editor/editorLabels.d.ts +4 -0
- package/dist/Components/Editor/editorLabels.js +24 -0
- package/dist/Components/Editor/editorTokenStyles.d.ts +28 -0
- package/dist/Components/Editor/editorTokenStyles.js +30 -0
- package/dist/Components/Editor/editorTokens.d.ts +26 -0
- package/dist/Components/Editor/editorTokens.js +134 -0
- package/dist/Components/Editor/useEditorBridge.d.ts +40 -0
- package/dist/Components/Editor/useEditorBridge.js +141 -0
- package/dist/Components/Kbd/Kbd.d.ts +6 -0
- package/dist/Components/Kbd/Kbd.js +33 -0
- package/dist/Components/Kbd/KbdProps.d.ts +17 -0
- package/dist/Components/Kbd/KbdProps.js +2 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.d.ts +4 -0
- package/dist/Components/LauncherTrigger/LauncherTrigger.js +41 -0
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.d.ts +16 -0
- package/dist/Components/LauncherTrigger/LauncherTriggerProps.js +2 -0
- package/dist/Components/NavLauncher/NavLauncher.d.ts +3 -0
- package/dist/Components/NavLauncher/NavLauncher.js +395 -0
- package/dist/Components/NavLauncher/NavLauncherProps.d.ts +187 -0
- package/dist/Components/NavLauncher/NavLauncherProps.js +2 -0
- package/dist/Components/NavLauncher/NewTabLink.d.ts +3 -0
- package/dist/Components/NavLauncher/NewTabLink.js +14 -0
- package/dist/Components/NavLauncher/PinToggle.d.ts +3 -0
- package/dist/Components/NavLauncher/PinToggle.js +21 -0
- package/dist/Components/NavLauncher/launcherParts.d.ts +93 -0
- package/dist/Components/NavLauncher/launcherParts.js +130 -0
- package/dist/Components/NavLauncher/match.d.ts +53 -0
- package/dist/Components/NavLauncher/match.js +178 -0
- package/dist/Components/NavLauncher/revealStyles.d.ts +4 -0
- package/dist/Components/NavLauncher/revealStyles.js +19 -0
- package/dist/Components/NavigationBar/NavigationBar.d.ts +1 -1
- package/dist/Components/NavigationBar/NavigationBar.js +2 -2
- package/dist/Components/NavigationBar/NavigationBarProps.d.ts +2 -0
- package/dist/Components/PageHeader/PageHeader.d.ts +1 -1
- package/dist/Components/PageHeader/PageHeader.js +9 -2
- package/dist/Components/PageHeader/PageHeaderProps.d.ts +8 -0
- package/dist/Components/PdfViewer/PdfViewer.d.ts +21 -4
- package/dist/Components/PdfViewer/PdfViewer.js +124 -3
- package/dist/Components/Search/Search.js +2 -1
- package/dist/Components/SideBar/SecondaryBar.js +4 -3
- package/dist/Components/SideBar/SideBar.d.ts +1 -1
- package/dist/Components/SideBar/SideBar.js +30 -9
- package/dist/Components/SideBar/SideBarProps.d.ts +32 -0
- package/dist/Components/SideBar/components/MenuItemBox.d.ts +6 -0
- package/dist/Components/SideBar/components/MenuItemBox.js +8 -4
- package/dist/Components/SideBar/components/MenuPopoverContent.js +3 -2
- package/dist/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/Components/SideBar/components/PinnedSection.d.ts +17 -0
- package/dist/Components/SideBar/components/PinnedSection.js +98 -0
- package/dist/Components/SideBar/sidebarFocus.d.ts +23 -0
- package/dist/Components/SideBar/sidebarFocus.js +20 -0
- package/dist/Components/StageProgress/StageProgress.js +2 -2
- package/dist/Components/StageProgress/StageProgressProps.d.ts +2 -0
- package/dist/Components/StageProgress/StepperStage.js +5 -2
- package/dist/Components/WizardDialog/WizardDialog.d.ts +9 -0
- package/dist/Components/WizardDialog/WizardDialog.js +102 -0
- package/dist/Components/WizardDialog/WizardDialogProps.d.ts +48 -0
- package/dist/Components/WizardDialog/WizardDialogProps.js +2 -0
- package/dist/Components/WizardDialog/useWizardFlow.d.ts +22 -0
- package/dist/Components/WizardDialog/useWizardFlow.js +47 -0
- package/dist/Components/WizardDialog/wizardSteps.d.ts +31 -0
- package/dist/Components/WizardDialog/wizardSteps.js +40 -0
- package/dist/esm/Components/AppSwitcher/AppSwitcher.js +2 -1
- package/dist/esm/Components/AppSwitcher/AppSwitcherProps.js +5 -3
- package/dist/esm/Components/Breadcrumbs/Breadcrumbs.js +35 -12
- package/dist/esm/Components/Card/Card.js +12 -2
- package/dist/esm/Components/Editor/Editor.js +48 -3
- package/dist/esm/Components/Editor/EditorFieldBar.js +13 -0
- package/dist/esm/Components/Editor/MakeDynamicDialog.js +20 -0
- package/dist/esm/Components/Editor/editorLabels.js +20 -0
- package/dist/esm/Components/Editor/editorTokenStyles.js +25 -0
- package/dist/esm/Components/Editor/editorTokens.js +121 -0
- package/dist/esm/Components/Editor/useEditorBridge.js +138 -0
- package/dist/esm/Components/Kbd/Kbd.js +28 -0
- package/dist/esm/Components/Kbd/KbdProps.js +1 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTrigger.js +37 -0
- package/dist/esm/Components/LauncherTrigger/LauncherTriggerProps.js +1 -0
- package/dist/esm/Components/NavLauncher/NavLauncher.js +356 -0
- package/dist/esm/Components/NavLauncher/NavLauncherProps.js +1 -0
- package/dist/esm/Components/NavLauncher/NewTabLink.js +11 -0
- package/dist/esm/Components/NavLauncher/PinToggle.js +18 -0
- package/dist/esm/Components/NavLauncher/launcherParts.js +110 -0
- package/dist/esm/Components/NavLauncher/match.js +172 -0
- package/dist/esm/Components/NavLauncher/revealStyles.js +15 -0
- package/dist/esm/Components/NavigationBar/NavigationBar.js +3 -3
- package/dist/esm/Components/PageHeader/PageHeader.js +9 -2
- package/dist/esm/Components/PdfViewer/PdfViewer.js +123 -2
- package/dist/esm/Components/Search/Search.js +3 -2
- package/dist/esm/Components/SideBar/SecondaryBar.js +4 -3
- package/dist/esm/Components/SideBar/SideBar.js +31 -10
- package/dist/esm/Components/SideBar/components/MenuItemBox.js +4 -2
- package/dist/esm/Components/SideBar/components/MenuPopoverContent.js +3 -2
- package/dist/esm/Components/SideBar/components/OtherApps.js +2 -1
- package/dist/esm/Components/SideBar/components/PinnedSection.js +92 -0
- package/dist/esm/Components/SideBar/sidebarFocus.js +15 -0
- package/dist/esm/Components/StageProgress/StageProgress.js +2 -2
- package/dist/esm/Components/StageProgress/StepperStage.js +5 -2
- package/dist/esm/Components/WizardDialog/WizardDialog.js +58 -0
- package/dist/esm/Components/WizardDialog/WizardDialogProps.js +1 -0
- package/dist/esm/Components/WizardDialog/useWizardFlow.js +44 -0
- package/dist/esm/Components/WizardDialog/wizardSteps.js +35 -0
- package/dist/esm/index.js +7 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +21 -1
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const normalize = (text) => text.toLocaleLowerCase().normalize("NFKD");
|
|
2
|
+
function score(label, haystack, tokens) {
|
|
3
|
+
if (!tokens.every((t) => haystack.includes(t)))
|
|
4
|
+
return null;
|
|
5
|
+
const l = normalize(label);
|
|
6
|
+
const q = tokens.join(" ");
|
|
7
|
+
if (l === q)
|
|
8
|
+
return 0;
|
|
9
|
+
if (l.startsWith(q))
|
|
10
|
+
return 1;
|
|
11
|
+
if (l.split(/\s+/).some((w) => w.startsWith(tokens[0])))
|
|
12
|
+
return 2;
|
|
13
|
+
return l.includes(tokens[0]) ? 3 : 4;
|
|
14
|
+
}
|
|
15
|
+
function rank(rows, text, tokens) {
|
|
16
|
+
return rows
|
|
17
|
+
.map((row, index) => ({
|
|
18
|
+
row,
|
|
19
|
+
index,
|
|
20
|
+
s: score(row.label, normalize(text(row)), tokens),
|
|
21
|
+
}))
|
|
22
|
+
.filter((r) => r.s !== null)
|
|
23
|
+
.sort((a, b) => a.s - b.s || a.index - b.index)
|
|
24
|
+
.map((r) => r.row);
|
|
25
|
+
}
|
|
26
|
+
export function flattenScreens(sections) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const section of sections) {
|
|
31
|
+
for (const module of section.modules) {
|
|
32
|
+
for (const screen of module.screens) {
|
|
33
|
+
if (seen.has(screen.id))
|
|
34
|
+
continue;
|
|
35
|
+
seen.add(screen.id);
|
|
36
|
+
out.push({
|
|
37
|
+
id: `screen:${screen.id}`,
|
|
38
|
+
screenId: screen.id,
|
|
39
|
+
label: screen.label,
|
|
40
|
+
context: screen.label === module.label ? section.label : module.label,
|
|
41
|
+
icon: (_a = screen.icon) !== null && _a !== void 0 ? _a : module.icon,
|
|
42
|
+
badge: screen.badge,
|
|
43
|
+
href: screen.href,
|
|
44
|
+
keywords: [module.label, ...((_b = module.keywords) !== null && _b !== void 0 ? _b : []), ...((_c = screen.keywords) !== null && _c !== void 0 ? _c : [])].join(" "),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
export function searchLauncher(input) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
const tokens = normalize(input.query).split(/\s+/).filter(Boolean);
|
|
54
|
+
if (tokens.length === 0)
|
|
55
|
+
return [];
|
|
56
|
+
const screens = flattenScreens(input.sections);
|
|
57
|
+
const actions = rank(((_a = input.actions) !== null && _a !== void 0 ? _a : []).map((a) => ({ ...a, id: `action:${a.id}` })), (a) => { var _a, _b; return `${a.label} ${(_a = a.context) !== null && _a !== void 0 ? _a : ""} ${(_b = a.keywords) !== null && _b !== void 0 ? _b : ""}`; }, tokens);
|
|
58
|
+
const groups = [
|
|
59
|
+
{ id: "actions", label: input.actionsLabel, items: actions },
|
|
60
|
+
{
|
|
61
|
+
id: "screens",
|
|
62
|
+
label: input.screensLabel,
|
|
63
|
+
items: rank(screens, (s) => { var _a; return `${s.label} ${(_a = s.context) !== null && _a !== void 0 ? _a : ""} ${s.keywords}`; }, tokens),
|
|
64
|
+
},
|
|
65
|
+
...((_b = input.extraResults) !== null && _b !== void 0 ? _b : []).map((g) => ({
|
|
66
|
+
id: g.id,
|
|
67
|
+
label: g.label,
|
|
68
|
+
items: g.items.map((i) => ({ ...i, id: `${g.id}:${i.id}` })),
|
|
69
|
+
})),
|
|
70
|
+
];
|
|
71
|
+
return groups.filter((g) => g.items.length > 0);
|
|
72
|
+
}
|
|
73
|
+
function matchNameOrKeyword(label, keywords, tokens) {
|
|
74
|
+
const name = normalize(label);
|
|
75
|
+
if (tokens.every((t) => name.includes(t)))
|
|
76
|
+
return {};
|
|
77
|
+
const terms = keywords.map(normalize);
|
|
78
|
+
const all = `${name} ${terms.join(" ")}`;
|
|
79
|
+
if (!tokens.every((t) => all.includes(t)))
|
|
80
|
+
return null;
|
|
81
|
+
const hit = keywords.find((_, i) => tokens.some((t) => terms[i].includes(t)));
|
|
82
|
+
return { keyword: hit !== null && hit !== void 0 ? hit : keywords[0] };
|
|
83
|
+
}
|
|
84
|
+
/** Search that keeps the sections: per section, matching modules, each followed by its matching screens. */
|
|
85
|
+
export function searchLauncherSections(input) {
|
|
86
|
+
var _a, _b, _c, _d, _e, _f;
|
|
87
|
+
const tokens = normalize(input.query).split(/\s+/).filter(Boolean);
|
|
88
|
+
if (tokens.length === 0)
|
|
89
|
+
return { sections: [], groups: [] };
|
|
90
|
+
const seen = new Set();
|
|
91
|
+
const sections = [];
|
|
92
|
+
for (const section of input.sections) {
|
|
93
|
+
const items = [];
|
|
94
|
+
for (const module of section.modules) {
|
|
95
|
+
const moduleHit = matchNameOrKeyword(module.label, (_a = module.keywords) !== null && _a !== void 0 ? _a : [], tokens);
|
|
96
|
+
if (moduleHit) {
|
|
97
|
+
items.push({
|
|
98
|
+
id: `module:${module.id}`,
|
|
99
|
+
kind: "module",
|
|
100
|
+
label: module.label,
|
|
101
|
+
keywordHint: moduleHit.keyword,
|
|
102
|
+
icon: module.icon,
|
|
103
|
+
badge: module.badge,
|
|
104
|
+
isNew: module.isNew,
|
|
105
|
+
href: module.href,
|
|
106
|
+
screenId: (_b = module.screens[0]) === null || _b === void 0 ? void 0 : _b.id,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
for (const screen of module.screens) {
|
|
110
|
+
if (screen.label === module.label || seen.has(screen.id))
|
|
111
|
+
continue;
|
|
112
|
+
if (!matchNameOrKeyword(screen.label, (_c = screen.keywords) !== null && _c !== void 0 ? _c : [], tokens))
|
|
113
|
+
continue;
|
|
114
|
+
seen.add(screen.id);
|
|
115
|
+
items.push({
|
|
116
|
+
id: `screen:${screen.id}`,
|
|
117
|
+
kind: "screen",
|
|
118
|
+
label: screen.label,
|
|
119
|
+
context: module.label,
|
|
120
|
+
icon: (_d = screen.icon) !== null && _d !== void 0 ? _d : module.icon,
|
|
121
|
+
badge: screen.badge,
|
|
122
|
+
href: screen.href,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (items.length > 0)
|
|
127
|
+
sections.push({ id: section.id, label: section.label, items });
|
|
128
|
+
}
|
|
129
|
+
const actions = rank(((_e = input.actions) !== null && _e !== void 0 ? _e : []).map((a) => ({ ...a, id: `action:${a.id}` })), (a) => { var _a, _b; return `${a.label} ${(_a = a.context) !== null && _a !== void 0 ? _a : ""} ${(_b = a.keywords) !== null && _b !== void 0 ? _b : ""}`; }, tokens);
|
|
130
|
+
const groups = [
|
|
131
|
+
{ id: "actions", label: input.actionsLabel, items: actions },
|
|
132
|
+
...((_f = input.extraResults) !== null && _f !== void 0 ? _f : []).map((g) => ({
|
|
133
|
+
id: g.id,
|
|
134
|
+
label: g.label,
|
|
135
|
+
items: g.items.map((i) => ({ ...i, id: `${g.id}:${i.id}` })),
|
|
136
|
+
})),
|
|
137
|
+
].filter((g) => g.items.length > 0);
|
|
138
|
+
return { sections, groups };
|
|
139
|
+
}
|
|
140
|
+
/** Splits `text` so every case-insensitive occurrence of a query token is its own matched segment. */
|
|
141
|
+
export function highlightSegments(text, query) {
|
|
142
|
+
const lower = text.toLocaleLowerCase();
|
|
143
|
+
const tokens = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
144
|
+
if (tokens.length === 0 || lower.length !== text.length)
|
|
145
|
+
return [{ text, isMatch: false }];
|
|
146
|
+
const ranges = [];
|
|
147
|
+
for (const token of tokens) {
|
|
148
|
+
for (let at = lower.indexOf(token); at !== -1; at = lower.indexOf(token, at + token.length)) {
|
|
149
|
+
ranges.push([at, at + token.length]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
ranges.sort((a, b) => a[0] - b[0]);
|
|
153
|
+
const merged = [];
|
|
154
|
+
for (const range of ranges) {
|
|
155
|
+
const last = merged[merged.length - 1];
|
|
156
|
+
if (last && range[0] <= last[1])
|
|
157
|
+
last[1] = Math.max(last[1], range[1]);
|
|
158
|
+
else
|
|
159
|
+
merged.push([...range]);
|
|
160
|
+
}
|
|
161
|
+
const out = [];
|
|
162
|
+
let cursor = 0;
|
|
163
|
+
for (const [start, end] of merged) {
|
|
164
|
+
if (start > cursor)
|
|
165
|
+
out.push({ text: text.slice(cursor, start), isMatch: false });
|
|
166
|
+
out.push({ text: text.slice(start, end), isMatch: true });
|
|
167
|
+
cursor = end;
|
|
168
|
+
}
|
|
169
|
+
if (cursor < text.length)
|
|
170
|
+
out.push({ text: text.slice(cursor), isMatch: false });
|
|
171
|
+
return out.length ? out : [{ text, isMatch: false }];
|
|
172
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { focusVisibleStyles } from "../../Theme/chakra/focusRing.styles.js";
|
|
2
|
+
import { reducedMotionSx } from "../../Theme/chakra/motion.js";
|
|
3
|
+
/** Shows a row affordance on row hover, row focus-within or its own keyboard focus, and always on touch. */
|
|
4
|
+
export const revealStyles = (colors) => {
|
|
5
|
+
const ring = focusVisibleStyles(colors);
|
|
6
|
+
return {
|
|
7
|
+
...ring,
|
|
8
|
+
_focusVisible: { ...ring._focusVisible, opacity: 1 },
|
|
9
|
+
_groupHover: { opacity: 1 },
|
|
10
|
+
_groupFocusWithin: { opacity: 1 },
|
|
11
|
+
"[data-reveal=true] &": { opacity: 1 },
|
|
12
|
+
"@media (hover: none)": { opacity: 1 },
|
|
13
|
+
...reducedMotionSx(),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Button, Flex, Menu, MenuButton, MenuDivider, MenuItem, MenuList, Stack, Text, } from "@chakra-ui/react";
|
|
3
3
|
import Avatar from "../Avatar/Avatar.js";
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
@@ -10,7 +10,7 @@ import PersonChip from "../PersonChip/PersonChip.js";
|
|
|
10
10
|
import { CircleArrowLeft, LogOut, PanelLeftClose, PanelRightClose, } from "lucide-react";
|
|
11
11
|
// Roomy enough to hover without aiming: the glyph is only 1.25rem.
|
|
12
12
|
const SIDEBAR_TOGGLE_HIT = "2.5rem";
|
|
13
|
-
export default function NavBar({ userAvathar, userName, userRole, navMenu, moreIcon, handleNavOnClick, handleLogout, logoutText, navigationBarText, sideBarToggole, onSideBarToggole, forceSideBarToggle = false, onSideBarPeek, }) {
|
|
13
|
+
export default function NavBar({ userAvathar, userName, userRole, navMenu, moreIcon, handleNavOnClick, handleLogout, logoutText, navigationBarText, sideBarToggole, onSideBarToggole, forceSideBarToggle = false, onSideBarPeek, leading, }) {
|
|
14
14
|
const theme = useCustomTheme();
|
|
15
15
|
const rowBackgrounds = listRowBackgrounds(theme.colors);
|
|
16
16
|
const menuHoverBg = rowBackgrounds.active;
|
|
@@ -46,7 +46,7 @@ export default function NavBar({ userAvathar, userName, userRole, navMenu, moreI
|
|
|
46
46
|
_focus: { bg: menuHoverBg },
|
|
47
47
|
_active: { bg: rowBackgrounds.selectedActive },
|
|
48
48
|
};
|
|
49
|
-
return (_jsx(Box, { bg: theme.colors.backgroundColor.light, px: 4, borderBottom: "1px solid", borderColor: theme.colors.boxborder[200], children: _jsxs(Flex, { h: 16, alignItems: "center", justifyContent: "space-between", children: [_jsxs(Box, { display: "flex", gap: 1.5, alignItems: "center", children: [_jsx(Box, { as: "button", type: "button", onClick: () => onSideBarToggole === null || onSideBarToggole === void 0 ? void 0 : onSideBarToggole(), onMouseEnter: onSideBarPeek, onFocus: onSideBarPeek, "aria-label": sideBarToggole ? "Close navigation menu" : "Open navigation menu", "aria-expanded": !!sideBarToggole, ...iconButtonStyle, display: forceSideBarToggle ? "flex" : { base: "flex", lg: "none" }, w: SIDEBAR_TOGGLE_HIT, h: SIDEBAR_TOGGLE_HIT, children: sideBarToggole ? (_jsx(PanelLeftClose, { size: "1.25rem" })) : (_jsx(PanelRightClose, { size: "1.25rem" })) }), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) && (_jsx(Box, { ...iconButtonStyle, as: "button", type: "button", "aria-label": "Go back", display: "flex", onClick: () => { var _a; return (_a = navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) === null || _a === void 0 ? void 0 : _a.call(navigationBarText); }, children: _jsx(CircleArrowLeft, { size: "1.25rem", color: theme.colors.text[500] }) })), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text) && (_jsx(Text, { color: accentTextOnCanvas(theme.colors.secondary, theme.colors.backgroundColor.light), fontSize: "1.25rem", fontWeight: 600, fontFamily: "open-sans, sans-serif", letterSpacing: "-0.013rem", children: navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text }))] }), _jsx(Flex, { minW: 0, flexShrink: 1, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 4, minW: 0, children: [moreIcon && (_jsx(Box, { display: "flex", alignItems: "center", minW: 0, children: moreIcon })), _jsxs(Menu, { children: [_jsx(MenuButton, { as: Button, rounded: "full", variant: "link", cursor: "pointer", minW: 0, flexShrink: 0, children: _jsx(Avatar, { size: "sm", name: userName, src: userAvathar }) }), _jsx(MenuList, { alignItems: "center", zIndex: 5, p: 0, py: "0.375rem",
|
|
49
|
+
return (_jsx(Box, { bg: theme.colors.backgroundColor.light, px: 4, borderBottom: "1px solid", borderColor: theme.colors.boxborder[200], children: _jsxs(Flex, { h: 16, alignItems: "center", justifyContent: "space-between", children: [_jsxs(Box, { display: "flex", gap: 1.5, alignItems: "center", children: [_jsx(Box, { as: "button", type: "button", onClick: () => onSideBarToggole === null || onSideBarToggole === void 0 ? void 0 : onSideBarToggole(), onMouseEnter: onSideBarPeek, onFocus: onSideBarPeek, "aria-label": sideBarToggole ? "Close navigation menu" : "Open navigation menu", "aria-expanded": !!sideBarToggole, ...iconButtonStyle, display: forceSideBarToggle ? "flex" : { base: "flex", lg: "none" }, w: SIDEBAR_TOGGLE_HIT, h: SIDEBAR_TOGGLE_HIT, children: sideBarToggole ? (_jsx(PanelLeftClose, { size: "1.25rem" })) : (_jsx(PanelRightClose, { size: "1.25rem" })) }), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) && (_jsx(Box, { ...iconButtonStyle, as: "button", type: "button", "aria-label": "Go back", display: "flex", onClick: () => { var _a; return (_a = navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.onIconClick) === null || _a === void 0 ? void 0 : _a.call(navigationBarText); }, children: _jsx(CircleArrowLeft, { size: "1.25rem", color: theme.colors.text[500] }) })), leading && (_jsxs(_Fragment, { children: [leading, _jsx(Box, { as: "span", "aria-hidden": "true", mx: 2, w: "1px", h: "1.625rem", bg: theme.colors.boxborder[200] })] })), (navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text) && (_jsx(Text, { color: accentTextOnCanvas(theme.colors.secondary, theme.colors.backgroundColor.light), fontSize: "1.25rem", fontWeight: 600, fontFamily: "open-sans, sans-serif", letterSpacing: "-0.013rem", children: navigationBarText === null || navigationBarText === void 0 ? void 0 : navigationBarText.text }))] }), _jsx(Flex, { minW: 0, flexShrink: 1, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 4, minW: 0, children: [moreIcon && (_jsx(Box, { display: "flex", alignItems: "center", minW: 0, children: moreIcon })), _jsxs(Menu, { children: [_jsx(MenuButton, { as: Button, rounded: "full", variant: "link", cursor: "pointer", minW: 0, flexShrink: 0, children: _jsx(Avatar, { size: "sm", name: userName, src: userAvathar }) }), _jsx(MenuList, { alignItems: "center", zIndex: 5, p: 0, py: "0.375rem",
|
|
50
50
|
// Without a cap one long title stretches the whole dropdown; titles truncate instead.
|
|
51
51
|
maxW: "18rem", bg: theme.colors.surfaceRaised,
|
|
52
52
|
// NOTE: Chakra's MenuItem inherits --menu-bg hardcoded to #fff via dead _dark — set it or items stay white.
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Flex, Heading, Text } from "@chakra-ui/react";
|
|
3
3
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
4
|
+
const TITLE_STYLES = {
|
|
5
|
+
md: { fontSize: "lg", fontWeight: 600, letterSpacing: "-0.01em" },
|
|
6
|
+
lg: { fontSize: "2xl", fontWeight: 700, letterSpacing: "-0.02em", lineHeight: 1.2 },
|
|
7
|
+
xl: { fontSize: { base: "2xl", md: "3xl" }, fontWeight: 700, letterSpacing: "-0.025em", lineHeight: 1.2 },
|
|
8
|
+
};
|
|
4
9
|
/** Page header: h1 title, muted subtitle, right-aligned actions that wrap under on narrow screens. */
|
|
5
|
-
const PageHeader = ({ title, subtitle, actions, breadcrumbs, leading, titleAddon, meta, tabs, "data-testid": testId, }) => {
|
|
10
|
+
const PageHeader = ({ title, subtitle, actions, breadcrumbs, leading, titleAddon, meta, tabs, titleSize = "md", actionsLayout = "auto", "data-testid": testId, }) => {
|
|
6
11
|
const { colors } = useCustomTheme();
|
|
7
|
-
|
|
12
|
+
const wraps = actionsLayout === "auto";
|
|
13
|
+
const stacked = actionsLayout === "stacked";
|
|
14
|
+
return (_jsxs(Flex, { direction: "column", gap: 3, "data-testid": testId, children: [breadcrumbs && (_jsx(Box, { fontSize: "sm", color: colors.textMuted, sx: { "[aria-current=page]": { color: colors.text[800] } }, children: breadcrumbs })), _jsxs(Flex, { justify: "space-between", align: stacked ? "flex-start" : { base: "flex-start", md: "center" }, direction: stacked ? "column" : { base: "column", md: "row" }, wrap: wraps ? "wrap" : "nowrap", gap: 3, children: [_jsxs(Flex, { gap: 3, align: "center", minW: 0, flex: wraps ? { base: "0 1 auto", md: "1 1 16rem" } : undefined, children: [leading && _jsx(Box, { flexShrink: 0, children: leading }), _jsxs(Box, { minW: 0, children: [_jsxs(Flex, { align: "center", gap: 2, wrap: "wrap", children: [_jsx(Heading, { as: "h1", ...TITLE_STYLES[titleSize], color: colors.header[900], children: title }), titleAddon] }), subtitle && (_jsx(Text, { mt: 0.5, fontSize: "sm", color: colors.textMuted, children: subtitle })), meta && (_jsx(Flex, { mt: 1, columnGap: 4, rowGap: 1, wrap: "wrap", align: "center", fontSize: "xs", color: colors.textMuted, children: meta }))] })] }), actions && (_jsx(Flex, { gap: 2, wrap: "wrap", align: "center", flexShrink: wraps ? undefined : 0, children: actions }))] }), tabs && _jsx(Box, { children: tabs })] }));
|
|
8
15
|
};
|
|
9
16
|
export default PageHeader;
|
|
@@ -1,16 +1,137 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
3
|
import { Box, Flex, Text } from "@chakra-ui/react";
|
|
3
4
|
import { Download, ExternalLink, FileText } from "lucide-react";
|
|
4
5
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
6
|
import { accentTextOnCanvas } from "../../Theme/tokens/builders/accentText.js";
|
|
6
7
|
import { listRowBackgrounds } from "../../Theme/tokens/builders/rowStates.js";
|
|
8
|
+
import Button from "../Button/Button.js";
|
|
9
|
+
import Skeletons from "../Skeletons/Skeletons.js";
|
|
7
10
|
import ToolTip from "../ToolTip/ToolTip.js";
|
|
11
|
+
const DEFAULT_LABELS = {
|
|
12
|
+
open: "Open in new tab",
|
|
13
|
+
download: "Download",
|
|
14
|
+
unsupported: "This browser can't display PDFs inline. Open or download the file instead.",
|
|
15
|
+
failed: "The document could not be loaded.",
|
|
16
|
+
};
|
|
17
|
+
const canEmbedPdf = () => typeof navigator === "undefined" || navigator.pdfViewerEnabled !== false;
|
|
18
|
+
const asPdf = (blob) => (blob.type ? blob : new Blob([blob], { type: "application/pdf" }));
|
|
8
19
|
/** Always-inline PDF embed panel (never a modal) — for a modal previewer of images/video/other too, use FilePreview. */
|
|
9
|
-
const PdfViewer = ({ pdfUrl, fileName = "Document.pdf", height = "480px", showToolbar = true, borderRadius = "xl", }) => {
|
|
20
|
+
const PdfViewer = ({ pdfUrl, getBlob, fileName = "Document.pdf", height = "480px", showToolbar = true, borderRadius = "xl", fallback, onLoad, onError, labels, "data-testid": testId, }) => {
|
|
10
21
|
const theme = useCustomTheme();
|
|
22
|
+
const text = { ...DEFAULT_LABELS, ...labels };
|
|
11
23
|
const toolbarSurface = theme.colors.background[50];
|
|
12
24
|
const iconHoverInk = accentTextOnCanvas(theme.colors.primary, toolbarSurface);
|
|
13
25
|
const iconHoverBg = listRowBackgrounds(theme.colors).active;
|
|
14
|
-
|
|
26
|
+
const supported = canEmbedPdf();
|
|
27
|
+
const isBlobMode = Boolean(getBlob);
|
|
28
|
+
const getBlobRef = useRef(getBlob);
|
|
29
|
+
const onLoadRef = useRef(onLoad);
|
|
30
|
+
const onErrorRef = useRef(onError);
|
|
31
|
+
getBlobRef.current = getBlob;
|
|
32
|
+
onLoadRef.current = onLoad;
|
|
33
|
+
onErrorRef.current = onError;
|
|
34
|
+
const [status, setStatus] = useState(isBlobMode && supported ? "loading" : "idle");
|
|
35
|
+
const [objectUrl, setObjectUrl] = useState(null);
|
|
36
|
+
const tempUrls = useRef([]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!isBlobMode || !supported)
|
|
40
|
+
return undefined;
|
|
41
|
+
let cancelled = false;
|
|
42
|
+
let created = null;
|
|
43
|
+
setStatus("loading");
|
|
44
|
+
setObjectUrl(null);
|
|
45
|
+
(_a = getBlobRef.current) === null || _a === void 0 ? void 0 : _a.call(getBlobRef).then((blob) => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (cancelled)
|
|
48
|
+
return;
|
|
49
|
+
created = URL.createObjectURL(asPdf(blob));
|
|
50
|
+
setObjectUrl(created);
|
|
51
|
+
setStatus("ready");
|
|
52
|
+
(_a = onLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadRef);
|
|
53
|
+
}, (error) => {
|
|
54
|
+
var _a;
|
|
55
|
+
if (cancelled)
|
|
56
|
+
return;
|
|
57
|
+
setStatus("error");
|
|
58
|
+
(_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error);
|
|
59
|
+
});
|
|
60
|
+
return () => {
|
|
61
|
+
cancelled = true;
|
|
62
|
+
if (created)
|
|
63
|
+
URL.revokeObjectURL(created);
|
|
64
|
+
};
|
|
65
|
+
}, [isBlobMode, supported]);
|
|
66
|
+
useEffect(() => () => {
|
|
67
|
+
tempUrls.current.forEach((url) => URL.revokeObjectURL(url));
|
|
68
|
+
tempUrls.current = [];
|
|
69
|
+
}, []);
|
|
70
|
+
const makeTempUrl = useCallback((blob) => {
|
|
71
|
+
const url = URL.createObjectURL(asPdf(blob));
|
|
72
|
+
tempUrls.current.push(url);
|
|
73
|
+
return url;
|
|
74
|
+
}, []);
|
|
75
|
+
const openBlob = () => {
|
|
76
|
+
var _a;
|
|
77
|
+
if (objectUrl) {
|
|
78
|
+
window.open(objectUrl, "_blank", "noopener");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const tab = window.open("", "_blank");
|
|
82
|
+
(_a = getBlobRef.current) === null || _a === void 0 ? void 0 : _a.call(getBlobRef).then((blob) => {
|
|
83
|
+
const url = makeTempUrl(blob);
|
|
84
|
+
if (tab)
|
|
85
|
+
tab.location.href = url;
|
|
86
|
+
else
|
|
87
|
+
window.location.assign(url);
|
|
88
|
+
}, (error) => {
|
|
89
|
+
var _a;
|
|
90
|
+
tab === null || tab === void 0 ? void 0 : tab.close();
|
|
91
|
+
(_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error);
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const downloadBlob = () => {
|
|
95
|
+
var _a;
|
|
96
|
+
(_a = getBlobRef.current) === null || _a === void 0 ? void 0 : _a.call(getBlobRef).then((blob) => {
|
|
97
|
+
const link = document.createElement("a");
|
|
98
|
+
link.href = makeTempUrl(blob);
|
|
99
|
+
link.download = fileName;
|
|
100
|
+
document.body.appendChild(link);
|
|
101
|
+
link.click();
|
|
102
|
+
link.remove();
|
|
103
|
+
}, (error) => { var _a; return (_a = onErrorRef.current) === null || _a === void 0 ? void 0 : _a.call(onErrorRef, error); });
|
|
104
|
+
};
|
|
105
|
+
const toolbarLabel = (kind) => {
|
|
106
|
+
if (labels === null || labels === void 0 ? void 0 : labels[kind])
|
|
107
|
+
return `${labels[kind]} ${fileName}`;
|
|
108
|
+
return kind === "open" ? `Open ${fileName} in a new tab` : `Download ${fileName}`;
|
|
109
|
+
};
|
|
110
|
+
const actionStyle = {
|
|
111
|
+
p: 2,
|
|
112
|
+
borderRadius: "lg",
|
|
113
|
+
color: theme.colors.gray[600],
|
|
114
|
+
_hover: { bg: iconHoverBg, color: iconHoverInk },
|
|
115
|
+
};
|
|
116
|
+
const openAction = isBlobMode ? (_jsx(Box, { as: "button", type: "button", onClick: openBlob, "aria-label": toolbarLabel("open"), ...actionStyle, children: _jsx(ExternalLink, { size: 16, "aria-hidden": "true" }) })) : (_jsx(Box, { as: "a", href: pdfUrl, target: "_blank", rel: "noopener noreferrer", "aria-label": toolbarLabel("open"), ...actionStyle, children: _jsx(ExternalLink, { size: 16, "aria-hidden": "true" }) }));
|
|
117
|
+
const downloadAction = isBlobMode && !objectUrl ? (_jsx(Box, { as: "button", type: "button", onClick: downloadBlob, "aria-label": toolbarLabel("download"), ...actionStyle, children: _jsx(Download, { size: 16, "aria-hidden": "true" }) })) : (_jsx(Box, { as: "a", href: objectUrl !== null && objectUrl !== void 0 ? objectUrl : pdfUrl, download: fileName, "aria-label": toolbarLabel("download"), ...actionStyle, children: _jsx(Download, { size: 16, "aria-hidden": "true" }) }));
|
|
118
|
+
const showFallback = !supported || status === "error";
|
|
119
|
+
const isLoading = isBlobMode && supported && status === "loading";
|
|
120
|
+
const renderFallback = () => {
|
|
121
|
+
if (fallback !== undefined)
|
|
122
|
+
return fallback;
|
|
123
|
+
return (_jsxs(Flex, { direction: "column", align: "flex-start", gap: 3, p: 4, "data-testid": "pdf-fallback", children: [_jsx(Text, { role: "status", fontSize: "sm", color: theme.colors.textMuted, children: supported ? text.failed : text.unsupported }), !showToolbar && (_jsxs(Flex, { gap: 2, wrap: "wrap", children: [_jsx(Button, { variant: "outline", colorScheme: "gray", leftIcon: _jsx(ExternalLink, { size: 16, "aria-hidden": "true" }), label: text.open, onClick: isBlobMode ? openBlob : () => window.open(pdfUrl, "_blank", "noopener"), "data-testid": "pdf-open" }), _jsx(Button, { variant: "outline", colorScheme: "gray", leftIcon: _jsx(Download, { size: 16, "aria-hidden": "true" }), label: text.download, onClick: isBlobMode ? downloadBlob : directDownload(pdfUrl, fileName), "data-testid": "pdf-download" })] }))] }));
|
|
124
|
+
};
|
|
125
|
+
return (_jsxs(Box, { border: "1px solid", borderColor: theme.colors.gray[200], borderRadius: borderRadius, overflow: "hidden", bg: theme.colors.background[50], "data-testid": testId, children: [showToolbar && (_jsxs(Flex, { align: "center", justify: "space-between", px: 4, py: 2.5, borderBottom: "1px solid", borderColor: theme.colors.gray[100], bg: theme.colors.background[50], children: [_jsxs(Flex, { align: "center", gap: 2, minW: 0, children: [_jsx(FileText, { size: 18, color: theme.colors.accentText, "aria-hidden": "true" }), _jsx(Text, { fontSize: "sm", fontWeight: 500, color: theme.colors.gray[700], overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", children: fileName })] }), _jsxs(Flex, { align: "center", gap: 1, children: [_jsx(ToolTip, { label: text.open, placement: "top", children: openAction }), _jsx(ToolTip, { label: text.download, placement: "top", children: downloadAction })] })] })), showFallback ? (renderFallback()) : isLoading ? (_jsx(Box, { "aria-busy": "true", "data-testid": "pdf-loading", children: _jsx(Skeletons, { type: "skeleton", height: height, width: "100%", borderRadius: "0" }) })) : (_jsx(Box, { as: "embed", src: objectUrl !== null && objectUrl !== void 0 ? objectUrl : pdfUrl, type: "application/pdf", title: fileName, onLoad: isBlobMode ? undefined : () => { var _a; return (_a = onLoadRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadRef); }, width: "100%", height: height, display: "block" }))] }));
|
|
126
|
+
};
|
|
127
|
+
const directDownload = (url, fileName) => () => {
|
|
128
|
+
if (!url)
|
|
129
|
+
return;
|
|
130
|
+
const link = document.createElement("a");
|
|
131
|
+
link.href = url;
|
|
132
|
+
link.download = fileName;
|
|
133
|
+
document.body.appendChild(link);
|
|
134
|
+
link.click();
|
|
135
|
+
link.remove();
|
|
15
136
|
};
|
|
16
137
|
export default PdfViewer;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useRef } from "react";
|
|
3
|
-
import { Input, InputGroup, InputLeftElement, InputRightElement, Icon, IconButton,
|
|
3
|
+
import { Input, InputGroup, InputLeftElement, InputRightElement, Icon, IconButton, FormControl, useMergeRefs, } from "@chakra-ui/react";
|
|
4
4
|
import { Search as SearchIconComponent, X } from "lucide-react";
|
|
5
|
+
import Kbd from "../Kbd/Kbd.js";
|
|
5
6
|
import { TextLabel } from "../Common/FormLabel.js";
|
|
6
7
|
import FieldMessage from "../Common/FieldMessage.js";
|
|
7
8
|
import { useFieldIds } from "../Common/useFieldIds.js";
|
|
@@ -44,6 +45,6 @@ const Search = forwardRef(function Search({ placeholder = "Search...", onSearch,
|
|
|
44
45
|
ps: spec.height,
|
|
45
46
|
pe: rightPadding,
|
|
46
47
|
...reducedMotionSx(),
|
|
47
|
-
} }), (showClear || showHint) && (_jsxs(InputRightElement, { h: spec.height, w: "auto", pe: spec.paddingX, gap: 1, children: [showClear && (_jsx(IconButton, { "aria-label": "Clear search", icon: _jsx(X, { size: spec.iconSize }), variant: "ghost", size: "xs", h: clearSize, minW: clearSize, color: theme.colors.textMuted, onClick: handleClear, sx: focusVisibleStyles(theme.colors) })), showHint && (_jsx(
|
|
48
|
+
} }), (showClear || showHint) && (_jsxs(InputRightElement, { h: spec.height, w: "auto", pe: spec.paddingX, gap: 1, children: [showClear && (_jsx(IconButton, { "aria-label": "Clear search", icon: _jsx(X, { size: spec.iconSize }), variant: "ghost", size: "xs", h: clearSize, minW: clearSize, color: theme.colors.textMuted, onClick: handleClear, sx: focusVisibleStyles(theme.colors) })), showHint && (_jsx("span", { "aria-hidden": true, children: _jsx(Kbd, { size: "xs", children: shortcut }) }))] }))] }), _jsx(FieldMessage, { error: error, errorMessage: errorMessage, helperText: helperText, helperId: ids.helperId, errorId: ids.errorId })] }));
|
|
48
49
|
});
|
|
49
50
|
export default Search;
|
|
@@ -4,6 +4,7 @@ import { Box, Flex, Icon, VStack, Badge, Popover, PopoverTrigger, PopoverContent
|
|
|
4
4
|
import { useCustomTheme } from "../../Theme/useCustomTheme.js";
|
|
5
5
|
import { getSidebarActiveAccent } from "./sidebarAccentColors.js";
|
|
6
6
|
import { transitionFor } from "../../Theme/tokens/primitives/motion.js";
|
|
7
|
+
import { sidebarFocusStyles } from "./sidebarFocus.js";
|
|
7
8
|
import { menuDisabled } from "./menuDisabled.js";
|
|
8
9
|
import { ChevronLeft, ChevronRight, LockKeyhole } from "lucide-react";
|
|
9
10
|
import OverflowTooltipText from "./components/OverflowTooltipText.js";
|
|
@@ -46,7 +47,7 @@ const CollapsedItem = ({ item, isActive, itemFontSize, onItemClick }) => {
|
|
|
46
47
|
e.preventDefault();
|
|
47
48
|
if (!blocked)
|
|
48
49
|
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
49
|
-
}, bg: isActive ? "whiteAlpha.300" : "transparent", transition: "background 0.12s", children: _jsxs(Box, { position: "relative", display: "flex", alignItems: "center", children: [_jsx(Icon, { as: item.icon, fontSize: SIDEBAR_ROW.iconSize, color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: "color 0.12s" }), badgeVal != null && (_jsx(Box, { position: "absolute", top: "0", right: "0", w: "0.375rem", h: "0.375rem", borderRadius: "full", bg: theme.colors.sidebar.semanticText.error }))] }) }) }), _jsx(Portal, { children: _jsx(PopoverContent, { borderRadius: "lg", bg: theme.colors.sidebar.elevated, boxShadow: "lg", minW: "10rem", maxW: "14rem", py: "0.125rem", ml: "-0.5rem", cursor: blocked ? "not-allowed" : "pointer", zIndex: 1500, color: theme.colors.white, border: 'none', children: _jsx(PopoverBody, { p: 3, children: _jsxs(Flex, { align: "center", gap: 2, justify: "space-between", children: [_jsxs(Flex, { align: "center", gap: 2, flex: "1", minW: 0, children: [_jsx(Icon, { as: item.icon, fontSize: "md", flexShrink: 0 }), _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: itemFontSize, fontWeight: "medium", as: "p", children: item.title })] }), item.locked ? (item.lockedReason ? (_jsx(ToolTip, { label: item.lockedReason, placement: "top", children: _jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon }) })) : (_jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon }))) : (badgeVal != null && (_jsx(Badge, { ...softBadge(theme.colors, colorScheme, sidebarRowPeak(theme.colors.sidebar.elevated)), fontSize: "xs", variant: variant, borderRadius: radius, children: badgeVal })))] }) }) }) })] }));
|
|
50
|
+
}, bg: isActive ? "whiteAlpha.300" : "transparent", transition: "background 0.12s", sx: sidebarFocusStyles(theme.colors), children: _jsxs(Box, { position: "relative", display: "flex", alignItems: "center", children: [_jsx(Icon, { as: item.icon, fontSize: SIDEBAR_ROW.iconSize, color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: "color 0.12s" }), badgeVal != null && (_jsx(Box, { position: "absolute", top: "0", right: "0", w: "0.375rem", h: "0.375rem", borderRadius: "full", bg: theme.colors.sidebar.semanticText.error }))] }) }) }), _jsx(Portal, { children: _jsx(PopoverContent, { borderRadius: "lg", bg: theme.colors.sidebar.elevated, boxShadow: "lg", minW: "10rem", maxW: "14rem", py: "0.125rem", ml: "-0.5rem", cursor: blocked ? "not-allowed" : "pointer", zIndex: 1500, color: theme.colors.white, border: 'none', children: _jsx(PopoverBody, { p: 3, children: _jsxs(Flex, { align: "center", gap: 2, justify: "space-between", children: [_jsxs(Flex, { align: "center", gap: 2, flex: "1", minW: 0, children: [_jsx(Icon, { as: item.icon, fontSize: "md", flexShrink: 0 }), _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: itemFontSize, fontWeight: "medium", as: "p", children: item.title })] }), item.locked ? (item.lockedReason ? (_jsx(ToolTip, { label: item.lockedReason, placement: "top", children: _jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon }) })) : (_jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon }))) : (badgeVal != null && (_jsx(Badge, { ...softBadge(theme.colors, colorScheme, sidebarRowPeak(theme.colors.sidebar.elevated)), fontSize: "xs", variant: variant, borderRadius: radius, children: badgeVal })))] }) }) }) })] }));
|
|
50
51
|
};
|
|
51
52
|
const ExpandedItem = ({ item, isActive, itemFontSize, onItemClick }) => {
|
|
52
53
|
var _a;
|
|
@@ -60,7 +61,7 @@ const ExpandedItem = ({ item, isActive, itemFontSize, onItemClick }) => {
|
|
|
60
61
|
e.preventDefault();
|
|
61
62
|
if (!blocked)
|
|
62
63
|
onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(item);
|
|
63
|
-
}, borderLeft: "2px solid", borderLeftColor: isActive ? theme.colors.sidebar.activeIcon : "transparent", transition: "background 0.12s", children: [_jsxs(Flex, { align: "center", gap: 2, flex: "1", minW: 0, overflow: "hidden", children: [_jsx(Icon, { as: item.icon, fontSize: SIDEBAR_ROW.iconSize, flexShrink: 0, color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: "color 0.12s" }), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: itemFontSize, fontWeight: isActive ? 600 : 500, color: isActive ? activeAccent.label : theme.colors.white, _groupHover: isActive ? undefined : { color: theme.colors.white }, as: "p", children: item.title }) })] }), item.locked ? (_jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon })) : (badgeVal != null && (_jsx(Badge, { ...softBadge(theme.colors, colorScheme, sidebarRowPeak(theme.colors.sidebar.background[500])), fontSize: "xs", variant: variant, borderRadius: radius, children: badgeVal })))] }));
|
|
64
|
+
}, borderLeft: "2px solid", borderLeftColor: isActive ? theme.colors.sidebar.activeIcon : "transparent", transition: "background 0.12s", sx: sidebarFocusStyles(theme.colors), children: [_jsxs(Flex, { align: "center", gap: 2, flex: "1", minW: 0, overflow: "hidden", children: [_jsx(Icon, { as: item.icon, fontSize: SIDEBAR_ROW.iconSize, flexShrink: 0, color: isActive ? activeAccent.icon : theme.colors.sidebar.mutedIcon, _groupHover: isActive ? undefined : { color: theme.colors.white }, transition: "color 0.12s" }), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: itemFontSize, fontWeight: isActive ? 600 : 500, color: isActive ? activeAccent.label : theme.colors.white, _groupHover: isActive ? undefined : { color: theme.colors.white }, as: "p", children: item.title }) })] }), item.locked ? (_jsx(Icon, { as: LockKeyhole, fontSize: "sm", flexShrink: 0, color: theme.colors.sidebar.mutedIcon })) : (badgeVal != null && (_jsx(Badge, { ...softBadge(theme.colors, colorScheme, sidebarRowPeak(theme.colors.sidebar.background[500])), fontSize: "xs", variant: variant, borderRadius: radius, children: badgeVal })))] }));
|
|
64
65
|
return item.locked && item.lockedReason ? (_jsx(ToolTip, { label: item.lockedReason, placement: "top", children: row })) : (row);
|
|
65
66
|
};
|
|
66
67
|
const SecondaryBar = ({ items = [], defaultCollapsed = true, collapsedWidth = "3.5rem", expandedWidth = "10rem", headerFontSize = SIDEBAR_ROW.fontSize, itemFontSize = SIDEBAR_ROW.fontSize, selected, onItemClick, title, icon, }) => {
|
|
@@ -69,7 +70,7 @@ const SecondaryBar = ({ items = [], defaultCollapsed = true, collapsedWidth = "3
|
|
|
69
70
|
const scrollContainerId = sanitizeId(useId());
|
|
70
71
|
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
71
72
|
const width = collapsed ? collapsedWidth : expandedWidth;
|
|
72
|
-
return (_jsx(Box, { as: "nav", "aria-label": title ? `${title} navigation` : "Secondary navigation", transition: transitionFor(["width"], "base"), pos: "sticky", top: 0, sx: fullViewportHeight, w: width, bg: theme.colors.sidebar.background[500], borderLeft: "1px solid", borderColor: theme.colors.sidebar.divider, boxShadow: theme.shadows.md, zIndex: 1, children: _jsxs(VStack, { align: "stretch", spacing: 0, h: "100%", children: [_jsxs(Flex, { align: "center", justify: collapsed ? "center" : "space-between", px: collapsed ? 0 : "10px", gap: "7px", h: HEADER_HEIGHT, overflow: "hidden", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, flexShrink: 0, children: [!collapsed && (_jsxs(_Fragment, { children: [icon && (_jsx(Icon, { as: icon, fontSize: SIDEBAR_ROW.iconSize, color: activeAccent.icon, flexShrink: 0 })), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: headerFontSize, fontWeight: 600, color: theme.colors.white, as: "p", children: title !== null && title !== void 0 ? title : "" }) })] })), _jsx(Box, { as: "button", type: "button", "aria-label": collapsed ? "Expand navigation panel" : "Collapse navigation panel", "aria-expanded": !collapsed, border: "none", bg: "transparent", w: "24px", h: "24px", borderRadius: "lg", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", flexShrink: 0, onClick: () => setCollapsed((c) => !c), _hover: { bg: "whiteAlpha.200" }, transition: "background 0.15s", children: collapsed ? (_jsx(ToolTip, { label: title !== null && title !== void 0 ? title : "", placement: "right", children: _jsx(ChevronRight, { size: 13, color: theme.colors.sidebar.mutedIcon }) })) : (_jsx(ChevronLeft, { size: 13, color: theme.colors.sidebar.mutedIcon })) })] }), _jsx(Box, { id: scrollContainerId, flex: "1", minH: 0, overflowY: "auto", overflowX: "hidden", py: 2, px: "6px", sx: cssForScrollBar(theme), children: items.map((item) => {
|
|
73
|
+
return (_jsx(Box, { as: "nav", "aria-label": title ? `${title} navigation` : "Secondary navigation", transition: transitionFor(["width"], "base"), pos: "sticky", top: 0, sx: fullViewportHeight, w: width, bg: theme.colors.sidebar.background[500], borderLeft: "1px solid", borderColor: theme.colors.sidebar.divider, boxShadow: theme.shadows.md, zIndex: 1, children: _jsxs(VStack, { align: "stretch", spacing: 0, h: "100%", children: [_jsxs(Flex, { align: "center", justify: collapsed ? "center" : "space-between", px: collapsed ? 0 : "10px", gap: "7px", h: HEADER_HEIGHT, overflow: "hidden", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, flexShrink: 0, children: [!collapsed && (_jsxs(_Fragment, { children: [icon && (_jsx(Icon, { as: icon, fontSize: SIDEBAR_ROW.iconSize, color: activeAccent.icon, flexShrink: 0 })), _jsx(Box, { flex: "1", minW: 0, children: _jsx(OverflowTooltipText, { placement: "right", maxWidth: "100%", fontSize: headerFontSize, fontWeight: 600, color: theme.colors.white, as: "p", children: title !== null && title !== void 0 ? title : "" }) })] })), _jsx(Box, { as: "button", type: "button", "aria-label": collapsed ? "Expand navigation panel" : "Collapse navigation panel", "aria-expanded": !collapsed, border: "none", bg: "transparent", w: "24px", h: "24px", borderRadius: "lg", display: "flex", alignItems: "center", justifyContent: "center", cursor: "pointer", flexShrink: 0, onClick: () => setCollapsed((c) => !c), _hover: { bg: "whiteAlpha.200" }, transition: "background 0.15s", sx: sidebarFocusStyles(theme.colors), children: collapsed ? (_jsx(ToolTip, { label: title !== null && title !== void 0 ? title : "", placement: "right", children: _jsx(ChevronRight, { size: 13, color: theme.colors.sidebar.mutedIcon }) })) : (_jsx(ChevronLeft, { size: 13, color: theme.colors.sidebar.mutedIcon })) })] }), _jsx(Box, { id: scrollContainerId, flex: "1", minH: 0, overflowY: "auto", overflowX: "hidden", py: 2, px: "6px", sx: cssForScrollBar(theme), children: items.map((item) => {
|
|
73
74
|
var _a;
|
|
74
75
|
const isActive = String(selected) === String(item.id) ||
|
|
75
76
|
String(selected) === String(item.title);
|
|
@@ -7,7 +7,8 @@ import { sanitizeId } from "./sidebarId.js";
|
|
|
7
7
|
import { cssForScrollBar, HEADER_HEIGHT } from "../../Constants/Sidebar.js";
|
|
8
8
|
import { overlayScrimStyles } from "../../Theme/chakra/overlay.styles.js";
|
|
9
9
|
import { REDUCED_MOTION_QUERY } from "../../Theme/chakra/motion.js";
|
|
10
|
-
import {
|
|
10
|
+
import { sidebarFocusStyles } from "./sidebarFocus.js";
|
|
11
|
+
import { MOTION_EASE, MOTION_MS } from "../../Theme/tokens/primitives/motion.js";
|
|
11
12
|
import { ArrowLeftToLine, ArrowRightToLine, ChevronLeft, Maximize2, MoreVertical, PanelLeft, Plus, X } from "lucide-react";
|
|
12
13
|
// Overlay stacking — mirrors theme.zIndices (overlay=1300 scrim, modal=1400 panel).
|
|
13
14
|
const Z_SCRIM = 1300;
|
|
@@ -18,6 +19,18 @@ const Z_PANEL = 1400;
|
|
|
18
19
|
const RAIL_WIDTH = "4.688rem";
|
|
19
20
|
const PANEL_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
20
21
|
const EXPANDED_WIDTH = "13rem";
|
|
22
|
+
const COLLAPSE_MS = { ...MOTION_MS, slow: 260 };
|
|
23
|
+
const NO_ACTIVE_MENU = "\u0000pinned-active";
|
|
24
|
+
const inlineTransitions = (collapse) => {
|
|
25
|
+
var _a;
|
|
26
|
+
if (collapse === "none")
|
|
27
|
+
return { width: "none", shadow: "none" };
|
|
28
|
+
const ms = COLLAPSE_MS[(_a = collapse.speed) !== null && _a !== void 0 ? _a : "slow"];
|
|
29
|
+
return {
|
|
30
|
+
width: `width ${ms}ms ${PANEL_EASE}`,
|
|
31
|
+
shadow: collapse.animateShadow === false ? "none" : `box-shadow ${ms}ms ${MOTION_EASE}`,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
21
34
|
const OVERLAY_WIDTH = "14.7rem";
|
|
22
35
|
const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
23
36
|
import MenuItems from "./components/MenuItems.js";
|
|
@@ -25,6 +38,7 @@ import DefaultLogo from "../../Assets/defaultLogo.js";
|
|
|
25
38
|
import OverflowTooltipText from "./components/OverflowTooltipText.js";
|
|
26
39
|
import SecondaryBar from "./SecondaryBar.js";
|
|
27
40
|
import OtherApps from "./components/OtherApps.js";
|
|
41
|
+
import PinnedSection from "./components/PinnedSection.js";
|
|
28
42
|
import { SIDEBAR_CHROME, SIDEBAR_ROW } from "./sidebarScale.js";
|
|
29
43
|
import { fullViewportHeight } from "../../Theme/tokens/builders/viewportHeight.js";
|
|
30
44
|
const SidebarHeader = ({ logo, companyName, companySubtitle, toggle, isLoading, onToggle, overlay, onClose, }) => {
|
|
@@ -41,6 +55,7 @@ const SidebarHeader = ({ logo, companyName, companySubtitle, toggle, isLoading,
|
|
|
41
55
|
// some brands (zinc), making the tile disappear. See THEME-CONTRACT.md sidebar rules.
|
|
42
56
|
bg: theme.colors.sidebar.activeBg, color: activeAccent.label, borderRadius: "lg", boxSize: "1.75rem", display: "flex", alignItems: "center", justifyContent: "center", fontWeight: "bold", flexShrink: 0, cursor: toggle ? "pointer" : undefined, onClick: toggle ? onToggle : undefined, children: _jsx(DefaultLogo, {}) }));
|
|
43
57
|
return (_jsxs(Flex, { h: HEADER_HEIGHT, w: "100%", alignItems: "center", justifyContent: toggle ? "center" : "flex-start", gap: 2, px: toggle ? "8px" : "10px", borderBottom: "1px solid", borderColor: theme.colors.sidebar.divider, minW: 0, overflow: "hidden", flexShrink: 0, children: [logoNode, !toggle && (_jsxs(Box, { flex: "1", minW: 0, children: [_jsx(OverflowTooltipText, { placement: "right", fontWeight: 600, fontSize: SIDEBAR_CHROME.titleFontSize, textAlign: "left", color: theme.colors.white, lineHeight: "1.3", as: "p", width: "100%", children: companyName !== null && companyName !== void 0 ? companyName : "" }), companySubtitle && (_jsx(Text, { fontSize: SIDEBAR_CHROME.metaFontSize, color: theme.colors.sidebar.mutedLabel, lineHeight: "1.3", isTruncated: true, children: companySubtitle }))] })), !toggle && (_jsx(Box, { as: "button", type: "button", onClick: overlay ? onClose : onToggle, "aria-label": overlay ? "Close menu" : "Collapse sidebar", w: "22px", h: "22px", borderRadius: "lg", bg: "whiteAlpha.200", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, position: "relative", _hover: { bg: "whiteAlpha.300" }, transition: "background 0.15s", sx: {
|
|
58
|
+
...sidebarFocusStyles(theme.colors),
|
|
44
59
|
"&::after": {
|
|
45
60
|
content: '""',
|
|
46
61
|
position: "absolute",
|
|
@@ -59,7 +74,7 @@ const SkeletonMenuRow = ({ toggle }) => {
|
|
|
59
74
|
const AddNewButton = ({ toggle, onClick, overlay }) => {
|
|
60
75
|
const theme = useCustomTheme();
|
|
61
76
|
const activeAccent = getSidebarActiveAccent(theme.colors);
|
|
62
|
-
return (_jsxs(Flex, { as: "button", type: "button", "data-group": "", "aria-label": "Add New", alignItems: "center", gap: "9px", px: "10px", py: overlay ? "11px" : "7px", borderRadius: "lg", cursor: "pointer", border: "none", bg: "transparent", w: "100%", mb: "2px", justifyContent: toggle ? "center" : "flex-start", _hover: { backgroundColor: "whiteAlpha.200" }, transition: "background 0.12s", onClick: onClick, children: [_jsx(Box, { w: "18px", h: "18px", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, children: _jsx(Plus, { size: 16, color: activeAccent.icon }) }), !toggle && (_jsx(Text, { fontSize: SIDEBAR_ROW.fontSize, color: theme.colors.white, fontWeight: "medium", children: "Add New" }))] }));
|
|
77
|
+
return (_jsxs(Flex, { as: "button", type: "button", "data-group": "", "aria-label": "Add New", alignItems: "center", gap: "9px", px: "10px", py: overlay ? "11px" : "7px", borderRadius: "lg", cursor: "pointer", border: "none", bg: "transparent", w: "100%", mb: "2px", justifyContent: toggle ? "center" : "flex-start", _hover: { backgroundColor: "whiteAlpha.200" }, transition: "background 0.12s", sx: sidebarFocusStyles(theme.colors), onClick: onClick, children: [_jsx(Box, { w: "18px", h: "18px", display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0, children: _jsx(Plus, { size: 16, color: activeAccent.icon }) }), !toggle && (_jsx(Text, { fontSize: SIDEBAR_ROW.fontSize, color: theme.colors.white, fontWeight: "medium", children: "Add New" }))] }));
|
|
63
78
|
};
|
|
64
79
|
const deriveInitials = (user) => {
|
|
65
80
|
if (user.initials)
|
|
@@ -77,13 +92,13 @@ const UserFooter = ({ user, toggle, overlay }) => {
|
|
|
77
92
|
const avatar = user.avatarUrl ? (_jsx(Image, { src: user.avatarUrl, alt: user.name, boxSize: "26px", borderRadius: "full", objectFit: "cover", flexShrink: 0 })) : (_jsx(Box, { boxSize: "26px", borderRadius: "full",
|
|
78
93
|
// Same rail-safe pairing as the logo tile — primary.opacity[32] was invisible on zinc/skyline.
|
|
79
94
|
bg: theme.colors.sidebar.activeBg, color: activeAccent.label, display: "flex", alignItems: "center", justifyContent: "center", fontSize: SIDEBAR_CHROME.metaFontSize, fontWeight: 600, flexShrink: 0, children: deriveInitials(user) }));
|
|
80
|
-
return (_jsx(Box, { borderTop: "1px solid", borderColor: theme.colors.sidebar.divider, py: 2, px: "6px", flexShrink: 0, children: _jsxs(Flex, { as: "button", type: "button", onClick: user.onClick, align: "center", gap: 2, px: 2, py: overlay ? "10px" : "6px", w: "100%", borderRadius: "lg", cursor: "pointer", bg: "transparent", border: "none", justify: toggle ? "center" : "flex-start", _hover: { bg: "whiteAlpha.200" }, transition: "background 0.12s", children: [avatar, !toggle && (_jsxs(Box, { flex: "1", minW: 0, textAlign: "left", children: [_jsx(Text, { fontSize: SIDEBAR_CHROME.labelFontSize, fontWeight: 500, color: theme.colors.white, isTruncated: true, children: user.name }), user.role && (_jsx(Text, { fontSize: SIDEBAR_CHROME.metaFontSize, color: theme.colors.sidebar.mutedLabel, isTruncated: true, children: user.role }))] })), !toggle && _jsx(MoreVertical, { size: 14, color: theme.colors.sidebar.mutedIcon })] }) }));
|
|
95
|
+
return (_jsx(Box, { borderTop: "1px solid", borderColor: theme.colors.sidebar.divider, py: 2, px: "6px", flexShrink: 0, children: _jsxs(Flex, { as: "button", type: "button", onClick: user.onClick, align: "center", gap: 2, px: 2, py: overlay ? "10px" : "6px", w: "100%", borderRadius: "lg", cursor: "pointer", bg: "transparent", border: "none", justify: toggle ? "center" : "flex-start", _hover: { bg: "whiteAlpha.200" }, transition: "background 0.12s", sx: sidebarFocusStyles(theme.colors), children: [avatar, !toggle && (_jsxs(Box, { flex: "1", minW: 0, textAlign: "left", children: [_jsx(Text, { fontSize: SIDEBAR_CHROME.labelFontSize, fontWeight: 500, color: theme.colors.white, isTruncated: true, children: user.name }), user.role && (_jsx(Text, { fontSize: SIDEBAR_CHROME.metaFontSize, color: theme.colors.sidebar.mutedLabel, isTruncated: true, children: user.role }))] })), !toggle && _jsx(MoreVertical, { size: 14, color: theme.colors.sidebar.mutedIcon })] }) }));
|
|
81
96
|
};
|
|
82
97
|
// Footer "cell" — one segment of the Collapse | Hide/Show control.
|
|
83
98
|
const ControlCell = ({ onClick, ariaLabel, label, accent, children }) => {
|
|
84
99
|
const theme = useCustomTheme();
|
|
85
100
|
const activeAccent = getSidebarActiveAccent(theme.colors);
|
|
86
|
-
return (_jsxs(Flex, { as: "button", type: "button", "aria-label": ariaLabel, flex: "1", minW: 0, alignItems: "center", justifyContent: "center", gap: "7px", px: "10px", py: "14px", cursor: "pointer", border: "none", bg: accent ? "whiteAlpha.300" : "transparent", onClick: onClick, _hover: { bg: accent ? "whiteAlpha.400" : "whiteAlpha.200" }, transition: "background 0.15s", children: [children, label && (_jsx(Text, { fontSize: SIDEBAR_CHROME.labelFontSize, color: accent ? activeAccent.label : theme.colors.sidebar.mutedLabel, fontWeight: "medium", children: label }))] }));
|
|
101
|
+
return (_jsxs(Flex, { as: "button", type: "button", "aria-label": ariaLabel, flex: "1", minW: 0, alignItems: "center", justifyContent: "center", gap: "7px", px: "10px", py: "14px", cursor: "pointer", border: "none", bg: accent ? "whiteAlpha.300" : "transparent", onClick: onClick, _hover: { bg: accent ? "whiteAlpha.400" : "whiteAlpha.200" }, transition: "background 0.15s", sx: sidebarFocusStyles(theme.colors), children: [children, label && (_jsx(Text, { fontSize: SIDEBAR_CHROME.labelFontSize, color: accent ? activeAccent.label : theme.colors.sidebar.mutedLabel, fontWeight: "medium", children: label }))] }));
|
|
87
102
|
};
|
|
88
103
|
// Collapse (mini-rail) sits next to the Hide/Show navbar-mode toggle. In the
|
|
89
104
|
// desktop mobile-nav overlay only "Show" (return to the docked sidebar) is shown;
|
|
@@ -102,7 +117,7 @@ const FooterControls = ({ toggle, overlay, mobileNav, onToggleCollapse, onToggle
|
|
|
102
117
|
return shell(_jsxs(_Fragment, { children: [_jsx(ControlCell, { onClick: onToggleCollapse, ariaLabel: toggle ? "Expand sidebar" : undefined, label: toggle ? undefined : "Collapse", children: toggle ? (_jsx(ArrowRightToLine, { size: 14, color: iconColor })) : (_jsx(ArrowLeftToLine, { size: 14, color: iconColor })) }), onToggleMobileNav && (_jsx(ControlCell, { onClick: onToggleMobileNav, ariaLabel: toggle ? "Show sidebar in overlay mode" : undefined, label: toggle ? undefined : "Hide", children: _jsx(Maximize2, { size: 14, color: iconColor }) }))] }));
|
|
103
118
|
};
|
|
104
119
|
// --- Main Sidebar component ---
|
|
105
|
-
export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, companySubtitle, user, isDisableAddNew = false, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open = true, otherApps, mobileOpen = false, onMobileClose, mobileNav = false, onToggleMobileNav, peekOpen = false, onPeekEnd, }) {
|
|
120
|
+
export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, companySubtitle, user, isDisableAddNew = false, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open = true, otherApps, mobileOpen = false, onMobileClose, mobileNav = false, onToggleMobileNav, peekOpen = false, onPeekEnd, pinnedItems, pinnedLabel, onUnpin, activePinnedId, pinnedLimit, pinnedLabels, collapseTransition = { speed: "slow" }, autoCollapse = true, }) {
|
|
106
121
|
var _a, _b;
|
|
107
122
|
const theme = useCustomTheme();
|
|
108
123
|
const scrollContainerId = sanitizeId(useId());
|
|
@@ -142,20 +157,24 @@ export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSeco
|
|
|
142
157
|
const activeTop = menus.find((m) => String(m.title) === String(activeMenu)) ||
|
|
143
158
|
menus.find((m) => String(m.id) === String(activeMenu));
|
|
144
159
|
const secondaryItems = (_b = activeTop === null || activeTop === void 0 ? void 0 : activeTop.secondaryItems) !== null && _b !== void 0 ? _b : [];
|
|
160
|
+
const inline = inlineTransitions(collapseTransition);
|
|
161
|
+
const pinnedActive = activePinnedId != null && !!(pinnedItems === null || pinnedItems === void 0 ? void 0 : pinnedItems.some((p) => String(p.id) === String(activePinnedId)));
|
|
145
162
|
// Sync toggle with external `open` prop.
|
|
146
163
|
// `open=false` → collapsed (toggle=true); `open=true` → expanded (toggle=false).
|
|
147
164
|
useEffect(() => {
|
|
165
|
+
if (!autoCollapse)
|
|
166
|
+
return;
|
|
148
167
|
const shouldBeCollapsed = !open;
|
|
149
168
|
if (shouldBeCollapsed !== toggleRef.current) {
|
|
150
169
|
changeToggleRef.current();
|
|
151
170
|
}
|
|
152
|
-
}, [open]);
|
|
171
|
+
}, [open, autoCollapse]);
|
|
153
172
|
// Auto-collapse the main sidebar whenever a secondary panel is active.
|
|
154
173
|
useEffect(() => {
|
|
155
|
-
if (secondaryItems.length > 0 && !toggleRef.current) {
|
|
174
|
+
if (autoCollapse && secondaryItems.length > 0 && !toggleRef.current) {
|
|
156
175
|
changeToggleRef.current();
|
|
157
176
|
}
|
|
158
|
-
}, [secondaryItems.length]);
|
|
177
|
+
}, [secondaryItems.length, autoCollapse]);
|
|
159
178
|
// Esc closes the overlay.
|
|
160
179
|
useEffect(() => {
|
|
161
180
|
if (!isOverlayOpen)
|
|
@@ -257,12 +276,14 @@ export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSeco
|
|
|
257
276
|
base: dragging
|
|
258
277
|
? "none"
|
|
259
278
|
: "transform 0.28s cubic-bezier(0.22, 1, 0.36, 1)",
|
|
260
|
-
lg:
|
|
279
|
+
lg: inline.shadow,
|
|
261
280
|
}, borderRadius: "none", boxShadow: mobileNav ? theme.shadows["2xl"] : { base: theme.shadows["2xl"], lg: theme.shadows.lg }, display: "flex", background: theme.colors.sidebar.background[500], borderRight: "1px solid", borderColor: theme.colors.sidebar.divider, role: overlay ? "dialog" : undefined, "aria-modal": overlay ? true : undefined, "aria-label": overlay ? "Main navigation" : undefined, ...(overlay && !isOverlayOpen ? { inert: "" } : {}), sx: {
|
|
262
281
|
...fullViewportHeight,
|
|
263
282
|
touchAction: overlay ? "pan-y" : "auto",
|
|
264
283
|
[REDUCED_MOTION_QUERY]: { "&, & *": { transition: "none", animation: "none" } },
|
|
265
284
|
}, onMouseLeave: overlayPeeking ? onPeekEnd : undefined, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, children: [_jsx(Box, { width: mobileNav
|
|
266
285
|
? OVERLAY_WIDTH
|
|
267
|
-
: { base: OVERLAY_WIDTH, lg: effToggle ? RAIL_WIDTH : EXPANDED_WIDTH }, transition:
|
|
286
|
+
: { base: OVERLAY_WIDTH, lg: effToggle ? RAIL_WIDTH : EXPANDED_WIDTH }, transition: mobileNav
|
|
287
|
+
? `width 0.26s ${PANEL_EASE}`
|
|
288
|
+
: { base: `width 0.26s ${PANEL_EASE}`, lg: inline.width }, display: "flex", flexDirection: "column", justifyContent: "space-between", sx: { "@media (prefers-reduced-motion: reduce)": { transition: "none" } }, children: _jsxs(Flex, { flexDir: "column", w: "100%", as: "nav", "aria-label": "Main navigation", h: "100%", children: [_jsx(SidebarHeader, { logo: logo, companyName: companyName, companySubtitle: companySubtitle, toggle: effToggle, isLoading: isLoading, onToggle: changeToggle, overlay: overlay, onClose: onMobileClose }), _jsx(Box, { id: scrollContainerId, flex: "1", minH: 0, w: "100%", overflowY: "auto", overflowX: "hidden", py: 2, px: "6px", sx: cssForScrollBar(theme), children: isLoading ? (Array.from({ length: loadingLines !== null && loadingLines !== void 0 ? loadingLines : 15 }).map((_, i) => (_jsx(SkeletonMenuRow, { toggle: effToggle }, i)))) : (_jsxs(_Fragment, { children: [pinnedItems && pinnedItems.length > 0 && (_jsx(PinnedSection, { items: pinnedItems, label: pinnedLabel, limit: pinnedLimit, toggle: effToggle, overlay: overlay, activeId: activePinnedId, labels: pinnedLabels, onItemClick: handleMenuClickInternal, onUnpin: onUnpin })), _jsx(MenuItems, { activeMenu: pinnedActive ? NO_ACTIVE_MENU : activeMenu, menus: menus, handleMenuClick: handleMenuClickInternal, toggle: effToggle, selectedSubMenu: selectedSubMenu, overlay: overlay, containerId: scrollContainerId })] })) }), _jsxs(Box, { flexShrink: 0, children: [!isDisableAddNew && (_jsx(Box, { borderTop: "1px solid", borderColor: theme.colors.sidebar.divider, py: 2, px: "6px", children: _jsx(AddNewButton, { toggle: effToggle, onClick: onAddNewClick, overlay: overlay }) })), _jsx(OtherApps, { toggle: effToggle, otherApps: otherApps !== null && otherApps !== void 0 ? otherApps : [] }), user && _jsx(UserFooter, { user: user, toggle: effToggle, overlay: overlay }), _jsx(FooterControls, { toggle: effToggle, overlay: overlay, mobileNav: mobileNav, onToggleCollapse: changeToggle, onToggleMobileNav: onToggleMobileNav })] })] }) }), secondaryItems.length > 0 && (_jsx(SecondaryBar, { items: secondaryItems, defaultCollapsed: effToggle, collapsedWidth: "3.5rem", expandedWidth: "10rem", selected: selectedSecondaryItem, onItemClick: handleSecondaryNavClick, title: activeTop === null || activeTop === void 0 ? void 0 : activeTop.title, icon: activeTop === null || activeTop === void 0 ? void 0 : activeTop.icon })), overlay && (_jsx(Box, { display: mobileOpen ? "block" : "none", position: "absolute", top: "50%", right: "6px", transform: "translateY(-50%)", w: "4px", h: "42px", borderRadius: "full", bg: theme.colors.sidebar.mutedIcon, "aria-hidden": "true" }))] })] }));
|
|
268
289
|
}
|