No Description

index.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { _ as _typeof, a as _inherits, b as _classCallCheck, c as _possibleConstructorReturn, d as _getPrototypeOf, e as _createClass } from '../inherits-6cb67931.js';
  2. import React from 'react';
  3. import { createPortal } from 'react-dom';
  4. import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
  5. function isBrowser() {
  6. return !((typeof window === "undefined" ? "undefined" : _typeof(window)) === undefined);
  7. }
  8. var css = ".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";
  9. var styles = {
  10. "wrapper": "Modal_wrapper__2hzaC",
  11. "overlay": "Modal_overlay__3iNdm",
  12. "overlayer": "Modal_overlayer__1zSH9",
  13. "container": "Modal_container__2veos"
  14. };
  15. styleInject(css);
  16. var Modal =
  17. /*#__PURE__*/
  18. function (_React$PureComponent) {
  19. _inherits(Modal, _React$PureComponent);
  20. function Modal() {
  21. _classCallCheck(this, Modal);
  22. return _possibleConstructorReturn(this, _getPrototypeOf(Modal).apply(this, arguments));
  23. }
  24. _createClass(Modal, [{
  25. key: "render",
  26. value: function render() {
  27. if (!isBrowser()) return null;
  28. var DEFAULT_CONTAINER = document.getElementById("container");
  29. var _this$props = this.props,
  30. children = _this$props.children,
  31. visible = _this$props.visible,
  32. onCancel = _this$props.onCancel,
  33. container = _this$props.container;
  34. var finalMountContainer;
  35. if (!container) {
  36. if (!DEFAULT_CONTAINER) {
  37. if (!Modal.hasShowWarning) {
  38. Modal.hasShowWarning = true;
  39. }
  40. finalMountContainer = document.body;
  41. } else {
  42. if (!Modal.hasShowWarning) {
  43. Modal.hasShowWarning = true;
  44. }
  45. finalMountContainer = DEFAULT_CONTAINER;
  46. }
  47. } else {
  48. finalMountContainer = container;
  49. }
  50. return visible && createPortal(React.createElement("div", {
  51. className: styles.wrapper
  52. }, React.createElement("div", {
  53. className: styles.overlay,
  54. onClick: onCancel
  55. }), React.createElement("div", {
  56. className: styles.container
  57. }, children)), finalMountContainer);
  58. }
  59. }]);
  60. return Modal;
  61. }(React.PureComponent);
  62. Modal.hasShowWarning = false;
  63. export default Modal;
  64. export { Modal };
  65. //# sourceMappingURL=index.js.map