UNPKG

49.4 kBTypeScriptView Raw
1// Type definitions for Onsen UI 2
2// Project: https://onsen.io/
3// Definitions by: Fran Dios <https://github.com/frandiox/>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/*~ If this module is a UMD module that exposes a global variable 'ons' when
7 *~ loaded outside a module loader environment, declare that global here.
8 *~ Otherwise, delete this declaration.
9 */
10export as namespace ons;
11
12/*~ This declaration specifies that the namespace
13 *~ is the exported object from the file
14 */
15export = ons;
16
17/**
18 * @description A global object that's used in Onsen UI. This object can be reached from the AngularJS scope
19 */
20declare namespace ons {
21
22 /**
23 * @return {Boolean} Will be true if Onsen UI is initialized
24 * @description Returns true if Onsen UI is initialized
25 */
26 function isReady(): boolean;
27 /**
28 * @return {Boolean} Will be true if the app is running in Cordova
29 * @description Returns true if running inside Cordova
30 */
31 function isWebView(): boolean;
32 /**
33 * @description Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized
34 * @param {Function} callback Function that executes after Onsen UI has been initialized
35 */
36 function ready(callback: Function): void;
37 /**
38 * @param {Function} listener Function that executes when device back button is pressed
39 * @description Set default handler for device back button
40 */
41 function setDefaultDeviceBackButtonListener(listener: (eventObject: any) => any): void;
42 /**
43 * @description Disable device back button event handler
44 */
45 function disableDeviceBackButtonHandler(): void;
46 /**
47 * @description Enable device back button event handler
48 */
49 function enableDeviceBackButtonHandler(): void;
50 /**
51 * @description Enable status bar fill feature on iOS7 and above (except for iPhone X)
52 */
53 function enableAutoStatusBarFill(): void;
54 /**
55 * @description Disable status bar fill feature on iOS7 and above (except for iPhone X)
56 */
57 function disableAutoStatusBarFill(): void;
58 /**
59 * @description Creates a static element similar to iOS status bar. Only useful for browser testing
60 */
61 function mockStatusBar(): void;
62 /**
63 * @description Disable all animations. Could be handy for testing and older devices.
64 */
65 function disableAnimations(): void;
66 /**
67 * @description Enable animations (default).
68 */
69 function enableAnimations(): void;
70 /**
71 * @description Disable automatic styling.
72 */
73 function disableAutoStyling(): void;
74 /**
75 * @description Enable automatic styling based on OS (default).
76 */
77 function enableAutoStyling(): void;
78 /**
79 * @description Disable adding `fa-` prefix automatically to `ons-icon` classes. Useful when including custom icon packs.
80 */
81 function disableIconAutoPrefix(): void;
82 /**
83 * @description Refresh styling for the given platform. Only useful for demos. Use `ons.platform.select(...)` for development and production.
84 */
85 function forcePlatformStyling(platform: string): void;
86 /**
87 * @description Access the last created page from the current `script` scope. Only works inside `<script></script>` tags that are direct children of `ons-page` element. Use this to add lifecycle hooks to a page.
88 * @return Returns the corresponding page element.
89 */
90 function getScriptPage(): HTMLElement | null;
91 /**
92 * @description Separated files need to be requested on demand and this can slightly delay pushing new pages. This method requests and caches templates for later use.
93 * @return Promise that resolves when all the templates are cached.
94 */
95 function preload(...args: any[]): Promise<DocumentFragment[]>;
96 /**
97 * @description Create a new element from a template. Both inline HTML and external files are supported although the return value differs.
98 * @return If the provided template was an inline HTML string, it returns the new element. Otherwise, it returns a promise that resolves to the new element.
99 */
100 function createElement(...args: any[]): HTMLElement | Promise<HTMLElement>;
101 /**
102 * @description Create a popover instance from a template.
103 * @return Promise object that resolves to the popover component object.
104 */
105 function createPopover(page: string, options?: OnsOptions): Promise<HTMLElement>;
106 /**
107 * @description Create a dialog instance from a template.
108 * @return Promise object that resolves to the dialog component object.
109 */
110 function createDialog(page: string, options?: OnsOptions): Promise<HTMLElement>;
111 /**
112 * @description Create a alert dialog instance from a template.
113 * @return Promise object that resolves to the alert dialog component object.
114 */
115 function createAlertDialog(page: string, options?: OnsOptions): Promise<HTMLElement>;
116 /**
117 * @description Shows an instant Action Sheet and lets the user choose an action.
118 * @return Will resolve when the action sheet is closed. The resolve value is either the index of the tapped button or -1 when canceled.
119 */
120 function openActionSheet(...args: any[]): Promise<number>;
121 /**
122 * @description If no page is defined for the `ons-loading-placeholder` attribute it will wait for this method being called before loading the page.
123 */
124 function resolveLoadingPlaceholder(page: string): void;
125 /**
126 * @description Utility methods to create different kinds of alert dialogs. There are three methods available: alert, confirm and prompt
127 */
128 namespace notification {
129 /**
130 * @param {Object} options Parameter object
131 * @param {String} [options.message] Alert message
132 * @param {String} [options.messageHTML] Alert message in HTML
133 * @param {String} [options.buttonLabel] Label for confirmation button. Default is "OK"
134 * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
135 * @param {String} [options.title] Dialog title. Default is "Alert"
136 * @param {String} [options.modifier] Modifier for the dialog
137 * @param {String} [options.id] The `<ons-alert-dialog>` element's ID.
138 * @param {Function} [options.callback] Function that executes after dialog has been closed
139 * @description
140 * Display an alert dialog to show the user a message
141 * The content of the message can be either simple text or HTML
142 * Must specify either message or messageHTML
143 */
144 function alert(message: string | AlertOptions, options?: AlertOptions): Promise<HTMLElement>;
145 /**
146 * @param {Object} options Parameter object
147 * @param {String} [options.message] Confirmation question
148 * @param {String} [options.messageHTML] Dialog content in HTML
149 * @param {Array} [options.buttonLabels] Labels for the buttons. Default is ["Cancel", "OK"]
150 * @param {Number} [options.primaryButtonIndex] Index of primary button. Default is 1
151 * @param {Boolean} [options.cancelable] Whether the dialog is cancelable or not. Default is false
152 * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
153 * @param {String} [options.title] Dialog title. Default is "Confirm"
154 * @param {String} [options.modifier] Modifier for the dialog
155 * @param {String} [options.id] The `<ons-alert-dialog>` element's ID.
156 * @param {Function} [options.callback]
157 * Function that executes after the dialog has been closed
158 * Argument for the function is the index of the button that was pressed or -1 if the dialog was canceled
159 * @description
160 * Display a dialog to ask the user for confirmation
161 * The default button labels are "Cancel" and "OK" but they can be customized
162 * Must specify either message or messageHTML
163 */
164 function confirm(message: string | AlertOptions, options?: AlertOptions): Promise<HTMLElement>;
165 /**
166 * @param {Object} options Parameter object
167 * @param {String} [options.message] Prompt question
168 * @param {String} [options.messageHTML] Dialog content in HTML
169 * @param {String} [options.buttonLabel] Label for confirmation button. Default is "OK"
170 * @param {Number} [options.primaryButtonIndex] Index of primary button. Default is 1
171 * @param {Boolean} [options.cancelable] Whether the dialog is cancelable or not. Default is false
172 * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
173 * @param {String} [options.title] Dialog title. Default is "Alert"
174 * @param {String} [options.modifier] Modifier for the dialog
175 * @param {String} [options.id] The `<ons-alert-dialog>` element's ID.
176 * @param {Function} [options.callback]
177 * Function that executes after the dialog has been closed
178 * Argument for the function is the value of the input field or null if the dialog was canceled
179 * @description
180 * Display a dialog with a prompt to ask the user a question
181 * Must specify either message or messageHTML
182 */
183 function prompt(message: string | AlertOptions, options?: AlertOptions): Promise<HTMLElement>;
184 function toast(...args: any[]): any;
185 }
186 /**
187 * @description Utility methods for orientation detection
188 */
189 namespace orientation {
190 /**
191 * @description Add an event listener.
192 */
193 function on(eventName: string, listener: Function): void;
194 /**
195 * @description Add an event listener that's only triggered once.
196 */
197 function once(eventName: string, listener: Function): void;
198 /**
199 * @description Remove an event listener. If the listener is not specified all listeners for the event type will be removed.
200 */
201 function off(eventName: string, listener?: Function): void;
202 /**
203 * @return {Boolean} Will be true if the current orientation is portrait mode
204 * @description Returns whether the current screen orientation is portrait or not
205 */
206 function isPortrait(): boolean;
207 /**
208 * @return {Boolean} Will be true if the current orientation is landscape mode
209 * @description Returns whether the current screen orientation is landscape or not
210 */
211 function isLandscape(): boolean;
212 }
213 /**
214 * @description Utility methods to detect current platform
215 */
216 namespace platform {
217 /**
218 * @param {string} platform Name of the platform. Possible values are: "opera", "firefox", "safari", "chrome", "ie", "android", "blackberry", "ios" or "wp".
219 * @description Sets the platform used to render the elements. Useful for testing.
220 */
221 function select(platform: string): void;
222 /**
223 * @description Returns whether app is running in Cordova
224 * @return {Boolean}
225 */
226 function isWebView(): boolean;
227
228 /**
229 * @description Returns whether the OS is iOS
230 * @return {Boolean}
231 */
232 function isIOS(): boolean;
233
234 /**
235 * @description Returns whether the OS is Android
236 * @return {Boolean}
237 */
238 function isAndroid(): boolean;
239
240 function isAndroidPhone(): boolean;
241
242 function isAndroidTablet(): boolean;
243
244 /**
245 * @description Returns whether app is running in iOS Safari.
246 * @return {Boolean}
247 */
248 function isIOSSafari(): boolean;
249
250 /**
251 * @description Returns whether app is running in WKWebView.
252 * @return {Boolean}
253 */
254 function isWKWebView(): boolean;
255
256 /**
257 * @description Returns whether the device is iPhone
258 * @return {Boolean}
259 */
260 function isIPhone(): boolean;
261
262 /**
263 * @description Returns whether the device is iPhone X
264 * @return {Boolean}
265 */
266 function isIPhoneX(): boolean;
267
268 /**
269 * @description Returns whether the device is iPad
270 * @return {Boolean}
271 */
272 function isIPad(): boolean;
273
274 /**
275 * @description Returns whether the device is BlackBerry
276 * @return {Boolean}
277 */
278 function isBlackBerry(): boolean;
279
280 /**
281 * @description Returns whether the browser is Opera
282 * @return {Boolean}
283 */
284 function isOpera(): boolean;
285
286 /**
287 * @description Returns whether the browser is Firefox
288 * @return {Boolean}
289 */
290 function isFirefox(): boolean;
291
292 /**
293 * @description Returns whether the browser is Safari
294 * @return {Boolean}
295 */
296 function isSafari(): boolean;
297
298 /**
299 * @description Returns whether the browser is Chrome
300 * @return {Boolean}
301 */
302 function isChrome(): boolean;
303
304 /**
305 * @description Returns whether the browser is Internet Explorer
306 * @return {Boolean}
307 */
308 function isIE(): boolean;
309
310 /**
311 * @description Returns whether the iOS version is 7 or above
312 * @return {Boolean}
313 */
314 function isIOS7above(): boolean;
315
316 /**
317 * @description Returns whether the OS is iPadOS
318 * @return {Boolean}
319 */
320 function isIPadOS(): boolean;
321
322 /**
323 *
324 */
325 function isEdge(): boolean;
326
327 /**
328 * @description Returns whether device is Windows phone
329 * @return {Boolean}
330 */
331 function isWP(): boolean;
332 }
333 /**
334 * @description Utility methods for modifier attributes
335 */
336 namespace modifier {
337 /**
338 * @description Add the specified modifiers to the element if they are not already included.
339 * @param {HTMLElemenet} element Target element.
340 * @param {String} modifier Name of the modifier.
341 */
342 function add(element: HTMLElement, ...modifier: string[]): void;
343 /**
344 * @description Remove the specified modifiers from the element if they are included.
345 * @param {HTMLElemenet} element Target element.
346 * @param {String} modifier Name of the modifier.
347 */
348 function remove(element: HTMLElement, ...modifier: string[]): void;
349 /**
350 * @description Check whether the specified modifier is included in the element.
351 * @param {HTMLElemenet} element Target element.
352 * @param {String} modifier Name of the modifier.
353 * @return {Boolean} 'true' when the specified modifier is found in the element's 'modifier' attribute. 'false' otherwise.
354 */
355 function contains(element: HTMLElement, modifier: string): boolean;
356 /**
357 * @description Toggle the specified modifier.
358 * @param {HTMLElemenet} element Target element.
359 * @param {String} modifier Name of the modifier.
360 * @param {Boolean} force If it evaluates to true, add specified modifier value, and if it evaluates to false, remove it.
361 */
362 function toggle(element: HTMLElement, modifier: string, force?: boolean): void;
363 }
364
365 /**
366 * @description Default page loader that load page template
367 */
368 var defaultPageLoader: PageLoader;
369
370 /**
371 * @description PageLoader class constructor
372 */
373 class PageLoader {
374 constructor(...args: any[]);
375 internalLoader: Function;
376 load(options: {page: any, parent: Element, params?: Object}, done: Function): void;
377 }
378
379 var GestureDetector: any;
380
381 interface OnsActionSheetElement extends HTMLElement {
382 show(...args: any[]): any;
383 hide(...args: any[]): any;
384 onDeviceBackButton: any;
385 visible: any;
386 disabled: any;
387 cancelable: any;
388 animationOptions?: object;
389 maskColor?: string;
390 }
391
392 interface OnsSelectElement extends HTMLElement {
393 length: any;
394 options: any;
395 selectedIndex: any;
396 value: any;
397 }
398
399 interface OnsSegmentElement extends HTMLElement {
400 /**
401 * @param {Number} index Button index
402 * @param {Object} [options] Parameter object passed to the tabbar, if any.
403 * @return Resolves to the selected index or to the new page element if there is a connected tabbar.
404 * @description Make button with the specified index active. If there is a connected tabbar it shows the corresponding tab page. In this case animations and other options can be specified by the second parameter.
405 */
406 setActiveButton(index: number, options?: TabbarOptions): Promise<HTMLElement>;
407 /**
408 * @return {Number} The index of the currently active button
409 * @description Returns button index of current active button. If active button is not found, returns -1
410 */
411 getActiveButtonIndex(): number;
412 /**
413 * @description Whether the element is disabled or not.
414 */
415 disabled: boolean;
416 activeIndex: number;
417 }
418
419 interface OnsToastElement extends HTMLElement {
420 show(...args: any[]): any;
421 toggle(...args: any[]): any;
422 hide(...args: any[]): any;
423 onDeviceBackButton: any;
424 visible: any;
425 animationOptions: object;
426 }
427
428 interface OnsToolbarElement extends HTMLElement {
429 /**
430 * @description Show or hide the toolbar element
431 */
432 setVisibility(visible: boolean): void;
433
434 /**
435 * @description Show the toolbar element
436 */
437 show(): void;
438
439 /**
440 * @description Hide the toolbar element
441 */
442 hide(): void;
443
444 visible: boolean;
445
446 /**
447 * @description Static toolbars are not animated by `ons-navigator` when pushing or popping pages. This can be useful to improve performance in some situations.
448 */
449 static: boolean;
450 }
451
452 interface OnsToolbarButtonElement extends HTMLElement {
453 disabled: any;
454 }
455
456 /**
457 * @description Should be used as root component of each page. The content inside page component is scrollable
458 */
459 interface OnsPageElement extends HTMLElement {
460 /**
461 * @description Function to be executed when scrolling to the bottom of the page. The function receives a done callback as an argument that must be called when it's finished.
462 */
463 onInfiniteScroll: Function;
464 /**
465 * @description Back-button handler.
466 */
467 backButtonHandler: any;
468 onDeviceBackButton: any;
469 /**
470 * @description User's custom data passed to `pushPage()`-like methods.
471 */
472 data: any;
473 }
474
475 /**
476 * @description Carousel component
477 */
478 interface OnsCarouselElement extends HTMLElement {
479 /**
480 * @description Specify the index of the `<ons-carousel-item>` to show.
481 * @return Resolves to the carousel element.
482 */
483 setActiveIndex(index: number, options?: CarouselOptions): Promise<HTMLElement>;
484 /**
485 * @description Returns the index of the currently visible `<ons-carousel-item>`.
486 * @return The current carousel item index.
487 */
488 getActiveIndex(): void;
489 /**
490 * @description Show next ons-carousel item
491 * @return Resolves to the carousel element
492 */
493 next(options?: CarouselOptions): Promise<HTMLElement>;
494 /**
495 * @description Show previous ons-carousel item
496 * @return Resolves to the carousel element
497 */
498 prev(options?: CarouselOptions): Promise<HTMLElement>;
499 /**
500 * @description Update the layout of the carousel. Used when adding ons-carousel-items dynamically or to automatically adjust the size.
501 */
502 refresh(): void;
503 /**
504 * @description Show first ons-carousel item
505 * @Resolves to the carousel element
506 */
507 first(): Promise<HTMLElement>;
508 /**
509 * @description Show last ons-carousel item
510 * @return Resolves to the carousel element
511 */
512 last(): Promise<HTMLElement>;
513 /**
514 * @description The number of carousel items.
515 **/
516 itemCount: number;
517 /**
518 * @description The current auto scroll ratio.
519 **/
520 autoScrollRatio: number;
521 /**
522 * @description true if the carousel is swipeable.
523 **/
524 swipeable: boolean;
525 /**
526 * @param {Number} index Decimal index of the current swipe.
527 * @param {Object} animationOptions Object containing duration and timing.
528 * @description Hook called whenever the user slides the carousel.
529 **/
530 onSwipe?: Function;
531 /**
532 * @description true if auto scroll is enabled.
533 **/
534 autoScroll: boolean;
535 /**
536 * @description Whether the carousel is disabled or not.
537 **/
538 disabled: boolean;
539 /**
540 * @description Whether the carousel is overscrollable or not.
541 **/
542 overscrollable: boolean;
543 /**
544 * @description Whether the carousel is centered or not.
545 **/
546 centered: boolean;
547 animationOptions: object;
548 activeIndex: number;
549 /**
550 * @description If this property is set the carousel will cover the whole screen.
551 **/
552 fullscreen: boolean;
553 /**
554 * @description When this property is set the carousel will automatically refresh when the number of child nodes change.
555 **/
556 autoRefresh: boolean;
557 }
558
559 /**
560 * @description Component that adds "pull-to-refresh" to an <ons-page> element
561 */
562 //later should be updated
563 interface OnsPullHookElement extends HTMLElement {
564 /**
565 * @description The height of the pull hook in pixels. The default value is `64px`.
566 */
567 height: string;
568 /**
569 * @param {Number} thresholdHeight Desired threshold height
570 * @description The thresholdHeight of the pull hook in pixels. The default value is `96px`.
571 */
572 thresholdHeight: string;
573 /**
574 * @description The current number of pixels the pull hook has moved.
575 */
576 state: string;
577 /**
578 * @description The current number of pixels the pull hook has moved.
579 */
580 pullDistance: number;
581 /**
582 * @description A boolean value that specifies whether the element is disabled or not.
583 */
584 disabled: boolean;
585 /**
586 * @description If this property is set the content of the page will not move when pulling.
587 */
588 fixedContent: boolean;
589 /**
590 * @param {Number} ratio Pulled ratio (scroll / height).
591 * @param {Object} animationOptions Object containing duration and timing.
592 * @description Hook called whenever the user pulls the element.
593 **/
594 onPull?: Function;
595 /**
596 * @description Define the function that will be called in the `"action"` state.
597 */
598 onAction?: Function;
599 }
600
601 /**
602 * @modifier android Display an Android style alert dialog
603 * @description Alert dialog that is displayed on top of the current screen
604 */
605 interface OnsAlertDialogElement extends HTMLElement {
606 /**
607 * @param {Object} [options] Parameter object
608 * @param {String} [options.animation] Animation name. Available animations are "fade", "slide" and "none"
609 * @param {Function} [options.callback] Function to execute after the dialog has been revealed
610 * @description Show the alert dialog
611 */
612 show(options?: DialogOptions): Promise<HTMLElement>;
613 /**
614 * @param {Object} [options] Parameter object
615 * @param {String} [options.animation] Animation name. Available animations are "fade", "slide" and "none"
616 * @param {Function} [options.callback] Function to execute after the dialog has been hidden
617 * @description Hide the alert dialog
618 */
619 hide(options?: DialogOptions): Promise<HTMLElement>;
620 /**
621 * @description A boolean value that specifies whether the dialog is disabled or not.
622 */
623 disabled: boolean;
624 /**
625 * @description A boolean value that specifies whether the dialog is cancelable or not. When the dialog is cancelable it can be closed by tapping the background or by pressing the back button on Android devices.
626 */
627 cancelable: boolean;
628 visible: any;
629 onDeviceBackButton: any;
630 animationOptions?: object;
631 maskColor?: string;
632 }
633
634 /**
635 * @description Dialog that is displayed on top of current screen
636 */
637 interface OnsDialogElement extends HTMLElement {
638 /**
639 * @return {Object} Device back button handler
640 * @description Retrieve the back button handler for overriding the default behavior
641 */
642 onDeviceBackButton(): any;
643 /**
644 * @param {Object} [options] Parameter object
645 * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
646 * @param {Function} [options.callback] This function is called after the dialog has been revealed
647 * @description Show the dialog
648 */
649 show(options?: DialogOptions): Promise<HTMLElement>;
650 /**
651 * @param {Object} [options] Parameter object
652 * @param {String} [options.animation] Animation name. Available animations are "none", "fade" and "slide"
653 * @param {Function} [options.callback] This functions is called after the dialog has been hidden
654 * @description Hide the dialog
655 */
656 hide(options?: DialogOptions): Promise<HTMLElement>;
657 /**
658 * @description Destroy the dialog and remove it from the DOM tree
659 */
660 destroy(): void;
661 visible: any;
662 /**
663 * @description A boolean value that specifies whether the dialog is disabled or not.
664 */
665 disabled: boolean;
666 /**
667 * @description A boolean value that specifies whether the dialog is cancelable or not. When the dialog is cancelable it can be closed by tapping the background or by pressing the back button on Android devices.
668 */
669 cancelable: boolean;
670 animationOptions?: object;
671 maskColor?: string;
672 }
673
674 /**
675 * @description Switch component
676 */
677 interface OnsSwitchElement extends HTMLElement {
678 /**
679 * @description If true the switch will be set to on.
680 */
681 checked: boolean;
682 /**
683 * @description Whether the element is disabled or not.
684 */
685 disabled: boolean;
686 /**
687 * @description The underlying checkbox element.
688 */
689 checkbox: HTMLElement;
690 value: any;
691 }
692
693 /**
694 * @description
695 * Modal component that masks current screen
696 * Underlying components are not subject to any events while the modal component is shown
697 */
698 interface OnsModalElement extends HTMLElement {
699 /**
700 * @return Device back button handler
701 * @param {String} [options.animation] Animation name. Available animations are `"none"` and `"fade"`.
702 * @param {String} [options.animationOptions] Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
703 * @description Toggle modal visibility
704 */
705 toggle(options?: ModalOptions): Promise<HTMLElement>;
706 /**
707 * @param {Object} [options] Parameter object
708 * @param {String} [options.animation] Animation name. Available animations are `"none"` and `"fade"`.
709 * @param {String} [options.animationOptions] Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
710 * @description Show modal
711 */
712 show(options?: ModalOptions): Promise<HTMLElement>;
713 /**
714 * @return Resolves to the hidden element
715 * @param {String} [options.animation] Animation name. Available animations are `"none"` and `"fade"`.
716 * @param {String} [options.animationOptions] Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
717 * @description Hide modal
718 */
719 hide(options?: ModalOptions): Promise<HTMLElement>;
720 /**
721 * @description Back-button handler.
722 */
723 onDeviceBackButton: any;
724 /**
725 * @description Whether the dialog is visible or not.
726 */
727 visible: boolean;
728 animationOptions?: object;
729 }
730
731 /**
732 * @description A component that provides page stack management and navigation. This component does not have a visible content
733 */
734 interface OnsNavigatorElement extends HTMLElement {
735 /**
736 * @param {Object} [options] Parameter object
737 * @param {Function} [options.callback] Function that is called when the transition has ended
738 * @description Pops the current page from the page stack. The previous page will be displayed
739 */
740 popPage(options?: NavigatorOptions): Promise<HTMLElement>;
741 /**
742 * @param {*} page Page URL. Can be either a HTML document or a <code>&lt;template&gt;</code>
743 * @param {Object} [options] Parameter object
744 * @param {String} [options.animation] Animation name. Available animations are "slide", "simpleslide", "lift", "fade" and "none"
745 * @param {Function} [options.callback] Function that is called when the transition has ended
746 * @return Promise which resolves to the pushed page.
747 * @description Pushes the specified pageUrl into the page stack.
748 */
749 pushPage(page: any, options?: PushPageOptions): Promise<HTMLElement>;
750 /**
751 * @return Promise which resolves to the inserted page
752 * @description Replaces the current page with the specified one. Extends pushPage parameters.
753 */
754 replacePage(page: any, options?: PushPageOptions): Promise<HTMLElement>;
755 /**
756 * @param {Number} index The index where it should be inserted
757 * @param {*} page Page URL. Can be either a HTML document or a <code>&lt;template&gt;</code>
758 * @param {Object} [options] Parameter object
759 * @param {String} [options.animation] Animation name. Available animations are "slide", "simpleslide", "lift", "fade" and "none"
760 * @description Insert the specified page into the page stack with specified index
761 */
762 insertPage(index: number, page: any, options?: NavigatorOptions): Promise<HTMLElement>;
763 removePage(...args: any[]): any;
764 /**
765 * @param {*} page Page URL. Can be either a HTML document or an <code>&lt;template&gt;</code>
766 * @param {Object} [options] Parameter object
767 * @param {String} [options.animation] Animation name. Available animations are "slide", "simpleslide", "lift", "fade" and "none"
768 * @param {Function} [options.callback] Function that is called when the transition has ended
769 * @description Clears page stack and adds the specified pageUrl to the page stack
770 */
771 resetToPage(page: any, options?: NavigatorOptions): Promise<HTMLElement>;
772 /**
773 * @param {any} item
774 * @param {Object} [options]
775 * @description Page URL or index of an existing page in navigator's stack.
776 */
777 bringPageTop(item: any, options?: Object): Promise<HTMLElement>;
778
779 pageLoader: any;
780 page: any;
781 onDeviceBackButton: any;
782 /**
783 * @return {HTMLElement}
784 * @description Current top page element. Use this method to access options passed by `pushPage()`-like methods.
785 */
786 topPage: HTMLElement; //attribute length in future?
787 /**
788 * @description Navigator's page stack.
789 */
790 pages: any;
791 /**
792 * @description Default options object. Attributes have priority over this property.
793 */
794 options: NavigatorOptions;
795 /**
796 * @param {Number} index Decimal ratio of the current swipe.
797 * @param {Object} animationOptions Object containing duration and timing.
798 * @description Hook called whenever the user slides the navigator.
799 **/
800 onSwipe?: Function;
801 /**
802 * @description Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.
803 **/
804 animationOptions: object;
805 }
806
807 /**
808 * @description A component to display a tab bar on the bottom of a page. Used with ons-tab to manage pages using tabs
809 */
810 interface OnsTabbarElement extends HTMLElement {
811 /**
812 * @param {*} url Page URL. Can be either an HTML document or an <code>&lt;template&gt;</code>
813 * @return Resolves to the new page element.
814 * @description Displays a new page without changing the active index
815 */
816 loadPage(page: any, options?: TabbarOptions): Promise<HTMLElement>;
817 /**
818 * @param {Number} index Tab index
819 * @param {Object} [options] Parameter object
820 * @param {Boolean} [options.keepPage] If true the page will not be changed
821 * @param {String} [options.animation] Animation name. Available animations are `"fade"`, `"slide"` and `"none"`.
822 * @return Resolves to the new page element.
823 * @description Show specified tab page. Animations and other options can be specified by the second parameter
824 */
825 setActiveTab(index: number, options?: TabbarOptions): Promise<HTMLElement>;
826 /**
827 * @description Used to hide or show the tab bar.
828 */
829 setTabbarVisibility(visible: boolean): void;
830 /**
831 * @return {Number} The index of the currently active tab
832 * @description Returns tab index on current active tab. If active tab is not found, returns -1
833 */
834 getActiveTabIndex(): number;
835 visible: any;
836 /**
837 * @description true if the tabbar is swipeable.
838 **/
839 swipeable: boolean;
840 /**
841 * @description If this property is set the tabs show a dynamic bottom border. Only works for iOS flat design since the border is always visible in Material Design.
842 **/
843 tabBorder: boolean;
844 /**
845 * @param {Number} index Decimal index of the current swipe.
846 * @param {Object} animationOptions Object containing duration and timing.
847 * @description Hook called whenever the user slides the tabbar.
848 **/
849 onSwipe?: Function;
850 hideTabs: boolean;
851 activeIndex: number;
852 /**
853 * @description Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.
854 **/
855 animationOptions: object;
856 }
857
858 /**
859 * @modifier android Display an Android style popover
860 * @description A component that displays a popover next to an element
861 */
862 interface OnsPopoverElement extends HTMLElement {
863 /**
864 * @param {String|Event|HTMLElement} target Target element. Can be either a CSS selector, an event object or a DOM element
865 * @param {Object} [options] Parameter object
866 * @param {String} [options.animation] Animation name. Available animations are "fade" and "none"
867 * @return Resolves to the displayed element
868 * @description Open the popover and point it at a target. The target can be either an event, a css selector or a DOM element
869 */
870 show(target: any, options?: PopoverOptions): Promise<HTMLElement>;
871 /**
872 * @param {Object} [options] Parameter object
873 * @param {String} [options.animation] Animation name. Available animations are "fade" and "none"
874 * @return Resolves to the hidden element
875 * @description Close the popover
876 */
877 hide(options?: PopoverOptions): Promise<HTMLElement>;
878 /**
879 * @description Whether the dialog is visible or not.
880 */
881 visible: boolean;
882 /**
883 * @description A boolean value that specifies whether the popover is cancelable or not. When the popover is cancelable it can be closed by tapping the background or by pressing the back button on Android devices.
884 */
885 cancelable: boolean;
886 /**
887 * @description If set the popover will cover the target on the screen.
888 */
889 coverTarget: boolean;
890 /**
891 * @description Retrieve the back- button handler.
892 */
893 onDeviceBackButton: any;
894 animationOptions?: object;
895 maskColor?: string;
896 }
897
898 interface OnsSplitterSideElement extends HTMLElement {
899 /**
900 * @description Page element loaded in the splitter side.
901 */
902 page: string;
903 pageLoader: any;
904 /**
905 * @description Current mode. Possible values are "split", "collapse", "closed", "open" or "changing".
906 */
907 mode: string;
908 /**
909 * @description Returns whether the popover is visible or not.
910 * @return {Boolean} This value is `true` when the menu is open.
911 */
912 isOpen: boolean;
913 /**
914 * @description Open menu in collapse mode.
915 * @return Resolves to the splitter side element or false if not in collapse mode
916 */
917 open(options?: SplitterSideOptions): Promise<HTMLElement | boolean>;
918 /**
919 * @description Close menu in collapse mode.
920 * @param {Object} [option]
921 * @return Resolves to the splitter side element or false if not in collapse mode
922 */
923 close(options?: SplitterSideOptions): Promise<HTMLElement | boolean>;
924 /**
925 * @description Opens if it's closed. Closes if it's open.
926 * @param {Object} [options]
927 * @return Resolves to the splitter side element or false if not in collapse mode
928 */
929 toggle(options?: SplitterSideOptions): Promise<HTMLElement | boolean>;
930 /**
931 * @description Show the page specified in pageUrl in the right section
932 * @param {*} page Page URL. Can be either an HTML document or an <template>.
933 * @param {Object} [option]
934 * @return Resolves to the new page element
935 */
936 load(page: any, options?: SplitterSideOptions): Promise<HTMLElement>;
937 /**
938 * @param {Number} index Decimal ratio of the current swipe.
939 * @param {Object} animationOptions Object containing duration and timing.
940 * @description Hook called whenever the user slides the splitter.
941 **/
942 onSwipe?: Function;
943 /**
944 * @description true if the splitter side element is swipeable.
945 **/
946 swipeable: boolean;
947 /**
948 * @description Specify the animation's duration, timing and delay with an object literal. E.g. `{duration: 0.2, delay: 1, timing: 'ease-in'}`.
949 **/
950 animationOptions: object;
951 }
952
953 interface OnsLazyRepeatElement extends HTMLElement {
954 /**
955 * @description Refresh the list. Use this method when the data has changed.
956 */
957 refresh(): void;
958 /**
959 * @Specify a delegate object to load and unload item elements.
960 */
961 delegate: LazyRepeatOptions;
962 }
963
964 interface OnsButtonElement extends HTMLElement {
965 /**
966 * @description A boolean value that specifies if the button is disabled or not.
967 */
968 disabled: boolean;
969
970 /**
971 * @description A boolean value that specifies if the button has a ripple effect or not.
972 */
973 ripple: boolean;
974 }
975
976 interface OnsAlertDialogButtonElement extends HTMLElement {
977 /**
978 * @description A boolean value that specifies if the button is disabled or not.
979 */
980 disabled: boolean;
981 }
982
983 interface OnsFabElement extends HTMLElement {
984 /**
985 * @description Show the floating action button.
986 */
987 show(): void;
988 /**
989 * @description Hide the floating action button.
990 */
991 hide(): void;
992 /**
993 * @description Toggle the visibility of the button.
994 */
995 toggle(): void;
996 /**
997 * @description A boolean value that specifies if the button is disabled or not.
998 */
999 disabled: boolean;
1000 /**
1001 * @description Whether the dialog is visible or not.
1002 */
1003 visible: boolean;
1004 /**
1005 * @description If this property is defined, the button will have a ripple effect when tapped.
1006 */
1007 ripple: boolean;
1008 }
1009
1010 interface OnsInputElement extends HTMLElement {
1011 /**
1012 * @description The current value of the input.
1013 */
1014 value: string;
1015 /**
1016 * @description This boolean specifies whether the input is checked or not. Only works for `radio` and `checkbox` type inputs.
1017 */
1018 checked: boolean;
1019 /**
1020 * @description A boolean value that specifies whether the input is disabled or not.
1021 */
1022 disabled: boolean;
1023 /**
1024 * @description If this property is present, the placeholder will be animated in Material Design.
1025 */
1026 float: boolean;
1027 }
1028
1029 interface OnsSearchInputElement extends HTMLElement {
1030 /**
1031 * @description The current value of the search input.
1032 */
1033 value: string;
1034 /**
1035 * @description A boolean value that specifies whether the search input is disabled or not.
1036 */
1037 disabled: boolean;
1038 }
1039
1040 interface OnsCheckboxElement extends HTMLElement {
1041 /**
1042 * @description The value of the checkbox.
1043 */
1044 value: string;
1045 /**
1046 * @description This boolean specifies whether the checkbox is checked or not.
1047 */
1048 checked: boolean;
1049 /**
1050 * @description A boolean value that specifies whether the checkbox is disabled or not.
1051 */
1052 disabled: boolean;
1053 }
1054
1055 interface OnsRadioElement extends HTMLElement {
1056 /**
1057 * @description The value of the radio button.
1058 */
1059 value: string;
1060 /**
1061 * @description This boolean specifies whether the radio button is selected or not.
1062 */
1063 checked: boolean;
1064 /**
1065 * @description A boolean value that specifies whether the radio button is disabled or not.
1066 */
1067 disabled: boolean;
1068 }
1069
1070 interface OnsRangeElement extends HTMLElement {
1071 /**
1072 * @description A boolean value that specifies whether the input is disabled or not.
1073 */
1074 disabled: boolean;
1075 /**
1076 * @description The current value of the input.
1077 */
1078 value: string;
1079 }
1080
1081 interface OnsRippleElement extends HTMLElement {
1082 /**
1083 * @description A boolean value that specifies whether the input is disabled or not.
1084 */
1085 disabled: boolean;
1086 /**
1087 * @description If this property is present, change the position of wave effect to center of the target element.
1088 */
1089 center: boolean;
1090 }
1091
1092 interface OnsSplitterContentElement extends HTMLElement {
1093 /**
1094 * @description Page element loaded in the splitter content.
1095 */
1096 page: string;
1097
1098 pageLoader: any;
1099
1100 /**
1101 * @description Show the page specified in pageUrl in the right section. Returns: Resolves to the new page element
1102 * @param {*} page
1103 * @param {Object} [options]
1104 * @return {Promise}
1105 */
1106 load(page: any, options?: SplitterContentOptions): Promise<HTMLElement>;
1107 }
1108
1109 interface OnsSplitterElement extends HTMLElement {
1110 /**
1111 * @description Left `<ons-splitter-side>` element.
1112 */
1113 left: HTMLElement;
1114 /**
1115 * @description Right `<ons-splitter-side>` element.
1116 */
1117 right: HTMLElement;
1118 side: any;
1119 /**
1120 * @description The `<ons-splitter-content>` element.
1121 */
1122 content: HTMLElement;
1123 /**
1124 * @description Retrieve the back button handler.
1125 */
1126 onDeviceBackButton: Function;
1127 }
1128
1129 interface OnsBackButtonElement extends HTMLElement {
1130 /**
1131 * @Options Options object.
1132 */
1133 options?: BackButtonOptions;
1134 onClick: any;
1135 }
1136
1137 interface OnsProgressBarElement extends HTMLElement {
1138 /**
1139 * @description Current progress. Should be a value between 0 and 100.
1140 */
1141 value: number;
1142 /**
1143 * @description Current secondary progress. Should be a value between 0 and 100.
1144 */
1145 secondaryValue: number;
1146 /**
1147 * @description If this property is `true`, an infinite looping animation will be shown.
1148 */
1149 indeterminate: boolean;
1150 }
1151
1152 interface OnsProgressCircularElement extends HTMLElement {
1153 /**
1154 * @description Current progress. Should be a value between 0 and 100.
1155 */
1156 value: number;
1157 /**
1158 * @description Current secondary progress. Should be a value between 0 and 100.
1159 */
1160 secondaryValue: number;
1161 /**
1162 * @description If this property is `true`, an infinite looping animation will be shown.
1163 */
1164 indeterminate: boolean;
1165 }
1166
1167 interface OnsIconElement extends HTMLElement {
1168 /**
1169 * @description When used in a list, you want the icons to have the same width so that they align vertically by defining this attribute.
1170 */
1171 fixedWidth(): boolean;
1172 /**
1173 * @description Specify whether the icon should be spinning.
1174 */
1175 spin(): boolean;
1176 }
1177
1178 interface OnsSpeedDialElement extends HTMLElement {
1179 /**
1180 * @description Show the speed dial.
1181 */
1182 show(): void;
1183 /**
1184 * @description Hide the speed dial.
1185 */
1186 hide(): void;
1187 /**
1188 * @description Show the speed dial items.
1189 */
1190 showItems(): void;
1191 /**
1192 * @description Hide the speed dial items.
1193 */
1194 hideItems(): void;
1195 isOpen(): any;
1196 /**
1197 * @description Toggle visibility.
1198 */
1199 toggle(): void;
1200 /**
1201 * @description Toggle item visibility.
1202 */
1203 toggleItems(): void;
1204 /**
1205 * @description Whether the element is disabled or not.
1206 */
1207 disabled: boolean;
1208 /**
1209 * @description Whether the element is inline or not.
1210 */
1211 inline: boolean;
1212 /**
1213 * @description Whether the element is visible or not.
1214 */
1215 visible: boolean;
1216 /**
1217 * @description Whether the speed items are visible or not.
1218 */
1219 open: boolean;
1220 /**
1221 * @description If this property is defined, the button will have a ripple effect when tapped.
1222 */
1223 ripple: boolean;
1224 }
1225
1226 interface OnsSpeedDialItemElement extends HTMLElement {
1227 /**
1228 * @description If this property is defined, the button will have a ripple effect when tapped.
1229 */
1230 ripple: boolean;
1231 }
1232
1233 interface OnsListItemElement extends HTMLElement {
1234 /**
1235 * @description Show the expandable content if element is expandable
1236 */
1237 showExpansion(): void;
1238 /**
1239 * @description Hide the expandable content if element is expandable
1240 */
1241 hideExpansion(): void;
1242 /**
1243 * @description For expandable list items, specifies whether the expandable content is expanded or not.
1244 **/
1245 expanded: boolean;
1246 /**
1247 * @description Whether the list item is expandable or not.
1248 **/
1249 expandable: boolean;
1250 /**
1251 * @description Makes the element react to taps.
1252 **/
1253 tappable: boolean;
1254 /**
1255 * @description Prevent vertical scrolling when the user drags horizontally.
1256 **/
1257 lockOnDrag: boolean;
1258 /**
1259 * @description The animation used when showing and hiding the expandable content. Can be either `"default"` or `"none"`.
1260 **/
1261 animation: string;
1262 /**
1263 * @description Changes the background color when tapped. For this to work, the attribute "tappable" needs to be set. The default color is "#d9d9d9". It will display as a ripple effect on Android.
1264 **/
1265 tapBackgroundColor: string;
1266 }
1267
1268}
1269
1270
1271interface OnsOptions {
1272 parentScope?: Object;
1273}
1274
1275interface AlertOptions {
1276 message?: string;
1277 messageHTML?: string;
1278 buttonLabel?: string;
1279 buttonLabels?: string[];
1280 primaryButtonIndex?: number;
1281 cancelable?: boolean;
1282 animation?: string;
1283 title?: string;
1284 modifier?: string;
1285 callback?: any;
1286 id?: string;
1287}
1288
1289interface CarouselOptions{
1290 callback?: Function;
1291 animation?: String;
1292 animationOptions?: Object;
1293}
1294
1295interface DialogOptions {
1296 animation?: string;
1297 callback?: Function;
1298}
1299
1300interface ModalOptions {
1301 /**
1302 * @description Animation name. Available animations are `"none"` and `"fade"`.
1303 */
1304 animation?: string;
1305 /**
1306 * @description Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
1307 */
1308 animationOptions?: string;
1309}
1310
1311interface NavigatorOptions {
1312 /**
1313 * @description Animation name. Available animations are `"slide"`, `"lift"`, `"fade"` and `"none"`. These are platform based animations. For fixed animations, add `"-ios"` or `"-md"` suffix to the animation name. E.g. `"lift-ios"`, `"lift-md"`. Defaults values are `"slide-ios"` and `"fade-md"`.
1314 */
1315 animation?: string;
1316 /**
1317 * @description Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
1318 */
1319 animationOptions?: string;
1320 /**
1321 * @description Function that is called when the transition has ended.
1322 */
1323 callback?: Function;
1324}
1325
1326interface PushPageOptions {
1327 page?: any,
1328 pageHTML?: string,
1329 animation?: string,
1330 animationOptions?: Object,
1331 callback?: Function,
1332 data?: Object
1333}
1334
1335interface TabbarOptions {
1336 /**
1337 * @description If true the page will not be changed.
1338 */
1339 keepPage?: boolean;
1340 /**
1341 * @description Animation name. Available animations are `"fade"`, `"slide"` and `"none"`.
1342 */
1343 animation?: string;
1344 /**
1345 * @description Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
1346 */
1347 animationOptions?: string;
1348 /**
1349 *
1350 */
1351 callback?: Function;
1352}
1353
1354interface PopoverOptions {
1355 animation?: string;
1356}
1357
1358interface SplitterSideOptions {
1359 /**
1360 * @description This function will be called after the menu has been opened.
1361 * @return {Function}
1362 */
1363 callback?: Function;
1364}
1365
1366interface LazyRepeatOptions {
1367 /**
1368 * @description This function should return a `HTMLElement`. To help rendering the element, the current index and a template is supplied as arguments. The template is the initial content of the `<ons-lazy-repeat>` element.
1369 */
1370 createItemContent?: HTMLElement;
1371 /**
1372 * @description Should return the number of items in the list.
1373 */
1374 countItems?: number;
1375 /**
1376 * @description Should return the height of an item. The index is provided as an argument. This is important when rendering lists where the items have different height. The function is optional and if it isn't present the height of the first item will be automatically calculated and used for all other items.
1377 */
1378 calculateItemHeight?: number;
1379 /**
1380 * @description This function is used called when an item is removed from the DOM. The index and DOM element is provided as arguments. The function is optional but may be important in order to avoid memory leaks.
1381 */
1382 destroyItem?: string;
1383 /**
1384 * @description Function which recieves an index and the scope for the item. Can be used to configure values in the item scope.
1385 */
1386 configureItemScope?: number;
1387}
1388
1389interface SplitterContentOptions {
1390 /**
1391 * @description This function will be called after the menu has been opened.
1392 * @return {Function}
1393 */
1394 callback?: Function;
1395}
1396
1397interface BackButtonOptions {
1398 /**
1399 * @description Animation name. Available animations are "slide", "lift", "fade" and "none". These are platform based animations. For fixed animations, add "-ios" or "-md" suffix to the animation name. E.g. "lift-ios", "lift-md". Defaults values are "slide-ios" and "fade-md".
1400 */
1401 animation?: string;
1402 /**
1403 * @description Specify the animation's duration, delay and timing. E.g. `{duration: 0.2, delay: 0.4, timing: 'ease-in'}`.
1404 */
1405 animationOptions?: string;
1406 /**
1407 * @description Function that is called when the transition has ended.
1408 */
1409 callback?: Function;
1410}