"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useClickOutside = void 0;
var _react = require("react");
const useClickOutside = (refObject, callback) => {
  const handleClickOutside = e => {
    var _refObject$current;
    if (!(refObject !== null && refObject !== void 0 && (_refObject$current = refObject.current) !== null && _refObject$current !== void 0 && _refObject$current.contains(e.target))) {
      callback();
    }
  };
  (0, _react.useEffect)(() => {
    document.addEventListener('mousedown', handleClickOutside);
    return () => document.removeEventListener('mousedown', handleClickOutside);
  });
};
exports.useClickOutside = useClickOutside;