stk-table-vue 0.4.1 → 0.4.3

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 CHANGED
@@ -15,11 +15,10 @@ repo:
15
15
  * [] 固定列列宽拖动目标。
16
16
 
17
17
  ## Feature TODO:
18
- * [x] 高亮行,单元格。使用css @keyframes实现。
19
- - [x] 虚拟滚动默认通过js计算行高亮背景色,可通过 `useCss` 设置为css @keyframe实现 。
20
- - [x] 支持配置高亮参数(持续时间,颜色,频率(虚拟滚动))。(`v0.2.9`)
21
- - [x] `setHighlightDimRow`/`setHighlightCellRow`支持自定义高亮css类名。(`v0.2.9`)
18
+ * [x] 高亮行,单元格。
22
19
  - [x] 使用 `Web Animations API` 实现高亮。(`v0.3.4` 变更为默认值)
20
+ - [x] 支持配置高亮参数(持续时间,颜色,频率)。(`v0.2.9`)
21
+ - [x] `setHighlightDimRow`/`setHighlightCellRow`支持自定义高亮css类名。(`v0.2.9`)
23
22
  * [x] 虚拟滚动。
24
23
  - [x] 纵向。
25
24
  - [x] 横向(必须设置列宽)。
@@ -29,21 +28,16 @@ repo:
29
28
  - [x] sticky column 动态计算阴影位置。(`v0.4.0`)
30
29
  * [] 列筛选。
31
30
  * [x] 斑马纹。
32
- - [x] 虚拟滚动斑马纹。
33
- * [x] 表头拖动更改顺序。
34
- * [x] 表头拖动调整列宽。
31
+ * [x] 拖动更改列顺序。
32
+ * [x] 拖动调整列宽。
35
33
  * [x] 排序
36
- - [x] 基本表头点击排序。
37
34
  - [x] 支持配置 `null` | `undefined` 永远排最后。
38
35
  - [x] 支持配置 string 使用 `String.prototype.localCompare` 排序。
39
36
  * [x] 多级表头。
40
- - [x] 支持最多`2级`表头。
41
- - [x] 支持更多级表头。
42
37
  - [] 横向虚拟滚动。
43
38
  * [x] 支持table-layout: fixed 配置。
44
39
  * [x] 鼠标悬浮在表格上,键盘滚动虚拟表格。
45
- - [x] 键盘 `ArrowUp`/`ArrowDown`/`ArrowLeft`/`ArrowRight` 按键支持。
46
- - [x] 键盘 `PageUp`/ `PageDown` 按键支持。
40
+ - [x] 键盘 `ArrowUp`/`ArrowDown`/`ArrowLeft`/`ArrowRight`/`PageUp`/ `PageDown` 按键支持。
47
41
  * [] 非虚拟滚动时,大数据分批加载。
48
42
  * [x] vue2.7支持(引入源码使用)。
49
43
  - [x] `props.optimizeVue2Scroll` 优化vue2虚拟滚动流畅度。(`v0.2.0`)
@@ -51,8 +45,6 @@ repo:
51
45
  * [x] `props.cellHover`单元格悬浮样式。(`v0.3.2`)
52
46
 
53
47
 
54
-
55
-
56
48
  ## Usage
57
49
  > npm install stk-table-vue
58
50
 
@@ -64,15 +56,15 @@ const stkTable = ref<InstanceType<typeof StkTable>>();
64
56
 
65
57
  // highlight row
66
58
  stkTable.value.setHighlightDimRow([rowKey],{
67
- method: 'css'|'js'|'animation',// 是否使用css @keyframe实现。虚拟滚动下默认false
68
- className: 'custom-class-name',// useCss 为true时生效。
59
+ method: 'css'|'js'|'animation',// 默认 animation
60
+ className: 'custom-class-name', // method css 时生效。
69
61
  keyframe: [{backgroundColor:'#aaa'},{backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
70
62
  duration: 2000,// 动画时长。
71
63
  });
72
64
  // highlight cell
73
65
  stkTable.value.setHighlightDimCell(rowKey, colDataIndex, {
74
66
  method: 'css'|'animation',
75
- className:'custom-class-name',// method css 时生效。
67
+ className:'custom-class-name', // method css 时生效。
76
68
  keyframe: [{backgroundColor:'#aaa'},{backgroundColor: '#222'}], // method animation 时生效。
77
69
  duration: 2000,// 动画时长。
78
70
  })
@@ -88,17 +80,17 @@ stkTable.value.setHighlightDimCell(rowKey, colDataIndex, {
88
80
  vue2.7 支持引入源码使用。依赖`less`。
89
81
  ```html
90
82
  <script>
91
- import { StkTable } from 'stk-table-vue/src/StkTable/index';
83
+ import { StkTable } from 'stk-table-vue/src/StkTable/index'; // include less
92
84
  </script>
93
85
  ```
94
- 不要less的话
86
+ Use `css`
95
87
  ```html
96
88
  <script>
97
- import { StkTable } from 'stk-table-vue/src/StkTable/StkTable.vue';
89
+ import StkTable from 'stk-table-vue/src/StkTable/StkTable.vue';
98
90
  import 'stk-table-vue/lib/style.css';
99
91
  </script>
100
92
  ```
101
- #### webpack TS 配置参考
93
+ #### webpack TS
102
94
  ##### webpack.config.js
103
95
  ```js
104
96
  rules:[{
@@ -142,6 +134,12 @@ export type StkProps = {
142
134
  theme?: 'light' | 'dark';
143
135
  /** 行高 */
144
136
  rowHeight?: number;
137
+ /** 是否高亮鼠标悬浮的行 */
138
+ rowHover?: boolean;
139
+ /** 是否高亮选中的行 */
140
+ rowActive?: boolean;
141
+ /** 当前行再次点击否可以取消 */
142
+ rowCurrentRevokable?: boolean;
145
143
  /** 表头行高。default = rowHeight */
146
144
  headerRowHeight?: number | null;
147
145
  /** 虚拟滚动 */
@@ -152,7 +150,7 @@ export type StkProps = {
152
150
  columns?: StkTableColumn<any>[];
153
151
  /** 表格数据源 */
154
152
  dataSource?: any[];
155
- /** 行唯一键 */
153
+ /** 行唯一键 (行唯一值不能为undefined)*/
156
154
  rowKey?: UniqKeyProp;
157
155
  /** 列唯一键 */
158
156
  colKey?: UniqKeyProp;
@@ -170,6 +168,7 @@ export type StkProps = {
170
168
  showOverflow?: boolean;
171
169
  /** 是否增加行hover class */
172
170
  showTrHoverClass?: boolean;
171
+
173
172
  /** 是否高亮鼠标悬浮的单元格 */
174
173
  cellHover?: boolean;
175
174
  /** 表头是否可拖动。支持回调函数。 */
@@ -262,9 +261,9 @@ export type StkProps = {
262
261
  (e: 'row-click', ev: MouseEvent, row: DT): void;
263
262
  /**
264
263
  * 选中一行触发。ev返回null表示不是点击事件触发的
265
- * ```(ev: MouseEvent | null, row: DT, data: { select: boolean })```
264
+ * ```(ev: MouseEvent | null, row: DT | undefined,, data: { select: boolean })```
266
265
  */
267
- (e: 'current-change', ev: MouseEvent | null, row: DT, data: { select: boolean }): void;
266
+ (e: 'current-change', ev: MouseEvent | null, row: DT | undefined,, data: { select: boolean }): void;
268
267
  /**
269
268
  * 行双击事件
270
269
  * ```(ev: MouseEvent, row: DT)```
@@ -431,7 +430,7 @@ export type SortConfig<T extends Record<string, any>> = {
431
430
  };
432
431
  /**
433
432
  * string排序是否使用 String.prototype.localCompare
434
- * 默认true (&$&应该false)
433
+ * 默认true ($*$应该false)
435
434
  */
436
435
  stringLocaleCompare?: boolean;
437
436
  };
@@ -444,7 +443,7 @@ export type SortConfig<T extends Record<string, any>> = {
444
443
  rowKeyValues: UniqKey[],
445
444
  option: {
446
445
  method?: 'css' | 'animation' | 'js';
447
- /** @deprecated 请使用method */
446
+ /** @deprecated use method */
448
447
  useCss?: boolean;
449
448
  className?: string;
450
449
  keyframe?: Parameters<Animatable['animate']>['0'];
@@ -458,7 +457,7 @@ export type SortConfig<T extends Record<string, any>> = {
458
457
  rowKeyValues: UniqKey[],
459
458
  option: {
460
459
  method?: 'css' | 'animation' | 'js';
461
- /** @deprecated 请使用method */
460
+ /** @deprecated use method */
462
461
  useCss?: boolean;
463
462
  className?: string;
464
463
  keyframe?: Parameters<Animatable['animate']>['0'];
@@ -542,7 +541,7 @@ export type SortConfig<T extends Record<string, any>> = {
542
541
  customCell: defineComponent({
543
542
  setup(){
544
543
  //...
545
- return () => <div></div>
544
+ return () => <div></div> // vue jsx
546
545
  }
547
546
  })
548
547
  },
@@ -570,6 +569,11 @@ export type SortConfig<T extends Record<string, any>> = {
570
569
  - 在 `customCell` 较多且复杂时。
571
570
  - 大量 highlight 动画时。
572
571
 
572
+ ## Tips
573
+ ### props.fixedMode
574
+ * **低版本浏览器** 需要设置 `props.width`(default: width=fit-content不生效)。否则列宽不设宽度会变为0。
575
+
576
+
573
577
  ## Other
574
578
  * `$*$` 兼容注释
575
579
 
@@ -1,6 +1,7 @@
1
1
  import { HighlightConfig, Order, SeqConfig, SortConfig, SortOption, SortState, StkTableColumn, UniqKeyProp } from './types/index';
2
+
2
3
  /** Generic stands for DataType */
3
- type DT = any;
4
+ type DT = Record<string | number, any>;
4
5
  /**
5
6
  * 选中一行,
6
7
  * @param {string} rowKey selected rowKey, null to unselect
@@ -23,7 +24,7 @@ declare function setSorter(dataIndex: string, order: Order, option?: {
23
24
  force?: boolean;
24
25
  silent?: boolean;
25
26
  sort?: boolean;
26
- }): any[];
27
+ }): DT[];
27
28
  /** 重置排序 */
28
29
  declare function resetSorter(): void;
29
30
  /**
@@ -33,10 +34,10 @@ declare function resetSorter(): void;
33
34
  */
34
35
  declare function scrollTo(top?: number | null, left?: number | null): void;
35
36
  /** 获取当前状态的表格数据 */
36
- declare function getTableData(): any[];
37
+ declare function getTableData(): DT[];
37
38
  /** 获取当前排序列的信息 */
38
- declare function getSortColumns(): SortState<DT>[];
39
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
39
+ declare function getSortColumns(): Partial<SortState<DT>>[];
40
+ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
40
41
  width?: string | undefined;
41
42
  /** 最小表格宽度 */
42
43
  minWidth?: string | undefined;
@@ -44,7 +45,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
44
45
  maxWidth?: string | undefined;
45
46
  /** 斑马线条纹 */
46
47
  stripe?: boolean | undefined;
47
- /** 是否使用 table-layout:fixed */
48
+ /** 是否使用 table-layout:fixed(低版本浏览器需要设置table) */
48
49
  fixedMode?: boolean | undefined;
49
50
  /** 是否隐藏表头 */
50
51
  headless?: boolean | undefined;
@@ -52,6 +53,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
52
53
  theme?: "light" | "dark" | undefined;
53
54
  /** 行高 */
54
55
  rowHeight?: number | undefined;
56
+ /** 是否高亮鼠标悬浮的行 */
57
+ rowHover?: boolean | undefined;
58
+ /** 是否高亮选中的行 */
59
+ rowActive?: boolean | undefined;
60
+ /** 当前行再次点击否可以取消 */
61
+ rowCurrentRevokable?: boolean | undefined;
55
62
  /** 表头行高。default = rowHeight */
56
63
  headerRowHeight?: number | null | undefined;
57
64
  /** 虚拟滚动 */
@@ -59,17 +66,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
59
66
  /** x轴虚拟滚动(必须设置列宽)*/
60
67
  virtualX?: boolean | undefined;
61
68
  /** 表格列配置 */
62
- columns?: StkTableColumn<any>[] | undefined;
69
+ columns?: StkTableColumn<DT>[] | undefined;
63
70
  /** 表格数据源 */
64
- dataSource?: any[] | undefined;
65
- /** 行唯一键 */
71
+ dataSource?: DT[] | undefined;
72
+ /** 行唯一键 (行唯一值不能为undefined) */
66
73
  rowKey?: UniqKeyProp | undefined;
67
74
  /** 列唯一键 */
68
75
  colKey?: UniqKeyProp | undefined;
69
76
  /** 空值展示文字 */
70
77
  emptyCellText?: string | ((option: {
71
- row: any;
72
- col: StkTableColumn<any>;
78
+ row: DT;
79
+ col: StkTableColumn<DT>;
73
80
  }) => string) | undefined;
74
81
  /** 暂无数据兜底高度是否撑满 */
75
82
  noDataFull?: boolean | undefined;
@@ -81,17 +88,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
81
88
  showHeaderOverflow?: boolean | undefined;
82
89
  /** 表体溢出是否展示... */
83
90
  showOverflow?: boolean | undefined;
84
- /** 是否增加行hover class */
91
+ /** 是否增加行hover class $*$ rename*/
85
92
  showTrHoverClass?: boolean | undefined;
86
93
  /** 是否高亮鼠标悬浮的单元格 */
87
94
  cellHover?: boolean | undefined;
88
95
  /** 表头是否可拖动。支持回调函数。 */
89
- headerDrag?: boolean | ((col: StkTableColumn<any>) => boolean) | undefined;
96
+ headerDrag?: boolean | ((col: StkTableColumn<DT>) => boolean) | undefined;
90
97
  /**
91
98
  * 给行附加className<br>
92
99
  * FIXME: 是否需要优化,因为不传此prop会使表格行一直执行空函数,是否有影响
93
100
  */
94
- rowClassName?: ((row: any, i: number) => string) | undefined;
101
+ rowClassName?: ((row: DT, i: number) => string) | undefined;
95
102
  /**
96
103
  * 列宽是否可拖动<br>
97
104
  * **不要设置**列minWidth,**必须**设置width<br>
@@ -119,7 +126,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
119
126
  /** 优化vue2 滚动 */
120
127
  optimizeVue2Scroll?: boolean | undefined;
121
128
  /** 排序配置 */
122
- sortConfig?: SortConfig<any> | undefined;
129
+ sortConfig?: SortConfig<DT> | undefined;
123
130
  /** 隐藏头部title。可传入dataIndex数组 */
124
131
  hideHeaderTitle?: boolean | string[] | undefined;
125
132
  /** 高亮配置 */
@@ -145,6 +152,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
145
152
  headless: boolean;
146
153
  theme: string;
147
154
  rowHeight: number;
155
+ rowHover: boolean;
156
+ rowActive: boolean;
157
+ rowCurrentRevokable: boolean;
148
158
  headerRowHeight: null;
149
159
  virtual: boolean;
150
160
  virtualX: boolean;
@@ -193,7 +203,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
193
203
  duration?: number | undefined;
194
204
  }) => void;
195
205
  /** 设置高亮渐暗行 */
196
- setHighlightDimRow: (rowKeyValues: import("./types/index").UniqKey[], option?: {
206
+ setHighlightDimRow: (rowKeyValues: import('./types/index').UniqKey[], option?: {
197
207
  method?: "animation" | "css" | "js" | undefined;
198
208
  useCss?: boolean | undefined;
199
209
  className?: string | undefined;
@@ -201,7 +211,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
201
211
  duration?: number | undefined;
202
212
  }) => void;
203
213
  /** 表格排序列dataIndex */
204
- sortCol: import("vue").Ref<string | null | undefined>;
214
+ sortCol: import('vue').Ref<string | number | undefined>;
205
215
  /** 获取当前排序状态 */
206
216
  getSortColumns: typeof getSortColumns;
207
217
  /** 设置排序 */
@@ -212,20 +222,20 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
212
222
  scrollTo: typeof scrollTo;
213
223
  /** 获取表格数据 */
214
224
  getTableData: typeof getTableData;
215
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
216
- "sort-change": (col: StkTableColumn<any>, order: Order, data: any[], sortConfig: SortConfig<any>) => void;
217
- "row-click": (ev: MouseEvent, row: any) => void;
218
- "current-change": (ev: MouseEvent | null, row: any, data: {
225
+ }, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
226
+ "sort-change": (col: StkTableColumn<DT>, order: Order, data: DT[], sortConfig: SortConfig<DT>) => void;
227
+ "row-click": (ev: MouseEvent, row: DT) => void;
228
+ "current-change": (ev: MouseEvent | null, row: DT | undefined, data: {
219
229
  select: boolean;
220
230
  }) => void;
221
- "row-dblclick": (ev: MouseEvent, row: any) => void;
231
+ "row-dblclick": (ev: MouseEvent, row: DT) => void;
222
232
  "header-row-menu": (ev: MouseEvent) => void;
223
- "row-menu": (ev: MouseEvent, row: any) => void;
224
- "cell-click": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
225
- "cell-mouseenter": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
226
- "cell-mouseleave": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
227
- "cell-mouseover": (ev: MouseEvent, row: any, col: StkTableColumn<any>) => void;
228
- "header-cell-click": (ev: MouseEvent, col: StkTableColumn<any>) => void;
233
+ "row-menu": (ev: MouseEvent, row: DT) => void;
234
+ "cell-click": (ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => void;
235
+ "cell-mouseenter": (ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => void;
236
+ "cell-mouseleave": (ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => void;
237
+ "cell-mouseover": (ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => void;
238
+ "header-cell-click": (ev: MouseEvent, col: StkTableColumn<DT>) => void;
229
239
  scroll: (ev: Event, data: {
230
240
  startIndex: number;
231
241
  endIndex: number;
@@ -234,8 +244,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
234
244
  "col-order-change": (dragStartKey: string, targetColKey: string) => void;
235
245
  "th-drag-start": (dragStartKey: string) => void;
236
246
  "th-drop": (targetColKey: string) => void;
237
- "update:columns": (cols: StkTableColumn<any>[]) => void;
238
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
247
+ "update:columns": (cols: StkTableColumn<DT>[]) => void;
248
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
239
249
  width?: string | undefined;
240
250
  /** 最小表格宽度 */
241
251
  minWidth?: string | undefined;
@@ -243,7 +253,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
243
253
  maxWidth?: string | undefined;
244
254
  /** 斑马线条纹 */
245
255
  stripe?: boolean | undefined;
246
- /** 是否使用 table-layout:fixed */
256
+ /** 是否使用 table-layout:fixed(低版本浏览器需要设置table) */
247
257
  fixedMode?: boolean | undefined;
248
258
  /** 是否隐藏表头 */
249
259
  headless?: boolean | undefined;
@@ -251,6 +261,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
251
261
  theme?: "light" | "dark" | undefined;
252
262
  /** 行高 */
253
263
  rowHeight?: number | undefined;
264
+ /** 是否高亮鼠标悬浮的行 */
265
+ rowHover?: boolean | undefined;
266
+ /** 是否高亮选中的行 */
267
+ rowActive?: boolean | undefined;
268
+ /** 当前行再次点击否可以取消 */
269
+ rowCurrentRevokable?: boolean | undefined;
254
270
  /** 表头行高。default = rowHeight */
255
271
  headerRowHeight?: number | null | undefined;
256
272
  /** 虚拟滚动 */
@@ -258,17 +274,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
258
274
  /** x轴虚拟滚动(必须设置列宽)*/
259
275
  virtualX?: boolean | undefined;
260
276
  /** 表格列配置 */
261
- columns?: StkTableColumn<any>[] | undefined;
277
+ columns?: StkTableColumn<DT>[] | undefined;
262
278
  /** 表格数据源 */
263
- dataSource?: any[] | undefined;
264
- /** 行唯一键 */
279
+ dataSource?: DT[] | undefined;
280
+ /** 行唯一键 (行唯一值不能为undefined) */
265
281
  rowKey?: UniqKeyProp | undefined;
266
282
  /** 列唯一键 */
267
283
  colKey?: UniqKeyProp | undefined;
268
284
  /** 空值展示文字 */
269
285
  emptyCellText?: string | ((option: {
270
- row: any;
271
- col: StkTableColumn<any>;
286
+ row: DT;
287
+ col: StkTableColumn<DT>;
272
288
  }) => string) | undefined;
273
289
  /** 暂无数据兜底高度是否撑满 */
274
290
  noDataFull?: boolean | undefined;
@@ -280,17 +296,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
280
296
  showHeaderOverflow?: boolean | undefined;
281
297
  /** 表体溢出是否展示... */
282
298
  showOverflow?: boolean | undefined;
283
- /** 是否增加行hover class */
299
+ /** 是否增加行hover class $*$ rename*/
284
300
  showTrHoverClass?: boolean | undefined;
285
301
  /** 是否高亮鼠标悬浮的单元格 */
286
302
  cellHover?: boolean | undefined;
287
303
  /** 表头是否可拖动。支持回调函数。 */
288
- headerDrag?: boolean | ((col: StkTableColumn<any>) => boolean) | undefined;
304
+ headerDrag?: boolean | ((col: StkTableColumn<DT>) => boolean) | undefined;
289
305
  /**
290
306
  * 给行附加className<br>
291
307
  * FIXME: 是否需要优化,因为不传此prop会使表格行一直执行空函数,是否有影响
292
308
  */
293
- rowClassName?: ((row: any, i: number) => string) | undefined;
309
+ rowClassName?: ((row: DT, i: number) => string) | undefined;
294
310
  /**
295
311
  * 列宽是否可拖动<br>
296
312
  * **不要设置**列minWidth,**必须**设置width<br>
@@ -318,7 +334,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
318
334
  /** 优化vue2 滚动 */
319
335
  optimizeVue2Scroll?: boolean | undefined;
320
336
  /** 排序配置 */
321
- sortConfig?: SortConfig<any> | undefined;
337
+ sortConfig?: SortConfig<DT> | undefined;
322
338
  /** 隐藏头部title。可传入dataIndex数组 */
323
339
  hideHeaderTitle?: boolean | string[] | undefined;
324
340
  /** 高亮配置 */
@@ -344,6 +360,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
344
360
  headless: boolean;
345
361
  theme: string;
346
362
  rowHeight: number;
363
+ rowHover: boolean;
364
+ rowActive: boolean;
365
+ rowCurrentRevokable: boolean;
347
366
  headerRowHeight: null;
348
367
  virtual: boolean;
349
368
  virtualX: boolean;
@@ -380,43 +399,46 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
380
399
  startIndex: number;
381
400
  endIndex: number;
382
401
  }) => any) | undefined;
383
- "onUpdate:columns"?: ((cols: StkTableColumn<any>[]) => any) | undefined;
402
+ "onUpdate:columns"?: ((cols: StkTableColumn<DT>[]) => any) | undefined;
384
403
  "onTh-drag-start"?: ((dragStartKey: string) => any) | undefined;
385
404
  "onCol-order-change"?: ((dragStartKey: string, targetColKey: string) => any) | undefined;
386
405
  "onTh-drop"?: ((targetColKey: string) => any) | undefined;
387
- "onSort-change"?: ((col: StkTableColumn<any>, order: Order, data: any[], sortConfig: SortConfig<any>) => any) | undefined;
388
- "onRow-click"?: ((ev: MouseEvent, row: any) => any) | undefined;
389
- "onCurrent-change"?: ((ev: MouseEvent | null, row: any, data: {
406
+ "onSort-change"?: ((col: StkTableColumn<DT>, order: Order, data: DT[], sortConfig: SortConfig<DT>) => any) | undefined;
407
+ "onRow-click"?: ((ev: MouseEvent, row: DT) => any) | undefined;
408
+ "onCurrent-change"?: ((ev: MouseEvent | null, row: DT | undefined, data: {
390
409
  select: boolean;
391
410
  }) => any) | undefined;
392
- "onRow-dblclick"?: ((ev: MouseEvent, row: any) => any) | undefined;
411
+ "onRow-dblclick"?: ((ev: MouseEvent, row: DT) => any) | undefined;
393
412
  "onHeader-row-menu"?: ((ev: MouseEvent) => any) | undefined;
394
- "onRow-menu"?: ((ev: MouseEvent, row: any) => any) | undefined;
395
- "onCell-click"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
396
- "onCell-mouseenter"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
397
- "onCell-mouseleave"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
398
- "onCell-mouseover"?: ((ev: MouseEvent, row: any, col: StkTableColumn<any>) => any) | undefined;
399
- "onHeader-cell-click"?: ((ev: MouseEvent, col: StkTableColumn<any>) => any) | undefined;
413
+ "onRow-menu"?: ((ev: MouseEvent, row: DT) => any) | undefined;
414
+ "onCell-click"?: ((ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => any) | undefined;
415
+ "onCell-mouseenter"?: ((ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => any) | undefined;
416
+ "onCell-mouseleave"?: ((ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => any) | undefined;
417
+ "onCell-mouseover"?: ((ev: MouseEvent, row: DT, col: StkTableColumn<DT>) => any) | undefined;
418
+ "onHeader-cell-click"?: ((ev: MouseEvent, col: StkTableColumn<DT>) => any) | undefined;
400
419
  "onScroll-x"?: ((ev: Event) => any) | undefined;
401
420
  }, {
402
421
  width: string;
403
422
  minWidth: string;
404
423
  maxWidth: string;
405
424
  rowHeight: number;
406
- headless: boolean;
407
425
  headerRowHeight: number | null;
426
+ headless: boolean;
408
427
  stripe: boolean;
409
428
  fixedMode: boolean;
410
429
  theme: "light" | "dark";
430
+ rowHover: boolean;
431
+ rowActive: boolean;
432
+ rowCurrentRevokable: boolean;
411
433
  virtual: boolean;
412
434
  virtualX: boolean;
413
- columns: StkTableColumn<any>[];
414
- dataSource: any[];
435
+ columns: StkTableColumn<DT>[];
436
+ dataSource: DT[];
415
437
  rowKey: UniqKeyProp;
416
438
  colKey: UniqKeyProp;
417
439
  emptyCellText: string | ((option: {
418
- row: any;
419
- col: StkTableColumn<any>;
440
+ row: DT;
441
+ col: StkTableColumn<DT>;
420
442
  }) => string);
421
443
  noDataFull: boolean;
422
444
  showNoData: boolean;
@@ -425,22 +447,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
425
447
  showOverflow: boolean;
426
448
  showTrHoverClass: boolean;
427
449
  cellHover: boolean;
428
- headerDrag: boolean | ((col: StkTableColumn<any>) => boolean);
429
- rowClassName: (row: any, i: number) => string;
450
+ headerDrag: boolean | ((col: StkTableColumn<DT>) => boolean);
451
+ rowClassName: (row: DT, i: number) => string;
430
452
  colResizable: boolean;
431
453
  colMinWidth: number;
432
454
  bordered: boolean | "h" | "v" | "body-v";
433
455
  autoResize: boolean | (() => void);
434
456
  fixedColShadow: boolean;
435
457
  optimizeVue2Scroll: boolean;
436
- sortConfig: SortConfig<any>;
458
+ sortConfig: SortConfig<DT>;
437
459
  hideHeaderTitle: boolean | string[];
438
460
  highlightConfig: HighlightConfig;
439
461
  seqConfig: SeqConfig;
440
462
  cellFixedMode: "sticky" | "relative";
441
463
  }, {}>, {
442
464
  tableHeader?(_: {
443
- col: StkTableColumn<any>;
465
+ col: StkTableColumn<DT>;
444
466
  }): any;
445
467
  empty?(_: {}): any;
446
468
  }>;
@@ -1,4 +1,3 @@
1
1
  export { default as StkTable } from './StkTable.vue';
2
2
  export { tableSort, insertToOrderedArray } from './utils';
3
3
  export type { StkTableColumn } from './types/index';
4
- import './style.less';
@@ -1,21 +1,34 @@
1
1
  import { Component, VNode } from 'vue';
2
+
2
3
  /** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
3
4
  export type Order = null | 'asc' | 'desc';
4
5
  type Sorter<T> = boolean | ((data: T[], option: {
5
6
  order: Order;
6
7
  column: any;
7
8
  }) => T[]);
8
- export type CustomCellFunc<T extends Record<string, any>> = (props: {
9
+ export type CustomCellProps<T extends Record<string, any>> = {
9
10
  row: T;
10
11
  col: StkTableColumn<T>;
11
12
  /** row[col.dataIndex] 的值 */
12
13
  cellValue: any;
13
14
  rowIndex: number;
14
15
  colIndex: number;
15
- }) => VNode;
16
- export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: {
16
+ };
17
+ /**
18
+ * $*$自定义单元格渲染函数
19
+ * @deprecated
20
+ */
21
+ export type CustomCellFunc<T extends Record<string, any>> = (props: CustomCellProps<T>) => VNode;
22
+ export type CustomHeaderCellProps<T extends Record<string, any>> = {
17
23
  col: StkTableColumn<T>;
18
- }) => VNode;
24
+ rowIndex: number;
25
+ colIndex: number;
26
+ };
27
+ /**
28
+ * $*$自定义表头渲染函数
29
+ * @deprecated
30
+ */
31
+ export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: CustomHeaderCellProps<T>) => VNode;
19
32
  /** 表格列配置 */
20
33
  export type StkTableColumn<T extends Record<string, any>> = {
21
34
  /**
@@ -55,17 +68,22 @@ export type StkTableColumn<T extends Record<string, any>> = {
55
68
  * 自定义 td 渲染内容。
56
69
  *
57
70
  * 组件prop入参:
58
- * - props.row 一行的记录。
59
- * - props.col 列配置
71
+ * @param props.row 一行的记录。
72
+ * @param props.col 列配置
73
+ * @param props.cellValue row[col.dataIndex] 的值
74
+ * @param props.rowIndex 行索引
75
+ * @param props.colIndex 列索引
60
76
  */
61
- customCell?: Component | VNode | CustomCellFunc<T>;
77
+ customCell?: Component<CustomCellProps<T>> | string;
62
78
  /**
63
79
  * 自定义 th 渲染内容
64
80
  *
65
81
  * 组件prop入参:
66
- * - props.col 列配置
82
+ * @param props.col 列配置
83
+ * @param props.rowIndex 行索引
84
+ * @param props.colIndex 列索引
67
85
  */
68
- customHeaderCell?: Component | VNode | CustomHeaderCellFunc<T>;
86
+ customHeaderCell?: Component<CustomHeaderCellProps<T>> | string;
69
87
  /** 二级表头 */
70
88
  children?: StkTableColumn<T>[];
71
89
  /** 父节点引用 */
@@ -76,7 +94,7 @@ export type StkTableColumn<T extends Record<string, any>> = {
76
94
  export type SortOption<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
77
95
  /** 排序状态 */
78
96
  export type SortState<T> = {
79
- dataIndex: T;
97
+ dataIndex: keyof T;
80
98
  order: null | 'asc' | 'desc';
81
99
  sortType?: 'number' | 'string';
82
100
  };
@@ -100,7 +118,7 @@ export type SortConfig<T extends Record<string, any>> = {
100
118
  };
101
119
  /**
102
120
  * string排序是否使用 String.prototype.localCompare
103
- * 默认true (&$&应该false)
121
+ * 默认true ($*$应该false)
104
122
  */
105
123
  stringLocaleCompare?: boolean;
106
124
  };
@@ -1,4 +1,5 @@
1
1
  import { Ref } from 'vue';
2
+
2
3
  type Options = {
3
4
  props: any;
4
5
  tableContainerRef: Ref<HTMLElement | undefined>;
@@ -1,5 +1,6 @@
1
1
  import { ComputedRef, Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn, UniqKey } from './types';
3
+
3
4
  type Params<DT extends Record<string, any>> = {
4
5
  props: any;
5
6
  emits: any;
@@ -1,6 +1,7 @@
1
1
  import { ComputedRef, Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn, UniqKey } from './types';
3
3
  import { VirtualScrollXStore } from './useVirtualScroll';
4
+
4
5
  type Params<T extends Record<string, any>> = {
5
6
  props: any;
6
7
  colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
@@ -1,6 +1,7 @@
1
1
  import { CSSProperties, ComputedRef, Ref } from 'vue';
2
2
  import { StkTableColumn, TagType } from './types';
3
3
  import { VirtualScrollStore, VirtualScrollXStore } from './useVirtualScroll';
4
+
4
5
  type Options<T extends Record<string, any>> = {
5
6
  props: any;
6
7
  isRelativeMode: Ref<boolean>;
@@ -1,5 +1,6 @@
1
1
  import { ComputedRef, ShallowRef } from 'vue';
2
2
  import { StkTableColumn, UniqKey } from './types';
3
+
3
4
  type Params<T extends Record<string, any>> = {
4
5
  colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
5
6
  tableHeaders: ShallowRef<StkTableColumn<T>[][]>;
@@ -1,5 +1,6 @@
1
1
  import { Ref } from 'vue';
2
2
  import { UniqKey } from './types';
3
+
3
4
  type Params = {
4
5
  props: any;
5
6
  stkTableId: string;