import React, { useId } from 'react' import { Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, DrawerBody, DrawerFooter, DrawerClose, DrawerOverlay, DrawerPortal, } from '../Drawer' import { X } from 'lucide-react' import Block from '../Primitives/Block/Block' import { ButtonSubType, ButtonType, Button } from '../Button' import type { PopoverV2Props } from './popoverV2.types' import { PopoverV2Size } from './popoverV2.types' import { FOUNDATION_THEME } from '../../tokens' import { useResponsiveTokens } from '../../hooks/useResponsiveTokens' import { type SkeletonVariant } from '../Skeleton' import type { PopoverV2TokenType } from './popoverV2.token' import PopoverV2Skeleton from './PopoverV2Skeleton' type MobilePopoverV2Props = PopoverV2Props & { useDrawerOnMobile?: boolean } const MobilePopoverV2: React.FC = ({ open, onOpenChange, heading, description, children, primaryAction, secondaryAction, showCloseButton = true, onClose, trigger, skeleton, size = PopoverV2Size.MD, }) => { const popoverTokens = useResponsiveTokens('POPOVERV2') const shouldShowSkeleton = skeleton?.show const showBodySkeleton = skeleton?.bodySkeletonProps?.show const skeletonVariant: SkeletonVariant = (skeleton?.variant as SkeletonVariant) ?? 'pulse' const bodySkeletonWidth = skeleton?.bodySkeletonProps?.width || '100%' const bodySkeletonHeight = skeleton?.bodySkeletonProps?.height || 200 const baseId = useId() const headingId = heading ? `${baseId}-heading` : undefined const descriptionId = description ? `${baseId}-description` : undefined const ariaDescribedBy = descriptionId || undefined return ( { if (onOpenChange) { onOpenChange(isOpen) } if (!isOpen && onClose) { onClose() } }} direction="bottom" modal={true} dismissible={true} > {trigger} {(heading || description || shouldShowSkeleton) && ( {shouldShowSkeleton ? ( ) : ( {heading && ( {heading} )} {description && ( {description} )} {showCloseButton && (