import React, { forwardRef } from 'react'; import { Label } from 'react-aria-components'; import classNames from 'classnames'; import { IconButton } from '../IconButton/IconButton'; import { Tooltip } from '../Tooltip/Tooltip'; import { FormRowHelperText } from './FormRowHelperText'; import type { FormRowLabelOwnProps } from './FormRowLabel'; import { FormRowLabel } from './FormRowLabel'; /** @inheritdoc */ export interface FormRowProps extends Pick { /** * The label for the form row. * If not provided, the form row will not render a label. */ label?: string; /** * Whether to visually hide the label (but keep it accessible for screen readers). */ labelHidden?: FormRowLabelOwnProps['visuallyHidden']; /** * Informational tooltip to display next to the form row. */ tooltip?: React.ReactNode; /** * The form row's children (usually an input element). */ children?: React.ReactNode; /** * The element to render the form row as. * @default 'label' */ as?: 'label' | 'div'; /** * If set to true, the container stretches to full width. */ isFullWidth?: boolean; } /** @deprecated */ export const FormRow = Object.assign( forwardRef(function FormRow( { label, labelHidden, children, required, tooltip, justify, as = 'label', htmlFor, isFullWidth, ...rest }: FormRowProps, forwardedRef: React.Ref ) { const Container = as === 'label' ? Label : as; return ( {label && ( {label} )} {children} {tooltip && ( )} ); }), { HelperText: FormRowHelperText, Label: FormRowLabel } );