28 lines
599 B
TypeScript
28 lines
599 B
TypeScript
import type { SwitchProps } from 'antd';
|
|
import { Form, Switch } from 'antd';
|
|
import type { BaseElementProps } from './types';
|
|
|
|
const { Item: FormItem } = Form;
|
|
|
|
export default function Element({
|
|
value,
|
|
setValue,
|
|
status,
|
|
isValid,
|
|
help,
|
|
...props
|
|
}: BaseElementProps<boolean>) {
|
|
return (
|
|
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
|
|
<Switch
|
|
checked={value}
|
|
onChange={(enabled) => setValue(enabled)}
|
|
disabled={status === 'Disabled'}
|
|
{...props}
|
|
/>
|
|
</FormItem>
|
|
);
|
|
}
|
|
|
|
export type { SwitchProps };
|