import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React, { forwardRef } 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 const TextField = /*#__PURE__*/forwardRef((_ref, ref) => {
  let {
    id,
    label,
    hasError,
    hint,
    onChange,
    value,
    name,
    disabled,
    readOnly,
    placeholder,
    inputProps,
    labelAlwaysShrank
  } = _ref,
      rest = _objectWithoutProperties(_ref, ["id", "label", "hasError", "hint", "onChange", "value", "name", "disabled", "readOnly", "placeholder", "inputProps", "labelAlwaysShrank"]);

  return /*#__PURE__*/React.createElement(SuperField, _extends({
    ref: ref
  }, 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));
});
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
};
TextField.displayName = 'TextField';
export default TextField;