source: trip-planner-front/node_modules/primeng/fesm2020/primeng-accordion.mjs@ 1ad8e64

Last change on this file since 1ad8e64 was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 15.9 KB
Line 
1import * as i0 from '@angular/core';
2import { EventEmitter, forwardRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Inject, Input, Output, ContentChildren, NgModule } from '@angular/core';
3import { trigger, state, style, transition, animate } from '@angular/animations';
4import * as i1 from '@angular/common';
5import { CommonModule } from '@angular/common';
6import { Header, PrimeTemplate, SharedModule } from 'primeng/api';
7
8let idx = 0;
9class AccordionTab {
10 constructor(accordion, changeDetector) {
11 this.changeDetector = changeDetector;
12 this.cache = true;
13 this.selectedChange = new EventEmitter();
14 this.transitionOptions = '400ms cubic-bezier(0.86, 0, 0.07, 1)';
15 this.id = `p-accordiontab-${idx++}`;
16 this.accordion = accordion;
17 }
18 get selected() {
19 return this._selected;
20 }
21 set selected(val) {
22 this._selected = val;
23 if (!this.loaded) {
24 if (this._selected && this.cache) {
25 this.loaded = true;
26 }
27 this.changeDetector.detectChanges();
28 }
29 }
30 ngAfterContentInit() {
31 this.templates.forEach((item) => {
32 switch (item.getType()) {
33 case 'content':
34 this.contentTemplate = item.template;
35 break;
36 case 'header':
37 this.headerTemplate = item.template;
38 break;
39 default:
40 this.contentTemplate = item.template;
41 break;
42 }
43 });
44 }
45 toggle(event) {
46 if (this.disabled) {
47 return false;
48 }
49 let index = this.findTabIndex();
50 if (this.selected) {
51 this.selected = false;
52 this.accordion.onClose.emit({ originalEvent: event, index: index });
53 }
54 else {
55 if (!this.accordion.multiple) {
56 for (var i = 0; i < this.accordion.tabs.length; i++) {
57 this.accordion.tabs[i].selected = false;
58 this.accordion.tabs[i].selectedChange.emit(false);
59 this.accordion.tabs[i].changeDetector.markForCheck();
60 }
61 }
62 this.selected = true;
63 this.loaded = true;
64 this.accordion.onOpen.emit({ originalEvent: event, index: index });
65 }
66 this.selectedChange.emit(this.selected);
67 this.accordion.updateActiveIndex();
68 this.changeDetector.markForCheck();
69 event.preventDefault();
70 }
71 findTabIndex() {
72 let index = -1;
73 for (var i = 0; i < this.accordion.tabs.length; i++) {
74 if (this.accordion.tabs[i] == this) {
75 index = i;
76 break;
77 }
78 }
79 return index;
80 }
81 get hasHeaderFacet() {
82 return this.headerFacet && this.headerFacet.length > 0;
83 }
84 onKeydown(event) {
85 if (event.which === 32 || event.which === 13) {
86 this.toggle(event);
87 event.preventDefault();
88 }
89 }
90 ngOnDestroy() {
91 this.accordion.tabs.splice(this.findTabIndex(), 1);
92 }
93}
94AccordionTab.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionTab, deps: [{ token: forwardRef(() => Accordion) }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
95AccordionTab.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: AccordionTab, selector: "p-accordionTab", inputs: { header: "header", disabled: "disabled", cache: "cache", transitionOptions: "transitionOptions", selected: "selected" }, outputs: { selectedChange: "selectedChange" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "headerFacet", predicate: Header }, { propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
96 <div class="p-accordion-tab" [ngClass]="{'p-accordion-tab-active': selected}">
97 <div class="p-accordion-header" [ngClass]="{'p-highlight': selected, 'p-disabled': disabled}">
98 <a role="tab" class="p-accordion-header-link" (click)="toggle($event)" (keydown)="onKeydown($event)" [attr.tabindex]="disabled ? null : 0"
99 [attr.id]="id" [attr.aria-controls]="id + '-content'" [attr.aria-expanded]="selected">
100 <span class="p-accordion-toggle-icon" [ngClass]="selected ? accordion.collapseIcon : accordion.expandIcon"></span>
101 <span class="p-accordion-header-text" *ngIf="!hasHeaderFacet">
102 {{header}}
103 </span>
104 <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
105 <ng-content select="p-header" *ngIf="hasHeaderFacet"></ng-content>
106 </a>
107 </div>
108 <div [attr.id]="id + '-content'" class="p-toggleable-content" [@tabContent]="selected ? {value: 'visible', params: {transitionParams: transitionOptions}} : {value: 'hidden', params: {transitionParams: transitionOptions}}"
109 role="region" [attr.aria-hidden]="!selected" [attr.aria-labelledby]="id">
110 <div class="p-accordion-content">
111 <ng-content></ng-content>
112 <ng-container *ngIf="contentTemplate && (cache ? loaded : selected)">
113 <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
114 </ng-container>
115 </div>
116 </div>
117 </div>
118 `, isInline: true, styles: [".p-accordion-header-link{cursor:pointer;display:flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;position:relative;text-decoration:none}.p-accordion-header-link:focus{z-index:1}.p-accordion-header-text{line-height:1}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], animations: [
119 trigger('tabContent', [
120 state('hidden', style({
121 height: '0',
122 overflow: 'hidden'
123 })),
124 state('visible', style({
125 height: '*'
126 })),
127 transition('visible <=> hidden', [style({ overflow: 'hidden' }), animate('{{transitionParams}}')]),
128 transition('void => *', animate(0))
129 ])
130 ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
131i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionTab, decorators: [{
132 type: Component,
133 args: [{ selector: 'p-accordionTab', template: `
134 <div class="p-accordion-tab" [ngClass]="{'p-accordion-tab-active': selected}">
135 <div class="p-accordion-header" [ngClass]="{'p-highlight': selected, 'p-disabled': disabled}">
136 <a role="tab" class="p-accordion-header-link" (click)="toggle($event)" (keydown)="onKeydown($event)" [attr.tabindex]="disabled ? null : 0"
137 [attr.id]="id" [attr.aria-controls]="id + '-content'" [attr.aria-expanded]="selected">
138 <span class="p-accordion-toggle-icon" [ngClass]="selected ? accordion.collapseIcon : accordion.expandIcon"></span>
139 <span class="p-accordion-header-text" *ngIf="!hasHeaderFacet">
140 {{header}}
141 </span>
142 <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>
143 <ng-content select="p-header" *ngIf="hasHeaderFacet"></ng-content>
144 </a>
145 </div>
146 <div [attr.id]="id + '-content'" class="p-toggleable-content" [@tabContent]="selected ? {value: 'visible', params: {transitionParams: transitionOptions}} : {value: 'hidden', params: {transitionParams: transitionOptions}}"
147 role="region" [attr.aria-hidden]="!selected" [attr.aria-labelledby]="id">
148 <div class="p-accordion-content">
149 <ng-content></ng-content>
150 <ng-container *ngIf="contentTemplate && (cache ? loaded : selected)">
151 <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
152 </ng-container>
153 </div>
154 </div>
155 </div>
156 `, animations: [
157 trigger('tabContent', [
158 state('hidden', style({
159 height: '0',
160 overflow: 'hidden'
161 })),
162 state('visible', style({
163 height: '*'
164 })),
165 transition('visible <=> hidden', [style({ overflow: 'hidden' }), animate('{{transitionParams}}')]),
166 transition('void => *', animate(0))
167 ])
168 ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
169 'class': 'p-element'
170 }, styles: [".p-accordion-header-link{cursor:pointer;display:flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;position:relative;text-decoration:none}.p-accordion-header-link:focus{z-index:1}.p-accordion-header-text{line-height:1}\n"] }]
171 }], ctorParameters: function () { return [{ type: undefined, decorators: [{
172 type: Inject,
173 args: [forwardRef(() => Accordion)]
174 }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { header: [{
175 type: Input
176 }], disabled: [{
177 type: Input
178 }], cache: [{
179 type: Input
180 }], selectedChange: [{
181 type: Output
182 }], transitionOptions: [{
183 type: Input
184 }], headerFacet: [{
185 type: ContentChildren,
186 args: [Header]
187 }], templates: [{
188 type: ContentChildren,
189 args: [PrimeTemplate]
190 }], selected: [{
191 type: Input
192 }] } });
193class Accordion {
194 constructor(el, changeDetector) {
195 this.el = el;
196 this.changeDetector = changeDetector;
197 this.onClose = new EventEmitter();
198 this.onOpen = new EventEmitter();
199 this.expandIcon = 'pi pi-fw pi-chevron-right';
200 this.collapseIcon = 'pi pi-fw pi-chevron-down';
201 this.activeIndexChange = new EventEmitter();
202 this.tabs = [];
203 }
204 ngAfterContentInit() {
205 this.initTabs();
206 this.tabListSubscription = this.tabList.changes.subscribe(_ => {
207 this.initTabs();
208 });
209 }
210 initTabs() {
211 this.tabs = this.tabList.toArray();
212 this.updateSelectionState();
213 this.changeDetector.markForCheck();
214 }
215 getBlockableElement() {
216 return this.el.nativeElement.children[0];
217 }
218 get activeIndex() {
219 return this._activeIndex;
220 }
221 set activeIndex(val) {
222 this._activeIndex = val;
223 if (this.preventActiveIndexPropagation) {
224 this.preventActiveIndexPropagation = false;
225 return;
226 }
227 this.updateSelectionState();
228 }
229 updateSelectionState() {
230 if (this.tabs && this.tabs.length && this._activeIndex != null) {
231 for (let i = 0; i < this.tabs.length; i++) {
232 let selected = this.multiple ? this._activeIndex.includes(i) : (i === this._activeIndex);
233 let changed = selected !== this.tabs[i].selected;
234 if (changed) {
235 this.tabs[i].selected = selected;
236 this.tabs[i].selectedChange.emit(selected);
237 this.tabs[i].changeDetector.markForCheck();
238 }
239 }
240 }
241 }
242 updateActiveIndex() {
243 let index = this.multiple ? [] : null;
244 this.tabs.forEach((tab, i) => {
245 if (tab.selected) {
246 if (this.multiple) {
247 index.push(i);
248 }
249 else {
250 index = i;
251 return;
252 }
253 }
254 });
255 this.preventActiveIndexPropagation = true;
256 this.activeIndexChange.emit(index);
257 }
258 ngOnDestroy() {
259 if (this.tabListSubscription) {
260 this.tabListSubscription.unsubscribe();
261 }
262 }
263}
264Accordion.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Accordion, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
265Accordion.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Accordion, selector: "p-accordion", inputs: { multiple: "multiple", style: "style", styleClass: "styleClass", expandIcon: "expandIcon", collapseIcon: "collapseIcon", activeIndex: "activeIndex" }, outputs: { onClose: "onClose", onOpen: "onOpen", activeIndexChange: "activeIndexChange" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "tabList", predicate: AccordionTab }], ngImport: i0, template: `
266 <div [ngClass]="'p-accordion p-component'" [ngStyle]="style" [class]="styleClass" role="tablist">
267 <ng-content></ng-content>
268 </div>
269 `, isInline: true, directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
270i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Accordion, decorators: [{
271 type: Component,
272 args: [{
273 selector: 'p-accordion',
274 template: `
275 <div [ngClass]="'p-accordion p-component'" [ngStyle]="style" [class]="styleClass" role="tablist">
276 <ng-content></ng-content>
277 </div>
278 `,
279 changeDetection: ChangeDetectionStrategy.OnPush,
280 host: {
281 'class': 'p-element'
282 }
283 }]
284 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { multiple: [{
285 type: Input
286 }], onClose: [{
287 type: Output
288 }], onOpen: [{
289 type: Output
290 }], style: [{
291 type: Input
292 }], styleClass: [{
293 type: Input
294 }], expandIcon: [{
295 type: Input
296 }], collapseIcon: [{
297 type: Input
298 }], activeIndexChange: [{
299 type: Output
300 }], tabList: [{
301 type: ContentChildren,
302 args: [AccordionTab]
303 }], activeIndex: [{
304 type: Input
305 }] } });
306class AccordionModule {
307}
308AccordionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
309AccordionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, declarations: [Accordion, AccordionTab], imports: [CommonModule], exports: [Accordion, AccordionTab, SharedModule] });
310AccordionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, imports: [[CommonModule], SharedModule] });
311i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, decorators: [{
312 type: NgModule,
313 args: [{
314 imports: [CommonModule],
315 exports: [Accordion, AccordionTab, SharedModule],
316 declarations: [Accordion, AccordionTab]
317 }]
318 }] });
319
320/**
321 * Generated bundle index. Do not edit.
322 */
323
324export { Accordion, AccordionModule, AccordionTab };
Note: See TracBrowser for help on using the repository browser.