saleor-dashboard/src/components/ControlledCheckbox.tsx

32 lines
776 B
TypeScript
Raw Normal View History

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 {
name: string;
label?: React.ReactNode;
checked: boolean;
disabled?: boolean;
onChange(event: any);
}
export const ControlledCheckbox: React.StatelessComponent<
ControlledCheckboxProps
> = ({ checked, disabled, name, label, onChange }) => (
<FormControlLabel
disabled={disabled}
control={
<Checkbox
checked={checked}
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}
/>
);
ControlledCheckbox.displayName = "ControlledCheckbox";
export default ControlledCheckbox;