UNPKG

@ackplus/react-tanstack-data-table

Version:

A powerful React data table component built with MUI and TanStack Table

47 lines (46 loc) 1.71 kB
import { TableFeature, RowData, Updater, Row } from '@tanstack/react-table'; export interface SelectionState { ids: string[]; type: 'include' | 'exclude'; selectMode?: 'page' | 'all'; } export type IsRowSelectableFunction<T = any> = (params: { row: T; id: string; }) => boolean; export type SelectMode = 'page' | 'all'; export interface CustomSelectionOptions { enableCustomSelection?: boolean; selectMode?: SelectMode; isRowSelectable?: IsRowSelectableFunction; onSelectionStateChange?: (updater: Updater<SelectionState>) => void; } export interface CustomSelectionTableState { selectionState: SelectionState; } declare module '@tanstack/table-core' { interface TableState extends CustomSelectionTableState { } interface TableOptionsResolved<TData extends RowData> extends CustomSelectionOptions { } interface Table<TData extends RowData> extends CustomSelectionInstance<TData> { } } export interface CustomSelectionInstance<TData extends RowData> { setSelectionState: (updater: Updater<SelectionState>) => void; toggleAllRowsSelected: () => void; toggleRowSelected: (rowId: string) => void; selectRow: (rowId: string) => void; deselectRow: (rowId: string) => void; selectAll: () => void; deselectAll: () => void; getIsAllRowsSelected: () => boolean; getIsSomeRowsSelected: () => boolean; getIsRowSelected: (rowId: string) => boolean; getSelectionState: () => SelectionState; getSelectedCount: () => number; getSelectedRows: () => Row<TData>[]; getSelectedRowIds: () => string[]; canSelectRow: (rowId: string) => boolean; } export declare const CustomSelectionFeature: TableFeature<any>;