diff --git a/src/ThriveUI/Popover/index.tsx b/src/ThriveUI/Popover/index.tsx index 7a47c29..4bbd6ff 100644 --- a/src/ThriveUI/Popover/index.tsx +++ b/src/ThriveUI/Popover/index.tsx @@ -5,7 +5,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react'; export interface PopoverProps { isOpen?: boolean; onOpenChange?: (open: boolean) => void; - placement?: 'top' | 'bottom' | 'left' | 'right'; + placement?: 'top' | 'top-end' | 'bottom' | 'bottom-end' | 'left' | 'right'; children: ReactNode; } @@ -20,7 +20,9 @@ export interface PopoverContentProps { const placementCls = { top: 'bottom-full left-1/2 mb-2 -translate-x-1/2', + 'top-end': 'bottom-full right-0 mb-2', bottom: 'top-full left-1/2 mt-2 -translate-x-1/2', + 'bottom-end': 'top-full right-0 mt-2', left: 'right-full top-1/2 mr-2 -translate-y-1/2', right: 'left-full top-1/2 ml-2 -translate-y-1/2', }; @@ -42,20 +44,26 @@ export function Popover({ isOpen, onOpenChange, placement = 'bottom', children } let trigger: ReactNode = null; let content: ReactNode = null; + let contentClassName = ''; for (const child of Array.isArray(children) ? children : [children]) { if (!child || typeof child !== 'object' || !('type' in child)) continue; - const el = child as React.ReactElement<{ children?: ReactNode }>; + const el = child as React.ReactElement<{ children?: ReactNode; className?: string }>; if (el.type === PopoverTrigger) trigger = el.props.children; - if (el.type === PopoverContent) content = el.props.children; + if (el.type === PopoverContent) { + content = el.props.children; + contentClassName = el.props.className ?? ''; + } } return (