import React, { forwardRef, useId } from 'react'; import './Input.css'; /** * Field — optional wrapper for label + input + hint/error. * * @param label string rendered above the control * @param hint small muted helper text below * @param error string error message (overrides hint, adds error state) * @param icon optional leading icon node (for Input variant) */ export function Field({ label, hint, error, icon, children }) { const id = useId(); const describedBy = error ? `${id}-err` : hint ? `${id}-hint` : undefined; const enriched = React.Children.map(children, (child) => { if (!React.isValidElement(child)) return child; return React.cloneElement(child, { id: child.props.id || id, 'aria-invalid': error ? true : undefined, 'aria-describedby': describedBy, }); }); return (