import { useCallback, useSyncExternalStore } from "react"; import { CornersIn, CornersOut, DotsThree, X } from "@phosphor-icons/react"; import type { IDockviewHeaderActionsProps } from "dockview-react"; import { IconButton, Menu, MenuCheckboxItem, MenuItem, MenuSeparator } from "../ui"; import { useDockLayoutStore } from "./dockLayoutStore"; import { PANEL_DEFINITIONS, isPanelId, panelsInZone } from "./panelRegistry"; /** Panel menu, maximise and close group, drawn on the active group's strip only. */ export function DockStripActions({ api, containerApi, panels, isGroupActive, }: IDockviewHeaderActionsProps) { const subscribe = useCallback( (onChange: () => void) => { const subscription = containerApi.onDidMaximizedGroupChange(onChange); return () => subscription.dispose(); }, [containerApi], ); const maximized = useSyncExternalStore(subscribe, () => api.isMaximized()); const openPanels = useDockLayoutStore((state) => state.openPanels); const togglePanel = useDockLayoutStore((state) => state.togglePanel); const resetLayout = useDockLayoutStore((state) => state.resetLayout); if (!isGroupActive) return null; const first = panels.find((panel) => isPanelId(panel.id))?.id; const menuPanels = isPanelId(first) ? panelsInZone(PANEL_DEFINITIONS[first].zone) : []; return (