import * as _angular_core from '@angular/core'; import { Signal, Provider, TemplateRef, Type, Injector } from '@angular/core'; import * as ng_primitives_internal from 'ng-primitives/internal'; import * as ng_primitives_toast from 'ng-primitives/toast'; import { NgpPortal } from 'ng-primitives/portal'; interface NgpToastOptions$1 { /** * The position of the toast. */ placement: NgpToastPlacement; /** * The duration of the toast in milliseconds. */ duration: number; /** * A function to register the toast instance with the manager. * @internal */ register: (toast: NgpToast) => void; /** * Whether the toast region is expanded. * @internal */ expanded: Signal; /** * Whether the toast supports swipe dismiss. * @internal */ dismissible: boolean; /** * The swipe directions supported by the toast. * @internal */ swipeDirections: NgpToastSwipeDirection[]; /** * When true, only the front toast's timer will run. * @internal */ sequential: boolean; /** * When true, the toast will not auto-dismiss and must be dismissed explicitly. * @internal */ persistent: boolean; } declare class NgpToast { private readonly manager; private readonly injector; private readonly elementRef; /** @internal */ readonly element: HTMLElement; protected readonly config: ng_primitives_toast.NgpToastConfig; /** @internal */ readonly options: NgpToastOptions$1; private readonly interactivityChecker; private readonly isInteracting; protected readonly duration: _angular_core.WritableSignal; private readonly persistent; private readonly timerRestarts; /** * How many times `NgpToastRef.update()` has restarted the timer. Key an element on it to restart * a CSS animation that follows the timer, such as a progress bar. */ readonly restarts: _angular_core.Signal; private pointerStartRef; private dragStartTime; protected readonly swiping: _angular_core.WritableSignal; protected readonly swipeDirection: _angular_core.WritableSignal<"x" | "y" | null>; protected readonly swipeAmount: _angular_core.WritableSignal<{ x: number; y: number; }>; protected readonly swipeOutDirection: _angular_core.Signal<"top" | "right" | "bottom" | "left" | null>; /** * Get all toasts that are currently being displayed in the same position. */ private readonly toasts; /** * The number of toasts that are currently being displayed before this toast. */ protected readonly index: _angular_core.Signal; /** * Determine the position of the toast in the list of toasts. * This is the combination of the heights of all the toasts before this one, plus the gap between them. */ protected readonly offset: _angular_core.Signal; /** * Determine if this toast is visible. * Visible considers the maximum number of toasts that can be displayed at once, and the last x toasts that are currently being displayed. */ protected readonly visible: _angular_core.Signal; /** * Determine the height of the front toast. * This is used to determine the height of the toast when it is not expanded. */ protected readonly frontToastHeight: _angular_core.Signal; /** * Determine the z-index of the toast. This is the inverse of the index. * The first toast will have the highest z-index, and the last toast will have the lowest z-index. * This is used to ensure that the first toast is always on top of the others. */ protected readonly zIndex: _angular_core.Signal; /** * Whether the auto-dismiss timer is paused. */ protected readonly paused: _angular_core.Signal; /** * The height of the toast in pixels. */ protected readonly dimensions: _angular_core.Signal; /** * The x position of the toast. */ readonly x: string; /** * The y position of the toast. */ readonly y: string; /** * The toast timer instance. */ private readonly timer; constructor(); /** * Restart the timer with a new duration, or stop it when the toast becomes persistent. * @internal */ restart({ duration, persistent }: { duration?: number; persistent?: boolean; }): void; /** * The milliseconds left before the toast auto-dismisses. Not reactive. */ remaining(): number; private onPointerDown; private onPointerMove; private onPointerUp; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } type NgpToastSwipeDirection = 'top' | 'right' | 'bottom' | 'left'; type NgpToastPlacement = 'top-start' | 'top-end' | 'top-center' | 'bottom-start' | 'bottom-end' | 'bottom-center'; interface NgpToastConfig { /** * The position of the toast. */ placement: NgpToastPlacement; /** * The duration of each toast. */ duration: number; /** * The offset from the top of the viewport in pixels. */ offsetTop: number; /** * The offset from the bottom of the viewport in pixels. */ offsetBottom: number; /** * The offset from the left of the viewport in pixels. */ offsetLeft: number; /** * The offset from the right of the viewport in pixels. */ offsetRight: number; /** * Whether a toast can be dismissed by swiping. */ dismissible: boolean; /** * The amount a toast must be swiped before it is considered dismissed. */ swipeThreshold: number; /** * The default swipe directions supported by the toast. */ swipeDirections: NgpToastSwipeDirection[]; /** * The maximum number of toasts that can be displayed at once. */ maxToasts: number; /** * The aria live setting. */ ariaLive: string; /** * The gap between each toast. */ gap: number; /** * The z-index of the toast container. * This is used to ensure that the toast container is always on top of other elements. */ zIndex: number; /** * When true, only the front toast's timer will run. * When a toast is dismissed, the timer will start on the next toast. */ sequential: boolean; /** * When true, toasts will not auto-dismiss and must be dismissed explicitly. */ persistent: boolean; } /** * Provide the default Toast configuration * @param config The Toast configuration * @returns The provider */ declare function provideToastConfig(config: Partial): Provider[]; /** * Inject the context passed to `show()`. It does not change when `NgpToastRef.update()` passes a * new context: use `injectToastContextSignal()` to follow it. */ declare function injectToastContext(): T; /** * Inject the context of the toast as a signal, which `NgpToastRef.update()` sets. */ declare function injectToastContextSignal(): Signal; declare class NgpToastManager { private readonly config; private readonly applicationRef; private readonly rendererFactory; private readonly renderer; private readonly injector; private readonly document; private readonly ngZone; private readonly destroyRef; private readonly isBrowser; private readonly containers; /** The element focused before focus entered the toasts, where it returns once they are gone. */ private focusBeforeToasts; /** Whether F6 moved focus to the toasts, so that F6 again or Escape takes it back. */ private enteredWithF6; private listeningForKeys; readonly toasts: _angular_core.WritableSignal; /** The toasts playing their exit animation, which can no longer take focus or be updated. */ private readonly dismissing; /** Signal that tracks which placements are expanded */ private readonly expanded; constructor(); /** Show a toast notification */ show(toast: TemplateRef | Type, options?: NgpToastOptions): NgpToastRef; /** Hide a toast notification */ dismiss(toast: NgpToast): Promise; /** @internal */ dismissBySwipe(toast: NgpToast): Promise; private hide; /** * A toast that holds focus as it starts to close hands focus on before its exit animation: * to the next toast for a keyboard user, otherwise back to where focus was before it * entered the toasts. Waiting for the removal would depend on how the toast animates out. */ private moveFocusOutOf; /** * The toast that takes focus when the given one leaves: the next older toast at the same * placement, or the next newer one when it was the oldest. */ private neighbourOf; /** * A container is a live region, and a live region must be in the page before the content it * announces, or screen readers may skip the first toast. So every placement gets one up front, * once the page has a body: a manager injected from a script in the `` adds them on the * first `show()`. The configured placement comes first so that * `querySelector('[data-ngp-toast-container]')` still finds the container default toasts use. */ private createContainers; /** * Lazily create or get a container for a given placement. */ private getOrCreateContainer; /** * F6 moves focus to the newest toast's region and back, so toasts stay reachable from the * keyboard even while a dialog traps focus. */ private listenForKeys; private containerOf; private hasToasts; private returnFocus; /** * Create a section in which toasts will be rendered for a specific placement. */ private createContainer; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵprov: _angular_core.ɵɵInjectableDeclaration; } interface NgpToastOptions { /** The position of the toast */ placement?: NgpToastPlacement; /** The duration of the toast in milliseconds */ duration?: number; /** Whether the toast is dismissible */ dismissible?: boolean; /** The swipe directions supported by the toast */ swipeDirections?: NgpToastSwipeDirection[]; /** The context to make available to the toast */ context?: T; /** When enabled, only the front toast's timer will run */ sequential?: boolean; /** When true, the toast will not auto-dismiss and must be dismissed explicitly */ persistent?: boolean; /** * The injector used to render the toast content. Provide the calling component's * injector when the toast depends on component-scoped providers. Defaults to root. */ injector?: Injector; } interface NgpToastRecord { instance: NgpToast; portal: NgpPortal; } interface NgpToastRef { /** Dismiss the toast. */ dismiss(): Promise; /** * Change the toast in place: it keeps its position and does not replay its enter animation. * The timer restarts with the new duration, or the current one, unless the toast is persistent. * Does nothing once the toast is being dismissed. */ update(changes: NgpToastUpdate): void; } interface NgpToastUpdate { /** The new context of the toast. */ context?: T; /** The new duration of the toast in milliseconds. */ duration?: number; /** When true, the toast stops its timer; when false, it starts it again. */ persistent?: boolean; } export { NgpToast, NgpToastManager, injectToastContext, injectToastContextSignal, provideToastConfig }; export type { NgpToastConfig, NgpToastOptions, NgpToastRef, NgpToastUpdate };