From 569a9c76fdf4fd8aed280bebaa6da0e64f93e892 Mon Sep 17 00:00:00 2001 From: Ankith Konda Date: Thu, 14 Mar 2019 07:48:40 +1000 Subject: [PATCH] mui-datatables - Add missing types for arguments of customToolbarSelect (#33836) * Add types for custom selected toolbar args * Fix lint errors * remove whitespaces --- types/mui-datatables/index.d.ts | 10 +++++++++- types/mui-datatables/mui-datatables-tests.tsx | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/types/mui-datatables/index.d.ts b/types/mui-datatables/index.d.ts index 1bdf9fc07f..1be1289ac6 100644 --- a/types/mui-datatables/index.d.ts +++ b/types/mui-datatables/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for mui-datatables 2.0 // Project: https://github.com/gregnb/mui-datatables // Definitions by: Jeroen "Favna" Claassens +// Ankith Konda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -122,7 +123,14 @@ export interface MUIDataTableOptions { expandableRows?: boolean; renderExpandableRow?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => React.ReactNode; customToolbar?: () => React.ReactNode; - customToolbarSelect?: () => React.ReactNode; + customToolbarSelect?: ( + selectedRows: { + data: Array<{ index: number; dataIndex: number }>; + lookup: { [key: number]: boolean }; + }, + displayData: Array<{ data: any[]; dataIndex: number }>, + setSelectedRows: (rows: number[]) => void + ) => React.ReactNode; customFooter?: () => React.ReactNode; customSort?: (data: any[], colIndex: number, order: string) => any[]; elevation?: number; diff --git a/types/mui-datatables/mui-datatables-tests.tsx b/types/mui-datatables/mui-datatables-tests.tsx index c6a477ea08..7fd89a488b 100644 --- a/types/mui-datatables/mui-datatables-tests.tsx +++ b/types/mui-datatables/mui-datatables-tests.tsx @@ -25,6 +25,21 @@ class MuiCustomTable extends React.Component { separator: ',' }, sortFilterList: false, + customToolbarSelect: (selectedRows, displayData, setSelectedRows) => { + return ( + + Custom Selected Toolbar:{' '} + {`${selectedRows.data.length} - ${JSON.stringify(displayData[0])}`} + + + ); + }, textLabels: { body: { noMatch: 'Sorry, no matching records found',