react-keyhub
Version:
A lightweight, scalable keyboard shortcut manager for React applications with TypeScript support
68 lines (67 loc) • 2.59 kB
TypeScript
import React from 'react';
import { EventBus } from './EventBus';
import { ShortcutSettings, KeyHubProviderProps, ShortcutCallback, ShortcutContext, ShortcutConfig } from './types';
/**
* Provider component for the KeyHub context
*/
export declare const KeyHubProvider: React.FC<KeyHubProviderProps>;
/**
* Hook to access the KeyHub event bus
* @returns The KeyHub event bus instance
*/
export declare const useKeyHub: () => EventBus;
/**
* Hook to access the shortcuts provided to the KeyHub provider
* @returns The shortcuts provided to the KeyHub provider
*/
export declare const useKeyHubShortcuts: () => ShortcutSettings;
/**
* Hook to subscribe to a keyboard shortcut
* @param shortcutId The ID of the shortcut to subscribe to
* @param callback The callback to execute when the shortcut is triggered
*/
export declare const useShortcut: <T extends string | number>(shortcutId: T, callback?: ShortcutCallback) => void;
/**
* Hook to get all registered shortcuts
* @returns All registered shortcuts
*/
export declare const useShortcutSheet: () => ShortcutSettings;
/**
* Hook to get shortcuts by group
* @param group The group to filter by
* @returns The shortcuts in the specified group
*/
export declare const useShortcutsByGroup: (group: string) => ShortcutSettings;
/**
* Hook to get all shortcut groups
* @returns An array of unique group names
*/
export declare const useShortcutGroups: () => string[];
/**
* Hook to enable or disable a shortcut
* @param shortcutId The ID of the shortcut to enable or disable
* @param enabled Whether the shortcut should be enabled
*/
export declare const useShortcutStatus: <T extends string | number>(shortcutId: T, enabled: boolean) => void;
/**
* Hook to update a shortcut configuration
* @param shortcutId The ID of the shortcut to update
* @param config The new configuration
*/
export declare const useShortcutUpdate: <T extends string | number>(shortcutId: T, config: Partial<ShortcutSettings[T]>) => void;
/**
* Hook to register a new shortcut
* @param shortcutId The ID of the shortcut to register
* @param config The shortcut configuration
*/
export declare const useShortcutRegister: <T extends string>(shortcutId: T, config: ShortcutConfig) => void;
/**
* Hook to set the active context
* @param context The context to set as active
*/
export declare const useShortcutContext: (context: ShortcutContext | null) => void;
/**
* Hook to pause and resume the event bus
* @param paused Whether the event bus should be paused
*/
export declare const useShortcutPause: (paused: boolean) => void;