import type { CSSResultGroup } from 'lit'; import DSAIcon from '../icon/icon'; import type DSAOption from '../option/option'; import DSAPopup from '../popup/popup'; import DSATag from '../tag/tag'; import { FormControlLayout } from '../../internal/components/form-control/form-control-layout'; import type { ShoelaceFormControl } from '../../internal/shoelace-element'; /** * @summary Selects allow you to choose items from a menu of predefined options. * @documentation https://dsa.service-public-autonomie.fr/latest/librairie-webcomponents/liste-deroulante/champ-a-liste-deroulante-select/web-5sgh8Yxf * * @dependency dsa-icon * @dependency dsa-popup * @dependency dsa-tag * @dependency dsa-error-text * * @slot - The listbox options. Must be `` elements. You can use `` to group items visually. * @slot label - The input's label. Alternatively, you can use the `label` attribute. * @slot prefix - Used to prepend a presentational icon or similar element to the combobox. * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute. * @slot tooltip - The tooltip slot allows additional information to be passed along the label. * * @event dsa-after-hide - Emitted after the select's menu closes and all animations are complete. * @event dsa-after-show - Emitted after the select's menu opens and all animations are complete. * @event dsa-change - Emitted when the control's value changes. * @event dsa-blur - Emitted when the control loses focus. * @event dsa-clear - Emitted when the control's value is cleared. * @event dsa-focus - Emitted when the control gains focus. * @event dsa-hide - Emitted when the select's menu closes. * @event dsa-input - Emitted when the control receives input. * @event dsa-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * @event dsa-show - Emitted when the select's menu opens. */ export default class DSASelect extends FormControlLayout implements ShoelaceFormControl { static styles: CSSResultGroup; static dependencies: { 'dsa-icon': typeof DSAIcon; 'dsa-popup': typeof DSAPopup; 'dsa-tag': typeof DSATag; 'dsa-error-text': typeof import("../error-text/error-text").default; }; private readonly formControlController; private readonly localize; private allOptions; private typeToSelectString; private typeToSelectTimeout; popup: DSAPopup; combobox: HTMLSlotElement; displayInput: HTMLInputElement; valueInput: HTMLInputElement; listbox: HTMLSlotElement; private hasFocus; displayLabel: string; currentOption: DSAOption | undefined; selectedOptions: DSAOption[]; /** * The current value of the select component, representing a list of the selected options (or single option if * “multiple” is disabled). It can be used to define which options are selected by default. Selected options * are designated by their value and separated by a space, and will * be submitted as name/value pairs with form data. */ value: string | string[]; /** The default value of the form control. Primarily used for resetting the form control. */ defaultValue: string | string[]; /** Allows more than one option to be selected. */ multiple: boolean; /** The select's variant. */ variant: 'base' | 'layer'; /** * The maximum number of selected options to show when `multiple` is true. After the maximum, "+n" will be shown to * indicate the number of additional items that are selected. Set to 0 to remove the limit. */ maxOptionsVisible: number; /** Adds a clear button when the select is not empty. */ clearable: boolean; /** * Indicates whether or not the select is open. You can toggle this attribute to show and hide the menu, or you can * use the `show()` and `hide()` methods and this attribute will reflect the select's open state. */ open: boolean; /** * Enable this option to prevent the listbox from being clipped when the component is placed inside a container with * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios. */ hoist: boolean; /** * The preferred placement of the select's menu. Note that the actual placement may vary as needed to keep the listbox * inside of the viewport. */ placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end'; /** When true it displays the option's value instead of the label */ displayValue: boolean; /** When set to true, the Popup's width is no longer equal to its anchor's width */ noSyncWidth: boolean; /** Gets the validity state object */ get validity(): ValidityState; /** Gets the validation message */ get validationMessage(): string; connectedCallback(): void; protected firstUpdated(): void; private addOpenListeners; private removeOpenListeners; private handleFocus; private handleBlur; private handleDocumentFocusIn; private handleKeyDown; private handleDocumentMouseDown; private handleComboboxMouseDown; private handleClearClick; private handleClearMouseDown; private handleOptionClick; private handleDefaultSlotChange; private handleTagRemove; private focusNextTagOrInput; private refreshOptionsCache; private setCurrentOption; private setSelectedOptions; private toggleOptionSelection; private selectionChanged; private handleInvalid; handleDisabledChange(): void; handleReadonlyChange(): void; handleValueChange(): void; handleOpenChange(): Promise; /** Shows the listbox. */ show(): Promise; /** Hides the listbox. */ hide(): Promise; /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */ checkValidity(): boolean; /** Gets the associated form, if one exists. */ getForm(): HTMLFormElement | null; /** Checks for validity and shows the browser's validation message if the control is invalid. */ reportValidity(): boolean; /** Sets a custom validation message. Pass an empty string to restore validity. */ setCustomValidity(message: string): void; /** Sets focus on the control. */ focus(options?: FocusOptions): void; /** Removes focus from the control. */ blur(): void; private getDescriptionIds; renderInput(): import("lit").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { 'dsa-select': DSASelect; } }