@tanstack/angular-hotkeys 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hotkeys-provider.d.ts +7 -10
- package/dist/hotkeys-provider.js +1 -2
- package/dist/injectHeldKeyCodes.d.ts +2 -5
- package/dist/injectHeldKeyCodes.js +3 -3
- package/dist/injectHeldKeys.d.ts +2 -5
- package/dist/injectHeldKeys.js +3 -3
- package/dist/injectHotkey.d.ts +3 -6
- package/dist/injectHotkey.js +3 -3
- package/dist/injectHotkeyHint.d.ts +2 -5
- package/dist/injectHotkeyHint.js +1 -2
- package/dist/injectHotkeyRecorder.d.ts +3 -6
- package/dist/injectHotkeyRecorder.js +4 -4
- package/dist/injectHotkeyRegistrations.d.ts +3 -6
- package/dist/injectHotkeyRegistrations.js +1 -2
- package/dist/injectHotkeySequence.d.ts +3 -6
- package/dist/injectHotkeySequence.js +1 -2
- package/dist/injectHotkeySequenceRecorder.d.ts +3 -6
- package/dist/injectHotkeySequenceRecorder.js +4 -4
- package/dist/injectHotkeySequences.d.ts +3 -6
- package/dist/injectHotkeySequences.js +1 -2
- package/dist/injectHotkeys.d.ts +3 -6
- package/dist/injectHotkeys.js +3 -3
- package/dist/injectKeyHold.d.ts +2 -5
- package/dist/injectKeyHold.js +3 -3
- package/package.json +12 -17
- package/dist/hotkeys-provider.cjs +0 -26
- package/dist/hotkeys-provider.cjs.map +0 -1
- package/dist/hotkeys-provider.d.cts +0 -22
- package/dist/hotkeys-provider.js.map +0 -1
- package/dist/index.cjs +0 -36
- package/dist/index.d.cts +0 -14
- package/dist/injectHeldKeyCodes.cjs +0 -34
- package/dist/injectHeldKeyCodes.cjs.map +0 -1
- package/dist/injectHeldKeyCodes.d.cts +0 -30
- package/dist/injectHeldKeyCodes.js.map +0 -1
- package/dist/injectHeldKeys.cjs +0 -29
- package/dist/injectHeldKeys.cjs.map +0 -1
- package/dist/injectHeldKeys.d.cts +0 -25
- package/dist/injectHeldKeys.js.map +0 -1
- package/dist/injectHotkey.cjs +0 -122
- package/dist/injectHotkey.cjs.map +0 -1
- package/dist/injectHotkey.d.cts +0 -75
- package/dist/injectHotkey.js.map +0 -1
- package/dist/injectHotkeyHint.cjs +0 -20
- package/dist/injectHotkeyHint.cjs.map +0 -1
- package/dist/injectHotkeyHint.d.cts +0 -15
- package/dist/injectHotkeyHint.js.map +0 -1
- package/dist/injectHotkeyRecorder.cjs +0 -82
- package/dist/injectHotkeyRecorder.cjs.map +0 -1
- package/dist/injectHotkeyRecorder.d.cts +0 -49
- package/dist/injectHotkeyRecorder.js.map +0 -1
- package/dist/injectHotkeyRegistrations.cjs +0 -28
- package/dist/injectHotkeyRegistrations.cjs.map +0 -1
- package/dist/injectHotkeyRegistrations.d.cts +0 -29
- package/dist/injectHotkeyRegistrations.js.map +0 -1
- package/dist/injectHotkeySequence.cjs +0 -93
- package/dist/injectHotkeySequence.cjs.map +0 -1
- package/dist/injectHotkeySequence.d.cts +0 -48
- package/dist/injectHotkeySequence.js.map +0 -1
- package/dist/injectHotkeySequenceRecorder.cjs +0 -58
- package/dist/injectHotkeySequenceRecorder.cjs.map +0 -1
- package/dist/injectHotkeySequenceRecorder.d.cts +0 -19
- package/dist/injectHotkeySequenceRecorder.js.map +0 -1
- package/dist/injectHotkeySequences.cjs +0 -105
- package/dist/injectHotkeySequences.cjs.map +0 -1
- package/dist/injectHotkeySequences.d.cts +0 -47
- package/dist/injectHotkeySequences.js.map +0 -1
- package/dist/injectHotkeys.cjs +0 -120
- package/dist/injectHotkeys.cjs.map +0 -1
- package/dist/injectHotkeys.d.cts +0 -66
- package/dist/injectHotkeys.js.map +0 -1
- package/dist/injectKeyHold.cjs +0 -49
- package/dist/injectKeyHold.cjs.map +0 -1
- package/dist/injectKeyHold.d.cts +0 -41
- package/dist/injectKeyHold.js.map +0 -1
- package/src/hotkeys-provider.ts +0 -44
- package/src/index.ts +0 -18
- package/src/injectHeldKeyCodes.ts +0 -31
- package/src/injectHeldKeys.ts +0 -26
- package/src/injectHotkey.ts +0 -171
- package/src/injectHotkeyHint.ts +0 -29
- package/src/injectHotkeyRecorder.ts +0 -128
- package/src/injectHotkeyRegistrations.ts +0 -48
- package/src/injectHotkeySequence.ts +0 -140
- package/src/injectHotkeySequenceRecorder.ts +0 -103
- package/src/injectHotkeySequences.ts +0 -176
- package/src/injectHotkeys.ts +0 -189
- package/src/injectKeyHold.ts +0 -57
|
@@ -2,21 +2,18 @@ import { InjectHotkeyOptions } from "./injectHotkey.js";
|
|
|
2
2
|
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.js";
|
|
3
3
|
import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
4
4
|
import { InjectionToken, StaticProvider } from "@angular/core";
|
|
5
|
-
|
|
6
5
|
//#region src/hotkeys-provider.d.ts
|
|
7
|
-
interface HotkeysProviderOptions {
|
|
6
|
+
export interface HotkeysProviderOptions {
|
|
8
7
|
hotkey?: Partial<InjectHotkeyOptions>;
|
|
9
8
|
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
10
9
|
hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
|
|
11
10
|
hotkeySequence?: Partial<InjectHotkeySequenceOptions>;
|
|
12
11
|
}
|
|
13
|
-
interface HotkeysContextValue {
|
|
12
|
+
export interface HotkeysContextValue {
|
|
14
13
|
readonly defaultOptions: HotkeysProviderOptions;
|
|
15
14
|
}
|
|
16
|
-
declare const HOTKEYS_INJECTION_TOKEN: InjectionToken<HotkeysContextValue>;
|
|
17
|
-
declare function provideHotkeys(defaultOptions: HotkeysProviderOptions): StaticProvider;
|
|
18
|
-
declare function injectHotkeysContext(): HotkeysContextValue;
|
|
19
|
-
declare function injectDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
22
|
-
//# sourceMappingURL=hotkeys-provider.d.ts.map
|
|
15
|
+
export declare const HOTKEYS_INJECTION_TOKEN: InjectionToken<HotkeysContextValue>;
|
|
16
|
+
export declare function provideHotkeys(defaultOptions: HotkeysProviderOptions): StaticProvider;
|
|
17
|
+
export declare function injectHotkeysContext(): HotkeysContextValue;
|
|
18
|
+
export declare function injectDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
19
|
+
//#endregion
|
package/dist/hotkeys-provider.js
CHANGED
|
@@ -19,5 +19,4 @@ function injectDefaultHotkeysOptions() {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
|
-
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
23
|
-
//# sourceMappingURL=hotkeys-provider.js.map
|
|
22
|
+
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Signal } from "@angular/core";
|
|
2
|
-
|
|
3
2
|
//#region src/injectHeldKeyCodes.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Angular inject-based API that returns a signal of a map from held key names to their physical `event.code` values.
|
|
@@ -24,7 +23,5 @@ import { Signal } from "@angular/core";
|
|
|
24
23
|
* }
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
declare function injectHeldKeyCodes(): Signal<Record<string, string>>;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { injectHeldKeyCodes };
|
|
30
|
-
//# sourceMappingURL=injectHeldKeyCodes.d.ts.map
|
|
26
|
+
export declare function injectHeldKeyCodes(): Signal<Record<string, string>>;
|
|
27
|
+
//#endregion
|
|
@@ -26,9 +26,9 @@ import { injectSelector } from "@tanstack/angular-store";
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
function injectHeldKeyCodes() {
|
|
29
|
-
|
|
29
|
+
const tracker = getKeyStateTracker();
|
|
30
|
+
return injectSelector(tracker.store, (state) => state.heldCodes);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
//#endregion
|
|
33
|
-
export { injectHeldKeyCodes };
|
|
34
|
-
//# sourceMappingURL=injectHeldKeyCodes.js.map
|
|
34
|
+
export { injectHeldKeyCodes };
|
package/dist/injectHeldKeys.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Signal } from "@angular/core";
|
|
2
|
-
|
|
3
2
|
//#region src/injectHeldKeys.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Angular inject-based API that returns a signal of currently held keyboard keys.
|
|
@@ -19,7 +18,5 @@ import { Signal } from "@angular/core";
|
|
|
19
18
|
* }
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
|
-
declare function injectHeldKeys(): Signal<Array<string>>;
|
|
23
|
-
//#endregion
|
|
24
|
-
export { injectHeldKeys };
|
|
25
|
-
//# sourceMappingURL=injectHeldKeys.d.ts.map
|
|
21
|
+
export declare function injectHeldKeys(): Signal<Array<string>>;
|
|
22
|
+
//#endregion
|
package/dist/injectHeldKeys.js
CHANGED
|
@@ -21,9 +21,9 @@ import { injectSelector } from "@tanstack/angular-store";
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
function injectHeldKeys() {
|
|
24
|
-
|
|
24
|
+
const tracker = getKeyStateTracker();
|
|
25
|
+
return injectSelector(tracker.store, (state) => state.heldKeys);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
//#endregion
|
|
28
|
-
export { injectHeldKeys };
|
|
29
|
-
//# sourceMappingURL=injectHeldKeys.js.map
|
|
29
|
+
export { injectHeldKeys };
|
package/dist/injectHotkey.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HotkeyCallback, HotkeyOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/injectHotkey.d.ts
|
|
4
|
-
interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
3
|
+
export interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
5
4
|
/**
|
|
6
5
|
* The DOM element to attach the event listener to.
|
|
7
6
|
* Can be a direct DOM element, an accessor (for reactive targets that become
|
|
@@ -69,7 +68,5 @@ interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
|
69
68
|
* }
|
|
70
69
|
* ```
|
|
71
70
|
*/
|
|
72
|
-
declare function injectHotkey(hotkey: RegisterableHotkey | (() => RegisterableHotkey), callback: HotkeyCallback, options?: InjectHotkeyOptions | (() => InjectHotkeyOptions)): void;
|
|
73
|
-
//#endregion
|
|
74
|
-
export { InjectHotkeyOptions, injectHotkey };
|
|
75
|
-
//# sourceMappingURL=injectHotkey.d.ts.map
|
|
71
|
+
export declare function injectHotkey(hotkey: RegisterableHotkey | (() => RegisterableHotkey), callback: HotkeyCallback, options?: InjectHotkeyOptions | (() => InjectHotkeyOptions)): void;
|
|
72
|
+
//#endregion
|
package/dist/injectHotkey.js
CHANGED
|
@@ -83,7 +83,8 @@ function injectHotkey(hotkey, callback, options = {}) {
|
|
|
83
83
|
...defaultOptions.hotkey,
|
|
84
84
|
...resolvedOptions
|
|
85
85
|
};
|
|
86
|
-
const
|
|
86
|
+
const platform = mergedOptions.platform ?? detectPlatform();
|
|
87
|
+
const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, platform);
|
|
87
88
|
const resolvedTarget = "target" in mergedOptions ? mergedOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
88
89
|
if (!resolvedTarget) {
|
|
89
90
|
if (registration?.isActive) {
|
|
@@ -118,5 +119,4 @@ function injectHotkey(hotkey, callback, options = {}) {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
//#endregion
|
|
121
|
-
export { injectHotkey };
|
|
122
|
-
//# sourceMappingURL=injectHotkey.js.map
|
|
122
|
+
export { injectHotkey };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
2
|
import { Signal } from "@angular/core";
|
|
3
|
-
|
|
4
3
|
//#region src/injectHotkeyHint.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Returns a computed signal indicating whether held modifiers reveal this shortcut.
|
|
@@ -9,7 +8,5 @@ import { Signal } from "@angular/core";
|
|
|
9
8
|
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
10
9
|
* This helper does not register a shortcut or check whether its target is focused.
|
|
11
10
|
*/
|
|
12
|
-
declare function injectHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): Signal<boolean>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { injectHotkeyHint };
|
|
15
|
-
//# sourceMappingURL=injectHotkeyHint.d.ts.map
|
|
11
|
+
export declare function injectHotkeyHint(hotkey: RegisterableHotkey | (() => RegisterableHotkey), options?: HeldModifierOptions | (() => HeldModifierOptions)): Signal<boolean>;
|
|
12
|
+
//#endregion
|
package/dist/injectHotkeyHint.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/injectHotkeyRecorder.d.ts
|
|
4
|
-
interface AngularHotkeyRecorder {
|
|
3
|
+
export interface AngularHotkeyRecorder {
|
|
5
4
|
/** Whether recording is currently active */
|
|
6
5
|
readonly isRecording: () => boolean;
|
|
7
6
|
/** The currently recorded hotkey (for live preview) */
|
|
@@ -43,7 +42,5 @@ interface AngularHotkeyRecorder {
|
|
|
43
42
|
* }
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
declare function injectHotkeyRecorder(options: HotkeyRecorderOptions | (() => HotkeyRecorderOptions)): AngularHotkeyRecorder;
|
|
47
|
-
//#endregion
|
|
48
|
-
export { AngularHotkeyRecorder, injectHotkeyRecorder };
|
|
49
|
-
//# sourceMappingURL=injectHotkeyRecorder.d.ts.map
|
|
45
|
+
export declare function injectHotkeyRecorder(options: HotkeyRecorderOptions | (() => HotkeyRecorderOptions)): AngularHotkeyRecorder;
|
|
46
|
+
//#endregion
|
|
@@ -38,10 +38,11 @@ function injectHotkeyRecorder(options) {
|
|
|
38
38
|
const destroyRef = inject(DestroyRef);
|
|
39
39
|
const recorderSignal = computed(() => untracked(() => {
|
|
40
40
|
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
41
|
-
|
|
41
|
+
const mergedOptions = {
|
|
42
42
|
...defaultOptions.hotkeyRecorder,
|
|
43
43
|
...resolvedOptions
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
|
+
return new HotkeyRecorder(mergedOptions);
|
|
45
46
|
}));
|
|
46
47
|
const recorderStore = computed(() => untracked(() => recorderSignal().store));
|
|
47
48
|
const isRecording = injectLazyStore(recorderStore, (state) => state.isRecording);
|
|
@@ -78,5 +79,4 @@ function injectLazyStore(storeSignal, selector) {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
//#endregion
|
|
81
|
-
export { injectHotkeyRecorder };
|
|
82
|
-
//# sourceMappingURL=injectHotkeyRecorder.js.map
|
|
82
|
+
export { injectHotkeyRecorder };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { HotkeyRegistrationView, SequenceRegistrationView } from "@tanstack/hotkeys";
|
|
2
2
|
import { Signal } from "@angular/core";
|
|
3
|
-
|
|
4
3
|
//#region src/injectHotkeyRegistrations.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Return type for injectHotkeyRegistrations.
|
|
7
6
|
*/
|
|
8
|
-
interface HotkeyRegistrationsResult {
|
|
7
|
+
export interface HotkeyRegistrationsResult {
|
|
9
8
|
/** Signal for all registered hotkeys (public view, no callbacks) */
|
|
10
9
|
hotkeys: Signal<Array<HotkeyRegistrationView>>;
|
|
11
10
|
/** Signal for all registered sequences */
|
|
@@ -23,7 +22,5 @@ interface HotkeyRegistrationsResult {
|
|
|
23
22
|
*
|
|
24
23
|
* @returns Object with `hotkeys` and `sequences` signals
|
|
25
24
|
*/
|
|
26
|
-
declare function injectHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { HotkeyRegistrationsResult, injectHotkeyRegistrations };
|
|
29
|
-
//# sourceMappingURL=injectHotkeyRegistrations.d.ts.map
|
|
25
|
+
export declare function injectHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
26
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/injectHotkeySequence.d.ts
|
|
4
|
-
interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'target'> {
|
|
3
|
+
export interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'target'> {
|
|
5
4
|
/** Whether the sequence is enabled. Defaults to true. */
|
|
6
5
|
enabled?: boolean;
|
|
7
6
|
/**
|
|
@@ -42,7 +41,5 @@ interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' |
|
|
|
42
41
|
* }
|
|
43
42
|
* ```
|
|
44
43
|
*/
|
|
45
|
-
declare function injectHotkeySequence(sequence: HotkeySequence | (() => HotkeySequence), callback: HotkeyCallback, options?: InjectHotkeySequenceOptions | (() => InjectHotkeySequenceOptions)): void;
|
|
46
|
-
//#endregion
|
|
47
|
-
export { InjectHotkeySequenceOptions, injectHotkeySequence };
|
|
48
|
-
//# sourceMappingURL=injectHotkeySequence.d.ts.map
|
|
44
|
+
export declare function injectHotkeySequence(sequence: HotkeySequence | (() => HotkeySequence), callback: HotkeyCallback, options?: InjectHotkeySequenceOptions | (() => InjectHotkeySequenceOptions)): void;
|
|
45
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/injectHotkeySequenceRecorder.d.ts
|
|
4
|
-
interface AngularHotkeySequenceRecorder {
|
|
3
|
+
export interface AngularHotkeySequenceRecorder {
|
|
5
4
|
readonly isRecording: () => boolean;
|
|
6
5
|
readonly steps: () => HotkeySequence;
|
|
7
6
|
readonly recordedSequence: () => HotkeySequence | null;
|
|
@@ -13,7 +12,5 @@ interface AngularHotkeySequenceRecorder {
|
|
|
13
12
|
/**
|
|
14
13
|
* Angular inject-based API for recording multi-chord sequences.
|
|
15
14
|
*/
|
|
16
|
-
declare function injectHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions | (() => HotkeySequenceRecorderOptions)): AngularHotkeySequenceRecorder;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { AngularHotkeySequenceRecorder, injectHotkeySequenceRecorder };
|
|
19
|
-
//# sourceMappingURL=injectHotkeySequenceRecorder.d.ts.map
|
|
15
|
+
export declare function injectHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions | (() => HotkeySequenceRecorderOptions)): AngularHotkeySequenceRecorder;
|
|
16
|
+
//#endregion
|
|
@@ -11,10 +11,11 @@ function injectHotkeySequenceRecorder(options) {
|
|
|
11
11
|
const destroyRef = inject(DestroyRef);
|
|
12
12
|
const recorderSignal = computed(() => untracked(() => {
|
|
13
13
|
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
14
|
-
|
|
14
|
+
const mergedOptions = {
|
|
15
15
|
...defaultOptions.hotkeySequenceRecorder,
|
|
16
16
|
...resolvedOptions
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
|
+
return new HotkeySequenceRecorder(mergedOptions);
|
|
18
19
|
}));
|
|
19
20
|
const recorderStore = computed(() => untracked(() => recorderSignal().store));
|
|
20
21
|
const isRecording = injectLazyStore(recorderStore, (state) => state.isRecording);
|
|
@@ -54,5 +55,4 @@ function injectLazyStore(storeSignal, selector) {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
//#endregion
|
|
57
|
-
export { injectHotkeySequenceRecorder };
|
|
58
|
-
//# sourceMappingURL=injectHotkeySequenceRecorder.js.map
|
|
58
|
+
export { injectHotkeySequenceRecorder };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.js";
|
|
2
2
|
import { HotkeyCallback, HotkeySequence } from "@tanstack/hotkeys";
|
|
3
|
-
|
|
4
3
|
//#region src/injectHotkeySequences.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A single sequence definition for use with `injectHotkeySequences`.
|
|
7
6
|
*/
|
|
8
|
-
interface InjectHotkeySequenceDefinition {
|
|
7
|
+
export interface InjectHotkeySequenceDefinition {
|
|
9
8
|
/** Array of hotkey strings that form the sequence */
|
|
10
9
|
sequence: HotkeySequence | (() => HotkeySequence);
|
|
11
10
|
/** The function to call when the sequence is completed */
|
|
@@ -41,7 +40,5 @@ interface InjectHotkeySequenceDefinition {
|
|
|
41
40
|
* }
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
44
|
-
declare function injectHotkeySequences(sequences: Array<InjectHotkeySequenceDefinition> | (() => Array<InjectHotkeySequenceDefinition>), commonOptions?: InjectHotkeySequenceOptions | (() => InjectHotkeySequenceOptions)): void;
|
|
45
|
-
//#endregion
|
|
46
|
-
export { InjectHotkeySequenceDefinition, injectHotkeySequences };
|
|
47
|
-
//# sourceMappingURL=injectHotkeySequences.d.ts.map
|
|
43
|
+
export declare function injectHotkeySequences(sequences: Array<InjectHotkeySequenceDefinition> | (() => Array<InjectHotkeySequenceDefinition>), commonOptions?: InjectHotkeySequenceOptions | (() => InjectHotkeySequenceOptions)): void;
|
|
44
|
+
//#endregion
|
package/dist/injectHotkeys.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { InjectHotkeyOptions } from "./injectHotkey.js";
|
|
2
2
|
import { HotkeyCallback, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
3
|
-
|
|
4
3
|
//#region src/injectHotkeys.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A single hotkey definition for use with `injectHotkeys`.
|
|
7
6
|
*/
|
|
8
|
-
interface InjectHotkeyDefinition {
|
|
7
|
+
export interface InjectHotkeyDefinition {
|
|
9
8
|
/** The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object */
|
|
10
9
|
hotkey: RegisterableHotkey | (() => RegisterableHotkey);
|
|
11
10
|
/** The function to call when the hotkey is pressed */
|
|
@@ -60,7 +59,5 @@ interface InjectHotkeyDefinition {
|
|
|
60
59
|
* }
|
|
61
60
|
* ```
|
|
62
61
|
*/
|
|
63
|
-
declare function injectHotkeys(hotkeys: Array<InjectHotkeyDefinition> | (() => Array<InjectHotkeyDefinition>), commonOptions?: InjectHotkeyOptions | (() => InjectHotkeyOptions)): void;
|
|
64
|
-
//#endregion
|
|
65
|
-
export { InjectHotkeyDefinition, injectHotkeys };
|
|
66
|
-
//# sourceMappingURL=injectHotkeys.d.ts.map
|
|
62
|
+
export declare function injectHotkeys(hotkeys: Array<InjectHotkeyDefinition> | (() => Array<InjectHotkeyDefinition>), commonOptions?: InjectHotkeyOptions | (() => InjectHotkeyOptions)): void;
|
|
63
|
+
//#endregion
|
package/dist/injectHotkeys.js
CHANGED
|
@@ -73,7 +73,8 @@ function injectHotkeys(hotkeys, commonOptions = {}) {
|
|
|
73
73
|
...resolvedCommonOptions,
|
|
74
74
|
...resolvedDefOptions
|
|
75
75
|
};
|
|
76
|
-
const
|
|
76
|
+
const platform = mergedOptions.platform ?? detectPlatform();
|
|
77
|
+
const hotkeyString = normalizeRegisterableHotkey(resolvedHotkey, platform);
|
|
77
78
|
const resolvedTarget = "target" in mergedOptions ? mergedOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
78
79
|
if (!resolvedTarget) continue;
|
|
79
80
|
const registrationKey = `${i}:${hotkeyString}`;
|
|
@@ -116,5 +117,4 @@ function injectHotkeys(hotkeys, commonOptions = {}) {
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
//#endregion
|
|
119
|
-
export { injectHotkeys };
|
|
120
|
-
//# sourceMappingURL=injectHotkeys.js.map
|
|
120
|
+
export { injectHotkeys };
|
package/dist/injectKeyHold.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IndividualKey } from "@tanstack/hotkeys";
|
|
2
2
|
import { Signal } from "@angular/core";
|
|
3
|
-
|
|
4
3
|
//#region src/injectKeyHold.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Angular inject-based API that returns a signal that is true when the given key is held.
|
|
@@ -35,7 +34,5 @@ import { Signal } from "@angular/core";
|
|
|
35
34
|
* }
|
|
36
35
|
* ```
|
|
37
36
|
*/
|
|
38
|
-
declare function injectKeyHold(key: IndividualKey | (() => IndividualKey)): Signal<boolean>;
|
|
39
|
-
//#endregion
|
|
40
|
-
export { injectKeyHold };
|
|
41
|
-
//# sourceMappingURL=injectKeyHold.d.ts.map
|
|
37
|
+
export declare function injectKeyHold(key: IndividualKey | (() => IndividualKey)): Signal<boolean>;
|
|
38
|
+
//#endregion
|
package/dist/injectKeyHold.js
CHANGED
|
@@ -37,7 +37,8 @@ import { injectSelector } from "@tanstack/angular-store";
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
function injectKeyHold(key) {
|
|
40
|
-
const
|
|
40
|
+
const tracker = getKeyStateTracker();
|
|
41
|
+
const heldKeysSelector = injectSelector(tracker.store, (state) => state.heldKeys);
|
|
41
42
|
return computed(() => {
|
|
42
43
|
const normalizedKey = (typeof key === "function" ? key() : key).toLowerCase();
|
|
43
44
|
return heldKeysSelector().some((heldKey) => heldKey.toLowerCase() === normalizedKey);
|
|
@@ -45,5 +46,4 @@ function injectKeyHold(key) {
|
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
//#endregion
|
|
48
|
-
export { injectKeyHold };
|
|
49
|
-
//# sourceMappingURL=injectKeyHold.js.map
|
|
49
|
+
export { injectKeyHold };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/angular-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Angular adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,36 +22,30 @@
|
|
|
22
22
|
"shortcuts"
|
|
23
23
|
],
|
|
24
24
|
"type": "module",
|
|
25
|
-
"
|
|
26
|
-
"module": "./dist/index.js",
|
|
27
|
-
"types": "./dist/index.d.cts",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
28
26
|
"exports": {
|
|
29
|
-
".":
|
|
30
|
-
"import": "./dist/index.js",
|
|
31
|
-
"require": "./dist/index.cjs"
|
|
32
|
-
},
|
|
27
|
+
".": "./dist/index.js",
|
|
33
28
|
"./package.json": "./package.json"
|
|
34
29
|
},
|
|
35
30
|
"sideEffects": false,
|
|
36
31
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
32
|
+
"node": ">=20"
|
|
38
33
|
},
|
|
39
34
|
"files": [
|
|
40
|
-
"dist"
|
|
41
|
-
"src"
|
|
35
|
+
"dist"
|
|
42
36
|
],
|
|
43
37
|
"dependencies": {
|
|
44
|
-
"@tanstack/angular-store": "^0.11.
|
|
45
|
-
"@tanstack/hotkeys": "0.
|
|
38
|
+
"@tanstack/angular-store": "^0.11.1",
|
|
39
|
+
"@tanstack/hotkeys": "0.10.1"
|
|
46
40
|
},
|
|
47
41
|
"peerDependencies": {
|
|
48
42
|
"@angular/common": ">=19.0.0",
|
|
49
43
|
"@angular/core": ">=19.0.0"
|
|
50
44
|
},
|
|
51
45
|
"devDependencies": {
|
|
52
|
-
"@angular/common": "^
|
|
53
|
-
"@angular/core": "^
|
|
54
|
-
"@angular/platform-browser-dynamic": "^
|
|
46
|
+
"@angular/common": "^22.1.7",
|
|
47
|
+
"@angular/core": "^22.1.7",
|
|
48
|
+
"@angular/platform-browser-dynamic": "^22.1.7",
|
|
55
49
|
"typescript": "6.0.3"
|
|
56
50
|
},
|
|
57
51
|
"scripts": {
|
|
@@ -62,6 +56,7 @@
|
|
|
62
56
|
"test:lib": "vitest --passWithNoTests",
|
|
63
57
|
"test:lib:dev": "pnpm test:lib --watch",
|
|
64
58
|
"test:types": "tsc",
|
|
65
|
-
"build": "tsdown"
|
|
59
|
+
"build": "tsdown",
|
|
60
|
+
"test:build": "publint --strict && node ../../scripts/verify-package.ts"
|
|
66
61
|
}
|
|
67
62
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys-provider.cjs","names":["InjectionToken"],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} 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 hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\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":";;;AAoBA,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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { InjectHotkeyOptions } from "./injectHotkey.cjs";
|
|
2
|
-
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.cjs";
|
|
3
|
-
import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } 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
|
-
hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
|
|
11
|
-
hotkeySequence?: Partial<InjectHotkeySequenceOptions>;
|
|
12
|
-
}
|
|
13
|
-
interface HotkeysContextValue {
|
|
14
|
-
readonly defaultOptions: HotkeysProviderOptions;
|
|
15
|
-
}
|
|
16
|
-
declare const HOTKEYS_INJECTION_TOKEN: InjectionToken<HotkeysContextValue>;
|
|
17
|
-
declare function provideHotkeys(defaultOptions: HotkeysProviderOptions): StaticProvider;
|
|
18
|
-
declare function injectHotkeysContext(): HotkeysContextValue;
|
|
19
|
-
declare function injectDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys };
|
|
22
|
-
//# sourceMappingURL=hotkeys-provider.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys-provider.js","names":[],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} 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 hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\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":";;;AAoBA,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
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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_injectHotkeys = require('./injectHotkeys.cjs');
|
|
5
|
-
const require_injectHotkeySequence = require('./injectHotkeySequence.cjs');
|
|
6
|
-
const require_injectHotkeySequences = require('./injectHotkeySequences.cjs');
|
|
7
|
-
const require_injectHeldKeys = require('./injectHeldKeys.cjs');
|
|
8
|
-
const require_injectHeldKeyCodes = require('./injectHeldKeyCodes.cjs');
|
|
9
|
-
const require_injectKeyHold = require('./injectKeyHold.cjs');
|
|
10
|
-
const require_injectHotkeyRecorder = require('./injectHotkeyRecorder.cjs');
|
|
11
|
-
const require_injectHotkeyRegistrations = require('./injectHotkeyRegistrations.cjs');
|
|
12
|
-
const require_injectHotkeySequenceRecorder = require('./injectHotkeySequenceRecorder.cjs');
|
|
13
|
-
const require_injectHotkeyHint = require('./injectHotkeyHint.cjs');
|
|
14
|
-
|
|
15
|
-
exports.HOTKEYS_INJECTION_TOKEN = require_hotkeys_provider.HOTKEYS_INJECTION_TOKEN;
|
|
16
|
-
exports.injectDefaultHotkeysOptions = require_hotkeys_provider.injectDefaultHotkeysOptions;
|
|
17
|
-
exports.injectHeldKeyCodes = require_injectHeldKeyCodes.injectHeldKeyCodes;
|
|
18
|
-
exports.injectHeldKeys = require_injectHeldKeys.injectHeldKeys;
|
|
19
|
-
exports.injectHotkey = require_injectHotkey.injectHotkey;
|
|
20
|
-
exports.injectHotkeyHint = require_injectHotkeyHint.injectHotkeyHint;
|
|
21
|
-
exports.injectHotkeyRecorder = require_injectHotkeyRecorder.injectHotkeyRecorder;
|
|
22
|
-
exports.injectHotkeyRegistrations = require_injectHotkeyRegistrations.injectHotkeyRegistrations;
|
|
23
|
-
exports.injectHotkeySequence = require_injectHotkeySequence.injectHotkeySequence;
|
|
24
|
-
exports.injectHotkeySequenceRecorder = require_injectHotkeySequenceRecorder.injectHotkeySequenceRecorder;
|
|
25
|
-
exports.injectHotkeySequences = require_injectHotkeySequences.injectHotkeySequences;
|
|
26
|
-
exports.injectHotkeys = require_injectHotkeys.injectHotkeys;
|
|
27
|
-
exports.injectHotkeysContext = require_hotkeys_provider.injectHotkeysContext;
|
|
28
|
-
exports.injectKeyHold = require_injectKeyHold.injectKeyHold;
|
|
29
|
-
exports.provideHotkeys = require_hotkeys_provider.provideHotkeys;
|
|
30
|
-
var _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
31
|
-
Object.keys(_tanstack_hotkeys).forEach(function (k) {
|
|
32
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () { return _tanstack_hotkeys[k]; }
|
|
35
|
-
});
|
|
36
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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 { InjectHotkeyDefinition, injectHotkeys } from "./injectHotkeys.cjs";
|
|
5
|
-
import { InjectHotkeySequenceDefinition, injectHotkeySequences } from "./injectHotkeySequences.cjs";
|
|
6
|
-
import { injectHeldKeys } from "./injectHeldKeys.cjs";
|
|
7
|
-
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.cjs";
|
|
8
|
-
import { injectKeyHold } from "./injectKeyHold.cjs";
|
|
9
|
-
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.cjs";
|
|
10
|
-
import { HotkeyRegistrationsResult, injectHotkeyRegistrations } from "./injectHotkeyRegistrations.cjs";
|
|
11
|
-
import { AngularHotkeySequenceRecorder, injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.cjs";
|
|
12
|
-
import { injectHotkeyHint } from "./injectHotkeyHint.cjs";
|
|
13
|
-
export * from "@tanstack/hotkeys";
|
|
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 };
|
|
@@ -1,34 +0,0 @@
|
|
|
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.injectSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
exports.injectHeldKeyCodes = injectHeldKeyCodes;
|
|
34
|
-
//# sourceMappingURL=injectHeldKeyCodes.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|