UNPKG

2.09 kBTypeScriptView Raw
1import '../../';
2
3export type DialogCloseFunction = () => void;
4
5export interface DialogOptions {
6 bottom?: boolean | undefined;
7}
8
9export interface OpenDialogOptions extends DialogOptions {
10 /** If true, the dialog will be closed when the user presses enter in the input. Defaults to true. */
11 closeOnEnter?: boolean | undefined;
12 /** Determines whether the dialog is closed when it loses focus. Defaults to true. */
13 closeOnBlur?: boolean | undefined;
14 /** An event handler that will be called whenever keydown fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
15 onKeyDown?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
16 /** An event handler that will be called whenever keyup fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
17 onKeyUp?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
18 /** An event handler that will be called whenever input fires in the dialog's input. If the callback returns true, the dialog will not do any further processing of the event. */
19 onInput?(event: KeyboardEvent, value: string, close: DialogCloseFunction): boolean | undefined;
20 /** A callback that will be called after the dialog has been closed and removed from the DOM. */
21 onClose?(instance: HTMLElement): void;
22}
23
24export interface OpenNotificationOptions extends DialogOptions {
25 duration?: number | undefined;
26}
27
28declare module '../../' {
29 interface Editor {
30 /** Provides a very simple way to query users for text input. */
31 openDialog(template: string | Node, callback: (value: string, e: Event) => void, options?: OpenDialogOptions): DialogCloseFunction;
32 openNotification(template: string | Node, options?: OpenNotificationOptions): DialogCloseFunction;
33 openConfirm(template: string | Node, callbacks: ReadonlyArray<(editor: Editor) => void>, options?: DialogOptions): DialogCloseFunction;
34 }
35}