@tanstack/angular-hotkeys 0.3.3
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 +122 -0
- package/dist/hotkeys-provider.cjs +26 -0
- package/dist/hotkeys-provider.cjs.map +1 -0
- package/dist/hotkeys-provider.d.cts +21 -0
- package/dist/hotkeys-provider.d.ts +21 -0
- package/dist/hotkeys-provider.js +23 -0
- package/dist/hotkeys-provider.js.map +1 -0
- package/dist/index.cjs +26 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +11 -0
- package/dist/injectHeldKeyCodes.cjs +34 -0
- package/dist/injectHeldKeyCodes.cjs.map +1 -0
- package/dist/injectHeldKeyCodes.d.cts +30 -0
- package/dist/injectHeldKeyCodes.d.ts +30 -0
- package/dist/injectHeldKeyCodes.js +34 -0
- package/dist/injectHeldKeyCodes.js.map +1 -0
- package/dist/injectHeldKeys.cjs +29 -0
- package/dist/injectHeldKeys.cjs.map +1 -0
- package/dist/injectHeldKeys.d.cts +25 -0
- package/dist/injectHeldKeys.d.ts +25 -0
- package/dist/injectHeldKeys.js +29 -0
- package/dist/injectHeldKeys.js.map +1 -0
- package/dist/injectHotkey.cjs +93 -0
- package/dist/injectHotkey.cjs.map +1 -0
- package/dist/injectHotkey.d.cts +73 -0
- package/dist/injectHotkey.d.ts +73 -0
- package/dist/injectHotkey.js +93 -0
- package/dist/injectHotkey.js.map +1 -0
- package/dist/injectHotkeyRecorder.cjs +82 -0
- package/dist/injectHotkeyRecorder.cjs.map +1 -0
- package/dist/injectHotkeyRecorder.d.cts +49 -0
- package/dist/injectHotkeyRecorder.d.ts +49 -0
- package/dist/injectHotkeyRecorder.js +82 -0
- package/dist/injectHotkeyRecorder.js.map +1 -0
- package/dist/injectHotkeySequence.cjs +55 -0
- package/dist/injectHotkeySequence.cjs.map +1 -0
- package/dist/injectHotkeySequence.d.cts +35 -0
- package/dist/injectHotkeySequence.d.ts +35 -0
- package/dist/injectHotkeySequence.js +55 -0
- package/dist/injectHotkeySequence.js.map +1 -0
- package/dist/injectKeyHold.cjs +49 -0
- package/dist/injectKeyHold.cjs.map +1 -0
- package/dist/injectKeyHold.d.cts +41 -0
- package/dist/injectKeyHold.d.ts +41 -0
- package/dist/injectKeyHold.js +49 -0
- package/dist/injectKeyHold.js.map +1 -0
- package/package.json +67 -0
- package/src/hotkeys-provider.ts +40 -0
- package/src/index.ts +13 -0
- package/src/injectHeldKeyCodes.ts +31 -0
- package/src/injectHeldKeys.ts +26 -0
- package/src/injectHotkey.ts +145 -0
- package/src/injectHotkeyRecorder.ts +128 -0
- package/src/injectHotkeySequence.ts +87 -0
- package/src/injectKeyHold.ts +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="./media/header_hotkeys.png" alt="TanStack Hotkeys" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<br />
|
|
6
|
+
|
|
7
|
+
<div align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@tanstack/hotkeys" target="\_parent">
|
|
9
|
+
<img alt="" src="https://img.shields.io/npm/dm/@tanstack/hotkeys.svg" alt="npm downloads" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://github.com/TanStack/hotkeys" target="\_parent">
|
|
12
|
+
<img alt="" src="https://img.shields.io/github/stars/TanStack/hotkeys.svg?style=social&label=Star" alt="GitHub stars" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://bundlephobia.com/result?p=@tanstack/react-hotkeys@latest" target="\_parent">
|
|
15
|
+
<img alt="" src="https://badgen.net/bundlephobia/minzip/@tanstack/react-hotkeys@latest" alt="Bundle size" />
|
|
16
|
+
</a>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<div align="center">
|
|
20
|
+
<a href="#badge">
|
|
21
|
+
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="#badge">
|
|
24
|
+
<img src="https://img.shields.io/github/v/release/tanstack/hotkeys" alt="Release"/>
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://twitter.com/tan_stack">
|
|
27
|
+
<img src="https://img.shields.io/twitter/follow/tan_stack.svg?style=social" alt="Follow @TanStack"/>
|
|
28
|
+
</a>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
|
|
33
|
+
### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
# TanStack Hotkeys
|
|
38
|
+
|
|
39
|
+
> [!NOTE]
|
|
40
|
+
> TanStack Hotkeys is pre-alpha (prototyping phase). We are actively developing the library and are open to feedback and contributions.
|
|
41
|
+
|
|
42
|
+
Type-safe keyboard shortcuts for the web. Template-string bindings, parsed objects, a cross-platform `Mod` key, a singleton Hotkey Manager, and utilities for cheatsheet UIs—built to stay SSR-friendly.
|
|
43
|
+
|
|
44
|
+
- Type-safe bindings — template strings (`Mod+Shift+S`, `Escape`) or parsed objects for full control
|
|
45
|
+
- Flexible options — `keydown`/`keyup`, `preventDefault`, `stopPropagation`, conditional enabled, `requireReset`
|
|
46
|
+
- Cross-platform Mod — maps to Cmd on macOS and Ctrl on Windows/Linux
|
|
47
|
+
- Batteries included — validation + matching, sequences (Vim-style), key-state tracking, recorder UI helpers, React hooks, and devtools (in progress)
|
|
48
|
+
|
|
49
|
+
### <a href="https://tanstack.com/hotkeys">Read the docs →</a>
|
|
50
|
+
|
|
51
|
+
<br />
|
|
52
|
+
|
|
53
|
+
> [!NOTE]
|
|
54
|
+
> You may know **TanStack Hotkeys** by our adapter names, too!
|
|
55
|
+
>
|
|
56
|
+
> - [**React Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/react/react-hotkeys)
|
|
57
|
+
> - [**Preact Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/preact/preact-hotkeys)
|
|
58
|
+
> - [**Solid Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/solid/reference)
|
|
59
|
+
> - [**Angular Hotkeys**](https://tanstack.com/hotkeys/latest/docs/framework/angular/reference)
|
|
60
|
+
> - Svelte Hotkeys – needs a contributor!
|
|
61
|
+
> - Vue Hotkeys – needs a contributor!
|
|
62
|
+
|
|
63
|
+
## Get Involved
|
|
64
|
+
|
|
65
|
+
- We welcome issues and pull requests!
|
|
66
|
+
- Participate in [GitHub discussions](https://github.com/TanStack/hotkeys/discussions)
|
|
67
|
+
- Chat with the community on [Discord](https://discord.com/invite/WrRKjPJ)
|
|
68
|
+
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions
|
|
69
|
+
|
|
70
|
+
## Partners
|
|
71
|
+
|
|
72
|
+
<div align="center">
|
|
73
|
+
|
|
74
|
+
<table align="center">
|
|
75
|
+
<tr>
|
|
76
|
+
<td>
|
|
77
|
+
<a href="https://www.coderabbit.ai/?via=tanstack&dub_id=aCcEEdAOqqutX6OS" >
|
|
78
|
+
<picture>
|
|
79
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/coderabbit-dark-D643Zkrv.svg" height="40" />
|
|
80
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/coderabbit-light-CIzGLYU_.svg" height="40" />
|
|
81
|
+
<img src="https://tanstack.com/assets/coderabbit-light-DVMJ2jHi.svg" height="40" alt="CodeRabbit" />
|
|
82
|
+
</picture>
|
|
83
|
+
</a>
|
|
84
|
+
</td>
|
|
85
|
+
<td>
|
|
86
|
+
<a href="https://www.cloudflare.com?utm_source=tanstack">
|
|
87
|
+
<picture>
|
|
88
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://tanstack.com/assets/cloudflare-white-Co-Tyjbl.svg" height="60" />
|
|
89
|
+
<source media="(prefers-color-scheme: light)" srcset="https://tanstack.com/assets/cloudflare-black-6Ojsn8yh.svg" height="60" />
|
|
90
|
+
<img src="https://tanstack.com/assets/cloudflare-black-CPufaW0B.svg" height="60" alt="Cloudflare" />
|
|
91
|
+
</picture>
|
|
92
|
+
</a>
|
|
93
|
+
</td>
|
|
94
|
+
</tr>
|
|
95
|
+
</table>
|
|
96
|
+
|
|
97
|
+
<div align="center">
|
|
98
|
+
<img src="media/partner_logo.svg" alt="Keys & you?" height="65">
|
|
99
|
+
<p>
|
|
100
|
+
We're looking for TanStack Hotkeys Partners to join our mission! Partner with us to push the boundaries of TanStack Hotkeys and build amazing things together.
|
|
101
|
+
</p>
|
|
102
|
+
<a href="mailto:partners@tanstack.com?subject=TanStack Hotkeys Partnership"><b>LET'S CHAT</b></a>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
## Explore the TanStack Ecosystem
|
|
108
|
+
|
|
109
|
+
- <a href="https://github.com/tanstack/config"><b>TanStack Config</b></a> – Tooling for JS/TS packages
|
|
110
|
+
- <a href="https://github.com/tanstack/db"><b>TanStack DB</b></a> – Reactive sync client store
|
|
111
|
+
- <a href="https://github.com/tanstack/devtools"><b>TanStack DevTools</b></a> – Unified devtools panel
|
|
112
|
+
- <a href="https://github.com/tanstack/form"><b>TanStack Form</b></a> – Type‑safe form state
|
|
113
|
+
- <a href="https://github.com/tanstack/hotkeys"><b>TanStack Hotkeys</b></a> – Type‑safe keyboard shortcuts
|
|
114
|
+
- <a href="https://github.com/tanstack/query"><b>TanStack Query</b></a> – Async state & caching
|
|
115
|
+
- <a href="https://github.com/tanstack/ranger"><b>TanStack Ranger</b></a> – Range & slider primitives
|
|
116
|
+
- <a href="https://github.com/tanstack/router"><b>TanStack Router</b></a> – Type‑safe routing, caching & URL state
|
|
117
|
+
- <a href="https://github.com/tanstack/start"><b>TanStack Start</b></a> – Full‑stack SSR & streaming
|
|
118
|
+
- <a href="https://github.com/tanstack/store"><b>TanStack Store</b></a> – Reactive data store
|
|
119
|
+
- <a href="https://github.com/tanstack/table"><b>TanStack Table</b></a> – Headless datagrids
|
|
120
|
+
- <a href="https://github.com/tanstack/virtual"><b>TanStack Virtual</b></a> – Virtualized rendering
|
|
121
|
+
|
|
122
|
+
… and more at <a href="https://tanstack.com"><b>TanStack.com »</b></a>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
let _angular_core = require("@angular/core");
|
|
2
|
+
|
|
3
|
+
//#region src/hotkeys-provider.ts
|
|
4
|
+
const HOTKEYS_INJECTION_TOKEN = new _angular_core.InjectionToken("HOTKEYS_INJECTION_TOKEN", {
|
|
5
|
+
providedIn: "root",
|
|
6
|
+
factory: () => ({ defaultOptions: {} })
|
|
7
|
+
});
|
|
8
|
+
function provideHotkeys(defaultOptions) {
|
|
9
|
+
return {
|
|
10
|
+
provide: HOTKEYS_INJECTION_TOKEN,
|
|
11
|
+
useValue: { defaultOptions }
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function injectHotkeysContext() {
|
|
15
|
+
return (0, _angular_core.inject)(HOTKEYS_INJECTION_TOKEN);
|
|
16
|
+
}
|
|
17
|
+
function injectDefaultHotkeysOptions() {
|
|
18
|
+
return injectHotkeysContext().defaultOptions;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.HOTKEYS_INJECTION_TOKEN = HOTKEYS_INJECTION_TOKEN;
|
|
23
|
+
exports.injectDefaultHotkeysOptions = injectDefaultHotkeysOptions;
|
|
24
|
+
exports.injectHotkeysContext = injectHotkeysContext;
|
|
25
|
+
exports.provideHotkeys = provideHotkeys;
|
|
26
|
+
//# sourceMappingURL=hotkeys-provider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotkeys-provider.cjs","names":["InjectionToken"],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type { HotkeyRecorderOptions } from '@tanstack/hotkeys'\nimport type { InjectHotkeyOptions } from './injectHotkey'\nimport type { InjectHotkeySequenceOptions } from './injectHotkeySequence'\nimport type { StaticProvider } from '@angular/core'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<InjectHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<InjectHotkeySequenceOptions>\n}\n\nexport interface HotkeysContextValue {\n readonly defaultOptions: HotkeysProviderOptions\n}\n\nexport const HOTKEYS_INJECTION_TOKEN = new InjectionToken<HotkeysContextValue>(\n 'HOTKEYS_INJECTION_TOKEN',\n {\n providedIn: 'root',\n factory: () => ({ defaultOptions: {} }),\n },\n)\n\nexport function provideHotkeys(\n defaultOptions: HotkeysProviderOptions,\n): StaticProvider {\n return {\n provide: HOTKEYS_INJECTION_TOKEN,\n useValue: { defaultOptions },\n }\n}\n\nexport function injectHotkeysContext(): HotkeysContextValue {\n return inject(HOTKEYS_INJECTION_TOKEN)\n}\n\nexport function injectDefaultHotkeysOptions(): HotkeysProviderOptions {\n return injectHotkeysContext().defaultOptions\n}\n"],"mappings":";;;AAgBA,MAAa,0BAA0B,IAAIA,6BACzC,2BACA;CACE,YAAY;CACZ,gBAAgB,EAAE,gBAAgB,EAAE,EAAE;CACvC,CACF;AAED,SAAgB,eACd,gBACgB;AAChB,QAAO;EACL,SAAS;EACT,UAAU,EAAE,gBAAgB;EAC7B;;AAGH,SAAgB,uBAA4C;AAC1D,kCAAc,wBAAwB;;AAGxC,SAAgB,8BAAsD;AACpE,QAAO,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InjectHotkeyOptions } from "./injectHotkey.cjs";
|
|
2
|
+
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.cjs";
|
|
3
|
+
import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
4
|
+
import { InjectionToken, StaticProvider } from "@angular/core";
|
|
5
|
+
|
|
6
|
+
//#region src/hotkeys-provider.d.ts
|
|
7
|
+
interface HotkeysProviderOptions {
|
|
8
|
+
hotkey?: Partial<InjectHotkeyOptions>;
|
|
9
|
+
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
10
|
+
hotkeySequence?: Partial<InjectHotkeySequenceOptions>;
|
|
11
|
+
}
|
|
12
|
+
interface HotkeysContextValue {
|
|
13
|
+
readonly defaultOptions: HotkeysProviderOptions;
|
|
14
|
+
}
|
|
15
|
+
declare const HOTKEYS_INJECTION_TOKEN: InjectionToken<HotkeysContextValue>;
|
|
16
|
+
declare function provideHotkeys(defaultOptions: HotkeysProviderOptions): StaticProvider;
|
|
17
|
+
declare function injectHotkeysContext(): HotkeysContextValue;
|
|
18
|
+
declare function injectDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
21
|
+
//# sourceMappingURL=hotkeys-provider.d.cts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InjectHotkeyOptions } from "./injectHotkey.js";
|
|
2
|
+
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.js";
|
|
3
|
+
import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
4
|
+
import { InjectionToken, StaticProvider } from "@angular/core";
|
|
5
|
+
|
|
6
|
+
//#region src/hotkeys-provider.d.ts
|
|
7
|
+
interface HotkeysProviderOptions {
|
|
8
|
+
hotkey?: Partial<InjectHotkeyOptions>;
|
|
9
|
+
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
10
|
+
hotkeySequence?: Partial<InjectHotkeySequenceOptions>;
|
|
11
|
+
}
|
|
12
|
+
interface HotkeysContextValue {
|
|
13
|
+
readonly defaultOptions: HotkeysProviderOptions;
|
|
14
|
+
}
|
|
15
|
+
declare const HOTKEYS_INJECTION_TOKEN: InjectionToken<HotkeysContextValue>;
|
|
16
|
+
declare function provideHotkeys(defaultOptions: HotkeysProviderOptions): StaticProvider;
|
|
17
|
+
declare function injectHotkeysContext(): HotkeysContextValue;
|
|
18
|
+
declare function injectDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
21
|
+
//# sourceMappingURL=hotkeys-provider.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InjectionToken, inject } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/hotkeys-provider.ts
|
|
4
|
+
const HOTKEYS_INJECTION_TOKEN = new InjectionToken("HOTKEYS_INJECTION_TOKEN", {
|
|
5
|
+
providedIn: "root",
|
|
6
|
+
factory: () => ({ defaultOptions: {} })
|
|
7
|
+
});
|
|
8
|
+
function provideHotkeys(defaultOptions) {
|
|
9
|
+
return {
|
|
10
|
+
provide: HOTKEYS_INJECTION_TOKEN,
|
|
11
|
+
useValue: { defaultOptions }
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function injectHotkeysContext() {
|
|
15
|
+
return inject(HOTKEYS_INJECTION_TOKEN);
|
|
16
|
+
}
|
|
17
|
+
function injectDefaultHotkeysOptions() {
|
|
18
|
+
return injectHotkeysContext().defaultOptions;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
23
|
+
//# sourceMappingURL=hotkeys-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotkeys-provider.js","names":[],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type { HotkeyRecorderOptions } from '@tanstack/hotkeys'\nimport type { InjectHotkeyOptions } from './injectHotkey'\nimport type { InjectHotkeySequenceOptions } from './injectHotkeySequence'\nimport type { StaticProvider } from '@angular/core'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<InjectHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequence?: Partial<InjectHotkeySequenceOptions>\n}\n\nexport interface HotkeysContextValue {\n readonly defaultOptions: HotkeysProviderOptions\n}\n\nexport const HOTKEYS_INJECTION_TOKEN = new InjectionToken<HotkeysContextValue>(\n 'HOTKEYS_INJECTION_TOKEN',\n {\n providedIn: 'root',\n factory: () => ({ defaultOptions: {} }),\n },\n)\n\nexport function provideHotkeys(\n defaultOptions: HotkeysProviderOptions,\n): StaticProvider {\n return {\n provide: HOTKEYS_INJECTION_TOKEN,\n useValue: { defaultOptions },\n }\n}\n\nexport function injectHotkeysContext(): HotkeysContextValue {\n return inject(HOTKEYS_INJECTION_TOKEN)\n}\n\nexport function injectDefaultHotkeysOptions(): HotkeysProviderOptions {\n return injectHotkeysContext().defaultOptions\n}\n"],"mappings":";;;AAgBA,MAAa,0BAA0B,IAAI,eACzC,2BACA;CACE,YAAY;CACZ,gBAAgB,EAAE,gBAAgB,EAAE,EAAE;CACvC,CACF;AAED,SAAgB,eACd,gBACgB;AAChB,QAAO;EACL,SAAS;EACT,UAAU,EAAE,gBAAgB;EAC7B;;AAGH,SAAgB,uBAA4C;AAC1D,QAAO,OAAO,wBAAwB;;AAGxC,SAAgB,8BAAsD;AACpE,QAAO,sBAAsB,CAAC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_hotkeys_provider = require('./hotkeys-provider.cjs');
|
|
3
|
+
const require_injectHotkey = require('./injectHotkey.cjs');
|
|
4
|
+
const require_injectHotkeySequence = require('./injectHotkeySequence.cjs');
|
|
5
|
+
const require_injectHeldKeys = require('./injectHeldKeys.cjs');
|
|
6
|
+
const require_injectHeldKeyCodes = require('./injectHeldKeyCodes.cjs');
|
|
7
|
+
const require_injectKeyHold = require('./injectKeyHold.cjs');
|
|
8
|
+
const require_injectHotkeyRecorder = require('./injectHotkeyRecorder.cjs');
|
|
9
|
+
|
|
10
|
+
exports.HOTKEYS_INJECTION_TOKEN = require_hotkeys_provider.HOTKEYS_INJECTION_TOKEN;
|
|
11
|
+
exports.injectDefaultHotkeysOptions = require_hotkeys_provider.injectDefaultHotkeysOptions;
|
|
12
|
+
exports.injectHeldKeyCodes = require_injectHeldKeyCodes.injectHeldKeyCodes;
|
|
13
|
+
exports.injectHeldKeys = require_injectHeldKeys.injectHeldKeys;
|
|
14
|
+
exports.injectHotkey = require_injectHotkey.injectHotkey;
|
|
15
|
+
exports.injectHotkeyRecorder = require_injectHotkeyRecorder.injectHotkeyRecorder;
|
|
16
|
+
exports.injectHotkeySequence = require_injectHotkeySequence.injectHotkeySequence;
|
|
17
|
+
exports.injectHotkeysContext = require_hotkeys_provider.injectHotkeysContext;
|
|
18
|
+
exports.injectKeyHold = require_injectKeyHold.injectKeyHold;
|
|
19
|
+
exports.provideHotkeys = require_hotkeys_provider.provideHotkeys;
|
|
20
|
+
var _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
21
|
+
Object.keys(_tanstack_hotkeys).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return _tanstack_hotkeys[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InjectHotkeyOptions, injectHotkey } from "./injectHotkey.cjs";
|
|
2
|
+
import { InjectHotkeySequenceOptions, injectHotkeySequence } from "./injectHotkeySequence.cjs";
|
|
3
|
+
import { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys } from "./hotkeys-provider.cjs";
|
|
4
|
+
import { injectHeldKeys } from "./injectHeldKeys.cjs";
|
|
5
|
+
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.cjs";
|
|
6
|
+
import { injectKeyHold } from "./injectKeyHold.cjs";
|
|
7
|
+
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.cjs";
|
|
8
|
+
export * from "@tanstack/hotkeys";
|
|
9
|
+
export { AngularHotkeyRecorder, HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyOptions, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InjectHotkeyOptions, injectHotkey } from "./injectHotkey.js";
|
|
2
|
+
import { InjectHotkeySequenceOptions, injectHotkeySequence } from "./injectHotkeySequence.js";
|
|
3
|
+
import { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys } from "./hotkeys-provider.js";
|
|
4
|
+
import { injectHeldKeys } from "./injectHeldKeys.js";
|
|
5
|
+
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.js";
|
|
6
|
+
import { injectKeyHold } from "./injectKeyHold.js";
|
|
7
|
+
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.js";
|
|
8
|
+
export * from "@tanstack/hotkeys";
|
|
9
|
+
export { AngularHotkeyRecorder, HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyOptions, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys } from "./hotkeys-provider.js";
|
|
2
|
+
import { injectHotkey } from "./injectHotkey.js";
|
|
3
|
+
import { injectHotkeySequence } from "./injectHotkeySequence.js";
|
|
4
|
+
import { injectHeldKeys } from "./injectHeldKeys.js";
|
|
5
|
+
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.js";
|
|
6
|
+
import { injectKeyHold } from "./injectKeyHold.js";
|
|
7
|
+
import { injectHotkeyRecorder } from "./injectHotkeyRecorder.js";
|
|
8
|
+
|
|
9
|
+
export * from "@tanstack/hotkeys"
|
|
10
|
+
|
|
11
|
+
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
+
let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
3
|
+
|
|
4
|
+
//#region src/injectHeldKeyCodes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.
|
|
7
|
+
*
|
|
8
|
+
* Useful for debugging which physical key was pressed (e.g. distinguishing
|
|
9
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
10
|
+
*
|
|
11
|
+
* @returns Signal of record mapping normalized key names to their `event.code` values
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @Component({
|
|
16
|
+
* template: `
|
|
17
|
+
* @for (key of heldKeys(); track key) {
|
|
18
|
+
* <kbd>{{ key }} <small>{{ heldCodes()[key] }}</small></kbd>
|
|
19
|
+
* }
|
|
20
|
+
* `,
|
|
21
|
+
* })
|
|
22
|
+
* export class KeyDebugComponent {
|
|
23
|
+
* heldKeys = injectHeldKeys()
|
|
24
|
+
* heldCodes = injectHeldKeyCodes()
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function injectHeldKeyCodes() {
|
|
29
|
+
return (0, _tanstack_angular_store.injectStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.injectHeldKeyCodes = injectHeldKeyCodes;
|
|
34
|
+
//# sourceMappingURL=injectHeldKeyCodes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectHeldKeyCodes.cjs","names":[],"sources":["../src/injectHeldKeyCodes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectStore } 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 injectStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,qBAAqD;AAEnE,4FADoC,CACT,QAAQ,UAAU,MAAM,UAAU"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/injectHeldKeyCodes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.
|
|
6
|
+
*
|
|
7
|
+
* Useful for debugging which physical key was pressed (e.g. distinguishing
|
|
8
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
9
|
+
*
|
|
10
|
+
* @returns Signal of record mapping normalized key names to their `event.code` values
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* @Component({
|
|
15
|
+
* template: `
|
|
16
|
+
* @for (key of heldKeys(); track key) {
|
|
17
|
+
* <kbd>{{ key }} <small>{{ heldCodes()[key] }}</small></kbd>
|
|
18
|
+
* }
|
|
19
|
+
* `,
|
|
20
|
+
* })
|
|
21
|
+
* export class KeyDebugComponent {
|
|
22
|
+
* heldKeys = injectHeldKeys()
|
|
23
|
+
* heldCodes = injectHeldKeyCodes()
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function injectHeldKeyCodes(): Signal<Record<string, string>>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { injectHeldKeyCodes };
|
|
30
|
+
//# sourceMappingURL=injectHeldKeyCodes.d.cts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/injectHeldKeyCodes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.
|
|
6
|
+
*
|
|
7
|
+
* Useful for debugging which physical key was pressed (e.g. distinguishing
|
|
8
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
9
|
+
*
|
|
10
|
+
* @returns Signal of record mapping normalized key names to their `event.code` values
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* @Component({
|
|
15
|
+
* template: `
|
|
16
|
+
* @for (key of heldKeys(); track key) {
|
|
17
|
+
* <kbd>{{ key }} <small>{{ heldCodes()[key] }}</small></kbd>
|
|
18
|
+
* }
|
|
19
|
+
* `,
|
|
20
|
+
* })
|
|
21
|
+
* export class KeyDebugComponent {
|
|
22
|
+
* heldKeys = injectHeldKeys()
|
|
23
|
+
* heldCodes = injectHeldKeyCodes()
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare function injectHeldKeyCodes(): Signal<Record<string, string>>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { injectHeldKeyCodes };
|
|
30
|
+
//# sourceMappingURL=injectHeldKeyCodes.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
+
import { injectStore } from "@tanstack/angular-store";
|
|
3
|
+
|
|
4
|
+
//#region src/injectHeldKeyCodes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.
|
|
7
|
+
*
|
|
8
|
+
* Useful for debugging which physical key was pressed (e.g. distinguishing
|
|
9
|
+
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
10
|
+
*
|
|
11
|
+
* @returns Signal of record mapping normalized key names to their `event.code` values
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @Component({
|
|
16
|
+
* template: `
|
|
17
|
+
* @for (key of heldKeys(); track key) {
|
|
18
|
+
* <kbd>{{ key }} <small>{{ heldCodes()[key] }}</small></kbd>
|
|
19
|
+
* }
|
|
20
|
+
* `,
|
|
21
|
+
* })
|
|
22
|
+
* export class KeyDebugComponent {
|
|
23
|
+
* heldKeys = injectHeldKeys()
|
|
24
|
+
* heldCodes = injectHeldKeyCodes()
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function injectHeldKeyCodes() {
|
|
29
|
+
return injectStore(getKeyStateTracker().store, (state) => state.heldCodes);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { injectHeldKeyCodes };
|
|
34
|
+
//# sourceMappingURL=injectHeldKeyCodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectHeldKeyCodes.js","names":[],"sources":["../src/injectHeldKeyCodes.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectStore } 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 injectStore(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,qBAAqD;AAEnE,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,UAAU"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
+
let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
3
|
+
|
|
4
|
+
//#region src/injectHeldKeys.ts
|
|
5
|
+
/**
|
|
6
|
+
* Angular inject-based API that returns a signal of currently held keyboard keys.
|
|
7
|
+
*
|
|
8
|
+
* Subscribes to the global KeyStateTracker and updates whenever keys are
|
|
9
|
+
* pressed or released.
|
|
10
|
+
*
|
|
11
|
+
* @returns Signal of array of currently held key names
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @Component({
|
|
16
|
+
* template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
|
|
17
|
+
* })
|
|
18
|
+
* export class KeyDisplayComponent {
|
|
19
|
+
* heldKeys = injectHeldKeys()
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
function injectHeldKeys() {
|
|
24
|
+
return (0, _tanstack_angular_store.injectStore)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldKeys);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.injectHeldKeys = injectHeldKeys;
|
|
29
|
+
//# sourceMappingURL=injectHeldKeys.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectHeldKeys.cjs","names":[],"sources":["../src/injectHeldKeys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectStore } 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 injectStore(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAwC;AAEtD,4FADoC,CACT,QAAQ,UAAU,MAAM,SAAS"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/injectHeldKeys.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Angular inject-based API that returns a signal of currently held keyboard keys.
|
|
6
|
+
*
|
|
7
|
+
* Subscribes to the global KeyStateTracker and updates whenever keys are
|
|
8
|
+
* pressed or released.
|
|
9
|
+
*
|
|
10
|
+
* @returns Signal of array of currently held key names
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* @Component({
|
|
15
|
+
* template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
|
|
16
|
+
* })
|
|
17
|
+
* export class KeyDisplayComponent {
|
|
18
|
+
* heldKeys = injectHeldKeys()
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function injectHeldKeys(): Signal<Array<string>>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { injectHeldKeys };
|
|
25
|
+
//# sourceMappingURL=injectHeldKeys.d.cts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
|
|
3
|
+
//#region src/injectHeldKeys.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Angular inject-based API that returns a signal of currently held keyboard keys.
|
|
6
|
+
*
|
|
7
|
+
* Subscribes to the global KeyStateTracker and updates whenever keys are
|
|
8
|
+
* pressed or released.
|
|
9
|
+
*
|
|
10
|
+
* @returns Signal of array of currently held key names
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* @Component({
|
|
15
|
+
* template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
|
|
16
|
+
* })
|
|
17
|
+
* export class KeyDisplayComponent {
|
|
18
|
+
* heldKeys = injectHeldKeys()
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function injectHeldKeys(): Signal<Array<string>>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { injectHeldKeys };
|
|
25
|
+
//# sourceMappingURL=injectHeldKeys.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
2
|
+
import { injectStore } from "@tanstack/angular-store";
|
|
3
|
+
|
|
4
|
+
//#region src/injectHeldKeys.ts
|
|
5
|
+
/**
|
|
6
|
+
* Angular inject-based API that returns a signal of currently held keyboard keys.
|
|
7
|
+
*
|
|
8
|
+
* Subscribes to the global KeyStateTracker and updates whenever keys are
|
|
9
|
+
* pressed or released.
|
|
10
|
+
*
|
|
11
|
+
* @returns Signal of array of currently held key names
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @Component({
|
|
16
|
+
* template: `<div>Currently pressed: {{ heldKeys().join(' + ') || 'None' }}</div>`,
|
|
17
|
+
* })
|
|
18
|
+
* export class KeyDisplayComponent {
|
|
19
|
+
* heldKeys = injectHeldKeys()
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
function injectHeldKeys() {
|
|
24
|
+
return injectStore(getKeyStateTracker().store, (state) => state.heldKeys);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { injectHeldKeys };
|
|
29
|
+
//# sourceMappingURL=injectHeldKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectHeldKeys.js","names":[],"sources":["../src/injectHeldKeys.ts"],"sourcesContent":["import { getKeyStateTracker } from '@tanstack/hotkeys'\nimport { injectStore } 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 injectStore(tracker.store, (state) => state.heldKeys)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAwC;AAEtD,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,SAAS"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const require_hotkeys_provider = require('./hotkeys-provider.cjs');
|
|
2
|
+
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
3
|
+
let _angular_core = require("@angular/core");
|
|
4
|
+
|
|
5
|
+
//#region src/injectHotkey.ts
|
|
6
|
+
/**
|
|
7
|
+
* Angular inject-based API for registering a keyboard hotkey.
|
|
8
|
+
*
|
|
9
|
+
* Uses the singleton HotkeyManager for efficient event handling.
|
|
10
|
+
* The callback receives both the keyboard event and a context object
|
|
11
|
+
* containing the hotkey string and parsed hotkey.
|
|
12
|
+
*
|
|
13
|
+
* Call in an injection context (e.g. constructor or field initializer).
|
|
14
|
+
* Uses effect() to track reactive dependencies and update registration
|
|
15
|
+
* when options or the callback change.
|
|
16
|
+
*
|
|
17
|
+
* @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function
|
|
18
|
+
* @param callback - The function to call when the hotkey is pressed
|
|
19
|
+
* @param options - Options for the hotkey behavior, or getter for reactive options
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* @Component({ ... })
|
|
24
|
+
* export class SaveButtonComponent {
|
|
25
|
+
* private readonly saveCount = signal(0)
|
|
26
|
+
*
|
|
27
|
+
* constructor() {
|
|
28
|
+
* injectHotkey('Mod+S', (event, { hotkey }) => {
|
|
29
|
+
* event.preventDefault()
|
|
30
|
+
* this.saveCount.update(c => c + 1)
|
|
31
|
+
* })
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* @Component({ ... })
|
|
39
|
+
* export class ModalComponent {
|
|
40
|
+
* isOpen = signal(true)
|
|
41
|
+
*
|
|
42
|
+
* constructor() {
|
|
43
|
+
* injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* @Component({ ... })
|
|
51
|
+
* export class EditorComponent {
|
|
52
|
+
* private readonly editorRef = viewChild<ElementRef<HTMLDivElement>>('editorRef')
|
|
53
|
+
*
|
|
54
|
+
* constructor() {
|
|
55
|
+
* injectHotkey('Mod+B', () => this.toggleBold(), () => ({
|
|
56
|
+
* target: this.editorRef()?.nativeElement ?? null,
|
|
57
|
+
* }))
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
function injectHotkey(hotkey, callback, options = {}) {
|
|
63
|
+
const defaultOptions = require_hotkeys_provider.injectDefaultHotkeysOptions();
|
|
64
|
+
const manager = (0, _tanstack_hotkeys.getHotkeyManager)();
|
|
65
|
+
(0, _angular_core.effect)((onCleanup) => {
|
|
66
|
+
const resolvedHotkey = typeof hotkey === "function" ? hotkey() : hotkey;
|
|
67
|
+
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
68
|
+
const mergedOptions = {
|
|
69
|
+
...defaultOptions.hotkey,
|
|
70
|
+
...resolvedOptions
|
|
71
|
+
};
|
|
72
|
+
const platform = mergedOptions.platform ?? (0, _tanstack_hotkeys.detectPlatform)();
|
|
73
|
+
const hotkeyString = typeof resolvedHotkey === "string" ? resolvedHotkey : (0, _tanstack_hotkeys.formatHotkey)((0, _tanstack_hotkeys.rawHotkeyToParsedHotkey)(resolvedHotkey, platform));
|
|
74
|
+
const resolvedTarget = "target" in mergedOptions ? mergedOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
75
|
+
if (!resolvedTarget) return;
|
|
76
|
+
const { target: _target, ...optionsWithoutTarget } = mergedOptions;
|
|
77
|
+
const registration = manager.register(hotkeyString, callback, {
|
|
78
|
+
...optionsWithoutTarget,
|
|
79
|
+
target: resolvedTarget
|
|
80
|
+
});
|
|
81
|
+
if (registration.isActive) {
|
|
82
|
+
registration.callback = callback;
|
|
83
|
+
registration.setOptions(optionsWithoutTarget);
|
|
84
|
+
}
|
|
85
|
+
onCleanup(() => {
|
|
86
|
+
if (registration.isActive) registration.unregister();
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
exports.injectHotkey = injectHotkey;
|
|
93
|
+
//# sourceMappingURL=injectHotkey.cjs.map
|