|
1 |
| -// Typings for NativeScript-Vue |
2 |
| -declare module 'nativescript-vue' { |
3 |
| - // import vue.js typings |
4 |
| - import Vue from 'vue'; |
5 |
| - |
6 |
| - // creat a nativescript vue class that extends vue.js |
7 |
| - class NativeScriptVue extends Vue { |
8 |
| - /** |
9 |
| - * Registers NativeScript Plugin. |
10 |
| - * @param elementName Name of the element to use in your template |
11 |
| - * @param resolver function to register the element |
12 |
| - * @param meta meta associated with the element |
13 |
| - */ |
14 |
| - static registerElement(elementName: string, resolver: Function, meta?: any): void; |
15 |
| - |
16 |
| - /** |
17 |
| - * starts the nativescript application |
18 |
| - */ |
19 |
| - $run(): void |
20 |
| - } |
21 |
| - |
22 |
| - export = NativeScriptVue; |
| 1 | +// import vue.js typings |
| 2 | +// import Vue from 'vue'; |
| 3 | +import { Vue, VueConstructor } from 'vue/types/vue' |
| 4 | +import { Page, NavigationEntry, Size } from 'tns-core-modules/ui/frame/frame' |
| 5 | +import { View } from 'tns-core-modules/ui/core/view' |
| 6 | + |
| 7 | +export type navigateTo = ( |
| 8 | + component: VueConstructor, |
| 9 | + options?: NavigationEntry, |
| 10 | + cb?: () => Page, |
| 11 | +) => Promise<Page>; |
| 12 | + |
| 13 | +export interface ModalOptions { |
| 14 | + context?: any; |
| 15 | + fullscreen?: boolean; |
| 16 | +} |
| 17 | + |
| 18 | +// create a nativescript vue class that extends vue.js |
| 19 | +export interface NativeScriptVue<V = View> extends Vue { |
| 20 | + nativeView: V |
| 21 | + |
| 22 | + $navigateTo: navigateTo |
| 23 | + $navigateBack: () => void |
| 24 | + |
| 25 | + $modal?: { close: (data?) => Promise<typeof data> }; |
| 26 | + |
| 27 | + /** |
| 28 | + * Open a modal using a component |
| 29 | + * @param {typeof Vue} component |
| 30 | + * @param {ModalOptions} options |
| 31 | + * @returns {any} |
| 32 | + */ |
| 33 | + $showModal: (component: typeof Vue, options?: ModalOptions) => Promise<any>; |
| 34 | + |
| 35 | + /** |
| 36 | + * starts the nativescript application |
| 37 | + */ |
| 38 | + $start: () => void |
| 39 | +} |
| 40 | + |
| 41 | +export interface NativeScriptVueConstructor extends VueConstructor<NativeScriptVue> { |
| 42 | + navigateTo: navigateTo |
| 43 | + navigateBack: () => void |
23 | 44 | }
|
| 45 | + |
| 46 | +export const NativeScriptVue: NativeScriptVueConstructor |
| 47 | + |
| 48 | +export default NativeScriptVue; |
| 49 | + |
| 50 | +// export as namespace NativeScriptVue; |
| 51 | + |
| 52 | +/** |
| 53 | + * Registers NativeScript Plugin. |
| 54 | + * @param elementName Name of the element to use in your template |
| 55 | + * @param resolver function to register the element |
| 56 | + * @param meta meta associated with the element |
| 57 | + */ |
| 58 | +export function registerElement(elementName: string, resolver: Function, meta?: any): void; |
0 commit comments