@oslokommune/punkt-elements
Version:
Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo
42 lines (41 loc) • 1.71 kB
TypeScript
import { IPktComboboxOption } from '../../shared-types/combobox';
/**
* Lit-specific utility functions for PktCombobox component.
*
* Framework-agnostic functions live in shared-utils/combobox/.
* Only Lit-specific functions (using Ref, in-place mutation) stay here.
*/
/**
* In-place option mutation helpers that preserve referential identity
* between this._options and this.options in the Lit component.
*/
export declare const selectionMutators: {
markOptionSelected(options: IPktComboboxOption[], value: string | null): void;
markOptionDeselected(options: IPktComboboxOption[], value: string | null): void;
markAllSelected(options: IPktComboboxOption[]): void;
markAllDeselected(options: IPktComboboxOption[]): void;
removeUserAddedOptions(options: IPktComboboxOption[]): IPktComboboxOption[];
};
/**
* Parses option elements from slot controller nodes into IPktComboboxOption[].
*/
export declare const slotUtils: {
parseOptionsFromSlot(nodes: Element[]): IPktComboboxOption[];
};
export declare const optionStateUtils: {
/**
* Ensures options have labels and fulltext set.
* Also syncs selected state with current values.
*
* IMPORTANT: Mutates options in place to preserve referential identity
* between this._options and this.options in the Lit component.
*/
syncOptionsWithValues(options: IPktComboboxOption[], values: string[]): {
options: IPktComboboxOption[];
newValues: string[];
};
/**
* Merges user-added options with new options, preserving user additions.
*/
mergeWithUserAdded(newOptions: IPktComboboxOption[], previousOptions: IPktComboboxOption[]): IPktComboboxOption[];
};