Brak opisu

index.js 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. _this$props$container = _this$props.container,
  39. container = _this$props$container === void 0 ? DEFAULT_CONTAINER : _this$props$container;
  40. var finalMountContainer = document.body;
  41. if (!container) {
  42. if (!DEFAULT_CONTAINER) {
  43. if (!Modal.hasShowWarning) {
  44. Modal.hasShowWarning = true;
  45. }
  46. finalMountContainer = document.body;
  47. } else {
  48. if (!Modal.hasShowWarning) {
  49. Modal.hasShowWarning = true;
  50. }
  51. finalMountContainer = DEFAULT_CONTAINER;
  52. }
  53. }
  54. return visible && reactDom.createPortal(React__default.createElement("div", {
  55. className: styles.wrapper
  56. }, React__default.createElement("div", {
  57. className: styles.overlay,
  58. onClick: onCancel
  59. }), React__default.createElement("div", {
  60. className: styles.container
  61. }, children)), finalMountContainer);
  62. }
  63. }]);
  64. return Modal;
  65. }(React__default.PureComponent);
  66. Modal.hasShowWarning = false;
  67. exports.Modal = Modal;
  68. exports.default = Modal;
  69. //# sourceMappingURL=index.js.map