import { memo } from "react"; import { createPortal } from "react-dom"; import { useContextMenuDismiss } from "../../hooks/useContextMenuDismiss"; export interface KeyframeDiamondContextMenuState { x: number; y: number; elementId: string; percentage: number; tweenPercentage?: number; currentEase?: string; } interface KeyframeDiamondContextMenuProps { state: KeyframeDiamondContextMenuState; onClose: () => void; onDelete: (elementId: string, percentage: number) => void; onDeleteAll: (elementId: string) => void; onChangeEase?: (elementId: string, percentage: number, ease: string) => void; onCopyProperties?: (elementId: string, percentage: number) => void; } export const KeyframeDiamondContextMenu = memo(function KeyframeDiamondContextMenu({ state, onClose, onDelete, onDeleteAll, }: KeyframeDiamondContextMenuProps) { const menuRef = useContextMenuDismiss(onClose); const menuWidth = 200; const menuHeight = 70; const overflowY = state.y + menuHeight - window.innerHeight; const adjustedX = state.x + menuWidth > window.innerWidth ? state.x - menuWidth : state.x; const adjustedY = overflowY > 0 ? state.y - overflowY - 8 : state.y; return createPortal(