2022-05-16 19:44:42 +03:00

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 };