@@ -14,46 +14,49 @@ const Input = styled.input`
14
14
}
15
15
` ;
16
16
17
- const Option = props => (
18
- < label
19
- css = { getLabelStyles ( props ) }
20
- role = "radio"
21
- aria-checked = { props . isChecked }
22
- onFocus = { props . onFocus }
23
- onBlur = { props . onBlur }
24
- htmlFor = { props . id }
25
- >
26
- < Input
27
- css = { accessibleHiddenInputStyles }
28
- id = { props . id }
29
- name = { props . name }
30
- value = { props . value }
31
- onChange = { props . isReadOnly ? undefined : props . onChange }
32
- disabled = { props . isDisabled }
33
- checked = { props . isChecked }
34
- type = "radio"
35
- readOnly = { props . isReadOnly }
36
- aria-readonly = { props . isReadOnly }
37
- { ...filterDataAttributes ( props ) }
38
- />
39
- < div css = { getContainerStyles ( props ) } >
40
- { props . isChecked ? < Icons . Checked /> : < Icons . Default /> }
41
- </ div >
42
- < div
43
- css = { css `
44
- width : 100% ;
45
- margin-left : ${ vars . spacingS } ;
46
- font-size : 1rem ;
47
- font-family : ${ vars . fontFamilyDefault } ;
48
- color : ${ props . isDisabled
49
- ? vars . fontColorForInputWhenDisabled
50
- : vars . fontColorForInput } ;
51
- ` }
17
+ const Option = props => {
18
+ const labelProps = props . id ? { htmlFor : props . id } : { } ;
19
+ return (
20
+ < label
21
+ css = { getLabelStyles ( props ) }
22
+ role = "radio"
23
+ aria-checked = { props . isChecked }
24
+ onFocus = { props . onFocus }
25
+ onBlur = { props . onBlur }
26
+ { ...labelProps }
52
27
>
53
- { props . children }
54
- </ div >
55
- </ label >
56
- ) ;
28
+ < Input
29
+ css = { accessibleHiddenInputStyles }
30
+ id = { props . id }
31
+ name = { props . name }
32
+ value = { props . value }
33
+ onChange = { props . isReadOnly ? undefined : props . onChange }
34
+ disabled = { props . isDisabled }
35
+ checked = { props . isChecked }
36
+ type = "radio"
37
+ readOnly = { props . isReadOnly }
38
+ aria-readonly = { props . isReadOnly }
39
+ { ...filterDataAttributes ( props ) }
40
+ />
41
+ < div css = { getContainerStyles ( props ) } >
42
+ { props . isChecked ? < Icons . Checked /> : < Icons . Default /> }
43
+ </ div >
44
+ < div
45
+ css = { css `
46
+ width : 100% ;
47
+ margin-left : ${ vars . spacingS } ;
48
+ font-size : 1rem ;
49
+ font-family : ${ vars . fontFamilyDefault } ;
50
+ color : ${ props . isDisabled
51
+ ? vars . fontColorForInputWhenDisabled
52
+ : vars . fontColorForInput } ;
53
+ ` }
54
+ >
55
+ { props . children }
56
+ </ div >
57
+ </ label >
58
+ ) ;
59
+ } ;
57
60
Option . displayName = 'RadioOption' ;
58
61
Option . propTypes = {
59
62
// Direct props
0 commit comments