UNPKG

766 BTypeScriptView Raw
1import type { Key } from 'react';
2export interface Options<T> {
3 defaultSelected?: T[];
4 itemKey?: string | ((item: T) => Key);
5}
6export default function useSelections<T>(items: T[], options?: T[] | Options<T>): {
7 readonly selected: T[];
8 readonly noneSelected: boolean;
9 readonly allSelected: boolean;
10 readonly partiallySelected: boolean;
11 readonly setSelected: import("react").Dispatch<import("react").SetStateAction<T[]>>;
12 readonly isSelected: (item: T) => boolean;
13 readonly select: (item: T) => void;
14 readonly unSelect: (item: T) => void;
15 readonly toggle: (item: T) => void;
16 readonly selectAll: () => void;
17 readonly unSelectAll: () => void;
18 readonly clearAll: () => void;
19 readonly toggleAll: () => void;
20};