import { type Accessor, createContext, useContext } from "solid-js"; import type { ToastIntlTranslations } from "./toast.intl"; export interface ToastContextValue { translations: Accessor; close: () => void; duration: Accessor; isPersistent: Accessor; closeTimerStartTime: Accessor; generateId: (part: string) => string; registerTitleId: (id: string) => () => void; registerDescriptionId: (id: string) => () => void; } export const ToastContext = createContext(); export function useToastContext() { const context = useContext(ToastContext); if (context === undefined) { throw new Error( "[kobalte]: `useToastContext` must be used within a `Toast.Root` component", ); } return context; }