feat: fast form 增加checkbox

release/desktop
moonrailgun 3 years ago
parent 0da45418e6
commit a0f3337ae0

@ -11,12 +11,14 @@ import { FastFormText } from './types/Text';
import { FastFormTextArea } from './types/TextArea';
import { FastFormPassword } from './types/Password';
import { FastFormSelect } from './types/Select';
import { FastFormCheckbox } from './types/Checkbox';
import { FastFormCustom } from './types/Custom';
regField('text', FastFormText);
regField('textarea', FastFormTextArea);
regField('password', FastFormPassword);
regField('select', FastFormSelect);
regField('checkbox', FastFormCheckbox);
regField('custom', FastFormCustom);
const WebFastFormContainer: FastFormContainerComponent = React.memo((props) => {

@ -0,0 +1,25 @@
import React from 'react';
import { Form, Checkbox } from 'antd';
import type { FastFormFieldComponent } from 'tailchat-shared';
import { getValidateStatus } from '../utils';
export const FastFormCheckbox: FastFormFieldComponent = React.memo((props) => {
const { name, label, value, onChange, error } = props;
return (
<Form.Item
label={label}
validateStatus={getValidateStatus(error)}
help={error}
>
<Checkbox
name={name}
checked={Boolean(value)}
onChange={(e) => onChange(e.target.checked)}
>
{label}
</Checkbox>
</Form.Item>
);
});
FastFormCheckbox.displayName = 'FastFormCheckbox';
Loading…
Cancel
Save