rx-hotkeys 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -42
- package/dist/{hotkeys.d.ts → core/hotkeys.d.ts} +35 -14
- package/dist/core/hotkeys.d.ts.map +1 -0
- package/dist/{hotkeys.js → core/hotkeys.js} +107 -42
- package/dist/core/hotkeys.js.map +1 -0
- package/dist/{hotkeys.test.d.ts.map → core/hotkeys.test.d.ts.map} +1 -1
- package/dist/{hotkeys.test.js → core/hotkeys.test.js} +201 -145
- package/dist/core/hotkeys.test.js.map +1 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{index.js → core/index.js} +1 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keys.d.ts.map +1 -0
- package/dist/{keys.js → core/keys.js} +1 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/testutils.d.ts.map +1 -0
- package/dist/{testutils.js → core/testutils.js} +1 -0
- package/dist/core/testutils.js.map +1 -0
- package/dist/integrations/react/index.d.ts +3 -0
- package/dist/integrations/react/index.d.ts.map +1 -0
- package/dist/integrations/react/index.js +3 -0
- package/dist/integrations/react/index.js.map +1 -0
- package/dist/integrations/react/provider.d.ts +36 -0
- package/dist/integrations/react/provider.d.ts.map +1 -0
- package/dist/integrations/react/provider.js +85 -0
- package/dist/integrations/react/provider.js.map +1 -0
- package/dist/integrations/react/useEventCallback.d.ts +14 -0
- package/dist/integrations/react/useEventCallback.d.ts.map +1 -0
- package/dist/integrations/react/useEventCallback.js +32 -0
- package/dist/integrations/react/useEventCallback.js.map +1 -0
- package/dist/integrations/react/useHotkeys.d.ts +43 -0
- package/dist/integrations/react/useHotkeys.d.ts.map +1 -0
- package/dist/integrations/react/useHotkeys.js +76 -0
- package/dist/integrations/react/useHotkeys.js.map +1 -0
- package/dist/integrations/react/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/integrations/react/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/dist/integrations/react/useIsomorphicLayoutEffect.js +3 -0
- package/dist/integrations/react/useIsomorphicLayoutEffect.js.map +1 -0
- package/package.json +19 -8
- package/dist/hotkeys.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/keys.d.ts.map +0 -1
- package/dist/testutils.d.ts.map +0 -1
- /package/dist/{hotkeys.test.d.ts → core/hotkeys.test.d.ts} +0 -0
- /package/dist/{index.d.ts → core/index.d.ts} +0 -0
- /package/dist/{keys.d.ts → core/keys.d.ts} +0 -0
- /package/dist/{testutils.d.ts → core/testutils.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/core/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAChB,iBAAiB;IACjB,YAAY,EAAE,cAAc;IAE5B,gBAAgB;IAChB,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM,EAAE,6CAA6C;IAC3D,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IAExB,kBAAkB;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,GAAG,EAAE,+BAA+B;IAE3C,kBAAkB;IAClB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAA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,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,QAAQ;IAChD,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI;IAC9E,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO;IAC7C,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG;IACnC,OAAO,EAAE,IAAI,CAAC,KAAK;IACnB,qCAAqC;CACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testutils.d.ts","sourceRoot":"","sources":["../../src/core/testutils.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY;cACH,GAAG,EAAE;;;;;EAc7B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,SAAS,GAAG,OAAmB,EAC1C,SAAS,GAAE,OAAO,CAAC,iBAAiB,CAAM,GAC3C,aAAa,CASf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testutils.js","sourceRoot":"","sources":["../../src/core/testutils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY;IACxB,MAAM,EAAE,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;QAC1B,EAAE,CAAC,WAAW,EAAE,CAAC;QACjB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,EAAE,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC,CAAC;IACF,EAAE,CAAC,WAAW,GAAG,CAAC,CAAC;IACnB,EAAE,CAAC,KAAK,GAAG,EAAW,CAAC;IACvB,EAAE,CAAC,QAAQ,GAAG,EAAW,CAAC;IAC1B,EAAE,CAAC,SAAS,GAAG,GAAG,EAAE;QAChB,EAAE,CAAC,WAAW,GAAG,CAAC,CAAC;QACnB,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC;QACd,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC,CAAC;IACF,OAAO,EAAE,CAAC;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC5B,MAAmB,EACnB,GAAW,EACX,YAAiC,SAAS,EAC1C,YAAwC,EAAE;IAE1C,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,SAAS,EAAE;QACvC,GAAG;QACH,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,GAAG,SAAS;KACf,CAAC,CAAC;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,oBAAoB,EACzB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GAC1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,UAAU,EACV,WAAW,GACd,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GAC1B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGH,UAAU,EACV,WAAW,GACd,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type StandardKey, Keys, Hotkeys } from "../../core/index.js";
|
|
2
|
+
export { Keys, type StandardKey };
|
|
3
|
+
export type HotkeysContextType = string | null;
|
|
4
|
+
export interface HotkeysProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
initialContext?: HotkeysContextType;
|
|
7
|
+
debugMode?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provides the Hotkeys manager instance and context stack management to its children.
|
|
11
|
+
* It initializes and destroys the Hotkeys manager.
|
|
12
|
+
* @param {HotkeysProviderProps} props - The provider's props.
|
|
13
|
+
* @param {ReactNode} props.children - The child components.
|
|
14
|
+
* @param {string | null} [props.initialContext=null] - The initial hotkey context for the manager.
|
|
15
|
+
* If this prop changes after the initial mount, the Hotkeys manager will be re-initialized.
|
|
16
|
+
* @param {boolean} [props.debugMode=false] - Whether to enable debug logging for the Hotkeys manager
|
|
17
|
+
* itself and for the provider's initialization.
|
|
18
|
+
*/
|
|
19
|
+
export declare function HotkeysProvider({ children, initialContext, debugMode }: HotkeysProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
/**
|
|
21
|
+
* Hook to get the Hotkeys manager instance.
|
|
22
|
+
* Returns `null` during server-side rendering and initial client render.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useHotkeysManager(): Hotkeys | null;
|
|
25
|
+
/**
|
|
26
|
+
* A hook to apply a specific hotkey context for the lifecycle of the component using it.
|
|
27
|
+
* When the component mounts, it pushes the `scopedContext` onto the manager's context stack.
|
|
28
|
+
* When the component unmounts, the context is popped from the stack.
|
|
29
|
+
*
|
|
30
|
+
* @param {HotkeysContextType} scopedContext - The context to apply for this scope.
|
|
31
|
+
* - Pass a string to set a specific context (e.g., 'modal').
|
|
32
|
+
* - Pass `null` to set the context to global/base.
|
|
33
|
+
* @param {boolean} [enabled=true] - Optional. If set to false, the hook will not apply or remove the context.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useScopedHotkeysContext(scopedContext: HotkeysContextType, enabled?: boolean): HotkeysContextType | undefined;
|
|
36
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/provider.tsx"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,WAAW,EAChB,IAAI,EACJ,OAAO,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;AAElC,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAAC;AAK/C,MAAM,WAAW,oBAAoB;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,cAAqB,EAAE,SAAiB,EAAE,EAAE,oBAAoB,2CA8B3G;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,GAAG,IAAI,CAElD;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,kBAAkB,EAAE,OAAO,GAAE,OAAc,GAAG,kBAAkB,GAAG,SAAS,CA8BlI"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useState, useContext, useEffect } from "react";
|
|
3
|
+
import { Keys, Hotkeys, } from "../../core/index.js";
|
|
4
|
+
export { Keys };
|
|
5
|
+
// Context for the Hotkeys manager instance
|
|
6
|
+
const HotkeysManagerContext = createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Provides the Hotkeys manager instance and context stack management to its children.
|
|
9
|
+
* It initializes and destroys the Hotkeys manager.
|
|
10
|
+
* @param {HotkeysProviderProps} props - The provider's props.
|
|
11
|
+
* @param {ReactNode} props.children - The child components.
|
|
12
|
+
* @param {string | null} [props.initialContext=null] - The initial hotkey context for the manager.
|
|
13
|
+
* If this prop changes after the initial mount, the Hotkeys manager will be re-initialized.
|
|
14
|
+
* @param {boolean} [props.debugMode=false] - Whether to enable debug logging for the Hotkeys manager
|
|
15
|
+
* itself and for the provider's initialization.
|
|
16
|
+
*/
|
|
17
|
+
export function HotkeysProvider({ children, initialContext = null, debugMode = false }) {
|
|
18
|
+
// 1. Initialize manager state as `null`. It will remain `null` during server-side rendering.
|
|
19
|
+
const [manager, setManager] = useState(null);
|
|
20
|
+
// 2. Use `useEffect` to create the Hotkeys instance only on the client-side.
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
// This effect runs only after the component has mounted in the browser.
|
|
23
|
+
const hotkeysManagerInstance = new Hotkeys(initialContext, debugMode);
|
|
24
|
+
setManager(hotkeysManagerInstance);
|
|
25
|
+
if (debugMode) {
|
|
26
|
+
console.log("[HotkeysProvider] Hotkeys manager instance created. Initial Context:", hotkeysManagerInstance.getActiveContext());
|
|
27
|
+
}
|
|
28
|
+
// 3. The cleanup function will be called when the provider unmounts.
|
|
29
|
+
return () => {
|
|
30
|
+
if (debugMode) {
|
|
31
|
+
console.log("[HotkeysProvider] Destroying hotkeys manager instance.");
|
|
32
|
+
}
|
|
33
|
+
hotkeysManagerInstance.destroy();
|
|
34
|
+
};
|
|
35
|
+
// The dependency array ensures this effect only re-runs if critical props change,
|
|
36
|
+
// which would necessitate re-creating the manager instance.
|
|
37
|
+
}, [initialContext, debugMode]);
|
|
38
|
+
return (_jsx(HotkeysManagerContext.Provider, { value: manager, children: children }));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Hook to get the Hotkeys manager instance.
|
|
42
|
+
* Returns `null` during server-side rendering and initial client render.
|
|
43
|
+
*/
|
|
44
|
+
export function useHotkeysManager() {
|
|
45
|
+
return useContext(HotkeysManagerContext);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A hook to apply a specific hotkey context for the lifecycle of the component using it.
|
|
49
|
+
* When the component mounts, it pushes the `scopedContext` onto the manager's context stack.
|
|
50
|
+
* When the component unmounts, the context is popped from the stack.
|
|
51
|
+
*
|
|
52
|
+
* @param {HotkeysContextType} scopedContext - The context to apply for this scope.
|
|
53
|
+
* - Pass a string to set a specific context (e.g., 'modal').
|
|
54
|
+
* - Pass `null` to set the context to global/base.
|
|
55
|
+
* @param {boolean} [enabled=true] - Optional. If set to false, the hook will not apply or remove the context.
|
|
56
|
+
*/
|
|
57
|
+
export function useScopedHotkeysContext(scopedContext, enabled = true) {
|
|
58
|
+
const manager = useHotkeysManager();
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
// Guard against running when manager is not yet created or disabled.
|
|
61
|
+
if (!manager || !enabled) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
manager.enterContext(scopedContext);
|
|
65
|
+
return () => {
|
|
66
|
+
// Check for manager existence in cleanup as well, just in case.
|
|
67
|
+
if (manager) {
|
|
68
|
+
manager.leaveContext();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}, [manager, scopedContext, enabled]);
|
|
72
|
+
// This part of the hook could also return the currently active context
|
|
73
|
+
// by subscribing to manager.activeContext$ if needed.
|
|
74
|
+
const [activeContext, setActiveContext] = useState(() => {
|
|
75
|
+
return manager?.getActiveContext();
|
|
76
|
+
});
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (!manager)
|
|
79
|
+
return;
|
|
80
|
+
const sub = manager.onContextChange$.subscribe(setActiveContext);
|
|
81
|
+
return () => sub.unsubscribe();
|
|
82
|
+
}, [manager]);
|
|
83
|
+
return activeContext;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/integrations/react/provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAEH,IAAI,EACJ,OAAO,GACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,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SAAS,CAAC,GAAG,EAAE;QACX,qEAAqE;QACrE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;YACvB,OAAO;QACX,CAAC;QAED,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACpC,OAAO,GAAG,EAAE;YACR,gEAAgE;YAChE,IAAG,OAAO,EAAE,CAAC;gBACT,OAAO,CAAC,YAAY,EAAE,CAAC;YAC3B,CAAC;QACL,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtC,uEAAuE;IACvE,sDAAsD;IACtD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE;QACpD,OAAO,OAAO,EAAE,gBAAgB,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACjE,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A custom React hook that creates a stable function reference (a "callback event")
|
|
3
|
+
* that will always call the latest version of the function passed to it.
|
|
4
|
+
* This is a TypeScript implementation of the pattern used to polyfill the
|
|
5
|
+
* upcoming official `useEffectEvent` hook.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the callback function.
|
|
8
|
+
* @param {T} callback - The function to be made stable. This function can use
|
|
9
|
+
* the latest props and state, and it will be updated on every render.
|
|
10
|
+
* @returns {T} A memoized function that has a stable identity across re-renders
|
|
11
|
+
* but executes the most recent version of the `callback`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useEventCallback<T extends (...args: any[]) => any>(callback: T): T;
|
|
14
|
+
//# sourceMappingURL=useEventCallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventCallback.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/useEventCallback.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAkBlF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useRef, useCallback } from "react";
|
|
2
|
+
import { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
3
|
+
/**
|
|
4
|
+
* A custom React hook that creates a stable function reference (a "callback event")
|
|
5
|
+
* that will always call the latest version of the function passed to it.
|
|
6
|
+
* This is a TypeScript implementation of the pattern used to polyfill the
|
|
7
|
+
* upcoming official `useEffectEvent` hook.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the callback function.
|
|
10
|
+
* @param {T} callback - The function to be made stable. This function can use
|
|
11
|
+
* the latest props and state, and it will be updated on every render.
|
|
12
|
+
* @returns {T} A memoized function that has a stable identity across re-renders
|
|
13
|
+
* but executes the most recent version of the `callback`.
|
|
14
|
+
*/
|
|
15
|
+
export function useEventCallback(callback) {
|
|
16
|
+
// 1. Store the latest callback in a ref. The ref's type is the function signature.
|
|
17
|
+
const callbackRef = useRef(callback);
|
|
18
|
+
// 2. Use useLayoutEffect to update the ref synchronously after every render.
|
|
19
|
+
// This ensures the ref always holds the latest version of the callback
|
|
20
|
+
// before any other effects run.
|
|
21
|
+
useIsomorphicLayoutEffect(() => {
|
|
22
|
+
callbackRef.current = callback;
|
|
23
|
+
}); // No dependency array means this effect runs on every render.
|
|
24
|
+
// 3. Return a stable, memoized function.
|
|
25
|
+
// This function's identity will never change because of the empty dependency array.
|
|
26
|
+
// We cast the returned function to type T to match the input function signature.
|
|
27
|
+
return useCallback((...args) => {
|
|
28
|
+
// When called, it executes the *current* function stored in the ref.
|
|
29
|
+
return callbackRef.current(...args);
|
|
30
|
+
}, []);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useEventCallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventCallback.js","sourceRoot":"","sources":["../../../src/integrations/react/useEventCallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAoC,QAAW;IAC3E,mFAAmF;IACnF,MAAM,WAAW,GAAG,MAAM,CAAI,QAAQ,CAAC,CAAC;IAExC,6EAA6E;IAC7E,uEAAuE;IACvE,gCAAgC;IAChC,yBAAyB,CAAC,GAAG,EAAE;QAC3B,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACnC,CAAC,CAAC,CAAC,CAAC,8DAA8D;IAElE,yCAAyC;IACzC,oFAAoF;IACpF,iFAAiF;IACjF,OAAO,WAAW,CAAC,CAAC,GAAG,IAAmB,EAAiB,EAAE;QACzD,qEAAqE;QACrE,OAAO,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC,EAAE,EAAE,CAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type KeyCombinationConfig, type KeySequenceConfig } from "../../core/index.js";
|
|
2
|
+
export type HotkeyHookOptions = Omit<KeyCombinationConfig, "id" | "keys" | "callback">;
|
|
3
|
+
export type SequenceHookOptions = Omit<KeySequenceConfig, "id" | "sequence" | "callback">;
|
|
4
|
+
/**
|
|
5
|
+
* React hook to declaratively register a key combination hotkey.
|
|
6
|
+
* The hotkey is automatically registered when the component mounts and unregistered when it unmounts.
|
|
7
|
+
*
|
|
8
|
+
* @param keys The key combination to listen for. Can be a string like "ctrl+s" or an array.
|
|
9
|
+
* @param callback The function to execute when the hotkey is triggered.
|
|
10
|
+
* @param options An optional configuration object for `preventDefault`, `context`, `target`, etc.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* import { useHotkeys, Keys } from "./wraper";
|
|
14
|
+
*
|
|
15
|
+
* function MyComponent() {
|
|
16
|
+
* const [count, setCount] = useState(0);
|
|
17
|
+
*
|
|
18
|
+
* // The callback can directly use the latest `count` state without stale closure issues,
|
|
19
|
+
* // and we no longer need to pass a dependency array for it.
|
|
20
|
+
* useHotkeys("c", () => {
|
|
21
|
+
* console.log(`Current count is: ${count}. Incrementing.`);
|
|
22
|
+
* setCount(count + 1);
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* return <div>Count: {count} (Press "c" to increment)</div>;
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
export declare function useHotkeys(keys: string | string[], callback: (event: KeyboardEvent) => void, options?: HotkeyHookOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* React hook to declaratively register a key sequence hotkey.
|
|
31
|
+
* The hotkey is automatically registered when the component mounts and unregistered when it unmounts.
|
|
32
|
+
*
|
|
33
|
+
* @param sequence The key sequence to listen for. Can be a string like "g -> i" or an array.
|
|
34
|
+
* @param callback The function to execute when the hotkey is triggered.
|
|
35
|
+
* @param options An optional configuration object for `preventDefault`, `context`, `sequenceTimeoutMs`, etc.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* useSequence("g -> i", () => {
|
|
39
|
+
* console.log("Navigating to inbox...");
|
|
40
|
+
* }, { sequenceTimeoutMs: 1000 });
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSequence(sequence: string | string[], callback: (event: KeyboardEvent) => void, options?: SequenceHookOptions): void;
|
|
43
|
+
//# sourceMappingURL=useHotkeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHotkeys.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/useHotkeys.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACzB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,EAAE,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC;AACvF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,EAAE,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;AA6C1F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACtB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,iBAAiB,GAC5B,IAAI,CAEN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACvB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,mBAAmB,GAC9B,IAAI,CAEN"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
|
+
import { useEventCallback } from "./useEventCallback.js";
|
|
3
|
+
import { useHotkeysManager } from "./provider.js";
|
|
4
|
+
// Internal hook to handle the common logic for both combination and sequence hotkeys
|
|
5
|
+
function useBaseHotkey(type, keyOrSequence, callback, options) {
|
|
6
|
+
const manager = useHotkeysManager();
|
|
7
|
+
// Generate a stable, unique ID for this hook instance.
|
|
8
|
+
const hotkeyId = useMemo(() => `react-hotkey-${Math.random().toString(36).slice(2, 11)}`, []);
|
|
9
|
+
// Use the provided useEventCallback hook.
|
|
10
|
+
// This creates a stable function `onHotkey` that always calls the latest `callback`.
|
|
11
|
+
const onHotkey = useEventCallback(callback);
|
|
12
|
+
// Memoize options object to prevent effect re-runs. It's recommended that users memoize this object themselves for performance.
|
|
13
|
+
const memoizedOptions = useMemo(() => options, [JSON.stringify(options)]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!manager || !keyOrSequence) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const config = {
|
|
19
|
+
id: hotkeyId,
|
|
20
|
+
...memoizedOptions,
|
|
21
|
+
};
|
|
22
|
+
const hotkey$ = type === "combination"
|
|
23
|
+
? manager.addCombination({ ...config, keys: keyOrSequence })
|
|
24
|
+
: manager.addSequence({ ...config, sequence: keyOrSequence });
|
|
25
|
+
const _subscription = hotkey$.subscribe(onHotkey);
|
|
26
|
+
return () => {
|
|
27
|
+
// The subscription is implicitly cleaned up because remove() completes the Observable.
|
|
28
|
+
manager.remove(hotkeyId);
|
|
29
|
+
};
|
|
30
|
+
// Re-run the effect if the manager, keys, options, or callback changes.
|
|
31
|
+
}, [manager, hotkeyId, keyOrSequence, memoizedOptions, onHotkey, type]);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* React hook to declaratively register a key combination hotkey.
|
|
35
|
+
* The hotkey is automatically registered when the component mounts and unregistered when it unmounts.
|
|
36
|
+
*
|
|
37
|
+
* @param keys The key combination to listen for. Can be a string like "ctrl+s" or an array.
|
|
38
|
+
* @param callback The function to execute when the hotkey is triggered.
|
|
39
|
+
* @param options An optional configuration object for `preventDefault`, `context`, `target`, etc.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* import { useHotkeys, Keys } from "./wraper";
|
|
43
|
+
*
|
|
44
|
+
* function MyComponent() {
|
|
45
|
+
* const [count, setCount] = useState(0);
|
|
46
|
+
*
|
|
47
|
+
* // The callback can directly use the latest `count` state without stale closure issues,
|
|
48
|
+
* // and we no longer need to pass a dependency array for it.
|
|
49
|
+
* useHotkeys("c", () => {
|
|
50
|
+
* console.log(`Current count is: ${count}. Incrementing.`);
|
|
51
|
+
* setCount(count + 1);
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* return <div>Count: {count} (Press "c" to increment)</div>;
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
export function useHotkeys(keys, callback, options) {
|
|
58
|
+
useBaseHotkey("combination", keys, callback, options);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* React hook to declaratively register a key sequence hotkey.
|
|
62
|
+
* The hotkey is automatically registered when the component mounts and unregistered when it unmounts.
|
|
63
|
+
*
|
|
64
|
+
* @param sequence The key sequence to listen for. Can be a string like "g -> i" or an array.
|
|
65
|
+
* @param callback The function to execute when the hotkey is triggered.
|
|
66
|
+
* @param options An optional configuration object for `preventDefault`, `context`, `sequenceTimeoutMs`, etc.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* useSequence("g -> i", () => {
|
|
70
|
+
* console.log("Navigating to inbox...");
|
|
71
|
+
* }, { sequenceTimeoutMs: 1000 });
|
|
72
|
+
*/
|
|
73
|
+
export function useSequence(sequence, callback, options) {
|
|
74
|
+
useBaseHotkey("sequence", sequence, callback, options);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=useHotkeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHotkeys.js","sourceRoot":"","sources":["../../../src/integrations/react/useHotkeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD,OAAO,EAAE,iBAAiB,EAAE,MAAO,eAAe,CAAC;AAMnD,qFAAqF;AACrF,SAAS,aAAa,CAClB,IAAgC,EAChC,aAAgC,EAChC,QAAwC,EACxC,OAAiD;IAEjD,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,uDAAuD;IACvD,MAAM,QAAQ,GAAG,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xC,OAA2B;IAE3B,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CACvB,QAA2B,EAC3B,QAAwC,EACxC,OAA6B;IAE7B,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../../src/integrations/react/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAE,MAAM,OAAO,CAAC;AAEnD,eAAO,MAAM,yBAAyB,kBAA8D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../src/integrations/react/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rx-hotkeys",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"clean": "rm -rf dist && rm -rf .cache",
|
|
7
|
+
"build": "tsc --build",
|
|
8
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
8
9
|
"pretest": "npm run build",
|
|
9
10
|
"test": "node --test './dist/**/*.test.js'"
|
|
10
11
|
},
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
13
|
-
"default": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
14
|
+
"default": "./dist/core/index.js",
|
|
15
|
+
"types": "./dist/core/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./react": {
|
|
18
|
+
"default": "./dist/integrations/react/index.js",
|
|
19
|
+
"types": "./dist/integrations/react/index.d.ts"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"keywords": [
|
|
@@ -32,13 +37,19 @@
|
|
|
32
37
|
"license": "MIT",
|
|
33
38
|
"description": "Advanced Keyboard Shortcut Management library using rxjs",
|
|
34
39
|
"packageManager": "npm@10.9.1+sha512.c89530d37c4baa38afd43e76a077a84b9aa63840b986426584fd5c5a54ab0a0b21bb1595c851042b733784b0b43706d36a494b4d8ae1a086a762cb8d3f95942a",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
42
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
43
|
+
"rxjs": "^7.0.0"
|
|
44
|
+
},
|
|
35
45
|
"devDependencies": {
|
|
36
46
|
"@types/jsdom": "^21.1.7",
|
|
37
47
|
"@types/node": "^22.15.19",
|
|
48
|
+
"@types/react": "^19.1.6",
|
|
49
|
+
"@types/react-dom": "^19.1.6",
|
|
38
50
|
"jsdom": "^26.1.0",
|
|
51
|
+
"react": "^19.1.0",
|
|
52
|
+
"rxjs": "^7.8.2",
|
|
39
53
|
"typescript": "^5.8.3"
|
|
40
|
-
},
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"rxjs": "^7.8.2"
|
|
43
54
|
}
|
|
44
55
|
}
|
package/dist/hotkeys.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../src/hotkeys.ts"],"names":[],"mappings":"AAAA,OAAO,EACgC,UAAU,EAC2B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;;;;;;;;;;OAmCG;IACI,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,UAAU,CAAC,aAAa,CAAC;IAqG9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACI,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC,aAAa,CAAC;IAmJxE;;;;;;OAMG;IACI,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAalC;;;;;;OAMG;IACI,kBAAkB,IAAI;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,aAAa,CAAA;KAAC,EAAE;IAa/G;;;;;OAKG;IACI,OAAO,IAAI,IAAI;CAUzB"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,WAAW,EAChB,IAAI,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,OAAO,GACV,MAAM,cAAc,CAAC"}
|
package/dist/keys.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyHP,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAelD,CAAC"}
|
package/dist/testutils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testutils.d.ts","sourceRoot":"","sources":["../src/testutils.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY;cACH,GAAG,EAAE;;;;;EAc7B;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC5B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,SAAS,GAAG,OAAmB,EAC1C,SAAS,GAAE,OAAO,CAAC,iBAAiB,CAAM,GAC3C,aAAa,CASf"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|