import { Menu, MenuButton, MenuItem, MenuList, MenuProps, MenuListProps, MenuItemProps, IconButton, Button, IconButtonProps, ButtonProps, } from '@chakra-ui/react'; import { MouseEventHandler, ReactNode } from 'react'; import { MdArrowDropDown, MdArrowDropUp } from 'react-icons/md'; interface IAIMenuItem { item: ReactNode | string; onClick: MouseEventHandler | undefined; } interface IAIMenuProps { menuType?: 'icon' | 'regular'; buttonText?: string; iconTooltip?: string; isLazy?: boolean; menuItems: IAIMenuItem[]; menuProps?: MenuProps; menuButtonProps?: IconButtonProps | ButtonProps; menuListProps?: MenuListProps; menuItemProps?: MenuItemProps; } export default function IAISimpleMenu(props: IAIMenuProps) { const { menuType = 'icon', iconTooltip, buttonText, isLazy = true, menuItems, menuProps, menuButtonProps, menuListProps, menuItemProps, } = props; const renderMenuItems = () => { const menuItemsToRender: ReactNode[] = []; menuItems.forEach((menuItem, index) => { menuItemsToRender.push( {menuItem.item} ); }); return menuItemsToRender; }; return ( {({ isOpen }) => ( <> : } paddingX={0} paddingY={menuType === 'regular' ? 2 : 0} {...menuButtonProps} > {menuType === 'regular' && buttonText} {renderMenuItems()} )} ); }