UNPKG

rooks

Version:

Collection of awesome react hooks

22 lines (21 loc) 895 B
import type { OptionalIndexValue } from "../types/index-value"; type Selection<T> = [number, T]; type UseSelectableListReturnType<T> = [ Selection<T>, { matchSelection: (parameters: OptionalIndexValue<T>) => boolean; toggleSelection: (parameters: OptionalIndexValue<T>) => () => void; updateSelection: (parameters: OptionalIndexValue<T>) => () => void; } ]; /** * useSelectableList * Easily select a single value from a list of values. very useful for radio buttons, select inputs etc. * * @param list - The list of values to select from * @param initialIndex - The index of the initial selection * @param allowUnselected * @see https://rooks.vercel.app/docs/hooks/useSelectableList */ declare function useSelectableList<T>(list?: T[], initialIndex?: number, allowUnselected?: boolean): UseSelectableListReturnType<T>; export { useSelectableList };