mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-19 12:06:42 +08:00
### What problem does this PR solve? Feat: Add hatPromptEngine component #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
38
web/src/components/switch-fom-field.tsx
Normal file
38
web/src/components/switch-fom-field.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import {
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
} from '@/components/ui/form';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { ReactNode } from 'react';
|
||||
import { useFormContext } from 'react-hook-form';
|
||||
|
||||
interface SwitchFormItemProps {
|
||||
name: string;
|
||||
label: ReactNode;
|
||||
}
|
||||
|
||||
export function SwitchFormField({ label, name }: SwitchFormItemProps) {
|
||||
const form = useFormContext();
|
||||
|
||||
return (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={name}
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex justify-between">
|
||||
<FormLabel className="text-base">{label}</FormLabel>
|
||||
<FormControl>
|
||||
<Switch
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
aria-readonly
|
||||
className="!m-0"
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user