/** * The `auro-menu` element provides users a way to select from a list of options. * @customElement auro-menu * * @event {CustomEvent} auroMenu-activatedOption - Notifies that a menuoption has been made `active`. * @event {CustomEvent} auroMenu-customEventFired - Notifies that a custom event has been fired. * @event {CustomEvent<{ loading: boolean; hasLoadingPlaceholder: boolean; }>} auroMenu-loadingChange - Notifies when the loading attribute is changed. * @event {CustomEvent<{ options: Array }>} auroMenu-optionsChange - Notifies that the set of available menu options has changed. * @event {CustomEvent} auroMenu-selectValueFailure - Notifies that an attempt to select a menuoption by matching a value has failed. * @event {CustomEvent} auroMenu-selectValueReset - Notifies that the component value has been reset. * @event {CustomEvent} auroMenu-selectedOption - Notifies that a new menuoption selection has been made. * @slot loadingText - Text to show while loading attribute is set * @slot loadingIcon - Icon to show while loading attribute is set * @slot - Slot for insertion of menu options. */ export class AuroMenu extends AuroElement { static get properties(): { /** * Applies a named layout variant to the menu. Free-form string consumed by the shared architecture helpers; menu defines no closed value set. */ layout: { type: StringConstructor; attribute: string; reflect: boolean; }; /** * Sets the shape of the menu options. * @type {'box' | 'pill' | 'snowflake'} * @default 'box' */ shape: "box" | "pill" | "snowflake"; /** * Sets the size of the menu options. * @type {'xs' | 'sm' | 'md' | 'lg' | 'xl'} * @default 'sm' */ size: "xs" | "sm" | "md" | "lg" | "xl"; /** * When true, the entire menu and all options are disabled. */ disabled: { type: BooleanConstructor; reflect: boolean; }; /** * Indent level for submenus. * @private */ level: { type: NumberConstructor; reflect: boolean; attribute: boolean; }; /** * When true, displays a loading state using the loadingIcon and loadingText slots if provided. */ loading: { type: BooleanConstructor; reflect: boolean; }; /** * Specifies a string used to highlight matched string parts in options. */ matchWord: { type: StringConstructor; attribute: string; }; /** * When true, the selected option can be multiple options. */ multiSelect: { type: BooleanConstructor; reflect: boolean; attribute: string; }; /** * When true, selected option will not show the checkmark. */ noCheckmark: { type: BooleanConstructor; reflect: boolean; attribute: string; }; optionActive: HTMLElement; optionSelected: HTMLElement | HTMLElement[]; /** * The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values. * Options marked `disabled` or `static` are not selectable by value; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared (`optionSelected` becomes `undefined`) and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped from the value and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option. */ value: { type: StringConstructor; reflect: boolean; attribute: string; }; }; static get styles(): import("lit").CSSResult[]; /** * This will register this element with the browser. * @param {string} [name="auro-menu"] - The name of element that you want to register to. * * @example * AuroMenu.register("custom-menu") // this will register this element to * */ static register(name?: string): void; value: any; optionSelected: any; matchWord: any; noCheckmark: boolean; optionActive: Element | undefined; loading: boolean; multiSelect: boolean; /** * Handles keyboard navigation and selection. * @private * @param {KeyboardEvent} event - The keydown event. */ private handleKeyDown; /** * Handles option selection via click events from menuoptions. * @private * @param {CustomEvent} event - The auroMenuOption-click event. */ private handleMouseSelect; /** * Handles option hover events. * @private * @param {CustomEvent} event - Event object from the browser. */ private handleOptionHover; /** * Handles slot change events. * @private */ private handleSlotChange; initializeArchitectureDefaults(): void; shape: string | undefined; size: string | undefined; /** * @readonly * @returns {Array} - Returns the array of available menu options. */ readonly get options(): Array; /** * @param {number} value - Sets the index of the currently active option. */ set index(value: number); /** * @returns {number} - Returns the index of the currently active option. */ get index(): number; /** * Gets the currently selected options as an array. * @returns {Array} */ get selectedOptions(): Array; /** * Gets the first selected option, or null if none. * @returns {HTMLElement|null} */ get selectedOption(): HTMLElement | null; /** * @readonly * @returns {string} - Returns the label of the currently selected option(s). */ readonly get currentLabel(): string; /** * Formatted value based on `multiSelect` state. * Default type is `String`, changing to `Array` when `multiSelect` is true. * @private * @returns {String|Array} */ private get formattedValue(); /** * Selects options by value. Options marked `disabled` or `static` are not selectable; `hidden` options remain selectable. In single-select mode, if the value matches a non-selectable option the selection is cleared and `auroMenu-selectValueFailure` is dispatched. In multi-select mode, non-selectable entries are dropped and the remaining selectable entries are selected; `auroMenu-selectValueFailure` is dispatched only when none of the entries match a selectable option. Passing `undefined`, `null`, an empty string, or an empty array clears the selection without dispatching a failure. * @param {string|string[]|undefined|null} value - The value(s) to select. * @public */ public selectByValue(value: string | string[] | undefined | null): void; _selectedKey: any; firstUpdated(): void; loadingSlots: NodeListOf | undefined; /** * Sets an attribute that matches the default tag name if the tag name is not the default. * @param {string} tagName - The tag name to set as an attribute. * @private */ private setTagAttribute; updated(changedProperties: any): void; _valueChangeFromSelection: boolean | undefined; _index: number | undefined; /** * Updates the UI state and appearance of menu items based on changed properties. * @private * @param {Map} changedProperties - LitElement's changed properties map. */ private updateItemsState; /** * Initializes the menu's state and structure. * @private */ private initializeMenu; /** * Initializes menu items and their attributes. * @private */ private initItems; items: Element[] | undefined; /** * Assigns a private, auto-generated unique key (`_optionKey`) to each menu * option that does not already have one. Keys are internal state on the * element instance — never reflected as an attribute or exposed publicly — * and let selection tracking distinguish options that share the same `value`. * * The `_optionKey === undefined` guard makes this idempotent: options keep the * key they were first assigned across re-renders and slot changes, and if a * nested menu's lifecycle runs a pass before the root, options simply wait for * the root to key them (or keep whatever key they already hold). * @private */ private _assignOptionKeys; /** * Updates menu state when an option is selected. * @private * @param {HTMLElement} option - The option element to select. */ private handleSelectState; /** * Deselects a menu option and updates related state. * @private * @param {HTMLElement} option - The menuoption to be deselected. */ private handleDeselectState; /** * Resets all options to their default state. * @private */ private clearSelection; /** * Re-sorts the multi-select selection into DOM order and rebuilds the derived * `_selectedKey` and `value` from `optionSelected`. Selection is always stored * and serialized in the order options appear in the menu, never in click * order — so selecting C then A yields `[A, C]`. * @private */ private _sortSelectedByDomOrder; /** * Resets the menu to its initial state. * This is the only way to return value to undefined. * @public */ public reset(): void; /** * Handles nested menu structure. * @private * @param {HTMLElement} menu - Root menu element. */ private handleNestedMenus; /** * Makes a selection based on the current index. * @private */ private makeSelection; /** * Toggle the selection state of the menuoption. * @private * @param {HTMLElement} option - The menuoption to toggle. */ private toggleOption; rootMenu: boolean | undefined; /** * Navigates through options using keyboard. * @param {string} direction - 'up' or 'down'. */ navigateOptions(direction: string): void; /** * Updates the active option state and dispatches events. * Accepts either a numeric index or an HTMLElement option. * @param {number|HTMLElement} indexOrOption - Index of the option or the option element to make active. */ updateActiveOption(indexOrOption: number | HTMLElement): void; /** * Handles custom events defined on options. * @private * @param {HTMLElement} option - Option with custom event. */ private handleCustomEvent; /** * Notifies selection change to parent components. * @param {any} source - The source that triggers this event. * @private */ private notifySelectionChange; /** * @private * @param {any} current - Current selection. * @param {any} next - New selection to compare. * @returns {boolean} Whether the selections are equal. */ private selectionEquals; /** * Checks if an option is currently selected. * @private * @param {HTMLElement} option - The option to check. * @returns {boolean} */ private isOptionSelected; /** * Getter for loading placeholder state. * @returns {boolean} - True if loading slots are present and non-empty. */ get hasLoadingPlaceholder(): boolean; /** * Getter for wrapper classes based on size. * @returns {Object} - Class map for the wrapper element. * @private */ private get wrapperClasses(); /** * Logic to determine the layout of the component. * @protected * @returns {void} */ protected renderLayout(): void; } import { AuroElement } from "../../layoutElement/src/auroElement.js";