Coerce remaining toast variants (lib)

cgen-f665641441ae43f985cd5062ce48c6b9
This commit is contained in:
Builder.io 2025-10-14 03:57:17 +00:00
parent 67cf45ffbc
commit 26d2767120

View file

@ -30,27 +30,66 @@ export const aethexToast = {
},
error: (options: AethexToastOptions) => {
const normalize = (d?: any) => {
if (d == null) return undefined;
if (typeof d === "string") return d;
if (typeof d === "object") {
if ((d as any).message) return String((d as any).message);
try {
return JSON.stringify(d);
} catch (e) {
return String(d);
}
}
return String(d);
};
return toast({
title: `${options.title || "Error"}`,
description: options.description,
description: normalize(options.description),
duration: options.duration || 5000,
variant: "destructive",
});
},
warning: (options: AethexToastOptions) => {
const normalize = (d?: any) => {
if (d == null) return undefined;
if (typeof d === "string") return d;
if (typeof d === "object") {
if ((d as any).message) return String((d as any).message);
try {
return JSON.stringify(d);
} catch (e) {
return String(d);
}
}
return String(d);
};
return toast({
title: `⚠️ ${options.title || "Warning"}`,
description: options.description,
description: normalize(options.description),
duration: options.duration || 5000,
variant: "warning" as any,
});
},
info: (options: AethexToastOptions) => {
const normalize = (d?: any) => {
if (d == null) return undefined;
if (typeof d === "string") return d;
if (typeof d === "object") {
if ((d as any).message) return String((d as any).message);
try {
return JSON.stringify(d);
} catch (e) {
return String(d);
}
}
return String(d);
};
return toast({
title: ` ${options.title || "Information"}`,
description: options.description,
description: normalize(options.description),
duration: options.duration || 5000,
variant: "info" as any,
});