react-hotkeys-hook 4.5.0 → 5.0.0-1

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 +1 @@
1
- {"version":3,"file":"react-hotkeys-hook.cjs.production.min.js","sources":["../src/parseHotkeys.ts","../src/isHotkeyPressed.ts","../src/validators.ts","../src/BoundHotkeysProxyProvider.tsx","../src/deepEqual.ts","../src/HotkeysProvider.tsx","../src/useHotkeys.ts","../src/useDeepEqualMemo.ts","../src/useRecordHotkeys.ts"],"sourcesContent":["import { Hotkey, KeyboardModifiers } from './types'\n\nconst reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl']\n\nconst mappedKeys: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n '.': 'period',\n ',': 'comma',\n '-': 'slash',\n ' ': 'space',\n '`': 'backquote',\n '#': 'backslash',\n '+': 'bracketright',\n ShiftLeft: 'shift',\n ShiftRight: 'shift',\n AltLeft: 'alt',\n AltRight: 'alt',\n MetaLeft: 'meta',\n MetaRight: 'meta',\n OSLeft: 'meta',\n OSRight: 'meta',\n ControlLeft: 'ctrl',\n ControlRight: 'ctrl',\n}\n\nexport function mapKey(key: string): string {\n return (mappedKeys[key] || key)\n .trim()\n .toLowerCase()\n .replace(/key|digit|numpad|arrow/, '')\n}\n\nexport function isHotkeyModifier(key: string) {\n return reservedModifierKeywords.includes(key)\n}\n\nexport function parseKeysHookInput(keys: string, splitKey = ','): string[] {\n return keys.split(splitKey)\n}\n\nexport function parseHotkey(hotkey: string, combinationKey = '+', description?: string): Hotkey {\n const keys = hotkey\n .toLocaleLowerCase()\n .split(combinationKey)\n .map((k) => mapKey(k))\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl') || keys.includes('control'),\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 description,\n }\n}\n","import { isHotkeyModifier, mapKey } from './parseHotkeys'\n;(() => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', (e) => {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)])\n })\n\n document.addEventListener('keyup', (e) => {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)])\n })\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('blur', () => {\n currentlyPressedKeys.clear()\n })\n }\n})()\n\nconst currentlyPressedKeys: Set<string> = new Set<string>()\n\n// https://github.com/microsoft/TypeScript/issues/17002\nexport function isReadonlyArray(value: unknown): value is readonly unknown[] {\n return Array.isArray(value)\n}\n\nexport function isHotkeyPressed(key: string | readonly string[], splitKey = ','): boolean {\n const hotkeyArray = isReadonlyArray(key) ? key : key.split(splitKey)\n\n return hotkeyArray.every((hotkey) => currentlyPressedKeys.has(hotkey.trim().toLowerCase()))\n}\n\nexport function pushToCurrentlyPressedKeys(key: string | string[]): void {\n const hotkeyArray = Array.isArray(key) ? key : [key]\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (currentlyPressedKeys.has('meta')) {\n currentlyPressedKeys.forEach((key) => !isHotkeyModifier(key) && currentlyPressedKeys.delete(key.toLowerCase()))\n }\n\n hotkeyArray.forEach((hotkey) => currentlyPressedKeys.add(hotkey.toLowerCase()))\n}\n\nexport function removeFromCurrentlyPressedKeys(key: string | string[]): void {\n const hotkeyArray = Array.isArray(key) ? key : [key]\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (key === 'meta') {\n currentlyPressedKeys.clear()\n } else {\n hotkeyArray.forEach((hotkey) => currentlyPressedKeys.delete(hotkey.toLowerCase()))\n }\n}\n","import { FormTags, Hotkey, Scopes, Trigger } from './types'\nimport { isHotkeyPressed, isReadonlyArray } from './isHotkeyPressed'\nimport { mapKey } from './parseHotkeys'\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(\n { target }: KeyboardEvent,\n enabledOnTags: readonly FormTags[] | boolean = false\n): boolean {\n const targetTagName = target && (target as HTMLElement).tagName\n\n if (isReadonlyArray(enabledOnTags)) {\n return Boolean(\n targetTagName && enabledOnTags && enabledOnTags.some((tag) => tag.toLowerCase() === targetTagName.toLowerCase())\n )\n }\n\n return Boolean(targetTagName && enabledOnTags && enabledOnTags === true)\n}\n\nexport function isScopeActive(activeScopes: string[], scopes?: Scopes): boolean {\n if (activeScopes.length === 0 && scopes) {\n console.warn(\n '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>'\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, ignoreModifiers = false): boolean => {\n const { alt, meta, mod, shift, ctrl, keys } = hotkey\n const { key: pressedKeyUppercase, code, ctrlKey, metaKey, shiftKey, altKey } = e\n\n const keyCode = mapKey(code)\n const pressedKey = pressedKeyUppercase.toLowerCase()\n\n if (!keys?.includes(keyCode) && !keys?.includes(pressedKey) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(keyCode)) {\n return false\n }\n\n if (!ignoreModifiers) {\n // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.\n if (alt === !altKey && pressedKey !== 'alt') {\n return false\n }\n\n if (shift === !shiftKey && 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 (meta === !metaKey && pressedKey !== 'meta' && pressedKey !== 'os') {\n return false\n }\n\n if (ctrl === !ctrlKey && pressedKey !== 'ctrl' && pressedKey !== 'control') {\n return false\n }\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 isHotkeyPressed(keys)\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 { createContext, ReactNode, useContext } from 'react'\nimport { Hotkey } from './types'\n\ntype BoundHotkeysProxyProviderType = {\n addHotkey: (hotkey: Hotkey) => void\n removeHotkey: (hotkey: Hotkey) => void\n}\n\nconst BoundHotkeysProxyProvider = createContext<BoundHotkeysProxyProviderType | undefined>(undefined)\n\nexport const useBoundHotkeysProxy = () => {\n return useContext(BoundHotkeysProxyProvider)\n}\n\ninterface Props {\n children: ReactNode\n addHotkey: (hotkey: Hotkey) => void\n removeHotkey: (hotkey: Hotkey) => void\n}\n\nexport default function BoundHotkeysProxyProviderProvider({ addHotkey, removeHotkey, children }: Props) {\n return (\n <BoundHotkeysProxyProvider.Provider value={{ addHotkey, removeHotkey }}>\n {children}\n </BoundHotkeysProxyProvider.Provider>\n )\n}\n","export default function deepEqual(x: any, y: any): boolean {\n //@ts-ignore\n return x && y && typeof x === 'object' && typeof y === 'object'\n ? Object.keys(x).length === Object.keys(y).length &&\n //@ts-ignore\n Object.keys(x).reduce((isEqual, key) => isEqual && deepEqual(x[key], y[key]), true)\n : x === y\n}\n","import { Hotkey } from './types'\nimport { createContext, ReactNode, useState, useContext, useCallback } from 'react'\nimport BoundHotkeysProxyProviderProvider from './BoundHotkeysProxyProvider'\nimport deepEqual from './deepEqual'\n\nexport type HotkeysContextType = {\n hotkeys: ReadonlyArray<Hotkey>\n enabledScopes: string[]\n toggleScope: (scope: string) => void\n enableScope: (scope: string) => void\n disableScope: (scope: string) => void\n}\n\n// The context is only needed for special features like global scoping, so we use a graceful default fallback\nconst HotkeysContext = createContext<HotkeysContextType>({\n hotkeys: [],\n enabledScopes: [], // This array has to be empty instead of containing '*' as default, to check if the provider is set or not\n toggleScope: () => {},\n enableScope: () => {},\n disableScope: () => {},\n})\n\nexport const useHotkeysContext = () => {\n return useContext(HotkeysContext)\n}\n\ninterface Props {\n initiallyActiveScopes?: string[]\n children: ReactNode\n}\n\nexport const HotkeysProvider = ({ initiallyActiveScopes = ['*'], children }: Props) => {\n const [internalActiveScopes, setInternalActiveScopes] = useState(\n initiallyActiveScopes?.length > 0 ? initiallyActiveScopes : ['*']\n )\n const [boundHotkeys, setBoundHotkeys] = useState<Hotkey[]>([])\n\n const enableScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.includes('*')) {\n return [scope]\n }\n\n return Array.from(new Set([...prev, scope]))\n })\n }, [])\n\n const disableScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.filter((s) => s !== scope).length === 0) {\n return ['*']\n } else {\n return prev.filter((s) => s !== scope)\n }\n })\n }, [])\n\n const toggleScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.includes(scope)) {\n if (prev.filter((s) => s !== scope).length === 0) {\n return ['*']\n } else {\n return prev.filter((s) => s !== scope)\n }\n } else {\n if (prev.includes('*')) {\n return [scope]\n }\n\n return Array.from(new Set([...prev, scope]))\n }\n })\n }, [])\n\n const addBoundHotkey = useCallback((hotkey: Hotkey) => {\n setBoundHotkeys((prev) => [...prev, hotkey])\n }, [])\n\n const removeBoundHotkey = useCallback((hotkey: Hotkey) => {\n setBoundHotkeys((prev) => prev.filter((h) => !deepEqual(h, hotkey)))\n }, [])\n\n return (\n <HotkeysContext.Provider\n value={{ enabledScopes: internalActiveScopes, hotkeys: boundHotkeys, enableScope, disableScope, toggleScope }}\n >\n <BoundHotkeysProxyProviderProvider addHotkey={addBoundHotkey} removeHotkey={removeBoundHotkey}>\n {children}\n </BoundHotkeysProxyProviderProvider>\n </HotkeysContext.Provider>\n )\n}\n","import { HotkeyCallback, Keys, Options, OptionsOrDependencyArray, RefType } from './types'\nimport { DependencyList, useCallback, useEffect, useLayoutEffect, useRef } from 'react'\nimport { mapKey, parseHotkey, parseKeysHookInput } from './parseHotkeys'\nimport {\n isHotkeyEnabled,\n isHotkeyEnabledOnTag,\n isHotkeyMatchingKeyboardEvent,\n isKeyboardEventTriggeredByInput,\n isScopeActive,\n maybePreventDefault,\n} from './validators'\nimport { useHotkeysContext } from './HotkeysProvider'\nimport { useBoundHotkeysProxy } from './BoundHotkeysProxyProvider'\nimport useDeepEqualMemo from './useDeepEqualMemo'\nimport { isReadonlyArray, pushToCurrentlyPressedKeys, removeFromCurrentlyPressedKeys } from './isHotkeyPressed'\n\nconst stopPropagation = (e: KeyboardEvent): void => {\n e.stopPropagation()\n e.preventDefault()\n e.stopImmediatePropagation()\n}\n\nconst useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\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 hasTriggeredRef = useRef(false)\n\n const _options: Options | undefined = !(options instanceof Array)\n ? (options as Options)\n : !(dependencies instanceof Array)\n ? (dependencies as Options)\n : undefined\n const _keys: string = isReadonlyArray(keys) ? keys.join(_options?.splitKey) : keys\n const _deps: DependencyList | undefined =\n options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined\n\n const memoisedCB = useCallback(callback, _deps ?? [])\n const cbRef = useRef<HotkeyCallback>(memoisedCB)\n\n if (_deps) {\n cbRef.current = memoisedCB\n } else {\n cbRef.current = callback\n }\n\n const memoisedOptions = useDeepEqualMemo(_options)\n\n const { enabledScopes } = useHotkeysContext()\n const proxy = useBoundHotkeysProxy()\n\n useSafeLayoutEffect(() => {\n if (memoisedOptions?.enabled === false || !isScopeActive(enabledScopes, memoisedOptions?.scopes)) {\n return\n }\n\n const listener = (e: KeyboardEvent, isKeyUp = false) => {\n if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions?.enableOnFormTags)) {\n return\n }\n\n // 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\n // REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.\n if (ref.current !== null) {\n const rootNode = ref.current.getRootNode()\n if (\n (rootNode instanceof Document || rootNode instanceof ShadowRoot) &&\n rootNode.activeElement !== ref.current &&\n !ref.current.contains(rootNode.activeElement)\n ) {\n stopPropagation(e)\n return\n }\n }\n\n if ((e.target as HTMLElement)?.isContentEditable && !memoisedOptions?.enableOnContentEditable) {\n return\n }\n\n parseKeysHookInput(_keys, memoisedOptions?.splitKey).forEach((key) => {\n const hotkey = parseHotkey(key, memoisedOptions?.combinationKey)\n\n if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) {\n if (memoisedOptions?.ignoreEventWhen?.(e)) {\n return\n }\n\n if (isKeyUp && hasTriggeredRef.current) {\n return\n }\n\n maybePreventDefault(e, hotkey, memoisedOptions?.preventDefault)\n\n if (!isHotkeyEnabled(e, hotkey, memoisedOptions?.enabled)) {\n stopPropagation(e)\n\n return\n }\n\n // Execute the user callback for that hotkey\n cbRef.current(e, hotkey)\n\n if (!isKeyUp) {\n hasTriggeredRef.current = true\n }\n }\n })\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n pushToCurrentlyPressedKeys(mapKey(event.code))\n\n if ((memoisedOptions?.keydown === undefined && memoisedOptions?.keyup !== true) || memoisedOptions?.keydown) {\n listener(event)\n }\n }\n\n const handleKeyUp = (event: KeyboardEvent) => {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n removeFromCurrentlyPressedKeys(mapKey(event.code))\n\n hasTriggeredRef.current = false\n\n if (memoisedOptions?.keyup) {\n listener(event, true)\n }\n }\n\n const domNode = ref.current || _options?.document || document\n\n // @ts-ignore\n domNode.addEventListener('keyup', handleKeyUp)\n // @ts-ignore\n domNode.addEventListener('keydown', handleKeyDown)\n\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions?.splitKey).forEach((key) =>\n proxy.addHotkey(parseHotkey(key, memoisedOptions?.combinationKey, memoisedOptions?.description))\n )\n }\n\n return () => {\n // @ts-ignore\n domNode.removeEventListener('keyup', handleKeyUp)\n // @ts-ignore\n domNode.removeEventListener('keydown', handleKeyDown)\n\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions?.splitKey).forEach((key) =>\n proxy.removeHotkey(parseHotkey(key, memoisedOptions?.combinationKey, memoisedOptions?.description))\n )\n }\n }\n }, [_keys, memoisedOptions, enabledScopes])\n\n return ref\n}\n","import { useRef } from 'react'\nimport deepEqual from './deepEqual'\n\nexport default function useDeepEqualMemo<T>(value: T) {\n const ref = useRef<T | undefined>(undefined)\n\n if (!deepEqual(ref.current, value)) {\n ref.current = value\n }\n\n return ref.current\n}\n","import { useCallback, useState } from 'react'\nimport { mapKey } from './parseHotkeys'\n\nexport default function useRecordHotkeys() {\n const [keys, setKeys] = useState(new Set<string>())\n const [isRecording, setIsRecording] = useState(false)\n\n const handler = useCallback((event: KeyboardEvent) => {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n event.preventDefault()\n event.stopPropagation()\n\n setKeys((prev) => {\n const newKeys = new Set(prev)\n\n newKeys.add(mapKey(event.code))\n\n return newKeys\n })\n }, [])\n\n const stop = useCallback(() => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handler)\n\n setIsRecording(false)\n }\n }, [handler])\n\n const start = useCallback(() => {\n setKeys(new Set<string>())\n\n if (typeof document !== 'undefined') {\n stop()\n\n document.addEventListener('keydown', handler)\n\n setIsRecording(true)\n }\n }, [handler, stop])\n\n const resetKeys = useCallback(() => {\n setKeys(new Set<string>())\n }, [])\n\n return [keys, { start, stop, resetKeys, isRecording }] as const\n}\n"],"names":["reservedModifierKeywords","mappedKeys","esc","return",".",",","-"," ","`","#","+","ShiftLeft","ShiftRight","AltLeft","AltRight","MetaLeft","MetaRight","OSLeft","OSRight","ControlLeft","ControlRight","mapKey","key","trim","toLowerCase","replace","parseKeysHookInput","keys","splitKey","split","parseHotkey","hotkey","combinationKey","description","toLocaleLowerCase","map","k","_extends","alt","includes","ctrl","shift","meta","mod","filter","document","addEventListener","e","undefined","pushToCurrentlyPressedKeys","code","removeFromCurrentlyPressedKeys","window","currentlyPressedKeys","clear","Set","isReadonlyArray","value","Array","isArray","isHotkeyPressed","every","has","hotkeyArray","forEach","isHotkeyModifier","add","isHotkeyEnabledOnTag","_ref","enabledOnTags","target","targetTagName","tagName","Boolean","some","tag","BoundHotkeysProxyProvider","createContext","BoundHotkeysProxyProviderProvider","_jsx","Provider","addHotkey","removeHotkey","children","deepEqual","x","y","Object","length","reduce","isEqual","HotkeysContext","hotkeys","enabledScopes","toggleScope","enableScope","disableScope","useHotkeysContext","useContext","stopPropagation","preventDefault","stopImmediatePropagation","useSafeLayoutEffect","useLayoutEffect","useEffect","initiallyActiveScopes","_ref$initiallyActiveS","_useState","useState","internalActiveScopes","setInternalActiveScopes","_useState2","boundHotkeys","setBoundHotkeys","useCallback","scope","prev","from","concat","s","addBoundHotkey","removeBoundHotkey","h","callback","options","dependencies","ref","useRef","hasTriggeredRef","_options","_keys","join","_deps","memoisedCB","cbRef","current","memoisedOptions","useDeepEqualMemo","proxy","enabled","scopes","activeScopes","console","warn","listener","isKeyUp","enableOnFormTags","rootNode","getRootNode","Document","ShadowRoot","activeElement","contains","_e$target","isContentEditable","enableOnContentEditable","ignoreModifiers","pressedKeyUppercase","ctrlKey","metaKey","shiftKey","altKey","keyCode","pressedKey","isHotkeyMatchingKeyboardEvent","_hotkey$keys","ignoreEventWhen","maybePreventDefault","isHotkeyEnabled","handleKeyDown","event","keydown","keyup","handleKeyUp","domNode","removeEventListener","setKeys","isRecording","setIsRecording","handler","newKeys","stop","start","resetKeys"],"mappings":"sSAEA,IAAMA,EAA2B,CAAC,QAAS,MAAO,OAAQ,MAAO,QAE3DC,EAAqC,CACzCC,IAAK,SACLC,OAAQ,QACRC,IAAK,SACLC,IAAK,QACLC,IAAK,QACLC,IAAK,QACLC,IAAK,YACLC,IAAK,YACLC,IAAK,eACLC,UAAW,QACXC,WAAY,QACZC,QAAS,MACTC,SAAU,MACVC,SAAU,OACVC,UAAW,OACXC,OAAQ,OACRC,QAAS,OACTC,YAAa,OACbC,aAAc,iBAGAC,EAAOC,GACrB,OAAQrB,EAAWqB,IAAQA,GACxBC,OACAC,cACAC,QAAQ,yBAA0B,aAOvBC,EAAmBC,EAAcC,GAC/C,gBAD+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AAoB,QAASF,GAErCC,EAAQC,oBAAoB,UAAWN,GAEnC/B,GACFhH,EAAmBwG,QAAOM,SAAAA,EAAiB5G,UAAUoC,SAAQ,SAAC1C,GAAG,OAC/DoH,EAAMxD,aAAapD,EAAYR,QAAKkH,SAAAA,EAAiBxG,qBAAgBwG,SAAAA,EAAiBvG,qBAI3F,CAACiG,EAAOM,EAAiB3C,IAErBiC,mEErKP,IAAAnB,EAAwBC,WAAS,IAAIrD,KAA9B5B,EAAIgF,KAAEqE,EAAOrE,KACpBI,EAAsCH,YAAS,GAAxCqE,EAAWlE,KAAEmE,EAAcnE,KAE5BoE,EAAUjE,eAAY,SAACwD,QACT1H,IAAd0H,EAAMpJ,MAKVoJ,EAAMtE,iBACNsE,EAAMvE,kBAEN6E,GAAQ,SAAC5D,GACP,IAAMgE,EAAU,IAAI7H,IAAI6D,GAIxB,OAFAgE,EAAQlH,IAAI7C,EAAOqJ,EAAMxH,OAElBkI,QAER,IAEGC,EAAOnE,eAAY,WACC,oBAAbrE,WACTA,SAASkI,oBAAoB,UAAWI,GAExCD,GAAe,MAEhB,CAACC,IAEEG,EAAQpE,eAAY,WACxB8D,EAAQ,IAAIzH,KAEY,oBAAbV,WACTwI,IAEAxI,SAASC,iBAAiB,UAAWqI,GAErCD,GAAe,MAEhB,CAACC,EAASE,IAEPE,EAAYrE,eAAY,WAC5B8D,EAAQ,IAAIzH,OACX,IAEH,MAAO,CAAC5B,EAAM,CAAE2J,MAAAA,EAAOD,KAAAA,EAAME,UAAAA,EAAWN,YAAAA"}
1
+ {"version":3,"file":"react-hotkeys-hook.cjs.production.min.js","sources":["../src/parseHotkeys.ts","../src/isHotkeyPressed.ts","../src/validators.ts","../src/BoundHotkeysProxyProvider.tsx","../src/deepEqual.ts","../src/HotkeysProvider.tsx","../src/useHotkeys.ts","../src/useDeepEqualMemo.ts","../src/useRecordHotkeys.ts"],"sourcesContent":["import { Hotkey, KeyboardModifiers } from './types'\n\nconst reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl', 'control']\n\nconst mappedKeys: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n left: 'arrowleft',\n right: 'arrowright',\n up: 'arrowup',\n down: 'arrowdown',\n ShiftLeft: 'shift',\n ShiftRight: 'shift',\n AltLeft: 'alt',\n AltRight: 'alt',\n MetaLeft: 'meta',\n MetaRight: 'meta',\n OSLeft: 'meta',\n OSRight: 'meta',\n ControlLeft: 'ctrl',\n ControlRight: 'ctrl',\n}\n\nexport function mapKey(key: string): string {\n return (mappedKeys[key.trim()] || key.trim()).toLowerCase().replace(/key|digit|numpad/, '')\n}\n\nexport function isHotkeyModifier(key: string) {\n return reservedModifierKeywords.includes(key)\n}\n\nexport function parseKeysHookInput(keys: string, delimiter = ','): string[] {\n return keys.toLowerCase().split(delimiter)\n}\n\nexport function parseHotkey(hotkey: string, splitKey = '+', useKey = false, description?: string): Hotkey {\n const keys = hotkey\n .toLocaleLowerCase()\n .split(splitKey)\n .map((k) => mapKey(k))\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl') || keys.includes('control'),\n shift: keys.includes('shift'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n useKey,\n }\n\n const singleCharKeys = keys.filter((k) => !reservedModifierKeywords.includes(k))\n\n return {\n ...modifiers,\n keys: singleCharKeys,\n description,\n }\n}\n","import { isHotkeyModifier, mapKey } from './parseHotkeys'\n;(() => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', (e) => {\n if (e.code === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n pushToCurrentlyPressedKeys([mapKey(e.code)])\n })\n\n document.addEventListener('keyup', (e) => {\n if (e.code === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n removeFromCurrentlyPressedKeys([mapKey(e.code)])\n })\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('blur', () => {\n currentlyPressedKeys.clear()\n })\n }\n})()\n\nconst currentlyPressedKeys: Set<string> = new Set<string>()\n\n// https://github.com/microsoft/TypeScript/issues/17002\nexport function isReadonlyArray(value: unknown): value is readonly unknown[] {\n return Array.isArray(value)\n}\n\nexport function isHotkeyPressed(key: string | readonly string[], delimiter = ','): boolean {\n const hotkeyArray = isReadonlyArray(key) ? key : key.split(delimiter)\n\n return hotkeyArray.every((hotkey) => currentlyPressedKeys.has(hotkey.trim().toLowerCase()))\n}\n\nexport function pushToCurrentlyPressedKeys(key: string | string[]): void {\n const hotkeyArray = Array.isArray(key) ? key : [key]\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (currentlyPressedKeys.has('meta')) {\n currentlyPressedKeys.forEach((key) => !isHotkeyModifier(key) && currentlyPressedKeys.delete(key.toLowerCase()))\n }\n\n hotkeyArray.forEach((hotkey) => currentlyPressedKeys.add(hotkey.toLowerCase()))\n}\n\nexport function removeFromCurrentlyPressedKeys(key: string | string[]): void {\n const hotkeyArray = Array.isArray(key) ? key : [key]\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (key === 'meta') {\n currentlyPressedKeys.clear()\n } else {\n hotkeyArray.forEach((hotkey) => currentlyPressedKeys.delete(hotkey.toLowerCase()))\n }\n}\n","import { FormTags, Hotkey, Scopes, Trigger } from './types'\nimport { isHotkeyPressed, isReadonlyArray } from './isHotkeyPressed'\nimport { mapKey } from './parseHotkeys'\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(\n { target }: KeyboardEvent,\n enabledOnTags: readonly FormTags[] | boolean = false\n): boolean {\n const targetTagName = target && (target as HTMLElement).tagName\n\n if (isReadonlyArray(enabledOnTags)) {\n return Boolean(\n targetTagName && enabledOnTags && enabledOnTags.some((tag) => tag.toLowerCase() === targetTagName.toLowerCase())\n )\n }\n\n return Boolean(targetTagName && enabledOnTags && enabledOnTags)\n}\n\nexport function isScopeActive(activeScopes: string[], scopes?: Scopes): boolean {\n if (activeScopes.length === 0 && scopes) {\n console.warn(\n '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>'\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, ignoreModifiers = false): boolean => {\n const { alt, meta, mod, shift, ctrl, keys, useKey } = hotkey\n const { code, key: producedKey, ctrlKey, metaKey, shiftKey, altKey } = e\n\n const mappedCode = mapKey(code)\n\n if (useKey && keys?.length === 1 && keys.includes(producedKey)) {\n return true\n }\n\n if (\n !keys?.includes(mappedCode) &&\n !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(mappedCode)\n ) {\n return false\n }\n\n if (!ignoreModifiers) {\n // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.\n if (alt !== altKey && mappedCode !== 'alt') {\n return false\n }\n\n if (shift !== shiftKey && mappedCode !== '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 (meta !== metaKey && mappedCode !== 'meta' && mappedCode !== 'os') {\n return false\n }\n\n if (ctrl !== ctrlKey && mappedCode !== 'ctrl' && mappedCode !== 'control') {\n return false\n }\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(mappedCode)) {\n return true\n } else if (keys) {\n // Check if all keys are present in pressedDownKeys set\n return isHotkeyPressed(keys)\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 { createContext, ReactNode, useContext } from 'react'\nimport { Hotkey } from './types'\n\ntype BoundHotkeysProxyProviderType = {\n addHotkey: (hotkey: Hotkey) => void\n removeHotkey: (hotkey: Hotkey) => void\n}\n\nconst BoundHotkeysProxyProvider = createContext<BoundHotkeysProxyProviderType | undefined>(undefined)\n\nexport const useBoundHotkeysProxy = () => {\n return useContext(BoundHotkeysProxyProvider)\n}\n\ninterface Props {\n children: ReactNode\n addHotkey: (hotkey: Hotkey) => void\n removeHotkey: (hotkey: Hotkey) => void\n}\n\nexport default function BoundHotkeysProxyProviderProvider({ addHotkey, removeHotkey, children }: Props) {\n return (\n <BoundHotkeysProxyProvider.Provider value={{ addHotkey, removeHotkey }}>\n {children}\n </BoundHotkeysProxyProvider.Provider>\n )\n}\n","export default function deepEqual(x: any, y: any): boolean {\n //@ts-ignore\n return x && y && typeof x === 'object' && typeof y === 'object'\n ? Object.keys(x).length === Object.keys(y).length &&\n //@ts-ignore\n Object.keys(x).reduce((isEqual, key) => isEqual && deepEqual(x[key], y[key]), true)\n : x === y\n}\n","import { Hotkey } from './types'\nimport { createContext, ReactNode, useState, useContext, useCallback } from 'react'\nimport BoundHotkeysProxyProviderProvider from './BoundHotkeysProxyProvider'\nimport deepEqual from './deepEqual'\n\nexport type HotkeysContextType = {\n hotkeys: ReadonlyArray<Hotkey>\n activeScopes: string[]\n toggleScope: (scope: string) => void\n enableScope: (scope: string) => void\n disableScope: (scope: string) => void\n}\n\n// The context is only needed for special features like global scoping, so we use a graceful default fallback\nconst HotkeysContext = createContext<HotkeysContextType>({\n hotkeys: [],\n activeScopes: [], // This array has to be empty instead of containing '*' as default, to check if the provider is set or not\n toggleScope: () => {},\n enableScope: () => {},\n disableScope: () => {},\n})\n\nexport const useHotkeysContext = () => {\n return useContext(HotkeysContext)\n}\n\ninterface Props {\n initiallyActiveScopes?: string[]\n children: ReactNode\n}\n\nexport const HotkeysProvider = ({ initiallyActiveScopes = ['*'], children }: Props) => {\n const [internalActiveScopes, setInternalActiveScopes] = useState(initiallyActiveScopes)\n const [boundHotkeys, setBoundHotkeys] = useState<Hotkey[]>([])\n\n const enableScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.includes('*')) {\n return [scope]\n }\n return Array.from(new Set([...prev, scope]))\n })\n }, [])\n\n const disableScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n return prev.filter((s) => s !== scope)\n })\n }, [])\n\n const toggleScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.includes(scope)) {\n return prev.filter((s) => s !== scope)\n } else {\n if (prev.includes('*')) {\n return [scope]\n }\n return Array.from(new Set([...prev, scope]))\n }\n })\n }, [])\n\n const addBoundHotkey = useCallback((hotkey: Hotkey) => {\n setBoundHotkeys((prev) => [...prev, hotkey])\n }, [])\n\n const removeBoundHotkey = useCallback((hotkey: Hotkey) => {\n setBoundHotkeys((prev) => prev.filter((h) => !deepEqual(h, hotkey)))\n }, [])\n\n return (\n <HotkeysContext.Provider\n value={{ activeScopes: internalActiveScopes, hotkeys: boundHotkeys, enableScope, disableScope, toggleScope }}\n >\n <BoundHotkeysProxyProviderProvider addHotkey={addBoundHotkey} removeHotkey={removeBoundHotkey}>\n {children}\n </BoundHotkeysProxyProviderProvider>\n </HotkeysContext.Provider>\n )\n}\n","import { HotkeyCallback, Keys, Options, OptionsOrDependencyArray, RefType } from './types'\nimport { DependencyList, useCallback, useEffect, useLayoutEffect, useRef } from 'react'\nimport { mapKey, parseHotkey, parseKeysHookInput } from './parseHotkeys'\nimport {\n isHotkeyEnabled,\n isHotkeyEnabledOnTag,\n isHotkeyMatchingKeyboardEvent,\n isKeyboardEventTriggeredByInput,\n isScopeActive,\n maybePreventDefault,\n} from './validators'\nimport { useHotkeysContext } from './HotkeysProvider'\nimport { useBoundHotkeysProxy } from './BoundHotkeysProxyProvider'\nimport useDeepEqualMemo from './useDeepEqualMemo'\nimport { isReadonlyArray, pushToCurrentlyPressedKeys, removeFromCurrentlyPressedKeys } from './isHotkeyPressed'\n\nconst stopPropagation = (e: KeyboardEvent): void => {\n e.stopPropagation()\n e.preventDefault()\n e.stopImmediatePropagation()\n}\n\nconst useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\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 hasTriggeredRef = useRef(false)\n\n const _options: Options | undefined = !(options instanceof Array)\n ? (options as Options)\n : !(dependencies instanceof Array)\n ? (dependencies as Options)\n : undefined\n const _keys: string = isReadonlyArray(keys) ? keys.join(_options?.delimiter) : keys\n const _deps: DependencyList | undefined =\n options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined\n\n const memoisedCB = useCallback(callback, _deps ?? [])\n const cbRef = useRef<HotkeyCallback>(memoisedCB)\n\n if (_deps) {\n cbRef.current = memoisedCB\n } else {\n cbRef.current = callback\n }\n\n const memoisedOptions = useDeepEqualMemo(_options)\n\n const { activeScopes } = useHotkeysContext()\n const proxy = useBoundHotkeysProxy()\n\n useSafeLayoutEffect(() => {\n if (memoisedOptions?.enabled === false || !isScopeActive(activeScopes, memoisedOptions?.scopes)) {\n return\n }\n\n const listener = (e: KeyboardEvent, isKeyUp = false) => {\n if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions?.enableOnFormTags)) {\n return\n }\n\n // 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\n // REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.\n if (ref.current !== null) {\n const rootNode = ref.current.getRootNode()\n\n if (\n (rootNode instanceof Document || rootNode instanceof ShadowRoot) &&\n rootNode.activeElement !== ref.current &&\n !ref.current.contains(rootNode.activeElement)\n ) {\n stopPropagation(e)\n return\n }\n }\n\n if ((e.target as HTMLElement)?.isContentEditable && !memoisedOptions?.enableOnContentEditable) {\n return\n }\n\n parseKeysHookInput(_keys, memoisedOptions?.delimiter).forEach((key) => {\n const hotkey = parseHotkey(key, memoisedOptions?.splitKey, memoisedOptions?.useKey)\n\n if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) {\n if (memoisedOptions?.ignoreEventWhen?.(e)) {\n return\n }\n\n if (isKeyUp && hasTriggeredRef.current) {\n return\n }\n\n maybePreventDefault(e, hotkey, memoisedOptions?.preventDefault)\n\n if (!isHotkeyEnabled(e, hotkey, memoisedOptions?.enabled)) {\n stopPropagation(e)\n\n return\n }\n\n // Execute the user callback for that hotkey\n cbRef.current(e, hotkey)\n\n if (!isKeyUp) {\n hasTriggeredRef.current = true\n }\n }\n })\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.code === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n pushToCurrentlyPressedKeys(mapKey(event.code))\n\n if ((memoisedOptions?.keydown === undefined && memoisedOptions?.keyup !== true) || memoisedOptions?.keydown) {\n listener(event)\n }\n }\n\n const handleKeyUp = (event: KeyboardEvent) => {\n if (event.code === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n removeFromCurrentlyPressedKeys(mapKey(event.code))\n\n hasTriggeredRef.current = false\n\n if (memoisedOptions?.keyup) {\n listener(event, true)\n }\n }\n\n const domNode = ref.current || _options?.document || document\n\n // @ts-ignore\n domNode.addEventListener('keyup', handleKeyUp)\n // @ts-ignore\n domNode.addEventListener('keydown', handleKeyDown)\n\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions?.delimiter).forEach((key) =>\n proxy.addHotkey(\n parseHotkey(key, memoisedOptions?.splitKey, memoisedOptions?.useKey, memoisedOptions?.description)\n )\n )\n }\n\n return () => {\n // @ts-ignore\n domNode.removeEventListener('keyup', handleKeyUp)\n // @ts-ignore\n domNode.removeEventListener('keydown', handleKeyDown)\n\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions?.delimiter).forEach((key) =>\n proxy.removeHotkey(\n parseHotkey(key, memoisedOptions?.splitKey, memoisedOptions?.useKey, memoisedOptions?.description)\n )\n )\n }\n }\n }, [_keys, memoisedOptions, activeScopes])\n\n return ref\n}\n","import { useRef } from 'react'\nimport deepEqual from './deepEqual'\n\nexport default function useDeepEqualMemo<T>(value: T) {\n const ref = useRef<T | undefined>(undefined)\n\n if (!deepEqual(ref.current, value)) {\n ref.current = value\n }\n\n return ref.current\n}\n","import { useCallback, useState } from 'react'\nimport { mapKey } from './parseHotkeys'\n\nexport default function useRecordHotkeys() {\n const [keys, setKeys] = useState(new Set<string>())\n const [isRecording, setIsRecording] = useState(false)\n\n const handler = useCallback((event: KeyboardEvent) => {\n if (event.code === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n event.preventDefault()\n event.stopPropagation()\n\n setKeys((prev) => {\n const newKeys = new Set(prev)\n\n newKeys.add(mapKey(event.code))\n\n return newKeys\n })\n }, [])\n\n const stop = useCallback(() => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handler)\n\n setIsRecording(false)\n }\n }, [handler])\n\n const start = useCallback(() => {\n setKeys(new Set<string>())\n\n if (typeof document !== 'undefined') {\n stop()\n\n document.addEventListener('keydown', handler)\n\n setIsRecording(true)\n }\n }, [handler, stop])\n\n const resetKeys = useCallback(() => {\n setKeys(new Set<string>())\n }, [])\n\n return [keys, { start, stop, resetKeys, isRecording }] as const\n}\n"],"names":["reservedModifierKeywords","mappedKeys","esc","return","left","right","up","down","ShiftLeft","ShiftRight","AltLeft","AltRight","MetaLeft","MetaRight","OSLeft","OSRight","ControlLeft","ControlRight","mapKey","key","trim","toLowerCase","replace","parseKeysHookInput","keys","delimiter","split","parseHotkey","hotkey","splitKey","useKey","description","toLocaleLowerCase","map","k","_extends","alt","includes","ctrl","shift","meta","mod","filter","document","addEventListener","e","undefined","code","pushToCurrentlyPressedKeys","removeFromCurrentlyPressedKeys","window","currentlyPressedKeys","clear","Set","isReadonlyArray","value","Array","isArray","isHotkeyPressed","every","has","hotkeyArray","forEach","isHotkeyModifier","add","isHotkeyEnabledOnTag","_ref","enabledOnTags","target","targetTagName","tagName","Boolean","some","tag","BoundHotkeysProxyProvider","createContext","BoundHotkeysProxyProviderProvider","_jsx","Provider","addHotkey","removeHotkey","children","deepEqual","x","y","Object","length","reduce","isEqual","HotkeysContext","hotkeys","activeScopes","toggleScope","enableScope","disableScope","useHotkeysContext","useContext","stopPropagation","preventDefault","stopImmediatePropagation","useSafeLayoutEffect","useLayoutEffect","useEffect","initiallyActiveScopes","_useState","useState","_ref$initiallyActiveS","internalActiveScopes","setInternalActiveScopes","_useState2","boundHotkeys","setBoundHotkeys","useCallback","scope","prev","from","concat","s","addBoundHotkey","removeBoundHotkey","h","callback","options","dependencies","ref","useRef","hasTriggeredRef","_options","_keys","join","_deps","memoisedCB","cbRef","current","memoisedOptions","useDeepEqualMemo","proxy","enabled","scopes","console","warn","isScopeActive","listener","isKeyUp","enableOnFormTags","rootNode","getRootNode","Document","ShadowRoot","activeElement","contains","_e$target","isContentEditable","enableOnContentEditable","ignoreModifiers","producedKey","ctrlKey","metaKey","shiftKey","altKey","mappedCode","isHotkeyMatchingKeyboardEvent","_hotkey$keys","ignoreEventWhen","maybePreventDefault","isHotkeyEnabled","handleKeyDown","event","keydown","keyup","handleKeyUp","domNode","removeEventListener","setKeys","isRecording","setIsRecording","handler","newKeys","stop","start","resetKeys"],"mappings":"sSAEA,IAAMA,EAA2B,CAAC,QAAS,MAAO,OAAQ,MAAO,OAAQ,WAEnEC,EAAqC,CACzCC,IAAK,SACLC,OAAQ,QACRC,KAAM,YACNC,MAAO,aACPC,GAAI,UACJC,KAAM,YACNC,UAAW,QACXC,WAAY,QACZC,QAAS,MACTC,SAAU,MACVC,SAAU,OACVC,UAAW,OACXC,OAAQ,OACRC,QAAS,OACTC,YAAa,OACbC,aAAc,iBAGAC,EAAOC,GACrB,OAAQlB,EAAWkB,EAAIC,SAAWD,EAAIC,QAAQC,cAAcC,QAAQ,mBAAoB,aAO1EC,EAAmBC,EAAcC,GAC/C,gBAD+CA,IAAAA,EAAY,KACpDD,EAAKH,cAAcK,MAAMD,YAGlBE,EAAYC,EAAgBC,EAAgBC,EAAgBC,YAAhCF,IAAAA,EAAW,cAAKC,IAAAA,GAAS,GACnE,IAAMN,EAAOI,EACVI,oBACAN,MAAMG,GACNI,KAAI,SAACC,GAAC,OAAKhB,EAAOgB,MAarB,OAAAC,KAXqC,CACnCC,IAAKZ,EAAKa,SAAS,OACnBC,KAAMd,EAAKa,SAAS,SAAWb,EAAKa,SAAS,WAC7CE,MAAOf,EAAKa,SAAS,SACrBG,KAAMhB,EAAKa,SAAS,QACpBI,IAAKjB,EAAKa,SAAS,OACnBP,OAAAA,IAOAN,KAJqBA,EAAKkB,QAAO,SAACR,GAAC,OAAMlC,EAAyBqC,SAASH,MAK3EH,YAAAA,ICrDsB,oBAAbY,WACTA,SAASC,iBAAiB,WAAW,SAACC,QACrBC,IAAXD,EAAEE,MAKNC,EAA2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,eAAY,WACxB6D,EAAQ,IAAIxH,KAEY,oBAAbV,WACTuI,IAEAvI,SAASC,iBAAiB,UAAWoI,GAErCD,GAAe,MAEhB,CAACC,EAASE,IAEPE,EAAYpE,eAAY,WAC5B6D,EAAQ,IAAIxH,OACX,IAEH,MAAO,CAAC7B,EAAM,CAAE2J,MAAAA,EAAOD,KAAAA,EAAME,UAAAA,EAAWN,YAAAA"}
@@ -16,17 +16,14 @@ function _extends() {
16
16
  return _extends.apply(this, arguments);
17
17
  }
18
18
 
19
- var reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl'];
19
+ var reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl', 'control'];
20
20
  var mappedKeys = {
21
21
  esc: 'escape',
22
22
  "return": 'enter',
23
- '.': 'period',
24
- ',': 'comma',
25
- '-': 'slash',
26
- ' ': 'space',
27
- '`': 'backquote',
28
- '#': 'backslash',
29
- '+': 'bracketright',
23
+ left: 'arrowleft',
24
+ right: 'arrowright',
25
+ up: 'arrowup',
26
+ down: 'arrowdown',
30
27
  ShiftLeft: 'shift',
31
28
  ShiftRight: 'shift',
32
29
  AltLeft: 'alt',
@@ -39,22 +36,25 @@ var mappedKeys = {
39
36
  ControlRight: 'ctrl'
40
37
  };
41
38
  function mapKey(key) {
42
- return (mappedKeys[key] || key).trim().toLowerCase().replace(/key|digit|numpad|arrow/, '');
39
+ return (mappedKeys[key.trim()] || key.trim()).toLowerCase().replace(/key|digit|numpad/, '');
43
40
  }
44
41
  function isHotkeyModifier(key) {
45
42
  return reservedModifierKeywords.includes(key);
46
43
  }
47
- function parseKeysHookInput(keys, splitKey) {
48
- if (splitKey === void 0) {
49
- splitKey = ',';
44
+ function parseKeysHookInput(keys, delimiter) {
45
+ if (delimiter === void 0) {
46
+ delimiter = ',';
50
47
  }
51
- return keys.split(splitKey);
48
+ return keys.toLowerCase().split(delimiter);
52
49
  }
53
- function parseHotkey(hotkey, combinationKey, description) {
54
- if (combinationKey === void 0) {
55
- combinationKey = '+';
50
+ function parseHotkey(hotkey, splitKey, useKey, description) {
51
+ if (splitKey === void 0) {
52
+ splitKey = '+';
53
+ }
54
+ if (useKey === void 0) {
55
+ useKey = false;
56
56
  }
57
- var keys = hotkey.toLocaleLowerCase().split(combinationKey).map(function (k) {
57
+ var keys = hotkey.toLocaleLowerCase().split(splitKey).map(function (k) {
58
58
  return mapKey(k);
59
59
  });
60
60
  var modifiers = {
@@ -62,7 +62,8 @@ function parseHotkey(hotkey, combinationKey, description) {
62
62
  ctrl: keys.includes('ctrl') || keys.includes('control'),
63
63
  shift: keys.includes('shift'),
64
64
  meta: keys.includes('meta'),
65
- mod: keys.includes('mod')
65
+ mod: keys.includes('mod'),
66
+ useKey: useKey
66
67
  };
67
68
  var singleCharKeys = keys.filter(function (k) {
68
69
  return !reservedModifierKeywords.includes(k);
@@ -76,18 +77,18 @@ function parseHotkey(hotkey, combinationKey, description) {
76
77
  (function () {
77
78
  if (typeof document !== 'undefined') {
78
79
  document.addEventListener('keydown', function (e) {
79
- if (e.key === undefined) {
80
- // Synthetic event (e.g., Chrome autofill). Ignore.
80
+ if (e.code === undefined) {
81
+ // Synthetic event (e.g., Chrome autofill). Ignore.
81
82
  return;
82
83
  }
83
- pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
84
+ pushToCurrentlyPressedKeys([mapKey(e.code)]);
84
85
  });
85
86
  document.addEventListener('keyup', function (e) {
86
- if (e.key === undefined) {
87
- // Synthetic event (e.g., Chrome autofill). Ignore.
87
+ if (e.code === undefined) {
88
+ // Synthetic event (e.g., Chrome autofill). Ignore.
88
89
  return;
89
90
  }
90
- removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
91
+ removeFromCurrentlyPressedKeys([mapKey(e.code)]);
91
92
  });
92
93
  }
93
94
  if (typeof window !== 'undefined') {
@@ -101,11 +102,11 @@ var currentlyPressedKeys = /*#__PURE__*/new Set();
101
102
  function isReadonlyArray(value) {
102
103
  return Array.isArray(value);
103
104
  }
104
- function isHotkeyPressed(key, splitKey) {
105
- if (splitKey === void 0) {
106
- splitKey = ',';
105
+ function isHotkeyPressed(key, delimiter) {
106
+ if (delimiter === void 0) {
107
+ delimiter = ',';
107
108
  }
108
- var hotkeyArray = isReadonlyArray(key) ? key : key.split(splitKey);
109
+ var hotkeyArray = isReadonlyArray(key) ? key : key.split(delimiter);
109
110
  return hotkeyArray.every(function (hotkey) {
110
111
  return currentlyPressedKeys.has(hotkey.trim().toLowerCase());
111
112
  });
@@ -167,7 +168,7 @@ function isHotkeyEnabledOnTag(_ref, enabledOnTags) {
167
168
  return tag.toLowerCase() === targetTagName.toLowerCase();
168
169
  }));
169
170
  }
170
- return Boolean(targetTagName && enabledOnTags && enabledOnTags === true);
171
+ return Boolean(targetTagName && enabledOnTags && enabledOnTags);
171
172
  }
172
173
  function isScopeActive(activeScopes, scopes) {
173
174
  if (activeScopes.length === 0 && scopes) {
@@ -190,24 +191,27 @@ var isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, ho
190
191
  mod = hotkey.mod,
191
192
  shift = hotkey.shift,
192
193
  ctrl = hotkey.ctrl,
193
- keys = hotkey.keys;
194
- var pressedKeyUppercase = e.key,
195
- code = e.code,
194
+ keys = hotkey.keys,
195
+ useKey = hotkey.useKey;
196
+ var code = e.code,
197
+ producedKey = e.key,
196
198
  ctrlKey = e.ctrlKey,
197
199
  metaKey = e.metaKey,
198
200
  shiftKey = e.shiftKey,
199
201
  altKey = e.altKey;
200
- var keyCode = mapKey(code);
201
- var pressedKey = pressedKeyUppercase.toLowerCase();
202
- if (!(keys != null && keys.includes(keyCode)) && !(keys != null && keys.includes(pressedKey)) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(keyCode)) {
202
+ var mappedCode = mapKey(code);
203
+ if (useKey && (keys == null ? void 0 : keys.length) === 1 && keys.includes(producedKey)) {
204
+ return true;
205
+ }
206
+ if (!(keys != null && keys.includes(mappedCode)) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(mappedCode)) {
203
207
  return false;
204
208
  }
205
209
  if (!ignoreModifiers) {
206
210
  // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.
207
- if (alt === !altKey && pressedKey !== 'alt') {
211
+ if (alt !== altKey && mappedCode !== 'alt') {
208
212
  return false;
209
213
  }
210
- if (shift === !shiftKey && pressedKey !== 'shift') {
214
+ if (shift !== shiftKey && mappedCode !== 'shift') {
211
215
  return false;
212
216
  }
213
217
  // Mod is a special key name that is checking for meta on macOS and ctrl on other platforms
@@ -216,17 +220,17 @@ var isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, ho
216
220
  return false;
217
221
  }
218
222
  } else {
219
- if (meta === !metaKey && pressedKey !== 'meta' && pressedKey !== 'os') {
223
+ if (meta !== metaKey && mappedCode !== 'meta' && mappedCode !== 'os') {
220
224
  return false;
221
225
  }
222
- if (ctrl === !ctrlKey && pressedKey !== 'ctrl' && pressedKey !== 'control') {
226
+ if (ctrl !== ctrlKey && mappedCode !== 'ctrl' && mappedCode !== 'control') {
223
227
  return false;
224
228
  }
225
229
  }
226
230
  }
227
231
  // All modifiers are correct, now check the key
228
232
  // If the key is set, we check for the key
229
- if (keys && keys.length === 1 && (keys.includes(pressedKey) || keys.includes(keyCode))) {
233
+ if (keys && keys.length === 1 && keys.includes(mappedCode)) {
230
234
  return true;
231
235
  } else if (keys) {
232
236
  // Check if all keys are present in pressedDownKeys set
@@ -267,7 +271,7 @@ function deepEqual(x, y) {
267
271
 
268
272
  var HotkeysContext = /*#__PURE__*/createContext({
269
273
  hotkeys: [],
270
- enabledScopes: [],
274
+ activeScopes: [],
271
275
  toggleScope: function toggleScope() {},
272
276
  enableScope: function enableScope() {},
273
277
  disableScope: function disableScope() {}
@@ -279,7 +283,7 @@ var HotkeysProvider = function HotkeysProvider(_ref) {
279
283
  var _ref$initiallyActiveS = _ref.initiallyActiveScopes,
280
284
  initiallyActiveScopes = _ref$initiallyActiveS === void 0 ? ['*'] : _ref$initiallyActiveS,
281
285
  children = _ref.children;
282
- var _useState = useState((initiallyActiveScopes == null ? void 0 : initiallyActiveScopes.length) > 0 ? initiallyActiveScopes : ['*']),
286
+ var _useState = useState(initiallyActiveScopes),
283
287
  internalActiveScopes = _useState[0],
284
288
  setInternalActiveScopes = _useState[1];
285
289
  var _useState2 = useState([]),
@@ -295,29 +299,17 @@ var HotkeysProvider = function HotkeysProvider(_ref) {
295
299
  }, []);
296
300
  var disableScope = useCallback(function (scope) {
297
301
  setInternalActiveScopes(function (prev) {
298
- if (prev.filter(function (s) {
302
+ return prev.filter(function (s) {
299
303
  return s !== scope;
300
- }).length === 0) {
301
- return ['*'];
302
- } else {
303
- return prev.filter(function (s) {
304
- return s !== scope;
305
- });
306
- }
304
+ });
307
305
  });
308
306
  }, []);
309
307
  var toggleScope = useCallback(function (scope) {
310
308
  setInternalActiveScopes(function (prev) {
311
309
  if (prev.includes(scope)) {
312
- if (prev.filter(function (s) {
310
+ return prev.filter(function (s) {
313
311
  return s !== scope;
314
- }).length === 0) {
315
- return ['*'];
316
- } else {
317
- return prev.filter(function (s) {
318
- return s !== scope;
319
- });
320
- }
312
+ });
321
313
  } else {
322
314
  if (prev.includes('*')) {
323
315
  return [scope];
@@ -340,7 +332,7 @@ var HotkeysProvider = function HotkeysProvider(_ref) {
340
332
  }, []);
341
333
  return /*#__PURE__*/jsx(HotkeysContext.Provider, {
342
334
  value: {
343
- enabledScopes: internalActiveScopes,
335
+ activeScopes: internalActiveScopes,
344
336
  hotkeys: boundHotkeys,
345
337
  enableScope: enableScope,
346
338
  disableScope: disableScope,
@@ -372,7 +364,7 @@ function useHotkeys(keys, callback, options, dependencies) {
372
364
  var ref = useRef(null);
373
365
  var hasTriggeredRef = useRef(false);
374
366
  var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined;
375
- var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.splitKey) : keys;
367
+ var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.delimiter) : keys;
376
368
  var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined;
377
369
  var memoisedCB = useCallback(callback, _deps != null ? _deps : []);
378
370
  var cbRef = useRef(memoisedCB);
@@ -383,10 +375,10 @@ function useHotkeys(keys, callback, options, dependencies) {
383
375
  }
384
376
  var memoisedOptions = useDeepEqualMemo(_options);
385
377
  var _useHotkeysContext = useHotkeysContext(),
386
- enabledScopes = _useHotkeysContext.enabledScopes;
378
+ activeScopes = _useHotkeysContext.activeScopes;
387
379
  var proxy = useBoundHotkeysProxy();
388
380
  useSafeLayoutEffect(function () {
389
- if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(enabledScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) {
381
+ if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(activeScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) {
390
382
  return;
391
383
  }
392
384
  var listener = function listener(e, isKeyUp) {
@@ -409,9 +401,9 @@ function useHotkeys(keys, callback, options, dependencies) {
409
401
  if ((_e$target = e.target) != null && _e$target.isContentEditable && !(memoisedOptions != null && memoisedOptions.enableOnContentEditable)) {
410
402
  return;
411
403
  }
412
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {
404
+ parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.delimiter).forEach(function (key) {
413
405
  var _hotkey$keys;
414
- var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey);
406
+ var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.splitKey, memoisedOptions == null ? void 0 : memoisedOptions.useKey);
415
407
  if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.ignoreModifiers) || (_hotkey$keys = hotkey.keys) != null && _hotkey$keys.includes('*')) {
416
408
  if (memoisedOptions != null && memoisedOptions.ignoreEventWhen != null && memoisedOptions.ignoreEventWhen(e)) {
417
409
  return;
@@ -433,7 +425,7 @@ function useHotkeys(keys, callback, options, dependencies) {
433
425
  });
434
426
  };
435
427
  var handleKeyDown = function handleKeyDown(event) {
436
- if (event.key === undefined) {
428
+ if (event.code === undefined) {
437
429
  // Synthetic event (e.g., Chrome autofill). Ignore.
438
430
  return;
439
431
  }
@@ -443,7 +435,7 @@ function useHotkeys(keys, callback, options, dependencies) {
443
435
  }
444
436
  };
445
437
  var handleKeyUp = function handleKeyUp(event) {
446
- if (event.key === undefined) {
438
+ if (event.code === undefined) {
447
439
  // Synthetic event (e.g., Chrome autofill). Ignore.
448
440
  return;
449
441
  }
@@ -459,8 +451,8 @@ function useHotkeys(keys, callback, options, dependencies) {
459
451
  // @ts-ignore
460
452
  domNode.addEventListener('keydown', handleKeyDown);
461
453
  if (proxy) {
462
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {
463
- return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
454
+ parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.delimiter).forEach(function (key) {
455
+ return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.splitKey, memoisedOptions == null ? void 0 : memoisedOptions.useKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
464
456
  });
465
457
  }
466
458
  return function () {
@@ -469,12 +461,12 @@ function useHotkeys(keys, callback, options, dependencies) {
469
461
  // @ts-ignore
470
462
  domNode.removeEventListener('keydown', handleKeyDown);
471
463
  if (proxy) {
472
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {
473
- return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
464
+ parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.delimiter).forEach(function (key) {
465
+ return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.splitKey, memoisedOptions == null ? void 0 : memoisedOptions.useKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
474
466
  });
475
467
  }
476
468
  };
477
- }, [_keys, memoisedOptions, enabledScopes]);
469
+ }, [_keys, memoisedOptions, activeScopes]);
478
470
  return ref;
479
471
  }
480
472
 
@@ -486,7 +478,7 @@ function useRecordHotkeys() {
486
478
  isRecording = _useState2[0],
487
479
  setIsRecording = _useState2[1];
488
480
  var handler = useCallback(function (event) {
489
- if (event.key === undefined) {
481
+ if (event.code === undefined) {
490
482
  // Synthetic event (e.g., Chrome autofill). Ignore.
491
483
  return;
492
484
  }