1 | declare namespace FomanticUI {
|
2 | interface Toast {
|
3 | settings: ToastSettings;
|
4 |
|
5 | /**
|
6 | * Pauses the display time decrease (and possible progress bar animation)
|
7 | */
|
8 | (behavior: 'animate pause'): JQuery;
|
9 |
|
10 | /**
|
11 | * Continues decreasing display time (and possible progress bar animation)
|
12 | */
|
13 | (behavior: 'animate continue'): JQuery;
|
14 |
|
15 | /**
|
16 | * Closes the toast
|
17 | */
|
18 | (behavior: 'close'): JQuery;
|
19 |
|
20 | /**
|
21 | * Returns all toasts as an array of objects which are visible within the current toast-container
|
22 | */
|
23 | (behavior: 'get toasts'): object[];
|
24 |
|
25 | /**
|
26 | * Returns the remaining time in milliseconds
|
27 | */
|
28 | (behavior: 'get remainingTime'): number;
|
29 |
|
30 | (behavior: 'refresh' | 'destroy'): JQuery;
|
31 | <K extends keyof ToastSettings>(behavior: 'setting', name: K, value?: undefined, ): Partial<Pick<ToastSettings, keyof ToastSettings>>;
|
32 | <K extends keyof ToastSettings>(behavior: 'setting', name: K, value: ToastSettings[K]): JQuery;
|
33 | (behavior: 'setting', value: Partial<Pick<ToastSettings, keyof ToastSettings>>): JQuery;
|
34 | (settings?: Partial<Pick<ToastSettings, keyof ToastSettings>>): JQuery;
|
35 | }
|
36 |
|
37 | /**
|
38 | * @see {@link https://fomantic-ui.com/modules/toast.html#/settings}
|
39 | */
|
40 | interface ToastSettings {
|
41 | // region Toast Settings
|
42 |
|
43 | /**
|
44 | * Sets where the toast can be displayed. Can be 'top right', 'top center', 'top left', 'bottom right', 'bottom center' and 'bottom left'.
|
45 | *
|
46 | * @default 'top right'
|
47 | */
|
48 | position: string;
|
49 |
|
50 | /**
|
51 | * If the toasts should stack horizontal instead of vertical.
|
52 | *
|
53 | * @default false
|
54 | */
|
55 | horizontal: boolean;
|
56 |
|
57 | /**
|
58 | * Define the class of notification. Can be any existing color definition or 'info', 'success', 'warning' and 'error'.
|
59 | * If ui message is used in className.toast option (see below), this option can hold any supported class of the message component.
|
60 | *
|
61 | * @default 'neutral'
|
62 | */
|
63 | class: string;
|
64 |
|
65 | /**
|
66 | * Can hold a string to be added to the progress bar class, for example a separate color
|
67 | *
|
68 | * @default false
|
69 | */
|
70 | classProgress: false | string;
|
71 |
|
72 | /**
|
73 | * Can hold a string to be added to the actions class to control its appearance.
|
74 | * Usually a combination of 'basic', 'left', 'top', 'bottom', 'vertical' and 'attached'.
|
75 | *
|
76 | * @default false
|
77 | */
|
78 | classActions: false | string;
|
79 |
|
80 | /**
|
81 | * Can hold a string to be added to the image class. 'mini', 'tiny', 'small' and 'avatar' are supported out of the box.
|
82 | *
|
83 | * @default 'mini'
|
84 | */
|
85 | classImage: string;
|
86 |
|
87 | /**
|
88 | * Selector or jquery object specifying the area to attach the toast container to.
|
89 | *
|
90 | * @default 'body'
|
91 | */
|
92 | context: string | JQuery;
|
93 |
|
94 | /**
|
95 | * Set the time (in ms) of the toast appearance. Set '0' to disable the automatic dismissal.
|
96 | * Set 'auto' to calculate the time by the given amount of words within the toast.
|
97 | *
|
98 | * @default 3000
|
99 | */
|
100 | displayTime: number | 'auto';
|
101 |
|
102 | /**
|
103 | * Minimum display time in case displayTime is set to 'auto'.
|
104 | *
|
105 | * @default 1000
|
106 | */
|
107 | minDisplayTime: number;
|
108 |
|
109 | /**
|
110 | * Base to calculate display time in case displayTime is set to 'auto'.
|
111 | *
|
112 | * @default 120
|
113 | */
|
114 | wordsPerMinute: number;
|
115 |
|
116 | /**
|
117 | * If an URL to an image is given, that image will be shown to the left of the toast.
|
118 | *
|
119 | * @default false
|
120 | */
|
121 | showImage: false | string;
|
122 |
|
123 | /**
|
124 | * Define if the toast should display an icon which matches to a given class.
|
125 | * If a string is given, this will be used as icon classname.
|
126 | *
|
127 | * @default true
|
128 | */
|
129 | showIcon: boolean | string;
|
130 |
|
131 | /**
|
132 | * This will make the toast closable by the top right corner icon instead of clicking anywhere on the toast when set to 'true'.
|
133 | * When set to 'left' the closeIcon is shown to the left instead of right.
|
134 | *
|
135 | * @default false
|
136 | */
|
137 | closeIcon: boolean | 'left';
|
138 |
|
139 | /**
|
140 | * Set to 'false' to avoid closing the toast when it is clicked.
|
141 | *
|
142 | * @default true
|
143 | */
|
144 | closeOnClick: boolean;
|
145 |
|
146 | /**
|
147 | * If a given DOM-Node should stay reusable by using a clone of it as toast.
|
148 | * If set to false the original DOM-Node will be detached and removed from the DOM then the toast is closed.
|
149 | *
|
150 | * @default true
|
151 | */
|
152 | cloneModule: boolean;
|
153 |
|
154 | /**
|
155 | * Displays a progress bar on 'top' or 'bottom' increasing until 'displayTime' is reached.
|
156 | * 'false' won't display any progress bar. If 'displayTime' option is '0', this option is ignored.
|
157 | *
|
158 | * @default false
|
159 | */
|
160 | showProgress: boolean | 'top' | 'bottom';
|
161 |
|
162 | /**
|
163 | * 'true' Increases the progress bar from 0% to 100%.
|
164 | * 'false' Decreases the progress bar from 100% to 0%.
|
165 | *
|
166 | * @default false
|
167 | */
|
168 | progressUp: boolean;
|
169 |
|
170 | /**
|
171 | * Set to 'false' if the display timer should not pause when the toast is hovered.
|
172 | *
|
173 | * @default true
|
174 | */
|
175 | pauseOnHover: boolean;
|
176 |
|
177 | /**
|
178 | * 'true' will display the toast in a fixed width, 'false' displays the toast responsively with dynamic width.
|
179 | *
|
180 | * @default true
|
181 | */
|
182 | compact: boolean;
|
183 |
|
184 | /**
|
185 | * Opacity value of the toast after the show-transition.
|
186 | *
|
187 | * @default 1
|
188 | */
|
189 | opacity: number;
|
190 |
|
191 | /**
|
192 | * Define if new toasts should be displayed above the others.
|
193 | *
|
194 | * @default false
|
195 | */
|
196 | newestOnTop: boolean;
|
197 |
|
198 | /**
|
199 | * Whether HTML included in given title, message or actions should be preserved.
|
200 | * Set to 'false' in case you work with untrusted 3rd party content.
|
201 | *
|
202 | * @default true
|
203 | */
|
204 | preserveHTML: boolean;
|
205 |
|
206 | /**
|
207 | * Settings to set the transitions and durations during the show or the hide of a toast.
|
208 | */
|
209 | transition: Toast.TransitionSettings;
|
210 |
|
211 | // endregion
|
212 |
|
213 | // region Callbacks
|
214 |
|
215 | /**
|
216 | * Callback before toast is shown. Returning 'false' from this callback will cancel the toast from showing.
|
217 | */
|
218 | onShow(this: JQuery): void;
|
219 |
|
220 | /**
|
221 | * Callback before toast is shown. Returning false from this callback will cancel the toast from showing..
|
222 | */
|
223 | onVisible(this: JQuery): void;
|
224 |
|
225 | /**
|
226 | * Callback after popup is clicked in
|
227 | */
|
228 | onClick(this: JQuery): void;
|
229 |
|
230 | /**
|
231 | * Callback before toast is hidden. Returning 'false' from this callback will cancel the toast from hiding.
|
232 | */
|
233 | onHide(this: JQuery): void;
|
234 |
|
235 | /**
|
236 | * Callback after toast is hidden.
|
237 | */
|
238 | onHidden(this: JQuery): void;
|
239 |
|
240 | /**
|
241 | * Callback before toast is destroyed.
|
242 | */
|
243 | onRemove(this: JQuery): void;
|
244 |
|
245 | /**
|
246 | * Callback when an existing button with class 'positive' or 'ok' or 'approve' is clicked. Return 'false' to avoid closing the toast.
|
247 | */
|
248 | onApprove(this: JQuery): void;
|
249 |
|
250 | /**
|
251 | * Callback when an existing button with class 'negative' or 'cancel' or 'deny' is clicked. Return 'false' to avoid closing the toast.
|
252 | */
|
253 | onDeny(this: JQuery): void;
|
254 |
|
255 | // endregion
|
256 |
|
257 | // region Content Settings
|
258 |
|
259 | /**
|
260 | * A title for the toast. Leave empty to not display it.
|
261 | *
|
262 | * @default ''
|
263 | */
|
264 | title: string;
|
265 |
|
266 | /**
|
267 | * Message to display.
|
268 | *
|
269 | * @default ''
|
270 | */
|
271 | message: string;
|
272 |
|
273 | /**
|
274 | * An array of objects. Each object defines an action with 'properties' 'text', 'class', 'icon' and 'click'.
|
275 | */
|
276 | actions: Toast.ActionsSettings;
|
277 |
|
278 | // endregion
|
279 |
|
280 | // region DOM Settings
|
281 |
|
282 | /**
|
283 | * Event namespace. Makes sure module teardown does not effect other events attached to an element.
|
284 | * @default 'toast'
|
285 | */
|
286 | namespace: string;
|
287 |
|
288 | /**
|
289 | * DOM Selectors used internally.
|
290 | */
|
291 | selector: Toast.SelectorSettings;
|
292 |
|
293 | /**
|
294 | * Class names used to attach style to state.
|
295 | */
|
296 | className: Toast.ClassNameSettings;
|
297 |
|
298 | /**
|
299 | * Icon names used internally.
|
300 | */
|
301 | icons: Toast.IconSettings;
|
302 |
|
303 | // endregion
|
304 |
|
305 | // region Debug Settings
|
306 |
|
307 | /**
|
308 | * Name used in log statements
|
309 | * @default 'Toast'
|
310 | */
|
311 | name: string;
|
312 |
|
313 | /**
|
314 | * Silences all console output including error messages, regardless of other debug settings.
|
315 | * @default false
|
316 | */
|
317 | silent: boolean;
|
318 |
|
319 | /**
|
320 | * Debug output to console
|
321 | * @default false
|
322 | */
|
323 | debug: boolean;
|
324 |
|
325 | /**
|
326 | * Show console.table output with performance metrics
|
327 | * @default true
|
328 | */
|
329 | performance: boolean;
|
330 |
|
331 | /**
|
332 | * Debug output includes all internal behaviors
|
333 | * @default false
|
334 | */
|
335 | verbose: boolean;
|
336 |
|
337 | error: Toast.ErrorSettings;
|
338 |
|
339 | // endregion
|
340 | }
|
341 |
|
342 | namespace Toast {
|
343 | type TransitionSettings = Partial<Pick<Settings.Transition, keyof Settings.Transition>>;
|
344 | type ActionsSettings = Partial<Pick<Settings.Actions, keyof Settings.Actions>>;
|
345 | type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
|
346 | type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
|
347 | type IconSettings = Partial<Pick<Settings.Icons, keyof Settings.Icons>>;
|
348 | type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;
|
349 |
|
350 | namespace Settings {
|
351 | interface Transition {
|
352 | /**
|
353 | * @default 'scale'
|
354 | */
|
355 | showMethod: string;
|
356 |
|
357 | /**
|
358 | * @default 500
|
359 | */
|
360 | showDuration: number;
|
361 |
|
362 | /**
|
363 | * @default 'scale'
|
364 | */
|
365 | hideMethod: string;
|
366 |
|
367 | /**
|
368 | * @default 500
|
369 | */
|
370 | hideDuration: number;
|
371 |
|
372 | /**
|
373 | * @default 'closeEasing'
|
374 | */
|
375 | closeEasing: string;
|
376 | }
|
377 |
|
378 | interface Actions {
|
379 | /**
|
380 | * @default 'Wait'
|
381 | */
|
382 | text: string;
|
383 |
|
384 | /**
|
385 | * @default 'red'
|
386 | */
|
387 | class: string;
|
388 |
|
389 | /**
|
390 | * @default 'exclamation'
|
391 | */
|
392 | icon: string;
|
393 |
|
394 | /**
|
395 | * @default function() {}
|
396 | */
|
397 | click: () => void;
|
398 | }
|
399 |
|
400 | interface Selectors {
|
401 | /**
|
402 | * @default '.ui.toast-container'
|
403 | */
|
404 | container: string;
|
405 |
|
406 | /**
|
407 | * @default '.toast-box'
|
408 | */
|
409 | box: string;
|
410 |
|
411 | /**
|
412 | * @default '.ui.toast'
|
413 | */
|
414 | toast: string;
|
415 |
|
416 | /**
|
417 | * @default 'input:not([type="hidden"]), textarea, select, button, .ui.button, ui.dropdown'
|
418 | */
|
419 | input: string;
|
420 |
|
421 | /**
|
422 | * @default '.actions .positive, .actions .approve, .actions .ok'
|
423 | */
|
424 | approve: string;
|
425 |
|
426 | /**
|
427 | * @default '.actions .negative, .actions .deny, .actions .cancel'
|
428 | */
|
429 | deny: string;
|
430 | }
|
431 |
|
432 | interface ClassNames {
|
433 | /**
|
434 | * @default 'toast-container'
|
435 | */
|
436 | container: string;
|
437 |
|
438 | /**
|
439 | * @default 'toast-box'
|
440 | */
|
441 | box: string;
|
442 |
|
443 | /**
|
444 | * @default 'ui attached active progress'
|
445 | */
|
446 | progress: string;
|
447 |
|
448 | /**
|
449 | * @default 'ui toast'
|
450 | */
|
451 | toast: string;
|
452 |
|
453 | /**
|
454 | * @default 'icon'
|
455 | */
|
456 | icon: string;
|
457 |
|
458 | /**
|
459 | * @default 'visible'
|
460 | */
|
461 | visible: string;
|
462 |
|
463 | /**
|
464 | * @default 'content'
|
465 | */
|
466 | content: string;
|
467 |
|
468 | /**
|
469 | * @default 'header'
|
470 | */
|
471 | title: string;
|
472 | }
|
473 |
|
474 | interface Icons {
|
475 | /**
|
476 | * @default 'info'
|
477 | */
|
478 | info: string;
|
479 |
|
480 | /**
|
481 | * @default 'checkmark'
|
482 | */
|
483 | success: string;
|
484 |
|
485 | /**
|
486 | * @default 'warning'
|
487 | */
|
488 | warning: string;
|
489 |
|
490 | /**
|
491 | * @default 'times'
|
492 | */
|
493 | error: string;
|
494 | }
|
495 |
|
496 | interface Errors {
|
497 | /**
|
498 | * @default 'The method you called is not defined.'
|
499 | */
|
500 | method: string;
|
501 |
|
502 | /**
|
503 | * @default 'This module requires ui transitions.'
|
504 | */
|
505 | noElement: string;
|
506 |
|
507 | /**
|
508 | * @default 'Vertical but not attached actions are not supported for card layout.'
|
509 | */
|
510 | verticalCard: string;
|
511 | }
|
512 | }
|
513 | }
|
514 | }
|