@tanstack/vue-hotkeys 0.17.1 → 0.18.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { publishAppHotkeysStore } from "@tanstack/hotkeys";
|
|
2
2
|
import { computed, hasInjectionContext, inject, onMounted, onScopeDispose, provide, toValue, watch } from "vue";
|
|
3
|
-
import { activateHotkeysProviderScope, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
|
|
3
|
+
import { activateHotkeysProviderScope, createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
|
|
4
4
|
|
|
5
5
|
//#region src/HotkeysProviderContext.ts
|
|
6
6
|
const HotkeysContext = Symbol("HotkeysContext");
|
|
@@ -28,7 +28,7 @@ const DEFAULT_OPTIONS = {};
|
|
|
28
28
|
function provideHotkeysContext(options = {}) {
|
|
29
29
|
const parent = inject(HotkeysContext, null);
|
|
30
30
|
const appHotkeys = toValue(options.appHotkeys);
|
|
31
|
-
const store = appHotkeys ?
|
|
31
|
+
const store = appHotkeys ? createAppHotkeysStore(appHotkeys, {
|
|
32
32
|
customHotkeys: options.customHotkeys,
|
|
33
33
|
onCustomHotkeysChange: (custom) => options.onCustomHotkeysChange?.(custom)
|
|
34
34
|
}) : null;
|
package/dist/useHeldKeys.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { Ref } from "vue";
|
|
|
3
3
|
/**
|
|
4
4
|
* Vue composable that returns a reactive ref of currently held keyboard keys.
|
|
5
5
|
*
|
|
6
|
-
* This composable
|
|
7
|
-
* to the global KeyStateTracker and updates whenever keys are pressed
|
|
6
|
+
* This composable subscribes to the global KeyStateTracker and updates whenever keys are pressed
|
|
8
7
|
* or released.
|
|
9
8
|
*
|
|
10
9
|
* @returns Reactive ref containing array of currently held key names
|
package/dist/useHeldKeys.js
CHANGED
|
@@ -5,8 +5,7 @@ import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
|
5
5
|
/**
|
|
6
6
|
* Vue composable that returns a reactive ref of currently held keyboard keys.
|
|
7
7
|
*
|
|
8
|
-
* This composable
|
|
9
|
-
* to the global KeyStateTracker and updates whenever keys are pressed
|
|
8
|
+
* This composable subscribes to the global KeyStateTracker and updates whenever keys are pressed
|
|
10
9
|
* or released.
|
|
11
10
|
*
|
|
12
11
|
* @returns Reactive ref containing array of currently held key names
|
package/dist/useStoreSelector.js
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import { shallowRef } from "vue";
|
|
2
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
1
|
+
import { onScopeDispose, shallowReadonly, shallowRef } from "vue";
|
|
3
2
|
|
|
4
3
|
//#region src/useStoreSelector.ts
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Subscribes to a store until the effect scope is disposed and returns a ref
|
|
6
|
+
* to the selected value, which updates when it changes (by `===`).
|
|
7
|
+
*
|
|
8
|
+
* Does not subscribe during server rendering. Vue never disposes component
|
|
9
|
+
* scopes on the server, so a subscription to a shared store would never be
|
|
10
|
+
* released. The server gets the current value instead.
|
|
9
11
|
*/
|
|
10
|
-
function useStoreSelector(
|
|
11
|
-
|
|
12
|
+
function useStoreSelector(store, selector) {
|
|
13
|
+
const selected = shallowRef(selector(store.get()));
|
|
14
|
+
if (typeof document === "undefined") return selected;
|
|
15
|
+
const { unsubscribe } = store.subscribe((state) => {
|
|
16
|
+
selected.value = selector(state);
|
|
17
|
+
});
|
|
18
|
+
onScopeDispose(unsubscribe);
|
|
19
|
+
return shallowReadonly(selected);
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Vue adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"skills"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tanstack/hotkeys": "0.
|
|
42
|
-
"@tanstack/vue-store": "^0.11.2"
|
|
41
|
+
"@tanstack/hotkeys": "0.20.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
44
|
"@vitejs/plugin-vue": "^6.0.9",
|