Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1017 B
Raw Blame
import type { ComponentProps } from 'react';

import { Popover, usePopoverContext } from '@chakra-ui/react';

import { useRegisterWidgetOverlay } from './widgetOverlays';

type PopoverContentProps = ComponentProps<typeof Popover.Content> & {
  /**
   * Every popover anchored to a trigger points at it, as menus and hover cards do. Only listboxes that sit flush under
   * their field opt out (ModelSelect's picker, as Select and Combobox do).
   */
  showArrow?: boolean;
};

/** Popover content closes with its owning widget; the theme recipe owns chrome. */
export const PopoverContent = ({ children, showArrow = true, ...props }: PopoverContentProps) => {
  const popover = usePopoverContext();
  const stale = useRegisterWidgetOverlay(popover.open, popover.setOpen);
  if (stale) {
    return null;
  }
  return (
    <Popover.Content {...props}>
      {showArrow ? (
        <Popover.Arrow>
          <Popover.ArrowTip />
        </Popover.Arrow>
      ) : null}
      {children}
    </Popover.Content>
  );
};