2022-05-18 21:54:29 +03:00

33 lines
757 B
TypeScript

import type { CheckboxProps } from 'antd';
import { Checkbox as AntCheckbox, Form } from 'antd';
import type { CheckboxChangeEvent } from 'antd/lib/checkbox';
import type { BaseElementProps } from './types';
const { Item: FormItem } = Form;
export default function Checkbox({
value,
setValue,
status,
isValid,
help,
...props
}: BaseElementProps<boolean>) {
function handleChange(e: CheckboxChangeEvent) {
setValue(e.target.checked);
}
return (
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
<AntCheckbox
checked={value}
onChange={handleChange}
disabled={status === 'Disabled'}
{...props}
/>
</FormItem>
);
}
export type { CheckboxProps };