saleor-dashboard/src/components/ControlledCheckbox.tsx
Patryk Andrzejewski 1d2eeb7592
Strict mode plugin (#3778)
* Stric mode plugin

* Update command
2023-06-21 11:28:00 +02:00

46 lines
1 KiB
TypeScript

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