Нема описа

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { a as _inherits, b as _createClass, c as _defineProperty, d as _classCallCheck, e as _possibleConstructorReturn, f as _getPrototypeOf } from '../_rollupPluginBabelHelpers-bf46fecd.js';
  2. import React from 'react';
  3. import '../style-inject.es-1f59c1d0.js';
  4. import { createPortal } from 'react-dom';
  5. import { i as isBrowser, s as styles } from '../Modal-67d33baf.js';
  6. var Modal =
  7. /*#__PURE__*/
  8. function (_React$PureComponent) {
  9. _inherits(Modal, _React$PureComponent);
  10. function Modal() {
  11. _classCallCheck(this, Modal);
  12. return _possibleConstructorReturn(this, _getPrototypeOf(Modal).apply(this, arguments));
  13. }
  14. _createClass(Modal, [{
  15. key: "render",
  16. value: function render() {
  17. if (!isBrowser()) return null; // 服务端无需渲染下列代码,渲染也会出错
  18. var DEFAULT_CONTAINER = document.getElementById('container');
  19. var _this$props = this.props,
  20. children = _this$props.children,
  21. visible = _this$props.visible,
  22. onCancel = _this$props.onCancel,
  23. _this$props$container = _this$props.container,
  24. container = _this$props$container === void 0 ? DEFAULT_CONTAINER : _this$props$container;
  25. var finalMountContainer = document.body;
  26. if (!container) {
  27. if (!DEFAULT_CONTAINER) {
  28. if (!Modal.hasShowWarning) {
  29. Modal.hasShowWarning = true;
  30. }
  31. finalMountContainer = document.body;
  32. } else {
  33. if (!Modal.hasShowWarning) {
  34. Modal.hasShowWarning = true;
  35. }
  36. finalMountContainer = DEFAULT_CONTAINER;
  37. }
  38. }
  39. return visible && createPortal(React.createElement("div", {
  40. className: styles.wrapper
  41. }, React.createElement("div", {
  42. className: styles.overlay,
  43. onClick: onCancel
  44. }), React.createElement("div", {
  45. className: styles.container
  46. }, children)), finalMountContainer);
  47. }
  48. }]);
  49. return Modal;
  50. }(React.PureComponent);
  51. _defineProperty(Modal, "hasShowWarning", false);
  52. export default Modal;
  53. export { Modal };
  54. //# sourceMappingURL=index.js.map