@ackplus/react-tanstack-data-table
Version:
A powerful React data table component built with MUI and TanStack Table
53 lines • 1.93 kB
TypeScript
/**
* Custom Selection Feature for TanStack Table
*
* This feature adds custom selection capabilities to TanStack Table
* following the official custom features pattern (same as CustomColumnFilterFeature)
*/
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 SelectionOptions {
enableAdvanceSelection?: boolean;
selectMode?: SelectMode;
isRowSelectable?: IsRowSelectableFunction;
onSelectionStateChange?: (updater: Updater<SelectionState>) => void;
}
export interface SelectionTableState {
selectionState: SelectionState;
}
declare module '@tanstack/react-table' {
interface TableState extends SelectionTableState {
}
interface TableOptionsResolved<TData extends RowData> extends SelectionOptions {
}
interface Table<TData extends RowData> extends SelectionInstance<TData> {
}
}
export interface SelectionInstance<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 SelectionFeature: TableFeature<any>;
//# sourceMappingURL=selection.feature.d.ts.map