import { toast as sonnerToast, type ExternalToast } from "sonner"; import { Icon, type IconProps } from "../icon/Icon"; import { cn } from "../../shared/utils/cn"; import { Typography } from "../typography/Typography"; import { toastStyles } from "./utils"; import type { JSX } from "react"; import { invariant } from "../../shared/utils/invariant"; import type { BaseProps } from "../../shared/types"; type RenderContentProps = { onDismiss: () => void; }; type WithRenderContent = { renderContent: (props: RenderContentProps) => JSX.Element; text?: never; icon?: never; }; type WithTextAndIcon = { text: string; icon: IconProps["icon"]; iconClassName: string; renderContent?: never; }; type IBaseToastProps = (WithRenderContent | WithTextAndIcon) & { id: string | number; }; const BaseToast = (props: IBaseToastProps) => { invariant( !!props.renderContent || !!props.text, "Either define renderContent or text. Both cannot be defined." ); const onDismiss = () => sonnerToast.dismiss(props.id); return (