@zhenliang/sheet 0.1.72-beta.2 → 0.1.72-beta.4
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,3 +1,4 @@
|
|
|
1
|
+
import { CellPosition } from "../../type/sheet";
|
|
1
2
|
import React, { CSSProperties } from 'react';
|
|
2
3
|
interface ControlProps {
|
|
3
4
|
startRowVisible: boolean;
|
|
@@ -8,8 +9,13 @@ interface ControlProps {
|
|
|
8
9
|
toTop: () => void;
|
|
9
10
|
toBottom: () => void;
|
|
10
11
|
backEditStyle?: Partial<CSSProperties>;
|
|
11
|
-
ControlContainer?: React.FC
|
|
12
|
+
ControlContainer?: React.FC<any>;
|
|
12
13
|
showBackEdit?: boolean;
|
|
14
|
+
selectInfo?: {
|
|
15
|
+
start?: CellPosition;
|
|
16
|
+
end?: CellPosition;
|
|
17
|
+
selecting?: boolean;
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
20
|
export declare const Control: React.FC<ControlProps>;
|
|
15
21
|
export {};
|
|
@@ -12,6 +12,7 @@ export var Control = function Control(props) {
|
|
|
12
12
|
startRowVisible = props.startRowVisible,
|
|
13
13
|
firstRowVisible = props.firstRowVisible,
|
|
14
14
|
lastRowVisible = props.lastRowVisible,
|
|
15
|
+
selectInfo = props.selectInfo,
|
|
15
16
|
toTop = props.toTop,
|
|
16
17
|
toBottom = props.toBottom,
|
|
17
18
|
backToEditRow = props.backToEditRow,
|
|
@@ -53,7 +54,9 @@ export var Control = function Control(props) {
|
|
|
53
54
|
}, [firstRowVisible, showQuickLocationBtn, lastRowVisible, startRowVisible, showBackEdit]);
|
|
54
55
|
if (!showBackEdit && !showQuickLocationBtn) return null;
|
|
55
56
|
if (ControlContainer) {
|
|
56
|
-
return /*#__PURE__*/_jsx(ControlContainer, {
|
|
57
|
+
return /*#__PURE__*/_jsx(ControlContainer, {
|
|
58
|
+
selectInfo: selectInfo
|
|
59
|
+
});
|
|
57
60
|
}
|
|
58
61
|
return /*#__PURE__*/_jsx("div", {
|
|
59
62
|
className: "control",
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -124,6 +124,22 @@ var Sheet = function Sheet(props) {
|
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
},
|
|
127
|
+
goTo: function goTo(row, col) {
|
|
128
|
+
dispatch(function (d, getState) {
|
|
129
|
+
var _sheetWrapperRef$curr4;
|
|
130
|
+
var _getState2 = getState(),
|
|
131
|
+
groupConfig = _getState2.groupConfig,
|
|
132
|
+
data = _getState2.data;
|
|
133
|
+
var container = sheetWrapperRef.current;
|
|
134
|
+
if (isNil(row) || isNil(col)) return;
|
|
135
|
+
var actual = rowToActualRow(row, groupConfig, data.length);
|
|
136
|
+
var rowHeight = getRowHeight(container);
|
|
137
|
+
var firstRowCell = container.querySelector("td.cell[data-col='".concat(col, "']"));
|
|
138
|
+
var colPosition = firstRowCell ? firstRowCell.offsetLeft - firstRowCell.clientWidth : 0;
|
|
139
|
+
var scrollHeight = actual * rowHeight;
|
|
140
|
+
(_sheetWrapperRef$curr4 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr4 === void 0 || _sheetWrapperRef$curr4.scrollTo(colPosition, scrollHeight);
|
|
141
|
+
});
|
|
142
|
+
},
|
|
127
143
|
pushToHistory: function pushToHistory(config) {
|
|
128
144
|
dispatch({
|
|
129
145
|
type: 'pushHistory',
|
|
@@ -188,9 +204,9 @@ var Sheet = function Sheet(props) {
|
|
|
188
204
|
useEffect(function () {
|
|
189
205
|
if (!state.editing && state.start) {
|
|
190
206
|
setTimeout(function () {
|
|
191
|
-
var _sheetWrapperRef$
|
|
207
|
+
var _sheetWrapperRef$curr5;
|
|
192
208
|
// 表格获取焦点 + 接收keyboard event
|
|
193
|
-
(_sheetWrapperRef$
|
|
209
|
+
(_sheetWrapperRef$curr5 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr5 === void 0 || _sheetWrapperRef$curr5.focus({
|
|
194
210
|
preventScroll: true
|
|
195
211
|
});
|
|
196
212
|
}, 1);
|
|
@@ -277,8 +293,11 @@ var Sheet = function Sheet(props) {
|
|
|
277
293
|
return null;
|
|
278
294
|
}, [isEmptyData, emptyRenderer]);
|
|
279
295
|
var hasHorizontalScrollbar = sheetWrapperRef.current && sheetWrapperRef.current.scrollWidth > sheetWrapperRef.current.clientWidth;
|
|
280
|
-
var handleScroll = useCallback(function (
|
|
281
|
-
|
|
296
|
+
var handleScroll = useCallback(function () {
|
|
297
|
+
if (!sheetWrapperRef.current) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
var div = sheetWrapperRef.current;
|
|
282
301
|
|
|
283
302
|
// 当前的滚动位置
|
|
284
303
|
var scrollLeft = div.scrollLeft;
|
|
@@ -294,6 +313,11 @@ var Sheet = function Sheet(props) {
|
|
|
294
313
|
setIsScrolledToEnd(false);
|
|
295
314
|
}
|
|
296
315
|
}, []);
|
|
316
|
+
useEffect(function () {
|
|
317
|
+
if (sheetWrapperRef.current) {
|
|
318
|
+
handleScroll();
|
|
319
|
+
}
|
|
320
|
+
}, []);
|
|
297
321
|
return /*#__PURE__*/_jsx(SheetEventContext.Provider, {
|
|
298
322
|
value: eventBus,
|
|
299
323
|
children: /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -350,7 +374,12 @@ var Sheet = function Sheet(props) {
|
|
|
350
374
|
return sheetInstance === null || sheetInstance === void 0 || (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 ? void 0 : _sheetInstance$curren3.zoomTo(((_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : 1) - 1);
|
|
351
375
|
},
|
|
352
376
|
showQuickLocationBtn: showQuickLocationBtn,
|
|
353
|
-
ControlContainer: ControlContainer
|
|
377
|
+
ControlContainer: ControlContainer,
|
|
378
|
+
selectInfo: {
|
|
379
|
+
start: state.start,
|
|
380
|
+
end: state.end,
|
|
381
|
+
selecting: state.selecting
|
|
382
|
+
}
|
|
354
383
|
}), children]
|
|
355
384
|
})]
|
|
356
385
|
}), /*#__PURE__*/_jsx(SearchInput, {
|
package/dist/type/sheet.d.ts
CHANGED
|
@@ -95,6 +95,7 @@ export type MenuRenderProps = {
|
|
|
95
95
|
};
|
|
96
96
|
export type SheetInstance = {
|
|
97
97
|
zoomTo: (row?: number) => void;
|
|
98
|
+
goTo: (row: number, col: number) => void;
|
|
98
99
|
pushToHistory: (value: OperateHistory) => void;
|
|
99
100
|
selectRow: (row?: number) => void;
|
|
100
101
|
select: (props: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhenliang/sheet",
|
|
3
|
-
"version": "0.1.72-beta.
|
|
3
|
+
"version": "0.1.72-beta.4",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
-
"preid": "beta",
|
|
12
11
|
"scripts": {
|
|
13
12
|
"build": "father build",
|
|
14
13
|
"build:watch": "father dev",
|
|
@@ -79,5 +78,6 @@
|
|
|
79
78
|
},
|
|
80
79
|
"authors": [
|
|
81
80
|
"fizz.zhou@ap.jll.com"
|
|
82
|
-
]
|
|
83
|
-
|
|
81
|
+
],
|
|
82
|
+
"preid": "beta"
|
|
83
|
+
}
|