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

const inputVariants = cva('shInput', {
  variants: {
    size: {
      xs: 'shControlXs',
      sm: 'shControlSm',
      md: 'shControlMd',
      lg: 'shControlLg',
      xl: 'shControlXl',
    },
  },
  defaultVariants: {
    size: 'md',
  },
});

export interface InputProps
  extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
    VariantProps<typeof inputVariants> {}

export const Input = React.forwardRef<HTMLInputElement, InputProps>(
  ({ className, size, ...props }, ref) => <input ref={ref} className={cn(inputVariants({ size, className }))} {...props} />,
);

Input.displayName = 'Input';
