import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["type", "select", "multiline", "multiple", "component", "endAdornment"];
import React from "react";
import PropTypes from "prop-types";
import TextFieldBase from "./TextFieldBase";
import InputAdornment from "../InputAdornment";
import ChevronDown from "../../Icon/ChevronDown";
var TextField = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var type = props.type,
      select = props.select,
      multiline = props.multiline,
      multiple = props.multiple,
      component = props.component,
      endAdornment = props.endAdornment,
      htmlProps = _objectWithoutProperties(props, _excluded);

  if (multiline) {
    return /*#__PURE__*/React.createElement(TextFieldBase, _extends({
      component: component !== null && component !== void 0 ? component : "textarea",
      ref: ref,
      endAdornment: endAdornment
    }, htmlProps));
  }

  if (select) {
    var defaultSelectAdornment = !multiple && /*#__PURE__*/React.createElement(InputAdornment, {
      position: "end",
      isInteractive: false
    }, /*#__PURE__*/React.createElement(ChevronDown, null));
    return /*#__PURE__*/React.createElement(TextFieldBase, _extends({
      ref: ref,
      component: component !== null && component !== void 0 ? component : "select",
      endAdornment: endAdornment || defaultSelectAdornment,
      multiple: multiple
    }, htmlProps));
  }

  return /*#__PURE__*/React.createElement(TextFieldBase, _extends({
    ref: ref,
    type: type,
    component: component,
    endAdornment: endAdornment
  }, htmlProps));
});
TextField.propTypes = {
  className: PropTypes.string,
  label: PropTypes.node,
  onChange: PropTypes.func,
  select: PropTypes.bool,
  multiple: PropTypes.bool,
  multiline: PropTypes.bool,
  component: PropTypes.elementType,
  id: PropTypes.string,
  endAdornment: PropTypes.node,
  startAdornment: PropTypes.node,
  error: PropTypes.bool,
  success: PropTypes.bool,
  warning: PropTypes.bool,
  helperText: PropTypes.node
};

if (process.env.NODE_ENV !== "production") {
  TextField.displayName = "TextField";
}

export default TextField;