@tanstack/react-hotkeys 0.11.0 → 0.12.0

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.
Files changed (94) hide show
  1. package/dist/HotkeysProvider.d.ts +6 -12
  2. package/dist/HotkeysProvider.js +1 -2
  3. package/dist/useHeldKeyCodes.d.ts +2 -4
  4. package/dist/useHeldKeyCodes.js +3 -3
  5. package/dist/useHeldKeys.d.ts +2 -4
  6. package/dist/useHeldKeys.js +3 -3
  7. package/dist/useHotkey.d.ts +3 -6
  8. package/dist/useHotkey.js +3 -3
  9. package/dist/useHotkeyHint.d.ts +2 -5
  10. package/dist/useHotkeyHint.js +1 -2
  11. package/dist/useHotkeyRecorder.d.ts +3 -6
  12. package/dist/useHotkeyRecorder.js +1 -2
  13. package/dist/useHotkeyRegistrations.d.ts +3 -6
  14. package/dist/useHotkeyRegistrations.js +1 -2
  15. package/dist/useHotkeySequence.d.ts +3 -6
  16. package/dist/useHotkeySequence.js +1 -2
  17. package/dist/useHotkeySequenceRecorder.d.ts +3 -6
  18. package/dist/useHotkeySequenceRecorder.js +1 -2
  19. package/dist/useHotkeySequences.d.ts +3 -6
  20. package/dist/useHotkeySequences.js +1 -2
  21. package/dist/useHotkeys.d.ts +3 -6
  22. package/dist/useHotkeys.js +1 -2
  23. package/dist/useKeyHold.d.ts +2 -5
  24. package/dist/useKeyHold.js +1 -2
  25. package/dist/utils.js +1 -2
  26. package/package.json +14 -19
  27. package/dist/HotkeysProvider.cjs +0 -23
  28. package/dist/HotkeysProvider.cjs.map +0 -1
  29. package/dist/HotkeysProvider.d.cts +0 -28
  30. package/dist/HotkeysProvider.js.map +0 -1
  31. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  32. package/dist/index.cjs +0 -35
  33. package/dist/index.d.cts +0 -14
  34. package/dist/useHeldKeyCodes.cjs +0 -38
  35. package/dist/useHeldKeyCodes.cjs.map +0 -1
  36. package/dist/useHeldKeyCodes.d.cts +0 -31
  37. package/dist/useHeldKeyCodes.js.map +0 -1
  38. package/dist/useHeldKeys.cjs +0 -34
  39. package/dist/useHeldKeys.cjs.map +0 -1
  40. package/dist/useHeldKeys.d.cts +0 -27
  41. package/dist/useHeldKeys.js.map +0 -1
  42. package/dist/useHotkey.cjs +0 -126
  43. package/dist/useHotkey.cjs.map +0 -1
  44. package/dist/useHotkey.d.cts +0 -74
  45. package/dist/useHotkey.js.map +0 -1
  46. package/dist/useHotkeyHint.cjs +0 -19
  47. package/dist/useHotkeyHint.cjs.map +0 -1
  48. package/dist/useHotkeyHint.d.cts +0 -14
  49. package/dist/useHotkeyHint.js.map +0 -1
  50. package/dist/useHotkeyRecorder.cjs +0 -72
  51. package/dist/useHotkeyRecorder.cjs.map +0 -1
  52. package/dist/useHotkeyRecorder.d.cts +0 -57
  53. package/dist/useHotkeyRecorder.js.map +0 -1
  54. package/dist/useHotkeyRegistrations.cjs +0 -49
  55. package/dist/useHotkeyRegistrations.cjs.map +0 -1
  56. package/dist/useHotkeyRegistrations.d.cts +0 -48
  57. package/dist/useHotkeyRegistrations.js.map +0 -1
  58. package/dist/useHotkeySequence.cjs +0 -121
  59. package/dist/useHotkeySequence.cjs.map +0 -1
  60. package/dist/useHotkeySequence.d.cts +0 -58
  61. package/dist/useHotkeySequence.js.map +0 -1
  62. package/dist/useHotkeySequenceRecorder.cjs +0 -42
  63. package/dist/useHotkeySequenceRecorder.cjs.map +0 -1
  64. package/dist/useHotkeySequenceRecorder.d.cts +0 -25
  65. package/dist/useHotkeySequenceRecorder.js.map +0 -1
  66. package/dist/useHotkeySequences.cjs +0 -127
  67. package/dist/useHotkeySequences.cjs.map +0 -1
  68. package/dist/useHotkeySequences.d.cts +0 -63
  69. package/dist/useHotkeySequences.js.map +0 -1
  70. package/dist/useHotkeys.cjs +0 -125
  71. package/dist/useHotkeys.cjs.map +0 -1
  72. package/dist/useHotkeys.d.cts +0 -63
  73. package/dist/useHotkeys.js.map +0 -1
  74. package/dist/useKeyHold.cjs +0 -54
  75. package/dist/useKeyHold.cjs.map +0 -1
  76. package/dist/useKeyHold.d.cts +0 -47
  77. package/dist/useKeyHold.js.map +0 -1
  78. package/dist/utils.cjs +0 -12
  79. package/dist/utils.cjs.map +0 -1
  80. package/dist/utils.js.map +0 -1
  81. package/src/HotkeysProvider.tsx +0 -58
  82. package/src/index.ts +0 -18
  83. package/src/useHeldKeyCodes.ts +0 -33
  84. package/src/useHeldKeys.ts +0 -29
  85. package/src/useHotkey.ts +0 -190
  86. package/src/useHotkeyHint.ts +0 -19
  87. package/src/useHotkeyRecorder.ts +0 -101
  88. package/src/useHotkeyRegistrations.ts +0 -67
  89. package/src/useHotkeySequence.ts +0 -191
  90. package/src/useHotkeySequenceRecorder.ts +0 -70
  91. package/src/useHotkeySequences.ts +0 -192
  92. package/src/useHotkeys.ts +0 -193
  93. package/src/useKeyHold.ts +0 -52
  94. package/src/utils.ts +0 -10
@@ -2,9 +2,8 @@ import { UseHotkeyOptions } from "./useHotkey.js";
2
2
  import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
3
3
  import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
4
  import React, { ReactNode } from "react";
5
-
6
5
  //#region src/HotkeysProvider.d.ts
7
- interface HotkeysProviderOptions {
6
+ export interface HotkeysProviderOptions {
8
7
  hotkey?: Partial<UseHotkeyOptions>;
9
8
  hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
10
9
  hotkeySequence?: Partial<UseHotkeySequenceOptions>;
@@ -13,16 +12,11 @@ interface HotkeysProviderOptions {
13
12
  interface HotkeysContextValue {
14
13
  defaultOptions: HotkeysProviderOptions;
15
14
  }
16
- interface HotkeysProviderProps {
15
+ export interface HotkeysProviderProps {
17
16
  children: ReactNode;
18
17
  defaultOptions?: HotkeysProviderOptions;
19
18
  }
20
- declare function HotkeysProvider({
21
- children,
22
- defaultOptions
23
- }: HotkeysProviderProps): React.JSX.Element;
24
- declare function useHotkeysContext(): HotkeysContextValue | null;
25
- declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
26
- //#endregion
27
- export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
28
- //# sourceMappingURL=HotkeysProvider.d.ts.map
19
+ export declare function HotkeysProvider({ children, defaultOptions }: HotkeysProviderProps): React.JSX.Element;
20
+ export declare function useHotkeysContext(): HotkeysContextValue | null;
21
+ export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
22
+ //#endregion
@@ -15,5 +15,4 @@ function useDefaultHotkeysOptions() {
15
15
  }
16
16
 
17
17
  //#endregion
18
- export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
19
- //# sourceMappingURL=HotkeysProvider.js.map
18
+ export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
@@ -25,7 +25,5 @@
25
25
  * }
26
26
  * ```
27
27
  */
28
- declare function useHeldKeyCodes(): Record<string, string>;
29
- //#endregion
30
- export { useHeldKeyCodes };
31
- //# sourceMappingURL=useHeldKeyCodes.d.ts.map
28
+ export declare function useHeldKeyCodes(): Record<string, string>;
29
+ //#endregion
@@ -29,9 +29,9 @@ import { useSelector } from "@tanstack/react-store";
29
29
  * ```
30
30
  */
31
31
  function useHeldKeyCodes() {
32
- return useSelector(getKeyStateTracker().store, (state) => state.heldCodes);
32
+ const tracker = getKeyStateTracker();
33
+ return useSelector(tracker.store, (state) => state.heldCodes);
33
34
  }
34
35
 
35
36
  //#endregion
36
- export { useHeldKeyCodes };
37
- //# sourceMappingURL=useHeldKeyCodes.js.map
37
+ export { useHeldKeyCodes };
@@ -21,7 +21,5 @@
21
21
  * }
22
22
  * ```
23
23
  */
24
- declare function useHeldKeys(): Array<string>;
25
- //#endregion
26
- export { useHeldKeys };
27
- //# sourceMappingURL=useHeldKeys.d.ts.map
24
+ export declare function useHeldKeys(): Array<string>;
25
+ //#endregion
@@ -25,9 +25,9 @@ import { useSelector } from "@tanstack/react-store";
25
25
  * ```
26
26
  */
27
27
  function useHeldKeys() {
28
- return useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
28
+ const tracker = getKeyStateTracker();
29
+ return useSelector(tracker.store, (state) => state.heldKeys);
29
30
  }
30
31
 
31
32
  //#endregion
32
- export { useHeldKeys };
33
- //# sourceMappingURL=useHeldKeys.js.map
33
+ export { useHeldKeys };
@@ -1,7 +1,6 @@
1
1
  import { HotkeyCallback, HotkeyOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useHotkey.d.ts
4
- interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
3
+ export interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
5
4
  /**
6
5
  * The DOM element to attach the event listener to.
7
6
  * Can be a React ref, direct DOM element, or null.
@@ -68,7 +67,5 @@ interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
68
67
  * }
69
68
  * ```
70
69
  */
71
- declare function useHotkey(hotkey: RegisterableHotkey, callback: HotkeyCallback, options?: UseHotkeyOptions): void;
72
- //#endregion
73
- export { UseHotkeyOptions, useHotkey };
74
- //# sourceMappingURL=useHotkey.d.ts.map
70
+ export declare function useHotkey(hotkey: RegisterableHotkey, callback: HotkeyCallback, options?: UseHotkeyOptions): void;
71
+ //#endregion
package/dist/useHotkey.js CHANGED
@@ -78,7 +78,8 @@ function useHotkey(hotkey, callback, options = {}) {
78
78
  managerRef.current = manager;
79
79
  const prevTargetRef = useRef(null);
80
80
  const prevHotkeyRef = useRef(null);
81
- const hotkeyString = normalizeRegisterableHotkey(hotkey, mergedOptions.platform ?? detectPlatform());
81
+ const platform = mergedOptions.platform ?? detectPlatform();
82
+ const hotkeyString = normalizeRegisterableHotkey(hotkey, platform);
82
83
  const { target: _target, ...optionsWithoutTarget } = mergedOptions;
83
84
  useEffect(() => {
84
85
  const resolvedTarget = isRef(optionsRef.current.target) ? optionsRef.current.target.current : optionsRef.current.target ?? (typeof document !== "undefined" ? document : null);
@@ -121,5 +122,4 @@ function useHotkey(hotkey, callback, options = {}) {
121
122
  }
122
123
 
123
124
  //#endregion
124
- export { useHotkey };
125
- //# sourceMappingURL=useHotkey.js.map
125
+ export { useHotkey };
@@ -1,5 +1,4 @@
1
1
  import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useHotkeyHint.d.ts
4
3
  /**
5
4
  * Returns a boolean indicating whether held modifiers reveal this shortcut.
@@ -8,7 +7,5 @@ import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
8
7
  * every modifier. Combine with the action's enabled state before showing a badge.
9
8
  * This helper does not register a shortcut or check whether its target is focused.
10
9
  */
11
- declare function useHotkeyHint(hotkey: RegisterableHotkey, options?: HeldModifierOptions): boolean;
12
- //#endregion
13
- export { useHotkeyHint };
14
- //# sourceMappingURL=useHotkeyHint.d.ts.map
10
+ export declare function useHotkeyHint(hotkey: RegisterableHotkey, options?: HeldModifierOptions): boolean;
11
+ //#endregion
@@ -14,5 +14,4 @@ function useHotkeyHint(hotkey, options = {}) {
14
14
  }
15
15
 
16
16
  //#endregion
17
- export { useHotkeyHint };
18
- //# sourceMappingURL=useHotkeyHint.js.map
17
+ export { useHotkeyHint };
@@ -1,7 +1,6 @@
1
1
  import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useHotkeyRecorder.d.ts
4
- interface ReactHotkeyRecorder {
3
+ export interface ReactHotkeyRecorder {
5
4
  /** Whether recording is currently active */
6
5
  isRecording: boolean;
7
6
  /** The currently recorded hotkey (for live preview) */
@@ -51,7 +50,5 @@ interface ReactHotkeyRecorder {
51
50
  * }
52
51
  * ```
53
52
  */
54
- declare function useHotkeyRecorder(options: HotkeyRecorderOptions): ReactHotkeyRecorder;
55
- //#endregion
56
- export { ReactHotkeyRecorder, useHotkeyRecorder };
57
- //# sourceMappingURL=useHotkeyRecorder.d.ts.map
53
+ export declare function useHotkeyRecorder(options: HotkeyRecorderOptions): ReactHotkeyRecorder;
54
+ //#endregion
@@ -67,5 +67,4 @@ function useHotkeyRecorder(options) {
67
67
  }
68
68
 
69
69
  //#endregion
70
- export { useHotkeyRecorder };
71
- //# sourceMappingURL=useHotkeyRecorder.js.map
70
+ export { useHotkeyRecorder };
@@ -1,10 +1,9 @@
1
1
  import { HotkeyRegistrationView, SequenceRegistrationView } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useHotkeyRegistrations.d.ts
4
3
  /**
5
4
  * Return type for useHotkeyRegistrations.
6
5
  */
7
- interface HotkeyRegistrationsResult {
6
+ export interface HotkeyRegistrationsResult {
8
7
  /** All registered hotkeys (public view, no callbacks) */
9
8
  hotkeys: Array<HotkeyRegistrationView>;
10
9
  /** All registered sequences */
@@ -42,7 +41,5 @@ interface HotkeyRegistrationsResult {
42
41
  * }
43
42
  * ```
44
43
  */
45
- declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
46
- //#endregion
47
- export { HotkeyRegistrationsResult, useHotkeyRegistrations };
48
- //# sourceMappingURL=useHotkeyRegistrations.d.ts.map
44
+ export declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
45
+ //#endregion
@@ -44,5 +44,4 @@ function useHotkeyRegistrations() {
44
44
  }
45
45
 
46
46
  //#endregion
47
- export { useHotkeyRegistrations };
48
- //# sourceMappingURL=useHotkeyRegistrations.js.map
47
+ export { useHotkeyRegistrations };
@@ -1,7 +1,6 @@
1
1
  import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useHotkeySequence.d.ts
4
- interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
3
+ export interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
5
4
  /**
6
5
  * The DOM element to attach the event listener to.
7
6
  * Can be a React ref, direct DOM element, or null.
@@ -52,7 +51,5 @@ interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
52
51
  * }
53
52
  * ```
54
53
  */
55
- declare function useHotkeySequence(sequence: HotkeySequence, callback: HotkeyCallback, options?: UseHotkeySequenceOptions): void;
56
- //#endregion
57
- export { UseHotkeySequenceOptions, useHotkeySequence };
58
- //# sourceMappingURL=useHotkeySequence.d.ts.map
54
+ export declare function useHotkeySequence(sequence: HotkeySequence, callback: HotkeyCallback, options?: UseHotkeySequenceOptions): void;
55
+ //#endregion
@@ -116,5 +116,4 @@ function useHotkeySequence(sequence, callback, options = {}) {
116
116
  }
117
117
 
118
118
  //#endregion
119
- export { useHotkeySequence };
120
- //# sourceMappingURL=useHotkeySequence.js.map
119
+ export { useHotkeySequence };
@@ -1,7 +1,6 @@
1
1
  import { HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useHotkeySequenceRecorder.d.ts
4
- interface ReactHotkeySequenceRecorder {
3
+ export interface ReactHotkeySequenceRecorder {
5
4
  /** Whether recording is currently active */
6
5
  isRecording: boolean;
7
6
  /** Chords captured in the current session */
@@ -19,7 +18,5 @@ interface ReactHotkeySequenceRecorder {
19
18
  *
20
19
  * @param options - Configuration options for the hotkey sequence recorder
21
20
  */
22
- declare function useHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions): ReactHotkeySequenceRecorder;
23
- //#endregion
24
- export { ReactHotkeySequenceRecorder, useHotkeySequenceRecorder };
25
- //# sourceMappingURL=useHotkeySequenceRecorder.d.ts.map
21
+ export declare function useHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions): ReactHotkeySequenceRecorder;
22
+ //#endregion
@@ -37,5 +37,4 @@ function useHotkeySequenceRecorder(options) {
37
37
  }
38
38
 
39
39
  //#endregion
40
- export { useHotkeySequenceRecorder };
41
- //# sourceMappingURL=useHotkeySequenceRecorder.js.map
40
+ export { useHotkeySequenceRecorder };
@@ -1,11 +1,10 @@
1
1
  import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
2
2
  import { HotkeyCallback, HotkeySequence } from "@tanstack/hotkeys";
3
-
4
3
  //#region src/useHotkeySequences.d.ts
5
4
  /**
6
5
  * A single sequence definition for use with `useHotkeySequences`.
7
6
  */
8
- interface UseHotkeySequenceDefinition {
7
+ export interface UseHotkeySequenceDefinition {
9
8
  /** Array of hotkey strings that form the sequence */
10
9
  sequence: HotkeySequence;
11
10
  /** The function to call when the sequence is completed */
@@ -57,7 +56,5 @@ interface UseHotkeySequenceDefinition {
57
56
  * }
58
57
  * ```
59
58
  */
60
- declare function useHotkeySequences(definitions: Array<UseHotkeySequenceDefinition>, commonOptions?: UseHotkeySequenceOptions): void;
61
- //#endregion
62
- export { UseHotkeySequenceDefinition, useHotkeySequences };
63
- //# sourceMappingURL=useHotkeySequences.d.ts.map
59
+ export declare function useHotkeySequences(definitions: Array<UseHotkeySequenceDefinition>, commonOptions?: UseHotkeySequenceOptions): void;
60
+ //#endregion
@@ -122,5 +122,4 @@ function useHotkeySequences(definitions, commonOptions = {}) {
122
122
  }
123
123
 
124
124
  //#endregion
125
- export { useHotkeySequences };
126
- //# sourceMappingURL=useHotkeySequences.js.map
125
+ export { useHotkeySequences };
@@ -1,11 +1,10 @@
1
1
  import { UseHotkeyOptions } from "./useHotkey.js";
2
2
  import { HotkeyCallback, RegisterableHotkey } from "@tanstack/hotkeys";
3
-
4
3
  //#region src/useHotkeys.d.ts
5
4
  /**
6
5
  * A single hotkey definition for use with `useHotkeys`.
7
6
  */
8
- interface UseHotkeyDefinition {
7
+ export interface UseHotkeyDefinition {
9
8
  /** The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object */
10
9
  hotkey: RegisterableHotkey;
11
10
  /** The function to call when the hotkey is pressed */
@@ -57,7 +56,5 @@ interface UseHotkeyDefinition {
57
56
  * }
58
57
  * ```
59
58
  */
60
- declare function useHotkeys(hotkeys: Array<UseHotkeyDefinition>, commonOptions?: UseHotkeyOptions): void;
61
- //#endregion
62
- export { UseHotkeyDefinition, useHotkeys };
63
- //# sourceMappingURL=useHotkeys.d.ts.map
59
+ export declare function useHotkeys(hotkeys: Array<UseHotkeyDefinition>, commonOptions?: UseHotkeyOptions): void;
60
+ //#endregion
@@ -120,5 +120,4 @@ function useHotkeys(hotkeys, commonOptions = {}) {
120
120
  }
121
121
 
122
122
  //#endregion
123
- export { useHotkeys };
124
- //# sourceMappingURL=useHotkeys.js.map
123
+ export { useHotkeys };
@@ -1,5 +1,4 @@
1
1
  import { IndividualKey } from "@tanstack/hotkeys";
2
-
3
2
  //#region src/useKeyHold.d.ts
4
3
  /**
5
4
  * React hook that returns whether a specific key is currently being held.
@@ -41,7 +40,5 @@ import { IndividualKey } from "@tanstack/hotkeys";
41
40
  * }
42
41
  * ```
43
42
  */
44
- declare function useKeyHold(key: IndividualKey): boolean;
45
- //#endregion
46
- export { useKeyHold };
47
- //# sourceMappingURL=useKeyHold.d.ts.map
43
+ export declare function useKeyHold(key: IndividualKey): boolean;
44
+ //#endregion
@@ -49,5 +49,4 @@ function useKeyHold(key) {
49
49
  }
50
50
 
51
51
  //#endregion
52
- export { useKeyHold };
53
- //# sourceMappingURL=useKeyHold.js.map
52
+ export { useKeyHold };
package/dist/utils.js CHANGED
@@ -7,5 +7,4 @@ function isRef(value) {
7
7
  }
8
8
 
9
9
  //#endregion
10
- export { isRef };
11
- //# sourceMappingURL=utils.js.map
10
+ export { isRef };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-hotkeys",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "React adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -20,37 +20,31 @@
20
20
  "keys"
21
21
  ],
22
22
  "type": "module",
23
- "main": "./dist/index.cjs",
24
- "module": "./dist/index.js",
25
- "types": "./dist/index.d.cts",
23
+ "types": "./dist/index.d.ts",
26
24
  "exports": {
27
- ".": {
28
- "import": "./dist/index.js",
29
- "require": "./dist/index.cjs"
30
- },
25
+ ".": "./dist/index.js",
31
26
  "./package.json": "./package.json"
32
27
  },
33
28
  "sideEffects": false,
34
29
  "engines": {
35
- "node": ">=18"
30
+ "node": ">=20"
36
31
  },
37
32
  "files": [
38
- "dist",
39
- "src"
33
+ "dist"
40
34
  ],
41
35
  "dependencies": {
42
- "@tanstack/react-store": "^0.11.0",
43
- "@tanstack/hotkeys": "0.9.0"
36
+ "@tanstack/hotkeys": "0.10.0",
37
+ "@tanstack/react-store": "^0.11.1"
44
38
  },
45
39
  "devDependencies": {
46
40
  "@eslint-react/eslint-plugin": "^4.2.3",
47
- "@testing-library/react": "^16.3.2",
48
- "@types/react": "^19.2.14",
49
- "@vitejs/plugin-react": "^6.0.1",
41
+ "@testing-library/react": "^16.3.3",
42
+ "@types/react": "^19.3.0",
43
+ "@vitejs/plugin-react": "^6.1.1",
50
44
  "eslint-plugin-react-compiler": "19.1.0-rc.2",
51
45
  "eslint-plugin-react-hooks": "^7.1.1",
52
- "react": "^19.2.5",
53
- "react-dom": "^19.2.5"
46
+ "react": "^19.3.0",
47
+ "react-dom": "^19.3.0"
54
48
  },
55
49
  "peerDependencies": {
56
50
  "react": ">=16.8",
@@ -64,6 +58,7 @@
64
58
  "test:lib": "vitest --passWithNoTests",
65
59
  "test:lib:dev": "pnpm test:lib --watch",
66
60
  "test:types": "tsc",
67
- "build": "tsdown"
61
+ "build": "tsdown",
62
+ "test:build": "publint --strict && node ../../scripts/verify-package.ts"
68
63
  }
69
64
  }
@@ -1,23 +0,0 @@
1
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
- let react = require("react");
3
- react = require_runtime.__toESM(react);
4
-
5
- //#region src/HotkeysProvider.tsx
6
- const HotkeysContext = (0, react.createContext)(null);
7
- const DEFAULT_OPTIONS = {};
8
- function HotkeysProvider({ children, defaultOptions = DEFAULT_OPTIONS }) {
9
- const contextValue = (0, react.useMemo)(() => ({ defaultOptions }), [defaultOptions]);
10
- return /* @__PURE__ */ react.default.createElement(HotkeysContext.Provider, { value: contextValue }, children);
11
- }
12
- function useHotkeysContext() {
13
- return (0, react.useContext)(HotkeysContext);
14
- }
15
- function useDefaultHotkeysOptions() {
16
- return (0, react.useContext)(HotkeysContext)?.defaultOptions ?? {};
17
- }
18
-
19
- //#endregion
20
- exports.HotkeysProvider = HotkeysProvider;
21
- exports.useDefaultHotkeysOptions = useDefaultHotkeysOptions;
22
- exports.useHotkeysContext = useHotkeysContext;
23
- //# sourceMappingURL=HotkeysProvider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProvider.cjs","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: ReactNode\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function HotkeysProvider({\n children,\n defaultOptions = DEFAULT_OPTIONS,\n}: HotkeysProviderProps) {\n const contextValue: HotkeysContextValue = useMemo(\n () => ({\n defaultOptions,\n }),\n [defaultOptions],\n )\n\n return (\n // eslint-disable-next-line @eslint-react/no-context-provider -- React 19+ only; we support React >=16.8\n <HotkeysContext.Provider value={contextValue}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n // eslint-disable-next-line @eslint-react/no-use-context -- React 19+ only; we support React >=16.8\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n // eslint-disable-next-line @eslint-react/no-use-context -- React 19+ only; we support React >=16.8\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;;AAoBA,MAAM,0CAA2D,KAAK;AAOtE,MAAM,kBAA0C,EAAE;AAElD,SAAgB,gBAAgB,EAC9B,UACA,iBAAiB,mBACM;CACvB,MAAM,yCACG,EACL,gBACD,GACD,CAAC,eAAe,CACjB;AAED,QAEE,4CAAC,eAAe,UAAhB,EAAyB,OAAO,cAEN,EADvB,SACuB;;AAI9B,SAAgB,oBAAoB;AAElC,8BAAkB,eAAe;;AAGnC,SAAgB,2BAA2B;AAGzC,8BAD2B,eAAe,EAC1B,kBAAkB,EAAE"}
@@ -1,28 +0,0 @@
1
- import { UseHotkeyOptions } from "./useHotkey.cjs";
2
- import { UseHotkeySequenceOptions } from "./useHotkeySequence.cjs";
3
- import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
- import React, { ReactNode } from "react";
5
-
6
- //#region src/HotkeysProvider.d.ts
7
- interface HotkeysProviderOptions {
8
- hotkey?: Partial<UseHotkeyOptions>;
9
- hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
10
- hotkeySequence?: Partial<UseHotkeySequenceOptions>;
11
- hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
12
- }
13
- interface HotkeysContextValue {
14
- defaultOptions: HotkeysProviderOptions;
15
- }
16
- interface HotkeysProviderProps {
17
- children: ReactNode;
18
- defaultOptions?: HotkeysProviderOptions;
19
- }
20
- declare function HotkeysProvider({
21
- children,
22
- defaultOptions
23
- }: HotkeysProviderProps): React.JSX.Element;
24
- declare function useHotkeysContext(): HotkeysContextValue | null;
25
- declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
26
- //#endregion
27
- export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
28
- //# sourceMappingURL=HotkeysProvider.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProvider.js","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react'\nimport type { ReactNode } from 'react'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: ReactNode\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function HotkeysProvider({\n children,\n defaultOptions = DEFAULT_OPTIONS,\n}: HotkeysProviderProps) {\n const contextValue: HotkeysContextValue = useMemo(\n () => ({\n defaultOptions,\n }),\n [defaultOptions],\n )\n\n return (\n // eslint-disable-next-line @eslint-react/no-context-provider -- React 19+ only; we support React >=16.8\n <HotkeysContext.Provider value={contextValue}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n // eslint-disable-next-line @eslint-react/no-use-context -- React 19+ only; we support React >=16.8\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n // eslint-disable-next-line @eslint-react/no-use-context -- React 19+ only; we support React >=16.8\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAiB,cAA0C,KAAK;AAOtE,MAAM,kBAA0C,EAAE;AAElD,SAAgB,gBAAgB,EAC9B,UACA,iBAAiB,mBACM;CACvB,MAAM,eAAoC,eACjC,EACL,gBACD,GACD,CAAC,eAAe,CACjB;AAED,QAEE,oCAAC,eAAe,UAAhB,EAAyB,OAAO,cAEN,EADvB,SACuB;;AAI9B,SAAgB,oBAAoB;AAElC,QAAO,WAAW,eAAe;;AAGnC,SAAgB,2BAA2B;AAGzC,QADgB,WAAW,eAAe,EAC1B,kBAAkB,EAAE"}
@@ -1,29 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
19
- }
20
- return to;
21
- };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
- value: mod,
24
- enumerable: true
25
- }) : target, mod));
26
-
27
- //#endregion
28
-
29
- exports.__toESM = __toESM;
package/dist/index.cjs DELETED
@@ -1,35 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_HotkeysProvider = require('./HotkeysProvider.cjs');
3
- const require_useHotkey = require('./useHotkey.cjs');
4
- const require_useHotkeys = require('./useHotkeys.cjs');
5
- const require_useHeldKeys = require('./useHeldKeys.cjs');
6
- const require_useHeldKeyCodes = require('./useHeldKeyCodes.cjs');
7
- const require_useKeyHold = require('./useKeyHold.cjs');
8
- const require_useHotkeySequence = require('./useHotkeySequence.cjs');
9
- const require_useHotkeySequences = require('./useHotkeySequences.cjs');
10
- const require_useHotkeyRecorder = require('./useHotkeyRecorder.cjs');
11
- const require_useHotkeyRegistrations = require('./useHotkeyRegistrations.cjs');
12
- const require_useHotkeySequenceRecorder = require('./useHotkeySequenceRecorder.cjs');
13
- const require_useHotkeyHint = require('./useHotkeyHint.cjs');
14
-
15
- exports.HotkeysProvider = require_HotkeysProvider.HotkeysProvider;
16
- exports.useDefaultHotkeysOptions = require_HotkeysProvider.useDefaultHotkeysOptions;
17
- exports.useHeldKeyCodes = require_useHeldKeyCodes.useHeldKeyCodes;
18
- exports.useHeldKeys = require_useHeldKeys.useHeldKeys;
19
- exports.useHotkey = require_useHotkey.useHotkey;
20
- exports.useHotkeyHint = require_useHotkeyHint.useHotkeyHint;
21
- exports.useHotkeyRecorder = require_useHotkeyRecorder.useHotkeyRecorder;
22
- exports.useHotkeyRegistrations = require_useHotkeyRegistrations.useHotkeyRegistrations;
23
- exports.useHotkeySequence = require_useHotkeySequence.useHotkeySequence;
24
- exports.useHotkeySequenceRecorder = require_useHotkeySequenceRecorder.useHotkeySequenceRecorder;
25
- exports.useHotkeySequences = require_useHotkeySequences.useHotkeySequences;
26
- exports.useHotkeys = require_useHotkeys.useHotkeys;
27
- exports.useHotkeysContext = require_HotkeysProvider.useHotkeysContext;
28
- exports.useKeyHold = require_useKeyHold.useKeyHold;
29
- var _tanstack_hotkeys = require("@tanstack/hotkeys");
30
- Object.keys(_tanstack_hotkeys).forEach(function (k) {
31
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
32
- enumerable: true,
33
- get: function () { return _tanstack_hotkeys[k]; }
34
- });
35
- });
package/dist/index.d.cts DELETED
@@ -1,14 +0,0 @@
1
- import { UseHotkeyOptions, useHotkey } from "./useHotkey.cjs";
2
- import { UseHotkeySequenceOptions, useHotkeySequence } from "./useHotkeySequence.cjs";
3
- import { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.cjs";
4
- import { UseHotkeyDefinition, useHotkeys } from "./useHotkeys.cjs";
5
- import { useHeldKeys } from "./useHeldKeys.cjs";
6
- import { useHeldKeyCodes } from "./useHeldKeyCodes.cjs";
7
- import { useKeyHold } from "./useKeyHold.cjs";
8
- import { UseHotkeySequenceDefinition, useHotkeySequences } from "./useHotkeySequences.cjs";
9
- import { ReactHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.cjs";
10
- import { HotkeyRegistrationsResult, useHotkeyRegistrations } from "./useHotkeyRegistrations.cjs";
11
- import { ReactHotkeySequenceRecorder, useHotkeySequenceRecorder } from "./useHotkeySequenceRecorder.cjs";
12
- import { useHotkeyHint } from "./useHotkeyHint.cjs";
13
- export * from "@tanstack/hotkeys";
14
- export { HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, ReactHotkeyRecorder, ReactHotkeySequenceRecorder, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeySequenceDefinition, UseHotkeySequenceOptions, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
@@ -1,38 +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/useHeldKeyCodes.ts
6
- /**
7
- * React hook that returns a map of currently held key names to their physical `event.code` values.
8
- *
9
- * This is useful for debugging which physical key was pressed (e.g. distinguishing
10
- * left vs right Shift via "ShiftLeft" / "ShiftRight").
11
- *
12
- * @returns Record mapping normalized key names to their `event.code` values
13
- *
14
- * @example
15
- * ```tsx
16
- * function KeyDebugDisplay() {
17
- * const heldKeys = useHeldKeys()
18
- * const heldCodes = useHeldKeyCodes()
19
- *
20
- * return (
21
- * <div>
22
- * {heldKeys.map((key) => (
23
- * <kbd key={key}>
24
- * {key} <small>{heldCodes[key]}</small>
25
- * </kbd>
26
- * ))}
27
- * </div>
28
- * )
29
- * }
30
- * ```
31
- */
32
- function useHeldKeyCodes() {
33
- return (0, _tanstack_react_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
34
- }
35
-
36
- //#endregion
37
- exports.useHeldKeyCodes = useHeldKeyCodes;
38
- //# sourceMappingURL=useHeldKeyCodes.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useHeldKeyCodes.cjs","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,0FADoC,CACT,QAAQ,UAAU,MAAM,UAAU"}