source: trip-planner-front/node_modules/primeng/fesm2015/primeng-messages.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: 13.3 KB
Line 
1import * as i0 from '@angular/core';
2import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Optional, Input, ContentChildren, Output, NgModule } from '@angular/core';
3import * as i2 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import { trigger, transition, style, animate } from '@angular/animations';
6import * as i1 from 'primeng/api';
7import { PrimeTemplate } from 'primeng/api';
8import * as i3 from 'primeng/ripple';
9import { RippleModule } from 'primeng/ripple';
10
11class Messages {
12 constructor(messageService, el, cd) {
13 this.messageService = messageService;
14 this.el = el;
15 this.cd = cd;
16 this.closable = true;
17 this.enableService = true;
18 this.escape = true;
19 this.showTransitionOptions = '300ms ease-out';
20 this.hideTransitionOptions = '200ms cubic-bezier(0.86, 0, 0.07, 1)';
21 this.valueChange = new EventEmitter();
22 }
23 ngAfterContentInit() {
24 this.templates.forEach((item) => {
25 switch (item.getType()) {
26 case 'content':
27 this.contentTemplate = item.template;
28 break;
29 default:
30 this.contentTemplate = item.template;
31 break;
32 }
33 });
34 if (this.messageService && this.enableService && !this.contentTemplate) {
35 this.messageSubscription = this.messageService.messageObserver.subscribe((messages) => {
36 if (messages) {
37 if (messages instanceof Array) {
38 let filteredMessages = messages.filter(m => this.key === m.key);
39 this.value = this.value ? [...this.value, ...filteredMessages] : [...filteredMessages];
40 }
41 else if (this.key === messages.key) {
42 this.value = this.value ? [...this.value, ...[messages]] : [messages];
43 }
44 this.cd.markForCheck();
45 }
46 });
47 this.clearSubscription = this.messageService.clearObserver.subscribe(key => {
48 if (key) {
49 if (this.key === key) {
50 this.value = null;
51 }
52 }
53 else {
54 this.value = null;
55 }
56 this.cd.markForCheck();
57 });
58 }
59 }
60 hasMessages() {
61 let parentEl = this.el.nativeElement.parentElement;
62 if (parentEl && parentEl.offsetParent) {
63 return this.contentTemplate != null || this.value && this.value.length > 0;
64 }
65 return false;
66 }
67 clear() {
68 this.value = [];
69 this.valueChange.emit(this.value);
70 }
71 removeMessage(i) {
72 this.value = this.value.filter((msg, index) => index !== i);
73 this.valueChange.emit(this.value);
74 }
75 get icon() {
76 const severity = this.severity || (this.hasMessages() ? this.value[0].severity : null);
77 if (this.hasMessages()) {
78 switch (severity) {
79 case 'success':
80 return 'pi-check';
81 break;
82 case 'info':
83 return 'pi-info-circle';
84 break;
85 case 'error':
86 return 'pi-times';
87 break;
88 case 'warn':
89 return 'pi-exclamation-triangle';
90 break;
91 default:
92 return 'pi-info-circle';
93 break;
94 }
95 }
96 return null;
97 }
98 ngOnDestroy() {
99 if (this.messageSubscription) {
100 this.messageSubscription.unsubscribe();
101 }
102 if (this.clearSubscription) {
103 this.clearSubscription.unsubscribe();
104 }
105 }
106}
107Messages.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Messages, deps: [{ token: i1.MessageService, optional: true }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
108Messages.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Messages, selector: "p-messages", inputs: { value: "value", closable: "closable", style: "style", styleClass: "styleClass", enableService: "enableService", key: "key", escape: "escape", severity: "severity", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions" }, outputs: { valueChange: "valueChange" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: `
109 <div class="p-messages p-component" role="alert" [ngStyle]="style" [class]="styleClass">
110 <ng-container *ngIf="!contentTemplate; else staticMessage">
111 <div *ngFor="let msg of value; let i=index" [ngClass]="'p-message p-message-' + msg.severity" role="alert"
112 [@messageAnimation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}">
113 <div class="p-message-wrapper">
114 <span [class]="'p-message-icon pi' + (msg.icon ? ' ' + msg.icon : '')" [ngClass]="{'pi-info-circle': msg.severity === 'info',
115 'pi-check': msg.severity === 'success',
116 'pi-exclamation-triangle': msg.severity === 'warn',
117 'pi-times-circle': msg.severity === 'error'}"></span>
118 <ng-container *ngIf="!escape; else escapeOut">
119 <span *ngIf="msg.summary" class="p-message-summary" [innerHTML]="msg.summary"></span>
120 <span *ngIf="msg.detail" class="p-message-detail" [innerHTML]="msg.detail"></span>
121 </ng-container>
122 <ng-template #escapeOut>
123 <span *ngIf="msg.summary" class="p-message-summary">{{msg.summary}}</span>
124 <span *ngIf="msg.detail" class="p-message-detail">{{msg.detail}}</span>
125 </ng-template>
126 <button class="p-message-close p-link" (click)="removeMessage(i)" *ngIf="closable" type="button" pRipple>
127 <i class="p-message-close-icon pi pi-times"></i>
128 </button>
129 </div>
130 </div>
131 </ng-container>
132 <ng-template #staticMessage>
133 <div [ngClass]="'p-message p-message-' + severity" role="alert">
134 <div class="p-message-wrapper">
135 <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
136 </div>
137 </div>
138 </ng-template>
139 </div>
140 `, isInline: true, styles: [".p-message-wrapper{display:flex;align-items:center}.p-message-close{display:flex;align-items:center;justify-content:center}.p-message-close.p-link{margin-left:auto;overflow:hidden;position:relative}\n"], directives: [{ type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.Ripple, selector: "[pRipple]" }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], animations: [
141 trigger('messageAnimation', [
142 transition(':enter', [
143 style({ opacity: 0, transform: 'translateY(-25%)' }),
144 animate('{{showTransitionParams}}')
145 ]),
146 transition(':leave', [
147 animate('{{hideTransitionParams}}', style({ height: 0, marginTop: 0, marginBottom: 0, marginLeft: 0, marginRight: 0, overflow: 'hidden', opacity: 0 }))
148 ])
149 ])
150 ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
151i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Messages, decorators: [{
152 type: Component,
153 args: [{ selector: 'p-messages', template: `
154 <div class="p-messages p-component" role="alert" [ngStyle]="style" [class]="styleClass">
155 <ng-container *ngIf="!contentTemplate; else staticMessage">
156 <div *ngFor="let msg of value; let i=index" [ngClass]="'p-message p-message-' + msg.severity" role="alert"
157 [@messageAnimation]="{value: 'visible', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}">
158 <div class="p-message-wrapper">
159 <span [class]="'p-message-icon pi' + (msg.icon ? ' ' + msg.icon : '')" [ngClass]="{'pi-info-circle': msg.severity === 'info',
160 'pi-check': msg.severity === 'success',
161 'pi-exclamation-triangle': msg.severity === 'warn',
162 'pi-times-circle': msg.severity === 'error'}"></span>
163 <ng-container *ngIf="!escape; else escapeOut">
164 <span *ngIf="msg.summary" class="p-message-summary" [innerHTML]="msg.summary"></span>
165 <span *ngIf="msg.detail" class="p-message-detail" [innerHTML]="msg.detail"></span>
166 </ng-container>
167 <ng-template #escapeOut>
168 <span *ngIf="msg.summary" class="p-message-summary">{{msg.summary}}</span>
169 <span *ngIf="msg.detail" class="p-message-detail">{{msg.detail}}</span>
170 </ng-template>
171 <button class="p-message-close p-link" (click)="removeMessage(i)" *ngIf="closable" type="button" pRipple>
172 <i class="p-message-close-icon pi pi-times"></i>
173 </button>
174 </div>
175 </div>
176 </ng-container>
177 <ng-template #staticMessage>
178 <div [ngClass]="'p-message p-message-' + severity" role="alert">
179 <div class="p-message-wrapper">
180 <ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
181 </div>
182 </div>
183 </ng-template>
184 </div>
185 `, animations: [
186 trigger('messageAnimation', [
187 transition(':enter', [
188 style({ opacity: 0, transform: 'translateY(-25%)' }),
189 animate('{{showTransitionParams}}')
190 ]),
191 transition(':leave', [
192 animate('{{hideTransitionParams}}', style({ height: 0, marginTop: 0, marginBottom: 0, marginLeft: 0, marginRight: 0, overflow: 'hidden', opacity: 0 }))
193 ])
194 ])
195 ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
196 'class': 'p-element'
197 }, styles: [".p-message-wrapper{display:flex;align-items:center}.p-message-close{display:flex;align-items:center;justify-content:center}.p-message-close.p-link{margin-left:auto;overflow:hidden;position:relative}\n"] }]
198 }], ctorParameters: function () {
199 return [{ type: i1.MessageService, decorators: [{
200 type: Optional
201 }] }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }];
202 }, propDecorators: { value: [{
203 type: Input
204 }], closable: [{
205 type: Input
206 }], style: [{
207 type: Input
208 }], styleClass: [{
209 type: Input
210 }], enableService: [{
211 type: Input
212 }], key: [{
213 type: Input
214 }], escape: [{
215 type: Input
216 }], severity: [{
217 type: Input
218 }], showTransitionOptions: [{
219 type: Input
220 }], hideTransitionOptions: [{
221 type: Input
222 }], templates: [{
223 type: ContentChildren,
224 args: [PrimeTemplate]
225 }], valueChange: [{
226 type: Output
227 }] } });
228class MessagesModule {
229}
230MessagesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: MessagesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
231MessagesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: MessagesModule, declarations: [Messages], imports: [CommonModule, RippleModule], exports: [Messages] });
232MessagesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: MessagesModule, imports: [[CommonModule, RippleModule]] });
233i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: MessagesModule, decorators: [{
234 type: NgModule,
235 args: [{
236 imports: [CommonModule, RippleModule],
237 exports: [Messages],
238 declarations: [Messages]
239 }]
240 }] });
241
242/**
243 * Generated bundle index. Do not edit.
244 */
245
246export { Messages, MessagesModule };
Note: See TracBrowser for help on using the repository browser.