31 lines
658 B
TypeScript
31 lines
658 B
TypeScript
import type { InputHTMLAttributes } from "react";
|
|
|
|
import { cn, inputClass, type InputState } from "@/lib/ui/variants";
|
|
|
|
interface TextInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
controlSize?: "sm" | "md";
|
|
state?: InputState;
|
|
}
|
|
|
|
const inputSizes: Record<NonNullable<TextInputProps["controlSize"]>, string> = {
|
|
sm: "px-2 py-1 text-xs",
|
|
md: "px-3 py-2 text-sm",
|
|
};
|
|
|
|
export function TextInput({
|
|
className,
|
|
controlSize = "md",
|
|
state,
|
|
...props
|
|
}: TextInputProps) {
|
|
return (
|
|
<input
|
|
className={inputClass({
|
|
state,
|
|
className: cn(inputSizes[controlSize], className),
|
|
})}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|