import { type ReactElement } from "react"; import * as React from "react"; import { Popover as PopoverPrimitive } from "@base-ui/react/popover"; import { cn } from "@/lib/utils"; import { asChildProps } from "@/lib/as-child"; import { useThemeVars } from "@/lib/theme-provider"; /** * Provides a DOM container for Popover portals rendered inside a Drawer/Dialog. * Without this, Base UI's FloatingPortal renders to document.body, which sits * outside Radix's DismissableLayer — causing outside-click detection to fire * and close the Drawer when the user clicks inside the popover. * * Usage: wrap DrawerContent body with * and place a
inside DrawerContent as the portal target. */ const PopoverPortalContext = React.createContext< HTMLElement | null | undefined >(undefined); export type PopoverPortalProviderProps = { container: HTMLElement | null | undefined; children: React.ReactNode; }; function PopoverPortalProvider({ container, children, }: PopoverPortalProviderProps): ReactElement { return ( {children} ); } export type PopoverProps = React.ComponentProps; function Popover({ ...props }: PopoverProps): ReactElement { return ; } export type PopoverTriggerProps = React.ComponentProps< typeof PopoverPrimitive.Trigger > & { /** shadcn-compatible alias for Base UI's `render`: replaces the trigger with its single child. */ asChild?: boolean; }; function PopoverTrigger({ asChild, children, ...props }: PopoverTriggerProps): ReactElement { return ( ); } export type PopoverContentProps = React.ComponentProps< typeof PopoverPrimitive.Popup > & { align?: "start" | "center" | "end"; sideOffset?: number; }; function PopoverContent({ className, align = "center", sideOffset = 4, style, ...props }: PopoverContentProps): ReactElement { const themeVars = useThemeVars(); const portalContainer = React.useContext(PopoverPortalContext); return ( ); } export type PopoverAnchorProps = React.ComponentProps<"div">; function PopoverAnchor({ ...props }: PopoverAnchorProps): ReactElement { return
; } export type PopoverHeaderProps = React.ComponentProps<"div">; function PopoverHeader({ className, ...props }: PopoverHeaderProps): ReactElement { return (
); } export type PopoverTitleProps = React.ComponentProps<"h2">; function PopoverTitle({ className, ...props }: PopoverTitleProps): ReactElement { return ( // eslint-disable-next-line jsx-a11y/heading-has-content -- children passed via props spread

); } export type PopoverDescriptionProps = React.ComponentProps<"p">; function PopoverDescription({ className, ...props }: PopoverDescriptionProps): ReactElement { return (

); } export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverHeader, PopoverTitle, PopoverDescription, PopoverPortalProvider, };