/var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/components
Edit: /var/softaculous/sitepad/editor/site-data/plugins/pagelayer/js/react/src/components/modal.js (1854B)
import { LabelControl } from './label';
import { useState, useRef, useEffect } from '@wordpress/element';
import { Popover } from '@wordpress/components';
export const ModalControl = (props) => {
const { prop, children, label } = props;
const { width } = prop;
const [isModalVisible, setIsModalVisible] = useState(false);
const modalRef = useRef(null);
const modalIconRef = useRef(null);
useEffect(() => {
const handleDocumentClick = (e) => {
// Access Modal Handler
if (
modalRef.current &&
!modalRef.current.contains(e.target) &&
modalIconRef.current &&
!modalIconRef.current.contains(e.target)
) {
setIsModalVisible(false);
}
};
document.addEventListener('click', handleDocumentClick);
return () => {
document.removeEventListener('click', handleDocumentClick);
};
}, []);
var style = pagelayer_empty(width) ? {} : {width: width};
return (
setIsModalVisible(true)}
ref={ modalIconRef }
>
{isModalVisible && (
{ label }
setIsModalVisible(false)}>
{ children }
) }
)
}