/** * 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} 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(): { /** * Allows deselecting an already selected option when clicked again in single-select mode. */ allowDeselect: { type: BooleanConstructor; reflect: boolean; }; /** * When true, the entire menu and all options are disabled. */ disabled: { type: BooleanConstructor; reflect: boolean; }; /** * Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state. */ hasLoadingPlaceholder: { type: BooleanConstructor; }; /** * @private */ layout: { type: StringConstructor; }; /** * 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; }; /** * Specifies the current active menuOption. */ optionActive: { type: ObjectConstructor; attribute: string; }; /** * An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements. */ optionSelected: { type: ObjectConstructor; }; options: { type: ArrayConstructor; reflect: boolean; attribute: boolean; }; /** * Sets the size of the menu. * @type {'sm' | 'md'} * @default 'sm' */ size: "sm" | "md"; /** * When true, selects all options that match the provided value/key when setting value and multiselect is enabled. */ selectAllMatchingOptions: { type: BooleanConstructor; reflect: boolean; }; /** * Sets the shape of the menu. * @type {'box' | 'round'} * @default 'box' */ shape: "box" | "round"; /** * The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values. */ 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 the element that you want to register. * * @example * AuroMenu.register("custom-menu") // this will register this element to * */ static register(name?: string): void; /** * @private */ private shape; /** * @private */ private size; value: any; optionSelected: any; matchWord: any; noCheckmark: boolean; optionActive: any; loading: boolean; multiSelect: boolean; allowDeselect: boolean; selectAllMatchingOptions: boolean; /** * Handles keyboard navigation. * @private * @param {KeyboardEvent} event - Event object from the browser. */ private handleKeyDown; /** * Handles slot change events. * @private */ private handleSlotChange; /** * @readonly * @returns {string} - Returns the label of the currently selected option(s). */ readonly get currentLabel(): string; /** * @readonly * @returns {Array} - Returns the array of available menu options. * @deprecated use `options` property instead. */ readonly get items(): 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; /** * Formatted value based on `multiSelect` state. * Default type is `String`, changing to `Array` when `multiSelect` is true. * @private * @returns {String|Array} */ private get formattedValue(); /** * Gets the current property values for the menu service. * @private * @returns {Object} */ private get propertyValues(); /** * Provides the menu context to child components. * Initializes the MenuService and subscribes to menu changes. * @protected */ protected provideContext(): void; menuService: MenuService; _contextProvider: ContextProvider, this>; /** * Updates the currently active option in the menu. * @param {HTMLElement} option - The option to set as active. */ updateActiveOption(option: HTMLElement): void; /** * Sets the internal value and manages update state. * @param {String|Array} value - The value to set. * @protected */ protected setInternalValue(value: string | Array): void; internalUpdateInProgress: boolean; /** * Handles changes from the menu service and updates component state. * @param {Object} event - The event object from the menu service. * @protected */ protected handleMenuChange(event: any): void; _index: any; options: any; /** * Gets the currently selected options. * @returns {Array} */ get selectedOptions(): Array; /** * Gets the first selected option, or null if none. * @returns {HTMLElement|null} */ get selectedOption(): HTMLElement | null; firstUpdated(): void; loadingSlots: NodeListOf; updated(changedProperties: any): void; /** * 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; /** * Sets the loading state and dispatches a loading change event. * @param {boolean} isLoading - Whether the menu is loading. * @protected */ protected setLoadingState(isLoading: boolean): void; /** * Initializes the menu's state and structure. * @private */ private initializeMenu; /** * Selects the currently highlighted option. * @protected */ protected makeSelection(): void; /** * Resets all options to their default state. * @private */ private clearSelection; /** * 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; /** * Navigates the menu options in the specified direction. * @param {'up'|'down'} direction - The direction to navigate. * @protected */ protected navigateOptions(direction: "up" | "down"): void; rootMenu: boolean; /** * 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; /** * 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"; import { MenuService } from "./auro-menu.context.js"; import { ContextProvider } from "@lit/context";