diff --git a/types/react-table/index.d.ts b/types/react-table/index.d.ts index d6b1679edd..1afb6eb0fd 100644 --- a/types/react-table/index.d.ts +++ b/types/react-table/index.d.ts @@ -1,6 +1,10 @@ // Type definitions for react-table 6.7 // Project: https://github.com/react-tools/react-table -// Definitions by: Roy Xue , Pavel Sakalo , Krzysztof Porębski , Andy S +// Definitions by: Roy Xue , +// Pavel Sakalo , +// Krzysztof Porębski , +// Andy S , +// Grzegorz Rozdzialik // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as React from 'react'; @@ -46,7 +50,7 @@ export interface SortingRule { desc?: true; } -export interface TableProps extends +export interface TableProps extends Partial, Partial, Partial, @@ -56,6 +60,8 @@ export interface TableProps extends /** Default: [] */ data: D[]; + resolveData?: (data: D[]) => ResolvedData[]; + /** Default: false */ loading: boolean; @@ -164,7 +170,7 @@ export interface TableProps extends column: Partial; /** Array of all Available Columns */ - columns?: Array>; + columns?: Array>; /** Expander defaults. */ expanderDefaults: Partial; @@ -180,9 +186,9 @@ export interface TableProps extends /** Control callback for functional rendering */ children: ( - state: FinalState, + state: FinalState, makeTable: () => React.ReactElement, - instance: Instance + instance: Instance ) => React.ReactNode; } diff --git a/types/react-table/lib/hoc/selectTable.d.ts b/types/react-table/lib/hoc/selectTable.d.ts index d70d84eb78..fd6d9bf42c 100644 --- a/types/react-table/lib/hoc/selectTable.d.ts +++ b/types/react-table/lib/hoc/selectTable.d.ts @@ -12,7 +12,7 @@ export interface SelectInputComponentProps { row: any; } -export interface SelectAllInputComponent { +export interface SelectAllInputComponentProps { selectType: SelectType; checked: boolean; onClick: () => any; @@ -28,7 +28,7 @@ export interface SelectTableAdditionalProps { selectAll?: boolean; - toggleAll?: SelectAllInputComponent['onClick']; + toggleAll?: SelectAllInputComponentProps['onClick']; toggleSelection?: SelectInputComponentProps['onClick']; @@ -38,7 +38,7 @@ export interface SelectTableAdditionalProps { selectType?: SelectType; SelectInputComponent?: ComponentType; - SelectAllInputComponent?: ComponentType; + SelectAllInputComponent?: ComponentType; } export interface SelectTableHOCOptions { diff --git a/types/react-table/test/select-table-tests.tsx b/types/react-table/test/select-table-tests.tsx index 1a1b231292..a4ed4d4f25 100644 --- a/types/react-table/test/select-table-tests.tsx +++ b/types/react-table/test/select-table-tests.tsx @@ -3,18 +3,41 @@ import * as ReactDOM from 'react-dom'; import ReactTable, { Column } from 'react-table'; import selectTableHOC, { - SelectTableAdditionalProps + SelectTableAdditionalProps, + SelectInputComponentProps, + SelectAllInputComponentProps } from 'react-table/lib/hoc/selectTable'; const SelectTable = selectTableHOC(ReactTable); +const SelectInput: React.StatelessComponent = ({ + onClick, + id, + checked, + row +}) => ( + onClick(id, e.shiftKey, row)} + checked={checked} + /> +); + +const SelectAllInput: React.StatelessComponent< + SelectAllInputComponentProps +> = ({ onClick, checked }) => ( + +); + const selectTableAdditionalProps: SelectTableAdditionalProps = { isSelected: () => true, keyField: 'id', selectAll: true, selectType: 'checkbox', toggleAll: () => null, - toggleSelection: () => null + toggleSelection: () => null, + SelectInputComponent: SelectInput, + SelectAllInputComponent: SelectAllInput }; const data = [{ id: 1, name: 'Foo' }, { id: 2, name: 'Bar' }];