rx-hotkeys
Version:
Advanced Keyboard Shortcut Management library using rxjs
36 lines • 1.99 kB
TypeScript
import { type StandardKey, Keys, Hotkeys } from "../../core/index.js";
export { Keys, type StandardKey };
export type HotkeysContextType = string | null;
export interface HotkeysProviderProps {
children: React.ReactNode;
initialContext?: HotkeysContextType;
debugMode?: boolean;
}
/**
* Provides the Hotkeys manager instance and context stack management to its children.
* It initializes and destroys the Hotkeys manager.
* @param {HotkeysProviderProps} props - The provider's props.
* @param {ReactNode} props.children - The child components.
* @param {string | null} [props.initialContext=null] - The initial hotkey context for the manager.
* If this prop changes after the initial mount, the Hotkeys manager will be re-initialized.
* @param {boolean} [props.debugMode=false] - Whether to enable debug logging for the Hotkeys manager
* itself and for the provider's initialization.
*/
export declare function HotkeysProvider({ children, initialContext, debugMode }: HotkeysProviderProps): import("react/jsx-runtime").JSX.Element;
/**
* Hook to get the Hotkeys manager instance.
* Returns `null` during server-side rendering and initial client render.
*/
export declare function useHotkeysManager(): Hotkeys | null;
/**
* A hook to apply a specific hotkey context for the lifecycle of the component using it.
* When the component mounts, it pushes the `scopedContext` onto the manager's context stack.
* When the component unmounts, the context is popped from the stack.
*
* @param {HotkeysContextType} scopedContext - The context to apply for this scope.
* - Pass a string to set a specific context (e.g., 'modal').
* - Pass `null` to set the context to global/base.
* @param {boolean} [enabled=true] - Optional. If set to false, the hook will not apply or remove the context.
*/
export declare function useScopedHotkeysContext(scopedContext: HotkeysContextType, enabled?: boolean): HotkeysContextType | undefined;
//# sourceMappingURL=provider.d.ts.map