1 | declare namespace FomanticUI {
|
2 | interface Sidebar {
|
3 | settings: SidebarSettings;
|
4 |
|
5 | /**
|
6 | * Attaches sidebar action to given selector.
|
7 | * Default event if none specified is 'toggle'.
|
8 | */
|
9 | (behavior: 'attach events', selector: string, event: string): JQuery;
|
10 |
|
11 | /**
|
12 | * Shows sidebar.
|
13 | */
|
14 | (behavior: 'show'): JQuery;
|
15 |
|
16 | /**
|
17 | * Hides sidebar.
|
18 | */
|
19 | (behavior: 'hide'): JQuery;
|
20 |
|
21 | /**
|
22 | * Toggles visibility of sidebar.
|
23 | */
|
24 | (behavior: 'toggle'): JQuery;
|
25 |
|
26 | /**
|
27 | * Returns whether sidebar is visible.
|
28 | */
|
29 | (behavior: 'is visible'): boolean;
|
30 |
|
31 | /**
|
32 | * Returns whether sidebar is hidden.
|
33 | */
|
34 | (behavior: 'is hidden'): boolean;
|
35 |
|
36 | /**
|
37 | * Pushes page content to be visible alongside sidebar.
|
38 | */
|
39 | (behavior: 'push page'): JQuery;
|
40 |
|
41 | /**
|
42 | * Returns direction of current sidebar.
|
43 | */
|
44 | (behavior: 'get direction'): string;
|
45 |
|
46 | /**
|
47 | * Returns page content to original position.
|
48 | */
|
49 | (behavior: 'pull page'): JQuery;
|
50 |
|
51 | /**
|
52 | * Adds stylesheet to page head to trigger sidebar animations.
|
53 | */
|
54 | (behavior: 'add body CSS'): JQuery;
|
55 |
|
56 | /**
|
57 | * Removes any inline stylesheets for sidebar animation.
|
58 | */
|
59 | (behavior: 'remove body CSS'): JQuery;
|
60 |
|
61 | /**
|
62 | * Returns vendor prefixed transition end event.
|
63 | */
|
64 | (behavior: 'get transition event'): string;
|
65 |
|
66 | /**
|
67 | * Destroys instance and removes all events.
|
68 | */
|
69 | (behavior: 'destroy'): JQuery;
|
70 |
|
71 | <K extends keyof SidebarSettings>(behavior: 'setting', name: K, value?: undefined, ): Partial<Pick<SidebarSettings, keyof SidebarSettings>>;
|
72 | <K extends keyof SidebarSettings>(behavior: 'setting', name: K, value: SidebarSettings[K]): JQuery;
|
73 | (behavior: 'setting', value: Partial<Pick<SidebarSettings, keyof SidebarSettings>>): JQuery;
|
74 | (settings?: Partial<Pick<SidebarSettings, keyof SidebarSettings>>): JQuery;
|
75 | }
|
76 |
|
77 | /**
|
78 | * @see {@link https://fomantic-ui.com/modules/sidebar.html#/settings}
|
79 | */
|
80 | interface SidebarSettings {
|
81 | // region Sidebar Settings
|
82 |
|
83 | /**
|
84 | * Context which sidebar will appear inside.
|
85 | * @default 'body'
|
86 | */
|
87 | context: string | JQuery;
|
88 |
|
89 | /**
|
90 | * Whether multiple sidebars can be open at once.
|
91 | * @default false
|
92 | */
|
93 | exclusive: boolean;
|
94 |
|
95 | /**
|
96 | * Whether sidebar can be closed by clicking on page.
|
97 | * @default true
|
98 | */
|
99 | closable: boolean;
|
100 |
|
101 | /**
|
102 | * Whether to dim page contents when sidebar is visible.
|
103 | * @default true
|
104 | */
|
105 | dimPage: boolean;
|
106 |
|
107 | /**
|
108 | * Whether dimmer should blur background.
|
109 | * @default false
|
110 | */
|
111 | blurring: boolean;
|
112 |
|
113 | /**
|
114 | * Whether to lock page scroll when sidebar is visible.
|
115 | * @default false
|
116 | */
|
117 | scrollLock: boolean;
|
118 |
|
119 | /**
|
120 | * Whether to return to original scroll position when sidebar is hidden, automatically occurs with 'transition: scale'.
|
121 | * @default false
|
122 | */
|
123 | returnScroll: boolean;
|
124 |
|
125 | /**
|
126 | * When sidebar is initialized without the proper HTML, using this option will defer creation of DOM to use 'requestAnimationFrame'.
|
127 | * @default false
|
128 | */
|
129 | delaySetup: boolean;
|
130 |
|
131 | // endregion
|
132 |
|
133 | // region Animation Settings
|
134 |
|
135 | /**
|
136 | * Named transition to use when animating sidebar.
|
137 | * Defaults to 'auto' which selects transition from 'defaultTransition' based on direction.
|
138 | * @default 'auto'
|
139 | */
|
140 | transition: string;
|
141 |
|
142 | /**
|
143 | * Named transition to use when animating when detecting mobile device.
|
144 | * Defaults to 'auto' which selects transition from 'defaultTransition' based on direction.
|
145 | * @default 'auto'
|
146 | */
|
147 | mobileTransition: string;
|
148 |
|
149 | /**
|
150 | * Default transitions for each direction and screen size, used with 'transition: auto'.
|
151 | * @default {}
|
152 | */
|
153 | defaultTransition: object;
|
154 |
|
155 | // endregion
|
156 |
|
157 | // region Callbacks
|
158 |
|
159 | /**
|
160 | * Is called when a sidebar has finished animating in.
|
161 | */
|
162 | onVisible(this: JQuery): void;
|
163 |
|
164 | /**
|
165 | * Is called when a sidebar begins animating in.
|
166 | * Returning 'false' from this callback will cancel the sidebar from showing.
|
167 | */
|
168 | onShow(this: JQuery): boolean;
|
169 |
|
170 | /**
|
171 | * Is called when a sidebar begins to hide or show.
|
172 | */
|
173 | onChange(this: JQuery): void;
|
174 |
|
175 | /**
|
176 | * Is called before a sidebar begins to animate out.
|
177 | * Returning 'false' from this callback will cancel the sidebar from hiding.
|
178 | */
|
179 | onHide(this: JQuery): boolean;
|
180 |
|
181 | /**
|
182 | * Is called after a sidebar has finished animating out.
|
183 | */
|
184 | onHidden(this: JQuery): void;
|
185 |
|
186 | // endregion
|
187 |
|
188 | // region DOM Settings
|
189 |
|
190 | /**
|
191 | * DOM Selectors used internally.
|
192 | * Selectors used to find parts of a module.
|
193 | */
|
194 | selector: Sidebar.SelectorSettings;
|
195 |
|
196 | /**
|
197 | * Regular expressions used in the module.
|
198 | */
|
199 | regExp: Sidebar.RegExpSettings;
|
200 |
|
201 | /**
|
202 | * Class names used to determine element state.
|
203 | */
|
204 | className: Sidebar.ClassNameSettings;
|
205 |
|
206 | // endregion
|
207 |
|
208 | // region Debug Settings
|
209 |
|
210 | /**
|
211 | * Name used in log statements
|
212 | * @default 'Sidebar'
|
213 | */
|
214 | name: string;
|
215 |
|
216 | /**
|
217 | * Event namespace. Makes sure module teardown does not effect other events attached to an element.
|
218 | * @default 'sidebar'
|
219 | */
|
220 | namespace: string;
|
221 |
|
222 | /**
|
223 | * Silences all console output including error messages, regardless of other debug settings.
|
224 | * @default false
|
225 | */
|
226 | silent: boolean;
|
227 |
|
228 | /**
|
229 | * Debug output to console
|
230 | * @default false
|
231 | */
|
232 | debug: boolean;
|
233 |
|
234 | /**
|
235 | * Show console.table output with performance metrics
|
236 | * @default true
|
237 | */
|
238 | performance: boolean;
|
239 |
|
240 | /**
|
241 | * Debug output includes all internal behaviors
|
242 | * @default false
|
243 | */
|
244 | verbose: boolean;
|
245 |
|
246 | error: Sidebar.ErrorSettings;
|
247 |
|
248 | // endregion
|
249 | }
|
250 |
|
251 | namespace Sidebar {
|
252 | type SelectorSettings = Partial<Pick<Settings.Selectors, keyof Settings.Selectors>>;
|
253 | type RegExpSettings = Partial<Pick<Settings.RegExps, keyof Settings.RegExps>>;
|
254 | type ClassNameSettings = Partial<Pick<Settings.ClassNames, keyof Settings.ClassNames>>;
|
255 | type ErrorSettings = Partial<Pick<Settings.Errors, keyof Settings.Errors>>;
|
256 |
|
257 | namespace Settings {
|
258 | interface Selectors {
|
259 | /**
|
260 | * @default '> .ui.fixed.menu, > .ui.right.toast-container, > .ui.right.sidebar, > .ui.fixed.nag, > .ui.fixed.nag > .close'
|
261 | */
|
262 | bodyFixed: string;
|
263 |
|
264 | /**
|
265 | * @default '.fixed'
|
266 | */
|
267 | fixed: string;
|
268 |
|
269 | /**
|
270 | * @default 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed'
|
271 | */
|
272 | omitted: string;
|
273 |
|
274 | /**
|
275 | * @default '.pusher'
|
276 | */
|
277 | pusher: string;
|
278 |
|
279 | /**
|
280 | * @default '.ui.sidebar'
|
281 | */
|
282 | sidebar: string;
|
283 | }
|
284 |
|
285 | interface RegExps {
|
286 | /**
|
287 | * @default /(iPad|iPhone|iPod)/g
|
288 | */
|
289 | ios: RegExp;
|
290 |
|
291 | /**
|
292 | * @default /(CriOS)/g
|
293 | */
|
294 | mobileChrome: RegExp;
|
295 |
|
296 | /**
|
297 | * @default /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g
|
298 | */
|
299 | mobile: RegExp;
|
300 | }
|
301 |
|
302 | interface ClassNames {
|
303 | /**
|
304 | * @default 'active'
|
305 | */
|
306 | active: string;
|
307 |
|
308 | /**
|
309 | * @default 'animating'
|
310 | */
|
311 | animating: string;
|
312 |
|
313 | /**
|
314 | * @default 'blurring'
|
315 | */
|
316 | blurring: string;
|
317 |
|
318 | /**
|
319 | * @default 'closing'
|
320 | */
|
321 | closing: string;
|
322 |
|
323 | /**
|
324 | * @default 'dimmed'
|
325 | */
|
326 | dimmed: string;
|
327 |
|
328 | /**
|
329 | * @default 'ios'
|
330 | */
|
331 | ios: string;
|
332 |
|
333 | /**
|
334 | * @default 'locked'
|
335 | */
|
336 | locked: string;
|
337 |
|
338 | /**
|
339 | * @default 'pushable'
|
340 | */
|
341 | pushable: string;
|
342 |
|
343 | /**
|
344 | * @default 'pushed'
|
345 | */
|
346 | pushed: string;
|
347 |
|
348 | /**
|
349 | * @default 'right'
|
350 | */
|
351 | right: string;
|
352 |
|
353 | /**
|
354 | * @default 'top'
|
355 | */
|
356 | top: string;
|
357 |
|
358 | /**
|
359 | * @default 'left'
|
360 | */
|
361 | left: string;
|
362 |
|
363 | /**
|
364 | * @default 'bottom'
|
365 | */
|
366 | bottom: string;
|
367 |
|
368 | /**
|
369 | * @default 'visible'
|
370 | */
|
371 | visible: string;
|
372 | }
|
373 |
|
374 | interface Errors {
|
375 | /**
|
376 | * @default 'The method you called is not defined.'
|
377 | */
|
378 | method: string;
|
379 |
|
380 | /**
|
381 | * @default 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element'
|
382 | */
|
383 | pusher: string;
|
384 |
|
385 | /**
|
386 | * @default 'Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag'
|
387 | */
|
388 | movedSidebar: string;
|
389 |
|
390 | /**
|
391 | * @default 'The overlay setting is no longer supported, use animation: overlay'
|
392 | */
|
393 | overlay: string;
|
394 |
|
395 | /**
|
396 | * @default 'There were no elements that matched the specified selector'
|
397 | */
|
398 | notFound: string;
|
399 | }
|
400 | }
|
401 | }
|
402 | }
|