'use client'; import { Portal, Content } from '@radix-ui/react-popover'; import { clsx } from 'clsx'; import { ComponentPropsWithoutRef, ComponentPropsWithRef, ReactNode, } from 'react'; import { Box, BoxProps } from '../box'; import { ScrollArea } from '../scroll-area'; import { popoverContentRecipe, PopoverContentVariants, } from './popover-content.css'; import type { Tone } from '../../styles'; type BoxStyleProps = Pick< BoxProps<'div'>, 'variant' | 'spacing' | 'radius' | 'elevation' | 'use' | 'tone' >; export type PopoverContentProps = { portaled?: boolean; maxHeight?: string; scrollable?: boolean; } & PopoverContentVariants & ComponentPropsWithoutRef & BoxStyleProps & Omit, keyof BoxStyleProps>; export interface PopoverScrollableProps { scrollable?: boolean; maxHeight?: string; children?: ReactNode; tone?: Tone; } export function PopoverScrollable({ children, scrollable = true, maxHeight, tone, }: PopoverScrollableProps) { if (scrollable === false) { return children; } return ( {children} ); } export function PopoverContent({ className, align = 'center', container, children, spacing = 4, radius = 'medium', variant, use, width, portaled = true, scrollable = true, maxHeight = 'var(--radix-popover-content-available-height)', elevation, tone, ...props }: PopoverContentProps) { const content = ( {children} ); return portaled === true ? ( {content} ) : ( content ); }