import * as i0 from '@angular/core'; import { Type, AfterViewInit, OnDestroy, OnInit, EventEmitter } from '@angular/core'; import * as rxjs from 'rxjs'; import { Observable } from 'rxjs'; import { DynamicTextContent, DynamicContent, GetDynamicViewContext } from '@odx/angular/cdk/dynamic-view'; import * as _odx_angular_utils from '@odx/angular/utils'; import * as i3 from '@odx/angular'; /** * An interface representing an action that can be performed from a toast notification. * Each action includes a label, an optional left and right icon `iconSet::iconName`, * and a function to execute when the action is triggered. */ interface ToastAction { label: DynamicTextContent; leftIcon?: string; rightIcon?: string; action: () => void; } type ToastVariant = (typeof ToastVariant)[keyof typeof ToastVariant]; declare const ToastVariant: { readonly DEFAULT: "default"; readonly WARNING: "warning"; readonly DANGER: "danger"; readonly SUCCESS: "success"; readonly WARNING_STRONG: "warning-strong"; readonly DANGER_STRONG: "danger-strong"; }; interface Toast { id?: string; title: DynamicTextContent; description?: DynamicContent; descriptionContext?: GetDynamicViewContext>; actions?: ToastAction[]; variant?: ToastVariant; } interface ToastOptions { dismissable: boolean; duration: number; } interface ToastRef { id: string; item: Toast; options: ToastOptions; } /** * Represents a container component for displaying toast notifications. This component manages and arranges toast messages, * handling animations for entering and leaving toasts. It ensures that only a limited number of toasts are shown at the same time, * based on the `maxItems` input. The container listens for toast events from the `ToastService` to update its list of toasts dynamically. * * The component uses a group of animations to slide toasts in and out smoothly and also provides an output for when a toast is dismissed. * It's designed to integrate with a single instance per application, ensuring no more than one toast container is initialized. */ declare class ToastContainerComponent implements AfterViewInit, OnDestroy { private static INITIALIZED; private previousItemsCount; private readonly destroyRef; private readonly windowRef; private readonly renderer; private readonly toastService; readonly element: i0.ElementRef; readonly items$: Observable; readonly hiddenToasts$: Observable; /** * Maximum number of toasts that can be displayed at once. * * @type {number} * @default 3 */ maxItems: number; /** * Emits an event when a toast is dismissed. * * @emits {ToastRef} - The toast reference that was dismissed. */ readonly dismiss: Observable; ngAfterViewInit(): void; ngOnDestroy(): void; protected onDismiss(itemRef: ToastRef): void; private updatePopverPosition; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_maxItems: unknown; } /** * A component that represents a single toast notification. This component is responsible for displaying * message content, handling toast actions, and managing the automatic dismissal of the toast based on a duration. * It supports dynamic content for descriptions and can show an optional set of actions. */ declare class ToastItemComponent implements OnInit { private readonly takeUntilDestroyed; readonly element: i0.ElementRef; /** * Determines the icon to display based on the toast's variant. * Returns a string representing the icon class. * * @returns {string} - The icon class name. * @default 'info' */ get icon(): string; /** * Unique identifier for the toast item, typically provided for accessibility purposes. * * @required * @type {string} */ id: string; /** * The main title of the toast, displayed prominently. * * @required * @type {DynamicTextContent} */ title: DynamicTextContent; /** * Optional detailed description for the toast. This can be plain text or a dynamic template. * * @type {DynamicContent | null} */ description?: DynamicContent | null; /** * Context for rendering the dynamic component of the description. * * @type {GetDynamicViewContext> | undefined} */ descriptionContext?: GetDynamicViewContext>; /** * The variant of the toast which influences the icon and styling. * * @type {ToastVariant | null} * @default ToastVariant.DEFAULT */ variant?: ToastVariant | null; /** * Optional actions related to the toast, such as 'retry' or 'dismiss'. * * @type {ToastAction[] | undefined} */ actions?: ToastAction[]; /** * Configuration options for the toast, including its duration and dismissal behavior. * * @required * @type {ToastOptions} */ options: ToastOptions; /** * Emits an event when the toast is dismissed, either through action or automatically. * * @emits {void} */ readonly dismiss: EventEmitter; ngOnInit(): void; protected onDismiss(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Utility functions generated by `createConfigTokens` to handle injection and provision of `ToastConfig`. * These include tokens and functions to access and provide the default configuration for toasts. * * `ToastDefaultConfig` provides the default settings for toasts. * `ToastConfig` is a token that can be used to inject toast configuration settings. * `injectToastConfig` is a function that retrieves the current toast configuration. * `provideToastConfig` is a function used to specify a custom configuration for toasts. * * @example * ```ts * // In module providers: * providers: [ * provideToastConfig({ // ... global module configuration }), * ] * * // In a component or service: * constructor(@Inject(ToastConfig) private readonly config: ToastConfig) {} * * // Or using the `injectToastConfig` function: * @Component({ ... }) * export class MyComponent { * private readonly config = injectToastConfig(); * } * ``` */ declare const ToastDefaultConfig: ToastOptions; type ToastConfig = ToastOptions; declare const ToastConfig: i0.InjectionToken>; declare const injectToastConfig: () => ToastOptions; declare const provideToastConfig: >>(config: _odx_angular_utils.ConfigProvider, D>) => i0.FactoryProvider | i0.ValueProvider; declare class ToastModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } /** * ToastService provides a centralized management system for toasts within an application. * It handles the creation, updates, and dismissal of toasts based on a FIFO (first-in, first-out) queue. * This service integrates custom toast options with default configurations and supports reactive updates through observables. */ declare class ToastService { private readonly queue; private readonly defaultOptions; /** * Observable stream of active toasts. * * @emits {ToastRef[]} The current list of active toasts. */ readonly toasts$: rxjs.Observable<(ToastRef & { id: string | number; })[]>; /** * Observable that emits when any update occurs in the toast queue. * * @emits {ToastRef[]} The updated list of active toasts. */ readonly onUpdate$: rxjs.Observable; /** * Observable that emits when a toast is added. * * @emits {ToastRef} The newly added toast. */ readonly onToastAdd$: rxjs.Observable; /** * Observable that emits when a toast is updated. * * @emits {ToastRef} The updated toast. */ readonly onToastUpdate$: rxjs.Observable; /** * Observable that emits when a toast is removed. * * @emits {ToastRef} The removed toast. */ readonly onToastRemove$: rxjs.Observable; /** * Creates and queues a new toast based on the provided item and options. * Merges given options with default configurations. * * @param {Toast} item The toast item to create. * @param {Partial} options Optional additional options for the toast. * @returns {ToastRef} The reference to the newly created toast. */ create(item: Toast, options?: Partial): ToastRef; /** * Dismisses a specific toast identified by a reference or ID. * * @param {ToastRef | ToastRef['id']} refOrId The reference or ID of the toast to dismiss. * @returns {ToastRef | null} The reference to the dismissed toast, or null if not found. */ dismiss(refOrId: ToastRef | ToastRef['id']): ToastRef | null; /** * Dismisses all toasts currently being displayed. */ dismissAll(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export { ToastConfig, ToastContainerComponent, ToastDefaultConfig, ToastItemComponent, ToastModule, ToastService, ToastVariant, injectToastConfig, provideToastConfig }; export type { Toast, ToastAction, ToastOptions, ToastRef };