+
{!!icon && (
@@ -97,29 +108,26 @@ export const Toast = ({
{icon}
)}
-
-
- {title}
-
-
- {description}
-
-
-
- {hasActionables && (
-
+
+
+
+ {title}
+
+ {description && (
+
+ {description}
+
+ )}
+
{!!action && (
+
+ {!!dismissable && (
+
toast.dismiss(id)}
+ >
+
+
)}
)
-}
\ No newline at end of file
+}
diff --git a/packages/design-system/ui/src/utils/toast.tsx b/packages/design-system/ui/src/utils/toast.tsx
index 8b4b3b4fb3..d7e55c4b22 100644
--- a/packages/design-system/ui/src/utils/toast.tsx
+++ b/packages/design-system/ui/src/utils/toast.tsx
@@ -1,44 +1,45 @@
import { Toast } from "@/components/toast"
import { ToastAction, ToastVariant, ToasterPosition } from "@/types"
import * as React from "react"
-import { toast as toastFn } from "sonner"
+import { ExternalToast, toast as toastFn } from "sonner"
interface BaseToastProps {
id?: string | number
position?: ToasterPosition
- dismissable?: boolean
- dismissLabel?: string
duration?: number
+ dismissable?: boolean
+ icon?: React.ReactNode
}
interface ToastProps extends BaseToastProps {
- description?: string
+ description?: React.ReactNode
action?: ToastAction
}
-function create(variant: ToastVariant, title: string, props: ToastProps = {}) {
- return toastFn.custom(
- (t) => {
- return (
-
toastFn.dismiss(props.id || t) : undefined
- }
- dismissLabel={props.dismissLabel}
- variant={variant}
- action={props.action}
- />
- )
- },
- {
- id: props.id,
- position: props.position,
- dismissible: props.dismissable,
- }
- )
+function create(variant: ToastVariant, title: React.ReactNode, props: ToastProps = {}) {
+ const external: ExternalToast = {
+ position: props.position,
+ duration: props.duration,
+ dismissible: props.dismissable,
+ }
+
+ if (props.id) {
+ external.id = props.id
+ }
+
+ return toastFn.custom((t) => {
+ return (
+
+ )
+ }, external)
}
function message(
@@ -54,6 +55,12 @@ function message(
return create("message", title, props)
}
+function custom() {
+ return create("message", "Custom",)
+}
+
+interface VariantToastProps extends Omit {}
+
function info(
/**
* The title of the toast.
@@ -61,7 +68,7 @@ function info(
/**
* The props of the toast.
*/
- props: ToastProps = {}
+ props: VariantToastProps = {}
) {
return create("info", title, props)
}
@@ -73,7 +80,7 @@ function error(
/**
* The props of the toast.
*/
- props: ToastProps = {}
+ props: VariantToastProps = {}
) {
return create("error", title, props)
}
@@ -85,7 +92,7 @@ function success(
/**
* The props of the toast.
*/
- props: ToastProps = {}
+ props: VariantToastProps = { }
) {
return create("success", title, props)
}
@@ -97,22 +104,19 @@ function warning(
/**
* The props of the toast.
*/
- props: ToastProps = {}
+ props: VariantToastProps = {}
) {
return create("warning", title, props)
}
-type LoadingToastProps = Omit
-
-function loading
-/**
- * The title of the toast.
- */(
- title: string,
+function loading(
+ /**
+ * The title of the toast.
+ */ title: string,
/**
* The props of the toast.
*/
- props: ToastProps = {}
+ props: VariantToastProps = {}
) {
return create("loading", title, { ...props, dismissable: false })
}
@@ -124,7 +128,7 @@ type PromiseStateProps =
description?: string
}
-interface PromiseToastProps extends BaseToastProps {
+interface PromiseToastProps extends Omit {
loading: PromiseStateProps
success: PromiseStateProps
error: PromiseStateProps
@@ -158,6 +162,7 @@ async function promise(
? undefined
: props.loading.description,
duration: Infinity,
+ dismissable: false,
}
)
diff --git a/yarn.lock b/yarn.lock
index 3659ba4240..149cd3cb31 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5272,7 +5272,7 @@ __metadata:
react-stately: ^3.31.1
resize-observer-polyfill: ^1.5.1
rimraf: ^5.0.1
- sonner: ^1.4.41
+ sonner: ^1.5.0
storybook: ^7.0.23
tailwind-merge: ^2.2.1
tailwindcss: ^3.4.3
@@ -27976,13 +27976,13 @@ __metadata:
languageName: node
linkType: hard
-"sonner@npm:^1.4.41":
- version: 1.4.41
- resolution: "sonner@npm:1.4.41"
+"sonner@npm:^1.5.0":
+ version: 1.5.0
+ resolution: "sonner@npm:1.5.0"
peerDependencies:
react: ^18.0.0
react-dom: ^18.0.0
- checksum: 31467ecab0fcbd5161fb76d158c698841b524686f7f598eecbc2a58d76bc496b5d5242df4350e274575aa3df59428d3aacd534415c968b19fc309c192c443330
+ checksum: 9561b5861bede7f874cc442e447a68c8bfa6e4eadad603bc04e38db35a8b8108741f595a12c9856742062bae230ffedf73122015940491f482c5aa9e68ee85e0
languageName: node
linkType: hard