auto-keywords-item.tsx


Overview

The auto-keywords-item.tsx file defines two React functional components, AutoKeywordsItem and AutoQuestionsItem, which are used to render form items for configuring automatic extraction settings in a user interface. Both components leverage Ant Design (antd) UI components and a custom translation hook for internationalization. These components allow users to specify numeric values via synchronized Slider and InputNumber controls within a form, specifically targeting configuration parameters related to "auto keywords" and "auto questions" respectively.


Components

1. AutoKeywordsItem

Purpose

Renders a form item that allows users to set the number of automatic keywords generated by some parser configuration. It combines a slider and a numeric input for flexible user input.

Function Signature

const AutoKeywordsItem: React.FC = () => JSX.Element;

Internals and Behavior

Usage Example

import { AutoKeywordsItem } from './auto-keywords-item';

<Form>
  <AutoKeywordsItem />
</Form>

2. AutoQuestionsItem

Purpose

Renders a form item for configuring the number of automatic questions generated by the parser configuration. Functionally similar to AutoKeywordsItem but with different value boundaries and form keys.

Function Signature

const AutoQuestionsItem: React.FC = () => JSX.Element;

Internals and Behavior

Usage Example

import { AutoQuestionsItem } from './auto-keywords-item';

<Form>
  <AutoQuestionsItem />
</Form>

Implementation Details and Algorithms


Interaction with Other System Components


Mermaid Diagram

componentDiagram
    component AutoKeywordsItem {
        +useTranslate('knowledgeDetails')
        +Form.Item(label, tooltip)
        +Flex(gap=20, align=center)
        +Form.Item(name=['parser_config','auto_keywords'], noStyle, initialValue=0)
        +Slider(max=30)
        +Form.Item(name=['parser_config','auto_keywords'], noStyle)
        +InputNumber(min=0, max=30)
    }
    component AutoQuestionsItem {
        +useTranslate('knowledgeDetails')
        +Form.Item(label, tooltip)
        +Flex(gap=20, align=center)
        +Form.Item(name=['parser_config','auto_questions'], noStyle, initialValue=0)
        +Slider(max=10)
        +Form.Item(name=['parser_config','auto_questions'], noStyle)
        +InputNumber(min=0, max=10)
    }
    AutoKeywordsItem <--> AutoQuestionsItem : share similar structure and form binding pattern

Summary

The auto-keywords-item.tsx file provides two reusable React components for setting numeric configuration values related to automatic keyword and question generation within a form. They use Ant Design's UI components for a polished and consistent UI experience and support internationalization. Their design promotes synchronized input controls and clear user guidance through labels and tooltips, fitting into a larger system that involves parser configuration management and localized user interfaces.