@zhenliang/sheet 0.1.16 → 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 +48 -35
- package/dist/core/sheet/index.less +8 -4
- package/dist/core/sheet/useMouseEvent.js +2 -2
- package/dist/core/sheet/useVirtualList.js +0 -9
- package/dist/core/shell/draggableShell/index.d.ts +1 -0
- package/dist/core/shell/draggableShell/index.js +2 -2
- package/dist/core/shell/tableShell.d.ts +1 -0
- 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
|
@@ -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);
|
|
@@ -193,39 +204,41 @@ var Sheet = function Sheet(props) {
|
|
|
193
204
|
return /*#__PURE__*/_jsx(SheetEventContext.Provider, {
|
|
194
205
|
value: eventBus,
|
|
195
206
|
children: /*#__PURE__*/_jsxs("span", {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
maxHeight: (_scroll$y = scroll === null || scroll === void 0 ? void 0 : scroll.y) !== null && _scroll$y !== void 0 ? _scroll$y : memoHeight,
|
|
201
|
-
width: (_scroll$x = scroll === null || scroll === void 0 ? void 0 : scroll.x) !== null && _scroll$x !== void 0 ? _scroll$x : '100%'
|
|
202
|
-
},
|
|
203
|
-
children: [/*#__PURE__*/_jsxs(SheetShell, {
|
|
204
|
-
className: classNames('harvest-sheet', className),
|
|
205
|
-
children: [virtualized && paddingTop > 0 && /*#__PURE__*/_jsx("tr", {
|
|
206
|
-
style: {
|
|
207
|
-
height: 0,
|
|
208
|
-
paddingBottom: paddingTop,
|
|
209
|
-
display: 'block'
|
|
210
|
-
}
|
|
211
|
-
}), rowElements, virtualized && paddingBottom > 0 && /*#__PURE__*/_jsx("tr", {
|
|
212
|
-
style: {
|
|
213
|
-
height: 0,
|
|
214
|
-
paddingBottom: paddingBottom,
|
|
215
|
-
display: 'block'
|
|
216
|
-
}
|
|
217
|
-
})]
|
|
218
|
-
}, "sheet"), ContextMenu ? /*#__PURE__*/_jsx("div", {
|
|
219
|
-
ref: contextMenuRef,
|
|
207
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
208
|
+
ref: sheetWrapperRef,
|
|
209
|
+
tabIndex: 0,
|
|
210
|
+
className: classNames('harvest harvest-sheet-container', className),
|
|
220
211
|
style: {
|
|
221
|
-
|
|
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%'
|
|
222
214
|
},
|
|
223
|
-
children: /*#__PURE__*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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", {
|
|
229
242
|
className: "harvest-sheet-control",
|
|
230
243
|
children: [children, showBackEdit && !startRowVisible ? /*#__PURE__*/_jsxs("div", {
|
|
231
244
|
className: "back-edit",
|
|
@@ -283,21 +283,25 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
283
283
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
.harvest-sheet-
|
|
287
|
-
position:
|
|
286
|
+
.harvest-sheet-control{
|
|
287
|
+
position: relative;
|
|
288
288
|
z-index: 3;
|
|
289
289
|
bottom: 0;
|
|
290
290
|
left: 0;
|
|
291
291
|
background-color: white;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
.harvest-sheet-
|
|
294
|
+
.harvest-sheet-control .back-edit{
|
|
295
295
|
padding: 5px 8px;
|
|
296
|
+
margin: 1px;
|
|
297
|
+
height: 30px;
|
|
296
298
|
display: flex;
|
|
297
299
|
width: 105px;
|
|
298
300
|
cursor: pointer;
|
|
299
301
|
align-items: center;
|
|
300
302
|
justify-content: center;
|
|
301
303
|
position: absolute;
|
|
302
|
-
z-index: 4
|
|
304
|
+
z-index: 4;
|
|
305
|
+
border:1px solid #D8DFEB;
|
|
306
|
+
border-radius:2px;
|
|
303
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
|
});
|
|
@@ -57,20 +57,11 @@ export var useVirtualList = function useVirtualList(elementRef) {
|
|
|
57
57
|
setState(newConfig);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
// todo 加入分组之后的 虚拟列表计算
|
|
62
60
|
var actualStart = rowToCountRow(start, groupConfigRef.current, data.length);
|
|
63
61
|
var actualEnd = rowToCountRow(end, groupConfigRef.current, data.length);
|
|
64
62
|
var maxEnd = rowToActualRow(data.length, groupConfigRef.current);
|
|
65
63
|
var invisibleTop = rowToActualRow(actualStart, groupConfigRef.current);
|
|
66
64
|
var invisibleBottom = maxEnd > end ? maxEnd - end : 0;
|
|
67
|
-
console.log('visiable-count', start, end, maxEnd);
|
|
68
|
-
console.log('visible-toactual-count', actualStart, actualEnd);
|
|
69
|
-
console.log('invisible', invisibleTop, invisibleBottom);
|
|
70
|
-
|
|
71
|
-
// const minStart = start - (actualStart - start)
|
|
72
|
-
// const maxEnd = end - (actualEnd - end);
|
|
73
|
-
|
|
74
65
|
var updateVirtualConfig = {
|
|
75
66
|
virtualStart: actualStart,
|
|
76
67
|
virtualEnd: actualEnd,
|
|
@@ -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
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { SheetType } from "../../type";
|
|
2
3
|
import './draggableShell/index.less';
|
|
3
4
|
export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|