chunk-method-card.tsx

Overview

The chunk-method-card.tsx file defines a React component that provides a user interface card for selecting and displaying information about different "chunk methods" (parsers) within a knowledge configuration context. This component integrates a selection dropdown to choose a chunk method and dynamically displays related information including title, description, example images, and dialogue examples associated with the selected chunk method.

The file contains two main React functional components:

This UI component leverages several internal UI components (form controls, select dropdowns, cards), hooks for translation and user settings, and external libraries such as Ant Design and DOMPurify for safe HTML rendering.


Components and Functions

1. CategoryPanel

const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => { ... }

Description

CategoryPanel is a presentational component that displays information about the currently selected chunk method. It shows:

If no images or information exist for the selected chunk method, it displays an empty state with a placeholder icon.

Parameters

Internal Logic

Return Value

Usage Example

<CategoryPanel chunkMethod="someChunkMethod" />

2. ChunkMethodCard

export default function ChunkMethodCard() { ... }

Description

ChunkMethodCard is the main exported component providing a card UI that allows users to select a chunk method from a dropdown list and view its details via the CategoryPanel.

Internal Logic

Return Value

Usage Example

<ChunkMethodCard />

Implementation Details and Algorithms


Interaction with Other System Components

This component would typically be used in a larger knowledge management or configuration UI where users need to select and understand chunking/parsing methods for documents or data.


Visual Diagram

componentDiagram
    direction LR
    ChunkMethodCard <--> CategoryPanel : passes chunkMethod prop
    ChunkMethodCard --> FormField : renders form field for selection
    FormField --> Select : dropdown for chunk method selection
    CategoryPanel --> useSelectParserList : fetch parser list
    CategoryPanel --> useTranslate : fetch localized strings
    CategoryPanel --> ImageMap : fetch images for chunkMethod
    CategoryPanel --> SvgIcon : render example images/icons
    CategoryPanel --> DOMPurify : sanitize HTML description
    ChunkMethodCard --> useFormContext : get form controls

Summary

Component

Purpose

Key Props/Params

CategoryPanel

Displays details, description, examples of chunk method

chunkMethod: string

ChunkMethodCard

Card UI with selector and details panel

None

This file provides a modular and localized UI for managing chunk method selection and display, integrating safely sanitized HTML content, dynamic images, and form handling within a styled card layout.


Notes


End of Documentation for chunk-method-card.tsx