import { trigger, state, style, transition, animate } from '@angular/animations'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i0 from '@angular/core'; import { EventEmitter, booleanAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChild, ContentChildren, NgModule } from '@angular/core'; import { Footer, PrimeTemplate, SharedModule } from 'primeng/api'; import { MinusIcon } from 'primeng/icons/minus'; import { PlusIcon } from 'primeng/icons/plus'; import * as i2 from 'primeng/ripple'; import { RippleModule } from 'primeng/ripple'; import { UniqueComponentId } from 'primeng/utils'; /** * Panel is a container with the optional content toggle feature. * @group Components */ class Panel { el; /** * Defines if content of panel can be expanded and collapsed. * @group Props */ toggleable; /** * Header text of the panel. * @group Props */ header; /** * Defines the initial state of panel content, supports one or two-way binding as well. * @group Props */ collapsed; /** * Inline style of the component. * @group Props */ style; /** * Style class of the component. * @group Props */ styleClass; /** * Position of the icons. * @group Props */ iconPos = 'end'; /** * Expand icon of the toggle button. * @group Props * @deprecated since v15.4.2, use `headericons` template instead. */ expandIcon; /** * Collapse icon of the toggle button. * @group Props * @deprecated since v15.4.2, use `headericons` template instead. */ collapseIcon; /** * Specifies if header of panel cannot be displayed. * @group Props * @deprecated since v15.4.2, use `headericons` template instead. */ showHeader = true; /** * Specifies the toggler element to toggle the panel content. * @group Props */ toggler = 'icon'; /** * Transition options of the animation. * @group Props */ transitionOptions = '400ms cubic-bezier(0.86, 0, 0.07, 1)'; /** * Emitted when the collapsed changes. * @param {boolean} value - New Value. * @group Emits */ collapsedChange = new EventEmitter(); /** * Callback to invoke before panel toggle. * @param {PanelBeforeToggleEvent} event - Custom panel toggle event * @group Emits */ onBeforeToggle = new EventEmitter(); /** * Callback to invoke after panel toggle. * @param {PanelAfterToggleEvent} event - Custom panel toggle event * @group Emits */ onAfterToggle = new EventEmitter(); footerFacet; templates; iconTemplate; animating; headerTemplate; contentTemplate; footerTemplate; headerIconTemplate; id = UniqueComponentId(); get buttonAriaLabel() { return this.header; } constructor(el) { this.el = el; } 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; case 'headericons': this.headerIconTemplate = 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(); else this.collapse(); } event.preventDefault(); } expand() { this.collapsed = false; this.collapsedChange.emit(this.collapsed); } collapse() { this.collapsed = true; this.collapsedChange.emit(this.collapsed); } getBlockableElement() { return this.el.nativeElement.children[0]; } onKeyDown(event) { if (event.code === 'Enter' || event.code === 'Space') { this.toggle(event); event.preventDefault(); } } onToggleDone(event) { this.animating = false; this.onAfterToggle.emit({ originalEvent: event, collapsed: this.collapsed }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Panel, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: Panel, selector: "p-panel", inputs: { toggleable: ["toggleable", "toggleable", booleanAttribute], header: "header", collapsed: ["collapsed", "collapsed", booleanAttribute], style: "style", styleClass: "styleClass", iconPos: "iconPos", expandIcon: "expandIcon", collapseIcon: "collapseIcon", showHeader: ["showHeader", "showHeader", booleanAttribute], 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: `