import React, { type AriaAttributes, type ReactElement } from "react"; import { type TooltipProps } from "@vibe/tooltip"; import { type IconType, type SubIcon } from "@vibe/icon"; import { type VibeComponentProps } from "../../../types"; import { type CloseMenuOption, type MenuChild } from "../Menu/MenuConstants"; import Label from "../../Label/Label"; import { type TooltipPositions } from "@vibe/tooltip"; import { type SubmenuPosition } from "./MenuItem.types"; export interface MenuItemProps extends VibeComponentProps { /** * The title of the menu item. */ title?: string; /** * The label displayed alongside the title. */ label?: string | React.ReactElement; /** * The icon displayed in the menu item. */ icon?: SubIcon; /** * The type of icon. */ iconType?: IconType; /** * The background color of the icon. */ iconBackgroundColor?: string; /** * The right icon to be displayed. */ rightIcon?: SubIcon; /** * The type of right icon. */ rightIconType?: IconType; /** * The background color of the right icon. */ rightIconBackgroundColor?: string; /** * Class name applied to the icon wrapper. */ rightIconWrapperClassName?: string; /** * If true, the menu item is disabled. */ disabled?: boolean; /** * The reason for disabling the item, shown in a tooltip. */ disableReason?: string; /** * If true, the menu item is selected. */ selected?: boolean; /** * Callback fired when the menu item is clicked. */ onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void; /** * The active item index in the menu. */ activeItemIndex?: number; /** * Callback to set the active item index. */ setActiveItemIndex?: (index: number) => void; /** * The index of the menu item. */ index?: number; /** * The key of the menu item. */ key?: string; /** * If true, the parent menu is visible. */ isParentMenuVisible?: boolean; /** * Callback to reset the open submenu index. */ resetOpenSubMenuIndex?: () => void; /** * If true, a submenu is open. */ hasOpenSubMenu?: boolean; /** * Callback to open or close a submenu by index. */ setSubMenuIsOpenByIndex?: (index: number, isOpen: boolean) => void; /** * If true, document event listeners are used for handling interactions. */ useDocumentEventListeners?: boolean; /** * The tooltip content for the menu item. */ tooltipContent?: string; /** * The position of the tooltip. */ tooltipPosition?: TooltipPositions; /** * The delay in milliseconds before the tooltip shows. */ tooltipShowDelay?: number; /** * Additional props for customizing the tooltip. */ tooltipProps?: Partial; /** * Callback fired when the mouse leaves the item. */ onMouseLeave?: (event: React.MouseEvent) => void; /** * Callback fired when the mouse enters the item. */ onMouseEnter?: (event: React.MouseEvent) => void; /** * Class name applied to the icon wrapper. */ iconWrapperClassName?: string; /** * If true, the menu item starts as selected. */ isInitialSelectedState?: boolean; /** * If true, the menu scrolls to ensure visibility. */ shouldScrollMenu?: boolean; /** * Function to close the menu with a given option. */ closeMenu?: (option: CloseMenuOption) => void; /** * Reference to the menu container. */ menuRef?: React.RefObject; /** * The submenu, if applicable. Must be a single `Menu` element. */ children?: MenuChild; /** * If true, enables a split menu item interaction where the main area triggers an action, * while the icon button opens the submenu. */ splitMenuItem?: boolean; /** * The label of the menu item for accessibility. */ "aria-label"?: AriaAttributes["aria-label"]; /** * The position of a submenu relative to the menu item. */ submenuPosition?: SubmenuPosition; /** * If true, automatically repositions the submenu when its content changes. */ autoAdjustOnSubMenuContentResize?: boolean; } export interface MenuItemTitleComponentProps extends Omit { title: ReactElement; "aria-label": NonNullable; } declare const MenuItem: React.ForwardRefExoticComponent<(MenuItemProps | MenuItemTitleComponentProps) & React.RefAttributes>; export default MenuItem;