import * as _angular_cdk_bidi from '@angular/cdk/bidi'; import * as _angular_core from '@angular/core'; import { Type, TemplateRef, ValueProvider } from '@angular/core'; import * as _spartan_ng_brain_sonner from '@spartan-ng/brain/sonner'; import { BooleanInput, NumberInput } from '@angular/cdk/coercion'; type Expand = T extends object ? (T extends infer O ? { [K in keyof O]: O[K]; } : never) : T; type ToastTypes = 'action' | 'success' | 'info' | 'warning' | 'error' | 'loading' | 'default'; type PromiseT = Promise | (() => Promise); type PromiseData = ExternalToast & { loading?: string | Type; success?: string | Type | ((data: ToastData) => Type | string); error?: string | Type | ((error: unknown) => Type | string); finally?: () => void | Promise; }; type ToastT = { /** * Custom id for the toast. * * @default autogenerated */ id: number | string; title?: string | Type; type?: ToastTypes; /** * Icon displayed in front of toast's text, aligned vertically. */ icon?: Type; component?: Type; componentProps?: Record; /** * Dark toast in light mode and vice versa. * * @default false */ invert?: boolean; /** * Adds a close button. * * @default false */ closeButton?: boolean; /** * If `false`, it'll prevent the user from dismissing the toast by swiping. * * @default true */ dismissible?: boolean; /** * Toast's description, renders underneath the title. */ description?: string | Type; /** * Time in milliseconds that should elapse before automatically closing the toast. * * @default 4000 */ duration?: number; delete?: boolean; /** * Control the sensitivity of the toast for screen readers. * * @default false */ important?: boolean; /** * Renders a primary button, clicking it will close the toast. */ action?: { label: string; onClick: (event: MouseEvent) => void; }; /** * Renders a secondary button, clicking it will close the toast. */ cancel?: { label: string; onClick?: (event: MouseEvent) => void; }; /** * The function gets called when either the close button is clicked, or the toast is swiped. * * @param toast */ onDismiss?: (toast: ToastT) => void; /** * Function that gets called when the toast disappears automatically after it's timeout (duration` prop). * * @param toast */ onAutoClose?: (toast: ToastT) => void; promise?: PromiseT; cancelButtonStyle?: string; actionButtonStyle?: string; style?: Record; /** * Removes the default styling, which allows for easier customization. */ unstyled?: boolean; class?: string; classes?: ToastClassnames; descriptionClass?: string; /** * Position of the toast. * * @default 'bottom-right' */ position?: Position; /** * @internal This is used to determine if the toast has been updated to determine when to reset timer. */ updated?: boolean; /** * Test id for the toast for reliable e2e testing with data-testid attributes. */ testId?: string; }; type Position = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center'; type HeightT = { height: number; toastId: number | string; position: Position; }; type Theme = 'light' | 'dark' | 'system'; type ToastToDismiss = { id: number | string; dismiss: boolean; }; type ExternalToast = Omit & { id?: number | string; }; type ToasterProps = { /** * Dark toasts in light mode and vice versa. * * @default false */ invert: boolean; /** * Toast's theme, either `light`, `dark`, or `system` * * @default 'light' */ theme: 'light' | 'dark' | 'system'; /** * Place where the toasts will be rendered * * @default 'bottom-right' */ position: Position; /** * Keyboard shortcut that will move focus to the toaster area. * * @default '⌥/alt + T' */ hotkey: string[]; /** * Makes error and success state more colorful * * @default false */ richColors: boolean; /** * Toasts will be expanded by default * * @default false */ expand: boolean; /** * The duration of the toast in milliseconds. * * @default 4000 */ duration: number; /** * Amount of visible toasts * * @default 3 */ visibleToasts: number; /** * Adds a close button to all toasts, shows on hover * * @default false */ closeButton: boolean; /** * These will act as default options for all toasts. * * @default {} */ toastOptions: ToastOptions; /** * Offset from the edges of the screen. * * @default '32px' */ offset: string | number | null; /** * Gap between toasts when expanded, in pixels. * * @default '14px' */ gap: number; /** * Changes the default loading icon * * @default - */ loadingIcon: TemplateRef; }; type ToastOptions = { /** * The classes applied to the toast element. */ class?: string; /** * The classes applied to the toast description element. */ descriptionClass?: string; /** * The CSS styles applied to the toast element. */ style?: Record; /** * The CSS styles applied to the cancel button element. */ cancelButtonStyle?: string; /** * The CSS styles applied to the action button element. */ actionButtonStyle?: string; /** * The duration of the toast in milliseconds. */ duration?: number; /** * Whether the toast should be unstyled or not. */ unstyled?: boolean; /** * Classes to apply to the various elements of the toast. */ classes?: Expand; }; /** * The classes applied to the various elements of the toast. */ type ToastClassnames = { toast?: string; title?: string; description?: string; loader?: string; closeButton?: string; cancelButton?: string; actionButton?: string; } & ToastTypeClasses; type ToastTypeClasses = Partial>; type ToastProps = { toast: ToastT; index: number; expanded: boolean; invert: boolean; position: Position; visibleToasts: number; expandByDefault: boolean; closeButton: boolean; interacting: boolean; cancelButtonStyle: string; actionButtonStyle: string; duration: number | null; descriptionClass: string; classes: ToastClassnames; unstyled: boolean; }; type ToastAction = { label: string; onClick: (event: MouseEvent) => void; }; type ToastActionTemplateContext = { $implicit: ToastAction; toast: ToastT; }; type ToastActionTemplateRef = TemplateRef; /** * Utils directory to typecheck the context of the templateRef * {@link ToastActionTemplateContext} context for content */ declare class BrnToastAction { readonly templateRef: TemplateRef; static ngTemplateContextGuard(_directive: BrnToastAction, context: unknown): context is ToastActionTemplateContext; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Utils directory to typecheck the context of the templateRef * {@link ToastActionTemplateContext} context for content */ declare class BrnToastCancelAction { readonly templateRef: TemplateRef; static ngTemplateContextGuard(_directive: BrnToastCancelAction, context: unknown): context is ToastActionTemplateContext; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } declare class BrnSonnerToaster { private readonly _platformId; private readonly _config; private readonly _document; private readonly _window; private readonly _dir; protected readonly _toasts: _angular_core.Signal<_spartan_ng_brain_sonner.ToastT[]>; private readonly _heights; private readonly _reset; readonly invert: _angular_core.InputSignalWithTransform; readonly theme: _angular_core.InputSignal<"light" | "dark" | "system">; readonly position: _angular_core.InputSignal; readonly hotKey: _angular_core.InputSignal; readonly richColors: _angular_core.InputSignalWithTransform; readonly expand: _angular_core.InputSignalWithTransform; readonly duration: _angular_core.InputSignalWithTransform; readonly visibleToasts: _angular_core.InputSignalWithTransform; readonly closeButton: _angular_core.InputSignalWithTransform; readonly toastOptions: _angular_core.InputSignal<_spartan_ng_brain_sonner.ToastOptions>; readonly offset: _angular_core.InputSignal; readonly userClass: _angular_core.InputSignal; readonly style: _angular_core.InputSignal>; protected readonly _possiblePositions: _angular_core.Signal; protected readonly _expanded: _angular_core.WritableSignal; protected readonly _actualTheme: _angular_core.WritableSignal; protected readonly _interacting: _angular_core.WritableSignal; /** internal **/ readonly direction: _angular_core.WritableSignal<_angular_cdk_bidi.Direction>; private readonly _listRef; private readonly _lastFocusedElementRef; private readonly _isFocusWithinRef; protected readonly _hotKeyLabel: _angular_core.Signal; protected readonly _toasterStyles: _angular_core.Signal<{ '--front-toast-height': string; '--offset': string | number; '--width': string; '--gap': string; }>; protected readonly _loadingIcon: _angular_core.Signal | undefined>; protected readonly _successIcon: _angular_core.Signal | undefined>; protected readonly _errorIcon: _angular_core.Signal | undefined>; protected readonly _warningIcon: _angular_core.Signal | undefined>; protected readonly _infoIcon: _angular_core.Signal | undefined>; protected readonly _action: _angular_core.Signal; protected readonly _cancelAction: _angular_core.Signal; constructor(); handleBlur(event: FocusEvent): void; handleFocus(event: FocusEvent): void; handlePointerDown(event: MouseEvent): void; handleMouseLeave(): void; private readonly handleKeydown; private readonly handleThemePreferenceChange; private getActualTheme; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } interface BrnSonnerToasterConfig { /** The maximum number of toasts visible at once */ visibleToastsAmount: number; /** The offset from the viewport for the toast container */ viewPortOffset: string; /** The default lifetime of a toast in milliseconds */ toastLifetime: number; /** The width of the toast in pixels */ toastWidth: number; /** The gap between toasts in pixels */ gap: number; /** The threshold in pixels for swipe to dismiss a toast */ swipeThreshold: number; /** The time in milliseconds before a toast is unmounted */ timeBeforeUnmount: number; } declare function provideBrnSonnerToasterConfig(config: Partial): ValueProvider; declare function injectBrnSonnerToasterConfig(): BrnSonnerToasterConfig; declare const defaultClasses: ToastClassnames; declare const toastState: { create: (data: ExternalToast & { message?: string | Type; type?: ToastTypes; promise?: PromiseT; }) => string | number; addToast: (data: ToastT) => void; dismiss: (id?: number | string) => string | number | undefined; message: (message: string | Type, data?: ExternalToast) => string | number; error: (message: string | Type, data?: ExternalToast) => string | number; success: (message: string | Type, data?: ExternalToast) => string | number; info: (message: string | Type, data?: ExternalToast) => string | number; warning: (message: string | Type, data?: ExternalToast) => string | number; loading: (message: string | Type, data?: ExternalToast) => string | number; promise: (promise: PromiseT, data?: PromiseData) => string | number | undefined; custom: (component: Type, data?: ExternalToast) => string | number; removeHeight: (id: number | string) => void; addHeight: (height: HeightT) => void; reset: () => void; toasts: _angular_core.Signal; heights: _angular_core.Signal; }; declare function toastFunction(message: string | Type, data?: ExternalToast): string | number; declare const toast: typeof toastFunction & { success: (message: string | Type, data?: ExternalToast) => string | number; info: (message: string | Type, data?: ExternalToast) => string | number; warning: (message: string | Type, data?: ExternalToast) => string | number; error: (message: string | Type, data?: ExternalToast) => string | number; custom: (component: Type, data?: ExternalToast) => string | number; message: (message: string | Type, data?: ExternalToast) => string | number; promise: (promise: PromiseT, data?: PromiseData) => string | number | undefined; dismiss: (id?: number | string) => string | number | undefined; loading: (message: string | Type, data?: ExternalToast) => string | number; }; declare const BrnSonnerImports: readonly [typeof BrnSonnerToaster, typeof BrnToastAction, typeof BrnToastCancelAction]; export { BrnSonnerImports, BrnSonnerToaster, BrnToastAction, BrnToastCancelAction, defaultClasses, injectBrnSonnerToasterConfig, provideBrnSonnerToasterConfig, toast, toastState }; export type { BrnSonnerToasterConfig, Expand, ExternalToast, HeightT, Position, PromiseData, PromiseT, Theme, ToastAction, ToastActionTemplateContext, ToastActionTemplateRef, ToastClassnames, ToastOptions, ToastProps, ToastT, ToastToDismiss, ToastTypes, ToasterProps };