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MACjBM,MAAM,KAAK,IACVC,QAAQ,KAAM,IACfA,QAAQ,IAAK,KAAO,KAEzBhB,SAASC,KAAKO,MAAMC,MAAQ,GAC5BT,SAASC,KAAKO,MAAMI,SAAW,GAC/BZ,SAASC,KAAKO,MAAMK,UAAY,GAChCH,OAAOO,SAAS,CAAEC,IAAKP,EAASQ,SAAU,QAC3C,IACA,CAACrC,IAMJ,MAAMZ,GAAiBkD,EAAAA,EAAAA,cAAY,KAjDZnD,MAkDrB,IAAIc,EAEJ,IAAK,IAAIsC,KAAavC,EAChBuC,EAAUnD,iBACuB,IAA/BmD,EAAUnD,mBAtDGD,EAuDDoD,EAAU1B,KAtD9Bf,GAAS0C,EAAAA,EAAAA,IAAoBrD,IAyD5B,GACA,CAACa,EAAgBC,IAEpB,OACED,GACAA,EAAesB,OAAS,GACtB,uBACEC,WAAWkB,EAAAA,EAAAA,GAAK5C,EAAec,EAAeD,KAAK,KAAML,GACzDqC,QAAStD,GALf,C","sources":["webpack:///./Scripts/Actions/Overlay.action.js","webpack:///./Scripts/Components/Overlay.js"],"sourcesContent":["import {\n OVERLAY_ADD_OVERLAY,\n OVERLAY_CLOSE_OVERLAY,\n OVERLAY_REMOVE_OVERLAY,\n OVERLAY_UPDATE_OVERLAY,\n} from '../constants';\n\nexport const addOverlay = (\n componentName,\n onOverlayClick,\n zIndexClass = null\n) => ({\n type: OVERLAY_ADD_OVERLAY,\n payload: {\n componentName,\n onOverlayClick,\n zIndexClass,\n },\n});\n\nexport const updateOverlay = (componentName, onOverlayClick, zIndexClass) => ({\n type: OVERLAY_UPDATE_OVERLAY,\n payload: {\n componentName,\n onOverlayClick,\n zIndexClass,\n },\n});\n\nexport const removeOverlay = (componentName) => ({\n type: OVERLAY_REMOVE_OVERLAY,\n payload: {\n componentName,\n },\n});\n\nexport const closeOverlay = () => ({\n type: OVERLAY_CLOSE_OVERLAY,\n payload: {\n activeOverlays: [],\n },\n});\n","import React, { useCallback, useEffect, useMemo } from 'react';\nimport { useDispatch, useSelector } from 'react-redux';\nimport { removeOverlay as removeOverlayAction } from '../Actions/Overlay.action';\nimport clsx from 'clsx';\n\nconst OVERLAY_CLASS = 'overlay';\n\nconst Overlay = () => {\n const dispatch = useDispatch();\n\n const { activeOverlays, disableOverlayClick } = useSelector(\n (state) => state.overlay\n );\n\n const zIndexClasses = useMemo(\n () =>\n activeOverlays\n .filter((o) => !!o.zIndexClass)\n .map((o) => o.zIndexClass)\n .join(' '),\n [activeOverlays]\n );\n\n const removeOverlay = (componentName) =>\n dispatch(removeOverlayAction(componentName));\n\n const overlayClasses = activeOverlays\n ? activeOverlays.map((c) => `${OVERLAY_CLASS}--${c.name}`)\n : [];\n /**\n * Adds overlay classes to body to enable styling on components based on active overlays\n */\n useEffect(() => {\n // Remove all overlay classes that are not active anymore, before adding new\n const classesToRemove = Array.from(document.body.classList).filter(\n (c) => c.startsWith(OVERLAY_CLASS) || c == OVERLAY_CLASS\n );\n if (classesToRemove && classesToRemove.length > 0) {\n for (let className of classesToRemove) {\n document.body.classList.remove(className);\n }\n }\n\n // Add overlay classes to body\n if (activeOverlays && activeOverlays.length > 0) {\n for (let className of overlayClasses) {\n document.body.classList.add(className);\n }\n\n if (!document.body.style.inset) {\n document.body.style.inset = `-${window.scrollY}px 0 0`;\n document.body.style.position = 'fixed';\n document.body.style.overflowY = 'scroll';\n }\n } else if (!!document.body.style.inset) {\n const scrollY = parseFloat(\n document.body.style.inset\n .split(' ')[0]\n ?.replace('px', '')\n .replace('-', '') ?? '0'\n );\n document.body.style.inset = '';\n document.body.style.position = '';\n document.body.style.overflowY = '';\n window.scrollTo({ top: scrollY, behavior: 'auto' });\n }\n }, [activeOverlays]);\n\n /**\n * Removes all overlays.\n * Triggers onOverLay click on all active overlay components\n */\n const onOverlayClick = useCallback(() => {\n if (disableOverlayClick) return;\n\n for (let component of activeOverlays) {\n if (component.onOverlayClick) {\n if (component.onOverlayClick() !== false) {\n removeOverlay(component.name);\n }\n }\n }\n }, [activeOverlays, disableOverlayClick]);\n\n return (\n activeOverlays &&\n activeOverlays.length > 0 && (\n
\n )\n );\n};\n\nexport default Overlay;\n"],"names":["addOverlay","componentName","onOverlayClick","zIndexClass","type","OVERLAY_ADD_OVERLAY","payload","updateOverlay","OVERLAY_UPDATE_OVERLAY","removeOverlay","OVERLAY_REMOVE_OVERLAY","OVERLAY_CLASS","dispatch","useDispatch","activeOverlays","disableOverlayClick","useSelector","state","overlay","zIndexClasses","useMemo","filter","o","map","join","overlayClasses","c","name","useEffect","classesToRemove","Array","from","document","body","classList","startsWith","length","className","remove","add","style","inset","window","scrollY","position","overflowY","parseFloat","split","replace","scrollTo","top","behavior","useCallback","component","removeOverlayAction","clsx","onClick"],"sourceRoot":""}