1 | import * as i0 from '@angular/core';
|
---|
2 | import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ContentChildren, NgModule } from '@angular/core';
|
---|
3 | import { trigger, state, style, transition, animate } from '@angular/animations';
|
---|
4 | import * as i1 from '@angular/common';
|
---|
5 | import { CommonModule } from '@angular/common';
|
---|
6 | import { PrimeTemplate, SharedModule } from 'primeng/api';
|
---|
7 | import * as i2 from 'primeng/ripple';
|
---|
8 | import { RippleModule } from 'primeng/ripple';
|
---|
9 |
|
---|
10 | let idx = 0;
|
---|
11 | class Fieldset {
|
---|
12 | constructor(el) {
|
---|
13 | this.el = el;
|
---|
14 | this.collapsed = false;
|
---|
15 | this.collapsedChange = new EventEmitter();
|
---|
16 | this.onBeforeToggle = new EventEmitter();
|
---|
17 | this.onAfterToggle = new EventEmitter();
|
---|
18 | this.transitionOptions = '400ms cubic-bezier(0.86, 0, 0.07, 1)';
|
---|
19 | this.id = `p-fieldset-${idx++}`;
|
---|
20 | }
|
---|
21 | ngAfterContentInit() {
|
---|
22 | this.templates.forEach((item) => {
|
---|
23 | switch (item.getType()) {
|
---|
24 | case 'header':
|
---|
25 | this.headerTemplate = item.template;
|
---|
26 | break;
|
---|
27 | case 'content':
|
---|
28 | this.contentTemplate = item.template;
|
---|
29 | break;
|
---|
30 | }
|
---|
31 | });
|
---|
32 | }
|
---|
33 | toggle(event) {
|
---|
34 | if (this.animating) {
|
---|
35 | return false;
|
---|
36 | }
|
---|
37 | this.animating = true;
|
---|
38 | this.onBeforeToggle.emit({ originalEvent: event, collapsed: this.collapsed });
|
---|
39 | if (this.collapsed)
|
---|
40 | this.expand(event);
|
---|
41 | else
|
---|
42 | this.collapse(event);
|
---|
43 | this.onAfterToggle.emit({ originalEvent: event, collapsed: this.collapsed });
|
---|
44 | event.preventDefault();
|
---|
45 | }
|
---|
46 | expand(event) {
|
---|
47 | this.collapsed = false;
|
---|
48 | this.collapsedChange.emit(this.collapsed);
|
---|
49 | }
|
---|
50 | collapse(event) {
|
---|
51 | this.collapsed = true;
|
---|
52 | this.collapsedChange.emit(this.collapsed);
|
---|
53 | }
|
---|
54 | getBlockableElement() {
|
---|
55 | return this.el.nativeElement.children[0];
|
---|
56 | }
|
---|
57 | onToggleDone(event) {
|
---|
58 | this.animating = false;
|
---|
59 | }
|
---|
60 | }
|
---|
61 | Fieldset.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Fieldset, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
---|
62 | Fieldset.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Fieldset, selector: "p-fieldset", inputs: { legend: "legend", toggleable: "toggleable", collapsed: "collapsed", 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: `
|
---|
63 | <fieldset [attr.id]="id" [ngClass]="{'p-fieldset p-component': true, 'p-fieldset-toggleable': toggleable}" [ngStyle]="style" [class]="styleClass">
|
---|
64 | <legend class="p-fieldset-legend">
|
---|
65 | <ng-container *ngIf="toggleable; else legendContent">
|
---|
66 | <a tabindex="0" (click)="toggle($event)" (keydown.enter)="toggle($event)" [attr.aria-controls]="id + '-content'" [attr.aria-expanded]="!collapsed" pRipple>
|
---|
67 | <span class="p-fieldset-toggler pi" *ngIf="toggleable" [ngClass]="{'pi-minus': !collapsed,'pi-plus':collapsed}"></span>
|
---|
68 | <ng-container *ngTemplateOutlet="legendContent"></ng-container>
|
---|
69 | </a>
|
---|
70 | </ng-container>
|
---|
71 | <ng-template #legendContent>
|
---|
72 | <span class="p-fieldset-legend-text">{{legend}}</span>
|
---|
73 | <ng-content select="p-header"></ng-content>
|
---|
74 | <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
---|
75 | </ng-template>
|
---|
76 | </legend>
|
---|
77 | <div [attr.id]="id + '-content'" class="p-toggleable-content" [@fieldsetContent]="collapsed ? {value: 'hidden', params: {transitionParams: transitionOptions, height: '0'}} : {value: 'visible', params: {transitionParams: animating ? transitionOptions : '0ms', height: '*'}}"
|
---|
78 | [attr.aria-labelledby]="id" [attr.aria-hidden]="collapsed"
|
---|
79 | (@fieldsetContent.done)="onToggleDone($event)" role="region">
|
---|
80 | <div class="p-fieldset-content">
|
---|
81 | <ng-content></ng-content>
|
---|
82 | <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
|
---|
83 | </div>
|
---|
84 | </div>
|
---|
85 | </fieldset>
|
---|
86 | `, isInline: true, styles: [".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;-ms-user-select:none;user-select:none;overflow:hidden;position:relative}.p-fieldset-legend-text{line-height:1}\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: i2.Ripple, selector: "[pRipple]" }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], animations: [
|
---|
87 | trigger('fieldsetContent', [
|
---|
88 | state('hidden', style({
|
---|
89 | height: '0',
|
---|
90 | overflow: 'hidden'
|
---|
91 | })),
|
---|
92 | state('visible', style({
|
---|
93 | height: '*'
|
---|
94 | })),
|
---|
95 | transition('visible <=> hidden', [style({ overflow: 'hidden' }), animate('{{transitionParams}}')]),
|
---|
96 | transition('void => *', animate(0))
|
---|
97 | ])
|
---|
98 | ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
---|
99 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Fieldset, decorators: [{
|
---|
100 | type: Component,
|
---|
101 | args: [{ selector: 'p-fieldset', template: `
|
---|
102 | <fieldset [attr.id]="id" [ngClass]="{'p-fieldset p-component': true, 'p-fieldset-toggleable': toggleable}" [ngStyle]="style" [class]="styleClass">
|
---|
103 | <legend class="p-fieldset-legend">
|
---|
104 | <ng-container *ngIf="toggleable; else legendContent">
|
---|
105 | <a tabindex="0" (click)="toggle($event)" (keydown.enter)="toggle($event)" [attr.aria-controls]="id + '-content'" [attr.aria-expanded]="!collapsed" pRipple>
|
---|
106 | <span class="p-fieldset-toggler pi" *ngIf="toggleable" [ngClass]="{'pi-minus': !collapsed,'pi-plus':collapsed}"></span>
|
---|
107 | <ng-container *ngTemplateOutlet="legendContent"></ng-container>
|
---|
108 | </a>
|
---|
109 | </ng-container>
|
---|
110 | <ng-template #legendContent>
|
---|
111 | <span class="p-fieldset-legend-text">{{legend}}</span>
|
---|
112 | <ng-content select="p-header"></ng-content>
|
---|
113 | <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
|
---|
114 | </ng-template>
|
---|
115 | </legend>
|
---|
116 | <div [attr.id]="id + '-content'" class="p-toggleable-content" [@fieldsetContent]="collapsed ? {value: 'hidden', params: {transitionParams: transitionOptions, height: '0'}} : {value: 'visible', params: {transitionParams: animating ? transitionOptions : '0ms', height: '*'}}"
|
---|
117 | [attr.aria-labelledby]="id" [attr.aria-hidden]="collapsed"
|
---|
118 | (@fieldsetContent.done)="onToggleDone($event)" role="region">
|
---|
119 | <div class="p-fieldset-content">
|
---|
120 | <ng-content></ng-content>
|
---|
121 | <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
|
---|
122 | </div>
|
---|
123 | </div>
|
---|
124 | </fieldset>
|
---|
125 | `, animations: [
|
---|
126 | trigger('fieldsetContent', [
|
---|
127 | state('hidden', style({
|
---|
128 | height: '0',
|
---|
129 | overflow: 'hidden'
|
---|
130 | })),
|
---|
131 | state('visible', style({
|
---|
132 | height: '*'
|
---|
133 | })),
|
---|
134 | transition('visible <=> hidden', [style({ overflow: 'hidden' }), animate('{{transitionParams}}')]),
|
---|
135 | transition('void => *', animate(0))
|
---|
136 | ])
|
---|
137 | ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
---|
138 | 'class': 'p-element'
|
---|
139 | }, styles: [".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;-ms-user-select:none;user-select:none;overflow:hidden;position:relative}.p-fieldset-legend-text{line-height:1}\n"] }]
|
---|
140 | }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { legend: [{
|
---|
141 | type: Input
|
---|
142 | }], toggleable: [{
|
---|
143 | type: Input
|
---|
144 | }], collapsed: [{
|
---|
145 | type: Input
|
---|
146 | }], collapsedChange: [{
|
---|
147 | type: Output
|
---|
148 | }], onBeforeToggle: [{
|
---|
149 | type: Output
|
---|
150 | }], onAfterToggle: [{
|
---|
151 | type: Output
|
---|
152 | }], style: [{
|
---|
153 | type: Input
|
---|
154 | }], styleClass: [{
|
---|
155 | type: Input
|
---|
156 | }], transitionOptions: [{
|
---|
157 | type: Input
|
---|
158 | }], templates: [{
|
---|
159 | type: ContentChildren,
|
---|
160 | args: [PrimeTemplate]
|
---|
161 | }] } });
|
---|
162 | class FieldsetModule {
|
---|
163 | }
|
---|
164 | FieldsetModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: FieldsetModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
---|
165 | FieldsetModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: FieldsetModule, declarations: [Fieldset], imports: [CommonModule, RippleModule], exports: [Fieldset, SharedModule] });
|
---|
166 | FieldsetModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: FieldsetModule, imports: [[CommonModule, RippleModule], SharedModule] });
|
---|
167 | i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: FieldsetModule, decorators: [{
|
---|
168 | type: NgModule,
|
---|
169 | args: [{
|
---|
170 | imports: [CommonModule, RippleModule],
|
---|
171 | exports: [Fieldset, SharedModule],
|
---|
172 | declarations: [Fieldset]
|
---|
173 | }]
|
---|
174 | }] });
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Generated bundle index. Do not edit.
|
---|
178 | */
|
---|
179 |
|
---|
180 | export { Fieldset, FieldsetModule };
|
---|