import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React from 'react';
import PropTypes from 'prop-types';
import getEventHandlersFromProps from '../utils/getEventHandlersFromProps';
import SuperField from '../SuperField';
import SuperFieldLabel from '../SuperFieldLabel';
import SuperFieldHint from '../SuperFieldHint';
import Input from '../Input';
/**
 * Convenient component for most of the TextFields. But with SuperField is simple to compose its own.
 * It just specified that this is a input field, that can have an error, hint, prefix or suffix.
 */

export var TextField = function TextField(_ref) {
  var id = _ref.id,
      label = _ref.label,
      hasError = _ref.hasError,
      hint = _ref.hint,
      onChange = _ref.onChange,
      value = _ref.value,
      name = _ref.name,
      disabled = _ref.disabled,
      readOnly = _ref.readOnly,
      placeholder = _ref.placeholder,
      inputProps = _ref.inputProps,
      labelAlwaysShrank = _ref.labelAlwaysShrank,
      rest = _objectWithoutProperties(_ref, ["id", "label", "hasError", "hint", "onChange", "value", "name", "disabled", "readOnly", "placeholder", "inputProps", "labelAlwaysShrank"]);

  return /*#__PURE__*/React.createElement(SuperField, _extends({}, rest, {
    disabled: disabled,
    readOnly: readOnly,
    hasError: hasError,
    id: id
  }), /*#__PURE__*/React.createElement(SuperFieldLabel, {
    alwaysShrank: labelAlwaysShrank
  }, label), /*#__PURE__*/React.createElement(Input, _extends({
    type: "text",
    placeholder: placeholder,
    value: value,
    name: name,
    onChange: onChange,
    disabled: disabled,
    readOnly: readOnly
  }, getEventHandlersFromProps(rest), inputProps)), /*#__PURE__*/React.createElement(SuperFieldHint, null, hint));
};
process.env.NODE_ENV !== "production" ? TextField.propTypes = {
  disabled: PropTypes.bool,
  hasError: PropTypes.bool,
  hint: PropTypes.node,
  id: PropTypes.string,
  inputProps: PropTypes.object,
  label: PropTypes.node,
  labelAlwaysShrank: PropTypes.bool,
  name: PropTypes.string,
  onChange: PropTypes.func,
  placeholder: PropTypes.string,
  readOnly: PropTypes.bool,
  value: PropTypes.any
} : void 0;
export default TextField;