1 | import type * as React from 'react';
|
2 | import type { Reference } from 'rc-table';
|
3 | import type { FixedType, GetComponentProps, ColumnType as RcColumnType, RenderedCell as RcRenderedCell } from 'rc-table/lib/interface';
|
4 | import { ExpandableConfig, GetRowKey } from 'rc-table/lib/interface';
|
5 | import type { Breakpoint } from '../_util/responsiveObserver';
|
6 | import type { AnyObject } from '../_util/type';
|
7 | import type { CheckboxProps } from '../checkbox';
|
8 | import type { PaginationProps } from '../pagination';
|
9 | import type { TooltipProps } from '../tooltip';
|
10 | import type { INTERNAL_SELECTION_ITEM } from './hooks/useSelection';
|
11 | import type { InternalTableProps, TableProps } from './InternalTable';
|
12 | export type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<TableProps<RecordType>> & React.RefAttributes<Reference>) => React.ReactElement;
|
13 | export type RefInternalTable = <RecordType = AnyObject>(props: React.PropsWithChildren<InternalTableProps<RecordType>> & React.RefAttributes<Reference>) => React.ReactElement;
|
14 | export { ExpandableConfig, GetRowKey };
|
15 | export type Key = React.Key;
|
16 | export type SafeKey = Exclude<Key, bigint>;
|
17 | export type RowSelectionType = 'checkbox' | 'radio';
|
18 | export type SelectionItemSelectFn = (currentRowKeys: Key[]) => void;
|
19 | export type ExpandType = null | 'row' | 'nest';
|
20 | export interface TableLocale {
|
21 | filterTitle?: string;
|
22 | filterConfirm?: React.ReactNode;
|
23 | filterReset?: React.ReactNode;
|
24 | filterEmptyText?: React.ReactNode;
|
25 | filterCheckall?: React.ReactNode;
|
26 | filterSearchPlaceholder?: string;
|
27 | emptyText?: React.ReactNode | (() => React.ReactNode);
|
28 | selectAll?: React.ReactNode;
|
29 | selectNone?: React.ReactNode;
|
30 | selectInvert?: React.ReactNode;
|
31 | selectionAll?: React.ReactNode;
|
32 | sortTitle?: string;
|
33 | expand?: string;
|
34 | collapse?: string;
|
35 | triggerDesc?: string;
|
36 | triggerAsc?: string;
|
37 | cancelSort?: string;
|
38 | }
|
39 | export type SortOrder = 'descend' | 'ascend' | null;
|
40 | export type SorterTooltipTarget = 'full-header' | 'sorter-icon';
|
41 | export type SorterTooltipProps = TooltipProps & {
|
42 | target?: SorterTooltipTarget;
|
43 | };
|
44 | declare const TableActions: readonly ["paginate", "sort", "filter"];
|
45 | export type TableAction = (typeof TableActions)[number];
|
46 | export type CompareFn<T = AnyObject> = (a: T, b: T, sortOrder?: SortOrder) => number;
|
47 | export interface ColumnFilterItem {
|
48 | text: React.ReactNode;
|
49 | value: React.Key | boolean;
|
50 | children?: ColumnFilterItem[];
|
51 | }
|
52 | export interface ColumnTitleProps<RecordType = AnyObject> {
|
53 |
|
54 | sortOrder?: SortOrder;
|
55 |
|
56 | sortColumn?: ColumnType<RecordType>;
|
57 | sortColumns?: {
|
58 | column: ColumnType<RecordType>;
|
59 | order: SortOrder;
|
60 | }[];
|
61 | filters?: Record<string, FilterValue>;
|
62 | }
|
63 | export type ColumnTitle<RecordType = AnyObject> = React.ReactNode | ((props: ColumnTitleProps<RecordType>) => React.ReactNode);
|
64 | export type FilterValue = (Key | boolean)[];
|
65 | export type FilterKey = (string | number)[] | null;
|
66 | export type FilterSearchType<RecordType = AnyObject> = boolean | ((input: string, record: RecordType) => boolean);
|
67 | export interface FilterConfirmProps {
|
68 | closeDropdown: boolean;
|
69 | }
|
70 | export interface FilterDropdownProps {
|
71 | prefixCls: string;
|
72 | setSelectedKeys: (selectedKeys: React.Key[]) => void;
|
73 | selectedKeys: React.Key[];
|
74 | |
75 |
|
76 |
|
77 |
|
78 | confirm: (param?: FilterConfirmProps) => void;
|
79 | clearFilters?: () => void;
|
80 | filters?: ColumnFilterItem[];
|
81 |
|
82 | close: () => void;
|
83 | visible: boolean;
|
84 | }
|
85 | export interface ColumnType<RecordType = AnyObject> extends Omit<RcColumnType<RecordType>, 'title'> {
|
86 | title?: ColumnTitle<RecordType>;
|
87 | sorter?: boolean | CompareFn<RecordType> | {
|
88 | compare?: CompareFn<RecordType>;
|
89 |
|
90 | multiple?: number;
|
91 | };
|
92 | sortOrder?: SortOrder;
|
93 | defaultSortOrder?: SortOrder;
|
94 | sortDirections?: SortOrder[];
|
95 | sortIcon?: (props: {
|
96 | sortOrder: SortOrder;
|
97 | }) => React.ReactNode;
|
98 | showSorterTooltip?: boolean | SorterTooltipProps;
|
99 | filtered?: boolean;
|
100 | filters?: ColumnFilterItem[];
|
101 | filterDropdown?: React.ReactNode | ((props: FilterDropdownProps) => React.ReactNode);
|
102 | filterOnClose?: boolean;
|
103 | filterMultiple?: boolean;
|
104 | filteredValue?: FilterValue | null;
|
105 | defaultFilteredValue?: FilterValue | null;
|
106 | filterIcon?: React.ReactNode | ((filtered: boolean) => React.ReactNode);
|
107 | filterMode?: 'menu' | 'tree';
|
108 | filterSearch?: FilterSearchType<ColumnFilterItem>;
|
109 | onFilter?: (value: React.Key | boolean, record: RecordType) => boolean;
|
110 | filterDropdownOpen?: boolean;
|
111 | onFilterDropdownOpenChange?: (visible: boolean) => void;
|
112 | filterResetToDefaultFilteredValue?: boolean;
|
113 | responsive?: Breakpoint[];
|
114 |
|
115 | filterDropdownVisible?: boolean;
|
116 |
|
117 | onFilterDropdownVisibleChange?: (visible: boolean) => void;
|
118 | }
|
119 | export interface ColumnGroupType<RecordType = AnyObject> extends Omit<ColumnType<RecordType>, 'dataIndex'> {
|
120 | children: ColumnsType<RecordType>;
|
121 | }
|
122 | export type ColumnsType<RecordType = AnyObject> = (ColumnGroupType<RecordType> | ColumnType<RecordType>)[];
|
123 | export interface SelectionItem {
|
124 | key: string;
|
125 | text: React.ReactNode;
|
126 | onSelect?: SelectionItemSelectFn;
|
127 | }
|
128 | export type SelectionSelectFn<T = AnyObject> = (record: T, selected: boolean, selectedRows: T[], nativeEvent: Event) => void;
|
129 | export type RowSelectMethod = 'all' | 'none' | 'invert' | 'single' | 'multiple';
|
130 | export interface TableRowSelection<T = AnyObject> {
|
131 |
|
132 | preserveSelectedRowKeys?: boolean;
|
133 | type?: RowSelectionType;
|
134 | selectedRowKeys?: Key[];
|
135 | defaultSelectedRowKeys?: Key[];
|
136 | onChange?: (selectedRowKeys: Key[], selectedRows: T[], info: {
|
137 | type: RowSelectMethod;
|
138 | }) => void;
|
139 | getCheckboxProps?: (record: T) => Partial<Omit<CheckboxProps, 'checked' | 'defaultChecked'>>;
|
140 | onSelect?: SelectionSelectFn<T>;
|
141 |
|
142 | onSelectMultiple?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
143 |
|
144 | onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
145 |
|
146 | onSelectInvert?: (selectedRowKeys: Key[]) => void;
|
147 |
|
148 | onSelectNone?: () => void;
|
149 | selections?: INTERNAL_SELECTION_ITEM[] | boolean;
|
150 | hideSelectAll?: boolean;
|
151 | fixed?: FixedType;
|
152 | columnWidth?: string | number;
|
153 | columnTitle?: React.ReactNode | ((checkboxNode: React.ReactNode) => React.ReactNode);
|
154 | checkStrictly?: boolean;
|
155 | renderCell?: (value: boolean, record: T, index: number, originNode: React.ReactNode) => React.ReactNode | RcRenderedCell<T>;
|
156 | onCell?: GetComponentProps<T>;
|
157 | }
|
158 | export type TransformColumns<RecordType = AnyObject> = (columns: ColumnsType<RecordType>) => ColumnsType<RecordType>;
|
159 | export interface TableCurrentDataSource<RecordType = AnyObject> {
|
160 | currentDataSource: RecordType[];
|
161 | action: TableAction;
|
162 | }
|
163 | export interface SorterResult<RecordType = AnyObject> {
|
164 | column?: ColumnType<RecordType>;
|
165 | order?: SortOrder;
|
166 | field?: Key | readonly Key[];
|
167 | columnKey?: Key;
|
168 | }
|
169 | export type GetPopupContainer = (triggerNode: HTMLElement) => HTMLElement;
|
170 | type TablePaginationPosition = 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'none';
|
171 | export interface TablePaginationConfig extends PaginationProps {
|
172 | position?: TablePaginationPosition[];
|
173 | }
|