import React, { useRef } from "react"; import { type AriaPopoverProps, DismissButton, Overlay, usePopover } from "react-aria"; import type { OverlayTriggerState } from "react-stately"; import cn from "~/utils/cn"; export interface PopoverProps extends Omit { children: React.ReactNode; state: OverlayTriggerState; popoverRef?: React.RefObject; className?: string; } export default function Popover(props: PopoverProps) { const ref = props.popoverRef ?? useRef(null); const { state, children, className } = props; const { popoverProps, underlayProps } = usePopover( { ...props, popoverRef: ref, offset: 8, }, state, ); return (
{children}
); }