From e3cda5a5025bb26783fa65384d50a94eb2d1b646 Mon Sep 17 00:00:00 2001 From: cristijora Date: Thu, 20 Apr 2017 10:36:46 +0300 Subject: [PATCH] Support vue-router integration --- dev/App.vue | 8 ++++---- dev/main.js | 15 +++++++++++++++ dist/vue-form-wizard.js | 2 +- package.json | 3 ++- src/components/FormWizard.vue | 17 +++++++++++++---- src/components/TabContent.vue | 3 +++ 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/dev/App.vue b/dev/App.vue index 396bd13..d20a085 100644 --- a/dev/App.vue +++ b/dev/App.vue @@ -5,18 +5,18 @@ color="#e74c3c" class="card"> - My first tab content - My second tab content - Yuhuuu! This seems pretty damn simple - + diff --git a/dev/main.js b/dev/main.js index 2e0faaf..d0ec270 100644 --- a/dev/main.js +++ b/dev/main.js @@ -1,12 +1,27 @@ import Vue from 'vue' +import VueRouter from 'vue-router' import App from './App.vue' import FormWizard from './../src/index' +const First = { template: '
First
' } +const Second = { template: '
Second
' } +const Third = { template: '
Third
' } + +const router = new VueRouter({ + mode: 'history', + routes: [ + { path: '/first', component: First }, + { path: '/second', component: Second }, + { path: '/third', component: Third } + ] +}) +Vue.use(VueRouter) Vue.use(FormWizard) Vue.config.productionTip = false /* eslint-disable no-new */ new Vue({ + router, el: '#app', template: '', components: {App} diff --git a/dist/vue-form-wizard.js b/dist/vue-form-wizard.js index 7aa752e..d3b5607 100644 --- a/dist/vue-form-wizard.js +++ b/dist/vue-form-wizard.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueFormWizard=e():t.VueFormWizard=e()}(this,function(){return function(t){function e(s){if(n[s])return n[s].exports;var i=n[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,s){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:s})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e){t.exports=function(t,e,n,s){var i,a=t=t||{},o=typeof t.default;"object"!==o&&"function"!==o||(i=t,a=t.default);var r="function"==typeof a?a.options:a;if(e&&(r.render=e.render,r.staticRenderFns=e.staticRenderFns),n&&(r._scopeId=n),s){var c=Object.create(r.computed||null);Object.keys(s).forEach(function(t){var e=s[t];c[t]=function(){return e}}),r.computed=c}return{esModule:i,exports:a,options:r}}},function(t,e,n){n(7),n(6);var s=n(0)(n(3),n(8),null,null);s.options.__file="C:\\work\\vue-tab-wizard\\src\\components\\FormWizard.vue",s.esModule&&Object.keys(s.esModule).some(function(t){return"default"!==t&&"__esModule"!==t})&&console.error("named exports are not supported in *.vue files."),s.options.functional&&console.error("[vue-loader] FormWizard.vue: functional components are not supported with templates, they should use render functions."),t.exports=s.exports},function(t,e,n){var s=n(0)(n(4),n(9),null,null);s.options.__file="C:\\work\\vue-tab-wizard\\src\\components\\TabContent.vue",s.esModule&&Object.keys(s.esModule).some(function(t){return"default"!==t&&"__esModule"!==t})&&console.error("named exports are not supported in *.vue files."),s.options.functional&&console.error("[vue-loader] TabContent.vue: functional components are not supported with templates, they should use render functions."),t.exports=s.exports},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={props:{title:{type:String,default:"Awesome Wizard"},subtitle:{type:String,default:"Split a complicated flow in multiple steps"},nextButtonText:{type:String,default:"Next"},backButtonText:{type:String,default:"Back"},finishButtonText:{type:String,default:"Finish"},color:{type:String,default:"#e74c3c"},shape:{type:String,default:"circle"},transition:{type:String,default:""},startIndex:{type:Number,default:0}},data:function(){return{activeTabIndex:0,isLastStep:!1,currentPercentage:0,maxStep:0,tabs:[]}},computed:{tabCount:function(){return this.tabs.length},displayPrevButton:function(){return 0!==this.activeTabIndex},stepPercentage:function(){return 1/(2*this.tabCount)*100},progressBarStyle:function(){return{backgroundColor:this.color,width:this.progress+"%",color:this.color}},iconActiveStyle:function(){return{backgroundColor:this.color}},stepCheckedStyle:function(){return{borderColor:this.color}},stepTitleStyle:function(){return{color:this.color}},isStepSquare:function(){return"square"===this.shape},isTabShape:function(){return"tab"===this.shape},fillButtonStyle:function(){return{backgroundColor:this.color,borderColor:this.color,color:"white"}},progress:function(){var t=0;if(this.activeTabIndex>0){t=this.stepPercentage*(2*this.activeTabIndex+1)}else t=this.stepPercentage;return t}},methods:{isChecked:function(t){return t<=this.maxStep},navigateToTab:function(t){t<=this.maxStep&&this.beforeTabChange(this.activeTabIndex)&&this.changeTab(this.activeTabIndex,t)},beforeTabChange:function(t){var e=this.tabs[t];return!e||void 0===e.beforeChange||e.beforeChange()},changeTab:function(t,e){var n=this.tabs[t],s=this.tabs[e];return n&&(n.show=!1,n.active=!1),s&&(s.show=!0,s.active=!0),this.activeTabIndex=e,this.checkStep(),!0},checkStep:function(){this.activeTabIndex===this.tabCount-1?this.isLastStep=!0:this.isLastStep=!1},increaseMaxStep:function(){this.activeTabIndex>this.maxStep&&(this.maxStep=this.activeTabIndex)},nextTab:function(){this.beforeTabChange(this.activeTabIndex)&&(this.activeTabIndex0&&(this.activeTabIndex--,this.isLastStep=!1)},finish:function(){this.$emit("on-complete")}},mounted:function(){if(this.tabs=this.$children.filter(function(t){return"tab-content"===t.$options.name}),this.tabs.length>0){var t=this.tabs[this.activeTabIndex];t.show=!0,t.active=!0}this.startIndex0){t=this.stepPercentage*(2*this.activeTabIndex+1)}else t=this.stepPercentage;return t}},methods:{isChecked:function(t){return t<=this.maxStep},navigateToTab:function(t){t<=this.maxStep&&this.beforeTabChange(this.activeTabIndex)&&this.changeTab(this.activeTabIndex,t)},beforeTabChange:function(t){var e=this.tabs[t];return!e||void 0===e.beforeChange||e.beforeChange()},changeTab:function(t,e){var n=this.tabs[t],s=this.tabs[e];return n&&(n.show=!1,n.active=!1),s&&(s.show=!0,s.active=!0),this.activeTabIndex=e,this.checkStep(),this.tryChangeRoute(s),!0},tryChangeRoute:function(t){this.$router&&t.route&&this.$router.push(t.route)},checkStep:function(){this.activeTabIndex===this.tabCount-1?this.isLastStep=!0:this.isLastStep=!1},increaseMaxStep:function(){this.activeTabIndex>this.maxStep&&(this.maxStep=this.activeTabIndex)},nextTab:function(){this.beforeTabChange(this.activeTabIndex)&&(this.activeTabIndex0&&(this.activeTabIndex--,this.isLastStep=!1)},finish:function(){this.$emit("on-complete")}},mounted:function(){if(this.tabs=this.$children.filter(function(t){return"tab-content"===t.$options.name}),this.tabs.length>0){var t=this.tabs[this.activeTabIndex];t.show=!0,t.active=!0,this.tryChangeRoute(t)}this.startIndex -
+
- {{index+1}} + {{index + 1}}
- {{index+1}} + {{index + 1}}
@@ -42,7 +43,7 @@