saleor-dashboard/src/components/ControlledCheckbox.tsx
Michał Droń 8d16513eab
Enable method signature style ESLint rule (#3849)
* Remove redundant rules handled by prettier

* Turn on method-signature-style

* Auto-lint files according to method-signature-style rule

* Add changeset
2023-07-05 11:19:58 +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) => 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;