UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 1.14 kB
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useRef as r,useEffect as s}from"../../../external/preact/hooks/dist/hooks.js";import o from"../../../_virtual/index.js";import{useModal as a}from"./useModal.js";const t=({children:t,classNameModifiers:i=[],isOpen:l,onClose:n,isDismissible:c=!0,labelledBy:d,describedBy:m,focusFirst:p,focusAfterClose:u,...f})=>{const k=r(),{closeModal:y,handleClickOutside:h}=a({modalElement:k.current,isOpen:l,isDismissible:c,focusFirst:p,focusAfterClose:u,onClose:n});return s(()=>{if(!k.current)return;const e=e=>{"Enter"!==e.key&&"Enter"!==e.code||e.stopPropagation()};return k.current.addEventListener("keypress",e,{capture:!0}),()=>{k.current.removeEventListener("keypress",e)}},[k.current]),e("div",{className:o("adyen-checkout__modal-wrapper",i.map(e=>`adyen-checkout__modal-wrapper--${e}`),{"adyen-checkout__modal-wrapper--open":l}),role:"dialog","aria-labelledby":d,"aria-describedby":m,"aria-modal":"true","aria-hidden":!l,onClick:h,...f},e("div",{className:"adyen-checkout__modal",ref:k},t({onCloseModal:y})))};export{t as Modal}; //# sourceMappingURL=Modal.js.map