UNPKG

@shopgate/pwa-common

Version:

Common library for the Shopgate Connect PWA.

7 lines 978 B
import React from'react';import PropTypes from'prop-types';import connect from"./connector";export var MODAL_EVENTS={SHOW:'Modal.show',HIDE:'Modal.hide'};/** * The ModalContainer is connected to the modal state * and renders the currently active modal. * @param {Object} props The component props. * @returns {JSX.Element} */var ModalContainer=function ModalContainer(_ref){var component=_ref.component,confirm=_ref.confirm,dismiss=_ref.dismiss,modal=_ref.modal;if(!modal){return null;}var componentProps={modal:modal,// A11Y focus is handled by the modal container itself. onConfirm:function onConfirm(){return confirm(modal.id);},onDismiss:function onDismiss(){return dismiss(modal.id);}};if(React.isValidElement(component)){return React.cloneElement(component,componentProps);}return React.createElement(component,componentProps);};ModalContainer.defaultProps={confirm:function confirm(){},dismiss:function dismiss(){},modal:null};export default connect(ModalContainer);