24 lines
562 B
TypeScript
24 lines
562 B
TypeScript
import type { BaseElementProps } from './types';
|
|
import type { SwitchProps } from 'antd';
|
|
import { Form, Switch as AntSwitch } from 'antd';
|
|
import type { FC } from 'react';
|
|
|
|
const { Item: FormItem } = Form;
|
|
|
|
function Switch({
|
|
value,
|
|
setValue,
|
|
status,
|
|
validateStatus,
|
|
help,
|
|
...props
|
|
}: BaseElementProps<boolean>) {
|
|
return (
|
|
<FormItem help={help} validateStatus={validateStatus}>
|
|
<AntSwitch checked={value} disabled={status === 'Disabled'} onChange={setValue} {...props} />
|
|
</FormItem>
|
|
);
|
|
}
|
|
|
|
export default Switch as FC<SwitchProps>;
|