import { Component, ContentChildren, QueryList } from '@angular/core';
import { Subscription } from 'rxjs';
import { RExpansionPanelComponent } from '../expansion-panel';
export class RExpansionPanelListComponent {
    constructor() {
        this.subs = new Subscription();
    }
    ngAfterContentInit() {
        this.subscribeOnExpandedChanges();
    }
    subscribeOnExpandedChanges() {
        const panels = this.panels.toArray();
        panels.forEach((panel) => {
            this.subs.add(panel.expandedChange.subscribe((expanded) => {
                if (expanded) {
                    this.resetPanelStates(panels);
                    panel.expanded = true;
                    panel.header.expanded = true;
                }
            }));
        });
    }
    resetPanelStates(panels) {
        panels.forEach((panel) => {
            panel.expanded = false;
            panel.header.expanded = false;
        });
    }
    ngOnDestroy() {
        this.subs.unsubscribe();
    }
}
RExpansionPanelListComponent.decorators = [
    { type: Component, args: [{
                selector: 'r-expansion-panel-list',
                template: `<ng-content select="r-expansion-panel"></ng-content>`,
                styles: [":host{display:block}"]
            },] }
];
RExpansionPanelListComponent.propDecorators = {
    panels: [{ type: ContentChildren, args: [RExpansionPanelComponent,] }]
};
//# sourceMappingURL=expansion-panel-list.component.js.map