11<script lang="ts" setup>
22import { ref , watchEffect } from ' vue' ;
3- import { toast , useVueSonner } from ' vue-sonner ' ;
3+ import { useToastsStore } from ' ./useToastsStore ' ;
44
5- const { activeToasts } = useVueSonner ();
5+ const { activeToasts, toast } = useToastsStore ();
66
77// Store timeout data for each toast
8- const toastTimers = ref (new Map < string | number , {
8+ const toastTimers = ref (new Map < string , {
99 timeoutId: number ;
1010 remainingTime : number ;
1111 startTime : number ;
@@ -41,7 +41,7 @@ function getToastClasses(type: string) {
4141 return classes [type as keyof typeof classes ] || classes .info ;
4242}
4343
44- function handleToastClick(toastId : string | number ) {
44+ function handleToastClick(toastId : string ) {
4545 const timer = toastTimers .value .get (toastId );
4646 if (timer ) {
4747 timer .stop ();
@@ -50,7 +50,7 @@ function handleToastClick(toastId: string | number) {
5050 toast .dismiss (toastId );
5151}
5252
53- function createAutoDissmiss(toastId : string | number , type : string , duration ? : number ) {
53+ function createAutoDissmiss(toastId : string , type : string , duration ? : number ) {
5454 // Check if toast should auto-dismiss
5555 const shouldAutoDismiss = duration !== Infinity && duration !== 0 ;
5656 if (! shouldAutoDismiss )
@@ -80,7 +80,7 @@ function createAutoDissmiss(toastId: string | number, type: string, duration?: n
8080 return timer ;
8181}
8282
83- function pauseAutoDissmiss(toastId : string | number ) {
83+ function pauseAutoDissmiss(toastId : string ) {
8484 const timer = toastTimers .value .get (toastId );
8585 if (timer ) {
8686 // Clear the current timeout
@@ -94,7 +94,7 @@ function pauseAutoDissmiss(toastId: string | number) {
9494 }
9595}
9696
97- function resumeAutoDissmiss(toastId : string | number ) {
97+ function resumeAutoDissmiss(toastId : string ) {
9898 const timer = toastTimers .value .get (toastId );
9999 if (timer && timer .remainingTime > 0 ) {
100100 // Create new timeout with remaining time
@@ -115,10 +115,10 @@ function resumeAutoDissmiss(toastId: string | number) {
115115
116116// Watch for changes in active toasts and manage timers
117117watchEffect (() => {
118- const activeToastIds = new Set (activeToasts .value . map (t => t .id ));
118+ const activeToastIds = new Set (activeToasts .map (t => t .id ));
119119
120120 // Set up timers for new toasts
121- activeToasts .value . forEach ((activeToast ) => {
121+ activeToasts .forEach ((activeToast ) => {
122122 if (! toastTimers .value .has (activeToast .id )) {
123123 createAutoDissmiss (
124124 activeToast .id ,
0 commit comments