import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["prefixCls", "onBlur", "children", "className"];
import React, { useEffect, useRef } from 'react';
import classNames from 'classnames';

var TextFieldGroup = function TextFieldGroup(_ref) {
  var prefixCls = _ref.prefixCls,
      onBlur = _ref.onBlur,
      children = _ref.children,
      className = _ref.className,
      otherProps = _objectWithoutProperties(_ref, _excluded);

  var ref = useRef(null);
  var selfPrefixCls = "".concat(prefixCls, "-group-wrapper");
  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.createElement("div", _extends({
    ref: ref
  }, otherProps, {
    className: classNames(selfPrefixCls, className)
  }), children);
};

TextFieldGroup.displayName = 'TextFieldGroup';
export default TextFieldGroup;
//# sourceMappingURL=TextFieldGroup.js.map
