From 6a9460389699d6862579e3e4eceeac269bc758d7 Mon Sep 17 00:00:00 2001 From: Can Rau Date: Sat, 30 Dec 2023 22:19:37 -0500 Subject: [PATCH] types: change label types to ReactNode (#280) * types: change label types to ReactNode * types: add `event` to cancel.onClick * feat: pass `event` to cancel.onClick * fix: missing `event` argument --- src/index.tsx | 4 ++-- src/types.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 06f05e8..7afdb9a 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -360,11 +360,11 @@ const Toast = (props: ToastProps) => { data-button data-cancel style={toast.cancelButtonStyle || cancelButtonStyle} - onClick={() => { + onClick={(event) => { if (!dismissible) return; deleteToast(); if (toast.cancel?.onClick) { - toast.cancel.onClick(); + toast.cancel.onClick(event); } }} className={cn(classNames?.cancelButton, toast?.classNames?.cancelButton)} diff --git a/src/types.ts b/src/types.ts index 489b369..eab1a96 100644 --- a/src/types.ts +++ b/src/types.ts @@ -42,12 +42,12 @@ export interface ToastT { delete?: boolean; important?: boolean; action?: { - label: string; + label: React.ReactNode; onClick: (event: React.MouseEvent) => void; }; cancel?: { - label: string; - onClick?: () => void; + label: React.ReactNode; + onClick?: (event: React.MouseEvent) => void; }; onDismiss?: (toast: ToastT) => void; onAutoClose?: (toast: ToastT) => void;