CommonStepper.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!-- Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { CommonStepperStep as Step } from './types'
  5. import CommonStepperStep from './CommonStepperStep.vue'
  6. interface Props {
  7. modelValue: string
  8. steps: Record<string, Step>
  9. }
  10. const props = defineProps<Props>()
  11. const emit = defineEmits<{
  12. (e: 'update:modelValue', value: string): void
  13. }>()
  14. const localSteps = computed(() => {
  15. return Object.entries(props.steps).sort(([, a], [, b]) => a.order - b.order)
  16. })
  17. </script>
  18. <template>
  19. <div class="flex justify-center text-base">
  20. <template v-for="([name, step], idx) of localSteps" :key="name">
  21. <div class="flex" :class="{ 'flex-1': idx !== localSteps.length - 1 }">
  22. <CommonStepperStep
  23. v-bind="step"
  24. :selected="name === modelValue"
  25. @click="emit('update:modelValue', name)"
  26. />
  27. <div
  28. v-if="idx !== localSteps.length - 1"
  29. class="mx-2 h-px flex-1 self-center bg-white/20"
  30. />
  31. </div>
  32. </template>
  33. </div>
  34. </template>