FieldToggleButtonsInput.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, toRef } from 'vue'
  4. import useValue from '#shared/components/Form/composables/useValue.ts'
  5. import CommonTabManager from '#desktop/components/CommonTabManager/CommonTabManager.vue'
  6. import type { FieldToggleButtonsProps } from './types.ts'
  7. const props = defineProps<FieldToggleButtonsProps>()
  8. const contextReactive = toRef(props, 'context')
  9. const { localValue } = useValue<string>(contextReactive)
  10. const tabs = computed(() => {
  11. return contextReactive.value.options.map((option) => {
  12. return {
  13. label: option.label,
  14. key: option.value,
  15. icon: option.icon,
  16. disabled: option.disabled,
  17. }
  18. })
  19. })
  20. </script>
  21. <template>
  22. <div
  23. :id="context.id"
  24. :class="context.classes.input"
  25. :aria-describedby="context.describedBy"
  26. v-bind="context.attrs"
  27. >
  28. <CommonTabManager
  29. v-if="tabs.length > 0"
  30. v-model="localValue"
  31. :tabs="tabs"
  32. />
  33. </div>
  34. </template>