{"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","_header","header","_leftIcon","leftIcon","_rightIcon","rightIcon","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,EApC9FC,KAAAC,OAAiB,EAIjBD,KAAAE,gBAA0B,MAE1BF,KAAAG,qBAA+B,WAsBxCH,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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AClC9D,KAAKyD,KAAKzD,KAAKoF,cAActB,UAAW,oCAIhDzB,EAAAhC,UAAAmD,aAAA,WACI,IAAI6B,EAAYC,EAAAA,WAAWC,WAAWvF,KAAKwF,OAAON,cAAe,kBACjElF,KAAKyF,OAAOP,cAAcQ,MAAMC,MAAQL,EAAAA,WAAWM,SAASP,GAAa,KACzErF,KAAKyF,OAAOP,cAAcQ,MAAMG,KAAQP,EAAAA,WAAWQ,UAAUT,GAAWQ,KAAOP,EAAAA,WAAWQ,UAAU9F,KAAKwF,OAAON,eAAeW,KAAO,+BA9M7I7D,EAAAA,UAASC,KAAA,CAAC,CACPC,SAAU,YACVrB,SAAU,63DAyBXkF,gBAAiBC,EAAAA,wBAAwBC,OACzCC,cAAeC,EAAAA,kBAAkBC,kdA7KTC,EAAAA,kBACoD9D,EAAAA,0DAiL1EC,EAAAA,qBAEAA,EAAAA,0BAEAA,EAAAA,4BAEAA,EAAAA,sBAEA8D,EAAAA,UAASrE,KAAA,CAAC,0BAEVqE,EAAAA,UAASrE,KAAA,CAAC,6BAEVQ,EAAAA,gBAAeR,KAAA,CAACrC,qBAEhB2G,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,EAAQzC,EAAS+G,EAAAA,cAC3BI,aAAc,CAAC1E,EAAQzC","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() closable: boolean;\n \n @Input() headerStyle: any;\n \n @Input() headerStyleClass: 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 _header: string;\n\n _leftIcon: string;\n\n _rightIcon: string;\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 if (val)\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 @Input() get header(): string {\n return this._header;\n }\n \n set header(header: string) {\n this._header = header;\n this.tabView.cd.markForCheck();\n }\n\n @Input() get leftIcon(): string {\n return this._leftIcon;\n }\n\n set leftIcon(leftIcon :string) {\n this._leftIcon = leftIcon;\n this.tabView.cd.markForCheck();\n }\n\n @Input() get rightIcon(): string {\n return this._rightIcon;\n }\n\n set rightIcon(rightIcon :string) {\n this._rightIcon = rightIcon;\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"]}