From b4fad1da940bff44921573238f3e9e2ecb1cf77c Mon Sep 17 00:00:00 2001 From: Grzegorz Rozdzialik Date: Fri, 26 Oct 2018 22:45:27 +0200 Subject: [PATCH] [react-table] add typings for selectTableHOC and treeTableHOC --- types/react-table/index.d.ts | 5 ++- types/react-table/lib/hoc/hoc-type.d.ts | 5 +++ types/react-table/lib/hoc/selectTable.d.ts | 50 ++++++++++++++++++++++ types/react-table/lib/hoc/treeTable.d.ts | 10 +++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 types/react-table/lib/hoc/hoc-type.d.ts create mode 100644 types/react-table/lib/hoc/selectTable.d.ts create mode 100644 types/react-table/lib/hoc/treeTable.d.ts diff --git a/types/react-table/index.d.ts b/types/react-table/index.d.ts index ca7981a6f8..90ad254134 100644 --- a/types/react-table/index.d.ts +++ b/types/react-table/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for react-table 6.7 // Project: https://github.com/react-tools/react-table -// Definitions by: Roy Xue , Pavel Sakalo , Krzysztof Porębski +// Definitions by: Roy Xue +// Pavel Sakalo +// Krzysztof Porębski +// 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/hoc-type.d.ts b/types/react-table/lib/hoc/hoc-type.d.ts new file mode 100644 index 0000000000..9970d07a5b --- /dev/null +++ b/types/react-table/lib/hoc/hoc-type.d.ts @@ -0,0 +1,5 @@ +import { ComponentType } from 'react'; + +type HOC = ( + Component: ComponentType +) => ComponentType; diff --git a/types/react-table/lib/hoc/selectTable.d.ts b/types/react-table/lib/hoc/selectTable.d.ts new file mode 100644 index 0000000000..59cf9d1f17 --- /dev/null +++ b/types/react-table/lib/hoc/selectTable.d.ts @@ -0,0 +1,50 @@ +import { ComponentType } from 'react'; + +import { TableProps } from '../../index'; +import { HOC } from './hoc-type'; + +export type SelectType = 'checkbox' | 'radio'; + +export interface SelectInputComponentProps { + selectType: SelectType; + onClick: (key: string, shiftKeyPressed: boolean, row: any) => any; + checked: boolean; + id: string; + row: any; +} + +export interface SelectAllInputComponent { + selectType: SelectType; + checked: boolean; + onClick: () => any; +} + +export interface SelectTableAdditionalProps { + /** + * Default: _id + */ + keyField?: string; + + isSelected?: (key: string) => boolean; + + selectAll?: boolean; + + toggleAll?: SelectAllInputComponent['onClick']; + + toggleSelection?: SelectInputComponentProps['onClick']; + + /** + * Default: checkbox + */ + selectType?: SelectType; + + SelectInputComponent?: ComponentType; + SelectAllInputComponent?: ComponentType; +} + +declare const selectTableHOC: HOC< + Partial, + SelectTableAdditionalProps +>; + +export default selectTableHOC; diff --git a/types/react-table/lib/hoc/treeTable.d.ts b/types/react-table/lib/hoc/treeTable.d.ts new file mode 100644 index 0000000000..2f91951789 --- /dev/null +++ b/types/react-table/lib/hoc/treeTable.d.ts @@ -0,0 +1,10 @@ +import { ComponentType } from 'react'; + +import { TableProps } from '../../index'; +import { HOC } from './hoc-type'; + +interface TreeTableAdditionalProps {} + +declare const treeTableHOC: HOC, TreeTableAdditionalProps>; + +export default treeTableHOC;