[react-table] add typings for selectTableHOC and treeTableHOC

This commit is contained in:
Grzegorz Rozdzialik
2018-10-27 13:11:41 +02:00
parent 33937378a6
commit b4fad1da94
4 changed files with 69 additions and 1 deletions
+4 -1
View File
@@ -1,6 +1,9 @@
// Type definitions for react-table 6.7
// Project: https://github.com/react-tools/react-table
// Definitions by: Roy Xue <https://github.com/royxue>, Pavel Sakalo <https://github.com/psakalo>, Krzysztof Porębski <https://github.com/Havret>
// Definitions by: Roy Xue <https://github.com/royxue>
// Pavel Sakalo <https://github.com/psakalo>
// Krzysztof Porębski <https://github.com/Havret>
// Grzegorz Rozdzialik <https://github.com/Gelio>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
+5
View File
@@ -0,0 +1,5 @@
import { ComponentType } from 'react';
type HOC<OwnProps, AdditionalProps> = <Props extends OwnProps>(
Component: ComponentType<Props>
) => ComponentType<Props & AdditionalProps>;
+50
View File
@@ -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<SelectInputComponentProps>;
SelectAllInputComponent?: ComponentType<SelectAllInputComponent>;
}
declare const selectTableHOC: HOC<
Partial<TableProps>,
SelectTableAdditionalProps
>;
export default selectTableHOC;
+10
View File
@@ -0,0 +1,10 @@
import { ComponentType } from 'react';
import { TableProps } from '../../index';
import { HOC } from './hoc-type';
interface TreeTableAdditionalProps {}
declare const treeTableHOC: HOC<Partial<TableProps>, TreeTableAdditionalProps>;
export default treeTableHOC;