stk-table-vue 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -194
- package/lib/{Dropdown-D_9cB0rD.js → Dropdown-BAANgg_5.js} +2 -2
- package/lib/{StkTable-CVcmlZi9.js → StkTable-CGcxwpdb.js} +22 -6
- package/lib/src/StkTable/StkTable.vue.d.ts +18 -4
- package/lib/src/StkTable/types/index.d.ts +4 -1
- package/lib/src/StkTable/useVirtualScroll.d.ts +6 -1
- package/lib/stk-table-vue.js +3 -3
- package/lib/style.css +1 -1
- package/package.json +93 -93
- package/src/StkTable/StkTable.vue +2362 -2338
- package/src/StkTable/components/DragHandle.vue +9 -9
- package/src/StkTable/components/SortIcon.vue +6 -6
- package/src/StkTable/components/TreeNodeCell.vue +19 -19
- package/src/StkTable/components/TriangleIcon.vue +3 -3
- package/src/StkTable/const.ts +50 -50
- package/src/StkTable/custom-cells/ChangeCell/ChangeCell.less +34 -34
- package/src/StkTable/custom-cells/ChangeCell/createChangeCell.ts +90 -90
- package/src/StkTable/custom-cells/ChangeCell/index.ts +4 -4
- package/src/StkTable/custom-cells/CheckboxCell/CheckboxCell.less +14 -14
- package/src/StkTable/custom-cells/CheckboxCell/CheckboxCell.vue +56 -56
- package/src/StkTable/custom-cells/CheckboxCell/createCheckboxCell.ts +146 -146
- package/src/StkTable/custom-cells/CheckboxCell/index.ts +5 -5
- package/src/StkTable/custom-cells/FilterCell/Dropdown/index.ts +16 -16
- package/src/StkTable/custom-cells/FilterCell/Dropdown/index.vue +186 -186
- package/src/StkTable/custom-cells/FilterCell/Filter.less +118 -118
- package/src/StkTable/custom-cells/FilterCell/Filter.vue +66 -66
- package/src/StkTable/custom-cells/FilterCell/createFilterCell.ts +120 -120
- package/src/StkTable/custom-cells/FilterCell/index.ts +6 -6
- package/src/StkTable/custom-cells/FilterCell/types.ts +43 -43
- package/src/StkTable/custom-cells/NumberCell/createNumberCell.ts +43 -43
- package/src/StkTable/custom-cells/NumberCell/index.ts +2 -2
- package/src/StkTable/custom-cells/utils/formatNumber.ts +137 -137
- package/src/StkTable/features/const.ts +1 -1
- package/src/StkTable/features/index.ts +1 -1
- package/src/StkTable/features/useAreaSelection.ts +1240 -1239
- package/src/StkTable/index.ts +20 -20
- package/src/StkTable/mergeCellsCache.ts +69 -69
- package/src/StkTable/registerFeature.ts +40 -40
- package/src/StkTable/style.less +791 -791
- package/src/StkTable/types/highlightDimOptions.ts +28 -28
- package/src/StkTable/types/index.ts +503 -500
- package/src/StkTable/useAutoResize.ts +87 -87
- package/src/StkTable/useColResize.ts +202 -202
- package/src/StkTable/useFixedCol.ts +168 -168
- package/src/StkTable/useFixedStyle.ts +75 -75
- package/src/StkTable/useGetFixedColPosition.ts +63 -63
- package/src/StkTable/useHighlight.ts +270 -270
- package/src/StkTable/useIndexResolver.ts +29 -29
- package/src/StkTable/useKeyboardArrowScroll.ts +114 -114
- package/src/StkTable/useMaxRowSpan.ts +60 -60
- package/src/StkTable/useMergeCells.ts +541 -541
- package/src/StkTable/useRowExpand.ts +81 -81
- package/src/StkTable/useScrollRowByRow.ts +96 -96
- package/src/StkTable/useScrollbar.ts +177 -177
- package/src/StkTable/useSorter.ts +267 -267
- package/src/StkTable/useTableColumns.ts +142 -142
- package/src/StkTable/useThDrag.ts +94 -94
- package/src/StkTable/useTrDrag.ts +100 -100
- package/src/StkTable/useTree.ts +253 -253
- package/src/StkTable/useVirtualScroll.ts +1032 -1025
- package/src/StkTable/useWheeling.ts +23 -23
- package/src/StkTable/utils/constRefUtils.ts +29 -29
- package/src/StkTable/utils/index.ts +331 -331
- package/src/StkTable/utils/rowHeightFenwickTree.ts +74 -74
- package/src/StkTable/utils/useTriggerRef.ts +33 -33
- package/src/VirtualTree.vue +622 -622
- package/src/VirtualTreeSelect.vue +367 -367
- package/src/vite-env.d.ts +10 -10
|
@@ -1,500 +1,503 @@
|
|
|
1
|
-
import { Component, ComputedRef, ConcreteComponent } from 'vue';
|
|
2
|
-
|
|
3
|
-
/** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
|
|
4
|
-
export type Order = null | 'asc' | 'desc';
|
|
5
|
-
|
|
6
|
-
type Sorter<T> = boolean | ((data: T[], option: { order: Order; column: any }) => T[]);
|
|
7
|
-
|
|
8
|
-
export type CustomCellProps<T extends Record<string, any>> = {
|
|
9
|
-
row: T;
|
|
10
|
-
col: StkTableColumn<T>;
|
|
11
|
-
/** row[col.dataIndex] 的值 */
|
|
12
|
-
cellValue: any;
|
|
13
|
-
rowIndex: number;
|
|
14
|
-
colIndex: number;
|
|
15
|
-
/**
|
|
16
|
-
* 当前行是否展开
|
|
17
|
-
* - 不展开: null
|
|
18
|
-
* - 展开: 返回column配置
|
|
19
|
-
*/
|
|
20
|
-
expanded?: PrivateRowDT['__EXP__'];
|
|
21
|
-
/** if tree expanded */
|
|
22
|
-
treeExpanded?: PrivateRowDT['__T_EXP__'];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type CustomHeaderCellProps<T extends Record<string, any>> = {
|
|
26
|
-
col: StkTableColumn<T>;
|
|
27
|
-
rowIndex: number;
|
|
28
|
-
colIndex: number;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type CustomFooterCellProps<T extends Record<string, any>> = {
|
|
32
|
-
col: StkTableColumn<T>;
|
|
33
|
-
row: T;
|
|
34
|
-
cellValue: any;
|
|
35
|
-
rowIndex: number;
|
|
36
|
-
colIndex: number;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type MergeCellsParam<T extends Record<string, any>> = {
|
|
40
|
-
row: T;
|
|
41
|
-
col: StkTableColumn<T>;
|
|
42
|
-
rowIndex: number;
|
|
43
|
-
colIndex: number;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type MergeCellsFn<T extends Record<string, any>> = (data: MergeCellsParam<T>) => { rowspan?: number; colspan?: number } | undefined;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 自定义渲染单元格
|
|
50
|
-
*
|
|
51
|
-
* `StkTableColumn.customCell` 类型直接定义 `Component<Props>` 如果 Props 属性为必选,则 通过`defineComponent` 创建的组件必须要定义所有的Prop,否则就不适配。但是在函数式组件中是正常使用的。customCell: (props) => {}。
|
|
52
|
-
*
|
|
53
|
-
* 如果定义 Props 所有属性均为可选时。`defineComponent` 定义的组件仅需实现个别的 Prop 即可。但是函数式组件的入参props就需要额外判断是否存在。这增加了使用成本。
|
|
54
|
-
*
|
|
55
|
-
* 因此这里重新组合了Component类型
|
|
56
|
-
*/
|
|
57
|
-
export type CustomCell<T extends CustomCellProps<U> | CustomHeaderCellProps<U>, U extends Record<string, any>> =
|
|
58
|
-
| ConcreteComponent<T>
|
|
59
|
-
| Exclude<Component<Partial<T>>, ConcreteComponent>
|
|
60
|
-
| string;
|
|
61
|
-
|
|
62
|
-
/** 表格列配置 */
|
|
63
|
-
export type StkTableColumn<T extends Record<string, any>> = {
|
|
64
|
-
/**
|
|
65
|
-
* 列唯一键,(可选),不传则默认取dataIndex 字段作为列唯一键。
|
|
66
|
-
*/
|
|
67
|
-
key?: any;
|
|
68
|
-
/**
|
|
69
|
-
* 列类型
|
|
70
|
-
* - seq 序号列
|
|
71
|
-
* - expand 展开列
|
|
72
|
-
* - dragRow 拖拽列(使用sktTableRef.getTableData 获取改变后的顺序)
|
|
73
|
-
* - tree-node 树节点列,这一列前面有展开收起箭头
|
|
74
|
-
*/
|
|
75
|
-
type?: 'seq' | 'expand' | 'dragRow' | 'tree-node';
|
|
76
|
-
/** 取值id */
|
|
77
|
-
dataIndex: keyof T & string;
|
|
78
|
-
/** 表头文字 */
|
|
79
|
-
title?: string;
|
|
80
|
-
/** 列内容对齐方式 */
|
|
81
|
-
align?: 'right' | 'left' | 'center';
|
|
82
|
-
/** 表头内容对齐方式 */
|
|
83
|
-
headerAlign?: 'right' | 'left' | 'center';
|
|
84
|
-
/** 筛选 */
|
|
85
|
-
sorter?: Sorter<T>;
|
|
86
|
-
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
87
|
-
width?: string | number;
|
|
88
|
-
/** 最小列宽。非x虚拟滚动生效。 */
|
|
89
|
-
minWidth?: string | number;
|
|
90
|
-
/** 最大列宽。非x虚拟滚动生效。 */
|
|
91
|
-
maxWidth?: string | number;
|
|
92
|
-
/**th class */
|
|
93
|
-
headerClassName?: string;
|
|
94
|
-
/** td class */
|
|
95
|
-
className?: string;
|
|
96
|
-
/** 排序字段。default: dataIndex */
|
|
97
|
-
sortField?: keyof T;
|
|
98
|
-
/** 排序方式。按数字/字符串 */
|
|
99
|
-
sortType?: 'number' | 'string';
|
|
100
|
-
/** 配置当前列的排序规则 */
|
|
101
|
-
sortConfig?: Omit<SortConfig<T>, 'defaultSort'>;
|
|
102
|
-
/** 固定列 */
|
|
103
|
-
fixed?: 'left' | 'right' | null;
|
|
104
|
-
/** 是否隐藏列 */
|
|
105
|
-
hidden?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* 自定义 td 渲染内容。
|
|
108
|
-
*
|
|
109
|
-
* 组件prop入参:
|
|
110
|
-
* @param props.row 一行的记录。
|
|
111
|
-
* @param props.col 列配置
|
|
112
|
-
* @param props.cellValue row[col.dataIndex] 的值
|
|
113
|
-
* @param props.rowIndex 行索引
|
|
114
|
-
* @param props.colIndex 列索引
|
|
115
|
-
*/
|
|
116
|
-
customCell?: CustomCell<CustomCellProps<T>, T>;
|
|
117
|
-
/**
|
|
118
|
-
* 自定义 th 渲染内容
|
|
119
|
-
*
|
|
120
|
-
* 组件prop入参:
|
|
121
|
-
* @param props.col 列配置
|
|
122
|
-
* @param props.rowIndex 行索引
|
|
123
|
-
* @param props.colIndex 列索引
|
|
124
|
-
*/
|
|
125
|
-
customHeaderCell?: CustomCell<CustomHeaderCellProps<T>, T>;
|
|
126
|
-
/**
|
|
127
|
-
* 自定义 tfoot td 渲染内容
|
|
128
|
-
*
|
|
129
|
-
* 组件prop入参:
|
|
130
|
-
* @param props.row tfoot行的记录。
|
|
131
|
-
* @param props.col 列配置
|
|
132
|
-
* @param props.cellValue row[col.dataIndex] 的值
|
|
133
|
-
* @param props.rowIndex tfoot行索引(从0开始)
|
|
134
|
-
* @param props.colIndex 列索引
|
|
135
|
-
*/
|
|
136
|
-
customFooterCell?: CustomCell<CustomFooterCellProps<T>, T>;
|
|
137
|
-
/** 二级表头 */
|
|
138
|
-
children?: StkTableColumn<T>[];
|
|
139
|
-
/** 单元格合并 */
|
|
140
|
-
mergeCells?: MergeCellsFn<T>;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/** private StkTableColumn type. Add some private key */
|
|
144
|
-
export type PrivateStkTableColumn<T extends Record<string, any>> = StkTableColumn<T> & {
|
|
145
|
-
/** header rowSpan */
|
|
146
|
-
__R_SP__?: number;
|
|
147
|
-
/** header colSpan */
|
|
148
|
-
__C_SP__?: number;
|
|
149
|
-
/**
|
|
150
|
-
* parent not ref
|
|
151
|
-
* @private
|
|
152
|
-
*/
|
|
153
|
-
__P__?: StkTableColumn<T> | null;
|
|
154
|
-
/**
|
|
155
|
-
* Save the calculated width. Used for horizontal virtual scrolling.
|
|
156
|
-
* @private
|
|
157
|
-
*/
|
|
158
|
-
__W__?: number;
|
|
159
|
-
/**
|
|
160
|
-
* 当前列在 tableHeaderLast 中的起始叶子索引(含)。用于多级表头横向虚拟滚动。
|
|
161
|
-
* @private
|
|
162
|
-
*/
|
|
163
|
-
__LF_S__?: number;
|
|
164
|
-
/**
|
|
165
|
-
* 当前列在 tableHeaderLast 中的结束叶子索引(不含)。用于多级表头横向虚拟滚动。
|
|
166
|
-
* @private
|
|
167
|
-
*/
|
|
168
|
-
__LF_E__?: number;
|
|
169
|
-
/**
|
|
170
|
-
* 虚拟滚动右侧 spacer 占用的列数。仅用于内部 spacer 标记列。
|
|
171
|
-
* @private
|
|
172
|
-
*/
|
|
173
|
-
__VT_C_SP__?: number;
|
|
174
|
-
/**
|
|
175
|
-
* Above-viewport placeholder colspan. Marks a placeholder td for rows
|
|
176
|
-
* above the viewport that only need structural colspan, not real content.
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
__VT_PH__?: number;
|
|
180
|
-
};
|
|
181
|
-
/** private row keys */
|
|
182
|
-
export type PrivateRowDT = {
|
|
183
|
-
/**
|
|
184
|
-
* Only expanded row will add this key
|
|
185
|
-
*
|
|
186
|
-
* If user define the `__R_K__` in table data, this value will be used as the row key
|
|
187
|
-
* @private
|
|
188
|
-
*/
|
|
189
|
-
__R_K__?: string;
|
|
190
|
-
/**
|
|
191
|
-
* if row expanded
|
|
192
|
-
* @private
|
|
193
|
-
*/
|
|
194
|
-
__EXP__?: StkTableColumn<any>;
|
|
195
|
-
/**
|
|
196
|
-
* if tree node row expanded
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
__T_EXP__?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* tree parent key
|
|
202
|
-
* @private
|
|
203
|
-
*/
|
|
204
|
-
__T_P_K__?: UniqKey;
|
|
205
|
-
/**
|
|
206
|
-
* tree level
|
|
207
|
-
* @private
|
|
208
|
-
*/
|
|
209
|
-
__T_LV__?: number;
|
|
210
|
-
/** expanded row */
|
|
211
|
-
__EXP_R__?: any;
|
|
212
|
-
/** expanded col */
|
|
213
|
-
__EXP_C__?: StkTableColumn<any>;
|
|
214
|
-
children?: any[];
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
export type SortOption<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* 单列排序状态
|
|
221
|
-
*/
|
|
222
|
-
export type SortState<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'key' | 'dataIndex' | 'sortField' | 'sortType'> & {
|
|
223
|
-
order: Order;
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
export type UniqKey = string | number;
|
|
227
|
-
export type UniqKeyFun = (param: any) => UniqKey;
|
|
228
|
-
export type UniqKeyProp = UniqKey | UniqKeyFun;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* 默认排序配置
|
|
232
|
-
*/
|
|
233
|
-
export type DefaultSortConfig<T extends Record<string, any>> = {
|
|
234
|
-
/**
|
|
235
|
-
* colKey
|
|
236
|
-
*
|
|
237
|
-
* if set `props.colKey`
|
|
238
|
-
*
|
|
239
|
-
* default: StkTableColumn<T>['dataIndex']
|
|
240
|
-
*/
|
|
241
|
-
key?: StkTableColumn<T>['key'];
|
|
242
|
-
dataIndex: StkTableColumn<T>['dataIndex'];
|
|
243
|
-
order: Order;
|
|
244
|
-
sortField?: StkTableColumn<T>['sortField'];
|
|
245
|
-
sortType?: StkTableColumn<T>['sortType'];
|
|
246
|
-
sorter?: StkTableColumn<T>['sorter'];
|
|
247
|
-
/**
|
|
248
|
-
* whether to disable trigger`sort-change` event. default: false
|
|
249
|
-
*/
|
|
250
|
-
silent?: boolean;
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
export type SortConfig<T extends Record<string, any>> = {
|
|
254
|
-
/**
|
|
255
|
-
* TODO: Sort icon display strategy
|
|
256
|
-
* - only-sort[default]: Only show sort icon in sorted column
|
|
257
|
-
* - always
|
|
258
|
-
* - none
|
|
259
|
-
*/
|
|
260
|
-
// showIcon?: "always" | 'only-sort' | 'none';
|
|
261
|
-
/**
|
|
262
|
-
* 1. trigger when init
|
|
263
|
-
* 2. trigger when sort direction is null
|
|
264
|
-
*/
|
|
265
|
-
defaultSort?: DefaultSortConfig<T>;
|
|
266
|
-
/** empty value always sort to bottom */
|
|
267
|
-
emptyToBottom?: boolean;
|
|
268
|
-
/**
|
|
269
|
-
* string sort if use `String.prototype.localCompare`
|
|
270
|
-
* default: false
|
|
271
|
-
*/
|
|
272
|
-
stringLocaleCompare?: boolean;
|
|
273
|
-
/**
|
|
274
|
-
* whether to sort children when sort current column. default: false
|
|
275
|
-
*/
|
|
276
|
-
sortChildren?: boolean;
|
|
277
|
-
/**
|
|
278
|
-
* 是否启用多列排序
|
|
279
|
-
* - false (default): 单列排序,点击新列会取消之前列的排序
|
|
280
|
-
* - true: 多列排序,支持同时按多列排序,通过点击顺序决定优先级
|
|
281
|
-
*/
|
|
282
|
-
multiSort?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* 多列排序时的最大列数限制
|
|
285
|
-
* default: 3
|
|
286
|
-
*/
|
|
287
|
-
multiSortLimit?: number;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/** th td type */
|
|
291
|
-
export const TagType = {
|
|
292
|
-
TH: 0,
|
|
293
|
-
TD: 1,
|
|
294
|
-
/** tfoot */
|
|
295
|
-
TF: 2,
|
|
296
|
-
} as const;
|
|
297
|
-
|
|
298
|
-
export type TagType = (typeof TagType)[keyof typeof TagType];
|
|
299
|
-
|
|
300
|
-
export type HighlightConfig = {
|
|
301
|
-
/** Duration of the highlight in seconds */
|
|
302
|
-
duration?: number;
|
|
303
|
-
/** Frame rate of the highlight */
|
|
304
|
-
fps?: number;
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Configuration options for the sequence column.
|
|
309
|
-
*/
|
|
310
|
-
export type SeqConfig = {
|
|
311
|
-
/** The initial subscript of the sequence number column is used to adapt the paging. */
|
|
312
|
-
startIndex?: number;
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/** Configuration options for the expand column */
|
|
316
|
-
export type ExpandConfig = {
|
|
317
|
-
/**
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
*
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
* @
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
*
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
*
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
1
|
+
import { Component, ComputedRef, ConcreteComponent } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
|
|
4
|
+
export type Order = null | 'asc' | 'desc';
|
|
5
|
+
|
|
6
|
+
type Sorter<T> = boolean | ((data: T[], option: { order: Order; column: any }) => T[]);
|
|
7
|
+
|
|
8
|
+
export type CustomCellProps<T extends Record<string, any>> = {
|
|
9
|
+
row: T;
|
|
10
|
+
col: StkTableColumn<T>;
|
|
11
|
+
/** row[col.dataIndex] 的值 */
|
|
12
|
+
cellValue: any;
|
|
13
|
+
rowIndex: number;
|
|
14
|
+
colIndex: number;
|
|
15
|
+
/**
|
|
16
|
+
* 当前行是否展开
|
|
17
|
+
* - 不展开: null
|
|
18
|
+
* - 展开: 返回column配置
|
|
19
|
+
*/
|
|
20
|
+
expanded?: PrivateRowDT['__EXP__'];
|
|
21
|
+
/** if tree expanded */
|
|
22
|
+
treeExpanded?: PrivateRowDT['__T_EXP__'];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type CustomHeaderCellProps<T extends Record<string, any>> = {
|
|
26
|
+
col: StkTableColumn<T>;
|
|
27
|
+
rowIndex: number;
|
|
28
|
+
colIndex: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type CustomFooterCellProps<T extends Record<string, any>> = {
|
|
32
|
+
col: StkTableColumn<T>;
|
|
33
|
+
row: T;
|
|
34
|
+
cellValue: any;
|
|
35
|
+
rowIndex: number;
|
|
36
|
+
colIndex: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type MergeCellsParam<T extends Record<string, any>> = {
|
|
40
|
+
row: T;
|
|
41
|
+
col: StkTableColumn<T>;
|
|
42
|
+
rowIndex: number;
|
|
43
|
+
colIndex: number;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type MergeCellsFn<T extends Record<string, any>> = (data: MergeCellsParam<T>) => { rowspan?: number; colspan?: number } | undefined;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 自定义渲染单元格
|
|
50
|
+
*
|
|
51
|
+
* `StkTableColumn.customCell` 类型直接定义 `Component<Props>` 如果 Props 属性为必选,则 通过`defineComponent` 创建的组件必须要定义所有的Prop,否则就不适配。但是在函数式组件中是正常使用的。customCell: (props) => {}。
|
|
52
|
+
*
|
|
53
|
+
* 如果定义 Props 所有属性均为可选时。`defineComponent` 定义的组件仅需实现个别的 Prop 即可。但是函数式组件的入参props就需要额外判断是否存在。这增加了使用成本。
|
|
54
|
+
*
|
|
55
|
+
* 因此这里重新组合了Component类型
|
|
56
|
+
*/
|
|
57
|
+
export type CustomCell<T extends CustomCellProps<U> | CustomHeaderCellProps<U>, U extends Record<string, any>> =
|
|
58
|
+
| ConcreteComponent<T>
|
|
59
|
+
| Exclude<Component<Partial<T>>, ConcreteComponent>
|
|
60
|
+
| string;
|
|
61
|
+
|
|
62
|
+
/** 表格列配置 */
|
|
63
|
+
export type StkTableColumn<T extends Record<string, any>> = {
|
|
64
|
+
/**
|
|
65
|
+
* 列唯一键,(可选),不传则默认取dataIndex 字段作为列唯一键。
|
|
66
|
+
*/
|
|
67
|
+
key?: any;
|
|
68
|
+
/**
|
|
69
|
+
* 列类型
|
|
70
|
+
* - seq 序号列
|
|
71
|
+
* - expand 展开列
|
|
72
|
+
* - dragRow 拖拽列(使用sktTableRef.getTableData 获取改变后的顺序)
|
|
73
|
+
* - tree-node 树节点列,这一列前面有展开收起箭头
|
|
74
|
+
*/
|
|
75
|
+
type?: 'seq' | 'expand' | 'dragRow' | 'tree-node';
|
|
76
|
+
/** 取值id */
|
|
77
|
+
dataIndex: keyof T & string;
|
|
78
|
+
/** 表头文字 */
|
|
79
|
+
title?: string;
|
|
80
|
+
/** 列内容对齐方式 */
|
|
81
|
+
align?: 'right' | 'left' | 'center';
|
|
82
|
+
/** 表头内容对齐方式 */
|
|
83
|
+
headerAlign?: 'right' | 'left' | 'center';
|
|
84
|
+
/** 筛选 */
|
|
85
|
+
sorter?: Sorter<T>;
|
|
86
|
+
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
87
|
+
width?: string | number;
|
|
88
|
+
/** 最小列宽。非x虚拟滚动生效。 */
|
|
89
|
+
minWidth?: string | number;
|
|
90
|
+
/** 最大列宽。非x虚拟滚动生效。 */
|
|
91
|
+
maxWidth?: string | number;
|
|
92
|
+
/**th class */
|
|
93
|
+
headerClassName?: string;
|
|
94
|
+
/** td class */
|
|
95
|
+
className?: string;
|
|
96
|
+
/** 排序字段。default: dataIndex */
|
|
97
|
+
sortField?: keyof T;
|
|
98
|
+
/** 排序方式。按数字/字符串 */
|
|
99
|
+
sortType?: 'number' | 'string';
|
|
100
|
+
/** 配置当前列的排序规则 */
|
|
101
|
+
sortConfig?: Omit<SortConfig<T>, 'defaultSort'>;
|
|
102
|
+
/** 固定列 */
|
|
103
|
+
fixed?: 'left' | 'right' | null;
|
|
104
|
+
/** 是否隐藏列 */
|
|
105
|
+
hidden?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* 自定义 td 渲染内容。
|
|
108
|
+
*
|
|
109
|
+
* 组件prop入参:
|
|
110
|
+
* @param props.row 一行的记录。
|
|
111
|
+
* @param props.col 列配置
|
|
112
|
+
* @param props.cellValue row[col.dataIndex] 的值
|
|
113
|
+
* @param props.rowIndex 行索引
|
|
114
|
+
* @param props.colIndex 列索引
|
|
115
|
+
*/
|
|
116
|
+
customCell?: CustomCell<CustomCellProps<T>, T>;
|
|
117
|
+
/**
|
|
118
|
+
* 自定义 th 渲染内容
|
|
119
|
+
*
|
|
120
|
+
* 组件prop入参:
|
|
121
|
+
* @param props.col 列配置
|
|
122
|
+
* @param props.rowIndex 行索引
|
|
123
|
+
* @param props.colIndex 列索引
|
|
124
|
+
*/
|
|
125
|
+
customHeaderCell?: CustomCell<CustomHeaderCellProps<T>, T>;
|
|
126
|
+
/**
|
|
127
|
+
* 自定义 tfoot td 渲染内容
|
|
128
|
+
*
|
|
129
|
+
* 组件prop入参:
|
|
130
|
+
* @param props.row tfoot行的记录。
|
|
131
|
+
* @param props.col 列配置
|
|
132
|
+
* @param props.cellValue row[col.dataIndex] 的值
|
|
133
|
+
* @param props.rowIndex tfoot行索引(从0开始)
|
|
134
|
+
* @param props.colIndex 列索引
|
|
135
|
+
*/
|
|
136
|
+
customFooterCell?: CustomCell<CustomFooterCellProps<T>, T>;
|
|
137
|
+
/** 二级表头 */
|
|
138
|
+
children?: StkTableColumn<T>[];
|
|
139
|
+
/** 单元格合并 */
|
|
140
|
+
mergeCells?: MergeCellsFn<T>;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** private StkTableColumn type. Add some private key */
|
|
144
|
+
export type PrivateStkTableColumn<T extends Record<string, any>> = StkTableColumn<T> & {
|
|
145
|
+
/** header rowSpan */
|
|
146
|
+
__R_SP__?: number;
|
|
147
|
+
/** header colSpan */
|
|
148
|
+
__C_SP__?: number;
|
|
149
|
+
/**
|
|
150
|
+
* parent not ref
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
__P__?: StkTableColumn<T> | null;
|
|
154
|
+
/**
|
|
155
|
+
* Save the calculated width. Used for horizontal virtual scrolling.
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
__W__?: number;
|
|
159
|
+
/**
|
|
160
|
+
* 当前列在 tableHeaderLast 中的起始叶子索引(含)。用于多级表头横向虚拟滚动。
|
|
161
|
+
* @private
|
|
162
|
+
*/
|
|
163
|
+
__LF_S__?: number;
|
|
164
|
+
/**
|
|
165
|
+
* 当前列在 tableHeaderLast 中的结束叶子索引(不含)。用于多级表头横向虚拟滚动。
|
|
166
|
+
* @private
|
|
167
|
+
*/
|
|
168
|
+
__LF_E__?: number;
|
|
169
|
+
/**
|
|
170
|
+
* 虚拟滚动右侧 spacer 占用的列数。仅用于内部 spacer 标记列。
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
__VT_C_SP__?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Above-viewport placeholder colspan. Marks a placeholder td for rows
|
|
176
|
+
* above the viewport that only need structural colspan, not real content.
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
179
|
+
__VT_PH__?: number;
|
|
180
|
+
};
|
|
181
|
+
/** private row keys */
|
|
182
|
+
export type PrivateRowDT = {
|
|
183
|
+
/**
|
|
184
|
+
* Only expanded row will add this key
|
|
185
|
+
*
|
|
186
|
+
* If user define the `__R_K__` in table data, this value will be used as the row key
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
__R_K__?: string;
|
|
190
|
+
/**
|
|
191
|
+
* if row expanded
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
__EXP__?: StkTableColumn<any>;
|
|
195
|
+
/**
|
|
196
|
+
* if tree node row expanded
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
__T_EXP__?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* tree parent key
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
__T_P_K__?: UniqKey;
|
|
205
|
+
/**
|
|
206
|
+
* tree level
|
|
207
|
+
* @private
|
|
208
|
+
*/
|
|
209
|
+
__T_LV__?: number;
|
|
210
|
+
/** expanded row */
|
|
211
|
+
__EXP_R__?: any;
|
|
212
|
+
/** expanded col */
|
|
213
|
+
__EXP_C__?: StkTableColumn<any>;
|
|
214
|
+
children?: any[];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export type SortOption<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 单列排序状态
|
|
221
|
+
*/
|
|
222
|
+
export type SortState<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'key' | 'dataIndex' | 'sortField' | 'sortType'> & {
|
|
223
|
+
order: Order;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export type UniqKey = string | number;
|
|
227
|
+
export type UniqKeyFun = (param: any) => UniqKey;
|
|
228
|
+
export type UniqKeyProp = UniqKey | UniqKeyFun;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 默认排序配置
|
|
232
|
+
*/
|
|
233
|
+
export type DefaultSortConfig<T extends Record<string, any>> = {
|
|
234
|
+
/**
|
|
235
|
+
* colKey
|
|
236
|
+
*
|
|
237
|
+
* if set `props.colKey`
|
|
238
|
+
*
|
|
239
|
+
* default: StkTableColumn<T>['dataIndex']
|
|
240
|
+
*/
|
|
241
|
+
key?: StkTableColumn<T>['key'];
|
|
242
|
+
dataIndex: StkTableColumn<T>['dataIndex'];
|
|
243
|
+
order: Order;
|
|
244
|
+
sortField?: StkTableColumn<T>['sortField'];
|
|
245
|
+
sortType?: StkTableColumn<T>['sortType'];
|
|
246
|
+
sorter?: StkTableColumn<T>['sorter'];
|
|
247
|
+
/**
|
|
248
|
+
* whether to disable trigger`sort-change` event. default: false
|
|
249
|
+
*/
|
|
250
|
+
silent?: boolean;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type SortConfig<T extends Record<string, any>> = {
|
|
254
|
+
/**
|
|
255
|
+
* TODO: Sort icon display strategy
|
|
256
|
+
* - only-sort[default]: Only show sort icon in sorted column
|
|
257
|
+
* - always
|
|
258
|
+
* - none
|
|
259
|
+
*/
|
|
260
|
+
// showIcon?: "always" | 'only-sort' | 'none';
|
|
261
|
+
/**
|
|
262
|
+
* 1. trigger when init
|
|
263
|
+
* 2. trigger when sort direction is null
|
|
264
|
+
*/
|
|
265
|
+
defaultSort?: DefaultSortConfig<T>;
|
|
266
|
+
/** empty value always sort to bottom */
|
|
267
|
+
emptyToBottom?: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* string sort if use `String.prototype.localCompare`
|
|
270
|
+
* default: false
|
|
271
|
+
*/
|
|
272
|
+
stringLocaleCompare?: boolean;
|
|
273
|
+
/**
|
|
274
|
+
* whether to sort children when sort current column. default: false
|
|
275
|
+
*/
|
|
276
|
+
sortChildren?: boolean;
|
|
277
|
+
/**
|
|
278
|
+
* 是否启用多列排序
|
|
279
|
+
* - false (default): 单列排序,点击新列会取消之前列的排序
|
|
280
|
+
* - true: 多列排序,支持同时按多列排序,通过点击顺序决定优先级
|
|
281
|
+
*/
|
|
282
|
+
multiSort?: boolean;
|
|
283
|
+
/**
|
|
284
|
+
* 多列排序时的最大列数限制
|
|
285
|
+
* default: 3
|
|
286
|
+
*/
|
|
287
|
+
multiSortLimit?: number;
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
/** th td type */
|
|
291
|
+
export const TagType = {
|
|
292
|
+
TH: 0,
|
|
293
|
+
TD: 1,
|
|
294
|
+
/** tfoot */
|
|
295
|
+
TF: 2,
|
|
296
|
+
} as const;
|
|
297
|
+
|
|
298
|
+
export type TagType = (typeof TagType)[keyof typeof TagType];
|
|
299
|
+
|
|
300
|
+
export type HighlightConfig = {
|
|
301
|
+
/** Duration of the highlight in seconds */
|
|
302
|
+
duration?: number;
|
|
303
|
+
/** Frame rate of the highlight */
|
|
304
|
+
fps?: number;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Configuration options for the sequence column.
|
|
309
|
+
*/
|
|
310
|
+
export type SeqConfig = {
|
|
311
|
+
/** The initial subscript of the sequence number column is used to adapt the paging. */
|
|
312
|
+
startIndex?: number;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/** Configuration options for the expand column */
|
|
316
|
+
export type ExpandConfig = {
|
|
317
|
+
/**
|
|
318
|
+
* worked in virtual mode
|
|
319
|
+
* 展开行的行高,支持动态修改(修改后行高累计与虚拟滚动会一同重算)
|
|
320
|
+
*/
|
|
321
|
+
height?: number;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/** drag row config */
|
|
325
|
+
export type DragRowConfig = {
|
|
326
|
+
mode?: 'none' | 'insert' | 'swap';
|
|
327
|
+
// disabled?: (row: T, rowIndex: number) => boolean;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export type TreeConfig = {
|
|
331
|
+
// childrenField?: string;
|
|
332
|
+
defaultExpandAll?: boolean;
|
|
333
|
+
defaultExpandKeys?: UniqKey[];
|
|
334
|
+
defaultExpandLevel?: number;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
/** header drag config */
|
|
338
|
+
export type HeaderDragConfig<DT extends Record<string, any> = any> = {
|
|
339
|
+
/**
|
|
340
|
+
* col switch mode
|
|
341
|
+
* - none
|
|
342
|
+
* - insert - (default)
|
|
343
|
+
* - swap
|
|
344
|
+
*/
|
|
345
|
+
mode?: 'none' | 'insert' | 'swap';
|
|
346
|
+
/** disabled drag col */
|
|
347
|
+
disabled?: (col: StkTableColumn<DT>) => boolean;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
export type AutoRowHeightConfig<DT> = {
|
|
351
|
+
/** Estimated row height */
|
|
352
|
+
expectedHeight?: number | ((row: DT) => number);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export type ColResizableConfig<DT extends Record<string, any>> = {
|
|
356
|
+
disabled: (col: StkTableColumn<DT>) => boolean;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
export type RowKeyGen = (row: any) => UniqKey;
|
|
360
|
+
|
|
361
|
+
export type ColKeyGen = ComputedRef<(col: StkTableColumn<any>) => UniqKey>;
|
|
362
|
+
|
|
363
|
+
export type CellKeyGen = (row: any, col: StkTableColumn<any>) => string;
|
|
364
|
+
|
|
365
|
+
export type RowActiveOption<DT> = {
|
|
366
|
+
enabled?: boolean;
|
|
367
|
+
/** disabled row active */
|
|
368
|
+
disabled?: (row: DT) => boolean;
|
|
369
|
+
/** current row again click can revoke active */
|
|
370
|
+
revokable?: boolean;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/** 单元格选区范围 */
|
|
374
|
+
export type AreaSelectionRange = {
|
|
375
|
+
index: {
|
|
376
|
+
/** column index range @deprecated */
|
|
377
|
+
x: [number, number];
|
|
378
|
+
/** row index range @deprecated */
|
|
379
|
+
y: [number, number];
|
|
380
|
+
/** start point index*/
|
|
381
|
+
begin: { row: number; col: number };
|
|
382
|
+
/** end point index */
|
|
383
|
+
end: { row: number; col: number };
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
/** 单元格选区配置 */
|
|
388
|
+
export type AreaSelectionConfig<T extends Record<string, any> = any> = {
|
|
389
|
+
/** default: true */
|
|
390
|
+
enabled?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* 复制时的单元格文本格式化回调。
|
|
393
|
+
* 如果你使用了 customCell 自定义渲染,应该提供此回调以确保复制内容与展示内容一致。
|
|
394
|
+
* @param row 行数据
|
|
395
|
+
* @param col 列配置
|
|
396
|
+
* @param rawValue row[col.dataIndex] 的原始值
|
|
397
|
+
* @returns 复制到剪贴板的文本
|
|
398
|
+
*/
|
|
399
|
+
formatCellForClipboard?: (row: T, col: StkTableColumn<T>, rawValue: any) => string;
|
|
400
|
+
/**
|
|
401
|
+
* 是否启用键盘控制选区移动。
|
|
402
|
+
* 启用后,方向键/Tab/Shift+Tab 可控制选区移动,类似 Excel 行为。
|
|
403
|
+
* 启用此功能后,原有的键盘滚动行为将失效。
|
|
404
|
+
* @default false
|
|
405
|
+
*/
|
|
406
|
+
keyboard?: boolean;
|
|
407
|
+
/**
|
|
408
|
+
* 是否启用 Ctrl 多选功能。
|
|
409
|
+
* 启用后,按住 Ctrl/Cmd 键点击可以选择多个不连续的区域。
|
|
410
|
+
* @default true
|
|
411
|
+
*/
|
|
412
|
+
ctrl?: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* 是否启用 Shift 扩选功能。
|
|
415
|
+
* 启用后,按住 Shift 键点击可以从锚点扩展到当前位置。
|
|
416
|
+
* @default true
|
|
417
|
+
*/
|
|
418
|
+
shift?: boolean;
|
|
419
|
+
/**
|
|
420
|
+
* 高亮配置
|
|
421
|
+
*/
|
|
422
|
+
highlight?: {
|
|
423
|
+
/**
|
|
424
|
+
* 是否启用单元格高亮与选中边框。
|
|
425
|
+
* @default true
|
|
426
|
+
*/
|
|
427
|
+
cell?: boolean;
|
|
428
|
+
/**
|
|
429
|
+
* 是否启用行高亮(单元格跨越的整行都会高亮)。
|
|
430
|
+
* @default false
|
|
431
|
+
*/
|
|
432
|
+
row?: boolean;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/** 获取选中的单元格信息 */
|
|
437
|
+
export type AreaSelectionSetterRange<DT extends Record<string, any>> = {
|
|
438
|
+
begin: { row: number | DT; col?: number | StkTableColumn<DT> };
|
|
439
|
+
end?: { row: number | DT; col?: number | StkTableColumn<DT> };
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
export type AreaSelectionSetterOption = {
|
|
443
|
+
silent?: boolean;
|
|
444
|
+
scrollToView?: boolean;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
/** 实验性功能配置 */
|
|
448
|
+
export type ExperimentalConfig = {
|
|
449
|
+
/** use transform to simulate scroll */
|
|
450
|
+
scrollY?: boolean;
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
/** 表格底部配置 */
|
|
454
|
+
export type FooterConfig = {
|
|
455
|
+
/**
|
|
456
|
+
* 表格底部吸附位置
|
|
457
|
+
* - bottom: 吸附在表格底部(默认)
|
|
458
|
+
* - top: 吸附在表格顶部
|
|
459
|
+
*/
|
|
460
|
+
position?: 'bottom' | 'top';
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* scrollTo options 重载中单个滚动轴的定位目标。
|
|
465
|
+
* 最终坐标 = `index` 或 `key` 解析出的基准偏移 + `px` 附加偏移。
|
|
466
|
+
*/
|
|
467
|
+
export interface ScrollAxisTarget {
|
|
468
|
+
/**
|
|
469
|
+
* 目标索引(0 起始)
|
|
470
|
+
* - `top` 轴:当前展示顺序(排序/筛选/树展开后)的行索引
|
|
471
|
+
* - `left` 轴:叶子列(最深层表头列)索引
|
|
472
|
+
* 与 `key` 同时给出时 `index` 优先
|
|
473
|
+
*/
|
|
474
|
+
index?: number;
|
|
475
|
+
/**
|
|
476
|
+
* 目标键值
|
|
477
|
+
* - `top` 轴:`props.rowKey` 对应的行键值
|
|
478
|
+
* - `left` 轴:列的 `dataIndex`
|
|
479
|
+
*/
|
|
480
|
+
key?: string | number;
|
|
481
|
+
/** 在基准偏移之上叠加的像素偏移,可为负值。仅传 `px` 时基准为 0 */
|
|
482
|
+
px?: number;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** scrollTo 实例方法 options 重载的参数 */
|
|
486
|
+
export interface ScrollToOptions {
|
|
487
|
+
/** 纵向目标:像素坐标或行定位目标。省略表示不改变纵向位置 */
|
|
488
|
+
top?: number | ScrollAxisTarget;
|
|
489
|
+
/** 横向目标:像素坐标或列定位目标。省略表示不改变横向位置 */
|
|
490
|
+
left?: number | ScrollAxisTarget;
|
|
491
|
+
/** 滚动行为,同原生 ScrollToOptions.behavior,默认 'auto'(立即跳转) */
|
|
492
|
+
behavior?: ScrollBehavior;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* scrollTo 实例方法的函数签名(数字重载 + options 重载)。
|
|
497
|
+
* - 数字重载中 `null` 表示不改变对应轴,省略默认 0
|
|
498
|
+
* - options 重载中省略的轴表示不改变位置
|
|
499
|
+
*/
|
|
500
|
+
export interface ScrollToFn {
|
|
501
|
+
(top?: number | null, left?: number | null): void;
|
|
502
|
+
(options: ScrollToOptions): void;
|
|
503
|
+
}
|