From 13bfd0795101f90772e1bdeed974023b90506f35 Mon Sep 17 00:00:00 2001 From: Cr3aHal0 Date: Wed, 20 Dec 2023 18:51:02 +0100 Subject: [PATCH] feat(toast): providing close callback to headless toast template --- src/app/components/toast/toast.ts | 4 +-- src/app/showcase/doc/toast/headlessdoc.ts | 40 ++++++++--------------- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/app/components/toast/toast.ts b/src/app/components/toast/toast.ts index f939d0177b4..e71eefe8d0a 100755 --- a/src/app/components/toast/toast.ts +++ b/src/app/components/toast/toast.ts @@ -51,7 +51,7 @@ import { ToastCloseEvent, ToastItemCloseEvent, ToastPositionType } from './toast [attr.data-pc-section]="'root'" > - +
@@ -181,7 +181,7 @@ export class ToastItem implements AfterViewInit, OnDestroy { this.initTimeout(); } - onCloseIconClick(event: Event) { + onCloseIconClick = (event: Event) => { this.clearTimeout(); this.onClose.emit({ diff --git a/src/app/showcase/doc/toast/headlessdoc.ts b/src/app/showcase/doc/toast/headlessdoc.ts index ae76e129d9d..3e514df3396 100644 --- a/src/app/showcase/doc/toast/headlessdoc.ts +++ b/src/app/showcase/doc/toast/headlessdoc.ts @@ -9,8 +9,8 @@ import { Code } from '../../domain/code';

Headless mode allows you to customize the entire user interface instead of the default elements.

- - + +
@@ -21,8 +21,8 @@ import { Code } from '../../domain/code';
- - + +
@@ -67,19 +67,13 @@ export class HeadlessDoc { } } - onConfirm() { - this.messageService.clear('confirm'); - this.visible = false; - } - - onReject() { - this.messageService.clear('confirm'); + onClose() { this.visible = false; } code: Code = { - basic: ` - + basic: ` +
@@ -90,8 +84,8 @@ export class HeadlessDoc {
- - + +
@@ -99,8 +93,8 @@ export class HeadlessDoc { `, html: `
- - + +
@@ -111,8 +105,8 @@ export class HeadlessDoc {
- - + +
@@ -162,13 +156,7 @@ export class ToastHeadlessDemo { } } - onConfirm() { - this.messageService.clear('confirm'); - this.visible = false; - } - - onReject() { - this.messageService.clear('confirm'); + onClose() { this.visible = false; } }`