import type { IconName } from '../icon'; /** How to handle sorting select options. */ export declare const SortOptions: { /** Sort matches at the beginning, prioritizing the beginnings of words. */ readonly DEFAULT: "default"; /** Sort matches by priority and remove any non-matches. */ readonly REDUCE: "reduce"; /** Neither sort nor remove options. */ readonly OFF: "off"; }; export type SortOption = (typeof SortOptions)[keyof typeof SortOptions]; /** Used for when you want to display things other than your keys */ export interface DetailedOption { /** Value of the option (used for onChange) */ value: string; /** Display label (defaults to `value` if unset) */ label?: string; /** Display description */ description?: string; /** Icon for this option */ icon?: IconName | undefined; } export declare const optionsToDetailedOptions: (opts: (string | DetailedOption)[]) => DetailedOption[]; export declare const optionDisplayValue: (opt: DetailedOption) => string; /** * A breakdown of how a search result should be highlighted. `before` is the * text preceding the highlighted portion of the result, `highlight` is the * part of the result that should be highlighted, and `after` is the text * succeeding the highlighted portion of the result. */ export type SearchHighlight = [ before: string, highlight: string, after: string ]; /** A search result with highlighting for potential matches */ export interface SearchResult { /** How the option should be highlighted. */ highlight: SearchHighlight | undefined; /** The select option that had a potential match. */ option: DetailedOption; /** The sorting priority for the option. */ priority: number; } /** * A map of search results prioritized by where the match occurred in the * option. */ export interface PrioritizedSearchResults { [priority: number]: SearchResult[] | undefined; 0: SearchResult[]; '-1': SearchResult[]; } /** * Checks the passed select option for a match with the passed search term, * and returns the match with a priority based on the result: * - `0` is any matches on the initial character of a word * - The index of the word in the option that matched * - `-1` for non-matches */ export declare const getSearchResult: (option: DetailedOption, searchTerm: string) => SearchResult; /** * Searches against the passed options with the passed search term before * sorting them and breaking them down into segments to allow for highlighting. * * @param options The select options to be searched and sorted * @param searchTerm The term to match against each of the `options` * @param sort If true, will not return options that did not match the search term * @returns {SearchResult[]} The sorted search results */ export declare const getSearchResults: (options: DetailedOption[], searchTerm?: string, sort?: SortOption) => SearchResult[];