index.tsx


Overview

This file defines a React functional component, TuShareForm, which implements a user input form tailored for interacting with the TuShare API — a financial data interface. The form allows users to provide necessary parameters such as API token, data source, date ranges, and keywords to fetch data from TuShare.

Additionally, the file defines a reusable DateTimePicker component wrapping Ant Design's DatePicker with time support, customized to handle date-time values as strings formatted for backend compatibility.

Key features:


Classes, Functions, and Components

DateTimePicker

A React component wrapping Ant Design's DatePicker with time selection enabled. It handles conversion between internal date-time string values and the dayjs object expected by the UI component.

Props

Name

Type

Description

onChange

[(val: number \

undefined) => void](/projects/311/71659) (optional)

value

[number \

undefined](/projects/311/74002) (optional)

Behavior

Usage Example

<DateTimePicker
  value={someTimestamp}
  onChange={(val) => console.log('Selected date-time:', val)}
/>

TuShareForm

Main export component representing the form used to collect TuShare API query parameters.

Props (from IOperatorForm interface)

Name

Type

Description

onValuesChange

(changedValues: any, allValues: any) => void

Callback invoked when any form field value changes.

form

FormInstance (from Ant Design)

The form instance used to control form state and validation.

node

any (likely node data from flow context)

Data passed to DynamicInputVariable component for dynamic variable inputs.

Form Fields

Dynamic inputs are also supported via the DynamicInputVariable component rendered at the top.

Implementation Details

Usage Example

<TuShareForm
  form={formInstance}
  onValuesChange={(changed, all) => console.log(all)}
  node={currentNodeData}
/>

Important Implementation Details and Algorithms


Interaction with Other Parts of the System


Mermaid Component Diagram

componentDiagram
    component TuShareForm {
        +onValuesChange
        +form
        +node
        -tuShareSrcOptions
        +render()
    }
    component DateTimePicker {
        +onChange
        +value
        -handleChange()
        +render()
    }
    component DynamicInputVariable
    component AntdForm
    component AntdInput
    component AntdSelect
    component AntdDatePicker

    TuShareForm --> AntdForm : uses
    TuShareForm --> DynamicInputVariable : uses
    TuShareForm --> AntdInput : uses
    TuShareForm --> AntdSelect : uses
    TuShareForm --> DateTimePicker : uses (for start_date, end_date)
    DateTimePicker --> AntdDatePicker : wraps

Summary

This file primarily provides a structured form component for configuring TuShare API queries, emphasizing user-friendly date-time input, localization, and dynamic variable injection. It leverages Ant Design components for consistent UI and integrates tightly with the system's translation and data source option management. The modular DateTimePicker component encapsulates date-time formatting logic to ensure clean separation of concerns and reusability.