import { EventEmitter } from "../../stencil-public-runtime"; import { ThemeableComponent } from "../../common"; import { DuetTheme } from "../../common-types"; import { DuetLangObject } from "../../utils/language-utils"; export type DuetComboboxEvent = { originalEvent?: Event; component: "duet-combobox"; value: any; item: DuetComboboxItem; }; export type DuetComboboxItem = { id?: string; value: any; name: string; html?: string; tags?: string[]; }; export declare class DuetCombobox implements ThemeableComponent { private input?; private listContainer; private listBoxId; private inputId; private activeDescendantId; private isAndroidDevice; private isInsideModal; private resizeObserver; element: HTMLDivElement; processedItems: DuetComboboxItem[]; inputValue: string; listOpen: boolean; popupMenuController: HTMLElement; popupMenuOpenHandler(): void; selectedItems?: Set; activeItem?: number; activeItemAnnouncement: string; activeItemHandler(_state: any): void; private announceActiveItem; inputValueHandler(): void; /** * Defaults for the accessible labels for the select items */ accessibleLabelDefaults: DuetLangObject | string; /** * Accessible labels for the select items */ accessibleLabels: Record; /** * Label for the input if input is not provided as a slotted element. */ label: string; /** * Caption for the input if input is not provided as a slotted element. */ caption: string; /** * Theme of the combobox. */ theme: DuetTheme; /** * Force the user to make a selection (typing things in the input field will only be used for list search). * This property also sync input value with selected value on blur. */ force: boolean; /** * Allow multiple selections. Selections are displayed as DuetChips. */ multiple: boolean; /** * Array of item objects. Each item should have properties name, value and optionally id. If id is not provided, it will be generated. * Alternatively, an array of strings can be provided, in which case the strings will be used for name, value and id. */ items: any; /** * A hook to overwrite how the values are displayed in the input field after a User select an item * @example (item) => `${item.name} (${item.value})` * @default undefined */ formatter: (item: DuetComboboxItem) => string; /** * Value of selected item/s. If multiple is true, value is an array of selected items, else it's a string. */ value: string | string[]; /** * Defines minimum number of characters that must be given to show search results */ minCharacters: number; /** * Defines if items list should always open after clicking on input */ openListOnClick: boolean; /** * Defines if filtering of items should be done by includes or startsWith */ filterType: "includes" | "startsWith"; /** * Emitted when selected item changed. */ duetChange: EventEmitter; handleDocumentClick(e: MouseEvent): void; /** * Exposes a formatter function to format the item value displayed after a user selects an item * @param item: DuetComboboxItem */ formatItem(item: DuetComboboxItem): Promise; processItems(): void; processValue(): void; processListOpenChange(): void; /** * Component lifecycle events. */ componentWillLoad(): void; connectedCallback(): void; disconnectedCallback(): void; componentDidLoad(): void; /** * Helper function that checks inputs in the field, compares it with the item list and returns true when inputvalue matches selectedItem id */ private shouldListBeFiltered; /** * Helper function that return correct collection depending on filter status returend by shouldListBeFiltered */ private returnFilteredOrNonFiltered; private emitChangeEvent; /** * Updates the value after selected items have changed for multiple selection. */ private updateMultipleValue; /** * Add item with id to the selectedItems set. Used only when multiple is true. */ private addSelectedItem; /** * Remove item with id from the selectedItems set. Used only when multiple is true. */ private removeSelectedItem; /** * Updates the selected item based on the item id. Used only when multiple is false. */ private updateSelectedItem; /** * Add or remove chips of the input based on the selectedItems Set. */ private updateChips; private getSelectedItemLabel; /** * Updates the input text when the combobox loses focus or when a selection is made. */ private updateInputText; private onListClick; private onInputChange; private onInputClick; private onInputTyping; private onKeyDown; private scrollToActive; private formatLabel; /** * Filter the items based on the input value */ private getFilteredItems; /** * Sort the return from getFilteredItems so that any item with and item.id that matches this.selectedItems is placed first */ private sortFilteredItems; /** * As the div.combobox-menu-container is inside popup-menu's shadow DOM, external styles don't work */ private getMenuContainerStyles; /** * render() function * Always the last one in the class. */ render(): any; }