@@ -13,7 +13,8 @@ export interface IPropsSelectionBase extends IPropsFieldBase {
13
13
disabled ?: boolean ;
14
14
checked : boolean ;
15
15
helperText ?: React . ReactNode ;
16
- FormControlLabelProps : Partial < FormControlLabelProps > ;
16
+ disableLabelMargin ?: boolean ;
17
+ FormControlLabelProps ?: Partial < FormControlLabelProps > ;
17
18
}
18
19
19
20
interface IProps extends IPropsSelectionBase {
@@ -28,12 +29,27 @@ interface IProps extends IPropsSelectionBase {
28
29
labelAlign : {
29
30
marginTop : 14
30
31
} ,
32
+ labelRight : {
33
+ textAlign : 'right'
34
+ } ,
31
35
helperText : {
32
36
opacity : 0.7 ,
33
37
fontSize : '95%'
34
38
}
35
39
} )
36
40
export default class FieldSelectionBase extends FieldCoreBase < IProps > {
41
+ get labelClassName ( ) : string {
42
+ const { helperText, disableLabelMargin, classes, FormControlLabelProps } = this . props ;
43
+ return ( helperText && ! disableLabelMargin ? classes . labelAlign : '' ) +
44
+ ( FormControlLabelProps && FormControlLabelProps . labelPlacement === 'start' ? classes . labelRight : '' ) ;
45
+ }
46
+
47
+ get helperTextClassName ( ) : string {
48
+ const { FormControlLabelProps, classes } = this . props ;
49
+ return classes . helperText +
50
+ ( FormControlLabelProps && FormControlLabelProps . labelPlacement === 'start' ? classes . labelRight : '' ) ;
51
+ }
52
+
37
53
onChange = ( event : React . ChangeEvent < any > ) => {
38
54
let value = this . props . value ;
39
55
@@ -82,9 +98,9 @@ export default class FieldSelectionBase extends FieldCoreBase<IProps> {
82
98
< React . Fragment >
83
99
{ ! ! label &&
84
100
< React . Fragment >
85
- < Typography className = { helperText ? classes . labelAlign : null } > { label } </ Typography >
101
+ < Typography className = { this . labelClassName } > { label } </ Typography >
86
102
{ ! ! helperText &&
87
- < Typography className = { classes . helperText } >
103
+ < Typography className = { this . helperTextClassName } >
88
104
{ helperText }
89
105
</ Typography >
90
106
}
0 commit comments