import React from 'react'; import type { CheckboxProps } from 'antd'; import { Checkbox } from 'antd'; import ProField from '@ant-design/pro-field'; import type { ProSchema } from '@ant-design/pro-utils'; import { runFunction } from '@ant-design/pro-utils'; import type { CheckboxGroupProps } from 'antd/lib/checkbox'; import createField from '../../BaseForm/createField'; import type { ProFormItemProps } from '../../interface'; export type ProFormCheckboxGroupProps = ProFormItemProps & { layout?: 'horizontal' | 'vertical'; options: CheckboxGroupProps['options']; valueEnum?: ProSchema['valueEnum']; request?: ProSchema['request']; }; const CheckboxGroup: React.FC = React.forwardRef( ({ options, fieldProps, proFieldProps, valueEnum, ...rest }, ref) => ( (valueEnum, undefined)} {...rest} fieldProps={{ options, ...fieldProps, }} {...proFieldProps} /> ), ); export type ProFormCheckboxProps = ProFormItemProps; /** * 多选框的 * * @param */ const ProFormCheckboxComponents: React.FC = React.forwardRef< any, ProFormCheckboxProps >(({ fieldProps, children }, ref) => { return ( {children} ); }); const ProFormCheckbox = createField(ProFormCheckboxComponents, { valuePropName: 'checked', }); const Group = createField(CheckboxGroup); const WrappedProFormCheckbox: typeof ProFormCheckbox & { Group: typeof Group; } = ProFormCheckbox as any; WrappedProFormCheckbox.Group = Group; export default WrappedProFormCheckbox;