stk-table-vue 0.7.2 → 0.8.1

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;
@@ -218,6 +218,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
218
218
  columns: () => never[];
219
219
  dataSource: () => never[];
220
220
  rowKey: string;
221
+ colKey: undefined;
221
222
  emptyCellText: string;
222
223
  noDataFull: boolean;
223
224
  showNoData: boolean;
@@ -291,14 +292,14 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
291
292
  * en: Set highlight cell
292
293
  * @see {@link setHighlightDimCell}
293
294
  */
294
- 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;
295
296
  /**
296
297
  * 设置高亮行
297
298
  *
298
299
  * en: Set highlight row
299
300
  * @see {@link setHighlightDimRow}
300
301
  */
301
- setHighlightDimRow: (rowKeyValues: import('./types/index').UniqKey[], option?: import('./types/highlightDimOptions').HighlightDimRowOption) => void;
302
+ setHighlightDimRow: (rowKeyValues: UniqKey[], option?: import('./types/highlightDimOptions').HighlightDimRowOption) => void;
302
303
  /**
303
304
  * 表格排序列colKey
304
305
  *
@@ -356,7 +357,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
356
357
  * en: When the row height is not fixed, call this method to update the row height if the row height changes.
357
358
  * @see {@link setAutoHeight}
358
359
  */
359
- setAutoHeight: (rowKey: import('./types/index').UniqKey, height?: number | null) => void;
360
+ setAutoHeight: (rowKey: UniqKey, height?: number | null) => void;
360
361
  /**
361
362
  * 清除所有行高
362
363
  *
@@ -370,9 +371,9 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
370
371
  * en: Set tree node expand state
371
372
  * @see {@link setTreeExpand}
372
373
  */
373
- setTreeExpand: (row: (import('./types/index').UniqKey | (PrivateRowDT & {
374
+ setTreeExpand: (row: (UniqKey | (PrivateRowDT & {
374
375
  children?: (PrivateRowDT & /*elided*/ any)[];
375
- })) | (import('./types/index').UniqKey | (PrivateRowDT & {
376
+ })) | (UniqKey | (PrivateRowDT & {
376
377
  children?: (PrivateRowDT & /*elided*/ any)[];
377
378
  }))[], option?: {
378
379
  expand?: boolean;
@@ -583,6 +584,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
583
584
  columns: () => never[];
584
585
  dataSource: () => never[];
585
586
  rowKey: string;
587
+ colKey: undefined;
586
588
  emptyCellText: string;
587
589
  noDataFull: boolean;
588
590
  showNoData: boolean;
@@ -677,6 +679,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
677
679
  optimizeVue2Scroll: boolean;
678
680
  rowKey: UniqKeyProp;
679
681
  headerRowHeight: number | string | null;
682
+ colKey: UniqKeyProp;
680
683
  fixedMode: boolean;
681
684
  theme: "light" | "dark";
682
685
  rowHover: boolean;
@@ -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
  };
@@ -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;