import React from "react"; import { IOption } from "../Form/SelectField"; import Tooltip from "../ToolTip"; import Typography, { ITypo, ITypoColor } from "../Typography"; import classes from "./classes.module.scss"; type IProps = { name?: string; option: IOption; toolTip?: string; onChange?: (e: React.ChangeEvent) => void; checked: boolean; }; type IState = { checked: boolean; }; export default class CheckBox extends React.Component { static defaultProps = { toolTip: "", checked: false, }; constructor(props: IProps) { super(props); this.state = { checked: this.props.checked ?? false, }; this.onChange = this.onChange.bind(this); } public override render(): JSX.Element { return ( ); } public override componentDidUpdate(prevProps: Readonly): void { if (prevProps.checked !== this.props.checked) { this.setState({ checked: this.props.checked, }); } } private onChange(e: React.ChangeEvent) { this.setState({ checked: !this.state.checked, }); this.props.onChange && this.props.onChange(e); } }