{ "version": 3, "sources": ["../../assets/breakpoints.js", "../../assets/scripts/store/hooks/useComponentVisible.ts"], "sourcesContent": ["// eslint-disable-next-line no-undef\r\nexport default {\r\n phone: 576,\r\n tablet: 768,\r\n laptop: 992,\r\n notebook: 1200,\r\n desktop: 1400,\r\n // sm: 576,\r\n // md: 768,\r\n // lg: 992,\r\n // xl: 1200,\r\n // xxl: 1400,\r\n};\r\n", "import type { Dispatch, RefObject, SetStateAction } from 'react';\r\nimport { useEffect, useRef, useState } from 'react';\r\n\r\nexport default function useComponentVisible(\r\n initialIsVisible: boolean,\r\n onClickOutside?: () => void\r\n): {\r\n ref: RefObject;\r\n isComponentVisible: boolean;\r\n setIsComponentVisible: Dispatch>;\r\n} {\r\n const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible);\r\n const ref = useRef(null);\r\n\r\n const handleClickOutside = ({ target }: MouseEvent) => {\r\n if (!(target instanceof HTMLElement)) return;\r\n if (ref.current && !ref.current.contains(target)) {\r\n setIsComponentVisible(false);\r\n if (onClickOutside) onClickOutside();\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n document.addEventListener('click', handleClickOutside, true);\r\n return () => {\r\n document.removeEventListener('click', handleClickOutside, true);\r\n };\r\n });\r\n\r\n return { ref, isComponentVisible, setIsComponentVisible };\r\n}\r\n"], "mappings": ";;;;;;;;AACA,IAAO,sBAAQ;AAAA,EACb,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAMX;;;ACXA,mBAA4C;AAE7B,SAAR,oBACL,kBACA,gBAKA;AACA,QAAM,CAAC,oBAAoB,qBAAqB,QAAI,uBAAS,gBAAgB;AAC7E,QAAM,UAAM,qBAAU,IAAI;AAE1B,QAAM,qBAAqB,CAAC,EAAE,OAAO,MAAkB;AACrD,QAAI,EAAE,kBAAkB,aAAc;AACtC,QAAI,IAAI,WAAW,CAAC,IAAI,QAAQ,SAAS,MAAM,GAAG;AAChD,4BAAsB,KAAK;AAC3B,UAAI,eAAgB,gBAAe;AAAA,IACrC;AAAA,EACF;AAEA,8BAAU,MAAM;AACd,aAAS,iBAAiB,SAAS,oBAAoB,IAAI;AAC3D,WAAO,MAAM;AACX,eAAS,oBAAoB,SAAS,oBAAoB,IAAI;AAAA,IAChE;AAAA,EACF,CAAC;AAED,SAAO,EAAE,KAAK,oBAAoB,sBAAsB;AAC1D;", "names": [] }