import { type Key } from '@react-types/shared'; import { type ItemKey, type ItemSelection, type NormalizedItem } from './itemUtils'; export interface UseStringifiedMultiSelectionOptions { normalizedItems: NormalizedItem[]; selectedKeys?: 'all' | Iterable; defaultSelectedKeys?: 'all' | Iterable; disabledKeys?: Iterable; /** * Handler that is called when the selection change. * Note that under the hood, this is just an alias for Spectrum's * `onSelectionChange`. We are renaming for better consistency with other * components. */ onChange?: (keys: ItemSelection) => void; } export interface UseStringifiedMultiSelectionResult { /** Stringified selection keys */ selectedStringKeys?: 'all' | Set; /** Stringified default selection keys */ defaultSelectedStringKeys?: 'all' | Set; /** Stringified disabled keys */ disabledStringKeys?: 'all' | Set; /** Handler that is called when the string key selections change */ onStringSelectionChange: (keys: 'all' | Set) => void; } /** * Spectrum collection components treat keys as strings if the `key` prop is * explicitly set on `Item` elements. Since we do this in `useRenderNormalizedItem`, * we need to ensure that keys are strings in order for selection to work. We * then need to convert back to the original key types in the onChange handler. * This hook encapsulates converting to and from strings so that keys can match * the original key type. * @param normalizedItems The normalized items to select from. * @param selectedKeys The currently selected keys in the collection. * @param defaultSelectedKeys The initial selected keys in the collection. * @param disabledKeys The currently disabled keys in the collection. * @param onChange Handler that is called when the selection changes. * @returns UseStringifiedMultiSelectionResult with stringified key sets and * string key selection change handler. */ export declare function useStringifiedMultiSelection({ normalizedItems, defaultSelectedKeys, disabledKeys, selectedKeys, onChange, }: UseStringifiedMultiSelectionOptions): UseStringifiedMultiSelectionResult; export default useStringifiedMultiSelection; //# sourceMappingURL=useStringifiedMultiSelection.d.ts.map