UNPKG

jupyterlab_toastify

Version:
120 lines (119 loc) 4.16 kB
import * as React from 'react'; import { ToastContent, ToastOptions, TypeOptions } from 'react-toastify'; export declare namespace INotification { interface IButton { /** * The label for the button. */ label: string; /** * Callback function */ callback: () => void; /** * The caption for the button. */ caption?: string; /** * The extra class name for the button. */ className?: string; } /** * Notification options */ interface IOptions { /** List of buttons with callback action to include in a toast */ buttons?: Array<IButton>; /** * Autoclosing behavior - undefined (not closing automatically) * or number (time in milliseconds before closing a toast) */ autoClose?: number | false; } /** * Helper function to show an error notification. Those * notifications need an user action to close. * * @param message Message to be printed in the notification * @param options Options for the error notification * @returns ToastId */ const error: (message: React.ReactNode, options?: IOptions) => Promise<React.ReactText>; /** * Helper function to show a warning notification. Those * notifications need an user action to close. * * @param message Message to be printed in the notification * @param options Options for the warning notification * @returns ToastId */ const warning: (message: React.ReactNode, options?: IOptions) => Promise<React.ReactText>; /** * Helper function to show an informative notification. Those * notifications close automatically. * * @param message Message to be printed in the notification * @param options Options for the error notification * @returns ToastId */ const info: (message: React.ReactNode, options?: IOptions) => Promise<React.ReactText>; /** * Helper function to show a success notification. Those * notifications close automatically. * * @param message Message to be printed in the notification * @param options Options for the error notification * @returns ToastId */ const success: (message: React.ReactNode, options?: IOptions) => Promise<React.ReactText>; /** * Helper function to show a in progress notification. Those * notifications do not close automatically. * * @param message Message to be printed in the notification * @param options Options for the error notification * @returns ToastId */ const inProgress: (message: React.ReactNode, options?: IOptions) => Promise<React.ReactText>; /** Options needed to update an existing toast */ interface IUpdate extends IOptions { /** Id of the toast to be updated */ toastId: React.ReactText; /** New message to be displayed */ message: React.ReactNode; /** New type of the toast */ type?: TypeOptions; /** * Autoclosing behavior - undefined (not closing automatically) * or number (time in milliseconds before closing a toast) */ autoClose?: number; } /** * Update an existing toast. * * If the toast is inactive (i.e. closed), a new one with the provided id * will be created with the new content. * * @param args Update options */ const update: (args: IUpdate) => Promise<void>; /** * Dismiss one toast (specified by its id) or all if no id provided * * @param toastId Toast id * @returns False or void */ const dismiss: (toastId?: React.ReactText) => Promise<false | void>; /** * Proxy to `toast` function from `react-toastify` module * * The Promise is due to the asynchronous import of the dependency * * @param content Toast content * @param options Toast creation option * @returns ToastId */ const notify: (content: ToastContent, options?: ToastOptions) => Promise<React.ReactText>; }