@zhenliang/sheet 0.1.15 → 0.1.17
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/dist/core/sheet/index.js +62 -44
- package/dist/core/sheet/index.less +18 -2
- package/dist/core/sheet/useMouseEvent.js +2 -2
- package/dist/core/sheet/useSelectVisible.d.ts +1 -1
- package/dist/core/sheet/useSelectVisible.js +7 -2
- package/dist/core/sheet/useVirtualList.js +23 -11
- package/dist/core/shell/draggableShell/index.js +2 -2
- package/dist/core/util.d.ts +2 -1
- package/dist/core/util.js +52 -3
- package/dist/hooks/useEventBus.d.ts +1 -0
- package/dist/type/sheetTable.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/sheet/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { useEffect, useMemo, useRef } from 'react';
|
|
|
15
15
|
import ReduxThunk from 'redux-thunk';
|
|
16
16
|
import DefaultRow from "./DefaultRow";
|
|
17
17
|
import DefaultShell from "./DefaultShell";
|
|
18
|
-
import {
|
|
18
|
+
import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
|
|
19
19
|
import { isNil, isNumber } from 'lodash';
|
|
20
20
|
import { SheetEventContext, useEventBus, useMiddlewareReducer } from "../../hooks";
|
|
21
21
|
import sheetReducer from "../reducers";
|
|
@@ -82,14 +82,25 @@ var Sheet = function Sheet(props) {
|
|
|
82
82
|
var _ref, _sheetWrapperRef$curr;
|
|
83
83
|
var _getState = getState(),
|
|
84
84
|
start = _getState.start,
|
|
85
|
-
groupConfig = _getState.groupConfig
|
|
85
|
+
groupConfig = _getState.groupConfig,
|
|
86
|
+
data = _getState.data;
|
|
86
87
|
var container = sheetWrapperRef.current;
|
|
87
88
|
if (!start && isNil(row)) return;
|
|
88
89
|
var actual = rowToActualRow((_ref = row) !== null && _ref !== void 0 ? _ref : start === null || start === void 0 ? void 0 : start.row, groupConfig);
|
|
89
90
|
var rowHeight = getRowHeight(container);
|
|
90
91
|
var firstRowCell = container.querySelector("td.cell[data-col='".concat(start === null || start === void 0 ? void 0 : start.col, "']"));
|
|
91
92
|
var colPosition = firstRowCell ? firstRowCell.offsetLeft - firstRowCell.clientWidth : 0;
|
|
92
|
-
|
|
93
|
+
var scrollHeight = (actual - 1) * rowHeight;
|
|
94
|
+
(_sheetWrapperRef$curr = sheetWrapperRef.current) === null || _sheetWrapperRef$curr === void 0 ? void 0 : _sheetWrapperRef$curr.scrollTo(isNumber(row) ? 0 : colPosition, scrollHeight);
|
|
95
|
+
|
|
96
|
+
// to do 最后一行的有bug
|
|
97
|
+
if (isNil(row) && start.row === data.length - 1) {
|
|
98
|
+
setTimeout(function () {
|
|
99
|
+
var _sheetWrapperRef$curr2, _sheetWrapperRef$curr3, _sheetWrapperRef$curr4;
|
|
100
|
+
console.log(scrollHeight, (_sheetWrapperRef$curr2 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr2 === void 0 ? void 0 : _sheetWrapperRef$curr2.scrollHeight);
|
|
101
|
+
(_sheetWrapperRef$curr3 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr3 === void 0 ? void 0 : _sheetWrapperRef$curr3.scrollTo(isNumber(row) ? 0 : colPosition, ((_sheetWrapperRef$curr4 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr4 === void 0 ? void 0 : _sheetWrapperRef$curr4.scrollHeight) || scrollHeight);
|
|
102
|
+
}, 500);
|
|
103
|
+
}
|
|
93
104
|
});
|
|
94
105
|
},
|
|
95
106
|
pushToHistory: function pushToHistory(config) {
|
|
@@ -146,9 +157,9 @@ var Sheet = function Sheet(props) {
|
|
|
146
157
|
useEffect(function () {
|
|
147
158
|
if (!state.editing && state.start) {
|
|
148
159
|
setTimeout(function () {
|
|
149
|
-
var _sheetWrapperRef$
|
|
160
|
+
var _sheetWrapperRef$curr5;
|
|
150
161
|
// 表格获取焦点 + 接收keyboard event
|
|
151
|
-
(_sheetWrapperRef$
|
|
162
|
+
(_sheetWrapperRef$curr5 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr5 === void 0 ? void 0 : _sheetWrapperRef$curr5.focus({
|
|
152
163
|
preventScroll: true
|
|
153
164
|
});
|
|
154
165
|
}, 1);
|
|
@@ -186,58 +197,65 @@ var Sheet = function Sheet(props) {
|
|
|
186
197
|
});
|
|
187
198
|
}, [state.data, groupConfig, virtualStart, virtualEnd, rowClassName]);
|
|
188
199
|
var memoHeight = Math.min(((_state$data$length = state === null || state === void 0 ? void 0 : (_state$data3 = state.data) === null || _state$data3 === void 0 ? void 0 : _state$data3.length) !== null && _state$data$length !== void 0 ? _state$data$length : 0) + 1, 10) * 42 + 43;
|
|
189
|
-
var
|
|
200
|
+
var _useSelectVisible = useSelectVisible(sheetWrapperRef, state.start),
|
|
201
|
+
_useSelectVisible2 = _slicedToArray(_useSelectVisible, 2),
|
|
202
|
+
startRowVisible = _useSelectVisible2[0],
|
|
203
|
+
direction = _useSelectVisible2[1];
|
|
190
204
|
return /*#__PURE__*/_jsx(SheetEventContext.Provider, {
|
|
191
205
|
value: eventBus,
|
|
192
206
|
children: /*#__PURE__*/_jsxs("span", {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
maxHeight: (_scroll$y = scroll === null || scroll === void 0 ? void 0 : scroll.y) !== null && _scroll$y !== void 0 ? _scroll$y : memoHeight,
|
|
198
|
-
width: (_scroll$x = scroll === null || scroll === void 0 ? void 0 : scroll.x) !== null && _scroll$x !== void 0 ? _scroll$x : '100%'
|
|
199
|
-
},
|
|
200
|
-
children: [/*#__PURE__*/_jsxs(SheetShell, {
|
|
201
|
-
className: classNames('harvest-sheet', className),
|
|
202
|
-
children: [virtualized && /*#__PURE__*/_jsx("tr", {
|
|
203
|
-
style: {
|
|
204
|
-
height: 0,
|
|
205
|
-
paddingBottom: paddingTop,
|
|
206
|
-
display: 'block'
|
|
207
|
-
}
|
|
208
|
-
}), rowElements, virtualized && paddingBottom > 0 && /*#__PURE__*/_jsx("tr", {
|
|
209
|
-
style: {
|
|
210
|
-
height: 0,
|
|
211
|
-
paddingBottom: paddingBottom,
|
|
212
|
-
display: 'block'
|
|
213
|
-
}
|
|
214
|
-
})]
|
|
215
|
-
}, "sheet"), ContextMenu ? /*#__PURE__*/_jsx("div", {
|
|
216
|
-
ref: contextMenuRef,
|
|
207
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
208
|
+
ref: sheetWrapperRef,
|
|
209
|
+
tabIndex: 0,
|
|
210
|
+
className: classNames('harvest harvest-sheet-container', className),
|
|
217
211
|
style: {
|
|
218
|
-
|
|
212
|
+
maxHeight: (_scroll$y = scroll === null || scroll === void 0 ? void 0 : scroll.y) !== null && _scroll$y !== void 0 ? _scroll$y : memoHeight,
|
|
213
|
+
width: (_scroll$x = scroll === null || scroll === void 0 ? void 0 : scroll.x) !== null && _scroll$x !== void 0 ? _scroll$x : '100%'
|
|
219
214
|
},
|
|
220
|
-
children: /*#__PURE__*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
215
|
+
children: [/*#__PURE__*/_jsxs(SheetShell, {
|
|
216
|
+
className: classNames('harvest-sheet', className),
|
|
217
|
+
children: [virtualized && paddingTop > 0 && /*#__PURE__*/_jsx("tr", {
|
|
218
|
+
style: {
|
|
219
|
+
height: 0,
|
|
220
|
+
paddingBottom: paddingTop,
|
|
221
|
+
display: 'block'
|
|
222
|
+
}
|
|
223
|
+
}), rowElements, virtualized && paddingBottom > 0 && /*#__PURE__*/_jsx("tr", {
|
|
224
|
+
style: {
|
|
225
|
+
height: 0,
|
|
226
|
+
paddingBottom: paddingBottom,
|
|
227
|
+
display: 'block'
|
|
228
|
+
}
|
|
229
|
+
})]
|
|
230
|
+
}, "sheet"), ContextMenu ? /*#__PURE__*/_jsx("div", {
|
|
231
|
+
ref: contextMenuRef,
|
|
232
|
+
style: {
|
|
233
|
+
display: menu.showMenu ? '' : 'none'
|
|
234
|
+
},
|
|
235
|
+
children: /*#__PURE__*/_jsx(ContextMenu, {
|
|
236
|
+
position: menu.position,
|
|
237
|
+
cell: menu.cellPosition,
|
|
238
|
+
onContextMenu: onContextMenu
|
|
239
|
+
})
|
|
240
|
+
}) : null]
|
|
241
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
226
242
|
className: "harvest-sheet-control",
|
|
227
|
-
children: [children, showBackEdit && !startRowVisible ? /*#__PURE__*/
|
|
228
|
-
|
|
243
|
+
children: [children, showBackEdit && !startRowVisible ? /*#__PURE__*/_jsxs("div", {
|
|
244
|
+
className: "back-edit",
|
|
229
245
|
onClick: function onClick() {
|
|
230
246
|
var _sheetInstance$curren;
|
|
231
247
|
return sheetInstance === null || sheetInstance === void 0 ? void 0 : (_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 ? void 0 : _sheetInstance$curren.zoomTo();
|
|
232
248
|
},
|
|
233
|
-
style: _objectSpread({
|
|
234
|
-
position: 'absolute',
|
|
235
|
-
zIndex: 4
|
|
236
|
-
}, !backEditStyle ? {
|
|
249
|
+
style: _objectSpread({}, !backEditStyle ? {
|
|
237
250
|
top: 0,
|
|
238
251
|
right: 0
|
|
239
252
|
} : backEditStyle),
|
|
240
|
-
children: "
|
|
253
|
+
children: [direction === 'up' ? /*#__PURE__*/_jsx(ArrowUpOutlined, {}) : /*#__PURE__*/_jsx(ArrowDownOutlined, {}), /*#__PURE__*/_jsx("span", {
|
|
254
|
+
style: {
|
|
255
|
+
marginLeft: 0
|
|
256
|
+
},
|
|
257
|
+
children: "\u8FD4\u56DE\u7F16\u8F91\u884C"
|
|
258
|
+
})]
|
|
241
259
|
}) : null]
|
|
242
260
|
})]
|
|
243
261
|
})
|
|
@@ -172,6 +172,7 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
172
172
|
background: var(--cell-read-only-background-color);
|
|
173
173
|
color: var(--read-color);
|
|
174
174
|
text-align: center;
|
|
175
|
+
cursor: not-allowed;
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
|
|
@@ -282,10 +283,25 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
282
283
|
|
|
283
284
|
}
|
|
284
285
|
|
|
285
|
-
.harvest-sheet-
|
|
286
|
-
position:
|
|
286
|
+
.harvest-sheet-control{
|
|
287
|
+
position: relative;
|
|
287
288
|
z-index: 3;
|
|
288
289
|
bottom: 0;
|
|
289
290
|
left: 0;
|
|
290
291
|
background-color: white;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.harvest-sheet-control .back-edit{
|
|
295
|
+
padding: 5px 8px;
|
|
296
|
+
margin: 1px;
|
|
297
|
+
height: 30px;
|
|
298
|
+
display: flex;
|
|
299
|
+
width: 105px;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
align-items: center;
|
|
302
|
+
justify-content: center;
|
|
303
|
+
position: absolute;
|
|
304
|
+
z-index: 4;
|
|
305
|
+
border:1px solid #D8DFEB;
|
|
306
|
+
border-radius:2px;
|
|
291
307
|
}
|
|
@@ -267,8 +267,8 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
|
|
|
267
267
|
});
|
|
268
268
|
}, []);
|
|
269
269
|
var loseFocus = useCallback(function (e) {
|
|
270
|
-
var _elementRef$current10;
|
|
271
|
-
if (!((_elementRef$current10 = elementRef.current) !== null && _elementRef$current10 !== void 0 && _elementRef$current10.contains(e.target))) {
|
|
270
|
+
var _elementRef$current10, _elementRef$current11;
|
|
271
|
+
if (!((_elementRef$current10 = elementRef.current) !== null && _elementRef$current10 !== void 0 && (_elementRef$current11 = _elementRef$current10.parentElement) !== null && _elementRef$current11 !== void 0 && _elementRef$current11.contains(e.target))) {
|
|
272
272
|
dispatch({
|
|
273
273
|
type: 'loseFocus'
|
|
274
274
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SheetType } from "../../type";
|
|
2
|
-
export declare const useSelectVisible: (sheetWrapper: React.RefObject<SheetType.refAssertion>, start?: SheetType.CellPosition) => boolean;
|
|
2
|
+
export declare const useSelectVisible: (sheetWrapper: React.RefObject<SheetType.refAssertion>, start?: SheetType.CellPosition) => [boolean, 'up' | 'down'];
|
|
@@ -11,6 +11,10 @@ export var useSelectVisible = function useSelectVisible(sheetWrapper, start) {
|
|
|
11
11
|
_useState2 = _slicedToArray(_useState, 2),
|
|
12
12
|
startVisible = _useState2[0],
|
|
13
13
|
setStartVisible = _useState2[1];
|
|
14
|
+
var _useState3 = useState('up'),
|
|
15
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
16
|
+
backDirection = _useState4[0],
|
|
17
|
+
setBackDirection = _useState4[1];
|
|
14
18
|
useEffect(function () {
|
|
15
19
|
var _sheetWrapper$current3;
|
|
16
20
|
var handleScroll = throttle(function () {
|
|
@@ -32,6 +36,7 @@ export var useSelectVisible = function useSelectVisible(sheetWrapper, start) {
|
|
|
32
36
|
setStartVisible(true);
|
|
33
37
|
} else {
|
|
34
38
|
setStartVisible(false);
|
|
39
|
+
setBackDirection(top < cellTop ? 'down' : 'up');
|
|
35
40
|
}
|
|
36
41
|
}, 100);
|
|
37
42
|
handleScroll();
|
|
@@ -42,7 +47,7 @@ export var useSelectVisible = function useSelectVisible(sheetWrapper, start) {
|
|
|
42
47
|
};
|
|
43
48
|
}, [sheetWrapper.current, start]);
|
|
44
49
|
if (!start) {
|
|
45
|
-
return true;
|
|
50
|
+
return [true, 'up'];
|
|
46
51
|
}
|
|
47
|
-
return startVisible;
|
|
52
|
+
return [startVisible, backDirection];
|
|
48
53
|
};
|
|
@@ -6,7 +6,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { isEqual, throttle } from 'lodash';
|
|
8
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { getRowHeight, rowToActualRow } from "../util";
|
|
9
|
+
import { getRowHeight, rowToActualRow, rowToCountRow } from "../util";
|
|
10
10
|
var extra = 20;
|
|
11
11
|
// 虚拟列表
|
|
12
12
|
export var useVirtualList = function useVirtualList(elementRef) {
|
|
@@ -43,18 +43,30 @@ export var useVirtualList = function useVirtualList(elementRef) {
|
|
|
43
43
|
clientHeight = _ref.clientHeight;
|
|
44
44
|
var start = Math.floor(scrollTop / itemHeight) - extra;
|
|
45
45
|
var end = Math.ceil((scrollTop + clientHeight) / itemHeight) + extra;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
if (!groupConfigRef.current) {
|
|
47
|
+
var newConfig = {
|
|
48
|
+
virtualStart: start,
|
|
49
|
+
virtualEnd: end,
|
|
50
|
+
paddingTop: start * itemHeight,
|
|
51
|
+
paddingBottom: (data.length - end) * itemHeight
|
|
52
|
+
};
|
|
53
|
+
if (isEqual(newConfig, virtualRef.current)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
virtualRef.current = newConfig;
|
|
57
|
+
setState(newConfig);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var actualStart = rowToCountRow(start, groupConfigRef.current, data.length);
|
|
61
|
+
var actualEnd = rowToCountRow(end, groupConfigRef.current, data.length);
|
|
62
|
+
var maxEnd = rowToActualRow(data.length, groupConfigRef.current);
|
|
63
|
+
var invisibleTop = rowToActualRow(actualStart, groupConfigRef.current);
|
|
64
|
+
var invisibleBottom = maxEnd > end ? maxEnd - end : 0;
|
|
53
65
|
var updateVirtualConfig = {
|
|
54
66
|
virtualStart: actualStart,
|
|
55
|
-
virtualEnd:
|
|
56
|
-
paddingTop:
|
|
57
|
-
paddingBottom:
|
|
67
|
+
virtualEnd: actualEnd,
|
|
68
|
+
paddingTop: invisibleTop * itemHeight,
|
|
69
|
+
paddingBottom: invisibleBottom * itemHeight
|
|
58
70
|
};
|
|
59
71
|
if (isEqual(updateVirtualConfig, virtualRef.current)) {
|
|
60
72
|
return;
|
|
@@ -8,7 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
8
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
9
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
11
|
+
import { createElement, useEffect, useMemo, useRef } from 'react';
|
|
12
12
|
import { useSetState, useWidth } from "../../../hooks";
|
|
13
13
|
import { classNames } from "../../util";
|
|
14
14
|
import { CheckViewer } from "../../viewer/checkViewer";
|
|
@@ -99,7 +99,7 @@ export var DraggableShell = function DraggableShell(_ref) {
|
|
|
99
99
|
},
|
|
100
100
|
children: /*#__PURE__*/_jsx("span", {
|
|
101
101
|
className: "value-viewer",
|
|
102
|
-
children: item.title
|
|
102
|
+
children: typeof item.title === 'function' ? /*#__PURE__*/createElement(item.title) : item.title
|
|
103
103
|
})
|
|
104
104
|
}, (_item$dataIndex = item.dataIndex) !== null && _item$dataIndex !== void 0 ? _item$dataIndex : index));
|
|
105
105
|
});
|
package/dist/core/util.d.ts
CHANGED
|
@@ -41,7 +41,8 @@ export declare const changeGroupConfig: (rowGroupConfig: SheetType.RowGroupConfi
|
|
|
41
41
|
add?: number | undefined;
|
|
42
42
|
remove?: number | undefined;
|
|
43
43
|
}) => SheetType.RowGroupConfig;
|
|
44
|
-
export declare const rowToActualRow: (row: number, groupConfig?: SheetType.RowGroupConfig) => number;
|
|
44
|
+
export declare const rowToActualRow: (row: number, groupConfig?: SheetType.RowGroupConfig, max?: number) => number;
|
|
45
|
+
export declare const rowToCountRow: (row: number, groupConfig: SheetType.RowGroupConfig, max: number) => number;
|
|
45
46
|
export declare const getRowHeight: (container: HTMLSpanElement) => number;
|
|
46
47
|
export declare const getNextVisibleRow: (row: number, maxRow: number, groupMap?: Map<number, SheetType.RowGroup & {
|
|
47
48
|
isStart: boolean;
|
package/dist/core/util.js
CHANGED
|
@@ -387,8 +387,23 @@ export var changeGroupConfig = function changeGroupConfig(rowGroupConfig, change
|
|
|
387
387
|
});
|
|
388
388
|
};
|
|
389
389
|
export var rowToActualRow = function rowToActualRow(row, groupConfig) {
|
|
390
|
+
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
|
|
390
391
|
var groupMap = groupConfigToGroupMap(groupConfig);
|
|
391
|
-
if (!groupMap.size) return row;
|
|
392
|
+
if (!groupMap.size || row < 0) return row;
|
|
393
|
+
var openCount = 0;
|
|
394
|
+
for (var i = 0; i < max; i++) {
|
|
395
|
+
var _groupMap$get9, _groupMap$get10;
|
|
396
|
+
if (groupMap.has(i) && !((_groupMap$get9 = groupMap.get(i)) !== null && _groupMap$get9 !== void 0 && _groupMap$get9.isOpen) && !((_groupMap$get10 = groupMap.get(i)) !== null && _groupMap$get10 !== void 0 && _groupMap$get10.isStart)) {
|
|
397
|
+
continue;
|
|
398
|
+
} else {
|
|
399
|
+
openCount++;
|
|
400
|
+
if (i >= row) {
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return openCount;
|
|
406
|
+
// 减法的做法 有bug
|
|
392
407
|
groupMap.forEach(function (item, index) {
|
|
393
408
|
if (index <= row && !(item !== null && item !== void 0 && item.isOpen) && !(item !== null && item !== void 0 && item.isStart)) {
|
|
394
409
|
row--;
|
|
@@ -396,13 +411,47 @@ export var rowToActualRow = function rowToActualRow(row, groupConfig) {
|
|
|
396
411
|
});
|
|
397
412
|
return row;
|
|
398
413
|
};
|
|
414
|
+
export var rowToCountRow = function rowToCountRow(row, groupConfig, max) {
|
|
415
|
+
var groupMap = groupConfigToGroupMap(groupConfig);
|
|
416
|
+
if (!groupMap.size || row < 0) return row;
|
|
417
|
+
|
|
418
|
+
// 加法的做法
|
|
419
|
+
var maxCount = 0;
|
|
420
|
+
var maxIndex = max;
|
|
421
|
+
for (var i = 0; i < max; i++) {
|
|
422
|
+
var _groupMap$get11, _groupMap$get12;
|
|
423
|
+
if (groupMap.has(i) && !((_groupMap$get11 = groupMap.get(i)) !== null && _groupMap$get11 !== void 0 && _groupMap$get11.isOpen) && !((_groupMap$get12 = groupMap.get(i)) !== null && _groupMap$get12 !== void 0 && _groupMap$get12.isStart)) {
|
|
424
|
+
continue;
|
|
425
|
+
} else {
|
|
426
|
+
maxCount++;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (row >= maxCount) {
|
|
430
|
+
return maxIndex;
|
|
431
|
+
}
|
|
432
|
+
maxIndex = 0;
|
|
433
|
+
var openCount = 0;
|
|
434
|
+
for (var _i2 = 0; _i2 < max; _i2++) {
|
|
435
|
+
var _groupMap$get13, _groupMap$get14;
|
|
436
|
+
if (groupMap.has(_i2) && !((_groupMap$get13 = groupMap.get(_i2)) !== null && _groupMap$get13 !== void 0 && _groupMap$get13.isOpen) && !((_groupMap$get14 = groupMap.get(_i2)) !== null && _groupMap$get14 !== void 0 && _groupMap$get14.isStart)) {
|
|
437
|
+
continue;
|
|
438
|
+
} else {
|
|
439
|
+
openCount++;
|
|
440
|
+
if (openCount >= row) {
|
|
441
|
+
maxIndex = _i2;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return maxIndex;
|
|
447
|
+
};
|
|
399
448
|
export var getRowHeight = function getRowHeight(container) {
|
|
400
449
|
var _container$getElement, _container$getElement2;
|
|
401
450
|
var h = ((_container$getElement = container.getElementsByTagName('td')[0]) === null || _container$getElement === void 0 ? void 0 : (_container$getElement2 = _container$getElement.parentNode) === null || _container$getElement2 === void 0 ? void 0 : _container$getElement2.clientHeight) || 30;
|
|
402
451
|
return h;
|
|
403
452
|
};
|
|
404
453
|
export var getNextVisibleRow = function getNextVisibleRow(row, maxRow, groupMap) {
|
|
405
|
-
var _groupMap$
|
|
454
|
+
var _groupMap$get15, _groupMap$get16;
|
|
406
455
|
var up = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
407
456
|
if (!(groupMap !== null && groupMap !== void 0 && groupMap.size)) {
|
|
408
457
|
return row;
|
|
@@ -410,7 +459,7 @@ export var getNextVisibleRow = function getNextVisibleRow(row, maxRow, groupMap)
|
|
|
410
459
|
if (row > maxRow) {
|
|
411
460
|
return null;
|
|
412
461
|
}
|
|
413
|
-
if (groupMap.get(row) && !((_groupMap$
|
|
462
|
+
if (groupMap.get(row) && !((_groupMap$get15 = groupMap.get(row)) !== null && _groupMap$get15 !== void 0 && _groupMap$get15.isOpen) && !((_groupMap$get16 = groupMap.get(row)) !== null && _groupMap$get16 !== void 0 && _groupMap$get16.isStart)) {
|
|
414
463
|
return getNextVisibleRow(row + up, maxRow, groupMap);
|
|
415
464
|
}
|
|
416
465
|
return row;
|