* feat: init localization-management * feat: resource api * Merge branch 'main' into T-62 * chore: change name * feat: basic feature * feat: support filter & sync * feat: support auto get texts afterSave * Merge branch 'main' into T-62 * chore: upgrade * fix: dependency * fix: field type * fix: type error * chore: remove some translations * feat: support extract text from menu * chore: cache text keys * chore: remove test key * fix: issue of extracting menu titles * feat: translate collections & fields name * fix: remove unique of text * refactor: improve cache * chore: remove listeners after disable * chore: translation * fix: lang switch bug * refactor: actions & filter * fix: translation * refactor: merge lang bundles at backend * fix: style & field name * fix: translate issues * fix: cache bug * fix: translation merge bug * fix: translate issues * fix: map translation * fix: translation issues * fix: card title bug * feat: cover mobile client tabbar * fix: menu title * refactor: add locale plugin * chore: merge locale plugin * fix: map translation * chore: remove no data * style: change button style * fix: sync bug * docs: add README * chore: change name --------- Co-authored-by: chenos <chenlinxh@gmail.com>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { Plugin, SchemaComponentOptions, SchemaInitializerContext, SchemaInitializerProvider } from '@nocobase/client';
|
|
import React, { useContext } from 'react';
|
|
import { ChartInitializers, ChartV2Block, ChartV2BlockDesigner, ChartV2BlockInitializer } from './block';
|
|
import { useChartsTranslation } from './locale';
|
|
import { ChartRenderer, ChartRendererProvider, InternalLibrary } from './renderer';
|
|
import { ChartLibraryProvider } from './renderer/ChartLibrary';
|
|
|
|
const Chart: React.FC = (props) => {
|
|
const { t } = useChartsTranslation();
|
|
const initializers = useContext<any>(SchemaInitializerContext);
|
|
const children = initializers.BlockInitializers.items[0].children;
|
|
const has = children.some((initializer) => initializer.component === 'ChartV2BlockInitializer');
|
|
if (!has) {
|
|
children.push({
|
|
key: 'chart-v2',
|
|
type: 'item',
|
|
title: t('Charts'),
|
|
component: 'ChartV2BlockInitializer',
|
|
});
|
|
}
|
|
return (
|
|
<SchemaComponentOptions
|
|
components={{
|
|
ChartV2BlockInitializer,
|
|
ChartRenderer,
|
|
ChartV2BlockDesigner,
|
|
ChartV2Block,
|
|
ChartRendererProvider,
|
|
}}
|
|
>
|
|
<SchemaInitializerProvider initializers={{ ...initializers, ChartInitializers }}>
|
|
<ChartLibraryProvider name="Built-in" charts={InternalLibrary}>
|
|
{props.children}
|
|
</ChartLibraryProvider>
|
|
</SchemaInitializerProvider>
|
|
</SchemaComponentOptions>
|
|
);
|
|
};
|
|
|
|
class DataVisualizationPlugin extends Plugin {
|
|
async load() {
|
|
this.app.addProvider(Chart);
|
|
}
|
|
}
|
|
|
|
export default DataVisualizationPlugin;
|
|
export { ChartLibraryProvider };
|