import React from 'react'; import PropTypes from 'prop-types'; import Body from './Body'; import Footer from './Footer'; import Header from './Header'; import { ComponentProps } from '../utils/types'; /** @public */ type ModalRequestCloseHandler = (data: { event: React.MouseEvent | MouseEvent | KeyboardEvent | TouchEvent; reason: 'clickAway' | 'escapeKey' | 'clickCloseButton'; }) => void; type ModalInitialFocus = 'first' | 'container' | (React.Component & { focus: () => void; }) | HTMLElement | null; interface ModalPropsBase { /** * Any renderable children can be passed to the `Modal`. * * To use the default Splunk UI `Modal` styles, use the * `Modal.Header`, `Modal.Body`, and `Modal.Footer`. */ children?: React.ReactNode; /** * Set to 'true' to enable closing the Modal by clicking outside of it. * * This behavior should be avoided as it can lead to accidental dismissal of the modal causing data loss or disruption of a user's workflow. * Only enable click outside to dismiss when: * - The modal content is non-critical or purely informational * - Accidental dismissal will not result in loss of progress, data, or important context * * `onRequestClose` will receive an event with reason 'clickAway' when this happens. */ closeOnClickAway?: boolean; /** * Show dividers between header, body and footer. */ divider?: 'header' | 'footer' | 'both' | 'none'; /** * A React ref which is set to the DOM element when the component mounts and null when it unmounts. */ elementRef?: React.Ref; /** * Allows focus to be set to a component other than the default. * Supports `first` (first focusable element in the modal), `container` (focus the modal itself), or a ref. */ initialFocus?: ModalInitialFocus; /** * Called when a close event occurs. * When `Modal` includes this prop, a close button is displayed by default in the `Modal.Header`. * To hide the close button, pass the `hideCloseButton` prop to `Modal.Header`. * * The callback is passed the event and a reason, which is 'escapeKey', 'clickAway', or 'clickCloseButton'. * * Generally, use this callback to toggle the `open` prop. */ onRequestClose?: ModalRequestCloseHandler; /** * Set to `true` if the `Modal` is currently open. Otherwise, set to `false`. */ open?: boolean; /** * Pass the ref of the invoking element (or other element that follows the logical flow of the application) to automatically move focus * to the invoking element on `Modal` close. If using a ref is not possible, you *must* pass a function that sets focus to the appropriate element. * This function will be called after `onRequestClose`. */ returnFocus: React.MutableRefObject<(React.Component & { focus: () => void; }) | HTMLElement | null> | (() => void); } type ModalProps = ComponentProps; declare function Modal({ children, closeOnClickAway, elementRef, divider, initialFocus, onRequestClose, open, returnFocus, style, ...otherProps }: ModalProps): React.JSX.Element; declare namespace Modal { var propTypes: { children: PropTypes.Requireable; closeOnClickAway: PropTypes.Requireable; divider: PropTypes.Requireable; elementRef: PropTypes.Requireable; initialFocus: PropTypes.Requireable>; onRequestClose: PropTypes.Requireable<(...args: any[]) => any>; open: PropTypes.Requireable; returnFocus: PropTypes.Validator; }; var Header: typeof import("./Header").default; var Footer: typeof import("./Footer").default; var Body: typeof import("./Body").default; } export default Modal; export { Body, Header, Footer, ModalRequestCloseHandler };