2019-06-19 14:40:52 +00:00
|
|
|
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
import Checkbox from "./Checkbox";
|
|
|
|
|
|
|
|
interface ControlledCheckboxProps {
|
2019-11-12 12:21:37 +00:00
|
|
|
className?: string;
|
2019-06-19 14:40:52 +00:00
|
|
|
name: string;
|
|
|
|
label?: React.ReactNode;
|
|
|
|
checked: boolean;
|
|
|
|
disabled?: boolean;
|
|
|
|
onChange(event: any);
|
|
|
|
}
|
|
|
|
|
2019-11-07 11:34:54 +00:00
|
|
|
export const ControlledCheckbox: React.FC<ControlledCheckboxProps> = ({
|
|
|
|
checked,
|
|
|
|
disabled,
|
|
|
|
name,
|
|
|
|
label,
|
2019-11-12 12:21:37 +00:00
|
|
|
onChange,
|
|
|
|
...props
|
2019-11-07 11:34:54 +00:00
|
|
|
}) => (
|
2019-06-19 14:40:52 +00:00
|
|
|
<FormControlLabel
|
|
|
|
disabled={disabled}
|
|
|
|
control={
|
|
|
|
<Checkbox
|
|
|
|
checked={checked}
|
2020-03-23 10:49:25 +00:00
|
|
|
disabled={disabled}
|
2019-06-19 14:40:52 +00:00
|
|
|
name={name}
|
2019-08-09 11:14:35 +00:00
|
|
|
disableClickPropagation
|
2019-06-19 14:40:52 +00:00
|
|
|
onChange={() => onChange({ target: { name, value: !checked } })}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={label}
|
2019-11-12 12:21:37 +00:00
|
|
|
{...props}
|
2019-06-19 14:40:52 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
ControlledCheckbox.displayName = "ControlledCheckbox";
|
|
|
|
export default ControlledCheckbox;
|