@zhenliang/sheet 0.1.79 → 0.1.81-beta
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,6 +1,6 @@
|
|
|
1
1
|
import { useMouse } from "../..";
|
|
2
2
|
import { useCallback, useEffect, useRef } from 'react';
|
|
3
|
-
import { extractDataRowAndCol, findParentTd,
|
|
3
|
+
import { extractDataRowAndCol, findParentTd, isSiblingControl } from "../util";
|
|
4
4
|
var rowCount = 10; //每秒10行
|
|
5
5
|
var colCount = 5; //每秒5列
|
|
6
6
|
|
|
@@ -268,9 +268,9 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
|
|
|
268
268
|
var loseFocus = useCallback(function (e) {
|
|
269
269
|
var _elementRef$current10, _elementRef$current11;
|
|
270
270
|
// todo 加一个root node
|
|
271
|
-
var
|
|
271
|
+
var isSibling = isSiblingControl((_elementRef$current10 = elementRef.current) === null || _elementRef$current10 === void 0 ? void 0 : _elementRef$current10.parentElement, e.target);
|
|
272
272
|
var isTableAControl = (_elementRef$current11 = elementRef.current) === null || _elementRef$current11 === void 0 || (_elementRef$current11 = _elementRef$current11.parentElement) === null || _elementRef$current11 === void 0 ? void 0 : _elementRef$current11.contains(e.target);
|
|
273
|
-
if (!(isTableAControl ||
|
|
273
|
+
if (!(isTableAControl || isSibling)) {
|
|
274
274
|
dispatch({
|
|
275
275
|
type: 'loseFocus'
|
|
276
276
|
});
|
|
@@ -52,15 +52,17 @@ export var GroupEvent = function GroupEvent(props) {
|
|
|
52
52
|
if (index >= 0) {
|
|
53
53
|
var groupOpen = _toConsumableArray(rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.groupOpen);
|
|
54
54
|
groupOpen[index] = !(rowGroupConfig !== null && rowGroupConfig !== void 0 && rowGroupConfig.groupOpen[index]);
|
|
55
|
-
|
|
55
|
+
var after = _objectSpread(_objectSpread({}, rowGroupConfig), {}, {
|
|
56
56
|
groupOpen: groupOpen
|
|
57
|
-
})
|
|
57
|
+
});
|
|
58
|
+
onGroupChange && onGroupChange(after);
|
|
58
59
|
sheetInstance === null || sheetInstance === void 0 || sheetInstance.pushToHistory({
|
|
59
60
|
type: 'Custom',
|
|
60
61
|
changes: [],
|
|
61
62
|
extraInfo: {
|
|
62
63
|
extraType: 'group',
|
|
63
|
-
groupConfig: rowGroupConfig
|
|
64
|
+
groupConfig: rowGroupConfig,
|
|
65
|
+
recoverGroupConfig: after
|
|
64
66
|
}
|
|
65
67
|
});
|
|
66
68
|
}
|
|
@@ -71,16 +73,18 @@ export var GroupEvent = function GroupEvent(props) {
|
|
|
71
73
|
if (!(rowGroupConfig !== null && rowGroupConfig !== void 0 && rowGroupConfig.groupOpen.some(function (item) {
|
|
72
74
|
return item !== value;
|
|
73
75
|
}))) return;
|
|
74
|
-
|
|
76
|
+
var after = _objectSpread(_objectSpread({}, rowGroupConfig), {}, {
|
|
75
77
|
groupOpen: Array(rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.groupOpen.length).fill(value),
|
|
76
78
|
defaultOpen: !groups.length ? value : undefined
|
|
77
|
-
})
|
|
79
|
+
});
|
|
80
|
+
onGroupChange && onGroupChange(after);
|
|
78
81
|
sheetInstance === null || sheetInstance === void 0 || sheetInstance.pushToHistory({
|
|
79
82
|
type: 'Custom',
|
|
80
83
|
changes: [],
|
|
81
84
|
extraInfo: {
|
|
82
85
|
extraType: 'group',
|
|
83
|
-
groupConfig: rowGroupConfig
|
|
86
|
+
groupConfig: rowGroupConfig,
|
|
87
|
+
recoverGroupConfig: after
|
|
84
88
|
}
|
|
85
89
|
});
|
|
86
90
|
}
|
package/dist/core/table/index.js
CHANGED
|
@@ -172,7 +172,20 @@ var Table = function Table(_ref) {
|
|
|
172
172
|
setGroupConfig(_groupConfig);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
}, [
|
|
175
|
+
}, [groupConfig]);
|
|
176
|
+
var handleRecover = useCallback(function (value) {
|
|
177
|
+
var _ref4 = value,
|
|
178
|
+
type = _ref4.type,
|
|
179
|
+
extraInfo = _ref4.extraInfo;
|
|
180
|
+
if (type === 'Custom') {
|
|
181
|
+
var _ref5 = extraInfo,
|
|
182
|
+
recoverGroupConfig = _ref5.recoverGroupConfig,
|
|
183
|
+
extraType = _ref5.extraType;
|
|
184
|
+
if (extraType === 'group') {
|
|
185
|
+
setGroupConfig(recoverGroupConfig);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, [groupConfig]);
|
|
176
189
|
var handleRowSelect = useCallback(function (value) {
|
|
177
190
|
if (!sheetInstance.current) return;
|
|
178
191
|
var currentRow = value;
|
|
@@ -225,9 +238,9 @@ var Table = function Table(_ref) {
|
|
|
225
238
|
setRemarkInfo = _useState6[1];
|
|
226
239
|
var handleCellClick = useCallback(function (cell) {
|
|
227
240
|
var _columns$dataIndex, _data$row, _data$row2;
|
|
228
|
-
var
|
|
229
|
-
col =
|
|
230
|
-
row =
|
|
241
|
+
var _ref6 = cell !== null && cell !== void 0 ? cell : {},
|
|
242
|
+
col = _ref6.col,
|
|
243
|
+
row = _ref6.row;
|
|
231
244
|
if (!cell || !(columns !== null && columns !== void 0 && columns.length) || !(data !== null && data !== void 0 && data.length) || !columns[col - offset]) {
|
|
232
245
|
//remove pop
|
|
233
246
|
setShowRemark(false);
|
|
@@ -269,11 +282,11 @@ var Table = function Table(_ref) {
|
|
|
269
282
|
return function (props) {
|
|
270
283
|
var _data$row3, _target$record, _target$record$includ;
|
|
271
284
|
var cell = props.cell;
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
col =
|
|
275
|
-
|
|
276
|
-
row =
|
|
285
|
+
var _ref7 = cell !== null && cell !== void 0 ? cell : {},
|
|
286
|
+
_ref7$col = _ref7.col,
|
|
287
|
+
col = _ref7$col === void 0 ? -1 : _ref7$col,
|
|
288
|
+
_ref7$row = _ref7.row,
|
|
289
|
+
row = _ref7$row === void 0 ? -1 : _ref7$row;
|
|
277
290
|
var target = data === null || data === void 0 || (_data$row3 = data[row]) === null || _data$row3 === void 0 ? void 0 : _data$row3[col + 1];
|
|
278
291
|
var cellHasRemark = (_target$record = target.record) === null || _target$record === void 0 || (_target$record = _target$record.remarks) === null || _target$record === void 0 || (_target$record$includ = _target$record.includes) === null || _target$record$includ === void 0 ? void 0 : _target$record$includ.call(_target$record, target.dataIndex);
|
|
279
292
|
if ((target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed && !cellHasRemark) {
|
|
@@ -291,11 +304,11 @@ var Table = function Table(_ref) {
|
|
|
291
304
|
return function (props) {
|
|
292
305
|
var _data$row4, _target$record2, _target$record2$inclu;
|
|
293
306
|
var cell = props.cell;
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
col =
|
|
297
|
-
|
|
298
|
-
row =
|
|
307
|
+
var _ref8 = cell !== null && cell !== void 0 ? cell : {},
|
|
308
|
+
_ref8$col = _ref8.col,
|
|
309
|
+
col = _ref8$col === void 0 ? -1 : _ref8$col,
|
|
310
|
+
_ref8$row = _ref8.row,
|
|
311
|
+
row = _ref8$row === void 0 ? -1 : _ref8$row;
|
|
299
312
|
var target = data === null || data === void 0 || (_data$row4 = data[row]) === null || _data$row4 === void 0 ? void 0 : _data$row4[col + 1];
|
|
300
313
|
var MenuFC = menuRenderer;
|
|
301
314
|
var cellHasRemark = (_target$record2 = target.record) === null || _target$record2 === void 0 || (_target$record2 = _target$record2.remarks) === null || _target$record2 === void 0 || (_target$record2$inclu = _target$record2.includes) === null || _target$record2$inclu === void 0 ? void 0 : _target$record2$inclu.call(_target$record2, target.dataIndex);
|
|
@@ -349,7 +362,10 @@ var Table = function Table(_ref) {
|
|
|
349
362
|
}), /*#__PURE__*/_jsx(SheetEvent, {
|
|
350
363
|
name: "reverse",
|
|
351
364
|
handler: handleReverse
|
|
352
|
-
}, "_reverse"), /*#__PURE__*/_jsx(
|
|
365
|
+
}, "_reverse"), /*#__PURE__*/_jsx(SheetEvent, {
|
|
366
|
+
name: "recover",
|
|
367
|
+
handler: handleRecover
|
|
368
|
+
}, "_recover"), /*#__PURE__*/_jsx(RemarkEvent, {
|
|
353
369
|
handler: handleCellClick
|
|
354
370
|
}), Object.keys(eventHandler || {}).map(function (key) {
|
|
355
371
|
return /*#__PURE__*/_jsx(SheetEvent, {
|
package/dist/core/util.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export declare const stripRowIndex: (data: SheetType.Cell[][]) => {
|
|
|
62
62
|
endIndex: number;
|
|
63
63
|
};
|
|
64
64
|
export declare const ensureFocus: (container?: HTMLElement | null) => void;
|
|
65
|
+
export declare const isSiblingControl: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
|
|
66
|
+
export declare const isAnotationElement: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
|
|
65
67
|
export declare const isSearchElement: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
|
|
66
68
|
export declare const noramlizeSearch: (target: string) => string;
|
|
67
69
|
export declare const searchInclude: (search: string, compare: string) => boolean;
|
package/dist/core/util.js
CHANGED
|
@@ -496,9 +496,16 @@ export var ensureFocus = function ensureFocus(container) {
|
|
|
496
496
|
focusInterval = undefined;
|
|
497
497
|
}, 1000);
|
|
498
498
|
};
|
|
499
|
-
export var
|
|
499
|
+
export var isSiblingControl = function isSiblingControl(tableRootNode, target) {
|
|
500
|
+
return isAnotationElement(tableRootNode, target) || isSearchElement(tableRootNode, target);
|
|
501
|
+
};
|
|
502
|
+
export var isAnotationElement = function isAnotationElement(tableRootNode, target) {
|
|
500
503
|
var _tableRootNode$nextSi;
|
|
501
|
-
return (_tableRootNode$nextSi = tableRootNode.nextSibling) === null || _tableRootNode$nextSi === void 0
|
|
504
|
+
return (_tableRootNode$nextSi = tableRootNode.nextSibling) === null || _tableRootNode$nextSi === void 0 ? void 0 : _tableRootNode$nextSi.contains(target);
|
|
505
|
+
};
|
|
506
|
+
export var isSearchElement = function isSearchElement(tableRootNode, target) {
|
|
507
|
+
var _tableRootNode$nextSi2;
|
|
508
|
+
return (_tableRootNode$nextSi2 = tableRootNode.nextSibling) === null || _tableRootNode$nextSi2 === void 0 || (_tableRootNode$nextSi2 = _tableRootNode$nextSi2.nextSibling) === null || _tableRootNode$nextSi2 === void 0 ? void 0 : _tableRootNode$nextSi2.contains(target);
|
|
502
509
|
};
|
|
503
510
|
var punctuationMap = new Map([[",", ","], [":", ":"], [";", ";"]]);
|
|
504
511
|
export var noramlizeSearch = function noramlizeSearch(target) {
|