CommonOverlayContainer.vue 1.1 KB

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