{"version":3,"file":"primeng-accordion.mjs","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, 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 host: {\n 'class': 'p-element'\n }\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.detectChanges();\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 host: {\n 'class': 'p-element'\n }\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})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