CommonOverlayContainer.vue 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. withDefaults(
  4. defineProps<{
  5. /**
  6. * @property teleportTo
  7. * The selector of the element to teleport the backdrop to.
  8. * @example '#test' '.test' 'body'
  9. * */
  10. teleportTo?: string
  11. tag: 'div' | 'aside'
  12. showBackdrop?: boolean
  13. noCloseOnBackdropClick?: boolean
  14. backdropClass?: string
  15. }>(),
  16. {
  17. showBackdrop: true,
  18. teleportTo: '#app',
  19. },
  20. )
  21. defineEmits<{
  22. 'click-background': []
  23. }>()
  24. </script>
  25. <template>
  26. <component :is="tag" :role="tag === 'div' ? 'dialog' : 'complementary'">
  27. <slot />
  28. <teleport v-if="showBackdrop" :to="teleportTo">
  29. <div
  30. class="bg-alpha-900 -:z-30 absolute bottom-0 left-0 right-0 top-0 h-full w-full"
  31. :class="backdropClass"
  32. role="presentation"
  33. tabindex="-1"
  34. @click="!noCloseOnBackdropClick && $emit('click-background')"
  35. />
  36. </teleport>
  37. </component>
  38. </template>