import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import InfoIconWithTooltip from './InfoIconWithTooltip'; import StandardLabel from './StandardLabel'; import HiddenLabel from './HiddenLabel'; // @ts-ignore flow import import commonMessages from '../../common/messages'; import './Label.scss'; const OptionalFormattedMessage = () => ( () ); export interface LabelProps { /** Child for the label */ children: React.ReactElement; /** Whether the text of the label should be accessibly hidden */ hideLabel?: boolean; /** Optional props for the icon */ infoIconProps?: Record; // eslint-disable-line @typescript-eslint/no-explicit-any /** Tooltip text for the info icon */ infoTooltip?: React.ReactNode; /** Whether to show the `(Optional)` text next to the label for an optional field */ showOptionalText?: boolean; /** The label text */ text: React.ReactNode; /** Optional tooltip text for the label */ tooltip?: React.ReactNode; } const Label = ({ text, tooltip, infoTooltip, infoIconProps, showOptionalText, hideLabel, children }: LabelProps) => { const labelContent = [ {text}, showOptionalText ? : null, ]; if (infoTooltip) { labelContent.push( , ); } if (hideLabel) { return {children}; } return ( {children} ); }; export default Label;