Fix missing CheckBoxInput labels
This commit is contained in:
@@ -23,13 +23,19 @@ type PrimaryTextProps = {
|
|||||||
type Props = BaseProps &
|
type Props = BaseProps &
|
||||||
((LabelProps & PropertiesNever<PrimaryTextProps>) | (PropertiesNever<LabelProps> & PrimaryTextProps));
|
((LabelProps & PropertiesNever<PrimaryTextProps>) | (PropertiesNever<LabelProps> & PrimaryTextProps));
|
||||||
|
|
||||||
export const CheckboxInput = ({ primaryText, secondaryText, sx, ...rest }: Props) => (
|
export const CheckboxInput = ({ label, primaryText, secondaryText, sx, ...rest }: Props) => (
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={<Checkbox {...rest} />}
|
control={<Checkbox {...rest} />}
|
||||||
label={
|
label={(() => {
|
||||||
primaryText && !secondaryText ? (
|
if (label) {
|
||||||
primaryText
|
return label;
|
||||||
) : (
|
}
|
||||||
|
|
||||||
|
if (primaryText && !secondaryText) {
|
||||||
|
return primaryText;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
sx={{
|
sx={{
|
||||||
// Padding comes from the MUI Checkbox component
|
// Padding comes from the MUI Checkbox component
|
||||||
@@ -45,8 +51,8 @@ export const CheckboxInput = ({ primaryText, secondaryText, sx, ...rest }: Props
|
|||||||
secondaryText
|
secondaryText
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
)
|
);
|
||||||
}
|
})()}
|
||||||
sx={sx}
|
sx={sx}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user