暫無描述

index.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var _rollupPluginBabelHelpers = require('../_rollupPluginBabelHelpers-3469b70d.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. require('../style-inject.es-dcee06b6.js');
  8. var reactDom = require('react-dom');
  9. var reactDom__default = _interopDefault(reactDom);
  10. var Modal$1 = require('../Modal-1001074b.js');
  11. var Modal =
  12. /*#__PURE__*/
  13. function (_React$PureComponent) {
  14. _rollupPluginBabelHelpers._inherits(Modal, _React$PureComponent);
  15. function Modal() {
  16. _rollupPluginBabelHelpers._classCallCheck(this, Modal);
  17. return _rollupPluginBabelHelpers._possibleConstructorReturn(this, _rollupPluginBabelHelpers._getPrototypeOf(Modal).apply(this, arguments));
  18. }
  19. _rollupPluginBabelHelpers._createClass(Modal, [{
  20. key: "render",
  21. value: function render() {
  22. if (!Modal$1.isBrowser()) return null; // 服务端无需渲染下列代码,渲染也会出错
  23. var DEFAULT_CONTAINER = document.getElementById('container');
  24. var _this$props = this.props,
  25. children = _this$props.children,
  26. visible = _this$props.visible,
  27. onCancel = _this$props.onCancel,
  28. _this$props$container = _this$props.container,
  29. container = _this$props$container === void 0 ? DEFAULT_CONTAINER : _this$props$container;
  30. var finalMountContainer = document.body;
  31. if (!container) {
  32. if (!DEFAULT_CONTAINER) {
  33. if (!Modal.hasShowWarning) {
  34. Modal.hasShowWarning = true;
  35. }
  36. finalMountContainer = document.body;
  37. } else {
  38. if (!Modal.hasShowWarning) {
  39. Modal.hasShowWarning = true;
  40. }
  41. finalMountContainer = DEFAULT_CONTAINER;
  42. }
  43. }
  44. return visible && reactDom.createPortal(React__default.createElement("div", {
  45. className: Modal$1.styles.wrapper
  46. }, React__default.createElement("div", {
  47. className: Modal$1.styles.overlay,
  48. onClick: onCancel
  49. }), React__default.createElement("div", {
  50. className: Modal$1.styles.container
  51. }, children)), finalMountContainer);
  52. }
  53. }]);
  54. return Modal;
  55. }(React__default.PureComponent);
  56. _rollupPluginBabelHelpers._defineProperty(Modal, "hasShowWarning", false);
  57. exports.Modal = Modal;
  58. exports.default = Modal;
  59. //# sourceMappingURL=index.js.map