fix(striker-ui): add input message to Autocomplete

main
Tsu-ba-me 3 years ago
parent 61de05569b
commit befe5ec4b5
  1. 38
      striker-ui/components/Autocomplete.tsx

@ -3,6 +3,7 @@ import {
autocompleteClasses as muiAutocompleteClasses, autocompleteClasses as muiAutocompleteClasses,
AutocompleteProps as MUIAutocompleteProps, AutocompleteProps as MUIAutocompleteProps,
AutocompleteRenderInputParams as MUIAutocompleteRenderInputParams, AutocompleteRenderInputParams as MUIAutocompleteRenderInputParams,
Box,
Grow as MUIGrow, Grow as MUIGrow,
outlinedInputClasses as muiOutlinedInputClasses, outlinedInputClasses as muiOutlinedInputClasses,
Paper as MUIPaper, Paper as MUIPaper,
@ -12,6 +13,8 @@ import {
import { GREY, TEXT } from '../lib/consts/DEFAULT_THEME'; import { GREY, TEXT } from '../lib/consts/DEFAULT_THEME';
import InputMessageBox from './InputMessageBox';
import { MessageBoxProps } from './MessageBox';
import OutlinedInputWithLabel, { import OutlinedInputWithLabel, {
OutlinedInputWithLabelProps, OutlinedInputWithLabelProps,
} from './OutlinedInputWithLabel'; } from './OutlinedInputWithLabel';
@ -21,6 +24,7 @@ type AutocompleteOptionalProps = {
inputWithLabelProps: OutlinedInputWithLabelProps, inputWithLabelProps: OutlinedInputWithLabelProps,
renderInputParams?: MUIAutocompleteRenderInputParams, renderInputParams?: MUIAutocompleteRenderInputParams,
) => void; ) => void;
messageBoxProps?: Partial<MessageBoxProps>;
}; };
type AutocompleteProps< type AutocompleteProps<
@ -54,8 +58,14 @@ const Autocomplete = <
>( >(
autocompleteProps: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, autocompleteProps: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo>,
): JSX.Element => { ): JSX.Element => {
const { componentsProps, extendRenderInput, label, renderInput, sx } = const {
autocompleteProps; componentsProps,
extendRenderInput,
label,
messageBoxProps,
renderInput,
sx,
} = autocompleteProps;
const combinedComponentsProps: AutocompleteProps< const combinedComponentsProps: AutocompleteProps<
T, T,
Multiple, Multiple,
@ -109,16 +119,20 @@ const Autocomplete = <
}; };
return ( return (
<MUIAutocomplete <Box sx={{ display: 'flex', flexDirection: 'column' }}>
// eslint-disable-next-line react/jsx-props-no-spreading <MUIAutocomplete
{...{ // eslint-disable-next-line react/jsx-props-no-spreading
PaperComponent: GrowPaper, {...{
...autocompleteProps, PaperComponent: GrowPaper,
componentsProps: combinedComponentsProps, ...autocompleteProps,
renderInput: combinedRenderInput, componentsProps: combinedComponentsProps,
sx: combinedSx, renderInput: combinedRenderInput,
}} sx: combinedSx,
/> }}
/>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<InputMessageBox {...messageBoxProps} />
</Box>
); );
}; };

Loading…
Cancel
Save