{"version":3,"sources":["../../src/app/components/sidebar/sidebar.ts"],"names":["Sidebar","el","renderer","cd","this","position","blockScroll","autoZIndex","baseZIndex","modal","dismissible","showCloseIcon","closeOnEscape","onShow","EventEmitter","onHide","visibleChange","prototype","ngAfterViewInit","initialized","appendTo","document","body","appendChild","containerViewChild","nativeElement","DomHandler","visible","show","ngAfterContentInit","_this","templates","forEach","item","getType","contentTemplate","template","Object","defineProperty","_visible","val","preventVisibleChangePropagation","hide","ngAfterViewChecked","executePostDisplayActions","emit","style","zIndex","String","zindex","enableModality","disableModality","close","event","preventDefault","mask","createElement","parseInt","addMultipleClasses","maskClickListener","listen","addClass","unbindMaskClickListener","removeChild","removeClass","onAnimationStart","toState","bindDocumentEscapeListener","unbindGlobalListeners","documentTarget","ownerDocument","documentEscapeListener","which","unbindDocumentEscapeListener","ngOnDestroy","Component","args","selector","animations","trigger","state","opacity","transition","animate","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","Renderer2","ChangeDetectorRef","Input","ViewChild","ContentChildren","PrimeTemplate","Output","NgModule","imports","CommonModule","RippleModule","exports","declarations"],"mappings":"mpBA8FI,SAAAA,EAAmBC,EAAuBC,EAA4BC,GAAnDC,KAAAH,GAAAA,EAAuBG,KAAAF,SAAAA,EAA4BE,KAAAD,GAAAA,EApD7DC,KAAAC,SAAmB,OAMnBD,KAAAE,aAAuB,EAQvBF,KAAAG,YAAsB,EAEtBH,KAAAI,WAAqB,EAErBJ,KAAAK,OAAiB,EAEjBL,KAAAM,aAAuB,EAEvBN,KAAAO,eAAyB,EAEzBP,KAAAQ,eAAyB,EAMxBR,KAAAS,OAA4B,IAAIC,EAAAA,aAEhCV,KAAAW,OAA4B,IAAID,EAAAA,aAEhCV,KAAAY,cAAkC,IAAIF,EAAAA,oBAoBhDd,EAAAiB,UAAAC,gBAAA,WACId,KAAKe,aAAc,EAEff,KAAKgB,WACiB,SAAlBhB,KAAKgB,SACLC,SAASC,KAAKC,YAAYn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,KAAKe,aAAc,EAEff,KAAKuB,SACLvB,KAAKsC,OAGLtC,KAAKgB,UACLhB,KAAKH,GAAGwB,cAAcF,YAAYnB,KAAKoB,mBAAmBC,eAGpErB,KAAKgE,kDAlQNO,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,YACVzC,SAAU,8hCAeV0C,WAAY,CACRC,EAAAA,QAAQ,aAAc,CAClBC,EAAAA,MAAM,SAAUlC,EAAAA,MAAM,CAClBmC,QAAS,KAEbD,EAAAA,MAAM,UAAWlC,EAAAA,MAAM,CACnBmC,QAAS,KAEbC,EAAAA,WAAW,oBAAqBC,EAAAA,QAAQ,kBACxCD,EAAAA,WAAW,oBAAqBC,EAAAA,QAAQ,sBAGhDC,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,+lDArCmEC,EAAAA,kBAAWC,EAAAA,iBAAiHC,EAAAA,uDA0C/NC,EAAAA,0BAEAA,EAAAA,wBAEAA,EAAAA,2BAEAA,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,8BAEAA,EAAAA,0BAEAA,EAAAA,0BAEAA,EAAAA,qBAEAA,EAAAA,2BAEAA,EAAAA,6BAEAA,EAAAA,6BAEAA,EAAAA,kCAEAC,EAAAA,UAASlB,KAAA,CAAC,gCAEVmB,EAAAA,gBAAenB,KAAA,CAACoB,EAAAA,+BAEhBC,EAAAA,uBAEAA,EAAAA,8BAEAA,EAAAA,wBAiDAJ,EAAAA,eAqJL,iCALCK,EAAAA,SAAQtB,KAAA,CAAC,CACNuB,QAAS,CAACC,EAAAA,aAAaC,EAAAA,cACvBC,QAAS,CAACtG,GACVuG,aAAc,CAACvG","sourcesContent":["import {NgModule,Component,AfterViewInit,AfterViewChecked,OnDestroy,Input,Output,EventEmitter,ViewChild,ElementRef,Renderer2,ChangeDetectionStrategy, ViewEncapsulation, ContentChildren, QueryList, AfterContentInit, TemplateRef, ChangeDetectorRef} from '@angular/core';\nimport {trigger, state, style, transition, animate} from '@angular/animations';\nimport {CommonModule} from '@angular/common';\nimport {RippleModule} from 'primeng/ripple';\nimport {DomHandler} from 'primeng/dom';\nimport {PrimeTemplate} from 'primeng/api';\n\n@Component({\n selector: 'p-sidebar',\n template: `\n
\n
\n \n \n \n
\n
\n `,\n animations: [\n trigger('panelState', [\n state('hidden', style({\n opacity: 0\n })),\n state('visible', style({\n opacity: 1\n })),\n transition('visible => hidden', animate('300ms ease-in')),\n transition('hidden => visible', animate('300ms ease-out'))\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./sidebar.css']\n})\nexport class Sidebar implements AfterViewInit, AfterContentInit, AfterViewChecked, OnDestroy {\n\n @Input() position: string = 'left';\n\n @Input() fullScreen: boolean;\n\n @Input() appendTo: string;\n\n @Input() blockScroll: boolean = false;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() ariaCloseLabel: string;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() modal: boolean = true;\n\n @Input() dismissible: boolean = true;\n\n @Input() showCloseIcon: boolean = true;\n\n @Input() closeOnEscape: boolean = true;\n\n @ViewChild('container') containerViewChild: ElementRef;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n @Output() onShow: EventEmitter = new EventEmitter();\n\n @Output() onHide: EventEmitter = new EventEmitter();\n\n @Output() visibleChange:EventEmitter = new EventEmitter();\n\n initialized: boolean;\n\n _visible: boolean;\n\n preventVisibleChangePropagation: boolean;\n\n mask: HTMLDivElement;\n\n maskClickListener: Function;\n\n documentEscapeListener: Function;\n\n executePostDisplayActions: boolean;\n\n contentTemplate: TemplateRef;\n\n constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef) {}\n\n ngAfterViewInit() {\n this.initialized = true;\n\n if (this.appendTo) {\n if (this.appendTo === 'body')\n document.body.appendChild(this.containerViewChild.nativeElement);\n else\n DomHandler.appendChild(this.containerViewChild.nativeElement, this.appendTo);\n }\n\n if (this.visible) {\n this.show();\n }\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'content':\n this.contentTemplate = item.template;\n break;\n\n default:\n this.contentTemplate = item.template;\n break;\n }\n });\n }\n\n @Input() get visible(): boolean {\n return this._visible;\n }\n\n set visible(val:boolean) {\n this._visible = val;\n\n if (this.initialized && this.containerViewChild && this.containerViewChild.nativeElement) {\n if (this._visible)\n this.show();\n else {\n if (this.preventVisibleChangePropagation)\n this.preventVisibleChangePropagation = false;\n else\n this.hide();\n }\n }\n }\n\n ngAfterViewChecked() {\n if (this.executePostDisplayActions) {\n this.onShow.emit({});\n this.executePostDisplayActions = false;\n }\n }\n\n show() {\n this.executePostDisplayActions = true;\n if (this.autoZIndex) {\n this.containerViewChild.nativeElement.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex));\n }\n\n if (this.modal) {\n this.enableModality();\n }\n }\n\n hide() {\n this.onHide.emit({});\n\n if (this.modal) {\n this.disableModality();\n }\n }\n\n close(event: Event) {\n this.preventVisibleChangePropagation = true;\n this.hide();\n this.visibleChange.emit(false);\n event.preventDefault();\n }\n\n enableModality() {\n if (!this.mask) {\n this.mask = document.createElement('div');\n this.mask.style.zIndex = String(parseInt(this.containerViewChild.nativeElement.style.zIndex) - 1);\n DomHandler.addMultipleClasses(this.mask, 'p-component-overlay p-sidebar-mask');\n\n if (this.dismissible){\n this.maskClickListener = this.renderer.listen(this.mask, 'click', (event: any) => {\n if (this.dismissible) {\n this.close(event);\n }\n });\n }\n\n document.body.appendChild(this.mask);\n if (this.blockScroll) {\n DomHandler.addClass(document.body, 'p-overflow-hidden');\n }\n }\n }\n\n disableModality() {\n if (this.mask) {\n this.unbindMaskClickListener();\n document.body.removeChild(this.mask);\n if (this.blockScroll) {\n DomHandler.removeClass(document.body, 'p-overflow-hidden');\n }\n this.mask = null;\n }\n }\n\n onAnimationStart(event){\n switch(event.toState) {\n case 'visible':\n if (this.closeOnEscape) {\n this.bindDocumentEscapeListener();\n }\n break;\n\n case 'hidden':\n this.unbindGlobalListeners();\n break;\n }\n }\n\n bindDocumentEscapeListener() {\n const documentTarget: any = this.el ? this.el.nativeElement.ownerDocument : 'document';\n\n this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', (event) => {\n if (event.which == 27) {\n if (parseInt(this.containerViewChild.nativeElement.style.zIndex) === (DomHandler.zindex + this.baseZIndex)) {\n this.close(event);\n }\n }\n });\n }\n\n unbindDocumentEscapeListener() {\n if (this.documentEscapeListener) {\n this.documentEscapeListener();\n this.documentEscapeListener = null;\n }\n }\n\n unbindMaskClickListener() {\n if (this.maskClickListener) {\n this.maskClickListener();\n this.maskClickListener = null;\n }\n }\n\n unbindGlobalListeners() {\n this.unbindMaskClickListener();\n this.unbindDocumentEscapeListener();\n }\n\n ngOnDestroy() {\n this.initialized = false;\n\n if (this.visible) {\n this.hide();\n }\n\n if (this.appendTo) {\n this.el.nativeElement.appendChild(this.containerViewChild.nativeElement);\n }\n\n\t\tthis.unbindGlobalListeners();\n }\n}\n\n@NgModule({\n imports: [CommonModule,RippleModule],\n exports: [Sidebar],\n declarations: [Sidebar]\n})\nexport class SidebarModule { }\n"]}