UNPKG

@oslokommune/punkt-elements

Version:

Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo

75 lines (74 loc) 3.01 kB
import { Ref } from 'lit/directives/ref.js'; import { PktInputElement } from '../../base-elements/input-element'; import { IPktComboboxOption, TPktComboboxTagPlacement } from './combobox-types'; import { default as PktListbox } from '../listbox'; /** * Base class for PktCombobox. * Declares all reactive properties, state, refs, and simple helpers. */ export declare class ComboboxBase extends PktInputElement { constructor(); value: string | string[]; options: IPktComboboxOption[]; defaultOptions: IPktComboboxOption[]; allowUserInput: boolean; typeahead: boolean; includeSearch: boolean; searchPlaceholder: string; multiple: boolean; maxlength: number | null; displayValueAs: string; tagPlacement: TPktComboboxTagPlacement | null; isOpen: boolean; _options: IPktComboboxOption[]; protected _value: string[]; protected _isOptionsOpen: boolean; protected _userInfoMessage: string; protected _addValueText: string | null; protected _maxIsReached: boolean; protected _search: string; protected _inputFocus: boolean; protected _internalValueSync: boolean; protected _optionsFromSlot: boolean; protected _lastSlotGeneration: number; /** When true, the next handleFocus call will not reopen the dropdown. */ protected _suppressNextOpen: boolean; protected readonly inputRef: Ref<HTMLInputElement>; protected readonly triggerRef: Ref<HTMLDivElement>; protected readonly listboxRef: Ref<PktListbox>; protected get _hasTextInput(): boolean; protected get _selectionDescription(): string | undefined; /** * Focuses the appropriate trigger element after closing the listbox. * Select-only: the combobox input div. Editable: the text input. */ protected focusTrigger(): void; /** * Parses the value prop into an internal string array. */ protected parseValue(): string[]; /** * Updates the _maxIsReached state flag. */ protected updateMaxReached(): void; /** * Syncs the public value property from internal _value state and dispatches * events if the value content changed. Always sets this.value as a string * to prevent array→string reflect cascades. */ protected syncValueAndDispatch(oldInternal: string[]): void; /** * Override onChange to skip the base class touched guard. * The base class returns early on the first call (setting touched = true but not * dispatching events). Combobox needs consistent event dispatch regardless of * touched state. */ protected onChange(value: string | string[]): void; /** * No-op override of the base class valueChanged. * The base class version sets both this.value AND this._value, which creates * an infinite _value → valueChanged → value → parseValue → _value loop. * Combobox handles value sync and event dispatch in syncValueAndDispatch() instead. */ protected valueChanged(): void; }