@devtable/dashboard 2.6.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { IConfigComponentProps, IViewComponentProps } from '../plugins/viz-manager/components';
3
+ import { IVizConfig } from '../types';
4
+ export declare function PluginVizConfigComponent({ setVizConf, ...props }: IConfigComponentProps & {
5
+ setVizConf: (val: React.SetStateAction<IVizConfig>) => void;
6
+ }): JSX.Element;
7
+ export declare function PluginVizViewComponent(props: IViewComponentProps): JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IVizConfig } from '../../types/dashboard';
2
+ import { IVizConfig } from '../../types';
3
3
  interface IViz {
4
4
  viz: IVizConfig;
5
5
  data: any;
@@ -0,0 +1,2 @@
1
+ export * from './use-channel-event';
2
+ export * from './use-storage-data';
@@ -0,0 +1,2 @@
1
+ import { ListenerFn, EventEmitter2 } from 'eventemitter2';
2
+ export declare function useChannelEvent(channel: EventEmitter2, event: string, listener: ListenerFn): void;
@@ -0,0 +1,6 @@
1
+ import { PluginStorage } from '../../types/plugin';
2
+ export declare const useStorageData: <T>(storage: PluginStorage, dataKey: string) => {
3
+ loading: boolean;
4
+ value: T | undefined;
5
+ set: (val: T) => Promise<void>;
6
+ };
@@ -0,0 +1,4 @@
1
+ export * from './viz-manager';
2
+ export * from './plugin-context';
3
+ export * from './plugin-data-migrator';
4
+ export * from './hooks';
@@ -1,8 +1,12 @@
1
1
  import { PluginStorage } from '../types/plugin';
2
2
  export declare class JsonPluginStorage implements PluginStorage {
3
- private root;
4
- constructor(root: Record<string, any>);
3
+ protected rootRef: {
4
+ current: Record<string, any>;
5
+ };
6
+ constructor(initValue: Record<string, any>);
5
7
  deleteItem(key: string): Promise<void>;
6
- getItem<T>(key: string): Promise<T>;
7
- setItem<T>(key: string, item: T): Promise<T>;
8
+ getItem<T>(key: string | null): Promise<T>;
9
+ private getValueFromRoot;
10
+ setItem<T>(key: string | null, item: T): Promise<T>;
11
+ watchItem<T>(key: string | null, callback: (value: T, previous?: T) => void): () => void;
8
12
  }
@@ -4,5 +4,4 @@ export declare class MessageChannels implements IMessageChannels {
4
4
  private channels;
5
5
  globalChannel: EventEmitter2;
6
6
  getChannel(name: string): EventEmitter2;
7
- close(name: string): void;
8
7
  }
@@ -0,0 +1 @@
1
+ export * from './plugin-data-migrator';
@@ -0,0 +1,13 @@
1
+ interface IMigration {
2
+ version: number;
3
+ handler: (data: any) => any;
4
+ }
5
+ export declare class PluginDataMigrator {
6
+ protected migrations: IMigration[];
7
+ version(version: number, handler: (data: any) => any): PluginDataMigrator;
8
+ run(migrationTarget: {
9
+ from: number;
10
+ to: number;
11
+ }, val: any): any;
12
+ }
13
+ export {};
@@ -0,0 +1,2 @@
1
+ import { VizComponent } from '../../../types/plugin';
2
+ export declare const TableVizComponent: VizComponent;
@@ -19,3 +19,4 @@ export interface ITableConf {
19
19
  striped: boolean;
20
20
  highlightOnHover: boolean;
21
21
  }
22
+ export declare const DEFAULT_CONFIG: ITableConf;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { VizConfigProps } from '../../../types/plugin';
3
+ export declare function VizTablePanel({ context }: VizConfigProps): JSX.Element;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { VizViewProps } from '../../../types/plugin';
3
+ export declare function VizTable({ context }: VizViewProps): JSX.Element;
@@ -13,11 +13,10 @@ export declare type IViewComponentProps<TDebug = {}> = {
13
13
  vizManager: IVizManager;
14
14
  } & TDebug;
15
15
  export declare const VizViewComponent: <T>(props: IViewComponentProps<T>) => JSX.Element;
16
- declare type IConfigComponentProps<TDebug = {}> = {
16
+ export declare type IConfigComponentProps<TDebug = {}> = {
17
17
  panel: IPanelInfo;
18
18
  panelInfoEditor: IPanelInfoEditor;
19
19
  vizManager: IVizManager;
20
20
  data: any;
21
21
  } & TDebug;
22
22
  export declare const VizConfigComponent: <T>(props: IConfigComponentProps<T>) => JSX.Element;
23
- export {};
@@ -1,3 +1,4 @@
1
1
  export { VizManager } from './impl';
2
2
  export type { IVizManager, IPanelInfo } from './types';
3
3
  export { VizConfigComponent, VizViewComponent } from './components';
4
+ export type { IViewPanelInfo, IViewComponentProps } from './components';
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  export interface VizInstance {
7
7
  id: string;
8
8
  name: string;
9
+ type: string;
9
10
  }
10
11
  /**
11
12
  * Props to render the view of viz component
@@ -15,9 +16,10 @@ export interface VizViewProps {
15
16
  context: VizViewContext;
16
17
  }
17
18
  export interface PluginStorage {
18
- getItem<T>(key: string): Promise<T>;
19
- setItem<T>(key: string, item: T): Promise<T>;
19
+ getItem<T>(key: string | null): Promise<T>;
20
+ setItem<T>(key: string | null, item: T): Promise<T>;
20
21
  deleteItem(key: string): Promise<void>;
22
+ watchItem<T>(key: string | null, callback: (value: T, previous?: T) => void): () => void;
21
23
  }
22
24
  export interface ColorPaletteItem {
23
25
  name: string;
@@ -38,7 +40,6 @@ export interface ColorPalette {
38
40
  export interface IMessageChannels {
39
41
  globalChannel: EventEmitter2;
40
42
  getChannel(name: string): EventEmitter2;
41
- close(name: string): void;
42
43
  }
43
44
  export interface VizContext {
44
45
  pluginData: PluginStorage;
@@ -68,7 +69,6 @@ export interface VizConfigProps {
68
69
  context: VizConfigContext;
69
70
  }
70
71
  export interface VizComponentMigrationContext {
71
- pluginData: PluginStorage;
72
72
  instanceData: PluginStorage;
73
73
  }
74
74
  export interface VizComponent {
@@ -76,7 +76,11 @@ export interface VizComponent {
76
76
  displayName?: string;
77
77
  viewRender: React.ComponentType<VizViewProps>;
78
78
  configRender: React.ComponentType<VizConfigProps>;
79
- migration: (ctx: VizComponentMigrationContext) => Promise<void>;
79
+ migrator: IVizComponentMigrator;
80
+ }
81
+ export interface IVizComponentMigrator {
82
+ needMigration(ctx: VizComponentMigrationContext): Promise<boolean>;
83
+ migrate(ctx: VizComponentMigrationContext): Promise<void>;
80
84
  }
81
85
  export interface IPluginManifest {
82
86
  viz: VizComponent[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,9 +32,9 @@
32
32
  "dependencies": {
33
33
  "eventemitter2": "^6.4.6",
34
34
  "file-saver": "2.0.5",
35
- "stickybits": "3.7.11",
36
35
  "jszip": "3.10.1",
37
- "popmotion": "^11.0.3"
36
+ "popmotion": "^11.0.3",
37
+ "stickybits": "3.7.11"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@mantine/core": "^5.0.2",
@@ -45,10 +45,12 @@
45
45
  "@mantine/notifications": "^5.0.2",
46
46
  "@mantine/prism": "^5.0.2",
47
47
  "@mantine/rte": "^5.0.2",
48
+ "@testing-library/cypress": "^8.0.3",
48
49
  "@testing-library/jest-dom": "^5.16.4",
49
50
  "@testing-library/react": "^13.3.0",
50
51
  "@testing-library/react-hooks": "^8.0.1",
51
52
  "@testing-library/user-event": "^14.3.0",
53
+ "@types/eventemitter2": "^4.1.0",
52
54
  "@types/file-saver": "2.0.5",
53
55
  "@types/lodash": "^4.14.182",
54
56
  "@types/react": "^18.0.0",
@@ -58,11 +60,13 @@
58
60
  "@vitest/ui": "^0.19.1",
59
61
  "ahooks": "^3.3.11",
60
62
  "axios": "^0.27.2",
63
+ "cypress": "^10.6.0",
61
64
  "echarts": "^5.3.2",
62
65
  "echarts-for-react": "^3.0.2",
63
66
  "echarts-gl": "^2.0.9",
64
67
  "echarts-stat": "1.2.0",
65
68
  "jsdom": "^20.0.0",
69
+ "jsdom-testing-mocks": "^1.5.0",
66
70
  "lodash": "^4.17.21",
67
71
  "numbro": "^2.3.6",
68
72
  "react-grid-layout": "^1.3.4",
@@ -72,7 +76,7 @@
72
76
  "typescript": "^4.6.3",
73
77
  "vite": "^3.0.3",
74
78
  "vite-plugin-dts": "^1.1.1",
75
- "vitest": "^0.19.1"
79
+ "vitest": "^0.21.1"
76
80
  },
77
81
  "peerDependencies": {
78
82
  "@emotion/react": "11.10.0",
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { ITableConf } from './type';
3
- interface IVizTable {
4
- conf: ITableConf;
5
- data: any;
6
- width: number;
7
- height: number;
8
- }
9
- export declare function VizTable({ conf, data, width, height }: IVizTable): JSX.Element;
10
- export {};
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import { IVizPanelProps } from '../../../types/viz-panel';
3
- export declare function VizTablePanel({ conf: { columns, ...restConf }, setConf, data }: IVizPanelProps): JSX.Element;