diff --git a/dist/viiny-form.min.js b/dist/viiny-form.min.js index b994f10..c620cdc 100644 --- a/dist/viiny-form.min.js +++ b/dist/viiny-form.min.js @@ -1 +1 @@ -var ViinyForm=(()=>{function e(r,t){t=n({onInit:()=>{},onBeforeNext:()=>!0,onNext:()=>{},onBeforePrev:()=>!0,onPrev:()=>{},onInvalid:()=>{},onComplete:()=>{},nextButtonClass:"btn-next",prevButtonClass:"btn-prev"},t);r=new e.instance(r,t);return r.setForms(),r.setNextButtons(),r.setPrevButtons(),r}(e.instance=function(r,t){this.options=t,this.currentFormIndex=0;t=document.querySelector(r);if(!t)throw"Wrapper element not found";this.formWrapper=t,this.formArr=this.formWrapper.querySelectorAll("form"),this.options.onInit()}).prototype.setForms=function(){this.formArr.forEach((r,t)=>{0!==t&&(r.style.display="none"),r.addEventListener("submit",r=>{r.preventDefault()})})},e.instance.prototype.setNextButtons=function(){const r=this.formWrapper.querySelectorAll("."+this.options.nextButtonClass);r.forEach(r=>{r.addEventListener("click",()=>{if(this.options.onBeforeNext(this.currentFormIndex,this.formArr[this.currentFormIndex])&&this.currentFormIndex<=this.formArr.length-1){if(!this.formArr[this.currentFormIndex].checkValidity())return this.formArr[this.currentFormIndex].classList.add("was-validated"),void this.options.onInvalid(this.currentFormIndex,this.formArr[this.currentFormIndex]);this.formArr[this.currentFormIndex]&&(this.formArr[this.currentFormIndex].style.display="none"),this.currentFormIndex++,this.formArr[this.currentFormIndex]&&(this.formArr[this.currentFormIndex].style.display="block"),this.currentFormIndex>this.formArr.length-1?this.options.onComplete(this.currentFormIndex,this.formArr[this.currentFormIndex-1]):this.options.onNext(this.currentFormIndex,this.formArr[this.currentFormIndex-1])}})})},e.instance.prototype.setPrevButtons=function(){const r=this.formWrapper.querySelectorAll("."+this.options.prevButtonClass);r.forEach(r=>{r.addEventListener("click",()=>{this.options.onBeforePrev(this.currentFormIndex,this.formArr[this.currentFormIndex])&&0{for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r};return e})(); \ No newline at end of file +var ViinyForm=(()=>{function e(r,t){t=n({onInit:()=>{},onBeforeNext:()=>!0,onNext:()=>{},onBeforePrev:()=>!0,onPrev:()=>{},onInvalid:()=>{},onComplete:()=>{},nextButtonClass:"btn-next",prevButtonClass:"btn-prev"},t);r=new e.instance(r,t);return r.setForms(),r.setNextButtons(),r.setPrevButtons(),r}(e.instance=function(r,t){this.options=t,this.currentFormIndex=0;t=document.querySelector(r);if(!t)throw"Wrapper element not found";this.formWrapper=t,this.formArr=this.formWrapper.querySelectorAll("form"),this.options.onInit(this.formArr.length)}).prototype.setForms=function(){this.formArr.forEach((r,t)=>{0!==t&&(r.style.display="none"),r.addEventListener("submit",r=>{r.preventDefault()})})},e.instance.prototype.setNextButtons=function(){const r=this.formWrapper.querySelectorAll("."+this.options.nextButtonClass);r.forEach(r=>{r.addEventListener("click",()=>{if(this.options.onBeforeNext(this.currentFormIndex,this.formArr[this.currentFormIndex])&&this.currentFormIndex<=this.formArr.length-1){if(!this.formArr[this.currentFormIndex].checkValidity())return this.formArr[this.currentFormIndex].classList.add("was-validated"),void this.options.onInvalid(this.currentFormIndex,this.formArr[this.currentFormIndex]);this.formArr[this.currentFormIndex]&&(this.formArr[this.currentFormIndex].style.display="none"),this.currentFormIndex++,this.formArr[this.currentFormIndex]&&(this.formArr[this.currentFormIndex].style.display="block"),this.currentFormIndex>this.formArr.length-1?this.options.onComplete(this.currentFormIndex,this.formArr[this.currentFormIndex-1]):this.options.onNext(this.currentFormIndex,this.formArr[this.currentFormIndex-1])}})})},e.instance.prototype.setPrevButtons=function(){const r=this.formWrapper.querySelectorAll("."+this.options.prevButtonClass);r.forEach(r=>{r.addEventListener("click",()=>{this.options.onBeforePrev(this.currentFormIndex,this.formArr[this.currentFormIndex])&&0{for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r};return e})(); \ No newline at end of file diff --git a/dist/viiny-form.min.js.map b/dist/viiny-form.min.js.map index 24977fb..65311af 100644 --- a/dist/viiny-form.min.js.map +++ b/dist/viiny-form.min.js.map @@ -1 +1 @@ -{"version":3,"file":"./dist/viiny-form.min.js.map","sources":["./src/index.js"],"names":["ViinyForm","el","options","extend","onInit","onBeforeNext","onNext","onBeforePrev","onPrev","onInvalid","onComplete","nextButtonClass","prevButtonClass","viinyForm","instance","setForms","setNextButtons","setPrevButtons","this","currentFormIndex","wrapperElement","document","querySelector","formWrapper","formArr","querySelectorAll","prototype","forEach","element","index","style","display","addEventListener","e","preventDefault","nextButtons","length","checkValidity","classList","add","prevButtons","obj","props","let","prop","hasOwnProperty"],"mappings":"AAAA,IAAIA,WAAY,KAMZ,SAASA,EAAUC,EAAIC,GAanBA,EAAUC,EAZW,CACjBC,OAAU,OACVC,aAAgB,KAAM,EACtBC,OAAU,OACVC,aAAgB,KAAM,EACtBC,OAAU,OACVC,UAAa,OACbC,WAAc,OACdC,gBAAmB,WACnBC,gBAAmB,YAGUV,GAE7BW,EAAY,IAAIb,EAAUc,SAASb,EAAIC,GAI3C,OAHAW,EAAUE,WACVF,EAAUG,iBACVH,EAAUI,iBACHJ,GAGXb,EAAUc,SAAW,SAAUb,EAAIC,GAC/BgB,KAAKhB,QAAUA,EACfgB,KAAKC,iBAAmB,EAEpBC,EAAiBC,SAASC,cAAcrB,GAE5C,IAAImB,EAIA,KAAM,4BAHNF,KAAKK,YAAcH,EAMvBF,KAAKM,QAAUN,KAAKK,YAAYE,iBAAiB,QAEjDP,KAAKhB,QAAgB,WAGNwB,UAAUX,SAAW,WACpCG,KAAKM,QAAQG,QAAQ,CAACC,EAASC,KACb,IAAVA,IACAD,EAAQE,MAAMC,QAAU,QAG5BH,EAAQI,iBAAiB,SAAU,IAC/BC,EAAEC,sBAKdlC,EAAUc,SAASY,UAAUV,eAAiB,WAC1C,MAAMmB,EAAcjB,KAAKK,YAAYE,iBAAiB,IAAIP,KAAKhB,QAAyB,iBAExFiC,EAAYR,QAAQ,IAChBC,EAAQI,iBAAiB,QAAS,KAC9B,GAAKd,KAAKhB,QA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IAAIC,KAAQF,EACTA,EAAMG,eAAeD,KACrBH,EAAIG,GAAQF,EAAME,IAG1B,OAAOH,GAGX,OAAOzC,GAlIK"} \ No newline at end of file +{"version":3,"file":"./dist/viiny-form.min.js.map","sources":["./src/index.js"],"names":["ViinyForm","el","options","extend","onInit","onBeforeNext","onNext","onBeforePrev","onPrev","onInvalid","onComplete","nextButtonClass","prevButtonClass","viinyForm","instance","setForms","setNextButtons","setPrevButtons","this","currentFormIndex","wrapperElement","document","querySelector","formWrapper","formArr","querySelectorAll","length","prototype","forEach","element","index","style","display","addEventListener","e","preventDefault","nextButtons","checkValidity","classList","add","prevButtons","obj","props","let","prop","hasOwnProperty"],"mappings":"AAAA,IAAIA,WAAY,KAMZ,SAASA,EAAUC,EAAIC,GAanBA,EAAUC,EAZW,CACjBC,OAAU,OACVC,aAAgB,KAAM,EACtBC,OAAU,OACVC,aAAgB,KAAM,EACtBC,OAAU,OACVC,UAAa,OACbC,WAAc,OACdC,gBAAmB,WACnBC,gBAAmB,YAGUV,GAE7BW,EAAY,IAAIb,EAAUc,SAASb,EAAIC,GAI3C,OAHAW,EAAUE,WACVF,EAAUG,iBACVH,EAAUI,iBACHJ,GAGXb,EAAUc,SAAW,SAAUb,EAAIC,GAC/BgB,KAAKhB,QAAUA,EACfgB,KAAKC,iBAAmB,EAEpBC,EAAiBC,SAASC,cAAcrB,GAE5C,IAAImB,EAIA,KAAM,4BAHNF,KAAKK,YAAcH,EAMvBF,KAAKM,QAAUN,KAAKK,YAAYE,iBAAiB,QAEjDP,KAAKhB,QAAgB,OAAEgB,KAAKM,QAAQE,UAGrBC,UAAUZ,SAAW,WACpCG,KAAKM,QAAQI,QAAQ,CAACC,EAASC,KACb,IAAVA,IACAD,EAAQE,MAAMC,QAAU,QAG5BH,EAAQI,iBAAiB,SAAU,IAC/BC,EAAEC,sBAKdnC,EAAUc,SAASa,UAAUX,eAAiB,WAC1C,MAAMoB,EAAclB,KAAKK,YAAYE,iBAAiB,IAAIP,KA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