"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

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

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

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

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

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

var _react = require("react");

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

var InputElement = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(InputElement, _Component);

  var _super = (0, _createSuper2["default"])(InputElement);

  function InputElement() {
    var _this;

    (0, _classCallCheck2["default"])(this, InputElement);
    _this = _super.apply(this, arguments);

    _this.focus = function () {
      var _assertThisInitialize = (0, _assertThisInitialized2["default"])(_this),
          ele = _assertThisInitialize.ele;

      if (typeof ele.focus === 'function') {
        ele.focus();
      } else {
        (0, _reactDom.findDOMNode)(ele).focus();
      }
    };

    _this.blur = function () {
      var _assertThisInitialize2 = (0, _assertThisInitialized2["default"])(_this),
          ele = _assertThisInitialize2.ele;

      if (typeof ele.blur === 'function') {
        ele.blur();
      } else {
        (0, _reactDom.findDOMNode)(ele).blur();
      }
    };

    _this.saveRef = function (ele) {
      _this.ele = ele;
      var ref = _this.props.children.ref;

      if (typeof ref === 'function') {
        ref(ele);
      }
    };

    return _this;
  }

  (0, _createClass2["default"])(InputElement, [{
    key: "render",
    value: function render() {
      var props = this.props,
          children = this.props.children;
      return /*#__PURE__*/(0, _react.cloneElement)(children, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
        ref: this.saveRef
      }), null);
    }
  }]);
  return InputElement;
}(_react.Component);

exports["default"] = InputElement;
//# sourceMappingURL=InputElement.js.map
