"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export type FormFieldProps = { label?: React.ReactNode; htmlFor?: string; description?: React.ReactNode; error?: string; required?: boolean; className?: string; children?: React.ReactNode; }; const formFieldShake = ` @keyframes formFieldShake { 0%, 100% { transform: translateX(0); } 10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); } 20%, 40%, 60%, 80% { transform: translateX(4px); } } `; export function FormField({ label, htmlFor, description, error, required = false, className, children }: FormFieldProps) { const [showError, setShowError] = React.useState(false); React.useEffect(() => { if (error) { setShowError(true); } }, [error]); return (
{label !== undefined && ( )}
{error && (

{error}

)} {children}
{description !== undefined && (

{description}

)}
); }