@tanstack/react-hotkeys 0.11.0 → 0.12.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.
- package/dist/HotkeysProvider.d.ts +6 -12
- package/dist/HotkeysProvider.js +1 -2
- package/dist/useHeldKeyCodes.d.ts +2 -4
- package/dist/useHeldKeyCodes.js +3 -3
- package/dist/useHeldKeys.d.ts +2 -4
- package/dist/useHeldKeys.js +3 -3
- package/dist/useHotkey.d.ts +3 -6
- package/dist/useHotkey.js +3 -3
- package/dist/useHotkeyHint.d.ts +2 -5
- package/dist/useHotkeyHint.js +1 -2
- package/dist/useHotkeyRecorder.d.ts +3 -6
- package/dist/useHotkeyRecorder.js +1 -2
- package/dist/useHotkeyRegistrations.d.ts +3 -6
- package/dist/useHotkeyRegistrations.js +1 -2
- package/dist/useHotkeySequence.d.ts +3 -6
- package/dist/useHotkeySequence.js +1 -2
- package/dist/useHotkeySequenceRecorder.d.ts +3 -6
- package/dist/useHotkeySequenceRecorder.js +1 -2
- package/dist/useHotkeySequences.d.ts +3 -6
- package/dist/useHotkeySequences.js +1 -2
- package/dist/useHotkeys.d.ts +3 -6
- package/dist/useHotkeys.js +1 -2
- package/dist/useKeyHold.d.ts +2 -5
- package/dist/useKeyHold.js +1 -2
- package/dist/utils.js +1 -2
- package/package.json +14 -19
- package/dist/HotkeysProvider.cjs +0 -23
- package/dist/HotkeysProvider.cjs.map +0 -1
- package/dist/HotkeysProvider.d.cts +0 -28
- package/dist/HotkeysProvider.js.map +0 -1
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/index.cjs +0 -35
- package/dist/index.d.cts +0 -14
- package/dist/useHeldKeyCodes.cjs +0 -38
- package/dist/useHeldKeyCodes.cjs.map +0 -1
- package/dist/useHeldKeyCodes.d.cts +0 -31
- package/dist/useHeldKeyCodes.js.map +0 -1
- package/dist/useHeldKeys.cjs +0 -34
- package/dist/useHeldKeys.cjs.map +0 -1
- package/dist/useHeldKeys.d.cts +0 -27
- package/dist/useHeldKeys.js.map +0 -1
- package/dist/useHotkey.cjs +0 -126
- package/dist/useHotkey.cjs.map +0 -1
- package/dist/useHotkey.d.cts +0 -74
- package/dist/useHotkey.js.map +0 -1
- package/dist/useHotkeyHint.cjs +0 -19
- package/dist/useHotkeyHint.cjs.map +0 -1
- package/dist/useHotkeyHint.d.cts +0 -14
- package/dist/useHotkeyHint.js.map +0 -1
- package/dist/useHotkeyRecorder.cjs +0 -72
- package/dist/useHotkeyRecorder.cjs.map +0 -1
- package/dist/useHotkeyRecorder.d.cts +0 -57
- package/dist/useHotkeyRecorder.js.map +0 -1
- package/dist/useHotkeyRegistrations.cjs +0 -49
- package/dist/useHotkeyRegistrations.cjs.map +0 -1
- package/dist/useHotkeyRegistrations.d.cts +0 -48
- package/dist/useHotkeyRegistrations.js.map +0 -1
- package/dist/useHotkeySequence.cjs +0 -121
- package/dist/useHotkeySequence.cjs.map +0 -1
- package/dist/useHotkeySequence.d.cts +0 -58
- package/dist/useHotkeySequence.js.map +0 -1
- package/dist/useHotkeySequenceRecorder.cjs +0 -42
- package/dist/useHotkeySequenceRecorder.cjs.map +0 -1
- package/dist/useHotkeySequenceRecorder.d.cts +0 -25
- package/dist/useHotkeySequenceRecorder.js.map +0 -1
- package/dist/useHotkeySequences.cjs +0 -127
- package/dist/useHotkeySequences.cjs.map +0 -1
- package/dist/useHotkeySequences.d.cts +0 -63
- package/dist/useHotkeySequences.js.map +0 -1
- package/dist/useHotkeys.cjs +0 -125
- package/dist/useHotkeys.cjs.map +0 -1
- package/dist/useHotkeys.d.cts +0 -63
- package/dist/useHotkeys.js.map +0 -1
- package/dist/useKeyHold.cjs +0 -54
- package/dist/useKeyHold.cjs.map +0 -1
- package/dist/useKeyHold.d.cts +0 -47
- package/dist/useKeyHold.js.map +0 -1
- package/dist/utils.cjs +0 -12
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
- package/src/HotkeysProvider.tsx +0 -58
- package/src/index.ts +0 -18
- package/src/useHeldKeyCodes.ts +0 -33
- package/src/useHeldKeys.ts +0 -29
- package/src/useHotkey.ts +0 -190
- package/src/useHotkeyHint.ts +0 -19
- package/src/useHotkeyRecorder.ts +0 -101
- package/src/useHotkeyRegistrations.ts +0 -67
- package/src/useHotkeySequence.ts +0 -191
- package/src/useHotkeySequenceRecorder.ts +0 -70
- package/src/useHotkeySequences.ts +0 -192
- package/src/useHotkeys.ts +0 -193
- package/src/useKeyHold.ts +0 -52
- package/src/utils.ts +0 -10
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/useHeldKeyCodes.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* React hook that returns a map of currently held key names to their physical `event.code` values.
|
|
4
|
-
*
|
|
5
|
-
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
6
|
-
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
7
|
-
*
|
|
8
|
-
* @returns Record mapping normalized key names to their `event.code` values
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* function KeyDebugDisplay() {
|
|
13
|
-
* const heldKeys = useHeldKeys()
|
|
14
|
-
* const heldCodes = useHeldKeyCodes()
|
|
15
|
-
*
|
|
16
|
-
* return (
|
|
17
|
-
* <div>
|
|
18
|
-
* {heldKeys.map((key) => (
|
|
19
|
-
* <kbd key={key}>
|
|
20
|
-
* {key} <small>{heldCodes[key]}</small>
|
|
21
|
-
* </kbd>
|
|
22
|
-
* ))}
|
|
23
|
-
* </div>
|
|
24
|
-
* )
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function useHeldKeyCodes(): Record<string, string>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { useHeldKeyCodes };
|
|
31
|
-
//# sourceMappingURL=useHeldKeyCodes.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHeldKeyCodes.js","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/react-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * React hook that returns a map of currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n *\n * return (\n * <div>\n * {heldKeys.map((key) => (\n * <kbd key={key}>\n * {key} <small>{heldCodes[key]}</small>\n * </kbd>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeyCodes(): Record<string, string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,kBAA0C;AAExD,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,UAAU"}
|
package/dist/useHeldKeys.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
3
|
-
let _tanstack_react_store = require("@tanstack/react-store");
|
|
4
|
-
|
|
5
|
-
//#region src/useHeldKeys.ts
|
|
6
|
-
/**
|
|
7
|
-
* React hook that returns an array of currently held keyboard keys.
|
|
8
|
-
*
|
|
9
|
-
* This hook uses `useSelector` from `@tanstack/react-store` to subscribe
|
|
10
|
-
* to the global KeyStateTracker and updates whenever keys are pressed
|
|
11
|
-
* or released.
|
|
12
|
-
*
|
|
13
|
-
* @returns Array of currently held key names
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* function KeyDisplay() {
|
|
18
|
-
* const heldKeys = useHeldKeys()
|
|
19
|
-
*
|
|
20
|
-
* return (
|
|
21
|
-
* <div>
|
|
22
|
-
* Currently pressed: {heldKeys.join(' + ') || 'None'}
|
|
23
|
-
* </div>
|
|
24
|
-
* )
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
function useHeldKeys() {
|
|
29
|
-
return (0, _tanstack_react_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
exports.useHeldKeys = useHeldKeys;
|
|
34
|
-
//# sourceMappingURL=useHeldKeys.cjs.map
|
package/dist/useHeldKeys.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHeldKeys.cjs","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useSelector } from '@tanstack/react-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * React hook that returns an array of currently held keyboard keys.\n *\n * This hook uses `useSelector` from `@tanstack/react-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Array of currently held key names\n *\n * @example\n * ```tsx\n * function KeyDisplay() {\n * const heldKeys = useHeldKeys()\n *\n * return (\n * <div>\n * Currently pressed: {heldKeys.join(' + ') || 'None'}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeys(): Array<string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAA6B;AAE3C,0FADoC,CACT,QAAQ,UAAU,MAAM,SAAS"}
|
package/dist/useHeldKeys.d.cts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//#region src/useHeldKeys.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* React hook that returns an array of currently held keyboard keys.
|
|
4
|
-
*
|
|
5
|
-
* This hook uses `useSelector` from `@tanstack/react-store` to subscribe
|
|
6
|
-
* to the global KeyStateTracker and updates whenever keys are pressed
|
|
7
|
-
* or released.
|
|
8
|
-
*
|
|
9
|
-
* @returns Array of currently held key names
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```tsx
|
|
13
|
-
* function KeyDisplay() {
|
|
14
|
-
* const heldKeys = useHeldKeys()
|
|
15
|
-
*
|
|
16
|
-
* return (
|
|
17
|
-
* <div>
|
|
18
|
-
* Currently pressed: {heldKeys.join(' + ') || 'None'}
|
|
19
|
-
* </div>
|
|
20
|
-
* )
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare function useHeldKeys(): Array<string>;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { useHeldKeys };
|
|
27
|
-
//# sourceMappingURL=useHeldKeys.d.cts.map
|
package/dist/useHeldKeys.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHeldKeys.js","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useSelector } from '@tanstack/react-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * React hook that returns an array of currently held keyboard keys.\n *\n * This hook uses `useSelector` from `@tanstack/react-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Array of currently held key names\n *\n * @example\n * ```tsx\n * function KeyDisplay() {\n * const heldKeys = useHeldKeys()\n *\n * return (\n * <div>\n * Currently pressed: {heldKeys.join(' + ') || 'None'}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeys(): Array<string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAA6B;AAE3C,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,SAAS"}
|
package/dist/useHotkey.cjs
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_HotkeysProvider = require('./HotkeysProvider.cjs');
|
|
3
|
-
const require_utils = require('./utils.cjs');
|
|
4
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
5
|
-
let react = require("react");
|
|
6
|
-
|
|
7
|
-
//#region src/useHotkey.ts
|
|
8
|
-
/**
|
|
9
|
-
* React hook for registering a keyboard hotkey.
|
|
10
|
-
*
|
|
11
|
-
* Uses the singleton HotkeyManager for efficient event handling.
|
|
12
|
-
* The callback receives both the keyboard event and a context object
|
|
13
|
-
* containing the hotkey string and parsed hotkey.
|
|
14
|
-
*
|
|
15
|
-
* This hook syncs the callback and options on every render to avoid
|
|
16
|
-
* stale closures. This means
|
|
17
|
-
* callbacks that reference React state will always have access to
|
|
18
|
-
* the latest values.
|
|
19
|
-
*
|
|
20
|
-
* @param hotkey - The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object (supports `mod` for cross-platform)
|
|
21
|
-
* @param callback - The function to call when the hotkey is pressed
|
|
22
|
-
* @param options - Options for the hotkey behavior. `enabled: false` keeps the registration (visible in devtools)
|
|
23
|
-
* and only suppresses firing; the hook updates the existing handle instead of unregistering.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```tsx
|
|
27
|
-
* function SaveButton() {
|
|
28
|
-
* const [count, setCount] = useState(0)
|
|
29
|
-
*
|
|
30
|
-
* // Callback always has access to latest count value
|
|
31
|
-
* useHotkey('Mod+S', (event, { hotkey }) => {
|
|
32
|
-
* console.log(`Save triggered, count is ${count}`)
|
|
33
|
-
* handleSave()
|
|
34
|
-
* })
|
|
35
|
-
*
|
|
36
|
-
* return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>
|
|
37
|
-
* }
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```tsx
|
|
42
|
-
* function Modal({ isOpen, onClose }) {
|
|
43
|
-
* // enabled option is synced on every render
|
|
44
|
-
* useHotkey('Escape', () => {
|
|
45
|
-
* onClose()
|
|
46
|
-
* }, { enabled: isOpen })
|
|
47
|
-
*
|
|
48
|
-
* if (!isOpen) return null
|
|
49
|
-
* return <div className="modal">...</div>
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```tsx
|
|
55
|
-
* function Editor() {
|
|
56
|
-
* const editorRef = useRef<HTMLDivElement>(null)
|
|
57
|
-
*
|
|
58
|
-
* // Scoped to a specific element
|
|
59
|
-
* useHotkey('Mod+S', () => {
|
|
60
|
-
* save()
|
|
61
|
-
* }, { target: editorRef })
|
|
62
|
-
*
|
|
63
|
-
* return <div ref={editorRef}>...</div>
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
function useHotkey(hotkey, callback, options = {}) {
|
|
68
|
-
const mergedOptions = {
|
|
69
|
-
...require_HotkeysProvider.useDefaultHotkeysOptions().hotkey,
|
|
70
|
-
...options
|
|
71
|
-
};
|
|
72
|
-
const manager = (0, _tanstack_hotkeys.getHotkeyManager)();
|
|
73
|
-
const registrationRef = (0, react.useRef)(null);
|
|
74
|
-
const callbackRef = (0, react.useRef)(callback);
|
|
75
|
-
const optionsRef = (0, react.useRef)(mergedOptions);
|
|
76
|
-
const managerRef = (0, react.useRef)(manager);
|
|
77
|
-
callbackRef.current = callback;
|
|
78
|
-
optionsRef.current = mergedOptions;
|
|
79
|
-
managerRef.current = manager;
|
|
80
|
-
const prevTargetRef = (0, react.useRef)(null);
|
|
81
|
-
const prevHotkeyRef = (0, react.useRef)(null);
|
|
82
|
-
const hotkeyString = (0, _tanstack_hotkeys.normalizeRegisterableHotkey)(hotkey, mergedOptions.platform ?? (0, _tanstack_hotkeys.detectPlatform)());
|
|
83
|
-
const { target: _target, ...optionsWithoutTarget } = mergedOptions;
|
|
84
|
-
(0, react.useEffect)(() => {
|
|
85
|
-
const resolvedTarget = require_utils.isRef(optionsRef.current.target) ? optionsRef.current.target.current : optionsRef.current.target ?? (typeof document !== "undefined" ? document : null);
|
|
86
|
-
if (!resolvedTarget) {
|
|
87
|
-
if (registrationRef.current?.isActive) {
|
|
88
|
-
registrationRef.current.unregister();
|
|
89
|
-
registrationRef.current = null;
|
|
90
|
-
}
|
|
91
|
-
prevTargetRef.current = null;
|
|
92
|
-
prevHotkeyRef.current = null;
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const targetChanged = prevTargetRef.current !== null && prevTargetRef.current !== resolvedTarget;
|
|
96
|
-
const hotkeyChanged = prevHotkeyRef.current !== null && prevHotkeyRef.current !== hotkeyString;
|
|
97
|
-
if (registrationRef.current?.isActive && (targetChanged || hotkeyChanged)) {
|
|
98
|
-
registrationRef.current.unregister();
|
|
99
|
-
registrationRef.current = null;
|
|
100
|
-
}
|
|
101
|
-
if (!registrationRef.current || !registrationRef.current.isActive) registrationRef.current = managerRef.current.register(hotkeyString, callbackRef.current, {
|
|
102
|
-
...optionsRef.current,
|
|
103
|
-
target: resolvedTarget
|
|
104
|
-
});
|
|
105
|
-
prevTargetRef.current = resolvedTarget;
|
|
106
|
-
prevHotkeyRef.current = hotkeyString;
|
|
107
|
-
});
|
|
108
|
-
(0, react.useEffect)(() => {
|
|
109
|
-
return () => {
|
|
110
|
-
if (registrationRef.current?.isActive) {
|
|
111
|
-
registrationRef.current.unregister();
|
|
112
|
-
registrationRef.current = null;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}, []);
|
|
116
|
-
(0, react.useEffect)(() => {
|
|
117
|
-
if (registrationRef.current?.isActive) {
|
|
118
|
-
registrationRef.current.callback = callback;
|
|
119
|
-
registrationRef.current.setOptions(optionsWithoutTarget);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
//#endregion
|
|
125
|
-
exports.useHotkey = useHotkey;
|
|
126
|
-
//# sourceMappingURL=useHotkey.cjs.map
|
package/dist/useHotkey.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkey.cjs","names":["useDefaultHotkeysOptions","isRef"],"sources":["../src/useHotkey.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport {\n detectPlatform,\n getHotkeyManager,\n normalizeRegisterableHotkey,\n} from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProvider'\nimport { isRef } from './utils'\nimport type {\n HotkeyCallback,\n HotkeyOptions,\n HotkeyRegistrationHandle,\n RegisterableHotkey,\n} from '@tanstack/hotkeys'\n\nexport interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {\n /**\n * The DOM element to attach the event listener to.\n * Can be a React ref, direct DOM element, or null.\n * Defaults to document.\n */\n target?:\n | React.RefObject<HTMLElement | null>\n | HTMLElement\n | Document\n | Window\n | null\n}\n\n/**\n * React hook for registering a keyboard hotkey.\n *\n * Uses the singleton HotkeyManager for efficient event handling.\n * The callback receives both the keyboard event and a context object\n * containing the hotkey string and parsed hotkey.\n *\n * This hook syncs the callback and options on every render to avoid\n * stale closures. This means\n * callbacks that reference React state will always have access to\n * the latest values.\n *\n * @param hotkey - The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object (supports `mod` for cross-platform)\n * @param callback - The function to call when the hotkey is pressed\n * @param options - Options for the hotkey behavior. `enabled: false` keeps the registration (visible in devtools)\n * and only suppresses firing; the hook updates the existing handle instead of unregistering.\n *\n * @example\n * ```tsx\n * function SaveButton() {\n * const [count, setCount] = useState(0)\n *\n * // Callback always has access to latest count value\n * useHotkey('Mod+S', (event, { hotkey }) => {\n * console.log(`Save triggered, count is ${count}`)\n * handleSave()\n * })\n *\n * return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>\n * }\n * ```\n *\n * @example\n * ```tsx\n * function Modal({ isOpen, onClose }) {\n * // enabled option is synced on every render\n * useHotkey('Escape', () => {\n * onClose()\n * }, { enabled: isOpen })\n *\n * if (!isOpen) return null\n * return <div className=\"modal\">...</div>\n * }\n * ```\n *\n * @example\n * ```tsx\n * function Editor() {\n * const editorRef = useRef<HTMLDivElement>(null)\n *\n * // Scoped to a specific element\n * useHotkey('Mod+S', () => {\n * save()\n * }, { target: editorRef })\n *\n * return <div ref={editorRef}>...</div>\n * }\n * ```\n */\nexport function useHotkey(\n hotkey: RegisterableHotkey,\n callback: HotkeyCallback,\n options: UseHotkeyOptions = {},\n): void {\n const mergedOptions = {\n ...useDefaultHotkeysOptions().hotkey,\n ...options,\n } as UseHotkeyOptions\n\n const manager = getHotkeyManager()\n\n // Stable ref for registration handle\n const registrationRef = useRef<HotkeyRegistrationHandle | null>(null)\n\n // Refs to capture current values for use in effect without adding dependencies\n const callbackRef = useRef(callback)\n const optionsRef = useRef(mergedOptions)\n const managerRef = useRef(manager)\n\n // Update refs on every render\n callbackRef.current = callback\n optionsRef.current = mergedOptions\n managerRef.current = manager\n\n // Track previous target and hotkey to detect changes requiring re-registration\n const prevTargetRef = useRef<HTMLElement | Document | Window | null>(null)\n const prevHotkeyRef = useRef<string | null>(null)\n\n // Normalize to hotkey string\n const platform = mergedOptions.platform ?? detectPlatform()\n const hotkeyString = normalizeRegisterableHotkey(hotkey, platform)\n\n // Extract options without target (target is handled separately)\n const { target: _target, ...optionsWithoutTarget } = mergedOptions\n\n useEffect(() => {\n // Resolve target inside the effect so refs are already attached after mount\n const resolvedTarget = isRef(optionsRef.current.target)\n ? optionsRef.current.target.current\n : (optionsRef.current.target ??\n (typeof document !== 'undefined' ? document : null))\n\n // Skip if no valid target (SSR or ref still null)\n if (!resolvedTarget) {\n if (registrationRef.current?.isActive) {\n registrationRef.current.unregister()\n registrationRef.current = null\n }\n prevTargetRef.current = null\n prevHotkeyRef.current = null\n return\n }\n\n // Check if we need to re-register (target or hotkey changed)\n const targetChanged =\n prevTargetRef.current !== null && prevTargetRef.current !== resolvedTarget\n const hotkeyChanged =\n prevHotkeyRef.current !== null && prevHotkeyRef.current !== hotkeyString\n\n // If we have an active registration and target/hotkey changed, unregister first\n if (registrationRef.current?.isActive && (targetChanged || hotkeyChanged)) {\n registrationRef.current.unregister()\n registrationRef.current = null\n }\n\n // Register if needed (no active registration)\n // Use refs to access current values without adding them to dependencies\n if (!registrationRef.current || !registrationRef.current.isActive) {\n registrationRef.current = managerRef.current.register(\n hotkeyString,\n callbackRef.current,\n {\n ...optionsRef.current,\n target: resolvedTarget,\n },\n )\n }\n\n // Update tracking refs\n prevTargetRef.current = resolvedTarget\n prevHotkeyRef.current = hotkeyString\n })\n\n useEffect(() => {\n // Cleanup on unmount\n return () => {\n if (registrationRef.current?.isActive) {\n registrationRef.current.unregister()\n registrationRef.current = null\n }\n }\n }, [])\n\n // Publish option changes after commit, never during render.\n useEffect(() => {\n if (registrationRef.current?.isActive) {\n registrationRef.current.callback = callback\n registrationRef.current.setOptions(optionsWithoutTarget)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAgB,UACd,QACA,UACA,UAA4B,EAAE,EACxB;CACN,MAAM,gBAAgB;EACpB,GAAGA,kDAA0B,CAAC;EAC9B,GAAG;EACJ;CAED,MAAM,mDAA4B;CAGlC,MAAM,oCAA0D,KAAK;CAGrE,MAAM,gCAAqB,SAAS;CACpC,MAAM,+BAAoB,cAAc;CACxC,MAAM,+BAAoB,QAAQ;AAGlC,aAAY,UAAU;AACtB,YAAW,UAAU;AACrB,YAAW,UAAU;CAGrB,MAAM,kCAA+D,KAAK;CAC1E,MAAM,kCAAsC,KAAK;CAIjD,MAAM,kEAA2C,QADhC,cAAc,mDAA4B,CACO;CAGlE,MAAM,EAAE,QAAQ,SAAS,GAAG,yBAAyB;AAErD,4BAAgB;EAEd,MAAM,iBAAiBC,oBAAM,WAAW,QAAQ,OAAO,GACnD,WAAW,QAAQ,OAAO,UACzB,WAAW,QAAQ,WACnB,OAAO,aAAa,cAAc,WAAW;AAGlD,MAAI,CAAC,gBAAgB;AACnB,OAAI,gBAAgB,SAAS,UAAU;AACrC,oBAAgB,QAAQ,YAAY;AACpC,oBAAgB,UAAU;;AAE5B,iBAAc,UAAU;AACxB,iBAAc,UAAU;AACxB;;EAIF,MAAM,gBACJ,cAAc,YAAY,QAAQ,cAAc,YAAY;EAC9D,MAAM,gBACJ,cAAc,YAAY,QAAQ,cAAc,YAAY;AAG9D,MAAI,gBAAgB,SAAS,aAAa,iBAAiB,gBAAgB;AACzE,mBAAgB,QAAQ,YAAY;AACpC,mBAAgB,UAAU;;AAK5B,MAAI,CAAC,gBAAgB,WAAW,CAAC,gBAAgB,QAAQ,SACvD,iBAAgB,UAAU,WAAW,QAAQ,SAC3C,cACA,YAAY,SACZ;GACE,GAAG,WAAW;GACd,QAAQ;GACT,CACF;AAIH,gBAAc,UAAU;AACxB,gBAAc,UAAU;GACxB;AAEF,4BAAgB;AAEd,eAAa;AACX,OAAI,gBAAgB,SAAS,UAAU;AACrC,oBAAgB,QAAQ,YAAY;AACpC,oBAAgB,UAAU;;;IAG7B,EAAE,CAAC;AAGN,4BAAgB;AACd,MAAI,gBAAgB,SAAS,UAAU;AACrC,mBAAgB,QAAQ,WAAW;AACnC,mBAAgB,QAAQ,WAAW,qBAAqB;;GAE1D"}
|
package/dist/useHotkey.d.cts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { HotkeyCallback, HotkeyOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
|
-
//#region src/useHotkey.d.ts
|
|
4
|
-
interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
5
|
-
/**
|
|
6
|
-
* The DOM element to attach the event listener to.
|
|
7
|
-
* Can be a React ref, direct DOM element, or null.
|
|
8
|
-
* Defaults to document.
|
|
9
|
-
*/
|
|
10
|
-
target?: React.RefObject<HTMLElement | null> | HTMLElement | Document | Window | null;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* React hook for registering a keyboard hotkey.
|
|
14
|
-
*
|
|
15
|
-
* Uses the singleton HotkeyManager for efficient event handling.
|
|
16
|
-
* The callback receives both the keyboard event and a context object
|
|
17
|
-
* containing the hotkey string and parsed hotkey.
|
|
18
|
-
*
|
|
19
|
-
* This hook syncs the callback and options on every render to avoid
|
|
20
|
-
* stale closures. This means
|
|
21
|
-
* callbacks that reference React state will always have access to
|
|
22
|
-
* the latest values.
|
|
23
|
-
*
|
|
24
|
-
* @param hotkey - The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object (supports `mod` for cross-platform)
|
|
25
|
-
* @param callback - The function to call when the hotkey is pressed
|
|
26
|
-
* @param options - Options for the hotkey behavior. `enabled: false` keeps the registration (visible in devtools)
|
|
27
|
-
* and only suppresses firing; the hook updates the existing handle instead of unregistering.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* function SaveButton() {
|
|
32
|
-
* const [count, setCount] = useState(0)
|
|
33
|
-
*
|
|
34
|
-
* // Callback always has access to latest count value
|
|
35
|
-
* useHotkey('Mod+S', (event, { hotkey }) => {
|
|
36
|
-
* console.log(`Save triggered, count is ${count}`)
|
|
37
|
-
* handleSave()
|
|
38
|
-
* })
|
|
39
|
-
*
|
|
40
|
-
* return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```tsx
|
|
46
|
-
* function Modal({ isOpen, onClose }) {
|
|
47
|
-
* // enabled option is synced on every render
|
|
48
|
-
* useHotkey('Escape', () => {
|
|
49
|
-
* onClose()
|
|
50
|
-
* }, { enabled: isOpen })
|
|
51
|
-
*
|
|
52
|
-
* if (!isOpen) return null
|
|
53
|
-
* return <div className="modal">...</div>
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```tsx
|
|
59
|
-
* function Editor() {
|
|
60
|
-
* const editorRef = useRef<HTMLDivElement>(null)
|
|
61
|
-
*
|
|
62
|
-
* // Scoped to a specific element
|
|
63
|
-
* useHotkey('Mod+S', () => {
|
|
64
|
-
* save()
|
|
65
|
-
* }, { target: editorRef })
|
|
66
|
-
*
|
|
67
|
-
* return <div ref={editorRef}>...</div>
|
|
68
|
-
* }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare function useHotkey(hotkey: RegisterableHotkey, callback: HotkeyCallback, options?: UseHotkeyOptions): void;
|
|
72
|
-
//#endregion
|
|
73
|
-
export { UseHotkeyOptions, useHotkey };
|
|
74
|
-
//# sourceMappingURL=useHotkey.d.cts.map
|
package/dist/useHotkey.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkey.js","names":[],"sources":["../src/useHotkey.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport {\n detectPlatform,\n getHotkeyManager,\n normalizeRegisterableHotkey,\n} from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProvider'\nimport { isRef } from './utils'\nimport type {\n HotkeyCallback,\n HotkeyOptions,\n HotkeyRegistrationHandle,\n RegisterableHotkey,\n} from '@tanstack/hotkeys'\n\nexport interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {\n /**\n * The DOM element to attach the event listener to.\n * Can be a React ref, direct DOM element, or null.\n * Defaults to document.\n */\n target?:\n | React.RefObject<HTMLElement | null>\n | HTMLElement\n | Document\n | Window\n | null\n}\n\n/**\n * React hook for registering a keyboard hotkey.\n *\n * Uses the singleton HotkeyManager for efficient event handling.\n * The callback receives both the keyboard event and a context object\n * containing the hotkey string and parsed hotkey.\n *\n * This hook syncs the callback and options on every render to avoid\n * stale closures. This means\n * callbacks that reference React state will always have access to\n * the latest values.\n *\n * @param hotkey - The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object (supports `mod` for cross-platform)\n * @param callback - The function to call when the hotkey is pressed\n * @param options - Options for the hotkey behavior. `enabled: false` keeps the registration (visible in devtools)\n * and only suppresses firing; the hook updates the existing handle instead of unregistering.\n *\n * @example\n * ```tsx\n * function SaveButton() {\n * const [count, setCount] = useState(0)\n *\n * // Callback always has access to latest count value\n * useHotkey('Mod+S', (event, { hotkey }) => {\n * console.log(`Save triggered, count is ${count}`)\n * handleSave()\n * })\n *\n * return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>\n * }\n * ```\n *\n * @example\n * ```tsx\n * function Modal({ isOpen, onClose }) {\n * // enabled option is synced on every render\n * useHotkey('Escape', () => {\n * onClose()\n * }, { enabled: isOpen })\n *\n * if (!isOpen) return null\n * return <div className=\"modal\">...</div>\n * }\n * ```\n *\n * @example\n * ```tsx\n * function Editor() {\n * const editorRef = useRef<HTMLDivElement>(null)\n *\n * // Scoped to a specific element\n * useHotkey('Mod+S', () => {\n * save()\n * }, { target: editorRef })\n *\n * return <div ref={editorRef}>...</div>\n * }\n * ```\n */\nexport function useHotkey(\n hotkey: RegisterableHotkey,\n callback: HotkeyCallback,\n options: UseHotkeyOptions = {},\n): void {\n const mergedOptions = {\n ...useDefaultHotkeysOptions().hotkey,\n ...options,\n } as UseHotkeyOptions\n\n const manager = getHotkeyManager()\n\n // Stable ref for registration handle\n const registrationRef = useRef<HotkeyRegistrationHandle | null>(null)\n\n // Refs to capture current values for use in effect without adding dependencies\n const callbackRef = useRef(callback)\n const optionsRef = useRef(mergedOptions)\n const managerRef = useRef(manager)\n\n // Update refs on every render\n callbackRef.current = callback\n optionsRef.current = mergedOptions\n managerRef.current = manager\n\n // Track previous target and hotkey to detect changes requiring re-registration\n const prevTargetRef = useRef<HTMLElement | Document | Window | null>(null)\n const prevHotkeyRef = useRef<string | null>(null)\n\n // Normalize to hotkey string\n const platform = mergedOptions.platform ?? detectPlatform()\n const hotkeyString = normalizeRegisterableHotkey(hotkey, platform)\n\n // Extract options without target (target is handled separately)\n const { target: _target, ...optionsWithoutTarget } = mergedOptions\n\n useEffect(() => {\n // Resolve target inside the effect so refs are already attached after mount\n const resolvedTarget = isRef(optionsRef.current.target)\n ? optionsRef.current.target.current\n : (optionsRef.current.target ??\n (typeof document !== 'undefined' ? document : null))\n\n // Skip if no valid target (SSR or ref still null)\n if (!resolvedTarget) {\n if (registrationRef.current?.isActive) {\n registrationRef.current.unregister()\n registrationRef.current = null\n }\n prevTargetRef.current = null\n prevHotkeyRef.current = null\n return\n }\n\n // Check if we need to re-register (target or hotkey changed)\n const targetChanged =\n prevTargetRef.current !== null && prevTargetRef.current !== resolvedTarget\n const hotkeyChanged =\n prevHotkeyRef.current !== null && prevHotkeyRef.current !== hotkeyString\n\n // If we have an active registration and target/hotkey changed, unregister first\n if (registrationRef.current?.isActive && (targetChanged || hotkeyChanged)) {\n registrationRef.current.unregister()\n registrationRef.current = null\n }\n\n // Register if needed (no active registration)\n // Use refs to access current values without adding them to dependencies\n if (!registrationRef.current || !registrationRef.current.isActive) {\n registrationRef.current = managerRef.current.register(\n hotkeyString,\n callbackRef.current,\n {\n ...optionsRef.current,\n target: resolvedTarget,\n },\n )\n }\n\n // Update tracking refs\n prevTargetRef.current = resolvedTarget\n prevHotkeyRef.current = hotkeyString\n })\n\n useEffect(() => {\n // Cleanup on unmount\n return () => {\n if (registrationRef.current?.isActive) {\n registrationRef.current.unregister()\n registrationRef.current = null\n }\n }\n }, [])\n\n // Publish option changes after commit, never during render.\n useEffect(() => {\n if (registrationRef.current?.isActive) {\n registrationRef.current.callback = callback\n registrationRef.current.setOptions(optionsWithoutTarget)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAgB,UACd,QACA,UACA,UAA4B,EAAE,EACxB;CACN,MAAM,gBAAgB;EACpB,GAAG,0BAA0B,CAAC;EAC9B,GAAG;EACJ;CAED,MAAM,UAAU,kBAAkB;CAGlC,MAAM,kBAAkB,OAAwC,KAAK;CAGrE,MAAM,cAAc,OAAO,SAAS;CACpC,MAAM,aAAa,OAAO,cAAc;CACxC,MAAM,aAAa,OAAO,QAAQ;AAGlC,aAAY,UAAU;AACtB,YAAW,UAAU;AACrB,YAAW,UAAU;CAGrB,MAAM,gBAAgB,OAA+C,KAAK;CAC1E,MAAM,gBAAgB,OAAsB,KAAK;CAIjD,MAAM,eAAe,4BAA4B,QADhC,cAAc,YAAY,gBAAgB,CACO;CAGlE,MAAM,EAAE,QAAQ,SAAS,GAAG,yBAAyB;AAErD,iBAAgB;EAEd,MAAM,iBAAiB,MAAM,WAAW,QAAQ,OAAO,GACnD,WAAW,QAAQ,OAAO,UACzB,WAAW,QAAQ,WACnB,OAAO,aAAa,cAAc,WAAW;AAGlD,MAAI,CAAC,gBAAgB;AACnB,OAAI,gBAAgB,SAAS,UAAU;AACrC,oBAAgB,QAAQ,YAAY;AACpC,oBAAgB,UAAU;;AAE5B,iBAAc,UAAU;AACxB,iBAAc,UAAU;AACxB;;EAIF,MAAM,gBACJ,cAAc,YAAY,QAAQ,cAAc,YAAY;EAC9D,MAAM,gBACJ,cAAc,YAAY,QAAQ,cAAc,YAAY;AAG9D,MAAI,gBAAgB,SAAS,aAAa,iBAAiB,gBAAgB;AACzE,mBAAgB,QAAQ,YAAY;AACpC,mBAAgB,UAAU;;AAK5B,MAAI,CAAC,gBAAgB,WAAW,CAAC,gBAAgB,QAAQ,SACvD,iBAAgB,UAAU,WAAW,QAAQ,SAC3C,cACA,YAAY,SACZ;GACE,GAAG,WAAW;GACd,QAAQ;GACT,CACF;AAIH,gBAAc,UAAU;AACxB,gBAAc,UAAU;GACxB;AAEF,iBAAgB;AAEd,eAAa;AACX,OAAI,gBAAgB,SAAS,UAAU;AACrC,oBAAgB,QAAQ,YAAY;AACpC,oBAAgB,UAAU;;;IAG7B,EAAE,CAAC;AAGN,iBAAgB;AACd,MAAI,gBAAgB,SAAS,UAAU;AACrC,mBAAgB,QAAQ,WAAW;AACnC,mBAAgB,QAAQ,WAAW,qBAAqB;;GAE1D"}
|
package/dist/useHotkeyHint.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
3
|
-
let _tanstack_react_store = require("@tanstack/react-store");
|
|
4
|
-
|
|
5
|
-
//#region src/useHotkeyHint.ts
|
|
6
|
-
/**
|
|
7
|
-
* Returns a boolean indicating whether held modifiers reveal this shortcut.
|
|
8
|
-
* Only visibility changes from held-key updates cause a rerender.
|
|
9
|
-
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
10
|
-
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
11
|
-
* This helper does not register a shortcut or check whether its target is focused.
|
|
12
|
-
*/
|
|
13
|
-
function useHotkeyHint(hotkey, options = {}) {
|
|
14
|
-
return (0, _tanstack_react_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => (0, _tanstack_hotkeys.matchesHeldModifiers)(hotkey, state.heldKeys, options));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.useHotkeyHint = useHotkeyHint;
|
|
19
|
-
//# sourceMappingURL=useHotkeyHint.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeyHint.cjs","names":[],"sources":["../src/useHotkeyHint.ts"],"sourcesContent":["import { useSelector } from '@tanstack/react-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a boolean indicating whether held modifiers reveal this shortcut.\n * Only visibility changes from held-key updates cause a rerender.\n * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires\n * every modifier. Combine with the action's enabled state before showing a badge.\n * This helper does not register a shortcut or check whether its target is focused.\n */\nexport function useHotkeyHint(\n hotkey: RegisterableHotkey,\n options: HeldModifierOptions = {},\n): boolean {\n return useSelector(getKeyStateTracker().store, (state) =>\n matchesHeldModifiers(hotkey, state.heldKeys, options),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,cACd,QACA,UAA+B,EAAE,EACxB;AACT,0FAAuC,CAAC,QAAQ,sDACzB,QAAQ,MAAM,UAAU,QAAQ,CACtD"}
|
package/dist/useHotkeyHint.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
|
-
//#region src/useHotkeyHint.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Returns a boolean indicating whether held modifiers reveal this shortcut.
|
|
6
|
-
* Only visibility changes from held-key updates cause a rerender.
|
|
7
|
-
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
8
|
-
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
9
|
-
* This helper does not register a shortcut or check whether its target is focused.
|
|
10
|
-
*/
|
|
11
|
-
declare function useHotkeyHint(hotkey: RegisterableHotkey, options?: HeldModifierOptions): boolean;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { useHotkeyHint };
|
|
14
|
-
//# sourceMappingURL=useHotkeyHint.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeyHint.js","names":[],"sources":["../src/useHotkeyHint.ts"],"sourcesContent":["import { useSelector } from '@tanstack/react-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a boolean indicating whether held modifiers reveal this shortcut.\n * Only visibility changes from held-key updates cause a rerender.\n * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires\n * every modifier. Combine with the action's enabled state before showing a badge.\n * This helper does not register a shortcut or check whether its target is focused.\n */\nexport function useHotkeyHint(\n hotkey: RegisterableHotkey,\n options: HeldModifierOptions = {},\n): boolean {\n return useSelector(getKeyStateTracker().store, (state) =>\n matchesHeldModifiers(hotkey, state.heldKeys, options),\n )\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,cACd,QACA,UAA+B,EAAE,EACxB;AACT,QAAO,YAAY,oBAAoB,CAAC,QAAQ,UAC9C,qBAAqB,QAAQ,MAAM,UAAU,QAAQ,CACtD"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
const require_HotkeysProvider = require('./HotkeysProvider.cjs');
|
|
3
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
4
|
-
let react = require("react");
|
|
5
|
-
let _tanstack_react_store = require("@tanstack/react-store");
|
|
6
|
-
|
|
7
|
-
//#region src/useHotkeyRecorder.ts
|
|
8
|
-
/**
|
|
9
|
-
* React hook for recording keyboard shortcuts.
|
|
10
|
-
*
|
|
11
|
-
* This hook provides a thin wrapper around the framework-agnostic `HotkeyRecorder`
|
|
12
|
-
* class, managing all the complexity of capturing keyboard events, converting them
|
|
13
|
-
* to hotkey strings, and handling edge cases like Escape to cancel or Backspace/Delete
|
|
14
|
-
* to clear.
|
|
15
|
-
*
|
|
16
|
-
* @param options - Configuration options for the recorder
|
|
17
|
-
* @returns An object with recording state and control functions
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* function ShortcutSettings() {
|
|
22
|
-
* const [shortcut, setShortcut] = useState<Hotkey>('Mod+S')
|
|
23
|
-
*
|
|
24
|
-
* const recorder = useHotkeyRecorder({
|
|
25
|
-
* onRecord: (hotkey) => {
|
|
26
|
-
* setShortcut(hotkey)
|
|
27
|
-
* },
|
|
28
|
-
* onCancel: () => {
|
|
29
|
-
* console.log('Recording cancelled')
|
|
30
|
-
* },
|
|
31
|
-
* })
|
|
32
|
-
*
|
|
33
|
-
* return (
|
|
34
|
-
* <div>
|
|
35
|
-
* <button onClick={recorder.startRecording}>
|
|
36
|
-
* {recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}
|
|
37
|
-
* </button>
|
|
38
|
-
* {recorder.recordedHotkey && (
|
|
39
|
-
* <div>Recording: {recorder.recordedHotkey}</div>
|
|
40
|
-
* )}
|
|
41
|
-
* </div>
|
|
42
|
-
* )
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
function useHotkeyRecorder(options) {
|
|
47
|
-
const mergedOptions = {
|
|
48
|
-
...require_HotkeysProvider.useDefaultHotkeysOptions().hotkeyRecorder,
|
|
49
|
-
...options
|
|
50
|
-
};
|
|
51
|
-
const recorderRef = (0, react.useRef)(null);
|
|
52
|
-
if (!recorderRef.current) recorderRef.current = new _tanstack_hotkeys.HotkeyRecorder(mergedOptions);
|
|
53
|
-
recorderRef.current.setOptions(mergedOptions);
|
|
54
|
-
const isRecording = (0, _tanstack_react_store.useSelector)(recorderRef.current.store, (state) => state.isRecording);
|
|
55
|
-
const recordedHotkey = (0, _tanstack_react_store.useSelector)(recorderRef.current.store, (state) => state.recordedHotkey);
|
|
56
|
-
(0, react.useEffect)(() => {
|
|
57
|
-
return () => {
|
|
58
|
-
recorderRef.current?.destroy();
|
|
59
|
-
};
|
|
60
|
-
}, []);
|
|
61
|
-
return {
|
|
62
|
-
isRecording,
|
|
63
|
-
recordedHotkey,
|
|
64
|
-
startRecording: () => recorderRef.current?.start(),
|
|
65
|
-
stopRecording: () => recorderRef.current?.stop(),
|
|
66
|
-
cancelRecording: () => recorderRef.current?.cancel()
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
//#endregion
|
|
71
|
-
exports.useHotkeyRecorder = useHotkeyRecorder;
|
|
72
|
-
//# sourceMappingURL=useHotkeyRecorder.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeyRecorder.cjs","names":["useDefaultHotkeysOptions","HotkeyRecorder"],"sources":["../src/useHotkeyRecorder.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { useSelector } from '@tanstack/react-store'\nimport { HotkeyRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProvider'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\nexport interface ReactHotkeyRecorder {\n /** Whether recording is currently active */\n isRecording: boolean\n /** The currently recorded hotkey (for live preview) */\n recordedHotkey: Hotkey | null\n /** Start recording a new hotkey */\n startRecording: () => void\n /** Stop recording (same as cancel) */\n stopRecording: () => void\n /** Cancel recording without saving */\n cancelRecording: () => void\n}\n\n/**\n * React hook for recording keyboard shortcuts.\n *\n * This hook provides a thin wrapper around the framework-agnostic `HotkeyRecorder`\n * class, managing all the complexity of capturing keyboard events, converting them\n * to hotkey strings, and handling edge cases like Escape to cancel or Backspace/Delete\n * to clear.\n *\n * @param options - Configuration options for the recorder\n * @returns An object with recording state and control functions\n *\n * @example\n * ```tsx\n * function ShortcutSettings() {\n * const [shortcut, setShortcut] = useState<Hotkey>('Mod+S')\n *\n * const recorder = useHotkeyRecorder({\n * onRecord: (hotkey) => {\n * setShortcut(hotkey)\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n *\n * return (\n * <div>\n * <button onClick={recorder.startRecording}>\n * {recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}\n * </button>\n * {recorder.recordedHotkey && (\n * <div>Recording: {recorder.recordedHotkey}</div>\n * )}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHotkeyRecorder(\n options: HotkeyRecorderOptions,\n): ReactHotkeyRecorder {\n const mergedOptions = {\n ...useDefaultHotkeysOptions().hotkeyRecorder,\n ...options,\n } as HotkeyRecorderOptions\n\n const recorderRef = useRef<HotkeyRecorder | null>(null)\n\n // Create recorder instance once\n if (!recorderRef.current) {\n recorderRef.current = new HotkeyRecorder(mergedOptions)\n }\n\n // Sync options on every render (same pattern as useHotkey)\n // This ensures callbacks always have access to latest values\n recorderRef.current.setOptions(mergedOptions)\n\n // Subscribe to recorder state using useSelector (same pattern as useHeldKeys)\n const isRecording = useSelector(\n recorderRef.current.store,\n (state) => state.isRecording,\n )\n const recordedHotkey = useSelector(\n recorderRef.current.store,\n (state) => state.recordedHotkey,\n )\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n recorderRef.current?.destroy()\n }\n }, [])\n\n return {\n isRecording,\n recordedHotkey,\n startRecording: () => recorderRef.current?.start(),\n stopRecording: () => recorderRef.current?.stop(),\n cancelRecording: () => recorderRef.current?.cancel(),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,kBACd,SACqB;CACrB,MAAM,gBAAgB;EACpB,GAAGA,kDAA0B,CAAC;EAC9B,GAAG;EACJ;CAED,MAAM,gCAA4C,KAAK;AAGvD,KAAI,CAAC,YAAY,QACf,aAAY,UAAU,IAAIC,iCAAe,cAAc;AAKzD,aAAY,QAAQ,WAAW,cAAc;CAG7C,MAAM,qDACJ,YAAY,QAAQ,QACnB,UAAU,MAAM,YAClB;CACD,MAAM,wDACJ,YAAY,QAAQ,QACnB,UAAU,MAAM,eAClB;AAGD,4BAAgB;AACd,eAAa;AACX,eAAY,SAAS,SAAS;;IAE/B,EAAE,CAAC;AAEN,QAAO;EACL;EACA;EACA,sBAAsB,YAAY,SAAS,OAAO;EAClD,qBAAqB,YAAY,SAAS,MAAM;EAChD,uBAAuB,YAAY,SAAS,QAAQ;EACrD"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
|
-
//#region src/useHotkeyRecorder.d.ts
|
|
4
|
-
interface ReactHotkeyRecorder {
|
|
5
|
-
/** Whether recording is currently active */
|
|
6
|
-
isRecording: boolean;
|
|
7
|
-
/** The currently recorded hotkey (for live preview) */
|
|
8
|
-
recordedHotkey: Hotkey | null;
|
|
9
|
-
/** Start recording a new hotkey */
|
|
10
|
-
startRecording: () => void;
|
|
11
|
-
/** Stop recording (same as cancel) */
|
|
12
|
-
stopRecording: () => void;
|
|
13
|
-
/** Cancel recording without saving */
|
|
14
|
-
cancelRecording: () => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* React hook for recording keyboard shortcuts.
|
|
18
|
-
*
|
|
19
|
-
* This hook provides a thin wrapper around the framework-agnostic `HotkeyRecorder`
|
|
20
|
-
* class, managing all the complexity of capturing keyboard events, converting them
|
|
21
|
-
* to hotkey strings, and handling edge cases like Escape to cancel or Backspace/Delete
|
|
22
|
-
* to clear.
|
|
23
|
-
*
|
|
24
|
-
* @param options - Configuration options for the recorder
|
|
25
|
-
* @returns An object with recording state and control functions
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* function ShortcutSettings() {
|
|
30
|
-
* const [shortcut, setShortcut] = useState<Hotkey>('Mod+S')
|
|
31
|
-
*
|
|
32
|
-
* const recorder = useHotkeyRecorder({
|
|
33
|
-
* onRecord: (hotkey) => {
|
|
34
|
-
* setShortcut(hotkey)
|
|
35
|
-
* },
|
|
36
|
-
* onCancel: () => {
|
|
37
|
-
* console.log('Recording cancelled')
|
|
38
|
-
* },
|
|
39
|
-
* })
|
|
40
|
-
*
|
|
41
|
-
* return (
|
|
42
|
-
* <div>
|
|
43
|
-
* <button onClick={recorder.startRecording}>
|
|
44
|
-
* {recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}
|
|
45
|
-
* </button>
|
|
46
|
-
* {recorder.recordedHotkey && (
|
|
47
|
-
* <div>Recording: {recorder.recordedHotkey}</div>
|
|
48
|
-
* )}
|
|
49
|
-
* </div>
|
|
50
|
-
* )
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function useHotkeyRecorder(options: HotkeyRecorderOptions): ReactHotkeyRecorder;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { ReactHotkeyRecorder, useHotkeyRecorder };
|
|
57
|
-
//# sourceMappingURL=useHotkeyRecorder.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeyRecorder.js","names":[],"sources":["../src/useHotkeyRecorder.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\nimport { useSelector } from '@tanstack/react-store'\nimport { HotkeyRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProvider'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\nexport interface ReactHotkeyRecorder {\n /** Whether recording is currently active */\n isRecording: boolean\n /** The currently recorded hotkey (for live preview) */\n recordedHotkey: Hotkey | null\n /** Start recording a new hotkey */\n startRecording: () => void\n /** Stop recording (same as cancel) */\n stopRecording: () => void\n /** Cancel recording without saving */\n cancelRecording: () => void\n}\n\n/**\n * React hook for recording keyboard shortcuts.\n *\n * This hook provides a thin wrapper around the framework-agnostic `HotkeyRecorder`\n * class, managing all the complexity of capturing keyboard events, converting them\n * to hotkey strings, and handling edge cases like Escape to cancel or Backspace/Delete\n * to clear.\n *\n * @param options - Configuration options for the recorder\n * @returns An object with recording state and control functions\n *\n * @example\n * ```tsx\n * function ShortcutSettings() {\n * const [shortcut, setShortcut] = useState<Hotkey>('Mod+S')\n *\n * const recorder = useHotkeyRecorder({\n * onRecord: (hotkey) => {\n * setShortcut(hotkey)\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n *\n * return (\n * <div>\n * <button onClick={recorder.startRecording}>\n * {recorder.isRecording ? 'Recording...' : 'Edit Shortcut'}\n * </button>\n * {recorder.recordedHotkey && (\n * <div>Recording: {recorder.recordedHotkey}</div>\n * )}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHotkeyRecorder(\n options: HotkeyRecorderOptions,\n): ReactHotkeyRecorder {\n const mergedOptions = {\n ...useDefaultHotkeysOptions().hotkeyRecorder,\n ...options,\n } as HotkeyRecorderOptions\n\n const recorderRef = useRef<HotkeyRecorder | null>(null)\n\n // Create recorder instance once\n if (!recorderRef.current) {\n recorderRef.current = new HotkeyRecorder(mergedOptions)\n }\n\n // Sync options on every render (same pattern as useHotkey)\n // This ensures callbacks always have access to latest values\n recorderRef.current.setOptions(mergedOptions)\n\n // Subscribe to recorder state using useSelector (same pattern as useHeldKeys)\n const isRecording = useSelector(\n recorderRef.current.store,\n (state) => state.isRecording,\n )\n const recordedHotkey = useSelector(\n recorderRef.current.store,\n (state) => state.recordedHotkey,\n )\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n recorderRef.current?.destroy()\n }\n }, [])\n\n return {\n isRecording,\n recordedHotkey,\n startRecording: () => recorderRef.current?.start(),\n stopRecording: () => recorderRef.current?.stop(),\n cancelRecording: () => recorderRef.current?.cancel(),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,kBACd,SACqB;CACrB,MAAM,gBAAgB;EACpB,GAAG,0BAA0B,CAAC;EAC9B,GAAG;EACJ;CAED,MAAM,cAAc,OAA8B,KAAK;AAGvD,KAAI,CAAC,YAAY,QACf,aAAY,UAAU,IAAI,eAAe,cAAc;AAKzD,aAAY,QAAQ,WAAW,cAAc;CAG7C,MAAM,cAAc,YAClB,YAAY,QAAQ,QACnB,UAAU,MAAM,YAClB;CACD,MAAM,iBAAiB,YACrB,YAAY,QAAQ,QACnB,UAAU,MAAM,eAClB;AAGD,iBAAgB;AACd,eAAa;AACX,eAAY,SAAS,SAAS;;IAE/B,EAAE,CAAC;AAEN,QAAO;EACL;EACA;EACA,sBAAsB,YAAY,SAAS,OAAO;EAClD,qBAAqB,YAAY,SAAS,MAAM;EAChD,uBAAuB,YAAY,SAAS,QAAQ;EACrD"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
3
|
-
let _tanstack_react_store = require("@tanstack/react-store");
|
|
4
|
-
|
|
5
|
-
//#region src/useHotkeyRegistrations.ts
|
|
6
|
-
/**
|
|
7
|
-
* React hook that reactively reads all hotkey and sequence registrations
|
|
8
|
-
* from the singleton managers.
|
|
9
|
-
*
|
|
10
|
-
* This is a standalone hook that does NOT require the HotkeysProvider.
|
|
11
|
-
* It subscribes to both HotkeyManager and SequenceManager stores and
|
|
12
|
-
* re-renders when registrations change.
|
|
13
|
-
*
|
|
14
|
-
* @returns Object with `hotkeys` and `sequences` arrays
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* function ShortcutPalette() {
|
|
19
|
-
* const { hotkeys, sequences } = useHotkeyRegistrations()
|
|
20
|
-
*
|
|
21
|
-
* return (
|
|
22
|
-
* <ul>
|
|
23
|
-
* {hotkeys.map((reg) => (
|
|
24
|
-
* <li key={reg.id}>
|
|
25
|
-
* {reg.options.meta?.name ?? reg.hotkey}
|
|
26
|
-
* </li>
|
|
27
|
-
* ))}
|
|
28
|
-
* {sequences.map((reg) => (
|
|
29
|
-
* <li key={reg.id}>
|
|
30
|
-
* {reg.options.meta?.name ?? reg.sequence.join(' ')}
|
|
31
|
-
* </li>
|
|
32
|
-
* ))}
|
|
33
|
-
* </ul>
|
|
34
|
-
* )
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
function useHotkeyRegistrations() {
|
|
39
|
-
const hotkeyManager = (0, _tanstack_hotkeys.getHotkeyManager)();
|
|
40
|
-
const sequenceManager = (0, _tanstack_hotkeys.getSequenceManager)();
|
|
41
|
-
return {
|
|
42
|
-
hotkeys: (0, _tanstack_react_store.useSelector)(hotkeyManager.registrations, (state) => Array.from(state.values()).map(_tanstack_hotkeys.toHotkeyRegistrationView)),
|
|
43
|
-
sequences: (0, _tanstack_react_store.useSelector)(sequenceManager.registrations, (state) => Array.from(state.values()))
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
exports.useHotkeyRegistrations = useHotkeyRegistrations;
|
|
49
|
-
//# sourceMappingURL=useHotkeyRegistrations.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeyRegistrations.cjs","names":["toHotkeyRegistrationView"],"sources":["../src/useHotkeyRegistrations.ts"],"sourcesContent":["import { useSelector } from '@tanstack/react-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\n\n/**\n * Return type for useHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** All registered hotkeys (public view, no callbacks) */\n hotkeys: Array<HotkeyRegistrationView>\n /** All registered sequences */\n sequences: Array<SequenceRegistrationView>\n}\n\n/**\n * React hook that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone hook that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * re-renders when registrations change.\n *\n * @returns Object with `hotkeys` and `sequences` arrays\n *\n * @example\n * ```tsx\n * function ShortcutPalette() {\n * const { hotkeys, sequences } = useHotkeyRegistrations()\n *\n * return (\n * <ul>\n * {hotkeys.map((reg) => (\n * <li key={reg.id}>\n * {reg.options.meta?.name ?? reg.hotkey}\n * </li>\n * ))}\n * {sequences.map((reg) => (\n * <li key={reg.id}>\n * {reg.options.meta?.name ?? reg.sequence.join(' ')}\n * </li>\n * ))}\n * </ul>\n * )\n * }\n * ```\n */\nexport function useHotkeyRegistrations(): HotkeyRegistrationsResult {\n const hotkeyManager = getHotkeyManager()\n const sequenceManager = getSequenceManager()\n\n const hotkeys = useSelector(hotkeyManager.registrations, (state) =>\n Array.from(state.values()).map(toHotkeyRegistrationView),\n )\n\n const sequences = useSelector(sequenceManager.registrations, (state) =>\n Array.from(state.values()),\n )\n\n return { hotkeys, sequences }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,yBAAoD;CAClE,MAAM,yDAAkC;CACxC,MAAM,6DAAsC;AAU5C,QAAO;EAAE,gDARmB,cAAc,gBAAgB,UACxD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAIA,2CAAyB,CACzD;EAMiB,kDAJY,gBAAgB,gBAAgB,UAC5D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { HotkeyRegistrationView, SequenceRegistrationView } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
|
-
//#region src/useHotkeyRegistrations.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Return type for useHotkeyRegistrations.
|
|
6
|
-
*/
|
|
7
|
-
interface HotkeyRegistrationsResult {
|
|
8
|
-
/** All registered hotkeys (public view, no callbacks) */
|
|
9
|
-
hotkeys: Array<HotkeyRegistrationView>;
|
|
10
|
-
/** All registered sequences */
|
|
11
|
-
sequences: Array<SequenceRegistrationView>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* React hook that reactively reads all hotkey and sequence registrations
|
|
15
|
-
* from the singleton managers.
|
|
16
|
-
*
|
|
17
|
-
* This is a standalone hook that does NOT require the HotkeysProvider.
|
|
18
|
-
* It subscribes to both HotkeyManager and SequenceManager stores and
|
|
19
|
-
* re-renders when registrations change.
|
|
20
|
-
*
|
|
21
|
-
* @returns Object with `hotkeys` and `sequences` arrays
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```tsx
|
|
25
|
-
* function ShortcutPalette() {
|
|
26
|
-
* const { hotkeys, sequences } = useHotkeyRegistrations()
|
|
27
|
-
*
|
|
28
|
-
* return (
|
|
29
|
-
* <ul>
|
|
30
|
-
* {hotkeys.map((reg) => (
|
|
31
|
-
* <li key={reg.id}>
|
|
32
|
-
* {reg.options.meta?.name ?? reg.hotkey}
|
|
33
|
-
* </li>
|
|
34
|
-
* ))}
|
|
35
|
-
* {sequences.map((reg) => (
|
|
36
|
-
* <li key={reg.id}>
|
|
37
|
-
* {reg.options.meta?.name ?? reg.sequence.join(' ')}
|
|
38
|
-
* </li>
|
|
39
|
-
* ))}
|
|
40
|
-
* </ul>
|
|
41
|
-
* )
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
46
|
-
//#endregion
|
|
47
|
-
export { HotkeyRegistrationsResult, useHotkeyRegistrations };
|
|
48
|
-
//# sourceMappingURL=useHotkeyRegistrations.d.cts.map
|