diff --git a/README.md b/README.md index 2a8ac1a..f99cf42 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ this.$modal.show('dialog', { handler: () => { alert('Woot!') } }, { - titile: '', // Button title + title: '', // Button title default: true, // Will be triggered by default if 'Enter' pressed. handler: () => {} // Button click handler }, diff --git a/package.json b/package.json index 239b855..9a1b153 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,13 @@ "type": "git", "url": "https://github.com/euvl/vue-js-modal.git" }, - "keywords": ["vue", "vuejs", "modal", "vue-js-modal"], + "types": "types/index.d.ts", + "keywords": [ + "vue", + "vuejs", + "modal", + "vue-js-modal" + ], "bugs": { "url": "https://github.com/euvl/vue-js-modal/issues" }, @@ -23,6 +29,7 @@ "unit": "./node_modules/karma/bin/karma start test/unit/karma.conf.js", "build": "npm run unit && npm run build:client && npm run build:ssr && npm run build:ssr-no-css" + "test:types": "tsc -p types/test" }, "license": "MIT", "devDependencies": { diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..a2a7d12 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,21 @@ +import Vue, { PluginObject } from "vue"; + +declare const VueJSModal: PluginObject; +export default VueJSModal; + +export declare interface VueJSModalOptions { + componentName?: string; + dialog?: boolean; +} + +declare interface VModal { + show(name: string, params?: object): void; + hide(name: string, params?: object): void; + toggle(name: string, params?: object): void; +} + +declare module "vue/types/vue" { + interface Vue { + $modal: VModal; + } +} diff --git a/types/test/index.ts b/types/test/index.ts new file mode 100644 index 0000000..7f29044 --- /dev/null +++ b/types/test/index.ts @@ -0,0 +1,16 @@ +import Vue from "vue"; +import VueJSModal, { VueJSModalOptions } from "../index"; + +Vue.use(VueJSModal); +Vue.use(VueJSModal, { + componentName: "another-modal-name", + dialog: false +}); + +const vm = new Vue({ + template: `` +}).$mount("#app"); + +vm.$modal.show("awesome-modal"); +vm.$modal.hide("awesome-modal", { customeEvent: "customEventParam" }); +vm.$modal.toggle("awesome-modal"); diff --git a/types/test/tsconfig.json b/types/test/tsconfig.json new file mode 100644 index 0000000..2acb656 --- /dev/null +++ b/types/test/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "es2015", + "moduleResolution": "node", + "strict": true, + "noEmit": true + }, + "include": [ + "*.ts", + "../index.d.ts" + ] +}