UNPKG

10.7 kBTypeScriptView Raw
1declare namespace FomanticUI {
2 interface Dimmer {
3 settings: DimmerSettings;
4
5 /**
6 * Detaches a given element from DOM and reattaches element inside dimmer.
7 */
8 (behavior: 'add content', element: string | JQuery): JQuery;
9
10 /**
11 * Shows dimmer.
12 */
13 (behavior: 'show'): JQuery;
14
15 /**
16 * Hides dimmer.
17 */
18 (behavior: 'hide'): JQuery;
19
20 /**
21 * Toggles current dimmer visibility.
22 */
23 (behavior: 'toggle'): JQuery;
24
25 /**
26 * Changes dimmer opacity.
27 */
28 (behavior: 'set opacity', opacity: number): JQuery;
29
30 /**
31 * Creates a new dimmer in dimmable context.
32 */
33 (behavior: 'create'): JQuery;
34
35 /**
36 * Returns current duration for show or hide event depending on current visibility.
37 */
38 (behavior: 'get duration'): number;
39
40 /**
41 * Returns DOM element for dimmer.
42 */
43 (behavior: 'get dimmer'): JQuery;
44
45 /**
46 * Returns whether current dimmable has a dimmer.
47 */
48 (behavior: 'has dimmer'): boolean;
49
50 /**
51 * Whether section's dimmer is active.
52 */
53 (behavior: 'is active'): boolean;
54
55 /**
56 * Whether dimmer is animating.
57 */
58 (behavior: 'is animating'): boolean;
59
60 /**
61 * Whether current element is a dimmer.
62 */
63 (behavior: 'is dimmer'): boolean;
64
65 /**
66 * Whether current element is a dimmable section.
67 */
68 (behavior: 'is dimmable'): boolean;
69
70 /**
71 * Whether dimmer is disabled.
72 */
73 (behavior: 'is disabled'): boolean;
74
75 /**
76 * Whether dimmer is not disabled.
77 */
78 (behavior: 'is enabled'): boolean;
79
80 /**
81 * Whether dimmable section is 'body'.
82 */
83 (behavior: 'is page'): boolean;
84
85 /**
86 * Whether dimmer is a page dimmer.
87 */
88 (behavior: 'is page dimmer'): boolean;
89
90 /**
91 * Sets page dimmer to active.
92 */
93 (behavior: 'set active'): JQuery;
94
95 /**
96 * Sets an element as a dimmable section.
97 */
98 (behavior: 'set dimmable'): JQuery;
99
100 /**
101 * Sets a dimmable section as dimmed.
102 */
103 (behavior: 'set dimmed'): JQuery;
104
105 /**
106 * Sets current dimmer as a page dimmer.
107 */
108 (behavior: 'set page dimmer'): JQuery;
109
110 /**
111 * Sets a dimmer as disabled.
112 */
113 (behavior: 'set disabled'): JQuery;
114
115 (behavior: 'destroy'): JQuery;
116 <K extends keyof DimmerSettings>(behavior: 'setting', name: K, value?: undefined, ): Partial<Pick<DimmerSettings, keyof DimmerSettings>>;
117 <K extends keyof DimmerSettings>(behavior: 'setting', name: K, value: DimmerSettings[K]): JQuery;
118 (behavior: 'setting', value: Partial<Pick<DimmerSettings, keyof DimmerSettings>>): JQuery;
119 (settings?: Partial<Pick<DimmerSettings, keyof DimmerSettings>>): JQuery;
120 }
121
122 /**
123 * @see {@link https://fomantic-ui.com/modules/dimmer.html#/settings}
124 */
125
126 interface DimmerSettings {
127 // region Dimmer Settings
128
129 /**
130 * Whether dimmers should use flex or legacy positioning.
131 * @default true
132 */
133 useFlex: boolean;
134
135 /**
136 * If initializing a dimmer on a 'dimmable' context, you can use 'dimmerName' to distinguish between multiple dimmers in that context.
137 * @default false
138 */
139 dimmerName: string | boolean;
140
141 /**
142 * Specify a variation to add when generating dimmer, like 'inverted'.
143 * @default false
144 */
145 variation: string | boolean;
146
147 /**
148 * Whether clicking on the dimmer should hide the dimmer (Defaults to 'auto', closable only when 'settings.on' is not 'hover').
149 * @default 'auto'
150 */
151 closable: 'auto' | boolean;
152
153 /**
154 * Whether to dim dimmers using CSS transitions.
155 * @default true
156 */
157 useCSS: boolean;
158
159 /**
160 * Named transition to use when animating menu in and out. Fade and slide down are available without including ui transitions.
161 * Alternatively you can provide an object to set individual values for hide/show transitions as well as hide/show duration
162 * @default 'fade'
163 */
164 transition: string | Dimmer.TransitionSettings;
165
166 /**
167 * Can be set to 'hover' or 'click' to show/hide dimmer on dimmable event.
168 * @default false
169 */
170 on: false | 'hover' | 'click';
171
172 /**
173 * Override the default opacity of the dimmer.
174 * @default 'auto'
175 */
176 opacity: 'auto' | number;
177
178 /**
179 * Animation duration of dimming. If an integer is used, that value will apply to both show and hide animations.
180 * Will be ignored completely when individual hide/show duration values are provided via the 'transition' setting.
181 */
182 duration: number | Dimmer.DurationSettings;
183
184 /**
185 * Whether a custom loader should be generated inside the dimmer.
186 * @default false
187 */
188 displayLoader: boolean;
189
190 /**
191 * Additional css classes to style the loader.
192 * @see {@link https://fomantic-ui.com/elements/loader.html}
193 * @default ''
194 */
195 loaderVariation: string;
196
197 /**
198 * If a string is given, it will be shown underneath the loader animation icon.
199 * @default false
200 */
201 loaderText: false | string;
202
203 // endregion
204
205 // region Callbacks
206
207 /**
208 * Callback on element show or hide.
209 */
210 onChange(this: JQuery): void;
211
212 /**
213 * Callback on element show.
214 */
215 onShow(this: JQuery): void;
216
217 /**
218 * Callback on element hide.
219 */
220 onHide(this: JQuery): void;
221
222 /**
223 * Callback after element is visible.
224 */
225 onVisible(this: JQuery): void;
226
227 /**
228 * Callback after element is hidden.
229 */
230 onHidden(this: JQuery): void;
231
232 // endregion
233
234 // region DOM Settings
235
236 /**
237 * Selectors used to find parts of a module.
238 */
239 selector: Dimmer.SelectorSettings;
240
241 /**
242 * Class names used to determine element state.
243 */
244 className: Dimmer.ClassNameSettings;
245
246 /**
247 * Templates used to generate dimmer content.
248 */
249 template: Dimmer.TemplateSettings;
250
251 // endregion
252
253 // region Debug Settings
254
255 /**
256 * Name used in log statements
257 * @default 'Dimmer'
258 */
259 name: string;
260
261 /**
262 * Event namespace. Makes sure module teardown does not effect other events attached to an element.
263 * @default 'dimmer'
264 */
265 namespace: string;
266
267 /**
268 * Silences all console output including error messages, regardless of other debug settings.
269 * @default false
270 */
271 silent: boolean;
272
273 /**
274 * Debug output to console
275 * @default false
276 */
277 debug: boolean;
278
279 /**
280 * Show console.table output with performance metrics
281 * @default true
282 */
283 performance: boolean;
284
285 /**
286 * Debug output includes all internal behaviors
287 * @default false
288 */
289 verbose: boolean;
290
291 error: Dimmer.ErrorSettings;
292
293 // endregion
294 }
295
296 namespace Dimmer {
297 type DurationSettings = Partial<Pick<Settings.Durations, keyof Settings.Durations>>;
298 type TransitionSettings = Partial<Pick<Settings.Transition, keyof Settings.Transition>>;
299 type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
300 type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
301 type TemplateSettings = Partial<Pick<Settings.Templates, keyof Settings.Templates>>;
302 type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;
303
304 namespace Settings {
305 interface Durations {
306 /**
307 * @default 500
308 */
309 show: number;
310
311 /**
312 * @default 500
313 */
314 hide: number;
315 }
316
317 interface Transition {
318 /**
319 * @default 'fade'
320 */
321 showMethod: string;
322
323 /**
324 * @default 200
325 */
326 showDuration: number;
327
328 /**
329 * @default 'zoom'
330 */
331 hideMethod: string;
332
333 /**
334 * @default 500
335 */
336 hideDuration: number;
337 }
338
339 interface Selectors {
340 /**
341 * @default '> .ui.dimmer'
342 */
343 dimmer: string;
344
345 /**
346 * @default '.ui.dimmer > .content, .ui.dimmer > .content > .center'
347 */
348 content: string;
349 }
350
351 interface ClassNames {
352 /**
353 * @default 'active'
354 */
355 active: string;
356
357 /**
358 * @default 'dimmable'
359 */
360 dimmable: string;
361
362 /**
363 * @default 'dimmed'
364 */
365 dimmed: string;
366
367 /**
368 * @default 'disabled'
369 */
370 disabled: string;
371
372 /**
373 * @default 'page'
374 */
375 pageDimmer: string;
376
377 /**
378 * @default 'hide'
379 */
380 hide: string;
381
382 /**
383 * @default 'show'
384 */
385 show: string;
386
387 /**
388 * @default 'transition'
389 */
390 transition: string;
391 }
392
393 interface Templates {
394 /**
395 * Used to generate dimmer content.
396 */
397 dimmer: JQuery;
398 }
399
400 interface Errors {
401 /**
402 * @default 'The method you called is not defined.'
403 */
404 method: string;
405 }
406 }
407 }
408}