"use strict";

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

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

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

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

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

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _injectE2E = _interopRequireDefault(require("../../Tools/injectE2E"));

var _Checkbox = _interopRequireDefault(require("./Checkbox"));

var _Radio = _interopRequireDefault(require("./Radio"));

//  strict
var Wrapper =
/*#__PURE__*/
_styledComponents.default.input.attrs({
  'data-e2e': _injectE2E.default,
  name: function name(props) {
    return props.name;
  },
  type: function type(props) {
    return props.type;
  }
}).withConfig({
  componentId: "sc-1c3roxu-0"
})(["\n  display: block;\n  width: ", ";\n  height: 2.7rem;\n  padding: 0 1.4rem;\n  box-sizing: border-box;\n  font-family: ", ";\n  font-size: 1rem;\n  color: ", ";\n  border-width: 1px;\n  border-color: ", ";\n  border-style: solid;\n  border-radius: ", ";\n  background-color: ", ";\n  background-image: none;\n  outline-width: 0;\n  user-select: text;\n\n  &:disabled {\n    color: ", ";\n    background: ", ";\n    cursor: not-allowed;\n  }\n\n  &::placeholder {\n    color: ", ";\n    font-size: 0.875rem;\n  }\n"], function (props) {
  return props.width;
}, function (props) {
  return props.theme['fontPrimary'];
}, function (props) {
  return props.theme['inputColor'];
}, function (props) {
  return props.theme['inputBorderColor'];
}, function (props) {
  return props.theme.inputBorderRadius;
}, function (props) {
  return props.theme['inputBackgroundColor'];
}, function (props) {
  return props.theme['inputColor'];
}, function (props) {
  return props.theme['inputBackgroundColor'];
}, function (props) {
  return props.theme['inputPlaceholderColor'];
});

var Input = function Input(_ref) {
  var input = _ref.input,
      type = _ref.type,
      rest = (0, _objectWithoutProperties2.default)(_ref, ["input", "type"]);

  if (type === 'checkbox') {
    return _react.default.createElement(_Checkbox.default, (0, _extends2.default)({}, input, rest, {
      type: type
    }));
  }

  if (type === 'radio') {
    return _react.default.createElement(_Radio.default, (0, _extends2.default)({}, input, rest, {
      type: type
    }));
  }

  return _react.default.createElement(Wrapper, (0, _extends2.default)({}, input, rest, {
    type: type
  }));
};

Input.propTypes = process.env.NODE_ENV !== "production" ? {
  disabled: _propTypes.default.bool,
  e2e: _propTypes.default.string,
  input: _propTypes.default.object,
  label: _propTypes.default.string,
  name: _propTypes.default.string,
  type: _propTypes.default.oneOf(['checkbox', 'date', 'number', 'password', 'radio', 'search', 'text']),
  value: _propTypes.default.string,
  width: _propTypes.default.string
} : {};
Input.defaultProps = {
  disabled: false,
  e2e: 'defaultInput',
  type: 'text',
  width: '100%'
};
var _default = Input;
exports.default = _default;