import React, {useEffect} from 'react'; import classnames from 'classnames'; import SUI from 'SUI'; import $ from 'jquery'; const {__} = wp.i18n; export default function Modal( { id = '', title = '', description = '', small = false, headerActions = false, focusAfterOpen = '', focusAfterClose = 'container', dialogClasses = [], disableCloseButton = false, enterDisabled = false, beforeTitle = false, onEnter = () => false, onClose = () => false, footer, children } ) { useEffect(() => { SUI.openModal( id, focusAfterClose, focusAfterOpen ? focusAfterOpen : getTitleId(), false, false ); return () => SUI.closeModal(); }, []); const handleKeyDown = (event) => { const isTargetInput = $(event.target).is('.sui-modal.sui-active input'); if (isTargetInput && event.keyCode === 13) { event.preventDefault(); event.stopPropagation(); if (!enterDisabled && onEnter) { onEnter(event); } } } function getTitleId() { return id + '-modal-title'; } function getHeaderActions() { const closeButton = getCloseButton(); if (small) { return closeButton; } else if (headerActions) { return headerActions; } else { return
{description}
} {children}