From 75d9dc4e15e94ff12b01f85085036a12a55032f3 Mon Sep 17 00:00:00 2001 From: AtsushiM Date: Fri, 13 Sep 2024 09:53:16 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20FormControl=E5=86=85=E3=81=A7=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=95=E3=82=8C=E3=82=8B=E5=8F=AF=E8=83=BD=E6=80=A7?= =?UTF-8?q?=E3=81=8C=E5=B0=91=E3=81=AA=E3=81=84=E7=AE=87=E6=89=80=E3=82=92?= =?UTF-8?q?memo=E5=8C=96=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/FormControl/FormControl.tsx | 186 ++++++++++++------ 1 file changed, 126 insertions(+), 60 deletions(-) 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 }