From 2fc37602d9223bbffe88b566079257dc3eb50680 Mon Sep 17 00:00:00 2001 From: Enrico Messall Date: Sat, 30 Sep 2023 09:57:38 +0200 Subject: [PATCH] Fixed #13784 - Fixed toast ngClass with SSR and Hydration --- src/app/components/toast/toast.interface.ts | 5 +++- src/app/components/toast/toast.ts | 26 +++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/app/components/toast/toast.interface.ts b/src/app/components/toast/toast.interface.ts index 3c01b9eac73..b73f8ebebe0 100644 --- a/src/app/components/toast/toast.interface.ts +++ b/src/app/components/toast/toast.interface.ts @@ -1,6 +1,5 @@ import { TemplateRef } from '@angular/core'; import { Message } from 'primeng/api'; -import { Toast } from './toast'; /** * Defines valid templates in Toast. @@ -17,6 +16,7 @@ export interface ToastTemplates { $implicit: any; }): TemplateRef<{ $implicit: any }>; } + /** * Custom close event. * @see {@link Toast.onClose} @@ -28,6 +28,7 @@ export interface ToastCloseEvent { */ message: Message; } + /** * Custom close event. * @see {@link ToastItem.onClose} @@ -38,3 +39,5 @@ export interface ToastItemCloseEvent extends ToastCloseEvent { */ index: number; } + +export type ToastPositionType = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center'; diff --git a/src/app/components/toast/toast.ts b/src/app/components/toast/toast.ts index 842bec2f66d..167b033439b 100755 --- a/src/app/components/toast/toast.ts +++ b/src/app/components/toast/toast.ts @@ -31,7 +31,7 @@ import { TimesCircleIcon } from 'primeng/icons/timescircle'; import { RippleModule } from 'primeng/ripple'; import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils'; import { Subscription } from 'rxjs'; -import { ToastCloseEvent, ToastItemCloseEvent } from './toast.interface'; +import { ToastCloseEvent, ToastItemCloseEvent, ToastPositionType } from './toast.interface'; @Component({ selector: 'p-toastItem', @@ -92,7 +92,13 @@ import { ToastCloseEvent, ToastItemCloseEvent } from './toast.interface'; opacity: 1 }) ), - transition('void => *', [style({ transform: '{{showTransformParams}}', opacity: 0 }), animate('{{showTransitionParams}}')]), + transition('void => *', [ + style({ + transform: '{{showTransformParams}}', + opacity: 0 + }), + animate('{{showTransitionParams}}') + ]), transition('* => void', [ animate( '{{hideTransitionParams}}', @@ -183,6 +189,7 @@ export class ToastItem implements AfterViewInit, OnDestroy { this.clearTimeout(); } } + /** * Toast is used to display messages in an overlay. * @group Components @@ -190,7 +197,7 @@ export class ToastItem implements AfterViewInit, OnDestroy { @Component({ selector: 'p-toast', template: ` -
+
| undefined; + _position: ToastPositionType = 'top-right'; + constructor(@Inject(DOCUMENT) private document: Document, private renderer: Renderer2, public messageService: MessageService, private cd: ChangeDetectorRef, public config: PrimeNGConfig) {} styleElement: any;