The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { ToastManagerAddOptions } from "@base-ui/react/toast"; |
| 2 | import type { ComponentPropsWithoutRef, ReactNode } from "react"; |
| 3 | |
| 4 | import type { ThreadToastData } from "./toast"; |
| 5 | |
| 6 | export type StackedThreadToastOptions = { |
| 7 | type: "error" | "warning" | "success" | "info" | "loading"; |
| 8 | title: ReactNode; |
| 9 | description?: ReactNode; |
| 10 | timeout?: number; |
| 11 | priority?: "low" | "high"; |
| 12 | actionProps?: ComponentPropsWithoutRef<"button">; |
| 13 | actionVariant?: ThreadToastData["actionVariant"]; |
| 14 | data?: Omit<ThreadToastData, "actionLayout">; |
| 15 | }; |
| 16 | |
| 17 | export function stackedThreadToast( |
| 18 | options: StackedThreadToastOptions, |
| 19 | ): ToastManagerAddOptions<ThreadToastData> { |
| 20 | const { type, title, description, timeout, priority, actionProps, actionVariant, data } = options; |
| 21 | |
| 22 | const mergedData: ThreadToastData = { |
| 23 | ...(data !== undefined ? data : {}), |
| 24 | actionLayout: "stacked-end", |
| 25 | }; |
| 26 | if (actionVariant !== undefined) { |
| 27 | mergedData.actionVariant = actionVariant; |
| 28 | } |
| 29 | |
| 30 | const payload: ToastManagerAddOptions<ThreadToastData> = { |
| 31 | type, |
| 32 | title, |
| 33 | data: mergedData, |
| 34 | }; |
| 35 | |
| 36 | if (description !== undefined) { |
| 37 | payload.description = description; |
| 38 | } |
| 39 | if (timeout !== undefined) { |
| 40 | payload.timeout = timeout; |
| 41 | } |
| 42 | if (priority !== undefined) { |
| 43 | payload.priority = priority; |
| 44 | } |
| 45 | if (actionProps !== undefined) { |
| 46 | payload.actionProps = actionProps; |
| 47 | } |
| 48 | |
| 49 | return payload; |
| 50 | } |