import { CourierBaseElement } from '@trycourier/courier-ui-core'; import { CourierToastThemeManager } from '../types/courier-toast-theme-manager'; import { CourierToastTheme } from '../types/courier-toast-theme'; import { InboxMessage } from '@trycourier/courier-js'; import { CourierToastItemActionClickEvent, CourierToastItemClickEvent, CourierToastItemFactoryProps } from '../types/toast'; /** * Default implementation of a Toast item. * * @see {@link CourierToast} * @public */ export declare class CourierToastItem extends CourierBaseElement { /** How long the exit animation runs before a dismissed toast's element is removed. */ private static readonly dismissAnimationTimeoutMs; private _themeManager; private _themeSubscription; private _message; private _customToastItemContent?; /** Whether this toast item is auto-dismissed. */ private readonly _autoDismiss; /** The timeout before the toast item is auto-dismissed, applicable if _autoDismiss is true. */ private readonly _autoDismissTimeoutMs; private _autoDismissTimeout; /** The progress bar element, paused/resumed alongside the countdown to stay in sync. */ private _autoDismissBar; private _onItemDismissedCallback; private _onToastItemClickCallback; private _onToastItemActionClickCallback; constructor(props: { message: InboxMessage; autoDismiss: boolean; autoDismissTimeoutMs: number; themeManager: CourierToastThemeManager; }); /** * Registers a handler called when the item is dismissed. * * @param handler - A function to be called when the item is dismissed. */ onItemDismissed(handler: (props: { message: InboxMessage; }) => void): void; /** * Registers a handler for item click events. * * @param handler - A function to be called when the item is clicked. */ onToastItemClick(handler: (props: CourierToastItemClickEvent) => void): void; /** * Registers a handler for item click events. * * @param handler - A function to be called when the item is clicked. */ onToastItemActionClick(handler: (props: CourierToastItemActionClickEvent) => void): void; /** * Set a custom content element for the toast item, reusing the {@link CourierToastItem} * container, which provides styling, animations, and event handling. * * @param factory - Function that returns an `HTMLElement` to render as the content. */ setToastItemContent(factory?: (props: CourierToastItemFactoryProps) => HTMLElement): void; /** * Dismiss the toast item. * * By default the toast fades out before it's removed. Set `timeoutMs` to * `0` to remove the item immediately. * * @param timeoutMs - the animation duration to fade out the toast item */ dismiss(timeoutMs?: number): void; /** * Pause the auto-dismiss countdown, banking the time already elapsed and * freezing the progress bar so the two stay in sync. * * Called by the containing {@link CourierToast} while the cursor is over the * toast stack, or while this item sits behind the top of the stack. No-op if * this item doesn't auto-dismiss. */ pauseAutoDismiss(): void; /** * Resume a paused auto-dismiss countdown from where it left off. * * Called by the containing {@link CourierToast} once the cursor leaves the * toast stack and this item is on top of it. No-op if this item doesn't * auto-dismiss. */ resumeAutoDismiss(): void; /** Freeze/unfreeze the progress bar to match the countdown. */ private syncAutoDismissBarPlayState; /** @override */ protected onComponentMounted(): void; /** @override */ protected onComponentUnmounted(): void; get theme(): CourierToastTheme; /** * @override */ static get id(): string; /** * @override */ static get observedAttributes(): string[]; /** * Render a toast item, either with default content or custom content if * a content factory function is provided. * * Note: Styles for the toast item are set in {@link CourierToast} since * toasts are ephemeral by nature and we want to avoid adding/removing/duplicating * styles as {@link CourierToastItem}s enter/exit. */ private render; /** Create the default content for this item. */ private createDefaultContent; private get messageHasActions(); private createActionButton; private onClick; }