@tanstack/vue-hotkeys 0.10.0 → 0.11.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.
package/README.md CHANGED
@@ -1,5 +1,19 @@
1
1
  <div align="center">
2
- <img src="./media/header_hotkeys.png" alt="TanStack Hotkeys" />
2
+ <picture>
3
+ <source
4
+ media="(prefers-color-scheme: dark)"
5
+ srcset="https://tanstack.com/api/readme/hotkeys.png?theme=dark"
6
+ />
7
+ <source
8
+ media="(prefers-color-scheme: light)"
9
+ srcset="https://tanstack.com/api/readme/hotkeys.png"
10
+ />
11
+ <img
12
+ src="https://tanstack.com/api/readme/hotkeys.png"
13
+ alt="TanStack Hotkeys"
14
+ width="900"
15
+ />
16
+ </picture>
3
17
  </div>
4
18
 
5
19
  <br />
package/dist/index.cjs CHANGED
@@ -11,6 +11,7 @@ const require_useHotkeySequences = require('./useHotkeySequences.cjs');
11
11
  const require_useHotkeyRecorder = require('./useHotkeyRecorder.cjs');
12
12
  const require_useHotkeyRegistrations = require('./useHotkeyRegistrations.cjs');
13
13
  const require_useHotkeySequenceRecorder = require('./useHotkeySequenceRecorder.cjs');
14
+ const require_useHotkeyHint = require('./useHotkeyHint.cjs');
14
15
 
15
16
  exports.HotkeysProvider = require_HotkeysProvider.HotkeysProvider;
16
17
  exports.provideHotkeysContext = require_HotkeysProviderContext.provideHotkeysContext;
@@ -18,6 +19,7 @@ exports.useDefaultHotkeysOptions = require_HotkeysProviderContext.useDefaultHotk
18
19
  exports.useHeldKeyCodes = require_useHeldKeyCodes.useHeldKeyCodes;
19
20
  exports.useHeldKeys = require_useHeldKeys.useHeldKeys;
20
21
  exports.useHotkey = require_useHotkey.useHotkey;
22
+ exports.useHotkeyHint = require_useHotkeyHint.useHotkeyHint;
21
23
  exports.useHotkeyRecorder = require_useHotkeyRecorder.useHotkeyRecorder;
22
24
  exports.useHotkeyRegistrations = require_useHotkeyRegistrations.useHotkeyRegistrations;
23
25
  exports.useHotkeySequence = require_useHotkeySequence.useHotkeySequence;
package/dist/index.d.cts CHANGED
@@ -10,5 +10,6 @@ import { UseHotkeySequenceDefinition, useHotkeySequences } from "./useHotkeySequ
10
10
  import { VueHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.cjs";
11
11
  import { HotkeyRegistrationsResult, useHotkeyRegistrations } from "./useHotkeyRegistrations.cjs";
12
12
  import { VueHotkeySequenceRecorder, useHotkeySequenceRecorder } from "./useHotkeySequenceRecorder.cjs";
13
+ import { useHotkeyHint } from "./useHotkeyHint.cjs";
13
14
  export * from "@tanstack/hotkeys";
14
- export { HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeySequenceDefinition, UseHotkeySequenceOptions, VueHotkeyRecorder, VueHotkeySequenceRecorder, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
15
+ export { HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeySequenceDefinition, UseHotkeySequenceOptions, VueHotkeyRecorder, VueHotkeySequenceRecorder, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
package/dist/index.d.ts CHANGED
@@ -10,5 +10,6 @@ import { UseHotkeySequenceDefinition, useHotkeySequences } from "./useHotkeySequ
10
10
  import { VueHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.js";
11
11
  import { HotkeyRegistrationsResult, useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
12
12
  import { VueHotkeySequenceRecorder, useHotkeySequenceRecorder } from "./useHotkeySequenceRecorder.js";
13
+ import { useHotkeyHint } from "./useHotkeyHint.js";
13
14
  export * from "@tanstack/hotkeys";
14
- export { HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeySequenceDefinition, UseHotkeySequenceOptions, VueHotkeyRecorder, VueHotkeySequenceRecorder, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
15
+ export { HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeySequenceDefinition, UseHotkeySequenceOptions, VueHotkeyRecorder, VueHotkeySequenceRecorder, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
package/dist/index.js CHANGED
@@ -10,7 +10,8 @@ import { useHotkeySequences } from "./useHotkeySequences.js";
10
10
  import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
11
11
  import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
12
12
  import { useHotkeySequenceRecorder } from "./useHotkeySequenceRecorder.js";
13
+ import { useHotkeyHint } from "./useHotkeyHint.js";
13
14
 
14
15
  export * from "@tanstack/hotkeys"
15
16
 
16
- export { HotkeysProvider, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
17
+ export { HotkeysProvider, provideHotkeysContext, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
@@ -0,0 +1,20 @@
1
+ let _tanstack_hotkeys = require("@tanstack/hotkeys");
2
+ let vue = require("vue");
3
+ let _tanstack_vue_store = require("@tanstack/vue-store");
4
+
5
+ //#region src/useHotkeyHint.ts
6
+ /**
7
+ * Returns a computed ref indicating whether held modifiers reveal this shortcut.
8
+ * Pass refs or getters to track changing bindings and options.
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
+ const held = (0, _tanstack_vue_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
15
+ return (0, vue.computed)(() => (0, _tanstack_hotkeys.matchesHeldModifiers)((0, vue.toValue)(hotkey), held.value, (0, vue.toValue)(options)));
16
+ }
17
+
18
+ //#endregion
19
+ exports.useHotkeyHint = useHotkeyHint;
20
+ //# sourceMappingURL=useHotkeyHint.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHotkeyHint.cjs","names":[],"sources":["../src/useHotkeyHint.ts"],"sourcesContent":["import { computed, toValue } from 'vue'\nimport { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { ComputedRef, MaybeRefOrGetter } from 'vue'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a computed ref indicating whether held modifiers reveal this shortcut.\n * Pass refs or getters to track changing bindings and options.\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: MaybeRefOrGetter<RegisterableHotkey>,\n options: MaybeRefOrGetter<HeldModifierOptions> = {},\n): ComputedRef<boolean> {\n const held = useSelector(\n getKeyStateTracker().store,\n (state) => state.heldKeys,\n )\n return computed(() =>\n matchesHeldModifiers(toValue(hotkey), held.value, toValue(options)),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,cACd,QACA,UAAiD,EAAE,EAC7B;CACtB,MAAM,uFACgB,CAAC,QACpB,UAAU,MAAM,SAClB;AACD,6FAC+B,OAAO,EAAE,KAAK,wBAAe,QAAQ,CAAC,CACpE"}
@@ -0,0 +1,15 @@
1
+ import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
+ import { ComputedRef, MaybeRefOrGetter } from "vue";
3
+
4
+ //#region src/useHotkeyHint.d.ts
5
+ /**
6
+ * Returns a computed ref indicating whether held modifiers reveal this shortcut.
7
+ * Pass refs or getters to track changing bindings and options.
8
+ * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
9
+ * every modifier. Combine with the action's enabled state before showing a badge.
10
+ * This helper does not register a shortcut or check whether its target is focused.
11
+ */
12
+ declare function useHotkeyHint(hotkey: MaybeRefOrGetter<RegisterableHotkey>, options?: MaybeRefOrGetter<HeldModifierOptions>): ComputedRef<boolean>;
13
+ //#endregion
14
+ export { useHotkeyHint };
15
+ //# sourceMappingURL=useHotkeyHint.d.cts.map
@@ -0,0 +1,15 @@
1
+ import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
2
+ import { ComputedRef, MaybeRefOrGetter } from "vue";
3
+
4
+ //#region src/useHotkeyHint.d.ts
5
+ /**
6
+ * Returns a computed ref indicating whether held modifiers reveal this shortcut.
7
+ * Pass refs or getters to track changing bindings and options.
8
+ * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
9
+ * every modifier. Combine with the action's enabled state before showing a badge.
10
+ * This helper does not register a shortcut or check whether its target is focused.
11
+ */
12
+ declare function useHotkeyHint(hotkey: MaybeRefOrGetter<RegisterableHotkey>, options?: MaybeRefOrGetter<HeldModifierOptions>): ComputedRef<boolean>;
13
+ //#endregion
14
+ export { useHotkeyHint };
15
+ //# sourceMappingURL=useHotkeyHint.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { getKeyStateTracker, matchesHeldModifiers } from "@tanstack/hotkeys";
2
+ import { computed, toValue } from "vue";
3
+ import { useSelector } from "@tanstack/vue-store";
4
+
5
+ //#region src/useHotkeyHint.ts
6
+ /**
7
+ * Returns a computed ref indicating whether held modifiers reveal this shortcut.
8
+ * Pass refs or getters to track changing bindings and options.
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
+ const held = useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
15
+ return computed(() => matchesHeldModifiers(toValue(hotkey), held.value, toValue(options)));
16
+ }
17
+
18
+ //#endregion
19
+ export { useHotkeyHint };
20
+ //# sourceMappingURL=useHotkeyHint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHotkeyHint.js","names":[],"sources":["../src/useHotkeyHint.ts"],"sourcesContent":["import { computed, toValue } from 'vue'\nimport { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { ComputedRef, MaybeRefOrGetter } from 'vue'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a computed ref indicating whether held modifiers reveal this shortcut.\n * Pass refs or getters to track changing bindings and options.\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: MaybeRefOrGetter<RegisterableHotkey>,\n options: MaybeRefOrGetter<HeldModifierOptions> = {},\n): ComputedRef<boolean> {\n const held = useSelector(\n getKeyStateTracker().store,\n (state) => state.heldKeys,\n )\n return computed(() =>\n matchesHeldModifiers(toValue(hotkey), held.value, toValue(options)),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,cACd,QACA,UAAiD,EAAE,EAC7B;CACtB,MAAM,OAAO,YACX,oBAAoB,CAAC,QACpB,UAAU,MAAM,SAClB;AACD,QAAO,eACL,qBAAqB,QAAQ,OAAO,EAAE,KAAK,OAAO,QAAQ,QAAQ,CAAC,CACpE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-hotkeys",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Vue adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -43,11 +43,11 @@
43
43
  ],
44
44
  "dependencies": {
45
45
  "@tanstack/vue-store": "^0.11.0",
46
- "@tanstack/hotkeys": "0.8.0"
46
+ "@tanstack/hotkeys": "0.9.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@vitejs/plugin-vue": "^6.0.6",
50
- "@vue/test-utils": "^2.4.6",
50
+ "@vue/test-utils": "^2.4.8",
51
51
  "vue": "^3.5.33"
52
52
  },
53
53
  "peerDependencies": {
package/src/index.ts CHANGED
@@ -16,3 +16,4 @@ export * from './useHotkeySequences'
16
16
  export * from './useHotkeyRecorder'
17
17
  export * from './useHotkeyRegistrations'
18
18
  export * from './useHotkeySequenceRecorder'
19
+ export * from './useHotkeyHint'
@@ -0,0 +1,25 @@
1
+ import { computed, toValue } from 'vue'
2
+ import { useSelector } from '@tanstack/vue-store'
3
+ import { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'
4
+ import type { ComputedRef, MaybeRefOrGetter } from 'vue'
5
+ import type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'
6
+
7
+ /**
8
+ * Returns a computed ref indicating whether held modifiers reveal this shortcut.
9
+ * Pass refs or getters to track changing bindings and options.
10
+ * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
11
+ * every modifier. Combine with the action's enabled state before showing a badge.
12
+ * This helper does not register a shortcut or check whether its target is focused.
13
+ */
14
+ export function useHotkeyHint(
15
+ hotkey: MaybeRefOrGetter<RegisterableHotkey>,
16
+ options: MaybeRefOrGetter<HeldModifierOptions> = {},
17
+ ): ComputedRef<boolean> {
18
+ const held = useSelector(
19
+ getKeyStateTracker().store,
20
+ (state) => state.heldKeys,
21
+ )
22
+ return computed(() =>
23
+ matchesHeldModifiers(toValue(hotkey), held.value, toValue(options)),
24
+ )
25
+ }