import { ReadonlyJSONValue } from '@lumino/coreutils'; import { IDisposable } from '@lumino/disposable'; import { ISignal } from '@lumino/signaling'; /** * Notification manager */ export declare class NotificationManager implements IDisposable { constructor(); /** * Signal emitted whenever a notification changes. */ get changed(): ISignal; /** * Total number of notifications. */ get count(): number; /** * Whether the manager is disposed or not. */ get isDisposed(): boolean; /** * The list of notifications. */ get notifications(): Notification.INotification[]; /** * Dismiss one notification (specified by its id) or all if no id provided. * * @param id Notification id */ dismiss(id?: string): void; /** * Dispose the manager. */ dispose(): void; /** * Test whether a notification exists or not. * * @param id Notification id * @returns Notification status */ has(id: string): boolean; /** * Add a new notification. * * This will trigger the `changed` signal with an `added` event. * * @param message Notification message * @param type Notification type * @param options Notification option * @returns Notification unique id */ notify(message: string, type: Notification.TypeOptions, options: Notification.IOptions): string; /** * Update an existing notification. * * If the notification does not exists this won't do anything. * * Once updated the notification will be moved at the begin * of the notification stack. * * @param args Update options * @returns Whether the update was successful or not. */ update(args: Notification.IUpdate): boolean; private _isDisposed; private _changed; private _queue; } /** * Notification namespace */ export declare namespace Notification { /** * Enumeration of available action display type. */ type ActionDisplayType = 'default' | 'accent' | 'warn' | 'link'; /** * Interface describing an action linked to a notification. */ interface IAction { /** * The action label. * * This should be a short description. */ label: string; /** * Callback function to trigger * * ### Notes * By default execution of the callback will close the toast * and dismiss the notification. You can prevent this by calling * `event.preventDefault()` in the callback. */ callback: (event: MouseEvent) => void; /** * The action caption. * * This can be a longer description of the action. */ caption?: string; /** * The action display type. * * This will be used to modify the action button style. */ displayType?: ActionDisplayType; } /** * Notification interface */ interface INotification { /** * Notification unique identifier */ id: string; /** * Notification message * * #### Notes * The message will be truncated if longer than 140 characters. */ message: string; /** * Notification creation date */ createdAt: number; /** * Notification modification date */ modifiedAt: number; /** * Notification type */ type: TypeOptions; /** * Notification options */ options: IOptions; } /** * Notification change interface */ interface IChange { /** * Change type */ type: 'added' | 'removed' | 'updated'; /** * Notification that changed */ notification: INotification; } /** * Notification options */ interface IOptions { /** * Autoclosing behavior - false (not closing automatically) * or number (time in milliseconds before hiding the notification) * * Set to zero if you want the notification to be retained in the notification * center but not displayed as toast. This is the default behavior. */ autoClose?: number | false; /** * List of associated actions */ actions?: Array; /** * Data associated with a notification */ data?: T; /** * Task progression * * ### Notes * This should be a number between 0 (not started) and 1 (completed). */ progress?: number; } /** * Parameters for notification depending on a promise. */ interface IPromiseOptions { /** * Promise pending message and options * * #### Notes * The message will be truncated if longer than 140 characters. */ pending: { message: string; options?: IOptions; }; /** * Message when promise resolves and options * * The message factory receives as first argument the result * of the promise and as second the success `options.data`. * * #### Notes * The message will be truncated if longer than 140 characters. */ success: { message: (result: unknown, data?: Success) => string; options?: IOptions; }; /** * Message when promise rejects and options * * The message factory receives as first argument the error * of the promise and as second the error `options.data`. * * #### Notes * The message will be truncated if longer than 140 characters. */ error: { message: (reason: unknown, data?: Error) => string; options?: IOptions; }; } /** * Type of notifications */ type TypeOptions = 'info' | 'in-progress' | 'success' | 'warning' | 'error' | 'default'; /** * Options for updating a notification */ interface IUpdate extends IOptions { /** * Notification unique id */ id: string; /** * New notification message */ message?: string; /** * New notification type */ type?: TypeOptions; } /** * The global notification manager. */ const manager: NotificationManager; /** * Dismiss one notification (specified by its id) or all if no id provided * * @param id notification id */ function dismiss(id?: string): void; /** * Helper function to emit a notification. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param message Notification message * @param type Notification type * @param options Options for the error notification * @returns Notification unique id */ function emit(message: string, type?: TypeOptions, options?: IOptions): string; /** * Helper function to emit an error notification. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param message Notification message * @param options Options for the error notification * @returns Notification unique id */ function error(message: string, options?: IOptions): string; /** * Helper function to emit an info notification. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param message Notification message * @param options Options for the info notification * @returns Notification unique id */ function info(message: string, options?: IOptions): string; /** * Helper function to show an in-progress notification. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param promise Promise to wait for * @param options Options for the in-progress notification * @returns Notification unique id */ function promise(promise: Promise, options: IPromiseOptions): string; /** * Helper function to emit a success notification. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param message Notification message * @param options Options for the success notification * @returns Notification unique id */ function success(message: string, options?: IOptions): string; /** * Helper function to update a notification. * * If the notification does not exists, nothing will happen. * * Once updated the notification will be moved at the begin * of the notification stack. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param args Update options * @returns Whether the update was successful or not. */ function update(args: IUpdate): boolean; /** * Helper function to emit a warning notification. * * #### Notes * The message will be truncated if longer than 140 characters. * * @param message Notification message * @param options Options for the warning notification * @returns Notification unique id */ function warning(message: string, options?: IOptions): string; }