import { useRef } from 'react'; import { Save } from 'lucide-react'; import { Portal, Content } from '@radix-ui/react-popover'; import type { ReactNode } from 'react'; import { useLocalize, useOnClickOutside } from '~/hooks'; import { cn, removeFocusOutlines } from '~/utils'; import { CrossIcon } from '~/components/svg'; import { Button } from '~/components/ui'; type TOptionsPopoverProps = { children: ReactNode; visible: boolean; saveAsPreset: () => void; closePopover: () => void; PopoverButtons: ReactNode; }; export default function OptionsPopover({ children, // endpoint, visible, saveAsPreset, closePopover, PopoverButtons, }: TOptionsPopoverProps) { const popoverRef = useRef(null); useOnClickOutside( popoverRef, () => closePopover(), ['dialog-template-content', 'shadcn-button', 'advanced-settings'], (_target) => { const target = _target as Element; if ( target?.id === 'presets-button' || (target?.parentNode instanceof Element && target.parentNode.id === 'presets-button') ) { return false; } const tagName = target?.tagName; return tagName === 'path' || tagName === 'svg' || tagName === 'circle'; }, ); const localize = useLocalize(); const cardStyle = 'shadow-xl rounded-md min-w-[75px] font-normal bg-white border-black/10 border dark:bg-gray-700 text-black dark:text-white '; if (!visible) { return null; } return (
{PopoverButtons}
{children}
); }