File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -6,16 +6,17 @@ import Radio, { RadioProps } from './index';
6
6
// Utils
7
7
import randomString from '../../utils/randomString' ;
8
8
9
+ type Value = string | number | boolean ;
9
10
export type RadioGroupOption = {
10
- key : string ;
11
+ key : Value ;
11
12
text : string ;
12
13
additionalText ?: string ;
13
14
} ;
14
15
export interface RadioGroupProps
15
16
extends Omit < RadioProps , 'label' | 'onChange' | 'options' | 'value' > {
16
- value : string | null ;
17
+ value : Value | null ;
17
18
options : string [ ] | RadioGroupOption [ ] ;
18
- onChange : ( value : string ) => void ;
19
+ onChange : ( value : Value ) => void ;
19
20
tooltipMessages ?: {
20
21
[ key : string ] : string ;
21
22
} ;
@@ -31,7 +32,7 @@ const RadioGroup: FC<RadioGroupProps> = ({
31
32
...props
32
33
} : RadioGroupProps ) => {
33
34
const handleChange = useCallback (
34
- ( newValue : string ) => ( ) => {
35
+ ( newValue : Value ) => ( ) => {
35
36
onChange ( newValue ) ;
36
37
} ,
37
38
[ onChange ] ,
@@ -48,15 +49,15 @@ const RadioGroup: FC<RadioGroupProps> = ({
48
49
{ mappedOptions ?. map ( ( { key, text, additionalText } ) => (
49
50
< Radio
50
51
{ ...props }
51
- key = { key }
52
+ key = { ` ${ key } ` }
52
53
mt = { flexDirection === 'column' ? 2 : 'initial' }
53
54
mr = { flexDirection === 'row' ? '20px' : 'initial' }
54
55
checked = { value === key }
55
56
label = { text }
56
57
name = { name }
57
58
addtionalText = { additionalText }
58
59
onChange = { handleChange ( key ) }
59
- tooltip = { tooltipMessages [ key ] }
60
+ tooltip = { tooltipMessages [ ` ${ key } ` ] }
60
61
/>
61
62
) ) }
62
63
</ Flex >
You can’t perform that action at this time.
0 commit comments