12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import { a as _inherits, b as _createClass, c as _defineProperty, d as _classCallCheck, e as _possibleConstructorReturn, f as _getPrototypeOf } from '../_rollupPluginBabelHelpers-bf46fecd.js';
- import React from 'react';
- import '../style-inject.es-1f59c1d0.js';
- import { createPortal } from 'react-dom';
- import { i as isBrowser, s as styles } from '../Modal-67d33baf.js';
-
- var Modal =
- /*#__PURE__*/
- function (_React$PureComponent) {
- _inherits(Modal, _React$PureComponent);
-
- function Modal() {
- _classCallCheck(this, Modal);
-
- return _possibleConstructorReturn(this, _getPrototypeOf(Modal).apply(this, arguments));
- }
-
- _createClass(Modal, [{
- key: "render",
- value: function render() {
- if (!isBrowser()) return null; // 服务端无需渲染下列代码,渲染也会出错
-
- var DEFAULT_CONTAINER = document.getElementById('container');
- var _this$props = this.props,
- children = _this$props.children,
- visible = _this$props.visible,
- onCancel = _this$props.onCancel,
- _this$props$container = _this$props.container,
- container = _this$props$container === void 0 ? DEFAULT_CONTAINER : _this$props$container;
- var finalMountContainer = document.body;
-
- if (!container) {
- if (!DEFAULT_CONTAINER) {
- if (!Modal.hasShowWarning) {
- Modal.hasShowWarning = true;
- }
-
- finalMountContainer = document.body;
- } else {
- if (!Modal.hasShowWarning) {
- Modal.hasShowWarning = true;
- }
-
- finalMountContainer = DEFAULT_CONTAINER;
- }
- }
-
- return visible && createPortal(React.createElement("div", {
- className: styles.wrapper
- }, React.createElement("div", {
- className: styles.overlay,
- onClick: onCancel
- }), React.createElement("div", {
- className: styles.container
- }, children)), finalMountContainer);
- }
- }]);
-
- return Modal;
- }(React.PureComponent);
-
- _defineProperty(Modal, "hasShowWarning", false);
-
- export default Modal;
- export { Modal };
- //# sourceMappingURL=index.js.map
|