stk-table-vue 0.6.16 → 0.7.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.
Files changed (39) hide show
  1. package/README.md +211 -213
  2. package/lib/src/StkTable/StkTable.vue.d.ts +43 -24
  3. package/lib/src/StkTable/components/TriangleIcon.vue.d.ts +2 -0
  4. package/lib/src/StkTable/const.d.ts +0 -1
  5. package/lib/src/StkTable/types/highlightDimOptions.d.ts +1 -5
  6. package/lib/src/StkTable/types/index.d.ts +26 -6
  7. package/lib/src/StkTable/useHighlight.d.ts +1 -1
  8. package/lib/src/StkTable/useRowExpand.d.ts +17 -0
  9. package/lib/src/StkTable/useTree.d.ts +20 -0
  10. package/lib/stk-table-vue.js +321 -170
  11. package/lib/style.css +29 -20
  12. package/package.json +75 -75
  13. package/src/StkTable/StkTable.vue +1557 -1550
  14. package/src/StkTable/components/DragHandle.vue +9 -9
  15. package/src/StkTable/components/SortIcon.vue +6 -6
  16. package/src/StkTable/components/TriangleIcon.vue +3 -0
  17. package/src/StkTable/const.ts +37 -37
  18. package/src/StkTable/index.ts +4 -4
  19. package/src/StkTable/style.less +567 -553
  20. package/src/StkTable/types/highlightDimOptions.ts +26 -26
  21. package/src/StkTable/types/index.ts +260 -239
  22. package/src/StkTable/useAutoResize.ts +91 -91
  23. package/src/StkTable/useColResize.ts +216 -216
  24. package/src/StkTable/useFixedCol.ts +148 -148
  25. package/src/StkTable/useFixedStyle.ts +75 -75
  26. package/src/StkTable/useGetFixedColPosition.ts +65 -65
  27. package/src/StkTable/useHighlight.ts +320 -318
  28. package/src/StkTable/useKeyboardArrowScroll.ts +112 -112
  29. package/src/StkTable/useRowExpand.ts +78 -0
  30. package/src/StkTable/useThDrag.ts +102 -102
  31. package/src/StkTable/useTrDrag.ts +118 -118
  32. package/src/StkTable/useTree.ts +158 -0
  33. package/src/StkTable/useVirtualScroll.ts +462 -462
  34. package/src/StkTable/utils/constRefUtils.ts +29 -29
  35. package/src/StkTable/utils/index.ts +213 -212
  36. package/src/StkTable/utils/useTriggerRef.ts +33 -33
  37. package/src/VirtualTree.vue +622 -622
  38. package/src/VirtualTreeSelect.vue +367 -367
  39. package/src/vite-env.d.ts +10 -10
@@ -1,148 +1,148 @@
1
- import { computed, ComputedRef, Ref, ShallowRef, shallowRef } from 'vue';
2
- import { StkTableColumn, UniqKey } from './types';
3
- import { VirtualScrollXStore } from './useVirtualScroll';
4
- import { getCalculatedColWidth } from './utils/constRefUtils';
5
-
6
- type Params<T extends Record<string, any>> = {
7
- props: any;
8
- colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
9
- getFixedColPosition: ComputedRef<(col: StkTableColumn<T>) => number>;
10
- tableHeaders: ShallowRef<StkTableColumn<T>[][]>;
11
- tableHeadersForCalc: ShallowRef<StkTableColumn<T>[][]>;
12
- tableContainerRef: Ref<HTMLDivElement | undefined>;
13
- };
14
-
15
- /**
16
- * 固定列处理
17
- * @returns
18
- */
19
- export function useFixedCol<DT extends Record<string, any>>({
20
- props,
21
- colKeyGen,
22
- getFixedColPosition,
23
- tableHeaders,
24
- tableHeadersForCalc,
25
- tableContainerRef,
26
- }: Params<DT>) {
27
- /** 保存需要出现阴影的列 */
28
- const fixedShadowCols = shallowRef<StkTableColumn<DT>[]>([]);
29
-
30
- /** 正在被固定的列 */
31
- const fixedCols = shallowRef<StkTableColumn<DT>[]>([]);
32
-
33
- /** 固定列的class */
34
- const fixedColClassMap = computed(() => {
35
- const colMap = new Map();
36
- const fixedShadowColsValue = fixedShadowCols.value;
37
- const fixedColsValue = fixedCols.value;
38
- const colKey = colKeyGen.value;
39
- const fixedColShadow = props.fixedColShadow;
40
- tableHeaders.value.forEach(cols => {
41
- cols.forEach(col => {
42
- const fixed = col.fixed;
43
- const showShadow = fixedColShadow && fixed && fixedShadowColsValue.includes(col);
44
- const classObj: Record<string, any> = {
45
- 'fixed-cell--active': fixedColsValue.includes(col), // 表示该列正在被固定
46
- };
47
- if (fixed) {
48
- classObj['fixed-cell'] = true;
49
- classObj['fixed-cell--' + fixed] = true;
50
- }
51
- if (showShadow) {
52
- classObj['fixed-cell--shadow'] = true;
53
- }
54
- colMap.set(colKey(col), classObj);
55
- });
56
- });
57
- return colMap;
58
- });
59
-
60
- /**
61
- * 返回所有父元素,包括自己
62
- * @param col
63
- * @param type 1-shadow(阴影) 2-active(被固定的列)
64
- *
65
- */
66
- // function getColAndParentCols(col: StkTableColumn<DT> | null, type: 1 | 2 = 1) {
67
- // if (!col) return [];
68
- // const colsTemp: StkTableColumn<DT>[] = [];
69
- // let node: any = { __PARENT__: col };
70
- // while ((node = node.__PARENT__)) {
71
- // if (type === 1 && node.fixed) {
72
- // // shadow
73
- // colsTemp.push(node);
74
- // }
75
- // if (type === 2) {
76
- // // active
77
- // colsTemp.push(node);
78
- // }
79
- // }
80
- // return colsTemp;
81
- // }
82
-
83
- /** 滚动条变化时,更新需要展示阴影的列 */
84
- function updateFixedShadow(virtualScrollX?: Ref<VirtualScrollXStore>) {
85
- const fixedColsTemp: StkTableColumn<DT>[] = [];
86
- const getFixedColPositionValue = getFixedColPosition.value;
87
- let clientWidth, scrollLeft;
88
-
89
- if (virtualScrollX?.value) {
90
- const { containerWidth: cw, scrollLeft: sl } = virtualScrollX.value;
91
- clientWidth = cw;
92
- scrollLeft = sl;
93
- } else {
94
- const { clientWidth: cw, scrollLeft: sl } = tableContainerRef.value as HTMLDivElement;
95
- clientWidth = cw;
96
- scrollLeft = sl;
97
- }
98
-
99
- /*******
100
- * 根据横向滚动位置,计算出哪个列需要展示阴影
101
- *****/
102
- /** 左侧需要展示阴影的列 */
103
- const leftShadowCol: StkTableColumn<DT>[] = [];
104
- /** 右侧展示阴影的列 */
105
- const rightShadowCol: StkTableColumn<DT>[] = [];
106
- tableHeadersForCalc.value.forEach((row, level) => {
107
- /**
108
- * 左侧第n个fixed:left 计算要加上前面所有left 的列宽。
109
- */
110
- let left = 0;
111
- row.forEach(col => {
112
- const position = getFixedColPositionValue(col);
113
- const isFixedLeft = col.fixed === 'left';
114
- const isFixedRight = col.fixed === 'right';
115
-
116
- if (isFixedLeft && position + scrollLeft > left) {
117
- fixedColsTemp.push(col);
118
- leftShadowCol[level] = col;
119
- }
120
-
121
- left += getCalculatedColWidth(col);
122
-
123
- if (isFixedRight && scrollLeft + clientWidth - left < position) {
124
- fixedColsTemp.push(col);
125
- // 右固定列阴影,只要第一列
126
- if (!rightShadowCol[level]) {
127
- rightShadowCol[level] = col;
128
- }
129
- }
130
- });
131
- });
132
-
133
- if (props.fixedColShadow) {
134
- fixedShadowCols.value = leftShadowCol.concat(rightShadowCol).filter(Boolean) as StkTableColumn<DT>[];
135
- }
136
-
137
- fixedCols.value = fixedColsTemp;
138
- }
139
-
140
- return {
141
- /** 正在被固定的列 */
142
- fixedCols,
143
- /** 固定列class */
144
- fixedColClassMap,
145
- /** 滚动条变化时,更新需要展示阴影的列 */
146
- updateFixedShadow,
147
- };
148
- }
1
+ import { computed, ComputedRef, Ref, ShallowRef, shallowRef } from 'vue';
2
+ import { StkTableColumn, UniqKey } from './types';
3
+ import { VirtualScrollXStore } from './useVirtualScroll';
4
+ import { getCalculatedColWidth } from './utils/constRefUtils';
5
+
6
+ type Params<T extends Record<string, any>> = {
7
+ props: any;
8
+ colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
9
+ getFixedColPosition: ComputedRef<(col: StkTableColumn<T>) => number>;
10
+ tableHeaders: ShallowRef<StkTableColumn<T>[][]>;
11
+ tableHeadersForCalc: ShallowRef<StkTableColumn<T>[][]>;
12
+ tableContainerRef: Ref<HTMLDivElement | undefined>;
13
+ };
14
+
15
+ /**
16
+ * 固定列处理
17
+ * @returns
18
+ */
19
+ export function useFixedCol<DT extends Record<string, any>>({
20
+ props,
21
+ colKeyGen,
22
+ getFixedColPosition,
23
+ tableHeaders,
24
+ tableHeadersForCalc,
25
+ tableContainerRef,
26
+ }: Params<DT>) {
27
+ /** 保存需要出现阴影的列 */
28
+ const fixedShadowCols = shallowRef<StkTableColumn<DT>[]>([]);
29
+
30
+ /** 正在被固定的列 */
31
+ const fixedCols = shallowRef<StkTableColumn<DT>[]>([]);
32
+
33
+ /** 固定列的class */
34
+ const fixedColClassMap = computed(() => {
35
+ const colMap = new Map();
36
+ const fixedShadowColsValue = fixedShadowCols.value;
37
+ const fixedColsValue = fixedCols.value;
38
+ const colKey = colKeyGen.value;
39
+ const fixedColShadow = props.fixedColShadow;
40
+ tableHeaders.value.forEach(cols => {
41
+ cols.forEach(col => {
42
+ const fixed = col.fixed;
43
+ const showShadow = fixedColShadow && fixed && fixedShadowColsValue.includes(col);
44
+ const classObj: Record<string, any> = {
45
+ 'fixed-cell--active': fixedColsValue.includes(col), // 表示该列正在被固定
46
+ };
47
+ if (fixed) {
48
+ classObj['fixed-cell'] = true;
49
+ classObj['fixed-cell--' + fixed] = true;
50
+ }
51
+ if (showShadow) {
52
+ classObj['fixed-cell--shadow'] = true;
53
+ }
54
+ colMap.set(colKey(col), classObj);
55
+ });
56
+ });
57
+ return colMap;
58
+ });
59
+
60
+ /**
61
+ * 返回所有父元素,包括自己
62
+ * @param col
63
+ * @param type 1-shadow(阴影) 2-active(被固定的列)
64
+ *
65
+ */
66
+ // function getColAndParentCols(col: StkTableColumn<DT> | null, type: 1 | 2 = 1) {
67
+ // if (!col) return [];
68
+ // const colsTemp: StkTableColumn<DT>[] = [];
69
+ // let node: any = { __PARENT__: col };
70
+ // while ((node = node.__PARENT__)) {
71
+ // if (type === 1 && node.fixed) {
72
+ // // shadow
73
+ // colsTemp.push(node);
74
+ // }
75
+ // if (type === 2) {
76
+ // // active
77
+ // colsTemp.push(node);
78
+ // }
79
+ // }
80
+ // return colsTemp;
81
+ // }
82
+
83
+ /** 滚动条变化时,更新需要展示阴影的列 */
84
+ function updateFixedShadow(virtualScrollX?: Ref<VirtualScrollXStore>) {
85
+ const fixedColsTemp: StkTableColumn<DT>[] = [];
86
+ const getFixedColPositionValue = getFixedColPosition.value;
87
+ let clientWidth, scrollLeft;
88
+
89
+ if (virtualScrollX?.value) {
90
+ const { containerWidth: cw, scrollLeft: sl } = virtualScrollX.value;
91
+ clientWidth = cw;
92
+ scrollLeft = sl;
93
+ } else {
94
+ const { clientWidth: cw, scrollLeft: sl } = tableContainerRef.value as HTMLDivElement;
95
+ clientWidth = cw;
96
+ scrollLeft = sl;
97
+ }
98
+
99
+ /*******
100
+ * 根据横向滚动位置,计算出哪个列需要展示阴影
101
+ *****/
102
+ /** 左侧需要展示阴影的列 */
103
+ const leftShadowCol: StkTableColumn<DT>[] = [];
104
+ /** 右侧展示阴影的列 */
105
+ const rightShadowCol: StkTableColumn<DT>[] = [];
106
+ tableHeadersForCalc.value.forEach((row, level) => {
107
+ /**
108
+ * 左侧第n个fixed:left 计算要加上前面所有left 的列宽。
109
+ */
110
+ let left = 0;
111
+ row.forEach(col => {
112
+ const position = getFixedColPositionValue(col);
113
+ const isFixedLeft = col.fixed === 'left';
114
+ const isFixedRight = col.fixed === 'right';
115
+
116
+ if (isFixedLeft && position + scrollLeft > left) {
117
+ fixedColsTemp.push(col);
118
+ leftShadowCol[level] = col;
119
+ }
120
+
121
+ left += getCalculatedColWidth(col);
122
+
123
+ if (isFixedRight && scrollLeft + clientWidth - left < position) {
124
+ fixedColsTemp.push(col);
125
+ // 右固定列阴影,只要第一列
126
+ if (!rightShadowCol[level]) {
127
+ rightShadowCol[level] = col;
128
+ }
129
+ }
130
+ });
131
+ });
132
+
133
+ if (props.fixedColShadow) {
134
+ fixedShadowCols.value = leftShadowCol.concat(rightShadowCol).filter(Boolean) as StkTableColumn<DT>[];
135
+ }
136
+
137
+ fixedCols.value = fixedColsTemp;
138
+ }
139
+
140
+ return {
141
+ /** 正在被固定的列 */
142
+ fixedCols,
143
+ /** 固定列class */
144
+ fixedColClassMap,
145
+ /** 滚动条变化时,更新需要展示阴影的列 */
146
+ updateFixedShadow,
147
+ };
148
+ }
@@ -1,75 +1,75 @@
1
- import { CSSProperties, ComputedRef, Ref } from 'vue';
2
- import { StkTableColumn, TagType } from './types';
3
- import { VirtualScrollStore, VirtualScrollXStore } from './useVirtualScroll';
4
-
5
- type Options<T extends Record<string, any>> = {
6
- props: any;
7
- isRelativeMode: Ref<boolean>;
8
- getFixedColPosition: ComputedRef<(col: StkTableColumn<T>) => number>;
9
- virtualScroll: Ref<VirtualScrollStore>;
10
- virtualScrollX: Ref<VirtualScrollXStore>;
11
- virtualX_on: Ref<boolean>;
12
- virtualX_offsetRight: Ref<number>;
13
- };
14
- /**
15
- * 固定列style
16
- * @param param0
17
- * @returns
18
- */
19
- export function useFixedStyle<DT extends Record<string, any>>({
20
- props,
21
- isRelativeMode,
22
- getFixedColPosition,
23
- virtualScroll,
24
- virtualScrollX,
25
- virtualX_on,
26
- virtualX_offsetRight,
27
- }: Options<DT>) {
28
- /**
29
- * 固定列的style
30
- * @param tagType 1-th 2-td
31
- * @param col
32
- * @param depth 深度。tagType = 1时使用
33
- */
34
- function getFixedStyle(tagType: TagType, col: StkTableColumn<DT>, depth = 0): CSSProperties | null {
35
- const { fixed } = col;
36
- if (tagType === TagType.TD && !fixed) return null;
37
-
38
- const style: CSSProperties = {};
39
- const { headerRowHeight, rowHeight } = props;
40
- const isFixedLeft = fixed === 'left';
41
- const { scrollLeft, scrollWidth, offsetLeft, containerWidth } = virtualScrollX.value;
42
- const scrollRight = scrollWidth - containerWidth - scrollLeft;
43
-
44
- if (tagType === TagType.TH) {
45
- // TH
46
- if (isRelativeMode.value) {
47
- style.top = virtualScroll.value.scrollTop + 'px';
48
- } else {
49
- style.top = depth * (headerRowHeight ?? rowHeight) + 'px';
50
- }
51
- }
52
-
53
- if (fixed === 'left' || fixed === 'right') {
54
- if (isRelativeMode.value) {
55
- if (isFixedLeft) {
56
- style.left = scrollLeft - (virtualX_on.value ? offsetLeft : 0) + 'px';
57
- } else {
58
- // fixed right
59
- style.right = Math.max(scrollRight - (virtualX_on.value ? virtualX_offsetRight.value : 0), 0) + 'px';
60
- }
61
- } else {
62
- const lr = getFixedColPosition.value(col) + 'px';
63
- if (isFixedLeft) {
64
- style.left = lr;
65
- } else {
66
- style.right = lr;
67
- }
68
- }
69
- }
70
-
71
- return style;
72
- }
73
-
74
- return getFixedStyle;
75
- }
1
+ import { CSSProperties, ComputedRef, Ref } from 'vue';
2
+ import { StkTableColumn, TagType } from './types';
3
+ import { VirtualScrollStore, VirtualScrollXStore } from './useVirtualScroll';
4
+
5
+ type Options<T extends Record<string, any>> = {
6
+ props: any;
7
+ isRelativeMode: Ref<boolean>;
8
+ getFixedColPosition: ComputedRef<(col: StkTableColumn<T>) => number>;
9
+ virtualScroll: Ref<VirtualScrollStore>;
10
+ virtualScrollX: Ref<VirtualScrollXStore>;
11
+ virtualX_on: Ref<boolean>;
12
+ virtualX_offsetRight: Ref<number>;
13
+ };
14
+ /**
15
+ * 固定列style
16
+ * @param param0
17
+ * @returns
18
+ */
19
+ export function useFixedStyle<DT extends Record<string, any>>({
20
+ props,
21
+ isRelativeMode,
22
+ getFixedColPosition,
23
+ virtualScroll,
24
+ virtualScrollX,
25
+ virtualX_on,
26
+ virtualX_offsetRight,
27
+ }: Options<DT>) {
28
+ /**
29
+ * 固定列的style
30
+ * @param tagType 1-th 2-td
31
+ * @param col
32
+ * @param depth 深度。tagType = 1时使用
33
+ */
34
+ function getFixedStyle(tagType: TagType, col: StkTableColumn<DT>, depth = 0): CSSProperties | null {
35
+ const { fixed } = col;
36
+ if (tagType === TagType.TD && !fixed) return null;
37
+
38
+ const style: CSSProperties = {};
39
+ const { headerRowHeight, rowHeight } = props;
40
+ const isFixedLeft = fixed === 'left';
41
+ const { scrollLeft, scrollWidth, offsetLeft, containerWidth } = virtualScrollX.value;
42
+ const scrollRight = scrollWidth - containerWidth - scrollLeft;
43
+
44
+ if (tagType === TagType.TH) {
45
+ // TH
46
+ if (isRelativeMode.value) {
47
+ style.top = virtualScroll.value.scrollTop + 'px';
48
+ } else {
49
+ style.top = depth * (headerRowHeight ?? rowHeight) + 'px';
50
+ }
51
+ }
52
+
53
+ if (fixed === 'left' || fixed === 'right') {
54
+ if (isRelativeMode.value) {
55
+ if (isFixedLeft) {
56
+ style.left = scrollLeft - (virtualX_on.value ? offsetLeft : 0) + 'px';
57
+ } else {
58
+ // fixed right
59
+ style.right = Math.max(scrollRight - (virtualX_on.value ? virtualX_offsetRight.value : 0), 0) + 'px';
60
+ }
61
+ } else {
62
+ const lr = getFixedColPosition.value(col) + 'px';
63
+ if (isFixedLeft) {
64
+ style.left = lr;
65
+ } else {
66
+ style.right = lr;
67
+ }
68
+ }
69
+ }
70
+
71
+ return style;
72
+ }
73
+
74
+ return getFixedStyle;
75
+ }
@@ -1,65 +1,65 @@
1
- import { ComputedRef, ShallowRef, computed } from 'vue';
2
- import { StkTableColumn, UniqKey } from './types';
3
- import { getCalculatedColWidth } from './utils/constRefUtils';
4
-
5
- type Params<T extends Record<string, any>> = {
6
- colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
7
- tableHeadersForCalc: ShallowRef<StkTableColumn<T>[][]>;
8
- };
9
-
10
- /**
11
- * 固定列fixed左侧或者右侧的距离
12
- * - col.fixed = left 则得到距离左侧的距离
13
- * - col.fixed = right 则得到距离右侧的距离
14
- */
15
- export function useGetFixedColPosition<DT extends Record<string, any>>({ tableHeadersForCalc, colKeyGen }: Params<DT>) {
16
- /** 固定列fixed左侧或者右侧的距离 */
17
- const getFixedColPosition = computed(() => {
18
- /** colKey 作为唯一标识 */
19
- const colKeyStore: Record<string, number> = {};
20
- /** 没有 colKey 的多级表头列,使用对象引用做标识 */
21
- const refStore = new WeakMap<StkTableColumn<DT>, number>();
22
- const colKeyGenValue = colKeyGen.value;
23
- tableHeadersForCalc.value.forEach(cols => {
24
- let left = 0;
25
- /**遍历右侧fixed时,因为left已经遍历过一次了。所以,可以拿到right遍历边界 */
26
- let rightStartIndex = 0;
27
- for (let i = 0; i < cols.length; i++) {
28
- const item = cols[i];
29
- if (item.fixed === 'left') {
30
- const colKey = colKeyGenValue(item);
31
- if (colKey) {
32
- colKeyStore[colKey] = left;
33
- } else {
34
- refStore.set(item, left);
35
- }
36
- left += getCalculatedColWidth(item);
37
- }
38
- if (!rightStartIndex && item.fixed === 'right') {
39
- rightStartIndex = i;
40
- }
41
- }
42
-
43
- let right = 0;
44
- for (let i = cols.length - 1; i >= rightStartIndex; i--) {
45
- const item = cols[i];
46
- const colKey = colKeyGenValue(item);
47
- if (item.fixed === 'right') {
48
- if (colKey) {
49
- colKeyStore[colKey] = right;
50
- } else {
51
- refStore.set(item, right);
52
- }
53
- right += getCalculatedColWidth(item);
54
- }
55
- }
56
- });
57
-
58
- return (col: StkTableColumn<any>) => {
59
- const colKey = colKeyGenValue(col);
60
- return colKey ? colKeyStore[colKey] : refStore.get(col) || 0;
61
- };
62
- });
63
-
64
- return getFixedColPosition;
65
- }
1
+ import { ComputedRef, ShallowRef, computed } from 'vue';
2
+ import { StkTableColumn, UniqKey } from './types';
3
+ import { getCalculatedColWidth } from './utils/constRefUtils';
4
+
5
+ type Params<T extends Record<string, any>> = {
6
+ colKeyGen: ComputedRef<(col: StkTableColumn<T>) => UniqKey>;
7
+ tableHeadersForCalc: ShallowRef<StkTableColumn<T>[][]>;
8
+ };
9
+
10
+ /**
11
+ * 固定列fixed左侧或者右侧的距离
12
+ * - col.fixed = left 则得到距离左侧的距离
13
+ * - col.fixed = right 则得到距离右侧的距离
14
+ */
15
+ export function useGetFixedColPosition<DT extends Record<string, any>>({ tableHeadersForCalc, colKeyGen }: Params<DT>) {
16
+ /** 固定列fixed左侧或者右侧的距离 */
17
+ const getFixedColPosition = computed(() => {
18
+ /** colKey 作为唯一标识 */
19
+ const colKeyStore: Record<string, number> = {};
20
+ /** 没有 colKey 的多级表头列,使用对象引用做标识 */
21
+ const refStore = new WeakMap<StkTableColumn<DT>, number>();
22
+ const colKeyGenValue = colKeyGen.value;
23
+ tableHeadersForCalc.value.forEach(cols => {
24
+ let left = 0;
25
+ /**遍历右侧fixed时,因为left已经遍历过一次了。所以,可以拿到right遍历边界 */
26
+ let rightStartIndex = 0;
27
+ for (let i = 0; i < cols.length; i++) {
28
+ const item = cols[i];
29
+ if (item.fixed === 'left') {
30
+ const colKey = colKeyGenValue(item);
31
+ if (colKey) {
32
+ colKeyStore[colKey] = left;
33
+ } else {
34
+ refStore.set(item, left);
35
+ }
36
+ left += getCalculatedColWidth(item);
37
+ }
38
+ if (!rightStartIndex && item.fixed === 'right') {
39
+ rightStartIndex = i;
40
+ }
41
+ }
42
+
43
+ let right = 0;
44
+ for (let i = cols.length - 1; i >= rightStartIndex; i--) {
45
+ const item = cols[i];
46
+ const colKey = colKeyGenValue(item);
47
+ if (item.fixed === 'right') {
48
+ if (colKey) {
49
+ colKeyStore[colKey] = right;
50
+ } else {
51
+ refStore.set(item, right);
52
+ }
53
+ right += getCalculatedColWidth(item);
54
+ }
55
+ }
56
+ });
57
+
58
+ return (col: StkTableColumn<any>) => {
59
+ const colKey = colKeyGenValue(col);
60
+ return colKey ? colKeyStore[colKey] : refStore.get(col) || 0;
61
+ };
62
+ });
63
+
64
+ return getFixedColPosition;
65
+ }