"use strict";

exports.__esModule = true;
exports.default = void 0;
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _uniqueId2 = _interopRequireDefault(require("lodash/fp/uniqueId"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _loader = _interopRequireDefault(require("../../atom/loader"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
class BrandUploadBox extends _react.default.Component {
  constructor(props) {
    super(props);
    this.state = {
      dragging: false
    };
    this.handleDragStart = this.handleDragStart.bind(this);
    this.handleDragStop = this.handleDragStop.bind(this);
  }
  handleDragStart() {
    this.setState({
      dragging: true
    });
  }
  handleDragStop() {
    this.setState({
      dragging: false
    });
  }
  render() {
    const idBox = (0, _uniqueId2.default)('drop-box-');
    const {
      skin
    } = this.context;
    const {
      status
    } = this.props;
    const {
      dragging
    } = this.state;
    let content;
    const {
      description = '',
      browse = '',
      onLoad,
      name
    } = this.props;
    const brandColor = (0, _get2.default)('common.brand', skin);
    switch (status) {
      case 'loading':
        content = /*#__PURE__*/_react.default.createElement("div", {
          className: _style.default.loading
        }, /*#__PURE__*/_react.default.createElement(_loader.default, null));
        break;
      default:
        content = /*#__PURE__*/_react.default.createElement("div", {
          className: _style.default.wrapper
        }, /*#__PURE__*/_react.default.createElement("div", {
          id: idBox,
          className: dragging ? _style.default.dropping : _style.default.defaultStyle
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: _style.default.cont
        }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidDataTransferDataUpload1, {
          style: {
            color: brandColor
          },
          className: _style.default.arrow
        }), /*#__PURE__*/_react.default.createElement("div", {
          className: _style.default.desc
        }, description), /*#__PURE__*/_react.default.createElement("span", {
          className: _style.default.browse
        }, browse)), /*#__PURE__*/_react.default.createElement("input", {
          type: "file",
          name: name,
          className: _style.default.inputFile,
          onChange: onLoad,
          onDragEnter: this.handleDragStart,
          onDrop: this.handleDragStop,
          onDragLeave: this.handleDragStop
        })));
    }
    return content;
  }
}
BrandUploadBox.propTypes = process.env.NODE_ENV !== "production" ? {
  name: _propTypes.default.string,
  description: _propTypes.default.string,
  browse: _propTypes.default.string,
  status: _propTypes.default.oneOf(['default', 'loading']),
  onLoad: _propTypes.default.func
} : {};
var _default = exports.default = BrandUploadBox;
//# sourceMappingURL=index.js.map