14
14
// You should have received a copy of the GNU Affero General Public License
15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
import React from "react" ;
17
+ import clsx from "clsx" ;
17
18
import Grid from "@material-ui/core/Grid" ;
18
19
import RadioGroup from "@material-ui/core/RadioGroup" ;
19
20
import FormControlLabel from "@material-ui/core/FormControlLabel" ;
@@ -40,6 +41,7 @@ interface RadioGroupProps {
40
41
id : string ;
41
42
name : string ;
42
43
tooltip ?: string ;
44
+ disableOptions ?: boolean ;
43
45
onChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ;
44
46
classes : any ;
45
47
displayInColumn ?: boolean ;
@@ -58,8 +60,23 @@ const styles = (theme: Theme) =>
58
60
paddingBottom : 10 ,
59
61
marginTop : 11 ,
60
62
} ,
63
+ optionLabel : {
64
+ "&.Mui-disabled" : {
65
+ "& .MuiFormControlLabel-label" : {
66
+ color : "#9c9c9c" ,
67
+ } ,
68
+ } ,
69
+ "&:last-child" : {
70
+ marginRight : 0 ,
71
+ } ,
72
+ "& .MuiFormControlLabel-label" : {
73
+ fontSize : 12 ,
74
+ color : "#000" ,
75
+ } ,
76
+ } ,
61
77
checkedOption : {
62
78
"& .MuiFormControlLabel-label" : {
79
+ fontSize : 12 ,
63
80
color : "#000" ,
64
81
fontWeight : 700 ,
65
82
} ,
@@ -98,6 +115,7 @@ export const RadioGroupSelector = ({
98
115
name,
99
116
onChange,
100
117
tooltip = "" ,
118
+ disableOptions = false ,
101
119
classes,
102
120
displayInColumn = false ,
103
121
} : RadioGroupProps ) => {
@@ -128,14 +146,14 @@ export const RadioGroupSelector = ({
128
146
return (
129
147
< FormControlLabel
130
148
key = { `rd-${ name } -${ selectorOption . value } ` }
131
- value = { selectorOption . value }
149
+ value = { disableOptions ? "disabled" : selectorOption . value }
132
150
control = { < RadioButton /> }
133
151
label = { selectorOption . label }
134
- className = {
135
- selectorOption . value === currentSelection
136
- ? classes . checkedOption
137
- : ""
138
- }
152
+ disabled = { disableOptions }
153
+ className = { clsx ( classes . optionLabel , {
154
+ [ classes . checkedOption ] :
155
+ selectorOption . value === currentSelection ,
156
+ } ) }
139
157
/>
140
158
) ;
141
159
} ) }
0 commit comments