stk-table-vue 0.8.8 → 0.8.9
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/lib/src/StkTable/StkTable.vue.d.ts +753 -749
- package/lib/src/StkTable/const.d.ts +36 -33
- package/lib/src/StkTable/types/index.d.ts +270 -263
- package/lib/src/StkTable/useMergeCells.d.ts +8 -8
- package/lib/stk-table-vue.js +2851 -2839
- package/package.json +1 -1
- package/src/StkTable/StkTable.vue +41 -20
- package/src/StkTable/const.ts +7 -1
- package/src/StkTable/types/index.ts +8 -0
- package/src/StkTable/useMergeCells.ts +12 -19
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export declare const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export declare const
|
|
22
|
-
/**
|
|
23
|
-
export declare const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export declare const
|
|
27
|
-
/**
|
|
28
|
-
export declare const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { RowActiveOption } from './types';
|
|
2
|
+
|
|
3
|
+
export declare const DEFAULT_COL_WIDTH = "100";
|
|
4
|
+
export declare const DEFAULT_TABLE_HEIGHT = 100;
|
|
5
|
+
export declare const DEFAULT_TABLE_WIDTH = 200;
|
|
6
|
+
export declare const DEFAULT_ROW_HEIGHT = 28;
|
|
7
|
+
/** highlight background */
|
|
8
|
+
export declare const HIGHLIGHT_COLOR: {
|
|
9
|
+
light: {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
};
|
|
13
|
+
dark: {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare const HIGHLIGHT_DURATION = 2000;
|
|
19
|
+
/** highlight change frequency 1000/30 -> 30FPS */
|
|
20
|
+
export declare const HIGHLIGHT_ROW_CLASS = "highlight-row";
|
|
21
|
+
export declare const HIGHLIGHT_CELL_CLASS = "highlight-cell";
|
|
22
|
+
/** legacy sticky compatible mode */
|
|
23
|
+
export declare const IS_LEGACY_MODE: boolean;
|
|
24
|
+
/** default props.smoothDefault */
|
|
25
|
+
export declare const DEFAULT_SMOOTH_SCROLL: boolean;
|
|
26
|
+
export declare const STK_ID_PREFIX = "stk";
|
|
27
|
+
/** expanded row key prefix */
|
|
28
|
+
export declare const EXPANDED_ROW_KEY_PREFIX = "expanded-";
|
|
29
|
+
/** cell key split str */
|
|
30
|
+
export declare const CELL_KEY_SEPARATE = "--";
|
|
31
|
+
export declare const DEFAULT_SORT_CONFIG: {
|
|
32
|
+
emptyToBottom: false;
|
|
33
|
+
stringLocaleCompare: false;
|
|
34
|
+
sortChildren: false;
|
|
35
|
+
};
|
|
36
|
+
export declare const DEFAULT_ROW_ACTIVE_CONFIG: Required<RowActiveOption<any>>;
|
|
@@ -1,263 +1,270 @@
|
|
|
1
|
-
import { Component, ComputedRef, ConcreteComponent } from 'vue';
|
|
2
|
-
|
|
3
|
-
/** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
|
|
4
|
-
export type Order = null | 'asc' | 'desc';
|
|
5
|
-
type Sorter<T> = boolean | ((data: T[], option: {
|
|
6
|
-
order: Order;
|
|
7
|
-
column: any;
|
|
8
|
-
}) => T[]);
|
|
9
|
-
export type CustomCellProps<T extends Record<string, any>> = {
|
|
10
|
-
row: T;
|
|
11
|
-
col: StkTableColumn<T>;
|
|
12
|
-
/** row[col.dataIndex] 的值 */
|
|
13
|
-
cellValue: any;
|
|
14
|
-
rowIndex: number;
|
|
15
|
-
colIndex: number;
|
|
16
|
-
/**
|
|
17
|
-
* 当前行是否展开
|
|
18
|
-
* - 不展开: null
|
|
19
|
-
* - 展开: 返回column配置
|
|
20
|
-
*/
|
|
21
|
-
expanded?: PrivateRowDT['__EXPANDED__'];
|
|
22
|
-
};
|
|
23
|
-
export type CustomHeaderCellProps<T extends Record<string, any>> = {
|
|
24
|
-
col: StkTableColumn<T>;
|
|
25
|
-
rowIndex: number;
|
|
26
|
-
colIndex: number;
|
|
27
|
-
};
|
|
28
|
-
export type MergeCellsParam<T extends Record<string, any>> = {
|
|
29
|
-
row: T;
|
|
30
|
-
col: StkTableColumn<T>;
|
|
31
|
-
rowIndex: number;
|
|
32
|
-
colIndex: number;
|
|
33
|
-
};
|
|
34
|
-
export type MergeCellsFn<T extends Record<string, any>> = (data: MergeCellsParam<T>) => {
|
|
35
|
-
rowspan?: number;
|
|
36
|
-
colspan?: number;
|
|
37
|
-
} | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* 自定义渲染单元格
|
|
40
|
-
*
|
|
41
|
-
* `StkTableColumn.customCell` 类型直接定义 `Component<Props>` 如果 Props 属性为必选,则 通过`defineComponent` 创建的组件必须要定义所有的Prop,否则就不适配。但是在函数式组件中是正常使用的。customCell: (props) => {}。
|
|
42
|
-
*
|
|
43
|
-
* 如果定义 Props 所有属性均为可选时。`defineComponent` 定义的组件仅需实现个别的 Prop 即可。但是函数式组件的入参props就需要额外判断是否存在。这增加了使用成本。
|
|
44
|
-
*
|
|
45
|
-
* 因此这里重新组合了Component类型
|
|
46
|
-
*/
|
|
47
|
-
export type CustomCell<T extends CustomCellProps<U> | CustomHeaderCellProps<U>, U extends Record<string, any>> = ConcreteComponent<T> | Exclude<Component<Partial<T>>, ConcreteComponent> | string;
|
|
48
|
-
/** 表格列配置 */
|
|
49
|
-
export type StkTableColumn<T extends Record<string, any>> = {
|
|
50
|
-
/**
|
|
51
|
-
* 列唯一键,(可选),不传则默认取dataIndex 字段作为列唯一键。
|
|
52
|
-
*/
|
|
53
|
-
key?: any;
|
|
54
|
-
/**
|
|
55
|
-
* 列类型
|
|
56
|
-
* - seq 序号列
|
|
57
|
-
* - expand 展开列
|
|
58
|
-
* - dragRow 拖拽列(使用sktTableRef.getTableData 获取改变后的顺序)
|
|
59
|
-
* - tree-node 树节点列,这一列前面有展开收起箭头
|
|
60
|
-
*/
|
|
61
|
-
type?: 'seq' | 'expand' | 'dragRow' | 'tree-node';
|
|
62
|
-
/** 取值id */
|
|
63
|
-
dataIndex: keyof T & string;
|
|
64
|
-
/** 表头文字 */
|
|
65
|
-
title?: string;
|
|
66
|
-
/** 列内容对齐方式 */
|
|
67
|
-
align?: 'right' | 'left' | 'center';
|
|
68
|
-
/** 表头内容对齐方式 */
|
|
69
|
-
headerAlign?: 'right' | 'left' | 'center';
|
|
70
|
-
/** 筛选 */
|
|
71
|
-
sorter?: Sorter<T>;
|
|
72
|
-
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
73
|
-
width?: string | number;
|
|
74
|
-
/** 最小列宽。非x虚拟滚动生效。 */
|
|
75
|
-
minWidth?: string | number;
|
|
76
|
-
/** 最大列宽。非x虚拟滚动生效。 */
|
|
77
|
-
maxWidth?: string | number;
|
|
78
|
-
/**th class */
|
|
79
|
-
headerClassName?: string;
|
|
80
|
-
/** td class */
|
|
81
|
-
className?: string;
|
|
82
|
-
/** 排序字段。default: dataIndex */
|
|
83
|
-
sortField?: keyof T;
|
|
84
|
-
/** 排序方式。按数字/字符串 */
|
|
85
|
-
sortType?: 'number' | 'string';
|
|
86
|
-
/** 配置当前列的排序规则 */
|
|
87
|
-
sortConfig?: Omit<SortConfig<T>, 'defaultSort'>;
|
|
88
|
-
/** 固定列 */
|
|
89
|
-
fixed?: 'left' | 'right' | null;
|
|
90
|
-
/**
|
|
91
|
-
* 自定义 td 渲染内容。
|
|
92
|
-
*
|
|
93
|
-
* 组件prop入参:
|
|
94
|
-
* @param props.row 一行的记录。
|
|
95
|
-
* @param props.col 列配置
|
|
96
|
-
* @param props.cellValue row[col.dataIndex] 的值
|
|
97
|
-
* @param props.rowIndex 行索引
|
|
98
|
-
* @param props.colIndex 列索引
|
|
99
|
-
*/
|
|
100
|
-
customCell?: CustomCell<CustomCellProps<T>, T>;
|
|
101
|
-
/**
|
|
102
|
-
* 自定义 th 渲染内容
|
|
103
|
-
*
|
|
104
|
-
* 组件prop入参:
|
|
105
|
-
* @param props.col 列配置
|
|
106
|
-
* @param props.rowIndex 行索引
|
|
107
|
-
* @param props.colIndex 列索引
|
|
108
|
-
*/
|
|
109
|
-
customHeaderCell?: CustomCell<CustomHeaderCellProps<T>, T>;
|
|
110
|
-
/** 二级表头 */
|
|
111
|
-
children?: StkTableColumn<T>[];
|
|
112
|
-
/** 单元格合并 */
|
|
113
|
-
mergeCells?: MergeCellsFn<T>;
|
|
114
|
-
};
|
|
115
|
-
/** private StkTableColumn type. Add some private key */
|
|
116
|
-
export type PrivateStkTableColumn<T extends Record<string, any>> = StkTableColumn<T> & {
|
|
117
|
-
/** header rowSpan */
|
|
118
|
-
__R_SP__?: number;
|
|
119
|
-
/** header colSpan */
|
|
120
|
-
__C_SP__?: number;
|
|
121
|
-
/**
|
|
122
|
-
* parent not ref
|
|
123
|
-
* @private
|
|
124
|
-
*/
|
|
125
|
-
__PARENT__?: StkTableColumn<T> | null;
|
|
126
|
-
/**
|
|
127
|
-
* Save the calculated width. Used for horizontal virtual scrolling.
|
|
128
|
-
* @private
|
|
129
|
-
*/
|
|
130
|
-
__WIDTH__?: number;
|
|
131
|
-
};
|
|
132
|
-
/** private row keys */
|
|
133
|
-
export type PrivateRowDT = {
|
|
134
|
-
/**
|
|
135
|
-
* Only expanded row will add this key
|
|
136
|
-
*
|
|
137
|
-
* If user define the `__ROW_KEY__` in table data, this value will be used as the row key
|
|
138
|
-
* @private
|
|
139
|
-
*/
|
|
140
|
-
__ROW_KEY__?: string;
|
|
141
|
-
/**
|
|
142
|
-
* if row expanded
|
|
143
|
-
* @private
|
|
144
|
-
*/
|
|
145
|
-
__EXPANDED__?: StkTableColumn<any> | null;
|
|
146
|
-
/**
|
|
147
|
-
* if tree node row expanded
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
__T_EXPANDED__?: boolean;
|
|
151
|
-
/**
|
|
152
|
-
* tree parent key
|
|
153
|
-
* @private
|
|
154
|
-
*/
|
|
155
|
-
__T_PARENT_K__?: UniqKey;
|
|
156
|
-
/**
|
|
157
|
-
* tree level
|
|
158
|
-
* @private
|
|
159
|
-
*/
|
|
160
|
-
__T_LV__?: number;
|
|
161
|
-
};
|
|
162
|
-
export type SortOption<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
|
|
163
|
-
export type SortState<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'dataIndex' | 'sortField' | 'sortType'> & {
|
|
164
|
-
order: Order;
|
|
165
|
-
};
|
|
166
|
-
export type UniqKey = string | number;
|
|
167
|
-
export type UniqKeyFun = (param: any) => UniqKey;
|
|
168
|
-
export type UniqKeyProp = UniqKey | UniqKeyFun;
|
|
169
|
-
export type SortConfig<T extends Record<string, any>> = {
|
|
170
|
-
/**
|
|
171
|
-
* 1. trigger when init
|
|
172
|
-
* 2. trigger when sort direction is null
|
|
173
|
-
*/
|
|
174
|
-
defaultSort?: {
|
|
175
|
-
/**
|
|
176
|
-
* colKey
|
|
177
|
-
*
|
|
178
|
-
* if set `props.colKey`
|
|
179
|
-
*
|
|
180
|
-
* default: StkTableColumn<T>['dataIndex']
|
|
181
|
-
*/
|
|
182
|
-
key?: StkTableColumn<T>['key'];
|
|
183
|
-
dataIndex: StkTableColumn<T>['dataIndex'];
|
|
184
|
-
order: Order;
|
|
185
|
-
sortField?: StkTableColumn<T>['sortField'];
|
|
186
|
-
sortType?: StkTableColumn<T>['sortType'];
|
|
187
|
-
sorter?: StkTableColumn<T>['sorter'];
|
|
188
|
-
/**
|
|
189
|
-
* whether to disable trigger`sort-change` event. default: false
|
|
190
|
-
*/
|
|
191
|
-
silent?: boolean;
|
|
192
|
-
};
|
|
193
|
-
/** empty value always sort to bottom */
|
|
194
|
-
emptyToBottom?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* string sort if use `String.prototype.localCompare`
|
|
197
|
-
* default: false
|
|
198
|
-
*/
|
|
199
|
-
stringLocaleCompare?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* whether to sort children when sort current column. default: false
|
|
202
|
-
*/
|
|
203
|
-
sortChildren?: boolean;
|
|
204
|
-
};
|
|
205
|
-
/** th td type */
|
|
206
|
-
export declare const enum TagType {
|
|
207
|
-
TH = 0,
|
|
208
|
-
TD = 1
|
|
209
|
-
}
|
|
210
|
-
export type HighlightConfig = {
|
|
211
|
-
/** Duration of the highlight in seconds */
|
|
212
|
-
duration?: number;
|
|
213
|
-
/** Frame rate of the highlight */
|
|
214
|
-
fps?: number;
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Configuration options for the sequence column.
|
|
218
|
-
*/
|
|
219
|
-
export type SeqConfig = {
|
|
220
|
-
/** The initial subscript of the sequence number column is used to adapt the paging. */
|
|
221
|
-
startIndex?: number;
|
|
222
|
-
};
|
|
223
|
-
/** Configuration options for the expand column */
|
|
224
|
-
export type ExpandConfig = {
|
|
225
|
-
/** worked in virtual mode */
|
|
226
|
-
height?: number;
|
|
227
|
-
};
|
|
228
|
-
export type ExpandedRow = PrivateRowDT & {
|
|
229
|
-
__EXPANDED_ROW__: any;
|
|
230
|
-
__EXPANDED_COL__: any;
|
|
231
|
-
};
|
|
232
|
-
/** drag row config */
|
|
233
|
-
export type DragRowConfig = {
|
|
234
|
-
mode?: 'none' | 'insert' | 'swap';
|
|
235
|
-
};
|
|
236
|
-
export type TreeConfig = {
|
|
237
|
-
defaultExpandAll?: boolean;
|
|
238
|
-
defaultExpandKeys?: UniqKey[];
|
|
239
|
-
defaultExpandLevel?: number;
|
|
240
|
-
};
|
|
241
|
-
/** header drag config */
|
|
242
|
-
export type HeaderDragConfig<DT extends Record<string, any> = any> = {
|
|
243
|
-
/**
|
|
244
|
-
* col switch mode
|
|
245
|
-
* - none
|
|
246
|
-
* - insert - (default)
|
|
247
|
-
* - swap
|
|
248
|
-
*/
|
|
249
|
-
mode?: 'none' | 'insert' | 'swap';
|
|
250
|
-
/** disabled drag col */
|
|
251
|
-
disabled?: (col: StkTableColumn<DT>) => boolean;
|
|
252
|
-
};
|
|
253
|
-
export type AutoRowHeightConfig<DT> = {
|
|
254
|
-
/** Estimated row height */
|
|
255
|
-
expectedHeight?: number | ((row: DT) => number);
|
|
256
|
-
};
|
|
257
|
-
export type ColResizableConfig<DT extends Record<string, any>> = {
|
|
258
|
-
disabled: (col: StkTableColumn<DT>) => boolean;
|
|
259
|
-
};
|
|
260
|
-
export type RowKeyGen = (row: any) => UniqKey;
|
|
261
|
-
export type ColKeyGen = ComputedRef<(col: StkTableColumn<any>) => UniqKey>;
|
|
262
|
-
export type CellKeyGen = (row: any, col: StkTableColumn<any>) => string;
|
|
263
|
-
export {
|
|
1
|
+
import { Component, ComputedRef, ConcreteComponent } from 'vue';
|
|
2
|
+
|
|
3
|
+
/** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
|
|
4
|
+
export type Order = null | 'asc' | 'desc';
|
|
5
|
+
type Sorter<T> = boolean | ((data: T[], option: {
|
|
6
|
+
order: Order;
|
|
7
|
+
column: any;
|
|
8
|
+
}) => T[]);
|
|
9
|
+
export type CustomCellProps<T extends Record<string, any>> = {
|
|
10
|
+
row: T;
|
|
11
|
+
col: StkTableColumn<T>;
|
|
12
|
+
/** row[col.dataIndex] 的值 */
|
|
13
|
+
cellValue: any;
|
|
14
|
+
rowIndex: number;
|
|
15
|
+
colIndex: number;
|
|
16
|
+
/**
|
|
17
|
+
* 当前行是否展开
|
|
18
|
+
* - 不展开: null
|
|
19
|
+
* - 展开: 返回column配置
|
|
20
|
+
*/
|
|
21
|
+
expanded?: PrivateRowDT['__EXPANDED__'];
|
|
22
|
+
};
|
|
23
|
+
export type CustomHeaderCellProps<T extends Record<string, any>> = {
|
|
24
|
+
col: StkTableColumn<T>;
|
|
25
|
+
rowIndex: number;
|
|
26
|
+
colIndex: number;
|
|
27
|
+
};
|
|
28
|
+
export type MergeCellsParam<T extends Record<string, any>> = {
|
|
29
|
+
row: T;
|
|
30
|
+
col: StkTableColumn<T>;
|
|
31
|
+
rowIndex: number;
|
|
32
|
+
colIndex: number;
|
|
33
|
+
};
|
|
34
|
+
export type MergeCellsFn<T extends Record<string, any>> = (data: MergeCellsParam<T>) => {
|
|
35
|
+
rowspan?: number;
|
|
36
|
+
colspan?: number;
|
|
37
|
+
} | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* 自定义渲染单元格
|
|
40
|
+
*
|
|
41
|
+
* `StkTableColumn.customCell` 类型直接定义 `Component<Props>` 如果 Props 属性为必选,则 通过`defineComponent` 创建的组件必须要定义所有的Prop,否则就不适配。但是在函数式组件中是正常使用的。customCell: (props) => {}。
|
|
42
|
+
*
|
|
43
|
+
* 如果定义 Props 所有属性均为可选时。`defineComponent` 定义的组件仅需实现个别的 Prop 即可。但是函数式组件的入参props就需要额外判断是否存在。这增加了使用成本。
|
|
44
|
+
*
|
|
45
|
+
* 因此这里重新组合了Component类型
|
|
46
|
+
*/
|
|
47
|
+
export type CustomCell<T extends CustomCellProps<U> | CustomHeaderCellProps<U>, U extends Record<string, any>> = ConcreteComponent<T> | Exclude<Component<Partial<T>>, ConcreteComponent> | string;
|
|
48
|
+
/** 表格列配置 */
|
|
49
|
+
export type StkTableColumn<T extends Record<string, any>> = {
|
|
50
|
+
/**
|
|
51
|
+
* 列唯一键,(可选),不传则默认取dataIndex 字段作为列唯一键。
|
|
52
|
+
*/
|
|
53
|
+
key?: any;
|
|
54
|
+
/**
|
|
55
|
+
* 列类型
|
|
56
|
+
* - seq 序号列
|
|
57
|
+
* - expand 展开列
|
|
58
|
+
* - dragRow 拖拽列(使用sktTableRef.getTableData 获取改变后的顺序)
|
|
59
|
+
* - tree-node 树节点列,这一列前面有展开收起箭头
|
|
60
|
+
*/
|
|
61
|
+
type?: 'seq' | 'expand' | 'dragRow' | 'tree-node';
|
|
62
|
+
/** 取值id */
|
|
63
|
+
dataIndex: keyof T & string;
|
|
64
|
+
/** 表头文字 */
|
|
65
|
+
title?: string;
|
|
66
|
+
/** 列内容对齐方式 */
|
|
67
|
+
align?: 'right' | 'left' | 'center';
|
|
68
|
+
/** 表头内容对齐方式 */
|
|
69
|
+
headerAlign?: 'right' | 'left' | 'center';
|
|
70
|
+
/** 筛选 */
|
|
71
|
+
sorter?: Sorter<T>;
|
|
72
|
+
/** 列宽。横向虚拟滚动时必须设置。 */
|
|
73
|
+
width?: string | number;
|
|
74
|
+
/** 最小列宽。非x虚拟滚动生效。 */
|
|
75
|
+
minWidth?: string | number;
|
|
76
|
+
/** 最大列宽。非x虚拟滚动生效。 */
|
|
77
|
+
maxWidth?: string | number;
|
|
78
|
+
/**th class */
|
|
79
|
+
headerClassName?: string;
|
|
80
|
+
/** td class */
|
|
81
|
+
className?: string;
|
|
82
|
+
/** 排序字段。default: dataIndex */
|
|
83
|
+
sortField?: keyof T;
|
|
84
|
+
/** 排序方式。按数字/字符串 */
|
|
85
|
+
sortType?: 'number' | 'string';
|
|
86
|
+
/** 配置当前列的排序规则 */
|
|
87
|
+
sortConfig?: Omit<SortConfig<T>, 'defaultSort'>;
|
|
88
|
+
/** 固定列 */
|
|
89
|
+
fixed?: 'left' | 'right' | null;
|
|
90
|
+
/**
|
|
91
|
+
* 自定义 td 渲染内容。
|
|
92
|
+
*
|
|
93
|
+
* 组件prop入参:
|
|
94
|
+
* @param props.row 一行的记录。
|
|
95
|
+
* @param props.col 列配置
|
|
96
|
+
* @param props.cellValue row[col.dataIndex] 的值
|
|
97
|
+
* @param props.rowIndex 行索引
|
|
98
|
+
* @param props.colIndex 列索引
|
|
99
|
+
*/
|
|
100
|
+
customCell?: CustomCell<CustomCellProps<T>, T>;
|
|
101
|
+
/**
|
|
102
|
+
* 自定义 th 渲染内容
|
|
103
|
+
*
|
|
104
|
+
* 组件prop入参:
|
|
105
|
+
* @param props.col 列配置
|
|
106
|
+
* @param props.rowIndex 行索引
|
|
107
|
+
* @param props.colIndex 列索引
|
|
108
|
+
*/
|
|
109
|
+
customHeaderCell?: CustomCell<CustomHeaderCellProps<T>, T>;
|
|
110
|
+
/** 二级表头 */
|
|
111
|
+
children?: StkTableColumn<T>[];
|
|
112
|
+
/** 单元格合并 */
|
|
113
|
+
mergeCells?: MergeCellsFn<T>;
|
|
114
|
+
};
|
|
115
|
+
/** private StkTableColumn type. Add some private key */
|
|
116
|
+
export type PrivateStkTableColumn<T extends Record<string, any>> = StkTableColumn<T> & {
|
|
117
|
+
/** header rowSpan */
|
|
118
|
+
__R_SP__?: number;
|
|
119
|
+
/** header colSpan */
|
|
120
|
+
__C_SP__?: number;
|
|
121
|
+
/**
|
|
122
|
+
* parent not ref
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
__PARENT__?: StkTableColumn<T> | null;
|
|
126
|
+
/**
|
|
127
|
+
* Save the calculated width. Used for horizontal virtual scrolling.
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
__WIDTH__?: number;
|
|
131
|
+
};
|
|
132
|
+
/** private row keys */
|
|
133
|
+
export type PrivateRowDT = {
|
|
134
|
+
/**
|
|
135
|
+
* Only expanded row will add this key
|
|
136
|
+
*
|
|
137
|
+
* If user define the `__ROW_KEY__` in table data, this value will be used as the row key
|
|
138
|
+
* @private
|
|
139
|
+
*/
|
|
140
|
+
__ROW_KEY__?: string;
|
|
141
|
+
/**
|
|
142
|
+
* if row expanded
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
__EXPANDED__?: StkTableColumn<any> | null;
|
|
146
|
+
/**
|
|
147
|
+
* if tree node row expanded
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
__T_EXPANDED__?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* tree parent key
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
__T_PARENT_K__?: UniqKey;
|
|
156
|
+
/**
|
|
157
|
+
* tree level
|
|
158
|
+
* @private
|
|
159
|
+
*/
|
|
160
|
+
__T_LV__?: number;
|
|
161
|
+
};
|
|
162
|
+
export type SortOption<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
|
|
163
|
+
export type SortState<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'dataIndex' | 'sortField' | 'sortType'> & {
|
|
164
|
+
order: Order;
|
|
165
|
+
};
|
|
166
|
+
export type UniqKey = string | number;
|
|
167
|
+
export type UniqKeyFun = (param: any) => UniqKey;
|
|
168
|
+
export type UniqKeyProp = UniqKey | UniqKeyFun;
|
|
169
|
+
export type SortConfig<T extends Record<string, any>> = {
|
|
170
|
+
/**
|
|
171
|
+
* 1. trigger when init
|
|
172
|
+
* 2. trigger when sort direction is null
|
|
173
|
+
*/
|
|
174
|
+
defaultSort?: {
|
|
175
|
+
/**
|
|
176
|
+
* colKey
|
|
177
|
+
*
|
|
178
|
+
* if set `props.colKey`
|
|
179
|
+
*
|
|
180
|
+
* default: StkTableColumn<T>['dataIndex']
|
|
181
|
+
*/
|
|
182
|
+
key?: StkTableColumn<T>['key'];
|
|
183
|
+
dataIndex: StkTableColumn<T>['dataIndex'];
|
|
184
|
+
order: Order;
|
|
185
|
+
sortField?: StkTableColumn<T>['sortField'];
|
|
186
|
+
sortType?: StkTableColumn<T>['sortType'];
|
|
187
|
+
sorter?: StkTableColumn<T>['sorter'];
|
|
188
|
+
/**
|
|
189
|
+
* whether to disable trigger`sort-change` event. default: false
|
|
190
|
+
*/
|
|
191
|
+
silent?: boolean;
|
|
192
|
+
};
|
|
193
|
+
/** empty value always sort to bottom */
|
|
194
|
+
emptyToBottom?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* string sort if use `String.prototype.localCompare`
|
|
197
|
+
* default: false
|
|
198
|
+
*/
|
|
199
|
+
stringLocaleCompare?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* whether to sort children when sort current column. default: false
|
|
202
|
+
*/
|
|
203
|
+
sortChildren?: boolean;
|
|
204
|
+
};
|
|
205
|
+
/** th td type */
|
|
206
|
+
export declare const enum TagType {
|
|
207
|
+
TH = 0,
|
|
208
|
+
TD = 1
|
|
209
|
+
}
|
|
210
|
+
export type HighlightConfig = {
|
|
211
|
+
/** Duration of the highlight in seconds */
|
|
212
|
+
duration?: number;
|
|
213
|
+
/** Frame rate of the highlight */
|
|
214
|
+
fps?: number;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Configuration options for the sequence column.
|
|
218
|
+
*/
|
|
219
|
+
export type SeqConfig = {
|
|
220
|
+
/** The initial subscript of the sequence number column is used to adapt the paging. */
|
|
221
|
+
startIndex?: number;
|
|
222
|
+
};
|
|
223
|
+
/** Configuration options for the expand column */
|
|
224
|
+
export type ExpandConfig = {
|
|
225
|
+
/** worked in virtual mode */
|
|
226
|
+
height?: number;
|
|
227
|
+
};
|
|
228
|
+
export type ExpandedRow = PrivateRowDT & {
|
|
229
|
+
__EXPANDED_ROW__: any;
|
|
230
|
+
__EXPANDED_COL__: any;
|
|
231
|
+
};
|
|
232
|
+
/** drag row config */
|
|
233
|
+
export type DragRowConfig = {
|
|
234
|
+
mode?: 'none' | 'insert' | 'swap';
|
|
235
|
+
};
|
|
236
|
+
export type TreeConfig = {
|
|
237
|
+
defaultExpandAll?: boolean;
|
|
238
|
+
defaultExpandKeys?: UniqKey[];
|
|
239
|
+
defaultExpandLevel?: number;
|
|
240
|
+
};
|
|
241
|
+
/** header drag config */
|
|
242
|
+
export type HeaderDragConfig<DT extends Record<string, any> = any> = {
|
|
243
|
+
/**
|
|
244
|
+
* col switch mode
|
|
245
|
+
* - none
|
|
246
|
+
* - insert - (default)
|
|
247
|
+
* - swap
|
|
248
|
+
*/
|
|
249
|
+
mode?: 'none' | 'insert' | 'swap';
|
|
250
|
+
/** disabled drag col */
|
|
251
|
+
disabled?: (col: StkTableColumn<DT>) => boolean;
|
|
252
|
+
};
|
|
253
|
+
export type AutoRowHeightConfig<DT> = {
|
|
254
|
+
/** Estimated row height */
|
|
255
|
+
expectedHeight?: number | ((row: DT) => number);
|
|
256
|
+
};
|
|
257
|
+
export type ColResizableConfig<DT extends Record<string, any>> = {
|
|
258
|
+
disabled: (col: StkTableColumn<DT>) => boolean;
|
|
259
|
+
};
|
|
260
|
+
export type RowKeyGen = (row: any) => UniqKey;
|
|
261
|
+
export type ColKeyGen = ComputedRef<(col: StkTableColumn<any>) => UniqKey>;
|
|
262
|
+
export type CellKeyGen = (row: any, col: StkTableColumn<any>) => string;
|
|
263
|
+
export type RowActiveOption<DT> = {
|
|
264
|
+
enabled?: boolean;
|
|
265
|
+
/** disabled row active */
|
|
266
|
+
disabled?: (row: DT) => boolean;
|
|
267
|
+
/** current row again click can revoke active */
|
|
268
|
+
revokable?: boolean;
|
|
269
|
+
};
|
|
270
|
+
export {};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ShallowRef } from 'vue';
|
|
2
|
-
import { ColKeyGen, MergeCellsParam, PrivateStkTableColumn, RowKeyGen, UniqKey } from './types';
|
|
1
|
+
import { Ref, ShallowRef } from 'vue';
|
|
2
|
+
import { ColKeyGen, MergeCellsParam, PrivateStkTableColumn, RowActiveOption, RowKeyGen, UniqKey } from './types';
|
|
3
3
|
|
|
4
4
|
type Options = {
|
|
5
|
-
|
|
5
|
+
rowActiveProp: Ref<RowActiveOption<any>>;
|
|
6
6
|
tableHeaderLast: ShallowRef<PrivateStkTableColumn<any>[]>;
|
|
7
7
|
rowKeyGen: RowKeyGen;
|
|
8
8
|
colKeyGen: ColKeyGen;
|
|
9
9
|
virtual_dataSourcePart: ShallowRef<any[]>;
|
|
10
10
|
};
|
|
11
|
-
export declare function useMergeCells({
|
|
12
|
-
hiddenCellMap:
|
|
11
|
+
export declare function useMergeCells({ rowActiveProp, tableHeaderLast, rowKeyGen, colKeyGen, virtual_dataSourcePart }: Options): {
|
|
12
|
+
hiddenCellMap: Ref<Record<UniqKey, Set<UniqKey>>, Record<UniqKey, Set<UniqKey>>>;
|
|
13
13
|
mergeCellsWrapper: (row: MergeCellsParam<any>["row"], col: MergeCellsParam<any>["col"], rowIndex: MergeCellsParam<any>["rowIndex"], colIndex: MergeCellsParam<any>["colIndex"]) => {
|
|
14
14
|
colspan?: number;
|
|
15
15
|
rowspan?: number;
|
|
16
16
|
} | undefined;
|
|
17
|
-
hoverMergedCells:
|
|
17
|
+
hoverMergedCells: Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
|
|
18
18
|
updateHoverMergedCells: (rowKey: UniqKey | undefined) => void;
|
|
19
|
-
activeMergedCells:
|
|
20
|
-
updateActiveMergedCells: (clear?: boolean) => void;
|
|
19
|
+
activeMergedCells: Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
|
|
20
|
+
updateActiveMergedCells: (clear?: boolean, rowKey?: UniqKey) => void;
|
|
21
21
|
};
|
|
22
22
|
export {};
|