38646.js.map 2.1 KB

1
  1. {"version":3,"file":"38646.js","mappings":";;;;;;;;;;;;;AAAyC;AAEzC;;;;;;CAMC,GACD,MAAME,uBAAuB,GAAG,CAC9BC,GAAiC,EACjCC,sBAAkC,EAClCC,eAAwB,GACrB;IACHJ,gDAAS,CAAC,IAAM;QACd,MAAMK,kBAAkB,GAAG,CAACC,KAAK,GAAK;YACpC,qGAAqG;YACrG,IAAIJ,GAAG,CAACK,OAAO,IAAI,CAACL,GAAG,CAACK,OAAO,CAACC,QAAQ,CAACF,KAAK,CAACG,MAAM,CAAC,EAAE;gBACtDN,sBAAsB,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC;QACD,qFAAqF;QACrF,IAAIC,eAAe,EAAE;YACnB,0BAA0B;YAC1BM,QAAQ,CAACC,gBAAgB,CAAC,WAAW,EAAEN,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,IAAM;YACX,wCAAwC;YACxCK,QAAQ,CAACE,mBAAmB,CAAC,WAAW,EAAEP,kBAAkB,CAAC,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC,EAAE;QAACH,GAAG;QAAEC,sBAAsB;QAAEC,eAAe;KAAC,CAAC,CAAC;AACrD,CAAC;AAED,iEAAeH,uBAAuB,EAAC","sources":["webpack://quran.com/./src/hooks/useOutsideClickDetector.ts"],"sourcesContent":["import React, { useEffect } from 'react';\n\n/**\n * A hook that detects clicking outside an element.\n *\n * @param {React.RefObject<HTMLElement>} ref\n * @param {()=> void} onClickOutsideDetected\n * @param {boolean} enableDetection\n */\nconst useOutsideClickDetector = (\n ref: React.RefObject<HTMLElement>,\n onClickOutsideDetected: () => void,\n enableDetection: boolean,\n) => {\n useEffect(() => {\n const handleClickOutside = (event) => {\n // if we click on an element inside the document that is not an inclusive descendant of the ref node.\n if (ref.current && !ref.current.contains(event.target)) {\n onClickOutsideDetected();\n }\n };\n // no need to attach the listener if the parent component's visibility is controlled.\n if (enableDetection) {\n // Bind the event listener\n document.addEventListener('mousedown', handleClickOutside);\n }\n return () => {\n // Unbind the event listener on clean up\n document.removeEventListener('mousedown', handleClickOutside);\n };\n }, [ref, onClickOutsideDetected, enableDetection]);\n};\n\nexport default useOutsideClickDetector;\n"],"names":["React","useEffect","useOutsideClickDetector","ref","onClickOutsideDetected","enableDetection","handleClickOutside","event","current","contains","target","document","addEventListener","removeEventListener"],"sourceRoot":""}