useFlyout.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import {
  3. closeOverlayContainer,
  4. getOpenedOverlayContainers,
  5. getOverlayContainerMeta,
  6. isOverlayContainerOpened,
  7. openOverlayContainer,
  8. useOverlayContainer,
  9. type OverlayContainerOptions,
  10. } from '#desktop/composables/useOverlayContainer.ts'
  11. const OVERLAY_CONTAINER_TYPE = 'flyout'
  12. export const getOpenedFlyouts = () =>
  13. getOpenedOverlayContainers(OVERLAY_CONTAINER_TYPE)
  14. export const isFlyoutOpened = (name?: string) =>
  15. isOverlayContainerOpened(OVERLAY_CONTAINER_TYPE, name)
  16. export const getFlyoutMeta = () => {
  17. const overlayContainerMeta = getOverlayContainerMeta(OVERLAY_CONTAINER_TYPE)
  18. return {
  19. flyoutsOptions: overlayContainerMeta.options,
  20. openedFlyouts: overlayContainerMeta.opened,
  21. }
  22. }
  23. export const openFlyout = async (
  24. name: string,
  25. props: Record<string, unknown>,
  26. ) => openOverlayContainer(OVERLAY_CONTAINER_TYPE, name, props)
  27. export const closeFlyout = async (name: string) =>
  28. closeOverlayContainer(OVERLAY_CONTAINER_TYPE, name)
  29. export const useFlyout = (options: OverlayContainerOptions) => {
  30. return useOverlayContainer(OVERLAY_CONTAINER_TYPE, options)
  31. }