@tanstack/vue-hotkeys 0.16.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HotkeysProviderContext.d.ts +5 -0
- package/dist/HotkeysProviderContext.js +8 -3
- package/dist/defaultOptions.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/useHeldKeyCodes.js +2 -2
- package/dist/useHeldKeys.js +2 -2
- package/dist/useHotkeyHint.d.ts +5 -4
- package/dist/useHotkeyHint.js +11 -8
- package/dist/useHotkeyRecorder.js +4 -4
- package/dist/useHotkeyRegistrations.js +2 -2
- package/dist/useHotkeyScopesState.d.ts +25 -0
- package/dist/useHotkeyScopesState.js +30 -0
- package/dist/useKeyHold.d.ts +2 -3
- package/dist/useKeyHold.js +8 -11
- package/dist/useStoreSelector.js +15 -0
- package/package.json +3 -3
- package/skills/vue-hotkeys/SKILL.md +18 -17
|
@@ -63,6 +63,11 @@ export interface ProvideHotkeysContextOptions {
|
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
65
|
export declare function provideHotkeysContext(options?: ProvideHotkeysContextOptions): void;
|
|
66
|
+
/**
|
|
67
|
+
* The nearest context, or `null`. Outside a component, such as in a bare
|
|
68
|
+
* `effectScope`, there is no context to read, so this skips `inject` and its
|
|
69
|
+
* warning.
|
|
70
|
+
*/
|
|
66
71
|
export declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
67
72
|
export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
68
73
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AppHotkeysStore, publishAppHotkeysStore } from "@tanstack/hotkeys";
|
|
2
|
-
import { computed, inject, onMounted, onScopeDispose, provide, toValue, watch } from "vue";
|
|
2
|
+
import { computed, hasInjectionContext, inject, onMounted, onScopeDispose, provide, toValue, watch } from "vue";
|
|
3
3
|
import { activateHotkeysProviderScope, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
|
|
4
4
|
|
|
5
5
|
//#region src/HotkeysProviderContext.ts
|
|
@@ -62,11 +62,16 @@ function provideHotkeysContext(options = {}) {
|
|
|
62
62
|
};
|
|
63
63
|
provide(HotkeysContext, contextValue);
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* The nearest context, or `null`. Outside a component, such as in a bare
|
|
67
|
+
* `effectScope`, there is no context to read, so this skips `inject` and its
|
|
68
|
+
* warning.
|
|
69
|
+
*/
|
|
65
70
|
function useHotkeysContext() {
|
|
66
|
-
return inject(HotkeysContext, null);
|
|
71
|
+
return hasInjectionContext() ? inject(HotkeysContext, null) : null;
|
|
67
72
|
}
|
|
68
73
|
function useDefaultHotkeysOptions() {
|
|
69
|
-
return
|
|
74
|
+
return useHotkeysContext()?.defaultOptions ?? DEFAULT_OPTIONS;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
//#endregion
|
package/dist/defaultOptions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useHotkeysContext } from "./HotkeysProviderContext.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
3
|
+
import { shallowRef } from "vue";
|
|
3
4
|
|
|
4
5
|
//#region src/defaultOptions.ts
|
|
5
6
|
/** Captures the context once and reads current defaults inside reactive computations. */
|
|
@@ -7,7 +8,6 @@ function useDefaultHotkeysOptionsSource() {
|
|
|
7
8
|
const context = useHotkeysContext();
|
|
8
9
|
return () => context?.defaultOptions ?? {};
|
|
9
10
|
}
|
|
10
|
-
const NO_APP_HOTKEYS = new Store(null);
|
|
11
11
|
/**
|
|
12
12
|
* The provider's app hotkeys store and a ref that tracks its state, so
|
|
13
13
|
* watchers re-run when app hotkeys or custom hotkeys change.
|
|
@@ -16,7 +16,7 @@ function useAppHotkeysStoreSource() {
|
|
|
16
16
|
const store = useHotkeysContext()?.appHotkeysStore ?? null;
|
|
17
17
|
return {
|
|
18
18
|
store,
|
|
19
|
-
state:
|
|
19
|
+
state: store ? useStoreSelector(store.store, (value) => value) : shallowRef(null)
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
|
7
7
|
import { useKeyHold } from "./useKeyHold.js";
|
|
8
8
|
import { VueHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
9
9
|
import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
|
|
10
|
+
import { useHotkeyScopesState } from "./useHotkeyScopesState.js";
|
|
10
11
|
import { useHotkeyHint } from "./useHotkeyHint.js";
|
|
11
12
|
import { UseCustomHotkeysResult, useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotkeys.js";
|
|
12
13
|
export * from "@tanstack/hotkeys";
|
|
13
|
-
export { HotkeysProvider, HotkeysProviderOptions, ProvideHotkeysContextOptions, UseAppHotkeyOptions, UseCustomHotkeysResult, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, VueHotkeyRecorder, provideHotkeysContext, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeys, useHotkeysContext, useKeyHold };
|
|
14
|
+
export { HotkeysProvider, HotkeysProviderOptions, ProvideHotkeysContextOptions, UseAppHotkeyOptions, UseCustomHotkeysResult, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, VueHotkeyRecorder, provideHotkeysContext, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold };
|
package/dist/index.js
CHANGED
|
@@ -7,9 +7,10 @@ import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
|
7
7
|
import { useKeyHold } from "./useKeyHold.js";
|
|
8
8
|
import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
9
9
|
import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
|
|
10
|
+
import { useHotkeyScopesState } from "./useHotkeyScopesState.js";
|
|
10
11
|
import { useHotkeyHint } from "./useHotkeyHint.js";
|
|
11
12
|
import { useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotkeys.js";
|
|
12
13
|
|
|
13
14
|
export * from "@tanstack/hotkeys"
|
|
14
15
|
|
|
15
|
-
export { HotkeysProvider, provideHotkeysContext, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeys, useHotkeysContext, useKeyHold };
|
|
16
|
+
export { HotkeysProvider, provideHotkeysContext, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold };
|
package/dist/useHeldKeyCodes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
1
2
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
3
3
|
|
|
4
4
|
//#region src/useHeldKeyCodes.ts
|
|
5
5
|
/**
|
|
@@ -30,7 +30,7 @@ import { useSelector } from "@tanstack/vue-store";
|
|
|
30
30
|
*/
|
|
31
31
|
function useHeldKeyCodes() {
|
|
32
32
|
const tracker = getKeyStateTracker();
|
|
33
|
-
return
|
|
33
|
+
return useStoreSelector(tracker.store, (state) => state.heldCodes);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
package/dist/useHeldKeys.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
1
2
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
3
3
|
|
|
4
4
|
//#region src/useHeldKeys.ts
|
|
5
5
|
/**
|
|
@@ -28,7 +28,7 @@ import { useSelector } from "@tanstack/vue-store";
|
|
|
28
28
|
*/
|
|
29
29
|
function useHeldKeys() {
|
|
30
30
|
const tracker = getKeyStateTracker();
|
|
31
|
-
return
|
|
31
|
+
return useStoreSelector(tracker.store, (state) => state.heldKeys);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
//#endregion
|
package/dist/useHotkeyHint.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
|
3
3
|
//#region src/useHotkeyHint.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Returns a computed ref indicating whether held modifiers reveal this shortcut.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The hint shows only while the hotkey can fire: some registration of it is
|
|
7
|
+
* enabled and in an active scope. Pass refs or getters to track changing
|
|
8
|
+
* hotkeys and options. A sequence reveals its hint from its first step, and
|
|
9
|
+
* an app hotkey matches its registrations by id and uses its effective hotkey
|
|
10
|
+
* (false while unbound). This helper does not register a shortcut. A hotkey on an element counts only while focus is inside it.
|
|
10
11
|
*/
|
|
11
12
|
export declare function useHotkeyHint(hotkey: MaybeRefOrGetter<RegisterableHotkey | AppHotkey>, options?: MaybeRefOrGetter<HeldModifierOptions>): ComputedRef<boolean>;
|
|
12
13
|
//#endregion
|
package/dist/useHotkeyHint.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
1
2
|
import { useAppHotkeysStoreSource } from "./defaultOptions.js";
|
|
2
|
-
import { getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
|
|
3
|
+
import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
|
|
3
4
|
import { computed, toValue } from "vue";
|
|
4
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
5
5
|
|
|
6
6
|
//#region src/useHotkeyHint.ts
|
|
7
7
|
/**
|
|
8
8
|
* Returns a computed ref indicating whether held modifiers reveal this shortcut.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* The hint shows only while the hotkey can fire: some registration of it is
|
|
10
|
+
* enabled and in an active scope. Pass refs or getters to track changing
|
|
11
|
+
* hotkeys and options. A sequence reveals its hint from its first step, and
|
|
12
|
+
* an app hotkey matches its registrations by id and uses its effective hotkey
|
|
13
|
+
* (false while unbound). This helper does not register a shortcut. A hotkey on an element counts only while focus is inside it.
|
|
13
14
|
*/
|
|
14
15
|
function useHotkeyHint(hotkey, options = {}) {
|
|
15
16
|
const appHotkeys = useAppHotkeysStoreSource();
|
|
16
|
-
const
|
|
17
|
+
const manager = getHotkeyManager();
|
|
18
|
+
const registrations = useStoreSelector(manager.registrations, (state) => state);
|
|
19
|
+
const held = useStoreSelector(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
17
20
|
return computed(() => {
|
|
18
21
|
appHotkeys.state.value;
|
|
19
22
|
const value = toValue(hotkey);
|
|
20
23
|
const resolved = isAppHotkey(value) ? resolveAppHotkey(value, appHotkeys.store).hotkey : value;
|
|
21
|
-
return resolved !== null && matchesHeldModifiers(resolved, held.value, toValue(options));
|
|
24
|
+
return resolved !== null && matchesHeldModifiers(resolved, held.value, toValue(options)) && registrations.value.size > 0 && manager.hasActiveRegistration(value);
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
1
2
|
import { useDefaultHotkeysOptionsSource } from "./defaultOptions.js";
|
|
2
3
|
import { HotkeyRecorder } from "@tanstack/hotkeys";
|
|
3
4
|
import { onScopeDispose, toValue, watch } from "vue";
|
|
4
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
5
5
|
|
|
6
6
|
//#region src/useHotkeyRecorder.ts
|
|
7
7
|
function useHotkeyRecorder(options) {
|
|
@@ -11,9 +11,9 @@ function useHotkeyRecorder(options) {
|
|
|
11
11
|
...toValue(options)
|
|
12
12
|
});
|
|
13
13
|
const recorder = new HotkeyRecorder(resolve());
|
|
14
|
-
const isRecording =
|
|
15
|
-
const steps =
|
|
16
|
-
const recordedHotkey =
|
|
14
|
+
const isRecording = useStoreSelector(recorder.store, (state) => state.isRecording);
|
|
15
|
+
const steps = useStoreSelector(recorder.store, (state) => state.steps);
|
|
16
|
+
const recordedHotkey = useStoreSelector(recorder.store, (state) => state.recordedHotkey);
|
|
17
17
|
const stopWatcher = watch(resolve, (resolved) => recorder.setOptions(resolved));
|
|
18
18
|
onScopeDispose(() => {
|
|
19
19
|
stopWatcher();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
1
2
|
import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
|
|
2
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
3
3
|
|
|
4
4
|
//#region src/useHotkeyRegistrations.ts
|
|
5
5
|
/**
|
|
@@ -23,7 +23,7 @@ import { useSelector } from "@tanstack/vue-store";
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
function useHotkeyRegistrations() {
|
|
26
|
-
return
|
|
26
|
+
return useStoreSelector(getHotkeyManager().registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HotkeyScopesState } from "@tanstack/hotkeys";
|
|
2
|
+
import { Ref } from "vue";
|
|
3
|
+
//#region src/useHotkeyScopesState.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vue composable that returns a ref of the hotkey manager's scope state: the
|
|
6
|
+
* active scopes, the exclusive scope that owns the keyboard, and the scopes
|
|
7
|
+
* it allows or suspends. Updates when scopes activate or release.
|
|
8
|
+
*
|
|
9
|
+
* @returns Reactive ref of the current scope state
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```vue
|
|
13
|
+
* <script setup>
|
|
14
|
+
* import { useHotkeyScopesState } from '@tanstack/vue-hotkeys'
|
|
15
|
+
*
|
|
16
|
+
* const scopes = useHotkeyScopesState()
|
|
17
|
+
* </script>
|
|
18
|
+
*
|
|
19
|
+
* <template>
|
|
20
|
+
* <p v-if="scopes.exclusive">Shortcuts belong to {{ scopes.exclusive }}</p>
|
|
21
|
+
* </template>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useHotkeyScopesState(): Ref<HotkeyScopesState>;
|
|
25
|
+
//#endregion
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useStoreSelector } from "./useStoreSelector.js";
|
|
2
|
+
import { getHotkeyManager } from "@tanstack/hotkeys";
|
|
3
|
+
|
|
4
|
+
//#region src/useHotkeyScopesState.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vue composable that returns a ref of the hotkey manager's scope state: the
|
|
7
|
+
* active scopes, the exclusive scope that owns the keyboard, and the scopes
|
|
8
|
+
* it allows or suspends. Updates when scopes activate or release.
|
|
9
|
+
*
|
|
10
|
+
* @returns Reactive ref of the current scope state
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```vue
|
|
14
|
+
* <script setup>
|
|
15
|
+
* import { useHotkeyScopesState } from '@tanstack/vue-hotkeys'
|
|
16
|
+
*
|
|
17
|
+
* const scopes = useHotkeyScopesState()
|
|
18
|
+
* <\/script>
|
|
19
|
+
*
|
|
20
|
+
* <template>
|
|
21
|
+
* <p v-if="scopes.exclusive">Shortcuts belong to {{ scopes.exclusive }}</p>
|
|
22
|
+
* </template>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function useHotkeyScopesState() {
|
|
26
|
+
return useStoreSelector(getHotkeyManager().scopes, (state) => state);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useHotkeyScopesState };
|
package/dist/useKeyHold.d.ts
CHANGED
|
@@ -4,9 +4,8 @@ import { MaybeRefOrGetter, Ref } from "vue";
|
|
|
4
4
|
/**
|
|
5
5
|
* Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the specified key is held.
|
|
7
|
+
* Reads the held keys from the global KeyStateTracker. The key may be a ref
|
|
8
|
+
* or getter; the result follows it without waiting for a key event.
|
|
10
9
|
*
|
|
11
10
|
* @param key - The key to check (e.g., 'Shift', 'Control', 'A')
|
|
12
11
|
* @returns Reactive ref that is true if the key is currently held down
|
package/dist/useKeyHold.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useSelector } from "@tanstack/vue-store";
|
|
1
|
+
import { useHeldKeys } from "./useHeldKeys.js";
|
|
2
|
+
import { computed, toValue } from "vue";
|
|
4
3
|
|
|
5
4
|
//#region src/useKeyHold.ts
|
|
6
5
|
/**
|
|
7
6
|
* Vue composable that returns a reactive ref indicating whether a specific key is currently being held.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* the specified key is held.
|
|
8
|
+
* Reads the held keys from the global KeyStateTracker. The key may be a ref
|
|
9
|
+
* or getter; the result follows it without waiting for a key event.
|
|
12
10
|
*
|
|
13
11
|
* @param key - The key to check (e.g., 'Shift', 'Control', 'A')
|
|
14
12
|
* @returns Reactive ref that is true if the key is currently held down
|
|
@@ -48,11 +46,10 @@ import { useSelector } from "@tanstack/vue-store";
|
|
|
48
46
|
* ```
|
|
49
47
|
*/
|
|
50
48
|
function useKeyHold(key) {
|
|
51
|
-
const
|
|
52
|
-
return
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
return state.heldKeys.some((heldKey) => heldKey.toLowerCase() === normalizedKey);
|
|
49
|
+
const heldKeys = useHeldKeys();
|
|
50
|
+
return computed(() => {
|
|
51
|
+
const target = toValue(key).toLowerCase();
|
|
52
|
+
return heldKeys.value.some((heldKey) => heldKey.toLowerCase() === target);
|
|
56
53
|
});
|
|
57
54
|
}
|
|
58
55
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { shallowRef } from "vue";
|
|
2
|
+
import { useSelector } from "@tanstack/vue-store";
|
|
3
|
+
|
|
4
|
+
//#region src/useStoreSelector.ts
|
|
5
|
+
/**
|
|
6
|
+
* `useSelector` that does not subscribe during server rendering. Vue never
|
|
7
|
+
* disposes component scopes on the server, so a subscription to a shared
|
|
8
|
+
* store would never be released. The server gets the current value instead.
|
|
9
|
+
*/
|
|
10
|
+
function useStoreSelector(source, selector) {
|
|
11
|
+
return typeof document === "undefined" ? shallowRef(selector(source.get())) : useSelector(source, selector);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useStoreSelector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Vue adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"skills"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tanstack/hotkeys": "0.
|
|
41
|
+
"@tanstack/hotkeys": "0.19.0",
|
|
42
42
|
"@tanstack/vue-store": "^0.11.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"vue": "^3.5.43"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"vue": ">=3.
|
|
50
|
+
"vue": ">=3.3.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"clean": "premove ./build ./dist",
|
|
@@ -52,23 +52,24 @@ useHotkey('Escape', () => closePanel(), { target: panel })
|
|
|
52
52
|
|
|
53
53
|
## API
|
|
54
54
|
|
|
55
|
-
| API | What it's for
|
|
56
|
-
| ----------------------------------------- |
|
|
57
|
-
| `useHotkey(hotkey, callback, options?)` | Register one chord, sequence, or app hotkey while the component is mounted; the hotkey and options can be refs or getters.
|
|
58
|
-
| `useHotkeys(definitions, commonOptions?)` | Register several hotkeys, or a ref or getter of a list built from data, in one call.
|
|
59
|
-
| `<HotkeysProvider>` | Set default options, a scope (`exclusive` for dialogs), `enabled`, and app hotkeys for its children, and emit `custom-hotkeys-change`.
|
|
60
|
-
| `provideHotkeysContext(options)` | Provide the same options from a component's setup instead of rendering `HotkeysProvider`; they apply to its children.
|
|
61
|
-
| `useHotkeysContext()` | Read the nearest provider's merged defaults and enabled state, or `null` outside a provider.
|
|
62
|
-
| `useDefaultHotkeysOptions()` | Read the default options merged from every provider above.
|
|
63
|
-
| `useAppHotkeys()` | Get a computed ref of the declared app hotkeys with the user's custom hotkeys applied.
|
|
64
|
-
| `useAppHotkeyList()` | Get a computed ref listing every app hotkey with its status, for a cheat sheet or settings screen.
|
|
65
|
-
| `useCustomHotkeys()` | Read, change, and reset the user's custom hotkeys, and check a new one for conflicts.
|
|
66
|
-
| `useHotkeyRecorder(options)` | Record a chord or sequence the user presses; destructure the refs it returns.
|
|
67
|
-
| `useHotkeyRegistrations()` | Get a ref listing every registered hotkey with its options and `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
55
|
+
| API | What it's for |
|
|
56
|
+
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `useHotkey(hotkey, callback, options?)` | Register one chord, sequence, or app hotkey while the component is mounted; the hotkey and options can be refs or getters. |
|
|
58
|
+
| `useHotkeys(definitions, commonOptions?)` | Register several hotkeys, or a ref or getter of a list built from data, in one call. |
|
|
59
|
+
| `<HotkeysProvider>` | Set default options, a scope (`exclusive` for dialogs), `enabled`, and app hotkeys for its children, and emit `custom-hotkeys-change`. |
|
|
60
|
+
| `provideHotkeysContext(options)` | Provide the same options from a component's setup instead of rendering `HotkeysProvider`; they apply to its children. |
|
|
61
|
+
| `useHotkeysContext()` | Read the nearest provider's merged defaults and enabled state, or `null` outside a provider. |
|
|
62
|
+
| `useDefaultHotkeysOptions()` | Read the default options merged from every provider above. |
|
|
63
|
+
| `useAppHotkeys()` | Get a computed ref of the declared app hotkeys with the user's custom hotkeys applied. |
|
|
64
|
+
| `useAppHotkeyList()` | Get a computed ref listing every app hotkey with its status, for a cheat sheet or settings screen. |
|
|
65
|
+
| `useCustomHotkeys()` | Read, change, and reset the user's custom hotkeys, and check a new one for conflicts. |
|
|
66
|
+
| `useHotkeyRecorder(options)` | Record a chord or sequence the user presses; destructure the refs it returns. |
|
|
67
|
+
| `useHotkeyRegistrations()` | Get a ref listing every registered hotkey with its options, `meta`, and `status` (whether it's enabled and in an active scope). |
|
|
68
|
+
| `useHotkeyScopesState()` | Get a ref of the active scopes and the exclusive scope that owns the keyboard. |
|
|
69
|
+
| `useHotkeyHint(hotkey, options?)` | Get a computed ref of whether held modifiers should reveal a shortcut's hint. False unless a registration of the hotkey can fire: enabled, in an active scope, and with focus inside its element target. |
|
|
70
|
+
| `useKeyHold(key)` | Get a ref of whether one key is held. |
|
|
71
|
+
| `useHeldKeys()` | Get a ref of every key that's held right now. |
|
|
72
|
+
| `useHeldKeyCodes()` | Get a ref mapping each held key to its physical `event.code`. |
|
|
72
73
|
|
|
73
74
|
The package also re-exports `@tanstack/hotkeys`, such as `formatForDisplay`, `matchesKeyboardEvent`, and `defineAppHotkeys`.
|
|
74
75
|
|