UNPKG

@commercetools-uikit/hooks

Version:

A collection of React hooks used across some of the UI-Kit components.

34 lines (33 loc) 814 B
export interface TRowItem { id: string; } export type TSelectionState = { [id: string]: boolean; }; export type TSelectionAction = { type: 'toggle'; payload: string; } | { type: 'select'; payload: string; } | { type: 'deselect'; payload: string; } | { type: 'selectAll'; } | { type: 'deselectAll'; }; declare const useRowSelection: <RowItem extends TRowItem = TRowItem>(keyName: string, rows: RowItem[]) => { rows: (RowItem & { [x: string]: boolean; })[]; toggleRow: (id: string) => void; selectRow: (id: string) => void; deselectRow: (id: string) => void; selectAllRows: () => void; deselectAllRows: () => void; getIsRowSelected: (id: string) => boolean; getNumberOfSelectedRows: () => number; }; export default useRowSelection;