import { EventEmitter } from '../../stencil-public-runtime'; import { HeaderMenuToggleDetail } from '../ontario-header/ontario-header.interface'; import { MenuItem } from '../../utils/common/common.interface'; import { Language } from '../../utils/common/language-types'; /** * Ontario Header Overflow Menu displays overflow navigation links for header contexts. * * It can operate in two modes: * * ### Standalone Mode * * Used when placed directly in the header (desktop view). * - Manages its own open/close state via `menuButtonToggled` event * - Automatically focuses first menu item when opened * - Sets up focus trap to keep keyboard navigation within menu * - Auto-closes when focus leaves the menu area * - **Emits**: `menuClosed` event when menu closes (for cleanup/state sync) * * ### Embedded Mode * * Used when placed inside `ontario-header-menu-tabs` (mobile/tablet view). * - Parent component controls open/close state * - Parent component manages focus trap * - Menu is always visible when parent tab is active * - **Emits**: `endOfMenuReached` event when Tab is pressed on last item (for focus looping) * * ### Mode Detection * * - Auto-detected based on DOM position (no prop needed). * - Checks if ancestor is `ontario-header-menu-tabs` or `.ontario-mobile-menu__panel`. * * For component guidance, see: * - https://designsystem.ontario.ca/components/detail/ontario-header.html * - https://designsystem.ontario.ca/components/detail/application-header.html * - https://designsystem.ontario.ca/components/detail/service-ontario-header.html * - https://designsystem.ontario.ca/developer-docs/components/ontario-header-overflow-menu/ */ export declare class OntarioHeaderOverflowMenu { el: HTMLElement; /** * The menu items to display. * Can be passed as a MenuItem array or JSON string. * * The items that will go inside the menu. * * @example * * */ menuItems: MenuItem[] | string; /** * Whether this is the last menu in a series of menus. * If true, Tab from last item goes to next element on page. * If false, Tab from last item emits focusNextElement for header to handle. */ isLastMenu?: boolean; /** * Whether Tab from the last menu item should return focus to the trigger button * instead of moving to the next menu or next page element. */ returnFocusToTriggerOnLastTab?: boolean; /** * Whether the standalone menu should move focus to the first item when opened. * This should only be true for keyboard-triggered opens. */ focusFirstItemOnOpen?: boolean; /** * The language of the component. * This is used for translations, and is by default set through event listeners checking for a language property from the header. If none is passed, it will default to English. */ language?: Language; /** * Parsed menu items (converted from string if needed). */ private menuItemState; /** * Whether the menu dropdown is currently open (standalone mode only). */ private menuIsOpen; /** * Current focused menu item index for arrow key navigation. */ private currentIndex; /** * Flag to track if auto-close check should happen. */ private shouldCheckAutoClose; /** * Flag to prevent focusin from interfering with arrow navigation. */ private isArrowNavigating; /** * Reference to the menu container element. */ private menu; /** * Reference to the ARIA live region for screen reader announcements. */ private ariaLiveRegion; /** * Prevent the same Arrow key event that opened/focused the embedded menu * from immediately advancing to the next item. */ private suppressNextArrowNavigation; /** * Runtime mode detection. * Returns true when standalone (not inside tabs or mobile panel). */ private get isStandalone(); /** * Whether we've already focused the first item after menu opened. */ private hasInitializedFocus; /** * Whether the menu should move focus to the first item when it opens. */ private shouldFocusFirstItemOnOpen; /** * Lifecycle hook called before the component is loaded. */ componentWillLoad(): void; /** * Lifecycle hook called after component updates. * Focuses first menu item when menu opens in standalone mode. */ componentDidUpdate(): void; /** * Watch for changes to menuItems prop and re-parse them. */ parseMenuItems(): void; /** * Event emitted when menu closes (standalone mode). */ menuClosed: EventEmitter; /** * Event emitted when Tab is pressed on the last menu item (embedded mode). */ endOfMenuReached: EventEmitter; /** * Event emitted when Shift+Tab is pressed on first menu item. * Tells the header to focus the menu button. */ focusMenuButtonEvent: EventEmitter; /** * Event emitted when Tab is pressed on the last menu item in standalone mode. * Tells the header to focus the next appropriate element. */ focusNextElement: EventEmitter; /** * Event emitted when user Tabs from the menu button. * Asks if menu is open and ready to receive focus. */ menuButtonTabPressed: EventEmitter; /** * Listen for focus first item event from menu tabs (embedded mode). */ handleFocusFirstItem(): void; /** * Listen for Tab pressed from menu button. * If menu is open and in standalone mode, focus first item. */ handleMenuButtonTab(): void; /** * Listen for menu button toggle events (standalone mode only). */ handleMenuButtonToggled(event: CustomEvent): void; /** * Handle keyboard navigation within the menu. */ handleKeyDown(event: KeyboardEvent): void; /** * Listen for signal that focus has returned to menu button. */ handleMenuButtonFocused(): void; /** * Auto-close menu when focus leaves (standalone mode only). */ handleFocusOut(event: FocusEvent): void; /** * Sync currentIndex when focus enters a menu item (after Tab navigation). */ handleFocusIn(event: FocusEvent): void; /** * This listens for the `setAppLanguage` event sent from the language toggle when it is connected to the DOM. * It is used for the initial language when the component loads. */ handleSetAppLanguage(event: CustomEvent | Language): void; /** * This listens for the `headerLanguageToggled` event sent from the language toggle when it is connected to the DOM. * It is used for changing the component language after the language toggle has been activated. */ handleLanguageToggle(event: CustomEvent<{ oldLanguage: Language; newLanguage: Language; }>): void; /** * Sync currentIndex after Tab navigation completes. */ private syncIndexAfterTab; /** * Handle keyboard events in standalone mode. */ private handleStandaloneKeyboard; /** * Handle keyboard events in embedded mode. */ private handleEmbeddedKeyboard; /** * Handle arrow key navigation (both modes). * Navigates through menu items with wrapping - arrows loop from last to first item and vice versa. */ private handleArrowNavigation; /** * Focus the first menu item. * Sets currentIndex to 0 to track position for arrow navigation. */ private focusFirstMenuItem; /** * Reset state when menu closes. */ private resetState; /** * Get all focusable elements within the menu. */ private getFocusableElements; /** * Update ARIA live region to announce current menu item position. */ private updateAriaLive; /** * Parse menu items from prop (array or JSON string). */ private parseMenuItemsData; /** * Get text in current language from a string or bilingual object. */ private getText; /** * Set active link based on current URL if none specified. */ private setActiveLink; render(): any; }