source: trip-planner-front/node_modules/primeng/fesm2020/primeng-toast.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: 21.2 KB
RevLine 
[59329aa]1import * as i0 from '@angular/core';
2import { EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, ViewChild, ContentChildren, NgModule } from '@angular/core';
3import * as i1 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import * as i3 from 'primeng/api';
6import { PrimeTemplate, SharedModule } from 'primeng/api';
7import { UniqueComponentId, ZIndexUtils } from 'primeng/utils';
8import * as i2 from 'primeng/ripple';
9import { RippleModule } from 'primeng/ripple';
10import { trigger, state, style, transition, animate, query, animateChild } from '@angular/animations';
11
12class ToastItem {
13 constructor(zone) {
14 this.zone = zone;
15 this.onClose = new EventEmitter();
16 }
17 ngAfterViewInit() {
18 this.initTimeout();
19 }
20 initTimeout() {
21 if (!this.message.sticky) {
22 this.zone.runOutsideAngular(() => {
23 this.timeout = setTimeout(() => {
24 this.onClose.emit({
25 index: this.index,
26 message: this.message
27 });
28 }, this.message.life || 3000);
29 });
30 }
31 }
32 clearTimeout() {
33 if (this.timeout) {
34 clearTimeout(this.timeout);
35 this.timeout = null;
36 }
37 }
38 onMouseEnter() {
39 this.clearTimeout();
40 }
41 onMouseLeave() {
42 this.initTimeout();
43 }
44 onCloseIconClick(event) {
45 this.clearTimeout();
46 this.onClose.emit({
47 index: this.index,
48 message: this.message
49 });
50 event.preventDefault();
51 }
52 ngOnDestroy() {
53 this.clearTimeout();
54 }
55}
56ToastItem.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ToastItem, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
57ToastItem.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: ToastItem, selector: "p-toastItem", inputs: { message: "message", index: "index", template: "template", showTransformOptions: "showTransformOptions", hideTransformOptions: "hideTransformOptions", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions" }, outputs: { onClose: "onClose" }, host: { classAttribute: "p-element" }, viewQueries: [{ propertyName: "containerViewChild", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: `
58 <div #container [attr.id]="message.id" [class]="message.styleClass" [ngClass]="['p-toast-message-' + message.severity, 'p-toast-message']" [@messageState]="{value: 'visible', params: {showTransformParams: showTransformOptions, hideTransformParams: hideTransformOptions, showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}"
59 (mouseenter)="onMouseEnter()" (mouseleave)="onMouseLeave()">
60 <div class="p-toast-message-content" role="alert" aria-live="assertive" aria-atomic="true" [ngClass]="message.contentStyleClass">
61 <ng-container *ngIf="!template">
62 <span [class]="'p-toast-message-icon pi' + (message.icon ? ' ' + message.icon : '')" [ngClass]="{'pi-info-circle': message.severity == 'info', 'pi-exclamation-triangle': message.severity == 'warn',
63 'pi-times-circle': message.severity == 'error', 'pi-check' :message.severity == 'success'}"></span>
64 <div class="p-toast-message-text">
65 <div class="p-toast-summary">{{message.summary}}</div>
66 <div class="p-toast-detail">{{message.detail}}</div>
67 </div>
68 </ng-container>
69 <ng-container *ngTemplateOutlet="template; context: {$implicit: message}"></ng-container>
70 <button type="button" class="p-toast-icon-close p-link" (click)="onCloseIconClick($event)" (keydown.enter)="onCloseIconClick($event)" *ngIf="message.closable !== false" pRipple>
71 <span class="p-toast-icon-close-icon pi pi-times"></span>
72 </button>
73 </div>
74 </div>
75 `, isInline: true, 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"] }, { type: i2.Ripple, selector: "[pRipple]" }], animations: [
76 trigger('messageState', [
77 state('visible', style({
78 transform: 'translateY(0)',
79 opacity: 1
80 })),
81 transition('void => *', [
82 style({ transform: '{{showTransformParams}}', opacity: 0 }),
83 animate('{{showTransitionParams}}')
84 ]),
85 transition('* => void', [
86 animate(('{{hideTransitionParams}}'), style({
87 height: 0,
88 opacity: 0,
89 transform: '{{hideTransformParams}}'
90 }))
91 ])
92 ])
93 ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
94i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ToastItem, decorators: [{
95 type: Component,
96 args: [{
97 selector: 'p-toastItem',
98 template: `
99 <div #container [attr.id]="message.id" [class]="message.styleClass" [ngClass]="['p-toast-message-' + message.severity, 'p-toast-message']" [@messageState]="{value: 'visible', params: {showTransformParams: showTransformOptions, hideTransformParams: hideTransformOptions, showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}"
100 (mouseenter)="onMouseEnter()" (mouseleave)="onMouseLeave()">
101 <div class="p-toast-message-content" role="alert" aria-live="assertive" aria-atomic="true" [ngClass]="message.contentStyleClass">
102 <ng-container *ngIf="!template">
103 <span [class]="'p-toast-message-icon pi' + (message.icon ? ' ' + message.icon : '')" [ngClass]="{'pi-info-circle': message.severity == 'info', 'pi-exclamation-triangle': message.severity == 'warn',
104 'pi-times-circle': message.severity == 'error', 'pi-check' :message.severity == 'success'}"></span>
105 <div class="p-toast-message-text">
106 <div class="p-toast-summary">{{message.summary}}</div>
107 <div class="p-toast-detail">{{message.detail}}</div>
108 </div>
109 </ng-container>
110 <ng-container *ngTemplateOutlet="template; context: {$implicit: message}"></ng-container>
111 <button type="button" class="p-toast-icon-close p-link" (click)="onCloseIconClick($event)" (keydown.enter)="onCloseIconClick($event)" *ngIf="message.closable !== false" pRipple>
112 <span class="p-toast-icon-close-icon pi pi-times"></span>
113 </button>
114 </div>
115 </div>
116 `,
117 animations: [
118 trigger('messageState', [
119 state('visible', style({
120 transform: 'translateY(0)',
121 opacity: 1
122 })),
123 transition('void => *', [
124 style({ transform: '{{showTransformParams}}', opacity: 0 }),
125 animate('{{showTransitionParams}}')
126 ]),
127 transition('* => void', [
128 animate(('{{hideTransitionParams}}'), style({
129 height: 0,
130 opacity: 0,
131 transform: '{{hideTransformParams}}'
132 }))
133 ])
134 ])
135 ],
136 encapsulation: ViewEncapsulation.None,
137 changeDetection: ChangeDetectionStrategy.OnPush,
138 host: {
139 'class': 'p-element'
140 }
141 }]
142 }], ctorParameters: function () { return [{ type: i0.NgZone }]; }, propDecorators: { message: [{
143 type: Input
144 }], index: [{
145 type: Input
146 }], template: [{
147 type: Input
148 }], showTransformOptions: [{
149 type: Input
150 }], hideTransformOptions: [{
151 type: Input
152 }], showTransitionOptions: [{
153 type: Input
154 }], hideTransitionOptions: [{
155 type: Input
156 }], onClose: [{
157 type: Output
158 }], containerViewChild: [{
159 type: ViewChild,
160 args: ['container']
161 }] } });
162class Toast {
163 constructor(messageService, cd, config) {
164 this.messageService = messageService;
165 this.cd = cd;
166 this.config = config;
167 this.autoZIndex = true;
168 this.baseZIndex = 0;
169 this.position = 'top-right';
170 this.preventOpenDuplicates = false;
171 this.preventDuplicates = false;
172 this.showTransformOptions = 'translateY(100%)';
173 this.hideTransformOptions = 'translateY(-100%)';
174 this.showTransitionOptions = '300ms ease-out';
175 this.hideTransitionOptions = '250ms ease-in';
176 this.onClose = new EventEmitter();
177 this.id = UniqueComponentId();
178 }
179 ngOnInit() {
180 this.messageSubscription = this.messageService.messageObserver.subscribe(messages => {
181 if (messages) {
182 if (messages instanceof Array) {
183 const filteredMessages = messages.filter(m => this.canAdd(m));
184 this.add(filteredMessages);
185 }
186 else if (this.canAdd(messages)) {
187 this.add([messages]);
188 }
189 }
190 });
191 this.clearSubscription = this.messageService.clearObserver.subscribe(key => {
192 if (key) {
193 if (this.key === key) {
194 this.messages = null;
195 }
196 }
197 else {
198 this.messages = null;
199 }
200 this.cd.markForCheck();
201 });
202 }
203 ngAfterViewInit() {
204 if (this.breakpoints) {
205 this.createStyle();
206 }
207 }
208 add(messages) {
209 this.messages = this.messages ? [...this.messages, ...messages] : [...messages];
210 if (this.preventDuplicates) {
211 this.messagesArchieve = this.messagesArchieve ? [...this.messagesArchieve, ...messages] : [...messages];
212 }
213 this.cd.markForCheck();
214 }
215 canAdd(message) {
216 let allow = this.key === message.key;
217 if (allow && this.preventOpenDuplicates) {
218 allow = !this.containsMessage(this.messages, message);
219 }
220 if (allow && this.preventDuplicates) {
221 allow = !this.containsMessage(this.messagesArchieve, message);
222 }
223 return allow;
224 }
225 containsMessage(collection, message) {
226 if (!collection) {
227 return false;
228 }
229 return collection.find(m => {
230 return ((m.summary === message.summary) && (m.detail == message.detail) && (m.severity === message.severity));
231 }) != null;
232 }
233 ngAfterContentInit() {
234 this.templates.forEach((item) => {
235 switch (item.getType()) {
236 case 'message':
237 this.template = item.template;
238 break;
239 default:
240 this.template = item.template;
241 break;
242 }
243 });
244 }
245 onMessageClose(event) {
246 this.messages.splice(event.index, 1);
247 this.onClose.emit({
248 message: event.message
249 });
250 this.cd.detectChanges();
251 }
252 onAnimationStart(event) {
253 if (event.fromState === 'void') {
254 this.containerViewChild.nativeElement.setAttribute(this.id, '');
255 if (this.autoZIndex) {
256 ZIndexUtils.set('modal', this.containerViewChild.nativeElement, this.baseZIndex || this.config.zIndex.modal);
257 }
258 }
259 }
260 onAnimationEnd(event) {
261 if (event.toState === 'void') {
262 if (this.autoZIndex) {
263 ZIndexUtils.clear(this.containerViewChild.nativeElement);
264 }
265 }
266 }
267 createStyle() {
268 if (!this.styleElement) {
269 this.styleElement = document.createElement('style');
270 this.styleElement.type = 'text/css';
271 document.head.appendChild(this.styleElement);
272 let innerHTML = '';
273 for (let breakpoint in this.breakpoints) {
274 let breakpointStyle = '';
275 for (let styleProp in this.breakpoints[breakpoint]) {
276 breakpointStyle += styleProp + ':' + this.breakpoints[breakpoint][styleProp] + ' !important;';
277 }
278 innerHTML += `
279 @media screen and (max-width: ${breakpoint}) {
280 .p-toast[${this.id}] {
281 ${breakpointStyle}
282 }
283 }
284 `;
285 }
286 this.styleElement.innerHTML = innerHTML;
287 }
288 }
289 destroyStyle() {
290 if (this.styleElement) {
291 document.head.removeChild(this.styleElement);
292 this.styleElement = null;
293 }
294 }
295 ngOnDestroy() {
296 if (this.messageSubscription) {
297 this.messageSubscription.unsubscribe();
298 }
299 if (this.containerViewChild && this.autoZIndex) {
300 ZIndexUtils.clear(this.containerViewChild.nativeElement);
301 }
302 if (this.clearSubscription) {
303 this.clearSubscription.unsubscribe();
304 }
305 this.destroyStyle();
306 }
307}
308Toast.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Toast, deps: [{ token: i3.MessageService }, { token: i0.ChangeDetectorRef }, { token: i3.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Component });
309Toast.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Toast, selector: "p-toast", inputs: { key: "key", autoZIndex: "autoZIndex", baseZIndex: "baseZIndex", style: "style", styleClass: "styleClass", position: "position", preventOpenDuplicates: "preventOpenDuplicates", preventDuplicates: "preventDuplicates", showTransformOptions: "showTransformOptions", hideTransformOptions: "hideTransformOptions", showTransitionOptions: "showTransitionOptions", hideTransitionOptions: "hideTransitionOptions", breakpoints: "breakpoints" }, outputs: { onClose: "onClose" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "containerViewChild", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: `
310 <div #container [ngClass]="'p-toast p-component p-toast-' + position" [ngStyle]="style" [class]="styleClass">
311 <p-toastItem *ngFor="let msg of messages; let i=index" [message]="msg" [index]="i" (onClose)="onMessageClose($event)"
312 [template]="template" @toastAnimation (@toastAnimation.start)="onAnimationStart($event)" (@toastAnimation.done)="onAnimationEnd($event)"
313 [showTransformOptions]="showTransformOptions" [hideTransformOptions]="hideTransformOptions"
314 [showTransitionOptions]="showTransitionOptions" [hideTransitionOptions]="hideTransitionOptions"></p-toastItem>
315 </div>
316 `, isInline: true, styles: [".p-toast{position:fixed;width:25rem}.p-toast-message{overflow:hidden}.p-toast-message-content{display:flex;align-items:flex-start}.p-toast-message-text{flex:1 1 auto}.p-toast-top-right{top:20px;right:20px}.p-toast-top-left{top:20px;left:20px}.p-toast-bottom-left{bottom:20px;left:20px}.p-toast-bottom-right{bottom:20px;right:20px}.p-toast-top-center{top:20px;left:50%;transform:translate(-50%)}.p-toast-bottom-center{bottom:20px;left:50%;transform:translate(-50%)}.p-toast-center{left:50%;top:50%;min-width:20vw;transform:translate(-50%,-50%)}.p-toast-icon-close{display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-toast-icon-close.p-link{cursor:pointer}\n"], components: [{ type: ToastItem, selector: "p-toastItem", inputs: ["message", "index", "template", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions"], outputs: ["onClose"] }], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], animations: [
317 trigger('toastAnimation', [
318 transition(':enter, :leave', [
319 query('@*', animateChild())
320 ])
321 ])
322 ], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
323i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Toast, decorators: [{
324 type: Component,
325 args: [{ selector: 'p-toast', template: `
326 <div #container [ngClass]="'p-toast p-component p-toast-' + position" [ngStyle]="style" [class]="styleClass">
327 <p-toastItem *ngFor="let msg of messages; let i=index" [message]="msg" [index]="i" (onClose)="onMessageClose($event)"
328 [template]="template" @toastAnimation (@toastAnimation.start)="onAnimationStart($event)" (@toastAnimation.done)="onAnimationEnd($event)"
329 [showTransformOptions]="showTransformOptions" [hideTransformOptions]="hideTransformOptions"
330 [showTransitionOptions]="showTransitionOptions" [hideTransitionOptions]="hideTransitionOptions"></p-toastItem>
331 </div>
332 `, animations: [
333 trigger('toastAnimation', [
334 transition(':enter, :leave', [
335 query('@*', animateChild())
336 ])
337 ])
338 ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
339 'class': 'p-element'
340 }, styles: [".p-toast{position:fixed;width:25rem}.p-toast-message{overflow:hidden}.p-toast-message-content{display:flex;align-items:flex-start}.p-toast-message-text{flex:1 1 auto}.p-toast-top-right{top:20px;right:20px}.p-toast-top-left{top:20px;left:20px}.p-toast-bottom-left{bottom:20px;left:20px}.p-toast-bottom-right{bottom:20px;right:20px}.p-toast-top-center{top:20px;left:50%;transform:translate(-50%)}.p-toast-bottom-center{bottom:20px;left:50%;transform:translate(-50%)}.p-toast-center{left:50%;top:50%;min-width:20vw;transform:translate(-50%,-50%)}.p-toast-icon-close{display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative}.p-toast-icon-close.p-link{cursor:pointer}\n"] }]
341 }], ctorParameters: function () { return [{ type: i3.MessageService }, { type: i0.ChangeDetectorRef }, { type: i3.PrimeNGConfig }]; }, propDecorators: { key: [{
342 type: Input
343 }], autoZIndex: [{
344 type: Input
345 }], baseZIndex: [{
346 type: Input
347 }], style: [{
348 type: Input
349 }], styleClass: [{
350 type: Input
351 }], position: [{
352 type: Input
353 }], preventOpenDuplicates: [{
354 type: Input
355 }], preventDuplicates: [{
356 type: Input
357 }], showTransformOptions: [{
358 type: Input
359 }], hideTransformOptions: [{
360 type: Input
361 }], showTransitionOptions: [{
362 type: Input
363 }], hideTransitionOptions: [{
364 type: Input
365 }], breakpoints: [{
366 type: Input
367 }], onClose: [{
368 type: Output
369 }], containerViewChild: [{
370 type: ViewChild,
371 args: ['container']
372 }], templates: [{
373 type: ContentChildren,
374 args: [PrimeTemplate]
375 }] } });
376class ToastModule {
377}
378ToastModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ToastModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
379ToastModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ToastModule, declarations: [Toast, ToastItem], imports: [CommonModule, RippleModule], exports: [Toast, SharedModule] });
380ToastModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ToastModule, imports: [[CommonModule, RippleModule], SharedModule] });
381i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: ToastModule, decorators: [{
382 type: NgModule,
383 args: [{
384 imports: [CommonModule, RippleModule],
385 exports: [Toast, SharedModule],
386 declarations: [Toast, ToastItem]
387 }]
388 }] });
389
390/**
391 * Generated bundle index. Do not edit.
392 */
393
394export { Toast, ToastItem, ToastModule };
Note: See TracBrowser for help on using the repository browser.