暫無描述

1
  1. {"version":3,"file":"index.js","sources":["../../src/components/Common/Utils/utils.ts","../../src/components/Common/Modal/index.tsx"],"sourcesContent":["export function isBrowser() {\r\n return !(typeof window === undefined);\r\n}","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":["isBrowser","window","undefined","Modal","DEFAULT_CONTAINER","document","getElementById","props","children","visible","onCancel","container","finalMountContainer","body","hasShowWarning","createPortal","React","createElement","className","styles","wrapper","overlay","onClick","PureComponent"],"mappings":";;;;;;;;;;;;;AAAM,SAAUA,SAAV,GAAmB;SAChB,EAAE,QAAOC,wDAAAA,OAAP,MAAkBC,SAApB;;;;;;;;;;;;ICWIC,KAAb;AAAA;AAAA,8BAAA;;;;;;;;;;;6BAGQ;UACA,CAACH,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