@sybilion/uilib 1.4.14 → 1.4.15
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/dist/agent-glossary/content-prompt.generated.ts +28 -23
- package/dist/agent-glossary/content.generated.ts +28 -23
- package/dist/agent-glossary/content.index.md +1 -1
- package/dist/agent-glossary/content.md +28 -23
- package/dist/agent-glossary/content.prompt.md +28 -23
- package/dist/agent-glossary/workspace.generated.ts +1 -1
- package/dist/agent-glossary/workspace.index.md +1 -1
- package/dist/agent-glossary/workspace.md +1 -1
- package/dist/esm/components/ui/Chat/ChatChrome/ChatChrome.js +28 -3
- package/dist/esm/components/ui/Chat/ChatSheet/useChatPanelChromeModel.js +31 -1
- package/dist/esm/components/ui/DropdownMenu/DropdownMenu.styl.js +2 -2
- package/dist/esm/components/ui/Page/Breadcrumbs/Breadcrumbs.js +28 -1
- package/dist/esm/components/ui/PanelResizeHandle/PanelResizeHandle.js +50 -0
- package/dist/esm/components/ui/Sidebar/Sidebar.styl.js +3 -3
- package/dist/esm/components/ui/Sidebar/SidebarAside.js +36 -0
- package/dist/esm/components/ui/Sidebar/SidebarContent/SidebarContent.js +13 -0
- package/dist/esm/components/ui/Sidebar/SidebarContent/SidebarContent.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarFooter/SidebarFooter.js +9 -0
- package/dist/esm/components/ui/Sidebar/SidebarFooter/SidebarFooter.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarGroup/SidebarGroup.js +9 -0
- package/dist/esm/components/ui/Sidebar/SidebarGroup/SidebarGroup.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.js +11 -0
- package/dist/esm/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenu/SidebarMenu.js +15 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenu/SidebarMenu.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.js +11 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.js +16 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuSub/SidebarMenuSub.js +12 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuSub/SidebarMenuSub.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.js +32 -0
- package/dist/esm/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarProvider/SidebarProvider.js +314 -0
- package/dist/esm/components/ui/Sidebar/SidebarProvider/SidebarProvider.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarRail/SidebarRail.js +11 -0
- package/dist/esm/components/ui/Sidebar/SidebarRail/SidebarRail.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.js +26 -0
- package/dist/esm/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarSeparator/SidebarSeparator.js +10 -0
- package/dist/esm/components/ui/Sidebar/SidebarSeparator/SidebarSeparator.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/SidebarTrigger/SidebarTrigger.js +16 -0
- package/dist/esm/components/ui/Sidebar/SidebarTrigger/SidebarTrigger.styl.js +7 -0
- package/dist/esm/components/ui/Sidebar/sidebarConstants.js +7 -0
- package/dist/esm/components/ui/Sidebar/sidebarContext.js +28 -0
- package/dist/esm/components/ui/Sidebar/sidebarUtils.js +41 -0
- package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.js +26 -5
- package/dist/esm/components/widgets/PerformanceChart/PerformanceTable.js +26 -4
- package/dist/esm/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.js +28 -1
- package/dist/esm/index.js +18 -1
- package/dist/esm/types/src/components/ui/PanelResizeHandle/PanelResizeHandle.d.ts +9 -0
- package/dist/esm/types/src/components/ui/Sidebar/Sidebar.d.ts +19 -108
- package/dist/esm/types/src/components/ui/Sidebar/Sidebar.types.d.ts +41 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarAside.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarContent/SidebarContent.d.ts +3 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarFooter/SidebarFooter.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarGroup/SidebarGroup.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.d.ts +4 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarMenu/SidebarMenu.d.ts +4 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.d.ts +5 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.d.ts +10 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarMenuSub/SidebarMenuSub.d.ts +3 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.d.ts +9 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarProvider/SidebarProvider.d.ts +11 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarRail/SidebarRail.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.d.ts +4 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarSeparator/SidebarSeparator.d.ts +3 -0
- package/dist/esm/types/src/components/ui/Sidebar/SidebarTrigger/SidebarTrigger.d.ts +3 -0
- package/dist/esm/types/src/components/ui/Sidebar/sidebarConstants.d.ts +5 -0
- package/dist/esm/types/src/components/ui/Sidebar/sidebarContext.d.ts +7 -0
- package/dist/esm/types/src/components/ui/Sidebar/sidebarUtils.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/ui/ChartAreaInteractive/AGENT.md +0 -4
- package/src/components/ui/Chat/ChatChrome/ChatChrome.tsx +5 -2
- package/src/components/ui/DropdownMenu/DropdownMenu.styl +4 -1
- package/src/components/ui/PanelResizeHandle/PanelResizeHandle.tsx +89 -0
- package/src/components/ui/Sidebar/Sidebar.styl +23 -625
- package/src/components/ui/Sidebar/Sidebar.styl.d.ts +0 -33
- package/src/components/ui/Sidebar/Sidebar.tsx +25 -1157
- package/src/components/ui/Sidebar/Sidebar.types.ts +46 -0
- package/src/components/ui/Sidebar/SidebarAside.tsx +92 -0
- package/src/components/ui/Sidebar/SidebarContent/SidebarContent.styl +27 -0
- package/src/components/ui/Sidebar/SidebarContent/SidebarContent.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarContent/SidebarContent.tsx +29 -0
- package/src/components/ui/Sidebar/SidebarFooter/SidebarFooter.styl +7 -0
- package/src/components/ui/Sidebar/SidebarFooter/SidebarFooter.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarFooter/SidebarFooter.tsx +15 -0
- package/src/components/ui/Sidebar/SidebarGroup/SidebarGroup.styl +10 -0
- package/src/components/ui/Sidebar/SidebarGroup/SidebarGroup.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarGroup/SidebarGroup.tsx +15 -0
- package/src/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl +34 -0
- package/src/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarGroupAction/SidebarGroupAction.tsx +23 -0
- package/src/components/ui/Sidebar/SidebarMenu/SidebarMenu.styl +60 -0
- package/src/components/ui/Sidebar/SidebarMenu/SidebarMenu.styl.d.ts +12 -0
- package/src/components/ui/Sidebar/SidebarMenu/SidebarMenu.tsx +40 -0
- package/src/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl +73 -0
- package/src/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.d.ts +8 -0
- package/src/components/ui/Sidebar/SidebarMenuAction/SidebarMenuAction.tsx +31 -0
- package/src/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl +107 -0
- package/src/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl.d.ts +15 -0
- package/src/components/ui/Sidebar/SidebarMenuButton/SidebarMenuButton.tsx +82 -0
- package/src/components/ui/Sidebar/SidebarMenuSub/SidebarMenuSub.styl +39 -0
- package/src/components/ui/Sidebar/SidebarMenuSub/SidebarMenuSub.styl.d.ts +8 -0
- package/src/components/ui/Sidebar/SidebarMenuSub/SidebarMenuSub.tsx +29 -0
- package/src/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl +71 -0
- package/src/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl.d.ts +8 -0
- package/src/components/ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.tsx +80 -0
- package/src/components/ui/Sidebar/SidebarProvider/SidebarProvider.styl +45 -0
- package/src/components/ui/Sidebar/SidebarProvider/SidebarProvider.styl.d.ts +9 -0
- package/src/components/ui/Sidebar/SidebarProvider/SidebarProvider.tsx +447 -0
- package/src/components/ui/Sidebar/SidebarRail/SidebarRail.styl +42 -0
- package/src/components/ui/Sidebar/SidebarRail/SidebarRail.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarRail/SidebarRail.tsx +22 -0
- package/src/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl +37 -0
- package/src/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.tsx +54 -0
- package/src/components/ui/Sidebar/SidebarSeparator/SidebarSeparator.styl +7 -0
- package/src/components/ui/Sidebar/SidebarSeparator/SidebarSeparator.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarSeparator/SidebarSeparator.tsx +20 -0
- package/src/components/ui/Sidebar/SidebarTrigger/SidebarTrigger.styl +11 -0
- package/src/components/ui/Sidebar/SidebarTrigger/SidebarTrigger.styl.d.ts +7 -0
- package/src/components/ui/Sidebar/SidebarTrigger/SidebarTrigger.tsx +34 -0
- package/src/components/ui/Sidebar/sidebarConstants.ts +6 -0
- package/src/components/ui/Sidebar/sidebarContext.tsx +46 -0
- package/src/components/ui/Sidebar/sidebarUtils.ts +47 -0
- package/src/components/widgets/DriverMap/AGENT.md +0 -4
- package/src/components/widgets/DriversComparisonChart/AGENT.md +0 -4
- package/src/components/widgets/PerformanceChart/AGENT.md +0 -4
- package/src/components/widgets/SidebarDatasetsItemsGrouped/AGENT.md +28 -11
- package/src/docs/components/DocsGuidance/DocsGuidance.styl +1 -0
- package/dist/esm/components/ui/Sidebar/Sidebar.js +0 -542
|
@@ -1,542 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import cn from 'classnames';
|
|
3
|
-
import { createContext, useContext, useMemo, useState, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
|
|
4
|
-
import { Button } from '../Button/Button.js';
|
|
5
|
-
import { Logo } from '../Logo/Logo.js';
|
|
6
|
-
import { Separator } from '../Separator/Separator.js';
|
|
7
|
-
import { Sheet, SheetContent } from '../Sheet/Sheet.js';
|
|
8
|
-
import { notifyPanelWidthDragStart, notifyPanelWidthDragEnd, SmartTextTruncate } from '../SmartTextTruncate/SmartTextTruncate.js';
|
|
9
|
-
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '../Tooltip/Tooltip.js';
|
|
10
|
-
import { clampSidebarWidthPx, CHAT_WIDTH_STORAGE_KEY, clampChatWidthPx, shellFitsSidebarsLayout, SIDEBAR_WIDTH_DEFAULT_PX, SIDEBAR_WIDTH_MIN_PX, SIDEBAR_WIDTH_STORAGE_KEY_PX, SIDEBAR_WIDTH_STORAGE_KEY_PCT, CHAT_WIDTH_DEFAULT_PX, CHAT_WIDTH_MIN_PX, defaultChatWidthPx } from '../../../hooks/panelWidth.js';
|
|
11
|
-
import useElemDrag from '../../../hooks/useDragElem.js';
|
|
12
|
-
import useEvent from '../../../hooks/useEvent.js';
|
|
13
|
-
import { useIsSidebarSheetLayout } from '../../../hooks/useIsSidebarSheetLayout.js';
|
|
14
|
-
import { useShellWidthObserver } from '../../../hooks/useShellWidthObserver.js';
|
|
15
|
-
import { setCookie, getCookie } from '../../../lib/cookie.js';
|
|
16
|
-
import { getCookiePreferences } from '../../../lib/cookie-consent/cookie-consent.js';
|
|
17
|
-
import { LS, Scroll } from '@homecode/ui';
|
|
18
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
19
|
-
import { PanelLeft, ChevronRight } from 'lucide-react';
|
|
20
|
-
import SidebarStem from './Sidebar.styl.js';
|
|
21
|
-
|
|
22
|
-
const SIDEBAR_WIDTH_MOBILE = '18rem';
|
|
23
|
-
const SIDEBAR_WIDTH_ICON = '3rem';
|
|
24
|
-
const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
25
|
-
/** Fired when nav open closes chat for layout; ChatSheet clears `?chat=` so URL sync does not reopen chat. */
|
|
26
|
-
const DISMISS_CHAT_FOR_LAYOUT_EVENT = 'sybilion:dismiss-chat-for-layout';
|
|
27
|
-
function isEditableKeyboardTarget(el) {
|
|
28
|
-
if (!el)
|
|
29
|
-
return false;
|
|
30
|
-
if (el instanceof HTMLElement && el.isContentEditable)
|
|
31
|
-
return true;
|
|
32
|
-
const tag = el.tagName;
|
|
33
|
-
return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
|
|
34
|
-
}
|
|
35
|
-
function readInitialSidebarWidthPx(storageKeyPx) {
|
|
36
|
-
if (typeof window === 'undefined')
|
|
37
|
-
return SIDEBAR_WIDTH_DEFAULT_PX;
|
|
38
|
-
const stored = LS.get(storageKeyPx);
|
|
39
|
-
if (typeof stored === 'number' && stored >= SIDEBAR_WIDTH_MIN_PX) {
|
|
40
|
-
return stored;
|
|
41
|
-
}
|
|
42
|
-
if (storageKeyPx === SIDEBAR_WIDTH_STORAGE_KEY_PX) {
|
|
43
|
-
const legacyPct = LS.get(SIDEBAR_WIDTH_STORAGE_KEY_PCT);
|
|
44
|
-
if (typeof legacyPct === 'number' && legacyPct > 0) {
|
|
45
|
-
const w = window.innerWidth;
|
|
46
|
-
return clampSidebarWidthPx(Math.round((legacyPct / 100) * w), w, {
|
|
47
|
-
chatPanelOpen: false,
|
|
48
|
-
chatWidthPx: 0,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return SIDEBAR_WIDTH_DEFAULT_PX;
|
|
53
|
-
}
|
|
54
|
-
function readInitialChatWidthPx() {
|
|
55
|
-
if (typeof window === 'undefined')
|
|
56
|
-
return CHAT_WIDTH_DEFAULT_PX;
|
|
57
|
-
const stored = LS.get(CHAT_WIDTH_STORAGE_KEY);
|
|
58
|
-
if (typeof stored === 'number' && stored >= CHAT_WIDTH_MIN_PX) {
|
|
59
|
-
return stored;
|
|
60
|
-
}
|
|
61
|
-
return defaultChatWidthPx(window.innerWidth);
|
|
62
|
-
}
|
|
63
|
-
const SidebarActionsContext = createContext(null);
|
|
64
|
-
const SidebarStateContext = createContext(null);
|
|
65
|
-
function useSidebarActions() {
|
|
66
|
-
const context = useContext(SidebarActionsContext);
|
|
67
|
-
if (!context) {
|
|
68
|
-
throw new Error('useSidebarActions must be used within a SidebarProvider.');
|
|
69
|
-
}
|
|
70
|
-
return context;
|
|
71
|
-
}
|
|
72
|
-
function useSidebarState() {
|
|
73
|
-
const context = useContext(SidebarStateContext);
|
|
74
|
-
if (!context) {
|
|
75
|
-
throw new Error('useSidebarState must be used within a SidebarProvider.');
|
|
76
|
-
}
|
|
77
|
-
return context;
|
|
78
|
-
}
|
|
79
|
-
function useSidebar() {
|
|
80
|
-
const actions = useSidebarActions();
|
|
81
|
-
const state = useSidebarState();
|
|
82
|
-
return useMemo(() => ({
|
|
83
|
-
...state,
|
|
84
|
-
...actions,
|
|
85
|
-
}), [state, actions]);
|
|
86
|
-
}
|
|
87
|
-
function SidebarProvider({ defaultOpen = getCookie('isSidebarOpen') ?? true, className, style, children, userId, sidebarWidthStorageKey, persistSidebarWidthWithoutConsent = false, ...props }) {
|
|
88
|
-
const sidebarLsKey = sidebarWidthStorageKey ?? SIDEBAR_WIDTH_STORAGE_KEY_PX;
|
|
89
|
-
const allowPersistSidebarWidth = persistSidebarWidthWithoutConsent ||
|
|
90
|
-
Boolean(getCookiePreferences(userId)?.functional);
|
|
91
|
-
const isSidebarSheetLayout = useIsSidebarSheetLayout();
|
|
92
|
-
const [isOpen, setIsOpen] = useState(isSidebarSheetLayout ? false : defaultOpen);
|
|
93
|
-
const wrapperRef = useRef(null);
|
|
94
|
-
const shellWidthRef = useRef(0);
|
|
95
|
-
const prevShellWidthRef = useRef(0);
|
|
96
|
-
const [shellEl, setShellEl] = useState(null);
|
|
97
|
-
const [chatPanelContainer, setChatPanelContainer] = useState(null);
|
|
98
|
-
const onChatPanelMount = useCallback((node) => {
|
|
99
|
-
setChatPanelContainer(node);
|
|
100
|
-
}, []);
|
|
101
|
-
const [sidebarWidthPx, _setSidebarWidthPx] = useState(() => readInitialSidebarWidthPx(sidebarLsKey));
|
|
102
|
-
const [chatWidthPx, _setChatWidthPx] = useState(readInitialChatWidthPx);
|
|
103
|
-
const [chatPanelOpen, _setChatPanelOpen] = useState(false);
|
|
104
|
-
const sidebarWidthRef = useRef(sidebarWidthPx);
|
|
105
|
-
const chatWidthRef = useRef(chatWidthPx);
|
|
106
|
-
const isOpenRef = useRef(isOpen);
|
|
107
|
-
const chatPanelOpenRef = useRef(chatPanelOpen);
|
|
108
|
-
/** Left nav was auto-closed because chat opened on a narrow shell; reopen when chat closes. */
|
|
109
|
-
const sidebarAutoClosedForChatRef = useRef(false);
|
|
110
|
-
sidebarWidthRef.current = sidebarWidthPx;
|
|
111
|
-
chatWidthRef.current = chatWidthPx;
|
|
112
|
-
isOpenRef.current = isOpen;
|
|
113
|
-
chatPanelOpenRef.current = chatPanelOpen;
|
|
114
|
-
const mergeWrapperRef = useCallback((el) => {
|
|
115
|
-
wrapperRef.current = el;
|
|
116
|
-
setShellEl(el);
|
|
117
|
-
}, []);
|
|
118
|
-
const getShellWidth = useCallback(() => {
|
|
119
|
-
const w = shellWidthRef.current;
|
|
120
|
-
if (w > 0)
|
|
121
|
-
return w;
|
|
122
|
-
if (wrapperRef.current) {
|
|
123
|
-
const cw = wrapperRef.current.getBoundingClientRect().width;
|
|
124
|
-
if (cw > 0)
|
|
125
|
-
return cw;
|
|
126
|
-
}
|
|
127
|
-
return typeof window !== 'undefined' ? window.innerWidth : 1200;
|
|
128
|
-
}, []);
|
|
129
|
-
const getChatPanelOpen = useCallback(() => chatPanelOpenRef.current, []);
|
|
130
|
-
const setSidebarWidthPx = useCallback((px, options) => {
|
|
131
|
-
const persist = options?.persist !== false;
|
|
132
|
-
const shellW = getShellWidth();
|
|
133
|
-
const next = clampSidebarWidthPx(px, shellW, {
|
|
134
|
-
chatPanelOpen: chatPanelOpenRef.current,
|
|
135
|
-
chatWidthPx: chatWidthRef.current,
|
|
136
|
-
});
|
|
137
|
-
sidebarWidthRef.current = next;
|
|
138
|
-
// Live drag: update CSS var only — avoid re-rendering the whole nav tree each frame.
|
|
139
|
-
if (wrapperRef.current) {
|
|
140
|
-
wrapperRef.current.style.setProperty('--sidebar-width', `${next}px`);
|
|
141
|
-
}
|
|
142
|
-
if (!persist)
|
|
143
|
-
return;
|
|
144
|
-
_setSidebarWidthPx(next);
|
|
145
|
-
if (allowPersistSidebarWidth) {
|
|
146
|
-
LS.set(sidebarLsKey, next);
|
|
147
|
-
}
|
|
148
|
-
}, [getShellWidth, sidebarLsKey, allowPersistSidebarWidth]);
|
|
149
|
-
const setChatWidthPx = useCallback((px, options) => {
|
|
150
|
-
const persist = options?.persist !== false;
|
|
151
|
-
const shellW = getShellWidth();
|
|
152
|
-
const effectiveSidebarW = isOpenRef.current ? sidebarWidthRef.current : 0;
|
|
153
|
-
const next = clampChatWidthPx(px, shellW, effectiveSidebarW);
|
|
154
|
-
_setChatWidthPx(next);
|
|
155
|
-
if (persist && getCookiePreferences(userId)?.functional) {
|
|
156
|
-
LS.set(CHAT_WIDTH_STORAGE_KEY, next);
|
|
157
|
-
}
|
|
158
|
-
}, [getShellWidth, userId]);
|
|
159
|
-
const handleShellResize = useCallback((shellW) => {
|
|
160
|
-
shellWidthRef.current = shellW;
|
|
161
|
-
const prev = prevShellWidthRef.current;
|
|
162
|
-
if (prev > 0 && shellW > 0) {
|
|
163
|
-
const s = sidebarWidthRef.current;
|
|
164
|
-
const c = chatWidthRef.current;
|
|
165
|
-
const sScaled = Math.round((s * shellW) / prev);
|
|
166
|
-
const cScaled = Math.round((c * shellW) / prev);
|
|
167
|
-
const effS = (navOpen, sidebarPx) => navOpen ? sidebarPx : 0;
|
|
168
|
-
let cNext = clampChatWidthPx(cScaled, shellW, effS(isOpenRef.current, sScaled));
|
|
169
|
-
let sNext = clampSidebarWidthPx(sScaled, shellW, {
|
|
170
|
-
chatPanelOpen: chatPanelOpenRef.current,
|
|
171
|
-
chatWidthPx: cNext,
|
|
172
|
-
});
|
|
173
|
-
cNext = clampChatWidthPx(cScaled, shellW, effS(isOpenRef.current, sNext));
|
|
174
|
-
sNext = clampSidebarWidthPx(sScaled, shellW, {
|
|
175
|
-
chatPanelOpen: chatPanelOpenRef.current,
|
|
176
|
-
chatWidthPx: cNext,
|
|
177
|
-
});
|
|
178
|
-
_setSidebarWidthPx(sNext);
|
|
179
|
-
_setChatWidthPx(cNext);
|
|
180
|
-
if (allowPersistSidebarWidth) {
|
|
181
|
-
LS.set(sidebarLsKey, sNext);
|
|
182
|
-
}
|
|
183
|
-
if (getCookiePreferences(userId)?.functional) {
|
|
184
|
-
LS.set(CHAT_WIDTH_STORAGE_KEY, cNext);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
prevShellWidthRef.current = shellW;
|
|
188
|
-
}, [userId, sidebarLsKey, allowPersistSidebarWidth]);
|
|
189
|
-
const fitPanelWidthsToShell = useCallback(() => {
|
|
190
|
-
const shellW = getShellWidth();
|
|
191
|
-
if (shellW <= 0)
|
|
192
|
-
return;
|
|
193
|
-
const s = sidebarWidthRef.current;
|
|
194
|
-
const c = chatWidthRef.current;
|
|
195
|
-
const effS = isOpenRef.current ? s : 0;
|
|
196
|
-
let cNext = clampChatWidthPx(c, shellW, effS);
|
|
197
|
-
let sNext = clampSidebarWidthPx(s, shellW, {
|
|
198
|
-
chatPanelOpen: chatPanelOpenRef.current,
|
|
199
|
-
chatWidthPx: cNext,
|
|
200
|
-
});
|
|
201
|
-
cNext = clampChatWidthPx(c, shellW, isOpenRef.current ? sNext : 0);
|
|
202
|
-
sNext = clampSidebarWidthPx(s, shellW, {
|
|
203
|
-
chatPanelOpen: chatPanelOpenRef.current,
|
|
204
|
-
chatWidthPx: cNext,
|
|
205
|
-
});
|
|
206
|
-
if (sNext !== s || cNext !== c) {
|
|
207
|
-
_setSidebarWidthPx(sNext);
|
|
208
|
-
_setChatWidthPx(cNext);
|
|
209
|
-
if (allowPersistSidebarWidth) {
|
|
210
|
-
LS.set(sidebarLsKey, sNext);
|
|
211
|
-
}
|
|
212
|
-
if (getCookiePreferences(userId)?.functional) {
|
|
213
|
-
LS.set(CHAT_WIDTH_STORAGE_KEY, cNext);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}, [getShellWidth, userId, sidebarLsKey, allowPersistSidebarWidth]);
|
|
217
|
-
useLayoutEffect(() => {
|
|
218
|
-
if (!shellEl || isSidebarSheetLayout)
|
|
219
|
-
return;
|
|
220
|
-
fitPanelWidthsToShell();
|
|
221
|
-
}, [
|
|
222
|
-
shellEl,
|
|
223
|
-
chatPanelOpen,
|
|
224
|
-
isSidebarSheetLayout,
|
|
225
|
-
isOpen,
|
|
226
|
-
fitPanelWidthsToShell,
|
|
227
|
-
]);
|
|
228
|
-
useShellWidthObserver(shellEl, handleShellResize);
|
|
229
|
-
const closeOppositeSidebarIfNoSpace = useCallback((openingMain, openingChat) => {
|
|
230
|
-
if (isSidebarSheetLayout)
|
|
231
|
-
return;
|
|
232
|
-
const shellW = getShellWidth();
|
|
233
|
-
const layoutAfterOpen = {
|
|
234
|
-
mainSidebarOpen: openingMain || isOpenRef.current,
|
|
235
|
-
chatPanelOpen: openingChat || chatPanelOpenRef.current,
|
|
236
|
-
sidebarWidthPx: sidebarWidthRef.current,
|
|
237
|
-
chatWidthPx: chatWidthRef.current,
|
|
238
|
-
};
|
|
239
|
-
if (shellFitsSidebarsLayout(shellW, layoutAfterOpen))
|
|
240
|
-
return;
|
|
241
|
-
if (openingMain && chatPanelOpenRef.current) {
|
|
242
|
-
_setChatPanelOpen(false);
|
|
243
|
-
if (typeof window !== 'undefined') {
|
|
244
|
-
window.dispatchEvent(new CustomEvent(DISMISS_CHAT_FOR_LAYOUT_EVENT));
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else if (openingChat && isOpenRef.current) {
|
|
248
|
-
sidebarAutoClosedForChatRef.current = true;
|
|
249
|
-
setIsOpen(false);
|
|
250
|
-
}
|
|
251
|
-
}, [isSidebarSheetLayout, getShellWidth]);
|
|
252
|
-
const setChatPanelOpen = useCallback((open) => {
|
|
253
|
-
if (open) {
|
|
254
|
-
closeOppositeSidebarIfNoSpace(false, true);
|
|
255
|
-
const shellW = getShellWidth();
|
|
256
|
-
if (shellW > 0 && !isSidebarSheetLayout) {
|
|
257
|
-
const navOpenAfter = isOpenRef.current && !sidebarAutoClosedForChatRef.current;
|
|
258
|
-
const effNav = navOpenAfter ? sidebarWidthRef.current : 0;
|
|
259
|
-
const cNext = clampChatWidthPx(chatWidthRef.current, shellW, effNav);
|
|
260
|
-
if (cNext !== chatWidthRef.current) {
|
|
261
|
-
_setChatWidthPx(cNext);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
_setChatPanelOpen(true);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
_setChatPanelOpen(false);
|
|
268
|
-
if (sidebarAutoClosedForChatRef.current) {
|
|
269
|
-
sidebarAutoClosedForChatRef.current = false;
|
|
270
|
-
setIsOpen(true);
|
|
271
|
-
if (getCookiePreferences(userId)?.functional) {
|
|
272
|
-
setCookie('isSidebarOpen', 'true', 60 * 60 * 24 * 7);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}, [
|
|
276
|
-
closeOppositeSidebarIfNoSpace,
|
|
277
|
-
getShellWidth,
|
|
278
|
-
isSidebarSheetLayout,
|
|
279
|
-
userId,
|
|
280
|
-
]);
|
|
281
|
-
const setOpen = useCallback((value, options) => {
|
|
282
|
-
const layoutAutoClose = options?.layoutAutoClose === true;
|
|
283
|
-
if (value) {
|
|
284
|
-
sidebarAutoClosedForChatRef.current = false;
|
|
285
|
-
closeOppositeSidebarIfNoSpace(true, false);
|
|
286
|
-
}
|
|
287
|
-
else if (layoutAutoClose) {
|
|
288
|
-
sidebarAutoClosedForChatRef.current = true;
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
sidebarAutoClosedForChatRef.current = false;
|
|
292
|
-
}
|
|
293
|
-
const useViewTransition = options?.viewTransition !== false &&
|
|
294
|
-
!isSidebarSheetLayout &&
|
|
295
|
-
'startViewTransition' in document &&
|
|
296
|
-
document.startViewTransition;
|
|
297
|
-
if (useViewTransition) {
|
|
298
|
-
document.startViewTransition(() => {
|
|
299
|
-
setIsOpen(value);
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
setIsOpen(value);
|
|
304
|
-
}
|
|
305
|
-
if (!layoutAutoClose && getCookiePreferences(userId)?.functional) {
|
|
306
|
-
setCookie('isSidebarOpen', value.toString(), 60 * 60 * 24 * 7);
|
|
307
|
-
}
|
|
308
|
-
}, [isSidebarSheetLayout, userId, closeOppositeSidebarIfNoSpace]);
|
|
309
|
-
const toggleSidebar = useCallback(() => setOpen(!isOpenRef.current), [setOpen]);
|
|
310
|
-
useEffect(() => {
|
|
311
|
-
const shell = wrapperRef.current;
|
|
312
|
-
if (!shell)
|
|
313
|
-
return;
|
|
314
|
-
if (chatPanelOpen) {
|
|
315
|
-
shell.setAttribute('data-chat-open', '');
|
|
316
|
-
if (isSidebarSheetLayout) {
|
|
317
|
-
shell.style.setProperty('--chat-panel-width', '100%');
|
|
318
|
-
shell.style.setProperty('--chat-panel-height', '100dvh');
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
shell.style.setProperty('--chat-panel-width', `${chatWidthPx}px`);
|
|
322
|
-
shell.style.removeProperty('--chat-panel-height');
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
shell.removeAttribute('data-chat-open');
|
|
327
|
-
shell.style.setProperty('--chat-panel-width', '0px');
|
|
328
|
-
shell.style.removeProperty('--chat-panel-height');
|
|
329
|
-
}
|
|
330
|
-
}, [chatPanelOpen, isSidebarSheetLayout, chatWidthPx]);
|
|
331
|
-
useEffect(() => {
|
|
332
|
-
return () => {
|
|
333
|
-
const shell = wrapperRef.current;
|
|
334
|
-
if (!shell)
|
|
335
|
-
return;
|
|
336
|
-
shell.removeAttribute('data-chat-open');
|
|
337
|
-
shell.style.setProperty('--chat-panel-width', '0px');
|
|
338
|
-
shell.style.removeProperty('--chat-panel-height');
|
|
339
|
-
};
|
|
340
|
-
}, []);
|
|
341
|
-
useEvent({
|
|
342
|
-
event: 'keydown',
|
|
343
|
-
callback: (e) => {
|
|
344
|
-
const isToggleShortcut = (e.key === SIDEBAR_KEYBOARD_SHORTCUT && (e.metaKey || e.ctrlKey)) ||
|
|
345
|
-
(e.key === '/' && !isEditableKeyboardTarget(document.activeElement));
|
|
346
|
-
if (isToggleShortcut) {
|
|
347
|
-
e.preventDefault();
|
|
348
|
-
toggleSidebar();
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
});
|
|
352
|
-
const sidebarActionsValue = useMemo(() => ({
|
|
353
|
-
setOpen,
|
|
354
|
-
toggleSidebar,
|
|
355
|
-
setSidebarWidthPx,
|
|
356
|
-
setChatWidthPx,
|
|
357
|
-
setChatPanelOpen,
|
|
358
|
-
getShellWidth,
|
|
359
|
-
getChatPanelOpen,
|
|
360
|
-
}), [
|
|
361
|
-
setOpen,
|
|
362
|
-
toggleSidebar,
|
|
363
|
-
setSidebarWidthPx,
|
|
364
|
-
setChatWidthPx,
|
|
365
|
-
setChatPanelOpen,
|
|
366
|
-
getShellWidth,
|
|
367
|
-
getChatPanelOpen,
|
|
368
|
-
]);
|
|
369
|
-
const sidebarStateValue = useMemo(() => ({
|
|
370
|
-
isOpen,
|
|
371
|
-
sidebarWidthPx,
|
|
372
|
-
chatWidthPx,
|
|
373
|
-
chatPanelOpen,
|
|
374
|
-
chatPanelContainer,
|
|
375
|
-
sidebarWrapperRef: wrapperRef,
|
|
376
|
-
}), [isOpen, sidebarWidthPx, chatWidthPx, chatPanelOpen, chatPanelContainer]);
|
|
377
|
-
return (jsx(SidebarActionsContext.Provider, { value: sidebarActionsValue, children: jsx(SidebarStateContext.Provider, { value: sidebarStateValue, children: jsx(TooltipProvider, { delayDuration: 0, children: jsxs("div", { ref: mergeWrapperRef, "data-slot": "sidebar-wrapper", "data-state": isOpen ? 'expanded' : 'collapsed', style: {
|
|
378
|
-
'--sidebar-width': `${sidebarWidthPx}px`,
|
|
379
|
-
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
380
|
-
...style,
|
|
381
|
-
}, className: cn(SidebarStem.sidebarWrapper, className), ...props, children: [jsx("div", { className: SidebarStem.sidebarMainShell, children: children }), jsx("div", { ref: onChatPanelMount, className: SidebarStem.chatPanelMount, "data-slot": "chat-panel-mount" })] }) }) }) }));
|
|
382
|
-
}
|
|
383
|
-
function Sidebar({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, side = 'left', variant = 'sidebar', collapsible = 'offcanvas', children, fullHeightResizer = false, brandText = 'Sybilion', ...props }) {
|
|
384
|
-
const isSidebarSheetLayout = useIsSidebarSheetLayout();
|
|
385
|
-
const { isOpen } = useSidebarState();
|
|
386
|
-
const { setOpen } = useSidebarActions();
|
|
387
|
-
const prevSheetLayoutRef = useRef(isSidebarSheetLayout);
|
|
388
|
-
/** Narrow shell: sidebar is a sheet; collapse only when crossing into this mode. */
|
|
389
|
-
useEffect(() => {
|
|
390
|
-
const enteredSheetLayout = isSidebarSheetLayout && !prevSheetLayoutRef.current;
|
|
391
|
-
prevSheetLayoutRef.current = isSidebarSheetLayout;
|
|
392
|
-
if (enteredSheetLayout)
|
|
393
|
-
setOpen(false);
|
|
394
|
-
}, [isSidebarSheetLayout, setOpen]);
|
|
395
|
-
if (collapsible === 'none') {
|
|
396
|
-
return (jsx("div", { "data-slot": "sidebar", className: cn(SidebarStem.sidebarNone, className), ...props, children: children }));
|
|
397
|
-
}
|
|
398
|
-
if (isSidebarSheetLayout) {
|
|
399
|
-
return (jsx(Sheet, { open: isOpen, onOpenChange: setOpen, ...props, children: jsx(SheetContent, { "data-sidebar": "sidebar", "data-slot": "sidebar", className: cn(SidebarStem.sheetContentSidebar, className), style: {
|
|
400
|
-
'--gap-top': '40px',
|
|
401
|
-
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
402
|
-
}, side: side, children: jsxs("div", { className: cn(SidebarStem.sheetSidebarInner), children: [jsx("div", { className: SidebarStem.sheetSidebarLogo, children: jsx(Logo, { size: "md", brandText: brandText }) }), children] }) }) }));
|
|
403
|
-
}
|
|
404
|
-
return (jsxs("aside", { className: cn(SidebarStem.sidebar, SidebarStem[`variant-${variant}`], className, fullHeightResizer && SidebarStem.fullHeightResizer), "data-state": isOpen ? 'expanded' : 'collapsed', "data-collapsible": !isOpen ? collapsible : '', "data-variant": variant, "data-side": side, ...props, children: [children, jsx(SidebarResizeHandle, { side: side })] }));
|
|
405
|
-
}
|
|
406
|
-
function SidebarTrigger({ className, onClick, ...props }) {
|
|
407
|
-
const { toggleSidebar } = useSidebarActions();
|
|
408
|
-
return (jsx(Button, { "data-sidebar": "trigger", "data-slot": "sidebar-trigger", variant: "ghost", icon: true, className: cn(SidebarStem.sidebarTrigger, className), onClick: event => {
|
|
409
|
-
onClick?.(event);
|
|
410
|
-
toggleSidebar();
|
|
411
|
-
}, ...props, children: jsx(PanelLeft, { size: 20, strokeWidth: 1.5, className: "text-foreground" }) }));
|
|
412
|
-
}
|
|
413
|
-
function SidebarRail({ className, ...props }) {
|
|
414
|
-
const { toggleSidebar } = useSidebarActions();
|
|
415
|
-
return (jsx("button", { "data-sidebar": "rail", "data-slot": "sidebar-rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn(SidebarStem.sidebarRail, className), ...props }));
|
|
416
|
-
}
|
|
417
|
-
function PanelResizeHandle({ className, edge, isActive, startWidthPx, getShellWidth, onDragWidth, onDragComplete, ...props }) {
|
|
418
|
-
const handleRef = useRef(null);
|
|
419
|
-
const startWidthRef = useRef(0);
|
|
420
|
-
const lastRawRef = useRef(0);
|
|
421
|
-
const handleDrag = useCallback((delta) => {
|
|
422
|
-
notifyPanelWidthDragStart();
|
|
423
|
-
const shellW = getShellWidth();
|
|
424
|
-
if (shellW <= 0)
|
|
425
|
-
return;
|
|
426
|
-
const raw = edge === 'trailing'
|
|
427
|
-
? startWidthRef.current + delta.x
|
|
428
|
-
: startWidthRef.current - delta.x;
|
|
429
|
-
lastRawRef.current = raw;
|
|
430
|
-
onDragWidth(raw);
|
|
431
|
-
}, [edge, getShellWidth, onDragWidth]);
|
|
432
|
-
const handleDragStart = useCallback((e) => {
|
|
433
|
-
startWidthRef.current = startWidthPx;
|
|
434
|
-
lastRawRef.current = startWidthPx;
|
|
435
|
-
handleRef.current?.setPointerCapture(e.pointerId);
|
|
436
|
-
}, [startWidthPx]);
|
|
437
|
-
const handleDragEnd = useCallback((e) => {
|
|
438
|
-
onDragComplete?.(lastRawRef.current);
|
|
439
|
-
notifyPanelWidthDragEnd();
|
|
440
|
-
try {
|
|
441
|
-
handleRef.current?.releasePointerCapture(e.pointerId);
|
|
442
|
-
}
|
|
443
|
-
catch {
|
|
444
|
-
// Capture already released
|
|
445
|
-
}
|
|
446
|
-
startWidthRef.current = 0;
|
|
447
|
-
}, [onDragComplete]);
|
|
448
|
-
useElemDrag({
|
|
449
|
-
elem: handleRef,
|
|
450
|
-
onDrag: handleDrag,
|
|
451
|
-
onDragStart: handleDragStart,
|
|
452
|
-
onDragEnd: handleDragEnd,
|
|
453
|
-
isActive,
|
|
454
|
-
});
|
|
455
|
-
if (!isActive) {
|
|
456
|
-
return null;
|
|
457
|
-
}
|
|
458
|
-
return (jsx("div", { ref: handleRef, "data-slot": "panel-resize-handle", "data-edge": edge, className: className, ...props }));
|
|
459
|
-
}
|
|
460
|
-
function SidebarResizeHandle({ className, side = 'left', ...props }) {
|
|
461
|
-
const { isOpen, sidebarWidthPx } = useSidebarState();
|
|
462
|
-
const { setSidebarWidthPx, getShellWidth } = useSidebarActions();
|
|
463
|
-
const isSidebarSheetLayout = useIsSidebarSheetLayout();
|
|
464
|
-
const edge = side === 'left' ? 'trailing' : 'leading';
|
|
465
|
-
const onDragWidth = useCallback((rawPx) => {
|
|
466
|
-
setSidebarWidthPx(rawPx, { persist: false });
|
|
467
|
-
}, [setSidebarWidthPx]);
|
|
468
|
-
const onDragComplete = useCallback((finalRawPx) => {
|
|
469
|
-
setSidebarWidthPx(finalRawPx, { persist: true });
|
|
470
|
-
}, [setSidebarWidthPx]);
|
|
471
|
-
if (isSidebarSheetLayout || !isOpen) {
|
|
472
|
-
return null;
|
|
473
|
-
}
|
|
474
|
-
return (jsx(PanelResizeHandle, { edge: edge, isActive: isOpen && !isSidebarSheetLayout, startWidthPx: sidebarWidthPx, getShellWidth: getShellWidth, onDragWidth: onDragWidth, onDragComplete: onDragComplete, "data-sidebar": "resize-handle", "data-slot": "sidebar-resize-handle", "data-side": side, className: cn(SidebarStem.sidebarResizeHandle, className), ...props }));
|
|
475
|
-
}
|
|
476
|
-
function SidebarFooter({ className, ...props }) {
|
|
477
|
-
return (jsx("div", { "data-slot": "sidebar-footer", "data-sidebar": "footer", className: cn(SidebarStem.sidebarFooter, className), ...props }));
|
|
478
|
-
}
|
|
479
|
-
function SidebarSeparator({ className, ...props }) {
|
|
480
|
-
return (jsx(Separator, { "data-slot": "sidebar-separator", "data-sidebar": "separator", className: cn(SidebarStem.sidebarSeparator, className), ...props }));
|
|
481
|
-
}
|
|
482
|
-
function SidebarContent({ className, innerClassName, children, }) {
|
|
483
|
-
// const sidebarContentTransition = useViewTransition({
|
|
484
|
-
// transitionName: 'sidebar-content',
|
|
485
|
-
// });
|
|
486
|
-
return (jsx(Scroll, { y: true, autoHide: true, fadeSize: "l", offset: { y: { before: 40, after: 20 } }, className: cn(SidebarStem.sidebarContent, className), innerClassName: innerClassName, children: children }));
|
|
487
|
-
}
|
|
488
|
-
function SidebarGroup({ className, ...props }) {
|
|
489
|
-
return (jsx("div", { "data-slot": "sidebar-group", "data-sidebar": "group", className: cn(SidebarStem.sidebarGroup, className), ...props }));
|
|
490
|
-
}
|
|
491
|
-
function SidebarGroupAction({ className, asChild = false, ...props }) {
|
|
492
|
-
const Comp = asChild ? Slot : 'button';
|
|
493
|
-
return (jsx(Comp, { "data-slot": "sidebar-group-action", "data-sidebar": "group-action", className: cn(SidebarStem.sidebarGroupAction, className), ...props }));
|
|
494
|
-
}
|
|
495
|
-
function SidebarMenu({ className, ...props }) {
|
|
496
|
-
return (jsx("ul", { "data-slot": "sidebar-menu", "data-sidebar": "menu", className: cn(SidebarStem.sidebarMenu, className), ...props }));
|
|
497
|
-
}
|
|
498
|
-
function SidebarMenuItem({ className, ...props }) {
|
|
499
|
-
return (jsx("li", { "data-slot": "sidebar-menu-item", "data-sidebar": "menu-item", className: cn(SidebarStem.sidebarMenuItem, className), ...props }));
|
|
500
|
-
}
|
|
501
|
-
function SidebarMenuButton({ asChild = false, isActive = false, hasSubItems = false, isExpanded = false, variant = 'ghost', size = 'sm', className, icon, children, addon, ...props }) {
|
|
502
|
-
const effectiveAsChild = asChild && !hasSubItems;
|
|
503
|
-
const label = (jsx(SmartTextTruncate, { className: SidebarStem.sidebarMenuButtonLabel, children: children }));
|
|
504
|
-
const chevron = hasSubItems ? (jsx("span", { className: cn(SidebarStem.sidebarMenuButtonChevron, isExpanded && SidebarStem.expanded), "aria-hidden": "true", children: jsx(ChevronRight, { size: 16 }) })) : null;
|
|
505
|
-
const userContent = (jsxs(Fragment, { children: [label, addon] }));
|
|
506
|
-
return (jsxs(Button, { asChild: effectiveAsChild, variant: variant, size: size, "data-slot": "sidebar-menu-button", "data-sidebar": "menu-button", "data-active": isActive, "aria-expanded": hasSubItems ? isExpanded : undefined, className: cn(variant === 'default' ? SidebarStem.sidebarMenuButtonCta : SidebarStem.sidebarMenuButton, SidebarStem[`size-${size}`], className), ...props, children: [icon, effectiveAsChild ? (userContent) : (jsxs(Fragment, { children: [userContent, chevron] }))] }));
|
|
507
|
-
}
|
|
508
|
-
function SidebarMenuAction({ className, asChild = false, showOnHover = false, ...props }) {
|
|
509
|
-
const Comp = asChild ? Slot : 'button';
|
|
510
|
-
return (jsx(Comp, { "data-slot": "sidebar-menu-action", "data-sidebar": "menu-action", className: cn(SidebarStem.sidebarMenuAction, showOnHover && SidebarStem.showOnHover, className), ...props }));
|
|
511
|
-
}
|
|
512
|
-
function SidebarMenuBadge({ className, ...props }) {
|
|
513
|
-
return (jsx("div", { "data-slot": "sidebar-menu-badge", "data-sidebar": "menu-badge", className: cn(SidebarStem.sidebarMenuBadge, className), ...props }));
|
|
514
|
-
}
|
|
515
|
-
function SidebarMenuSub({ className, ...props }) {
|
|
516
|
-
return (jsx("ul", { "data-slot": "sidebar-menu-sub", "data-sidebar": "menu-sub", className: cn(SidebarStem.sidebarMenuSub, className), ...props }));
|
|
517
|
-
}
|
|
518
|
-
function SidebarMenuSubItem({ className, ...props }) {
|
|
519
|
-
return (jsx("li", { "data-slot": "sidebar-menu-sub-item", "data-sidebar": "menu-sub-item", className: cn(SidebarStem.sidebarMenuSubItem, className), ...props }));
|
|
520
|
-
}
|
|
521
|
-
function SidebarMenuSubButton({ asChild = false, size = 'md', isActive = false, tooltip, className, onClick, children, addon, ...props }) {
|
|
522
|
-
const Comp = asChild ? Slot : 'a';
|
|
523
|
-
const { isOpen } = useSidebarState();
|
|
524
|
-
const { setOpen } = useSidebarActions();
|
|
525
|
-
const isSidebarSheetLayout = useIsSidebarSheetLayout();
|
|
526
|
-
const handleClick = (event) => {
|
|
527
|
-
if (isSidebarSheetLayout && isOpen)
|
|
528
|
-
setOpen(false);
|
|
529
|
-
onClick?.(event);
|
|
530
|
-
};
|
|
531
|
-
const button = (jsxs(Comp, { "data-slot": "sidebar-menu-sub-button", "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive, className: cn(SidebarStem.sidebarMenuSubButton, SidebarStem[`size-${size}`], className), onClick: handleClick, ...props, children: [jsx(SmartTextTruncate, { className: SidebarStem.sidebarMenuSubButtonLabel, children: children }), addon] }));
|
|
532
|
-
if (!tooltip)
|
|
533
|
-
return button;
|
|
534
|
-
if (typeof tooltip === 'string') {
|
|
535
|
-
tooltip = {
|
|
536
|
-
children: tooltip,
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
return (jsxs(Tooltip, { children: [jsx(TooltipTrigger, { asChild: true, children: button }), jsx(TooltipContent, { side: "right", align: "center", hidden: !isOpen || isSidebarSheetLayout, ...tooltip })] }));
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
export { DISMISS_CHAT_FOR_LAYOUT_EVENT, PanelResizeHandle, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarResizeHandle, SidebarSeparator, SidebarTrigger, useSidebar, useSidebarActions, useSidebarState };
|