import React from 'react';
import { Menu } from '@arco-design/web-react';
import AddNodeMenu from './addNodeMenu';

const SubMenu = Menu.SubMenu;

interface PaneContextMenuProps {
  onAddNode: (nodeType: string, position: { x: number; y: number }) => void;
  position: { x: number; y: number };
}

const PaneContextMenu: React.FC<PaneContextMenuProps> = ({
                                                           onAddNode,
                                                           position
                                                         }) => {
  // 包装onAddNode函数以适配AddNodeMenu组件的接口
  const handleAddNode = (nodeType: string) => {
    onAddNode(nodeType, position);
  };

  return (
    <Menu
      style={{
        minWidth: 200,
        border: '1px solid #e4e7ed',
        borderRadius: 4,
        boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)'
      }}
    >
      <SubMenu
        key="add-node"
        title="添加节点"
        popup
        triggerProps={{
          popupStyle: { height: 'auto', maxHeight: 'none' }
        }}
      >
        <AddNodeMenu onAddNode={handleAddNode} />
      </SubMenu>
    </Menu>
  );
};

export default PaneContextMenu;