{"size": 781, "ext": "js", "max_stars_repo_path": "repos/keg-components/build/esm/web/useOutsideDetect.js", "max_stars_repo_name": "simpleviewinc/sv-keg", "max_stars_repo_stars_event_min_datetime": "2020-10-08T20:23:01.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-18T15:44:13.000Z", "max_issues_repo_path": "repos/keg-components/build/esm/web/useOutsideDetect.js", "max_issues_repo_name": "simpleviewinc/sv-keg", "max_issues_repo_issues_event_min_datetime": "2020-09-02T18:35:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T05:51:10.000Z", "max_forks_repo_path": "repos/keg-components/build/esm/web/useOutsideDetect.js", "max_forks_repo_name": "KegHub/keg-hub", "max_forks_repo_forks_event_min_datetime": "2020-08-27T16:04:00.000Z", "max_forks_repo_forks_event_max_datetime": "2021-01-06T07:25:38.000Z"}
{"max_stars_count": 2, "max_issues_count": 85, "max_forks_count": 4, "avg_line_length": 39.05, "max_line_length": 131, "alphanum_fraction": 0.7055057618}
import { useEffect } from 'react';

var eventIsOutside = function eventIsOutside(evt, ref) {
  return (ref === null || ref === void 0 ? void 0 : ref.current) && !ref.current.contains(evt.target);
};
var useOutsideDetect = function useOutsideDetect(ref, onOutsideClick) {
  useEffect(function () {
    var handleClickOutside = function handleClickOutside(event) {
      return eventIsOutside(event, ref) && (onOutsideClick === null || onOutsideClick === void 0 ? void 0 : onOutsideClick(event));
    };
    document.addEventListener('mousedown', handleClickOutside);
    return function () {
      return document.removeEventListener('mousedown', handleClickOutside);
    };
  }, [ref, onOutsideClick]);
};

export { useOutsideDetect };
//# sourceMappingURL=useOutsideDetect.js.map
