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 DrawerRequestCloseHandler = (data: { event: React.MouseEvent | MouseEvent | KeyboardEvent | TouchEvent; reason: 'clickAway' | 'escapeKey' | 'clickCloseButton'; }) => void; type DrawerInitialFocus = 'first' | 'container' | (React.Component & { focus: () => void; }) | HTMLElement | null; interface DrawerPropsBase { /** * Any renderable children can be passed to the `Drawer`. * * To use the default `Drawer` styles, use the * `Drawer.Header`, `Drawer.Body`, and `Drawer.Footer`. */ children?: React.ReactNode; /** * Set to `true` to enable closing the Drawer by clicking the scrim (overlay). * * Only applies to `position="page"` because other position modes do not have a scrim. * * When `false` (default), the scrim is still displayed to block interaction with * underlying content, but clicking it will not close the Drawer. * * Closing on click away should be avoided as it can lead to accidental dismissal * of the drawer causing data loss or disruption of a user's workflow. * Only enable click outside to dismiss when: * - The drawer content is non-critical or purely informational * - Accidental dismissal will not result in loss of progress, data, or important context * * When enabled, `onRequestClose` will receive an event with reason `clickAway`. */ 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 drawer), `container` (focus the drawer itself), or a ref. */ initialFocus?: DrawerInitialFocus; /** * Called when a close event occurs. * * 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?: DrawerRequestCloseHandler; /** * Set `open` to `true` to open the drawer and `false` to close it. */ open?: boolean; /** * The layout mode for the drawer. * - `page`: Positions relative to the viewport (default) * - `container`: Positions relative to nearest positioned ancestor * - `inline`: Renders inline without portal, allowing content to reflow around the drawer */ position?: 'page' | 'container' | 'inline'; /** * 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 `Drawer` 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`. * * Recommended when `position` is `page` to ensure proper focus management. */ returnFocus?: React.MutableRefObject<(React.Component & { focus: () => void; }) | HTMLElement | null> | (() => void); /** * Width of the drawer. */ width?: string; } interface DrawerPageProps extends DrawerPropsBase { position?: 'page'; } interface DrawerNonPageProps extends DrawerPropsBase { position: 'container' | 'inline'; closeOnClickAway?: never; } type DrawerProps = ComponentProps; declare function Drawer({ children, closeOnClickAway, elementRef, divider, initialFocus, onRequestClose, open, position, returnFocus, width, className, ...otherProps }: DrawerProps): React.JSX.Element; declare namespace Drawer { 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; position: PropTypes.Requireable; returnFocus: PropTypes.Requireable; width: PropTypes.Requireable; }; var Header: typeof import("./Header").default; var Footer: typeof import("./Footer").default; var Body: typeof import("./Body").default; } export default Drawer; export { Body, Header, Footer, DrawerRequestCloseHandler };