import type { DashboardWidget } from './types.js';
import { DeesContextmenu } from '../dees-contextmenu/dees-contextmenu.js';
import type { DeesDashboardgrid } from './dees-dashboardgrid.js';
import * as plugins from '../00plugins.js';

export interface WidgetContextMenuOptions {
  widget: DashboardWidget;
  host: DeesDashboardgrid;
  event: MouseEvent;
}

export const openWidgetContextMenu = ({
  widget,
  host,
  event,
}: WidgetContextMenuOptions) => {
  const items: (plugins.tsclass.website.IMenuItem | { divider: true })[] = [
    {
      name: 'Delete tile',
      iconName: 'lucide:trash2' as any,
      action: async () => {
        host.removeWidget(widget.id);
        return null;
      },
    },
  ];

  DeesContextmenu.openContextMenuWithOptions(event, items as any);
};
