|
|
@ -19,6 +19,7 @@ import OutlinedInputLabel, { |
|
|
|
} from './OutlinedInputLabel'; |
|
|
|
} from './OutlinedInputLabel'; |
|
|
|
|
|
|
|
|
|
|
|
type OutlinedInputWithLabelOptionalProps = { |
|
|
|
type OutlinedInputWithLabelOptionalProps = { |
|
|
|
|
|
|
|
fillRow?: boolean; |
|
|
|
formControlProps?: Partial<MUIFormControlProps>; |
|
|
|
formControlProps?: Partial<MUIFormControlProps>; |
|
|
|
helpMessageBoxProps?: Partial<MessageBoxProps>; |
|
|
|
helpMessageBoxProps?: Partial<MessageBoxProps>; |
|
|
|
id?: string; |
|
|
|
id?: string; |
|
|
@ -45,6 +46,7 @@ const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required< |
|
|
|
OutlinedInputWithLabelOptionalProps, |
|
|
|
OutlinedInputWithLabelOptionalProps, |
|
|
|
'onChange' | 'onHelp' | 'onHelpAppend' |
|
|
|
'onChange' | 'onHelp' | 'onHelpAppend' |
|
|
|
> = { |
|
|
|
> = { |
|
|
|
|
|
|
|
fillRow: false, |
|
|
|
formControlProps: {}, |
|
|
|
formControlProps: {}, |
|
|
|
helpMessageBoxProps: {}, |
|
|
|
helpMessageBoxProps: {}, |
|
|
|
id: '', |
|
|
|
id: '', |
|
|
@ -58,6 +60,7 @@ const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required< |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const OutlinedInputWithLabel: FC<OutlinedInputWithLabelProps> = ({ |
|
|
|
const OutlinedInputWithLabel: FC<OutlinedInputWithLabelProps> = ({ |
|
|
|
|
|
|
|
fillRow: isFillRow = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.fillRow, |
|
|
|
formControlProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.formControlProps, |
|
|
|
formControlProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.formControlProps, |
|
|
|
helpMessageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.helpMessageBoxProps, |
|
|
|
helpMessageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.helpMessageBoxProps, |
|
|
|
id = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.id, |
|
|
|
id = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.id, |
|
|
@ -73,10 +76,15 @@ const OutlinedInputWithLabel: FC<OutlinedInputWithLabelProps> = ({ |
|
|
|
onHelpAppend, |
|
|
|
onHelpAppend, |
|
|
|
value = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.value, |
|
|
|
value = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.value, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
|
|
|
|
const { sx: formControlSx, ...restFormControlProps } = formControlProps; |
|
|
|
const { text: helpText = '' } = helpMessageBoxProps; |
|
|
|
const { text: helpText = '' } = helpMessageBoxProps; |
|
|
|
|
|
|
|
|
|
|
|
const [isShowHelp, setIsShowHelp] = useState<boolean>(false); |
|
|
|
const [isShowHelp, setIsShowHelp] = useState<boolean>(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formControlWidth = useMemo( |
|
|
|
|
|
|
|
() => (isFillRow ? '100%' : undefined), |
|
|
|
|
|
|
|
[isFillRow], |
|
|
|
|
|
|
|
); |
|
|
|
const isShowHelpButton: boolean = useMemo( |
|
|
|
const isShowHelpButton: boolean = useMemo( |
|
|
|
() => onHelp !== undefined || helpText.length > 0, |
|
|
|
() => onHelp !== undefined || helpText.length > 0, |
|
|
|
[helpText, onHelp], |
|
|
|
[helpText, onHelp], |
|
|
@ -101,7 +109,10 @@ const OutlinedInputWithLabel: FC<OutlinedInputWithLabelProps> = ({ |
|
|
|
const handleHelp = useMemo(createHelpHandler, [createHelpHandler]); |
|
|
|
const handleHelp = useMemo(createHelpHandler, [createHelpHandler]); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<MUIFormControl {...formControlProps}> |
|
|
|
<MUIFormControl |
|
|
|
|
|
|
|
{...restFormControlProps} |
|
|
|
|
|
|
|
sx={{ width: formControlWidth, ...formControlSx }} |
|
|
|
|
|
|
|
> |
|
|
|
<OutlinedInputLabel {...{ htmlFor: id, ...inputLabelProps }}> |
|
|
|
<OutlinedInputLabel {...{ htmlFor: id, ...inputLabelProps }}> |
|
|
|
{label} |
|
|
|
{label} |
|
|
|
</OutlinedInputLabel> |
|
|
|
</OutlinedInputLabel> |
|
|
|