source: trip-planner-front/node_modules/primeng/fesm2015/primeng-accordion.mjs@ 8d391a1

Last change on this file since 8d391a1 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 () {
172 return [{ type: undefined, decorators: [{
173 type: Inject,
174 args: [forwardRef(() => Accordion)]
175 }] }, { type: i0.ChangeDetectorRef }];
176 }, propDecorators: { header: [{
177 type: Input
178 }], disabled: [{
179 type: Input
180 }], cache: [{
181 type: Input
182 }], selectedChange: [{
183 type: Output
184 }], transitionOptions: [{
185 type: Input
186 }], headerFacet: [{
187 type: ContentChildren,
188 args: [Header]
189 }], templates: [{
190 type: ContentChildren,
191 args: [PrimeTemplate]
192 }], selected: [{
193 type: Input
194 }] } });
195class Accordion {
196 constructor(el, changeDetector) {
197 this.el = el;
198 this.changeDetector = changeDetector;
199 this.onClose = new EventEmitter();
200 this.onOpen = new EventEmitter();
201 this.expandIcon = 'pi pi-fw pi-chevron-right';
202 this.collapseIcon = 'pi pi-fw pi-chevron-down';
203 this.activeIndexChange = new EventEmitter();
204 this.tabs = [];
205 }
206 ngAfterContentInit() {
207 this.initTabs();
208 this.tabListSubscription = this.tabList.changes.subscribe(_ => {
209 this.initTabs();
210 });
211 }
212 initTabs() {
213 this.tabs = this.tabList.toArray();
214 this.updateSelectionState();
215 this.changeDetector.markForCheck();
216 }
217 getBlockableElement() {
218 return this.el.nativeElement.children[0];
219 }
220 get activeIndex() {
221 return this._activeIndex;
222 }
223 set activeIndex(val) {
224 this._activeIndex = val;
225 if (this.preventActiveIndexPropagation) {
226 this.preventActiveIndexPropagation = false;
227 return;
228 }
229 this.updateSelectionState();
230 }
231 updateSelectionState() {
232 if (this.tabs && this.tabs.length && this._activeIndex != null) {
233 for (let i = 0; i < this.tabs.length; i++) {
234 let selected = this.multiple ? this._activeIndex.includes(i) : (i === this._activeIndex);
235 let changed = selected !== this.tabs[i].selected;
236 if (changed) {
237 this.tabs[i].selected = selected;
238 this.tabs[i].selectedChange.emit(selected);
239 this.tabs[i].changeDetector.markForCheck();
240 }
241 }
242 }
243 }
244 updateActiveIndex() {
245 let index = this.multiple ? [] : null;
246 this.tabs.forEach((tab, i) => {
247 if (tab.selected) {
248 if (this.multiple) {
249 index.push(i);
250 }
251 else {
252 index = i;
253 return;
254 }
255 }
256 });
257 this.preventActiveIndexPropagation = true;
258 this.activeIndexChange.emit(index);
259 }
260 ngOnDestroy() {
261 if (this.tabListSubscription) {
262 this.tabListSubscription.unsubscribe();
263 }
264 }
265}
266Accordion.ɵ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 });
267Accordion.ɵ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: `
268 <div [ngClass]="'p-accordion p-component'" [ngStyle]="style" [class]="styleClass" role="tablist">
269 <ng-content></ng-content>
270 </div>
271 `, isInline: true, directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
272i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Accordion, decorators: [{
273 type: Component,
274 args: [{
275 selector: 'p-accordion',
276 template: `
277 <div [ngClass]="'p-accordion p-component'" [ngStyle]="style" [class]="styleClass" role="tablist">
278 <ng-content></ng-content>
279 </div>
280 `,
281 changeDetection: ChangeDetectionStrategy.OnPush,
282 host: {
283 'class': 'p-element'
284 }
285 }]
286 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { multiple: [{
287 type: Input
288 }], onClose: [{
289 type: Output
290 }], onOpen: [{
291 type: Output
292 }], style: [{
293 type: Input
294 }], styleClass: [{
295 type: Input
296 }], expandIcon: [{
297 type: Input
298 }], collapseIcon: [{
299 type: Input
300 }], activeIndexChange: [{
301 type: Output
302 }], tabList: [{
303 type: ContentChildren,
304 args: [AccordionTab]
305 }], activeIndex: [{
306 type: Input
307 }] } });
308class AccordionModule {
309}
310AccordionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
311AccordionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, declarations: [Accordion, AccordionTab], imports: [CommonModule], exports: [Accordion, AccordionTab, SharedModule] });
312AccordionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, imports: [[CommonModule], SharedModule] });
313i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: AccordionModule, decorators: [{
314 type: NgModule,
315 args: [{
316 imports: [CommonModule],
317 exports: [Accordion, AccordionTab, SharedModule],
318 declarations: [Accordion, AccordionTab]
319 }]
320 }] });
321
322/**
323 * Generated bundle index. Do not edit.
324 */
325
326export { Accordion, AccordionModule, AccordionTab };
Note: See TracBrowser for help on using the repository browser.