template-node.tsx


Overview

The template-node.tsx file defines a React functional component named TemplateNode that visually represents a customized node within a flow-based UI, likely part of a workflow or data flow editor. It leverages the @xyflow/react library for node handles and positions, antd for layout, and React hooks to integrate theme and dynamic label fetching.

The component displays:

It supports theming (dark/light mode) and selection highlighting, making it visually adaptable within a larger flow canvas.


Detailed Explanation

Imports & Dependencies


Component: InnerTemplateNode

Signature

function InnerTemplateNode({
  id,
  data,
  isConnectable = true,
  selected,
}: NodeProps<ITemplateNode>): JSX.Element

Parameters

Returns

Description

Usage Example

import { TemplateNode } from './template-node';

// Within a React Flow canvas or similar container:
<TemplateNode
  id="node-1"
  data={{
    name: 'Example Node',
    label: 'Example Label',
    form: {
      parameters: [
        { id: 'p1', key: 'Param A', component_id: 'comp123' },
        { id: 'p2', key: 'Param B', component_id: 'comp456' },
      ],
    },
  }}
  selected={true}
  isConnectable={true}
/>

Exported Component

export const TemplateNode = memo(InnerTemplateNode);

Important Implementation Details


Interaction with Other System Parts


Visual Diagram

classDiagram
    class InnerTemplateNode {
        +id: string
        +data: ITemplateNode
        +isConnectable: boolean
        +selected: boolean
        +render(): JSX.Element
    }
    InnerTemplateNode o-- NodeHeader : uses
    InnerTemplateNode ..> Handle : renders two
    InnerTemplateNode ..> useTheme : hook
    InnerTemplateNode ..> useGetComponentLabelByValue : hook
    InnerTemplateNode ..> Flex : layout parameters

Summary

template-node.tsx encapsulates the UI and logic of a templated flow node with connection handles, dynamic parameter display, and theming support. It is a building block within a flow-based visual editor, integrating with hooks and components from the broader application ecosystem to provide a responsive and informative node representation. The file exemplifies modular React component design with clean separation of concerns and extensible styling patterns.