feat: Remove documentLink prop and onNavigatorSnapshot logic, and add openDetailPanel and closeDetailPanel to document shell.
This commit is contained in:
@@ -89,9 +89,11 @@ const applyPanelWidthToRoot = (panel: PanelKey, width: number, active: boolean):
|
||||
|
||||
interface PanelManagerProviderProps {
|
||||
children: ReactNode;
|
||||
isOpen?: boolean;
|
||||
onClose?: () => void;
|
||||
}
|
||||
|
||||
export const PanelManagerProvider: React.FC<PanelManagerProviderProps> = ({ children }) => {
|
||||
export const PanelManagerProvider: React.FC<PanelManagerProviderProps> = ({ children, isOpen, onClose }) => {
|
||||
const { collapsed, setCollapsed } = useSidebarContext();
|
||||
const initialSidebarWidth = readStoredWidth('sidebar', DEFAULT_SIDEBAR_WIDTH);
|
||||
const initialDetailWidth = readStoredWidth('detail', DEFAULT_DETAIL_WIDTH);
|
||||
@@ -100,7 +102,13 @@ export const PanelManagerProvider: React.FC<PanelManagerProviderProps> = ({ chil
|
||||
const [detailWidth, setDetailWidthState] = useState(() => clampPanelWidth('detail', initialDetailWidth));
|
||||
const [resizingPanel, setResizingPanel] = useState(null);
|
||||
const [sidebarSuppressed, setSidebarSuppressed] = useState(false);
|
||||
const [detailPanelOpen, setDetailPanelOpen] = useState(false);
|
||||
const [detailPanelOpen, setDetailPanelOpen] = useState(Boolean(isOpen));
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen !== undefined) {
|
||||
setDetailPanelOpen(isOpen);
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const detailCloseHandlerRef = useRef(null);
|
||||
const panelWidthsRef = useRef({ sidebar: sidebarWidth, detail: detailWidth });
|
||||
@@ -109,7 +117,11 @@ export const PanelManagerProvider: React.FC<PanelManagerProviderProps> = ({ chil
|
||||
const closeDetailPanel = useCallback(() => {
|
||||
const handler = detailCloseHandlerRef.current;
|
||||
handler?.();
|
||||
}, []);
|
||||
onClose?.();
|
||||
if (isOpen === undefined) {
|
||||
setDetailPanelOpen(false);
|
||||
}
|
||||
}, [onClose, isOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
panelWidthsRef.current.sidebar = sidebarWidth;
|
||||
@@ -228,11 +240,16 @@ export const PanelManagerProvider: React.FC<PanelManagerProviderProps> = ({ chil
|
||||
}, []);
|
||||
|
||||
const setDetailActive = useCallback(
|
||||
(isOpen) => {
|
||||
setDetailPanelOpen(Boolean(isOpen));
|
||||
handlePanelLayoutChange('detail', isOpen ? 'opened' : 'closed');
|
||||
(active) => {
|
||||
if (isOpen === undefined) {
|
||||
setDetailPanelOpen(Boolean(active));
|
||||
}
|
||||
if (!active) {
|
||||
onClose?.();
|
||||
}
|
||||
handlePanelLayoutChange('detail', active ? 'opened' : 'closed');
|
||||
},
|
||||
[handlePanelLayoutChange],
|
||||
[handlePanelLayoutChange, isOpen, onClose],
|
||||
);
|
||||
|
||||
const expandSidebar = useCallback(() => {
|
||||
@@ -394,8 +411,8 @@ export const usePanelResizeBindings = (
|
||||
|
||||
const handleProps = enabled
|
||||
? {
|
||||
onPointerDown: handlePointerDown,
|
||||
}
|
||||
onPointerDown: handlePointerDown,
|
||||
}
|
||||
: {};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user