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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import type { ReactNode } from 'react';
import { Menu, Portal } from '@chakra-ui/react';
import { MenuContent } from '@platform/ui';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import type { CanvasContextMenuTarget } from './canvasContextMenu';
export const CanvasGlobalContextMenu = ({
children,
onClose,
target,
}: {
children: ReactNode;
onClose: () => void;
target: CanvasContextMenuTarget;
}) => {
const { t } = useTranslation();
const positioning = useMemo(
() => ({
getAnchorRect: () => ({ height: 1, width: 1, x: target.x, y: target.y }),
placement: 'bottom-start' as const,
}),
[target.x, target.y]
);
const onOpenChange = useCallback(
(details: { open: boolean }) => {
if (!details.open) {
onClose();
}
},
[onClose]
);
return (
<Menu.Root lazyMount open positioning={positioning} unmountOnExit onOpenChange={onOpenChange}>
<Portal>
<Menu.Positioner>
<MenuContent minW="14rem" py="1">
<Menu.ItemGroup>
<Menu.ItemGroupLabel color="fg.subtle" fontSize="xs" textTransform="uppercase">
{t('widgets.labels.canvas')}
</Menu.ItemGroupLabel>
{children}
</Menu.ItemGroup>
</MenuContent>
</Menu.Positioner>
</Portal>
</Menu.Root>
);
};