FormGroup.vue 765 B

1234567891011121314151617181920212223242526272829303132333435
  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. 'mb-4': !hasHelp,
  17. [classMap.dirtyMark]: showDirtyMark,
  18. },
  19. ]"
  20. >
  21. <slot />
  22. </div>
  23. <div v-if="hasHelp" class="mb-4 pt-1" :class="classMap.help">
  24. <slot name="help">
  25. {{ help }}
  26. </slot>
  27. </div>
  28. </template>