import { ToastUpdateProps } from './internal/types'; import { ToastProps } from './internal/Toast'; export type toastProps = Pick; /** * Use to run toast methods for adding, updating, and dismissing toasts. * * @method info * @method success * @method warning * @method danger * @method promise * @method update * @method dismiss */ export declare const toast: { (): void; /** * Use to add info toast to the stack. * * @example * import { toast } from "@servicetitan/anvil2"; * const id = toast.info({ * message: "This is an info toast", * title: "Info", * }); */ info: (props: toastProps) => string; /** * Use to add success toast to the stack. * * @example * import { toast } from "@servicetitan/anvil2"; * const id = toast.success({ * message: "This is an info toast", * title: "Info", * }); */ success: (props: toastProps) => string; /** * Use to add warning toast to the stack. * * @example * import { toast } from "@servicetitan/anvil2"; * const id = toast.warning({ * message: "This is an info toast", * title: "Info", * }); */ warning: (props: toastProps) => string; /** * Use to add danger toast to the stack. * * @example * import { toast } from "@servicetitan/anvil2"; * const id = toast.danger({ * message: "This is an info toast", * title: "Info", * }); */ danger: (props: toastProps) => string; /** * Use to update a specific toast in the stack. * * @example * import { toast } from "@servicetitan/anvil2"; * const id = toast.info({ * message: "This is an info toast", * title: "Info", * }); * toast.update(id, { * message: "This is an updated toast", * title: "Updated", * }); */ update: (id: string, props: Omit) => void; /** * Use to dismiss a specific toast in the stack. * * @example * import { toast } from "@servicetitan/anvil2"; * const id = toast.info({ * message: "This is an info toast", * title: "Info", * }); * toast.dismiss(id); */ dismiss: (id?: string) => void; /** * Use to create a toast that updates itself based on a Promise state. * * @example * ```ts * import { toast } from "@servicetitan/anvil2"; * toast.promise( * new Promise((resolve, reject) => { * setTimeout(() => { * resolve("This is a success toast"); * }, 2000); * }), * { * loading: { * message: "This is a loading toast", * title: "Loading", * }, * success: (data) => ({ * message: data, * title: "Success", * }), * error: (error) => ({ * message: error, * title: "Error", * }), * }, * ); * ``` */ promise: (promise: Promise, toastConfig: { loading: toastProps; success: (data: string) => Omit; error: (error: string) => Omit; }) => Promise; };