import { useState, useRef, useEffect } from 'react'; import { arrayToClassName } from 'elementor-app/utils/utils.js'; import Button from 'elementor-app/ui/molecules/button'; import Grid from 'elementor-app/ui/grid/grid'; import Icon from 'elementor-app/ui/atoms/icon'; import Text from 'elementor-app/ui/atoms/text'; import ModalSection from './modal-section'; import ModalTip from './modal-tip'; import './modal.scss'; export default function ModalProvider( props ) { const [ show, setShow ] = useState( props.show ), hideModal = () => { setShow( false ); // The purpose of the props.setShow is to sync an external state with the component inner state. if ( props.setShow ) { props.setShow( false ); } }, showModal = () => { setShow( true ); // The purpose of the props.setShow is to sync an external state with the component inner state. if ( props.setShow ) { props.setShow( true ); } }, modalAttrs = { ...props, show, hideModal, showModal, }; useEffect( () => { // Sync with external state. setShow( props.show ); }, [ props.show ] ); return ( <> { props.toggleButtonProps &&