@serene-dev/toast-notifications
Version:
This is an Angular Toast Notification library.
83 lines (82 loc) • 2.77 kB
TypeScript
import { Subject } from 'rxjs';
/**
* An interface to guide the creation of a notification.
*/
export interface IAddToastNotification {
/**Text to display in the header of the notification */
header: string;
/**Message to display in the body of the notification */
body?: string;
/**Time to display the notification in milliseconds */
duration?: number;
/**Indicates if the notification stays up until the consumer triggers a close action */
manuallyDismiss?: boolean;
/**Indicates if the notification is in a loading state */
loading?: boolean;
/**Class name to wrap around the notification */
toastClass?: string;
/**Class icon name to use for the icon. Overrides the default icon set. */
iconClass?: string;
/**Preferred colour tag*/
tag?: EToastTag | 0 | 1 | 2 | 3;
/**Callback function to handle the expansion button click */
expansionHandler?: (item: IToastNotification) => any;
}
/**
* Interface for toast notification configuration
* @remarks
* This interface defines the structure for configuring toast notifications,
* including their appearance, behavior, and actions.
*/
export interface IToastNotification extends IAddToastNotification {
/**An RXJS observable the tells the subscriber when the notification is closed */
closed: Subject<{
/**Indicates if the closure was manually triggered or not */ manuallyClosed: boolean;
}>;
/**The id generated for the notification */
id: string;
/**Icon class */
_iconClass?: string;
/**Generated tag */
_tag?: EToastTag;
/**Date time when the notification was created */
datetime: number;
/**If the notification is expanded currently */
expanded?: boolean;
/**If the notification is expandable */
expandable: boolean;
}
/**
* Enum for the different notification tags
*/
export declare enum EToastTag {
/** Danger */
danger = "DANGER",
/** Success */
success = "SUCCESS",
/** Info */
info = "INFO",
/** Warning */
warning = "WARNING"
}
/**Maps tag enum values to tag numerical values */
export declare const ToastTagMap: {
[e in EToastTag]: 0 | 1 | 2 | 3;
};
/**Maps the numerical tags to the enums */
export declare const ToastTagReverseMap: {
[e in 0 | 1 | 2 | 3]: EToastTag;
};
/**
* General configuration for all instances of the toast notification
*/
export interface IToastComponentConfig {
/**In milliseconds */
defaultDuration: number;
/**Show the expansion button */
showExpansionButton?: boolean;
/**Horizontal position of the notification panel */
xPosition?: 'left' | 'right' | 'center';
/**Function to handle the expansion button */
expandHandler?: (item: IToastNotification) => any;
}