'use strict';

import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import ReactDom from 'react-dom';
import Static from 'react-bootstrap/lib/FormControlStatic';
import BSFormControl from 'react-bootstrap/lib/FormControl';
import { FormControl } from './FormControl';
export var TextInputControl =
/*#__PURE__*/
function (_FormControl) {
  _inheritsLoose(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 = _objectWithoutPropertiesLoose(_this$getPropsFromCon, ["type"]);

    type = type || 'text';
    return props.readOnly ? React.createElement(Static, _extends({
      ref: "input"
    }, this.getSafeProps(props), {
      "data-test-automation-id": "input"
    }), props.value) : React.createElement(BSFormControl, _extends({}, this.getSafeProps(props), {
      "data-test-automation-id": "input",
      type: type,
      ref: "input"
    }));
  }
  /** @public */
  ;

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

  return TextInputControl;
}(FormControl);

_defineProperty(TextInputControl, "propTypes", Object.assign({}, FormControl.propTypes));

_defineProperty(TextInputControl, "defaultProps", Object.assign({}, FormControl.defaultProps, {
  maxLength: 64
}));