Skip to content

Commit

Permalink
Fix implicit any error for Table
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Nov 21, 2017
1 parent 8260e32 commit 5cb5a2a
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 252 deletions.
4 changes: 2 additions & 2 deletions components/pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import Select from '../select';
import MiniSelect from './MiniSelect';

export interface PaginationProps {
total: number;
total?: number;
defaultCurrent?: number;
current?: number;
defaultPageSize?: number;
pageSize?: number;
onChange?: (page: number, pageSize: number) => void;
onChange?: (page: number, pageSize?: number) => void;
showSizeChanger?: boolean;
pageSizeOptions?: string[];
onShowSizeChange?: (current: number, size: number) => void;
Expand Down
26 changes: 1 addition & 25 deletions components/table/Column.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
import * as React from 'react';

export interface ColumnProps<T> {
title?: React.ReactNode;
key?: string;
dataIndex?: string;
render?: (text: any, record: T, index: number) => React.ReactNode;
filters?: { text: string; value: string, children?: any[] }[];
onFilter?: (value: any, record: T) => boolean;
filterMultiple?: boolean;
filterDropdown?: React.ReactNode;
filterDropdownVisible?: boolean;
onFilterDropdownVisibleChange?: (visible: boolean) => void;
sorter?: boolean | ((a: any, b: any) => number);
defaultSortOrder?: 'ascend' | 'descend';
colSpan?: number;
width?: string | number;
className?: string;
fixed?: boolean | ('left' | 'right');
filterIcon?: React.ReactNode;
filteredValue?: any[];
sortOrder?: boolean | ('ascend' | 'descend');
children?: ColumnProps<T>[];
onCellClick?: (record: T, event: any) => void;
onCell?: (record: T) => any;
}
import { ColumnProps } from './interface';

export default class Column<T> extends React.Component<ColumnProps<T>, React.ComponentState> {}
17 changes: 4 additions & 13 deletions components/table/SelectionBox.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
import * as React from 'react';
import Checkbox from '../checkbox';
import Radio from '../radio';
import { Store } from './createStore';
import { SelectionBoxProps, SelectionBoxState } from './interface';

export interface SelectionBoxProps {
store: Store;
type: string;
defaultSelection: string[];
rowIndex: string;
disabled?: boolean;
onChange: (e) => void;
}

export default class SelectionBox extends React.Component<SelectionBoxProps, any> {
export default class SelectionBox extends React.Component<SelectionBoxProps, SelectionBoxState> {
unsubscribe: () => void;

constructor(props) {
constructor(props: SelectionBoxProps) {
super(props);

this.state = {
Expand All @@ -41,7 +32,7 @@ export default class SelectionBox extends React.Component<SelectionBoxProps, any
});
}

getCheckState(props) {
getCheckState(props: SelectionBoxProps) {
const { store, defaultSelection, rowIndex } = props;
let checked = false;
if (store.getState().selectionDirty) {
Expand Down
43 changes: 12 additions & 31 deletions components/table/SelectionCheckboxAll.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
import * as React from 'react';
import Checkbox from '../checkbox';
import { Store } from './createStore';
import Dropdown from '../dropdown';
import Menu from '../menu';
import Icon from '../icon';
import classNames from 'classnames';
import { SelectionCheckboxAllProps, SelectionCheckboxAllState, SelectionItem } from './interface';

export interface SelectionDecorator {
key: string;
text: React.ReactNode;
onSelect: (changeableRowKeys: string[]) => void;
}

export interface SelectionCheckboxAllProps {
store: Store;
locale: any;
disabled: boolean;
getCheckboxPropsByItem: (item: any, index: number) => any;
getRecordKey: (record: any, index?: number) => string;
data: any[];
prefixCls: string | undefined;
onSelect: (key: string, index: number, selectFunc: any) => void;
hideDefaultSelections?: boolean;
selections?: SelectionDecorator[] | boolean;
getPopupContainer: (triggerNode?: Element) => HTMLElement;
}

export default class SelectionCheckboxAll extends React.Component<SelectionCheckboxAllProps, any> {
export default class SelectionCheckboxAll<T> extends
React.Component<SelectionCheckboxAllProps<T>, SelectionCheckboxAllState> {
unsubscribe: () => void;
defaultSelections: SelectionDecorator[];
defaultSelections: SelectionItem[];

constructor(props) {
constructor(props: SelectionCheckboxAllProps<T>) {
super(props);

this.defaultSelections = props.hideDefaultSelections ? [] : [{
Expand All @@ -53,7 +34,7 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
this.subscribe();
}

componentWillReceiveProps(nextProps) {
componentWillReceiveProps(nextProps: SelectionCheckboxAllProps<T>) {
this.setCheckState(nextProps);
}

Expand All @@ -70,7 +51,7 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
});
}

checkSelection(data, type, byDefaultChecked) {
checkSelection(data: T[], type: string, byDefaultChecked: boolean) {
const { store, getCheckboxPropsByItem, getRecordKey } = this.props;
// type should be 'every' | 'some'
if (type === 'every' || type === 'some') {
Expand All @@ -84,7 +65,7 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
return false;
}

setCheckState(props) {
setCheckState(props: SelectionCheckboxAllProps<T>) {
const checked = this.getCheckState(props);
const indeterminate = this.getIndeterminateState(props);
if (checked !== this.state.checked) {
Expand All @@ -95,7 +76,7 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
}
}

getCheckState(props) {
getCheckState(props: SelectionCheckboxAllProps<T>) {
const { store, data } = props;
let checked;
if (!data.length) {
Expand All @@ -112,7 +93,7 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
return checked;
}

getIndeterminateState(props) {
getIndeterminateState(props: SelectionCheckboxAllProps<T>) {
const { store, data } = props;
let indeterminate;
if (!data.length) {
Expand All @@ -132,12 +113,12 @@ export default class SelectionCheckboxAll extends React.Component<SelectionCheck
return indeterminate;
}

handleSelectAllChagne = (e) => {
handleSelectAllChagne = (e: React.ChangeEvent<HTMLInputElement>) => {
let checked = e.target.checked;
this.props.onSelect(checked ? 'all' : 'removeAll', 0, null);
}

renderMenus(selections: SelectionDecorator[]) {
renderMenus(selections: SelectionItem[]) {
return selections.map((selection, index) => {
return (
<Menu.Item
Expand Down
Loading

0 comments on commit 5cb5a2a

Please sign in to comment.