var _excluded = ["portal", "show", "maskAttribute", "icon", "caption", "captionAttribute"];

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { createPortal } from 'react-dom';

var Toast = /*#__PURE__*/function (_Component) {
  _inheritsLoose(Toast, _Component);

  function Toast(props) {
    var _this;

    _this = _Component.call(this, props) || this;

    _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () {});

    return _this;
  }

  var _proto = Toast.prototype;

  _proto.render = function render() {
    var _this2 = this;

    var _this$props = this.props,
        portal = _this$props.portal,
        show = _this$props.show,
        _this$props$maskAttri = _this$props.maskAttribute,
        maskAttribute = _this$props$maskAttri === void 0 ? {} : _this$props$maskAttri,
        icon = _this$props.icon,
        caption = _this$props.caption,
        _this$props$captionAt = _this$props.captionAttribute,
        captionAttribute = _this$props$captionAt === void 0 ? {} : _this$props$captionAt,
        others = _objectWithoutPropertiesLoose(_this$props, _excluded);

    return createPortal( /*#__PURE__*/React.createElement("div", _extends({
      ref: function ref(el) {
        _this2.$el = el;
      }
    }, maskAttribute, {
      className: "mask toast-mask" + (maskAttribute.className ? ' ' + maskAttribute.className : '') + (show ? ' active' : '')
    }), /*#__PURE__*/React.createElement("div", _extends({}, others, {
      className: "toast" + (others.className ? ' ' + others.className : '') + (show ? ' active' : '')
    }), /*#__PURE__*/React.createElement("div", {
      className: "toast-wrapper"
    }, icon, caption && /*#__PURE__*/React.createElement("span", _extends({}, captionAttribute, {
      className: "toast-caption" + (captionAttribute.className ? ' ' + captionAttribute.className : '')
    }), caption)))), this.props.portal || document.getElementById('root') || document.body);
  };

  return Toast;
}(Component);

_defineProperty(Toast, "defaultProps", {});

export { Toast as default };
Toast.propTypes = process.env.NODE_ENV !== "production" ? {
  portal: PropTypes.object,
  show: PropTypes.bool,
  maskAttribute: PropTypes.object,
  caption: PropTypes.node,
  captionAttribute: PropTypes.object,
  icon: PropTypes.node
} : {};