import { Avatar as AvatarPrimitive } from '@base-ui/react/avatar'; import * as React from 'react'; import { cn } from '@/lib/utils'; type AvatarFallbackProps = React.ComponentProps< typeof AvatarPrimitive.Fallback >; type AvatarGroupChildProps = { className?: string; style?: React.CSSProperties; }; type AvatarGroupProps = React.ComponentProps<'div'>; type AvatarImageProps = React.ComponentProps; type AvatarRootProps = React.ComponentProps; function AvatarFallback({ className, ...props }: AvatarFallbackProps) { return ( ); } function AvatarGroup({ children, className, ...props }: AvatarGroupProps) { return (
{React.Children.map(children, (child, index) => { if (!React.isValidElement(child)) { return child; } return React.cloneElement(child, { className: cn( 'ring-background relative ring-2', child.props.className, ), style: { ...child.props.style, zIndex: index + 1, }, }); })}
); } function AvatarImage({ className, ...props }: AvatarImageProps) { return ( ); } function AvatarRoot({ className, ...props }: AvatarRootProps) { return ( ); } const Avatar = Object.assign(AvatarRoot, { Fallback: AvatarFallback, Group: AvatarGroup, Image: AvatarImage, }); export { Avatar, AvatarFallback, AvatarGroup, AvatarImage, AvatarRoot }; export type { AvatarFallbackProps, AvatarGroupProps, AvatarImageProps, AvatarRootProps, };