@kdcloudjs/kdesign 1.6.33 → 1.6.34
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/CHANGELOG.md +14 -0
- package/dist/kdesign-complete.less +3 -9
- package/dist/kdesign.css +4 -5
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +193 -23
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +5 -5
- package/dist/kdesign.min.js.map +1 -1
- package/es/rate/style/index.css +3 -3
- package/es/rate/style/index.less +3 -9
- package/es/style/icon/kdicon.css +0 -1
- package/es/table/api.d.ts +4 -0
- package/es/table/api.js +162 -0
- package/es/table/interface.d.ts +3 -0
- package/es/table/table.js +2 -8
- package/lib/rate/style/index.css +3 -3
- package/lib/rate/style/index.less +3 -9
- package/lib/style/icon/kdicon.css +0 -1
- package/lib/table/api.d.ts +4 -0
- package/lib/table/api.js +171 -0
- package/lib/table/interface.d.ts +3 -0
- package/lib/table/table.js +3 -8
- package/package.json +1 -1
package/es/rate/style/index.css
CHANGED
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
-ms-flex-pack: start;
|
|
121
121
|
justify-content: flex-start;
|
|
122
122
|
}
|
|
123
|
-
.kd-rate-size-large
|
|
123
|
+
.kd-rate-size-large {
|
|
124
124
|
font-size: var(--kd-c-rate-font-size-large, 20px);
|
|
125
125
|
}
|
|
126
|
-
.kd-rate-size-middle
|
|
126
|
+
.kd-rate-size-middle {
|
|
127
127
|
font-size: var(--kd-c-rate-font-size-middle, 16px);
|
|
128
128
|
}
|
|
129
|
-
.kd-rate-size-small
|
|
129
|
+
.kd-rate-size-small {
|
|
130
130
|
font-size: var(--kd-c-rate-font-size-small, 12px);
|
|
131
131
|
}
|
|
132
132
|
.kd-rate-item {
|
package/es/rate/style/index.less
CHANGED
|
@@ -9,19 +9,13 @@
|
|
|
9
9
|
display: inline-flex;
|
|
10
10
|
justify-content: flex-start;
|
|
11
11
|
&-size-large {
|
|
12
|
-
|
|
13
|
-
font-size: @rate-large-font-size;
|
|
14
|
-
}
|
|
12
|
+
font-size: @rate-large-font-size;
|
|
15
13
|
}
|
|
16
14
|
&-size-middle {
|
|
17
|
-
|
|
18
|
-
font-size: @rate-middle-font-size;
|
|
19
|
-
}
|
|
15
|
+
font-size: @rate-middle-font-size;
|
|
20
16
|
}
|
|
21
17
|
&-size-small {
|
|
22
|
-
|
|
23
|
-
font-size: @rate-small-font-size;
|
|
24
|
-
}
|
|
18
|
+
font-size: @rate-small-font-size;
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
.@{rate-prefix-cls}-item {
|
package/es/style/icon/kdicon.css
CHANGED
package/es/table/api.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
2
|
+
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
3
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
4
|
+
import { collectNodes } from '@kdcloudjs/table/es/table/utils';
|
|
5
|
+
import { rangeSelectionKey } from '@kdcloudjs/table/es/table/pipeline/features/rangeSelection';
|
|
6
|
+
export default function getApi(pipelineRef) {
|
|
7
|
+
function getColumns() {
|
|
8
|
+
var _a;
|
|
9
|
+
|
|
10
|
+
return (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getDataSource() {
|
|
14
|
+
var _a;
|
|
15
|
+
|
|
16
|
+
return (_a = pipelineRef.current.getDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getFooterDataSource() {
|
|
20
|
+
var _a;
|
|
21
|
+
|
|
22
|
+
return (_a = pipelineRef.current.getFooterDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 清除范围选中内容
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function clearRangeSelection() {
|
|
30
|
+
var pipeline = pipelineRef.current;
|
|
31
|
+
pipeline.setStateAtKey(rangeSelectionKey, null);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 将目标行滚动到可视位置
|
|
35
|
+
* @param rowIndex 行索引
|
|
36
|
+
* @param position 目标行滚动到的位置,不传则根据目标行相对视口的位置滚动到底部或顶部,可取值为'top' | 'middle' | 'bottom'
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
function ensureRowIndexVisible(rowIndex, position) {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
|
|
44
|
+
var pipeline = pipelineRef.current;
|
|
45
|
+
|
|
46
|
+
var _ref = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager,
|
|
47
|
+
cache = _ref.cache;
|
|
48
|
+
|
|
49
|
+
if (typeof rowIndex !== 'number' || rowIndex < 0 || rowIndex >= cache.length) {
|
|
50
|
+
console.warn('invalid row index for ensureIndexVisible: ' + rowIndex);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var tableBodyContainer = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.tableBody;
|
|
55
|
+
if (!tableBodyContainer) return;
|
|
56
|
+
var rowTopPixel = 0;
|
|
57
|
+
|
|
58
|
+
for (var i = 0; i < rowIndex; i++) {
|
|
59
|
+
rowTopPixel += cache[i];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var rowBottomPixel = rowTopPixel + cache[rowIndex];
|
|
63
|
+
var viewportHeight = tableBodyContainer.clientHeight;
|
|
64
|
+
var vScrollTop = tableBodyContainer.scrollTop;
|
|
65
|
+
var vScrollBottom = vScrollTop + viewportHeight;
|
|
66
|
+
var pxTop = rowTopPixel;
|
|
67
|
+
var pxBottom = rowBottomPixel - viewportHeight;
|
|
68
|
+
var pxMiddle = Math.min((pxTop + pxBottom) / 2, rowTopPixel);
|
|
69
|
+
var rowBelowViewport = vScrollTop > rowTopPixel;
|
|
70
|
+
var rowAboveViewport = vScrollBottom < rowBottomPixel;
|
|
71
|
+
var newScrollPosition = null;
|
|
72
|
+
|
|
73
|
+
if (position === 'top') {
|
|
74
|
+
newScrollPosition = pxTop;
|
|
75
|
+
} else if (position === 'bottom') {
|
|
76
|
+
newScrollPosition = pxBottom;
|
|
77
|
+
} else if (position === 'middle') {
|
|
78
|
+
newScrollPosition = pxMiddle;
|
|
79
|
+
} else if (rowBelowViewport) {
|
|
80
|
+
// 目标行在视口之上,则向上滚动到顶部
|
|
81
|
+
newScrollPosition = pxTop;
|
|
82
|
+
} else if (rowAboveViewport) {
|
|
83
|
+
// 目标行在视口之下,则向下滚动到底部
|
|
84
|
+
newScrollPosition = pxBottom;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (newScrollPosition !== null) {
|
|
88
|
+
tableBodyContainer.scrollTop = newScrollPosition;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 将目标列滚动到可视位置
|
|
93
|
+
* @param code 列标识
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
function ensureColumnVisible(code) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
|
|
101
|
+
var pipeline = pipelineRef.current;
|
|
102
|
+
var tableBodyContainer = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.domHelper.tableBody;
|
|
103
|
+
var tableScroll = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.stickyScroll;
|
|
104
|
+
var columnNodes = collectNodes(pipeline.getColumns(), 'leaf-only');
|
|
105
|
+
|
|
106
|
+
var column = _findInstanceProperty(columnNodes).call(columnNodes, function (col) {
|
|
107
|
+
return col.code === code;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
var index = _findIndexInstanceProperty(columnNodes).call(columnNodes, function (col) {
|
|
111
|
+
return col.code === code;
|
|
112
|
+
}); // 固定列也不需要重置滚动条
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if (!column || !tableBodyContainer || (column === null || column === void 0 ? void 0 : column.lock)) return;
|
|
116
|
+
|
|
117
|
+
var colLeft = _sliceInstanceProperty(columnNodes).call(columnNodes, 0, index).reduce(function (acc, col) {
|
|
118
|
+
return acc + col.width;
|
|
119
|
+
}, 0);
|
|
120
|
+
|
|
121
|
+
var colLeftPixel = colLeft; // 目标列前面列宽总和
|
|
122
|
+
|
|
123
|
+
var colRightPixel = colLeftPixel + column.width;
|
|
124
|
+
var viewportWidth = tableBodyContainer.clientWidth; // 表体容器的宽度
|
|
125
|
+
|
|
126
|
+
var scrollPosition = tableScroll.scrollLeft; // 滚动条滚动的距离
|
|
127
|
+
|
|
128
|
+
var vScrollLeft = scrollPosition;
|
|
129
|
+
var vScrollRight = scrollPosition + viewportWidth;
|
|
130
|
+
var pxLeft = colLeftPixel;
|
|
131
|
+
var pxRight = colRightPixel - viewportWidth;
|
|
132
|
+
var colBeforeViewport = vScrollLeft > colLeftPixel; // 滚动距离大于目标列前面列宽总和,说明目标列在视口之前
|
|
133
|
+
|
|
134
|
+
var colPastViewport = vScrollRight < colRightPixel; // 目标列是视口之后
|
|
135
|
+
|
|
136
|
+
var colToSmallForViewport = viewportWidth < column.width;
|
|
137
|
+
var alignColToLeft = colBeforeViewport || colToSmallForViewport;
|
|
138
|
+
var alignColToRight = colPastViewport;
|
|
139
|
+
|
|
140
|
+
if (alignColToLeft || alignColToRight) {
|
|
141
|
+
var newScrollPosition = alignColToLeft ? pxLeft : pxRight;
|
|
142
|
+
tableScroll.scrollLeft = newScrollPosition;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getHeightCache() {
|
|
147
|
+
var _a;
|
|
148
|
+
|
|
149
|
+
var pipeline = pipelineRef.current;
|
|
150
|
+
return (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager.cache;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
getColumns: getColumns,
|
|
155
|
+
getDataSource: getDataSource,
|
|
156
|
+
getFooterDataSource: getFooterDataSource,
|
|
157
|
+
clearRangeSelection: clearRangeSelection,
|
|
158
|
+
ensureRowIndexVisible: ensureRowIndexVisible,
|
|
159
|
+
ensureColumnVisible: ensureColumnVisible,
|
|
160
|
+
getHeightCache: getHeightCache
|
|
161
|
+
};
|
|
162
|
+
}
|
package/es/table/interface.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare type TableApi = {
|
|
|
15
15
|
getDataSource: () => any[];
|
|
16
16
|
getFooterDataSource: () => any[];
|
|
17
17
|
clearRangeSelection: () => void;
|
|
18
|
+
getHeightCache: () => number[];
|
|
19
|
+
ensureRowIndexVisible: (rowIndex: number, position?: string | undefined) => void;
|
|
20
|
+
ensureColumnVisible: (code: string) => void;
|
|
18
21
|
};
|
|
19
22
|
export declare type TableInstance = {
|
|
20
23
|
api: TableApi;
|
package/es/table/table.js
CHANGED
|
@@ -22,6 +22,7 @@ import useMergeCellHover from './feature/mergeCellHover';
|
|
|
22
22
|
import devWarning from '../_utils/devwarning';
|
|
23
23
|
import useFooterDataSource from './feature/useFooterDataSource';
|
|
24
24
|
import usecolGroupExtendable from './feature/colGroupExtendable';
|
|
25
|
+
import getApi from './api';
|
|
25
26
|
var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
27
|
var columns = props.columns,
|
|
27
28
|
dataSource = props.dataSource,
|
|
@@ -80,15 +81,8 @@ var Table = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
80
81
|
// }
|
|
81
82
|
|
|
82
83
|
useImperativeHandle(ref, function () {
|
|
83
|
-
var _a, _b, _c, _d;
|
|
84
|
-
|
|
85
84
|
return {
|
|
86
|
-
api:
|
|
87
|
-
getColumns: (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current),
|
|
88
|
-
getDataSource: (_b = pipelineRef.current.getDataSource) === null || _b === void 0 ? void 0 : _b.bind(pipelineRef.current),
|
|
89
|
-
getFooterDataSource: (_c = pipelineRef.current.getFooterDataSource) === null || _c === void 0 ? void 0 : _c.bind(pipelineRef.current),
|
|
90
|
-
clearRangeSelection: (_d = pipelineRef.current.clearRangeSelection) === null || _d === void 0 ? void 0 : _d.bind(pipelineRef.current)
|
|
91
|
-
}
|
|
85
|
+
api: getApi(pipelineRef)
|
|
92
86
|
};
|
|
93
87
|
});
|
|
94
88
|
/* -------------------------------------------------------------------------- */
|
package/lib/rate/style/index.css
CHANGED
|
@@ -120,13 +120,13 @@
|
|
|
120
120
|
-ms-flex-pack: start;
|
|
121
121
|
justify-content: flex-start;
|
|
122
122
|
}
|
|
123
|
-
.kd-rate-size-large
|
|
123
|
+
.kd-rate-size-large {
|
|
124
124
|
font-size: var(--kd-c-rate-font-size-large, 20px);
|
|
125
125
|
}
|
|
126
|
-
.kd-rate-size-middle
|
|
126
|
+
.kd-rate-size-middle {
|
|
127
127
|
font-size: var(--kd-c-rate-font-size-middle, 16px);
|
|
128
128
|
}
|
|
129
|
-
.kd-rate-size-small
|
|
129
|
+
.kd-rate-size-small {
|
|
130
130
|
font-size: var(--kd-c-rate-font-size-small, 12px);
|
|
131
131
|
}
|
|
132
132
|
.kd-rate-item {
|
|
@@ -9,19 +9,13 @@
|
|
|
9
9
|
display: inline-flex;
|
|
10
10
|
justify-content: flex-start;
|
|
11
11
|
&-size-large {
|
|
12
|
-
|
|
13
|
-
font-size: @rate-large-font-size;
|
|
14
|
-
}
|
|
12
|
+
font-size: @rate-large-font-size;
|
|
15
13
|
}
|
|
16
14
|
&-size-middle {
|
|
17
|
-
|
|
18
|
-
font-size: @rate-middle-font-size;
|
|
19
|
-
}
|
|
15
|
+
font-size: @rate-middle-font-size;
|
|
20
16
|
}
|
|
21
17
|
&-size-small {
|
|
22
|
-
|
|
23
|
-
font-size: @rate-small-font-size;
|
|
24
|
-
}
|
|
18
|
+
font-size: @rate-small-font-size;
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
.@{rate-prefix-cls}-item {
|
package/lib/table/api.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = getApi;
|
|
9
|
+
|
|
10
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
11
|
+
|
|
12
|
+
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
13
|
+
|
|
14
|
+
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
15
|
+
|
|
16
|
+
var _utils = require("@kdcloudjs/table/es/table/utils");
|
|
17
|
+
|
|
18
|
+
var _rangeSelection = require("@kdcloudjs/table/es/table/pipeline/features/rangeSelection");
|
|
19
|
+
|
|
20
|
+
function getApi(pipelineRef) {
|
|
21
|
+
function getColumns() {
|
|
22
|
+
var _a;
|
|
23
|
+
|
|
24
|
+
return (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getDataSource() {
|
|
28
|
+
var _a;
|
|
29
|
+
|
|
30
|
+
return (_a = pipelineRef.current.getDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getFooterDataSource() {
|
|
34
|
+
var _a;
|
|
35
|
+
|
|
36
|
+
return (_a = pipelineRef.current.getFooterDataSource) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current)();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 清除范围选中内容
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function clearRangeSelection() {
|
|
44
|
+
var pipeline = pipelineRef.current;
|
|
45
|
+
pipeline.setStateAtKey(_rangeSelection.rangeSelectionKey, null);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 将目标行滚动到可视位置
|
|
49
|
+
* @param rowIndex 行索引
|
|
50
|
+
* @param position 目标行滚动到的位置,不传则根据目标行相对视口的位置滚动到底部或顶部,可取值为'top' | 'middle' | 'bottom'
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
function ensureRowIndexVisible(rowIndex, position) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
|
|
58
|
+
var pipeline = pipelineRef.current;
|
|
59
|
+
|
|
60
|
+
var _ref = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager,
|
|
61
|
+
cache = _ref.cache;
|
|
62
|
+
|
|
63
|
+
if (typeof rowIndex !== 'number' || rowIndex < 0 || rowIndex >= cache.length) {
|
|
64
|
+
console.warn('invalid row index for ensureIndexVisible: ' + rowIndex);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var tableBodyContainer = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.tableBody;
|
|
69
|
+
if (!tableBodyContainer) return;
|
|
70
|
+
var rowTopPixel = 0;
|
|
71
|
+
|
|
72
|
+
for (var i = 0; i < rowIndex; i++) {
|
|
73
|
+
rowTopPixel += cache[i];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var rowBottomPixel = rowTopPixel + cache[rowIndex];
|
|
77
|
+
var viewportHeight = tableBodyContainer.clientHeight;
|
|
78
|
+
var vScrollTop = tableBodyContainer.scrollTop;
|
|
79
|
+
var vScrollBottom = vScrollTop + viewportHeight;
|
|
80
|
+
var pxTop = rowTopPixel;
|
|
81
|
+
var pxBottom = rowBottomPixel - viewportHeight;
|
|
82
|
+
var pxMiddle = Math.min((pxTop + pxBottom) / 2, rowTopPixel);
|
|
83
|
+
var rowBelowViewport = vScrollTop > rowTopPixel;
|
|
84
|
+
var rowAboveViewport = vScrollBottom < rowBottomPixel;
|
|
85
|
+
var newScrollPosition = null;
|
|
86
|
+
|
|
87
|
+
if (position === 'top') {
|
|
88
|
+
newScrollPosition = pxTop;
|
|
89
|
+
} else if (position === 'bottom') {
|
|
90
|
+
newScrollPosition = pxBottom;
|
|
91
|
+
} else if (position === 'middle') {
|
|
92
|
+
newScrollPosition = pxMiddle;
|
|
93
|
+
} else if (rowBelowViewport) {
|
|
94
|
+
// 目标行在视口之上,则向上滚动到顶部
|
|
95
|
+
newScrollPosition = pxTop;
|
|
96
|
+
} else if (rowAboveViewport) {
|
|
97
|
+
// 目标行在视口之下,则向下滚动到底部
|
|
98
|
+
newScrollPosition = pxBottom;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (newScrollPosition !== null) {
|
|
102
|
+
tableBodyContainer.scrollTop = newScrollPosition;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 将目标列滚动到可视位置
|
|
107
|
+
* @param code 列标识
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function ensureColumnVisible(code) {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
|
|
115
|
+
var pipeline = pipelineRef.current;
|
|
116
|
+
var tableBodyContainer = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.domHelper.tableBody;
|
|
117
|
+
var tableScroll = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.stickyScroll;
|
|
118
|
+
var columnNodes = (0, _utils.collectNodes)(pipeline.getColumns(), 'leaf-only');
|
|
119
|
+
var column = (0, _find.default)(columnNodes).call(columnNodes, function (col) {
|
|
120
|
+
return col.code === code;
|
|
121
|
+
});
|
|
122
|
+
var index = (0, _findIndex.default)(columnNodes).call(columnNodes, function (col) {
|
|
123
|
+
return col.code === code;
|
|
124
|
+
}); // 固定列也不需要重置滚动条
|
|
125
|
+
|
|
126
|
+
if (!column || !tableBodyContainer || (column === null || column === void 0 ? void 0 : column.lock)) return;
|
|
127
|
+
var colLeft = (0, _slice.default)(columnNodes).call(columnNodes, 0, index).reduce(function (acc, col) {
|
|
128
|
+
return acc + col.width;
|
|
129
|
+
}, 0);
|
|
130
|
+
var colLeftPixel = colLeft; // 目标列前面列宽总和
|
|
131
|
+
|
|
132
|
+
var colRightPixel = colLeftPixel + column.width;
|
|
133
|
+
var viewportWidth = tableBodyContainer.clientWidth; // 表体容器的宽度
|
|
134
|
+
|
|
135
|
+
var scrollPosition = tableScroll.scrollLeft; // 滚动条滚动的距离
|
|
136
|
+
|
|
137
|
+
var vScrollLeft = scrollPosition;
|
|
138
|
+
var vScrollRight = scrollPosition + viewportWidth;
|
|
139
|
+
var pxLeft = colLeftPixel;
|
|
140
|
+
var pxRight = colRightPixel - viewportWidth;
|
|
141
|
+
var colBeforeViewport = vScrollLeft > colLeftPixel; // 滚动距离大于目标列前面列宽总和,说明目标列在视口之前
|
|
142
|
+
|
|
143
|
+
var colPastViewport = vScrollRight < colRightPixel; // 目标列是视口之后
|
|
144
|
+
|
|
145
|
+
var colToSmallForViewport = viewportWidth < column.width;
|
|
146
|
+
var alignColToLeft = colBeforeViewport || colToSmallForViewport;
|
|
147
|
+
var alignColToRight = colPastViewport;
|
|
148
|
+
|
|
149
|
+
if (alignColToLeft || alignColToRight) {
|
|
150
|
+
var newScrollPosition = alignColToLeft ? pxLeft : pxRight;
|
|
151
|
+
tableScroll.scrollLeft = newScrollPosition;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getHeightCache() {
|
|
156
|
+
var _a;
|
|
157
|
+
|
|
158
|
+
var pipeline = pipelineRef.current;
|
|
159
|
+
return (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager.cache;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
getColumns: getColumns,
|
|
164
|
+
getDataSource: getDataSource,
|
|
165
|
+
getFooterDataSource: getFooterDataSource,
|
|
166
|
+
clearRangeSelection: clearRangeSelection,
|
|
167
|
+
ensureRowIndexVisible: ensureRowIndexVisible,
|
|
168
|
+
ensureColumnVisible: ensureColumnVisible,
|
|
169
|
+
getHeightCache: getHeightCache
|
|
170
|
+
};
|
|
171
|
+
}
|
package/lib/table/interface.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare type TableApi = {
|
|
|
15
15
|
getDataSource: () => any[];
|
|
16
16
|
getFooterDataSource: () => any[];
|
|
17
17
|
clearRangeSelection: () => void;
|
|
18
|
+
getHeightCache: () => number[];
|
|
19
|
+
ensureRowIndexVisible: (rowIndex: number, position?: string | undefined) => void;
|
|
20
|
+
ensureColumnVisible: (code: string) => void;
|
|
18
21
|
};
|
|
19
22
|
export declare type TableInstance = {
|
|
20
23
|
api: TableApi;
|
package/lib/table/table.js
CHANGED
|
@@ -61,6 +61,8 @@ var _useFooterDataSource = _interopRequireDefault(require("./feature/useFooterDa
|
|
|
61
61
|
|
|
62
62
|
var _colGroupExtendable = _interopRequireDefault(require("./feature/colGroupExtendable"));
|
|
63
63
|
|
|
64
|
+
var _api = _interopRequireDefault(require("./api"));
|
|
65
|
+
|
|
64
66
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
65
67
|
|
|
66
68
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -123,15 +125,8 @@ var Table = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
123
125
|
// }
|
|
124
126
|
|
|
125
127
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
126
|
-
var _a, _b, _c, _d;
|
|
127
|
-
|
|
128
128
|
return {
|
|
129
|
-
api:
|
|
130
|
-
getColumns: (_a = pipelineRef.current.getColumns) === null || _a === void 0 ? void 0 : _a.bind(pipelineRef.current),
|
|
131
|
-
getDataSource: (_b = pipelineRef.current.getDataSource) === null || _b === void 0 ? void 0 : _b.bind(pipelineRef.current),
|
|
132
|
-
getFooterDataSource: (_c = pipelineRef.current.getFooterDataSource) === null || _c === void 0 ? void 0 : _c.bind(pipelineRef.current),
|
|
133
|
-
clearRangeSelection: (_d = pipelineRef.current.clearRangeSelection) === null || _d === void 0 ? void 0 : _d.bind(pipelineRef.current)
|
|
134
|
-
}
|
|
129
|
+
api: (0, _api.default)(pipelineRef)
|
|
135
130
|
};
|
|
136
131
|
});
|
|
137
132
|
/* -------------------------------------------------------------------------- */
|