import { FASTElement } from "@microsoft/fast-element"; import type { MenuItemRole } from "./menu-item.options.js"; /** * MenuItem * @summary A MenuItem component that represents an item in a menu with various states and interactions. * * @example * ```html * * ``` * * @attr {boolean} disabled - The disabled state of the element. * @attr {MenuItemRole} role - The role of the element. Possible values: 'menuitem', 'menuitemcheckbox', 'menuitemradio'. * @attr {boolean} checked - The checked value of the element. * @attr {boolean} hidden - The hidden attribute. * * @prop {boolean} disabled - The disabled state of the element. * @prop {MenuItemRole} role - The role of the element. * @prop {boolean} checked - The checked value of the element. * @prop {boolean} hidden - The hidden attribute. * @prop {HTMLElement[]} slottedSubmenu - The submenu slotted content. * @prop {HTMLElement | undefined} submenu - The submenu element associated with this menu item. * * @slot - Default slot for menu item content. * @slot start - Slot for the start content. * @slot end - Slot for the end content. * @slot indicator - The checkbox or radio indicator. * @slot submenu-glyph - The submenu expand/collapse indicator. * @slot submenu - Slot for the submenu content. * * @csspart content - The main content of the menu item. * * @cssprop --indent - Custom property for indentation level (default: 0). * @cssprop --menu-max-height - Maximum height for submenu (default: auto). * * @internal connectedCallback - Called when the element is added to the document. * @internal disconnectedCallback - Called when the element is removed from the document. * @method disabledChanged - Handles changes to the disabled attribute. * @method roleChanged - Handles changes to the role attribute. * @method checkedChanged - Handles changes to the checked attribute. * @method slottedSubmenuChanged - Handles changes to the slotted submenu content. * @method handleMenuItemKeyDown - Handles keydown events for the menu item. * @method handleMenuItemClick - Handles click events for the menu item. * @method handleMouseOver - Handles mouse over events for the menu item. * @method handleMouseOut - Handles mouse out events for the menu item. * @method toggleHandler - Handles toggle events from submenu popover. * * @fires change - Fired when the checked state changes. * * @extends FASTElement * @tagname fabric-menu-item * @public */ export declare class MenuItem extends FASTElement { #private; /** * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component. * * @internal */ private elementInternals; /** * The disabled state of the element. * * @public * @remarks * HTML Attribute: disabled */ disabled: boolean; /** * Handles changes to disabled attribute custom states and element internals * @param prev - the previous state * @param next - the next state */ disabledChanged(prev: boolean | undefined, next: boolean | undefined): void; /** * The role of the element. * * @public * @remarks * HTML Attribute: role */ role: MenuItemRole; /** * Handles changes to role attribute element internals properties * @param prev - the previous state * @param next - the next state */ roleChanged(prev: MenuItemRole | undefined, next: MenuItemRole | undefined): void; /** * The checked value of the element. * * @public * @remarks * HTML Attribute: checked */ checked: boolean; /** * Handles changes to checked attribute custom states and element internals. * @param prev - the previous state * @param next - the next state */ protected checkedChanged(prev: boolean, next: boolean): void; /** * The hidden attribute. * * @public * @remarks * HTML Attribute: hidden */ hidden: boolean; /** * The submenu slotted content. * * @internal */ slottedSubmenu: HTMLElement[]; /** * Sets the submenu and updates its position. * * @internal */ protected slottedSubmenuChanged(prev: HTMLElement[] | undefined, next: HTMLElement[]): void; /** * @public */ submenu: HTMLElement | undefined; /** * @public * Sets the role and registers event listeners. */ connectedCallback(): void; /** * Removes event listeners when component is disconnected. */ disconnectedCallback(): void; /** * Handles keydown events for the menu item. * * @param e - The keyboard event * @returns `false` if the event was handled and should not propagate, `true` otherwise * @protected */ protected handleMenuItemKeyDown: (e: KeyboardEvent) => boolean; /** * Handles click events for the menu item. * * @param e - The mouse event * @returns `false` if the event was handled and should not propagate * @protected */ protected handleMenuItemClick: (e: MouseEvent) => boolean; /** * Handles mouse over events for the menu item. * Opens any associated submenu when hovering over the item. * * @param e - The mouse event (unused but required for event handler signature) * @returns `false` if the event was handled and should not propagate * @protected */ protected handleMouseOver: () => boolean; /** * Handles mouse out events for the menu item. * Closes any associated submenu when the mouse leaves the item, * unless the focus remains within the menu item. * * @param e - The mouse event (unused but required for event handler signature) * @returns `false` if the event was handled and should not propagate * @protected */ protected handleMouseOut: () => boolean; /** * Handles toggle events from associated submenu popover. * Sets up required ARIA attributes and tab navigation when submenu opens/closes. * * @param e - The toggle event from the submenu popover * @protected */ protected toggleHandler: (e: Event) => void; /** * Invokes the appropriate action based on the menu item's role. * For checkbox items, toggles the checked state. * For radio items, sets the checked state to true if not already checked. * For regular menu items, opens submenus or emits a change event. * * @internal */ private invoke; /** * Sets the fallback position of the submenu when CSS anchor positioning is not supported. * Calculates optimal positioning to keep the submenu within the viewport bounds. * Positions the submenu to the inline-end by default, but adjusts based on available space. * * @internal */ private setSubmenuPosition; } /** * Menu Item column count * @public */ export type MenuItemColumnCount = 0 | 1 | 2; //# sourceMappingURL=menu-item.d.ts.map