From 1180f3973af2ef648954249adfa4ae4ff7329514 Mon Sep 17 00:00:00 2001 From: Grzegorz Rozdzialik Date: Sun, 25 Nov 2018 19:41:27 +0100 Subject: [PATCH] [react-table] fix select table props, add tests --- types/react-table/index.d.ts | 6 ++++- types/react-table/lib/hoc/selectTable.d.ts | 6 ++--- types/react-table/test/select-table-tests.tsx | 27 +++++++++++++++++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/types/react-table/index.d.ts b/types/react-table/index.d.ts index d6b1679edd..b7192d3064 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'; diff --git a/types/react-table/lib/hoc/selectTable.d.ts b/types/react-table/lib/hoc/selectTable.d.ts index a128e221fa..fd6d9bf42c 100644 --- a/types/react-table/lib/hoc/selectTable.d.ts +++ b/types/react-table/lib/hoc/selectTable.d.ts @@ -37,10 +37,8 @@ export interface SelectTableAdditionalProps { */ selectType?: SelectType; - SelectInputComponent?: ComponentType>; - SelectAllInputComponent?: ComponentType< - Partial - >; + SelectInputComponent?: 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' }];