import { forwardRef, type ComponentPropsWithoutRef, type ComponentRef } from 'react';
import { Text as RNText } from 'react-native';
import { cn } from '@cdx-ui/utils';
import { textStyle, TextVariantProps } from './styles';

export type TextProps = TextVariantProps &
  ComponentPropsWithoutRef<typeof RNText> & { className?: string };

export const Text = forwardRef<ComponentRef<typeof RNText>, TextProps>(function Text(
  { className, size = 'md', ...props },
  ref,
) {
  return <RNText className={cn(textStyle({ size }), className)} {...props} ref={ref} />;
});

Text.displayName = 'Text';
