# All files TooltipHoverModeProvider.tsx

100% Statements 56/56
100% Branches 2/2
100% Functions 2/2
100% Lines 56/56

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
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    571x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    39x
    39x
    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
     import type { ReactElement, ReactNode } from "react";
    import { createContext, useContext } from "react";
    import type { HoverModeConfiguration, HoverModeContext } from "../hoverMode";
    import { createHoverModeContext, useHoverModeProvider } from "../hoverMode";
    import { DEFAULT_TOOLTIP_DELAY } from "./constants";

    /** @remarks \@since 6.0.0 */
    export type TooltipHoverModeContext = HoverModeContext;

    const context = createContext<TooltipHoverModeContext>(
      createHoverModeContext({
        hoverTimeout: DEFAULT_TOOLTIP_DELAY,
        leaveTimeout: 0,
      })
    );
    context.displayName = "TooltipHoverMode";
    const { Provider } = context;

    /**
     * @internal
     * @remarks \@since 6.0.0
     */
    export function useTooltipHoverMode(): Readonly<TooltipHoverModeContext> {
      return useContext(context);
    }

    /**
     * @remarks \@since 6.0.0
     */
    export interface TooltipHoverModeProviderProps
      extends Partial<HoverModeConfiguration> {
      children: ReactNode;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export function TooltipHoverModeProvider(
      props: TooltipHoverModeProviderProps
    ): ReactElement {
      const {
        hoverTimeout = DEFAULT_TOOLTIP_DELAY,
        leaveTimeout = 0,
        disableTimeout = DEFAULT_TOOLTIP_DELAY,
        defaultActiveId,
        children,
      } = props;
      const context = useHoverModeProvider({
        hoverTimeout,
        leaveTimeout,
        disableTimeout,
        defaultActiveId,
      });

      return <Provider value={context}>{children}</Provider>;
    }