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

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

export interface SelectProps
  extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'>,
    VariantProps<typeof selectVariants> {}

export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
  ({ className, size, ...props }, ref) => <select ref={ref} className={cn(selectVariants({ size, className }))} {...props} />,
);

Select.displayName = 'Select';
