import { type VariantProps } from 'class-variance-authority';

import * as React from 'react';

import { cn } from '@/lib/utils';

import { inputVariants } from './input-variants';

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

/** @status stable */
const Input = React.forwardRef<HTMLInputElement, InputProps>(
  ({ className, type, variant, fieldSize, ...props }, ref) => {
    return (
      <input
        type={type}
        className={cn(
          inputVariants({ variant, fieldSize }),
          // File inputs need different padding treatment
          type === 'file' &&
            'file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground',
          className,
        )}
        ref={ref}
        {...props}
      />
    );
  },
);
Input.displayName = 'Input';

export { Input };
