'use strict';

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

exports.__esModule = true;
exports.TextInputControl = void 0;

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

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

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

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

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

var _reactDom = _interopRequireDefault(require("react-dom"));

var _FormControlStatic = _interopRequireDefault(require("react-bootstrap/lib/FormControlStatic"));

var _FormControl2 = _interopRequireDefault(require("react-bootstrap/lib/FormControl"));

var _FormControl3 = require("./FormControl");

var TextInputControl =
/*#__PURE__*/
function (_FormControl) {
  (0, _inheritsLoose2.default)(TextInputControl, _FormControl);

  function TextInputControl() {
    return _FormControl.apply(this, arguments) || this;
  }

  var _proto = TextInputControl.prototype;

  _proto.render = function render() {
    var _this$getPropsFromCon = this.getPropsFromContext(),
        type = _this$getPropsFromCon.type,
        props = (0, _objectWithoutPropertiesLoose2.default)(_this$getPropsFromCon, ["type"]);

    type = type || 'text';
    return props.readOnly ? _react.default.createElement(_FormControlStatic.default, (0, _extends2.default)({
      ref: "input"
    }, this.getSafeProps(props), {
      "data-test-automation-id": "input"
    }), props.value) : _react.default.createElement(_FormControl2.default, (0, _extends2.default)({}, this.getSafeProps(props), {
      "data-test-automation-id": "input",
      type: type,
      ref: "input"
    }));
  }
  /** @public */
  ;

  _proto.triggerFocus = function triggerFocus() {
    _reactDom.default.findDOMNode(this.refs.input).focus();
  };

  return TextInputControl;
}(_FormControl3.FormControl);

exports.TextInputControl = TextInputControl;
(0, _defineProperty2.default)(TextInputControl, "propTypes", Object.assign({}, _FormControl3.FormControl.propTypes));
(0, _defineProperty2.default)(TextInputControl, "defaultProps", Object.assign({}, _FormControl3.FormControl.defaultProps, {
  maxLength: 64
}));