@zhenliang/sheet 0.1.74 → 0.1.75
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 { useKeyBoard } from "../..";
|
|
2
2
|
import { sideEffectReducer } from "../reducers/sideEffectReducer";
|
|
3
|
-
import { ensureFocus, getRowHeight } from "../util";
|
|
3
|
+
import { ensureFocus, getRowHeight, isSearchElement } from "../util";
|
|
4
4
|
export var useKeyBoardEvent = function useKeyBoardEvent(dispatch, elementRef) {
|
|
5
5
|
useKeyBoard({
|
|
6
6
|
move: function move(e, value) {
|
|
@@ -63,13 +63,20 @@ export var useKeyBoardEvent = function useKeyBoardEvent(dispatch, elementRef) {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
|
-
copy: function copy() {
|
|
67
|
-
|
|
66
|
+
copy: function copy(e) {
|
|
67
|
+
var _elementRef$current2;
|
|
68
|
+
var isFromSearch = isSearchElement((_elementRef$current2 = elementRef.current) === null || _elementRef$current2 === void 0 ? void 0 : _elementRef$current2.parentElement, e.target);
|
|
69
|
+
isFromSearch ? null : dispatch(sideEffectReducer.copy);
|
|
68
70
|
},
|
|
69
|
-
paste: function paste() {
|
|
70
|
-
|
|
71
|
+
paste: function paste(e) {
|
|
72
|
+
var _elementRef$current3;
|
|
73
|
+
var isFromSearch = isSearchElement((_elementRef$current3 = elementRef.current) === null || _elementRef$current3 === void 0 ? void 0 : _elementRef$current3.parentElement, e.target);
|
|
74
|
+
isFromSearch ? null : dispatch(sideEffectReducer.paste);
|
|
71
75
|
},
|
|
72
|
-
cut: function cut() {
|
|
76
|
+
cut: function cut(e) {
|
|
77
|
+
var _elementRef$current4;
|
|
78
|
+
var isFromSearch = isSearchElement((_elementRef$current4 = elementRef.current) === null || _elementRef$current4 === void 0 ? void 0 : _elementRef$current4.parentElement, e.target);
|
|
79
|
+
if (isFromSearch) return;
|
|
73
80
|
dispatch(sideEffectReducer.copy);
|
|
74
81
|
dispatch(sideEffectReducer.delete);
|
|
75
82
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMouse } from "../..";
|
|
2
2
|
import { useCallback, useEffect, useRef } from 'react';
|
|
3
|
-
import { extractDataRowAndCol, findParentTd } from "../util";
|
|
3
|
+
import { extractDataRowAndCol, findParentTd, isSearchElement } from "../util";
|
|
4
4
|
var rowCount = 10; //每秒10行
|
|
5
5
|
var colCount = 5; //每秒5列
|
|
6
6
|
|
|
@@ -267,7 +267,8 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
|
|
|
267
267
|
}, []);
|
|
268
268
|
var loseFocus = useCallback(function (e) {
|
|
269
269
|
var _elementRef$current10, _elementRef$current11;
|
|
270
|
-
|
|
270
|
+
// todo 加一个root node
|
|
271
|
+
var isSearch = isSearchElement((_elementRef$current10 = elementRef.current) === null || _elementRef$current10 === void 0 ? void 0 : _elementRef$current10.parentElement, e.target);
|
|
271
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);
|
|
272
273
|
if (!(isTableAControl || isSearch)) {
|
|
273
274
|
dispatch({
|
package/dist/core/util.d.ts
CHANGED
|
@@ -62,3 +62,4 @@ 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 isSearchElement: (tableRootNode: HTMLDivElement, target: HTMLElement) => boolean | undefined;
|
package/dist/core/util.js
CHANGED
|
@@ -495,4 +495,8 @@ export var ensureFocus = function ensureFocus(container) {
|
|
|
495
495
|
clearInterval(focusInterval);
|
|
496
496
|
focusInterval = undefined;
|
|
497
497
|
}, 1000);
|
|
498
|
+
};
|
|
499
|
+
export var isSearchElement = function isSearchElement(tableRootNode, target) {
|
|
500
|
+
var _tableRootNode$nextSi;
|
|
501
|
+
return (_tableRootNode$nextSi = tableRootNode.nextSibling) === null || _tableRootNode$nextSi === void 0 || (_tableRootNode$nextSi = _tableRootNode$nextSi.nextSibling) === null || _tableRootNode$nextSi === void 0 ? void 0 : _tableRootNode$nextSi.contains(target);
|
|
498
502
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect } from 'react';
|
|
2
2
|
import { A_KEY, BACKSPACE_KEY, C_KEY, DELETE_KEY, DOWN_KEY, ENTER_KEY, ESCAPE_KEY, F_KEY, LEFT_KEY, RIGHT_KEY, TAB_KEY, UP_KEY, V_KEY, X_KEY, Y_KEY, Z_KEY } from "../core/config";
|
|
3
|
-
import { isInputKey } from "../core/util";
|
|
3
|
+
import { isInputKey, isSearchElement } from "../core/util";
|
|
4
4
|
var ua = window.navigator.userAgent;
|
|
5
5
|
var isIE = /MSIE|Trident/.test(ua);
|
|
6
6
|
export function move(keyCode, isShiftKey) {
|
|
@@ -38,7 +38,8 @@ export function move(keyCode, isShiftKey) {
|
|
|
38
38
|
}
|
|
39
39
|
export var useKeyBoard = function useKeyBoard(handler, listenElement) {
|
|
40
40
|
var handleKey = useCallback(function (e) {
|
|
41
|
-
|
|
41
|
+
var isFromSearch = isSearchElement(listenElement === null || listenElement === void 0 ? void 0 : listenElement.parentElement, e.target);
|
|
42
|
+
if (e.defaultPrevented || isFromSearch) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
var ctrlKey = e.ctrlKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhenliang/sheet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.75",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -85,4 +85,4 @@
|
|
|
85
85
|
"fizz.zhou@ap.jll.com"
|
|
86
86
|
],
|
|
87
87
|
"preid": "beta"
|
|
88
|
-
}
|
|
88
|
+
}
|