import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
//  strict
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import injectE2E from '../../Tools/injectE2E';
import Checkbox from './Checkbox';
import Radio from './Radio';
var Wrapper =
/*#__PURE__*/
styled.input.attrs({
  'data-e2e': injectE2E,
  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 = _objectWithoutProperties(_ref, ["input", "type"]);

  if (type === 'checkbox') {
    return React.createElement(Checkbox, _extends({}, input, rest, {
      type: type
    }));
  }

  if (type === 'radio') {
    return React.createElement(Radio, _extends({}, input, rest, {
      type: type
    }));
  }

  return React.createElement(Wrapper, _extends({}, input, rest, {
    type: type
  }));
};

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