@sybilion/uilib 1.4.13 → 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 -106
- 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 -621
- package/src/components/ui/Sidebar/Sidebar.styl.d.ts +0 -33
- package/src/components/ui/Sidebar/Sidebar.tsx +25 -1145
- 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/src/docs/components/DocsSidebar/DocsSidebar.tsx +14 -8
- package/src/docs/pages/SmartTextTruncatePage.styl +2 -14
- package/src/docs/pages/SmartTextTruncatePage.styl.d.ts +0 -1
- package/src/docs/pages/SmartTextTruncatePage.tsx +0 -6
- package/dist/esm/components/ui/Sidebar/Sidebar.js +0 -541
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect, useMemo } from 'react';
|
|
4
|
+
import { TooltipProvider } from '../../Tooltip/Tooltip.js';
|
|
5
|
+
import { clampSidebarWidthPx, CHAT_WIDTH_STORAGE_KEY, clampChatWidthPx, shellFitsSidebarsLayout, SIDEBAR_WIDTH_STORAGE_KEY_PX } from '../../../../hooks/panelWidth.js';
|
|
6
|
+
import useEvent from '../../../../hooks/useEvent.js';
|
|
7
|
+
import { useIsSidebarSheetLayout } from '../../../../hooks/useIsSidebarSheetLayout.js';
|
|
8
|
+
import { useShellWidthObserver } from '../../../../hooks/useShellWidthObserver.js';
|
|
9
|
+
import { setCookie, getCookie } from '../../../../lib/cookie.js';
|
|
10
|
+
import { getCookiePreferences } from '../../../../lib/cookie-consent/cookie-consent.js';
|
|
11
|
+
import { LS } from '@homecode/ui';
|
|
12
|
+
import S from './SidebarProvider.styl.js';
|
|
13
|
+
import { DISMISS_CHAT_FOR_LAYOUT_EVENT, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH_ICON } from '../sidebarConstants.js';
|
|
14
|
+
import { SidebarActionsContext, SidebarStateContext } from '../sidebarContext.js';
|
|
15
|
+
import { readInitialSidebarWidthPx, readInitialChatWidthPx, isEditableKeyboardTarget } from '../sidebarUtils.js';
|
|
16
|
+
|
|
17
|
+
function SidebarProvider({ defaultOpen = getCookie('isSidebarOpen') ?? true, className, style, children, userId, sidebarWidthStorageKey, persistSidebarWidthWithoutConsent = false, ...props }) {
|
|
18
|
+
const sidebarLsKey = sidebarWidthStorageKey ?? SIDEBAR_WIDTH_STORAGE_KEY_PX;
|
|
19
|
+
const allowPersistSidebarWidth = persistSidebarWidthWithoutConsent ||
|
|
20
|
+
Boolean(getCookiePreferences(userId)?.functional);
|
|
21
|
+
const isSidebarSheetLayout = useIsSidebarSheetLayout();
|
|
22
|
+
const [isOpen, setIsOpen] = useState(isSidebarSheetLayout ? false : defaultOpen);
|
|
23
|
+
const wrapperRef = useRef(null);
|
|
24
|
+
const shellWidthRef = useRef(0);
|
|
25
|
+
const prevShellWidthRef = useRef(0);
|
|
26
|
+
const [shellEl, setShellEl] = useState(null);
|
|
27
|
+
const [chatPanelContainer, setChatPanelContainer] = useState(null);
|
|
28
|
+
const onChatPanelMount = useCallback((node) => {
|
|
29
|
+
setChatPanelContainer(node);
|
|
30
|
+
}, []);
|
|
31
|
+
const [sidebarWidthPx, _setSidebarWidthPx] = useState(() => readInitialSidebarWidthPx(sidebarLsKey));
|
|
32
|
+
const [chatWidthPx, _setChatWidthPx] = useState(readInitialChatWidthPx);
|
|
33
|
+
const [chatPanelOpen, _setChatPanelOpen] = useState(false);
|
|
34
|
+
const sidebarWidthRef = useRef(sidebarWidthPx);
|
|
35
|
+
const chatWidthRef = useRef(chatWidthPx);
|
|
36
|
+
const isOpenRef = useRef(isOpen);
|
|
37
|
+
const chatPanelOpenRef = useRef(chatPanelOpen);
|
|
38
|
+
/** Left nav was auto-closed because chat opened on a narrow shell; reopen when chat closes. */
|
|
39
|
+
const sidebarAutoClosedForChatRef = useRef(false);
|
|
40
|
+
sidebarWidthRef.current = sidebarWidthPx;
|
|
41
|
+
chatWidthRef.current = chatWidthPx;
|
|
42
|
+
isOpenRef.current = isOpen;
|
|
43
|
+
chatPanelOpenRef.current = chatPanelOpen;
|
|
44
|
+
const mergeWrapperRef = useCallback((el) => {
|
|
45
|
+
wrapperRef.current = el;
|
|
46
|
+
setShellEl(el);
|
|
47
|
+
}, []);
|
|
48
|
+
const getShellWidth = useCallback(() => {
|
|
49
|
+
const w = shellWidthRef.current;
|
|
50
|
+
if (w > 0)
|
|
51
|
+
return w;
|
|
52
|
+
if (wrapperRef.current) {
|
|
53
|
+
const cw = wrapperRef.current.getBoundingClientRect().width;
|
|
54
|
+
if (cw > 0)
|
|
55
|
+
return cw;
|
|
56
|
+
}
|
|
57
|
+
return typeof window !== 'undefined' ? window.innerWidth : 1200;
|
|
58
|
+
}, []);
|
|
59
|
+
const getChatPanelOpen = useCallback(() => chatPanelOpenRef.current, []);
|
|
60
|
+
const setSidebarWidthPx = useCallback((px, options) => {
|
|
61
|
+
const persist = options?.persist !== false;
|
|
62
|
+
const shellW = getShellWidth();
|
|
63
|
+
const next = clampSidebarWidthPx(px, shellW, {
|
|
64
|
+
chatPanelOpen: chatPanelOpenRef.current,
|
|
65
|
+
chatWidthPx: chatWidthRef.current,
|
|
66
|
+
});
|
|
67
|
+
sidebarWidthRef.current = next;
|
|
68
|
+
// Live drag: update CSS var only — avoid re-rendering the whole nav tree each frame.
|
|
69
|
+
if (wrapperRef.current) {
|
|
70
|
+
wrapperRef.current.style.setProperty('--sidebar-width', `${next}px`);
|
|
71
|
+
}
|
|
72
|
+
if (!persist)
|
|
73
|
+
return;
|
|
74
|
+
_setSidebarWidthPx(next);
|
|
75
|
+
if (allowPersistSidebarWidth) {
|
|
76
|
+
LS.set(sidebarLsKey, next);
|
|
77
|
+
}
|
|
78
|
+
}, [getShellWidth, sidebarLsKey, allowPersistSidebarWidth]);
|
|
79
|
+
const setChatWidthPx = useCallback((px, options) => {
|
|
80
|
+
const persist = options?.persist !== false;
|
|
81
|
+
const shellW = getShellWidth();
|
|
82
|
+
const effectiveSidebarW = isOpenRef.current ? sidebarWidthRef.current : 0;
|
|
83
|
+
const next = clampChatWidthPx(px, shellW, effectiveSidebarW);
|
|
84
|
+
_setChatWidthPx(next);
|
|
85
|
+
if (persist && getCookiePreferences(userId)?.functional) {
|
|
86
|
+
LS.set(CHAT_WIDTH_STORAGE_KEY, next);
|
|
87
|
+
}
|
|
88
|
+
}, [getShellWidth, userId]);
|
|
89
|
+
const handleShellResize = useCallback((shellW) => {
|
|
90
|
+
shellWidthRef.current = shellW;
|
|
91
|
+
const prev = prevShellWidthRef.current;
|
|
92
|
+
if (prev > 0 && shellW > 0) {
|
|
93
|
+
const s = sidebarWidthRef.current;
|
|
94
|
+
const c = chatWidthRef.current;
|
|
95
|
+
const sScaled = Math.round((s * shellW) / prev);
|
|
96
|
+
const cScaled = Math.round((c * shellW) / prev);
|
|
97
|
+
const effS = (navOpen, sidebarPx) => navOpen ? sidebarPx : 0;
|
|
98
|
+
let cNext = clampChatWidthPx(cScaled, shellW, effS(isOpenRef.current, sScaled));
|
|
99
|
+
let sNext = clampSidebarWidthPx(sScaled, shellW, {
|
|
100
|
+
chatPanelOpen: chatPanelOpenRef.current,
|
|
101
|
+
chatWidthPx: cNext,
|
|
102
|
+
});
|
|
103
|
+
cNext = clampChatWidthPx(cScaled, shellW, effS(isOpenRef.current, sNext));
|
|
104
|
+
sNext = clampSidebarWidthPx(sScaled, shellW, {
|
|
105
|
+
chatPanelOpen: chatPanelOpenRef.current,
|
|
106
|
+
chatWidthPx: cNext,
|
|
107
|
+
});
|
|
108
|
+
_setSidebarWidthPx(sNext);
|
|
109
|
+
_setChatWidthPx(cNext);
|
|
110
|
+
if (allowPersistSidebarWidth) {
|
|
111
|
+
LS.set(sidebarLsKey, sNext);
|
|
112
|
+
}
|
|
113
|
+
if (getCookiePreferences(userId)?.functional) {
|
|
114
|
+
LS.set(CHAT_WIDTH_STORAGE_KEY, cNext);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
prevShellWidthRef.current = shellW;
|
|
118
|
+
}, [userId, sidebarLsKey, allowPersistSidebarWidth]);
|
|
119
|
+
const fitPanelWidthsToShell = useCallback(() => {
|
|
120
|
+
const shellW = getShellWidth();
|
|
121
|
+
if (shellW <= 0)
|
|
122
|
+
return;
|
|
123
|
+
const s = sidebarWidthRef.current;
|
|
124
|
+
const c = chatWidthRef.current;
|
|
125
|
+
const effS = isOpenRef.current ? s : 0;
|
|
126
|
+
let cNext = clampChatWidthPx(c, shellW, effS);
|
|
127
|
+
let sNext = clampSidebarWidthPx(s, shellW, {
|
|
128
|
+
chatPanelOpen: chatPanelOpenRef.current,
|
|
129
|
+
chatWidthPx: cNext,
|
|
130
|
+
});
|
|
131
|
+
cNext = clampChatWidthPx(c, shellW, isOpenRef.current ? sNext : 0);
|
|
132
|
+
sNext = clampSidebarWidthPx(s, shellW, {
|
|
133
|
+
chatPanelOpen: chatPanelOpenRef.current,
|
|
134
|
+
chatWidthPx: cNext,
|
|
135
|
+
});
|
|
136
|
+
if (sNext !== s || cNext !== c) {
|
|
137
|
+
_setSidebarWidthPx(sNext);
|
|
138
|
+
_setChatWidthPx(cNext);
|
|
139
|
+
if (allowPersistSidebarWidth) {
|
|
140
|
+
LS.set(sidebarLsKey, sNext);
|
|
141
|
+
}
|
|
142
|
+
if (getCookiePreferences(userId)?.functional) {
|
|
143
|
+
LS.set(CHAT_WIDTH_STORAGE_KEY, cNext);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, [getShellWidth, userId, sidebarLsKey, allowPersistSidebarWidth]);
|
|
147
|
+
useLayoutEffect(() => {
|
|
148
|
+
if (!shellEl || isSidebarSheetLayout)
|
|
149
|
+
return;
|
|
150
|
+
fitPanelWidthsToShell();
|
|
151
|
+
}, [
|
|
152
|
+
shellEl,
|
|
153
|
+
chatPanelOpen,
|
|
154
|
+
isSidebarSheetLayout,
|
|
155
|
+
isOpen,
|
|
156
|
+
fitPanelWidthsToShell,
|
|
157
|
+
]);
|
|
158
|
+
useShellWidthObserver(shellEl, handleShellResize);
|
|
159
|
+
const closeOppositeSidebarIfNoSpace = useCallback((openingMain, openingChat) => {
|
|
160
|
+
if (isSidebarSheetLayout)
|
|
161
|
+
return;
|
|
162
|
+
const shellW = getShellWidth();
|
|
163
|
+
const layoutAfterOpen = {
|
|
164
|
+
mainSidebarOpen: openingMain || isOpenRef.current,
|
|
165
|
+
chatPanelOpen: openingChat || chatPanelOpenRef.current,
|
|
166
|
+
sidebarWidthPx: sidebarWidthRef.current,
|
|
167
|
+
chatWidthPx: chatWidthRef.current,
|
|
168
|
+
};
|
|
169
|
+
if (shellFitsSidebarsLayout(shellW, layoutAfterOpen))
|
|
170
|
+
return;
|
|
171
|
+
if (openingMain && chatPanelOpenRef.current) {
|
|
172
|
+
_setChatPanelOpen(false);
|
|
173
|
+
if (typeof window !== 'undefined') {
|
|
174
|
+
window.dispatchEvent(new CustomEvent(DISMISS_CHAT_FOR_LAYOUT_EVENT));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (openingChat && isOpenRef.current) {
|
|
178
|
+
sidebarAutoClosedForChatRef.current = true;
|
|
179
|
+
setIsOpen(false);
|
|
180
|
+
}
|
|
181
|
+
}, [isSidebarSheetLayout, getShellWidth]);
|
|
182
|
+
const setChatPanelOpen = useCallback((open) => {
|
|
183
|
+
if (open) {
|
|
184
|
+
closeOppositeSidebarIfNoSpace(false, true);
|
|
185
|
+
const shellW = getShellWidth();
|
|
186
|
+
if (shellW > 0 && !isSidebarSheetLayout) {
|
|
187
|
+
const navOpenAfter = isOpenRef.current && !sidebarAutoClosedForChatRef.current;
|
|
188
|
+
const effNav = navOpenAfter ? sidebarWidthRef.current : 0;
|
|
189
|
+
const cNext = clampChatWidthPx(chatWidthRef.current, shellW, effNav);
|
|
190
|
+
if (cNext !== chatWidthRef.current) {
|
|
191
|
+
_setChatWidthPx(cNext);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
_setChatPanelOpen(true);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
_setChatPanelOpen(false);
|
|
198
|
+
if (sidebarAutoClosedForChatRef.current) {
|
|
199
|
+
sidebarAutoClosedForChatRef.current = false;
|
|
200
|
+
setIsOpen(true);
|
|
201
|
+
if (getCookiePreferences(userId)?.functional) {
|
|
202
|
+
setCookie('isSidebarOpen', 'true', 60 * 60 * 24 * 7);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}, [
|
|
206
|
+
closeOppositeSidebarIfNoSpace,
|
|
207
|
+
getShellWidth,
|
|
208
|
+
isSidebarSheetLayout,
|
|
209
|
+
userId,
|
|
210
|
+
]);
|
|
211
|
+
const setOpen = useCallback((value, options) => {
|
|
212
|
+
const layoutAutoClose = options?.layoutAutoClose === true;
|
|
213
|
+
if (value) {
|
|
214
|
+
sidebarAutoClosedForChatRef.current = false;
|
|
215
|
+
closeOppositeSidebarIfNoSpace(true, false);
|
|
216
|
+
}
|
|
217
|
+
else if (layoutAutoClose) {
|
|
218
|
+
sidebarAutoClosedForChatRef.current = true;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
sidebarAutoClosedForChatRef.current = false;
|
|
222
|
+
}
|
|
223
|
+
const useViewTransition = options?.viewTransition !== false &&
|
|
224
|
+
!isSidebarSheetLayout &&
|
|
225
|
+
'startViewTransition' in document &&
|
|
226
|
+
document.startViewTransition;
|
|
227
|
+
if (useViewTransition) {
|
|
228
|
+
document.startViewTransition(() => {
|
|
229
|
+
setIsOpen(value);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
setIsOpen(value);
|
|
234
|
+
}
|
|
235
|
+
if (!layoutAutoClose && getCookiePreferences(userId)?.functional) {
|
|
236
|
+
setCookie('isSidebarOpen', value.toString(), 60 * 60 * 24 * 7);
|
|
237
|
+
}
|
|
238
|
+
}, [isSidebarSheetLayout, userId, closeOppositeSidebarIfNoSpace]);
|
|
239
|
+
const toggleSidebar = useCallback(() => setOpen(!isOpenRef.current), [setOpen]);
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
const shell = wrapperRef.current;
|
|
242
|
+
if (!shell)
|
|
243
|
+
return;
|
|
244
|
+
if (chatPanelOpen) {
|
|
245
|
+
shell.setAttribute('data-chat-open', '');
|
|
246
|
+
if (isSidebarSheetLayout) {
|
|
247
|
+
shell.style.setProperty('--chat-panel-width', '100%');
|
|
248
|
+
shell.style.setProperty('--chat-panel-height', '100dvh');
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
shell.style.setProperty('--chat-panel-width', `${chatWidthPx}px`);
|
|
252
|
+
shell.style.removeProperty('--chat-panel-height');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
shell.removeAttribute('data-chat-open');
|
|
257
|
+
shell.style.setProperty('--chat-panel-width', '0px');
|
|
258
|
+
shell.style.removeProperty('--chat-panel-height');
|
|
259
|
+
}
|
|
260
|
+
}, [chatPanelOpen, isSidebarSheetLayout, chatWidthPx]);
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
return () => {
|
|
263
|
+
const shell = wrapperRef.current;
|
|
264
|
+
if (!shell)
|
|
265
|
+
return;
|
|
266
|
+
shell.removeAttribute('data-chat-open');
|
|
267
|
+
shell.style.setProperty('--chat-panel-width', '0px');
|
|
268
|
+
shell.style.removeProperty('--chat-panel-height');
|
|
269
|
+
};
|
|
270
|
+
}, []);
|
|
271
|
+
useEvent({
|
|
272
|
+
event: 'keydown',
|
|
273
|
+
callback: (e) => {
|
|
274
|
+
const isToggleShortcut = (e.key === SIDEBAR_KEYBOARD_SHORTCUT && (e.metaKey || e.ctrlKey)) ||
|
|
275
|
+
(e.key === '/' && !isEditableKeyboardTarget(document.activeElement));
|
|
276
|
+
if (isToggleShortcut) {
|
|
277
|
+
e.preventDefault();
|
|
278
|
+
toggleSidebar();
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
const sidebarActionsValue = useMemo(() => ({
|
|
283
|
+
setOpen,
|
|
284
|
+
toggleSidebar,
|
|
285
|
+
setSidebarWidthPx,
|
|
286
|
+
setChatWidthPx,
|
|
287
|
+
setChatPanelOpen,
|
|
288
|
+
getShellWidth,
|
|
289
|
+
getChatPanelOpen,
|
|
290
|
+
}), [
|
|
291
|
+
setOpen,
|
|
292
|
+
toggleSidebar,
|
|
293
|
+
setSidebarWidthPx,
|
|
294
|
+
setChatWidthPx,
|
|
295
|
+
setChatPanelOpen,
|
|
296
|
+
getShellWidth,
|
|
297
|
+
getChatPanelOpen,
|
|
298
|
+
]);
|
|
299
|
+
const sidebarStateValue = useMemo(() => ({
|
|
300
|
+
isOpen,
|
|
301
|
+
sidebarWidthPx,
|
|
302
|
+
chatWidthPx,
|
|
303
|
+
chatPanelOpen,
|
|
304
|
+
chatPanelContainer,
|
|
305
|
+
sidebarWrapperRef: wrapperRef,
|
|
306
|
+
}), [isOpen, sidebarWidthPx, chatWidthPx, chatPanelOpen, chatPanelContainer]);
|
|
307
|
+
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: {
|
|
308
|
+
'--sidebar-width': `${sidebarWidthPx}px`,
|
|
309
|
+
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
310
|
+
...style,
|
|
311
|
+
}, className: cn(S.sidebarWrapper, className), ...props, children: [jsx("div", { className: S.sidebarMainShell, children: children }), jsx("div", { ref: onChatPanelMount, className: S.chatPanelMount, "data-slot": "chat-panel-mount" })] }) }) }) }));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export { SidebarProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SidebarProvider_sidebarWrapper__psbi-{align-items:stretch;display:flex;flex-direction:row;height:100%;min-height:0;width:100%}.SidebarProvider_sidebarWrapper__psbi- #page-sidebar-actions{min-height:100%}@media (max-width:768px){.SidebarProvider_sidebarWrapper__psbi-{flex-direction:column;height:100dvh;max-height:100dvh}}.SidebarProvider_sidebarMainShell__yyuK4{display:flex;flex:1;flex-direction:column;min-height:0;min-width:0}.SidebarProvider_chatPanelMount__2EdC6{background:var(--background);border-left:1px solid var(--border);flex:0 0 0px;flex:0 0 var(--chat-panel-width,0px);min-height:0;min-width:0;overflow:hidden;width:0;width:var(--chat-panel-width,0)}@media (max-width:768px){.SidebarProvider_chatPanelMount__2EdC6{border-left:none;border-top:1px solid var(--border);flex:0 0 0px;flex:0 0 var(--chat-panel-height,0px);height:0;height:var(--chat-panel-height,0);transition:flex-basis .2s ease,height .2s ease;width:100%}}";
|
|
4
|
+
var S = {"sidebarWrapper":"SidebarProvider_sidebarWrapper__psbi-","sidebarMainShell":"SidebarProvider_sidebarMainShell__yyuK4","chatPanelMount":"SidebarProvider_chatPanelMount__2EdC6"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import S from './SidebarRail.styl.js';
|
|
4
|
+
import { useSidebarActions } from '../sidebarContext.js';
|
|
5
|
+
|
|
6
|
+
function SidebarRail({ className, ...props }) {
|
|
7
|
+
const { toggleSidebar } = useSidebarActions();
|
|
8
|
+
return (jsx("button", { "data-sidebar": "rail", "data-slot": "sidebar-rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn(S.sidebarRail, className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { SidebarRail };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SidebarRail_sidebarRail__UVd9-{position:absolute;inset-y:0;display:hidden;transition:all ease-out;width:1rem;z-index:20}.SidebarRail_sidebarRail__UVd9-:hover:after{background-color:var(--sidebar-border)}.SidebarRail_sidebarRail__UVd9-[data-side=left]{right:-1rem}.SidebarRail_sidebarRail__UVd9-[data-side=right]{left:0}.SidebarRail_sidebarRail__UVd9-:after{content:\"\";position:absolute;inset-y:0;left:50%;width:2px}@media (min-width:640px){.SidebarRail_sidebarRail__UVd9-{display:flex}}.SidebarRail_sidebarRail__UVd9-[data-side=left]{cursor:w-resize}.SidebarRail_sidebarRail__UVd9-[data-side=left][data-state=collapsed],.SidebarRail_sidebarRail__UVd9-[data-side=right]{cursor:e-resize}.SidebarRail_sidebarRail__UVd9-[data-side=right][data-state=collapsed]{cursor:w-resize}.SidebarRail_sidebarRail__UVd9-[data-collapsible=offcanvas]{transform:translateX(0)}.SidebarRail_sidebarRail__UVd9-[data-collapsible=offcanvas]:hover{background-color:var(--sidebar)}.SidebarRail_sidebarRail__UVd9-[data-collapsible=offcanvas]:after{left:100%}.SidebarRail_sidebarRail__UVd9-[data-side=left][data-collapsible=offcanvas]{right:-.5rem}.SidebarRail_sidebarRail__UVd9-[data-side=right][data-collapsible=offcanvas]{left:-.5rem}";
|
|
4
|
+
var S = {"sidebarRail":"SidebarRail_sidebarRail__UVd9-"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { PanelResizeHandle } from '../../PanelResizeHandle/PanelResizeHandle.js';
|
|
5
|
+
import { useIsSidebarSheetLayout } from '../../../../hooks/useIsSidebarSheetLayout.js';
|
|
6
|
+
import { useSidebarState, useSidebarActions } from '../sidebarContext.js';
|
|
7
|
+
import SidebarResizeStem from './SidebarResizeHandle.styl.js';
|
|
8
|
+
|
|
9
|
+
function SidebarResizeHandle({ className, side = 'left', ...props }) {
|
|
10
|
+
const { isOpen, sidebarWidthPx } = useSidebarState();
|
|
11
|
+
const { setSidebarWidthPx, getShellWidth } = useSidebarActions();
|
|
12
|
+
const isSidebarSheetLayout = useIsSidebarSheetLayout();
|
|
13
|
+
const edge = side === 'left' ? 'trailing' : 'leading';
|
|
14
|
+
const onDragWidth = useCallback((rawPx) => {
|
|
15
|
+
setSidebarWidthPx(rawPx, { persist: false });
|
|
16
|
+
}, [setSidebarWidthPx]);
|
|
17
|
+
const onDragComplete = useCallback((finalRawPx) => {
|
|
18
|
+
setSidebarWidthPx(finalRawPx, { persist: true });
|
|
19
|
+
}, [setSidebarWidthPx]);
|
|
20
|
+
if (isSidebarSheetLayout || !isOpen) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
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(SidebarResizeStem.sidebarResizeHandle, className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { SidebarResizeHandle };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SidebarResizeHandle_sidebarResizeHandle__pJOgE{background-color:transparent;background-color:var(--page-color);border-radius:2.5px;height:calc(100vh + 200px);height:calc(100vh + 200px - var(--app-banner-height, 0px));opacity:0;position:absolute;top:-200px;touch-action:none;transition:opacity .15s ease-out;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:5px;z-index:30}.SidebarResizeHandle_sidebarResizeHandle__pJOgE:before{content:\"\";cursor:col-resize;height:100%;position:absolute;right:0;width:30px}.SidebarResizeHandle_sidebarResizeHandle__pJOgE[data-side=left]{right:2px}.SidebarResizeHandle_sidebarResizeHandle__pJOgE[data-side=right]{left:0}.SidebarResizeHandle_sidebarResizeHandle__pJOgE:hover{opacity:1}.SidebarResizeHandle_sidebarResizeHandle__pJOgE:active{opacity:0}[data-full-height-resizer] .SidebarResizeHandle_sidebarResizeHandle__pJOgE{height:calc(100vh - var(--gap-top)*-1);height:calc(100vh - var(--gap-top)*-1 - var(--app-banner-height, 0px));top:-80px}";
|
|
4
|
+
var SidebarResizeStem = {"sidebarResizeHandle":"SidebarResizeHandle_sidebarResizeHandle__pJOgE"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { SidebarResizeStem as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Separator } from '../../Separator/Separator.js';
|
|
4
|
+
import S from './SidebarSeparator.styl.js';
|
|
5
|
+
|
|
6
|
+
function SidebarSeparator({ className, ...props }) {
|
|
7
|
+
return (jsx(Separator, { "data-slot": "sidebar-separator", "data-sidebar": "separator", className: cn(S.sidebarSeparator, className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SidebarSeparator };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SidebarSeparator_sidebarSeparator__guqmP{background-color:var(--sidebar-border);margin-left:0;margin-right:0;width:auto}";
|
|
4
|
+
var S = {"sidebarSeparator":"SidebarSeparator_sidebarSeparator__guqmP"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Button } from '../../Button/Button.js';
|
|
4
|
+
import { PanelLeft } from 'lucide-react';
|
|
5
|
+
import S from './SidebarTrigger.styl.js';
|
|
6
|
+
import { useSidebarActions } from '../sidebarContext.js';
|
|
7
|
+
|
|
8
|
+
function SidebarTrigger({ className, onClick, ...props }) {
|
|
9
|
+
const { toggleSidebar } = useSidebarActions();
|
|
10
|
+
return (jsx(Button, { "data-sidebar": "trigger", "data-slot": "sidebar-trigger", variant: "ghost", icon: true, className: cn(S.sidebarTrigger, className), onClick: event => {
|
|
11
|
+
onClick?.(event);
|
|
12
|
+
toggleSidebar();
|
|
13
|
+
}, ...props, children: jsx(PanelLeft, { size: 20, strokeWidth: 1.5, className: "text-foreground" }) }));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { SidebarTrigger };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from 'style-inject';
|
|
2
|
+
|
|
3
|
+
var css_248z = "@media (max-width:768px){:root{--page-x-padding:var(--p-6);--page-y-padding:var(--p-6)}}.SidebarTrigger_sidebarTrigger__mx0LZ{cursor:pointer;margin-left:calc(var(--p-4)*-1);width:var(--p-5)}.SidebarTrigger_sidebarTrigger__mx0LZ svg{height:20px;width:20px}";
|
|
4
|
+
var S = {"sidebarTrigger":"SidebarTrigger_sidebarTrigger__mx0LZ"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const SIDEBAR_WIDTH_MOBILE = '18rem';
|
|
2
|
+
const SIDEBAR_WIDTH_ICON = '3rem';
|
|
3
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
4
|
+
/** Fired when nav open closes chat for layout; ChatSheet clears `?chat=` so URL sync does not reopen chat. */
|
|
5
|
+
const DISMISS_CHAT_FOR_LAYOUT_EVENT = 'sybilion:dismiss-chat-for-layout';
|
|
6
|
+
|
|
7
|
+
export { DISMISS_CHAT_FOR_LAYOUT_EVENT, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
const SidebarActionsContext = createContext(null);
|
|
4
|
+
const SidebarStateContext = createContext(null);
|
|
5
|
+
function useSidebarActions() {
|
|
6
|
+
const context = useContext(SidebarActionsContext);
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error('useSidebarActions must be used within a SidebarProvider.');
|
|
9
|
+
}
|
|
10
|
+
return context;
|
|
11
|
+
}
|
|
12
|
+
function useSidebarState() {
|
|
13
|
+
const context = useContext(SidebarStateContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error('useSidebarState must be used within a SidebarProvider.');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
function useSidebar() {
|
|
20
|
+
const actions = useSidebarActions();
|
|
21
|
+
const state = useSidebarState();
|
|
22
|
+
return useMemo(() => ({
|
|
23
|
+
...state,
|
|
24
|
+
...actions,
|
|
25
|
+
}), [state, actions]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { SidebarActionsContext, SidebarStateContext, useSidebar, useSidebarActions, useSidebarState };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SIDEBAR_WIDTH_DEFAULT_PX, SIDEBAR_WIDTH_MIN_PX, SIDEBAR_WIDTH_STORAGE_KEY_PX, SIDEBAR_WIDTH_STORAGE_KEY_PCT, clampSidebarWidthPx, CHAT_WIDTH_DEFAULT_PX, CHAT_WIDTH_STORAGE_KEY, CHAT_WIDTH_MIN_PX, defaultChatWidthPx } from '../../../hooks/panelWidth.js';
|
|
2
|
+
import { LS } from '@homecode/ui';
|
|
3
|
+
|
|
4
|
+
function isEditableKeyboardTarget(el) {
|
|
5
|
+
if (!el)
|
|
6
|
+
return false;
|
|
7
|
+
if (el instanceof HTMLElement && el.isContentEditable)
|
|
8
|
+
return true;
|
|
9
|
+
const tag = el.tagName;
|
|
10
|
+
return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT';
|
|
11
|
+
}
|
|
12
|
+
function readInitialSidebarWidthPx(storageKeyPx) {
|
|
13
|
+
if (typeof window === 'undefined')
|
|
14
|
+
return SIDEBAR_WIDTH_DEFAULT_PX;
|
|
15
|
+
const stored = LS.get(storageKeyPx);
|
|
16
|
+
if (typeof stored === 'number' && stored >= SIDEBAR_WIDTH_MIN_PX) {
|
|
17
|
+
return stored;
|
|
18
|
+
}
|
|
19
|
+
if (storageKeyPx === SIDEBAR_WIDTH_STORAGE_KEY_PX) {
|
|
20
|
+
const legacyPct = LS.get(SIDEBAR_WIDTH_STORAGE_KEY_PCT);
|
|
21
|
+
if (typeof legacyPct === 'number' && legacyPct > 0) {
|
|
22
|
+
const w = window.innerWidth;
|
|
23
|
+
return clampSidebarWidthPx(Math.round((legacyPct / 100) * w), w, {
|
|
24
|
+
chatPanelOpen: false,
|
|
25
|
+
chatWidthPx: 0,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return SIDEBAR_WIDTH_DEFAULT_PX;
|
|
30
|
+
}
|
|
31
|
+
function readInitialChatWidthPx() {
|
|
32
|
+
if (typeof window === 'undefined')
|
|
33
|
+
return CHAT_WIDTH_DEFAULT_PX;
|
|
34
|
+
const stored = LS.get(CHAT_WIDTH_STORAGE_KEY);
|
|
35
|
+
if (typeof stored === 'number' && stored >= CHAT_WIDTH_MIN_PX) {
|
|
36
|
+
return stored;
|
|
37
|
+
}
|
|
38
|
+
return defaultChatWidthPx(window.innerWidth);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { isEditableKeyboardTarget, readInitialChatWidthPx, readInitialSidebarWidthPx };
|
|
@@ -11,17 +11,38 @@ import { InfoIcon } from 'lucide-react';
|
|
|
11
11
|
import '../../ui/Page/AppShell/AppShell.js';
|
|
12
12
|
import '../../ui/Page/pageContext.js';
|
|
13
13
|
import 'react-router-dom';
|
|
14
|
-
import '../../ui/Sidebar/
|
|
15
|
-
import '../../ui/Page/Breadcrumbs/Breadcrumbs.styl.js';
|
|
14
|
+
import '../../ui/Sidebar/sidebarContext.js';
|
|
16
15
|
import { Tooltip, TooltipTrigger, TooltipContent } from '../../ui/Tooltip/Tooltip.js';
|
|
16
|
+
import '../../../tools/env.js';
|
|
17
|
+
import '@homecode/ui';
|
|
18
|
+
import '../../ui/Sidebar/SidebarProvider/SidebarProvider.styl.js';
|
|
19
|
+
import '@phosphor-icons/react';
|
|
20
|
+
import '@radix-ui/react-dialog';
|
|
21
|
+
import '../../ui/Sheet/Sheet.styl.js';
|
|
22
|
+
import '../../ui/Logo/Logo.styl.js';
|
|
23
|
+
import '../../ui/Sidebar/Sidebar.styl.js';
|
|
24
|
+
import '../../ui/SmartTextTruncate/SmartTextTruncate.js';
|
|
25
|
+
import '../../ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.js';
|
|
26
|
+
import '../../ui/Sidebar/SidebarTrigger/SidebarTrigger.styl.js';
|
|
27
|
+
import '../../ui/Sidebar/SidebarRail/SidebarRail.styl.js';
|
|
28
|
+
import '../../ui/Sidebar/SidebarFooter/SidebarFooter.styl.js';
|
|
29
|
+
import '@radix-ui/react-separator';
|
|
30
|
+
import '../../ui/Separator/Separator.styl.js';
|
|
31
|
+
import '../../ui/Sidebar/SidebarSeparator/SidebarSeparator.styl.js';
|
|
32
|
+
import '../../ui/Sidebar/SidebarContent/SidebarContent.styl.js';
|
|
33
|
+
import '../../ui/Sidebar/SidebarGroup/SidebarGroup.styl.js';
|
|
34
|
+
import '../../ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.js';
|
|
35
|
+
import '../../ui/Sidebar/SidebarMenu/SidebarMenu.styl.js';
|
|
36
|
+
import '../../ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl.js';
|
|
37
|
+
import '../../ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.js';
|
|
38
|
+
import '../../ui/Sidebar/SidebarMenuSub/SidebarMenuSub.styl.js';
|
|
39
|
+
import '../../ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl.js';
|
|
40
|
+
import '../../ui/Page/Breadcrumbs/Breadcrumbs.styl.js';
|
|
17
41
|
import '../../ui/Page/PageHeader/PageHeader.styl.js';
|
|
18
42
|
import '../../ui/Page/PageEmptyCanvas/PageEmptyCanvas.styl.js';
|
|
19
43
|
import '../../ui/Page/PageContent/PageContent.styl.js';
|
|
20
|
-
import '@homecode/ui';
|
|
21
44
|
import '../../ui/Page/PageScroll/PageScroll.styl.js';
|
|
22
|
-
import '../../../tools/env.js';
|
|
23
45
|
import { PageXScroll } from '../../ui/Page/PageXScroll/PageXScroll.js';
|
|
24
|
-
import '../../ui/Logo/Logo.styl.js';
|
|
25
46
|
import '../../ui/Page/PageFooter/PageFooter.styl.js';
|
|
26
47
|
import '@radix-ui/react-tabs';
|
|
27
48
|
import '../../ui/Tabs/Tabs.styl.js';
|
|
@@ -11,16 +11,38 @@ import 'classnames';
|
|
|
11
11
|
import '../../ui/Page/AppShell/AppShell.js';
|
|
12
12
|
import '../../ui/Page/pageContext.js';
|
|
13
13
|
import 'react-router-dom';
|
|
14
|
-
import '../../ui/Sidebar/
|
|
14
|
+
import '../../ui/Sidebar/sidebarContext.js';
|
|
15
|
+
import '../../../tools/env.js';
|
|
16
|
+
import '@homecode/ui';
|
|
17
|
+
import '../../ui/Sidebar/SidebarProvider/SidebarProvider.styl.js';
|
|
18
|
+
import '@phosphor-icons/react';
|
|
19
|
+
import '@radix-ui/react-dialog';
|
|
20
|
+
import '../../ui/Sheet/Sheet.styl.js';
|
|
21
|
+
import '../../ui/Logo/Logo.styl.js';
|
|
22
|
+
import '../../ui/Sidebar/Sidebar.styl.js';
|
|
23
|
+
import '../../ui/SmartTextTruncate/SmartTextTruncate.js';
|
|
24
|
+
import '../../ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.js';
|
|
25
|
+
import '../../ui/Sidebar/SidebarTrigger/SidebarTrigger.styl.js';
|
|
26
|
+
import '../../ui/Sidebar/SidebarRail/SidebarRail.styl.js';
|
|
27
|
+
import '../../ui/Sidebar/SidebarFooter/SidebarFooter.styl.js';
|
|
28
|
+
import '@radix-ui/react-separator';
|
|
29
|
+
import '../../ui/Separator/Separator.styl.js';
|
|
30
|
+
import '../../ui/Sidebar/SidebarSeparator/SidebarSeparator.styl.js';
|
|
31
|
+
import '../../ui/Sidebar/SidebarContent/SidebarContent.styl.js';
|
|
32
|
+
import '../../ui/Sidebar/SidebarGroup/SidebarGroup.styl.js';
|
|
33
|
+
import '@radix-ui/react-slot';
|
|
34
|
+
import '../../ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.js';
|
|
35
|
+
import '../../ui/Sidebar/SidebarMenu/SidebarMenu.styl.js';
|
|
36
|
+
import '../../ui/Sidebar/SidebarMenuButton/SidebarMenuButton.styl.js';
|
|
37
|
+
import '../../ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.js';
|
|
38
|
+
import '../../ui/Sidebar/SidebarMenuSub/SidebarMenuSub.styl.js';
|
|
39
|
+
import '../../ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.styl.js';
|
|
15
40
|
import '../../ui/Page/Breadcrumbs/Breadcrumbs.styl.js';
|
|
16
41
|
import '../../ui/Page/PageHeader/PageHeader.styl.js';
|
|
17
42
|
import '../../ui/Page/PageEmptyCanvas/PageEmptyCanvas.styl.js';
|
|
18
43
|
import '../../ui/Page/PageContent/PageContent.styl.js';
|
|
19
|
-
import '@homecode/ui';
|
|
20
44
|
import '../../ui/Page/PageScroll/PageScroll.styl.js';
|
|
21
|
-
import '../../../tools/env.js';
|
|
22
45
|
import { PageXScroll } from '../../ui/Page/PageXScroll/PageXScroll.js';
|
|
23
|
-
import '../../ui/Logo/Logo.styl.js';
|
|
24
46
|
import '../../ui/Page/PageFooter/PageFooter.styl.js';
|
|
25
47
|
import '@radix-ui/react-tabs';
|
|
26
48
|
import '../../ui/Tabs/Tabs.styl.js';
|
package/dist/esm/components/widgets/SidebarDatasetsItemsGrouped/SidebarDatasetsItemsGrouped.js
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo, useState, useEffect } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import '../../ui/Sidebar/sidebarContext.js';
|
|
4
|
+
import 'classnames';
|
|
5
|
+
import '../../ui/Tooltip/Tooltip.js';
|
|
6
|
+
import '../../../tools/env.js';
|
|
7
|
+
import '@homecode/ui';
|
|
8
|
+
import '../../ui/Sidebar/SidebarProvider/SidebarProvider.styl.js';
|
|
9
|
+
import '@phosphor-icons/react';
|
|
10
|
+
import '@radix-ui/react-dialog';
|
|
11
|
+
import '../../ui/Sheet/Sheet.styl.js';
|
|
12
|
+
import '../../ui/Logo/Logo.styl.js';
|
|
13
|
+
import '../../ui/Sidebar/Sidebar.styl.js';
|
|
4
14
|
import { SmartTextTruncate } from '../../ui/SmartTextTruncate/SmartTextTruncate.js';
|
|
15
|
+
import '../../ui/Sidebar/SidebarResizeHandle/SidebarResizeHandle.styl.js';
|
|
16
|
+
import '@radix-ui/react-slot';
|
|
17
|
+
import '../../ui/Button/Button.styl.js';
|
|
5
18
|
import { PackageOpen } from 'lucide-react';
|
|
19
|
+
import '../../ui/Sidebar/SidebarTrigger/SidebarTrigger.styl.js';
|
|
20
|
+
import '../../ui/Sidebar/SidebarRail/SidebarRail.styl.js';
|
|
21
|
+
import '../../ui/Sidebar/SidebarFooter/SidebarFooter.styl.js';
|
|
22
|
+
import '@radix-ui/react-separator';
|
|
23
|
+
import '../../ui/Separator/Separator.styl.js';
|
|
24
|
+
import '../../ui/Sidebar/SidebarSeparator/SidebarSeparator.styl.js';
|
|
25
|
+
import '../../ui/Sidebar/SidebarContent/SidebarContent.styl.js';
|
|
26
|
+
import { SidebarGroup } from '../../ui/Sidebar/SidebarGroup/SidebarGroup.js';
|
|
27
|
+
import '../../ui/Sidebar/SidebarGroupAction/SidebarGroupAction.styl.js';
|
|
28
|
+
import { SidebarMenu, SidebarMenuItem } from '../../ui/Sidebar/SidebarMenu/SidebarMenu.js';
|
|
29
|
+
import { SidebarMenuButton } from '../../ui/Sidebar/SidebarMenuButton/SidebarMenuButton.js';
|
|
30
|
+
import '../../ui/Sidebar/SidebarMenuAction/SidebarMenuAction.styl.js';
|
|
31
|
+
import { SidebarMenuSub, SidebarMenuSubItem } from '../../ui/Sidebar/SidebarMenuSub/SidebarMenuSub.js';
|
|
32
|
+
import { SidebarMenuSubButton } from '../../ui/Sidebar/SidebarMenuSubButton/SidebarMenuSubButton.js';
|
|
6
33
|
import S from './SidebarDatasetsItemsGrouped.styl.js';
|
|
7
34
|
import { groupSidebarDatasets } from './groupSidebarDatasets.js';
|
|
8
35
|
|