CommonOverlayContainer.vue 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. }>(),
  15. {
  16. showBackdrop: true,
  17. teleportTo: '#page-main-content',
  18. },
  19. )
  20. defineEmits<{
  21. 'click-background': []
  22. }>()
  23. </script>
  24. <template>
  25. <component :is="tag" :role="tag === 'div' ? 'dialog' : 'complementary'">
  26. <slot />
  27. <teleport v-if="showBackdrop" :to="teleportTo">
  28. <div
  29. class="bg-alpha-100 dark:bg-alpha-800 absolute bottom-0 left-0 right-0 top-0 z-10 h-full w-full"
  30. role="presentation"
  31. tabindex="-1"
  32. aria-hidden="true"
  33. @click="!noCloseOnBackdropClick && $emit('click-background')"
  34. />
  35. </teleport>
  36. </component>
  37. </template>