import type { JSX } from "@solidjs/web"; import { type Accessor } from "solid-js"; import { type MaybeAccessor } from "../internals/maybe-accessor.js"; import type { ToastManager } from "./create-toast-manager.js"; import { type ToastStore } from "./toast-store.js"; import type { ToastManagerAddOptions, ToastManagerPromiseOptions, ToastManagerUpdateOptions, ToastObject } from "./use-toast-manager.js"; export type { ToastObject }; /** * Options for {@link createToast}. * * The queue is internally owned — `timeout` / `limit` configure it but the * consumer does not hold signals for them. Unlike `createTabs`/etc the toast * primitive owns internal state because the queue IS the implementation (it * is not a consumer-controlled value; the consumer drives it via `add` / `close` * / `update` imperatives). */ export interface CreateToastOptions { /** * Default auto-dismiss duration in milliseconds. `0` disables auto-dismiss. * @default 5000 */ timeout?: MaybeAccessor; /** * Maximum number of visible toasts. Oldest toasts beyond the limit are * marked `limited` so consumers can animate them out. * @default 3 */ limit?: MaybeAccessor; /** * Optional external manager created via {@link createToastManager}. Events * emitted by the manager are forwarded into this primitive's queue, letting * code outside the component tree add / close / update toasts. */ toastManager?: MaybeAccessor; } /** * Public API returned by {@link createToast}. */ export interface ToastApi { /** Reactive accessor for the current toast queue. */ toasts: Accessor[]>; /** Whether any toast is hovered or focused. */ expanded: Accessor; /** Whether the viewport is hovering. */ hovering: Accessor; /** Whether the viewport is focused. */ focused: Accessor; /** Whether the queue is empty. */ isEmpty: Accessor; /** Add a toast and return its id. */ add: (options: ToastManagerAddOptions) => string; /** Close a toast by id, or all toasts when id is omitted. */ close: (id?: string) => void; /** Update an existing toast in place. */ update: (id: string, options: ToastManagerUpdateOptions) => void; /** Add a promise-backed toast that transitions through loading → success/error. */ promise: (value: Promise, options: ToastManagerPromiseOptions) => Promise; /** * The underlying store. Passed into `` so the * existing wrapper components (`Toast.Provider`, `Toast.Viewport`, etc.) * can compose this primitive. */ readonly store: ToastStore; /** Context provider — pair with {@link useToast}. */ Provider: (props: { children: JSX.Element; }) => JSX.Element; } /** * Read the nearest {@link ToastApi} provided by `c.Provider`. Throws if * called outside a Provider. */ export declare function useToast(): ToastApi; /** * Solid-native headless toast primitive. Owns the queue, timers, and * lifecycle bookkeeping. The consumer drives the queue via `add` / `close` / * `update` / `promise` imperatives and reads reactive state (`toasts`, * `expanded`, `hovering`, `focused`, `isEmpty`) through accessors. * * Internal state IS appropriate here: the queue is implementation detail * (not a consumer-controlled value). `timeout` / `limit` configure the store * but the consumer never holds the backing signals. * * Callbacks (`onValueChange` etc.) are not part of this surface because there * is no discrete "value" the consumer needs to mirror — the consumer observes * the queue reactively via `toasts()`. The `onClose` / `onRemove` hooks on * individual `ToastObject`s serve per-toast lifecycle needs. */ export declare function createToast(options?: CreateToastOptions): ToastApi; //# sourceMappingURL=create-toast.d.ts.map