@tanstack/preact-hotkeys 0.11.0 → 0.12.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/dist/HotkeysProvider.d.ts +6 -13
- package/dist/HotkeysProvider.js +1 -2
- package/dist/useHeldKeyCodes.d.ts +2 -4
- package/dist/useHeldKeyCodes.js +3 -3
- package/dist/useHeldKeys.d.ts +2 -4
- package/dist/useHeldKeys.js +3 -3
- package/dist/useHotkey.d.ts +3 -6
- package/dist/useHotkey.js +3 -3
- package/dist/useHotkeyHint.d.ts +2 -5
- package/dist/useHotkeyHint.js +1 -2
- package/dist/useHotkeyRecorder.d.ts +3 -6
- package/dist/useHotkeyRecorder.js +1 -2
- package/dist/useHotkeyRegistrations.d.ts +3 -6
- package/dist/useHotkeyRegistrations.js +1 -2
- package/dist/useHotkeySequence.d.ts +3 -6
- package/dist/useHotkeySequence.js +1 -2
- package/dist/useHotkeySequenceRecorder.d.ts +3 -6
- package/dist/useHotkeySequenceRecorder.js +1 -2
- package/dist/useHotkeySequences.d.ts +3 -6
- package/dist/useHotkeySequences.js +1 -2
- package/dist/useHotkeys.d.ts +3 -6
- package/dist/useHotkeys.js +1 -2
- package/dist/useKeyHold.d.ts +2 -5
- package/dist/useKeyHold.js +1 -2
- package/dist/utils.js +1 -2
- package/package.json +11 -16
- package/dist/HotkeysProvider.cjs +0 -26
- package/dist/HotkeysProvider.cjs.map +0 -1
- package/dist/HotkeysProvider.d.cts +0 -29
- package/dist/HotkeysProvider.js.map +0 -1
- package/dist/index.cjs +0 -35
- package/dist/index.d.cts +0 -14
- package/dist/useHeldKeyCodes.cjs +0 -37
- package/dist/useHeldKeyCodes.cjs.map +0 -1
- package/dist/useHeldKeyCodes.d.cts +0 -31
- package/dist/useHeldKeyCodes.js.map +0 -1
- package/dist/useHeldKeys.cjs +0 -33
- package/dist/useHeldKeys.cjs.map +0 -1
- package/dist/useHeldKeys.d.cts +0 -27
- package/dist/useHeldKeys.js.map +0 -1
- package/dist/useHotkey.cjs +0 -125
- package/dist/useHotkey.cjs.map +0 -1
- package/dist/useHotkey.d.cts +0 -75
- package/dist/useHotkey.js.map +0 -1
- package/dist/useHotkeyHint.cjs +0 -18
- package/dist/useHotkeyHint.cjs.map +0 -1
- package/dist/useHotkeyHint.d.cts +0 -14
- package/dist/useHotkeyHint.js.map +0 -1
- package/dist/useHotkeyRecorder.cjs +0 -71
- package/dist/useHotkeyRecorder.cjs.map +0 -1
- package/dist/useHotkeyRecorder.d.cts +0 -57
- package/dist/useHotkeyRecorder.js.map +0 -1
- package/dist/useHotkeyRegistrations.cjs +0 -29
- package/dist/useHotkeyRegistrations.cjs.map +0 -1
- package/dist/useHotkeyRegistrations.d.cts +0 -26
- package/dist/useHotkeyRegistrations.js.map +0 -1
- package/dist/useHotkeySequence.cjs +0 -120
- package/dist/useHotkeySequence.cjs.map +0 -1
- package/dist/useHotkeySequence.d.cts +0 -59
- package/dist/useHotkeySequence.js.map +0 -1
- package/dist/useHotkeySequenceRecorder.cjs +0 -39
- package/dist/useHotkeySequenceRecorder.cjs.map +0 -1
- package/dist/useHotkeySequenceRecorder.d.cts +0 -19
- package/dist/useHotkeySequenceRecorder.js.map +0 -1
- package/dist/useHotkeySequences.cjs +0 -126
- package/dist/useHotkeySequences.cjs.map +0 -1
- package/dist/useHotkeySequences.d.cts +0 -63
- package/dist/useHotkeySequences.js.map +0 -1
- package/dist/useHotkeys.cjs +0 -124
- package/dist/useHotkeys.cjs.map +0 -1
- package/dist/useHotkeys.d.cts +0 -63
- package/dist/useHotkeys.js.map +0 -1
- package/dist/useKeyHold.cjs +0 -53
- package/dist/useKeyHold.cjs.map +0 -1
- package/dist/useKeyHold.d.cts +0 -47
- package/dist/useKeyHold.js.map +0 -1
- package/dist/utils.cjs +0 -12
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
- package/src/HotkeysProvider.tsx +0 -56
- package/src/index.ts +0 -18
- package/src/useHeldKeyCodes.ts +0 -33
- package/src/useHeldKeys.ts +0 -29
- package/src/useHotkey.ts +0 -191
- package/src/useHotkeyHint.ts +0 -19
- package/src/useHotkeyRecorder.ts +0 -101
- package/src/useHotkeyRegistrations.ts +0 -51
- package/src/useHotkeySequence.ts +0 -192
- package/src/useHotkeySequenceRecorder.ts +0 -64
- package/src/useHotkeySequences.ts +0 -192
- package/src/useHotkeys.ts +0 -193
- package/src/useKeyHold.ts +0 -52
- package/src/utils.ts +0 -8
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { UseHotkeyOptions } from "./useHotkey.js";
|
|
2
2
|
import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
|
|
3
3
|
import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
4
|
-
import * as _$preact from "preact";
|
|
5
4
|
import { ComponentChildren } from "preact";
|
|
6
|
-
|
|
7
5
|
//#region src/HotkeysProvider.d.ts
|
|
8
|
-
interface HotkeysProviderOptions {
|
|
6
|
+
export interface HotkeysProviderOptions {
|
|
9
7
|
hotkey?: Partial<UseHotkeyOptions>;
|
|
10
8
|
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
11
9
|
hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
|
|
@@ -14,16 +12,11 @@ interface HotkeysProviderOptions {
|
|
|
14
12
|
interface HotkeysContextValue {
|
|
15
13
|
defaultOptions: HotkeysProviderOptions;
|
|
16
14
|
}
|
|
17
|
-
interface HotkeysProviderProps {
|
|
15
|
+
export interface HotkeysProviderProps {
|
|
18
16
|
children: ComponentChildren;
|
|
19
17
|
defaultOptions?: HotkeysProviderOptions;
|
|
20
18
|
}
|
|
21
|
-
declare function HotkeysProvider({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
26
|
-
declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
|
|
29
|
-
//# sourceMappingURL=HotkeysProvider.d.ts.map
|
|
19
|
+
export declare function HotkeysProvider({ children, defaultOptions }: HotkeysProviderProps): import("preact").JSX.Element;
|
|
20
|
+
export declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
21
|
+
export declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
22
|
+
//#endregion
|
package/dist/HotkeysProvider.js
CHANGED
|
@@ -25,7 +25,5 @@
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
declare function useHeldKeyCodes(): Record<string, string>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { useHeldKeyCodes };
|
|
31
|
-
//# sourceMappingURL=useHeldKeyCodes.d.ts.map
|
|
28
|
+
export declare function useHeldKeyCodes(): Record<string, string>;
|
|
29
|
+
//#endregion
|
package/dist/useHeldKeyCodes.js
CHANGED
|
@@ -29,9 +29,9 @@ import { useSelector } from "@tanstack/preact-store";
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
function useHeldKeyCodes() {
|
|
32
|
-
|
|
32
|
+
const tracker = getKeyStateTracker();
|
|
33
|
+
return useSelector(tracker.store, (state) => state.heldCodes);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
//#endregion
|
|
36
|
-
export { useHeldKeyCodes };
|
|
37
|
-
//# sourceMappingURL=useHeldKeyCodes.js.map
|
|
37
|
+
export { useHeldKeyCodes };
|
package/dist/useHeldKeys.d.ts
CHANGED
package/dist/useHeldKeys.js
CHANGED
|
@@ -25,9 +25,9 @@ import { useSelector } from "@tanstack/preact-store";
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
function useHeldKeys() {
|
|
28
|
-
|
|
28
|
+
const tracker = getKeyStateTracker();
|
|
29
|
+
return useSelector(tracker.store, (state) => state.heldKeys);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
//#endregion
|
|
32
|
-
export { useHeldKeys };
|
|
33
|
-
//# sourceMappingURL=useHeldKeys.js.map
|
|
33
|
+
export { useHeldKeys };
|
package/dist/useHotkey.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { HotkeyCallback, HotkeyOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
2
|
import { RefObject } from "preact";
|
|
3
|
-
|
|
4
3
|
//#region src/useHotkey.d.ts
|
|
5
|
-
interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
4
|
+
export interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
6
5
|
/**
|
|
7
6
|
* The DOM element to attach the event listener to.
|
|
8
7
|
* Can be a Preact ref, direct DOM element, or null.
|
|
@@ -69,7 +68,5 @@ interface UseHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
|
69
68
|
* }
|
|
70
69
|
* ```
|
|
71
70
|
*/
|
|
72
|
-
declare function useHotkey(hotkey: RegisterableHotkey, callback: HotkeyCallback, options?: UseHotkeyOptions): void;
|
|
73
|
-
//#endregion
|
|
74
|
-
export { UseHotkeyOptions, useHotkey };
|
|
75
|
-
//# sourceMappingURL=useHotkey.d.ts.map
|
|
71
|
+
export declare function useHotkey(hotkey: RegisterableHotkey, callback: HotkeyCallback, options?: UseHotkeyOptions): void;
|
|
72
|
+
//#endregion
|
package/dist/useHotkey.js
CHANGED
|
@@ -78,7 +78,8 @@ function useHotkey(hotkey, callback, options = {}) {
|
|
|
78
78
|
managerRef.current = manager;
|
|
79
79
|
const prevTargetRef = useRef(null);
|
|
80
80
|
const prevHotkeyRef = useRef(null);
|
|
81
|
-
const
|
|
81
|
+
const platform = mergedOptions.platform ?? detectPlatform();
|
|
82
|
+
const hotkeyString = normalizeRegisterableHotkey(hotkey, platform);
|
|
82
83
|
const { target: _target, ...optionsWithoutTarget } = mergedOptions;
|
|
83
84
|
useEffect(() => {
|
|
84
85
|
const resolvedTarget = isRef(optionsRef.current.target) ? optionsRef.current.target.current : optionsRef.current.target ?? (typeof document !== "undefined" ? document : null);
|
|
@@ -121,5 +122,4 @@ function useHotkey(hotkey, callback, options = {}) {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
//#endregion
|
|
124
|
-
export { useHotkey };
|
|
125
|
-
//# sourceMappingURL=useHotkey.js.map
|
|
125
|
+
export { useHotkey };
|
package/dist/useHotkeyHint.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/useHotkeyHint.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns a boolean indicating whether held modifiers reveal this shortcut.
|
|
@@ -8,7 +7,5 @@ import { HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
|
8
7
|
* every modifier. Combine with the action's enabled state before showing a badge.
|
|
9
8
|
* This helper does not register a shortcut or check whether its target is focused.
|
|
10
9
|
*/
|
|
11
|
-
declare function useHotkeyHint(hotkey: RegisterableHotkey, options?: HeldModifierOptions): boolean;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { useHotkeyHint };
|
|
14
|
-
//# sourceMappingURL=useHotkeyHint.d.ts.map
|
|
10
|
+
export declare function useHotkeyHint(hotkey: RegisterableHotkey, options?: HeldModifierOptions): boolean;
|
|
11
|
+
//#endregion
|
package/dist/useHotkeyHint.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Hotkey, HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/useHotkeyRecorder.d.ts
|
|
4
|
-
interface PreactHotkeyRecorder {
|
|
3
|
+
export interface PreactHotkeyRecorder {
|
|
5
4
|
/** Whether recording is currently active */
|
|
6
5
|
isRecording: boolean;
|
|
7
6
|
/** The currently recorded hotkey (for live preview) */
|
|
@@ -51,7 +50,5 @@ interface PreactHotkeyRecorder {
|
|
|
51
50
|
* }
|
|
52
51
|
* ```
|
|
53
52
|
*/
|
|
54
|
-
declare function useHotkeyRecorder(options: HotkeyRecorderOptions): PreactHotkeyRecorder;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { PreactHotkeyRecorder, useHotkeyRecorder };
|
|
57
|
-
//# sourceMappingURL=useHotkeyRecorder.d.ts.map
|
|
53
|
+
export declare function useHotkeyRecorder(options: HotkeyRecorderOptions): PreactHotkeyRecorder;
|
|
54
|
+
//#endregion
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { HotkeyRegistrationView, SequenceRegistrationView } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/useHotkeyRegistrations.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Return type for useHotkeyRegistrations.
|
|
6
5
|
*/
|
|
7
|
-
interface HotkeyRegistrationsResult {
|
|
6
|
+
export interface HotkeyRegistrationsResult {
|
|
8
7
|
/** All registered hotkeys (public view, no callbacks) */
|
|
9
8
|
hotkeys: Array<HotkeyRegistrationView>;
|
|
10
9
|
/** All registered sequences */
|
|
@@ -20,7 +19,5 @@ interface HotkeyRegistrationsResult {
|
|
|
20
19
|
*
|
|
21
20
|
* @returns Object with `hotkeys` and `sequences` arrays
|
|
22
21
|
*/
|
|
23
|
-
declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { HotkeyRegistrationsResult, useHotkeyRegistrations };
|
|
26
|
-
//# sourceMappingURL=useHotkeyRegistrations.d.ts.map
|
|
22
|
+
export declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
23
|
+
//#endregion
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
|
|
2
2
|
import { RefObject } from "preact";
|
|
3
|
-
|
|
4
3
|
//#region src/useHotkeySequence.d.ts
|
|
5
|
-
interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
|
|
4
|
+
export interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
|
|
6
5
|
/**
|
|
7
6
|
* The DOM element to attach the event listener to.
|
|
8
7
|
* Can be a Preact ref, direct DOM element, or null.
|
|
@@ -53,7 +52,5 @@ interface UseHotkeySequenceOptions extends Omit<SequenceOptions, 'target'> {
|
|
|
53
52
|
* }
|
|
54
53
|
* ```
|
|
55
54
|
*/
|
|
56
|
-
declare function useHotkeySequence(sequence: HotkeySequence, callback: HotkeyCallback, options?: UseHotkeySequenceOptions): void;
|
|
57
|
-
//#endregion
|
|
58
|
-
export { UseHotkeySequenceOptions, useHotkeySequence };
|
|
59
|
-
//# sourceMappingURL=useHotkeySequence.d.ts.map
|
|
55
|
+
export declare function useHotkeySequence(sequence: HotkeySequence, callback: HotkeyCallback, options?: UseHotkeySequenceOptions): void;
|
|
56
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HotkeySequence, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/useHotkeySequenceRecorder.d.ts
|
|
4
|
-
interface PreactHotkeySequenceRecorder {
|
|
3
|
+
export interface PreactHotkeySequenceRecorder {
|
|
5
4
|
isRecording: boolean;
|
|
6
5
|
steps: HotkeySequence;
|
|
7
6
|
recordedSequence: HotkeySequence | null;
|
|
@@ -13,7 +12,5 @@ interface PreactHotkeySequenceRecorder {
|
|
|
13
12
|
/**
|
|
14
13
|
* Preact hook for recording multi-chord sequences (Vim-style shortcuts).
|
|
15
14
|
*/
|
|
16
|
-
declare function useHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions): PreactHotkeySequenceRecorder;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { PreactHotkeySequenceRecorder, useHotkeySequenceRecorder };
|
|
19
|
-
//# sourceMappingURL=useHotkeySequenceRecorder.d.ts.map
|
|
15
|
+
export declare function useHotkeySequenceRecorder(options: HotkeySequenceRecorderOptions): PreactHotkeySequenceRecorder;
|
|
16
|
+
//#endregion
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { UseHotkeySequenceOptions } from "./useHotkeySequence.js";
|
|
2
2
|
import { HotkeyCallback, HotkeySequence } from "@tanstack/hotkeys";
|
|
3
|
-
|
|
4
3
|
//#region src/useHotkeySequences.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A single sequence definition for use with `useHotkeySequences`.
|
|
7
6
|
*/
|
|
8
|
-
interface UseHotkeySequenceDefinition {
|
|
7
|
+
export interface UseHotkeySequenceDefinition {
|
|
9
8
|
/** Array of hotkey strings that form the sequence */
|
|
10
9
|
sequence: HotkeySequence;
|
|
11
10
|
/** The function to call when the sequence is completed */
|
|
@@ -57,7 +56,5 @@ interface UseHotkeySequenceDefinition {
|
|
|
57
56
|
* }
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
|
-
declare function useHotkeySequences(definitions: Array<UseHotkeySequenceDefinition>, commonOptions?: UseHotkeySequenceOptions): void;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { UseHotkeySequenceDefinition, useHotkeySequences };
|
|
63
|
-
//# sourceMappingURL=useHotkeySequences.d.ts.map
|
|
59
|
+
export declare function useHotkeySequences(definitions: Array<UseHotkeySequenceDefinition>, commonOptions?: UseHotkeySequenceOptions): void;
|
|
60
|
+
//#endregion
|
package/dist/useHotkeys.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { UseHotkeyOptions } from "./useHotkey.js";
|
|
2
2
|
import { HotkeyCallback, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
3
|
-
|
|
4
3
|
//#region src/useHotkeys.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A single hotkey definition for use with `useHotkeys`.
|
|
7
6
|
*/
|
|
8
|
-
interface UseHotkeyDefinition {
|
|
7
|
+
export interface UseHotkeyDefinition {
|
|
9
8
|
/** The hotkey string (e.g., 'Mod+S', 'Escape') or RawHotkey object */
|
|
10
9
|
hotkey: RegisterableHotkey;
|
|
11
10
|
/** The function to call when the hotkey is pressed */
|
|
@@ -57,7 +56,5 @@ interface UseHotkeyDefinition {
|
|
|
57
56
|
* }
|
|
58
57
|
* ```
|
|
59
58
|
*/
|
|
60
|
-
declare function useHotkeys(hotkeys: Array<UseHotkeyDefinition>, commonOptions?: UseHotkeyOptions): void;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { UseHotkeyDefinition, useHotkeys };
|
|
63
|
-
//# sourceMappingURL=useHotkeys.d.ts.map
|
|
59
|
+
export declare function useHotkeys(hotkeys: Array<UseHotkeyDefinition>, commonOptions?: UseHotkeyOptions): void;
|
|
60
|
+
//#endregion
|
package/dist/useHotkeys.js
CHANGED
package/dist/useKeyHold.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IndividualKey } from "@tanstack/hotkeys";
|
|
2
|
-
|
|
3
2
|
//#region src/useKeyHold.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Preact hook that returns whether a specific key is currently being held.
|
|
@@ -41,7 +40,5 @@ import { IndividualKey } from "@tanstack/hotkeys";
|
|
|
41
40
|
* }
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
44
|
-
declare function useKeyHold(key: IndividualKey): boolean;
|
|
45
|
-
//#endregion
|
|
46
|
-
export { useKeyHold };
|
|
47
|
-
//# sourceMappingURL=useKeyHold.d.ts.map
|
|
43
|
+
export declare function useKeyHold(key: IndividualKey): boolean;
|
|
44
|
+
//#endregion
|
package/dist/useKeyHold.js
CHANGED
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/preact-hotkeys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Preact adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,32 +20,26 @@
|
|
|
20
20
|
"keys"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"
|
|
24
|
-
"module": "./dist/index.js",
|
|
25
|
-
"types": "./dist/index.d.cts",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
26
24
|
"exports": {
|
|
27
|
-
".":
|
|
28
|
-
"import": "./dist/index.js",
|
|
29
|
-
"require": "./dist/index.cjs"
|
|
30
|
-
},
|
|
25
|
+
".": "./dist/index.js",
|
|
31
26
|
"./package.json": "./package.json"
|
|
32
27
|
},
|
|
33
28
|
"sideEffects": false,
|
|
34
29
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
30
|
+
"node": ">=20"
|
|
36
31
|
},
|
|
37
32
|
"files": [
|
|
38
|
-
"dist"
|
|
39
|
-
"src"
|
|
33
|
+
"dist"
|
|
40
34
|
],
|
|
41
35
|
"dependencies": {
|
|
42
|
-
"@tanstack/
|
|
43
|
-
"@tanstack/
|
|
36
|
+
"@tanstack/hotkeys": "0.10.0",
|
|
37
|
+
"@tanstack/preact-store": "^0.13.3"
|
|
44
38
|
},
|
|
45
39
|
"devDependencies": {
|
|
46
|
-
"@preact/preset-vite": "^2.10.
|
|
40
|
+
"@preact/preset-vite": "^2.10.6",
|
|
47
41
|
"@testing-library/preact": "^3.2.4",
|
|
48
|
-
"preact": "^10.29.
|
|
42
|
+
"preact": "^10.29.8"
|
|
49
43
|
},
|
|
50
44
|
"peerDependencies": {
|
|
51
45
|
"preact": ">=10.0.0"
|
|
@@ -58,6 +52,7 @@
|
|
|
58
52
|
"test:lib": "vitest --passWithNoTests",
|
|
59
53
|
"test:lib:dev": "pnpm test:lib --watch",
|
|
60
54
|
"test:types": "tsc",
|
|
61
|
-
"build": "tsdown"
|
|
55
|
+
"build": "tsdown",
|
|
56
|
+
"test:build": "publint --strict && node ../../scripts/verify-package.ts"
|
|
62
57
|
}
|
|
63
58
|
}
|
package/dist/HotkeysProvider.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
let preact = require("preact");
|
|
2
|
-
let preact_hooks = require("preact/hooks");
|
|
3
|
-
let preact_jsx_runtime = require("preact/jsx-runtime");
|
|
4
|
-
|
|
5
|
-
//#region src/HotkeysProvider.tsx
|
|
6
|
-
const HotkeysContext = (0, preact.createContext)(null);
|
|
7
|
-
const DEFAULT_OPTIONS = {};
|
|
8
|
-
function HotkeysProvider({ children, defaultOptions = DEFAULT_OPTIONS }) {
|
|
9
|
-
const contextValue = (0, preact_hooks.useMemo)(() => ({ defaultOptions }), [defaultOptions]);
|
|
10
|
-
return /* @__PURE__ */ (0, preact_jsx_runtime.jsx)(HotkeysContext.Provider, {
|
|
11
|
-
value: contextValue,
|
|
12
|
-
children
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function useHotkeysContext() {
|
|
16
|
-
return (0, preact_hooks.useContext)(HotkeysContext);
|
|
17
|
-
}
|
|
18
|
-
function useDefaultHotkeysOptions() {
|
|
19
|
-
return (0, preact_hooks.useContext)(HotkeysContext)?.defaultOptions ?? {};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
exports.HotkeysProvider = HotkeysProvider;
|
|
24
|
-
exports.useDefaultHotkeysOptions = useDefaultHotkeysOptions;
|
|
25
|
-
exports.useHotkeysContext = useHotkeysContext;
|
|
26
|
-
//# sourceMappingURL=HotkeysProvider.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HotkeysProvider.cjs","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { createContext } from 'preact'\nimport { useContext, useMemo } from 'preact/hooks'\nimport type { ComponentChildren } from 'preact'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: ComponentChildren\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function HotkeysProvider({\n children,\n defaultOptions = DEFAULT_OPTIONS,\n}: HotkeysProviderProps) {\n const contextValue: HotkeysContextValue = useMemo(\n () => ({\n defaultOptions,\n }),\n [defaultOptions],\n )\n\n return (\n <HotkeysContext.Provider value={contextValue}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;;AAqBA,MAAM,2CAA2D,KAAK;AAOtE,MAAM,kBAA0C,EAAE;AAElD,SAAgB,gBAAgB,EAC9B,UACA,iBAAiB,mBACM;CACvB,MAAM,gDACG,EACL,gBACD,GACD,CAAC,eAAe,CACjB;AAED,QACE,4CAAC,eAAe,UAAhB;EAAyB,OAAO;EAC7B;EACuB;;AAI9B,SAAgB,oBAAoB;AAClC,qCAAkB,eAAe;;AAGnC,SAAgB,2BAA2B;AAEzC,qCAD2B,eAAe,EAC1B,kBAAkB,EAAE"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { UseHotkeyOptions } from "./useHotkey.cjs";
|
|
2
|
-
import { UseHotkeySequenceOptions } from "./useHotkeySequence.cjs";
|
|
3
|
-
import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
4
|
-
import * as _$preact from "preact";
|
|
5
|
-
import { ComponentChildren } from "preact";
|
|
6
|
-
|
|
7
|
-
//#region src/HotkeysProvider.d.ts
|
|
8
|
-
interface HotkeysProviderOptions {
|
|
9
|
-
hotkey?: Partial<UseHotkeyOptions>;
|
|
10
|
-
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
11
|
-
hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
|
|
12
|
-
hotkeySequence?: Partial<UseHotkeySequenceOptions>;
|
|
13
|
-
}
|
|
14
|
-
interface HotkeysContextValue {
|
|
15
|
-
defaultOptions: HotkeysProviderOptions;
|
|
16
|
-
}
|
|
17
|
-
interface HotkeysProviderProps {
|
|
18
|
-
children: ComponentChildren;
|
|
19
|
-
defaultOptions?: HotkeysProviderOptions;
|
|
20
|
-
}
|
|
21
|
-
declare function HotkeysProvider({
|
|
22
|
-
children,
|
|
23
|
-
defaultOptions
|
|
24
|
-
}: HotkeysProviderProps): _$preact.JSX.Element;
|
|
25
|
-
declare function useHotkeysContext(): HotkeysContextValue | null;
|
|
26
|
-
declare function useDefaultHotkeysOptions(): HotkeysProviderOptions;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext };
|
|
29
|
-
//# sourceMappingURL=HotkeysProvider.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HotkeysProvider.js","names":[],"sources":["../src/HotkeysProvider.tsx"],"sourcesContent":["import { createContext } from 'preact'\nimport { useContext, useMemo } from 'preact/hooks'\nimport type { ComponentChildren } from 'preact'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { UseHotkeyOptions } from './useHotkey'\nimport type { UseHotkeySequenceOptions } from './useHotkeySequence'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<UseHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<UseHotkeySequenceOptions>\n}\n\ninterface HotkeysContextValue {\n defaultOptions: HotkeysProviderOptions\n}\n\nconst HotkeysContext = createContext<HotkeysContextValue | null>(null)\n\nexport interface HotkeysProviderProps {\n children: ComponentChildren\n defaultOptions?: HotkeysProviderOptions\n}\n\nconst DEFAULT_OPTIONS: HotkeysProviderOptions = {}\n\nexport function HotkeysProvider({\n children,\n defaultOptions = DEFAULT_OPTIONS,\n}: HotkeysProviderProps) {\n const contextValue: HotkeysContextValue = useMemo(\n () => ({\n defaultOptions,\n }),\n [defaultOptions],\n )\n\n return (\n <HotkeysContext.Provider value={contextValue}>\n {children}\n </HotkeysContext.Provider>\n )\n}\n\nexport function useHotkeysContext() {\n return useContext(HotkeysContext)\n}\n\nexport function useDefaultHotkeysOptions() {\n const context = useContext(HotkeysContext)\n return context?.defaultOptions ?? {}\n}\n"],"mappings":";;;;;AAqBA,MAAM,iBAAiB,cAA0C,KAAK;AAOtE,MAAM,kBAA0C,EAAE;AAElD,SAAgB,gBAAgB,EAC9B,UACA,iBAAiB,mBACM;CACvB,MAAM,eAAoC,eACjC,EACL,gBACD,GACD,CAAC,eAAe,CACjB;AAED,QACE,oBAAC,eAAe,UAAhB;EAAyB,OAAO;EAC7B;EACuB;;AAI9B,SAAgB,oBAAoB;AAClC,QAAO,WAAW,eAAe;;AAGnC,SAAgB,2BAA2B;AAEzC,QADgB,WAAW,eAAe,EAC1B,kBAAkB,EAAE"}
|
package/dist/index.cjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_HotkeysProvider = require('./HotkeysProvider.cjs');
|
|
3
|
-
const require_useHotkey = require('./useHotkey.cjs');
|
|
4
|
-
const require_useHotkeys = require('./useHotkeys.cjs');
|
|
5
|
-
const require_useHeldKeys = require('./useHeldKeys.cjs');
|
|
6
|
-
const require_useHeldKeyCodes = require('./useHeldKeyCodes.cjs');
|
|
7
|
-
const require_useKeyHold = require('./useKeyHold.cjs');
|
|
8
|
-
const require_useHotkeySequence = require('./useHotkeySequence.cjs');
|
|
9
|
-
const require_useHotkeySequences = require('./useHotkeySequences.cjs');
|
|
10
|
-
const require_useHotkeyRecorder = require('./useHotkeyRecorder.cjs');
|
|
11
|
-
const require_useHotkeyRegistrations = require('./useHotkeyRegistrations.cjs');
|
|
12
|
-
const require_useHotkeySequenceRecorder = require('./useHotkeySequenceRecorder.cjs');
|
|
13
|
-
const require_useHotkeyHint = require('./useHotkeyHint.cjs');
|
|
14
|
-
|
|
15
|
-
exports.HotkeysProvider = require_HotkeysProvider.HotkeysProvider;
|
|
16
|
-
exports.useDefaultHotkeysOptions = require_HotkeysProvider.useDefaultHotkeysOptions;
|
|
17
|
-
exports.useHeldKeyCodes = require_useHeldKeyCodes.useHeldKeyCodes;
|
|
18
|
-
exports.useHeldKeys = require_useHeldKeys.useHeldKeys;
|
|
19
|
-
exports.useHotkey = require_useHotkey.useHotkey;
|
|
20
|
-
exports.useHotkeyHint = require_useHotkeyHint.useHotkeyHint;
|
|
21
|
-
exports.useHotkeyRecorder = require_useHotkeyRecorder.useHotkeyRecorder;
|
|
22
|
-
exports.useHotkeyRegistrations = require_useHotkeyRegistrations.useHotkeyRegistrations;
|
|
23
|
-
exports.useHotkeySequence = require_useHotkeySequence.useHotkeySequence;
|
|
24
|
-
exports.useHotkeySequenceRecorder = require_useHotkeySequenceRecorder.useHotkeySequenceRecorder;
|
|
25
|
-
exports.useHotkeySequences = require_useHotkeySequences.useHotkeySequences;
|
|
26
|
-
exports.useHotkeys = require_useHotkeys.useHotkeys;
|
|
27
|
-
exports.useHotkeysContext = require_HotkeysProvider.useHotkeysContext;
|
|
28
|
-
exports.useKeyHold = require_useKeyHold.useKeyHold;
|
|
29
|
-
var _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
30
|
-
Object.keys(_tanstack_hotkeys).forEach(function (k) {
|
|
31
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return _tanstack_hotkeys[k]; }
|
|
34
|
-
});
|
|
35
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { UseHotkeyOptions, useHotkey } from "./useHotkey.cjs";
|
|
2
|
-
import { UseHotkeySequenceOptions, useHotkeySequence } from "./useHotkeySequence.cjs";
|
|
3
|
-
import { HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.cjs";
|
|
4
|
-
import { UseHotkeyDefinition, useHotkeys } from "./useHotkeys.cjs";
|
|
5
|
-
import { useHeldKeys } from "./useHeldKeys.cjs";
|
|
6
|
-
import { useHeldKeyCodes } from "./useHeldKeyCodes.cjs";
|
|
7
|
-
import { useKeyHold } from "./useKeyHold.cjs";
|
|
8
|
-
import { UseHotkeySequenceDefinition, useHotkeySequences } from "./useHotkeySequences.cjs";
|
|
9
|
-
import { PreactHotkeyRecorder, useHotkeyRecorder } from "./useHotkeyRecorder.cjs";
|
|
10
|
-
import { HotkeyRegistrationsResult, useHotkeyRegistrations } from "./useHotkeyRegistrations.cjs";
|
|
11
|
-
import { PreactHotkeySequenceRecorder, useHotkeySequenceRecorder } from "./useHotkeySequenceRecorder.cjs";
|
|
12
|
-
import { useHotkeyHint } from "./useHotkeyHint.cjs";
|
|
13
|
-
export * from "@tanstack/hotkeys";
|
|
14
|
-
export { HotkeyRegistrationsResult, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, PreactHotkeyRecorder, PreactHotkeySequenceRecorder, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeySequenceDefinition, UseHotkeySequenceOptions, useDefaultHotkeysOptions, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeySequence, useHotkeySequenceRecorder, useHotkeySequences, useHotkeys, useHotkeysContext, useKeyHold };
|
package/dist/useHeldKeyCodes.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
let _tanstack_hotkeys = require("@tanstack/hotkeys");
|
|
2
|
-
let _tanstack_preact_store = require("@tanstack/preact-store");
|
|
3
|
-
|
|
4
|
-
//#region src/useHeldKeyCodes.ts
|
|
5
|
-
/**
|
|
6
|
-
* Preact hook that returns a map of currently held key names to their physical `event.code` values.
|
|
7
|
-
*
|
|
8
|
-
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
9
|
-
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
10
|
-
*
|
|
11
|
-
* @returns Record mapping normalized key names to their `event.code` values
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```tsx
|
|
15
|
-
* function KeyDebugDisplay() {
|
|
16
|
-
* const heldKeys = useHeldKeys()
|
|
17
|
-
* const heldCodes = useHeldKeyCodes()
|
|
18
|
-
*
|
|
19
|
-
* return (
|
|
20
|
-
* <div>
|
|
21
|
-
* {heldKeys.map((key) => (
|
|
22
|
-
* <kbd key={key}>
|
|
23
|
-
* {key} <small>{heldCodes[key]}</small>
|
|
24
|
-
* </kbd>
|
|
25
|
-
* ))}
|
|
26
|
-
* </div>
|
|
27
|
-
* )
|
|
28
|
-
* }
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
function useHeldKeyCodes() {
|
|
32
|
-
return (0, _tanstack_preact_store.useSelector)((0, _tanstack_hotkeys.getKeyStateTracker)().store, (state) => state.heldCodes);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
exports.useHeldKeyCodes = useHeldKeyCodes;
|
|
37
|
-
//# sourceMappingURL=useHeldKeyCodes.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHeldKeyCodes.cjs","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/preact-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * Preact hook that returns a map of currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n *\n * return (\n * <div>\n * {heldKeys.map((key) => (\n * <kbd key={key}>\n * {key} <small>{heldCodes[key]}</small>\n * </kbd>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeyCodes(): Record<string, string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,kBAA0C;AAExD,2FADoC,CACT,QAAQ,UAAU,MAAM,UAAU"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
//#region src/useHeldKeyCodes.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Preact hook that returns a map of currently held key names to their physical `event.code` values.
|
|
4
|
-
*
|
|
5
|
-
* This is useful for debugging which physical key was pressed (e.g. distinguishing
|
|
6
|
-
* left vs right Shift via "ShiftLeft" / "ShiftRight").
|
|
7
|
-
*
|
|
8
|
-
* @returns Record mapping normalized key names to their `event.code` values
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```tsx
|
|
12
|
-
* function KeyDebugDisplay() {
|
|
13
|
-
* const heldKeys = useHeldKeys()
|
|
14
|
-
* const heldCodes = useHeldKeyCodes()
|
|
15
|
-
*
|
|
16
|
-
* return (
|
|
17
|
-
* <div>
|
|
18
|
-
* {heldKeys.map((key) => (
|
|
19
|
-
* <kbd key={key}>
|
|
20
|
-
* {key} <small>{heldCodes[key]}</small>
|
|
21
|
-
* </kbd>
|
|
22
|
-
* ))}
|
|
23
|
-
* </div>
|
|
24
|
-
* )
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function useHeldKeyCodes(): Record<string, string>;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { useHeldKeyCodes };
|
|
31
|
-
//# sourceMappingURL=useHeldKeyCodes.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useHeldKeyCodes.js","names":[],"sources":["../src/useHeldKeyCodes.ts"],"sourcesContent":["import { useSelector } from '@tanstack/preact-store'\nimport { getKeyStateTracker } from '@tanstack/hotkeys'\n\n/**\n * Preact hook that returns a map of currently held key names to their physical `event.code` values.\n *\n * This is useful for debugging which physical key was pressed (e.g. distinguishing\n * left vs right Shift via \"ShiftLeft\" / \"ShiftRight\").\n *\n * @returns Record mapping normalized key names to their `event.code` values\n *\n * @example\n * ```tsx\n * function KeyDebugDisplay() {\n * const heldKeys = useHeldKeys()\n * const heldCodes = useHeldKeyCodes()\n *\n * return (\n * <div>\n * {heldKeys.map((key) => (\n * <kbd key={key}>\n * {key} <small>{heldCodes[key]}</small>\n * </kbd>\n * ))}\n * </div>\n * )\n * }\n * ```\n */\nexport function useHeldKeyCodes(): Record<string, string> {\n const tracker = getKeyStateTracker()\n return useSelector(tracker.store, (state) => state.heldCodes)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,kBAA0C;AAExD,QAAO,YADS,oBAAoB,CACT,QAAQ,UAAU,MAAM,UAAU"}
|