import { type Key } from '@react-types/shared'; import { type ItemKey, type NormalizedItem, type NormalizedSection } from './itemUtils'; export interface UseStringifiedSelectionOptions { normalizedItems: (NormalizedItem | NormalizedSection)[]; selectedKey: ItemKey | null | undefined; defaultSelectedKey: ItemKey | undefined; disabledKeys: Iterable | undefined; onChange: ((key: ItemKey | null) => void) | undefined; } export interface UseStringifiedSelectionResult { defaultSelectedStringKey?: Key; selectedStringKey?: Key | null; disabledStringKeys?: Set; onStringSelectionChange: (key: Key | null) => 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 selectedKey The currently selected key in the collection. * @param defaultSelectedKey The initial selected key in the collection. * @param disabledKeys The currently disabled keys in the collection. * @param onChange Handler that is called when the selection changes. * @returns UseStringifiedSelectionResult with stringified key sets and string * key selection change handler. */ export declare function useStringifiedSelection({ normalizedItems, defaultSelectedKey, selectedKey, disabledKeys, onChange, }: UseStringifiedSelectionOptions): UseStringifiedSelectionResult; export default useStringifiedSelection; //# sourceMappingURL=useStringifiedSelection.d.ts.map