Comparing version 3.1.12 to 3.1.13
@@ -11,4 +11,5 @@ import type { BasicTarget } from '../utils/domTarget'; | ||
target?: Target; | ||
exactMatch?: boolean; | ||
}; | ||
declare function useKeyPress(keyFilter: KeyFilter, eventHandler: EventHandler, option?: Options): void; | ||
export default useKeyPress; |
@@ -158,3 +158,3 @@ var __values = this && this.__values || function (o) { | ||
function genFilterKey(event, keyFilter) { | ||
function genFilterKey(event, keyFilter, exactMatch) { | ||
var e_1, _a; // 浏览器自动补全 input 的时候,会触发 keyDown、keyUp 事件,但此时 event.key 等为空 | ||
@@ -207,3 +207,7 @@ | ||
return genLen === genArr.length && countKeyByEvent(event) === genArr.length; | ||
if (exactMatch) { | ||
return genLen === genArr.length && countKeyByEvent(event) === genArr.length; | ||
} | ||
return genLen === genArr.length; | ||
} | ||
@@ -217,3 +221,3 @@ /** | ||
function genKeyFormater(keyFilter) { | ||
function genKeyFormater(keyFilter, exactMatch) { | ||
if (typeof keyFilter === 'function') { | ||
@@ -225,3 +229,3 @@ return keyFilter; | ||
return function (event) { | ||
return genFilterKey(event, keyFilter); | ||
return genFilterKey(event, keyFilter, exactMatch); | ||
}; | ||
@@ -233,3 +237,3 @@ } | ||
return keyFilter.some(function (item) { | ||
return genFilterKey(event, item); | ||
return genFilterKey(event, item, exactMatch); | ||
}); | ||
@@ -252,3 +256,5 @@ }; | ||
events = _b === void 0 ? defaultEvents : _b, | ||
target = _a.target; | ||
target = _a.target, | ||
_c = _a.exactMatch, | ||
exactMatch = _c === void 0 ? false : _c; | ||
@@ -271,3 +277,3 @@ var eventHandlerRef = useLatest(eventHandler); | ||
var genGuard = genKeyFormater(keyFilterRef.current); | ||
var genGuard = genKeyFormater(keyFilterRef.current, exactMatch); | ||
@@ -274,0 +280,0 @@ if (genGuard(event)) { |
@@ -11,4 +11,5 @@ import type { BasicTarget } from '../utils/domTarget'; | ||
target?: Target; | ||
exactMatch?: boolean; | ||
}; | ||
declare function useKeyPress(keyFilter: KeyFilter, eventHandler: EventHandler, option?: Options): void; | ||
export default useKeyPress; |
@@ -173,3 +173,3 @@ "use strict"; | ||
function genFilterKey(event, keyFilter) { | ||
function genFilterKey(event, keyFilter, exactMatch) { | ||
var e_1, _a; // 浏览器自动补全 input 的时候,会触发 keyDown、keyUp 事件,但此时 event.key 等为空 | ||
@@ -222,3 +222,7 @@ | ||
return genLen === genArr.length && countKeyByEvent(event) === genArr.length; | ||
if (exactMatch) { | ||
return genLen === genArr.length && countKeyByEvent(event) === genArr.length; | ||
} | ||
return genLen === genArr.length; | ||
} | ||
@@ -232,3 +236,3 @@ /** | ||
function genKeyFormater(keyFilter) { | ||
function genKeyFormater(keyFilter, exactMatch) { | ||
if (typeof keyFilter === 'function') { | ||
@@ -240,3 +244,3 @@ return keyFilter; | ||
return function (event) { | ||
return genFilterKey(event, keyFilter); | ||
return genFilterKey(event, keyFilter, exactMatch); | ||
}; | ||
@@ -248,3 +252,3 @@ } | ||
return keyFilter.some(function (item) { | ||
return genFilterKey(event, item); | ||
return genFilterKey(event, item, exactMatch); | ||
}); | ||
@@ -267,3 +271,5 @@ }; | ||
events = _b === void 0 ? defaultEvents : _b, | ||
target = _a.target; | ||
target = _a.target, | ||
_c = _a.exactMatch, | ||
exactMatch = _c === void 0 ? false : _c; | ||
@@ -286,3 +292,3 @@ var eventHandlerRef = useLatest_1["default"](eventHandler); | ||
var genGuard = genKeyFormater(keyFilterRef.current); | ||
var genGuard = genKeyFormater(keyFilterRef.current, exactMatch); | ||
@@ -289,0 +295,0 @@ if (genGuard(event)) { |
{ | ||
"name": "ahooks", | ||
"version": "3.1.12", | ||
"version": "3.1.13", | ||
"description": "react hooks library", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"gitHead": "6d5bda4efbef756056511d23ddc2bcb0327344c3" | ||
"gitHead": "fda70978a7e69c7851ea45e0cb52ce4055f531c4" | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
634799
15750