usePopoverInstances.ts 614 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { computed, ref } from 'vue'
  3. import type { CommonPopoverInternalInstance } from './types.ts'
  4. import type { ComputedRef } from 'vue'
  5. const instances = ref(
  6. new Set<CommonPopoverInternalInstance>(),
  7. ) as unknown as ComputedRef<Set<CommonPopoverInternalInstance>>
  8. export const usePopoverInstances = () => {
  9. const isOpened = computed(() => {
  10. for (const instance of instances.value) {
  11. if (instance.isOpen.value) {
  12. return true
  13. }
  14. }
  15. return false
  16. })
  17. return {
  18. isOpened,
  19. instances,
  20. }
  21. }