@tanstack/angular-hotkeys 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,19 @@
1
1
  <div align="center">
2
- <img src="./media/header_hotkeys.png" alt="TanStack Hotkeys" />
2
+ <picture>
3
+ <source
4
+ media="(prefers-color-scheme: dark)"
5
+ srcset="https://tanstack.com/api/readme/hotkeys.png?theme=dark"
6
+ />
7
+ <source
8
+ media="(prefers-color-scheme: light)"
9
+ srcset="https://tanstack.com/api/readme/hotkeys.png"
10
+ />
11
+ <img
12
+ src="https://tanstack.com/api/readme/hotkeys.png"
13
+ alt="TanStack Hotkeys"
14
+ width="900"
15
+ />
16
+ </picture>
3
17
  </div>
4
18
 
5
19
  <br />
package/dist/index.cjs CHANGED
@@ -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 };
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/angular-hotkeys",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Angular adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -42,16 +42,16 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@tanstack/angular-store": "^0.11.0",
45
- "@tanstack/hotkeys": "0.8.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.9",
53
- "@angular/core": "^21.2.9",
54
- "@angular/platform-browser-dynamic": "^21.2.9",
52
+ "@angular/common": "^21.2.10",
53
+ "@angular/core": "^21.2.10",
54
+ "@angular/platform-browser-dynamic": "^21.2.10",
55
55
  "typescript": "6.0.3"
56
56
  },
57
57
  "scripts": {
package/src/index.ts CHANGED
@@ -15,3 +15,4 @@ export * from './injectKeyHold'
15
15
  export * from './injectHotkeyRecorder'
16
16
  export * from './injectHotkeyRegistrations'
17
17
  export * from './injectHotkeySequenceRecorder'
18
+ export * from './injectHotkeyHint'
@@ -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
+ }