import React from "react"; import { cn } from "../lib/cn"; export interface AuthInputProps extends Omit, "size"> { /** Visual size of the input */ size?: "sm" | "md" | "lg"; /** Error message */ error?: string; /** Helper text */ helperText?: string; /** Icon to show at the start of the input */ startIcon?: React.ReactNode; /** Whether the field is required */ required?: boolean; /** Full width (default: true) */ fullWidth?: boolean; } const sizeMap: Record = { sm: { height: "32px", padding: "0 var(--space-3)", fontSize: "var(--text-xs)" }, md: { height: "44px", padding: "0 var(--space-4)", fontSize: "var(--text-sm)" }, lg: { height: "52px", padding: "0 var(--space-5)", fontSize: "var(--text-base)" }, }; export const AuthInput = React.forwardRef( ( { size = "md", error, helperText, startIcon, required = false, fullWidth = true, className, style, id: customId, autoComplete, ...props }, ref, ) => { const s = sizeMap[size] || sizeMap.md; const hasError = !!error; const inputClass = cn( "w-full rounded-[var(--radius-md)] border border-[var(--border-color)] bg-[var(--bg-tertiary)] text-[var(--text-primary)] font-sans outline-none transition-all duration-150 ease-[cubic-bezier(0.16,1,0.3,1)] disabled:opacity-60 disabled:cursor-not-allowed", hasError ? "border-[var(--color-error)] focus-visible:ring-[var(--color-error)]" : "focus-visible:ring-[var(--color-primary)]", className, ); return (
{startIcon && (
{startIcon}
)}
{error && ( {error} )} {!error && helperText && ( {helperText} )}
); }, ); AuthInput.displayName = "AuthInput";