1 | import { Dialog } from './dialog';
|
2 | /**
|
3 | * Namespace for input dialogs
|
4 | */
|
5 | export declare namespace InputDialog {
|
6 | /**
|
7 | * Common constructor options for input dialogs
|
8 | */
|
9 | interface IOptions extends IBaseOptions {
|
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 | * An optional renderer for dialog items. Defaults to a shared
|
20 | * default renderer.
|
21 | */
|
22 | renderer?: Dialog.IRenderer;
|
23 | /**
|
24 | * Label for ok button.
|
25 | */
|
26 | okLabel?: string;
|
27 | /**
|
28 | * Label for cancel button.
|
29 | */
|
30 | cancelLabel?: string;
|
31 | /**
|
32 | * The checkbox to display in the footer. Defaults no checkbox.
|
33 | */
|
34 | checkbox?: Partial<Dialog.ICheckbox> | null;
|
35 | /**
|
36 | * The index of the default button. Defaults to the last button.
|
37 | */
|
38 | defaultButton?: number;
|
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 item selection input dialogs
|
108 | */
|
109 | interface IMultipleItemsOptions extends IOptions {
|
110 | /**
|
111 | * List of choices
|
112 | */
|
113 | items: Array<string>;
|
114 | /**
|
115 | * Default choices
|
116 | */
|
117 | defaults?: string[];
|
118 | }
|
119 | /**
|
120 | * Create and show a input dialog for a choice.
|
121 | *
|
122 | * @param options - The dialog setup options.
|
123 | *
|
124 | * @returns A promise that resolves with whether the dialog was accepted
|
125 | */
|
126 | function getMultipleItems(options: IMultipleItemsOptions): Promise<Dialog.IResult<string[]>>;
|
127 | /**
|
128 | * Constructor options for text input dialogs
|
129 | */
|
130 | interface ITextOptions extends IOptions {
|
131 | /**
|
132 | * Default input text
|
133 | */
|
134 | text?: string;
|
135 | /**
|
136 | * Placeholder text
|
137 | */
|
138 | placeholder?: string;
|
139 | /**
|
140 | * Selection range
|
141 | *
|
142 | * Number of characters to pre-select when dialog opens.
|
143 | * Default is to select the whole input text if present.
|
144 | */
|
145 | selectionRange?: number;
|
146 | /**
|
147 | * Pattern used by the browser to validate the input value.
|
148 | */
|
149 | pattern?: string;
|
150 | /**
|
151 | * Whether the input is required (has to be non-empty).
|
152 | */
|
153 | required?: boolean;
|
154 | }
|
155 | /**
|
156 | * Create and show a input dialog for a text.
|
157 | *
|
158 | * @param options - The dialog setup options.
|
159 | *
|
160 | * @returns A promise that resolves with whether the dialog was accepted
|
161 | */
|
162 | function getText(options: ITextOptions): Promise<Dialog.IResult<string>>;
|
163 | /**
|
164 | * Create and show a input dialog for a password.
|
165 | *
|
166 | * @param options - The dialog setup options.
|
167 | *
|
168 | * @returns A promise that resolves with whether the dialog was accepted
|
169 | */
|
170 | function getPassword(options: Omit<ITextOptions, 'selectionRange'>): Promise<Dialog.IResult<string>>;
|
171 | }
|
172 | /**
|
173 | * Constructor options for base input dialog body.
|
174 | */
|
175 | interface IBaseOptions {
|
176 | /**
|
177 | * Label of the requested input
|
178 | */
|
179 | label?: string;
|
180 | /**
|
181 | * Additional prefix string preceding the input (e.g. £).
|
182 | */
|
183 | prefix?: string;
|
184 | /**
|
185 | * Additional suffix string following the input (e.g. $).
|
186 | */
|
187 | suffix?: string;
|
188 | }
|
189 | export {};
|