No Description

index.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {
  2. _ as _typeof,
  3. a as _inherits,
  4. b as _classCallCheck,
  5. c as _possibleConstructorReturn,
  6. d as _getPrototypeOf,
  7. e as _createClass
  8. } from "../inherits-6cb67931.js";
  9. import React from "react";
  10. import { createPortal } from "react-dom";
  11. import { s as styleInject } from "../style-inject.es-1f59c1d0.js";
  12. function isBrowser() {
  13. return !(
  14. (typeof window === "undefined" ? "undefined" : _typeof(window)) ===
  15. undefined
  16. );
  17. }
  18. var css =
  19. ".Modal_wrapper__2hzaC {\n position: fixed;\n width: 100vw;\n height: 100vh;\n top: 0;\n left: 0;\n z-index: 1000;\n}\n.Modal_overlay__3iNdm {\n width: 100vw;\n height: 100vh;\n background: #000;\n animation: Modal_overlayer__1zSH9 0.3s forwards;\n}\n.Modal_container__2veos {\n position: absolute;\n top: 20%;\n left: 50%;\n animation: Modal_container__2veos 0.3s forwards;\n}\n@keyframes Modal_overlayer__1zSH9 {\n from {\n opacity: 0;\n }\n to {\n opacity: 0.3;\n }\n}\n@keyframes Modal_container__2veos {\n from {\n transform: translateX(-50%) scale(0, 0);\n }\n to {\n transform: translateX(-50%) scale(1, 1);\n }\n}\n";
  20. var styles = {
  21. wrapper: "Modal_wrapper__2hzaC",
  22. overlay: "Modal_overlay__3iNdm",
  23. overlayer: "Modal_overlayer__1zSH9",
  24. container: "Modal_container__2veos"
  25. };
  26. styleInject(css);
  27. var Modal =
  28. /*#__PURE__*/
  29. (function(_React$PureComponent) {
  30. _inherits(Modal, _React$PureComponent);
  31. function Modal() {
  32. _classCallCheck(this, Modal);
  33. return _possibleConstructorReturn(
  34. this,
  35. _getPrototypeOf(Modal).apply(this, arguments)
  36. );
  37. }
  38. _createClass(Modal, [
  39. {
  40. key: "render",
  41. value: function render() {
  42. if (!isBrowser()) return null;
  43. var DEFAULT_CONTAINER = document.getElementById("container");
  44. var _this$props = this.props,
  45. children = _this$props.children,
  46. visible = _this$props.visible,
  47. onCancel = _this$props.onCancel,
  48. _this$props$container = _this$props.container,
  49. container =
  50. _this$props$container === void 0
  51. ? DEFAULT_CONTAINER
  52. : _this$props$container;
  53. var finalMountContainer = document.body;
  54. if (!container) {
  55. if (!DEFAULT_CONTAINER) {
  56. if (!Modal.hasShowWarning) {
  57. Modal.hasShowWarning = true;
  58. }
  59. finalMountContainer = document.body;
  60. } else {
  61. if (!Modal.hasShowWarning) {
  62. Modal.hasShowWarning = true;
  63. }
  64. finalMountContainer = DEFAULT_CONTAINER;
  65. }
  66. }
  67. return (
  68. visible &&
  69. createPortal(
  70. React.createElement(
  71. "div",
  72. {
  73. className: styles.wrapper
  74. },
  75. React.createElement("div", {
  76. className: styles.overlay,
  77. onClick: onCancel
  78. }),
  79. React.createElement(
  80. "div",
  81. {
  82. className: styles.container
  83. },
  84. children
  85. )
  86. ),
  87. finalMountContainer
  88. )
  89. );
  90. }
  91. }
  92. ]);
  93. return Modal;
  94. })(React.PureComponent);
  95. Modal.hasShowWarning = false;
  96. export default Modal;
  97. export { Modal };
  98. //# sourceMappingURL=index.js.map