stk-table-vue 0.7.1 → 0.8.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.
@@ -1,4 +1,4 @@
1
- import { AutoRowHeightConfig, ColResizableConfig, DragRowConfig, ExpandConfig, HeaderDragConfig, HighlightConfig, Order, PrivateRowDT, SeqConfig, SortConfig, SortOption, StkTableColumn, TreeConfig, UniqKeyProp } from './types/index';
1
+ import { AutoRowHeightConfig, ColResizableConfig, DragRowConfig, ExpandConfig, HeaderDragConfig, HighlightConfig, Order, PrivateRowDT, PrivateStkTableColumn, SeqConfig, SortConfig, SortOption, StkTableColumn, TreeConfig, UniqKey, UniqKeyProp } from './types/index';
2
2
 
3
3
  /** Generic stands for DataType */
4
4
  type DT = any & PrivateRowDT;
@@ -54,7 +54,7 @@ declare function getSortColumns(): {
54
54
  }[];
55
55
  declare function __VLS_template(): {
56
56
  tableHeader?(_: {
57
- col: StkTableColumn<any>;
57
+ col: PrivateStkTableColumn<any>;
58
58
  }): any;
59
59
  expand?(_: {
60
60
  row: any;
@@ -94,7 +94,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
94
94
  /** 当前行再次点击否可以取消 (rowActive=true)*/
95
95
  rowCurrentRevokable?: boolean;
96
96
  /** 表头行高。default = rowHeight */
97
- headerRowHeight?: number | null;
97
+ headerRowHeight?: number | string | null;
98
98
  /** 虚拟滚动 */
99
99
  virtual?: boolean;
100
100
  /** x轴虚拟滚动(必须设置列宽)*/
@@ -194,8 +194,11 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
194
194
  * - true: 不使用 onwheel 滚动。鼠标滚轮滚动时更加平滑。滚动过快时会白屏。
195
195
  */
196
196
  smoothScroll?: boolean;
197
- /** 按整数行纵向滚动 */
198
- scrollRowByRow?: boolean;
197
+ /**
198
+ * 按整数行纵向滚动
199
+ * - scrollbar:仅拖动滚动条生效
200
+ */
201
+ scrollRowByRow?: boolean | "scrollbar";
199
202
  }>, {
200
203
  width: string;
201
204
  fixedMode: boolean;
@@ -215,6 +218,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
215
218
  columns: () => never[];
216
219
  dataSource: () => never[];
217
220
  rowKey: string;
221
+ colKey: undefined;
218
222
  emptyCellText: string;
219
223
  noDataFull: boolean;
220
224
  showNoData: boolean;
@@ -288,14 +292,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
288
292
  * en: Set highlight cell
289
293
  * @see {@link setHighlightDimCell}
290
294
  */
291
- setHighlightDimCell: (rowKeyValue: import('./types/index').UniqKey, colKeyValue: string, option?: import('./types/highlightDimOptions').HighlightDimCellOption) => void;
295
+ setHighlightDimCell: (rowKeyValue: UniqKey, colKeyValue: string, option?: import('./types/highlightDimOptions').HighlightDimCellOption) => void;
292
296
  /**
293
297
  * 设置高亮行
294
298
  *
295
299
  * en: Set highlight row
296
300
  * @see {@link setHighlightDimRow}
297
301
  */
298
- setHighlightDimRow: (rowKeyValues: import('./types/index').UniqKey[], option?: import('./types/highlightDimOptions').HighlightDimRowOption) => void;
302
+ setHighlightDimRow: (rowKeyValues: UniqKey[], option?: import('./types/highlightDimOptions').HighlightDimRowOption) => void;
299
303
  /**
300
304
  * 表格排序列colKey
301
305
  *
@@ -353,7 +357,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
353
357
  * en: When the row height is not fixed, call this method to update the row height if the row height changes.
354
358
  * @see {@link setAutoHeight}
355
359
  */
356
- setAutoHeight: (rowKey: import('./types/index').UniqKey, height?: number | null) => void;
360
+ setAutoHeight: (rowKey: UniqKey, height?: number | null) => void;
357
361
  /**
358
362
  * 清除所有行高
359
363
  *
@@ -367,12 +371,12 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
367
371
  * en: Set tree node expand state
368
372
  * @see {@link setTreeExpand}
369
373
  */
370
- setTreeExpand: (row: (import('./types/index').UniqKey | (PrivateRowDT & {
374
+ setTreeExpand: (row: (UniqKey | (PrivateRowDT & {
371
375
  children?: (PrivateRowDT & /*elided*/ any)[];
372
- })) | (import('./types/index').UniqKey | (PrivateRowDT & {
376
+ })) | (UniqKey | (PrivateRowDT & {
373
377
  children?: (PrivateRowDT & /*elided*/ any)[];
374
378
  }))[], option?: {
375
- expand? /** 是否高亮选中的行 */: boolean;
379
+ expand?: boolean;
376
380
  }) => void;
377
381
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
378
382
  "sort-change": (col: StkTableColumn<any> | null, order: Order, data: any[], sortConfig: SortConfig<any>) => void;
@@ -456,7 +460,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
456
460
  /** 当前行再次点击否可以取消 (rowActive=true)*/
457
461
  rowCurrentRevokable?: boolean;
458
462
  /** 表头行高。default = rowHeight */
459
- headerRowHeight?: number | null;
463
+ headerRowHeight?: number | string | null;
460
464
  /** 虚拟滚动 */
461
465
  virtual?: boolean;
462
466
  /** x轴虚拟滚动(必须设置列宽)*/
@@ -556,8 +560,11 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
556
560
  * - true: 不使用 onwheel 滚动。鼠标滚轮滚动时更加平滑。滚动过快时会白屏。
557
561
  */
558
562
  smoothScroll?: boolean;
559
- /** 按整数行纵向滚动 */
560
- scrollRowByRow?: boolean;
563
+ /**
564
+ * 按整数行纵向滚动
565
+ * - scrollbar:仅拖动滚动条生效
566
+ */
567
+ scrollRowByRow?: boolean | "scrollbar";
561
568
  }>, {
562
569
  width: string;
563
570
  fixedMode: boolean;
@@ -577,6 +584,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
577
584
  columns: () => never[];
578
585
  dataSource: () => never[];
579
586
  rowKey: string;
587
+ colKey: undefined;
580
588
  emptyCellText: string;
581
589
  noDataFull: boolean;
582
590
  showNoData: boolean;
@@ -670,7 +678,8 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
670
678
  stripe: boolean;
671
679
  optimizeVue2Scroll: boolean;
672
680
  rowKey: UniqKeyProp;
673
- headerRowHeight: number | null;
681
+ headerRowHeight: number | string | null;
682
+ colKey: UniqKeyProp;
674
683
  fixedMode: boolean;
675
684
  theme: "light" | "dark";
676
685
  rowHover: boolean;
@@ -708,7 +717,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
708
717
  treeConfig: TreeConfig;
709
718
  cellFixedMode: "sticky" | "relative";
710
719
  smoothScroll: boolean;
711
- scrollRowByRow: boolean;
720
+ scrollRowByRow: boolean | "scrollbar";
712
721
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
713
722
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
714
723
  export default _default;
@@ -1,4 +1,4 @@
1
- import { Component, ConcreteComponent } from 'vue';
1
+ import { Component, ComputedRef, ConcreteComponent } from 'vue';
2
2
 
3
3
  /** 排序方式,asc-正序,desc-倒序,null-默认顺序 */
4
4
  export type Order = null | 'asc' | 'desc';
@@ -25,6 +25,16 @@ export type CustomHeaderCellProps<T extends Record<string, any>> = {
25
25
  rowIndex: number;
26
26
  colIndex: number;
27
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;
28
38
  /**
29
39
  * 自定义渲染单元格
30
40
  *
@@ -77,8 +87,6 @@ export type StkTableColumn<T extends Record<string, any>> = {
77
87
  sortConfig?: Pick<SortConfig<T>, 'emptyToBottom' | 'stringLocaleCompare'>;
78
88
  /** 固定列 */
79
89
  fixed?: 'left' | 'right' | null;
80
- /** private */ rowSpan?: number;
81
- /** private */ colSpan?: number;
82
90
  /**
83
91
  * 自定义 td 渲染内容。
84
92
  *
@@ -101,16 +109,22 @@ export type StkTableColumn<T extends Record<string, any>> = {
101
109
  customHeaderCell?: CustomCell<CustomHeaderCellProps<T>, T>;
102
110
  /** 二级表头 */
103
111
  children?: StkTableColumn<T>[];
112
+ /** 单元格合并 */
113
+ mergeCells?: MergeCellsFn<T>;
104
114
  };
105
115
  /** private StkTableColumn type. Add some private key */
106
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;
107
121
  /**
108
- * 父节点引用
122
+ * parent not ref
109
123
  * @private
110
124
  */
111
125
  __PARENT__?: StkTableColumn<T> | null;
112
126
  /**
113
- * 保存计算的宽度。横向虚拟滚动用。
127
+ * Save the calculated width. Used for horizontal virtual scrolling.
114
128
  * @private
115
129
  */
116
130
  __WIDTH__?: number;
@@ -236,4 +250,7 @@ export type AutoRowHeightConfig<DT> = {
236
250
  export type ColResizableConfig<DT extends Record<string, any>> = {
237
251
  disabled: (col: StkTableColumn<DT>) => boolean;
238
252
  };
253
+ export type RowKeyGen = (row: any) => UniqKey;
254
+ export type ColKeyGen = ComputedRef<(col: StkTableColumn<any>) => UniqKey>;
255
+ export type CellKeyGen = (row: any, col: StkTableColumn<any>) => string;
239
256
  export {};
@@ -0,0 +1,20 @@
1
+ import { ShallowRef } from 'vue';
2
+ import { ColKeyGen, MergeCellsParam, PrivateStkTableColumn, RowKeyGen, UniqKey } from './types';
3
+
4
+ export declare function useMergeCells({ props, tableHeaderLast, rowKeyGen, colKeyGen, virtual_dataSourcePart, }: {
5
+ props: any;
6
+ tableHeaderLast: ShallowRef<PrivateStkTableColumn<any>[]>;
7
+ rowKeyGen: RowKeyGen;
8
+ colKeyGen: ColKeyGen;
9
+ virtual_dataSourcePart: ShallowRef<any[]>;
10
+ }): {
11
+ hiddenCellMap: import('vue').Ref<Record<UniqKey, Set<UniqKey>>, Record<UniqKey, Set<UniqKey>>>;
12
+ mergeCellsWrapper: (row: MergeCellsParam<any>["row"], col: MergeCellsParam<any>["col"], rowIndex: MergeCellsParam<any>["rowIndex"], colIndex: MergeCellsParam<any>["colIndex"]) => {
13
+ colspan?: number;
14
+ rowspan?: number;
15
+ } | undefined;
16
+ hoverMergedCells: import('vue').Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
17
+ updateHoverMergedCells: (rowKey: UniqKey | undefined) => void;
18
+ activeMergedCells: import('vue').Ref<Set<string> & Omit<Set<string>, keyof Set<any>>, Set<string> | (Set<string> & Omit<Set<string>, keyof Set<any>>)>;
19
+ updateActiveMergedCells: (clear?: boolean) => void;
20
+ };
@@ -1,9 +1,9 @@
1
1
  import { ShallowRef } from 'vue';
2
- import { PrivateRowDT, StkTableColumn, UniqKey } from './types';
2
+ import { PrivateRowDT, RowKeyGen, StkTableColumn } from './types';
3
3
 
4
4
  type DT = PrivateRowDT;
5
5
  type Option<DT extends Record<string, any>> = {
6
- rowKeyGen: (row: any) => UniqKey;
6
+ rowKeyGen: RowKeyGen;
7
7
  dataSourceCopy: ShallowRef<DT[]>;
8
8
  emits: any;
9
9
  };
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+
3
+ type Params = {
4
+ props: any;
5
+ tableContainerRef: Ref<HTMLElement | undefined>;
6
+ };
7
+ export declare function useScrollRowByRow({ props, tableContainerRef }: Params): {
8
+ isSRBRActive: import('vue').ComputedRef<any>;
9
+ isDragScroll: Ref<boolean, boolean>;
10
+ };
11
+ export {};
@@ -1,20 +1,19 @@
1
- import { ComputedRef } from 'vue';
2
- import { StkTableColumn, UniqKey } from './types';
1
+ import { ColKeyGen, StkTableColumn } from './types';
3
2
 
4
- type Params<T extends Record<string, any>> = {
3
+ type Params = {
5
4
  props: any;
6
5
  emits: any;
7
- colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
6
+ colKeyGen: ColKeyGen;
8
7
  };
9
8
  /**
10
9
  * 列顺序拖动
11
10
  * @returns
12
11
  */
13
- export declare function useThDrag<DT extends Record<string, any>>({ props, emits, colKeyGen }: Params<DT>): {
12
+ export declare function useThDrag({ props, emits, colKeyGen }: Params): {
14
13
  onThDragStart: (e: DragEvent) => void;
15
14
  onThDragOver: (e: DragEvent) => void;
16
15
  onThDrop: (e: DragEvent) => void;
17
16
  /** 是否可拖拽 */
18
- isHeaderDraggable: (col: StkTableColumn<DT>) => any;
17
+ isHeaderDraggable: (col: StkTableColumn<any>) => any;
19
18
  };
20
19
  export {};
@@ -1,12 +1,12 @@
1
1
  import { ShallowRef } from 'vue';
2
- import { PrivateRowDT, UniqKey } from './types';
2
+ import { PrivateRowDT, RowKeyGen, UniqKey } from './types';
3
3
 
4
4
  type DT = PrivateRowDT & {
5
5
  children?: DT[];
6
6
  };
7
7
  type Option<DT extends Record<string, any>> = {
8
8
  props: any;
9
- rowKeyGen: (row: any) => UniqKey;
9
+ rowKeyGen: RowKeyGen;
10
10
  dataSourceCopy: ShallowRef<DT[]>;
11
11
  emits: any;
12
12
  };
@@ -1,14 +1,14 @@
1
1
  import { Ref, ShallowRef } from 'vue';
2
- import { StkTableColumn, UniqKey } from './types';
2
+ import { PrivateStkTableColumn, RowKeyGen, UniqKey } from './types';
3
3
 
4
4
  type Option<DT extends Record<string, any>> = {
5
5
  props: any;
6
6
  tableContainerRef: Ref<HTMLElement | undefined>;
7
7
  trRef: Ref<HTMLTableRowElement[] | undefined>;
8
8
  dataSourceCopy: ShallowRef<DT[]>;
9
- tableHeaderLast: ShallowRef<StkTableColumn<DT>[]>;
10
- tableHeaders: ShallowRef<StkTableColumn<DT>[][]>;
11
- rowKeyGen: (row: any) => UniqKey;
9
+ tableHeaderLast: ShallowRef<PrivateStkTableColumn<DT>[]>;
10
+ tableHeaders: ShallowRef<PrivateStkTableColumn<DT>[][]>;
11
+ rowKeyGen: RowKeyGen;
12
12
  };
13
13
  /** 暂存纵向虚拟滚动的数据 */
14
14
  export type VirtualScrollStore = {
@@ -88,7 +88,7 @@ export declare function useVirtualScroll<DT extends Record<string, any>>({ props
88
88
  virtual_dataSourcePart: import('vue').ComputedRef<DT[]>;
89
89
  virtual_offsetBottom: import('vue').ComputedRef<number>;
90
90
  virtualX_on: import('vue').ComputedRef<any>;
91
- virtualX_columnPart: import('vue').ComputedRef<StkTableColumn<DT>[]>;
91
+ virtualX_columnPart: import('vue').ComputedRef<PrivateStkTableColumn<DT>[]>;
92
92
  virtualX_offsetRight: import('vue').ComputedRef<number>;
93
93
  initVirtualScroll: (height?: number) => void;
94
94
  initVirtualScrollY: (height?: number) => void;
@@ -1,4 +1,4 @@
1
- import { Order, SortConfig, SortOption, SortState, StkTableColumn } from '../types';
1
+ import { Order, SortConfig, SortOption, SortState, StkTableColumn, UniqKey } from '../types';
2
2
 
3
3
  /** 是否空值 */
4
4
  export declare function isEmptyValue(val: any, isNumber?: boolean): boolean;
@@ -50,3 +50,4 @@ export declare function howDeepTheHeader(arr: StkTableColumn<any>[], level?: num
50
50
  /** number width +px */
51
51
  export declare function transformWidthToStr(width?: string | number): string | undefined;
52
52
  export declare function getBrowsersVersion(browserName: string): number;
53
+ export declare function pureCellKeyGen(rowKey: UniqKey, colKey: UniqKey): string;
@@ -402,3 +402,9 @@
402
402
  .stk-table .stk-fold-icon:hover::before{
403
403
  border-left:5px solid var(--fold-icon-hover-color);
404
404
  }
405
+ .stk-table td.cell-hover{
406
+ background-color:var(--tr-hover-bgc);
407
+ }
408
+ .stk-table td.cell-active{
409
+ background-color:var(--tr-active-bgc);
410
+ }