{"version":3,"file":"primeng-tabview.umd.js","sources":["../../src/app/components/tabview/tabview.ts","../../src/app/components/tabview/primeng-tabview.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["Component","Inject","forwardRef","ViewContainerRef","ChangeDetectorRef","Input","ContentChildren","PrimeTemplate","EventEmitter","DomHandler","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","ViewChild","Output","NgModule","CommonModule","SharedModule","TooltipModule","RippleModule"],"mappings":";;;;;;IASA,IAAI,GAAG,GAAW,CAAC,CAAC;;QA0DhB,kBAA+C,OAAO,EAAS,aAA+B,EAAS,EAAqB;YAA7D,kBAAa,GAAb,aAAa,CAAkB;YAAS,OAAE,GAAF,EAAE,CAAmB;YA9BnH,UAAK,GAAY,IAAI,CAAC;YAItB,oBAAe,GAAW,KAAK,CAAC;YAEhC,yBAAoB,GAAW,UAAU,CAAC;YAgBnD,OAAE,GAAW,gBAAc,GAAG,EAAI,CAAC;YAS/B,IAAI,CAAC,OAAO,GAAG,OAAkB,CAAC;SACrC;QAED,qCAAkB,GAAlB;YAAA,iBAgBC;YAfG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI;gBACxB,QAAO,IAAI,CAAC,OAAO,EAAE;oBACjB,KAAK,QAAQ;wBACT,KAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC;wBACxC,MAAM;oBAEN,KAAK,SAAS;wBACV,KAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC;wBACzC,MAAM;oBAEN;wBACI,KAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAA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