@tanstack/vue-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.
Files changed (96) hide show
  1. package/dist/HotkeysProvider.d.ts +5 -9
  2. package/dist/HotkeysProvider.js +1 -2
  3. package/dist/HotkeysProviderContext.d.ts +5 -8
  4. package/dist/HotkeysProviderContext.js +1 -2
  5. package/dist/useHeldKeyCodes.d.ts +2 -5
  6. package/dist/useHeldKeyCodes.js +3 -3
  7. package/dist/useHeldKeys.d.ts +2 -5
  8. package/dist/useHeldKeys.js +3 -3
  9. package/dist/useHotkey.d.ts +3 -6
  10. package/dist/useHotkey.js +3 -3
  11. package/dist/useHotkeyHint.d.ts +2 -5
  12. package/dist/useHotkeyHint.js +1 -2
  13. package/dist/useHotkeyRecorder.d.ts +3 -6
  14. package/dist/useHotkeyRecorder.js +1 -2
  15. package/dist/useHotkeyRegistrations.d.ts +3 -6
  16. package/dist/useHotkeyRegistrations.js +1 -2
  17. package/dist/useHotkeySequence.d.ts +3 -6
  18. package/dist/useHotkeySequence.js +1 -2
  19. package/dist/useHotkeySequenceRecorder.d.ts +3 -6
  20. package/dist/useHotkeySequenceRecorder.js +1 -2
  21. package/dist/useHotkeySequences.d.ts +3 -6
  22. package/dist/useHotkeySequences.js +1 -2
  23. package/dist/useHotkeys.d.ts +3 -6
  24. package/dist/useHotkeys.js +3 -3
  25. package/dist/useKeyHold.d.ts +2 -5
  26. package/dist/useKeyHold.js +3 -3
  27. package/package.json +12 -17
  28. package/dist/HotkeysProvider.cjs +0 -31
  29. package/dist/HotkeysProvider.cjs.map +0 -1
  30. package/dist/HotkeysProvider.d.cts +0 -34
  31. package/dist/HotkeysProvider.js.map +0 -1
  32. package/dist/HotkeysProviderContext.cjs +0 -20
  33. package/dist/HotkeysProviderContext.cjs.map +0 -1
  34. package/dist/HotkeysProviderContext.d.cts +0 -20
  35. package/dist/HotkeysProviderContext.js.map +0 -1
  36. package/dist/index.cjs +0 -37
  37. package/dist/index.d.cts +0 -15
  38. package/dist/useHeldKeyCodes.cjs +0 -37
  39. package/dist/useHeldKeyCodes.cjs.map +0 -1
  40. package/dist/useHeldKeyCodes.d.cts +0 -33
  41. package/dist/useHeldKeyCodes.js.map +0 -1
  42. package/dist/useHeldKeys.cjs +0 -35
  43. package/dist/useHeldKeys.cjs.map +0 -1
  44. package/dist/useHeldKeys.d.cts +0 -31
  45. package/dist/useHeldKeys.js.map +0 -1
  46. package/dist/useHotkey.cjs +0 -140
  47. package/dist/useHotkey.cjs.map +0 -1
  48. package/dist/useHotkey.d.cts +0 -86
  49. package/dist/useHotkey.js.map +0 -1
  50. package/dist/useHotkeyHint.cjs +0 -20
  51. package/dist/useHotkeyHint.cjs.map +0 -1
  52. package/dist/useHotkeyHint.d.cts +0 -15
  53. package/dist/useHotkeyHint.js.map +0 -1
  54. package/dist/useHotkeyRecorder.cjs +0 -80
  55. package/dist/useHotkeyRecorder.cjs.map +0 -1
  56. package/dist/useHotkeyRecorder.d.cts +0 -61
  57. package/dist/useHotkeyRecorder.js.map +0 -1
  58. package/dist/useHotkeyRegistrations.cjs +0 -26
  59. package/dist/useHotkeyRegistrations.cjs.map +0 -1
  60. package/dist/useHotkeyRegistrations.d.cts +0 -27
  61. package/dist/useHotkeyRegistrations.js.map +0 -1
  62. package/dist/useHotkeySequence.cjs +0 -122
  63. package/dist/useHotkeySequence.cjs.map +0 -1
  64. package/dist/useHotkeySequence.d.cts +0 -68
  65. package/dist/useHotkeySequence.js.map +0 -1
  66. package/dist/useHotkeySequenceRecorder.cjs +0 -45
  67. package/dist/useHotkeySequenceRecorder.cjs.map +0 -1
  68. package/dist/useHotkeySequenceRecorder.d.cts +0 -20
  69. package/dist/useHotkeySequenceRecorder.js.map +0 -1
  70. package/dist/useHotkeySequences.cjs +0 -140
  71. package/dist/useHotkeySequences.cjs.map +0 -1
  72. package/dist/useHotkeySequences.d.cts +0 -64
  73. package/dist/useHotkeySequences.js.map +0 -1
  74. package/dist/useHotkeys.cjs +0 -139
  75. package/dist/useHotkeys.cjs.map +0 -1
  76. package/dist/useHotkeys.d.cts +0 -65
  77. package/dist/useHotkeys.js.map +0 -1
  78. package/dist/useKeyHold.cjs +0 -60
  79. package/dist/useKeyHold.cjs.map +0 -1
  80. package/dist/useKeyHold.d.cts +0 -52
  81. package/dist/useKeyHold.js.map +0 -1
  82. package/src/HotkeysProvider.tsx +0 -29
  83. package/src/HotkeysProviderContext.ts +0 -41
  84. package/src/index.ts +0 -19
  85. package/src/useHeldKeyCodes.ts +0 -34
  86. package/src/useHeldKeys.ts +0 -32
  87. package/src/useHotkey.ts +0 -213
  88. package/src/useHotkeyHint.ts +0 -25
  89. package/src/useHotkeyRecorder.ts +0 -112
  90. package/src/useHotkeyRegistrations.ts +0 -46
  91. package/src/useHotkeySequence.ts +0 -187
  92. package/src/useHotkeySequenceRecorder.ts +0 -75
  93. package/src/useHotkeySequences.ts +0 -221
  94. package/src/useHotkeys.ts +0 -221
  95. package/src/useKeyHold.ts +0 -65
  96. package/src/vue.d.ts +0 -6
@@ -1,6 +1,4 @@
1
1
  import { HotkeysProviderOptions } from "./HotkeysProviderContext.js";
2
- import * as _$vue from "vue";
3
-
4
2
  //#region src/HotkeysProvider.d.ts
5
3
  /**
6
4
  * Vue component that provides default options for hotkeys context.
@@ -14,21 +12,19 @@ import * as _$vue from "vue";
14
12
  * </template>
15
13
  * ```
16
14
  */
17
- declare const HotkeysProvider: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
15
+ export declare const HotkeysProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
18
16
  defaultOptions: {
19
17
  type: () => HotkeysProviderOptions;
20
18
  default: undefined;
21
19
  };
22
- }>, () => _$vue.VNode<_$vue.RendererNode, _$vue.RendererElement, {
20
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
21
  [key: string]: any;
24
- }>[] | undefined, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
22
+ }>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
23
  defaultOptions: {
26
24
  type: () => HotkeysProviderOptions;
27
25
  default: undefined;
28
26
  };
29
27
  }>> & Readonly<{}>, {
30
28
  defaultOptions: HotkeysProviderOptions;
31
- }, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
32
- //#endregion
33
- export { HotkeysProvider };
34
- //# sourceMappingURL=HotkeysProvider.d.ts.map
29
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
30
+ //#endregion
@@ -27,5 +27,4 @@ const HotkeysProvider = defineComponent({
27
27
  });
28
28
 
29
29
  //#endregion
30
- export { HotkeysProvider };
31
- //# sourceMappingURL=HotkeysProvider.js.map
30
+ export { HotkeysProvider };
@@ -1,9 +1,8 @@
1
1
  import { UseHotkeyOptions } from "./useHotkey.js";
2
2
  import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
3
3
  import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
-
5
4
  //#region src/HotkeysProviderContext.d.ts
6
- interface HotkeysProviderOptions {
5
+ export interface HotkeysProviderOptions {
7
6
  hotkey?: Partial<UseHotkeyOptions>;
8
7
  hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
9
8
  hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
@@ -12,9 +11,7 @@ interface HotkeysProviderOptions {
12
11
  interface HotkeysContextValue {
13
12
  defaultOptions: HotkeysProviderOptions;
14
13
  }
15
- declare function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions): void;
16
- declare function useHotkeysContext(): HotkeysContextValue | null;
17
- declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
18
- //#endregion
19
- export { HotkeysProviderOptions, provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
20
- //# sourceMappingURL=HotkeysProviderContext.d.ts.map
14
+ export declare function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions): void;
15
+ export declare function useHotkeysContext(): HotkeysContextValue | null;
16
+ export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
17
+ //#endregion
@@ -14,5 +14,4 @@ function useDefaultHotkeysOptions() {
14
14
  }
15
15
 
16
16
  //#endregion
17
- export { provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
18
- //# sourceMappingURL=HotkeysProviderContext.js.map
17
+ export { provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
@@ -1,5 +1,4 @@
1
1
  import { Ref } from "vue";
2
-
3
2
  //#region src/useHeldKeyCodes.d.ts
4
3
  /**
5
4
  * Vue composable that returns a reactive ref mapping currently held key names to their physical `event.code` values.
@@ -27,7 +26,5 @@ import { Ref } from "vue";
27
26
  * </template>
28
27
  * ```
29
28
  */
30
- declare function useHeldKeyCodes(): Ref<Record<string, string>>;
31
- //#endregion
32
- export { useHeldKeyCodes };
33
- //# sourceMappingURL=useHeldKeyCodes.d.ts.map
29
+ export declare function useHeldKeyCodes(): Ref<Record<string, string>>;
30
+ //#endregion
@@ -29,9 +29,9 @@ import { useSelector } from "@tanstack/vue-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 };
@@ -1,5 +1,4 @@
1
1
  import { Ref } from "vue";
2
-
3
2
  //#region src/useHeldKeys.d.ts
4
3
  /**
5
4
  * Vue composable that returns a reactive ref of currently held keyboard keys.
@@ -25,7 +24,5 @@ import { Ref } from "vue";
25
24
  * </template>
26
25
  * ```
27
26
  */
28
- declare function useHeldKeys(): Ref<Array<string>>;
29
- //#endregion
30
- export { useHeldKeys };
31
- //# sourceMappingURL=useHeldKeys.d.ts.map
27
+ export declare function useHeldKeys(): Ref<Array<string>>;
28
+ //#endregion
@@ -27,9 +27,9 @@ import { useSelector } from "@tanstack/vue-store";
27
27
  * ```
28
28
  */
29
29
  function useHeldKeys() {
30
- return useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
30
+ const tracker = getKeyStateTracker();
31
+ return useSelector(tracker.store, (state) => state.heldKeys);
31
32
  }
32
33
 
33
34
  //#endregion
34
- export { useHeldKeys };
35
- //# sourceMappingURL=useHeldKeys.js.map
35
+ export { useHeldKeys };
@@ -1,8 +1,7 @@
1
1
  import { HotkeyCallback, HotkeyOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
2
  import { MaybeRefOrGetter } from "vue";
3
-
4
3
  //#region src/useHotkey.d.ts
5
- interface UseHotkeyOptions extends Omit<HotkeyOptions, 'enabled' | 'target'> {
4
+ export interface UseHotkeyOptions extends Omit<HotkeyOptions, 'enabled' | 'target'> {
6
5
  /**
7
6
  * Whether the hotkey is active.
8
7
  * Can be a Ref, a getter function, or a boolean value.
@@ -80,7 +79,5 @@ interface UseHotkeyOptions extends Omit<HotkeyOptions, 'enabled' | 'target'> {
80
79
  * </template>
81
80
  * ```
82
81
  */
83
- declare function useHotkey(hotkey: MaybeRefOrGetter<RegisterableHotkey>, callback: HotkeyCallback, options?: MaybeRefOrGetter<UseHotkeyOptions>): void;
84
- //#endregion
85
- export { UseHotkeyOptions, useHotkey };
86
- //# sourceMappingURL=useHotkey.d.ts.map
82
+ export declare function useHotkey(hotkey: MaybeRefOrGetter<RegisterableHotkey>, callback: HotkeyCallback, options?: MaybeRefOrGetter<UseHotkeyOptions>): void;
83
+ //#endregion
package/dist/useHotkey.js CHANGED
@@ -87,7 +87,8 @@ function useHotkey(hotkey, callback, options = {}) {
87
87
  resolvedTarget: mergedOptions.target === void 0 ? void 0 : resolveMaybeRefOrGetter(mergedOptions.target)
88
88
  };
89
89
  }, ({ resolvedHotkey, mergedOptions, resolvedEnabled, resolvedTarget }) => {
90
- const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, mergedOptions.platform ?? detectPlatform());
90
+ const platform = mergedOptions.platform ?? detectPlatform();
91
+ const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, platform);
91
92
  const finalTarget = resolvedTarget === void 0 ? typeof document !== "undefined" ? document : null : resolvedTarget;
92
93
  if (!finalTarget) {
93
94
  if (registration?.isActive) {
@@ -136,5 +137,4 @@ function resolveMaybeRefOrGetter(value) {
136
137
  }
137
138
 
138
139
  //#endregion
139
- export { useHotkey };
140
- //# sourceMappingURL=useHotkey.js.map
140
+ export { useHotkey };
@@ -1,6 +1,5 @@
1
1
  import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
2
  import { ComputedRef, MaybeRefOrGetter } from "vue";
3
-
4
3
  //#region src/useHotkeyHint.d.ts
5
4
  /**
6
5
  * Returns a computed ref indicating whether held modifiers reveal this shortcut.
@@ -9,7 +8,5 @@ import { ComputedRef, MaybeRefOrGetter } from "vue";
9
8
  * every modifier. Combine with the action's enabled state before showing a badge.
10
9
  * This helper does not register a shortcut or check whether its target is focused.
11
10
  */
12
- declare function useHotkeyHint(hotkey: MaybeRefOrGetter<RegisterableHotkey>, options?: MaybeRefOrGetter<HeldModifierOptions>): ComputedRef<boolean>;
13
- //#endregion
14
- export { useHotkeyHint };
15
- //# sourceMappingURL=useHotkeyHint.d.ts.map
11
+ export declare function useHotkeyHint(hotkey: MaybeRefOrGetter<RegisterableHotkey>, options?: MaybeRefOrGetter<HeldModifierOptions>): ComputedRef<boolean>;
12
+ //#endregion
@@ -16,5 +16,4 @@ function useHotkeyHint(hotkey, options = {}) {
16
16
  }
17
17
 
18
18
  //#endregion
19
- export { useHotkeyHint };
20
- //# sourceMappingURL=useHotkeyHint.js.map
19
+ export { useHotkeyHint };
@@ -1,8 +1,7 @@
1
1
  import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
2
2
  import { MaybeRefOrGetter, Ref } from "vue";
3
-
4
3
  //#region src/useHotkeyRecorder.d.ts
5
- interface VueHotkeyRecorder {
4
+ export interface VueHotkeyRecorder {
6
5
  /** Whether recording is currently active */
7
6
  isRecording: Ref<boolean>;
8
7
  /** The currently recorded hotkey (for live preview) */
@@ -55,7 +54,5 @@ interface VueHotkeyRecorder {
55
54
  * </template>
56
55
  * ```
57
56
  */
58
- declare function useHotkeyRecorder(options: MaybeRefOrGetter<HotkeyRecorderOptions>): VueHotkeyRecorder;
59
- //#endregion
60
- export { VueHotkeyRecorder, useHotkeyRecorder };
61
- //# sourceMappingURL=useHotkeyRecorder.d.ts.map
57
+ export declare function useHotkeyRecorder(options: MaybeRefOrGetter<HotkeyRecorderOptions>): VueHotkeyRecorder;
58
+ //#endregion
@@ -76,5 +76,4 @@ function resolveMaybeRefOrGetter(value) {
76
76
  }
77
77
 
78
78
  //#endregion
79
- export { useHotkeyRecorder };
80
- //# sourceMappingURL=useHotkeyRecorder.js.map
79
+ export { useHotkeyRecorder };
@@ -1,11 +1,10 @@
1
1
  import { HotkeyRegistrationView, SequenceRegistrationView } from "@tanstack/hotkeys";
2
2
  import { Ref } from "vue";
3
-
4
3
  //#region src/useHotkeyRegistrations.d.ts
5
4
  /**
6
5
  * Return type for useHotkeyRegistrations.
7
6
  */
8
- interface HotkeyRegistrationsResult {
7
+ export interface HotkeyRegistrationsResult {
9
8
  /** All registered hotkeys (public view, no callbacks) */
10
9
  hotkeys: Ref<Array<HotkeyRegistrationView>>;
11
10
  /** All registered sequences */
@@ -21,7 +20,5 @@ interface HotkeyRegistrationsResult {
21
20
  *
22
21
  * @returns Object with `hotkeys` and `sequences` refs
23
22
  */
24
- declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
25
- //#endregion
26
- export { HotkeyRegistrationsResult, useHotkeyRegistrations };
27
- //# sourceMappingURL=useHotkeyRegistrations.d.ts.map
23
+ export declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
24
+ //#endregion
@@ -22,5 +22,4 @@ function useHotkeyRegistrations() {
22
22
  }
23
23
 
24
24
  //#endregion
25
- export { useHotkeyRegistrations };
26
- //# sourceMappingURL=useHotkeyRegistrations.js.map
25
+ export { useHotkeyRegistrations };
@@ -1,8 +1,7 @@
1
1
  import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
2
2
  import { MaybeRefOrGetter } from "vue";
3
-
4
3
  //#region src/useHotkeySequence.d.ts
5
- interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'target'> {
4
+ export interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'target'> {
6
5
  /**
7
6
  * Whether the sequence is active.
8
7
  * Can be a Ref, a getter function, or a boolean value.
@@ -62,7 +61,5 @@ interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'ta
62
61
  * </template>
63
62
  * ```
64
63
  */
65
- declare function useHotkeySequence(sequence: MaybeRefOrGetter<HotkeySequence>, callback: HotkeyCallback, options?: MaybeRefOrGetter<UseHotkeySequenceOptions>): void;
66
- //#endregion
67
- export { UseHotkeySequenceOptions, useHotkeySequence };
68
- //# sourceMappingURL=useHotkeySequence.d.ts.map
64
+ export declare function useHotkeySequence(sequence: MaybeRefOrGetter<HotkeySequence>, callback: HotkeyCallback, options?: MaybeRefOrGetter<UseHotkeySequenceOptions>): void;
65
+ //#endregion
@@ -118,5 +118,4 @@ function resolveMaybeRefOrGetter(value) {
118
118
  }
119
119
 
120
120
  //#endregion
121
- export { useHotkeySequence };
122
- //# sourceMappingURL=useHotkeySequence.js.map
121
+ export { useHotkeySequence };
@@ -1,8 +1,7 @@
1
1
  import { HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
2
2
  import { MaybeRefOrGetter, Ref } from "vue";
3
-
4
3
  //#region src/useHotkeySequenceRecorder.d.ts
5
- interface VueHotkeySequenceRecorder {
4
+ export interface VueHotkeySequenceRecorder {
6
5
  isRecording: Ref<boolean>;
7
6
  steps: Ref<HotkeySequence>;
8
7
  recordedSequence: Ref<HotkeySequence | null>;
@@ -14,7 +13,5 @@ interface VueHotkeySequenceRecorder {
14
13
  /**
15
14
  * Vue composable for recording multi-chord sequences (Vim-style shortcuts).
16
15
  */
17
- declare function useHotkeySequenceRecorder(options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>): VueHotkeySequenceRecorder;
18
- //#endregion
19
- export { VueHotkeySequenceRecorder, useHotkeySequenceRecorder };
20
- //# sourceMappingURL=useHotkeySequenceRecorder.d.ts.map
16
+ export declare function useHotkeySequenceRecorder(options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>): VueHotkeySequenceRecorder;
17
+ //#endregion
@@ -41,5 +41,4 @@ function resolveMaybeRefOrGetter(value) {
41
41
  }
42
42
 
43
43
  //#endregion
44
- export { useHotkeySequenceRecorder };
45
- //# sourceMappingURL=useHotkeySequenceRecorder.js.map
44
+ export { useHotkeySequenceRecorder };
@@ -1,12 +1,11 @@
1
1
  import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
2
2
  import { HotkeyCallback, HotkeySequence } from "@tanstack/hotkeys";
3
3
  import { MaybeRefOrGetter } from "vue";
4
-
5
4
  //#region src/useHotkeySequences.d.ts
6
5
  /**
7
6
  * A single sequence definition for use with `useHotkeySequences`.
8
7
  */
9
- interface UseHotkeySequenceDefinition {
8
+ export interface UseHotkeySequenceDefinition {
10
9
  /** Array of hotkey strings that form the sequence */
11
10
  sequence: MaybeRefOrGetter<HotkeySequence>;
12
11
  /** The function to call when the sequence is completed */
@@ -58,7 +57,5 @@ interface UseHotkeySequenceDefinition {
58
57
  * </script>
59
58
  * ```
60
59
  */
61
- declare function useHotkeySequences(definitions: MaybeRefOrGetter<Array<UseHotkeySequenceDefinition>>, commonOptions?: MaybeRefOrGetter<UseHotkeySequenceOptions>): void;
62
- //#endregion
63
- export { UseHotkeySequenceDefinition, useHotkeySequences };
64
- //# sourceMappingURL=useHotkeySequences.d.ts.map
60
+ export declare function useHotkeySequences(definitions: MaybeRefOrGetter<Array<UseHotkeySequenceDefinition>>, commonOptions?: MaybeRefOrGetter<UseHotkeySequenceOptions>): void;
61
+ //#endregion
@@ -136,5 +136,4 @@ function resolveMaybeRefOrGetter(value) {
136
136
  }
137
137
 
138
138
  //#endregion
139
- export { useHotkeySequences };
140
- //# sourceMappingURL=useHotkeySequences.js.map
139
+ export { useHotkeySequences };
@@ -1,12 +1,11 @@
1
1
  import { UseHotkeyOptions } from "./useHotkey.js";
2
2
  import { HotkeyCallback, RegisterableHotkey } from "@tanstack/hotkeys";
3
3
  import { MaybeRefOrGetter } from "vue";
4
-
5
4
  //#region src/useHotkeys.d.ts
6
5
  /**
7
6
  * A single hotkey definition for use with `useHotkeys`.
8
7
  */
9
- interface UseHotkeyDefinition {
8
+ export interface UseHotkeyDefinition {
10
9
  /** The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object */
11
10
  hotkey: MaybeRefOrGetter<RegisterableHotkey>;
12
11
  /** The function to call when the hotkey is pressed */
@@ -59,7 +58,5 @@ interface UseHotkeyDefinition {
59
58
  * </script>
60
59
  * ```
61
60
  */
62
- declare function useHotkeys(hotkeys: MaybeRefOrGetter<Array<UseHotkeyDefinition>>, commonOptions?: MaybeRefOrGetter<UseHotkeyOptions>): void;
63
- //#endregion
64
- export { UseHotkeyDefinition, useHotkeys };
65
- //# sourceMappingURL=useHotkeys.d.ts.map
61
+ export declare function useHotkeys(hotkeys: MaybeRefOrGetter<Array<UseHotkeyDefinition>>, commonOptions?: MaybeRefOrGetter<UseHotkeyOptions>): void;
62
+ //#endregion
@@ -63,7 +63,8 @@ function useHotkeys(hotkeys, commonOptions = {}) {
63
63
  ...resolvedCommonOptions,
64
64
  ...resolvedDefOptions
65
65
  };
66
- const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, mergedOptions.platform ?? detectPlatform());
66
+ const platform = mergedOptions.platform ?? detectPlatform();
67
+ const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, platform);
67
68
  const resolvedEnabled = mergedOptions.enabled === void 0 ? void 0 : resolveMaybeRefOrGetter(mergedOptions.enabled);
68
69
  const resolvedTarget = mergedOptions.target === void 0 ? void 0 : resolveMaybeRefOrGetter(mergedOptions.target);
69
70
  return {
@@ -135,5 +136,4 @@ function resolveMaybeRefOrGetter(value) {
135
136
  }
136
137
 
137
138
  //#endregion
138
- export { useHotkeys };
139
- //# sourceMappingURL=useHotkeys.js.map
139
+ export { useHotkeys };
@@ -1,6 +1,5 @@
1
1
  import { IndividualKey } from "@tanstack/hotkeys";
2
2
  import { MaybeRefOrGetter, Ref } from "vue";
3
-
4
3
  //#region src/useKeyHold.d.ts
5
4
  /**
6
5
  * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
@@ -46,7 +45,5 @@ import { MaybeRefOrGetter, Ref } from "vue";
46
45
  * </template>
47
46
  * ```
48
47
  */
49
- declare function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean>;
50
- //#endregion
51
- export { useKeyHold };
52
- //# sourceMappingURL=useKeyHold.d.ts.map
48
+ export declare function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean>;
49
+ //#endregion
@@ -48,7 +48,8 @@ import { useSelector } from "@tanstack/vue-store";
48
48
  * ```
49
49
  */
50
50
  function useKeyHold(key) {
51
- return useSelector(getKeyStateTracker().store, (state) => {
51
+ const tracker = getKeyStateTracker();
52
+ return useSelector(tracker.store, (state) => {
52
53
  const keyValue = unref(key);
53
54
  const normalizedKey = (typeof keyValue === "string" ? keyValue : String(keyValue)).toLowerCase();
54
55
  return state.heldKeys.some((heldKey) => heldKey.toLowerCase() === normalizedKey);
@@ -56,5 +57,4 @@ function useKeyHold(key) {
56
57
  }
57
58
 
58
59
  //#endregion
59
- export { useKeyHold };
60
- //# sourceMappingURL=useKeyHold.js.map
60
+ export { useKeyHold };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-hotkeys",
3
- "version": "0.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Vue adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -23,32 +23,26 @@
23
23
  "shortcuts"
24
24
  ],
25
25
  "type": "module",
26
- "main": "./dist/index.cjs",
27
- "module": "./dist/index.js",
28
- "types": "./dist/index.d.cts",
26
+ "types": "./dist/index.d.ts",
29
27
  "exports": {
30
- ".": {
31
- "import": "./dist/index.js",
32
- "require": "./dist/index.cjs"
33
- },
28
+ ".": "./dist/index.js",
34
29
  "./package.json": "./package.json"
35
30
  },
36
31
  "sideEffects": false,
37
32
  "engines": {
38
- "node": ">=18"
33
+ "node": ">=20"
39
34
  },
40
35
  "files": [
41
- "dist",
42
- "src"
36
+ "dist"
43
37
  ],
44
38
  "dependencies": {
45
- "@tanstack/vue-store": "^0.11.0",
46
- "@tanstack/hotkeys": "0.9.0"
39
+ "@tanstack/hotkeys": "0.10.1",
40
+ "@tanstack/vue-store": "^0.11.1"
47
41
  },
48
42
  "devDependencies": {
49
- "@vitejs/plugin-vue": "^6.0.6",
50
- "@vue/test-utils": "^2.4.8",
51
- "vue": "^3.5.33"
43
+ "@vitejs/plugin-vue": "^6.0.9",
44
+ "@vue/test-utils": "^2.5.1",
45
+ "vue": "^3.5.43"
52
46
  },
53
47
  "peerDependencies": {
54
48
  "vue": ">=3.0.0"
@@ -61,6 +55,7 @@
61
55
  "test:lib": "vitest --passWithNoTests",
62
56
  "test:lib:dev": "pnpm test:lib --watch",
63
57
  "test:types": "tsc",
64
- "build": "tsdown"
58
+ "build": "tsdown",
59
+ "test:build": "publint --strict && node ../../scripts/verify-package.ts"
65
60
  }
66
61
  }
@@ -1,31 +0,0 @@
1
- const require_HotkeysProviderContext = require('./HotkeysProviderContext.cjs');
2
- let vue = require("vue");
3
-
4
- //#region src/HotkeysProvider.tsx
5
- /**
6
- * Vue component that provides default options for hotkeys context.
7
- *
8
- * @example
9
- * ```vue
10
- * <template>
11
- * <HotkeysProvider :defaultOptions="{ hotkey: { enabled: true } }">
12
- * <App />
13
- * </HotkeysProvider>
14
- * </template>
15
- * ```
16
- */
17
- const HotkeysProvider = (0, vue.defineComponent)({
18
- name: "HotkeysProvider",
19
- props: { defaultOptions: {
20
- type: Object,
21
- default: void 0
22
- } },
23
- setup(props, { slots }) {
24
- require_HotkeysProviderContext.provideHotkeysContext(props.defaultOptions);
25
- return () => slots.default?.();
26
- }
27
- });
28
-
29
- //#endregion
30
- exports.HotkeysProvider = HotkeysProvider;
31
- //# sourceMappingURL=HotkeysProvider.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProvider.cjs","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { provideHotkeysContext } from './HotkeysProviderContext'\nimport type { HotkeysProviderOptions } from './HotkeysProviderContext'\n\n/**\n * Vue component that provides default options for hotkeys context.\n *\n * @example\n * ```vue\n * <template>\n * <HotkeysProvider :defaultOptions=\"{ hotkey: { enabled: true } }\">\n * <App />\n * </HotkeysProvider>\n * </template>\n * ```\n */\nexport const HotkeysProvider = defineComponent({\n name: 'HotkeysProvider',\n props: {\n defaultOptions: {\n type: Object as () => HotkeysProviderOptions,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n provideHotkeysContext(props.defaultOptions)\n return () => slots.default?.()\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,2CAAkC;CAC7C,MAAM;CACN,OAAO,EACL,gBAAgB;EACd,MAAM;EACN,SAAS;EACV,EACF;CACD,MAAM,OAAO,EAAE,SAAS;AACtB,uDAAsB,MAAM,eAAe;AAC3C,eAAa,MAAM,WAAW;;CAEjC,CAAC"}
@@ -1,34 +0,0 @@
1
- import { HotkeysProviderOptions } from "./HotkeysProviderContext.cjs";
2
- import * as _$vue from "vue";
3
-
4
- //#region src/HotkeysProvider.d.ts
5
- /**
6
- * Vue component that provides default options for hotkeys context.
7
- *
8
- * @example
9
- * ```vue
10
- * <template>
11
- * <HotkeysProvider :defaultOptions="{ hotkey: { enabled: true } }">
12
- * <App />
13
- * </HotkeysProvider>
14
- * </template>
15
- * ```
16
- */
17
- declare const HotkeysProvider: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
18
- defaultOptions: {
19
- type: () => HotkeysProviderOptions;
20
- default: undefined;
21
- };
22
- }>, () => _$vue.VNode<_$vue.RendererNode, _$vue.RendererElement, {
23
- [key: string]: any;
24
- }>[] | undefined, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
25
- defaultOptions: {
26
- type: () => HotkeysProviderOptions;
27
- default: undefined;
28
- };
29
- }>> & Readonly<{}>, {
30
- defaultOptions: HotkeysProviderOptions;
31
- }, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
32
- //#endregion
33
- export { HotkeysProvider };
34
- //# sourceMappingURL=HotkeysProvider.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProvider.js","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { provideHotkeysContext } from './HotkeysProviderContext'\nimport type { HotkeysProviderOptions } from './HotkeysProviderContext'\n\n/**\n * Vue component that provides default options for hotkeys context.\n *\n * @example\n * ```vue\n * <template>\n * <HotkeysProvider :defaultOptions=\"{ hotkey: { enabled: true } }\">\n * <App />\n * </HotkeysProvider>\n * </template>\n * ```\n */\nexport const HotkeysProvider = defineComponent({\n name: 'HotkeysProvider',\n props: {\n defaultOptions: {\n type: Object as () => HotkeysProviderOptions,\n default: undefined,\n },\n },\n setup(props, { slots }) {\n provideHotkeysContext(props.defaultOptions)\n return () => slots.default?.()\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,gBAAgB;CAC7C,MAAM;CACN,OAAO,EACL,gBAAgB;EACd,MAAM;EACN,SAAS;EACV,EACF;CACD,MAAM,OAAO,EAAE,SAAS;AACtB,wBAAsB,MAAM,eAAe;AAC3C,eAAa,MAAM,WAAW;;CAEjC,CAAC"}
@@ -1,20 +0,0 @@
1
- let vue = require("vue");
2
-
3
- //#region src/HotkeysProviderContext.ts
4
- const HotkeysContext = Symbol("HotkeysContext");
5
- const DEFAULT_OPTIONS = {};
6
- function provideHotkeysContext(defaultOptions) {
7
- (0, vue.provide)(HotkeysContext, { defaultOptions: defaultOptions ?? DEFAULT_OPTIONS });
8
- }
9
- function useHotkeysContext() {
10
- return (0, vue.inject)(HotkeysContext, null);
11
- }
12
- function useDefaultHotkeysOptions() {
13
- return (0, vue.inject)(HotkeysContext, null)?.defaultOptions ?? {};
14
- }
15
-
16
- //#endregion
17
- exports.provideHotkeysContext = provideHotkeysContext;
18
- exports.useDefaultHotkeysOptions = useDefaultHotkeysOptions;
19
- exports.useHotkeysContext = useHotkeysContext;
20
- //# sourceMappingURL=HotkeysProviderContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProviderContext.cjs","names":[],"sources":["../src/HotkeysProviderContext.ts"],"sourcesContent":["import { inject, provide } from 'vue'\nimport type { InjectionKey } from 'vue'\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 hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext: InjectionKey<HotkeysContextValue> =\n Symbol('HotkeysContext')\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions) {\n const contextValue: HotkeysContextValue = {\n defaultOptions: defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n provide(HotkeysContext, contextValue)\n}\n\nexport function useHotkeysContext() {\n return inject(HotkeysContext, null)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = inject(HotkeysContext, null)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;AAoBA,MAAM,iBACJ,OAAO,iBAAiB;AAE1B,MAAM,kBAA0C,EAAE;AAElD,SAAgB,sBAAsB,gBAAyC;AAK7E,kBAAQ,gBAJkC,EACxC,gBAAgB,kBAAkB,iBACnC,CAEoC;;AAGvC,SAAgB,oBAAoB;AAClC,wBAAc,gBAAgB,KAAK;;AAGrC,SAAgB,2BAA2B;AAEzC,wBADuB,gBAAgB,KAAK,EAC5B,kBAAkB,EAAE"}
@@ -1,20 +0,0 @@
1
- import { UseHotkeyOptions } from "./useHotkey.cjs";
2
- import { UseHotkeySequenceOptions } from "./useHotkeySequence.cjs";
3
- import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
-
5
- //#region src/HotkeysProviderContext.d.ts
6
- interface HotkeysProviderOptions {
7
- hotkey?: Partial<UseHotkeyOptions>;
8
- hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
9
- hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
10
- hotkeySequence?: Partial<UseHotkeySequenceOptions>;
11
- }
12
- interface HotkeysContextValue {
13
- defaultOptions: HotkeysProviderOptions;
14
- }
15
- declare function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions): void;
16
- declare function useHotkeysContext(): HotkeysContextValue | null;
17
- declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
18
- //#endregion
19
- export { HotkeysProviderOptions, provideHotkeysContext, useDefaultHotkeysOptions, useHotkeysContext };
20
- //# sourceMappingURL=HotkeysProviderContext.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotkeysProviderContext.js","names":[],"sources":["../src/HotkeysProviderContext.ts"],"sourcesContent":["import { inject, provide } from 'vue'\nimport type { InjectionKey } from 'vue'\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 hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext: InjectionKey<HotkeysContextValue> =\n Symbol('HotkeysContext')\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function provideHotkeysContext(defaultOptions?: HotkeysProviderOptions) {\n const contextValue: HotkeysContextValue = {\n defaultOptions: defaultOptions ?? DEFAULT_OPTIONS,\n }\n\n provide(HotkeysContext, contextValue)\n}\n\nexport function useHotkeysContext() {\n return inject(HotkeysContext, null)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = inject(HotkeysContext, null)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;AAoBA,MAAM,iBACJ,OAAO,iBAAiB;AAE1B,MAAM,kBAA0C,EAAE;AAElD,SAAgB,sBAAsB,gBAAyC;AAK7E,SAAQ,gBAJkC,EACxC,gBAAgB,kBAAkB,iBACnC,CAEoC;;AAGvC,SAAgB,oBAAoB;AAClC,QAAO,OAAO,gBAAgB,KAAK;;AAGrC,SAAgB,2BAA2B;AAEzC,QADgB,OAAO,gBAAgB,KAAK,EAC5B,kBAAkB,EAAE"}