react-hotkeys-hook 3.4.4 → 3.4.5

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.
package/README.md CHANGED
@@ -1,6 +1,59 @@
1
- # react-hotkeys-hook
2
- React hook for using keyboard shortcuts in components.
3
- This is a hook version for the [hotkeys] package.
1
+ <hr>
2
+ <div align="center">
3
+ <h1 align="center">
4
+ useHotkeys(key, handler)
5
+ </h1>
6
+ </div>
7
+
8
+ <p align="center">
9
+ <a href="https://bundlephobia.com/result?p=react-hotkeys-hook">
10
+ <img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/react-hotkeys-hook?style=for-the-badge&labelColor=24292e">
11
+ </a>
12
+ <a aria-label="Types" href="https://www.npmjs.com/package/react-hotkeys-hook">
13
+ <img alt="Types" src="https://img.shields.io/npm/types/react-use-system-color-mode?style=for-the-badge&labelColor=24292e">
14
+ </a>
15
+ <a aria-label="NPM version" href="https://www.npmjs.com/package/react-hotkeys-hook">
16
+ <img alt="NPM Version" src="https://img.shields.io/npm/v/react-hotkeys-hook?style=for-the-badge&labelColor=24292e">
17
+ </a>
18
+ <a aria-label="License" href="https://jaredlunde.mit-license.org/">
19
+ <img alt="MIT License" src="https://img.shields.io/npm/l/react-hotkeys-hook?style=for-the-badge&labelColor=24292e">
20
+ </a>
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a aria-label="Sponsored by Spaceteams" href="https://spaceteams.de">
25
+ <img alt="Sponsored by Spaceteams" src="https://raw.githubusercontent.com/spaceteams/badges/main/sponsored-by-spaceteams.svg">
26
+ </a>
27
+ </p>
28
+
29
+ <pre align="center">npm i react-hotkeys-hook</pre>
30
+
31
+ <p align="center">
32
+ A React hook for using keyboard shortcuts in components.
33
+ </p>
34
+
35
+ <hr>
36
+
37
+ ## Quick Start
38
+
39
+ ```jsx harmony
40
+ import { useHotkeys } from 'react-use-hotkeys-hook'
41
+
42
+ export const ExampleComponent = () => {
43
+ const [count, setCount] = useState(0)
44
+ useHotkeys('ctrl+k', () => setCount(prevCount => prevCount + 1))
45
+
46
+ return (
47
+ <p>
48
+ Pressed {count} times.
49
+ </p>
50
+ )
51
+ }
52
+ ```
53
+
54
+ The hook takes care of all the binding and unbinding for you.
55
+ As soon as the component mounts into the DOM, the key stroke will be
56
+ listened to. When the component unmounts it will stop listening.
4
57
 
5
58
  ## Documentation & Live Examples
6
59
 
@@ -13,39 +66,9 @@ This is a hook version for the [hotkeys] package.
13
66
  If you use this package please share your thoughts on how we can improve this hook with version 4.
14
67
  Please engage at the corresponding [Github issue](https://github.com/JohannesKlauss/react-hotkeys-hook/issues/574).
15
68
 
16
- ## Installation
17
-
18
- ```shell
19
- npm install react-hotkeys-hook
20
- ```
21
-
22
- or
69
+ ## API
23
70
 
24
- ```shell
25
- yarn add react-hotkeys-hook
26
- ```
27
-
28
- Make sure that you have at least version 16.8 of `react` and `react-dom` installed, or otherwise hooks won't work for you.
29
-
30
- ## Usage
31
- ```js
32
- export const ExampleComponent = () => {
33
- const [count, setCount] = useState(0);
34
- useHotkeys('ctrl+k', () => setCount(prevCount => prevCount + 1));
35
-
36
- return (
37
- <p>
38
- Pressed {count} times.
39
- </p>
40
- );
41
- };
42
- ```
43
-
44
- The hook takes care of all the binding and unbinding for you.
45
- As soon as the component mounts into the DOM, the key stroke will be
46
- listened to. When the component unmounts it will stop listening.
47
-
48
- ### Call Signature
71
+ ### useHotkeys()
49
72
 
50
73
  ```typescript
51
74
  useHotkeys(keys: string, callback: (event: KeyboardEvent, handler: HotkeysEvent) => void, options: Options = {}, deps: any[] = [])
@@ -53,11 +76,11 @@ useHotkeys(keys: string, callback: (event: KeyboardEvent, handler: HotkeysEvent)
53
76
 
54
77
  ### Parameters
55
78
  - `keys: string`: Here you can set the key strokes you want the hook to listen to. You can use single or multiple keys,
56
- modifier combination, etc. See [this](https://github.com/jaywcjlove/hotkeys/#defining-shortcuts)
57
- section on the hotkeys documentation for more info.
79
+ modifier combination, etc. See [this](https://github.com/jaywcjlove/hotkeys/#defining-shortcuts)
80
+ section on the hotkeys documentation for more info.
58
81
  - `callback: (event: KeyboardEvent, handler: HotkeysEvent) => void`: Gets executed when the defined keystroke
59
- gets hit by the user. **Important:** Since version 1.5.0 this callback gets memoised inside the hook. So you don't have
60
- to do this anymore by yourself.
82
+ gets hit by the user. **Important:** Since version 1.5.0 this callback gets memoised inside the hook. So you don't have
83
+ to do this anymore by yourself.
61
84
  - `options: Options = {}`
62
85
  - `filter: (event: KeyboardEvent): boolean` is used to filter if a callback gets triggered depending on the keyboard event.
63
86
  **Breaking Change in `3.0.0`!** Prior to version `3.0.0` the filter settings was one global setting that applied to every
@@ -70,20 +93,20 @@ to do this anymore by yourself.
70
93
  - `keydown: boolean` Determine if want to listen on the keydown event
71
94
  - `enabled: boolean` is used to prevent installation of the hotkey when set to false (default value: `true`)
72
95
  - `deps: any[] = []`: The dependency array that gets appended to the memoisation of the callback. Here you define the inner
73
- dependencies of your callback. If for example your callback actions depend on a referentially unstable value or a value
74
- that will change over time, you should add this value to your deps array. Since most of the time your callback won't
75
- depend on any unstable callbacks or changing values over time you can leave this value alone since it will be set to an
76
- empty array by default. See the [Memoisation](#memoisation) section to
77
- learn more and see an example where you have to set this array.
96
+ dependencies of your callback. If for example your callback actions depend on a referentially unstable value or a value
97
+ that will change over time, you should add this value to your deps array. Since most of the time your callback won't
98
+ depend on any unstable callbacks or changing values over time you can leave this value alone since it will be set to an
99
+ empty array by default. See the [Memoisation](#memoisation) section to
100
+ learn more and see an example where you have to set this array.
78
101
 
79
102
  ### `isHotkeyPressed` function
80
103
 
81
104
  This function allows us to check if the user is currently pressing down a key.
82
105
 
83
106
  ```ts
84
- import { isHotkeyPressed } from 'react-hotkeys-hook';
107
+ import { isHotkeyPressed } from 'react-hotkeys-hook'
85
108
 
86
- isHotkeyPressed('return'); // Returns true if Return key is pressed down.
109
+ isHotkeyPressed('return') // Returns true if Return key is pressed down.
87
110
  ```
88
111
 
89
112
  ## Support
@@ -91,10 +114,6 @@ isHotkeyPressed('return'); // Returns true if Return key is pressed down.
91
114
  * Ask your question in the [Github Discussions]([Support](https://github.com/JohannesKlauss/react-hotkeys-hook/discussions))
92
115
  * Ask your question on [StackOverflow](https://stackoverflow.com/search?page=1&tab=Relevance&q=react-hotkeys-hook)
93
116
 
94
- If you'd like to support me, please buy me a ko-fi:
95
-
96
- [![alt text](https://ucbab0164bf5c81e2a9872c53fa1.previews.dropboxusercontent.com/p/thumb/ABTE4xGDxskgsqIuOARP8_ePPukYVVLKu8I7pKjNIf9u7aJmZcTeCXXCVyQsHkviVu_5aHZWlDRVoxO_o6gEDyTngS6wyWdoRdFqzANOEgUGj5ZcREIMy33x6DKDJkg1CORDq74mJPPBmkUnIph9OKWswrc2zY3sKeNBbBbbE2Xadfy78mWAQCtRXuvwrwV-mDjxsvxrcOZo73i-9J1u2p2QYjeP7jGPCqNnuavI-18SF65Kq6KFBEyhJQ1WtqJzmEWT92alq24aQlizVSt9w10_ouccdemRwhPaSLaFvyAETrFo9gGQe21ocMjTzT9tTb7ctWZBkIi6zVvy8EKfKsTE8nB7O3tbNd2_uQrVnd-kLg/p.png?fv_content=true&size_mode=5 "Buy me a Ko-Fi")](https://ko-fi.com/thegoodcode#checkoutModal)
97
-
98
117
  ## Found an issue or have a feature request?
99
118
 
100
119
  Open up an [issue](https://github.com/JohannesKlauss/react-hotkeys-hook/issues/new)
@@ -104,9 +123,23 @@ or [pull request](https://github.com/JohannesKlauss/react-hotkeys-hook/compare)
104
123
 
105
124
  Checkout this repo, run `yarn` or `npm i` and then run the `test` script to test the behavior of the hook.
106
125
 
107
- ## Authors
126
+ ## Contributing
127
+ Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
128
+
129
+ 1. Fork the Project
130
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
131
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
132
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
133
+ 5. Open a Pull Request
134
+
135
+ ## License
136
+ Distributed under the MIT License. See `LICENSE` for more information.
137
+
138
+ ## Contact
139
+
140
+ Johannes Klauss - [@JohannesKlauss](https://github.com/JohannesKlauss) - klauss.johannes@gmail.com
108
141
 
109
- * Johannes Klauss
142
+ Project Link: [https://github.com/JohannesKlauss/react-hotkeys-hook](https://github.com/JohannesKlauss/react-use-system-color-mode)
110
143
 
111
144
  ## Contributors
112
145
 
@@ -118,11 +151,3 @@ Checkout this repo, run `yarn` or `npm i` and then run the `test` script to test
118
151
  * [godspeedelbow](https://github.com/godspeedelbow)
119
152
  * [JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)
120
153
  * [ggascoigne](https://github.com/ggascoigne)
121
-
122
- ---
123
-
124
- MIT License.
125
-
126
- ---
127
-
128
- [hotkeys]: https://github.com/jaywcjlove/hotkeys
@@ -0,0 +1,16 @@
1
+ import { Hotkey } from './types';
2
+ import { ReactNode } from 'react';
3
+ declare type HotkeysContextType = {
4
+ hotkeys: Hotkey[];
5
+ activeScopes: string[];
6
+ toggleScope: (scope: string) => void;
7
+ activateScope: (scope: string) => void;
8
+ deactivateScope: (scope: string) => void;
9
+ };
10
+ interface Props {
11
+ initialActiveScopes?: string[];
12
+ children: ReactNode;
13
+ }
14
+ export declare const useHotkeysContext: () => HotkeysContextType;
15
+ export declare const HotkeysProvider: ({ initialActiveScopes, children }: Props) => JSX.Element;
16
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import { useIsHotkeyPressed } from './useIsHotkeyPressed';
2
- import { useHotkeys, Options } from './useHotkeys';
3
- declare const isHotkeyPressed: {
4
- (keyCode: number): boolean;
5
- (keyCode: string): boolean;
6
- };
7
- export { useHotkeys, useIsHotkeyPressed, isHotkeyPressed, Options };
1
+ import useHotkeys from './useHotkeys';
2
+ import type { Options } from './types';
3
+ import { HotkeysProvider, useHotkeysContext } from './HotkeysProvider';
4
+ export { useHotkeys, useHotkeysContext, HotkeysProvider, Options, };
package/dist/index.js CHANGED
@@ -1,8 +1,2 @@
1
-
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./react-hotkeys-hook.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./react-hotkeys-hook.cjs.development.js')
8
- }
1
+ import{useCallback as R,useLayoutEffect as N,useRef as S}from"react";var A=["ctrl","shift","alt","meta","mod"];function H(t,o=","){return typeof t=="string"?t.split(o):t}function b(t,o="+"){let e=t.toLocaleLowerCase().split(o).map(a=>a.trim()),i={alt:e.includes("alt"),ctrl:e.includes("ctrl"),shift:e.includes("shift"),meta:e.includes("meta"),mod:e.includes("mod")},c=e.filter(a=>!A.includes(a));return{...i,keys:c}}function E(t,o,e){(typeof e=="function"&&e(t,o)||e===!0)&&t.preventDefault()}function K(t,o,e){return typeof e=="function"?e(t,o):e===!0||e===void 0}function h(t){return g(t,["INPUT","TEXTAREA","SELECT"])}function g({target:t},o){let e=t&&t.tagName;return Boolean(e&&o&&o.includes(e))}function T(t,o){return t.length===0&&o?(console.warn("A hotkey has a set scopes options, although no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>"),!0):o?t.some(e=>o.includes(e))||t.includes("*"):!0}var x=(t,o,e)=>{let{alt:i,ctrl:c,meta:a,mod:r,shift:d,keys:n}=o,{altKey:l,ctrlKey:u,metaKey:f,shiftKey:p,key:s,code:m}=t,y=m.toLowerCase().replace("key",""),k=s.toLowerCase();if(l!==i&&k!=="alt"||p!==d&&k!=="shift")return!1;if(r){if(!f&&!u)return!1}else if(f!==a&&y!=="meta"||u!==c&&y!=="ctrl")return!1;return n&&n.length===1&&(n.includes(k)||n.includes(y))?!0:n?n.every(L=>e.has(L)):!n};import{createContext as O,useMemo as M,useState as P,useContext as D}from"react";var C=O(void 0),v=()=>{let t=D(C);return t===void 0?{hotkeys:[],activeScopes:[],toggleScope:()=>{},activateScope:()=>{},deactivateScope:()=>{}}:t},I=({initialActiveScopes:t=["*"],children:o})=>{let[e,i]=P(t?.length>0?t:["*"]),c=M(()=>e.includes("*"),[e]),a=n=>{i(c?[n]:[...e,n])},r=n=>{let l=e.filter(u=>u!==n);l.length===0?i(["*"]):i(l)},d=n=>{e.includes(n)?r(n):a(n)};return React.createElement(C.Provider,{value:{activeScopes:e,hotkeys:[],activateScope:a,deactivateScope:r,toggleScope:d}},o)};function w(t,o,e,i){let c=S(null),{current:a}=S(new Set),r=e instanceof Array?i instanceof Array?void 0:i:e,d=e instanceof Array?e:i instanceof Array?i:[],n=R(o,[...d]),l=v();return N(()=>{if(r?.enabled===!1||!T(l.activeScopes,r?.scopes))return;let u=s=>{h(s)&&!g(s,r?.enableOnTags)||c.current!==null&&document.activeElement!==c.current||(console.log("isContentEditable",s.target?.isContentEditable),!(s.target?.isContentEditable&&!r?.enableOnContentEditable)&&H(t,r?.splitKey).forEach(m=>{let y=b(m,r?.combinationKey);if(x(s,y,a)||y.keys?.includes("*")){if(E(s,y,r?.preventDefault),!K(s,y,r?.enabled))return;n(s,y)}}))},f=s=>{a.add(s.key.toLowerCase()),(r?.keydown===void 0&&r?.keyup!==!0||r?.keydown)&&u(s)},p=s=>{r?.keyup&&u(s),a.delete(s.key.toLowerCase())};return document.addEventListener("keyup",p),document.addEventListener("keydown",f),()=>{document.removeEventListener("keyup",p),document.removeEventListener("keydown",f)}},[t,n,r]),c}export{I as HotkeysProvider,w as useHotkeys,v as useHotkeysContext};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/useHotkeys.ts", "../src/parseHotkeys.ts", "../src/validators.ts", "../src/HotkeysProvider.tsx"],
4
+ "sourcesContent": ["import { HotkeyCallback, Keys, OptionsOrDependencyArray, RefType } from './types'\nimport { useCallback, useLayoutEffect, useRef } from 'react'\nimport { parseHotkey, parseKeysHookInput } from './parseHotkeys'\nimport {\n isHotkeyEnabled,\n isHotkeyEnabledOnTag,\n isHotkeyMatchingKeyboardEvent,\n isKeyboardEventTriggeredByInput,\n isScopeActive,\n maybePreventDefault,\n} from './validators'\nimport { useHotkeysContext } from './HotkeysProvider'\n\nexport default function useHotkeys<T extends HTMLElement>(\n keys: Keys,\n callback: HotkeyCallback,\n options?: OptionsOrDependencyArray,\n dependencies?: OptionsOrDependencyArray\n) {\n const ref = useRef<RefType<T>>(null)\n const { current: pressedDownKeys } = useRef<Set<string>>(new Set())\n\n const _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined\n const _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : []\n\n const cb = useCallback(callback, [..._deps])\n const ctx = useHotkeysContext()\n\n useLayoutEffect(() => {\n if (_options?.enabled === false || !isScopeActive(ctx.activeScopes, _options?.scopes)) {\n return\n }\n\n const listener = (e: KeyboardEvent) => {\n if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, _options?.enableOnTags)) {\n return\n }\n\n if (ref.current !== null && document.activeElement !== ref.current) {\n return\n }\n\n console.log('isContentEditable', ((e.target as HTMLElement)?.isContentEditable))\n\n if (((e.target as HTMLElement)?.isContentEditable && !_options?.enableOnContentEditable)) {\n return\n }\n\n parseKeysHookInput(keys, _options?.splitKey).forEach((key) => {\n const hotkey = parseHotkey(key, _options?.combinationKey)\n\n if (isHotkeyMatchingKeyboardEvent(e, hotkey, pressedDownKeys) || hotkey.keys?.includes('*')) {\n maybePreventDefault(e, hotkey, _options?.preventDefault)\n\n if (!isHotkeyEnabled(e, hotkey, _options?.enabled)) {\n return\n }\n\n cb(e, hotkey)\n }\n })\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n pressedDownKeys.add(event.key.toLowerCase())\n\n if ((_options?.keydown === undefined && _options?.keyup !== true) || _options?.keydown) {\n listener(event)\n }\n }\n\n const handleKeyUp = (event: KeyboardEvent) => {\n if (_options?.keyup) {\n listener(event)\n }\n\n pressedDownKeys.delete(event.key.toLowerCase())\n }\n\n document.addEventListener('keyup', handleKeyUp)\n document.addEventListener('keydown', handleKeyDown)\n\n return () => {\n document.removeEventListener('keyup', handleKeyUp)\n document.removeEventListener('keydown', handleKeyDown)\n }\n }, [keys, cb, _options])\n\n return ref\n}\n", "import { Hotkey, KeyboardModifiers, Keys } from './types'\n\nconst reservedModifierKeywords = ['ctrl', 'shift', 'alt', 'meta', 'mod']\n\nexport function parseKeysHookInput(keys: Keys, splitKey: string = ','): string[] {\n if (typeof keys === 'string') {\n return keys.split(splitKey)\n }\n\n return keys\n}\n\nexport function parseHotkey(hotkey: string, combinationKey: string = '+'): Hotkey {\n const keys = hotkey\n .toLocaleLowerCase()\n .split(combinationKey)\n .map((k) => k.trim())\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl'),\n shift: keys.includes('shift'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n }\n\n const singleCharKeys = keys.filter((k) => !reservedModifierKeywords.includes(k))\n\n return {\n ...modifiers,\n keys: singleCharKeys,\n }\n}\n", "import { FormTags, Hotkey, Scopes, Trigger } from './types'\n\nexport function maybePreventDefault(e: KeyboardEvent, hotkey: Hotkey, preventDefault?: Trigger): void {\n if ((typeof preventDefault === 'function' && preventDefault(e, hotkey)) || preventDefault === true) {\n e.preventDefault()\n }\n}\n\nexport function isHotkeyEnabled(e: KeyboardEvent, hotkey: Hotkey, enabled?: Trigger): boolean {\n if (typeof enabled === 'function') {\n return enabled(e, hotkey)\n }\n\n return enabled === true || enabled === undefined\n}\n\nexport function isKeyboardEventTriggeredByInput(ev: KeyboardEvent): boolean {\n return isHotkeyEnabledOnTag(ev, ['INPUT', 'TEXTAREA', 'SELECT'])\n}\n\nexport function isHotkeyEnabledOnTag({ target }: KeyboardEvent, enabledOnTags?: FormTags[]): boolean {\n const targetTagName = target && (target as HTMLElement).tagName\n\n return Boolean(targetTagName && enabledOnTags && enabledOnTags.includes(targetTagName as FormTags))\n}\n\nexport function isScopeActive(activeScopes: string[], scopes?: Scopes): boolean {\n if (activeScopes.length === 0 && scopes) {\n console.warn(\n 'A hotkey has a set scopes options, although no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'\n )\n\n return true\n }\n\n if (!scopes) {\n return true\n }\n\n return activeScopes.some(scope => scopes.includes(scope)) || activeScopes.includes('*')\n}\n\nexport const isHotkeyMatchingKeyboardEvent = (e: KeyboardEvent, hotkey: Hotkey, pressedDownKeys: Set<string>): boolean => {\n const { alt, ctrl, meta, mod, shift, keys } = hotkey\n const { altKey, ctrlKey, metaKey, shiftKey, key: pressedKeyUppercase, code } = e\n\n const keyCode = code.toLowerCase().replace('key', '')\n const pressedKey = pressedKeyUppercase.toLowerCase()\n\n if (altKey !== alt && pressedKey !== 'alt') {\n return false\n }\n\n if (shiftKey !== shift && pressedKey !== 'shift') {\n return false\n }\n\n // Mod is a special key name that is checking for meta on macOS and ctrl on other platforms\n if (mod) {\n if (!metaKey && !ctrlKey) {\n return false\n }\n } else {\n if (metaKey !== meta && keyCode !== 'meta') {\n return false\n }\n\n if (ctrlKey !== ctrl && keyCode !== 'ctrl') {\n return false\n }\n }\n\n // All modifiers are correct, now check the key\n // If the key is set we check for the key\n if (keys && keys.length === 1 && (keys.includes(pressedKey) || keys.includes(keyCode))) {\n return true\n } else if (keys) {\n // Check if all keys are present in pressedDownKeys set\n return keys.every(key => pressedDownKeys.has(key))\n }\n else if (!keys) {\n // If the key is not set, we only listen for modifiers, that check went alright, so we return true\n return true\n }\n\n // There is nothing that matches.\n return false\n}\n", "import { Hotkey } from './types'\nimport { createContext, ReactNode, useMemo, useState, useContext } from 'react'\n\ntype HotkeysContextType = {\n hotkeys: Hotkey[]\n activeScopes: string[]\n toggleScope: (scope: string) => void\n activateScope: (scope: string) => void\n deactivateScope: (scope: string) => void\n}\n\nconst HotkeysContext = createContext<HotkeysContextType | undefined>(undefined)\n\ninterface Props {\n initialActiveScopes?: string[]\n children: ReactNode\n}\n\nexport const useHotkeysContext = () => {\n const context = useContext(HotkeysContext)\n\n // The context is only needed for special features like global scoping, so we don't throw an error if it's not defined\n if (context === undefined) {\n return {\n hotkeys: [],\n activeScopes: [],\n toggleScope: () => {},\n activateScope: () => {},\n deactivateScope: () => {},\n }\n }\n\n return context\n}\n\nexport const HotkeysProvider = ({initialActiveScopes = ['*'], children}: Props) => {\n const [activeScopes, setActiveScopes] = useState(initialActiveScopes?.length > 0 ? initialActiveScopes : ['*'])\n\n const isAllActive = useMemo(() => activeScopes.includes('*'), [activeScopes])\n\n const activateScope = (scope: string) => {\n if (isAllActive) {\n setActiveScopes([scope])\n } else {\n setActiveScopes([...activeScopes, scope])\n }\n }\n\n const deactivateScope = (scope: string) => {\n const scopes = activeScopes.filter(s => s !== scope)\n\n if (scopes.length === 0) {\n setActiveScopes(['*'])\n } else {\n setActiveScopes(scopes)\n }\n }\n\n const toggleScope = (scope: string) => {\n if (activeScopes.includes(scope)) {\n deactivateScope(scope)\n } else {\n activateScope(scope)\n }\n }\n\n return (\n <HotkeysContext.Provider value={{activeScopes, hotkeys: [], activateScope, deactivateScope, toggleScope}}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n"],
5
+ "mappings": "AACA,qECCA,GAAM,GAA2B,CAAC,OAAQ,QAAS,MAAO,OAAQ,OAE3D,WAA4B,EAAY,EAAmB,IAAe,CAC/E,MAAI,OAAO,IAAS,SACX,EAAK,MAAM,GAGb,EAGF,WAAqB,EAAgB,EAAyB,IAAa,CAChF,GAAM,GAAO,EACV,oBACA,MAAM,GACN,IAAI,AAAC,GAAM,EAAE,QAEV,EAA+B,CACnC,IAAK,EAAK,SAAS,OACnB,KAAM,EAAK,SAAS,QACpB,MAAO,EAAK,SAAS,SACrB,KAAM,EAAK,SAAS,QACpB,IAAK,EAAK,SAAS,QAGf,EAAiB,EAAK,OAAO,AAAC,GAAM,CAAC,EAAyB,SAAS,IAE7E,MAAO,IACF,EACH,KAAM,GC5BH,WAA6B,EAAkB,EAAgB,EAAgC,CACpG,AAAK,OAAO,IAAmB,YAAc,EAA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CAG3F,GAFA,EAAoB,EAAG,EAAQ,GAAU,gBAErC,CAAC,EAAgB,EAAG,EAAQ,GAAU,SACxC,OAGF,EAAG,EAAG,QAKN,EAAgB,AAAC,GAAyB,CAC9C,EAAgB,IAAI,EAAM,IAAI,eAEzB,IAAU,UAAY,QAAa,GAAU,QAAU,IAAS,GAAU,UAC7E,EAAS,IAIP,EAAc,AAAC,GAAyB,CAC5C,AAAI,GAAU,OACZ,EAAS,GAGX,EAAgB,OAAO,EAAM,IAAI,gBAGnC,gBAAS,iBAAiB,QAAS,GACnC,SAAS,iBAAiB,UAAW,GAE9B,IAAM,CACX,SAAS,oBAAoB,QAAS,GACtC,SAAS,oBAAoB,UAAW,KAEzC,CAAC,EAAM,EAAI,IAEP",
6
+ "names": []
7
+ }
@@ -0,0 +1,3 @@
1
+ import { Hotkey, Keys } from './types';
2
+ export declare function parseKeysHookInput(keys: Keys, splitKey?: string): string[];
3
+ export declare function parseHotkey(hotkey: string, combinationKey?: string): Hotkey;
@@ -0,0 +1,32 @@
1
+ import type { DependencyList } from 'react';
2
+ export declare type FormTags = 'INPUT' | 'TEXTAREA' | 'SELECT';
3
+ export declare type Keys = string | string[];
4
+ export declare type Scopes = string | string[];
5
+ export declare type RefType<T> = T | null;
6
+ export declare type KeyboardModifiers = {
7
+ alt?: boolean;
8
+ ctrl?: boolean;
9
+ meta?: boolean;
10
+ shift?: boolean;
11
+ mod?: boolean;
12
+ };
13
+ export declare type Hotkey = KeyboardModifiers & {
14
+ keys?: string[];
15
+ scopes?: Scopes;
16
+ };
17
+ export declare type HotkeysEvent = Hotkey & {};
18
+ export declare type HotkeyCallback = (keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent) => void;
19
+ export declare type Trigger = boolean | ((keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent) => boolean);
20
+ export declare type Options = {
21
+ enabled?: Trigger;
22
+ enableOnTags?: FormTags[];
23
+ enableOnContentEditable?: boolean;
24
+ combinationKey?: string;
25
+ splitKey?: string;
26
+ scopes?: Scopes;
27
+ keyup?: boolean;
28
+ keydown?: boolean;
29
+ preventDefault?: Trigger;
30
+ description?: string;
31
+ };
32
+ export declare type OptionsOrDependencyArray = Options | DependencyList;
@@ -1,18 +1,2 @@
1
- import hotkeys, { KeyHandler } from 'hotkeys-js';
2
- import React from 'react';
3
- declare type AvailableTags = 'INPUT' | 'TEXTAREA' | 'SELECT';
4
- export declare type Options = {
5
- enabled?: boolean;
6
- filter?: typeof hotkeys.filter;
7
- filterPreventDefault?: boolean;
8
- enableOnTags?: AvailableTags[];
9
- enableOnContentEditable?: boolean;
10
- splitKey?: string;
11
- scope?: string;
12
- keyup?: boolean;
13
- keydown?: boolean;
14
- };
15
- export declare function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options): React.MutableRefObject<T | null>;
16
- export declare function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, deps?: any[]): React.MutableRefObject<T | null>;
17
- export declare function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options, deps?: any[]): React.MutableRefObject<T | null>;
18
- export {};
1
+ import { HotkeyCallback, Keys, OptionsOrDependencyArray, RefType } from './types';
2
+ export default function useHotkeys<T extends HTMLElement>(keys: Keys, callback: HotkeyCallback, options?: OptionsOrDependencyArray, dependencies?: OptionsOrDependencyArray): import("react").MutableRefObject<RefType<T>>;
@@ -0,0 +1,7 @@
1
+ import { FormTags, Hotkey, Scopes, Trigger } from './types';
2
+ export declare function maybePreventDefault(e: KeyboardEvent, hotkey: Hotkey, preventDefault?: Trigger): void;
3
+ export declare function isHotkeyEnabled(e: KeyboardEvent, hotkey: Hotkey, enabled?: Trigger): boolean;
4
+ export declare function isKeyboardEventTriggeredByInput(ev: KeyboardEvent): boolean;
5
+ export declare function isHotkeyEnabledOnTag({ target }: KeyboardEvent, enabledOnTags?: FormTags[]): boolean;
6
+ export declare function isScopeActive(activeScopes: string[], scopes?: Scopes): boolean;
7
+ export declare const isHotkeyMatchingKeyboardEvent: (e: KeyboardEvent, hotkey: Hotkey, pressedDownKeys: Set<string>) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hotkeys-hook",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "repository": "https://JohannesKlauss@github.com/JohannesKlauss/react-keymap-hook.git",
5
5
  "homepage": "https://johannesklauss.github.io/react-hotkeys-hook/",
6
6
  "author": "Johannes Klauss",
@@ -54,29 +54,29 @@
54
54
  "trailingComma": "es5"
55
55
  },
56
56
  "dependencies": {
57
- "hotkeys-js": "3.8.7"
57
+ "hotkeys-js": "3.9.3"
58
58
  },
59
59
  "devDependencies": {
60
- "@babel/core": "7.15.8",
61
- "@babel/plugin-proposal-class-properties": "7.14.5",
62
- "@babel/preset-env": "7.15.8",
63
- "@babel/preset-react": "7.14.5",
64
- "@babel/preset-typescript": "7.15.0",
65
- "@testing-library/react": "12.1.2",
66
- "@testing-library/react-hooks": "7.0.2",
67
- "@testing-library/user-event": "13.4.1",
68
- "@types/jest": "27.0.1",
69
- "@types/react": "17.0.30",
70
- "@types/react-dom": "17.0.9",
60
+ "@babel/core": "7.17.10",
61
+ "@babel/plugin-proposal-class-properties": "7.16.7",
62
+ "@babel/preset-env": "7.17.10",
63
+ "@babel/preset-react": "7.16.7",
64
+ "@babel/preset-typescript": "7.16.7",
65
+ "@testing-library/react": "13.2.0",
66
+ "@testing-library/react-hooks": "8.0.0",
67
+ "@testing-library/user-event": "13.5.0",
68
+ "@types/jest": "27.5.1",
69
+ "@types/react": "18.0.9",
70
+ "@types/react-dom": "18.0.3",
71
71
  "eslint-plugin-prettier": "4.0.0",
72
72
  "jest": "26.6.3",
73
- "prettier": "2.4.1",
74
- "react": "17.0.2",
75
- "react-dom": "17.0.2",
76
- "react-test-renderer": "17.0.2",
73
+ "prettier": "2.6.2",
74
+ "react": "18.1.0",
75
+ "react-dom": "18.1.0",
76
+ "react-test-renderer": "18.1.0",
77
77
  "tsdx": "0.14.1",
78
- "tslib": "2.3.1",
79
- "typescript": "4.4.4"
78
+ "tslib": "2.4.0",
79
+ "typescript": "4.6.4"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "react": ">=16.8.1",
@@ -1,93 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
-
5
- var hotkeys = _interopDefault(require('hotkeys-js'));
6
- var react = require('react');
7
-
8
- /**
9
- * @deprecated Use isHotkeyPressed instead. Will be removed version 4.
10
- */
11
-
12
- function useIsHotkeyPressed() {
13
- return hotkeys.isPressed;
14
- }
15
-
16
- hotkeys.filter = function () {
17
- return true;
18
- };
19
-
20
- var tagFilter = function tagFilter(_ref, enableOnTags) {
21
- var target = _ref.target;
22
- var targetTagName = target && target.tagName;
23
- return Boolean(targetTagName && enableOnTags && enableOnTags.includes(targetTagName));
24
- };
25
-
26
- var isKeyboardEventTriggeredByInput = function isKeyboardEventTriggeredByInput(ev) {
27
- return tagFilter(ev, ['INPUT', 'TEXTAREA', 'SELECT']);
28
- };
29
-
30
- function useHotkeys(keys, callback, options, deps) {
31
- if (options instanceof Array) {
32
- deps = options;
33
- options = undefined;
34
- }
35
-
36
- var _ref2 = options || {},
37
- enableOnTags = _ref2.enableOnTags,
38
- filter = _ref2.filter,
39
- keyup = _ref2.keyup,
40
- keydown = _ref2.keydown,
41
- _ref2$filterPreventDe = _ref2.filterPreventDefault,
42
- filterPreventDefault = _ref2$filterPreventDe === void 0 ? true : _ref2$filterPreventDe,
43
- _ref2$enabled = _ref2.enabled,
44
- enabled = _ref2$enabled === void 0 ? true : _ref2$enabled,
45
- _ref2$enableOnContent = _ref2.enableOnContentEditable,
46
- enableOnContentEditable = _ref2$enableOnContent === void 0 ? false : _ref2$enableOnContent;
47
-
48
- var ref = react.useRef(null); // The return value of this callback determines if the browsers default behavior is prevented.
49
-
50
- var memoisedCallback = react.useCallback(function (keyboardEvent, hotkeysEvent) {
51
- var _keyboardEvent$target;
52
-
53
- if (filter && !filter(keyboardEvent)) {
54
- return !filterPreventDefault;
55
- } // Check whether the hotkeys was triggered inside an input and that input is enabled or if it was triggered by a content editable tag and it is enabled.
56
-
57
-
58
- if (isKeyboardEventTriggeredByInput(keyboardEvent) && !tagFilter(keyboardEvent, enableOnTags) || (_keyboardEvent$target = keyboardEvent.target) != null && _keyboardEvent$target.isContentEditable && !enableOnContentEditable) {
59
- return true;
60
- }
61
-
62
- if (ref.current === null || document.activeElement === ref.current) {
63
- callback(keyboardEvent, hotkeysEvent);
64
- return true;
65
- }
66
-
67
- return false;
68
- }, deps ? [ref, enableOnTags, filter].concat(deps) : [ref, enableOnTags, filter]);
69
- react.useEffect(function () {
70
- if (!enabled) {
71
- hotkeys.unbind(keys, memoisedCallback);
72
- return;
73
- } // In this case keydown is likely undefined, so we set it to false, since hotkeys needs the `keydown` key to have a value.
74
-
75
-
76
- if (keyup && keydown !== true) {
77
- options.keydown = false;
78
- }
79
-
80
- hotkeys(keys, options || {}, memoisedCallback);
81
- return function () {
82
- return hotkeys.unbind(keys, memoisedCallback);
83
- };
84
- }, [memoisedCallback, keys, enabled]);
85
- return ref;
86
- }
87
-
88
- var isHotkeyPressed = hotkeys.isPressed;
89
-
90
- exports.isHotkeyPressed = isHotkeyPressed;
91
- exports.useHotkeys = useHotkeys;
92
- exports.useIsHotkeyPressed = useIsHotkeyPressed;
93
- //# sourceMappingURL=react-hotkeys-hook.cjs.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hotkeys-hook.cjs.development.js","sources":["../src/useIsHotkeyPressed.ts","../src/useHotkeys.ts","../src/index.ts"],"sourcesContent":["import hotkeys from 'hotkeys-js';\n\n/**\n * @deprecated Use isHotkeyPressed instead. Will be removed version 4.\n */\nexport function useIsHotkeyPressed() {\n return hotkeys.isPressed;\n}","import hotkeys, { HotkeysEvent, KeyHandler } from 'hotkeys-js';\nimport React, { useCallback, useEffect, useRef } from 'react';\n\ntype AvailableTags = 'INPUT' | 'TEXTAREA' | 'SELECT';\n\n// We implement our own custom filter system.\nhotkeys.filter = () => true;\n\nconst tagFilter = ({ target }: KeyboardEvent, enableOnTags?: AvailableTags[]) => {\n const targetTagName = target && (target as HTMLElement).tagName;\n\n return Boolean((targetTagName && enableOnTags && enableOnTags.includes(targetTagName as AvailableTags)));\n};\n\nconst isKeyboardEventTriggeredByInput = (ev: KeyboardEvent) => {\n return tagFilter(ev, ['INPUT', 'TEXTAREA', 'SELECT']);\n};\n\nexport type Options = {\n enabled?: boolean; // Main setting that determines if the hotkey is enabled or not. (Default: true)\n filter?: typeof hotkeys.filter; // A filter function returning whether the callback should get triggered or not. (Default: undefined)\n filterPreventDefault?: boolean; // Prevent default browser behavior if the filter function returns false. (Default: true)\n enableOnTags?: AvailableTags[]; // Enable hotkeys on a list of tags. (Default: [])\n enableOnContentEditable?: boolean; // Enable hotkeys on tags with contentEditable props. (Default: false)\n splitKey?: string; // Character to split keys in hotkeys combinations. (Default +)\n scope?: string; // Scope. Currently not doing anything.\n keyup?: boolean; // Trigger on keyup event? (Default: undefined)\n keydown?: boolean; // Trigger on keydown event? (Default: true)\n};\n\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, deps?: any[]): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options, deps?: any[]): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: any[] | Options, deps?: any[]): React.MutableRefObject<T | null> {\n if (options instanceof Array) {\n deps = options;\n options = undefined;\n }\n\n const {\n enableOnTags,\n filter,\n keyup,\n keydown,\n filterPreventDefault = true,\n enabled = true,\n enableOnContentEditable = false,\n } = options as Options || {};\n const ref = useRef<T | null>(null);\n\n // The return value of this callback determines if the browsers default behavior is prevented.\n const memoisedCallback = useCallback((keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent) => {\n if (filter && !filter(keyboardEvent)) {\n return !filterPreventDefault;\n }\n\n // Check whether the hotkeys was triggered inside an input and that input is enabled or if it was triggered by a content editable tag and it is enabled.\n if (\n (isKeyboardEventTriggeredByInput(keyboardEvent) && !tagFilter(keyboardEvent, enableOnTags))\n || ((keyboardEvent.target as HTMLElement)?.isContentEditable && !enableOnContentEditable)\n ) {\n return true;\n }\n\n if (ref.current === null || document.activeElement === ref.current) {\n callback(keyboardEvent, hotkeysEvent);\n return true;\n }\n\n return false;\n }, deps ? [ref, enableOnTags, filter, ...deps] : [ref, enableOnTags, filter]);\n\n useEffect(() => {\n if (!enabled) {\n hotkeys.unbind(keys, memoisedCallback);\n\n return;\n }\n\n // In this case keydown is likely undefined, so we set it to false, since hotkeys needs the `keydown` key to have a value.\n if (keyup && keydown !== true) {\n (options as Options).keydown = false;\n }\n\n hotkeys(keys, (options as Options) || {}, memoisedCallback);\n\n return () => hotkeys.unbind(keys, memoisedCallback);\n }, [memoisedCallback, keys, enabled]);\n\n return ref;\n}\n","import { useIsHotkeyPressed } from './useIsHotkeyPressed';\nimport { useHotkeys, Options } from './useHotkeys';\nimport hotkeys from 'hotkeys-js';\n\nconst isHotkeyPressed = hotkeys.isPressed;\n\nexport { useHotkeys, useIsHotkeyPressed, isHotkeyPressed, Options };"],"names":["useIsHotkeyPressed","hotkeys","isPressed","filter","tagFilter","enableOnTags","target","targetTagName","tagName","Boolean","includes","isKeyboardEventTriggeredByInput","ev","useHotkeys","keys","callback","options","deps","Array","undefined","keyup","keydown","filterPreventDefault","enabled","enableOnContentEditable","ref","useRef","memoisedCallback","useCallback","keyboardEvent","hotkeysEvent","isContentEditable","current","document","activeElement","useEffect","unbind","isHotkeyPressed"],"mappings":";;;;;;;AAEA;;;;SAGgBA;AACd,SAAOC,OAAO,CAACC,SAAf;AACD;;ACDDD,OAAO,CAACE,MAAR,GAAiB;AAAA,SAAM,IAAN;AAAA,CAAjB;;AAEA,IAAMC,SAAS,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,iBAAtC,IAA2D,CAACP,uBAFnE,EAGE;AACA,aAAO,IAAP;AACD;;AAED,QAAIC,GAAG,CAACO,OAAJ,KAAgB,IAAhB,IAAwBC,QAAQ,CAACC,aAAT,KAA2BT,GAAG,CAACO,OAA3D,EAAoE;AAClEjB,MAAAA,QAAQ,CAACc,aAAD,EAAgBC,YAAhB,CAAR;AACA,aAAO,IAAP;AACD;;AAED,WAAO,KAAP;AACD,GAnBmC,EAmBjCb,IAAI,IAAIQ,GAAJ,EAASpB,YAAT,EAAuBF,MAAvB,SAAkCc,IAAlC,IAA0C,CAACQ,GAAD,EAAMpB,YAAN,EAAoBF,MAApB,CAnBb,CAApC;AAqBAgC,EAAAA,eAAS,CAAC;AACR,QAAI,CAACZ,OAAL,EAAc;AACZtB,MAAAA,OAAO,CAACmC,MAAR,CAAetB,IAAf,EAAqBa,gBAArB;AAEA;AACD;;;AAGD,QAAIP,KAAK,IAAIC,OAAO,KAAK,IAAzB,EAA+B;AAC5BL,MAAAA,OAAmB,CAACK,OAApB,GAA8B,KAA9B;AACF;;AAEDpB,IAAAA,OAAO,CAACa,IAAD,EAAQE,OAAmB,IAAI,EAA/B,EAAmCW,gBAAnC,CAAP;AAEA,WAAO;AAAA,aAAM1B,OAAO,CAACmC,MAAR,CAAetB,IAAf,EAAqBa,gBAArB,CAAN;AAAA,KAAP;AACD,GAfQ,EAeN,CAACA,gBAAD,EAAmBb,IAAnB,EAAyBS,OAAzB,CAfM,CAAT;AAiBA,SAAOE,GAAP;AACD;;ICtFKY,eAAe,GAAGpC,OAAO,CAACC,SAAhC;;;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";var e,t=(e=require("hotkeys-js"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("react");t.filter=function(){return!0};var r=function(e,t){var n=e.target,r=n&&n.tagName;return Boolean(r&&t&&t.includes(r))};exports.isHotkeyPressed=t.isPressed,exports.useHotkeys=function(e,u,i,o){i instanceof Array&&(o=i,i=void 0);var s=i||{},a=s.enableOnTags,l=s.filter,c=s.keyup,d=s.keydown,f=s.filterPreventDefault,v=void 0===f||f,b=s.enabled,y=void 0===b||b,k=s.enableOnContentEditable,E=void 0!==k&&k,P=n.useRef(null),p=n.useCallback((function(e,t){var n;return l&&!l(e)?!v:!!(r(e,["INPUT","TEXTAREA","SELECT"])&&!r(e,a)||null!=(n=e.target)&&n.isContentEditable&&!E)||(null===P.current||document.activeElement===P.current)&&(u(e,t),!0)}),o?[P,a,l].concat(o):[P,a,l]);return n.useEffect((function(){if(y)return c&&!0!==d&&(i.keydown=!1),t(e,i||{},p),function(){return t.unbind(e,p)};t.unbind(e,p)}),[p,e,y]),P},exports.useIsHotkeyPressed=function(){return t.isPressed};
2
- //# sourceMappingURL=react-hotkeys-hook.cjs.production.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hotkeys-hook.cjs.production.min.js","sources":["../src/useHotkeys.ts","../src/index.ts","../src/useIsHotkeyPressed.ts"],"sourcesContent":["import hotkeys, { HotkeysEvent, KeyHandler } from 'hotkeys-js';\nimport React, { useCallback, useEffect, useRef } from 'react';\n\ntype AvailableTags = 'INPUT' | 'TEXTAREA' | 'SELECT';\n\n// We implement our own custom filter system.\nhotkeys.filter = () => true;\n\nconst tagFilter = ({ target }: KeyboardEvent, enableOnTags?: AvailableTags[]) => {\n const targetTagName = target && (target as HTMLElement).tagName;\n\n return Boolean((targetTagName && enableOnTags && enableOnTags.includes(targetTagName as AvailableTags)));\n};\n\nconst isKeyboardEventTriggeredByInput = (ev: KeyboardEvent) => {\n return tagFilter(ev, ['INPUT', 'TEXTAREA', 'SELECT']);\n};\n\nexport type Options = {\n enabled?: boolean; // Main setting that determines if the hotkey is enabled or not. (Default: true)\n filter?: typeof hotkeys.filter; // A filter function returning whether the callback should get triggered or not. (Default: undefined)\n filterPreventDefault?: boolean; // Prevent default browser behavior if the filter function returns false. (Default: true)\n enableOnTags?: AvailableTags[]; // Enable hotkeys on a list of tags. (Default: [])\n enableOnContentEditable?: boolean; // Enable hotkeys on tags with contentEditable props. (Default: false)\n splitKey?: string; // Character to split keys in hotkeys combinations. (Default +)\n scope?: string; // Scope. Currently not doing anything.\n keyup?: boolean; // Trigger on keyup event? (Default: undefined)\n keydown?: boolean; // Trigger on keydown event? (Default: true)\n};\n\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, deps?: any[]): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options, deps?: any[]): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: any[] | Options, deps?: any[]): React.MutableRefObject<T | null> {\n if (options instanceof Array) {\n deps = options;\n options = undefined;\n }\n\n const {\n enableOnTags,\n filter,\n keyup,\n keydown,\n filterPreventDefault = true,\n enabled = true,\n enableOnContentEditable = false,\n } = options as Options || {};\n const ref = useRef<T | null>(null);\n\n // The return value of this callback determines if the browsers default behavior is prevented.\n const memoisedCallback = useCallback((keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent) => {\n if (filter && !filter(keyboardEvent)) {\n return !filterPreventDefault;\n }\n\n // Check whether the hotkeys was triggered inside an input and that input is enabled or if it was triggered by a content editable tag and it is enabled.\n if (\n (isKeyboardEventTriggeredByInput(keyboardEvent) && !tagFilter(keyboardEvent, enableOnTags))\n || ((keyboardEvent.target as HTMLElement)?.isContentEditable && !enableOnContentEditable)\n ) {\n return true;\n }\n\n if (ref.current === null || document.activeElement === ref.current) {\n callback(keyboardEvent, hotkeysEvent);\n return true;\n }\n\n return false;\n }, deps ? [ref, enableOnTags, filter, ...deps] : [ref, enableOnTags, filter]);\n\n useEffect(() => {\n if (!enabled) {\n hotkeys.unbind(keys, memoisedCallback);\n\n return;\n }\n\n // In this case keydown is likely undefined, so we set it to false, since hotkeys needs the `keydown` key to have a value.\n if (keyup && keydown !== true) {\n (options as Options).keydown = false;\n }\n\n hotkeys(keys, (options as Options) || {}, memoisedCallback);\n\n return () => hotkeys.unbind(keys, memoisedCallback);\n }, [memoisedCallback, keys, enabled]);\n\n return ref;\n}\n","import { useIsHotkeyPressed } from './useIsHotkeyPressed';\nimport { useHotkeys, Options } from './useHotkeys';\nimport hotkeys from 'hotkeys-js';\n\nconst isHotkeyPressed = hotkeys.isPressed;\n\nexport { useHotkeys, useIsHotkeyPressed, isHotkeyPressed, Options };","import hotkeys from 'hotkeys-js';\n\n/**\n * @deprecated Use isHotkeyPressed instead. Will be removed version 4.\n */\nexport function useIsHotkeyPressed() {\n return hotkeys.isPressed;\n}"],"names":["hotkeys","filter","tagFilter","enableOnTags","target","targetTagName","tagName","Boolean","includes","isPressed","keys","callback","options","deps","Array","undefined","keyup","keydown","filterPreventDefault","enabled","enableOnContentEditable","ref","useRef","memoisedCallback","useCallback","keyboardEvent","hotkeysEvent","isContentEditable","current","document","activeElement","useEffect","unbind"],"mappings":"iHAMAA,EAAQC,OAAS,kBAAM,GAEvB,IAAMC,EAAY,WAA4BC,OAAzBC,IAAAA,OACbC,EAAgBD,GAAWA,EAAuBE,eAEjDC,QAASF,GAAiBF,GAAgBA,EAAaK,SAASH,6BCPjDL,EAAQS,6BD6BhC,SAA8CC,EAAcC,EAAsBC,EAA2BC,GACvGD,aAAmBE,QACrBD,EAAOD,EACPA,OAAUG,SAWRH,GAAsB,GAPxBT,IAAAA,aACAF,IAAAA,OACAe,IAAAA,MACAC,IAAAA,YACAC,qBAAAA,oBACAC,QAAAA,oBACAC,wBAAAA,gBAEIC,EAAMC,SAAiB,MAGvBC,EAAmBC,eAAY,SAACC,EAA8BC,gBAC9DzB,IAAWA,EAAOwB,IACZP,KAtCLhB,EA2C8BuB,EA3ChB,CAAC,QAAS,WAAY,aA2CavB,EAAUuB,EAAetB,aACxEsB,EAAcrB,WAAwBuB,oBAAsBP,KAK/C,OAAhBC,EAAIO,SAAoBC,SAASC,gBAAkBT,EAAIO,WACzDjB,EAASc,EAAeC,IACjB,KAIRb,GAAQQ,EAAKlB,EAAcF,UAAWY,GAAQ,CAACQ,EAAKlB,EAAcF,WAErE8B,aAAU,cACHZ,SAODH,IAAqB,IAAZC,IACVL,EAAoBK,SAAU,GAGjCjB,EAAQU,EAAOE,GAAuB,GAAIW,GAEnC,kBAAMvB,EAAQgC,OAAOtB,EAAMa,IAZhCvB,EAAQgC,OAAOtB,EAAMa,KAatB,CAACA,EAAkBb,EAAMS,IAErBE,gDEnFArB,EAAQS"}
@@ -1,87 +0,0 @@
1
- import hotkeys from 'hotkeys-js';
2
- import { useRef, useCallback, useEffect } from 'react';
3
-
4
- /**
5
- * @deprecated Use isHotkeyPressed instead. Will be removed version 4.
6
- */
7
-
8
- function useIsHotkeyPressed() {
9
- return hotkeys.isPressed;
10
- }
11
-
12
- hotkeys.filter = function () {
13
- return true;
14
- };
15
-
16
- var tagFilter = function tagFilter(_ref, enableOnTags) {
17
- var target = _ref.target;
18
- var targetTagName = target && target.tagName;
19
- return Boolean(targetTagName && enableOnTags && enableOnTags.includes(targetTagName));
20
- };
21
-
22
- var isKeyboardEventTriggeredByInput = function isKeyboardEventTriggeredByInput(ev) {
23
- return tagFilter(ev, ['INPUT', 'TEXTAREA', 'SELECT']);
24
- };
25
-
26
- function useHotkeys(keys, callback, options, deps) {
27
- if (options instanceof Array) {
28
- deps = options;
29
- options = undefined;
30
- }
31
-
32
- var _ref2 = options || {},
33
- enableOnTags = _ref2.enableOnTags,
34
- filter = _ref2.filter,
35
- keyup = _ref2.keyup,
36
- keydown = _ref2.keydown,
37
- _ref2$filterPreventDe = _ref2.filterPreventDefault,
38
- filterPreventDefault = _ref2$filterPreventDe === void 0 ? true : _ref2$filterPreventDe,
39
- _ref2$enabled = _ref2.enabled,
40
- enabled = _ref2$enabled === void 0 ? true : _ref2$enabled,
41
- _ref2$enableOnContent = _ref2.enableOnContentEditable,
42
- enableOnContentEditable = _ref2$enableOnContent === void 0 ? false : _ref2$enableOnContent;
43
-
44
- var ref = useRef(null); // The return value of this callback determines if the browsers default behavior is prevented.
45
-
46
- var memoisedCallback = useCallback(function (keyboardEvent, hotkeysEvent) {
47
- var _keyboardEvent$target;
48
-
49
- if (filter && !filter(keyboardEvent)) {
50
- return !filterPreventDefault;
51
- } // Check whether the hotkeys was triggered inside an input and that input is enabled or if it was triggered by a content editable tag and it is enabled.
52
-
53
-
54
- if (isKeyboardEventTriggeredByInput(keyboardEvent) && !tagFilter(keyboardEvent, enableOnTags) || (_keyboardEvent$target = keyboardEvent.target) != null && _keyboardEvent$target.isContentEditable && !enableOnContentEditable) {
55
- return true;
56
- }
57
-
58
- if (ref.current === null || document.activeElement === ref.current) {
59
- callback(keyboardEvent, hotkeysEvent);
60
- return true;
61
- }
62
-
63
- return false;
64
- }, deps ? [ref, enableOnTags, filter].concat(deps) : [ref, enableOnTags, filter]);
65
- useEffect(function () {
66
- if (!enabled) {
67
- hotkeys.unbind(keys, memoisedCallback);
68
- return;
69
- } // In this case keydown is likely undefined, so we set it to false, since hotkeys needs the `keydown` key to have a value.
70
-
71
-
72
- if (keyup && keydown !== true) {
73
- options.keydown = false;
74
- }
75
-
76
- hotkeys(keys, options || {}, memoisedCallback);
77
- return function () {
78
- return hotkeys.unbind(keys, memoisedCallback);
79
- };
80
- }, [memoisedCallback, keys, enabled]);
81
- return ref;
82
- }
83
-
84
- var isHotkeyPressed = hotkeys.isPressed;
85
-
86
- export { isHotkeyPressed, useHotkeys, useIsHotkeyPressed };
87
- //# sourceMappingURL=react-hotkeys-hook.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hotkeys-hook.esm.js","sources":["../src/useIsHotkeyPressed.ts","../src/useHotkeys.ts","../src/index.ts"],"sourcesContent":["import hotkeys from 'hotkeys-js';\n\n/**\n * @deprecated Use isHotkeyPressed instead. Will be removed version 4.\n */\nexport function useIsHotkeyPressed() {\n return hotkeys.isPressed;\n}","import hotkeys, { HotkeysEvent, KeyHandler } from 'hotkeys-js';\nimport React, { useCallback, useEffect, useRef } from 'react';\n\ntype AvailableTags = 'INPUT' | 'TEXTAREA' | 'SELECT';\n\n// We implement our own custom filter system.\nhotkeys.filter = () => true;\n\nconst tagFilter = ({ target }: KeyboardEvent, enableOnTags?: AvailableTags[]) => {\n const targetTagName = target && (target as HTMLElement).tagName;\n\n return Boolean((targetTagName && enableOnTags && enableOnTags.includes(targetTagName as AvailableTags)));\n};\n\nconst isKeyboardEventTriggeredByInput = (ev: KeyboardEvent) => {\n return tagFilter(ev, ['INPUT', 'TEXTAREA', 'SELECT']);\n};\n\nexport type Options = {\n enabled?: boolean; // Main setting that determines if the hotkey is enabled or not. (Default: true)\n filter?: typeof hotkeys.filter; // A filter function returning whether the callback should get triggered or not. (Default: undefined)\n filterPreventDefault?: boolean; // Prevent default browser behavior if the filter function returns false. (Default: true)\n enableOnTags?: AvailableTags[]; // Enable hotkeys on a list of tags. (Default: [])\n enableOnContentEditable?: boolean; // Enable hotkeys on tags with contentEditable props. (Default: false)\n splitKey?: string; // Character to split keys in hotkeys combinations. (Default +)\n scope?: string; // Scope. Currently not doing anything.\n keyup?: boolean; // Trigger on keyup event? (Default: undefined)\n keydown?: boolean; // Trigger on keydown event? (Default: true)\n};\n\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, deps?: any[]): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: Options, deps?: any[]): React.MutableRefObject<T | null>;\nexport function useHotkeys<T extends Element>(keys: string, callback: KeyHandler, options?: any[] | Options, deps?: any[]): React.MutableRefObject<T | null> {\n if (options instanceof Array) {\n deps = options;\n options = undefined;\n }\n\n const {\n enableOnTags,\n filter,\n keyup,\n keydown,\n filterPreventDefault = true,\n enabled = true,\n enableOnContentEditable = false,\n } = options as Options || {};\n const ref = useRef<T | null>(null);\n\n // The return value of this callback determines if the browsers default behavior is prevented.\n const memoisedCallback = useCallback((keyboardEvent: KeyboardEvent, hotkeysEvent: HotkeysEvent) => {\n if (filter && !filter(keyboardEvent)) {\n return !filterPreventDefault;\n }\n\n // Check whether the hotkeys was triggered inside an input and that input is enabled or if it was triggered by a content editable tag and it is enabled.\n if (\n (isKeyboardEventTriggeredByInput(keyboardEvent) && !tagFilter(keyboardEvent, enableOnTags))\n || ((keyboardEvent.target as HTMLElement)?.isContentEditable && !enableOnContentEditable)\n ) {\n return true;\n }\n\n if (ref.current === null || document.activeElement === ref.current) {\n callback(keyboardEvent, hotkeysEvent);\n return true;\n }\n\n return false;\n }, deps ? [ref, enableOnTags, filter, ...deps] : [ref, enableOnTags, filter]);\n\n useEffect(() => {\n if (!enabled) {\n hotkeys.unbind(keys, memoisedCallback);\n\n return;\n }\n\n // In this case keydown is likely undefined, so we set it to false, since hotkeys needs the `keydown` key to have a value.\n if (keyup && keydown !== true) {\n (options as Options).keydown = false;\n }\n\n hotkeys(keys, (options as Options) || {}, memoisedCallback);\n\n return () => hotkeys.unbind(keys, memoisedCallback);\n }, [memoisedCallback, keys, enabled]);\n\n return ref;\n}\n","import { useIsHotkeyPressed } from './useIsHotkeyPressed';\nimport { useHotkeys, Options } from './useHotkeys';\nimport hotkeys from 'hotkeys-js';\n\nconst isHotkeyPressed = hotkeys.isPressed;\n\nexport { useHotkeys, useIsHotkeyPressed, isHotkeyPressed, Options };"],"names":["useIsHotkeyPressed","hotkeys","isPressed","filter","tagFilter","enableOnTags","target","targetTagName","tagName","Boolean","includes","isKeyboardEventTriggeredByInput","ev","useHotkeys","keys","callback","options","deps","Array","undefined","keyup","keydown","filterPreventDefault","enabled","enableOnContentEditable","ref","useRef","memoisedCallback","useCallback","keyboardEvent","hotkeysEvent","isContentEditable","current","document","activeElement","useEffect","unbind","isHotkeyPressed"],"mappings":";;;AAEA;;;;SAGgBA;AACd,SAAOC,OAAO,CAACC,SAAf;AACD;;ACDDD,OAAO,CAACE,MAAR,GAAiB;AAAA,SAAM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,yBAAAwB,aAAa,CAACvB,MAAd,mCAAsCyB,iBAAtC,IAA2D,CAACP,uBAFnE,EAGE;AACA,aAAO,IAAP;AACD;;AAED,QAAIC,GAAG,CAACO,OAAJ,KAAgB,IAAhB,IAAwBC,QAAQ,CAACC,aAAT,KAA2BT,GAAG,CAACO,OAA3D,EAAoE;AAClEjB,MAAAA,QAAQ,CAACc,aAAD,EAAgBC,YAAhB,CAAR;AACA,aAAO,IAAP;AACD;;AAED,WAAO,KAAP;AACD,GAnBmC,EAmBjCb,IAAI,IAAIQ,GAAJ,EAASpB,YAAT,EAAuBF,MAAvB,SAAkCc,IAAlC,IAA0C,CAACQ,GAAD,EAAMpB,YAAN,EAAoBF,MAApB,CAnBb,CAApC;AAqBAgC,EAAAA,SAAS,CAAC;AACR,QAAI,CAACZ,OAAL,EAAc;AACZtB,MAAAA,OAAO,CAACmC,MAAR,CAAetB,IAAf,EAAqBa,gBAArB;AAEA;AACD;;;AAGD,QAAIP,KAAK,IAAIC,OAAO,KAAK,IAAzB,EAA+B;AAC5BL,MAAAA,OAAmB,CAACK,OAApB,GAA8B,KAA9B;AACF;;AAEDpB,IAAAA,OAAO,CAACa,IAAD,EAAQE,OAAmB,IAAI,EAA/B,EAAmCW,gBAAnC,CAAP;AAEA,WAAO;AAAA,aAAM1B,OAAO,CAACmC,MAAR,CAAetB,IAAf,EAAqBa,gBAArB,CAAN;AAAA,KAAP;AACD,GAfQ,EAeN,CAACA,gBAAD,EAAmBb,IAAnB,EAAyBS,OAAzB,CAfM,CAAT;AAiBA,SAAOE,GAAP;AACD;;ICtFKY,eAAe,GAAGpC,OAAO,CAACC,SAAhC;;;;"}
@@ -1,7 +0,0 @@
1
- /**
2
- * @deprecated Use isHotkeyPressed instead. Will be removed version 4.
3
- */
4
- export declare function useIsHotkeyPressed(): {
5
- (keyCode: number): boolean;
6
- (keyCode: string): boolean;
7
- };