From deb06b03bfddb2a92a75991d708af16841e17e8d Mon Sep 17 00:00:00 2001 From: cristijora Date: Wed, 22 Nov 2017 18:59:57 +0200 Subject: [PATCH] Add typescript definitions Closes #79 --- package.json | 9 ++++++--- types/FormWizard.ts | 33 +++++++++++++++++++++++++++++++++ types/TabContent.ts | 14 ++++++++++++++ types/WizardStep.ts | 6 ++++++ types/index.d.ts | 12 ++++++++++++ yarn.lock | 12 ++++++------ 6 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 types/FormWizard.ts create mode 100644 types/TabContent.ts create mode 100644 types/WizardStep.ts create mode 100644 types/index.d.ts diff --git a/package.json b/package.json index 60a3a02..95b355f 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,11 @@ "description": "A vue based tab/form wizard", "main": "dist/vue-form-wizard.js", "files": [ - "dist" + "dist", + "types", + "src" ], + "typings": "types/index.d.ts", "homepage": "https://github.com/cristijora/vue-form-wizard", "scripts": { "dev": "node build/dev-server.js", @@ -88,12 +91,12 @@ "sinon-chai": "^2.14.0", "stats-webpack-plugin": "^0.6.0", "url-loader": "^0.6.2", - "vue": "^2.4.2", + "vue": "^2.5.8", "vue-form-generator": "^2.1.1", "vue-loader": "^11.1.4", "vue-router": "^2.5.1", "vue-style-loader": "^3.0.3", - "vue-template-compiler": "^2.4.2", + "vue-template-compiler": "^2.5.8", "vue-test-utils": "^1.0.0-beta.1", "webpack": "^2.2.1", "webpack-bundle-analyzer": "^2.9.1", diff --git a/types/FormWizard.ts b/types/FormWizard.ts new file mode 100644 index 0000000..cba14d0 --- /dev/null +++ b/types/FormWizard.ts @@ -0,0 +1,33 @@ +export type ShapeType = 'circle' | 'square' | 'tab' +export type LayoutType = 'vertical' | 'horizontal' +export type StepSizeType = 'xs' | 'sm' | 'md' | 'lg' + +export declare class Wizard { + /** Wizard title */ + title: string + /** Wizard subtitle */ + subtitle: string + nextButtonText: string + backButtonText: string + finishButtonText: string + /** Whether to hide footer buttons */ + hideButtons: boolean + /** Whether to trigger beforeChange function when navigating back */ + validateOnBack: boolean + /** Active step and button color */ + color: string + /** Step color when the current step is not valid */ + errorColor: string + /** Main step shape */ + shape: ShapeType + /** Wizard layout */ + layout: LayoutType + /** Additional css classes for steps */ + stepsClasses: string[] + /** Step size */ + stepSize: StepSizeType + /** Step transition from inactive to active */ + transition: string + /** Tab index where the wizard should start */ + startIndex: number +} diff --git a/types/TabContent.ts b/types/TabContent.ts new file mode 100644 index 0000000..e937889 --- /dev/null +++ b/types/TabContent.ts @@ -0,0 +1,14 @@ +export declare class Tab { + /** Title to be displayed under each step */ + title?: string + /** css class for each step icon */ + icon?: string + /*** + * Function to execute before tab switch. Return value must be boolean + * If the return result is false, tab switch is restricted + */ + beforeChange (): boolean | Promise + /** Vue router route object */ + route: string | object + additionalInfo: object +} diff --git a/types/WizardStep.ts b/types/WizardStep.ts new file mode 100644 index 0000000..f858edc --- /dev/null +++ b/types/WizardStep.ts @@ -0,0 +1,6 @@ +export declare class Step { + /** Tab component for the step. This should be usually passed through the `step` scoped slot */ + tab: object + transition: string + index: number +} diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..6d0ce57 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,12 @@ +import Vue from 'vue' + +export function install (vue: typeof Vue): void + +import { Wizard } from './FormWizard' +import { Tab } from './TabContent' +import { Step } from './WizardStep' + +export class FormWizard extends Wizard {} +export class TabContent extends Tab {} +export class WizardStep extends Step {} + diff --git a/yarn.lock b/yarn.lock index 4ec7d76..ceca56d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6338,9 +6338,9 @@ vue-style-loader@^3.0.3: hash-sum "^1.0.2" loader-utils "^1.0.2" -vue-template-compiler@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.4.2.tgz#5a45d843f148b098f6c1d1e35ac20c4956d30ad1" +vue-template-compiler@^2.5.8: + version "2.5.8" + resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.5.8.tgz#826ae77e1d5faa7fa5fca554f33872dde38de674" dependencies: de-indent "^1.0.2" he "^1.1.0" @@ -6355,9 +6355,9 @@ vue-test-utils@^1.0.0-beta.1: dependencies: lodash "^4.17.4" -vue@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/vue/-/vue-2.4.2.tgz#a9855261f191c978cc0dc1150531b8d08149b58c" +vue@^2.5.8: + version "2.5.8" + resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.8.tgz#f855c1c27255184a82225f4bef225473e8faf15b" watchpack@^1.3.1: version "1.4.0"