Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@preline/stepper

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preline/stepper - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

2

index.d.ts

@@ -1,3 +0,1 @@

export interface IBasePlugin<O, E> {

@@ -4,0 +2,0 @@ el: E;

22

index.js

@@ -1,17 +0,17 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(self,(()=>(()=>{"use strict";var t={737:(t,e)=>{
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(self,(()=>(()=>{"use strict";var t={961:(t,e)=>{
/*
* HSBasePlugin
* @version: 2.1.0
* @author: HTMLStream
* @license: Licensed under MIT (https://preline.co/docs/license.html)
* Copyright 2023 HTMLStream
* @version: 2.4.0
* @author: Preline Labs Ltd.
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
* Copyright 2024 Preline Labs Ltd.
*/
Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,n){this.el=t,this.options=e,this.events=n,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var n;t.push({id:(null===(n=null==e?void 0:e.el)||void 0===n?void 0:n.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=n},957:function(t,e,n){
Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,n){this.el=t,this.options=e,this.events=n,this.el=t,this.options=e,this.events={}}return t.prototype.createCollection=function(t,e){var n;t.push({id:(null===(n=null==e?void 0:e.el)||void 0===n?void 0:n.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.on=function(t,e){this.events[t]=e},t}();e.default=n},887:function(t,e,n){
/*
* HSStepper
* @version: 2.1.0
* @author: HTMLStream
* @license: Licensed under MIT (https://preline.co/docs/license.html)
* Copyright 2023 HTMLStream
* @version: 2.4.0
* @author: Preline Labs Ltd.
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
* Copyright 2024 Preline Labs Ltd.
*/
var i,s=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},o.apply(this,arguments)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var l=n(969),a=function(t){function e(e,n){var i=t.call(this,e,n)||this,s=e.getAttribute("data-hs-stepper"),r=s?JSON.parse(s):{},l=o(o({},r),n);return i.currentIndex=(null==l?void 0:l.currentIndex)||1,i.mode=(null==l?void 0:l.mode)||"linear",i.isCompleted=void 0!==(null==l?void 0:l.isCompleted)&&(null==l?void 0:l.isCompleted),i.totalSteps=1,i.navItems=[],i.contentItems=[],i.init(),i}return s(e,t),e.prototype.init=function(){this.createCollection(window.$hsStepperCollection,this),this.buildNav(),this.buildContent(),this.buildButtons(),this.setTotalSteps()},e.prototype.getUncompletedSteps=function(t){return void 0===t&&(t=!1),this.navItems.filter((function(e){var n=e.isCompleted,i=e.isSkip;return t?!n||i:!n&&!i}))},e.prototype.setTotalSteps=function(){var t=this;this.navItems.forEach((function(e){var n=e.index;n>t.totalSteps&&(t.totalSteps=n)}))},e.prototype.buildNav=function(){var t=this;this.el.querySelectorAll("[data-hs-stepper-nav-item]").forEach((function(e){return t.addNavItem(e)})),this.navItems.forEach((function(e){return t.buildNavItem(e)}))},e.prototype.buildNavItem=function(t){var e=this,n=t.index,i=t.isDisabled,s=t.el;n===this.currentIndex&&this.setCurrentNavItem(),("linear"!==this.mode||i)&&s.addEventListener("click",(function(){return e.handleNavItemClick(t)}))},e.prototype.addNavItem=function(t){var e=JSON.parse(t.getAttribute("data-hs-stepper-nav-item")),n=e.index,i=e.isFinal,s=void 0!==i&&i,o=e.isCompleted,r=void 0!==o&&o,l=e.isSkip,a=void 0!==l&&l,p=e.isOptional,c=void 0!==p&&p,d=e.isDisabled,u=void 0!==d&&d,h=e.isProcessed,m=void 0!==h&&h,f=e.hasError,v=void 0!==f&&f;r&&t.classList.add("success"),a&&t.classList.add("skipped"),u&&("BUTTON"!==t.tagName&&"INPUT"!==t.tagName||t.setAttribute("disabled","disabled"),t.classList.add("disabled")),v&&t.classList.add("error"),this.navItems.push({index:n,isFinal:s,isCompleted:r,isSkip:a,isOptional:c,isDisabled:u,isProcessed:m,hasError:v,el:t})},e.prototype.setCurrentNavItem=function(){var t=this;this.navItems.forEach((function(e){var n=e.index,i=e.el;n===t.currentIndex?t.setCurrentNavItemActions(i):t.unsetCurrentNavItemActions(i)}))},e.prototype.setCurrentNavItemActions=function(t){t.classList.add("active"),this.fireEvent("active",this.currentIndex),(0,l.dispatch)("active.hs.stepper",this.el,this.currentIndex)},e.prototype.getNavItem=function(t){return void 0===t&&(t=this.currentIndex),this.navItems.find((function(e){return e.index===t}))},e.prototype.setProcessedNavItemActions=function(t){t.isProcessed=!0,t.el.classList.add("processed")},e.prototype.setErrorNavItemActions=function(t){t.hasError=!0,t.el.classList.add("error")},e.prototype.unsetCurrentNavItemActions=function(t){t.classList.remove("active")},e.prototype.handleNavItemClick=function(t){var e=t.index;this.currentIndex=e,this.setCurrentNavItem(),this.setCurrentContentItem(),this.checkForTheFirstStep()},e.prototype.buildContent=function(){var t=this;this.el.querySelectorAll("[data-hs-stepper-content-item]").forEach((function(e){return t.addContentItem(e)})),this.navItems.forEach((function(e){return t.buildContentItem(e)}))},e.prototype.buildContentItem=function(t){t.index===this.currentIndex&&this.setCurrentContentItem()},e.prototype.addContentItem=function(t){var e=JSON.parse(t.getAttribute("data-hs-stepper-content-item")),n=e.index,i=e.isFinal,s=void 0!==i&&i,o=e.isCompleted,r=void 0!==o&&o,l=e.isSkip,a=void 0!==l&&l;r&&t.classList.add("success"),a&&t.classList.add("skipped"),this.contentItems.push({index:n,isFinal:s,isCompleted:r,isSkip:a,el:t})},e.prototype.setCurrentContentItem=function(){var t=this;if(this.isCompleted){var e=this.contentItems.find((function(t){return t.isFinal})),n=this.contentItems.filter((function(t){return!t.isFinal}));return e.el.style.display="",n.forEach((function(t){return t.el.style.display="none"})),!1}this.contentItems.forEach((function(e){var n=e.index,i=e.el;n===t.currentIndex?t.setCurrentContentItemActions(i):t.unsetCurrentContentItemActions(i)}))},e.prototype.hideAllContentItems=function(){this.contentItems.forEach((function(t){return t.el.style.display="none"}))},e.prototype.setCurrentContentItemActions=function(t){t.style.display=""},e.prototype.unsetCurrentContentItemActions=function(t){t.style.display="none"},e.prototype.disableAll=function(){var t=this.getNavItem(this.currentIndex);t.hasError=!1,t.isCompleted=!1,t.isDisabled=!1,t.el.classList.remove("error","success"),this.disableButtons()},e.prototype.disableNavItemActions=function(t){t.isDisabled=!0,t.el.classList.add("disabled")},e.prototype.enableNavItemActions=function(t){t.isDisabled=!1,t.el.classList.remove("disabled")},e.prototype.buildButtons=function(){this.backBtn=this.el.querySelector("[data-hs-stepper-back-btn]"),this.nextBtn=this.el.querySelector("[data-hs-stepper-next-btn]"),this.skipBtn=this.el.querySelector("[data-hs-stepper-skip-btn]"),this.completeStepBtn=this.el.querySelector("[data-hs-stepper-complete-step-btn]"),this.finishBtn=this.el.querySelector("[data-hs-stepper-finish-btn]"),this.resetBtn=this.el.querySelector("[data-hs-stepper-reset-btn]"),this.buildBackButton(),this.buildNextButton(),this.buildSkipButton(),this.buildCompleteStepButton(),this.buildFinishButton(),this.buildResetButton()},e.prototype.buildBackButton=function(){var t=this;this.backBtn&&(this.checkForTheFirstStep(),this.backBtn.addEventListener("click",(function(){if(t.handleBackButtonClick(),"linear"===t.mode){var e=t.navItems.find((function(e){return e.index===t.currentIndex})),n=t.contentItems.find((function(e){return e.index===t.currentIndex}));if(!e||!n)return;e.isCompleted&&(e.isCompleted=!1,e.isSkip=!1,e.el.classList.remove("success","skipped")),n.isCompleted&&(n.isCompleted=!1,n.isSkip=!1,n.el.classList.remove("success","skipped")),"linear"===t.mode&&t.currentIndex!==t.totalSteps&&(t.nextBtn&&(t.nextBtn.style.display=""),t.completeStepBtn&&(t.completeStepBtn.style.display="")),t.showSkipButton(),t.showFinishButton(),t.showCompleteStepButton()}})))},e.prototype.handleBackButtonClick=function(){1!==this.currentIndex&&("linear"===this.mode&&this.removeOptionalClasses(),this.currentIndex--,"linear"===this.mode&&this.removeOptionalClasses(),this.setCurrentNavItem(),this.setCurrentContentItem(),this.checkForTheFirstStep(),this.completeStepBtn&&this.changeTextAndDisableCompleteButtonIfStepCompleted(),this.fireEvent("back",this.currentIndex),(0,l.dispatch)("back.hs.stepper",this.el,this.currentIndex))},e.prototype.checkForTheFirstStep=function(){1===this.currentIndex?this.setToDisabled(this.backBtn):this.setToNonDisabled(this.backBtn)},e.prototype.setToDisabled=function(t){"BUTTON"!==t.tagName&&"INPUT"!==t.tagName||t.setAttribute("disabled","disabled"),t.classList.add("disabled")},e.prototype.setToNonDisabled=function(t){"BUTTON"!==t.tagName&&"INPUT"!==t.tagName||t.removeAttribute("disabled"),t.classList.remove("disabled")},e.prototype.buildNextButton=function(){var t=this;this.nextBtn&&this.nextBtn.addEventListener("click",(function(){var e;if(t.fireEvent("beforeNext",t.currentIndex),(0,l.dispatch)("beforeNext.hs.stepper",t.el,t.currentIndex),null===(e=t.getNavItem(t.currentIndex))||void 0===e?void 0:e.isProcessed)return t.disableAll(),!1;t.goToNext()}))},e.prototype.unsetProcessedNavItemActions=function(t){t.isProcessed=!1,t.el.classList.remove("processed")},e.prototype.handleNextButtonClick=function(t){if(void 0===t&&(t=!0),t)this.currentIndex===this.totalSteps?this.currentIndex=1:this.currentIndex++;else{var e=this.getUncompletedSteps();if(1===e.length){var n=e[0].index;this.currentIndex=n}else{if(this.currentIndex===this.totalSteps)return;this.currentIndex++}}"linear"===this.mode&&this.removeOptionalClasses(),this.setCurrentNavItem(),this.setCurrentContentItem(),this.checkForTheFirstStep(),this.completeStepBtn&&this.changeTextAndDisableCompleteButtonIfStepCompleted(),this.showSkipButton(),this.showFinishButton(),this.showCompleteStepButton(),this.fireEvent("next",this.currentIndex),(0,l.dispatch)("next.hs.stepper",this.el,this.currentIndex)},e.prototype.removeOptionalClasses=function(){var t=this,e=this.navItems.find((function(e){return e.index===t.currentIndex})),n=this.contentItems.find((function(e){return e.index===t.currentIndex}));e.isSkip=!1,e.hasError=!1,e.isDisabled=!1,n.isSkip=!1,e.el.classList.remove("skipped","success","error"),n.el.classList.remove("skipped","success","error")},e.prototype.buildSkipButton=function(){var t=this;this.skipBtn&&(this.showSkipButton(),this.skipBtn.addEventListener("click",(function(){t.handleSkipButtonClick(),"linear"===t.mode&&t.currentIndex===t.totalSteps&&(t.nextBtn&&(t.nextBtn.style.display="none"),t.completeStepBtn&&(t.completeStepBtn.style.display="none"),t.finishBtn&&(t.finishBtn.style.display=""))})))},e.prototype.setSkipItem=function(t){var e=this,n=this.navItems.find((function(n){return n.index===(t||e.currentIndex)})),i=this.contentItems.find((function(n){return n.index===(t||e.currentIndex)}));n&&i&&(this.setSkipItemActions(n),this.setSkipItemActions(i))},e.prototype.setSkipItemActions=function(t){t.isSkip=!0,t.el.classList.add("skipped")},e.prototype.showSkipButton=function(){var t=this;if(this.skipBtn){var e=this.navItems.find((function(e){return e.index===t.currentIndex})).isOptional;this.skipBtn.style.display=e?"":"none"}},e.prototype.handleSkipButtonClick=function(){this.setSkipItem(),this.handleNextButtonClick(),this.fireEvent("skip",this.currentIndex),(0,l.dispatch)("skip.hs.stepper",this.el,this.currentIndex)},e.prototype.buildCompleteStepButton=function(){var t=this;this.completeStepBtn&&(this.completeStepBtnDefaultText=this.completeStepBtn.innerText,this.completeStepBtn.addEventListener("click",(function(){return t.handleCompleteStepButtonClick()})))},e.prototype.changeTextAndDisableCompleteButtonIfStepCompleted=function(){var t=this,e=this.navItems.find((function(e){return e.index===t.currentIndex})),n=JSON.parse(this.completeStepBtn.getAttribute("data-hs-stepper-complete-step-btn")).completedText;e&&(e.isCompleted?(this.completeStepBtn.innerText=n||this.completeStepBtnDefaultText,this.completeStepBtn.setAttribute("disabled","disabled"),this.completeStepBtn.classList.add("disabled")):(this.completeStepBtn.innerText=this.completeStepBtnDefaultText,this.completeStepBtn.removeAttribute("disabled"),this.completeStepBtn.classList.remove("disabled")))},e.prototype.setCompleteItem=function(t){var e=this,n=this.navItems.find((function(n){return n.index===(t||e.currentIndex)})),i=this.contentItems.find((function(n){return n.index===(t||e.currentIndex)}));n&&i&&(this.setCompleteItemActions(n),this.setCompleteItemActions(i))},e.prototype.setCompleteItemActions=function(t){t.isCompleted=!0,t.el.classList.add("success")},e.prototype.showCompleteStepButton=function(){this.completeStepBtn&&(1===this.getUncompletedSteps().length?this.completeStepBtn.style.display="none":this.completeStepBtn.style.display="")},e.prototype.handleCompleteStepButtonClick=function(){this.setCompleteItem(),this.fireEvent("complete",this.currentIndex),(0,l.dispatch)("complete.hs.stepper",this.el,this.currentIndex),this.handleNextButtonClick(!1),this.showFinishButton(),this.showCompleteStepButton(),this.checkForTheFirstStep(),this.completeStepBtn&&this.changeTextAndDisableCompleteButtonIfStepCompleted(),this.showSkipButton()},e.prototype.buildFinishButton=function(){var t=this;this.finishBtn&&(this.isCompleted&&this.setCompleted(),this.finishBtn.addEventListener("click",(function(){return t.handleFinishButtonClick()})))},e.prototype.setCompleted=function(){this.el.classList.add("completed")},e.prototype.unsetCompleted=function(){this.el.classList.remove("completed")},e.prototype.showFinishButton=function(){this.finishBtn&&(1===this.getUncompletedSteps().length?this.finishBtn.style.display="":this.finishBtn.style.display="none")},e.prototype.handleFinishButtonClick=function(){var t=this,e=this.getUncompletedSteps(),n=this.getUncompletedSteps(!0),i=this.contentItems.find((function(t){return t.isFinal})).el;e.length&&e.forEach((function(e){var n=e.index;return t.setCompleteItem(n)})),this.currentIndex=this.totalSteps,this.setCurrentNavItem(),this.hideAllContentItems();var s=this.navItems.find((function(e){return e.index===t.currentIndex}));(s?s.el:null).classList.remove("active"),i.style.display="block",this.backBtn&&(this.backBtn.style.display="none"),this.nextBtn&&(this.nextBtn.style.display="none"),this.skipBtn&&(this.skipBtn.style.display="none"),this.completeStepBtn&&(this.completeStepBtn.style.display="none"),this.finishBtn&&(this.finishBtn.style.display="none"),this.resetBtn&&(this.resetBtn.style.display=""),n.length<=1&&(this.isCompleted=!0,this.setCompleted()),this.fireEvent("finish",this.currentIndex),(0,l.dispatch)("finish.hs.stepper",this.el,this.currentIndex)},e.prototype.buildResetButton=function(){var t=this;this.resetBtn&&this.resetBtn.addEventListener("click",(function(){return t.handleResetButtonClick()}))},e.prototype.handleResetButtonClick=function(){var t=this;this.backBtn&&(this.backBtn.style.display=""),this.nextBtn&&(this.nextBtn.style.display=""),this.completeStepBtn&&(this.completeStepBtn.style.display="",this.completeStepBtn.innerText=this.completeStepBtnDefaultText,this.completeStepBtn.removeAttribute("disabled"),this.completeStepBtn.classList.remove("disabled")),this.resetBtn&&(this.resetBtn.style.display="none"),this.navItems.forEach((function(e){var n=e.el;e.isSkip=!1,e.isCompleted=!1,t.unsetCurrentNavItemActions(n),n.classList.remove("success","skipped")})),this.contentItems.forEach((function(e){var n=e.el;e.isSkip=!1,e.isCompleted=!1,t.unsetCurrentContentItemActions(n),n.classList.remove("success","skipped")})),this.currentIndex=1,this.setCurrentNavItem(),this.setCurrentContentItem(),this.showFinishButton(),this.showCompleteStepButton(),this.checkForTheFirstStep(),this.unsetCompleted(),this.isCompleted=!1,this.fireEvent("reset",this.currentIndex),(0,l.dispatch)("reset.hs.stepper",this.el,this.currentIndex)},e.prototype.setProcessedNavItem=function(t){var e=this.getNavItem(t);e&&this.setProcessedNavItemActions(e)},e.prototype.unsetProcessedNavItem=function(t){var e=this.getNavItem(t);e&&this.unsetProcessedNavItemActions(e)},e.prototype.goToNext=function(){"linear"===this.mode&&this.setCompleteItem(),this.handleNextButtonClick("linear"!==this.mode),"linear"===this.mode&&this.currentIndex===this.totalSteps&&(this.nextBtn&&(this.nextBtn.style.display="none"),this.completeStepBtn&&(this.completeStepBtn.style.display="none"))},e.prototype.disableButtons=function(){this.backBtn&&this.setToDisabled(this.backBtn),this.nextBtn&&this.setToDisabled(this.nextBtn)},e.prototype.enableButtons=function(){this.backBtn&&this.setToNonDisabled(this.backBtn),this.nextBtn&&this.setToNonDisabled(this.nextBtn)},e.prototype.setErrorNavItem=function(t){var e=this.getNavItem(t);e&&this.setErrorNavItemActions(e)},e.getInstance=function(t,e){var n=window.$hsStepperCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return n?e?n:n.element:null},e.autoInit=function(){window.$hsStepperCollection||(window.$hsStepperCollection=[]),document.querySelectorAll("[data-hs-stepper]:not(.--prevent-on-load-init)").forEach((function(t){window.$hsStepperCollection.find((function(e){var n;return(null===(n=null==e?void 0:e.element)||void 0===n?void 0:n.el)===t}))||new e(t)}))},e}(r(n(737)).default);window.addEventListener("load",(function(){a.autoInit()})),"undefined"!=typeof window&&(window.HSStepper=a),e.default=a},969:function(t,e){var n=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getClassPropertyAlt=e.getClassProperty=e.stringToBoolean=void 0;e.stringToBoolean=function(t){return"true"===t};e.getClassProperty=function(t,e,n){return void 0===n&&(n=""),(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ","")};e.getClassPropertyAlt=function(t,e,n){void 0===n&&(n="");var i="";return t.classList.forEach((function(t){t.includes(e)&&(i=t)})),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:n};e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isEnoughSpace=function(t,e,n,i,s){void 0===n&&(n="auto"),void 0===i&&(i=10),void 0===s&&(s=null);var o=e.getBoundingClientRect(),r=s?s.getBoundingClientRect():null,l=window.innerHeight,a=r?o.top-r.top:o.top,p=(s?r.bottom:l)-o.bottom,c=t.clientHeight+i;return"bottom"===n?p>=c:"top"===n?a>=c:a>=c||p>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var i=function(t){return!!t&&("none"===window.getComputedStyle(t).display||i(t.parentElement))};e.isParentOrElementHidden=i;e.debounce=function(t,e){var i;return void 0===e&&(e=200),function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];clearTimeout(i),i=setTimeout((function(){t.apply(n,s)}),e)}};e.dispatch=function(t,e,n){void 0===n&&(n=null);var i=new CustomEvent(t,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(i)};e.afterTransition=function(t,e){var n=function(){e(),t.removeEventListener("transitionend",n,!0)};window.getComputedStyle(t,null).getPropertyValue("transition")!==(navigator.userAgent.includes("Firefox")?"all":"all 0s ease 0s")?t.addEventListener("transitionend",n,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,n,i){void 0===n&&(n=" "),void 0===i&&(i="add"),t.split(n).forEach((function(t){return"add"===i?e.classList.add(t):e.classList.remove(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var n=function n(i){var s=e[i];if(void 0!==s)return s.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(957);return n})()));
var i,s=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),o=this&&this.__assign||function(){return o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},o.apply(this,arguments)},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var l=n(292),a=function(t){function e(e,n){var i=t.call(this,e,n)||this,s=e.getAttribute("data-hs-stepper"),r=s?JSON.parse(s):{},l=o(o({},r),n);return i.currentIndex=(null==l?void 0:l.currentIndex)||1,i.mode=(null==l?void 0:l.mode)||"linear",i.isCompleted=void 0!==(null==l?void 0:l.isCompleted)&&(null==l?void 0:l.isCompleted),i.totalSteps=1,i.navItems=[],i.contentItems=[],i.init(),i}return s(e,t),e.prototype.init=function(){this.createCollection(window.$hsStepperCollection,this),this.buildNav(),this.buildContent(),this.buildButtons(),this.setTotalSteps()},e.prototype.getUncompletedSteps=function(t){return void 0===t&&(t=!1),this.navItems.filter((function(e){var n=e.isCompleted,i=e.isSkip;return t?!n||i:!n&&!i}))},e.prototype.setTotalSteps=function(){var t=this;this.navItems.forEach((function(e){var n=e.index;n>t.totalSteps&&(t.totalSteps=n)}))},e.prototype.buildNav=function(){var t=this;this.el.querySelectorAll("[data-hs-stepper-nav-item]").forEach((function(e){return t.addNavItem(e)})),this.navItems.forEach((function(e){return t.buildNavItem(e)}))},e.prototype.buildNavItem=function(t){var e=this,n=t.index,i=t.isDisabled,s=t.el;n===this.currentIndex&&this.setCurrentNavItem(),("linear"!==this.mode||i)&&s.addEventListener("click",(function(){return e.handleNavItemClick(t)}))},e.prototype.addNavItem=function(t){var e=JSON.parse(t.getAttribute("data-hs-stepper-nav-item")),n=e.index,i=e.isFinal,s=void 0!==i&&i,o=e.isCompleted,r=void 0!==o&&o,l=e.isSkip,a=void 0!==l&&l,p=e.isOptional,c=void 0!==p&&p,d=e.isDisabled,u=void 0!==d&&d,h=e.isProcessed,m=void 0!==h&&h,f=e.hasError,v=void 0!==f&&f;r&&t.classList.add("success"),a&&t.classList.add("skipped"),u&&("BUTTON"!==t.tagName&&"INPUT"!==t.tagName||t.setAttribute("disabled","disabled"),t.classList.add("disabled")),v&&t.classList.add("error"),this.navItems.push({index:n,isFinal:s,isCompleted:r,isSkip:a,isOptional:c,isDisabled:u,isProcessed:m,hasError:v,el:t})},e.prototype.setCurrentNavItem=function(){var t=this;this.navItems.forEach((function(e){var n=e.index,i=e.el;n===t.currentIndex?t.setCurrentNavItemActions(i):t.unsetCurrentNavItemActions(i)}))},e.prototype.setCurrentNavItemActions=function(t){t.classList.add("active"),this.fireEvent("active",this.currentIndex),(0,l.dispatch)("active.hs.stepper",this.el,this.currentIndex)},e.prototype.getNavItem=function(t){return void 0===t&&(t=this.currentIndex),this.navItems.find((function(e){return e.index===t}))},e.prototype.setProcessedNavItemActions=function(t){t.isProcessed=!0,t.el.classList.add("processed")},e.prototype.setErrorNavItemActions=function(t){t.hasError=!0,t.el.classList.add("error")},e.prototype.unsetCurrentNavItemActions=function(t){t.classList.remove("active")},e.prototype.handleNavItemClick=function(t){var e=t.index;this.currentIndex=e,this.setCurrentNavItem(),this.setCurrentContentItem(),this.checkForTheFirstStep()},e.prototype.buildContent=function(){var t=this;this.el.querySelectorAll("[data-hs-stepper-content-item]").forEach((function(e){return t.addContentItem(e)})),this.navItems.forEach((function(e){return t.buildContentItem(e)}))},e.prototype.buildContentItem=function(t){t.index===this.currentIndex&&this.setCurrentContentItem()},e.prototype.addContentItem=function(t){var e=JSON.parse(t.getAttribute("data-hs-stepper-content-item")),n=e.index,i=e.isFinal,s=void 0!==i&&i,o=e.isCompleted,r=void 0!==o&&o,l=e.isSkip,a=void 0!==l&&l;r&&t.classList.add("success"),a&&t.classList.add("skipped"),this.contentItems.push({index:n,isFinal:s,isCompleted:r,isSkip:a,el:t})},e.prototype.setCurrentContentItem=function(){var t=this;if(this.isCompleted){var e=this.contentItems.find((function(t){return t.isFinal})),n=this.contentItems.filter((function(t){return!t.isFinal}));return e.el.style.display="",n.forEach((function(t){return t.el.style.display="none"})),!1}this.contentItems.forEach((function(e){var n=e.index,i=e.el;n===t.currentIndex?t.setCurrentContentItemActions(i):t.unsetCurrentContentItemActions(i)}))},e.prototype.hideAllContentItems=function(){this.contentItems.forEach((function(t){return t.el.style.display="none"}))},e.prototype.setCurrentContentItemActions=function(t){t.style.display=""},e.prototype.unsetCurrentContentItemActions=function(t){t.style.display="none"},e.prototype.disableAll=function(){var t=this.getNavItem(this.currentIndex);t.hasError=!1,t.isCompleted=!1,t.isDisabled=!1,t.el.classList.remove("error","success"),this.disableButtons()},e.prototype.disableNavItemActions=function(t){t.isDisabled=!0,t.el.classList.add("disabled")},e.prototype.enableNavItemActions=function(t){t.isDisabled=!1,t.el.classList.remove("disabled")},e.prototype.buildButtons=function(){this.backBtn=this.el.querySelector("[data-hs-stepper-back-btn]"),this.nextBtn=this.el.querySelector("[data-hs-stepper-next-btn]"),this.skipBtn=this.el.querySelector("[data-hs-stepper-skip-btn]"),this.completeStepBtn=this.el.querySelector("[data-hs-stepper-complete-step-btn]"),this.finishBtn=this.el.querySelector("[data-hs-stepper-finish-btn]"),this.resetBtn=this.el.querySelector("[data-hs-stepper-reset-btn]"),this.buildBackButton(),this.buildNextButton(),this.buildSkipButton(),this.buildCompleteStepButton(),this.buildFinishButton(),this.buildResetButton()},e.prototype.buildBackButton=function(){var t=this;this.backBtn&&(this.checkForTheFirstStep(),this.backBtn.addEventListener("click",(function(){if(t.handleBackButtonClick(),"linear"===t.mode){var e=t.navItems.find((function(e){return e.index===t.currentIndex})),n=t.contentItems.find((function(e){return e.index===t.currentIndex}));if(!e||!n)return;e.isCompleted&&(e.isCompleted=!1,e.isSkip=!1,e.el.classList.remove("success","skipped")),n.isCompleted&&(n.isCompleted=!1,n.isSkip=!1,n.el.classList.remove("success","skipped")),"linear"===t.mode&&t.currentIndex!==t.totalSteps&&(t.nextBtn&&(t.nextBtn.style.display=""),t.completeStepBtn&&(t.completeStepBtn.style.display="")),t.showSkipButton(),t.showFinishButton(),t.showCompleteStepButton()}})))},e.prototype.handleBackButtonClick=function(){1!==this.currentIndex&&("linear"===this.mode&&this.removeOptionalClasses(),this.currentIndex--,"linear"===this.mode&&this.removeOptionalClasses(),this.setCurrentNavItem(),this.setCurrentContentItem(),this.checkForTheFirstStep(),this.completeStepBtn&&this.changeTextAndDisableCompleteButtonIfStepCompleted(),this.fireEvent("back",this.currentIndex),(0,l.dispatch)("back.hs.stepper",this.el,this.currentIndex))},e.prototype.checkForTheFirstStep=function(){1===this.currentIndex?this.setToDisabled(this.backBtn):this.setToNonDisabled(this.backBtn)},e.prototype.setToDisabled=function(t){"BUTTON"!==t.tagName&&"INPUT"!==t.tagName||t.setAttribute("disabled","disabled"),t.classList.add("disabled")},e.prototype.setToNonDisabled=function(t){"BUTTON"!==t.tagName&&"INPUT"!==t.tagName||t.removeAttribute("disabled"),t.classList.remove("disabled")},e.prototype.buildNextButton=function(){var t=this;this.nextBtn&&this.nextBtn.addEventListener("click",(function(){var e;if(t.fireEvent("beforeNext",t.currentIndex),(0,l.dispatch)("beforeNext.hs.stepper",t.el,t.currentIndex),null===(e=t.getNavItem(t.currentIndex))||void 0===e?void 0:e.isProcessed)return t.disableAll(),!1;t.goToNext()}))},e.prototype.unsetProcessedNavItemActions=function(t){t.isProcessed=!1,t.el.classList.remove("processed")},e.prototype.handleNextButtonClick=function(t){if(void 0===t&&(t=!0),t)this.currentIndex===this.totalSteps?this.currentIndex=1:this.currentIndex++;else{var e=this.getUncompletedSteps();if(1===e.length){var n=e[0].index;this.currentIndex=n}else{if(this.currentIndex===this.totalSteps)return;this.currentIndex++}}"linear"===this.mode&&this.removeOptionalClasses(),this.setCurrentNavItem(),this.setCurrentContentItem(),this.checkForTheFirstStep(),this.completeStepBtn&&this.changeTextAndDisableCompleteButtonIfStepCompleted(),this.showSkipButton(),this.showFinishButton(),this.showCompleteStepButton(),this.fireEvent("next",this.currentIndex),(0,l.dispatch)("next.hs.stepper",this.el,this.currentIndex)},e.prototype.removeOptionalClasses=function(){var t=this,e=this.navItems.find((function(e){return e.index===t.currentIndex})),n=this.contentItems.find((function(e){return e.index===t.currentIndex}));e.isSkip=!1,e.hasError=!1,e.isDisabled=!1,n.isSkip=!1,e.el.classList.remove("skipped","success","error"),n.el.classList.remove("skipped","success","error")},e.prototype.buildSkipButton=function(){var t=this;this.skipBtn&&(this.showSkipButton(),this.skipBtn.addEventListener("click",(function(){t.handleSkipButtonClick(),"linear"===t.mode&&t.currentIndex===t.totalSteps&&(t.nextBtn&&(t.nextBtn.style.display="none"),t.completeStepBtn&&(t.completeStepBtn.style.display="none"),t.finishBtn&&(t.finishBtn.style.display=""))})))},e.prototype.setSkipItem=function(t){var e=this,n=this.navItems.find((function(n){return n.index===(t||e.currentIndex)})),i=this.contentItems.find((function(n){return n.index===(t||e.currentIndex)}));n&&i&&(this.setSkipItemActions(n),this.setSkipItemActions(i))},e.prototype.setSkipItemActions=function(t){t.isSkip=!0,t.el.classList.add("skipped")},e.prototype.showSkipButton=function(){var t=this;if(this.skipBtn){var e=this.navItems.find((function(e){return e.index===t.currentIndex})).isOptional;this.skipBtn.style.display=e?"":"none"}},e.prototype.handleSkipButtonClick=function(){this.setSkipItem(),this.handleNextButtonClick(),this.fireEvent("skip",this.currentIndex),(0,l.dispatch)("skip.hs.stepper",this.el,this.currentIndex)},e.prototype.buildCompleteStepButton=function(){var t=this;this.completeStepBtn&&(this.completeStepBtnDefaultText=this.completeStepBtn.innerText,this.completeStepBtn.addEventListener("click",(function(){return t.handleCompleteStepButtonClick()})))},e.prototype.changeTextAndDisableCompleteButtonIfStepCompleted=function(){var t=this,e=this.navItems.find((function(e){return e.index===t.currentIndex})),n=JSON.parse(this.completeStepBtn.getAttribute("data-hs-stepper-complete-step-btn")).completedText;e&&(e.isCompleted?(this.completeStepBtn.innerText=n||this.completeStepBtnDefaultText,this.completeStepBtn.setAttribute("disabled","disabled"),this.completeStepBtn.classList.add("disabled")):(this.completeStepBtn.innerText=this.completeStepBtnDefaultText,this.completeStepBtn.removeAttribute("disabled"),this.completeStepBtn.classList.remove("disabled")))},e.prototype.setCompleteItem=function(t){var e=this,n=this.navItems.find((function(n){return n.index===(t||e.currentIndex)})),i=this.contentItems.find((function(n){return n.index===(t||e.currentIndex)}));n&&i&&(this.setCompleteItemActions(n),this.setCompleteItemActions(i))},e.prototype.setCompleteItemActions=function(t){t.isCompleted=!0,t.el.classList.add("success")},e.prototype.showCompleteStepButton=function(){this.completeStepBtn&&(1===this.getUncompletedSteps().length?this.completeStepBtn.style.display="none":this.completeStepBtn.style.display="")},e.prototype.handleCompleteStepButtonClick=function(){this.setCompleteItem(),this.fireEvent("complete",this.currentIndex),(0,l.dispatch)("complete.hs.stepper",this.el,this.currentIndex),this.handleNextButtonClick(!1),this.showFinishButton(),this.showCompleteStepButton(),this.checkForTheFirstStep(),this.completeStepBtn&&this.changeTextAndDisableCompleteButtonIfStepCompleted(),this.showSkipButton()},e.prototype.buildFinishButton=function(){var t=this;this.finishBtn&&(this.isCompleted&&this.setCompleted(),this.finishBtn.addEventListener("click",(function(){return t.handleFinishButtonClick()})))},e.prototype.setCompleted=function(){this.el.classList.add("completed")},e.prototype.unsetCompleted=function(){this.el.classList.remove("completed")},e.prototype.showFinishButton=function(){this.finishBtn&&(1===this.getUncompletedSteps().length?this.finishBtn.style.display="":this.finishBtn.style.display="none")},e.prototype.handleFinishButtonClick=function(){var t=this,e=this.getUncompletedSteps(),n=this.getUncompletedSteps(!0),i=this.contentItems.find((function(t){return t.isFinal})).el;e.length&&e.forEach((function(e){var n=e.index;return t.setCompleteItem(n)})),this.currentIndex=this.totalSteps,this.setCurrentNavItem(),this.hideAllContentItems();var s=this.navItems.find((function(e){return e.index===t.currentIndex}));(s?s.el:null).classList.remove("active"),i.style.display="block",this.backBtn&&(this.backBtn.style.display="none"),this.nextBtn&&(this.nextBtn.style.display="none"),this.skipBtn&&(this.skipBtn.style.display="none"),this.completeStepBtn&&(this.completeStepBtn.style.display="none"),this.finishBtn&&(this.finishBtn.style.display="none"),this.resetBtn&&(this.resetBtn.style.display=""),n.length<=1&&(this.isCompleted=!0,this.setCompleted()),this.fireEvent("finish",this.currentIndex),(0,l.dispatch)("finish.hs.stepper",this.el,this.currentIndex)},e.prototype.buildResetButton=function(){var t=this;this.resetBtn&&this.resetBtn.addEventListener("click",(function(){return t.handleResetButtonClick()}))},e.prototype.handleResetButtonClick=function(){var t=this;this.backBtn&&(this.backBtn.style.display=""),this.nextBtn&&(this.nextBtn.style.display=""),this.completeStepBtn&&(this.completeStepBtn.style.display="",this.completeStepBtn.innerText=this.completeStepBtnDefaultText,this.completeStepBtn.removeAttribute("disabled"),this.completeStepBtn.classList.remove("disabled")),this.resetBtn&&(this.resetBtn.style.display="none"),this.navItems.forEach((function(e){var n=e.el;e.isSkip=!1,e.isCompleted=!1,t.unsetCurrentNavItemActions(n),n.classList.remove("success","skipped")})),this.contentItems.forEach((function(e){var n=e.el;e.isSkip=!1,e.isCompleted=!1,t.unsetCurrentContentItemActions(n),n.classList.remove("success","skipped")})),this.currentIndex=1,this.setCurrentNavItem(),this.setCurrentContentItem(),this.showFinishButton(),this.showCompleteStepButton(),this.checkForTheFirstStep(),this.unsetCompleted(),this.isCompleted=!1,this.fireEvent("reset",this.currentIndex),(0,l.dispatch)("reset.hs.stepper",this.el,this.currentIndex)},e.prototype.setProcessedNavItem=function(t){var e=this.getNavItem(t);e&&this.setProcessedNavItemActions(e)},e.prototype.unsetProcessedNavItem=function(t){var e=this.getNavItem(t);e&&this.unsetProcessedNavItemActions(e)},e.prototype.goToNext=function(){"linear"===this.mode&&this.setCompleteItem(),this.handleNextButtonClick("linear"!==this.mode),"linear"===this.mode&&this.currentIndex===this.totalSteps&&(this.nextBtn&&(this.nextBtn.style.display="none"),this.completeStepBtn&&(this.completeStepBtn.style.display="none"))},e.prototype.disableButtons=function(){this.backBtn&&this.setToDisabled(this.backBtn),this.nextBtn&&this.setToDisabled(this.nextBtn)},e.prototype.enableButtons=function(){this.backBtn&&this.setToNonDisabled(this.backBtn),this.nextBtn&&this.setToNonDisabled(this.nextBtn)},e.prototype.setErrorNavItem=function(t){var e=this.getNavItem(t);e&&this.setErrorNavItemActions(e)},e.getInstance=function(t,e){var n=window.$hsStepperCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return n?e?n:n.element:null},e.autoInit=function(){window.$hsStepperCollection||(window.$hsStepperCollection=[]),document.querySelectorAll("[data-hs-stepper]:not(.--prevent-on-load-init)").forEach((function(t){window.$hsStepperCollection.find((function(e){var n;return(null===(n=null==e?void 0:e.element)||void 0===n?void 0:n.el)===t}))||new e(t)}))},e}(r(n(961)).default);window.addEventListener("load",(function(){a.autoInit()})),"undefined"!=typeof window&&(window.HSStepper=a),e.default=a},292:function(t,e){var n=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getZIndex=e.getClassPropertyAlt=e.getClassProperty=e.stringToBoolean=void 0,e.getHighestZIndex=function(t){var e=Number.NEGATIVE_INFINITY;return t.forEach((function(t){var n=i(t);"auto"!==n&&(n=parseInt(n,10))>e&&(e=n)})),e};e.stringToBoolean=function(t){return"true"===t};e.getClassProperty=function(t,e,n){return void 0===n&&(n=""),(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ","")};e.getClassPropertyAlt=function(t,e,n){void 0===n&&(n="");var i="";return t.classList.forEach((function(t){t.includes(e)&&(i=t)})),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:n};var i=function(t){return window.getComputedStyle(t).getPropertyValue("z-index")};e.getZIndex=i;e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isEnoughSpace=function(t,e,n,i,s){void 0===n&&(n="auto"),void 0===i&&(i=10),void 0===s&&(s=null);var o=e.getBoundingClientRect(),r=s?s.getBoundingClientRect():null,l=window.innerHeight,a=r?o.top-r.top:o.top,p=(s?r.bottom:l)-o.bottom,c=t.clientHeight+i;return"bottom"===n?p>=c:"top"===n?a>=c:a>=c||p>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var s=function(t){return!!t&&("none"===window.getComputedStyle(t).display||s(t.parentElement))};e.isParentOrElementHidden=s;e.debounce=function(t,e){var i;return void 0===e&&(e=200),function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];clearTimeout(i),i=setTimeout((function(){t.apply(n,s)}),e)}};e.dispatch=function(t,e,n){void 0===n&&(n=null);var i=new CustomEvent(t,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(i)};e.afterTransition=function(t,e){var n=function(){e(),t.removeEventListener("transitionend",n,!0)};window.getComputedStyle(t,null).getPropertyValue("transition")!==(navigator.userAgent.includes("Firefox")?"all":"all 0s ease 0s")?t.addEventListener("transitionend",n,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,n,i){void 0===n&&(n=" "),void 0===i&&(i="add"),t.split(n).forEach((function(t){return"add"===i?e.classList.add(t):e.classList.remove(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var n=function n(i){var s=e[i];if(void 0!==s)return s.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(887);return n})()));
{
"name": "@preline/stepper",
"version": "2.3.0",
"version": "2.4.0",
"description": "Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc