UNPKG

rooks

Version:

Essential React custom hooks ⚓ to super charge your components!

26 lines 952 B
import { FocusEvent } from "react"; interface FocusEvents { /** Handler that is called when the element receives focus. */ onFocus?: (e: FocusEvent) => void; /** Handler that is called when the element loses focus. */ onBlur?: (e: FocusEvent) => void; /** Handler that is called when the element's focus status changes. */ onFocusChange?: (isFocused: boolean) => void; } interface DOMAttributes<T> { onFocus?: (e: FocusEvent<T>) => void; onBlur?: (e: FocusEvent<T>) => void; } type FocusProps = FocusEvents; interface FocusResult<T> { /** Props to spread onto the target element. */ focusProps: DOMAttributes<T>; } /** * useFocus * @description Handles focus events for the immediate target element. * @see {@link https://rooks.vercel.app/docs/hooks/useFocus} */ declare const useFocus: <T extends HTMLElement>(props: FocusProps) => FocusResult<T>; export { useFocus }; //# sourceMappingURL=useFocus.d.ts.map