UNPKG

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