No Description

index.js 3.1KB

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