{"version":3,"sources":["webpack:///./Scripts/Containers/Overlay.container.js"],"names":["OVERLAY_CLASS","connect","state","overlay","dispatch","closeOverlay","removeOverlay","componentName","activeOverlays","disableOverlayClick","overlayClasses","length","map","c","name","useEffect","classesToRemove","Array","from","document","body","classList","filter","startsWith","remove","add","className","join","onClick","component","onOverlayClick"],"mappings":"mJAIA,MAAMA,EAAgB,UAqDtB,GAAeC,SAbSC,IACb,IACAA,EAAMC,YAIUC,IAChB,CACHC,aAAcD,GAASC,WACvBC,cAAeC,GAAiBH,GAASE,QAAcC,OAI/D,EAnDyB,EAAGC,iBAAgBF,gBAAeG,0BAEvD,MAAMC,EAAiBF,EAAiB,CAACA,EAAeG,OAAS,GAAKX,KAAkBQ,EAAeI,KAAIC,GAAM,YAAoBA,EAAEC,UAAW,IAIlJC,gBAAU,KAEN,MAAMC,EAAkBC,MAAMC,KAAKC,SAASC,KAAKC,WAAWC,QAAOT,GAAKA,EAAEU,WAAWvB,IAAkBa,GAAKb,IACzGgB,GAAmBA,EAAgBL,OAAS,GAC3CQ,SAASC,KAAKC,UAAUG,UAAUR,GAInCR,GAAkBA,EAAeG,OAAS,GACzCQ,SAASC,KAAKC,UAAUI,OAAOf,KAGpC,CAACF,IAiBJ,OAAOA,GAAkBA,EAAeG,OAAS,EAAI,uBAAKe,UAAWhB,EAAeiB,KAAK,KAAMC,QAXxE,KACnB,IAAGnB,EAEH,IAAI,IAAIoB,KAAarB,EACdqB,EAAUC,iBACTD,EAAUC,iBACVxB,EAAcuB,EAAUf,UAK6F","file":"503.25c1abb9d2d2067ad629.js","sourcesContent":["import React, { useEffect } from \"react\"\r\nimport { connect } from \"react-redux\"\r\nimport { closeOverlay, removeOverlay } from \"../Actions/Overlay.action\"\r\n\r\nconst OVERLAY_CLASS = \"overlay\"\r\n\r\nconst OverlayContainer = ({ activeOverlays, removeOverlay, disableOverlayClick }) => {\r\n \r\n const overlayClasses = activeOverlays ? [activeOverlays.length > 0 && OVERLAY_CLASS, ...activeOverlays.map(c => `${OVERLAY_CLASS}--${c.name}`)] : []\r\n /**\r\n * Adds overlay classes to body to enable styling on components based on active overlays\r\n */\r\n useEffect(() => {\r\n // Remove all overlay classes that are not active anymore, before adding new\r\n const classesToRemove = Array.from(document.body.classList).filter(c => c.startsWith(OVERLAY_CLASS) || c == OVERLAY_CLASS)\r\n if(classesToRemove && classesToRemove.length > 0) {\r\n document.body.classList.remove(...classesToRemove)\r\n }\r\n\r\n // Add overlay classes to body\r\n if(activeOverlays && activeOverlays.length > 0) {\r\n document.body.classList.add(...overlayClasses)\r\n }\r\n \r\n }, [activeOverlays])\r\n\r\n /**\r\n * Removes all overlays.\r\n * Triggers onOverLay click on all active overlay components\r\n */\r\n const onOverlayClick = () => {\r\n if(disableOverlayClick) return;\r\n \r\n for(let component of activeOverlays) {\r\n if(component.onOverlayClick) {\r\n component.onOverlayClick()\r\n removeOverlay(component.name)\r\n }\r\n }\r\n }\r\n\r\n return activeOverlays && activeOverlays.length > 0 ?
: null\r\n}\r\n\r\nconst mapStateToProps = state => {\r\n return {\r\n ...state.overlay\r\n }\r\n}\r\n\r\nconst mapDispatchToProps = dispatch => {\r\n return {\r\n closeOverlay: dispatch(closeOverlay()),\r\n removeOverlay: componentName => dispatch(removeOverlay(componentName))\r\n }\r\n}\r\n\r\nexport default connect(mapStateToProps, mapDispatchToProps)(OverlayContainer)"],"sourceRoot":""}