"use strict";

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

exports.__esModule = true;
exports.default = exports.TextField = void 0;

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

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

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

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

var _SuperField = _interopRequireDefault(require("../SuperField"));

var _SuperFieldLabel = _interopRequireDefault(require("../SuperFieldLabel"));

var _SuperFieldHint = _interopRequireDefault(require("../SuperFieldHint"));

var _Input = _interopRequireDefault(require("../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.
 */
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 = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["id", "label", "hasError", "hint", "onChange", "value", "name", "disabled", "readOnly", "placeholder", "inputProps", "labelAlwaysShrank"]);
  return _react.default.createElement(_SuperField.default, (0, _extends2.default)({}, rest, {
    disabled: disabled,
    readOnly: readOnly,
    hasError: hasError,
    id: id
  }), _react.default.createElement(_SuperFieldLabel.default, {
    alwaysShrank: labelAlwaysShrank
  }, label), _react.default.createElement(_Input.default, (0, _extends2.default)({
    type: "text",
    placeholder: placeholder,
    value: value,
    name: name,
    onChange: onChange,
    disabled: disabled,
    readOnly: readOnly
  }, inputProps)), _react.default.createElement(_SuperFieldHint.default, null, hint));
};

exports.TextField = TextField;
TextField.propTypes = {
  disabled: _propTypes.default.bool,
  hasError: _propTypes.default.bool,
  hint: _propTypes.default.node,
  id: _propTypes.default.string,
  inputProps: _propTypes.default.object,
  label: _propTypes.default.node,
  labelAlwaysShrank: _propTypes.default.bool,
  name: _propTypes.default.string,
  onChange: _propTypes.default.func,
  placeholder: _propTypes.default.string,
  readOnly: _propTypes.default.bool,
  value: _propTypes.default.any.isRequired
};
var _default = TextField;
exports.default = _default;