import React, { forwardRef } from 'react' import Checkbox, { type CheckboxProps } from '../../atoms/Checkbox' import Label from '../../atoms/Label' export interface CheckboxFieldProps extends CheckboxProps { /** * The text displayed to identify the input checkbox. */ label: string /** * The error message is displayed when an error occurs. */ error?: string /** * Control the vertical alignment of the checkbox in relation to the label (center, top, bottom). */ alignment?: 'center' | 'top' | 'bottom' } const CheckboxField = forwardRef( function CheckboxField( { testId = 'fs-checkbox-field', id, label, value, name, error, disabled, alignment = 'center', ...otherProps }, ref ) { const shouldDisplayError = !disabled && error && error !== '' return (
{shouldDisplayError && ( {error} )}
) } ) export default CheckboxField