2020-02-29 23:11:02 +08:00
|
|
|
import {
|
|
|
|
GetRowKey,
|
|
|
|
ColumnType as RcColumnType,
|
|
|
|
RenderedCell as RcRenderedCell,
|
|
|
|
ExpandableConfig,
|
|
|
|
} from 'rc-table/lib/interface';
|
2019-11-15 14:35:25 +08:00
|
|
|
import { CheckboxProps } from '../checkbox';
|
2020-04-27 23:45:14 +08:00
|
|
|
import { PaginationProps } from '../pagination';
|
2020-04-24 12:17:42 +08:00
|
|
|
import { Breakpoint } from '../_util/responsiveObserve';
|
2020-04-22 21:59:18 +08:00
|
|
|
import { INTERNAL_SELECTION_ITEM } from './hooks/useSelection';
|
2020-04-26 16:25:42 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export { GetRowKey, ExpandableConfig };
|
2019-08-05 18:38:10 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type Key = React.Key;
|
2017-11-21 13:48:37 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type RowSelectionType = 'checkbox' | 'radio';
|
2019-05-07 11:53:08 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type SelectionItemSelectFn = (currentRowKeys: Key[]) => void;
|
2017-11-21 13:48:37 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type ExpandType = null | 'row' | 'nest';
|
2017-11-21 13:48:37 +08:00
|
|
|
|
|
|
|
export interface TableLocale {
|
|
|
|
filterTitle?: string;
|
2018-01-11 23:13:42 +08:00
|
|
|
filterConfirm?: React.ReactNode;
|
|
|
|
filterReset?: React.ReactNode;
|
|
|
|
emptyText?: React.ReactNode | (() => React.ReactNode);
|
|
|
|
selectAll?: React.ReactNode;
|
|
|
|
selectInvert?: React.ReactNode;
|
2019-11-15 14:35:25 +08:00
|
|
|
selectionAll?: React.ReactNode;
|
2018-09-17 17:57:01 +08:00
|
|
|
sortTitle?: string;
|
2019-07-22 19:28:23 +08:00
|
|
|
expand?: string;
|
|
|
|
collapse?: string;
|
2020-02-29 22:01:13 +08:00
|
|
|
triggerDesc?: string;
|
|
|
|
triggerAsc?: string;
|
|
|
|
cancelSort?: string;
|
2017-11-21 13:48:37 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type SortOrder = 'descend' | 'ascend' | null;
|
2018-05-07 12:32:26 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type CompareFn<T> = (a: T, b: T, sortOrder?: SortOrder) => number;
|
2019-01-17 13:44:15 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export interface ColumnFilterItem {
|
|
|
|
text: React.ReactNode;
|
2020-03-18 11:20:21 +08:00
|
|
|
value: string | number | boolean;
|
2019-11-15 14:35:25 +08:00
|
|
|
children?: ColumnFilterItem[];
|
2019-01-17 13:44:15 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export interface ColumnTitleProps<RecordType> {
|
|
|
|
/** @deprecated Please use `sorterColumns` instead. */
|
|
|
|
sortOrder?: SortOrder;
|
|
|
|
/** @deprecated Please use `sorterColumns` instead. */
|
|
|
|
sortColumn?: ColumnType<RecordType>;
|
|
|
|
sortColumns?: { column: ColumnType<RecordType>; order: SortOrder }[];
|
2019-06-16 20:51:47 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
filters?: Record<string, string[]>;
|
2019-08-28 02:35:39 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type ColumnTitle<RecordType> =
|
|
|
|
| React.ReactNode
|
|
|
|
| ((props: ColumnTitleProps<RecordType>) => React.ReactNode);
|
2019-08-28 02:35:39 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export interface FilterDropdownProps {
|
|
|
|
prefixCls: string;
|
2020-04-03 20:15:27 +08:00
|
|
|
setSelectedKeys: (selectedKeys: React.Key[]) => void;
|
2019-11-15 14:35:25 +08:00
|
|
|
selectedKeys: React.Key[];
|
|
|
|
confirm: () => void;
|
2019-11-25 15:16:59 +08:00
|
|
|
clearFilters?: () => void;
|
2019-11-15 14:35:25 +08:00
|
|
|
filters?: ColumnFilterItem[];
|
|
|
|
visible: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ColumnType<RecordType> extends RcColumnType<RecordType> {
|
|
|
|
title?: ColumnTitle<RecordType>;
|
|
|
|
|
|
|
|
// Sorter
|
|
|
|
sorter?:
|
|
|
|
| boolean
|
|
|
|
| CompareFn<RecordType>
|
|
|
|
| {
|
|
|
|
compare: CompareFn<RecordType>;
|
|
|
|
/** Config multiple sorter order priority */
|
|
|
|
multiple: number;
|
|
|
|
};
|
|
|
|
sortOrder?: SortOrder;
|
|
|
|
defaultSortOrder?: SortOrder;
|
2019-01-08 17:27:41 +08:00
|
|
|
sortDirections?: SortOrder[];
|
2020-02-29 22:01:13 +08:00
|
|
|
showSorterTooltip?: boolean;
|
2019-10-22 11:54:03 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
// Filter
|
2020-03-03 18:18:19 +08:00
|
|
|
filtered?: boolean;
|
2019-11-15 14:35:25 +08:00
|
|
|
filters?: ColumnFilterItem[];
|
|
|
|
filterDropdown?: React.ReactNode | ((props: FilterDropdownProps) => React.ReactNode);
|
|
|
|
filterMultiple?: boolean;
|
2019-11-25 15:16:59 +08:00
|
|
|
filteredValue?: Key[] | null;
|
2019-12-11 15:15:23 +08:00
|
|
|
defaultFilteredValue?: Key[] | null;
|
2019-11-15 14:35:25 +08:00
|
|
|
filterIcon?: React.ReactNode | ((filtered: boolean) => React.ReactNode);
|
2020-03-18 11:20:21 +08:00
|
|
|
onFilter?: (value: string | number | boolean, record: RecordType) => boolean;
|
2019-11-15 14:35:25 +08:00
|
|
|
filterDropdownVisible?: boolean;
|
|
|
|
onFilterDropdownVisibleChange?: (visible: boolean) => void;
|
2020-04-24 12:17:42 +08:00
|
|
|
|
|
|
|
// Responsive
|
|
|
|
responsive?: Breakpoint[];
|
2017-11-21 13:48:37 +08:00
|
|
|
}
|
|
|
|
|
2020-03-20 23:33:14 +08:00
|
|
|
export interface ColumnGroupType<RecordType> extends Omit<ColumnType<RecordType>, 'dataIndex'> {
|
2019-11-25 15:16:59 +08:00
|
|
|
children: ColumnsType<RecordType>;
|
2019-11-19 10:03:03 +08:00
|
|
|
}
|
|
|
|
|
2019-11-17 17:57:35 +08:00
|
|
|
export type ColumnsType<RecordType = unknown> = (
|
|
|
|
| ColumnGroupType<RecordType>
|
2019-12-25 19:09:17 +08:00
|
|
|
| ColumnType<RecordType>
|
|
|
|
)[];
|
2017-11-21 13:48:37 +08:00
|
|
|
|
|
|
|
export interface SelectionItem {
|
|
|
|
key: string;
|
|
|
|
text: React.ReactNode;
|
2019-09-28 16:20:19 +08:00
|
|
|
onSelect?: SelectionItemSelectFn;
|
2017-11-21 13:48:37 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type SelectionSelectFn<T> = (
|
|
|
|
record: T,
|
|
|
|
selected: boolean,
|
|
|
|
selectedRows: Object[],
|
|
|
|
nativeEvent: Event,
|
|
|
|
) => void;
|
2017-11-21 13:48:37 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export interface TableRowSelection<T> {
|
2017-11-21 13:48:37 +08:00
|
|
|
type?: RowSelectionType;
|
2019-11-15 14:35:25 +08:00
|
|
|
selectedRowKeys?: Key[];
|
|
|
|
onChange?: (selectedRowKeys: Key[], selectedRows: T[]) => void;
|
2020-03-19 23:58:25 +08:00
|
|
|
getCheckboxProps?: (record: T) => Partial<Omit<CheckboxProps, 'checked' | 'defaultChecked'>>;
|
2019-11-15 14:35:25 +08:00
|
|
|
onSelect?: SelectionSelectFn<T>;
|
|
|
|
onSelectMultiple?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
|
|
|
/** @deprecated This function is meaningless and should use `onChange` instead */
|
|
|
|
onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
|
|
|
/** @deprecated This function is meaningless and should use `onChange` instead */
|
|
|
|
onSelectInvert?: (selectedRowKeys: Key[]) => void;
|
2020-04-22 21:59:18 +08:00
|
|
|
selections?: INTERNAL_SELECTION_ITEM[] | boolean;
|
2019-11-15 14:35:25 +08:00
|
|
|
hideDefaultSelections?: boolean;
|
|
|
|
fixed?: boolean;
|
|
|
|
columnWidth?: string | number;
|
|
|
|
columnTitle?: string | React.ReactNode;
|
2020-02-29 23:11:02 +08:00
|
|
|
renderCell?: (
|
|
|
|
value: boolean,
|
|
|
|
record: T,
|
|
|
|
index: number,
|
|
|
|
originNode: React.ReactNode,
|
|
|
|
) => React.ReactNode | RcRenderedCell<T>;
|
2017-11-21 13:48:37 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type TransformColumns<RecordType> = (
|
|
|
|
columns: ColumnsType<RecordType>,
|
|
|
|
) => ColumnsType<RecordType>;
|
2017-11-21 13:48:37 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export interface TableCurrentDataSource<RecordType> {
|
|
|
|
currentDataSource: RecordType[];
|
2018-05-07 12:32:26 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export interface SorterResult<RecordType> {
|
|
|
|
column?: ColumnType<RecordType>;
|
|
|
|
order?: SortOrder;
|
|
|
|
field?: Key | Key[];
|
|
|
|
columnKey?: Key;
|
2017-11-21 13:48:37 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
export type GetPopupContainer = (triggerNode: HTMLElement) => HTMLElement;
|
2018-09-30 11:17:39 +08:00
|
|
|
|
2020-04-27 23:45:14 +08:00
|
|
|
type TablePaginationPosition =
|
|
|
|
| 'topLeft'
|
|
|
|
| 'topCenter'
|
|
|
|
| 'topRight'
|
|
|
|
| 'bottomLeft'
|
|
|
|
| 'bottomCenter'
|
|
|
|
| 'bottomRight';
|
|
|
|
|
|
|
|
export interface TablePaginationConfig extends PaginationProps {
|
|
|
|
position?: TablePaginationPosition[];
|
2019-11-15 14:35:25 +08:00
|
|
|
}
|