@oslokommune/punkt-elements
Version:
Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo
25 lines (24 loc) • 896 B
TypeScript
/**
* Shared combobox typeahead utility functions used by both Elements and React packages.
* Only framework-agnostic functions belong here.
*/
/**
* Checks if a character is a letter or space (Unicode-aware).
*/
export declare const isLetterOrSpace: (char: string) => boolean;
/**
* Creates a typeahead handler that manages debounced character accumulation.
* Returns a stateful handler — call destroy() when done to clear timeouts.
*/
export declare const createTypeaheadHandler: (timeout?: number) => {
append: (char: string) => string;
reset: () => void;
getBuffer: () => string;
};
/**
* Finds the first option element whose text content starts with the search string.
* Works with an array of elements, matching against textContent.
*/
export declare const findTypeaheadOptionMatch: (options: {
textContent: string | null;
}[], searchString: string) => number;