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, ContentChildren, NgModule } from '@angular/core'; import { 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'; /** * Fieldset is a grouping component with the optional content toggle feature. * @group Components */ class Fieldset { el; /** * Header text of the fieldset. * @group Props */ legend; /** * When specified, content can toggled by clicking the legend. * @group Props * @defaultValue false */ toggleable; /** * Defines the default visibility state of the content. * * @group Props */ collapsed = false; /** * Inline style of the component. * @group Props */ style; /** * Style class of the component. * @group Props */ styleClass; /** * Transition options of the panel animation. * @group Props */ transitionOptions = '400ms cubic-bezier(0.86, 0, 0.07, 1)'; /** * Emits when the collapsed state changes. * @param {boolean} value - New value. * @group Emits */ collapsedChange = new EventEmitter(); /** * Callback to invoke before panel toggle. * @param {PanelBeforeToggleEvent} event - Custom toggle event * @group Emits */ onBeforeToggle = new EventEmitter(); /** * Callback to invoke after panel toggle. * @param {PanelAfterToggleEvent} event - Custom toggle event * @group Emits */ onAfterToggle = new EventEmitter(); templates; get id() { return UniqueComponentId(); } get buttonAriaLabel() { return this.legend; } animating; headerTemplate; contentTemplate; collapseIconTemplate; expandIconTemplate; constructor(el) { this.el = el; } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'header': this.headerTemplate = item.template; break; case 'expandicon': this.expandIconTemplate = item.template; break; case 'collapseicon': this.collapseIconTemplate = item.template; break; case 'content': this.contentTemplate = item.template; break; } }); } toggle(event) { if (this.animating) { return false; } this.animating = true; this.onBeforeToggle.emit({ originalEvent: event, collapsed: this.collapsed }); if (this.collapsed) this.expand(); else this.collapse(); this.onAfterToggle.emit({ originalEvent: event, collapsed: this.collapsed }); event.preventDefault(); } onKeyDown(event) { if (event.code === 'Enter' || event.code === 'Space') { this.toggle(event); 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]; } onToggleDone() { this.animating = false; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Fieldset, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.3.7", type: Fieldset, selector: "p-fieldset", inputs: { legend: "legend", toggleable: ["toggleable", "toggleable", booleanAttribute], collapsed: ["collapsed", "collapsed", booleanAttribute], style: "style", styleClass: "styleClass", transitionOptions: "transitionOptions" }, outputs: { collapsedChange: "collapsedChange", onBeforeToggle: "onBeforeToggle", onAfterToggle: "onAfterToggle" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
{{ legend }}
`, isInline: true, styles: ["@layer primeng{.p-fieldset{min-width:initial}.p-fieldset-legend>a,.p-fieldset-legend>span{display:flex;align-items:center;justify-content:center}.p-fieldset-toggleable .p-fieldset-legend a{cursor:pointer;-webkit-user-select:none;user-select:none;overflow:hidden;position:relative}.p-fieldset-legend-text{line-height:1}.p-fieldset-toggleable.p-fieldset-expanded>.p-toggleable-content:not(.ng-animating){overflow:visible}.p-fieldset-toggleable .p-toggleable-content{overflow:hidden}}\n"], dependencies: [{ kind: "directive", type: i0.forwardRef(() => i1.NgClass), selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgIf), selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgTemplateOutlet), selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i0.forwardRef(() => i1.NgStyle), selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i0.forwardRef(() => i2.Ripple), selector: "[pRipple]" }, { kind: "component", type: i0.forwardRef(() => MinusIcon), selector: "MinusIcon" }, { kind: "component", type: i0.forwardRef(() => PlusIcon), selector: "PlusIcon" }], animations: [ trigger('fieldsetContent', [ state('hidden', style({ height: '0' })), state('visible', style({ height: '*' })), transition('visible <=> hidden', [animate('{{transitionParams}}')]), transition('void => *', animate(0)) ]) ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: Fieldset, decorators: [{ type: Component, args: [{ selector: 'p-fieldset', template: `
{{ legend }}
`, animations: [ trigger('fieldsetContent', [ state('hidden', style({ height: '0' })), state('visible', style({ height: '*' })), transition('visible <=> hidden', [animate('{{transitionParams}}')]), transition('void => *', animate(0)) ]) ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { class: 'p-element' }, styles: ["@layer primeng{.p-fieldset{min-width:initial}.p-fieldset-legend>a,.p-fieldset-legend>span{display:flex;align-items:center;justify-content:center}.p-fieldset-toggleable .p-fieldset-legend a{cursor:pointer;-webkit-user-select:none;user-select:none;overflow:hidden;position:relative}.p-fieldset-legend-text{line-height:1}.p-fieldset-toggleable.p-fieldset-expanded>.p-toggleable-content:not(.ng-animating){overflow:visible}.p-fieldset-toggleable .p-toggleable-content{overflow:hidden}}\n"] }] }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { legend: [{ type: Input }], toggleable: [{ type: Input, args: [{ transform: booleanAttribute }] }], collapsed: [{ type: Input, args: [{ transform: booleanAttribute }] }], style: [{ type: Input }], styleClass: [{ type: Input }], transitionOptions: [{ type: Input }], collapsedChange: [{ type: Output }], onBeforeToggle: [{ type: Output }], onAfterToggle: [{ type: Output }], templates: [{ type: ContentChildren, args: [PrimeTemplate] }] } }); class FieldsetModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FieldsetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.7", ngImport: i0, type: FieldsetModule, declarations: [Fieldset], imports: [CommonModule, RippleModule, MinusIcon, PlusIcon], exports: [Fieldset, SharedModule] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FieldsetModule, imports: [CommonModule, RippleModule, MinusIcon, PlusIcon, SharedModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: FieldsetModule, decorators: [{ type: NgModule, args: [{ imports: [CommonModule, RippleModule, MinusIcon, PlusIcon], exports: [Fieldset, SharedModule], declarations: [Fieldset] }] }] }); /** * Generated bundle index. Do not edit. */ export { Fieldset, FieldsetModule }; //# sourceMappingURL=primeng-fieldset.mjs.map