'use strict';

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

var _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; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

var _selectArrow = require('../Images/img/select-arrow.png');

var _selectArrow2 = _interopRequireDefault(_selectArrow);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var BaseSelectInput = _styledComponents2.default.select.withConfig({
  displayName: 'NativeSelect__BaseSelectInput'
})(['height:30px;width:160px;font-size:13px;font-weight:300;padding:2px 6px;outline:none;appearance:none;border-radius:3px;background-image:url(', ');background-size:12px;background-repeat:no-repeat;background-position:center right 10px;color:', ';font-family:\'Montserrat\',Helvetica,sans-serif;background-color:', ';border:1px solid ', ';margin-left:', ';&:active,&:focus{border:1px solid ', ';}'], _selectArrow2.default, function (props) {
  return props.theme['gray-5'];
}, function (props) {
  return props.theme['white'];
}, function (props) {
  return props.theme['gray-2'];
}, function (props) {
  return props.inline ? '5px' : '0px';
}, function (props) {
  return props.theme['brand-secondary'];
});

var selectBorderColor = function selectBorderColor(state) {
  switch (state) {
    case 'initial':
      return 'gray-2';
    case 'invalid':
      return 'error';
    case 'valid':
      return 'success';
    default:
      return 'gray-2';
  }
};

var SelectInput = function SelectInput(props) {
  var errorState = props.errorState,
      disabled = props.disabled,
      input = props.input,
      rest = _objectWithoutProperties(props, ['errorState', 'disabled', 'input']);

  var borderColor = selectBorderColor(errorState);

  return _react2.default.createElement(BaseSelectInput, _extends({ inline: true, borderColor: borderColor, disabled: disabled, onChange: input.onChange }, rest));
};

exports.default = SelectInput;