UNPKG

4.05 kBTypeScriptView Raw
1import { Dialog } from './dialog';
2/**
3 * Namespace for input dialogs
4 */
5export declare namespace InputDialog {
6 /**
7 * Common constructor options for input dialogs
8 */
9 interface IOptions {
10 /**
11 * The top level text for the dialog. Defaults to an empty string.
12 */
13 title: Dialog.Header;
14 /**
15 * The host element for the dialog. Defaults to `document.body`.
16 */
17 host?: HTMLElement;
18 /**
19 * Label of the requested input
20 */
21 label?: string;
22 /**
23 * An optional renderer for dialog items. Defaults to a shared
24 * default renderer.
25 */
26 renderer?: Dialog.IRenderer;
27 /**
28 * Label for ok button.
29 */
30 okLabel?: string;
31 /**
32 * Label for cancel button.
33 */
34 cancelLabel?: string;
35 /**
36 * The checkbox to display in the footer. Defaults no checkbox.
37 */
38 checkbox?: Partial<Dialog.ICheckbox> | null;
39 }
40 /**
41 * Constructor options for boolean input dialogs
42 */
43 interface IBooleanOptions extends IOptions {
44 /**
45 * Default value
46 */
47 value?: boolean;
48 }
49 /**
50 * Create and show a input dialog for a boolean.
51 *
52 * @param options - The dialog setup options.
53 *
54 * @returns A promise that resolves with whether the dialog was accepted
55 */
56 function getBoolean(options: IBooleanOptions): Promise<Dialog.IResult<boolean>>;
57 /**
58 * Constructor options for number input dialogs
59 */
60 interface INumberOptions extends IOptions {
61 /**
62 * Default value
63 */
64 value?: number;
65 }
66 /**
67 * Create and show a input dialog for a number.
68 *
69 * @param options - The dialog setup options.
70 *
71 * @returns A promise that resolves with whether the dialog was accepted
72 */
73 function getNumber(options: INumberOptions): Promise<Dialog.IResult<number>>;
74 /**
75 * Constructor options for item selection input dialogs
76 */
77 interface IItemOptions extends IOptions {
78 /**
79 * List of choices
80 */
81 items: Array<string>;
82 /**
83 * Default choice
84 *
85 * If the list is editable a string with a default value can be provided
86 * otherwise the index of the default choice should be given.
87 */
88 current?: number | string;
89 /**
90 * Is the item editable?
91 */
92 editable?: boolean;
93 /**
94 * Placeholder text for editable input
95 */
96 placeholder?: string;
97 }
98 /**
99 * Create and show a input dialog for a choice.
100 *
101 * @param options - The dialog setup options.
102 *
103 * @returns A promise that resolves with whether the dialog was accepted
104 */
105 function getItem(options: IItemOptions): Promise<Dialog.IResult<string>>;
106 /**
107 * Constructor options for text input dialogs
108 */
109 interface ITextOptions extends IOptions {
110 /**
111 * Default input text
112 */
113 text?: string;
114 /**
115 * Placeholder text
116 */
117 placeholder?: string;
118 /**
119 * Selection range
120 *
121 * Number of characters to pre-select when dialog opens.
122 * Default is to select the whole input text if present.
123 */
124 selectionRange?: number;
125 }
126 /**
127 * Create and show a input dialog for a text.
128 *
129 * @param options - The dialog setup options.
130 *
131 * @returns A promise that resolves with whether the dialog was accepted
132 */
133 function getText(options: ITextOptions): Promise<Dialog.IResult<string>>;
134 /**
135 * Create and show a input dialog for a password.
136 *
137 * @param options - The dialog setup options.
138 *
139 * @returns A promise that resolves with whether the dialog was accepted
140 */
141 function getPassword(options: Omit<ITextOptions, 'selectionRange'>): Promise<Dialog.IResult<string>>;
142}