import { useEffect, useState } from '@wordpress/element'; import classNames from 'classnames'; import { Button, Popover as WordpressPopover } from '@wordpress/components'; import Cross2Icon from 'blockbite-icons/dist/Cross2'; type PopoverProps = { children: React.ReactNode; className?: string; defaultValue?: string; value?: string; position?: any; visible?: boolean; onVisibleChange?: (value: boolean) => void; }; export const Popover: React.FC = ({ children, className, position, visible, onVisibleChange, }) => { const [isVisible, setIsVisible] = useState(!!visible); useEffect(() => { if (visible !== undefined) { setIsVisible(visible); } }, [visible]); const toggleVisible = () => { const newValue = !isVisible; setIsVisible(newValue); onVisibleChange && onVisibleChange(newValue); }; return ( <> {isVisible && ( { setIsVisible(false); onVisibleChange && onVisibleChange(false); }} >
{children}
)} ); }; export default Popover;