{"version":3,"sources":["../../src/app/components/accordion/accordion.ts"],"names":["idx","AccordionTab","accordion","changeDetector","this","cache","selectedChange","EventEmitter","transitionOptions","id","Object","defineProperty","prototype","_selected","val","loaded","markForCheck","ngAfterContentInit","_this","templates","forEach","item","getType","contentTemplate","template","headerTemplate","toggle","event","disabled","index","findTabIndex","selected","onClose","emit","originalEvent","multiple","i","tabs","length","onOpen","updateActiveIndex","preventDefault","headerFacet","onKeydown","which","ngOnDestroy","splice","Component","args","selector","animations","trigger","state","style","height","overflow","transition","animate","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","Inject","forwardRef","Accordion","ChangeDetectorRef","Input","Output","ContentChildren","Header","PrimeTemplate","el","expandIcon","collapseIcon","activeIndexChange","initTabs","tabListSubscription","tabList","changes","subscribe","_","toArray","updateSelectionState","getBlockableElement","nativeElement","children","_activeIndex","preventActiveIndexPropagation","includes","tab","push","unsubscribe","ElementRef","NgModule","imports","CommonModule","exports","SharedModule","declarations"],"mappings":"mhBAQA,IAAIA,EAAc,eAyFd,SAAAC,EAAiDC,EAAkBC,GAAAC,KAAAD,eAAAA,EAtC1DC,KAAAC,OAAiB,EAEhBD,KAAAE,eAAoC,IAAIC,EAAAA,aAEzCH,KAAAI,kBAA4B,uCA4BrCJ,KAAAK,GAAa,kBAAkBT,IAO3BI,KAAKF,UAAYA,SA3BrBQ,OAAAC,eAAaV,EAAAW,UAAA,WAAQ,KAArB,WACI,OAAOR,KAAKS,eAGhB,SAAaC,GACTV,KAAKS,UAAYC,EAEZV,KAAKW,SACFX,KAAKS,WAAaT,KAAKC,QACvBD,KAAKW,QAAS,GAGlBX,KAAKD,eAAea,iDAkB5Bf,EAAAW,UAAAK,mBAAA,WAAA,IAAAC,EAAAd,KACIA,KAAKe,UAAUC,SAAQ,SAACC,GACpB,OAAOA,EAAKC,WACR,IAAK,UACDJ,EAAKK,gBAAkBF,EAAKG,SAChC,MAEA,IAAK,SACDN,EAAKO,eAAiBJ,EAAK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AAA,0BAEAA,EAAAA,0BAEAA,EAAAA,4BAEAA,EAAAA,iCAEAC,EAAAA,wBAEAC,EAAAA,gBAAetB,KAAA,CAAC/C,wBA8BhBmE,EAAAA,eA2DL,iCALC2B,EAAAA,SAAQ/C,KAAA,CAAC,CACNgD,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAChC,EAAUjE,EAAakG,EAAAA,cACjCC,aAAc,CAAClC,EAAUjE","sourcesContent":["import { NgModule, Component, ElementRef, AfterContentInit, OnDestroy, Input, Output, EventEmitter, \n ContentChildren, QueryList, ChangeDetectorRef, Inject, forwardRef, TemplateRef, ViewRef, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport { trigger, state, style, transition, animate } from '@angular/animations';\nimport { CommonModule } from '@angular/common';\nimport { SharedModule, Header, PrimeTemplate } from 'primeng/api';\nimport { BlockableUI } from 'primeng/api';\nimport { Subscription } from 'rxjs';\n\nlet idx: number = 0;\n\n@Component({\n selector: 'p-accordionTab',\n template: `\n
\n
\n \n \n \n {{header}}\n \n \n \n \n
\n
\n
\n \n \n \n \n
\n
\n
\n `,\n animations: [\n trigger('tabContent', [\n state('hidden', style({\n height: '0',\n overflow: 'hidden'\n })),\n state('visible', style({\n height: '*'\n })),\n transition('visible <=> hidden', [style({overflow: 'hidden'}), animate('{{transitionParams}}')]),\n transition('void => *', animate(0))\n ])\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./accordion.css']\n})\nexport class AccordionTab implements AfterContentInit,OnDestroy {\n\n @Input() header: string;\n\n @Input() disabled: boolean;\n\n @Input() cache: boolean = true;\n\n @Output() selectedChange: EventEmitter = new EventEmitter();\n\n @Input() transitionOptions: string = '400ms cubic-bezier(0.86, 0, 0.07, 1)';\n\n @ContentChildren(Header) headerFacet: QueryList
;\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n private _selected: boolean;\n\n @Input() get selected(): any {\n return this._selected;\n }\n\n set selected(val: any) {\n this._selected = val;\n \n if (!this.loaded) {\n if (this._selected && this.cache) {\n this.loaded = true;\n }\n\n this.changeDetector.markForCheck();\n }\n }\n\n contentTemplate: TemplateRef;\n\n headerTemplate: TemplateRef;\n\n id: string = `p-accordiontab-${idx++}`;\n\n loaded: boolean;\n\n accordion: Accordion;\n\n constructor(@Inject(forwardRef(() => Accordion)) accordion, public changeDetector: ChangeDetectorRef) {\n this.accordion = accordion as Accordion;\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'content':\n this.contentTemplate = item.template;\n break;\n\n case 'header':\n this.headerTemplate = item.template;\n break;\n \n default:\n this.contentTemplate = item.template;\n break;\n }\n });\n }\n\n toggle(event) {\n if (this.disabled) {\n return false;\n }\n\n let index = this.findTabIndex();\n\n if (this.selected) {\n this.selected = false;\n this.accordion.onClose.emit({ originalEvent: event, index: index });\n }\n else {\n if (!this.accordion.multiple) {\n for (var i = 0; i < this.accordion.tabs.length; i++) {\n this.accordion.tabs[i].selected = false;\n this.accordion.tabs[i].selectedChange.emit(false);\n this.accordion.tabs[i].changeDetector.markForCheck();\n }\n }\n\n this.selected = true;\n this.loaded = true;\n this.accordion.onOpen.emit({ originalEvent: event, index: index });\n }\n\n this.selectedChange.emit(this.selected);\n this.accordion.updateActiveIndex();\n this.changeDetector.markForCheck();\n\n event.preventDefault();\n }\n\n findTabIndex() {\n let index = -1;\n for (var i = 0; i < this.accordion.tabs.length; i++) {\n if (this.accordion.tabs[i] == this) {\n index = i;\n break;\n }\n }\n return index;\n }\n\n get hasHeaderFacet(): boolean {\n return this.headerFacet && this.headerFacet.length > 0;\n }\n\n onKeydown(event: KeyboardEvent) {\n if (event.which === 32 || event.which === 13) {\n this.toggle(event);\n event.preventDefault();\n }\n }\n\n ngOnDestroy() {\n this.accordion.tabs.splice(this.findTabIndex(), 1);\n }\n}\n\n@Component({\n selector: 'p-accordion',\n template: `\n
\n \n
\n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class Accordion implements BlockableUI, AfterContentInit, OnDestroy {\n \n @Input() multiple: boolean;\n \n @Output() onClose: EventEmitter = new EventEmitter();\n\n @Output() onOpen: EventEmitter = new EventEmitter();\n\n @Input() style: any;\n \n @Input() styleClass: string;\n\n @Input() expandIcon: string = 'pi pi-fw pi-chevron-right';\n\n @Input() collapseIcon: string = 'pi pi-fw pi-chevron-down';\n\n @Output() activeIndexChange: EventEmitter = new EventEmitter();\n \n @ContentChildren(AccordionTab) tabList: QueryList;\n\n tabListSubscription: Subscription;\n \n private _activeIndex: any;\n\n preventActiveIndexPropagation: boolean;\n \n public tabs: AccordionTab[] = [];\n\n constructor(public el: ElementRef, public changeDetector: ChangeDetectorRef) {}\n\n ngAfterContentInit() {\n this.initTabs();\n\n this.tabListSubscription = this.tabList.changes.subscribe(_ => {\n this.initTabs();\n });\n }\n\n initTabs(): any {\n this.tabs = this.tabList.toArray();\n this.updateSelectionState();\n this.changeDetector.markForCheck();\n }\n \n getBlockableElement(): HTMLElement {\n return this.el.nativeElement.children[0];\n } \n \n @Input() get activeIndex(): any {\n return this._activeIndex;\n }\n\n set activeIndex(val: any) {\n this._activeIndex = val;\n if (this.preventActiveIndexPropagation) {\n this.preventActiveIndexPropagation = false;\n return;\n }\n\n this.updateSelectionState();\n }\n\n updateSelectionState() {\n if (this.tabs && this.tabs.length && this._activeIndex != null) {\n for (let i = 0; i < this.tabs.length; i++) {\n let selected = this.multiple ? this._activeIndex.includes(i) : (i === this._activeIndex);\n let changed = selected !== this.tabs[i].selected;\n\n if (changed) {\n this.tabs[i].selected = selected;\n this.tabs[i].selectedChange.emit(selected);\n this.tabs[i].changeDetector.markForCheck();\n }\n }\n }\n }\n\n updateActiveIndex() {\n let index: any = this.multiple ? [] : null;\n this.tabs.forEach((tab, i) => {\n if (tab.selected) {\n if (this.multiple) {\n index.push(i);\n }\n else {\n index = i;\n return;\n }\n }\n });\n\n this.preventActiveIndexPropagation = true;\n this.activeIndexChange.emit(index);\n }\n\n ngOnDestroy() {\n if (this.tabListSubscription) {\n this.tabListSubscription.unsubscribe();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [Accordion,AccordionTab,SharedModule],\n declarations: [Accordion,AccordionTab]\n})\nexport class AccordionModule { }\n"]}