Socket
Socket
Sign inDemoInstall

react-hotkeys-hook

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hotkeys-hook - npm Package Compare versions

Comparing version 4.0.7 to 4.0.8

106

dist/react-hotkeys-hook.cjs.development.js

@@ -205,2 +205,11 @@ 'use strict';

function deepEqual(x, y) {
//@ts-ignore
return x && y && typeof x === 'object' && typeof y === 'object'
//@ts-ignore
? Object.keys(x).length === Object.keys(y).length && Object.keys(x).reduce(function (isEqual, key) {
return isEqual && deepEqual(x[key], y[key]);
}, true) : x === y;
}
var HotkeysContext = /*#__PURE__*/react.createContext({

@@ -226,37 +235,55 @@ hotkeys: [],

setBoundHotkeys = _useState2[1];
var isAllActive = react.useMemo(function () {
return internalActiveScopes.includes('*');
}, [internalActiveScopes]);
var enableScope = function enableScope(scope) {
if (isAllActive) {
setInternalActiveScopes([scope]);
} else {
setInternalActiveScopes(Array.from(new Set([].concat(internalActiveScopes, [scope]))));
}
};
var disableScope = function disableScope(scope) {
var scopes = internalActiveScopes.filter(function (s) {
return s !== scope;
var enableScope = react.useCallback(function (scope) {
setInternalActiveScopes(function (prev) {
if (prev.includes('*')) {
return [scope];
}
return Array.from(new Set([].concat(prev, [scope])));
});
if (scopes.length === 0) {
setInternalActiveScopes(['*']);
} else {
setInternalActiveScopes(scopes);
}
};
var toggleScope = function toggleScope(scope) {
if (internalActiveScopes.includes(scope)) {
disableScope(scope);
} else {
enableScope(scope);
}
};
var addBoundHotkey = function addBoundHotkey(hotkey) {
setBoundHotkeys([].concat(boundHotkeys, [hotkey]));
};
var removeBoundHotkey = function removeBoundHotkey(hotkey) {
setBoundHotkeys(boundHotkeys.filter(function (h) {
return h.keys !== hotkey.keys;
}));
};
}, []);
var disableScope = react.useCallback(function (scope) {
setInternalActiveScopes(function (prev) {
if (prev.filter(function (s) {
return s !== scope;
}).length === 0) {
return ['*'];
} else {
return prev.filter(function (s) {
return s !== scope;
});
}
});
}, []);
var toggleScope = react.useCallback(function (scope) {
setInternalActiveScopes(function (prev) {
if (prev.includes(scope)) {
if (prev.filter(function (s) {
return s !== scope;
}).length === 0) {
return ['*'];
} else {
return prev.filter(function (s) {
return s !== scope;
});
}
} else {
if (prev.includes('*')) {
return [scope];
}
return Array.from(new Set([].concat(prev, [scope])));
}
});
}, []);
var addBoundHotkey = react.useCallback(function (hotkey) {
setBoundHotkeys(function (prev) {
return [].concat(prev, [hotkey]);
});
}, []);
var removeBoundHotkey = react.useCallback(function (hotkey) {
setBoundHotkeys(function (prev) {
return prev.filter(function (h) {
return !deepEqual(h, hotkey);
});
});
}, []);
return /*#__PURE__*/jsxRuntime.jsx(HotkeysContext.Provider, {

@@ -278,11 +305,2 @@ value: {

function deepEqual(x, y) {
//@ts-ignore
return x && y && typeof x === 'object' && typeof y === 'object'
//@ts-ignore
? Object.keys(x).length === Object.keys(y).length && Object.keys(x).reduce(function (isEqual, key) {
return isEqual && deepEqual(x[key], y[key]);
}, true) : x === y;
}
function useDeepEqualMemo(value) {

@@ -322,3 +340,3 @@ var ref = react.useRef(undefined);

// TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE
// REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WONT TRIGGER THE HOTKEY.
// REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.
if (ref.current !== null && document.activeElement !== ref.current && !ref.current.contains(document.activeElement)) {

@@ -325,0 +343,0 @@ stopPropagation(e);

@@ -1,2 +0,2 @@

"use strict";var e=require("react"),t=require("react/jsx-runtime");function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i=["shift","alt","meta","mod"],u={esc:"escape",return:"enter",left:"arrowleft",up:"arrowup",right:"arrowright",down:"arrowdown",1:"digit1",2:"digit2",3:"digit3",4:"digit4",5:"digit5",6:"digit6",7:"digit7",8:"digit8",9:"digit9"};function a(e,t){return void 0===t&&(t=","),"string"==typeof e?e.split(t):e}function c(e,t){void 0===t&&(t="+");var r=e.toLocaleLowerCase().split(t).map((function(e){return e.trim()})).map((function(e){return u[e]||e}));return n({},{alt:r.includes("alt"),shift:r.includes("shift"),meta:r.includes("meta"),mod:r.includes("mod")},{keys:r.filter((function(e){return!i.includes(e)}))})}function l(e,t){var n=e.target;void 0===t&&(t=!1);var r=n&&n.tagName;return t instanceof Array?Boolean(r&&t&&t.some((function(e){return e.toLowerCase()===r.toLowerCase()}))):Boolean(r&&t&&!0===t)}var d=e.createContext(void 0);function s(e){return t.jsx(d.Provider,{value:{addHotkey:e.addHotkey,removeHotkey:e.removeHotkey},children:e.children})}var f=e.createContext({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),y=function(){return e.useContext(f)};function v(e,t){return e&&t&&"object"==typeof e&&"object"==typeof t?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((function(n,r){return n&&v(e[r],t[r])}),!0):e===t}var p=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},m="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,k=new Set,h=new Set;"undefined"!=typeof window&&window.addEventListener("DOMContentLoaded",(function(){document.addEventListener("keydown",(function(e){var t;void 0!==e.key&&(t=e.key,(Array.isArray(t)?t:[t]).forEach((function(e){return h.add(c(e))})))})),document.addEventListener("keyup",(function(e){var t;void 0!==e.key&&(t=e.key,(Array.isArray(t)?t:[t]).forEach((function(e){for(var t,n=c(e),r=o(h);!(t=r()).done;){var i,u=t.value;null!=(i=u.keys)&&i.every((function(e){var t;return null==(t=n.keys)?void 0:t.includes(e)}))&&h.delete(u)}})))}))})),exports.HotkeysProvider=function(n){var r=n.initiallyActiveScopes,o=void 0===r?["*"]:r,i=n.children,u=e.useState((null==o?void 0:o.length)>0?o:["*"]),a=u[0],c=u[1],l=e.useState([]),d=l[0],y=l[1],v=e.useMemo((function(){return a.includes("*")}),[a]),p=function(e){c(v?[e]:Array.from(new Set([].concat(a,[e]))))},m=function(e){var t=a.filter((function(t){return t!==e}));c(0===t.length?["*"]:t)};return t.jsx(f.Provider,{value:{enabledScopes:a,hotkeys:d,enableScope:p,disableScope:m,toggleScope:function(e){a.includes(e)?m(e):p(e)}},children:t.jsx(s,{addHotkey:function(e){y([].concat(d,[e]))},removeHotkey:function(e){y(d.filter((function(t){return t.keys!==e.keys})))},children:i})})},exports.isHotkeyPressed=function(e,t){return void 0===t&&(t=","),(Array.isArray(e)?e:e.split(t)).every((function(e){for(var t,n=c(e),r=o(h);!(t=r()).done;)if(v(n,t.value))return!0}))},exports.useHotkeys=function(t,n,r,o){var i=e.useRef(null),u=r instanceof Array?o instanceof Array?void 0:o:r,s=e.useCallback(n,[].concat(r instanceof Array?r:o instanceof Array?o:[])),f=function(t){var n=e.useRef(void 0);return v(n.current,t)||(n.current=t),n.current}(u),h=y().enabledScopes,g=e.useContext(d);return m((function(){if(!1!==(null==f?void 0:f.enabled)&&(n=null==f?void 0:f.scopes,0===(e=h).length&&n?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),1):!n||e.some((function(e){return n.includes(e)}))||e.includes("*"))){var e,n,r=function(e){var n;l(e,["input","textarea","select"])&&!l(e,null==f?void 0:f.enableOnFormTags)||(null===i.current||document.activeElement===i.current||i.current.contains(document.activeElement)?(null==(n=e.target)||!n.isContentEditable||null!=f&&f.enableOnContentEditable)&&a(t,null==f?void 0:f.splitKey).forEach((function(t){var n,r=c(t,null==f?void 0:f.combinationKey);if(function(e,t,n){var r=t.alt,o=t.meta,i=t.mod,u=t.shift,a=t.keys,c=e.altKey,l=e.ctrlKey,d=e.metaKey,s=e.shiftKey,f=e.key,y=e.code.toLowerCase().replace("key",""),v=f.toLowerCase();if(c!==r&&"alt"!==v)return!1;if(s!==u&&"shift"!==v)return!1;if(i){if(!d&&!l)return!1}else if(d!==o&&l!==o&&"meta"!==y&&"ctrl"!==y)return!1;return!(!a||1!==a.length||!a.includes(v)&&!a.includes(y))||(a?a.every((function(e){return n.has(e)})):!a)}(e,r,k)||null!=(n=r.keys)&&n.includes("*")){if(function(e,t,n){("function"==typeof n&&n(e,t)||!0===n)&&e.preventDefault()}(e,r,null==f?void 0:f.preventDefault),!function(e,t,n){return"function"==typeof n?n(e,t):!0===n||void 0===n}(e,r,null==f?void 0:f.enabled))return void p(e);s(e,r)}})):p(e))},o=function(e){void 0!==e.key&&(k.add(e.key.toLowerCase()),(void 0===(null==f?void 0:f.keydown)&&!0!==(null==f?void 0:f.keyup)||null!=f&&f.keydown)&&r(e))},u=function(e){void 0!==e.key&&("meta"!==e.key.toLowerCase()?k.delete(e.key.toLowerCase()):k.clear(),null!=f&&f.keyup&&r(e))};return(i.current||document).addEventListener("keyup",u),(i.current||document).addEventListener("keydown",o),g&&a(t,null==f?void 0:f.splitKey).forEach((function(e){return g.addHotkey(c(e,null==f?void 0:f.combinationKey))})),function(){(i.current||document).removeEventListener("keyup",u),(i.current||document).removeEventListener("keydown",o),g&&a(t,null==f?void 0:f.splitKey).forEach((function(e){return g.removeHotkey(c(e,null==f?void 0:f.combinationKey))}))}}}),[t,s,f,h]),i},exports.useHotkeysContext=y;
"use strict";var e=require("react"),t=require("react/jsx-runtime");function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function o(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i=["shift","alt","meta","mod"],u={esc:"escape",return:"enter",left:"arrowleft",up:"arrowup",right:"arrowright",down:"arrowdown",1:"digit1",2:"digit2",3:"digit3",4:"digit4",5:"digit5",6:"digit6",7:"digit7",8:"digit8",9:"digit9"};function a(e,t){return void 0===t&&(t=","),"string"==typeof e?e.split(t):e}function c(e,t){void 0===t&&(t="+");var r=e.toLocaleLowerCase().split(t).map((function(e){return e.trim()})).map((function(e){return u[e]||e}));return n({},{alt:r.includes("alt"),shift:r.includes("shift"),meta:r.includes("meta"),mod:r.includes("mod")},{keys:r.filter((function(e){return!i.includes(e)}))})}function l(e,t){var n=e.target;void 0===t&&(t=!1);var r=n&&n.tagName;return t instanceof Array?Boolean(r&&t&&t.some((function(e){return e.toLowerCase()===r.toLowerCase()}))):Boolean(r&&t&&!0===t)}var d=e.createContext(void 0);function s(e){return t.jsx(d.Provider,{value:{addHotkey:e.addHotkey,removeHotkey:e.removeHotkey},children:e.children})}function f(e,t){return e&&t&&"object"==typeof e&&"object"==typeof t?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((function(n,r){return n&&f(e[r],t[r])}),!0):e===t}var y=e.createContext({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),v=function(){return e.useContext(y)},p=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},m="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,k=new Set,b=new Set;"undefined"!=typeof window&&window.addEventListener("DOMContentLoaded",(function(){document.addEventListener("keydown",(function(e){var t;void 0!==e.key&&(t=e.key,(Array.isArray(t)?t:[t]).forEach((function(e){return b.add(c(e))})))})),document.addEventListener("keyup",(function(e){var t;void 0!==e.key&&(t=e.key,(Array.isArray(t)?t:[t]).forEach((function(e){for(var t,n=c(e),r=o(b);!(t=r()).done;){var i,u=t.value;null!=(i=u.keys)&&i.every((function(e){var t;return null==(t=n.keys)?void 0:t.includes(e)}))&&b.delete(u)}})))}))})),exports.HotkeysProvider=function(n){var r=n.initiallyActiveScopes,o=void 0===r?["*"]:r,i=n.children,u=e.useState((null==o?void 0:o.length)>0?o:["*"]),a=u[0],c=u[1],l=e.useState([]),d=l[0],v=l[1],p=e.useCallback((function(e){c((function(t){return t.includes("*")?[e]:Array.from(new Set([].concat(t,[e])))}))}),[]),m=e.useCallback((function(e){c((function(t){return 0===t.filter((function(t){return t!==e})).length?["*"]:t.filter((function(t){return t!==e}))}))}),[]),k=e.useCallback((function(e){c((function(t){return t.includes(e)?0===t.filter((function(t){return t!==e})).length?["*"]:t.filter((function(t){return t!==e})):t.includes("*")?[e]:Array.from(new Set([].concat(t,[e])))}))}),[]),b=e.useCallback((function(e){v((function(t){return[].concat(t,[e])}))}),[]),h=e.useCallback((function(e){v((function(t){return t.filter((function(t){return!f(t,e)}))}))}),[]);return t.jsx(y.Provider,{value:{enabledScopes:a,hotkeys:d,enableScope:p,disableScope:m,toggleScope:k},children:t.jsx(s,{addHotkey:b,removeHotkey:h,children:i})})},exports.isHotkeyPressed=function(e,t){return void 0===t&&(t=","),(Array.isArray(e)?e:e.split(t)).every((function(e){for(var t,n=c(e),r=o(b);!(t=r()).done;)if(f(n,t.value))return!0}))},exports.useHotkeys=function(t,n,r,o){var i=e.useRef(null),u=r instanceof Array?o instanceof Array?void 0:o:r,s=e.useCallback(n,[].concat(r instanceof Array?r:o instanceof Array?o:[])),y=function(t){var n=e.useRef(void 0);return f(n.current,t)||(n.current=t),n.current}(u),b=v().enabledScopes,h=e.useContext(d);return m((function(){if(!1!==(null==y?void 0:y.enabled)&&(n=null==y?void 0:y.scopes,0===(e=b).length&&n?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),1):!n||e.some((function(e){return n.includes(e)}))||e.includes("*"))){var e,n,r=function(e){var n;l(e,["input","textarea","select"])&&!l(e,null==y?void 0:y.enableOnFormTags)||(null===i.current||document.activeElement===i.current||i.current.contains(document.activeElement)?(null==(n=e.target)||!n.isContentEditable||null!=y&&y.enableOnContentEditable)&&a(t,null==y?void 0:y.splitKey).forEach((function(t){var n,r=c(t,null==y?void 0:y.combinationKey);if(function(e,t,n){var r=t.alt,o=t.meta,i=t.mod,u=t.shift,a=t.keys,c=e.altKey,l=e.ctrlKey,d=e.metaKey,s=e.shiftKey,f=e.key,y=e.code.toLowerCase().replace("key",""),v=f.toLowerCase();if(c!==r&&"alt"!==v)return!1;if(s!==u&&"shift"!==v)return!1;if(i){if(!d&&!l)return!1}else if(d!==o&&l!==o&&"meta"!==y&&"ctrl"!==y)return!1;return!(!a||1!==a.length||!a.includes(v)&&!a.includes(y))||(a?a.every((function(e){return n.has(e)})):!a)}(e,r,k)||null!=(n=r.keys)&&n.includes("*")){if(function(e,t,n){("function"==typeof n&&n(e,t)||!0===n)&&e.preventDefault()}(e,r,null==y?void 0:y.preventDefault),!function(e,t,n){return"function"==typeof n?n(e,t):!0===n||void 0===n}(e,r,null==y?void 0:y.enabled))return void p(e);s(e,r)}})):p(e))},o=function(e){void 0!==e.key&&(k.add(e.key.toLowerCase()),(void 0===(null==y?void 0:y.keydown)&&!0!==(null==y?void 0:y.keyup)||null!=y&&y.keydown)&&r(e))},u=function(e){void 0!==e.key&&("meta"!==e.key.toLowerCase()?k.delete(e.key.toLowerCase()):k.clear(),null!=y&&y.keyup&&r(e))};return(i.current||document).addEventListener("keyup",u),(i.current||document).addEventListener("keydown",o),h&&a(t,null==y?void 0:y.splitKey).forEach((function(e){return h.addHotkey(c(e,null==y?void 0:y.combinationKey))})),function(){(i.current||document).removeEventListener("keyup",u),(i.current||document).removeEventListener("keydown",o),h&&a(t,null==y?void 0:y.splitKey).forEach((function(e){return h.removeHotkey(c(e,null==y?void 0:y.combinationKey))}))}}}),[t,s,y,b]),i},exports.useHotkeysContext=v;
//# sourceMappingURL=react-hotkeys-hook.cjs.production.min.js.map

@@ -1,2 +0,2 @@

import { useContext, createContext, useState, useMemo, useRef, useCallback, useLayoutEffect, useEffect } from 'react';
import { useContext, createContext, useState, useCallback, useRef, useLayoutEffect, useEffect } from 'react';
import { jsx } from 'react/jsx-runtime';

@@ -203,2 +203,11 @@

function deepEqual(x, y) {
//@ts-ignore
return x && y && typeof x === 'object' && typeof y === 'object'
//@ts-ignore
? Object.keys(x).length === Object.keys(y).length && Object.keys(x).reduce(function (isEqual, key) {
return isEqual && deepEqual(x[key], y[key]);
}, true) : x === y;
}
var HotkeysContext = /*#__PURE__*/createContext({

@@ -224,37 +233,55 @@ hotkeys: [],

setBoundHotkeys = _useState2[1];
var isAllActive = useMemo(function () {
return internalActiveScopes.includes('*');
}, [internalActiveScopes]);
var enableScope = function enableScope(scope) {
if (isAllActive) {
setInternalActiveScopes([scope]);
} else {
setInternalActiveScopes(Array.from(new Set([].concat(internalActiveScopes, [scope]))));
}
};
var disableScope = function disableScope(scope) {
var scopes = internalActiveScopes.filter(function (s) {
return s !== scope;
var enableScope = useCallback(function (scope) {
setInternalActiveScopes(function (prev) {
if (prev.includes('*')) {
return [scope];
}
return Array.from(new Set([].concat(prev, [scope])));
});
if (scopes.length === 0) {
setInternalActiveScopes(['*']);
} else {
setInternalActiveScopes(scopes);
}
};
var toggleScope = function toggleScope(scope) {
if (internalActiveScopes.includes(scope)) {
disableScope(scope);
} else {
enableScope(scope);
}
};
var addBoundHotkey = function addBoundHotkey(hotkey) {
setBoundHotkeys([].concat(boundHotkeys, [hotkey]));
};
var removeBoundHotkey = function removeBoundHotkey(hotkey) {
setBoundHotkeys(boundHotkeys.filter(function (h) {
return h.keys !== hotkey.keys;
}));
};
}, []);
var disableScope = useCallback(function (scope) {
setInternalActiveScopes(function (prev) {
if (prev.filter(function (s) {
return s !== scope;
}).length === 0) {
return ['*'];
} else {
return prev.filter(function (s) {
return s !== scope;
});
}
});
}, []);
var toggleScope = useCallback(function (scope) {
setInternalActiveScopes(function (prev) {
if (prev.includes(scope)) {
if (prev.filter(function (s) {
return s !== scope;
}).length === 0) {
return ['*'];
} else {
return prev.filter(function (s) {
return s !== scope;
});
}
} else {
if (prev.includes('*')) {
return [scope];
}
return Array.from(new Set([].concat(prev, [scope])));
}
});
}, []);
var addBoundHotkey = useCallback(function (hotkey) {
setBoundHotkeys(function (prev) {
return [].concat(prev, [hotkey]);
});
}, []);
var removeBoundHotkey = useCallback(function (hotkey) {
setBoundHotkeys(function (prev) {
return prev.filter(function (h) {
return !deepEqual(h, hotkey);
});
});
}, []);
return /*#__PURE__*/jsx(HotkeysContext.Provider, {

@@ -276,11 +303,2 @@ value: {

function deepEqual(x, y) {
//@ts-ignore
return x && y && typeof x === 'object' && typeof y === 'object'
//@ts-ignore
? Object.keys(x).length === Object.keys(y).length && Object.keys(x).reduce(function (isEqual, key) {
return isEqual && deepEqual(x[key], y[key]);
}, true) : x === y;
}
function useDeepEqualMemo(value) {

@@ -320,3 +338,3 @@ var ref = useRef(undefined);

// TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE
// REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WONT TRIGGER THE HOTKEY.
// REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.
if (ref.current !== null && document.activeElement !== ref.current && !ref.current.contains(document.activeElement)) {

@@ -323,0 +341,0 @@ stopPropagation(e);

{
"name": "react-hotkeys-hook",
"version": "4.0.7",
"version": "4.0.8",
"repository": "https://JohannesKlauss@github.com/JohannesKlauss/react-keymap-hook.git",

@@ -5,0 +5,0 @@ "homepage": "https://johannesklauss.github.io/react-hotkeys-hook/",

@@ -54,3 +54,3 @@ import { HotkeyCallback, Keys, Options, OptionsOrDependencyArray, RefType } from './types'

// TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE
// REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WONT TRIGGER THE HOTKEY.
// REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.
if (ref.current !== null && document.activeElement !== ref.current && !ref.current.contains(document.activeElement)) {

@@ -57,0 +57,0 @@ stopPropagation(e)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc