UNPKG

1.64 kBTypeScriptView Raw
1import * as React from 'react';
2type ClickAwayMouseEventHandler = 'onClick' | 'onMouseDown' | 'onMouseUp' | 'onPointerDown' | 'onPointerUp';
3type 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/base-ui/react-click-away-listener/)
37 *
38 * API:
39 *
40 * - [ClickAwayListener API](https://mui.com/base-ui/react-click-away-listener/components-api/#click-away-listener)
41 */
42declare function ClickAwayListener(props: ClickAwayListenerProps): JSX.Element;
43declare namespace ClickAwayListener {
44 var propTypes: any;
45}
46export { ClickAwayListener };