// @flow strict import * as React from 'react'; import type {ColorTypes} from '../../types/typography'; import classify from '../../utils/classify'; import type {IconSize, IconType} from '../Icon'; import {Icon} from '../Icon'; import css from './FormTitleWrapper.module.css'; type ClassNames = $ReadOnly<{ wrapper?: string, title?: string, rightSlot?: string, }>; export type FormTitleWrapperProps = { classNames?: ClassNames, iconType?: IconType, iconName?: string, iconSize?: IconSize, iconColor?: ColorTypes, title: React.Node, // Should always atleast have a title rightSlot?: React.Node, }; export const FormTitleWrapper: React$AbstractComponent< FormTitleWrapperProps, HTMLDivElement, > = React.forwardRef( ( { classNames, iconType, iconName, iconSize = 'small', iconColor, title, rightSlot, }: FormTitleWrapperProps, ref, ) => (
{!!iconName && ( )} {/* This is to safeguard semantics as it internally composes from a subTitleSmall className we don't fix the component here as resolves to

and since title is a React.Node, this would break semantics in case custom components are passed inside */}
{title}

{rightSlot}
), );