CommonStepper.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { FormStep } from '#shared/components/Form/types.ts'
  5. import CommonStepperStep from './CommonStepperStep.vue'
  6. interface Props {
  7. modelValue: string
  8. steps: Record<string, FormStep>
  9. }
  10. const props = defineProps<Props>()
  11. const emit = defineEmits<{
  12. 'update:modelValue': [string]
  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>