index.tsx
952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { FormItem, Checkbox } from '@formily/antd-v5';
import { Field } from '@formily/react';
import cx from 'classnames';
import './index.less';
import { FieldProps } from '../../typings';
interface Option {
value: string | number;
label: string;
disabled?: boolean;
}
export interface P extends FieldProps {
options: Option[];
}
const CheckboxGroup: React.FC<P> = (props) => {
const { name, title, options = [], validator = [], decoratorProps, componentProps } = props;
return (
<div className={cx('global_checkbox')}>
<Field
{...props}
name={name}
title={title}
dataSource={options}
decorator={[FormItem, { ...decoratorProps }]}
component={[
Checkbox.Group,
{
...componentProps,
componenttypename: 'Checkbox.Group',
},
]}
validator={validator}
/>
</div>
);
};
export default CheckboxGroup;