mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
[react-table] fix select table props, add tests
This commit is contained in:
Vendored
+5
-1
@@ -1,6 +1,10 @@
|
||||
// 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>, Andy S <https://github.com/andys8>
|
||||
// Definitions by: Roy Xue <https://github.com/royxue>,
|
||||
// Pavel Sakalo <https://github.com/psakalo>,
|
||||
// Krzysztof Porębski <https://github.com/Havret>,
|
||||
// Andy S <https://github.com/andys8>,
|
||||
// Grzegorz Rozdzialik <https://github.com/Gelio>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
import * as React from 'react';
|
||||
|
||||
+2
-4
@@ -37,10 +37,8 @@ export interface SelectTableAdditionalProps {
|
||||
*/
|
||||
selectType?: SelectType;
|
||||
|
||||
SelectInputComponent?: ComponentType<Partial<SelectInputComponentProps>>;
|
||||
SelectAllInputComponent?: ComponentType<
|
||||
Partial<SelectAllInputComponentProps>
|
||||
>;
|
||||
SelectInputComponent?: ComponentType<SelectInputComponentProps>;
|
||||
SelectAllInputComponent?: ComponentType<SelectAllInputComponentProps>;
|
||||
}
|
||||
|
||||
export interface SelectTableHOCOptions {
|
||||
|
||||
@@ -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<SelectInputComponentProps> = ({
|
||||
onClick,
|
||||
id,
|
||||
checked,
|
||||
row
|
||||
}) => (
|
||||
<input
|
||||
type="checkbox"
|
||||
onClick={e => onClick(id, e.shiftKey, row)}
|
||||
checked={checked}
|
||||
/>
|
||||
);
|
||||
|
||||
const SelectAllInput: React.StatelessComponent<
|
||||
SelectAllInputComponentProps
|
||||
> = ({ onClick, checked }) => (
|
||||
<input type="checkbox" onClick={onClick} checked={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' }];
|
||||
|
||||
Reference in New Issue
Block a user