"use strict"; exports.id = 38646; exports.ids = [38646]; exports.modules = { /***/ 38646: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); /** * A hook that detects clicking outside an element. * * @param {React.RefObject} ref * @param {()=> void} onClickOutsideDetected * @param {boolean} enableDetection */ const useOutsideClickDetector = (ref, onClickOutsideDetected, enableDetection)=>{ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(()=>{ const handleClickOutside = (event)=>{ // if we click on an element inside the document that is not an inclusive descendant of the ref node. if (ref.current && !ref.current.contains(event.target)) { onClickOutsideDetected(); } }; // no need to attach the listener if the parent component's visibility is controlled. if (enableDetection) { // Bind the event listener document.addEventListener("mousedown", handleClickOutside); } return ()=>{ // Unbind the event listener on clean up document.removeEventListener("mousedown", handleClickOutside); }; }, [ ref, onClickOutsideDetected, enableDetection ]); }; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useOutsideClickDetector); /***/ }) }; ; //# sourceMappingURL=38646.js.map