diff --git a/packages/smarthr-ui/src/components/FormControl/FormControl.tsx b/packages/smarthr-ui/src/components/FormControl/FormControl.tsx index ef438758a3..caf2e9d74d 100644 --- a/packages/smarthr-ui/src/components/FormControl/FormControl.tsx +++ b/packages/smarthr-ui/src/components/FormControl/FormControl.tsx @@ -233,75 +233,141 @@ export const ActualFormControl: React.FC = ({ aria-describedby={isRoleGroup && describedbyIds ? describedbyIds : undefined} className={wrapperStyle} > - - - {helpMessage && ( -

- {helpMessage} -

- )} - {exampleMessage && ( - - {exampleMessage} - - )} - - {actualErrorMessages.length > 0 && ( - - )} - + + + +
{decorateFirstInputElement(children, { error: autoBindErrorInput && actualErrorMessages.length > 0, })}
- - {supplementaryMessage && ( - - {supplementaryMessage} - - )} + ) } +const TitleCluster = React.memo< + Pick & { + titleType: TextProps['styleType'] + statusLabelList: StatusLabelProps[] + isRoleGroup: boolean + managedHtmlFor: string + managedLabelId: string + labelStyle: string + } +>( + ({ + isRoleGroup, + managedHtmlFor, + managedLabelId, + labelStyle, + dangerouslyTitleHidden, + titleType, + title, + statusLabelList, + }) => ( + + ), +) + +const HelpMessageParagraph = React.memo & { managedHtmlFor: string }>( + ({ helpMessage, managedHtmlFor }) => + helpMessage ? ( +

+ {helpMessage} +

+ ) : null, +) + +const ExampleMessageText = React.memo & { managedHtmlFor: string }>( + ({ exampleMessage, managedHtmlFor }) => + exampleMessage ? ( + + {exampleMessage} + + ) : null, +) + +const ErrorMessageList = React.memo<{ + errorMessages: ReactNode[] + managedHtmlFor: string + errorListStyle: string + errorIconStyle: string +}>(({ errorMessages, managedHtmlFor, errorListStyle, errorIconStyle }) => { + if (errorMessages.length === 0) { + return null + } + + return ( + + ) +}) + +const SupplementaryMessageText = React.memo< + Pick & { managedHtmlFor: string } +>(({ supplementaryMessage, managedHtmlFor }) => + supplementaryMessage ? ( + + {supplementaryMessage} + + ) : null, +) + type DecorateFirstInputElementParams = { error: boolean }