{"version":3,"sources":["webpack:///./Scripts/Containers/Overlay.container.js"],"names":["OVERLAY_CLASS","OverlayContainer","dispatch","useDispatch","activeOverlays","disableOverlayClick","useSelector","state","overlay","overlayClasses","map","c","name","useEffect","classesToRemove","Array","from","document","body","classList","filter","startsWith","length","className","remove","add","onOverlayClick","useCallback","componentName","component","removeOverlayAction","join","onClick","props","store","global","LitiumReduxStore"],"mappings":"wJAOA,MAAMA,EAAgB,UAEhBC,EAAmB,KACvB,MAAMC,GAAWC,WAEX,eAAEC,EAAF,oBAAkBC,IAAwBC,SAC7CC,GAAUA,EAAMC,UAObC,EAAiBL,EACnBA,EAAeM,KAAKC,GAAO,GAAEX,MAAkBW,EAAEC,SAC7C,IAINC,gBAAU,KAEV,MAAMC,EAAkBC,MAAMC,KAAKC,SAASC,KAAKC,WAAWC,QACzDT,GAAMA,EAAEU,WAAWrB,IAAkBW,GAAKX,IAE7C,GAAIc,GAAmBA,EAAgBQ,OAAS,EAC5C,IAAK,IAAIC,KAAaT,EACtBG,SAASC,KAAKC,UAAUK,OAAOD,GAK/B,GAAInB,GAAkBA,EAAekB,OAAS,EAAG,CAC7CL,SAASC,KAAKC,UAAUM,IAAIzB,GAChC,IAAK,IAAIuB,KAAad,EACtBQ,SAASC,KAAKC,UAAUM,IAAIF,EAE/B,IACA,CAACnB,IAMJ,MAAMsB,GAAiBC,kBAAY,KAjCZC,MAkCrB,IAAIvB,EAEJ,IAAK,IAAIwB,KAAazB,EAChByB,EAAUH,iBACuB,IAA/BG,EAAUH,mBAtCGE,EAuCDC,EAAUjB,KAtC1BV,GAAS4B,QAAoBF,IAyChC,GACA,CAACxB,EAAgBC,IAEpB,OACED,GACAA,EAAekB,OAAS,GACrB,uBAAKC,UAAY,GAAEvB,KAAiBS,EAAesB,KAAK,OAAQC,QAASN,GAH9E,EAsBF,EAAgBO,GACd,gBAAC,KAAD,CAAUC,MAAOC,IAAOC,kBACtB,gBAACnC,EAAqBgC,G","file":"5221.060795e575fc3efd6cc1.js","sourcesContent":["import React, { useCallback, useEffect } from 'react';\nimport { connect, Provider, useDispatch, useSelector } from 'react-redux';\nimport {\n closeOverlay as closeOverlayAction,\n removeOverlay as removeOverlayAction,\n} from '../Actions/Overlay.action';\n\nconst OVERLAY_CLASS = 'overlay';\n\nconst OverlayContainer = () => {\n const dispatch = useDispatch();\n\n const { activeOverlays, disableOverlayClick } = useSelector(\n (state) => state.overlay\n );\n\n const closeOverlay = () => dispatch(closeOverlayAction());\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 document.body.classList.add(OVERLAY_CLASS);\n for (let className of overlayClasses) {\n document.body.classList.add(className);\n }\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\nconst mapStateToProps = (state) => {\n return {\n ...state.overlay,\n };\n};\n\nconst mapDispatchToProps = (dispatch) => {\n return {\n closeOverlay: dispatch(closeOverlay()),\n removeOverlay: (componentName) =>\n dispatch(removeOverlayAction(componentName)),\n };\n};\n\nexport default (props) => (\n \n \n \n);\n"],"sourceRoot":""}