toastr2
Version:
ToastrJS is a JavaScript library for Gnome / Growl type non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.
83 lines (82 loc) • 2.79 kB
TypeScript
import './toastr.scss';
declare type Required<T> = {
[P in keyof T]-?: T[P];
};
export declare type ToastType = {
info?: string;
error?: string;
warning?: string;
success?: string;
};
export declare type RequiredToastType = Required<ToastType>;
export declare type ToastrOptions<T = ToastType> = {
tapToDismiss?: boolean;
toastClass?: string | string[];
containerId?: string;
debug?: boolean;
showMethod?: 'fadeIn' | 'slideDown' | 'show';
showDuration?: number;
showEasing?: 'swing' | 'linear';
onShown?: () => void;
hideMethod?: 'fadeOut';
hideDuration?: number;
hideEasing?: 'swing';
onHidden?: () => void;
closeMethod?: boolean;
closeDuration?: number | false;
closeEasing?: boolean;
closeOnHover?: boolean;
extendedTimeOut?: number;
iconClasses?: T;
iconClass?: string | string[];
positionClass?: string | string[];
timeOut?: number;
titleClass?: string | string[];
messageClass?: string | string[];
escapeHtml?: boolean;
target?: string;
closeHtml?: string;
closeClass?: string | string[];
newestOnTop?: boolean;
preventDuplicates?: boolean;
progressBar?: boolean;
progressClass?: string | string[];
onclick?: (event: MouseEvent) => void;
onCloseClick?: (event: Event) => void;
closeButton?: boolean;
rtl?: boolean;
};
export declare type NotifyMap = {
type: string;
optionsOverride?: ToastrOptions;
iconClass: string;
title?: string;
message?: string;
};
declare class Toastr {
private listener;
private toastId;
private previousToast;
private toastType;
private version;
options: Required<ToastrOptions<RequiredToastType>>;
$container: HTMLElement;
constructor(options?: ToastrOptions);
createContainer(): HTMLElement;
getContainer(options?: Partial<ToastrOptions>, create?: boolean): HTMLElement;
error(message?: string, title?: string, optionsOverride?: ToastrOptions): HTMLElement | null;
warning(message?: string, title?: string, optionsOverride?: ToastrOptions): HTMLElement | null;
success(message?: string, title?: string, optionsOverride?: ToastrOptions): HTMLElement | null;
info(message?: string, title?: string, optionsOverride?: ToastrOptions): HTMLElement | null;
subscribe(callback: (response: Toastr) => void): void;
publish(args: Toastr): void;
clear(toastElement?: HTMLElement | null, clearOptions?: {
force?: boolean;
}): void;
remove(toastElement?: HTMLElement | null): void;
removeToast(toastElement: HTMLElement): void;
private clearContainer;
private clearToast;
private notify;
}
export default Toastr;