{"version":3,"file":"primeng-menubar.mjs","sources":["../../src/app/components/menubar/menubar.ts","../../src/app/components/menubar/primeng-menubar.ts"],"sourcesContent":["import { NgModule, Component, ElementRef, Input, Renderer2, OnDestroy,ChangeDetectorRef, ChangeDetectionStrategy, ViewEncapsulation, AfterContentInit, ContentChildren, QueryList, TemplateRef, ViewChild, Output, EventEmitter } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DomHandler } from 'primeng/dom';\nimport { ZIndexUtils } from 'primeng/utils';\nimport { MenuItem, PrimeNGConfig, PrimeTemplate } from 'primeng/api';\nimport { RouterModule } from '@angular/router';\nimport { RippleModule } from 'primeng/ripple';\nimport { TooltipModule } from 'primeng/tooltip';\n\n@Component({\n selector: 'p-menubarSub',\n template: `\n \n `,\n encapsulation: ViewEncapsulation.None,\n host: {\n 'class': 'p-element'\n }\n})\nexport class MenubarSub implements OnDestroy {\n\n @Input() item: MenuItem;\n\n @Input() root: boolean;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() mobileActive: boolean;\n\n @Input() autoDisplay: boolean;\n\n @Input() get parentActive():boolean\n {\n return this._parentActive;\n }\n set parentActive(value) {\n if (!this.root) {\n this._parentActive = value;\n\n if (!value)\n this.activeItem = null;\n }\n }\n\n @Output() leafClick: EventEmitter = new EventEmitter();\n\n _parentActive: boolean;\n\n documentClickListener: any;\n\n menuHoverActive: boolean = false;\n\n activeItem: any;\n\n constructor(public el: ElementRef, public renderer: Renderer2, private cd: ChangeDetectorRef) { }\n\n onItemClick(event, item) {\n if (item.disabled) {\n event.preventDefault();\n return;\n }\n\n if (!item.url && !item.routerLink) {\n event.preventDefault();\n }\n\n if (item.command) {\n item.command({\n originalEvent: event,\n item: item\n });\n }\n\n if (item.items) {\n if (this.activeItem && item === this.activeItem) {\n this.activeItem = null;\n this.unbindDocumentClickListener();\n }\n else {\n this.activeItem = item;\n if (this.root) {\n this.bindDocumentClickListener();\n }\n }\n }\n\n if (!item.items) {\n this.onLeafClick();\n }\n }\n\n onItemMouseEnter(event, item) {\n if (item.disabled || this.mobileActive) {\n event.preventDefault();\n return;\n }\n\n if (this.root) {\n if (this.activeItem || this.autoDisplay) {\n this.activeItem = item;\n this.bindDocumentClickListener();\n }\n }\n else {\n this.activeItem = item;\n this.bindDocumentClickListener();\n }\n }\n\n onLeafClick() {\n this.activeItem = null;\n if (this.root) {\n this.unbindDocumentClickListener();\n }\n\n this.leafClick.emit();\n }\n\n bindDocumentClickListener() {\n if (!this.documentClickListener) {\n this.documentClickListener = (event) => {\n if (this.el && !this.el.nativeElement.contains(event.target)) {\n this.activeItem = null;\n this.cd.markForCheck();\n this.unbindDocumentClickListener();\n }\n };\n\n document.addEventListener('click', this.documentClickListener);\n }\n }\n\n unbindDocumentClickListener() {\n if (this.documentClickListener) {\n document.removeEventListener('click', this.documentClickListener);\n this.documentClickListener = null;\n }\n }\n\n ngOnDestroy() {\n this.unbindDocumentClickListener();\n }\n}\n\n@Component({\n selector: 'p-menubar',\n template: `\n
\n
\n \n
\n \n \n \n \n
\n \n
\n \n
\n \n
\n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./menubar.css'],\n host: {\n 'class': 'p-element'\n }\n})\nexport class Menubar implements AfterContentInit, OnDestroy {\n\n @Input() model: MenuItem[];\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() autoZIndex: boolean = true;\n\n @Input() baseZIndex: number = 0;\n\n @Input() autoDisplay: boolean;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n @ViewChild('menubutton') menubutton: ElementRef;\n\n @ViewChild('rootmenu') rootmenu: MenubarSub;\n\n startTemplate: TemplateRef;\n\n endTemplate: TemplateRef;\n\n mobileActive: boolean;\n\n outsideClickListener: any;\n\n constructor(public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig) { }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'start':\n this.startTemplate = item.template;\n break;\n\n case 'end':\n this.endTemplate = item.template;\n break;\n }\n });\n }\n\n toggle(event) {\n if (this.mobileActive) {\n this.hide();\n ZIndexUtils.clear(this.rootmenu.el.nativeElement);\n }\n else {\n this.mobileActive = true;\n ZIndexUtils.set('menu', this.rootmenu.el.nativeElement, this.config.zIndex.menu);\n }\n\n this.bindOutsideClickListener();\n event.preventDefault();\n }\n\n bindOutsideClickListener() {\n if (!this.outsideClickListener) {\n this.outsideClickListener = (event) => {\n if (this.mobileActive && this.rootmenu.el.nativeElement !== event.target && !this.rootmenu.el.nativeElement.contains(event.target)\n && this.menubutton.nativeElement !== event.target && !this.menubutton.nativeElement.contains(event.target)) {\n this.hide();\n }\n };\n document.addEventListener('click', this.outsideClickListener);\n }\n }\n\n hide() {\n this.mobileActive = false;\n this.cd.markForCheck();\n ZIndexUtils.clear(this.rootmenu.el.nativeElement);\n this.unbindOutsideClickListener();\n }\n\n onLeafClick() {\n this.hide();\n }\n\n unbindOutsideClickListener() {\n if (this.outsideClickListener) {\n document.removeEventListener('click', this.outsideClickListener);\n this.outsideClickListener = null;\n }\n }\n\n ngOnDestroy() {\n this.unbindOutsideClickListener();\n }\n}\n\n@NgModule({\n imports: [CommonModule,RouterModule,RippleModule,TooltipModule],\n exports: [Menubar,RouterModule,TooltipModule],\n declarations: [Menubar,MenubarSub]\n})\nexport class MenubarModule { }\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;MA4Ca,UAAU;IAqCnB,YAAmB,EAAc,EAAS,QAAmB,EAAU,EAAqB;QAAzE,OAAE,GAAF,EAAE,CAAY;QAAS,aAAQ,GAAR,QAAQ,CAAW;QAAU,OAAE,GAAF,EAAE,CAAmB;QA/BnF,eAAU,GAAY,IAAI,CAAC;QAE3B,eAAU,GAAW,CAAC,CAAC;QAmBtB,cAAS,GAAsB,IAAI,YAAY,EAAE,CAAC;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