@@ -12,32 +12,31 @@ import Autocomplete from "@mui/material/Autocomplete";
12
12
import TextField from "@mui/material/TextField" ;
13
13
import FormHelperText from "@mui/material/FormHelperText" ;
14
14
15
- type AutocompleteInputProps < T > = {
15
+ export type AutocompleteInputProps < T > = {
16
16
label : string ;
17
- type ?: string ;
18
17
autoFocus ?: boolean ;
19
18
disabled ?: boolean ;
20
19
readOnly ?: boolean ;
21
20
error ?: string ;
22
21
testId ?: string ;
23
22
size ?: "small" | "medium" ;
24
- keyValue : keyof T ;
25
23
value : T | null ;
26
24
options : T [ ] ;
27
25
renderOption : ( option : T ) => React . ReactNode ;
26
+ getOptionLabel : ( option : T ) => string ;
28
27
} ;
29
28
30
29
function AutocompleteInputRaw < T > (
31
30
props : AutocompleteInputProps < T > & {
32
31
name : string ;
33
- value : T [ ] | undefined | null ;
32
+ value : T | undefined | null ;
34
33
onChange : ( value : T ) => void ;
35
34
onBlur : ( ) => void ;
36
35
} ,
37
36
ref ?: ForwardedRef < HTMLDivElement | null >
38
37
) {
39
38
return (
40
- < FormControl error = { ! ! props . error } disabled = { props . disabled } >
39
+ < FormControl error = { ! ! props . error } disabled = { props . disabled } fullWidth >
41
40
< Autocomplete
42
41
ref = { ref }
43
42
id = { `autocomplete-${ props . name } ` }
@@ -50,7 +49,7 @@ function AutocompleteInputRaw<T>(
50
49
} }
51
50
onBlur = { props . onBlur }
52
51
data-testid = { props . testId }
53
- getOptionLabel = { ( option ) => option ?. [ props . keyValue ] ?. toString ( ) ?? "" }
52
+ getOptionLabel = { props . getOptionLabel }
54
53
renderOption = { ( htmlProps , option ) => (
55
54
< li { ...htmlProps } > { props . renderOption ( option ) } </ li >
56
55
) }
@@ -70,8 +69,8 @@ function AutocompleteInputRaw<T>(
70
69
const AutocompleteInput = forwardRef ( AutocompleteInputRaw ) as never as < T > (
71
70
props : AutocompleteInputProps < T > & {
72
71
name : string ;
73
- value : T [ ] | undefined | null ;
74
- onChange : ( value : T [ ] ) => void ;
72
+ value : T | undefined | null ;
73
+ onChange : ( value : T ) => void ;
75
74
onBlur : ( ) => void ;
76
75
} & { ref ?: ForwardedRef < HTMLDivElement | null > }
77
76
) => ReturnType < typeof AutocompleteInputRaw > ;
@@ -93,15 +92,15 @@ function FormAutocompleteInput<
93
92
{ ...field }
94
93
label = { props . label }
95
94
autoFocus = { props . autoFocus }
96
- type = { props . type }
97
95
error = { fieldState . error ?. message }
98
96
disabled = { props . disabled }
99
97
readOnly = { props . readOnly }
100
98
testId = { props . testId }
101
99
options = { props . options }
102
100
renderOption = { props . renderOption }
103
- keyValue = { props . keyValue }
101
+ getOptionLabel = { props . getOptionLabel }
104
102
size = { props . size }
103
+ value = { props . value }
105
104
/>
106
105
) }
107
106
/>
0 commit comments