FormGroup.vue 817 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, useSlots } from 'vue'
  4. import { getFormGroupClasses } from './initializeFormGroupClasses.ts'
  5. const props = defineProps<{ help?: string; showDirtyMark?: boolean }>()
  6. const slots = useSlots()
  7. const hasHelp = computed(() => slots.help || props.help)
  8. const classMap = getFormGroupClasses()
  9. </script>
  10. <template>
  11. <div
  12. v-bind="$attrs"
  13. :class="[
  14. classMap.container,
  15. {
  16. [classMap.bottomMargin]: !hasHelp,
  17. [classMap.dirtyMark]: showDirtyMark,
  18. },
  19. ]"
  20. >
  21. <slot />
  22. </div>
  23. <div
  24. v-if="hasHelp"
  25. class="pt-1"
  26. :class="[classMap.bottomMargin, classMap.help]"
  27. >
  28. <slot name="help">
  29. {{ help }}
  30. </slot>
  31. </div>
  32. </template>