import * as React from 'react'; import { PaginationProps } from '../pagination'; import { SpinProps } from '../spin'; import { Store } from './createStore'; export type CompareFn = ((a: T, b: T) => number); export type ColumnFilterItem = { text: string; value: string, children?: ColumnFilterItem[] }; export interface ColumnProps { title?: React.ReactNode; key?: React.Key; dataIndex?: string; render?: (text: any, record: T, index: number) => React.ReactNode; filters?: ColumnFilterItem[]; onFilter?: (value: any, record: T) => boolean; filterMultiple?: boolean; filterDropdown?: React.ReactNode; filterDropdownVisible?: boolean; onFilterDropdownVisibleChange?: (visible: boolean) => void; sorter?: boolean | CompareFn; 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[]; onCellClick?: (record: T, event: any) => void; onCell?: (record: T) => any; } export interface TableComponents { table?: any; header?: { wrapper?: any; row?: any; cell?: any; }; body?: { wrapper?: any; row?: any; cell?: any; }; } export interface TableLocale { filterTitle?: string; filterConfirm?: string; filterReset?: string; emptyText?: string; selectAll?: string; selectInvert?: string; } export type RowSelectionType = 'checkbox' | 'radio'; export type SelectionSelectFn = (record: T, selected: boolean, selectedRows: Object[]) => any; export interface TableRowSelection { type?: RowSelectionType; selectedRowKeys?: string[] | number[]; onChange?: (selectedRowKeys: string[] | number[], selectedRows: Object[]) => any; getCheckboxProps?: (record: T) => Object; onSelect?: SelectionSelectFn; onSelectAll?: (selected: boolean, selectedRows: Object[], changeRows: Object[]) => any; onSelectInvert?: (selectedRows: Object[]) => any; selections?: SelectionItem[] | boolean; hideDefaultSelections?: boolean; fixed?: boolean; } export interface TableProps { prefixCls?: string; dropdownPrefixCls?: string; rowSelection?: TableRowSelection; pagination?: PaginationProps | false; size?: 'default' | 'middle' | 'small'; dataSource?: T[]; components?: TableComponents; columns?: ColumnProps[]; rowKey?: string | ((record: T, index: number) => string); rowClassName?: (record: T, index: number) => string; expandedRowRender?: any; defaultExpandedRowKeys?: string[] | number[]; expandedRowKeys?: string[] | number[]; expandIconAsCell?: boolean; expandIconColumnIndex?: number; onExpandedRowsChange?: (expandedRowKeys: string[] | number[]) => void; onExpand?: (expanded: boolean, record: T) => void; onChange?: (pagination: PaginationProps | boolean, filters: string[], sorter: Object) => any; loading?: boolean | SpinProps; locale?: Object; indentSize?: number; onRowClick?: (record: T, index: number, event: Event) => any; onRow?: (record: T, 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; } export interface TableStateFilters { [key: string]: string[]; } export interface TableState { pagination: PaginationProps; filters: TableStateFilters; sortColumn: ColumnProps | null; sortOrder: string; } export type SelectionItemSelectFn = (key: string[]) => any; 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: (triggerNode?: Element) => HTMLElement; } export interface SelectionCheckboxAllState { checked: boolean; indeterminate: boolean; } export interface SelectionBoxProps { store: Store; type?: RowSelectionType; defaultSelection: string[]; rowIndex: string; disabled?: boolean; onChange: React.ChangeEventHandler; } export interface SelectionBoxState { checked?: boolean; } export interface FilterMenuProps { locale: TableLocale; selectedKeys: string[]; column: ColumnProps; confirmFilter: (column: ColumnProps, selectedKeys: string[]) => any; prefixCls: string; dropdownPrefixCls: string; getPopupContainer: (triggerNode?: Element) => HTMLElement; } export interface FilterMenuState { selectedKeys: string[]; keyPathOfSelectedItem: { [key: string]: string }; visible?: boolean; }