UNPKG

1.67 kBTypeScriptView Raw
1import * as React from 'react';
2declare type ClickAwayMouseEventHandler = 'onClick' | 'onMouseDown' | 'onMouseUp';
3declare type ClickAwayTouchEventHandler = 'onTouchStart' | 'onTouchEnd';
4export interface ClickAwayListenerProps {
5 /**
6 * The wrapped element.
7 */
8 children: React.ReactElement;
9 /**
10 * If `true`, the React tree is ignored and only the DOM tree is considered.
11 * This prop changes how portaled elements are handled.
12 * @default false
13 */
14 disableReactTree?: boolean;
15 /**
16 * The mouse event to listen to. You can disable the listener by providing `false`.
17 * @default 'onClick'
18 */
19 mouseEvent?: ClickAwayMouseEventHandler | false;
20 /**
21 * Callback fired when a "click away" event is detected.
22 */
23 onClickAway: (event: MouseEvent | TouchEvent) => void;
24 /**
25 * The touch event to listen to. You can disable the listener by providing `false`.
26 * @default 'onTouchEnd'
27 */
28 touchEvent?: ClickAwayTouchEventHandler | false;
29}
30/**
31 * Listen for click events that occur somewhere in the document, outside of the element itself.
32 * For instance, if you need to hide a menu when people click anywhere else on your page.
33 *
34 * Demos:
35 *
36 * - [Click Away Listener](https://mui.com/components/click-away-listener/)
37 * - [Menus](https://mui.com/components/menus/)
38 *
39 * API:
40 *
41 * - [ClickAwayListener API](https://mui.com/api/click-away-listener/)
42 */
43declare function ClickAwayListener(props: ClickAwayListenerProps): JSX.Element;
44declare namespace ClickAwayListener {
45 var propTypes: any;
46}
47export default ClickAwayListener;