import { EventEmitter } from '../../stencil-public-runtime';
import {
ApplicationHeaderInfo,
HeaderMenuToggleDetail,
LanguageToggleOptions,
OntarioHeaderType,
} from './ontario-header.interface';
import { Language } from '../../utils/common/language-types';
import { MenuItem } from '../../utils/common/common.interface';
import { DeviceType } from '../../utils/helper/utils-types';
/**
* Ontario Header renders Ontario.ca, application, and ServiceOntario header variants.
*
* 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/
*/
export declare class OntarioHeader {
el: HTMLElement;
/**
* The type of header.
*/
type?: OntarioHeaderType;
/**
* Information pertaining to the application and ServiceOntario headers.
*
* For the 'application' header type, this includes the application name, URL and optional props for the number of links in the subheader for desktop, tablet, and mobile views.
*
* For the 'serviceOntario' header type, the 'title' property is used as the service name displayed in the subheader.
*
* @example
*
*
*
*
*
*/
applicationHeaderInfo: ApplicationHeaderInfo | string;
/**
* The items that will go inside the menu dropdown.
*
* For the 'ontario' header type, these items are displayed in the overflow menu. If `disableDynamicMenu` is false, static items will be overridden by dynamically fetched items from the Ontario Header API.
*
* For the 'application' and 'serviceOntario' header types, these items are displayed in the subheader menu and overflow menu.
*/
menuItems: MenuItem[] | string;
/**
* Information pertaining to the sign-in menu items for the Ontario header.
*/
signInMenuItems?: MenuItem[] | string;
/**
* A custom function to pass to the sign-in button.
*/
customSignInToggle?: (event: globalThis.Event) => void;
/**
* Option to disable fetching of the dynamic menu from the Ontario Header API.
*
* When set to true, the static `menuItems` prop will be used instead of fetching from the API.
* When set to false (default), menu items are fetched dynamically from the Ontario Header API endpoint.
*
* This property only applies to the 'ontario' header type. The 'application' and 'serviceOntario' types always use static menu items.
*
* @default false
*
* @example
*
*
*/
disableDynamicMenu: boolean;
/**
* Information pertaining to the language toggle links.
*
* @example
*
*
*/
languageToggleOptions?: LanguageToggleOptions | string;
/**
* A custom function to pass to the language toggle button.
*/
customLanguageToggle?: (event: globalThis.Event) => void;
/**
* 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;
/**
* The base path to an assets folder containing the Design System assets
*/
assetBasePath: string;
/**
* The application header information is reassigned to applicationHeaderInfoState for parsing
*/
private applicationHeaderInfoState;
/**
* The menuItems is reassigned to itemState for parsing
*
* @example
*
*
*/
private menuItemState;
/**
* The parsed sign-in menu items state
*/
private signInMenuItemsState;
/**
* A boolean state to handle the toggling of the sign-in menu
*/
signInToggled: boolean;
/**
* Check to see if menu is dynamic or static
*/
private isDynamicMenu;
/**
* The languageToggleOptions is reassigned to languageState for parsing
*
* @example
*
*/
private languageState;
/**
* Toggler for the menu and the search button
*/
menuToggled: boolean;
searchToggle?: boolean;
translations: any;
breakpointDeviceState: DeviceType;
/**
* Tracks the current value of the search input field.
*
* This state is updated as the user types and is used as the single
* source of truth for the search input content (instead of directly
* manipulating the DOM). Clearing the field via Escape now resets this
* state, which triggers the UI to update automatically.
*
* Also used as the value submitted when performing a header search,
* improving consistency and reliability of the search behaviour.
*/
private searchBoxTextState;
private shouldFocusMenuOnOpen;
private pendingMenuToggleTrigger;
/**
* Header-specific device detection.
*/
private getHeaderDeviceType;
/**
* Helper to check if current breakpoint is mobile or tablet (not desktop)
*/
private get isMobileOrTablet();
private createMenuToggleDetail;
private emitMenuToggle;
private consumePendingMenuToggleTrigger;
private isMenuOpenButtonKey;
private moveFocusIntoOpenMenu;
private focusDesktopMenuAfterKeyboardOpen;
private handleMenuButtonKeyDown;
private handleMenuButtonClick;
private handleSignInButtonKeyDown;
private handleSignInButtonClick;
private parseApplicationHeaderInfo;
parseMenuItems(): void;
parseSignInMenuItems(): void;
private parseLanguage;
/**
* Watch for changes to the disableDynamicMenu prop to reset the fetch state.
* This allows the menu to be fetched again if the prop is changed after initial load.
*/
private handleDisableDynamicMenuChange;
handleKeyDown(event: KeyboardEvent): void;
/**
* Logic to close the menu when anything outside the menu is clicked
*/
handleClick(event: any): void;
/**
* Logic to close the menu when the focus leaves the menu
*/
handleFocusOut(event: FocusEvent): void;
/**
* Logic to set breakpointDeviceState to the appropriate device when the screen resizes
*/
handleResize(): void;
/**
* This listens for the `setAppLanguage` event sent from the language toggle when it is is connected to the DOM.
* It is used for the initial language when the input component loads.
*/
handleSetAppLanguage(event: CustomEvent | Language): void;
/**
* This listens for the `headerLanguageToggled` event sent from the language toggle when it is 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;
/**
* Listen for menu closed event from overflow menu
*/
handleMenuClosed(): void;
/**
* Listen for overflow menu requesting menu button focus.
* Happens when user presses Shift+Tab from first menu item.
*/
handleFocusMenuButton(): void;
/**
* This event is toggled when the menu button is pressed.
* The `` sub-component listens for this event
* To trigger the showing and hiding of the overflow menu.
*/
menuButtonToggled: EventEmitter;
/**
* Logic to handle the menu toggling
*/
handlemenuToggled: (trigger?: HeaderMenuToggleDetail['trigger']) => void;
/**
* Logic to handle the search toggling
*/
handleSearchToggle: () => void;
/**
* Logic to handle the sign-in toggling
*/
handleSignInToggled: (trigger?: HeaderMenuToggleDetail['trigger']) => void;
/**
* event.preventDefault(): https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
* location.href: https://developer.mozilla.org/en-US/docs/Web/API/Location/href
*/
handleSubmit: (event: any) => void;
/**
* Logic to make the focus go back to the menu button when the list ends
*/
focusMenuButton(): void;
/**
* Call to Ontario Menu API to fetch linksets to populate header component
*/
fetchOntarioMenu(): Promise;
/**
* Hydration Guard Flag
*
* This flag is used to determine if the component has been hydrated in the browser.
* It prevents certain browser-only operations, like fetching from APIs, from running
* during Server-Side Rendering (SSR), where `window` and `fetch` are not available.
*
* The `isHydrated` flag is set to true in `componentDidLoad()` and checked before
* triggering logic that should only run in the browser (e.g., `fetchOntarioMenu()`).
*
* Not reactive - should not be stored in State.
*/
private isHydrated;
/**
* Generate the full path to an image asset based on the base asset path.
*
* - If `assetBasePath` is provided, it is used as the base path.
* - If not, attempts to use Stencil's `getAssetPath` (for Stencil/Angular builds).
* - If that fails (e.g., in React), falls back to `/assets/`, assuming assets are in the public folder.
*
* This allows the component to work across multiple environments (Stencil, Angular, React).
*
* @param imageName - The name of the image file.
* @returns The full image path as a string.
*/
private getImageAssetSrcPath;
/**
* This function generates the menu dropdown button for the ontario header component.
* It now derives viewport from component state (this.breakpointDeviceState) instead
* of relying on a caller-provided string.
*/
private renderMenuButton;
/**
* This function generates the sign-in button for the ontario header component.
*/
private renderSignInButton;
/**
* The onEscapePressed function clears the searchbar form when Escape is pressed
*/
private onEscapePressed;
private isMenuVisible;
componentWillLoad(): void;
componentDidLoad(): void;
componentDidRender(): void;
/**
* Handles the search focus when the search toggle button is clicked.
* When search button is clicked, the search bar is in focus,
* when the closed button is clicked, the search button is back into focus.
*/
componentDidUpdate(): void;
/**
* Assigning values to elements to use them as ref
*/
header: HTMLElement;
menuButton: HTMLElement;
signInButton: HTMLElement;
searchBar: HTMLInputElement;
searchButton: HTMLInputElement;
render(): any;
}