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,KAAKqD,MAAMS,MACxC,GAAC,8BAED,WACE,OAAOC,KAAKC,IAAIhE,KAAKoD,KAAKa,mBAAoBjE,KAAKqD,MAAMY,mBAC3D,GAAC,8BACD,WACEjE,KAAKoD,KAAK1C,mBACVV,KAAKqD,MAAM3C,mBACXV,KAAK4D,eACP,KAAC,EA/BuB,CAASM,EAAAA,E","sources":["app-react/services/drawer/drawer-content-decorator.ts","app-react/services/drawer/drawer-handler.ts","app-react/services/drawer/drawer.service.ts"],"sourcesContent":["import React from 'react';\nimport {IDrawerContent} from './drawer.service.interface';\n\nexport class DrawerContentDecorator implements IDrawerContent {\n constructor(private readonly _originalDrawerContent: IDrawerContent, private readonly _id: string) {\n\n }\n\n get id(): string {\n if(this._originalDrawerContent.id) {\n return this._originalDrawerContent.id;\n }\n\n return this._id;\n }\n get isMinimized(): boolean {\n return this._originalDrawerContent.isMinimized;\n }\n\n onClose(): void {\n if(this._originalDrawerContent.onClose) {\n this._originalDrawerContent.onClose();\n }\n }\n\n render(): React.ReactNode {\n return this._originalDrawerContent.render();\n }\n\n get title(): string {\n return this._originalDrawerContent.title;\n }\n\n get minOverlayZIndex(): number | null {\n return this._originalDrawerContent.minOverlayZIndex;\n }\n\n get supportsCloseIntent(): boolean {\n return Boolean(this._originalDrawerContent.supportsCloseIntent);\n }\n\n get isBlurBackground(): boolean {\n return Boolean(this._originalDrawerContent.isBlurBackground);\n }\n\n onOverlayClicked(): void {\n if(this._originalDrawerContent.onOverlayClicked) {\n this._originalDrawerContent.onOverlayClicked();\n }\n }\n}","import { action, observable, runInAction, makeObservable } from \"mobx\";\nimport {IServiceFactoryExtended} from \"../service-factory-extended.interface\";\nimport {IDrawerContent, IDrawerContentHandler, IDrawer} from \"./drawer.service.interface\";\nimport {DrawerContentDecorator} from './drawer-content-decorator';\n\nexport class Drawer implements IDrawer {\n\n\n @observable.ref\n isSpinnerVisible: boolean = false;\n\n\n @observable.ref\n private _drawerContentStack: IDrawerContent[] = [];\n\n constructor(private _services:IServiceFactoryExtended){\n makeObservable(this);\n }\n\n getOverlayZIndex(): number {\n const itemIndex = this.getLastVisibleDrawerItemIndex();\n const drawerItem = this.currentContent && this.currentContent[itemIndex];\n if(drawerItem?.minOverlayZIndex) {\n return drawerItem.minOverlayZIndex;\n }\n\n return 110;\n }\n\n get hasBlurBackground(): boolean {\n const itemIndex = this.getLastVisibleDrawerItemIndex();\n const drawerItem = this.currentContent && this.currentContent[itemIndex];\n return drawerItem?.isBlurBackground;\n }\n\n /**\n * The drawer can contain multiple items but only the last one added will actually be visible on the screen.\n * However, if the last one has isMinimized=true then the one added before will be rendered and so on.\n * Basically this method returns the index of the item that will be rendered as visible in the drawer.\n * There might be other items rendered in the drawer but those will have display: none\n */\n getLastVisibleDrawerItemIndex(): number {\n const currentDrawerContent = this.currentContent;\n for(let i = currentDrawerContent.length - 1; i>=0; i--) {\n if(!currentDrawerContent[i].isMinimized) {\n return i;\n }\n }\n\n return -1;\n }\n\n @action.bound\n showSpinner(): void {\n this.isSpinnerVisible = true;\n }\n\n @action.bound\n hideSpinner(): void {\n this.isSpinnerVisible = false;\n }\n\n\n @action.bound\n push(content: IDrawerContent): IDrawerContentHandler {\n\n content = new DrawerContentDecorator(content, this._services.tools.getGuid());\n\n const clone = [...this._drawerContentStack];\n\n const existingContentIndex = clone.findIndex(c => c.id === content.id);\n\n if(existingContentIndex >= 0) {\n clone.splice(existingContentIndex, 1); // if is already in the drawer we will remove it here in order to put it on top in the next line\n }\n\n this._drawerContentStack = [...clone, content];\n\n return {\n remove: () => {\n const contentIndexToRemove = this._drawerContentStack.findIndex(c => c.id === content.id);\n if(contentIndexToRemove >= 0) {\n this._removeOneDrawerItem(contentIndexToRemove);\n }\n }\n }\n }\n\n private _removeOneDrawerItem(itemIndex: number): void {\n runInAction(() => {\n const clone = [...this._drawerContentStack];\n clone.splice(itemIndex, 1);\n this._drawerContentStack = clone;\n });\n\n }\n\n @action.bound\n back() {\n const itemOnTheStackTop = this._drawerContentStack[this._drawerContentStack.length - 1]\n this._closeDrawerContentItem(itemOnTheStackTop);\n if(!itemOnTheStackTop.isMinimized) {\n this._removeOneDrawerItem(this._drawerContentStack.length - 1);\n }\n }\n\n get currentContent(): IDrawerContent[] {\n return this._drawerContentStack;\n }\n\n get isOpen(): boolean{\n return this._getNonMinimizedContents().length > 0 || this.isSpinnerVisible;\n }\n\n get shouldShowBackButton(): boolean {\n return 1 < this.currentContent.filter(item => !item.isMinimized).length;\n }\n _getNonMinimizedContents(): IDrawerContent[] {\n return this.currentContent.filter(c => !c.isMinimized);\n }\n\n private _closeDrawerContentItem(item: IDrawerContent) {\n if(item.onClose){\n try {\n item.onClose();\n } catch(err){\n this._services.logger.error(`Fail to call onClose for drawer content ${item}`, err)\n }\n }\n }\n\n onOverlayClicked() {\n this._drawerContentStack.forEach(item => {\n item.onOverlayClicked();\n })\n }\n\n @action.bound\n closeDrawer(): void {\n const nonClosableItems: IDrawerContent[] = [];\n\n this._drawerContentStack.forEach(drawerContent => {\n if(drawerContent.supportsCloseIntent) {\n nonClosableItems.push(drawerContent);\n } else {\n this._closeDrawerContentItem(drawerContent);\n if(drawerContent.isMinimized) {\n nonClosableItems.push(drawerContent);\n }\n }\n });\n this._drawerContentStack = nonClosableItems;\n this.hideSpinner();\n }\n}\n","import {ServiceBase} from \"../ServiceBase\";\nimport {IServiceFactoryExtended} from \"../service-factory-extended.interface\";\nimport {Drawer} from \"./drawer-handler\";\nimport {IDrawerService} from \"./drawer.service.interface\";\nimport {IOverlayConsumer} from \"../overlay/overlay-consumer.interface\";\n\nexport class DrawerService extends ServiceBase implements IDrawerService, IOverlayConsumer{\n\n left: Drawer;\n right: Drawer;\n\n constructor(serviceFactory: IServiceFactoryExtended) {\n super(serviceFactory);\n\n this.left = new Drawer(this.services);\n this.right = new Drawer(this.services);\n\n serviceFactory.overlay.registerConsumer(this);\n this.reaction(() => this.services.user.isAuthorized, isAuthorized => !isAuthorized && this._closeDrawers());\n }\n\n private _closeDrawers():void{\n this.left.closeDrawer();\n this.right.closeDrawer();\n }\n\n get needsOverlay(): boolean {\n return this.left.isOpen || this.right.isOpen\n }\n\n getOverlayZIndex(): number | undefined {\n return Math.max(this.left.getOverlayZIndex(), this.right.getOverlayZIndex())\n }\n onOverlayClicked(): void {\n this.left.onOverlayClicked();\n this.right.onOverlayClicked();\n this._closeDrawers();\n }\n\n}\n"],"names":["DrawerContentDecorator","_originalDrawerContent","_id","this","id","isMinimized","onClose","render","title","minOverlayZIndex","Boolean","supportsCloseIntent","isBlurBackground","onOverlayClicked","Drawer","observable","action","_services","makeObservable","itemIndex","getLastVisibleDrawerItemIndex","drawerItem","currentContent","currentDrawerContent","i","length","isSpinnerVisible","content","tools","getGuid","clone","_drawerContentStack","existingContentIndex","findIndex","c","splice","remove","contentIndexToRemove","_removeOneDrawerItem","runInAction","itemOnTheStackTop","_closeDrawerContentItem","_getNonMinimizedContents","filter","item","err","logger","error","forEach","nonClosableItems","drawerContent","push","hideSpinner","DrawerService","serviceFactory","left","right","services","overlay","registerConsumer","reaction","user","isAuthorized","_closeDrawers","closeDrawer","isOpen","Math","max","getOverlayZIndex","ServiceBase"],"sourceRoot":""}