@tanstack/vue-hotkeys 0.9.0 → 0.10.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.
@@ -29,7 +29,7 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
29
29
  * ```
30
30
  */
31
31
  function useHeldKeyCodes() {
32
- return (0, _tanstack_vue_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
32
+ return (0, _tanstack_vue_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
33
33
  }
34
34
 
35
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useHeldKeyCodes.cjs","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref mapping 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 Reactive ref containing record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n * </script>\n *\n * <template>\n * <div>\n * <kbd v-for=\"key in heldKeys\" :key=\"key\">\n * {{ key }} <small>{{ heldCodes[key] }}</small>\n * </kbd>\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeyCodes(): Ref<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAA+C;AAE7D,qFADoC,CACZ,QAAQ,UAAU,MAAM,UAAU"}
1
+ {"version":3,"file":"useHeldKeyCodes.cjs","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref mapping 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 Reactive ref containing record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n * </script>\n *\n * <template>\n * <div>\n * <kbd v-for=\"key in heldKeys\" :key=\"key\">\n * {{ key }} <small>{{ heldCodes[key] }}</small>\n * </kbd>\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeyCodes(): Ref<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAA+C;AAE7D,wFADoC,CACT,QAAQ,UAAU,MAAM,UAAU"}
@@ -1,5 +1,5 @@
1
1
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
- import { useStore } from "@tanstack/vue-store";
2
+ import { useSelector } from "@tanstack/vue-store";
3
3
 
4
4
  //#region src/useHeldKeyCodes.ts
5
5
  /**
@@ -29,7 +29,7 @@ import { useStore } from "@tanstack/vue-store";
29
29
  * ```
30
30
  */
31
31
  function useHeldKeyCodes() {
32
- return useStore(getKeyStateTracker().store, (state) => state.heldCodes);
32
+ return useSelector(getKeyStateTracker().store, (state) => state.heldCodes);
33
33
  }
34
34
 
35
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useHeldKeyCodes.js","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref mapping 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 Reactive ref containing record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n * </script>\n *\n * <template>\n * <div>\n * <kbd v-for=\"key in heldKeys\" :key=\"key\">\n * {{ key }} <small>{{ heldCodes[key] }}</small>\n * </kbd>\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeyCodes(): Ref<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAA+C;AAE7D,QAAO,SADS,oBAAoB,CACZ,QAAQ,UAAU,MAAM,UAAU"}
1
+ {"version":3,"file":"useHeldKeyCodes.js","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref mapping 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 Reactive ref containing record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys, useHeldKeyCodes } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n * </script>\n *\n * <template>\n * <div>\n * <kbd v-for=\"key in heldKeys\" :key=\"key\">\n * {{ key }} <small>{{ heldCodes[key] }}</small>\n * </kbd>\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeyCodes(): Ref<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,kBAA+C;AAE7D,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,UAAU"}
@@ -5,7 +5,7 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
5
5
  /**
6
6
  * Vue composable that returns a reactive ref of currently held keyboard keys.
7
7
  *
8
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
8
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
9
9
  * to the global KeyStateTracker and updates whenever keys are pressed
10
10
  * or released.
11
11
  *
@@ -27,7 +27,7 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
27
27
  * ```
28
28
  */
29
29
  function useHeldKeys() {
30
- return (0, _tanstack_vue_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
30
+ return (0, _tanstack_vue_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
31
31
  }
32
32
 
33
33
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useHeldKeys.cjs","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref of currently held keyboard keys.\n *\n * This composable uses `useStore` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Reactive ref containing array of currently held key names\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * </script>\n *\n * <template>\n * <div>\n * Currently pressed: {{ heldKeys.join(' + ') || 'None' }}\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeys(): Ref<Array<string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAkC;AAEhD,qFADoC,CACZ,QAAQ,UAAU,MAAM,SAAS"}
1
+ {"version":3,"file":"useHeldKeys.cjs","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref of currently held keyboard keys.\n *\n * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Reactive ref containing array of currently held key names\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * </script>\n *\n * <template>\n * <div>\n * Currently pressed: {{ heldKeys.join(' + ') || 'None' }}\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeys(): Ref<Array<string>> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAkC;AAEhD,wFADoC,CACT,QAAQ,UAAU,MAAM,SAAS"}
@@ -4,7 +4,7 @@ import { Ref } from "vue";
4
4
  /**
5
5
  * Vue composable that returns a reactive ref of currently held keyboard keys.
6
6
  *
7
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
7
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
8
8
  * to the global KeyStateTracker and updates whenever keys are pressed
9
9
  * or released.
10
10
  *
@@ -4,7 +4,7 @@ import { Ref } from "vue";
4
4
  /**
5
5
  * Vue composable that returns a reactive ref of currently held keyboard keys.
6
6
  *
7
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
7
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
8
8
  * to the global KeyStateTracker and updates whenever keys are pressed
9
9
  * or released.
10
10
  *
@@ -1,11 +1,11 @@
1
1
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
- import { useStore } from "@tanstack/vue-store";
2
+ import { useSelector } from "@tanstack/vue-store";
3
3
 
4
4
  //#region src/useHeldKeys.ts
5
5
  /**
6
6
  * Vue composable that returns a reactive ref of currently held keyboard keys.
7
7
  *
8
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
8
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
9
9
  * to the global KeyStateTracker and updates whenever keys are pressed
10
10
  * or released.
11
11
  *
@@ -27,7 +27,7 @@ import { useStore } from "@tanstack/vue-store";
27
27
  * ```
28
28
  */
29
29
  function useHeldKeys() {
30
- return useStore(getKeyStateTracker().store, (state) => state.heldKeys);
30
+ return useSelector(getKeyStateTracker().store, (state) => state.heldKeys);
31
31
  }
32
32
 
33
33
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useHeldKeys.js","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref of currently held keyboard keys.\n *\n * This composable uses `useStore` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Reactive ref containing array of currently held key names\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * </script>\n *\n * <template>\n * <div>\n * Currently pressed: {{ heldKeys.join(' + ') || 'None' }}\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeys(): Ref<Array<string>> {\n const tracker = getKeyStateTracker()\n return useStore(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAkC;AAEhD,QAAO,SADS,oBAAoB,CACZ,QAAQ,UAAU,MAAM,SAAS"}
1
+ {"version":3,"file":"useHeldKeys.js","names":[],"sources":["../src/useHeldKeys.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Vue composable that returns a reactive ref of currently held keyboard keys.\n *\n * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and updates whenever keys are pressed\n * or released.\n *\n * @returns Reactive ref containing array of currently held key names\n *\n * @example\n * ```vue\n * <script setup>\n * import { useHeldKeys } from '@tanstack/vue-hotkeys'\n *\n * const heldKeys = useHeldKeys()\n * </script>\n *\n * <template>\n * <div>\n * Currently pressed: {{ heldKeys.join(' + ') || 'None' }}\n * </div>\n * </template>\n * ```\n */\nexport function useHeldKeys(): Ref<Array<string>> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAkC;AAEhD,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,SAAS"}
@@ -48,8 +48,8 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
48
48
  function useHotkeyRecorder(options) {
49
49
  const defaultOptions = require_HotkeysProviderContext.useDefaultHotkeysOptions();
50
50
  const recorder = new _tanstack_hotkeys.HotkeyRecorder(resolveRecorderOptions(options, defaultOptions));
51
- const isRecording = (0, _tanstack_vue_store.useStore)(recorder.store, (state) => state.isRecording);
52
- const recordedHotkey = (0, _tanstack_vue_store.useStore)(recorder.store, (state) => state.recordedHotkey);
51
+ const isRecording = (0, _tanstack_vue_store.useSelector)(recorder.store, (state) => state.isRecording);
52
+ const recordedHotkey = (0, _tanstack_vue_store.useSelector)(recorder.store, (state) => state.recordedHotkey);
53
53
  const stopWatcher = (0, vue.watch)(() => resolveRecorderOptions(options, defaultOptions), (resolvedOptions) => {
54
54
  recorder.setOptions(resolvedOptions);
55
55
  }, { immediate: true });
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkeyRecorder.cjs","names":["useDefaultHotkeysOptions","HotkeyRecorder"],"sources":["../src/useHotkeyRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useStore } from '@tanstack/vue-store'\nimport { HotkeyRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\nexport interface VueHotkeyRecorder {\n /** Whether recording is currently active */\n isRecording: Ref<boolean>\n /** The currently recorded hotkey (for live preview) */\n recordedHotkey: Ref<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 * Vue composable for recording keyboard shortcuts.\n *\n * This composable 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 * ```vue\n * <script setup>\n * import { ref } from 'vue'\n * import { useHotkeyRecorder } from '@tanstack/vue-hotkeys'\n *\n * const shortcut = ref<Hotkey>('Mod+S')\n *\n * const recorder = useHotkeyRecorder({\n * onRecord: (hotkey) => {\n * shortcut.value = hotkey\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n * </script>\n *\n * <template>\n * <div>\n * <button @click=\"recorder.startRecording()\">\n * {{ recorder.isRecording ? 'Recording...' : 'Edit Shortcut' }}\n * </button>\n * <div v-if=\"recorder.recordedHotkey\">\n * Recording: {{ recorder.recordedHotkey }}\n * </div>\n * </div>\n * </template>\n * ```\n */\nexport function useHotkeyRecorder(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n): VueHotkeyRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeyRecorder(\n resolveRecorderOptions(options, defaultOptions),\n )\n\n // Subscribe to recorder state using useStore\n const isRecording = useStore(recorder.store, (state) => state.isRecording)\n const recordedHotkey = useStore(\n recorder.store,\n (state) => state.recordedHotkey,\n )\n\n const stopWatcher = watch(\n () => resolveRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n // Cleanup on unmount\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n recordedHotkey: recordedHotkey as Ref<Hotkey | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n }\n}\n\nfunction resolveRecorderOptions(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeyRecorderOptions {\n return {\n ...defaultOptions.hotkeyRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeyRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,kBACd,SACmB;CACnB,MAAM,iBAAiBA,yDAA0B;CACjD,MAAM,WAAW,IAAIC,iCACnB,uBAAuB,SAAS,eAAe,CAChD;CAGD,MAAM,gDAAuB,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC1E,MAAM,mDACJ,SAAS,QACR,UAAU,MAAM,eAClB;CAED,MAAM,mCACE,uBAAuB,SAAS,eAAe,GACpD,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAGD,4BAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACG;EAChB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,uBACP,SACA,gBACuB;AACvB,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,kBAAS,MAAM"}
1
+ {"version":3,"file":"useHotkeyRecorder.cjs","names":["useDefaultHotkeysOptions","HotkeyRecorder"],"sources":["../src/useHotkeyRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useSelector } from '@tanstack/vue-store'\nimport { HotkeyRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\nexport interface VueHotkeyRecorder {\n /** Whether recording is currently active */\n isRecording: Ref<boolean>\n /** The currently recorded hotkey (for live preview) */\n recordedHotkey: Ref<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 * Vue composable for recording keyboard shortcuts.\n *\n * This composable 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 * ```vue\n * <script setup>\n * import { ref } from 'vue'\n * import { useHotkeyRecorder } from '@tanstack/vue-hotkeys'\n *\n * const shortcut = ref<Hotkey>('Mod+S')\n *\n * const recorder = useHotkeyRecorder({\n * onRecord: (hotkey) => {\n * shortcut.value = hotkey\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n * </script>\n *\n * <template>\n * <div>\n * <button @click=\"recorder.startRecording()\">\n * {{ recorder.isRecording ? 'Recording...' : 'Edit Shortcut' }}\n * </button>\n * <div v-if=\"recorder.recordedHotkey\">\n * Recording: {{ recorder.recordedHotkey }}\n * </div>\n * </div>\n * </template>\n * ```\n */\nexport function useHotkeyRecorder(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n): VueHotkeyRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeyRecorder(\n resolveRecorderOptions(options, defaultOptions),\n )\n\n // Subscribe to recorder state using useSelector\n const isRecording = useSelector(recorder.store, (state) => state.isRecording)\n const recordedHotkey = useSelector(\n recorder.store,\n (state) => state.recordedHotkey,\n )\n\n const stopWatcher = watch(\n () => resolveRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n // Cleanup on unmount\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n recordedHotkey: recordedHotkey as Ref<Hotkey | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n }\n}\n\nfunction resolveRecorderOptions(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeyRecorderOptions {\n return {\n ...defaultOptions.hotkeyRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeyRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,kBACd,SACmB;CACnB,MAAM,iBAAiBA,yDAA0B;CACjD,MAAM,WAAW,IAAIC,iCACnB,uBAAuB,SAAS,eAAe,CAChD;CAGD,MAAM,mDAA0B,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC7E,MAAM,sDACJ,SAAS,QACR,UAAU,MAAM,eAClB;CAED,MAAM,mCACE,uBAAuB,SAAS,eAAe,GACpD,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAGD,4BAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACG;EAChB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,uBACP,SACA,gBACuB;AACvB,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,kBAAS,MAAM"}
@@ -1,7 +1,7 @@
1
1
  import { useDefaultHotkeysOptions } from "./HotkeysProviderContext.js";
2
2
  import { HotkeyRecorder } from "@tanstack/hotkeys";
3
3
  import { onUnmounted, unref, watch } from "vue";
4
- import { useStore } from "@tanstack/vue-store";
4
+ import { useSelector } from "@tanstack/vue-store";
5
5
 
6
6
  //#region src/useHotkeyRecorder.ts
7
7
  /**
@@ -48,8 +48,8 @@ import { useStore } from "@tanstack/vue-store";
48
48
  function useHotkeyRecorder(options) {
49
49
  const defaultOptions = useDefaultHotkeysOptions();
50
50
  const recorder = new HotkeyRecorder(resolveRecorderOptions(options, defaultOptions));
51
- const isRecording = useStore(recorder.store, (state) => state.isRecording);
52
- const recordedHotkey = useStore(recorder.store, (state) => state.recordedHotkey);
51
+ const isRecording = useSelector(recorder.store, (state) => state.isRecording);
52
+ const recordedHotkey = useSelector(recorder.store, (state) => state.recordedHotkey);
53
53
  const stopWatcher = watch(() => resolveRecorderOptions(options, defaultOptions), (resolvedOptions) => {
54
54
  recorder.setOptions(resolvedOptions);
55
55
  }, { immediate: true });
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkeyRecorder.js","names":[],"sources":["../src/useHotkeyRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useStore } from '@tanstack/vue-store'\nimport { HotkeyRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\nexport interface VueHotkeyRecorder {\n /** Whether recording is currently active */\n isRecording: Ref<boolean>\n /** The currently recorded hotkey (for live preview) */\n recordedHotkey: Ref<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 * Vue composable for recording keyboard shortcuts.\n *\n * This composable 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 * ```vue\n * <script setup>\n * import { ref } from 'vue'\n * import { useHotkeyRecorder } from '@tanstack/vue-hotkeys'\n *\n * const shortcut = ref<Hotkey>('Mod+S')\n *\n * const recorder = useHotkeyRecorder({\n * onRecord: (hotkey) => {\n * shortcut.value = hotkey\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n * </script>\n *\n * <template>\n * <div>\n * <button @click=\"recorder.startRecording()\">\n * {{ recorder.isRecording ? 'Recording...' : 'Edit Shortcut' }}\n * </button>\n * <div v-if=\"recorder.recordedHotkey\">\n * Recording: {{ recorder.recordedHotkey }}\n * </div>\n * </div>\n * </template>\n * ```\n */\nexport function useHotkeyRecorder(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n): VueHotkeyRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeyRecorder(\n resolveRecorderOptions(options, defaultOptions),\n )\n\n // Subscribe to recorder state using useStore\n const isRecording = useStore(recorder.store, (state) => state.isRecording)\n const recordedHotkey = useStore(\n recorder.store,\n (state) => state.recordedHotkey,\n )\n\n const stopWatcher = watch(\n () => resolveRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n // Cleanup on unmount\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n recordedHotkey: recordedHotkey as Ref<Hotkey | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n }\n}\n\nfunction resolveRecorderOptions(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeyRecorderOptions {\n return {\n ...defaultOptions.hotkeyRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeyRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,kBACd,SACmB;CACnB,MAAM,iBAAiB,0BAA0B;CACjD,MAAM,WAAW,IAAI,eACnB,uBAAuB,SAAS,eAAe,CAChD;CAGD,MAAM,cAAc,SAAS,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC1E,MAAM,iBAAiB,SACrB,SAAS,QACR,UAAU,MAAM,eAClB;CAED,MAAM,cAAc,YACZ,uBAAuB,SAAS,eAAe,GACpD,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAGD,mBAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACG;EAChB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,uBACP,SACA,gBACuB;AACvB,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,GAAG,MAAM,MAAM"}
1
+ {"version":3,"file":"useHotkeyRecorder.js","names":[],"sources":["../src/useHotkeyRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useSelector } from '@tanstack/vue-store'\nimport { HotkeyRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { Hotkey, HotkeyRecorderOptions } from '@tanstack/hotkeys'\n\nexport interface VueHotkeyRecorder {\n /** Whether recording is currently active */\n isRecording: Ref<boolean>\n /** The currently recorded hotkey (for live preview) */\n recordedHotkey: Ref<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 * Vue composable for recording keyboard shortcuts.\n *\n * This composable 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 * ```vue\n * <script setup>\n * import { ref } from 'vue'\n * import { useHotkeyRecorder } from '@tanstack/vue-hotkeys'\n *\n * const shortcut = ref<Hotkey>('Mod+S')\n *\n * const recorder = useHotkeyRecorder({\n * onRecord: (hotkey) => {\n * shortcut.value = hotkey\n * },\n * onCancel: () => {\n * console.log('Recording cancelled')\n * },\n * })\n * </script>\n *\n * <template>\n * <div>\n * <button @click=\"recorder.startRecording()\">\n * {{ recorder.isRecording ? 'Recording...' : 'Edit Shortcut' }}\n * </button>\n * <div v-if=\"recorder.recordedHotkey\">\n * Recording: {{ recorder.recordedHotkey }}\n * </div>\n * </div>\n * </template>\n * ```\n */\nexport function useHotkeyRecorder(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n): VueHotkeyRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeyRecorder(\n resolveRecorderOptions(options, defaultOptions),\n )\n\n // Subscribe to recorder state using useSelector\n const isRecording = useSelector(recorder.store, (state) => state.isRecording)\n const recordedHotkey = useSelector(\n recorder.store,\n (state) => state.recordedHotkey,\n )\n\n const stopWatcher = watch(\n () => resolveRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n // Cleanup on unmount\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n recordedHotkey: recordedHotkey as Ref<Hotkey | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n }\n}\n\nfunction resolveRecorderOptions(\n options: MaybeRefOrGetter<HotkeyRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeyRecorderOptions {\n return {\n ...defaultOptions.hotkeyRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeyRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgB,kBACd,SACmB;CACnB,MAAM,iBAAiB,0BAA0B;CACjD,MAAM,WAAW,IAAI,eACnB,uBAAuB,SAAS,eAAe,CAChD;CAGD,MAAM,cAAc,YAAY,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC7E,MAAM,iBAAiB,YACrB,SAAS,QACR,UAAU,MAAM,eAClB;CAED,MAAM,cAAc,YACZ,uBAAuB,SAAS,eAAe,GACpD,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAGD,mBAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACG;EAChB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,uBACP,SACA,gBACuB;AACvB,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,GAAG,MAAM,MAAM"}
@@ -16,8 +16,8 @@ function useHotkeyRegistrations() {
16
16
  const hotkeyManager = (0, _tanstack_hotkeys.getHotkeyManager)();
17
17
  const sequenceManager = (0, _tanstack_hotkeys.getSequenceManager)();
18
18
  return {
19
- hotkeys: (0, _tanstack_vue_store.useStore)(hotkeyManager.registrations, (state) => Array.from(state.values()).map(_tanstack_hotkeys.toHotkeyRegistrationView)),
20
- sequences: (0, _tanstack_vue_store.useStore)(sequenceManager.registrations, (state) => Array.from(state.values()))
19
+ hotkeys: (0, _tanstack_vue_store.useSelector)(hotkeyManager.registrations, (state) => Array.from(state.values()).map(_tanstack_hotkeys.toHotkeyRegistrationView)),
20
+ sequences: (0, _tanstack_vue_store.useSelector)(sequenceManager.registrations, (state) => Array.from(state.values()))
21
21
  };
22
22
  }
23
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkeyRegistrations.cjs","names":["toHotkeyRegistrationView"],"sources":["../src/useHotkeyRegistrations.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Return type for useHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** All registered hotkeys (public view, no callbacks) */\n hotkeys: Ref<Array<HotkeyRegistrationView>>\n /** All registered sequences */\n sequences: Ref<Array<SequenceRegistrationView>>\n}\n\n/**\n * Vue composable that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone composable that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * triggers reactivity when registrations change.\n *\n * @returns Object with `hotkeys` and `sequences` refs\n */\nexport function useHotkeyRegistrations(): HotkeyRegistrationsResult {\n const hotkeyManager = getHotkeyManager()\n const sequenceManager = getSequenceManager()\n\n const hotkeys = useStore(hotkeyManager.registrations, (state) =>\n Array.from(state.values()).map(toHotkeyRegistrationView),\n )\n\n const sequences = useStore(sequenceManager.registrations, (state) =>\n Array.from(state.values()),\n )\n\n return { hotkeys, sequences }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,yBAAoD;CAClE,MAAM,yDAAkC;CACxC,MAAM,6DAAsC;AAU5C,QAAO;EAAE,2CARgB,cAAc,gBAAgB,UACrD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAIA,2CAAyB,CACzD;EAMiB,6CAJS,gBAAgB,gBAAgB,UACzD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
1
+ {"version":3,"file":"useHotkeyRegistrations.cjs","names":["toHotkeyRegistrationView"],"sources":["../src/useHotkeyRegistrations.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Return type for useHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** All registered hotkeys (public view, no callbacks) */\n hotkeys: Ref<Array<HotkeyRegistrationView>>\n /** All registered sequences */\n sequences: Ref<Array<SequenceRegistrationView>>\n}\n\n/**\n * Vue composable that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone composable that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * triggers reactivity when registrations change.\n *\n * @returns Object with `hotkeys` and `sequences` refs\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":";;;;;;;;;;;;;;AAgCA,SAAgB,yBAAoD;CAClE,MAAM,yDAAkC;CACxC,MAAM,6DAAsC;AAU5C,QAAO;EAAE,8CARmB,cAAc,gBAAgB,UACxD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAIA,2CAAyB,CACzD;EAMiB,gDAJY,gBAAgB,gBAAgB,UAC5D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
@@ -1,5 +1,5 @@
1
1
  import { getHotkeyManager, getSequenceManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
2
- import { useStore } from "@tanstack/vue-store";
2
+ import { useSelector } from "@tanstack/vue-store";
3
3
 
4
4
  //#region src/useHotkeyRegistrations.ts
5
5
  /**
@@ -16,8 +16,8 @@ function useHotkeyRegistrations() {
16
16
  const hotkeyManager = getHotkeyManager();
17
17
  const sequenceManager = getSequenceManager();
18
18
  return {
19
- hotkeys: useStore(hotkeyManager.registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView)),
20
- sequences: useStore(sequenceManager.registrations, (state) => Array.from(state.values()))
19
+ hotkeys: useSelector(hotkeyManager.registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView)),
20
+ sequences: useSelector(sequenceManager.registrations, (state) => Array.from(state.values()))
21
21
  };
22
22
  }
23
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkeyRegistrations.js","names":[],"sources":["../src/useHotkeyRegistrations.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Return type for useHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** All registered hotkeys (public view, no callbacks) */\n hotkeys: Ref<Array<HotkeyRegistrationView>>\n /** All registered sequences */\n sequences: Ref<Array<SequenceRegistrationView>>\n}\n\n/**\n * Vue composable that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone composable that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * triggers reactivity when registrations change.\n *\n * @returns Object with `hotkeys` and `sequences` refs\n */\nexport function useHotkeyRegistrations(): HotkeyRegistrationsResult {\n const hotkeyManager = getHotkeyManager()\n const sequenceManager = getSequenceManager()\n\n const hotkeys = useStore(hotkeyManager.registrations, (state) =>\n Array.from(state.values()).map(toHotkeyRegistrationView),\n )\n\n const sequences = useStore(sequenceManager.registrations, (state) =>\n Array.from(state.values()),\n )\n\n return { hotkeys, sequences }\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,yBAAoD;CAClE,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,kBAAkB,oBAAoB;AAU5C,QAAO;EAAE,SARO,SAAS,cAAc,gBAAgB,UACrD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAI,yBAAyB,CACzD;EAMiB,WAJA,SAAS,gBAAgB,gBAAgB,UACzD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
1
+ {"version":3,"file":"useHotkeyRegistrations.js","names":[],"sources":["../src/useHotkeyRegistrations.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { Ref } from 'vue'\n\n/**\n * Return type for useHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** All registered hotkeys (public view, no callbacks) */\n hotkeys: Ref<Array<HotkeyRegistrationView>>\n /** All registered sequences */\n sequences: Ref<Array<SequenceRegistrationView>>\n}\n\n/**\n * Vue composable that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone composable that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * triggers reactivity when registrations change.\n *\n * @returns Object with `hotkeys` and `sequences` refs\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":";;;;;;;;;;;;;;AAgCA,SAAgB,yBAAoD;CAClE,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,kBAAkB,oBAAoB;AAU5C,QAAO;EAAE,SARO,YAAY,cAAc,gBAAgB,UACxD,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAI,yBAAyB,CACzD;EAMiB,WAJA,YAAY,gBAAgB,gBAAgB,UAC5D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
@@ -10,9 +10,9 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
10
10
  function useHotkeySequenceRecorder(options) {
11
11
  const defaultOptions = require_HotkeysProviderContext.useDefaultHotkeysOptions();
12
12
  const recorder = new _tanstack_hotkeys.HotkeySequenceRecorder(resolveHotkeySequenceRecorderOptions(options, defaultOptions));
13
- const isRecording = (0, _tanstack_vue_store.useStore)(recorder.store, (state) => state.isRecording);
14
- const steps = (0, _tanstack_vue_store.useStore)(recorder.store, (state) => state.steps);
15
- const recordedSequence = (0, _tanstack_vue_store.useStore)(recorder.store, (state) => state.recordedSequence);
13
+ const isRecording = (0, _tanstack_vue_store.useSelector)(recorder.store, (state) => state.isRecording);
14
+ const steps = (0, _tanstack_vue_store.useSelector)(recorder.store, (state) => state.steps);
15
+ const recordedSequence = (0, _tanstack_vue_store.useSelector)(recorder.store, (state) => state.recordedSequence);
16
16
  const stopWatcher = (0, vue.watch)(() => resolveHotkeySequenceRecorderOptions(options, defaultOptions), (resolvedOptions) => {
17
17
  recorder.setOptions(resolvedOptions);
18
18
  }, { immediate: true });
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkeySequenceRecorder.cjs","names":["useDefaultHotkeysOptions","HotkeySequenceRecorder"],"sources":["../src/useHotkeySequenceRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useStore } from '@tanstack/vue-store'\nimport { HotkeySequenceRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type {\n HotkeySequence,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\n\nexport interface VueHotkeySequenceRecorder {\n isRecording: Ref<boolean>\n steps: Ref<HotkeySequence>\n recordedSequence: Ref<HotkeySequence | null>\n startRecording: () => void\n stopRecording: () => void\n cancelRecording: () => void\n commitRecording: () => void\n}\n\n/**\n * Vue composable for recording multi-chord sequences (Vim-style shortcuts).\n */\nexport function useHotkeySequenceRecorder(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n): VueHotkeySequenceRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeySequenceRecorder(\n resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n )\n\n const isRecording = useStore(recorder.store, (state) => state.isRecording)\n const steps = useStore(recorder.store, (state) => state.steps)\n const recordedSequence = useStore(\n recorder.store,\n (state) => state.recordedSequence,\n )\n\n const stopWatcher = watch(\n () => resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n steps: steps as Ref<HotkeySequence>,\n recordedSequence: recordedSequence as Ref<HotkeySequence | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n commitRecording: () => recorder.commit(),\n }\n}\n\nfunction resolveHotkeySequenceRecorderOptions(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeySequenceRecorderOptions {\n return {\n ...defaultOptions.hotkeySequenceRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeySequenceRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,0BACd,SAC2B;CAC3B,MAAM,iBAAiBA,yDAA0B;CACjD,MAAM,WAAW,IAAIC,yCACnB,qCAAqC,SAAS,eAAe,CAC9D;CAED,MAAM,gDAAuB,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC1E,MAAM,0CAAiB,SAAS,QAAQ,UAAU,MAAM,MAAM;CAC9D,MAAM,qDACJ,SAAS,QACR,UAAU,MAAM,iBAClB;CAED,MAAM,mCACE,qCAAqC,SAAS,eAAe,GAClE,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAED,4BAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACN;EACW;EAClB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACxC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,qCACP,SACA,gBAC+B;AAC/B,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,kBAAS,MAAM"}
1
+ {"version":3,"file":"useHotkeySequenceRecorder.cjs","names":["useDefaultHotkeysOptions","HotkeySequenceRecorder"],"sources":["../src/useHotkeySequenceRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useSelector } from '@tanstack/vue-store'\nimport { HotkeySequenceRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type {\n HotkeySequence,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\n\nexport interface VueHotkeySequenceRecorder {\n isRecording: Ref<boolean>\n steps: Ref<HotkeySequence>\n recordedSequence: Ref<HotkeySequence | null>\n startRecording: () => void\n stopRecording: () => void\n cancelRecording: () => void\n commitRecording: () => void\n}\n\n/**\n * Vue composable for recording multi-chord sequences (Vim-style shortcuts).\n */\nexport function useHotkeySequenceRecorder(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n): VueHotkeySequenceRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeySequenceRecorder(\n resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n )\n\n const isRecording = useSelector(recorder.store, (state) => state.isRecording)\n const steps = useSelector(recorder.store, (state) => state.steps)\n const recordedSequence = useSelector(\n recorder.store,\n (state) => state.recordedSequence,\n )\n\n const stopWatcher = watch(\n () => resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n steps: steps as Ref<HotkeySequence>,\n recordedSequence: recordedSequence as Ref<HotkeySequence | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n commitRecording: () => recorder.commit(),\n }\n}\n\nfunction resolveHotkeySequenceRecorderOptions(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeySequenceRecorderOptions {\n return {\n ...defaultOptions.hotkeySequenceRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeySequenceRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,0BACd,SAC2B;CAC3B,MAAM,iBAAiBA,yDAA0B;CACjD,MAAM,WAAW,IAAIC,yCACnB,qCAAqC,SAAS,eAAe,CAC9D;CAED,MAAM,mDAA0B,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC7E,MAAM,6CAAoB,SAAS,QAAQ,UAAU,MAAM,MAAM;CACjE,MAAM,wDACJ,SAAS,QACR,UAAU,MAAM,iBAClB;CAED,MAAM,mCACE,qCAAqC,SAAS,eAAe,GAClE,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAED,4BAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACN;EACW;EAClB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACxC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,qCACP,SACA,gBAC+B;AAC/B,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,kBAAS,MAAM"}
@@ -1,7 +1,7 @@
1
1
  import { useDefaultHotkeysOptions } from "./HotkeysProviderContext.js";
2
2
  import { HotkeySequenceRecorder } from "@tanstack/hotkeys";
3
3
  import { onUnmounted, unref, watch } from "vue";
4
- import { useStore } from "@tanstack/vue-store";
4
+ import { useSelector } from "@tanstack/vue-store";
5
5
 
6
6
  //#region src/useHotkeySequenceRecorder.ts
7
7
  /**
@@ -10,9 +10,9 @@ import { useStore } from "@tanstack/vue-store";
10
10
  function useHotkeySequenceRecorder(options) {
11
11
  const defaultOptions = useDefaultHotkeysOptions();
12
12
  const recorder = new HotkeySequenceRecorder(resolveHotkeySequenceRecorderOptions(options, defaultOptions));
13
- const isRecording = useStore(recorder.store, (state) => state.isRecording);
14
- const steps = useStore(recorder.store, (state) => state.steps);
15
- const recordedSequence = useStore(recorder.store, (state) => state.recordedSequence);
13
+ const isRecording = useSelector(recorder.store, (state) => state.isRecording);
14
+ const steps = useSelector(recorder.store, (state) => state.steps);
15
+ const recordedSequence = useSelector(recorder.store, (state) => state.recordedSequence);
16
16
  const stopWatcher = watch(() => resolveHotkeySequenceRecorderOptions(options, defaultOptions), (resolvedOptions) => {
17
17
  recorder.setOptions(resolvedOptions);
18
18
  }, { immediate: true });
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkeySequenceRecorder.js","names":[],"sources":["../src/useHotkeySequenceRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useStore } from '@tanstack/vue-store'\nimport { HotkeySequenceRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type {\n HotkeySequence,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\n\nexport interface VueHotkeySequenceRecorder {\n isRecording: Ref<boolean>\n steps: Ref<HotkeySequence>\n recordedSequence: Ref<HotkeySequence | null>\n startRecording: () => void\n stopRecording: () => void\n cancelRecording: () => void\n commitRecording: () => void\n}\n\n/**\n * Vue composable for recording multi-chord sequences (Vim-style shortcuts).\n */\nexport function useHotkeySequenceRecorder(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n): VueHotkeySequenceRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeySequenceRecorder(\n resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n )\n\n const isRecording = useStore(recorder.store, (state) => state.isRecording)\n const steps = useStore(recorder.store, (state) => state.steps)\n const recordedSequence = useStore(\n recorder.store,\n (state) => state.recordedSequence,\n )\n\n const stopWatcher = watch(\n () => resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n steps: steps as Ref<HotkeySequence>,\n recordedSequence: recordedSequence as Ref<HotkeySequence | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n commitRecording: () => recorder.commit(),\n }\n}\n\nfunction resolveHotkeySequenceRecorderOptions(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeySequenceRecorderOptions {\n return {\n ...defaultOptions.hotkeySequenceRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeySequenceRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,0BACd,SAC2B;CAC3B,MAAM,iBAAiB,0BAA0B;CACjD,MAAM,WAAW,IAAI,uBACnB,qCAAqC,SAAS,eAAe,CAC9D;CAED,MAAM,cAAc,SAAS,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC1E,MAAM,QAAQ,SAAS,SAAS,QAAQ,UAAU,MAAM,MAAM;CAC9D,MAAM,mBAAmB,SACvB,SAAS,QACR,UAAU,MAAM,iBAClB;CAED,MAAM,cAAc,YACZ,qCAAqC,SAAS,eAAe,GAClE,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAED,mBAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACN;EACW;EAClB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACxC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,qCACP,SACA,gBAC+B;AAC/B,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,GAAG,MAAM,MAAM"}
1
+ {"version":3,"file":"useHotkeySequenceRecorder.js","names":[],"sources":["../src/useHotkeySequenceRecorder.ts"],"sourcesContent":["import { onUnmounted, unref, watch } from 'vue'\nimport { useSelector } from '@tanstack/vue-store'\nimport { HotkeySequenceRecorder } from '@tanstack/hotkeys'\nimport { useDefaultHotkeysOptions } from './HotkeysProviderContext'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type {\n HotkeySequence,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\n\nexport interface VueHotkeySequenceRecorder {\n isRecording: Ref<boolean>\n steps: Ref<HotkeySequence>\n recordedSequence: Ref<HotkeySequence | null>\n startRecording: () => void\n stopRecording: () => void\n cancelRecording: () => void\n commitRecording: () => void\n}\n\n/**\n * Vue composable for recording multi-chord sequences (Vim-style shortcuts).\n */\nexport function useHotkeySequenceRecorder(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n): VueHotkeySequenceRecorder {\n const defaultOptions = useDefaultHotkeysOptions()\n const recorder = new HotkeySequenceRecorder(\n resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n )\n\n const isRecording = useSelector(recorder.store, (state) => state.isRecording)\n const steps = useSelector(recorder.store, (state) => state.steps)\n const recordedSequence = useSelector(\n recorder.store,\n (state) => state.recordedSequence,\n )\n\n const stopWatcher = watch(\n () => resolveHotkeySequenceRecorderOptions(options, defaultOptions),\n (resolvedOptions) => {\n recorder.setOptions(resolvedOptions)\n },\n { immediate: true },\n )\n\n onUnmounted(() => {\n stopWatcher()\n recorder.destroy()\n })\n\n return {\n isRecording: isRecording as Ref<boolean>,\n steps: steps as Ref<HotkeySequence>,\n recordedSequence: recordedSequence as Ref<HotkeySequence | null>,\n startRecording: () => recorder.start(),\n stopRecording: () => recorder.stop(),\n cancelRecording: () => recorder.cancel(),\n commitRecording: () => recorder.commit(),\n }\n}\n\nfunction resolveHotkeySequenceRecorderOptions(\n options: MaybeRefOrGetter<HotkeySequenceRecorderOptions>,\n defaultOptions: ReturnType<typeof useDefaultHotkeysOptions>,\n): HotkeySequenceRecorderOptions {\n return {\n ...defaultOptions.hotkeySequenceRecorder,\n ...resolveMaybeRefOrGetter(options),\n } as HotkeySequenceRecorderOptions\n}\n\nfunction resolveMaybeRefOrGetter<T>(value: MaybeRefOrGetter<T>): T {\n return typeof value === 'function' ? (value as () => T)() : unref(value)\n}\n"],"mappings":";;;;;;;;;AAuBA,SAAgB,0BACd,SAC2B;CAC3B,MAAM,iBAAiB,0BAA0B;CACjD,MAAM,WAAW,IAAI,uBACnB,qCAAqC,SAAS,eAAe,CAC9D;CAED,MAAM,cAAc,YAAY,SAAS,QAAQ,UAAU,MAAM,YAAY;CAC7E,MAAM,QAAQ,YAAY,SAAS,QAAQ,UAAU,MAAM,MAAM;CACjE,MAAM,mBAAmB,YACvB,SAAS,QACR,UAAU,MAAM,iBAClB;CAED,MAAM,cAAc,YACZ,qCAAqC,SAAS,eAAe,GAClE,oBAAoB;AACnB,WAAS,WAAW,gBAAgB;IAEtC,EAAE,WAAW,MAAM,CACpB;AAED,mBAAkB;AAChB,eAAa;AACb,WAAS,SAAS;GAClB;AAEF,QAAO;EACQ;EACN;EACW;EAClB,sBAAsB,SAAS,OAAO;EACtC,qBAAqB,SAAS,MAAM;EACpC,uBAAuB,SAAS,QAAQ;EACxC,uBAAuB,SAAS,QAAQ;EACzC;;AAGH,SAAS,qCACP,SACA,gBAC+B;AAC/B,QAAO;EACL,GAAG,eAAe;EAClB,GAAG,wBAAwB,QAAQ;EACpC;;AAGH,SAAS,wBAA2B,OAA+B;AACjE,QAAO,OAAO,UAAU,aAAc,OAAmB,GAAG,MAAM,MAAM"}
@@ -6,7 +6,7 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
6
6
  /**
7
7
  * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
8
8
  *
9
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
9
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
10
10
  * to the global KeyStateTracker and uses a selector to determine if
11
11
  * the specified key is held.
12
12
  *
@@ -48,7 +48,7 @@ let _tanstack_vue_store = require("@tanstack/vue-store");
48
48
  * ```
49
49
  */
50
50
  function useKeyHold(key) {
51
- return (0, _tanstack_vue_store.useStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => {
51
+ return (0, _tanstack_vue_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => {
52
52
  const keyValue = (0, vue.unref)(key);
53
53
  const normalizedKey = (typeof keyValue === "string" ? keyValue : String(keyValue)).toLowerCase();
54
54
  return state.heldKeys.some((heldKey) => heldKey.toLowerCase() === normalizedKey);
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyHold.cjs","names":[],"sources":["../src/useKeyHold.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { unref } from 'vue'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { IndividualKey } from '@tanstack/hotkeys'\n\n/**\n * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.\n *\n * This composable uses `useStore` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and uses a selector to determine if\n * the specified key is held.\n *\n * @param key - The key to check (e.g., 'Shift', 'Control', 'A')\n * @returns Reactive ref that is true if the key is currently held down\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const isShiftHeld = useKeyHold('Shift')\n * </script>\n *\n * <template>\n * <div :style=\"{ opacity: isShiftHeld ? 1 : 0.5 }\">\n * {{ isShiftHeld ? 'Shift is pressed!' : 'Press Shift' }}\n * </div>\n * </template>\n * ```\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const ctrl = useKeyHold('Control')\n * const shift = useKeyHold('Shift')\n * const alt = useKeyHold('Alt')\n * </script>\n *\n * <template>\n * <div>\n * <span :style=\"{ opacity: ctrl ? 1 : 0.3 }\">Ctrl</span>\n * <span :style=\"{ opacity: shift ? 1 : 0.3 }\">Shift</span>\n * <span :style=\"{ opacity: alt ? 1 : 0.3 }\">Alt</span>\n * </div>\n * </template>\n * ```\n */\nexport function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean> {\n const tracker = getKeyStateTracker()\n\n const isHeld = useStore(tracker.store, (state) => {\n const keyValue = unref(key)\n const normalizedKey = (\n typeof keyValue === 'string' ? keyValue : String(keyValue)\n ).toLowerCase()\n return state.heldKeys.some(\n (heldKey) => heldKey.toLowerCase() === normalizedKey,\n )\n })\n\n return isHeld as Ref<boolean>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,WAAW,KAAoD;AAa7E,qFAZoC,CAEJ,QAAQ,UAAU;EAChD,MAAM,0BAAiB,IAAI;EAC3B,MAAM,iBACJ,OAAO,aAAa,WAAW,WAAW,OAAO,SAAS,EAC1D,aAAa;AACf,SAAO,MAAM,SAAS,MACnB,YAAY,QAAQ,aAAa,KAAK,cACxC;GACD"}
1
+ {"version":3,"file":"useKeyHold.cjs","names":[],"sources":["../src/useKeyHold.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { unref } from 'vue'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { IndividualKey } from '@tanstack/hotkeys'\n\n/**\n * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.\n *\n * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and uses a selector to determine if\n * the specified key is held.\n *\n * @param key - The key to check (e.g., 'Shift', 'Control', 'A')\n * @returns Reactive ref that is true if the key is currently held down\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const isShiftHeld = useKeyHold('Shift')\n * </script>\n *\n * <template>\n * <div :style=\"{ opacity: isShiftHeld ? 1 : 0.5 }\">\n * {{ isShiftHeld ? 'Shift is pressed!' : 'Press Shift' }}\n * </div>\n * </template>\n * ```\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const ctrl = useKeyHold('Control')\n * const shift = useKeyHold('Shift')\n * const alt = useKeyHold('Alt')\n * </script>\n *\n * <template>\n * <div>\n * <span :style=\"{ opacity: ctrl ? 1 : 0.3 }\">Ctrl</span>\n * <span :style=\"{ opacity: shift ? 1 : 0.3 }\">Shift</span>\n * <span :style=\"{ opacity: alt ? 1 : 0.3 }\">Alt</span>\n * </div>\n * </template>\n * ```\n */\nexport function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean> {\n const tracker = getKeyStateTracker()\n\n const isHeld = useSelector(tracker.store, (state) => {\n const keyValue = unref(key)\n const normalizedKey = (\n typeof keyValue === 'string' ? keyValue : String(keyValue)\n ).toLowerCase()\n return state.heldKeys.some(\n (heldKey) => heldKey.toLowerCase() === normalizedKey,\n )\n })\n\n return isHeld as Ref<boolean>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,WAAW,KAAoD;AAa7E,wFAZoC,CAED,QAAQ,UAAU;EACnD,MAAM,0BAAiB,IAAI;EAC3B,MAAM,iBACJ,OAAO,aAAa,WAAW,WAAW,OAAO,SAAS,EAC1D,aAAa;AACf,SAAO,MAAM,SAAS,MACnB,YAAY,QAAQ,aAAa,KAAK,cACxC;GACD"}
@@ -5,7 +5,7 @@ import { MaybeRefOrGetter, Ref } from "vue";
5
5
  /**
6
6
  * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
7
7
  *
8
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
8
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
9
9
  * to the global KeyStateTracker and uses a selector to determine if
10
10
  * the specified key is held.
11
11
  *
@@ -5,7 +5,7 @@ import { MaybeRefOrGetter, Ref } from "vue";
5
5
  /**
6
6
  * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
7
7
  *
8
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
8
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
9
9
  * to the global KeyStateTracker and uses a selector to determine if
10
10
  * the specified key is held.
11
11
  *
@@ -1,12 +1,12 @@
1
1
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
2
  import { unref } from "vue";
3
- import { useStore } from "@tanstack/vue-store";
3
+ import { useSelector } from "@tanstack/vue-store";
4
4
 
5
5
  //#region src/useKeyHold.ts
6
6
  /**
7
7
  * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
8
8
  *
9
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
9
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
10
10
  * to the global KeyStateTracker and uses a selector to determine if
11
11
  * the specified key is held.
12
12
  *
@@ -48,7 +48,7 @@ import { useStore } from "@tanstack/vue-store";
48
48
  * ```
49
49
  */
50
50
  function useKeyHold(key) {
51
- return useStore(getKeyStateTracker().store, (state) => {
51
+ return useSelector(getKeyStateTracker().store, (state) => {
52
52
  const keyValue = unref(key);
53
53
  const normalizedKey = (typeof keyValue === "string" ? keyValue : String(keyValue)).toLowerCase();
54
54
  return state.heldKeys.some((heldKey) => heldKey.toLowerCase() === normalizedKey);
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyHold.js","names":[],"sources":["../src/useKeyHold.ts"],"sourcesContent":["import { useStore } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { unref } from 'vue'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { IndividualKey } from '@tanstack/hotkeys'\n\n/**\n * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.\n *\n * This composable uses `useStore` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and uses a selector to determine if\n * the specified key is held.\n *\n * @param key - The key to check (e.g., 'Shift', 'Control', 'A')\n * @returns Reactive ref that is true if the key is currently held down\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const isShiftHeld = useKeyHold('Shift')\n * </script>\n *\n * <template>\n * <div :style=\"{ opacity: isShiftHeld ? 1 : 0.5 }\">\n * {{ isShiftHeld ? 'Shift is pressed!' : 'Press Shift' }}\n * </div>\n * </template>\n * ```\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const ctrl = useKeyHold('Control')\n * const shift = useKeyHold('Shift')\n * const alt = useKeyHold('Alt')\n * </script>\n *\n * <template>\n * <div>\n * <span :style=\"{ opacity: ctrl ? 1 : 0.3 }\">Ctrl</span>\n * <span :style=\"{ opacity: shift ? 1 : 0.3 }\">Shift</span>\n * <span :style=\"{ opacity: alt ? 1 : 0.3 }\">Alt</span>\n * </div>\n * </template>\n * ```\n */\nexport function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean> {\n const tracker = getKeyStateTracker()\n\n const isHeld = useStore(tracker.store, (state) => {\n const keyValue = unref(key)\n const normalizedKey = (\n typeof keyValue === 'string' ? keyValue : String(keyValue)\n ).toLowerCase()\n return state.heldKeys.some(\n (heldKey) => heldKey.toLowerCase() === normalizedKey,\n )\n })\n\n return isHeld as Ref<boolean>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,WAAW,KAAoD;AAa7E,QAVe,SAFC,oBAAoB,CAEJ,QAAQ,UAAU;EAChD,MAAM,WAAW,MAAM,IAAI;EAC3B,MAAM,iBACJ,OAAO,aAAa,WAAW,WAAW,OAAO,SAAS,EAC1D,aAAa;AACf,SAAO,MAAM,SAAS,MACnB,YAAY,QAAQ,aAAa,KAAK,cACxC;GACD"}
1
+ {"version":3,"file":"useKeyHold.js","names":[],"sources":["../src/useKeyHold.ts"],"sourcesContent":["import { useSelector } from '@tanstack/vue-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { unref } from 'vue'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\nimport type { IndividualKey } from '@tanstack/hotkeys'\n\n/**\n * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.\n *\n * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe\n * to the global KeyStateTracker and uses a selector to determine if\n * the specified key is held.\n *\n * @param key - The key to check (e.g., 'Shift', 'Control', 'A')\n * @returns Reactive ref that is true if the key is currently held down\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const isShiftHeld = useKeyHold('Shift')\n * </script>\n *\n * <template>\n * <div :style=\"{ opacity: isShiftHeld ? 1 : 0.5 }\">\n * {{ isShiftHeld ? 'Shift is pressed!' : 'Press Shift' }}\n * </div>\n * </template>\n * ```\n *\n * @example\n * ```vue\n * <script setup>\n * import { useKeyHold } from '@tanstack/vue-hotkeys'\n *\n * const ctrl = useKeyHold('Control')\n * const shift = useKeyHold('Shift')\n * const alt = useKeyHold('Alt')\n * </script>\n *\n * <template>\n * <div>\n * <span :style=\"{ opacity: ctrl ? 1 : 0.3 }\">Ctrl</span>\n * <span :style=\"{ opacity: shift ? 1 : 0.3 }\">Shift</span>\n * <span :style=\"{ opacity: alt ? 1 : 0.3 }\">Alt</span>\n * </div>\n * </template>\n * ```\n */\nexport function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean> {\n const tracker = getKeyStateTracker()\n\n const isHeld = useSelector(tracker.store, (state) => {\n const keyValue = unref(key)\n const normalizedKey = (\n typeof keyValue === 'string' ? keyValue : String(keyValue)\n ).toLowerCase()\n return state.heldKeys.some(\n (heldKey) => heldKey.toLowerCase() === normalizedKey,\n )\n })\n\n return isHeld as Ref<boolean>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,WAAW,KAAoD;AAa7E,QAVe,YAFC,oBAAoB,CAED,QAAQ,UAAU;EACnD,MAAM,WAAW,MAAM,IAAI;EAC3B,MAAM,iBACJ,OAAO,aAAa,WAAW,WAAW,OAAO,SAAS,EAC1D,aAAa;AACf,SAAO,MAAM,SAAS,MACnB,YAAY,QAAQ,aAAa,KAAK,cACxC;GACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/vue-hotkeys",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Vue adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -42,13 +42,13 @@
42
42
  "src"
43
43
  ],
44
44
  "dependencies": {
45
- "@tanstack/vue-store": "^0.9.3",
46
- "@tanstack/hotkeys": "0.7.0"
45
+ "@tanstack/vue-store": "^0.11.0",
46
+ "@tanstack/hotkeys": "0.8.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@vitejs/plugin-vue": "^6.0.5",
49
+ "@vitejs/plugin-vue": "^6.0.6",
50
50
  "@vue/test-utils": "^2.4.6",
51
- "vue": "^3.5.31"
51
+ "vue": "^3.5.33"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "vue": ">=3.0.0"
@@ -1,4 +1,4 @@
1
- import { useStore } from '@tanstack/vue-store'
1
+ import { useSelector } from '@tanstack/vue-store'
2
2
  import { getKeyStateTracker } from '@tanstack/hotkeys'
3
3
  import type { Ref } from 'vue'
4
4
 
@@ -30,5 +30,5 @@ import type { Ref } from 'vue'
30
30
  */
31
31
  export function useHeldKeyCodes(): Ref<Record<string, string>> {
32
32
  const tracker = getKeyStateTracker()
33
- return useStore(tracker.store, (state) => state.heldCodes)
33
+ return useSelector(tracker.store, (state) => state.heldCodes)
34
34
  }
@@ -1,11 +1,11 @@
1
- import { useStore } from '@tanstack/vue-store'
1
+ import { useSelector } from '@tanstack/vue-store'
2
2
  import { getKeyStateTracker } from '@tanstack/hotkeys'
3
3
  import type { Ref } from 'vue'
4
4
 
5
5
  /**
6
6
  * Vue composable that returns a reactive ref of currently held keyboard keys.
7
7
  *
8
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
8
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
9
9
  * to the global KeyStateTracker and updates whenever keys are pressed
10
10
  * or released.
11
11
  *
@@ -28,5 +28,5 @@ import type { Ref } from 'vue'
28
28
  */
29
29
  export function useHeldKeys(): Ref<Array<string>> {
30
30
  const tracker = getKeyStateTracker()
31
- return useStore(tracker.store, (state) => state.heldKeys)
31
+ return useSelector(tracker.store, (state) => state.heldKeys)
32
32
  }
@@ -1,5 +1,5 @@
1
1
  import { onUnmounted, unref, watch } from 'vue'
2
- import { useStore } from '@tanstack/vue-store'
2
+ import { useSelector } from '@tanstack/vue-store'
3
3
  import { HotkeyRecorder } from '@tanstack/hotkeys'
4
4
  import { useDefaultHotkeysOptions } from './HotkeysProviderContext'
5
5
  import type { MaybeRefOrGetter, Ref } from 'vue'
@@ -67,9 +67,9 @@ export function useHotkeyRecorder(
67
67
  resolveRecorderOptions(options, defaultOptions),
68
68
  )
69
69
 
70
- // Subscribe to recorder state using useStore
71
- const isRecording = useStore(recorder.store, (state) => state.isRecording)
72
- const recordedHotkey = useStore(
70
+ // Subscribe to recorder state using useSelector
71
+ const isRecording = useSelector(recorder.store, (state) => state.isRecording)
72
+ const recordedHotkey = useSelector(
73
73
  recorder.store,
74
74
  (state) => state.recordedHotkey,
75
75
  )
@@ -1,4 +1,4 @@
1
- import { useStore } from '@tanstack/vue-store'
1
+ import { useSelector } from '@tanstack/vue-store'
2
2
  import {
3
3
  getHotkeyManager,
4
4
  getSequenceManager,
@@ -34,11 +34,11 @@ export function useHotkeyRegistrations(): HotkeyRegistrationsResult {
34
34
  const hotkeyManager = getHotkeyManager()
35
35
  const sequenceManager = getSequenceManager()
36
36
 
37
- const hotkeys = useStore(hotkeyManager.registrations, (state) =>
37
+ const hotkeys = useSelector(hotkeyManager.registrations, (state) =>
38
38
  Array.from(state.values()).map(toHotkeyRegistrationView),
39
39
  )
40
40
 
41
- const sequences = useStore(sequenceManager.registrations, (state) =>
41
+ const sequences = useSelector(sequenceManager.registrations, (state) =>
42
42
  Array.from(state.values()),
43
43
  )
44
44
 
@@ -1,5 +1,5 @@
1
1
  import { onUnmounted, unref, watch } from 'vue'
2
- import { useStore } from '@tanstack/vue-store'
2
+ import { useSelector } from '@tanstack/vue-store'
3
3
  import { HotkeySequenceRecorder } from '@tanstack/hotkeys'
4
4
  import { useDefaultHotkeysOptions } from './HotkeysProviderContext'
5
5
  import type { MaybeRefOrGetter, Ref } from 'vue'
@@ -29,9 +29,9 @@ export function useHotkeySequenceRecorder(
29
29
  resolveHotkeySequenceRecorderOptions(options, defaultOptions),
30
30
  )
31
31
 
32
- const isRecording = useStore(recorder.store, (state) => state.isRecording)
33
- const steps = useStore(recorder.store, (state) => state.steps)
34
- const recordedSequence = useStore(
32
+ const isRecording = useSelector(recorder.store, (state) => state.isRecording)
33
+ const steps = useSelector(recorder.store, (state) => state.steps)
34
+ const recordedSequence = useSelector(
35
35
  recorder.store,
36
36
  (state) => state.recordedSequence,
37
37
  )
package/src/useKeyHold.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useStore } from '@tanstack/vue-store'
1
+ import { useSelector } from '@tanstack/vue-store'
2
2
  import { getKeyStateTracker } from '@tanstack/hotkeys'
3
3
  import { unref } from 'vue'
4
4
  import type { MaybeRefOrGetter, Ref } from 'vue'
@@ -7,7 +7,7 @@ import type { IndividualKey } from '@tanstack/hotkeys'
7
7
  /**
8
8
  * Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
9
9
  *
10
- * This composable uses `useStore` from `@tanstack/vue-store` to subscribe
10
+ * This composable uses `useSelector` from `@tanstack/vue-store` to subscribe
11
11
  * to the global KeyStateTracker and uses a selector to determine if
12
12
  * the specified key is held.
13
13
  *
@@ -51,7 +51,7 @@ import type { IndividualKey } from '@tanstack/hotkeys'
51
51
  export function useKeyHold(key: MaybeRefOrGetter<IndividualKey>): Ref<boolean> {
52
52
  const tracker = getKeyStateTracker()
53
53
 
54
- const isHeld = useStore(tracker.store, (state) => {
54
+ const isHeld = useSelector(tracker.store, (state) => {
55
55
  const keyValue = unref(key)
56
56
  const normalizedKey = (
57
57
  typeof keyValue === 'string' ? keyValue : String(keyValue)