@tanstack/angular-hotkeys 0.9.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/injectHeldKeyCodes.cjs +1 -1
- package/dist/injectHeldKeyCodes.cjs.map +1 -1
- package/dist/injectHeldKeyCodes.js +2 -2
- package/dist/injectHeldKeyCodes.js.map +1 -1
- package/dist/injectHeldKeys.cjs +1 -1
- package/dist/injectHeldKeys.cjs.map +1 -1
- package/dist/injectHeldKeys.js +2 -2
- package/dist/injectHeldKeys.js.map +1 -1
- package/dist/injectHotkeyHint.cjs +20 -0
- package/dist/injectHotkeyHint.cjs.map +1 -0
- package/dist/injectHotkeyHint.d.cts +15 -0
- package/dist/injectHotkeyHint.d.ts +15 -0
- package/dist/injectHotkeyHint.js +20 -0
- package/dist/injectHotkeyHint.js.map +1 -0
- package/dist/injectHotkeyRegistrations.cjs +2 -2
- package/dist/injectHotkeyRegistrations.cjs.map +1 -1
- package/dist/injectHotkeyRegistrations.js +3 -3
- package/dist/injectHotkeyRegistrations.js.map +1 -1
- package/dist/injectKeyHold.cjs +1 -1
- package/dist/injectKeyHold.cjs.map +1 -1
- package/dist/injectKeyHold.js +2 -2
- package/dist/injectKeyHold.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +1 -0
- package/src/injectHeldKeyCodes.ts +2 -2
- package/src/injectHeldKeys.ts +2 -2
- package/src/injectHotkeyHint.ts +29 -0
- package/src/injectHotkeyRegistrations.ts +3 -3
- package/src/injectKeyHold.ts +5 -2
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://tanstack.com/api/readme/hotkeys.png?theme=dark"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://tanstack.com/api/readme/hotkeys.png"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
src="https://tanstack.com/api/readme/hotkeys.png"
|
|
13
|
+
alt="TanStack Hotkeys"
|
|
14
|
+
width="900"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
3
17
|
</div>
|
|
4
18
|
|
|
5
19
|
<br />
|
package/dist/index.cjs
CHANGED
|
@@ -10,12 +10,14 @@ const require_injectKeyHold = require('./injectKeyHold.cjs');
|
|
|
10
10
|
const require_injectHotkeyRecorder = require('./injectHotkeyRecorder.cjs');
|
|
11
11
|
const require_injectHotkeyRegistrations = require('./injectHotkeyRegistrations.cjs');
|
|
12
12
|
const require_injectHotkeySequenceRecorder = require('./injectHotkeySequenceRecorder.cjs');
|
|
13
|
+
const require_injectHotkeyHint = require('./injectHotkeyHint.cjs');
|
|
13
14
|
|
|
14
15
|
exports.HOTKEYS_INJECTION_TOKEN = require_hotkeys_provider.HOTKEYS_INJECTION_TOKEN;
|
|
15
16
|
exports.injectDefaultHotkeysOptions = require_hotkeys_provider.injectDefaultHotkeysOptions;
|
|
16
17
|
exports.injectHeldKeyCodes = require_injectHeldKeyCodes.injectHeldKeyCodes;
|
|
17
18
|
exports.injectHeldKeys = require_injectHeldKeys.injectHeldKeys;
|
|
18
19
|
exports.injectHotkey = require_injectHotkey.injectHotkey;
|
|
20
|
+
exports.injectHotkeyHint = require_injectHotkeyHint.injectHotkeyHint;
|
|
19
21
|
exports.injectHotkeyRecorder = require_injectHotkeyRecorder.injectHotkeyRecorder;
|
|
20
22
|
exports.injectHotkeyRegistrations = require_injectHotkeyRegistrations.injectHotkeyRegistrations;
|
|
21
23
|
exports.injectHotkeySequence = require_injectHotkeySequence.injectHotkeySequence;
|
package/dist/index.d.cts
CHANGED
|
@@ -9,5 +9,6 @@ import { injectKeyHold } from "./injectKeyHold.cjs";
|
|
|
9
9
|
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.cjs";
|
|
10
10
|
import { HotkeyRegistrationsResult, injectHotkeyRegistrations } from "./injectHotkeyRegistrations.cjs";
|
|
11
11
|
import { AngularHotkeySequenceRecorder, injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.cjs";
|
|
12
|
+
import { injectHotkeyHint } from "./injectHotkeyHint.cjs";
|
|
12
13
|
export * from "@tanstack/hotkeys";
|
|
13
|
-
export { AngularHotkeyRecorder, AngularHotkeySequenceRecorder, HOTKEYS_INJECTION_TOKEN, HotkeyRegistrationsResult, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceDefinition, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeyRegistrations, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
14
|
+
export { AngularHotkeyRecorder, AngularHotkeySequenceRecorder, HOTKEYS_INJECTION_TOKEN, HotkeyRegistrationsResult, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceDefinition, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyHint, injectHotkeyRecorder, injectHotkeyRegistrations, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ import { injectKeyHold } from "./injectKeyHold.js";
|
|
|
9
9
|
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.js";
|
|
10
10
|
import { HotkeyRegistrationsResult, injectHotkeyRegistrations } from "./injectHotkeyRegistrations.js";
|
|
11
11
|
import { AngularHotkeySequenceRecorder, injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.js";
|
|
12
|
+
import { injectHotkeyHint } from "./injectHotkeyHint.js";
|
|
12
13
|
export * from "@tanstack/hotkeys";
|
|
13
|
-
export { AngularHotkeyRecorder, AngularHotkeySequenceRecorder, HOTKEYS_INJECTION_TOKEN, HotkeyRegistrationsResult, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceDefinition, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeyRegistrations, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
14
|
+
export { AngularHotkeyRecorder, AngularHotkeySequenceRecorder, HOTKEYS_INJECTION_TOKEN, HotkeyRegistrationsResult, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceDefinition, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyHint, injectHotkeyRecorder, injectHotkeyRegistrations, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,8 @@ import { injectKeyHold } from "./injectKeyHold.js";
|
|
|
9
9
|
import { injectHotkeyRecorder } from "./injectHotkeyRecorder.js";
|
|
10
10
|
import { injectHotkeyRegistrations } from "./injectHotkeyRegistrations.js";
|
|
11
11
|
import { injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.js";
|
|
12
|
+
import { injectHotkeyHint } from "./injectHotkeyHint.js";
|
|
12
13
|
|
|
13
14
|
export * from "@tanstack/hotkeys"
|
|
14
15
|
|
|
15
|
-
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeyRegistrations, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
16
|
+
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyHint, injectHotkeyRecorder, injectHotkeyRegistrations, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
@@ -26,7 +26,7 @@ let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function injectHeldKeyCodes() {
|
|
29
|
-
return (0, _tanstack_angular_store.
|
|
29
|
+
return (0, _tanstack_angular_store.injectSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHeldKeyCodes.cjs","names":[],"sources":["../src/injectHeldKeyCodes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport {
|
|
1
|
+
{"version":3,"file":"injectHeldKeyCodes.cjs","names":[],"sources":["../src/injectHeldKeyCodes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectSelector } from '@tanstack/angular-store'\nimport type { Signal } from '@angular/core'\n\n/**\n * Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.\n *\n * Useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Signal of record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * @for (key of heldKeys(); track key) {\n * <kbd>{{ key }} <small>{{ heldCodes()[key] }}</small></kbd>\n * }\n * `,\n * })\n * export class KeyDebugComponent {\n * heldKeys = injectHeldKeys()\n * heldCodes = injectHeldKeyCodes()\n * }\n * ```\n */\nexport function injectHeldKeyCodes(): Signal<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return injectSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,qBAAqD;AAEnE,+FADoC,CACN,QAAQ,UAAU,MAAM,UAAU"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
-
import {
|
|
2
|
+
import { injectSelector } from "@tanstack/angular-store";
|
|
3
3
|
|
|
4
4
|
//#region src/injectHeldKeyCodes.ts
|
|
5
5
|
/**
|
|
@@ -26,7 +26,7 @@ import { injectStore } from "@tanstack/angular-store";
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function injectHeldKeyCodes() {
|
|
29
|
-
return
|
|
29
|
+
return injectSelector(getKeyStateTracker().store, (state) => state.heldCodes);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHeldKeyCodes.js","names":[],"sources":["../src/injectHeldKeyCodes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport {
|
|
1
|
+
{"version":3,"file":"injectHeldKeyCodes.js","names":[],"sources":["../src/injectHeldKeyCodes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectSelector } from '@tanstack/angular-store'\nimport type { Signal } from '@angular/core'\n\n/**\n * Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.\n *\n * Useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Signal of record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * @for (key of heldKeys(); track key) {\n * <kbd>{{ key }} <small>{{ heldCodes()[key] }}</small></kbd>\n * }\n * `,\n * })\n * export class KeyDebugComponent {\n * heldKeys = injectHeldKeys()\n * heldCodes = injectHeldKeyCodes()\n * }\n * ```\n */\nexport function injectHeldKeyCodes(): Signal<Record<string, string>> {\n const tracker = getKeyStateTracker()\n return injectSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,qBAAqD;AAEnE,QAAO,eADS,oBAAoB,CACN,QAAQ,UAAU,MAAM,UAAU"}
|
package/dist/injectHeldKeys.cjs
CHANGED
|
@@ -21,7 +21,7 @@ let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function injectHeldKeys() {
|
|
24
|
-
return (0, _tanstack_angular_store.
|
|
24
|
+
return (0, _tanstack_angular_store.injectSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHeldKeys.cjs","names":[],"sources":["../src/injectHeldKeys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport {
|
|
1
|
+
{"version":3,"file":"injectHeldKeys.cjs","names":[],"sources":["../src/injectHeldKeys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectSelector } from '@tanstack/angular-store'\nimport type { Signal } from '@angular/core'\n\n/**\n * Angular inject-based API that returns a signal of currently held keyboard keys.\n *\n * Subscribes to the global KeyStateTracker and updates whenever keys are\n * pressed or released.\n *\n * @returns Signal of array of currently held key names\n *\n * @example\n * ```ts\n * @Component({\n * template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,\n * })\n * export class KeyDisplayComponent {\n * heldKeys = injectHeldKeys()\n * }\n * ```\n */\nexport function injectHeldKeys(): Signal<Array<string>> {\n const tracker = getKeyStateTracker()\n return injectSelector(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAwC;AAEtD,+FADoC,CACN,QAAQ,UAAU,MAAM,SAAS"}
|
package/dist/injectHeldKeys.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
-
import {
|
|
2
|
+
import { injectSelector } from "@tanstack/angular-store";
|
|
3
3
|
|
|
4
4
|
//#region src/injectHeldKeys.ts
|
|
5
5
|
/**
|
|
@@ -21,7 +21,7 @@ import { injectStore } from "@tanstack/angular-store";
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function injectHeldKeys() {
|
|
24
|
-
return
|
|
24
|
+
return injectSelector(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHeldKeys.js","names":[],"sources":["../src/injectHeldKeys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport {
|
|
1
|
+
{"version":3,"file":"injectHeldKeys.js","names":[],"sources":["../src/injectHeldKeys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectSelector } from '@tanstack/angular-store'\nimport type { Signal } from '@angular/core'\n\n/**\n * Angular inject-based API that returns a signal of currently held keyboard keys.\n *\n * Subscribes to the global KeyStateTracker and updates whenever keys are\n * pressed or released.\n *\n * @returns Signal of array of currently held key names\n *\n * @example\n * ```ts\n * @Component({\n * template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,\n * })\n * export class KeyDisplayComponent {\n * heldKeys = injectHeldKeys()\n * }\n * ```\n */\nexport function injectHeldKeys(): Signal<Array<string>> {\n const tracker = getKeyStateTracker()\n return injectSelector(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAwC;AAEtD,QAAO,eADS,oBAAoB,CACN,QAAQ,UAAU,MAAM,SAAS"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
+
let _angular_core = require("@angular/core");
|
|
3
|
+
let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
4
|
+
|
|
5
|
+
//#region src/injectHotkeyHint.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns a computed signal indicating whether held modifiers reveal this shortcut.
|
|
8
|
+
* Call in an injection context; pass signal getters for changing inputs.
|
|
9
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
10
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
11
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
12
|
+
*/
|
|
13
|
+
function injectHotkeyHint(hotkey, options = {}) {
|
|
14
|
+
const held = (0, _tanstack_angular_store.injectSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
15
|
+
return (0, _angular_core.computed)(() => (0, _tanstack_hotkeys.matchesHeldModifiers)(typeof hotkey === "function" ? hotkey() : hotkey, held(), typeof options === "function" ? options() : options));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.injectHotkeyHint = injectHotkeyHint;
|
|
20
|
+
//# sourceMappingURL=injectHotkeyHint.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectHotkeyHint.cjs","names":[],"sources":["../src/injectHotkeyHint.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { Signal } from '@angular/core'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a computed signal indicating whether held modifiers reveal this shortcut.\n * Call in an injection context; pass signal getters for changing inputs.\n * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires\n * every modifier. Combine with the action's enabled state before showing a badge.\n * This helper does not register a shortcut or check whether its target is focused.\n */\nexport function injectHotkeyHint(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n options: HeldModifierOptions | (() => HeldModifierOptions) = {},\n): Signal<boolean> {\n const held = injectSelector(\n getKeyStateTracker().store,\n (state) => state.heldKeys,\n )\n return computed(() =>\n matchesHeldModifiers(\n typeof hotkey === 'function' ? hotkey() : hotkey,\n held(),\n typeof options === 'function' ? options() : options,\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,iBACd,QACA,UAA6D,EAAE,EAC9C;CACjB,MAAM,8FACgB,CAAC,QACpB,UAAU,MAAM,SAClB;AACD,sFAEI,OAAO,WAAW,aAAa,QAAQ,GAAG,QAC1C,MAAM,EACN,OAAO,YAAY,aAAa,SAAS,GAAG,QAC7C,CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
+
import { Signal } from "@angular/core";
|
|
3
|
+
|
|
4
|
+
//#region src/injectHotkeyHint.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns a computed signal indicating whether held modifiers reveal this shortcut.
|
|
7
|
+
* Call in an injection context; pass signal getters for changing inputs.
|
|
8
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
9
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
10
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
11
|
+
*/
|
|
12
|
+
declare function injectHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): Signal<boolean>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { injectHotkeyHint };
|
|
15
|
+
//# sourceMappingURL=injectHotkeyHint.d.cts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
+
import { Signal } from "@angular/core";
|
|
3
|
+
|
|
4
|
+
//#region src/injectHotkeyHint.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns a computed signal indicating whether held modifiers reveal this shortcut.
|
|
7
|
+
* Call in an injection context; pass signal getters for changing inputs.
|
|
8
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
9
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
10
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
11
|
+
*/
|
|
12
|
+
declare function injectHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): Signal<boolean>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { injectHotkeyHint };
|
|
15
|
+
//# sourceMappingURL=injectHotkeyHint.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getKeyStateTracker, matchesHeldModifiers } from "@tanstack/hotkeys";
|
|
2
|
+
import { computed } from "@angular/core";
|
|
3
|
+
import { injectSelector } from "@tanstack/angular-store";
|
|
4
|
+
|
|
5
|
+
//#region src/injectHotkeyHint.ts
|
|
6
|
+
/**
|
|
7
|
+
* Returns a computed signal indicating whether held modifiers reveal this shortcut.
|
|
8
|
+
* Call in an injection context; pass signal getters for changing inputs.
|
|
9
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
10
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
11
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
12
|
+
*/
|
|
13
|
+
function injectHotkeyHint(hotkey, options = {}) {
|
|
14
|
+
const held = injectSelector(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
15
|
+
return computed(() => matchesHeldModifiers(typeof hotkey === "function" ? hotkey() : hotkey, held(), typeof options === "function" ? options() : options));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { injectHotkeyHint };
|
|
20
|
+
//# sourceMappingURL=injectHotkeyHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectHotkeyHint.js","names":[],"sources":["../src/injectHotkeyHint.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'\nimport type { Signal } from '@angular/core'\nimport type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'\n\n/**\n * Returns a computed signal indicating whether held modifiers reveal this shortcut.\n * Call in an injection context; pass signal getters for changing inputs.\n * Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires\n * every modifier. Combine with the action's enabled state before showing a badge.\n * This helper does not register a shortcut or check whether its target is focused.\n */\nexport function injectHotkeyHint(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n options: HeldModifierOptions | (() => HeldModifierOptions) = {},\n): Signal<boolean> {\n const held = injectSelector(\n getKeyStateTracker().store,\n (state) => state.heldKeys,\n )\n return computed(() =>\n matchesHeldModifiers(\n typeof hotkey === 'function' ? hotkey() : hotkey,\n held(),\n typeof options === 'function' ? options() : options,\n ),\n )\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,iBACd,QACA,UAA6D,EAAE,EAC9C;CACjB,MAAM,OAAO,eACX,oBAAoB,CAAC,QACpB,UAAU,MAAM,SAClB;AACD,QAAO,eACL,qBACE,OAAO,WAAW,aAAa,QAAQ,GAAG,QAC1C,MAAM,EACN,OAAO,YAAY,aAAa,SAAS,GAAG,QAC7C,CACF"}
|
|
@@ -18,8 +18,8 @@ function injectHotkeyRegistrations() {
|
|
|
18
18
|
const hotkeyManager = (0, _tanstack_hotkeys.getHotkeyManager)();
|
|
19
19
|
const sequenceManager = (0, _tanstack_hotkeys.getSequenceManager)();
|
|
20
20
|
return {
|
|
21
|
-
hotkeys: (0, _tanstack_angular_store.
|
|
22
|
-
sequences: (0, _tanstack_angular_store.
|
|
21
|
+
hotkeys: (0, _tanstack_angular_store.injectSelector)(hotkeyManager.registrations, (state) => Array.from(state.values()).map(_tanstack_hotkeys.toHotkeyRegistrationView)),
|
|
22
|
+
sequences: (0, _tanstack_angular_store.injectSelector)(sequenceManager.registrations, (state) => Array.from(state.values()))
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHotkeyRegistrations.cjs","names":["toHotkeyRegistrationView"],"sources":["../src/injectHotkeyRegistrations.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"injectHotkeyRegistrations.cjs","names":["toHotkeyRegistrationView"],"sources":["../src/injectHotkeyRegistrations.ts"],"sourcesContent":["import { injectSelector } from '@tanstack/angular-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { Signal } from '@angular/core'\n\n/**\n * Return type for injectHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** Signal for all registered hotkeys (public view, no callbacks) */\n hotkeys: Signal<Array<HotkeyRegistrationView>>\n /** Signal for all registered sequences */\n sequences: Signal<Array<SequenceRegistrationView>>\n}\n\n/**\n * Angular injectable that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone injectable that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * triggers change detection when registrations change.\n *\n * Must be called in an injection context (constructor, factory, or `inject()`).\n *\n * @returns Object with `hotkeys` and `sequences` signals\n */\nexport function injectHotkeyRegistrations(): HotkeyRegistrationsResult {\n const hotkeyManager = getHotkeyManager()\n const sequenceManager = getSequenceManager()\n\n const hotkeys = injectSelector(hotkeyManager.registrations, (state) =>\n Array.from(state.values()).map(toHotkeyRegistrationView),\n )\n\n const sequences = injectSelector(sequenceManager.registrations, (state) =>\n Array.from(state.values()),\n )\n\n return { hotkeys, sequences }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,4BAAuD;CACrE,MAAM,yDAAkC;CACxC,MAAM,6DAAsC;AAU5C,QAAO;EAAE,qDARsB,cAAc,gBAAgB,UAC3D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAIA,2CAAyB,CACzD;EAMiB,uDAJe,gBAAgB,gBAAgB,UAC/D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getHotkeyManager, getSequenceManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
|
|
2
|
-
import {
|
|
2
|
+
import { injectSelector } from "@tanstack/angular-store";
|
|
3
3
|
|
|
4
4
|
//#region src/injectHotkeyRegistrations.ts
|
|
5
5
|
/**
|
|
@@ -18,8 +18,8 @@ function injectHotkeyRegistrations() {
|
|
|
18
18
|
const hotkeyManager = getHotkeyManager();
|
|
19
19
|
const sequenceManager = getSequenceManager();
|
|
20
20
|
return {
|
|
21
|
-
hotkeys:
|
|
22
|
-
sequences:
|
|
21
|
+
hotkeys: injectSelector(hotkeyManager.registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView)),
|
|
22
|
+
sequences: injectSelector(sequenceManager.registrations, (state) => Array.from(state.values()))
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHotkeyRegistrations.js","names":[],"sources":["../src/injectHotkeyRegistrations.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"injectHotkeyRegistrations.js","names":[],"sources":["../src/injectHotkeyRegistrations.ts"],"sourcesContent":["import { injectSelector } from '@tanstack/angular-store'\nimport {\n getHotkeyManager,\n getSequenceManager,\n toHotkeyRegistrationView,\n} from '@tanstack/hotkeys'\nimport type {\n HotkeyRegistrationView,\n SequenceRegistrationView,\n} from '@tanstack/hotkeys'\nimport type { Signal } from '@angular/core'\n\n/**\n * Return type for injectHotkeyRegistrations.\n */\nexport interface HotkeyRegistrationsResult {\n /** Signal for all registered hotkeys (public view, no callbacks) */\n hotkeys: Signal<Array<HotkeyRegistrationView>>\n /** Signal for all registered sequences */\n sequences: Signal<Array<SequenceRegistrationView>>\n}\n\n/**\n * Angular injectable that reactively reads all hotkey and sequence registrations\n * from the singleton managers.\n *\n * This is a standalone injectable that does NOT require the HotkeysProvider.\n * It subscribes to both HotkeyManager and SequenceManager stores and\n * triggers change detection when registrations change.\n *\n * Must be called in an injection context (constructor, factory, or `inject()`).\n *\n * @returns Object with `hotkeys` and `sequences` signals\n */\nexport function injectHotkeyRegistrations(): HotkeyRegistrationsResult {\n const hotkeyManager = getHotkeyManager()\n const sequenceManager = getSequenceManager()\n\n const hotkeys = injectSelector(hotkeyManager.registrations, (state) =>\n Array.from(state.values()).map(toHotkeyRegistrationView),\n )\n\n const sequences = injectSelector(sequenceManager.registrations, (state) =>\n Array.from(state.values()),\n )\n\n return { hotkeys, sequences }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,SAAgB,4BAAuD;CACrE,MAAM,gBAAgB,kBAAkB;CACxC,MAAM,kBAAkB,oBAAoB;AAU5C,QAAO;EAAE,SARO,eAAe,cAAc,gBAAgB,UAC3D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAAC,IAAI,yBAAyB,CACzD;EAMiB,WAJA,eAAe,gBAAgB,gBAAgB,UAC/D,MAAM,KAAK,MAAM,QAAQ,CAAC,CAC3B;EAE4B"}
|
package/dist/injectKeyHold.cjs
CHANGED
|
@@ -37,7 +37,7 @@ let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
function injectKeyHold(key) {
|
|
40
|
-
const heldKeysSelector = (0, _tanstack_angular_store.
|
|
40
|
+
const heldKeysSelector = (0, _tanstack_angular_store.injectSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
41
41
|
return (0, _angular_core.computed)(() => {
|
|
42
42
|
const normalizedKey = (typeof key === "function" ? key() : key).toLowerCase();
|
|
43
43
|
return heldKeysSelector().some((heldKey) => heldKey.toLowerCase() === normalizedKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectKeyHold.cjs","names":[],"sources":["../src/injectKeyHold.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport {
|
|
1
|
+
{"version":3,"file":"injectKeyHold.cjs","names":[],"sources":["../src/injectKeyHold.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { IndividualKey } from '@tanstack/hotkeys'\nimport type { Signal } from '@angular/core'\n\n/**\n * Angular inject-based API that returns a signal that is true when the given key is held.\n *\n * Subscribes to the global KeyStateTracker and uses a computed to determine\n * if the specified key is held.\n *\n * @param key - The key to check (e.g. 'Shift', 'Control', 'Space') - can be a getter function\n * @returns Signal that returns true if the key is currently held down\n *\n * @example\n * ```ts\n * @Component({\n * template: `{{ isShiftHeld() ? 'Shift is pressed!' : 'Press Shift' }}`,\n * })\n * export class ShiftIndicatorComponent {\n * isShiftHeld = injectKeyHold('Shift')\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * <span [style.opacity]=\"ctrl() ? 1 : 0.3\">Ctrl</span>\n * <span [style.opacity]=\"shift() ? 1 : 0.3\">Shift</span>\n * `,\n * })\n * export class ModifierIndicatorsComponent {\n * ctrl = injectKeyHold('Control')\n * shift = injectKeyHold('Shift')\n * }\n * ```\n */\nexport function injectKeyHold(\n key: IndividualKey | (() => IndividualKey),\n): Signal<boolean> {\n const tracker = getKeyStateTracker()\n const heldKeysSelector = injectSelector(\n tracker.store,\n (state) => state.heldKeys,\n )\n\n return computed(() => {\n const resolvedKey = typeof key === 'function' ? key() : key\n const normalizedKey = resolvedKey.toLowerCase()\n\n return heldKeysSelector().some(\n (heldKey) => heldKey.toLowerCase() === normalizedKey,\n )\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,cACd,KACiB;CAEjB,MAAM,0GAD8B,CAE1B,QACP,UAAU,MAAM,SAClB;AAED,0CAAsB;EAEpB,MAAM,iBADc,OAAO,QAAQ,aAAa,KAAK,GAAG,KACtB,aAAa;AAE/C,SAAO,kBAAkB,CAAC,MACvB,YAAY,QAAQ,aAAa,KAAK,cACxC;GACD"}
|
package/dist/injectKeyHold.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
2
|
import { computed } from "@angular/core";
|
|
3
|
-
import {
|
|
3
|
+
import { injectSelector } from "@tanstack/angular-store";
|
|
4
4
|
|
|
5
5
|
//#region src/injectKeyHold.ts
|
|
6
6
|
/**
|
|
@@ -37,7 +37,7 @@ import { injectStore } from "@tanstack/angular-store";
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
function injectKeyHold(key) {
|
|
40
|
-
const heldKeysSelector =
|
|
40
|
+
const heldKeysSelector = injectSelector(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
41
41
|
return computed(() => {
|
|
42
42
|
const normalizedKey = (typeof key === "function" ? key() : key).toLowerCase();
|
|
43
43
|
return heldKeysSelector().some((heldKey) => heldKey.toLowerCase() === normalizedKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectKeyHold.js","names":[],"sources":["../src/injectKeyHold.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport {
|
|
1
|
+
{"version":3,"file":"injectKeyHold.js","names":[],"sources":["../src/injectKeyHold.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\nimport type { IndividualKey } from '@tanstack/hotkeys'\nimport type { Signal } from '@angular/core'\n\n/**\n * Angular inject-based API that returns a signal that is true when the given key is held.\n *\n * Subscribes to the global KeyStateTracker and uses a computed to determine\n * if the specified key is held.\n *\n * @param key - The key to check (e.g. 'Shift', 'Control', 'Space') - can be a getter function\n * @returns Signal that returns true if the key is currently held down\n *\n * @example\n * ```ts\n * @Component({\n * template: `{{ isShiftHeld() ? 'Shift is pressed!' : 'Press Shift' }}`,\n * })\n * export class ShiftIndicatorComponent {\n * isShiftHeld = injectKeyHold('Shift')\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * <span [style.opacity]=\"ctrl() ? 1 : 0.3\">Ctrl</span>\n * <span [style.opacity]=\"shift() ? 1 : 0.3\">Shift</span>\n * `,\n * })\n * export class ModifierIndicatorsComponent {\n * ctrl = injectKeyHold('Control')\n * shift = injectKeyHold('Shift')\n * }\n * ```\n */\nexport function injectKeyHold(\n key: IndividualKey | (() => IndividualKey),\n): Signal<boolean> {\n const tracker = getKeyStateTracker()\n const heldKeysSelector = injectSelector(\n tracker.store,\n (state) => state.heldKeys,\n )\n\n return computed(() => {\n const resolvedKey = typeof key === 'function' ? key() : key\n const normalizedKey = resolvedKey.toLowerCase()\n\n return heldKeysSelector().some(\n (heldKey) => heldKey.toLowerCase() === normalizedKey,\n )\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,cACd,KACiB;CAEjB,MAAM,mBAAmB,eADT,oBAAoB,CAE1B,QACP,UAAU,MAAM,SAClB;AAED,QAAO,eAAe;EAEpB,MAAM,iBADc,OAAO,QAAQ,aAAa,KAAK,GAAG,KACtB,aAAa;AAE/C,SAAO,kBAAkB,CAAC,MACvB,YAAY,QAAQ,aAAa,KAAK,cACxC;GACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Angular adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
"src"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@tanstack/angular-store": "^0.
|
|
45
|
-
"@tanstack/hotkeys": "0.
|
|
44
|
+
"@tanstack/angular-store": "^0.11.0",
|
|
45
|
+
"@tanstack/hotkeys": "0.9.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@angular/common": ">=19.0.0",
|
|
49
49
|
"@angular/core": ">=19.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@angular/common": "^21.2.
|
|
53
|
-
"@angular/core": "^21.2.
|
|
54
|
-
"@angular/platform-browser-dynamic": "^21.2.
|
|
55
|
-
"typescript": "6.0.
|
|
52
|
+
"@angular/common": "^21.2.10",
|
|
53
|
+
"@angular/core": "^21.2.10",
|
|
54
|
+
"@angular/platform-browser-dynamic": "^21.2.10",
|
|
55
|
+
"typescript": "6.0.3"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"clean": "premove ./build ./dist",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getKeyStateTracker } from '@tanstack/hotkeys'
|
|
2
|
-
import {
|
|
2
|
+
import { injectSelector } from '@tanstack/angular-store'
|
|
3
3
|
import type { Signal } from '@angular/core'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -27,5 +27,5 @@ import type { Signal } from '@angular/core'
|
|
|
27
27
|
*/
|
|
28
28
|
export function injectHeldKeyCodes(): Signal<Record<string, string>> {
|
|
29
29
|
const tracker = getKeyStateTracker()
|
|
30
|
-
return
|
|
30
|
+
return injectSelector(tracker.store, (state) => state.heldCodes)
|
|
31
31
|
}
|
package/src/injectHeldKeys.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getKeyStateTracker } from '@tanstack/hotkeys'
|
|
2
|
-
import {
|
|
2
|
+
import { injectSelector } from '@tanstack/angular-store'
|
|
3
3
|
import type { Signal } from '@angular/core'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -22,5 +22,5 @@ import type { Signal } from '@angular/core'
|
|
|
22
22
|
*/
|
|
23
23
|
export function injectHeldKeys(): Signal<Array<string>> {
|
|
24
24
|
const tracker = getKeyStateTracker()
|
|
25
|
-
return
|
|
25
|
+
return injectSelector(tracker.store, (state) => state.heldKeys)
|
|
26
26
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { computed } from '@angular/core'
|
|
2
|
+
import { injectSelector } from '@tanstack/angular-store'
|
|
3
|
+
import { getKeyStateTracker, matchesHeldModifiers } from '@tanstack/hotkeys'
|
|
4
|
+
import type { Signal } from '@angular/core'
|
|
5
|
+
import type { HeldModifierOptions, RegisterableHotkey } from '@tanstack/hotkeys'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns a computed signal indicating whether held modifiers reveal this shortcut.
|
|
9
|
+
* Call in an injection context; pass signal getters for changing inputs.
|
|
10
|
+
* Uses the nonempty-subset/AltGr rules of `matchesHeldModifiers`; `exact` requires
|
|
11
|
+
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
12
|
+
* This helper does not register a shortcut or check whether its target is focused.
|
|
13
|
+
*/
|
|
14
|
+
export function injectHotkeyHint(
|
|
15
|
+
hotkey: RegisterableHotkey | (() => RegisterableHotkey),
|
|
16
|
+
options: HeldModifierOptions | (() => HeldModifierOptions) = {},
|
|
17
|
+
): Signal<boolean> {
|
|
18
|
+
const held = injectSelector(
|
|
19
|
+
getKeyStateTracker().store,
|
|
20
|
+
(state) => state.heldKeys,
|
|
21
|
+
)
|
|
22
|
+
return computed(() =>
|
|
23
|
+
matchesHeldModifiers(
|
|
24
|
+
typeof hotkey === 'function' ? hotkey() : hotkey,
|
|
25
|
+
held(),
|
|
26
|
+
typeof options === 'function' ? options() : options,
|
|
27
|
+
),
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { injectSelector } from '@tanstack/angular-store'
|
|
2
2
|
import {
|
|
3
3
|
getHotkeyManager,
|
|
4
4
|
getSequenceManager,
|
|
@@ -36,11 +36,11 @@ export function injectHotkeyRegistrations(): HotkeyRegistrationsResult {
|
|
|
36
36
|
const hotkeyManager = getHotkeyManager()
|
|
37
37
|
const sequenceManager = getSequenceManager()
|
|
38
38
|
|
|
39
|
-
const hotkeys =
|
|
39
|
+
const hotkeys = injectSelector(hotkeyManager.registrations, (state) =>
|
|
40
40
|
Array.from(state.values()).map(toHotkeyRegistrationView),
|
|
41
41
|
)
|
|
42
42
|
|
|
43
|
-
const sequences =
|
|
43
|
+
const sequences = injectSelector(sequenceManager.registrations, (state) =>
|
|
44
44
|
Array.from(state.values()),
|
|
45
45
|
)
|
|
46
46
|
|
package/src/injectKeyHold.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed } from '@angular/core'
|
|
2
|
-
import {
|
|
2
|
+
import { injectSelector } from '@tanstack/angular-store'
|
|
3
3
|
import { getKeyStateTracker } from '@tanstack/hotkeys'
|
|
4
4
|
import type { IndividualKey } from '@tanstack/hotkeys'
|
|
5
5
|
import type { Signal } from '@angular/core'
|
|
@@ -41,7 +41,10 @@ export function injectKeyHold(
|
|
|
41
41
|
key: IndividualKey | (() => IndividualKey),
|
|
42
42
|
): Signal<boolean> {
|
|
43
43
|
const tracker = getKeyStateTracker()
|
|
44
|
-
const heldKeysSelector =
|
|
44
|
+
const heldKeysSelector = injectSelector(
|
|
45
|
+
tracker.store,
|
|
46
|
+
(state) => state.heldKeys,
|
|
47
|
+
)
|
|
45
48
|
|
|
46
49
|
return computed(() => {
|
|
47
50
|
const resolvedKey = typeof key === 'function' ? key() : key
|