1 | import type * as React from 'react';
|
2 | import type { DeepNamePath } from './namePathType';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export type Key = React.Key;
|
20 | export type FixedType = 'left' | 'right' | boolean;
|
21 | export type DefaultRecordType = Record<string, any>;
|
22 | export type TableLayout = 'auto' | 'fixed';
|
23 | export type ScrollConfig = {
|
24 | index?: number;
|
25 | key?: Key;
|
26 | top?: number;
|
27 | };
|
28 | export type Reference = {
|
29 | nativeElement: HTMLDivElement;
|
30 | scrollTo: (config: ScrollConfig) => void;
|
31 | };
|
32 | export type RowClassName<RecordType> = (record: RecordType, index: number, indent: number) => string;
|
33 | export interface CellType<RecordType> {
|
34 | key?: Key;
|
35 | className?: string;
|
36 | style?: React.CSSProperties;
|
37 | children?: React.ReactNode;
|
38 | column?: ColumnsType<RecordType>[number];
|
39 | colSpan?: number;
|
40 | rowSpan?: number;
|
41 |
|
42 | hasSubColumns?: boolean;
|
43 | colStart?: number;
|
44 | colEnd?: number;
|
45 | }
|
46 | export interface RenderedCell<RecordType> {
|
47 | props?: CellType<RecordType>;
|
48 | children?: React.ReactNode;
|
49 | }
|
50 | export type Direction = 'ltr' | 'rtl';
|
51 | export type SpecialString<T> = T | (string & {});
|
52 | export type DataIndex<T = any> = DeepNamePath<T> | SpecialString<T> | number | (SpecialString<T> | number)[];
|
53 | export type CellEllipsisType = {
|
54 | showTitle?: boolean;
|
55 | } | boolean;
|
56 | export type ColScopeType = 'col' | 'colgroup';
|
57 | export type RowScopeType = 'row' | 'rowgroup';
|
58 | export type ScopeType = ColScopeType | RowScopeType;
|
59 | interface ColumnSharedType<RecordType> {
|
60 | title?: React.ReactNode;
|
61 | key?: Key;
|
62 | className?: string;
|
63 | hidden?: boolean;
|
64 | fixed?: FixedType;
|
65 | onHeaderCell?: GetComponentProps<ColumnsType<RecordType>[number]>;
|
66 | ellipsis?: CellEllipsisType;
|
67 | align?: AlignType;
|
68 | rowScope?: RowScopeType;
|
69 | }
|
70 | export interface ColumnGroupType<RecordType> extends ColumnSharedType<RecordType> {
|
71 | children: ColumnsType<RecordType>;
|
72 | }
|
73 | export type AlignType = 'start' | 'end' | 'left' | 'right' | 'center' | 'justify' | 'match-parent';
|
74 | export interface ColumnType<RecordType> extends ColumnSharedType<RecordType> {
|
75 | colSpan?: number;
|
76 | dataIndex?: DataIndex<RecordType>;
|
77 | render?: (value: any, record: RecordType, index: number) => React.ReactNode | RenderedCell<RecordType>;
|
78 | shouldCellUpdate?: (record: RecordType, prevRecord: RecordType) => boolean;
|
79 | rowSpan?: number;
|
80 | width?: number | string;
|
81 | minWidth?: number;
|
82 | onCell?: GetComponentProps<RecordType>;
|
83 |
|
84 | onCellClick?: (record: RecordType, e: React.MouseEvent<HTMLElement>) => void;
|
85 | }
|
86 | export type ColumnsType<RecordType = unknown> = readonly (ColumnGroupType<RecordType> | ColumnType<RecordType>)[];
|
87 | export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
|
88 | export interface StickyOffsets {
|
89 | left: readonly number[];
|
90 | right: readonly number[];
|
91 | isSticky?: boolean;
|
92 | }
|
93 | export type GetComponentProps<DataType> = (data: DataType, index?: number) => React.HTMLAttributes<any> & React.TdHTMLAttributes<any>;
|
94 | type Component<P> = React.ComponentType<P> | React.ForwardRefExoticComponent<P> | React.FC<P> | keyof React.ReactHTML;
|
95 | export type CustomizeComponent = Component<any>;
|
96 | export type OnCustomizeScroll = (info: {
|
97 | currentTarget?: HTMLElement;
|
98 | scrollLeft?: number;
|
99 | }) => void;
|
100 | export type CustomizeScrollBody<RecordType> = (data: readonly RecordType[], info: {
|
101 | scrollbarSize: number;
|
102 | ref: React.Ref<{
|
103 | scrollLeft: number;
|
104 | scrollTo?: (scrollConfig: ScrollConfig) => void;
|
105 | }>;
|
106 | onScroll: OnCustomizeScroll;
|
107 | }) => React.ReactNode;
|
108 | export interface TableComponents<RecordType> {
|
109 | table?: CustomizeComponent;
|
110 | header?: {
|
111 | table?: CustomizeComponent;
|
112 | wrapper?: CustomizeComponent;
|
113 | row?: CustomizeComponent;
|
114 | cell?: CustomizeComponent;
|
115 | };
|
116 | body?: CustomizeScrollBody<RecordType> | {
|
117 | wrapper?: CustomizeComponent;
|
118 | row?: CustomizeComponent;
|
119 | cell?: CustomizeComponent;
|
120 | };
|
121 | }
|
122 | export type GetComponent = (path: readonly string[], defaultComponent?: CustomizeComponent) => CustomizeComponent;
|
123 | export type ExpandableType = false | 'row' | 'nest';
|
124 | export interface LegacyExpandableProps<RecordType> {
|
125 |
|
126 | expandedRowKeys?: Key[];
|
127 |
|
128 | defaultExpandedRowKeys?: Key[];
|
129 |
|
130 | expandedRowRender?: ExpandedRowRender<RecordType>;
|
131 |
|
132 | expandRowByClick?: boolean;
|
133 |
|
134 | expandIcon?: RenderExpandIcon<RecordType>;
|
135 |
|
136 | onExpand?: (expanded: boolean, record: RecordType) => void;
|
137 |
|
138 | onExpandedRowsChange?: (expandedKeys: Key[]) => void;
|
139 |
|
140 | defaultExpandAllRows?: boolean;
|
141 |
|
142 | indentSize?: number;
|
143 |
|
144 | expandIconColumnIndex?: number;
|
145 |
|
146 | expandedRowClassName?: RowClassName<RecordType>;
|
147 |
|
148 | childrenColumnName?: string;
|
149 | title?: PanelRender<RecordType>;
|
150 | }
|
151 | export type ExpandedRowRender<ValueType> = (record: ValueType, index: number, indent: number, expanded: boolean) => React.ReactNode;
|
152 | export interface RenderExpandIconProps<RecordType> {
|
153 | prefixCls: string;
|
154 | expanded: boolean;
|
155 | record: RecordType;
|
156 | expandable: boolean;
|
157 | onExpand: TriggerEventHandler<RecordType>;
|
158 | }
|
159 | export type RenderExpandIcon<RecordType> = (props: RenderExpandIconProps<RecordType>) => React.ReactNode;
|
160 | export interface ExpandableConfig<RecordType> {
|
161 | expandedRowKeys?: readonly Key[];
|
162 | defaultExpandedRowKeys?: readonly Key[];
|
163 | expandedRowRender?: ExpandedRowRender<RecordType>;
|
164 | columnTitle?: React.ReactNode;
|
165 | expandRowByClick?: boolean;
|
166 | expandIcon?: RenderExpandIcon<RecordType>;
|
167 | onExpand?: (expanded: boolean, record: RecordType) => void;
|
168 | onExpandedRowsChange?: (expandedKeys: readonly Key[]) => void;
|
169 | defaultExpandAllRows?: boolean;
|
170 | indentSize?: number;
|
171 |
|
172 | expandIconColumnIndex?: number;
|
173 | showExpandColumn?: boolean;
|
174 | expandedRowClassName?: RowClassName<RecordType>;
|
175 | childrenColumnName?: string;
|
176 | rowExpandable?: (record: RecordType) => boolean;
|
177 | columnWidth?: number | string;
|
178 | fixed?: FixedType;
|
179 | }
|
180 | export type PanelRender<RecordType> = (data: readonly RecordType[]) => React.ReactNode;
|
181 | export type TriggerEventHandler<RecordType> = (record: RecordType, event: React.MouseEvent<HTMLElement>) => void;
|
182 | export interface TableSticky {
|
183 | offsetHeader?: number;
|
184 | offsetSummary?: number;
|
185 | offsetScroll?: number;
|
186 | getContainer?: () => Window | HTMLElement;
|
187 | }
|
188 | export {};
|