useCommonSelect.ts 607 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { computed, ref } from 'vue'
  3. import type { CommonSelectInternalInstance } from './types.ts'
  4. import type { ComputedRef } from 'vue'
  5. const instances = ref(
  6. new Set<CommonSelectInternalInstance>(),
  7. ) as unknown as ComputedRef<Set<CommonSelectInternalInstance>>
  8. export const useCommonSelect = () => {
  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. }