UNPKG

reablocks

Version:
30 lines (28 loc) 999 B
import { MutableRefObject, RefObject } from 'react'; interface ExitListenerOptions { /** * A ref object pointing to the target element that the hook should * observe for click outside and escape key events. */ ref: RefObject<HTMLElement | null> | MutableRefObject<HTMLElement>; /** * An optional boolean to enable or disable the event listeners. * When set to true (default), the event listeners are active. */ open?: boolean; /** * An optional callback function that is called when a click * event occurs outside the target element. */ onClickOutside?: (event: MouseEvent) => void; /** * An optional callback function that is called * when the 'Escape' key is pressed. */ onEscape?: (event: KeyboardEvent) => void; } /** * Hook to listen for click outside and escape key events. */ export declare const useExitListener: ({ ref, open, onClickOutside, onEscape }: ExitListenerOptions) => void; export {};