import * as i0 from '@angular/core';
import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChild, ContentChildren, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import { Footer, PrimeTemplate, SharedModule } from 'primeng/api';
import * as i2 from 'primeng/ripple';
import { RippleModule } from 'primeng/ripple';
import { trigger, state, style, transition, animate } from '@angular/animations';
let idx = 0;
class Panel {
constructor(el) {
this.el = el;
this.collapsed = false;
this.expandIcon = 'pi pi-plus';
this.collapseIcon = 'pi pi-minus';
this.showHeader = true;
this.toggler = "icon";
this.collapsedChange = new EventEmitter();
this.onBeforeToggle = new EventEmitter();
this.onAfterToggle = new EventEmitter();
this.transitionOptions = '400ms cubic-bezier(0.86, 0, 0.07, 1)';
this.id = `p-panel-${idx++}`;
}
ngAfterContentInit() {
this.templates.forEach((item) => {
switch (item.getType()) {
case 'header':
this.headerTemplate = item.template;
break;
case 'content':
this.contentTemplate = item.template;
break;
case 'footer':
this.footerTemplate = item.template;
break;
case 'icons':
this.iconTemplate = item.template;
break;
default:
this.contentTemplate = item.template;
break;
}
});
}
onHeaderClick(event) {
if (this.toggler === 'header') {
this.toggle(event);
}
}
onIconClick(event) {
if (this.toggler === 'icon') {
this.toggle(event);
}
}
toggle(event) {
if (this.animating) {
return false;
}
this.animating = true;
this.onBeforeToggle.emit({ originalEvent: event, collapsed: this.collapsed });
if (this.toggleable) {
if (this.collapsed)
this.expand(event);
else
this.collapse(event);
}
event.preventDefault();
}
expand(event) {
this.collapsed = false;
this.collapsedChange.emit(this.collapsed);
}
collapse(event) {
this.collapsed = true;
this.collapsedChange.emit(this.collapsed);
}
getBlockableElement() {
return this.el.nativeElement.children[0];
}
onToggleDone(event) {
this.animating = false;
this.onAfterToggle.emit({ originalEvent: event, collapsed: this.collapsed });
}
}
Panel.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Panel, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
Panel.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Panel, selector: "p-panel", inputs: { toggleable: "toggleable", header: "header", collapsed: "collapsed", style: "style", styleClass: "styleClass", expandIcon: "expandIcon", collapseIcon: "collapseIcon", showHeader: "showHeader", toggler: "toggler", transitionOptions: "transitionOptions" }, outputs: { collapsedChange: "collapsedChange", onBeforeToggle: "onBeforeToggle", onAfterToggle: "onAfterToggle" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "footerFacet", first: true, predicate: Footer, descendants: true }, { propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
`, isInline: true, styles: [".p-panel-header{display:flex;justify-content:space-between;align-items:center}.p-panel-title{line-height:1}.p-panel-header-icon{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;text-decoration:none;overflow:hidden;position:relative}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i2.Ripple, selector: "[pRipple]" }], animations: [
trigger('panelContent', [
state('hidden', style({
height: '0',
overflow: 'hidden'
})),
state('void', style({
height: '{{height}}'
}), { params: { height: '0' } }),
state('visible', style({
height: '*'
})),
transition('visible <=> hidden', [style({ overflow: 'hidden' }), animate('{{transitionParams}}')]),
transition('void => hidden', animate('{{transitionParams}}')),
transition('void => visible', animate('{{transitionParams}}'))
])
], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Panel, decorators: [{
type: Component,
args: [{ selector: 'p-panel', template: `
`, animations: [
trigger('panelContent', [
state('hidden', style({
height: '0',
overflow: 'hidden'
})),
state('void', style({
height: '{{height}}'
}), { params: { height: '0' } }),
state('visible', style({
height: '*'
})),
transition('visible <=> hidden', [style({ overflow: 'hidden' }), animate('{{transitionParams}}')]),
transition('void => hidden', animate('{{transitionParams}}')),
transition('void => visible', animate('{{transitionParams}}'))
])
], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
'class': 'p-element'
}, styles: [".p-panel-header{display:flex;justify-content:space-between;align-items:center}.p-panel-title{line-height:1}.p-panel-header-icon{display:inline-flex;justify-content:center;align-items:center;cursor:pointer;text-decoration:none;overflow:hidden;position:relative}\n"] }]
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { toggleable: [{
type: Input
}], header: [{
type: Input
}], collapsed: [{
type: Input
}], style: [{
type: Input
}], styleClass: [{
type: Input
}], expandIcon: [{
type: Input
}], collapseIcon: [{
type: Input
}], showHeader: [{
type: Input
}], toggler: [{
type: Input
}], collapsedChange: [{
type: Output
}], onBeforeToggle: [{
type: Output
}], onAfterToggle: [{
type: Output
}], transitionOptions: [{
type: Input
}], footerFacet: [{
type: ContentChild,
args: [Footer]
}], templates: [{
type: ContentChildren,
args: [PrimeTemplate]
}] } });
class PanelModule {
}
PanelModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PanelModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
PanelModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PanelModule, declarations: [Panel], imports: [CommonModule, SharedModule, RippleModule], exports: [Panel, SharedModule] });
PanelModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PanelModule, imports: [[CommonModule, SharedModule, RippleModule], SharedModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PanelModule, decorators: [{
type: NgModule,
args: [{
imports: [CommonModule, SharedModule, RippleModule],
exports: [Panel, SharedModule],
declarations: [Panel]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { Panel, PanelModule };