UNPKG

1.09 kBTypeScriptView Raw
1/// <reference types="react" />
2export declare type MouseEvents = {
3 [K in keyof GlobalEventHandlersEventMap]: GlobalEventHandlersEventMap[K] extends MouseEvent ? K : never;
4}[keyof GlobalEventHandlersEventMap];
5export interface RootCloseOptions {
6 disabled?: boolean;
7 clickTrigger?: MouseEvents;
8}
9/**
10 * The `useRootClose` hook registers your callback on the document
11 * when rendered. Powers the `<Overlay/>` component. This is used achieve modal
12 * style behavior where your callback is triggered when the user tries to
13 * interact with the rest of the document or hits the `esc` key.
14 *
15 * @param {Ref<HTMLElement>| HTMLElement} ref The element boundary
16 * @param {function} onRootClose
17 * @param {object=} options
18 * @param {boolean=} options.disabled
19 * @param {string=} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on
20 */
21declare function useRootClose(ref: React.RefObject<Element> | Element | null | undefined, onRootClose: (e: Event) => void, { disabled, clickTrigger }?: RootCloseOptions): void;
22export default useRootClose;