import React, { DetailedHTMLProps, forwardRef, InputHTMLAttributes, Ref, } from "react"; import Typography from "./Typography"; import classNames from "./lib/classNames"; export interface CustomInputProps { description?: string; block?: boolean; error?: string; label?: string; } export interface InputProps extends DetailedHTMLProps< InputHTMLAttributes, HTMLInputElement >, CustomInputProps {} export function getInputStyles({ block }: CustomInputProps) { const inputStyles = { base: "shadow-sm placeholder-gray-400 block text-sm border-gray-300 rounded-md focus:ring-0 focus:border-gray-400", block: "w-full", }; return classNames(inputStyles.base, block && inputStyles.block); } function Input( { description, className, error, block, label, ...rest }: InputProps, ref: Ref ) { return ( {label && ( {label} )} {error && ( {error} )} {description && ( {description} )} ); } export default forwardRef(Input);