index.tsx


Overview

This file defines a React functional component, TuShareForm, which renders a form interface for users to input and configure parameters related to the TuShare API, a financial data service. The form includes inputs for API token, data source selection, date ranges, and keywords. A custom DateTimePicker component is embedded in the form for selecting date and time with proper formatting and value handling.

The primary purpose of this file is to provide a reusable, localized, and well-structured form UI component that integrates with Ant Design (antd), handles date-time inputs consistently using dayjs, and supports dynamic input variables through the imported DynamicInputVariable component.


Components and Functions

1. DateTimePicker

Description

A wrapper component around Ant Design's DatePicker that supports both date and time selection. It handles the conversion between the external numeric timestamp value and the internal dayjs object required by the DatePicker.

Props

Prop

Type

Description

onChange

[(val: number \

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

value

[number \

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

Behavior & Implementation Details

Usage Example

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

2. TuShareForm

Description

A form component built with Ant Design's Form component that collects parameters for queries to the TuShare financial data API. It supports internationalization through the useTranslate hook and dynamic input variables via the DynamicInputVariable component.

Props (from IOperatorForm interface)

Prop

Type

Description

onValuesChange

(changedValues, allValues) => void (optional)

Callback triggered when any form field changes.

form

FormInstance (Ant Design form instance)

The Ant Design form instance to be managed externally.

node

any (likely a data node object)

Passed to DynamicInputVariable for dynamic inputs.

Form Fields

Label (i18n key)

Name

Input Type

Notes

token

token

Text Input

API token, tooltip points to https://tushare.pro/

src

src

Select

Data source from predefined options (TuShareSrcOptions)

startDate

start_date

DateTimePicker

Start date/time for query

endDate

end_date

DateTimePicker

End date/time for query

keyword

keyword

Text Input

Keyword filter

Implementation Details

Usage Example

import { Form } from 'antd';
import TuShareForm from './index';

const [form] = Form.useForm();

const handleValuesChange = (changedValues, allValues) => {
  console.log('Form changed:', changedValues);
  console.log('All values:', allValues);
};

<TuShareForm form={form} onValuesChange={handleValuesChange} node={someNode} />;

Important Implementation Details & Algorithms


Interaction With Other Parts of the System

The form component (TuShareForm) is likely used within a larger workflow or node-based editor UI where operators or nodes represent different data sources or transformations. The node prop hints at contextual data passed down for dynamic input rendering.


Visual Diagram

componentDiagram
    component "TuShareForm" {
        +form: FormInstance
        +onValuesChange(changedValues, allValues)
        +node: any
        +DynamicInputVariable(node)
        +Form.Item(token: Input)
        +Form.Item(src: Select)
        +Form.Item(start_date: DateTimePicker)
        +Form.Item(end_date: DateTimePicker)
        +Form.Item(keyword: Input)
    }

    component "DateTimePicker" {
        +value: number | undefined
        +onChange(val: number | undefined)
        +DatePicker(showTime, format, onChange, value)
    }

    TuShareForm --> DateTimePicker : uses (for start_date, end_date)
    TuShareForm --> DynamicInputVariable : embeds

Summary

This file provides a localized, extensible form component for TuShare API parameter input in a React application. It leverages Ant Design UI components, supports dynamic variables, and handles date/time inputs robustly with dayjs. The modular design and typed props ensure seamless integration into larger workflows or node-based UI systems. The DateTimePicker subcomponent abstracts date/time formatting and conversion complexities, allowing consistent handling of date inputs throughout the app.