Keine Beschreibung

index.js.map 2.7KB

1
  1. {"version":3,"file":"index.js","sources":["../../src/components/Common/Modal/index.tsx"],"sourcesContent":["import React from 'react';\r\nimport { createPortal } from 'react-dom';\r\nimport { isBrowser } from '../Utils/utils';\r\n\r\nimport styles from './Modal.less';\r\n\r\nexport interface ModalProps {\r\n visible: boolean\r\n onCancel: (e: any) => void\r\n container?: HTMLElement | null\r\n}\r\n\r\nexport class Modal extends React.PureComponent<ModalProps> {\r\n static hasShowWarning = false;\r\n\r\n render() {\r\n if (!isBrowser()) return null; // 服务端无需渲染下列代码,渲染也会出错\r\n const DEFAULT_CONTAINER: HTMLElement | null = document.getElementById('container');\r\n const { children, visible, onCancel, container = DEFAULT_CONTAINER } = this.props\r\n let finalMountContainer: HTMLElement = document.body;\r\n if (!container) {\r\n if (!DEFAULT_CONTAINER) {\r\n if (!Modal.hasShowWarning) {\r\n Modal.hasShowWarning = true;\r\n }\r\n finalMountContainer = document.body;\r\n } else {\r\n if (!Modal.hasShowWarning) {\r\n Modal.hasShowWarning = true;\r\n }\r\n finalMountContainer = DEFAULT_CONTAINER;\r\n }\r\n }\r\n return visible && createPortal(\r\n <div className={ styles.wrapper }>\r\n <div\r\n className={ styles.overlay }\r\n onClick={ onCancel }\r\n />\r\n <div\r\n className={ styles.container }\r\n >\r\n { children }\r\n </div>\r\n </div>,\r\n finalMountContainer,\r\n )\r\n }\r\n}\r\n\r\nexport default Modal;"],"names":["Modal","isBrowser","DEFAULT_CONTAINER","document","getElementById","props","children","visible","onCancel","container","finalMountContainer","body","hasShowWarning","createPortal","React","styles","wrapper","overlay","PureComponent"],"mappings":";;;;;;;;;;;;;;IAYaA,KAAb;;AAAA;;;;;;;;;;;6BAGW;UACH,CAACC,iBAAS,EAAd,EAAkB,OAAO,IAAP,CADX;;UAEDC,iBAAqC,GAAGC,QAAQ,CAACC,cAAT,CAAwB,WAAxB,CAA9C;wBACuE,KAAKC,KAHrE;UAGCC,QAHD,eAGCA,QAHD;UAGWC,OAHX,eAGWA,OAHX;UAGoBC,QAHpB,eAGoBA,QAHpB;8CAG8BC,SAH9B;UAG8BA,SAH9B,sCAG0CP,iBAH1C;UAIHQ,mBAAgC,GAAGP,QAAQ,CAACQ,IAAhD;;UACI,CAACF,SAAL,EAAgB;YACV,CAACP,iBAAL,EAAwB;cAClB,CAACF,KAAK,CAACY,cAAX,EAA2B;YACzBZ,KAAK,CAACY,cAAN,GAAuB,IAAvB;;;UAEFF,mBAAmB,GAAGP,QAAQ,CAACQ,IAA/B;SAJF,MAKO;cACD,CAACX,KAAK,CAACY,cAAX,EAA2B;YACzBZ,KAAK,CAACY,cAAN,GAAuB,IAAvB;;;UAEFF,mBAAmB,GAAGR,iBAAtB;;;;aAGGK,OAAO,IAAIM,qBAAY,CAC5BC;QAAK,SAAS,EAAGC,cAAM,CAACC;SACtBF;QACE,SAAS,EAAGC,cAAM,CAACE,OADrB;QAEE,OAAO,EAAGT;QAHd,EAKEM;QACE,SAAS,EAAGC,cAAM,CAACN;SAEjBH,QAHJ,CALF,CAD4B,EAY5BI,mBAZ4B,CAA9B;;;;;EArBuBI,cAAK,CAACI,aAAjC;;0CAAalB,yBACa;;;;;"}