@vectara/vectara-ui
Version:
Vectara's design system, codified as a React and Sass component library
15 lines (14 loc) • 818 B
TypeScript
import { OptionListItem } from "../optionsList/types";
/**
* The desired UX to is sort selected options to the top of the list.
*
* When there is an active async search, the list of options has already
* been filtered, so we only want to show selected options that are in
* the list of options. In this case, cache will NOT be provided.
*
* When the async search is not active, the list of options will consist
* of the first few pages and might not contain any "searched" options
* that have been selected. We need to show all selected options so we
* use the cache to fill in any holes. In this case, cache will be provided.
*/
export declare const sortSelectedOptions: <T>(selectedOptions: T[], options: OptionListItem<T>[], cache?: Record<string, OptionListItem<T>> | undefined) => OptionListItem<T>[];