mirror of https://github.com/msgbyte/tailchat
feat: fast form 增加checkbox
parent
0da45418e6
commit
a0f3337ae0
@ -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…
Reference in New Issue