{"version":3,"file":"useDpiStepper.mjs","sources":["../../../lib/data-provider-interface/composables/useDpiStepper.ts"],"sourcesContent":["import { provide, ref, computed } from 'vue';\nimport { dpiStepperKey } from '../utils/injectionKeys';\nimport useSteps from '../utils/useSteps.js';\n\n/**\n * Provides the stepper state and methods to manage stepper.\n */\nexport function useDpiStepper() {\n  const { steps, activeStep, stepPlugin, visitedSteps } = useSteps();\n  const stepList = ref([] as string[]);\n  const activeStepIndex = computed(() => stepList.value.indexOf(activeStep.value));\n  \n  const previousStep = computed(() => {\n    const previousStepIndex = activeStepIndex.value - 1;\n    if (previousStepIndex >= 0) {\n      return stepList.value[previousStepIndex];\n    }\n    return '';\n  });\n\n  const nextStep = computed(() => {\n    const nextStepIndex = activeStepIndex.value + 1;\n    if (nextStepIndex < stepList.value.length) {\n      return stepList.value[nextStepIndex];\n    }\n    return '';\n  });\n\n  const registerStep = (stepName: string) => {\n    if (!stepList.value.includes(stepName)) {\n      stepList.value.push(stepName);\n    }\n  };\n\n  const goToNextStep = () => {\n    const nextStepIndex = activeStepIndex.value + 1;\n    if (nextStepIndex < stepList.value.length) {\n      activeStep.value = stepList.value[nextStepIndex];\n    }\n  }\n\n  const goToPreviousStep = () => {\n    const previousStepIndex = activeStepIndex.value - 1;\n    if (previousStepIndex >= 0) {\n      activeStep.value = stepList.value[previousStepIndex];\n    }\n  }\n\n  const goToStep = (stepName: string) => {\n    if (stepList.value.includes(stepName)) {\n      activeStep.value = stepName;\n    }\n  }\n\n  const goToStepByIndex = (index: number) => {\n    if (index >= 0 && index < stepList.value.length) {\n      activeStep.value = stepList.value[index];\n    }\n  }\n\n  provide(dpiStepperKey, {\n    steps,\n    activeStep,\n    registerStep,\n  });\n\n  return {\n    steps,\n    activeStep,\n    activeStepIndex,\n    previousStep,\n    nextStep,\n    visitedSteps,\n    stepPlugin,\n    stepList,\n    registerStep,\n    goToNextStep,\n    goToPreviousStep,\n    goToStep,\n    goToStepByIndex,\n  }\n}"],"names":["useDpiStepper","steps","activeStep","stepPlugin","visitedSteps","useSteps","stepList","ref","activeStepIndex","computed","previousStep","previousStepIndex","nextStep","nextStepIndex","registerStep","stepName","goToNextStep","goToPreviousStep","goToStep","goToStepByIndex","index","provide","dpiStepperKey"],"mappings":";;;AAOO,SAASA,IAAgB;AAC9B,QAAM,EAAE,OAAAC,GAAO,YAAAC,GAAY,YAAAC,GAAY,cAAAC,EAAA,IAAiBC,KAClDC,IAAWC,EAAI,CAAA,CAAc,GAC7BC,IAAkBC,EAAS,MAAMH,EAAS,MAAM,QAAQJ,EAAW,KAAK,CAAC,GAEzEQ,IAAeD,EAAS,MAAM;AAC5B,UAAAE,IAAoBH,EAAgB,QAAQ;AAClD,WAAIG,KAAqB,IAChBL,EAAS,MAAMK,CAAiB,IAElC;AAAA,EAAA,CACR,GAEKC,IAAWH,EAAS,MAAM;AACxB,UAAAI,IAAgBL,EAAgB,QAAQ;AAC1C,WAAAK,IAAgBP,EAAS,MAAM,SAC1BA,EAAS,MAAMO,CAAa,IAE9B;AAAA,EAAA,CACR,GAEKC,IAAe,CAACC,MAAqB;AACzC,IAAKT,EAAS,MAAM,SAASS,CAAQ,KAC1BT,EAAA,MAAM,KAAKS,CAAQ;AAAA,EAC9B,GAGIC,IAAe,MAAM;AACnB,UAAAH,IAAgBL,EAAgB,QAAQ;AAC1C,IAAAK,IAAgBP,EAAS,MAAM,WACtBJ,EAAA,QAAQI,EAAS,MAAMO,CAAa;AAAA,EACjD,GAGII,IAAmB,MAAM;AACvB,UAAAN,IAAoBH,EAAgB,QAAQ;AAClD,IAAIG,KAAqB,MACZT,EAAA,QAAQI,EAAS,MAAMK,CAAiB;AAAA,EACrD,GAGIO,IAAW,CAACH,MAAqB;AACrC,IAAIT,EAAS,MAAM,SAASS,CAAQ,MAClCb,EAAW,QAAQa;AAAA,EACrB,GAGII,IAAkB,CAACC,MAAkB;AACzC,IAAIA,KAAS,KAAKA,IAAQd,EAAS,MAAM,WAC5BJ,EAAA,QAAQI,EAAS,MAAM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