All files / src/hooks useHelp.ts

100% Statements 33/33
100% Branches 0/0
100% Functions 0/0
100% Lines 33/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 341x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * @file useHelp.ts
 * @description
 * Custom hook for accessing global help context from anywhere in the component tree.
 * Provides type-safe access to help state and functions.
 *
 * @usage
 * const { openHelp, closeHelp, currentTopicId, isOpen } = useHelp()
 * openHelp('app.main')
 */
 
import { HelpContext, type HelpContextType } from '../context/help/HelpContext.types';
import { createContextHook } from './createContextHook';
 
/**
 * Access global help context from anywhere in the component tree.
 * Must be used within a component wrapped by HelpProvider.
 *
 * @returns Help context with state and functions
 * @throws Error if used outside HelpProvider
 *
 * @example
 * ```tsx
 * const { openHelp, closeHelp, currentTopicId, isOpen } = useHelp()
 * 
 * return (
 *   <button onClick={() => openHelp('inventory.editItem')}>
 *     Help
 *   </button>
 * )
 * ```
 */
export const useHelp = createContextHook<HelpContextType>(HelpContext, 'useHelp');