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 = (a: T, b: T, sortOrder?: SortOrder) => number; export type ColumnFilterItem = { text: React.ReactNode; value: string; children?: ColumnFilterItem[]; }; export interface FilterDropdownProps { prefixCls?: string; setSelectedKeys?: (selectedKeys: string[]) => void; selectedKeys?: string[]; confirm?: () => void; clearFilters?: (selectedKeys: string[]) => void; filters?: ColumnFilterItem[]; getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement; } export interface ColumnProps { 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: FilterDropdownProps) => React.ReactNode); filterDropdownVisible?: boolean; onFilterDropdownVisibleChange?: (visible: boolean) => void; sorter?: boolean | CompareFn; defaultSortOrder?: SortOrder; colSpan?: number; width?: string | number; className?: string; fixed?: boolean | ('left' | 'right'); filterIcon?: React.ReactNode | ((filtered: boolean) => React.ReactNode); filteredValue?: any[]; sortOrder?: SortOrder | boolean; children?: ColumnProps[]; onCellClick?: (record: T, event: any) => void; onCell?: (record: T, rowIndex: number) => any; onHeaderCell?: (props: ColumnProps) => any; sortDirections?: SortOrder[]; } export interface AdditionalCellProps { onClick?: React.MouseEventHandler; [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 = ( record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event, ) => any; export type TableSelectWay = 'onSelect' | 'onSelectMultiple' | 'onSelectAll' | 'onSelectInvert'; export interface TableRowSelection { type?: RowSelectionType; selectedRowKeys?: string[] | number[]; onChange?: (selectedRowKeys: string[] | number[], selectedRows: T[]) => void; getCheckboxProps?: (record: T) => Object; onSelect?: SelectionSelectFn; 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 { column: ColumnProps; order: SortOrder; field: string; columnKey: string; } export type TableSize = 'default' | 'middle' | 'small'; export interface ExpandIconProps { prefixCls: string; expanded: boolean; record: T; needIndentSpaced: boolean; expandable: boolean; onExpand: (record: T, event: MouseEvent) => void; } export interface TableCurrentDataSource { currentDataSource: T[]; } export interface TableProps { prefixCls?: string; dropdownPrefixCls?: string; rowSelection?: TableRowSelection; pagination?: PaginationConfig | false; size?: TableSize; dataSource?: T[]; components?: TableComponents; columns?: ColumnProps[]; rowKey?: string | ((record: T, index: number) => string); rowClassName?: (record: T, index: number) => string; expandedRowRender?: ( record: T, index: number, indent: number, expanded: boolean, ) => React.ReactNode; defaultExpandAllRows?: boolean; defaultExpandedRowKeys?: string[] | number[]; expandedRowKeys?: string[] | number[]; expandIcon?: (props: ExpandIconProps) => React.ReactNode; expandIconAsCell?: boolean; expandIconColumnIndex?: number; expandRowByClick?: boolean; onExpandedRowsChange?: (expandedRowKeys: string[] | number[]) => void; onExpand?: (expanded: boolean, record: T) => void; onChange?: ( pagination: PaginationConfig, filters: Record, sorter: SorterResult, extra: TableCurrentDataSource, ) => void; loading?: boolean | SpinProps; locale?: TableLocale; indentSize?: number; onRowClick?: (record: T, index: number, event: Event) => void; onRow?: (record: T, index: number) => any; onHeaderRow?: (columns: ColumnProps[], index: number) => any; useFixedHeader?: boolean; bordered?: boolean; showHeader?: boolean; footer?: (currentPageData: Object[]) => React.ReactNode; title?: (currentPageData: Object[]) => React.ReactNode; scroll?: { x?: boolean | number | string; y?: boolean | number | string }; childrenColumnName?: string; bodyStyle?: React.CSSProperties; className?: string; style?: React.CSSProperties; children?: React.ReactNode; sortDirections?: SortOrder[]; } export interface TableStateFilters { [key: string]: string[]; } export interface TableState { pagination: PaginationConfig; filters: TableStateFilters; sortColumn: ColumnProps | null; sortOrder?: SortOrder; pivot?: number; } export type SelectionItemSelectFn = (key: string[]) => any; type GetPopupContainer = (triggerNode?: HTMLElement) => HTMLElement; export interface SelectionItem { key: string; text: React.ReactNode; onSelect: SelectionItemSelectFn; } export interface SelectionCheckboxAllProps { store: Store; locale: any; disabled: boolean; getCheckboxPropsByItem: (item: any, index: number) => any; getRecordKey: (record: any, index?: number) => string; data: T[]; prefixCls: string | undefined; onSelect: (key: string, index: number, selectFunc: any) => void; hideDefaultSelections?: boolean; selections?: SelectionItem[] | boolean; getPopupContainer?: GetPopupContainer; } export interface SelectionCheckboxAllState { checked?: boolean; indeterminate?: boolean; } export interface SelectionBoxProps { store: Store; type?: RowSelectionType; defaultSelection: string[]; rowIndex: string; name?: string; disabled?: boolean; onChange: (e: RadioChangeEvent | CheckboxChangeEvent) => void; } export interface SelectionBoxState { checked?: boolean; } export interface SelectionInfo { selectWay: TableSelectWay; record?: T; checked?: boolean; changeRowKeys?: React.Key[]; nativeEvent?: Event; } export interface FilterMenuProps { locale: TableLocale; selectedKeys: string[]; column: ColumnProps; confirmFilter: (column: ColumnProps, selectedKeys: string[]) => any; prefixCls: string; dropdownPrefixCls: string; getPopupContainer?: GetPopupContainer; } export interface FilterMenuState { selectedKeys: string[]; valueKeys: { [name: string]: any }; keyPathOfSelectedItem: { [key: string]: string }; visible?: boolean; prevProps: FilterMenuProps; } export type PrepareParamsArgumentsReturn = [ any, string[], Object, { currentDataSource: T[]; }, ];