import { ActionUnion, BoundActionCreators } from '../../../utils/typedActions'; /** * @file Context for managing global keyboard shortcuts with registration and event handling */ import * as React from "react"; export type KeyboardShortcut = { key: string; ctrl?: boolean; shift?: boolean; alt?: boolean; meta?: boolean; /** * When true, registers both Ctrl (Windows/Linux) and Cmd (Mac) variants * Cannot be used together with ctrl or meta */ cmdOrCtrl?: boolean; }; /** * Handler function for keyboard shortcuts * @returns false to allow default browser behavior, true or void to prevent default */ export type ShortcutHandler = (e: KeyboardEvent) => void | boolean; export type KeyboardShortcutState = { shortcuts: Map; isEnabled: boolean; }; export declare const keyboardShortcutActions: { readonly registerShortcut: ((shortcut: KeyboardShortcut, handler: ShortcutHandler) => { type: "REGISTER_SHORTCUT"; payload: { shortcut: KeyboardShortcut; handler: ShortcutHandler; }; }) & { readonly type: "REGISTER_SHORTCUT"; }; readonly unregisterShortcut: ((shortcut: KeyboardShortcut) => { type: "UNREGISTER_SHORTCUT"; payload: { shortcut: KeyboardShortcut; }; }) & { readonly type: "UNREGISTER_SHORTCUT"; }; readonly enableShortcuts: (() => { type: "ENABLE_SHORTCUTS"; }) & { readonly type: "ENABLE_SHORTCUTS"; }; readonly disableShortcuts: (() => { type: "DISABLE_SHORTCUTS"; }) & { readonly type: "DISABLE_SHORTCUTS"; }; }; export type KeyboardShortcutAction = ActionUnion; export declare const keyboardShortcutReducer: (state: KeyboardShortcutState, action: KeyboardShortcutAction) => KeyboardShortcutState; export declare const defaultKeyboardShortcutState: KeyboardShortcutState; export type KeyboardShortcutActionsValue = { dispatch: React.Dispatch; actions: BoundActionCreators; actionCreators: typeof keyboardShortcutActions; registerShortcut: (shortcut: KeyboardShortcut, handler: ShortcutHandler) => void; unregisterShortcut: (shortcut: KeyboardShortcut) => void; }; export type KeyboardShortcutContextValue = KeyboardShortcutActionsValue & { state: KeyboardShortcutState; }; export declare const KeyboardShortcutContext: React.Context; export type KeyboardShortcutProviderProps = { children: React.ReactNode; initialState?: Partial; }; export declare const KeyboardShortcutProvider: React.FC; /** * Hook to access only the keyboard shortcut state * Use this when you only need to read state and don't need actions */ export declare const useKeyboardShortcutState: () => KeyboardShortcutState; /** * Hook to access only the keyboard shortcut actions * Use this when you only need to register/unregister shortcuts and don't need to re-render on state changes * The returned actions have stable references and won't cause re-renders */ export declare const useKeyboardShortcutActions: () => KeyboardShortcutActionsValue; /** * Hook to access both state and actions (backward compatible) * Prefer useKeyboardShortcutState or useKeyboardShortcutActions for better performance */ export declare const useKeyboardShortcut: () => KeyboardShortcutContextValue; export declare const useRegisterShortcut: (shortcut: KeyboardShortcut, handler: ShortcutHandler, deps?: React.DependencyList) => void;