From 4da85408118c3f286fb934b2c9403d7245104cd2 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Thu, 24 Sep 2020 19:21:14 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Merge=20PR=20#48152=20Update=20`?= =?UTF-8?q?mui-datatables`=20declarations=20with=20missing/incorrect=20typ?= =?UTF-8?q?ings=20by=20@Patrick-Erichsen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick-Erichsen --- types/mui-datatables/index.d.ts | 38 +++++++++++++------ types/mui-datatables/mui-datatables-tests.tsx | 1 - 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/types/mui-datatables/index.d.ts b/types/mui-datatables/index.d.ts index ecafa43d1b..2d841d705c 100644 --- a/types/mui-datatables/index.d.ts +++ b/types/mui-datatables/index.d.ts @@ -6,6 +6,7 @@ // souppower // Byron "Byrekt" Mitchell // Bohdan Yavorskyi +// Patrick Erichsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.5 @@ -47,7 +48,7 @@ export interface MUIDataTableState { data: any[]; displayData: Array<{ dataIndex: number; data: any[] }>; expandedRows: MUIDataTableStateRows; - filterData: any[]; + filterData: string[][]; filterList: string[][]; page: number; previousSelectedRow: null | { index: number; dataIndex: number }; @@ -138,7 +139,13 @@ export interface MUIDataTableFilterOptions { * `filterList` must be of the same type in the main column options, that is an array of arrays, where each array corresponds to the filter list for a given column. * {@link https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js Example} */ - display?: (filterList: string[], onChange: any, index: number, column: any) => void; + display?: ( + filterList: MUIDataTableState['filterList'], + onChange: (val: string | string[], index: number, column: MUIDataTableColumn) => void, + index: number, + column: MUIDataTableColumn, + filterData: MUIDataTableState['filterData'], + ) => void; /** * custom filter logic. * {@link https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js Example} @@ -167,7 +174,7 @@ export interface MUIDataTableColumnState extends MUIDataTableColumnOptions { export interface MUIDataTableColumnOptions { customBodyRender?: ( - value: any, + value: string, tableMeta: MUIDataTableMeta, updateValue: (value: string) => void, ) => string | React.ReactNode; @@ -219,7 +226,10 @@ export type MUIDataTableOptions = Partial<{ caseSensitive: boolean; confirmFilters: boolean; count: number; - customFilterDialogFooter: (filterList: any[], applyNewFilters?: (...args: any[]) => any) => React.ReactNode; + customFilterDialogFooter: ( + filterList: MUIDataTableState['filterList'], + applyNewFilters?: (...args: any[]) => any, + ) => React.ReactNode; customFooter: ( rowCount: number, page: number, @@ -290,18 +300,22 @@ export type MUIDataTableOptions = Partial<{ columns: any, data: any, ) => string | boolean; - onFilterChange: (changedColumn: string, filterList: any[], type: FilterType | 'chip' | 'reset') => void; + onFilterChange: ( + changedColumn: string | MUIDataTableColumn | null, + filterList: MUIDataTableState['filterList'], + type: FilterType | 'chip' | 'reset', + ) => void; /** * Callback function that is triggered when a user clicks the "X" on a filter chip. * {@link https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-filters/index.js Example} */ - onFilterChipClose: (index: number, removedFilter: string, filterList: any[]) => void; + onFilterChipClose: (index: number, removedFilter: string, filterList: MUIDataTableState['filterList']) => void; /** * Callback function that is triggered when a user presses the "confirm" button on the filter popover. * This occurs only if you've set `confirmFilters` option to `true`. * {@link https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-filters/index.js Example} */ - onFilterConfirm: (filterList: any[]) => void; + onFilterConfirm: (filterList: MUIDataTableState['filterList']) => void; onFilterDialogClose: () => void; onFilterDialogOpen: () => void; onRowClick: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => void; @@ -311,7 +325,7 @@ export type MUIDataTableOptions = Partial<{ data: Array<{ index: number; dataIndex: number }>; }) => void; onRowSelectionChange: (currentRowsSelected: any[], allRowsSelected: any[], rowsSelected?: any[]) => void; - onSearchChange: (searchText: string) => void; + onSearchChange: (searchText: string | null) => void; onSearchClose: () => void; onSearchOpen: () => void; onTableChange: (action: string, tableState: MUIDataTableState) => void; @@ -390,7 +404,7 @@ export interface MUIDataTableBody { columns: MUIDataTableColumnDef[]; count: number; data: Array; - filterList?: string[][]; + filterList?: MUIDataTableState['filterList']; onRowClick?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => void; options: MUIDataTableOptions; searchText?: string; @@ -433,7 +447,7 @@ export interface MUIDataTableBodyRow { export interface MUIDataTableFilter { classes?: object; filterData: any[]; - filterList?: string[][]; + filterList?: MUIDataTableState['filterList']; onFilterRest?: (...args: any) => any; onFilterUpdate?: (...args: any) => any; options: MUIDataTableOptions; @@ -443,7 +457,7 @@ export interface MUIDataTableFilterList { columnNames?: Array<{ name: string; filterType: FilterType }>; customFilterListUpdate?: any[]; classes?: object; - filterList: string[][]; + filterList: MUIDataTableState['filterList']; filterListRenderers?: (e: any) => any[]; filterUpdate?: (...args: any) => any; options: MUIDataTableOptions; @@ -551,7 +565,7 @@ export interface MUIDataTableToolbar { data?: MUIDataTableData[]; displayData?: Array<{ data: any[]; dataIndex: number }>; filterData?: any[][]; - filterList?: string[][]; + filterList?: MUIDataTableState['filterList']; filterUpdate?: (...args: any) => any; updateFilterByType?: (...args: any) => any; options?: MUIDataTableOptions; diff --git a/types/mui-datatables/mui-datatables-tests.tsx b/types/mui-datatables/mui-datatables-tests.tsx index f8a280e5b0..5132e22f01 100644 --- a/types/mui-datatables/mui-datatables-tests.tsx +++ b/types/mui-datatables/mui-datatables-tests.tsx @@ -1,7 +1,6 @@ import MUIDataTable, { MUIDataTableColumn, MUIDataTableOptions, - MUIDataTableTextLabels, MUIDataTableProps, } from 'mui-datatables'; import * as React from 'react';