import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../../lib/utils';

const textareaVariants = cva('shTextarea', {
  variants: {
    size: {
      xs: 'shTextareaXs',
      sm: 'shTextareaSm',
      md: 'shTextareaMd',
      lg: 'shTextareaLg',
      xl: 'shTextareaXl',
    },
  },
  defaultVariants: {
    size: 'md',
  },
});

export interface TextareaProps
  extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
    VariantProps<typeof textareaVariants> {}

export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
  ({ className, size, ...props }, ref) => <textarea ref={ref} className={cn(textareaVariants({ size, className }))} {...props} />,
);

Textarea.displayName = 'Textarea';
