import { Dialog, Transition } from '@headlessui/react' import { Fragment, useRef, forwardRef } from '@wordpress/element' import { __ } from '@wordpress/i18n' import { Icon, close } from '@wordpress/icons' import { Button } from '@wordpress/components' import { useGlobalStore } from '../../state/GlobalState' export const Modal = forwardRef( ({ isOpen, heading, onClose, children }, initialFocus) => { const focusBackup = useRef(null) const defaultClose = useGlobalStore((state) => state.removeAllModals) onClose = onClose ?? defaultClose return (
{heading ? (
{heading}
) : (
)}
{children}
) }, ) const CloseButton = forwardRef((props, focusRef) => { return (