2018-03-29 22:08:04 +08:00
|
|
|
import PropTypes from '../_util/vue-types'
|
|
|
|
import { PaginationProps as getPaginationProps } from '../pagination'
|
|
|
|
import { SpinProps as getSpinProps } from '../spin'
|
|
|
|
import { Store } from './createStore'
|
|
|
|
|
|
|
|
const PaginationProps = getPaginationProps()
|
|
|
|
const SpinProps = getSpinProps()
|
|
|
|
|
|
|
|
// export type CompareFn<T> = ((a: T, b: T) => number);
|
|
|
|
export const ColumnFilterItem = PropTypes.shape({
|
|
|
|
text: PropTypes.string,
|
|
|
|
value: PropTypes.string,
|
|
|
|
children: PropTypes.array,
|
|
|
|
}).loose
|
|
|
|
|
|
|
|
export const ColumnProps = {
|
|
|
|
title: PropTypes.any,
|
|
|
|
// key?: React.Key;
|
|
|
|
dataIndex: PropTypes.string,
|
2018-04-01 12:52:27 +08:00
|
|
|
customRender: PropTypes.func,
|
2018-04-04 10:29:42 +08:00
|
|
|
customCell: PropTypes.func,
|
|
|
|
customHeaderCell: PropTypes.func,
|
2018-04-07 14:29:59 +08:00
|
|
|
align: PropTypes.oneOf(['left', 'right', 'center']),
|
2018-03-29 22:08:04 +08:00
|
|
|
filters: PropTypes.arrayOf(ColumnFilterItem),
|
|
|
|
// onFilter: (value: any, record: T) => PropTypes.bool,
|
|
|
|
filterMultiple: PropTypes.bool,
|
|
|
|
filterDropdown: PropTypes.any,
|
|
|
|
filterDropdownVisible: PropTypes.bool,
|
|
|
|
// onFilterDropdownVisibleChange?: (visible: boolean) => void;
|
|
|
|
sorter: PropTypes.oneOfType([PropTypes.boolean, PropTypes.func]),
|
|
|
|
defaultSortOrder: PropTypes.oneOf(['ascend', 'descend']),
|
|
|
|
colSpan: PropTypes.number,
|
|
|
|
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
2018-03-31 17:46:35 +08:00
|
|
|
className: PropTypes.string,
|
2018-03-29 22:08:04 +08:00
|
|
|
fixed: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['left', 'right'])]),
|
|
|
|
filterIcon: PropTypes.any,
|
|
|
|
filteredValue: PropTypes.array,
|
|
|
|
sortOrder: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['ascend', 'descend'])]),
|
|
|
|
// children?: ColumnProps<T>[];
|
|
|
|
// onCellClick?: (record: T, event: any) => void;
|
|
|
|
// onCell?: (record: T) => any;
|
|
|
|
// onHeaderCell?: (props: ColumnProps<T>) => any;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export interface TableComponents {
|
|
|
|
// table?: any;
|
|
|
|
// header?: {
|
|
|
|
// wrapper?: any;
|
|
|
|
// row?: any;
|
|
|
|
// cell?: any;
|
|
|
|
// };
|
|
|
|
// body?: {
|
|
|
|
// wrapper?: any;
|
|
|
|
// row?: any;
|
|
|
|
// cell?: any;
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
|
|
|
|
export const TableLocale = PropTypes.shape({
|
|
|
|
filterTitle: PropTypes.string,
|
|
|
|
filterConfirm: PropTypes.any,
|
|
|
|
filterReset: PropTypes.any,
|
|
|
|
emptyText: PropTypes.any,
|
|
|
|
selectAll: PropTypes.any,
|
|
|
|
selectInvert: PropTypes.any,
|
|
|
|
}).loose
|
|
|
|
|
|
|
|
export const RowSelectionType = PropTypes.oneOf(['checkbox', 'radio'])
|
|
|
|
// export type SelectionSelectFn<T> = (record: T, selected: boolean, selectedRows: Object[]) => any;
|
|
|
|
|
|
|
|
export const TableRowSelection = {
|
|
|
|
type: RowSelectionType,
|
|
|
|
selectedRowKeys: PropTypes.array,
|
|
|
|
// onChange?: (selectedRowKeys: string[] | number[], selectedRows: Object[]) => any;
|
|
|
|
getCheckboxProps: PropTypes.func,
|
|
|
|
// onSelect?: SelectionSelectFn<T>;
|
|
|
|
// onSelectAll?: (selected: boolean, selectedRows: Object[], changeRows: Object[]) => any;
|
|
|
|
// onSelectInvert?: (selectedRows: Object[]) => any;
|
|
|
|
selections: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
|
|
|
|
hideDefaultSelections: PropTypes.bool,
|
|
|
|
fixed: PropTypes.bool,
|
2018-04-07 14:29:59 +08:00
|
|
|
columnWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
2018-03-29 22:08:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export const TableProps = {
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
dropdownPrefixCls: PropTypes.string,
|
2018-03-31 21:11:02 +08:00
|
|
|
rowSelection: PropTypes.oneOfType([PropTypes.shape(TableRowSelection).loose, null]),
|
2018-04-07 14:29:59 +08:00
|
|
|
pagination: PropTypes.oneOfType([
|
|
|
|
PropTypes.shape({
|
|
|
|
...PaginationProps,
|
|
|
|
position: PropTypes.oneOf(['top', 'bottom', 'both']),
|
|
|
|
}).loose,
|
|
|
|
PropTypes.bool,
|
|
|
|
]),
|
2018-03-31 21:11:02 +08:00
|
|
|
size: PropTypes.oneOf(['default', 'middle', 'small', 'large']),
|
2018-03-29 22:08:04 +08:00
|
|
|
dataSource: PropTypes.array,
|
|
|
|
components: PropTypes.object,
|
|
|
|
columns: PropTypes.array,
|
|
|
|
rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
|
|
rowClassName: PropTypes.func,
|
|
|
|
expandedRowRender: PropTypes.any,
|
|
|
|
defaultExpandAllRows: PropTypes.bool,
|
|
|
|
defaultExpandedRowKeys: PropTypes.array,
|
|
|
|
expandedRowKeys: PropTypes.array,
|
|
|
|
expandIconAsCell: PropTypes.bool,
|
|
|
|
expandIconColumnIndex: PropTypes.number,
|
|
|
|
expandRowByClick: PropTypes.bool,
|
|
|
|
// onExpandedRowsChange?: (expandedRowKeys: string[] | number[]) => void;
|
|
|
|
// onExpand?: (expanded: boolean, record: T) => void;
|
|
|
|
// onChange?: (pagination: PaginationProps | boolean, filters: string[], sorter: Object) => any;
|
|
|
|
loading: PropTypes.oneOfType([PropTypes.shape(SpinProps).loose, PropTypes.bool]),
|
|
|
|
locale: PropTypes.object,
|
|
|
|
indentSize: PropTypes.number,
|
|
|
|
// onRowClick?: (record: T, index: number, event: Event) => any;
|
2018-03-31 17:46:35 +08:00
|
|
|
customRow: PropTypes.func,
|
|
|
|
customHeaderRow: PropTypes.func,
|
2018-03-29 22:08:04 +08:00
|
|
|
useFixedHeader: PropTypes.bool,
|
|
|
|
bordered: PropTypes.bool,
|
|
|
|
showHeader: PropTypes.bool,
|
2018-04-01 16:50:31 +08:00
|
|
|
footer: PropTypes.func,
|
|
|
|
title: PropTypes.func,
|
2018-03-29 22:08:04 +08:00
|
|
|
scroll: PropTypes.object,
|
|
|
|
childrenColumnName: PropTypes.string,
|
|
|
|
bodyStyle: PropTypes.any,
|
|
|
|
// className?: PropTypes.string,
|
|
|
|
// style?: React.CSSProperties;
|
|
|
|
// children?: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export interface TableStateFilters {
|
|
|
|
// [key: string]: string[];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// export interface TableState<T> {
|
|
|
|
// pagination: PaginationProps;
|
|
|
|
// filters: TableStateFilters;
|
|
|
|
// sortColumn: ColumnProps<T> | null;
|
|
|
|
// sortOrder: PropTypes.string,
|
|
|
|
// }
|
|
|
|
|
|
|
|
// export type SelectionItemSelectFn = (key: string[]) => any;
|
|
|
|
|
|
|
|
// export interface SelectionItem {
|
|
|
|
// key: PropTypes.string,
|
|
|
|
// text: PropTypes.any,
|
|
|
|
// onSelect: SelectionItemSelectFn;
|
|
|
|
// }
|
|
|
|
|
|
|
|
export const SelectionCheckboxAllProps = {
|
|
|
|
store: Store,
|
|
|
|
locale: PropTypes.any,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
getCheckboxPropsByItem: PropTypes.func,
|
|
|
|
getRecordKey: PropTypes.func,
|
|
|
|
data: PropTypes.array,
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
// onSelect: (key: string, index: number, selectFunc: any) => void;
|
|
|
|
hideDefaultSelections: PropTypes.bool,
|
|
|
|
selections: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
|
|
|
|
getPopupContainer: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
|
|
|
// export interface SelectionCheckboxAllState {
|
|
|
|
// checked: PropTypes.bool,
|
|
|
|
// indeterminate: PropTypes.bool,
|
|
|
|
// }
|
|
|
|
|
|
|
|
export const SelectionBoxProps = {
|
|
|
|
store: Store,
|
|
|
|
type: RowSelectionType,
|
2018-06-06 22:02:31 +08:00
|
|
|
defaultSelection: PropTypes.arrayOf([PropTypes.string, PropTypes.number]),
|
2018-04-02 22:13:11 +08:00
|
|
|
rowIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
2018-03-29 22:08:04 +08:00
|
|
|
name: PropTypes.string,
|
|
|
|
disabled: PropTypes.bool,
|
2018-06-01 21:25:16 +08:00
|
|
|
id: PropTypes.string,
|
2018-03-29 22:08:04 +08:00
|
|
|
// onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
|
|
}
|
|
|
|
|
|
|
|
// export interface SelectionBoxState {
|
|
|
|
// checked?: PropTypes.bool,
|
|
|
|
// }
|
|
|
|
|
|
|
|
export const FilterMenuProps = {
|
|
|
|
locale: TableLocale,
|
2018-06-06 22:02:31 +08:00
|
|
|
selectedKeys: PropTypes.arrayOf([PropTypes.string, PropTypes.number]),
|
2018-04-01 22:33:01 +08:00
|
|
|
column: PropTypes.object,
|
2018-03-29 22:08:04 +08:00
|
|
|
confirmFilter: PropTypes.func,
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
dropdownPrefixCls: PropTypes.string,
|
|
|
|
getPopupContainer: PropTypes.func,
|
2018-03-31 21:11:02 +08:00
|
|
|
handleFilter: PropTypes.func,
|
2018-03-29 22:08:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// export interface FilterMenuState {
|
|
|
|
// selectedKeys: string[];
|
|
|
|
// keyPathOfSelectedItem: { [key: string]: string };
|
|
|
|
// visible?: PropTypes.bool,
|
|
|
|
// }
|