UNPKG

2.98 kBTypeScriptView Raw
1import * as React from 'react';
2import { StandardProps, ModalManager } from '..';
3import { BackdropProps } from '../Backdrop';
4import { PortalProps } from '../Portal';
5
6export interface ModalProps
7 extends StandardProps<React.HTMLAttributes<HTMLDivElement>, never, 'children'> {
8 BackdropComponent?: React.ElementType<BackdropProps>;
9 BackdropProps?: Partial<BackdropProps>;
10 children: React.ReactElement;
11 closeAfterTransition?: boolean;
12 container?: PortalProps['container'];
13 disableAutoFocus?: boolean;
14 /**
15 * If `true`, clicking the backdrop will not fire the `onClose` callback.
16 * @deprecated Use the onClose prop with the `reason` argument to filter the `backdropClick` events.
17 */
18 disableBackdropClick?: boolean;
19 disableEnforceFocus?: boolean;
20 disableEscapeKeyDown?: boolean;
21 disablePortal?: PortalProps['disablePortal'];
22 disableRestoreFocus?: boolean;
23 disableScrollLock?: boolean;
24 hideBackdrop?: boolean;
25 keepMounted?: boolean;
26 manager?: ModalManager;
27 /**
28 * Callback fired when the backdrop is clicked.
29 * @deprecated Use the onClose prop with the `reason` argument to handle the `backdropClick` events.
30 */
31 onBackdropClick?: React.ReactEventHandler<{}>;
32 /**
33 * Callback fired when the component requests to be closed.
34 *
35 * @param {object} event The event source of the callback.
36 * @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`.
37 */
38 onClose?: {
39 bivarianceHack(event: {}, reason: 'backdropClick' | 'escapeKeyDown'): void;
40 }['bivarianceHack'];
41 /**
42 * Callback fired when the escape key is pressed,
43 * `disableKeyboard` is false and the modal is in focus.
44 * @deprecated Use the onClose prop with the `reason` argument to handle the `escapeKeyDown` events.
45 */
46 onEscapeKeyDown?: React.ReactEventHandler<{}>;
47 /**
48 * Callback fired once the children has been mounted into the `container`.
49 * It signals that the `open={true}` prop took effect.
50 *
51 * This prop will be removed in v5, the ref can be used instead.
52 * @deprecated Use the ref instead.
53 */
54 onRendered?: PortalProps['onRendered'];
55 /**
56 * If `true`, the modal is open.
57 */
58 open: boolean;
59}
60
61/**
62 * Modal is a lower-level construct that is leveraged by the following components:
63 *
64 * - [Dialog](https://material-ui.com/api/dialog/)
65 * - [Drawer](https://material-ui.com/api/drawer/)
66 * - [Menu](https://material-ui.com/api/menu/)
67 * - [Popover](https://material-ui.com/api/popover/)
68 *
69 * If you are creating a modal dialog, you probably want to use the [Dialog](https://material-ui.com/api/dialog/) component
70 * rather than directly using Modal.
71 *
72 * This component shares many concepts with [react-overlays](https://react-bootstrap.github.io/react-overlays/#modals).
73 * Demos:
74 *
75 * - [Modal](https://material-ui.com/components/modal/)
76 *
77 * API:
78 *
79 * - [Modal API](https://material-ui.com/api/modal/)
80 */
81declare const Modal: React.ComponentType<ModalProps>;
82
83export default Modal;