import { UiElement } from '../shared/element.js'; import '../notification/notification.js'; import type { NotificationKind, UiNotification } from '../notification/notification.js'; import { type ToasterPlacement } from '../../core/toaster.js'; export type { ToasterPlacement } from '../../core/toaster.js'; /** * The corner where toasts stack (Carbon has no toast manager; Carbon's toast guidance: top right, under * the header). Usually created by `toast()`; place one yourself to change `placement` or `max`. * * - One polite live region (`role="region"`, "Notifications") that exists before any toast, so every toast * is announced; the toasts inside have no live role of their own (an actionable one keeps * `alertdialog` and takes focus). * - In the top layer (`popover="manual"`, shown from the start so the live region is in place before the * first toast); while a `ui-modal` is open a new toast is drawn above it — but the page outside a modal * dialog is inert, so that toast can't be clicked or read by screen readers: give feedback inside the * modal with an inline `ui-notification` instead (Carbon guidance). * - Under a `` it starts 16px below the 48px header; `--ui-toaster-offset` overrides. * - At most `max` toasts: a new one closes the oldest. Closed toasts are removed. * * @slot - `` elements (added by `toast()`) * @cssprop --ui-toaster-offset - Distance from the top (or bottom) edge (default 16px; 64px under a ui-header) */ export declare class UiToaster extends UiElement { static readonly styles: import("lit").CSSResult; /** Corner: newest toast nearest the edge. */ placement: ToasterPlacement; /** Most toasts shown at once; a new one closes the oldest. */ max: number; private readonly localize; constructor(); connectedCallback(): void; /** Into the top layer; again (to the top) when asked — only while a modal is open, re-showing briefly hides the region. */ private lift; protected updated(): void; /** Adds `toast`, closes the oldest beyond `max`, and lifts the region above anything opened since. */ add(toast: UiNotification): void; render(): import("lit-html").TemplateResult<1>; private readonly onClose; } export interface ToastOptions { /** Carbon notification kind (default `info`). */ kind?: NotificationKind; title: string; subtitle?: string; caption?: string; /** * Auto-close after this many ms (paused while hovered or focused). Default: 5000 for info / success, * 0 (stays until closed) for error / warning — those need reading. */ timeout?: number; /** Adds an action button (Carbon actionable toast; it never closes on its own). */ actionLabel?: string; onAction?: () => void; lowContrast?: boolean; /** A toast with the same id that is still open is replaced instead of stacking a duplicate. */ id?: string; } export interface ToastHandle { element: UiNotification; close: () => void; } /** The page's ``, created at the end of `` when there is none. */ export declare function getToaster(): UiToaster; /** * Shows a toast notification: `toast({ kind: 'success', title: 'Saved', subtitle: 'Contract RQ-12' })`. * Returns the element and a `close()`. A micro app in a shadow root passes its own ``. */ export declare function toast(options: ToastOptions, toaster?: UiToaster): ToastHandle; declare global { interface HTMLElementTagNameMap { 'ui-toaster': UiToaster; } }