import { Schema as S } from 'effect'; import { type ChildAttribute, type Html } from 'foldkit/html'; import { Message, Position, Variant } from './schema.js'; import { WaitBeforeDismissal } from './update.js'; export type { CompletedWaitBeforeDismissal, Dismissed, DismissedAll, GotAnimationMessage, HoveredEntry, InitConfig, LeftEntry, } from './schema.js'; export type { ShowInput } from './update.js'; export * as test from './test.js'; export { Message, Variant, Position, WaitBeforeDismissal }; /** Handlers passed to `entryToView`. Spread `dismiss` onto a close * button's attribute array (typically inside `h.button([...dismiss])`) * to let users dismiss the entry manually. The attribute carries the * Toast's dismiss handler bound to this entry's id; it routes through * the Toast boundary's wrap chain at click time. */ export type EntryHandlers = Readonly<{ dismiss: ReadonlyArray; }>; /** Factory that binds `Toast` to a user-provided payload schema. The * returned module contains everything needed to wire a toast stack into an * app: `Model`, `Message`, `Entry`, `Added`, `init`, `update`, `show` / * `dismiss` / `dismissAll` helpers, and the headless `view`. * * The payload is whatever content shape the consumer supplies via Schema. * The component never reads it. It flows through to `entryToView`. The * component itself owns only lifecycle and a11y fields (id, variant, * animation, dismiss timer, hover state). * * Consume the bound module's exports everywhere. `Toast.Model` in your app * Model, `Toast.Message` in your parent Message union, `Toast.show` / * `Toast.dismiss` in your update, `Toast.view` in your view. The top-level * exports (`Variant`, `Position`, static message tags, * `WaitBeforeDismissal`) are * payload-independent and safe to reference when you need them without a * bound module, but the typical path is through the factory return. * * @example * ```ts * const ToastPayload = S.Struct({ * bodyText: S.String, * maybeLink: S.Option(S.Struct({ * href: S.String, * text: S.String, * })), * }) * export const Toast = Toast.make(ToastPayload) * ``` */ export declare const make: (payloadSchema: S.Codec) => { readonly view: import("foldkit/submodel").View<{ readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }, { readonly _tag: "GotAnimationMessage"; readonly entryId: string; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; } | { readonly _tag: "Dismissed"; readonly entryId: string; } | { readonly _tag: "DismissedAll"; } | { readonly _tag: "CompletedWaitBeforeDismissal"; readonly entryId: string; readonly version: number; } | { readonly _tag: "HoveredEntry"; readonly entryId: string; } | { readonly _tag: "LeftEntry"; readonly entryId: string; } | { readonly _tag: "Added"; readonly entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }; }, Readonly<{ position: Position; entryToView: (entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }, handlers: EntryHandlers) => Html; ariaLabel?: string; containerClassName?: string; entryClassName?: string; }>>; readonly Entry: S.Struct<{ readonly id: S.String; readonly variant: S.Literals; readonly animation: S.Struct<{ readonly id: S.String; readonly isShowing: S.Boolean; readonly transitionState: S.Literals; }>; readonly maybeDuration: S.Option; readonly pendingDismissVersion: S.Number; readonly isHovered: S.Boolean; readonly payload: S.Codec; }>; readonly Model: S.Struct<{ readonly id: S.String; readonly defaultDuration: S.DurationFromMillis; readonly entries: S.$Array; readonly animation: S.Struct<{ readonly id: S.String; readonly isShowing: S.Boolean; readonly transitionState: S.Literals; }>; readonly maybeDuration: S.Option; readonly pendingDismissVersion: S.Number; readonly isHovered: S.Boolean; readonly payload: S.Codec; }>>; readonly nextEntryKey: S.Number; }>; readonly Message: import("foldkit/message").MessageUnion<{ readonly Added: { readonly entry: S.Struct<{ readonly id: S.String; readonly variant: S.Literals; readonly animation: S.Struct<{ readonly id: S.String; readonly isShowing: S.Boolean; readonly transitionState: S.Literals; }>; readonly maybeDuration: S.Option; readonly pendingDismissVersion: S.Number; readonly isHovered: S.Boolean; readonly payload: S.Codec; }>; }; readonly Dismissed: { readonly entryId: S.String; }; readonly DismissedAll: {}; readonly CompletedWaitBeforeDismissal: { readonly entryId: S.String; readonly version: S.Number; }; readonly HoveredEntry: { readonly entryId: S.String; }; readonly LeftEntry: { readonly entryId: S.String; }; readonly GotAnimationMessage: { readonly entryId: S.String; readonly message: import("foldkit/message").MessageUnion<{ readonly Showed: {}; readonly Hid: {}; readonly CompletedWaitForPaint: {}; readonly EndedAnimation: {}; }>; }; }>; readonly OutMessage: import("foldkit/message").MessageUnion<{ readonly DismissedToast: { readonly payload: S.Codec; }; }>; readonly Added: import("foldkit/schema").CallableTaggedStruct<"Added", { readonly entry: S.Struct<{ readonly id: S.String; readonly variant: S.Literals; readonly animation: S.Struct<{ readonly id: S.String; readonly isShowing: S.Boolean; readonly transitionState: S.Literals; }>; readonly maybeDuration: S.Option; readonly pendingDismissVersion: S.Number; readonly isHovered: S.Boolean; readonly payload: S.Codec; }>; }>; readonly DismissedToast: import("foldkit/schema").CallableTaggedStruct<"DismissedToast", { readonly payload: S.Codec; }>; readonly init: (config: Readonly<{ id: string; defaultDuration?: import("effect/Duration").Input; }>) => { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }; readonly update: (model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }, message: { readonly _tag: "DismissedAll"; } | { readonly _tag: "GotAnimationMessage"; readonly entryId: string; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; } | { readonly _tag: "Dismissed"; readonly entryId: string; } | { readonly _tag: "CompletedWaitBeforeDismissal"; readonly entryId: string; readonly version: number; } | { readonly _tag: "HoveredEntry"; readonly entryId: string; } | { readonly _tag: "LeftEntry"; readonly entryId: string; } | { readonly _tag: "Added"; readonly entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }; }) => Readonly<{ model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }; commands?: import("foldkit/update").Commands<{ readonly _tag: "DismissedAll"; } | { readonly _tag: "GotAnimationMessage"; readonly entryId: string; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; } | { readonly _tag: "Dismissed"; readonly entryId: string; } | { readonly _tag: "CompletedWaitBeforeDismissal"; readonly entryId: string; readonly version: number; } | { readonly _tag: "HoveredEntry"; readonly entryId: string; } | { readonly _tag: "LeftEntry"; readonly entryId: string; } | { readonly _tag: "Added"; readonly entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }; }, never>; outMessage?: { readonly _tag: "DismissedToast"; readonly payload: A; }; }>; readonly show: (model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }, input: Readonly<{ payload: A; variant?: Variant; duration?: import("effect/Duration").Input; sticky?: boolean; }>) => Readonly<{ model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }; commands?: import("foldkit/update").Commands<{ readonly _tag: "DismissedAll"; } | { readonly _tag: "GotAnimationMessage"; readonly entryId: string; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; } | { readonly _tag: "Dismissed"; readonly entryId: string; } | { readonly _tag: "CompletedWaitBeforeDismissal"; readonly entryId: string; readonly version: number; } | { readonly _tag: "HoveredEntry"; readonly entryId: string; } | { readonly _tag: "LeftEntry"; readonly entryId: string; } | { readonly _tag: "Added"; readonly entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }; }, never>; outMessage?: { readonly _tag: "DismissedToast"; readonly payload: A; }; }>; readonly dismiss: (model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }, entryId: string) => Readonly<{ model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }; commands?: import("foldkit/update").Commands<{ readonly _tag: "DismissedAll"; } | { readonly _tag: "GotAnimationMessage"; readonly entryId: string; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; } | { readonly _tag: "Dismissed"; readonly entryId: string; } | { readonly _tag: "CompletedWaitBeforeDismissal"; readonly entryId: string; readonly version: number; } | { readonly _tag: "HoveredEntry"; readonly entryId: string; } | { readonly _tag: "LeftEntry"; readonly entryId: string; } | { readonly _tag: "Added"; readonly entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }; }, never>; outMessage?: { readonly _tag: "DismissedToast"; readonly payload: A; }; }>; readonly dismissAll: (model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }) => Readonly<{ model: { readonly id: string; readonly defaultDuration: import("effect/Duration").Duration; readonly entries: readonly { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }[]; readonly nextEntryKey: number; }; commands?: import("foldkit/update").Commands<{ readonly _tag: "DismissedAll"; } | { readonly _tag: "GotAnimationMessage"; readonly entryId: string; readonly message: { readonly _tag: "Showed"; } | { readonly _tag: "Hid"; } | { readonly _tag: "CompletedWaitForPaint"; } | { readonly _tag: "EndedAnimation"; }; } | { readonly _tag: "Dismissed"; readonly entryId: string; } | { readonly _tag: "CompletedWaitBeforeDismissal"; readonly entryId: string; readonly version: number; } | { readonly _tag: "HoveredEntry"; readonly entryId: string; } | { readonly _tag: "LeftEntry"; readonly entryId: string; } | { readonly _tag: "Added"; readonly entry: { readonly id: string; readonly variant: "Error" | "Info" | "Success" | "Warning"; readonly animation: { readonly id: string; readonly isShowing: boolean; readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating"; }; readonly maybeDuration: import("effect/Option").Option; readonly pendingDismissVersion: number; readonly isHovered: boolean; readonly payload: A; }; }, never>; outMessage?: { readonly _tag: "DismissedToast"; readonly payload: A; }; }>; }; //# sourceMappingURL=index.d.ts.map