'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp;

var _immutable = require('immutable');

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactDropzone = require('react-dropzone');

var _reactDropzone2 = _interopRequireDefault(_reactDropzone);

var _lib = require('@instructure/ui-themeable/lib');

var _lib2 = _interopRequireDefault(_lib);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.file_selector__styles__dropzone {\n  background-color: ' + theme.dropzoneBackgroundColor + ';\n  border: ' + theme.dropzoneBorderWidth + ' dashed ' + theme.dropzoneBorderColor + ';\n  cursor: pointer;\n  padding: ' + theme.dropzonePadding + ';\n}\n';
  },
  'dropzone': 'file_selector__styles__dropzone'
};
var FileSelector = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(FileSelector, _Component);

  function FileSelector() {
    (0, _classCallCheck3.default)(this, FileSelector);

    var _this = (0, _possibleConstructorReturn3.default)(this, (FileSelector.__proto__ || Object.getPrototypeOf(FileSelector)).call(this));

    _this.onDrop = _this.onDrop.bind(_this);
    return _this;
  }

  (0, _createClass3.default)(FileSelector, [{
    key: 'onDrop',
    value: function onDrop(files) {
      this.props.fileHandler((0, _immutable.List)(files));
    }
  }, {
    key: 'renderContent',
    value: function renderContent() {
      return this.props.content;
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        'div',
        null,
        _react2.default.createElement(
          _reactDropzone2.default,
          {
            className: styles.dropzone,
            multiple: this.props.multiple,
            onDrop: this.onDrop,
            accept: this.props.acceptAttribute
          },
          this.renderContent()
        )
      );
    }
  }]);
  FileSelector.displayName = 'FileSelector'
  ;
  return FileSelector;
}(_react.Component), _class2.propTypes = {
  acceptAttribute: _propTypes2.default.string.isRequired,
  content: _propTypes2.default.node.isRequired,
  fileHandler: _propTypes2.default.func.isRequired,
  multiple: _propTypes2.default.bool
}, _class2.defaultProps = {
  multiple: false
}, _temp)) || _class);
exports.default = FileSelector;