import { forwardRef, type ReactNode } from 'react'; import { Text, View, type ViewProps } from 'react-native'; import { dataAttributes, mergeDataAttributes } from '@cdx-ui/primitives'; import { cn } from '@cdx-ui/utils'; import type { ForgeIcon } from '@cdx-ui/icons'; import { Icon } from '../Icon'; import { badgeIconVariants, badgeIndicatorVariants, badgeLabelVariants, badgeRootVariants, type BadgeVariantProps, } from './styles'; const INDICATOR_STYLE = { pointerEvents: 'none' as const }; export interface BadgeProps extends ViewProps, BadgeVariantProps { children?: ReactNode; label?: ReactNode; icon?: ForgeIcon; className?: string; } const Badge = forwardRef( ( { children, variant = 'default', color = 'action', placement = 'top-end', overlap = 'rectangular', label, icon: IconComponent, accessibilityLabel, className, style, ...props }, ref, ) => { const isDecorative = variant === 'dot' || !accessibilityLabel; const renderContent = () => { if (variant === 'dot') return null; if (IconComponent) { return ; } if (typeof label === 'string' || typeof label === 'number') { return ( {label} ); } return label ?? null; }; const hasChildren = children != null; return ( {children} {renderContent()} ); }, ); Badge.displayName = 'Badge'; export { Badge }; export type { BadgeVariantProps } from './styles';