"use strict";

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

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

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

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

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

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 _reactDropzone = _interopRequireDefault(require("react-dropzone"));

var _utils = require("../../../utils");

var _Block = require("../Block");

var _Button = require("../Button");

// for full documentation visit https://react-dropzone.js.org/#dropzone
var Dropzone =
/*#__PURE__*/
function (_Component) {
  (0, _inheritsLoose2.default)(Dropzone, _Component);

  function Dropzone() {
    return _Component.apply(this, arguments) || this;
  }

  var _proto = Dropzone.prototype;

  _proto.renderContent = function renderContent() {
    var _this$props = this.props,
        children = _this$props.children,
        contentClassname = _this$props.contentClassname,
        dragText = _this$props.dragText,
        orText = _this$props.orText;

    if (children) {
      return _react.default.createElement("div", {
        className: contentClassname
      }, children);
    }

    return _react.default.createElement("div", {
      className: contentClassname
    }, _react.default.createElement(_Block.Block, {
      condensed: true
    }, _react.default.createElement("span", {
      className: "rc-dropzone-caption"
    }, (0, _utils.translate)(dragText))), _react.default.createElement(_Block.Block, {
      condensed: true
    }, _react.default.createElement("span", {
      className: "rc-dropzone-or"
    }, (0, _utils.translate)(orText))), _react.default.createElement(_Button.Button, null, "Upload File"));
  };

  _proto.render = function render() {
    var _this$props2 = this.props,
        testAutomationId = _this$props2.testAutomationId,
        restProps = (0, _objectWithoutPropertiesLoose2.default)(_this$props2, ["testAutomationId"]);
    return _react.default.createElement(_reactDropzone.default, (0, _extends2.default)({}, restProps, {
      className: "rc-dropzone",
      activeClassName: "rc-dropzone-active",
      acceptClassName: "rc-dropzone-accept",
      rejectClassName: "rc-dropzone-reject",
      disabledClassName: "rc-dropzone-disabled",
      "data-test-automation-id": testAutomationId
    }), this.renderContent());
  };

  return Dropzone;
}(_react.Component);

exports.Dropzone = Dropzone;
(0, _defineProperty2.default)(Dropzone, "propTypes", Object.assign({}, _reactDropzone.default.propTypes, {
  contentClassname: _propTypes.default.string,
  testAutomationId: _propTypes.default.string,
  dragText: _propTypes.default.string,
  orText: _propTypes.default.string
}));
(0, _defineProperty2.default)(Dropzone, "defaultProps", {
  contentClassname: 'rc-dropzone-content',
  testAutomationId: 'dropzone',
  dragText: 'TRANSLATE:DRAG_FILES_HERE',
  orText: 'TRANSLATE:OR'
});