{"version":3,"file":"primeng-accordion.umd.js","sources":["../../src/app/components/accordion/accordion.ts","../../src/app/components/accordion/primeng-accordion.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","Component","trigger","state","style","transition","animate","ChangeDetectionStrategy","ViewEncapsulation","Inject","forwardRef","ChangeDetectorRef","Input","Output","ContentChildren","Header","PrimeTemplate","ElementRef","NgModule","CommonModule","SharedModule"],"mappings":";;;;;;IAQA,IAAI,GAAG,GAAW,CAAC,CAAC;;QAyFhB,sBAAiD,SAAS,EAAS,cAAiC;YAAjC,mBAAc,GAAd,cAAc,CAAmB;YAtC3F,UAAK,GAAY,IAAI,CAAC;YAErB,mBAAc,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAExD,sBAAiB,GAAW,sCAAsC,CAAC;YA4B5E,OAAE,GAAW,oBAAkB,GAAG,EAAI,CAAC;YAOnC,IAAI,CAAC,SAAS,GAAG,SAAsB,CAAC;SAC3C;QA5BD,sBAAa,kCAAQ;iBAArB;gBACI,OAAO,IAAI,CAAC,SAAS,CAAC;aACzB;iBAED,UAAa,GAAQ;gBACjB,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;gBAErB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBACd,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,EAAE;wBAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;qBACtB;oBAED,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;iBACtC;aACJ;;;WAZA;QA4BD,yCAAkB,GAAlB;YAAA,iBAgBC;YAfG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI;gBACxB,QAAO,IAAI,CAAC,OAAO,EAAE;oBACjB,KAAK,SAAS;wBACV,KAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC;wBACzC,MAAM;oBAEN,KAAK,QAAQ;wBACT,KAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC;wBACxC,MAAM;oBAEN;wBACI,KAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAA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