import { TableOutlined } from '@ant-design/icons'; import { FormDialog, FormLayout } from '@formily/antd'; import { SchemaOptionsContext } from '@formily/react'; import { SchemaComponent, SchemaComponentOptions, SchemaInitializer, SchemaInitializerButtonContext, useAPIClient, } from '@nocobase/client'; import React, { useContext, useEffect, useState } from 'react'; import { useChartQueryMetadataContext } from './ChartQueryMetadataProvider'; import { lang } from './locale'; import { getQueryTypeSchema } from './settings/queryTypes'; export interface ChartQueryMetadata { id: number; title: string; type: string; fields: { name: string }[]; } export const ChartQueryBlockInitializer = (props) => { const defaultItems: any = [ { type: 'itemGroup', title: lang('Select query data'), children: [], }, ]; const { templateWrap, onCreateBlockSchema, componentType, createBlockSchema, insert, ...others } = props; const { setVisible } = useContext(SchemaInitializerButtonContext); const [items, setItems] = useState(defaultItems); const apiClient = useAPIClient(); const ctx = useChartQueryMetadataContext(); const options = useContext(SchemaOptionsContext); const onAddQuery = (info) => { FormDialog( { sql: lang('Add SQL query'), json: lang('Add JSON query'), }[info.key], () => { return (