import { useCallback } from 'react'; import { getNodesBounds, useReactFlow, useStore } from '@xyflow/react'; import { START_NODE_ID } from '../../utils/strategyFlowLayout'; type Props = { onDelete: () => void; }; export function MultiSelectionDeleteButton({ onDelete }: Props) { const { getNodes, flowToScreenPosition } = useReactFlow(); const selectionKey = useStore(useCallback((state) => { const selected = state.nodes.filter(n => n.selected && n.id !== START_NODE_ID); if (selected.length < 2) return null; return selected .map(n => `${n.id}:${Math.round(n.position.x)}:${Math.round(n.position.y)}`) .join('|'); }, [])); if (!selectionKey) return null; const selectedNodes = getNodes().filter(n => n.selected && n.id !== START_NODE_ID); if (selectedNodes.length < 2) return null; const bounds = getNodesBounds(selectedNodes); const anchor = flowToScreenPosition({ x: bounds.x + bounds.width, y: bounds.y, }); return ( ); }