From dcf1d46f1abd7536df89430e167ba016b294391e Mon Sep 17 00:00:00 2001 From: Clara Castillo Date: Tue, 20 Feb 2024 23:55:39 +0100 Subject: [PATCH] feat: add transformers to toaster inputs --- libs/ngx-sonner/src/lib/toaster.component.ts | 27 +++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/libs/ngx-sonner/src/lib/toaster.component.ts b/libs/ngx-sonner/src/lib/toaster.component.ts index 8b9864a..fe76a76 100644 --- a/libs/ngx-sonner/src/lib/toaster.component.ts +++ b/libs/ngx-sonner/src/lib/toaster.component.ts @@ -1,5 +1,6 @@ import { isPlatformBrowser } from '@angular/common'; import { + booleanAttribute, ChangeDetectionStrategy, Component, computed, @@ -7,6 +8,7 @@ import { ElementRef, inject, input, + numberAttribute, OnDestroy, PLATFORM_ID, signal, @@ -110,15 +112,28 @@ export class ToasterComponent implements OnDestroy { toasts = this.sonner.toasts; heights = this.sonner.heights; - invert = input(false); + invert = input(false, { + transform: booleanAttribute, + }); theme = input('light'); position = input('bottom-right'); hotKey = input(['altKey', 'KeyT']); - richColors = input(false); - expand = input(false); - duration = input(TOAST_LIFETIME); - visibleToasts = input(VISIBLE_TOASTS_AMOUNT); - closeButton = input(false); + richColors = input(false, { + transform: booleanAttribute, + }); + expand = input(false, { + transform: booleanAttribute, + }); + duration = input(TOAST_LIFETIME, { + transform: numberAttribute, + }); + visibleToasts = input( + VISIBLE_TOASTS_AMOUNT, + { transform: numberAttribute } + ); + closeButton = input(false, { + transform: booleanAttribute, + }); toastOptions = input({}); offset = input(null); dir = input(this.getDocumentDirection());