saleor-dashboard/src/components/ControlledCheckbox.tsx
Dominik Żegleń 935a6f4542
Reduce bundle size (#1103)
* Add analysis tools

* Use deep imports to reduce bundle size

* Remove tslint config

* Remove unused packages

* Remove lodash-es references

* Use root level mui imports

* Remove mui from restricted imports
2021-05-14 10:15:15 +02:00

39 lines
856 B
TypeScript

import { Checkbox, FormControlLabel } from "@material-ui/core";
import React from "react";
interface ControlledCheckboxProps {
className?: string;
name: string;
label?: React.ReactNode;
checked: boolean;
disabled?: boolean;
checkedIcon?: React.ReactNode;
onChange(event: any);
}
export const ControlledCheckbox: React.FC<ControlledCheckboxProps> = ({
checked,
disabled,
name,
label,
onChange,
checkedIcon,
...props
}) => (
<FormControlLabel
disabled={disabled}
control={
<Checkbox
checkedIcon={checkedIcon}
checked={!!checked}
disabled={disabled}
name={name}
onChange={() => onChange({ target: { name, value: !checked } })}
/>
}
label={label}
{...props}
/>
);
ControlledCheckbox.displayName = "ControlledCheckbox";
export default ControlledCheckbox;