import type { SelectHTMLAttributes } from "react";

import { cn, inputClass, type InputState } from "@/lib/ui/variants";

interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
  controlSize?: "sm" | "md";
  state?: InputState;
}

const selectSizes: Record<NonNullable<SelectProps["controlSize"]>, string> = {
  sm: "px-2 py-1 text-xs",
  md: "px-3 py-2 text-sm",
};

export function Select({
  className,
  controlSize = "md",
  state,
  ...props
}: SelectProps) {
  return (
    <select
      className={inputClass({
        state,
        className: cn(selectSizes[controlSize], className),
      })}
      {...props}
    />
  );
}
