"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.Loader = void 0;

var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _Spinner = require("./Spinner/Spinner");

var Loader =
/*#__PURE__*/
function (_PureComponent) {
  (0, _inheritsLoose2.default)(Loader, _PureComponent);

  function Loader() {
    return _PureComponent.apply(this, arguments) || this;
  }

  var _proto = Loader.prototype;

  _proto.renderContent = function renderContent() {
    var children = this.props.children;

    if (!children || typeof children === 'string' && !children.trim()) {
      return null;
    }

    return _react.default.createElement("div", {
      className: "loader-content"
    }, children);
  };

  _proto.render = function render() {
    var size = this.props.size;
    return _react.default.createElement("div", {
      className: "loader-overlay"
    }, _react.default.createElement("div", {
      className: "loader-wrapper"
    }, _react.default.createElement("div", {
      className: "loader"
    }, _react.default.createElement(_Spinner.Spinner, {
      size: size
    }), this.renderContent())));
  };

  return Loader;
}(_react.PureComponent);

exports.Loader = Loader;
(0, _defineProperty2.default)(Loader, "propTypes", {
  children: _propTypes.default.node,
  size: _propTypes.default.number
});
(0, _defineProperty2.default)(Loader, "defaultProps", {
  children: null,
  size: 32
});