2024-01-27 09:55:55 +00:00
|
|
|
import { Popover, PopoverAnchor, PopoverBody, PopoverContent } from '@invoke-ai/ui-library';
|
2024-02-28 16:45:34 +00:00
|
|
|
import { PromptTriggerSelect } from 'features/prompt/PromptTriggerSelect';
|
|
|
|
import type { PromptPopoverProps } from 'features/prompt/types';
|
2023-12-29 03:05:56 +00:00
|
|
|
import { memo } from 'react';
|
2023-12-28 13:03:21 +00:00
|
|
|
|
2024-02-28 16:45:34 +00:00
|
|
|
export const PromptPopover = memo((props: PromptPopoverProps) => {
|
2024-01-20 00:04:19 +00:00
|
|
|
const { onSelect, isOpen, onClose, width, children } = props;
|
2023-12-28 13:03:21 +00:00
|
|
|
|
|
|
|
return (
|
2024-01-20 00:04:19 +00:00
|
|
|
<Popover
|
2023-12-28 13:03:21 +00:00
|
|
|
isOpen={isOpen}
|
|
|
|
onClose={onClose}
|
|
|
|
placement="bottom"
|
|
|
|
openDelay={0}
|
|
|
|
closeDelay={0}
|
|
|
|
closeOnBlur={true}
|
2024-02-28 16:45:34 +00:00
|
|
|
returnFocusOnClose={false}
|
2023-12-28 13:03:21 +00:00
|
|
|
isLazy
|
|
|
|
>
|
2024-01-20 00:04:19 +00:00
|
|
|
<PopoverAnchor>{children}</PopoverAnchor>
|
|
|
|
<PopoverContent
|
2023-12-28 13:03:21 +00:00
|
|
|
p={0}
|
|
|
|
insetBlockStart={-1}
|
|
|
|
shadow="dark-lg"
|
2024-01-05 13:08:36 +00:00
|
|
|
borderColor="invokeBlue.300"
|
2023-12-28 13:03:21 +00:00
|
|
|
borderWidth="2px"
|
|
|
|
borderStyle="solid"
|
|
|
|
>
|
2024-01-20 00:04:19 +00:00
|
|
|
<PopoverBody p={0} width={`calc(${width}px - 0.25rem)`}>
|
2024-02-28 16:45:34 +00:00
|
|
|
<PromptTriggerSelect onClose={onClose} onSelect={onSelect} />
|
2024-01-20 00:04:19 +00:00
|
|
|
</PopoverBody>
|
|
|
|
</PopoverContent>
|
|
|
|
</Popover>
|
2023-12-28 13:03:21 +00:00
|
|
|
);
|
2023-12-29 03:05:56 +00:00
|
|
|
});
|
|
|
|
|
2024-02-28 16:45:34 +00:00
|
|
|
PromptPopover.displayName = 'PromptPopover';
|