import {forwardRef} from 'react'; import {m} from 'framer-motion'; import {OverlayProps} from './overlay-props'; import {useOverlayViewport} from './use-overlay-viewport'; import {Underlay} from './underlay'; import {FocusScope} from '@react-aria/focus'; import {useObjectRef} from '@react-aria/utils'; import clsx from 'clsx'; export const Modal = forwardRef( ( { children, autoFocus = false, restoreFocus = true, isDismissable = true, isOpen = false, placement = 'center', onClose, }, ref ) => { const viewPortStyle = useOverlayViewport(); const objRef = useObjectRef(ref); return (
{ if (e.key === 'Escape') { e.stopPropagation(); e.preventDefault(); onClose(); } }} > { if (isDismissable) { onClose(); } }} /> {children}
); } );