stk-table-vue 0.2.8 → 0.3.0

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
@@ -12,7 +12,11 @@ repo:
12
12
  * [x] props.dataSource 为 shallowRef 时,高亮行不生效。(bug:2024.02.21)(resolved:0.2.3)
13
13
 
14
14
  ## Feature TODO:
15
- * [x] 高亮行,单元格。
15
+ * [x] 高亮行,单元格。使用css @keyframes实现。
16
+ - [x] 虚拟滚动默认通过js计算行高亮背景色,可通过 `useCss` 设置为css @keyframe实现 。
17
+ - [x] 支持配置高亮参数(持续时间,颜色,频率(虚拟滚动))。(`v0.2.9`)
18
+ - [x] `setHighlightDimRow`/`setHighlightCellRow`支持自定义高亮css类名。(`v0.2.9`)
19
+ - [x] 使用 `Web Animations API` 实现高亮。
16
20
  * [x] 虚拟滚动。
17
21
  - [x] 纵向。
18
22
  - [x] 横向(必须设置列宽)。
@@ -29,19 +33,20 @@ repo:
29
33
  - [x] 基本表头点击排序。
30
34
  - [x] 支持配置 `null` | `undefined` 永远排最后。
31
35
  - [] 支持配置 string 使用 `String.prototype.localCompare` 排序。
32
- * 多级表头。
36
+ * [x] 多级表头。
33
37
  - [x] 支持最多`2级`表头。
34
38
  - [x] 支持更多级表头。
35
39
  - [] 横向虚拟滚动。
36
40
  * [x] 支持table-layout: fixed 配置。
37
- * 鼠标悬浮在表格上,键盘滚动虚拟表格。
41
+ * [x] 鼠标悬浮在表格上,键盘滚动虚拟表格。
38
42
  - [x] 键盘 `ArrowUp`/`ArrowDown`/`ArrowLeft`/`ArrowRight` 按键支持。
39
43
  - [x] 键盘 `PageUp`/ `PageDown` 按键支持。
40
44
  * [] 非虚拟滚动时,大数据分批加载。
41
45
  * [x] vue2.7支持(引入源码使用)。
42
- - [x] `props.optimizeVue2Scroll` 优化vue2虚拟滚动流畅度。
43
- * [x] `props.emptyCellText` 支持传入函数。
44
- * [] 支持配置高亮参数。
46
+ - [x] `props.optimizeVue2Scroll` 优化vue2虚拟滚动流畅度。(`v0.2.0`)
47
+ * [x] 支持配置序号列。`StkTableColumn['type']`。(`v0.3.0`)
48
+
49
+
45
50
 
46
51
 
47
52
  ## Usage
@@ -52,9 +57,21 @@ repo:
52
57
  import { StkTable } from 'stk-table-vue'
53
58
  import { ref } from 'vue'
54
59
  const stkTable = ref<InstanceType<typeof StkTable>>();
55
- // highlight
56
- stkTable.value.setHighlightDimRow([rowId]);// highlight row
57
- stkTable.value.setHighlightDimCell(rowId, colId) // highlight cell
60
+
61
+ // highlight row
62
+ stkTable.value.setHighlightDimRow([rowKey],{
63
+ method: 'css'|'js'|'animation',// 是否使用css @keyframe实现。虚拟滚动下默认false。
64
+ className: 'custom-class-name',// useCss 为true时生效。
65
+ keyframe: [{backgroundColor:'#aaa'},{backgroundColor: '#222'}],//same as https://developer.mozilla.org/zh-CN/docs/Web/API/Web_Animations_API/Keyframe_Formats
66
+ duration: 2000,// 动画时长。
67
+ });
68
+ // highlight cell
69
+ stkTable.value.setHighlightDimCell(rowKey, colDataIndex, {
70
+ method: 'css'|'animation',
71
+ className:'custom-class-name',// method css 时生效。
72
+ keyframe: [{backgroundColor:'#aaa'},{backgroundColor: '#222'}], // method animation 时生效。
73
+ duration: 2000,// 动画时长。
74
+ })
58
75
  </script>
59
76
 
60
77
  <template>
@@ -125,7 +142,7 @@ export type StkProps = {
125
142
  headerRowHeight?: number | null;
126
143
  /** 虚拟滚动 */
127
144
  virtual?: boolean;
128
- /** x轴虚拟滚动 */
145
+ /** x轴虚拟滚动(必须设置列宽)*/
129
146
  virtualX?: boolean;
130
147
  /** 表格列配置 */
131
148
  columns?: StkTableColumn<any>[];
@@ -199,6 +216,23 @@ export type StkProps = {
199
216
  },
200
217
  /** 隐藏头部title。可传入dataIndex数组 */
201
218
  hideHeaderTitle?: boolean | string[];
219
+ /** 高亮配置 */
220
+ highlightConfig?: {
221
+ /** 高亮持续时间(s) */
222
+ duration?: number;
223
+ /** 高亮背景色 */
224
+ color?: {
225
+ light?: { from: string; to: string };
226
+ dark?: { from: string; to: string };
227
+ };
228
+ /** 高亮帧率(虚拟滚动生效) */
229
+ fps?: number;
230
+ };
231
+ /** 序号列配置 */
232
+ seqConfig?: {
233
+ /** 序号列起始下标 用于适配分页 */
234
+ startIndex?: number;
235
+ };
202
236
  };
203
237
  ```
204
238
  #### Emits
@@ -309,6 +343,11 @@ defineExpose({
309
343
  type Sorter<T> = boolean | ((data: T[], option: { order: Order; column: any }) => T[]);
310
344
  /** 表格列配置 */
311
345
  export type StkTableColumn<T extends Record<string, any>> = {
346
+ /**
347
+ * 列类型
348
+ * - seq 序号列
349
+ */
350
+ type?: 'seq';
312
351
  /** 取值id */
313
352
  dataIndex: keyof T & string;
314
353
  /** 表头文字 */
@@ -371,6 +410,51 @@ export type SortConfig<T extends Record<string, any>> = {
371
410
  };
372
411
  ```
373
412
 
413
+ ### setHighlightDimCell & setHighlightDimRow
414
+ #### setHighlightDimCell
415
+ ```ts
416
+ setHighlightDimCell(
417
+ rowKeyValues: UniqKey[],
418
+ option: {
419
+ method?: 'css' | 'animation' | 'js';
420
+ /** @deprecated 请使用method */
421
+ useCss?: boolean;
422
+ className?: string;
423
+ keyframe?: Parameters<Animatable['animate']>['0'];
424
+ duration?: number;
425
+ } = {},
426
+ )
427
+ ```
428
+ #### setHighlightDimRow
429
+ ```ts
430
+ setHighlightDimRow(
431
+ rowKeyValues: UniqKey[],
432
+ option: {
433
+ method?: 'css' | 'animation' | 'js';
434
+ /** @deprecated 请使用method */
435
+ useCss?: boolean;
436
+ className?: string;
437
+ keyframe?: Parameters<Animatable['animate']>['0'];
438
+ duration?: number;
439
+ }
440
+ )
441
+ ```
442
+ #### option
443
+ | key |value| desc |
444
+ | ---- | ---- | ---- |
445
+ | method | `css` `animation` `js` | 设置高亮方式。虚拟滚动默认js。否则css |
446
+ | ~~useCss~~ `deprecated` | `boolean`| ~~是否使用css~~ |
447
+ | className | `string` | 设置高亮样式。method == 'css' 生效 |
448
+ | keyframe | `Parameters<Animatable['animate']>['0']` | 设置高亮动画。method == 'animation' 生效。 |
449
+ | duration | `number` | 设置高亮动画持续时间。 method='css'状态下,用于移除class,如果传入了className则需要与自定义的动画时间一致。|
450
+
451
+ ##### option.method
452
+ | `option.method`| desc |
453
+ | ---- | ---- |
454
+ | css | 使用css class 实现高亮。 |
455
+ | animation | 使用 animation api 实现高亮。 |
456
+ | js | 使用 js 循环计算颜色实现高亮。虚拟滚动默认使用js。 |
457
+
374
458
  ### Example
375
459
  ```vue
376
460
  <template>
@@ -443,6 +527,9 @@ export type SortConfig<T extends Record<string, any>> = {
443
527
  ### 鼠标悬浮表头时,不展示title
444
528
  * 将 `StkTableColumn` 中的 `title` 字段置为 "" 空字符串。这样th中就没有title了。
445
529
  * 使用 `StkTableColumn` 中的 `customHeaderCell` 属性中,自定义表头渲染。
530
+ ### 虚拟滚动高亮性能
531
+ * 虚拟滚动下,高亮默认由js计算背景实现。好处是滚动不影响高亮状态。
532
+ * 在虚拟滚动下,高亮强制使用css @keyframes 实现动画。`setHighlightDimRow`/`setHighlightCellRow` 最后一个参数传入 `{useCss: true}` 即可。
446
533
 
447
534
 
448
535
  ## Other
@@ -1,4 +1,4 @@
1
- import { Order, SortConfig, SortOption, SortState, StkTableColumn, UniqKeyProp } from './types/index';
1
+ import { HighlightConfig, Order, SeqConfig, SortConfig, SortOption, SortState, StkTableColumn, UniqKeyProp } from './types/index';
2
2
  /** Generic stands for DataType */
3
3
  type DT = any;
4
4
  /**
@@ -56,7 +56,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
56
56
  headerRowHeight?: number | null | undefined;
57
57
  /** 虚拟滚动 */
58
58
  virtual?: boolean | undefined;
59
- /** x轴虚拟滚动 */
59
+ /** x轴虚拟滚动(必须设置列宽)*/
60
60
  virtualX?: boolean | undefined;
61
61
  /** 表格列配置 */
62
62
  columns?: StkTableColumn<any>[] | undefined;
@@ -120,6 +120,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
120
120
  sortConfig?: SortConfig<any> | undefined;
121
121
  /** 隐藏头部title。可传入dataIndex数组 */
122
122
  hideHeaderTitle?: boolean | string[] | undefined;
123
+ /** 高亮配置 */
124
+ highlightConfig?: HighlightConfig | undefined;
125
+ /** 序号列配置 */
126
+ seqConfig?: SeqConfig | undefined;
123
127
  }>, {
124
128
  width: string;
125
129
  fixedMode: boolean;
@@ -156,6 +160,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
156
160
  stringLocaleCompare: boolean;
157
161
  };
158
162
  hideHeaderTitle: boolean;
163
+ highlightConfig: () => {};
164
+ seqConfig: () => {};
159
165
  }>, {
160
166
  /** 初始化横向纵向虚拟滚动 */
161
167
  initVirtualScroll: (height?: number | undefined) => void;
@@ -166,10 +172,19 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
166
172
  /** 设置当前选中行 */
167
173
  setCurrentRow: typeof setCurrentRow;
168
174
  /** 设置高亮渐暗单元格 */
169
- setHighlightDimCell: (rowKeyValue: string, dataIndex: string) => void;
175
+ setHighlightDimCell: (rowKeyValue: string, dataIndex: string, option?: {
176
+ className?: string | undefined;
177
+ method?: "css" | "animation" | undefined;
178
+ keyframe?: Keyframe[] | PropertyIndexedKeyframes | null | undefined;
179
+ duration?: number | undefined;
180
+ }) => void;
170
181
  /** 设置高亮渐暗行 */
171
182
  setHighlightDimRow: (rowKeyValues: import("./types/index").UniqKey[], option?: {
183
+ method?: "css" | "animation" | "js" | undefined;
172
184
  useCss?: boolean | undefined;
185
+ className?: string | undefined;
186
+ keyframe?: Keyframe[] | PropertyIndexedKeyframes | null | undefined; /** v-model:columns col resize 时更新宽度*/
187
+ duration?: number | undefined;
173
188
  }) => void;
174
189
  /** 表格排序列dataIndex */
175
190
  sortCol: import("vue").Ref<string | null | undefined>;
@@ -221,7 +236,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
221
236
  headerRowHeight?: number | null | undefined;
222
237
  /** 虚拟滚动 */
223
238
  virtual?: boolean | undefined;
224
- /** x轴虚拟滚动 */
239
+ /** x轴虚拟滚动(必须设置列宽)*/
225
240
  virtualX?: boolean | undefined;
226
241
  /** 表格列配置 */
227
242
  columns?: StkTableColumn<any>[] | undefined;
@@ -285,6 +300,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
285
300
  sortConfig?: SortConfig<any> | undefined;
286
301
  /** 隐藏头部title。可传入dataIndex数组 */
287
302
  hideHeaderTitle?: boolean | string[] | undefined;
303
+ /** 高亮配置 */
304
+ highlightConfig?: HighlightConfig | undefined;
305
+ /** 序号列配置 */
306
+ seqConfig?: SeqConfig | undefined;
288
307
  }>, {
289
308
  width: string;
290
309
  fixedMode: boolean;
@@ -321,6 +340,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
321
340
  stringLocaleCompare: boolean;
322
341
  };
323
342
  hideHeaderTitle: boolean;
343
+ highlightConfig: () => {};
344
+ seqConfig: () => {};
324
345
  }>>> & {
325
346
  onScroll?: ((ev: Event, data: {
326
347
  startIndex: number;
@@ -375,6 +396,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
375
396
  optimizeVue2Scroll: boolean;
376
397
  sortConfig: SortConfig<any>;
377
398
  hideHeaderTitle: boolean | string[];
399
+ highlightConfig: HighlightConfig;
400
+ seqConfig: SeqConfig;
378
401
  }, {}>, {
379
402
  tableHeader?(_: {
380
403
  col: StkTableColumn<any>;
@@ -1,9 +1,9 @@
1
- export declare const Default_Col_Width = "100";
2
- export declare const Default_Table_Height = 100;
3
- export declare const Default_Table_Width = 200;
4
- export declare const Default_Row_Height = 28;
1
+ export declare const DEFAULT_COL_WIDTH = "100";
2
+ export declare const DEFAULT_TABLE_HEIGHT = 100;
3
+ export declare const DEFAULT_TABLE_WIDTH = 200;
4
+ export declare const DEFAULT_ROW_HEIGHT = 28;
5
5
  /** 高亮背景色 */
6
- export declare const Highlight_Color: {
6
+ export declare const HIGHLIGHT_COLOR: {
7
7
  light: {
8
8
  from: string;
9
9
  to: string;
@@ -14,8 +14,13 @@ export declare const Highlight_Color: {
14
14
  };
15
15
  };
16
16
  /** 高亮持续时间 */
17
- export declare const Highlight_Duration = 2000;
17
+ export declare const HIGHLIGHT_DURATION = 2000;
18
18
  /** 高亮变更频率 */
19
- export declare const Highlight_Color_Change_Freq = 100;
19
+ export declare const HIGHLIGHT_FREQ: number;
20
+ /** 高亮行class */
21
+ export declare const HIGHLIGHT_ROW_CLASS = "highlight-row";
22
+ /** 高连单元格class */
23
+ export declare const HIGHLIGHT_CELL_CLASS = "highlight-cell";
20
24
  /** 是否兼容低版本模式 */
21
- export declare const Is_Legacy_Mode: boolean;
25
+ export declare const IS_LEGACY_MODE: boolean;
26
+ export declare const STK_ID_PREFIX = "stk";
@@ -15,6 +15,11 @@ export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: {
15
15
  }) => VNode;
16
16
  /** 表格列配置 */
17
17
  export type StkTableColumn<T extends Record<string, any>> = {
18
+ /**
19
+ * 列类型
20
+ * - seq 序号列
21
+ */
22
+ type?: 'seq';
18
23
  /** 取值id */
19
24
  dataIndex: keyof T & string;
20
25
  /** 表头文字 */
@@ -62,6 +67,8 @@ export type StkTableColumn<T extends Record<string, any>> = {
62
67
  children?: StkTableColumn<T>[];
63
68
  /** 父节点引用 */
64
69
  __PARENT__?: StkTableColumn<T> | null;
70
+ /** 保存计算的宽度。横向虚拟滚动用。 */
71
+ __WIDTH__?: number;
65
72
  };
66
73
  export type SortOption<T extends Record<string, any>> = Pick<StkTableColumn<T>, 'sorter' | 'dataIndex' | 'sortField' | 'sortType'>;
67
74
  /** 排序状态 */
@@ -99,4 +106,16 @@ export declare const enum TagType {
99
106
  TH = 0,
100
107
  TD = 1
101
108
  }
109
+ /** 高亮配置 */
110
+ export type HighlightConfig = {
111
+ /** 高亮持续时间(s) */
112
+ duration?: number;
113
+ /** 高亮帧率 */
114
+ fps?: number;
115
+ };
116
+ /** 序号列配置 */
117
+ export type SeqConfig = {
118
+ /** 序号列起始下标 用于适配分页 */
119
+ startIndex?: number;
120
+ };
102
121
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Ref } from 'vue';
2
2
  type Options = {
3
3
  props: any;
4
- tableContainer: Ref<HTMLElement | undefined>;
4
+ tableContainerRef: Ref<HTMLElement | undefined>;
5
5
  initVirtualScroll: () => void;
6
6
  /** 防抖延时 */
7
7
  debounceMs: number;
@@ -10,5 +10,5 @@ type Options = {
10
10
  * 窗口变化自动重置虚拟滚动
11
11
  * @param param0
12
12
  */
13
- export declare function useAutoResize({ tableContainer, initVirtualScroll, props, debounceMs }: Options): void;
13
+ export declare function useAutoResize({ tableContainerRef, initVirtualScroll, props, debounceMs }: Options): void;
14
14
  export {};
@@ -1,15 +1,15 @@
1
- import { Ref } from 'vue';
1
+ import { Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn } from './types';
3
3
  type Params<DT extends Record<string, any>> = {
4
4
  props: any;
5
5
  emits: any;
6
- tableContainer: Ref<HTMLElement | undefined>;
7
- tableHeaderLast: Ref<StkTableColumn<DT>[]>;
8
- colResizeIndicator: Ref<HTMLElement | undefined>;
6
+ tableContainerRef: Ref<HTMLElement | undefined>;
7
+ tableHeaderLast: ShallowRef<StkTableColumn<DT>[]>;
8
+ colResizeIndicatorRef: Ref<HTMLElement | undefined>;
9
9
  colKeyGen: (p: any) => string;
10
10
  };
11
11
  /** 列宽拖动 */
12
- export declare function useColResize<DT extends Record<string, any>>({ tableContainer, tableHeaderLast, colResizeIndicator, props, emits, colKeyGen, }: Params<DT>): {
12
+ export declare function useColResize<DT extends Record<string, any>>({ tableContainerRef, tableHeaderLast, colResizeIndicatorRef, props, emits, colKeyGen, }: Params<DT>): {
13
13
  isColResizing: Ref<boolean>;
14
14
  onThResizeMouseDown: (e: MouseEvent, col: StkTableColumn<DT>, isPrev?: boolean) => void;
15
15
  onThResizeMouseMove: (e: MouseEvent) => void;
@@ -1,17 +1,17 @@
1
- import { Ref } from 'vue';
1
+ import { Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn } from './types';
3
3
  type Params<T extends Record<string, any>> = {
4
4
  props: any;
5
5
  colKeyGen: (col: StkTableColumn<T>) => string;
6
- tableHeaders: Ref<StkTableColumn<T>[][]>;
7
- tableHeaderLast: Ref<StkTableColumn<T>[]>;
8
- tableContainer: Ref<HTMLDivElement | undefined>;
6
+ tableHeaders: ShallowRef<StkTableColumn<T>[][]>;
7
+ tableHeaderLast: ShallowRef<StkTableColumn<T>[]>;
8
+ tableContainerRef: Ref<HTMLDivElement | undefined>;
9
9
  };
10
10
  /**
11
11
  * 固定列处理
12
12
  * @returns
13
13
  */
14
- export declare function useFixedCol<DT extends Record<string, any>>({ props, colKeyGen, tableHeaders, tableHeaderLast, tableContainer }: Params<DT>): {
14
+ export declare function useFixedCol<DT extends Record<string, any>>({ props, colKeyGen, tableHeaders, tableHeaderLast, tableContainerRef }: Params<DT>): {
15
15
  /** 固定列class */
16
16
  fixedColClassMap: import("vue").ComputedRef<Map<any, any>>;
17
17
  /** 处理固定列阴影 */
@@ -1,9 +1,9 @@
1
- import { CSSProperties, Ref } from 'vue';
1
+ import { CSSProperties, Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn, TagType } from './types';
3
3
  import { VirtualScrollStore, VirtualScrollXStore } from './useVirtualScroll';
4
4
  type Options<T extends Record<string, any>> = {
5
5
  props: any;
6
- tableHeaders: Ref<StkTableColumn<T>[][]>;
6
+ tableHeaders: ShallowRef<StkTableColumn<T>[][]>;
7
7
  virtualScroll: Ref<VirtualScrollStore>;
8
8
  virtualScrollX: Ref<VirtualScrollXStore>;
9
9
  virtualX_on: Ref<boolean>;
@@ -15,6 +15,6 @@ type Options<T extends Record<string, any>> = {
15
15
  * @returns
16
16
  */
17
17
  export declare function useFixedStyle<DT extends Record<string, any>>({ props, tableHeaders, virtualScroll, virtualScrollX, virtualX_on, virtualX_offsetRight, }: Options<DT>): {
18
- getFixedStyle: (tagType: TagType, col: StkTableColumn<DT>, depth?: number) => CSSProperties;
18
+ getFixedStyle: (tagType: TagType, col: StkTableColumn<DT>, depth?: number) => CSSProperties | null;
19
19
  };
20
20
  export {};
@@ -1,28 +1,28 @@
1
1
  import { Ref } from 'vue';
2
2
  import { UniqKey } from './types';
3
3
  type Params = {
4
- props: {
5
- theme: 'light' | 'dark';
6
- virtual: boolean;
7
- dataSource: any[];
8
- };
9
- tableContainer: Ref<HTMLElement | undefined>;
10
- };
11
- /** 高亮行保存的东西 */
12
- type HighlightRowStore = {
13
- bgc: string;
14
- bgc_progress_ms: number;
15
- bgc_progress: number;
4
+ props: any;
5
+ stkTableId: string;
6
+ tableContainerRef: Ref<HTMLDivElement | undefined>;
16
7
  };
17
8
  /**
18
9
  * 高亮单元格,行
19
- * row中新增_bgc_progress_ms 属性控制高亮状态,_bgc控制颜色
20
10
  */
21
- export declare function useHighlight({ props, tableContainer }: Params): {
22
- highlightRowStore: Ref<Record<UniqKey, HighlightRowStore>>;
11
+ export declare function useHighlight({ props, stkTableId, tableContainerRef }: Params): {
12
+ highlightSteps: number;
23
13
  setHighlightDimRow: (rowKeyValues: UniqKey[], option?: {
14
+ method?: 'css' | 'animation' | 'js';
15
+ /** @deprecated 请使用method */
24
16
  useCss?: boolean;
17
+ className?: string;
18
+ keyframe?: Parameters<Animatable['animate']>['0'];
19
+ duration?: number;
20
+ }) => void;
21
+ setHighlightDimCell: (rowKeyValue: string, dataIndex: string, option?: {
22
+ className?: string;
23
+ method?: 'css' | 'animation';
24
+ keyframe?: Parameters<Animatable['animate']>['0'];
25
+ duration?: number;
25
26
  }) => void;
26
- setHighlightDimCell: (rowKeyValue: string, dataIndex: string) => void;
27
27
  };
28
28
  export {};
@@ -1,4 +1,4 @@
1
- import { Ref } from 'vue';
1
+ import { ComputedRef, Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn } from './types';
3
3
  import { VirtualScrollStore, VirtualScrollXStore } from './useVirtualScroll';
4
4
  type Options<DT extends Record<string, any>> = {
@@ -6,12 +6,13 @@ type Options<DT extends Record<string, any>> = {
6
6
  scrollTo: (y: number | null, x: number | null) => void;
7
7
  virtualScroll: Ref<VirtualScrollStore>;
8
8
  virtualScrollX: Ref<VirtualScrollXStore>;
9
- tableHeaders: Ref<StkTableColumn<DT>[][]>;
9
+ tableHeaders: ShallowRef<StkTableColumn<DT>[][]>;
10
+ virtual_on: ComputedRef<boolean>;
10
11
  };
11
12
  /**
12
13
  * 按下键盘箭头滚动。只有悬浮在表体上才能生效键盘。
13
14
  *
14
15
  * 在低版本浏览器中,虚拟滚动时,使用键盘滚动,等选中的行消失在视口外时,滚动会失效。
15
16
  */
16
- export declare function useKeyboardArrowScroll<DT extends Record<string, any>>(targetElement: Ref<HTMLElement | undefined>, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders }: Options<DT>): void;
17
+ export declare function useKeyboardArrowScroll<DT extends Record<string, any>>(targetElement: Ref<HTMLElement | undefined>, { props, scrollTo, virtualScroll, virtualScrollX, tableHeaders, virtual_on }: Options<DT>): void;
17
18
  export {};
@@ -2,10 +2,10 @@ import { Ref, ShallowRef } from 'vue';
2
2
  import { StkTableColumn } from './types';
3
3
  type Option<DT extends Record<string, any>> = {
4
4
  props: any;
5
- tableContainer: Ref<HTMLElement | undefined>;
5
+ tableContainerRef: Ref<HTMLElement | undefined>;
6
6
  dataSourceCopy: ShallowRef<DT[]>;
7
- tableHeaderLast: Ref<StkTableColumn<DT>[]>;
8
- tableHeaders: Ref<StkTableColumn<DT>[][]>;
7
+ tableHeaderLast: ShallowRef<StkTableColumn<DT>[]>;
8
+ tableHeaders: ShallowRef<StkTableColumn<DT>[][]>;
9
9
  };
10
10
  /** 暂存纵向虚拟滚动的数据 */
11
11
  export type VirtualScrollStore = {
@@ -42,7 +42,7 @@ export type VirtualScrollXStore = {
42
42
  * @param param0
43
43
  * @returns
44
44
  */
45
- export declare function useVirtualScroll<DT extends Record<string, any>>({ props, tableContainer, dataSourceCopy, tableHeaderLast, tableHeaders, }: Option<DT>): {
45
+ export declare function useVirtualScroll<DT extends Record<string, any>>({ props, tableContainerRef, dataSourceCopy, tableHeaderLast, tableHeaders, }: Option<DT>): {
46
46
  virtualScroll: Ref<{
47
47
  containerHeight: number;
48
48
  pageSize: number;
@@ -23,7 +23,15 @@ export declare function insertToOrderedArray<T extends object>(sortState: SortSt
23
23
  export declare function tableSort<T extends Record<string, any>>(sortOption: SortOption<T>, order: Order, dataSource: T[], sortConfig?: SortConfig<T>): T[];
24
24
  /** 表头column配置的层级 */
25
25
  export declare function howDeepTheHeader(arr: StkTableColumn<any>[], level?: number): number;
26
- /** 获取列宽 */
26
+ /**
27
+ * 获取列宽
28
+ *
29
+ * 关于列宽的操作往往在横向滚动中使用。既然已经有横向滚动了,则列宽会被压缩至minWidth,所以优先取minWidth
30
+ */
27
31
  export declare function getColWidth(col: StkTableColumn<any> | null): number;
28
- /** 获取列宽配置。用于支持列宽配置数字 */
29
- export declare function getColWidthStr(col: StkTableColumn<any> | null | undefined, key?: 'width' | 'minWidth' | 'maxWidth'): string | undefined;
32
+ /** 获取计算后的宽度 */
33
+ export declare function getCalculatedColWidth(col: StkTableColumn<any> | null): number;
34
+ /** number列宽+px */
35
+ export declare function transformWidthToStr(width?: string | number): string | undefined;
36
+ /** 创建组件唯一标识 */
37
+ export declare function createStkTableId(): string;