File tree Expand file tree Collapse file tree 4 files changed +8
-1
lines changed
Expand file tree Collapse file tree 4 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ export class KolToastContainer implements ToasterAPI {
7474 ...this . state ,
7575 _toastStates : this . state . _toastStates . filter ( ( localToastState ) => localToastState . id !== toastState . id ) ,
7676 } ;
77+ toastState . toast . onClose ?.( ) ;
7778 } , TRANSITION_TIMEOUT ) ;
7879 }
7980
@@ -101,6 +102,9 @@ export class KolToastContainer implements ToasterAPI {
101102 ...this . state ,
102103 _toastStates : this . state . _toastStates . filter ( ( toastState ) => toastsToClose . every ( ( toastToClose ) => toastToClose . id !== toastState . id ) ) ,
103104 } ;
105+ toastsToClose . forEach ( ( toastState ) => {
106+ toastState . toast . onClose ?.( ) ;
107+ } ) ;
104108 } , TRANSITION_TIMEOUT ) ;
105109 }
106110 }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export type Toast = {
1818 */
1919 alertVariant ?: AlertVariant ;
2020 variant ?: AlertVariant ;
21+ onClose ?: ( ) => void ;
2122} ;
2223
2324export type ToastState = {
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ export const ToastBasic: FC = () => {
2020 description : 'Toasty' ,
2121 label : `Initial Toast` ,
2222 type : 'warning' ,
23+ onClose : ( ) => {
24+ console . log ( 'Simple toast has been closed.' ) ;
25+ } ,
2326 } ) ;
2427 } ;
2528
Original file line number Diff line number Diff line change @@ -29,6 +29,5 @@ export default defineConfig({
2929 } ,
3030 server : {
3131 port : 9191 ,
32- strictPort : true ,
3332 } ,
3433} ) ;
You can’t perform that action at this time.
0 commit comments