1 |
- {"version":3,"file":"index.js","sources":["../../src/components/Common/Utils/utils.ts","../../src/components/Common/Modal/index.tsx"],"sourcesContent":["export function isBrowser() {\n return !(typeof window === undefined);\n}","import React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { isBrowser } from \"../Utils/utils\";\n\nimport styles from \"./Modal.less\";\n\nexport interface ModalProps {\n visible: boolean;\n onCancel: (e: any) => void;\n container?: HTMLElement;\n}\n\nexport class Modal extends React.PureComponent<ModalProps> {\n static hasShowWarning = false;\n\n render() {\n if (!isBrowser()) return null; // 服务端无需渲染下列代码,渲染也会出错\n const DEFAULT_CONTAINER: HTMLElement | null = document.getElementById(\n \"container\"\n );\n const { children, visible, onCancel, container } = this.props;\n let finalMountContainer: HTMLElement;\n if (!container) {\n if (!DEFAULT_CONTAINER) {\n if (!Modal.hasShowWarning) {\n Modal.hasShowWarning = true;\n }\n finalMountContainer = document.body;\n } else {\n if (!Modal.hasShowWarning) {\n Modal.hasShowWarning = true;\n }\n finalMountContainer = DEFAULT_CONTAINER;\n }\n } else {\n finalMountContainer = container;\n }\n return (\n visible &&\n createPortal(\n <div className={styles.wrapper}>\n <div className={styles.overlay} onClick={onCancel} />\n <div className={styles.container}>{children}</div>\n </div>,\n finalMountContainer\n )\n );\n }\n}\n\nexport default Modal;\n"],"names":["isBrowser","window","undefined","Modal","DEFAULT_CONTAINER","document","getElementById","props","children","visible","onCancel","container","finalMountContainer","hasShowWarning","body","createPortal","React","createElement","className","styles","wrapper","overlay","onClick","PureComponent"],"mappings":";;;;;AAAM,SAAUA,SAAV,GAAmB;SAChB,EAAE,QAAOC,+CAAAA,OAAP,MAAkBC,SAApB;;;;;;;;;;;;ICWIC,KAAb;AAAA;AAAA,8BAAA;;;;;;;;;;;6BAGQ;UACA,CAACH,SAAS,IAAI,OAAO,IAAP;UACZI,iBAAiB,GAAuBC,QAAQ,CAACC,cAAT,CAC5C,WAD4C;wBAGK,KAAKC;UAAhDC,QALJ,eAKIA;UAAUC,OALd,eAK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