import { MoreVert } from '@mui/icons-material' import { IconButton, Menu, MenuItem, ListItemIcon, ListItemText, } from '@mui/material' import type { WrapperOptionsProps } from '../types' import { useState } from 'react' import { styles } from '../styles' const EMPTY_OPTIONS: NonNullable = [] /** * Renders a dropdown options menu in the widget wrapper header, triggered by a vertical ellipsis icon button. */ export function Options({ labels, options = EMPTY_OPTIONS, }: WrapperOptionsProps) { const [anchorEl, setAnchorEl] = useState(null) const handleOptionAction = ( e: React.MouseEvent, option: NonNullable[number], ) => { e.stopPropagation() option.onClick() setAnchorEl(null) } return ( <> { e.stopPropagation() setAnchorEl(e.currentTarget) }} > setAnchorEl(null)} MenuListProps={{ sx: { paddingBottom: 0, }, }} > {options.map((option) => ( handleOptionAction(e, option)} > {option.icon && {option.icon}} {option.label} ))} ) }