import React from 'react'; import { cn } from '../../utils/cn'; import { ControlButton } from './ControlButton'; export interface GraphControlsProps { dragEnabled?: boolean; onDragToggle?: (enabled: boolean) => void; manualLayout?: boolean; onManualLayoutToggle?: (enabled: boolean) => void; onPinAll?: () => void; onUnpinAll?: () => void; onReset?: () => void; onFitView?: () => void; pinnedCount?: number; totalNodes?: number; visible?: boolean; position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; className?: string; } export const GraphControls: React.FC = ({ dragEnabled = true, onDragToggle, manualLayout = false, onManualLayoutToggle, onPinAll, onUnpinAll, onReset, onFitView, pinnedCount = 0, totalNodes = 0, visible = true, position = 'top-left', className, }) => { if (!visible) return null; const positionClasses: Record = { 'top-left': 'top-4 left-4', 'top-right': 'top-4 right-4', 'bottom-left': 'bottom-4 left-4', 'bottom-right': 'bottom-4 right-4', }; return (
onDragToggle?.(!dragEnabled)} active={dragEnabled} icon="✋" label={dragEnabled ? 'Drag enabled' : 'Drag disabled'} /> onManualLayoutToggle?.(!manualLayout)} active={manualLayout} icon="🔧" label={manualLayout ? 'Manual layout: ON' : 'Manual layout: OFF'} />
onPinAll?.()} disabled={totalNodes === 0} icon="📌" label={`Pin all nodes (${totalNodes})`} /> onUnpinAll?.()} disabled={pinnedCount === 0} icon="📍" label={`Unpin all (${pinnedCount} pinned)`} />
onFitView?.()} disabled={totalNodes === 0} icon="🎯" label="Fit all nodes in view" /> onReset?.()} disabled={totalNodes === 0} icon="↺" label="Reset to auto-layout" />
Nodes: {totalNodes}
{pinnedCount > 0 && (
Pinned: {pinnedCount}
)}
); }; GraphControls.displayName = 'GraphControls';