'use client'; import { PrimitiveIcon, UIIcon } from '@gluestack-ui/core/icon/creator'; import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils'; import { tva, useStyleContext, withStyleContext } from '@gluestack-ui/utils/nativewind-utils'; import { styled } from 'nativewind'; import React from 'react'; import { Text, View } from 'react-native'; import { Svg } from 'react-native-svg'; const SCOPE = 'BADGE'; const badgeStyle = tva({ base: 'flex-row items-center justify-center rounded-sm px-2 py-0.5', variants: { variant: { default: 'bg-primary', secondary: 'bg-secondary', destructive: 'bg-destructive dark:bg-destructive/60', outline: 'border border-border dark:border-border/90 bg-transparent', }, }, }); const badgeTextStyle = tva({ base: 'text-xs font-medium tracking-normal uppercase', parentVariants: { variant: { default: 'text-primary-foreground', secondary: 'text-secondary-foreground', destructive: 'text-white', outline: 'text-foreground', }, }, }); const badgeIconStyle = tva({ base: 'fill-none h-3 w-3 pointer-events-none', parentVariants: { variant: { default: 'text-primary-foreground', secondary: 'text-secondary-foreground', destructive: 'text-white', outline: 'text-foreground', }, }, }); const ContextView = withStyleContext(View, SCOPE); type IBadgeProps = React.ComponentPropsWithoutRef & VariantProps; function Badge({ children, variant = 'default', className, ...props }: { className?: string } & IBadgeProps) { return ( {children} ); } type IBadgeTextProps = React.ComponentPropsWithoutRef & VariantProps; const BadgeText = React.forwardRef< React.ComponentRef, IBadgeTextProps >(function BadgeText({ children, className, ...props }, ref) { const { variant: parentVariant } = useStyleContext(SCOPE); return ( {children} ); }); type IBadgeIconProps = React.ComponentPropsWithoutRef & VariantProps & { size?: number; }; const StyledUIIcon = styled(UIIcon, { className: { target: 'style', nativeStyleToProp: { height: true, width: true, fill: true, color: 'classNameColor', stroke: true, }, }, }); const BadgeIcon = React.forwardRef< React.ComponentRef, IBadgeIconProps >(function BadgeIcon({ className, size, ...props }, ref) { const { variant: parentVariant } = useStyleContext(SCOPE); if (typeof size === 'number') { return ( ); } else if ( (props?.height !== undefined || props?.width !== undefined) && size === undefined ) { return ( ); } return ( ); }); Badge.displayName = 'Badge'; BadgeText.displayName = 'BadgeText'; BadgeIcon.displayName = 'BadgeIcon'; export { Badge, BadgeIcon, BadgeText };