Created
September 7, 2018 13:46
-
-
Save nidheeshdas/ebdb07d147d7ff89e09bb44fe822ba31 to your computer and use it in GitHub Desktop.
DTS for mui-datatables: makeshift yet usable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module "mui-datatables" { | |
import { ReactNode } from "react"; | |
export interface MUIDataTableColumn { | |
name: string | |
options?: MUIDataTableColumnOptions | |
} | |
export interface MUIDataTableColumnOptions { | |
display?: "true" | "false" | "excluded" | |
filter?: boolean | |
sort?: boolean | |
download?: boolean | |
customHeadRender?: (value, tableMeta, updateValue) => string | |
customBodyRender?: (value, tableMeta, updateValue) => string | ReactNode | |
} | |
export interface MUIDataTableOptions { | |
page?: number | |
count?: number | |
serverSide?: boolean | |
filterList?: any[] | |
rowsSelected?: any[] | |
filterType?: string | |
textLabels?: object | |
pagination?: boolean | |
selectableRows?: boolean | |
resizableColumns?: boolean | |
customToolbar?: () => ReactNode | |
customToolbarSelect?: () => ReactNode | |
customFooter?: () => ReactNode | |
caseSensitive?: boolean | |
responsive?: string | |
rowsPerPage?: number | |
rowsPerPageOptions?: number[] | |
rowHover?: boolean | |
sortFilterList?: boolean | |
sort?: boolean | |
filter?: boolean | |
search?: boolean | |
print?: boolean | |
download?: boolean | |
downloadOptions?: { filename: string, separator: string } | |
viewColumns?: boolean | |
onRowsSelect?: (currentRowsSelected: any[], rowsSelected: any[]) => void | |
onRowsDelete?: (rowsDeleted: any[]) => void | |
onRowClick?: (rowData: string[], rowMeta: { dataIndex: number, rowIndex: number }) => void | |
onCellClick?: (colIndex: number, rowIndex: number) => void | |
onChangePage?: (currentPage: number) => void | |
onChangeRowsPerPage?: (numberOfRows: number) => void | |
onSearchChange?: (searchText: string) => void | |
onFilterChange?: (changedColumn: string, filterList: any[]) => void | |
onColumnSortChange?: (changedColumn: string, direction: string) => void | |
onColumnViewChange?: (changedColumn: string, action: string) => void | |
onServerRequest?: (action: string, tableState: MuiDatatablesTableState) => void | |
} | |
export interface MuiDatatablesTableState { | |
page: number | |
rowsPerPage: number | |
filterList: any[] | |
} | |
export type MUIDataTableColumnDef = string | MUIDataTableColumn; | |
export interface MUIDataTableProps { | |
title: string | |
columns: MUIDataTableColumnDef[] | |
data: any[] | |
options?: MUIDataTableOptions | |
} | |
export const MUIDataTable: React.ComponentType<MUIDataTableProps>; | |
export default MUIDataTable; | |
} |
great job, just what I was looking for, thanks!
I am getting below exception
warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Any idea ?
This should be deprecated in favor of @types/mui-datatables. I took this gist as a basis and updated it to be proper for the latest published version of mui-datatables (2.0.0-beta-53 at time of writing) as well as DefinitetlyTyped standards.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 15 and 16 throw a compile error due to the function params implicitly having "any" type. I went ahead and set them explicitly to "any" in my copy since the project readme doesn't mention their types.