import { forwardRef } from "react"; /** * FormControl * * column: boolean - two-column layout (label left, input right) * label: string | ReactNode - label text * htmlFor: string - ties the label to its input id * labelAlt: string | ReactNode - supplementary label (right side or sub-text in column mode) * error: string | ReactNode - validation message; shown via CSS on invalid state * altBottom: string | ReactNode - bottom-left supplementary text * altBottomRight: string | ReactNode - bottom-right supplementary text */ const FormControl = forwardRef(function FormControl( { column = false, label, htmlFor, labelAlt, error, altBottom, altBottomRight, className = "", children, ...props }, ref ) { const wrapperClass = column ? "prs-form-control-col" : "prs-form-control"; return (
{(label || labelAlt) && (
{label && ( )} {labelAlt && ( {labelAlt} )}
)}
{children} {(error || altBottom || altBottomRight) && (
{error && {error}} {altBottom && {altBottom}} {altBottomRight && {altBottomRight}}
)}
); }); export default FormControl;