{"version":3,"file":"primeng-tabview.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() 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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AASA,IAAI,GAAG,GAAW,CAAC,CAAC;MAcP,QAAQ;IA4CjB,YAA+C,OAAO,EAAS,aAA+B,EAAS,EAAqB;QAA7D,kBAAa,GAAb,aAAa,CAAkB;QAAS,OAAE,GAAF,EAAE,CAAmB;QApCnH,UAAK,GAAY,IAAI,CAAC;QAItB,oBAAe,GAAW,KAAK,CAAC;QAEhC,yBAAoB,GAAW,UAAU,CAAC;QAsBnD,OAAE,GAAW,cAAc,GAAG,EAAE,EAAE,CAAC;QAS/B,IAAI,CAAC,OAAO,GAAG,OAAkB,CAAC;KACrC;IAED,kBAAkB;QACd,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI;YACxB,QAAO,IAAI,CAAC,OAAO,EAAE;gBACjB,KAAK,QAAQ;oBACT,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC;oBACxC,MAAM;gBAEN,KAAK,SAAS;oBACV,IAAI,CAA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