import * as i0 from '@angular/core'; import { EnvironmentProviders, InjectionToken } from '@angular/core'; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ type WrToastType = 'info' | 'success' | 'warning' | 'danger'; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ type WrToastPosition = 'top-start' | 'top' | 'top-end' | 'bottom-start' | 'bottom' | 'bottom-end'; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Per-toast options passed to {@link WrToast.show}. Any field * omitted falls back to the global {@link WrToastConfig}. */ interface WrToastOptions { /** Visual type. @default 'info' */ readonly type?: WrToastType; /** Heading shown at the top of the toast. */ readonly title?: string; /** Body message. */ readonly message: string; /** Auto-dismiss after N ms. `0` disables auto-dismiss. Default from global config. */ readonly duration?: number; /** Show a close (×) button. @default true */ readonly dismissible?: boolean; /** Override the corner for this toast only. */ readonly position?: WrToastPosition; /** Override the progress bar visibility for this toast only. */ readonly showProgress?: boolean; /** Override the copy button visibility for this toast only. */ readonly showCopy?: boolean; } /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * How the host arranges multiple toasts. * * - `stack` — Sonner-style: toasts cascade behind the newest one when the * pointer is outside the host; on hover the stack fans out into a list. * - `list` — classic vertical column, no overlap, no hover transition. */ type WrToastMode = 'stack' | 'list'; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Global toast configuration registered through {@link provideWrToastConfig}. * * Per-toast {@link WrToastOptions} can override individual fields at call * time (`position`, `duration`, `showProgress`, `showCopy`). */ interface WrToastConfig { /** Corner the stack renders in. @default 'top-end' */ readonly position: WrToastPosition; /** Layout mode for multiple toasts. @default 'stack' (Sonner-style hover-to-expand) */ readonly mode: WrToastMode; /** Auto-dismiss after N ms. `0` disables auto-dismiss. @default 4000 */ readonly duration: number; /** Render a countdown progress bar that pauses on hover. @default true */ readonly showProgress: boolean; /** Render a "copy message" button on each toast. @default false */ readonly showCopy: boolean; /** Render a "Close all" button when the stack reaches the threshold. @default true */ readonly showCloseAll: boolean; /** Minimum number of stacked toasts before "Close all" appears. @default 2 */ readonly closeAllThreshold: number; /** Maximum toasts visible at once. Oldest is dismissed when exceeded. `0` = unlimited. @default 5 */ readonly maxStack: number; /** Labels rendered in the UI. Keep short — meant to be overridden for i18n. */ readonly labels: { readonly close: string; readonly copy: string; readonly copied: string; readonly closeAll: string; }; } /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Handle returned by `WrToast.show()`. Call `dismiss()` to remove * the toast early. Inspect `options` to see what the caller requested. */ declare class WrToastRef { readonly id: number; readonly options: WrToastOptions; private readonly onDismiss; constructor(id: number, options: WrToastOptions, onDismiss: (id: number) => void); /** Remove this toast from the stack. */ dismiss(): void; } /** * Opens toast notifications in a single shared overlay. * * Global defaults come from {@link WR_TOAST_CONFIG}; register * {@link provideWrToastConfig} once at bootstrap to customise. Each * `show()` call accepts per-toast overrides via {@link WrToastOptions}. * * @example * ```ts * const toast = inject(WrToast); * * toast.show({ type: 'success', title: 'Saved', message: 'Profile updated.' }); * toast.show({ type: 'danger', message: 'Network error', duration: 0 }); * toast.show({ message: 'Permalink copied', position: 'bottom', showCopy: true }); * ``` * * @see https://ngwr.dev/components/toast */ declare class WrToast { private readonly overlay; private readonly config; private overlayRef; private hostRef; private currentPosition; private currentMode; private nextId; /** Currently rendered toasts (capped at `config.maxStack`). */ private active; /** Overflow waiting for a free slot — promoted FIFO as actives dismiss, so * nothing is ever silently dropped. */ private queue; /** Open a toast. Returns a handle you can `dismiss()` early. */ show(options: WrToastOptions): WrToastRef; /** Dismiss a single toast by id. */ dismiss(id: number): void; /** Dismiss every visible toast. Wired to the host's "Close all" button. */ dismissAll(): void; /** Change the corner the stack opens in. Affects future toasts. */ setPosition(position: WrToastPosition): void; /** Switch the layout mode at runtime. Persists across host re-creation. */ setMode(mode: 'stack' | 'list'): void; private startTimer; private pauseTimer; private ensureHost; /** Fill any free stack slots from the queue (FIFO), starting each promoted * toast's auto-dismiss timer only as it becomes visible. */ private promoteFromQueue; private pushToHost; private disposeHost; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Registers a global {@link WrToastConfig} for {@link WrToast}. Any * field you omit falls back to {@link DEFAULT_TOAST_CONFIG}; the `labels` * sub-object is merged separately so you can override a single string at a * time (useful for i18n). * * @example * ```ts * bootstrapApplication(AppComponent, { * providers: [ * provideWrToastConfig({ * position: 'bottom-end', * showCopy: true, * maxStack: 3, * labels: { close: 'Закрыть', copy: 'Копировать', copied: 'Скопировано', closeAll: 'Закрыть все' }, * }), * ], * }); * ``` */ declare function provideWrToastConfig(config: Partial): EnvironmentProviders; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Library defaults applied when no {@link provideWrToastConfig} call is * registered. Merged shallowly with the consumer's overrides (the `labels` * sub-object is merged separately so callers can override one string at a * time). */ declare const DEFAULT_TOAST_CONFIG: WrToastConfig; /** * @license * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE */ /** * Holds the global {@link WrToastConfig} used by {@link WrToast}. * The default factory returns {@link DEFAULT_TOAST_CONFIG} so the service * works out of the box; override via {@link provideWrToastConfig}. */ declare const WR_TOAST_CONFIG: InjectionToken; export { DEFAULT_TOAST_CONFIG, WR_TOAST_CONFIG, WrToast, WrToastRef, provideWrToastConfig }; export type { WrToastConfig, WrToastMode, WrToastOptions, WrToastPosition, WrToastType };