{"version":3,"sources":["../../src/app/components/tabview/tabview.ts"],"names":["idx","TabPanel","tabView","viewContainer","cd","this","cache","tooltipPosition","tooltipPositionStyle","id","prototype","ngAfterContentInit","_this","templates","forEach","item","getType","headerTemplate","template","contentTemplate","Object","defineProperty","_selected","val","loaded","detectChanges","_disabled","disabled","markForCheck","ngOnDestroy","view","Component","args","selector","Inject","forwardRef","TabView","ViewContainerRef","ChangeDetectorRef","Input","ContentChildren","PrimeTemplate","el","orientation","onChange","EventEmitter","onClose","activeIndexChange","initTabs","tabPanels","changes","subscribe","_","ngAfterViewChecked","tabChanged","updateInkBar","tabs","toArray","findSelectedTab","length","activeIndex","selected","open","event","tab","preventDefault","selectedTab","selectedTabIndex","findTabIndex","preventActiveIndexPropagation","emit","originalEvent","index","close","controlClose","closeTab","stopPropagation","i","tabPanel","closed","getBlockableElement","nativeElement","children","_activeIndex","tabHeader","DomHandler","findSingle","navbar","inkbar","style","width","getWidth","left","getOffset","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","ElementRef","ViewChild","Output","NgModule","imports","CommonModule","SharedModule","TooltipModule","RippleModule","exports","declarations"],"mappings":"4nBASA,IAAIA,EAAc,eA0Dd,SAAAC,EAA+CC,EAAgBC,EAAwCC,GAAxCC,KAAAF,cAAAA,EAAwCE,KAAAD,GAAAA,EA9B9FC,KAAAC,OAAiB,EAIjBD,KAAAE,gBAA0B,MAE1BF,KAAAG,qBAA+B,WAgBxCH,KAAAI,GAAa,cAAcT,IASvBK,KAAKH,QAAUA,SAGnBD,EAAAS,UAAAC,mBAAA,WAAA,IAAAC,EAAAP,KACIA,KAAKQ,UAAUC,SAAQ,SAACC,GACpB,OAAOA,EAAKC,WACR,IAAK,SACDJ,EAAKK,eAAiBF,EAAKG,SAC/B,MAEA,IAAK,UAIL,QACIN,EAAKO,gBAAkBJ,EAAKG,cAM5CE,OAAAC,eAAapB,EAAAS,UAAA,WAAQ,KAArB,WACI,OAAOL,KAAKiB,eAGhB,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AeC,EAAAA,kBAAkBC,kdAjJTC,EAAAA,kBACoD9D,EAAAA,0DAqJ1EC,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,4BAEAA,EAAAA,sBAEA8D,EAAAA,UAASrE,KAAA,CAAC,0BAEVqE,EAAAA,UAASrE,KAAA,CAAC,6BAEVQ,EAAAA,gBAAeR,KAAA,CAAC/B,qBAEhBqG,EAAAA,wBAEAA,EAAAA,kCAEAA,EAAAA,4BAuIA/D,EAAAA,eA8BL,iCALCgE,EAAAA,SAAQvE,KAAA,CAAC,CACNwE,QAAS,CAACC,EAAAA,aAAaC,EAAAA,aAAaC,EAAAA,cAAcC,EAAAA,cAClDC,QAAS,CAACzE,EAAQnC,EAASyG,EAAAA,cAC3BI,aAAc,CAAC1E,EAAQnC","sourcesContent":["import {NgModule,Component,ElementRef,OnDestroy,Input,Output,EventEmitter,AfterContentInit,\n ContentChildren,QueryList,TemplateRef,EmbeddedViewRef,ViewContainerRef,ChangeDetectorRef,ChangeDetectionStrategy, ViewEncapsulation, ViewChild, AfterViewChecked, forwardRef, Inject} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {TooltipModule} from 'primeng/tooltip';\nimport {RippleModule} from 'primeng/ripple';\nimport {SharedModule,PrimeTemplate} from 'primeng/api';\nimport {BlockableUI} from 'primeng/api';\nimport {DomHandler} from 'primeng/dom';\n\nlet idx: number = 0;\n\n@Component({\n selector: 'p-tabPanel',\n template: `\n
\n \n \n \n \n
\n `\n})\nexport class TabPanel implements AfterContentInit,OnDestroy {\n\n @Input() header: string;\n \n @Input() closable: boolean;\n \n @Input() headerStyle: any;\n \n @Input() headerStyleClass: string;\n \n @Input() leftIcon: string;\n \n @Input() rightIcon: string;\n \n @Input() cache: boolean = true;\n\n @Input() tooltip: any;\n \n @Input() tooltipPosition: string = 'top';\n\n @Input() tooltipPositionStyle: string = 'absolute';\n\n @Input() tooltipStyleClass: string;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n \n closed: boolean;\n \n view: EmbeddedViewRef;\n \n _selected: boolean;\n\n _disabled: boolean;\n \n loaded: boolean;\n \n id: string = `p-tabpanel-${idx++}`;\n \n contentTemplate: TemplateRef;\n\n headerTemplate: TemplateRef;\n\n tabView: TabView;\n\n constructor(@Inject(forwardRef(() => TabView)) tabView, public viewContainer: ViewContainerRef, public cd: ChangeDetectorRef) {\n this.tabView = tabView as TabView;\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'header':\n this.headerTemplate = item.template;\n break;\n\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 selected(): boolean {\n return this._selected;\n }\n\n set selected(val: boolean) {\n this._selected = val;\n \n if (!this.loaded) {\n this.cd.detectChanges();\n }\n\n this.loaded = true;\n }\n\n @Input() get disabled(): boolean {\n return this._disabled;\n };\n\n set disabled(disabled: boolean) {\n this._disabled = disabled;\n this.tabView.cd.markForCheck();\n }\n \n ngOnDestroy() {\n this.view = null;\n }\n}\n\n@Component({\n selector: 'p-tabView',\n template: `\n
\n \n
\n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./tabview.css']\n})\nexport class TabView implements AfterContentInit,AfterViewChecked,BlockableUI {\n\n @Input() orientation: string = 'top';\n \n @Input() style: any;\n \n @Input() styleClass: string;\n \n @Input() controlClose: boolean;\n\n @ViewChild('navbar') navbar: ElementRef;\n\n @ViewChild('inkbar') inkbar: ElementRef;\n \n @ContentChildren(TabPanel) tabPanels: QueryList;\n\n @Output() onChange: EventEmitter = new EventEmitter();\n\n @Output() onClose: EventEmitter = new EventEmitter();\n\n @Output() activeIndexChange: EventEmitter = new EventEmitter();\n \n initialized: boolean;\n \n tabs: TabPanel[];\n \n _activeIndex: number;\n \n preventActiveIndexPropagation: boolean;\n\n tabChanged: boolean;\n\n constructor(public el: ElementRef, public cd: ChangeDetectorRef) {}\n \n ngAfterContentInit() {\n this.initTabs();\n \n this.tabPanels.changes.subscribe(_ => {\n this.initTabs();\n });\n }\n\n ngAfterViewChecked() {\n if (this.tabChanged) {\n this.updateInkBar();\n this.tabChanged = false;\n }\n }\n \n initTabs(): void {\n this.tabs = this.tabPanels.toArray();\n let selectedTab: TabPanel = this.findSelectedTab();\n if (!selectedTab && this.tabs.length) {\n if (this.activeIndex != null && this.tabs.length > this.activeIndex)\n this.tabs[this.activeIndex].selected = true;\n else\n this.tabs[0].selected = true;\n\n this.tabChanged = true;\n }\n\n this.cd.markForCheck();\n }\n \n open(event: Event, tab: TabPanel) {\n if (tab.disabled) {\n if (event) {\n event.preventDefault();\n }\n return;\n }\n \n if (!tab.selected) {\n let selectedTab: TabPanel = this.findSelectedTab();\n if (selectedTab) {\n selectedTab.selected = false\n }\n \n this.tabChanged = true;\n tab.selected = true;\n let selectedTabIndex = this.findTabIndex(tab);\n this.preventActiveIndexPropagation = true;\n this.activeIndexChange.emit(selectedTabIndex);\n this.onChange.emit({originalEvent: event, index: selectedTabIndex});\n }\n \n if (event) {\n event.preventDefault();\n }\n }\n \n close(event: Event, tab: TabPanel) {\n if (this.controlClose) {\n this.onClose.emit({\n originalEvent: event,\n index: this.findTabIndex(tab),\n close: () => {\n this.closeTab(tab);\n }}\n );\n }\n else {\n this.closeTab(tab);\n this.onClose.emit({\n originalEvent: event,\n index: this.findTabIndex(tab)\n });\n }\n \n event.stopPropagation();\n }\n \n closeTab(tab: TabPanel) {\n if (tab.disabled) {\n return;\n }\n if (tab.selected) {\n this.tabChanged = true;\n tab.selected = false;\n for(let i = 0; i < this.tabs.length; i++) {\n let tabPanel = this.tabs[i];\n if (!tabPanel.closed&&!tab.disabled) {\n tabPanel.selected = true;\n break;\n }\n }\n }\n \n tab.closed = true;\n }\n \n findSelectedTab() {\n for(let i = 0; i < this.tabs.length; i++) {\n if (this.tabs[i].selected) {\n return this.tabs[i];\n }\n }\n return null;\n }\n \n findTabIndex(tab: TabPanel) {\n let index = -1;\n for(let i = 0; i < this.tabs.length; i++) {\n if (this.tabs[i] == tab) {\n index = i;\n break;\n }\n }\n return index;\n }\n \n getBlockableElement(): HTMLElement {\n return this.el.nativeElement.children[0];\n }\n \n @Input() get activeIndex(): number {\n return this._activeIndex;\n }\n\n set activeIndex(val:number) {\n this._activeIndex = val;\n if (this.preventActiveIndexPropagation) {\n this.preventActiveIndexPropagation = false;\n return;\n }\n\n if (this.tabs && this.tabs.length && this._activeIndex != null && this.tabs.length > this._activeIndex) {\n this.findSelectedTab().selected = false;\n this.tabs[this._activeIndex].selected = true;\n }\n }\n\n updateInkBar() {\n let tabHeader = DomHandler.findSingle(this.navbar.nativeElement, 'li.p-highlight');\n this.inkbar.nativeElement.style.width = DomHandler.getWidth(tabHeader) + 'px';\n this.inkbar.nativeElement.style.left = DomHandler.getOffset(tabHeader).left - DomHandler.getOffset(this.navbar.nativeElement).left + 'px';\n }\n}\n\n\n@NgModule({\n imports: [CommonModule,SharedModule,TooltipModule,RippleModule],\n exports: [TabView,TabPanel,SharedModule],\n declarations: [TabView,TabPanel]\n})\nexport class TabViewModule { }\n"]}