CommonOverlayContainer.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. aria-hidden="true"
  35. @click="!noCloseOnBackdropClick && $emit('click-background')"
  36. />
  37. </teleport>
  38. </component>
  39. </template>