import * as _angular_core from '@angular/core'; import { InjectionToken, Signal, TemplateRef, Provider } from '@angular/core'; import { SwipeDirection, SwipeEventDetail } from 'forty-cdk/core'; type ForToastVariant = 'info' | 'success' | 'warning' | 'error'; /** * Allowed swipe directions on a toast — accepts a single direction or * an array of directions (multi-axis dismissal). `null` / empty array * disables swipe. */ type ForToastSwipeDirection = SwipeDirection | readonly SwipeDirection[] | null; type ForToastCloseReason = 'auto' | 'manual' | 'action' | 'escape' | 'programmatic' | 'swipe'; /** * Region a toast belongs to. Toasts route to the `` whose * `[region]` matches; an unspecified region falls through to this default, so * the common single-viewport setup needs no `region` anywhere. */ declare const DEFAULT_TOAST_REGION = "default"; /** * Configuration for a programmatic toast. Pass to `ForToastManager.show()`. * * The default rendered shape is `title` + optional `description` + optional * `action` button + optional `close` button, wired via `[forToastTitle]`, * `[forToastDescription]`, `[forToastAction]`, `[forToastClose]`. For custom * rendering, pass `template` with a `TemplateRef` — * the same helper directives keep working inside it (the viewport renders the * template with the `[forToast]` injection context in scope). Pass `class` / * `classList` to apply consumer CSS classes onto the rendered toast root. */ interface ForToastConfig { /** Stable id for dedupe / `update()` / external dismissal. Auto-generated when omitted. */ id?: string; /** * Routes the toast to the `` whose `[region]` matches. * Omit it (or pass {@link DEFAULT_TOAST_REGION}) for the common * single-viewport setup. Use distinct regions to drive independent viewports * — e.g. a top-right region for system notifications and a bottom-center one * for action confirmations. */ region?: string; title?: string; description?: string; /** * Affects `role` and `aria-live`: * - `'info'` | `'success'` | `'warning'` (default `'info'`) → `role="status"` + `aria-live="polite"`. * - `'error'` → `role="alert"` + `aria-live="assertive"`. */ variant?: ForToastVariant; /** * Auto-dismiss timer in milliseconds. Default `5000`. `0` keeps the toast * sticky (no auto-dismiss; only manual / action / escape close). */ duration?: number; /** Action button. The button auto-closes the toast after invoking `activate`. */ action?: { label: string; activate: () => void; }; /** * Whether the user can dismiss the toast (Escape, close button, * auto-dismiss timer, swipe). Also gates the default close button rendered * by `ForToastViewport`. Default `true`. */ dismissible?: boolean; /** * Direction(s) the user can swipe to dismiss the toast. Pass a single * direction (`'right'`) or an array (`['right', 'down']`). When unset, * the value falls through to the viewport-level `[swipeDirection]` * (or stays disabled if that is also unset). */ swipeDirection?: ForToastSwipeDirection; /** * Pixels of pointer travel along the active swipe direction needed to * trigger a dismissal. Falls back to the viewport-level * `[swipeThreshold]` (or `50` if neither is set). */ swipeThreshold?: number; /** * Consumer CSS class(es) applied to the rendered toast root (the * `[forToast]` element). Pass a single class (`'toast--compact'`) or a * space-separated string (`'toast toast--compact'`). Merged with the * directive's own host attributes — it never clobbers `data-state` / * `data-variant` / the swipe hooks. * * Use this to carry design-system classes onto programmatic toasts so you * are not forced to style globally by the `[forToast]` attribute selector. * For multiple classes as an array, prefer {@link classList}. */ class?: string; /** * Consumer CSS class(es) applied to the rendered toast root, as an array * (`['toast', 'toast--compact']`) or a space-separated string. Merged with * {@link class} and with the directive's own host attributes. */ classList?: string | readonly string[]; /** * CSS class applied via `animate.enter` to the rendered toast root, so it * plays an enter animation on mount. Optional and symmetric with * {@link animateLeave}: a plain CSS `@keyframes` / `animation` declared on * `[forToast]` already plays on mount without this, so this is only needed * for class-applied entrances. When unset, falls through to the * viewport-level `[animateEnter]`. */ animateEnter?: string; /** * CSS class applied via `animate.leave` to the rendered toast root, so it * plays an exit animation before the toast leaves the DOM on dismiss. When * unset, falls through to the viewport-level `[animateLeave]`. * * This is the only way to express a toast exit animation on the programmatic * path: the viewport renders the toast inside its own `@for`, and a pure-CSS * exit cannot defer the unmount — Angular needs `animate.leave` on the node to * keep it mounted until the animation settles. Leaving it unset keeps the * existing synchronous unmount on dismiss. */ animateLeave?: string; /** Arbitrary payload passed to `template` context as `data`. */ data?: D; /** Override the default rendering with a `TemplateRef`. */ template?: TemplateRef>; } interface ForToastTemplateContext { /** The toast handle for `dismiss()` / state. */ $implicit: ForToastInstance; data: D | undefined; } /** * Read-only view of a programmatic toast as managed by `ForToastManager`. * The viewport iterates over a `Signal`. */ interface ForToastInstance { readonly id: string; readonly config: ForToastConfig; /** Dismiss this toast. Idempotent. */ dismiss(reason?: ForToastCloseReason): void; } /** * Handle a `[forToastAction]` registers with its parent `[forToast]` so the * toast can compose a screen-reader announcement that includes the action's * `altText` (per WCAG 2.2.1, when the toast is time-limited the announcement * must tell the user how to recover the action even after it disappears). * * `altText` is a signal that returns `''` when the consumer hasn't set * `[altText]` on the action — in which case the action is treated as * voice-less for announcement purposes. * * Part of the registration protocol, so it is never exported from * `public-api.ts` — see {@link ToastContext}. */ interface ForToastActionHandle { readonly altText: Signal; } /** * Reactive text source a `[forToastTitle]` / `[forToastDescription]` registers * with its parent `[forToast]` so the announcement is composed from a tracked * signal rather than a one-shot DOM read. The signal re-emits when the rendered * text changes (e.g. through `ref.update()`), which is what drives the toast to * re-announce. * * Part of the registration protocol, so it is never exported from * `public-api.ts` — see {@link ToastContext}. */ interface ForToastTextHandle { /** Generated id host-bound for `aria-labelledby` / `aria-describedby`. */ readonly id: string; /** Current rendered text content of the piece, reactive across re-renders. */ readonly text: Signal; } /** * Coordination contract owned by `ForToast`. Exposes the resolved * `aria-labelledby` / `aria-describedby` the registered title and description * compose, and the `requestClose` command action and close buttons route * through. */ interface ForToastContext { readonly variant: Signal; readonly dismissible: Signal; readonly paused: Signal; readonly labelledBy: Signal; readonly describedBy: Signal; /** Request close. Always honored — the directive emits `(dismiss)` and the consumer unmounts. */ requestClose(reason: ForToastCloseReason): void; } /** * DI token for the toast's coordination surface, provided by `[forToast]`. * * Publicly typed as the read surface {@link ForToastContext}, which is the whole of what the * token promises a consumer. The pieces read the same token at an internal type that adds * the title / description / action registration protocol, so a wrapper re-providing it must * alias it to the root: `{ provide: FOR_TOAST_CONTEXT, useExisting: MyToast }`, where * `MyToast` extends `ForToast`. A value that merely satisfies the declared type resolves * too, and is rejected in dev mode by the first piece to reach the protocol. */ declare const FOR_TOAST_CONTEXT: InjectionToken; /** * The toast's internal coordination surface: everything {@link ForToastContext} * publishes plus the title / description / action registration protocol the * `aria-labelledby` / `aria-describedby` wiring and the synthesized * announcement are composed from. * * Never exported from `public-api.ts`. It is the type the pieces read * {@link FOR_TOAST_CONTEXT} at, so a consumer who injects that token gets the * read surface while the pieces get the wiring protocol. `ForToast` declares the * protocol members TS-`private`, which keeps them out of the emitted `.d.ts` * while `useExisting` still satisfies this contract at runtime. */ interface ToastContext extends ForToastContext { registerLabel(handle: ForToastTextHandle): void; unregisterLabel(handle: ForToastTextHandle): void; registerDescription(handle: ForToastTextHandle): void; unregisterDescription(handle: ForToastTextHandle): void; /** * Register an action so the toast can include its `altText` in the * synthesized announcement. Actions without `altText` are still allowed * to register — they're skipped during composition. */ registerAction(handle: ForToastActionHandle): void; unregisterAction(handle: ForToastActionHandle): void; } type SwipeState = 'start' | 'move' | 'cancel' | 'end'; /** * One toast notification. Apply on a `
` (or ``, `
`) * — the directive sets `role="status"` (`'info'` / `'success'` / `'warning'`) * or `role="alert"` (`'error'`), `aria-live`, and the timer / pause * machinery. * * The `role` / `aria-live` pair is a **switch**, not a doubled channel, and * this is the one host in the library binding both. Every variant except a * bare `error` announces through `LiveAnnouncer` and silences its own host * with `aria-live="off"`, leaving a non-live `role="status"` region behind; a * bare `error` keeps `role="alert"` + `aria-live="assertive"`, because a live * role is what is read reliably when a node is inserted with its text already * present. Both channels are therefore *bound* rather than static, which is * also what exempts this host from `forty-cdk/no-doubled-live-region-channel` * by construction — everywhere else a static live role stands alone * (`[forFieldError]`, `[forComboboxStatus]`, `[forComboboxEmpty]`), since it * already implies its own `aria-live` / `aria-atomic`. * * The directive does **not** control its own visibility. The consumer * mounts it (typically through `` for programmatic * toasts, or directly with `@if` for declarative ones) and unmounts it * when `(dismiss)` fires. Pair the unmount with `animate.leave="…"` for * exit animations. * * Behavior: * - Auto-dismisses after `duration` ms (default 5000). `0` is sticky. * - Hovering or focusing the toast pauses the timer; leaving / blurring * resumes with the remaining time. * - Escape (while focus is inside) closes the toast. * - When `[swipeDirection]` is set, the user can drag past * `[swipeThreshold]` (default 50 px) to dismiss. While the gesture is * live the host reflects `data-swipe="start" | "move" | "cancel" | "end"`, * `data-swipe-direction`, and the CSS variables * `--for-toast-swipe-movement-x` / `--for-toast-swipe-movement-y`. * - The host carries `data-state="open"` while alive (no `closed` state — * the consumer unmounts on close). */ declare class ForToast implements ForToastContext { #private; /** * Severity of the toast. `'error'` announces assertively and takes `role="alert"`; every other * variant announces politely. */ readonly variant: _angular_core.InputSignal; /** Auto-dismiss timer in ms. `0` keeps the toast sticky. */ readonly duration: _angular_core.InputSignalWithTransform; /** * Whether the user can dismiss the toast through an ambient gesture — * Escape, the close button, the auto-dismiss timer, and swipe. Defaults to * `true`. * * Set `false` for a sticky / forced-action toast: every ambient gesture is * suppressed, no auto-dismiss timer is scheduled, and a `[forToastClose]` * button (if present) becomes inert. The **action button stays live and is * the sanctioned dismissal path** — `[forToastAction]` still emits `(dismiss)` * with reason `'action'` so a forced-action toast (e.g. "Update available — * Reload") can be dismissed by the only control the user is meant to use. * Programmatic close via `ForToastRef.dismiss()` is also always honored. */ readonly dismissible: _angular_core.InputSignalWithTransform; /** * Direction(s) the user can swipe to dismiss the toast. Pass a * single direction (`'right'`) or an array of directions * (`['right', 'down']`). `null` (default) disables swipe. * * The swipe gesture uses pointer events, so it works for both touch * and mouse drags. While the user is swiping, the host reflects * `data-swipe="start" | "move" | "cancel" | "end"` and * `data-swipe-direction` plus the CSS custom properties * `--for-toast-swipe-movement-x` / `--for-toast-swipe-movement-y` so the * consumer can drive a transform-based animation entirely from CSS. */ readonly swipeDirection: _angular_core.InputSignal; /** * Pixels of pointer travel along the active swipe direction needed * to commit a dismissal. Defaults to `50`. */ readonly swipeThreshold: _angular_core.InputSignalWithTransform; /** Emitted when the toast wants to be unmounted. The consumer reacts by removing it from the rendered list. */ readonly dismiss: _angular_core.OutputEmitterRef; /** Fired once on the move that arms the swipe. */ readonly swipeStart: _angular_core.OutputEmitterRef; /** Fired on every pointer move while the swipe is active. */ readonly swipeMove: _angular_core.OutputEmitterRef; /** Fired on pointer-up after the threshold is crossed (immediately followed by `(dismiss)`). */ readonly swipeEnd: _angular_core.OutputEmitterRef; /** Fired on pointer-up before the threshold, or on `pointercancel`. */ readonly swipeCancel: _angular_core.OutputEmitterRef; readonly paused: Signal; protected readonly swipeState: Signal; protected readonly swipeActiveDirection: Signal; protected readonly swipeMovementX: Signal; protected readonly swipeMovementY: Signal; readonly labelledBy: Signal; readonly describedBy: Signal; protected readonly computedRole: Signal<"alert" | "status">; protected readonly ariaLive: Signal<"assertive" | "off">; constructor(); private registerLabel; private unregisterLabel; private registerDescription; private unregisterDescription; private registerAction; private unregisterAction; requestClose(reason: ForToastCloseReason): void; /** * Clear a parked swipe-cancel state at the start of the next pointer * interaction. After a cancel the host keeps `data-swipe="cancel"` and the * released movement vars so the consumer's CSS can spring the toast back; a * fresh `pointerdown` is the terminal reset that returns the host to a clean * slate (no stale `data-swipe`, zeroed movement vars) before a new gesture * arms. A re-armed swipe overwrites the state anyway, so this only matters * for the parked-after-cancel window. */ protected onPointerDown(): void; protected onPause(reason: 'hover' | 'focus'): void; protected onResume(reason: 'hover' | 'focus'): void; protected onMaybeResumeFocus(event: FocusEvent): void; protected onKeyDown(event: KeyboardEvent): void; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Motion applied to the toasts a mutation of the stack pushes to a new * position. Set it on `[forToastViewport]` via `[stackShift]`, or per scope * with `provideForToastDefaults({ stackShift })`. The glide is played on * `translate`, leaving `transform` to the consumer. * * `animate.enter` / `animate.leave` cover the row that mounts or unmounts; * this covers its siblings, which reflow to their new spot in a single frame * with no property of their own for CSS to transition. */ interface ForToastStackShift { /** Duration in ms of the glide to the new position. Must be greater than `0`. */ duration: number; /** Easing of the glide, as a CSS easing function. Defaults to `'linear'`. */ easing?: string; } /** * Mounted once near the root of the app — typically inside `app.html`. * Listens to `ForToastManager.toasts()` and renders each programmatic * toast inline. Position the viewport from CSS (`position: fixed`, * `top|bottom`, `left|right`) — the directive doesn't impose any. * * Custom rendering: if a toast's config has `template`, that * `TemplateRef` is used instead of the default * title / description / action / close shape. The template receives * `$implicit: instance` and `data: instance.config.data`, and is rendered * with the `[forToast]` injection context in scope (via `ForToastOutlet`), * so `[forToastTitle]` / `[forToastDescription]` / `[forToastAction]` / * `[forToastClose]` keep their automatic a11y / close wiring inside it. * * Per-toast classes: a config's `class` / `classList` is applied to the * rendered toast root, merged with the directive's own host attributes. * * Enter / exit animations: a toast renders inside this viewport's `@for`, so a * `[animate.leave]` on the row defers the unmount natively — the toast stays * mounted until its exit animation settles. Supply the class per-toast with * `show({ animateLeave })` or set a viewport-wide default with `[animateLeave]` * (per-toast wins); `[animateEnter]` mirrors it for class-applied entrances. * * Stack shift: those two hooks cover the row that mounts or unmounts, never its * siblings — by default the siblings snap to their new spot in a single frame. * Set `[stackShift]` to glide them instead. The glide is driven from `translate`, * so your own `transform` — the swipe recipe, an enter / leave keyframe — still * composes. * * Hotkey: pressing the configured `hotkey` (default `F6`) anywhere in the * document focuses the first toast. Override per-viewport with `[hotkey]` * or globally with `provideForToastDefaults({ hotkey: '…' })`. The listener * is owned once by `ForToastManager`, so the hotkey never double-fires when * several viewports are mounted. * * Regions: a viewport renders only toasts whose `region` matches its `[region]` input (default * {@link DEFAULT_TOAST_REGION}), so several viewports can coexist — top-right system notifications * beside bottom-center confirmations. If two share a region, only the first mounted renders it and * the rest stay dormant and warn in dev mode, so one `show()` always produces one toast node. * * Accessibility: the host carries `role="region"` and an `aria-label` — set it * per-viewport with `[ariaLabel]`, or per-scope with * `provideForToastDefaults({ viewportAriaLabel: '…' })` (default * `Notifications`). Toast nodes themselves carry their own `role` * (`status` / `alert`) and `aria-live`, so screen readers announce updates * without forcing focus. * * Over a modal: the host carries `data-for-modal-exempt` by default, so an open `ForDialog` / * `ForDrawer` leaves the viewport out of its inert pass and treats a click on a toast as inside * rather than as `pointerDownOutside`. A toast shown from a flow inside a modal therefore stays * interactive, and clicking it does not dismiss the modal. Opt out with * `provideForToastDefaults({ overModal: 'inert' })`, which drops the marker so the viewport is * inerted and a click on a toast dismisses the modal like any other background sibling. */ declare class ForToastViewport { #private; /** * How this viewport behaves over an open modal `ForDialog` / `ForDrawer`, * resolved per-scope from `provideForToastDefaults({ overModal })` (default * `'peer'`). `'peer'` host-binds `data-for-modal-exempt` so the viewport * stays interactive over the modal; `'inert'` drops the marker so the modal * inerts the viewport and a click on a toast dismisses it. */ protected readonly overModal: "peer" | "inert"; /** * Accessible name for the viewport region, exposed as `aria-label`. Defaults * to the scope's `viewportAriaLabel` (`'Notifications'` unless overridden via * `provideForToastDefaults`); set `[ariaLabel]` to override per-instance, or * `null` to drop the attribute. A static `aria-label` on the host replaces * both the default and this input. */ readonly ariaLabel: _angular_core.InputSignal; protected readonly resolvedAriaLabel: Signal; /** * The toast region this viewport renders. Only toasts whose `region` matches * appear here; toasts opened without a `region` use * {@link DEFAULT_TOAST_REGION}, so the common single-viewport setup needs no * `[region]` at all. Mount viewports with distinct `[region]` values to drive * independent toast regions from one global `ForToastManager`. */ readonly region: _angular_core.InputSignal; /** Hotkey to focus the viewport. Default reads from `provideForToastDefaults`, falling back to `F6`. */ readonly hotkey: _angular_core.InputSignal; /** * Maximum number of toasts rendered at once. Older toasts collapse out of * the visible stack but stay in `manager.toasts()` until dismissed. When * unset (`null`, the default), the viewport falls back to the global * `provideForToastDefaults({ maxVisible })` value (itself `Infinity` unless * configured, which renders all live toasts). Setting `[maxVisible]` * per-viewport overrides the global default. * * **Overflow is parked, not auto-expired.** A toast pushed out of the * visible window is unmounted, so its auto-dismiss timer is not running * while it waits. It re-enters the window when a newer toast is dismissed, * and its `duration` countdown then restarts from full (a fresh `[forToast]` * mounts). Cap with `maxVisible` for layout, but dismiss explicitly — via * `ForToastRef.dismiss()`, `dismissAll()`, or the action / close button — * if you need overflow toasts to clear on a deadline. */ readonly maxVisible: _angular_core.InputSignalWithTransform; /** * Default swipe direction(s) applied to every programmatic toast that * doesn't override `swipeDirection` in its own config. `null` (default) * keeps swipe disabled unless explicitly opted into per-toast. */ readonly swipeDirection: _angular_core.InputSignal; /** * Default dismiss-distance in pixels applied to every programmatic toast * that doesn't override `swipeThreshold` in its own config. */ readonly swipeThreshold: _angular_core.InputSignalWithTransform; /** * Default `animate.enter` class applied to every programmatic toast that * doesn't set `animateEnter` in its own config. Empty (default) plays no * class-applied enter animation — a plain CSS `@keyframes` on `[forToast]` * already runs on mount without it. */ readonly animateEnter: _angular_core.InputSignal; /** * Default `animate.leave` class applied to every programmatic toast that * doesn't set `animateLeave` in its own config. Empty (default) unmounts the * toast synchronously on dismiss; set it (or per-toast `animateLeave`) to * keep the toast mounted until its exit animation settles before it leaves * the DOM. */ readonly animateLeave: _angular_core.InputSignal; /** * Motion applied to the toasts a mutation of the stack pushes to a new * position — the siblings of the row that mounted or unmounted, which * `animateEnter` / `animateLeave` cannot reach. The viewport measures the new * layout, offsets each moved row back to where it was and animates it to zero * (FLIP), driving `translate` so your own `transform` — the swipe recipe's * `translate3d(var(--for-toast-swipe-movement-x), …)`, an enter / leave * keyframe — composes with the glide instead of being suppressed by it. * * `null` (the default) keeps today's synchronous reflow, and falls back to * the scope's `provideForToastDefaults({ stackShift })` value. A bare number * is shorthand for `{ duration }` (easing `'linear'`), and `0` opts a single * viewport out of a scope default. Fully skipped under * `prefers-reduced-motion: reduce`. */ readonly stackShift: _angular_core.InputSignal; protected readonly defaultDuration: Signal; /** * Resolved `maxVisible` limit: the per-viewport `[maxVisible]` when set, * otherwise the global `provideForToastDefaults({ maxVisible })` value. */ protected readonly resolvedMaxVisible: Signal; protected readonly visible: Signal[]>; constructor(); protected onClose(toast: ForToastInstance, reason: ForToastCloseReason): void; /** * Consumer class(es) for a toast row, resolved from its config's `class` / * `classList`. Returns `''` when neither is set so the `[class]` host * binding emits no extra tokens and leaves the directive's own host * attributes untouched. */ protected toastClass(toast: ForToastInstance): string; /** * `animate.enter` class for a toast row: its per-toast `animateEnter` config * when set, otherwise the viewport-level `[animateEnter]`. Empty when neither * is set. */ protected toastAnimateEnter(toast: ForToastInstance): string; /** * `animate.leave` class for a toast row: its per-toast `animateLeave` config * when set, otherwise the viewport-level `[animateLeave]`. Empty when neither * is set, which keeps the toast's unmount synchronous on dismiss. */ protected toastAnimateLeave(toast: ForToastInstance): string; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } /** * Element holding the toast's accessible name. Registers its generated id * with the parent `[forToast]` so `aria-labelledby` is wired automatically. * Apply on whatever heading element fits (``, `

`, `
`). */ declare class ForToastTitle { #private; protected readonly id: string; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Supplementary description for the toast. Registers its generated id * with the parent `[forToast]` so `aria-describedby` is wired automatically. */ declare class ForToastDescription { #private; protected readonly id: string; constructor(); static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Action button inside a toast (e.g. "Undo"). Apply on a * `