|
|
|
import * as React from 'react';
|
|
|
|
import { SpinProps } from '../spin';
|
|
|
|
import { Store } from './createStore';
|
|
|
|
import { RadioChangeEvent } from '../radio';
|
|
|
|
import { CheckboxChangeEvent } from '../checkbox';
|
|
|
|
import { PaginationConfig } from '../pagination';
|
|
|
|
export { PaginationConfig } from '../pagination';
|
|
|
|
|
|
|
|
export type CompareFn<T> = ((a: T, b: T, sortOrder?: SortOrder) => number);
|
|
|
|
export type ColumnFilterItem = { text: string; value: string; children?: ColumnFilterItem[] };
|
|
|
|
|
|
|
|
export interface ColumnProps<T> {
|
|
|
|
title?:
|
|
|
|
| React.ReactNode
|
|
|
|
| ((
|
|
|
|
options: {
|
|
|
|
filters: TableStateFilters;
|
|
|
|
sortOrder?: SortOrder;
|
|
|
|
},
|
|
|
|
) => React.ReactNode);
|
|
|
|
key?: React.Key;
|
|
|
|
dataIndex?: string; // Note: We can not use generic type here, since we need to support nested key, see #9393
|
|
|
|
render?: (text: any, record: T, index: number) => React.ReactNode;
|
|
|
|
align?: 'left' | 'right' | 'center';
|
|
|
|
filters?: ColumnFilterItem[];
|
|
|
|
onFilter?: (value: any, record: T) => boolean;
|
|
|
|
filterMultiple?: boolean;
|
|
|
|
filterDropdown?: React.ReactNode | ((props: Object) => React.ReactNode);
|
|
|
|
filterDropdownVisible?: boolean;
|
|
|
|
onFilterDropdownVisibleChange?: (visible: boolean) => void;
|
|
|
|
sorter?: boolean | CompareFn<T>;
|
|
|
|
defaultSortOrder?: SortOrder;
|
|
|
|
colSpan?: number;
|
|
|
|
width?: string | number;
|
|
|
|
className?: string;
|
|
|
|
fixed?: boolean | ('left' | 'right');
|
|
|
|
filterIcon?: React.ReactNode | ((filtered: boolean) => React.ReactNode);
|
|
|
|
filteredValue?: any[];
|
|
|
|
sortOrder?: SortOrder;
|
|
|
|
children?: ColumnProps<T>[];
|
|
|
|
onCellClick?: (record: T, event: any) => void;
|
|
|
|
onCell?: (record: T, rowIndex: number) => any;
|
|
|
|
onHeaderCell?: (props: ColumnProps<T>) => any;
|
|
|
|
sortDirections?: SortOrder[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AdditionalCellProps {
|
|
|
|
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
|
|
[name: string]: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface TableComponents {
|
|
|
|
table?: React.ReactType;
|
|
|
|
header?: {
|
|
|
|
wrapper?: React.ReactType;
|
|
|
|
row?: React.ReactType;
|
|
|
|
cell?: React.ReactType;
|
|
|
|
};
|
|
|
|
body?: {
|
|
|
|
wrapper?: React.ReactType;
|
|
|
|
row?: React.ReactType;
|
|
|
|
cell?: React.ReactType;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface TableLocale {
|
|
|
|
filterTitle?: string;
|
|
|
|
filterConfirm?: React.ReactNode;
|
|
|
|
filterReset?: React.ReactNode;
|
|
|
|
emptyText?: React.ReactNode | (() => React.ReactNode);
|
|
|
|
selectAll?: React.ReactNode;
|
|
|
|
selectInvert?: React.ReactNode;
|
|
|
|
sortTitle?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type RowSelectionType = 'checkbox' | 'radio';
|
|
|
|
export type SelectionSelectFn<T> = (
|
|
|
|
record: T,
|
|
|
|
selected: boolean,
|
|
|
|
selectedRows: Object[],
|
|
|
|
nativeEvent: Event,
|
|
|
|
) => any;
|
|
|
|
|
|
|
|
export type TableSelectWay = 'onSelect' | 'onSelectMultiple' | 'onSelectAll' | 'onSelectInvert';
|
|
|
|
|
|
|
|
export interface TableRowSelection<T> {
|
|
|
|
type?: RowSelectionType;
|
|
|
|
selectedRowKeys?: string[] | number[];
|
|
|
|
onChange?: (selectedRowKeys: string[] | number[], selectedRows: T[]) => void;
|
|
|
|
getCheckboxProps?: (record: T) => Object;
|
|
|
|
onSelect?: SelectionSelectFn<T>;
|
|
|
|
onSelectMultiple?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
|
|
|
onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
|
|
|
onSelectInvert?: (selectedRowKeys: string[] | number[]) => void;
|
|
|
|
selections?: SelectionItem[] | boolean;
|
|
|
|
hideDefaultSelections?: boolean;
|
|
|
|
fixed?: boolean;
|
|
|
|
columnWidth?: string | number;
|
|
|
|
selectWay?: TableSelectWay;
|
|
|
|
columnTitle?: string | React.ReactNode;
|
|
|
|
}
|
|
|
|
export type SortOrder = 'descend' | 'ascend';
|
|
|
|
export interface SorterResult<T> {
|
|
|
|
column: ColumnProps<T>;
|
|
|
|
order: SortOrder;
|
|
|
|
field: string;
|
|
|
|
columnKey: string;
|
|
|
|
}
|
|
|