1 | declare namespace FomanticUI {
|
2 | interface Modal {
|
3 | settings: ModalSettings;
|
4 |
|
5 | /**
|
6 | * Shows the modal.
|
7 | */
|
8 | (behavior: 'show'): JQuery;
|
9 |
|
10 | /**
|
11 | * Hides the modal.
|
12 | */
|
13 | (behavior: 'hide'): JQuery;
|
14 |
|
15 | /**
|
16 | * Toggles the modal.
|
17 | */
|
18 | (behavior: 'toggle'): JQuery;
|
19 |
|
20 | /**
|
21 | * Refreshes centering of modal on page.
|
22 | */
|
23 | (behavior: 'refresh'): JQuery;
|
24 |
|
25 | /**
|
26 | * Shows associated page dimmer.
|
27 | */
|
28 | (behavior: 'show dimmer'): JQuery;
|
29 |
|
30 | /**
|
31 | * Hides associated page dimmer.
|
32 | */
|
33 | (behavior: 'hide dimmer'): JQuery;
|
34 |
|
35 | /**
|
36 | * Hides all modals not selected modal in a dimmer.
|
37 | */
|
38 | (behavior: 'hide others'): JQuery;
|
39 |
|
40 | /**
|
41 | * Hides all visible modals in the same dimmer.
|
42 | */
|
43 | (behavior: 'hide all'): JQuery;
|
44 |
|
45 | /**
|
46 | * Caches current modal size.
|
47 | */
|
48 | (behavior: 'cache sizes'): JQuery;
|
49 |
|
50 | /**
|
51 | * Returns whether the modal can fit on the page.
|
52 | */
|
53 | (behavior: 'can fit'): boolean;
|
54 |
|
55 | /**
|
56 | * Returns whether the modal is active.
|
57 | */
|
58 | (behavior: 'is active'): boolean;
|
59 |
|
60 | /**
|
61 | * Sets modal to active.
|
62 | */
|
63 | (behavior: 'set active'): JQuery;
|
64 |
|
65 | (behavior: 'destroy'): JQuery;
|
66 | <K extends keyof ModalSettings>(behavior: 'setting', name: K, value?: undefined, ): Partial<Pick<ModalSettings, keyof ModalSettings>>;
|
67 | <K extends keyof ModalSettings>(behavior: 'setting', name: K, value: ModalSettings[K]): JQuery;
|
68 | (behavior: 'setting', value: Partial<Pick<ModalSettings, keyof ModalSettings>>): JQuery;
|
69 | (settings?: Partial<Pick<ModalSettings, keyof ModalSettings>>): JQuery;
|
70 | }
|
71 |
|
72 | /**
|
73 | * @see {@link https://fomantic-ui.com/modules/modal.html#/settings}
|
74 | */
|
75 | interface ModalSettings {
|
76 | // region Accordion Settings
|
77 |
|
78 | /**
|
79 | * If set to 'false' will prevent the modal from being moved to inside the dimmer.
|
80 | * @default true
|
81 | */
|
82 | detachable: boolean;
|
83 |
|
84 | /**
|
85 | * Auto will automatically use flex in browsers that support absolutely positioned elements inside flex containers.
|
86 | * Setting to 'true'/'false' will force this setting for all browsers.
|
87 | * @default 'auto'
|
88 | */
|
89 | useFlex: 'auto' | boolean;
|
90 |
|
91 | /**
|
92 | * When 'true', the first form input inside the modal will receive focus when shown.
|
93 | * Set this to 'false' to prevent this behavior.
|
94 | * @default true
|
95 | */
|
96 | autofocus: boolean;
|
97 |
|
98 | /**
|
99 | * When 'false', the last focused element, before the modal was shown, will not get refocused again when the modal hides.
|
100 | * This could prevent unwanted scrolling behaviors after closing a modal.
|
101 | * @default true
|
102 | */
|
103 | restoreFocus: boolean;
|
104 |
|
105 | /**
|
106 | * When 'true', immediately shows the modal at instantiation time.
|
107 | * @default false
|
108 | */
|
109 | autoShow: boolean;
|
110 |
|
111 | /**
|
112 | * Whether any change in modal DOM should automatically refresh cached positions.
|
113 | * @default false
|
114 | */
|
115 | observeChanges: boolean;
|
116 |
|
117 | /**
|
118 | * If set to 'true' will not close other visible modals when opening a new one.
|
119 | * @default false
|
120 | */
|
121 | allowMultiple: boolean;
|
122 |
|
123 | /**
|
124 | * If inverted dimmer should be used.
|
125 | * @default false
|
126 | */
|
127 | inverted: boolean;
|
128 |
|
129 | /**
|
130 | * If dimmer should blur background.
|
131 | * @default false
|
132 | */
|
133 | blurring: boolean;
|
134 |
|
135 | /**
|
136 | * If modal should be center aligned.
|
137 | * @default true
|
138 | */
|
139 | centered: boolean;
|
140 |
|
141 | /**
|
142 | * Whether to automatically bind keyboard shortcuts.
|
143 | * This will close the modal when the 'ESC-Key' is pressed.
|
144 | * @default true
|
145 | */
|
146 | keyboardShortcuts: boolean;
|
147 |
|
148 | /**
|
149 | * A vertical offset to allow for content outside of modal, for example a close button, to be centered.
|
150 | * @default 0
|
151 | */
|
152 | offset: number;
|
153 |
|
154 | /**
|
155 | * Selector or jquery object specifying the area to dim.
|
156 | * @default 'body'
|
157 | */
|
158 | context: string | JQuery;
|
159 |
|
160 | /**
|
161 | * Setting to 'false' will not allow you to close the modal by clicking on the dimmer.
|
162 | * @default true
|
163 | */
|
164 | closable: boolean;
|
165 |
|
166 | /**
|
167 | * Custom settings to extend UI dimmer.
|
168 | */
|
169 | dimmerSettings: DimmerSettings;
|
170 |
|
171 | /**
|
172 | * Custom settings to extend UI dimmer.
|
173 | * @default 'scale'
|
174 | */
|
175 | transition: string | TransitionSettings;
|
176 |
|
177 | /**
|
178 | * Duration of animation.
|
179 | * The value will be ignored when individual hide/show duration values are provided via the 'transition' setting.
|
180 | * @default 400
|
181 | */
|
182 | duration: number;
|
183 |
|
184 | /**
|
185 | * Whether additional animations should queue.
|
186 | * @default false
|
187 | */
|
188 | queue: boolean;
|
189 |
|
190 | /**
|
191 | * Used internally to determine if the webkit custom scrollbar was clicked to prevent hiding the dimmer.
|
192 | * This should be set to the same (numeric) value as defined for '@customScrollbarWidth' in 'site.less' in case you are using a different theme.
|
193 | * @default 10
|
194 | */
|
195 | scrollbarWidth: number;
|
196 |
|
197 | // endregion
|
198 |
|
199 | // region Callbacks
|
200 |
|
201 | /**
|
202 | * Is called when a modal starts to show.
|
203 | * If the function returns 'false', the modal will not be shown.
|
204 | */
|
205 | onShow(this: JQuery): void;
|
206 |
|
207 | /**
|
208 | * Is called after a modal has finished showing animating.
|
209 | */
|
210 | onVisible(this: JQuery): void;
|
211 |
|
212 | /**
|
213 | * Is called after a modal starts to hide.
|
214 | * If the function returns 'false', the modal will not hide.
|
215 | */
|
216 | onHide(this: JQuery, $element: JQuery): void;
|
217 |
|
218 | /**
|
219 | * Is called after a modal has finished hiding animation.
|
220 | */
|
221 | onHidden(this: JQuery): void;
|
222 |
|
223 | /**
|
224 | * Is called after a positive, approve or ok button is pressed.
|
225 | * If the function returns 'false', the modal will not hide.
|
226 | */
|
227 | onApprove(this: JQuery, $element: JQuery): void;
|
228 |
|
229 | /**
|
230 | * Is called after a negative, deny or cancel button is pressed. If the function returns 'false' the modal will not hide.
|
231 | */
|
232 | onDeny(this: JQuery, $element: JQuery): void;
|
233 |
|
234 | // endregion
|
235 |
|
236 | // region DOM Settings
|
237 |
|
238 | /**
|
239 | * DOM Selectors used internally.
|
240 | * Selectors used to find parts of a module.
|
241 | */
|
242 | selector: Modal.SelectorSettings;
|
243 |
|
244 | /**
|
245 | * Class names used to determine element state.
|
246 | */
|
247 | className: Modal.ClassNameSettings;
|
248 |
|
249 | // endregion
|
250 |
|
251 | // region Config Template Settings
|
252 |
|
253 | // endregion
|
254 |
|
255 | // region Debug Settings
|
256 |
|
257 | /**
|
258 | * Name used in log statements
|
259 | * @default 'Modal'
|
260 | */
|
261 | name: string;
|
262 |
|
263 | /**
|
264 | * Event namespace. Makes sure module teardown does not effect other events attached to an element.
|
265 | * @default 'modal'
|
266 | */
|
267 | namespace: string;
|
268 |
|
269 | /**
|
270 | * Silences all console output including error messages, regardless of other debug settings.
|
271 | * @default false
|
272 | */
|
273 | silent: boolean;
|
274 |
|
275 | /**
|
276 | * Debug output to console
|
277 | * @default false
|
278 | */
|
279 | debug: boolean;
|
280 |
|
281 | /**
|
282 | * Show console.table output with performance metrics
|
283 | * @default true
|
284 | */
|
285 | performance: boolean;
|
286 |
|
287 | /**
|
288 | * Debug output includes all internal behaviors
|
289 | * @default false
|
290 | */
|
291 | verbose: boolean;
|
292 |
|
293 | error: Modal.ErrorSettings;
|
294 |
|
295 | // endregion
|
296 | }
|
297 |
|
298 | namespace Modal {
|
299 | type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
|
300 | type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
|
301 | type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;
|
302 |
|
303 | namespace Settings {
|
304 | interface Selectors {
|
305 | /**
|
306 | * @default '> .header'
|
307 | */
|
308 | title: string;
|
309 |
|
310 | /**
|
311 | * @default '> .content'
|
312 | */
|
313 | content: string;
|
314 |
|
315 | /**
|
316 | * @default '> .actions'
|
317 | */
|
318 | actions: string;
|
319 |
|
320 | /**
|
321 | * @default '> .close'
|
322 | */
|
323 | close: string;
|
324 |
|
325 | /**
|
326 | * @default '.actions .positive, .actions .approve, .actions .ok'
|
327 | */
|
328 | approve: string;
|
329 |
|
330 | /**
|
331 | * @default '.actions .negative, .actions .deny, .actions .cancel'
|
332 | */
|
333 | deny: string;
|
334 |
|
335 | /**
|
336 | * @default '> .ui.dimmer'
|
337 | */
|
338 | dimmer: string;
|
339 |
|
340 | /**
|
341 | * @default '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close'
|
342 | */
|
343 | bodyFixed: string;
|
344 |
|
345 | /**
|
346 | * @default '.ui.input > input'
|
347 | */
|
348 | prompt: string;
|
349 | }
|
350 |
|
351 | interface ClassNames {
|
352 | /**
|
353 | * @default 'active'
|
354 | */
|
355 | active: string;
|
356 |
|
357 | /**
|
358 | * @default 'animating'
|
359 | */
|
360 | animating: string;
|
361 |
|
362 | /**
|
363 | * @default 'blurring'
|
364 | */
|
365 | blurring: string;
|
366 |
|
367 | /**
|
368 | * @default 'inverted'
|
369 | */
|
370 | inverted: string;
|
371 |
|
372 | /**
|
373 | * @default 'legacy'
|
374 | */
|
375 | legacy: string;
|
376 |
|
377 | /**
|
378 | * @default 'loading'
|
379 | */
|
380 | loading: string;
|
381 |
|
382 | /**
|
383 | * @default 'scrolling'
|
384 | */
|
385 | scrolling: string;
|
386 |
|
387 | /**
|
388 | * @default 'undetached'
|
389 | */
|
390 | undetached: string;
|
391 |
|
392 | /**
|
393 | * @default 'front'
|
394 | */
|
395 | front: string;
|
396 |
|
397 | /**
|
398 | * @default 'close icon'
|
399 | */
|
400 | close: string;
|
401 |
|
402 | /**
|
403 | * @default 'ui button'
|
404 | */
|
405 | button: string;
|
406 |
|
407 | /**
|
408 | * @default 'ui modal'
|
409 | */
|
410 | modal: string;
|
411 |
|
412 | /**
|
413 | * @default 'header'
|
414 | */
|
415 | title: string;
|
416 |
|
417 | /**
|
418 | * @default 'content'
|
419 | */
|
420 | content: string;
|
421 |
|
422 | /**
|
423 | * @default 'actions'
|
424 | */
|
425 | actions: string;
|
426 |
|
427 | /**
|
428 | * @default 'ui tiny modal'
|
429 | */
|
430 | template: string;
|
431 |
|
432 | /**
|
433 | * @default 'positive'
|
434 | */
|
435 | ok: string;
|
436 |
|
437 | /**
|
438 | * @default 'negative'
|
439 | */
|
440 | cancel: string;
|
441 |
|
442 | /**
|
443 | * @default 'ui fluid input'
|
444 | */
|
445 | prompt: string;
|
446 |
|
447 | /**
|
448 | * @default 'ui inverted dimmer'
|
449 | */
|
450 | innerDimmer: string;
|
451 | }
|
452 |
|
453 | interface Errors {
|
454 | /**
|
455 | * @default 'UI Dimmer, a required component is not included in this page'
|
456 | */
|
457 | dimmer: string;
|
458 |
|
459 | /**
|
460 | * @default 'The method you called is not defined.'
|
461 | */
|
462 | method: string;
|
463 |
|
464 | /**
|
465 | * @default 'The element you specified could not be found'
|
466 | */
|
467 | notFound: string;
|
468 | }
|
469 | }
|
470 | }
|
471 | }
|