"use strict";

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

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

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

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

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _excluded = ["prefixCls", "onBlur", "children", "className"];

var TextFieldGroup = function TextFieldGroup(_ref) {
  var prefixCls = _ref.prefixCls,
      onBlur = _ref.onBlur,
      children = _ref.children,
      className = _ref.className,
      otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
  var ref = (0, _react.useRef)(null);
  var selfPrefixCls = "".concat(prefixCls, "-group-wrapper");
  (0, _react.useEffect)(function () {
    var current = ref.current;

    if (current && onBlur) {
      var handleMousedown = function handleMousedown(e) {
        var target = e.target;

        if (!e.defaultPrevented && !current.contains(target)) {
          onBlur(e);
        }
      };

      document.addEventListener('mousedown', handleMousedown, false);
      return function () {
        document.removeEventListener('mousedown', handleMousedown, false);
      };
    }
  }, [onBlur, ref]);
  return /*#__PURE__*/_react["default"].createElement("div", (0, _extends2["default"])({
    ref: ref
  }, otherProps, {
    className: (0, _classnames["default"])(selfPrefixCls, className)
  }), children);
};

TextFieldGroup.displayName = 'TextFieldGroup';
var _default = TextFieldGroup;
exports["default"] = _default;
//# sourceMappingURL=TextFieldGroup.js.map
