fix(striker-ui): add message to OutlinedInputWithLabel

main
Tsu-ba-me 3 years ago
parent 776988da47
commit d5967c1361
  1. 24
      striker-ui/components/OutlinedInputWithLabel.tsx

@ -3,6 +3,7 @@ import {
FormControlProps as MUIFormControlProps, FormControlProps as MUIFormControlProps,
} from '@mui/material'; } from '@mui/material';
import MessageBox, { MessageBoxProps } from './MessageBox';
import OutlinedInput, { OutlinedInputProps } from './OutlinedInput'; import OutlinedInput, { OutlinedInputProps } from './OutlinedInput';
import OutlinedInputLabel, { import OutlinedInputLabel, {
OutlinedInputLabelProps, OutlinedInputLabelProps,
@ -13,6 +14,7 @@ type OutlinedInputWithLabelOptionalProps = {
id?: string; id?: string;
inputProps?: Partial<OutlinedInputProps>; inputProps?: Partial<OutlinedInputProps>;
inputLabelProps?: Partial<OutlinedInputLabelProps>; inputLabelProps?: Partial<OutlinedInputLabelProps>;
messageBoxProps?: Partial<MessageBoxProps>;
}; };
type OutlinedInputWithLabelProps = { type OutlinedInputWithLabelProps = {
@ -25,6 +27,7 @@ const OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS: Required<OutlinedInputWithLabelOp
id: '', id: '',
inputProps: {}, inputProps: {},
inputLabelProps: {}, inputLabelProps: {},
messageBoxProps: {},
}; };
const OutlinedInputWithLabel = ({ const OutlinedInputWithLabel = ({
@ -33,7 +36,15 @@ const OutlinedInputWithLabel = ({
inputProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputProps, inputProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputProps,
inputLabelProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputLabelProps, inputLabelProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.inputLabelProps,
label, label,
}: OutlinedInputWithLabelProps): JSX.Element => ( messageBoxProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS.messageBoxProps,
}: OutlinedInputWithLabelProps): JSX.Element => {
const {
sx: messageBoxSx,
text: messageBoxText,
...messageBoxRestProps
} = messageBoxProps;
return (
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading
<MUIFormControl {...formControlProps}> <MUIFormControl {...formControlProps}>
{/* eslint-disable-next-line react/jsx-props-no-spreading */} {/* eslint-disable-next-line react/jsx-props-no-spreading */}
@ -49,8 +60,19 @@ const OutlinedInputWithLabel = ({
...inputProps, ...inputProps,
}} }}
/> />
{messageBoxText && (
<MessageBox
// eslint-disable-next-line react/jsx-props-no-spreading
{...{
...messageBoxRestProps,
sx: { marginTop: '.4em', ...messageBoxSx },
text: messageBoxText,
}}
/>
)}
</MUIFormControl> </MUIFormControl>
); );
};
OutlinedInputWithLabel.defaultProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS; OutlinedInputWithLabel.defaultProps = OUTLINED_INPUT_WITH_LABEL_DEFAULT_PROPS;

Loading…
Cancel
Save