@uifabric/utilities
Version:
Fluent UI React utilities for building components.
25 lines (24 loc) • 1.12 kB
TypeScript
import * as React from 'react';
/**
* Initializes the logic which:
*
* 1. Subscribes keydown and mousedown events. (It will only do it once per window,
* so it's safe to call this method multiple times.)
* 2. When the user presses directional keyboard keys, adds the 'ms-Fabric--isFocusVisible' classname
* to the document body, removes the 'ms-Fabric-isFocusHidden' classname.
* 3. When the user clicks a mouse button, adds the 'ms-Fabric-isFocusHidden' classname to the
* document body, removes the 'ms-Fabric--isFocusVisible' classname.
*
* This logic allows components on the page to conditionally render focus treatments based on
* the existence of global classnames, which simplifies logic overall.
*
* @param rootRef - A Ref object. Focus rectangle can be applied on itself and all its children.
*/
export declare function useFocusRects(rootRef?: React.RefObject<HTMLElement>): void;
/**
* Function Component wrapper which enables calling `useFocusRects` hook.
* Renders nothing.
*/
export declare const FocusRects: React.FunctionComponent<{
rootRef?: React.RefObject<HTMLElement>;
}>;