mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-16 20:15:58 +08:00
### What problem does this PR solve? Feat: Add FormContainer component #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
f8cc557892
commit
3877bcfc21
@ -13,6 +13,7 @@ import { Input } from '@/components/ui/input';
|
|||||||
import { Plus, Trash2 } from 'lucide-react';
|
import { Plus, Trash2 } from 'lucide-react';
|
||||||
import { useFieldArray, useFormContext } from 'react-hook-form';
|
import { useFieldArray, useFormContext } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Separator } from '../ui/separator';
|
||||||
|
|
||||||
export function DynamicPageRange() {
|
export function DynamicPageRange() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -31,7 +32,7 @@ export function DynamicPageRange() {
|
|||||||
{fields.map((field, index) => {
|
{fields.map((field, index) => {
|
||||||
const typeField = `parser_config.pages.${index}.from`;
|
const typeField = `parser_config.pages.${index}.from`;
|
||||||
return (
|
return (
|
||||||
<div key={field.id} className="flex items-center gap-1">
|
<div key={field.id} className="flex items-center gap-2 pt-2">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name={typeField}
|
name={typeField}
|
||||||
@ -42,6 +43,7 @@ export function DynamicPageRange() {
|
|||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
placeholder={t('common.pleaseInput')}
|
placeholder={t('common.pleaseInput')}
|
||||||
|
className="!m-0"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@ -49,6 +51,7 @@ export function DynamicPageRange() {
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
<Separator className="w-3 "></Separator>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name={`parser_config.pages.${index}.to`}
|
name={`parser_config.pages.${index}.to`}
|
||||||
@ -59,6 +62,7 @@ export function DynamicPageRange() {
|
|||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
placeholder={t('common.pleaseInput')}
|
placeholder={t('common.pleaseInput')}
|
||||||
|
className="!m-0"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
@ -75,9 +79,8 @@ export function DynamicPageRange() {
|
|||||||
})}
|
})}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => append({ from: 1, to: 100 })}
|
onClick={() => append({ from: 1, to: 100 })}
|
||||||
className="mt-4"
|
className="mt-4 border-dashed w-full"
|
||||||
variant={'outline'}
|
variant={'outline'}
|
||||||
size={'sm'}
|
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<Plus />
|
<Plus />
|
||||||
|
@ -30,10 +30,10 @@ import {
|
|||||||
AutoKeywordsFormField,
|
AutoKeywordsFormField,
|
||||||
AutoQuestionsFormField,
|
AutoQuestionsFormField,
|
||||||
} from '../auto-keywords-form-field';
|
} from '../auto-keywords-form-field';
|
||||||
import { DatasetConfigurationContainer } from '../dataset-configuration-container';
|
|
||||||
import { DelimiterFormField } from '../delimiter-form-field';
|
import { DelimiterFormField } from '../delimiter-form-field';
|
||||||
import { EntityTypesFormField } from '../entity-types-form-field';
|
import { EntityTypesFormField } from '../entity-types-form-field';
|
||||||
import { ExcelToHtmlFormField } from '../excel-to-html-form-field';
|
import { ExcelToHtmlFormField } from '../excel-to-html-form-field';
|
||||||
|
import { FormContainer } from '../form-container';
|
||||||
import { LayoutRecognizeFormField } from '../layout-recognize-form-field';
|
import { LayoutRecognizeFormField } from '../layout-recognize-form-field';
|
||||||
import { MaxTokenNumberFormField } from '../max-token-number-from-field';
|
import { MaxTokenNumberFormField } from '../max-token-number-from-field';
|
||||||
import {
|
import {
|
||||||
@ -242,6 +242,7 @@ export function ChunkMethodDialog({
|
|||||||
className="space-y-6 max-h-[70vh] overflow-auto"
|
className="space-y-6 max-h-[70vh] overflow-auto"
|
||||||
id={FormId}
|
id={FormId}
|
||||||
>
|
>
|
||||||
|
<FormContainer>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="parser_id"
|
name="parser_id"
|
||||||
@ -265,7 +266,9 @@ export function ChunkMethodDialog({
|
|||||||
name="parser_config.task_page_size"
|
name="parser_config.task_page_size"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel tooltip={t('knowledgeDetails.taskPageSizeTip')}>
|
<FormLabel
|
||||||
|
tooltip={t('knowledgeDetails.taskPageSizeTip')}
|
||||||
|
>
|
||||||
{t('knowledgeDetails.taskPageSize')}
|
{t('knowledgeDetails.taskPageSize')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
@ -281,7 +284,8 @@ export function ChunkMethodDialog({
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<DatasetConfigurationContainer
|
</FormContainer>
|
||||||
|
<FormContainer
|
||||||
show={showOne || showMaxTokenNumber}
|
show={showOne || showMaxTokenNumber}
|
||||||
className="space-y-3"
|
className="space-y-3"
|
||||||
>
|
>
|
||||||
@ -298,8 +302,8 @@ export function ChunkMethodDialog({
|
|||||||
<DelimiterFormField></DelimiterFormField>
|
<DelimiterFormField></DelimiterFormField>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</DatasetConfigurationContainer>
|
</FormContainer>
|
||||||
<DatasetConfigurationContainer
|
<FormContainer
|
||||||
show={showAutoKeywords(selectedTag) || showExcelToHtml}
|
show={showAutoKeywords(selectedTag) || showExcelToHtml}
|
||||||
className="space-y-3"
|
className="space-y-3"
|
||||||
>
|
>
|
||||||
@ -310,13 +314,13 @@ export function ChunkMethodDialog({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{showExcelToHtml && <ExcelToHtmlFormField></ExcelToHtmlFormField>}
|
{showExcelToHtml && <ExcelToHtmlFormField></ExcelToHtmlFormField>}
|
||||||
</DatasetConfigurationContainer>
|
</FormContainer>
|
||||||
{showRaptorParseConfiguration(
|
{showRaptorParseConfiguration(
|
||||||
selectedTag as DocumentParserType,
|
selectedTag as DocumentParserType,
|
||||||
) && (
|
) && (
|
||||||
<DatasetConfigurationContainer>
|
<FormContainer>
|
||||||
<RaptorFormFields></RaptorFormFields>
|
<RaptorFormFields></RaptorFormFields>
|
||||||
</DatasetConfigurationContainer>
|
</FormContainer>
|
||||||
)}
|
)}
|
||||||
{showGraphRagItems(selectedTag as DocumentParserType) &&
|
{showGraphRagItems(selectedTag as DocumentParserType) &&
|
||||||
useGraphRag && <UseGraphRagFormField></UseGraphRagFormField>}
|
useGraphRag && <UseGraphRagFormField></UseGraphRagFormField>}
|
||||||
|
21
web/src/components/form-container.tsx
Normal file
21
web/src/components/form-container.tsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { PropsWithChildren } from 'react';
|
||||||
|
|
||||||
|
type FormContainerProps = {
|
||||||
|
className?: string;
|
||||||
|
show?: boolean;
|
||||||
|
} & PropsWithChildren;
|
||||||
|
|
||||||
|
export function FormContainer({
|
||||||
|
children,
|
||||||
|
show = true,
|
||||||
|
className,
|
||||||
|
}: FormContainerProps) {
|
||||||
|
return show ? (
|
||||||
|
<section className={cn('border rounded-lg p-5 space-y-5', className)}>
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
|
) : (
|
||||||
|
children
|
||||||
|
);
|
||||||
|
}
|
@ -38,8 +38,19 @@ export function SliderInputFormField({
|
|||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<FormLabel tooltip={tooltip}>{label}</FormLabel>
|
<FormLabel tooltip={tooltip}>{label}</FormLabel>
|
||||||
|
<div className="flex items-center gap-14 justify-between">
|
||||||
|
<FormControl>
|
||||||
|
<SingleFormSlider
|
||||||
|
{...field}
|
||||||
|
max={max}
|
||||||
|
min={min}
|
||||||
|
step={step}
|
||||||
|
// defaultValue={
|
||||||
|
// typeof defaultValue === 'number' ? [defaultValue] : undefined
|
||||||
|
// }
|
||||||
|
></SingleFormSlider>
|
||||||
|
</FormControl>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input
|
||||||
type={'number'}
|
type={'number'}
|
||||||
@ -52,17 +63,6 @@ export function SliderInputFormField({
|
|||||||
></Input>
|
></Input>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
<FormControl>
|
|
||||||
<SingleFormSlider
|
|
||||||
{...field}
|
|
||||||
max={max}
|
|
||||||
min={min}
|
|
||||||
step={step}
|
|
||||||
// defaultValue={
|
|
||||||
// typeof defaultValue === 'number' ? [defaultValue] : undefined
|
|
||||||
// }
|
|
||||||
></SingleFormSlider>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
@ -29,7 +29,7 @@ const DualRangeSlider = React.forwardRef<
|
|||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
|
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
|
||||||
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
<SliderPrimitive.Range className="absolute h-full bg-background-checked" />
|
||||||
</SliderPrimitive.Track>
|
</SliderPrimitive.Track>
|
||||||
{initialValue.map((value, index) => (
|
{initialValue.map((value, index) => (
|
||||||
<React.Fragment key={index}>
|
<React.Fragment key={index}>
|
||||||
@ -65,7 +65,6 @@ const SingleFormSlider = React.forwardRef<
|
|||||||
return (
|
return (
|
||||||
<DualRangeSlider
|
<DualRangeSlider
|
||||||
ref={ref}
|
ref={ref}
|
||||||
label={(value) => value}
|
|
||||||
value={[value]}
|
value={[value]}
|
||||||
onValueChange={(vals) => {
|
onValueChange={(vals) => {
|
||||||
onChange(vals[0]);
|
onChange(vals[0]);
|
||||||
|
@ -99,7 +99,7 @@ const FormLabel = React.forwardRef<
|
|||||||
return (
|
return (
|
||||||
<Label
|
<Label
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(error && 'text-destructive', className, 'flex')}
|
className={cn(error && 'text-destructive', className, 'flex pb-0.5')}
|
||||||
htmlFor={formItemId}
|
htmlFor={formItemId}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user