import React from 'react'; import { Tooltip } from '@carbon/react'; import { Information } from '@carbon/react/icons'; import { useTranslation } from 'react-i18next'; import { type FormField } from '../../types'; import styles from './field-label.scss'; interface FieldLabelProps { field: FormField; /** * Custom label text to override the default field label. */ customLabel?: string; } const TooltipWrapper: React.FC<{ field: FormField; children: React.ReactNode }> = ({ field, children }) => { const { t } = useTranslation(); const hasTooltip = Boolean(field.questionInfo); return hasTooltip ? ( {children} ) : ( <>{children}> ); }; const FieldLabel: React.FC = ({ field, customLabel }) => { const { t } = useTranslation(); const hasTooltip = Boolean(field.questionInfo); const labelText = customLabel || t(field.label); return ( {labelText} {field.isRequired && ( * )} {hasTooltip && ( )} ); }; export default FieldLabel;