@devtable/dashboard 6.5.0 → 6.7.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.
Files changed (55) hide show
  1. package/dist/dashboard.es.js +3622 -3460
  2. package/dist/dashboard.umd.js +19 -18
  3. package/dist/definition-editor/query-editor/editor.d.ts +0 -1
  4. package/dist/definition-editor/query-editor/form.d.ts +0 -1
  5. package/dist/main/use-panel-full-screen.d.ts +1394 -36
  6. package/dist/model/queries/index.d.ts +21 -45
  7. package/dist/model/queries/mute-query.d.ts +3 -1
  8. package/dist/model/queries/query.d.ts +6 -10
  9. package/dist/model/variables/index.d.ts +141 -0
  10. package/dist/model/views/view/index.d.ts +6338 -162
  11. package/dist/model/views/view/panels/index.d.ts +2091 -54
  12. package/dist/model/views/view/panels/panel.d.ts +208 -19
  13. package/dist/panel/index.d.ts +1 -1
  14. package/dist/panel/settings/common/text-array-input.d.ts +4 -0
  15. package/dist/panel/settings/variable-config/model.d.ts +338 -0
  16. package/dist/panel/settings/variable-config/styles.d.ts +5 -0
  17. package/dist/panel/settings/variable-config/variable-config-panel.d.ts +11 -0
  18. package/dist/panel/settings/variable-config/variable-field.d.ts +10 -0
  19. package/dist/plugins/instance-migrator/index.d.ts +2 -0
  20. package/dist/plugins/plugin-context.d.ts +1712 -0
  21. package/dist/plugins/plugin-data-migrator/plugin-data-migrator.d.ts +8 -5
  22. package/dist/plugins/plugin-data-migrator/version-based-migrator.d.ts +5 -5
  23. package/dist/plugins/viz-components/boxplot-chart/index.d.ts +5 -0
  24. package/dist/plugins/viz-components/boxplot-chart/reference-lines/index.d.ts +3 -1
  25. package/dist/plugins/viz-components/boxplot-chart/type.d.ts +0 -2
  26. package/dist/plugins/viz-components/cartesian/index.d.ts +5 -0
  27. package/dist/plugins/viz-components/cartesian/option/index.d.ts +2 -1
  28. package/dist/plugins/viz-components/cartesian/option/series.d.ts +2 -1
  29. package/dist/plugins/viz-components/cartesian/panel/reference-areas/index.d.ts +3 -1
  30. package/dist/plugins/viz-components/cartesian/panel/reference-lines/index.d.ts +3 -1
  31. package/dist/plugins/viz-components/cartesian/panel/scatter-size-select/dynamic-size-function-editor.d.ts +8 -0
  32. package/dist/plugins/viz-components/cartesian/panel/scatter-size-select/dynamic.d.ts +9 -0
  33. package/dist/plugins/viz-components/cartesian/panel/scatter-size-select/get-echarts-symbol-size.d.ts +3 -0
  34. package/dist/plugins/viz-components/cartesian/panel/scatter-size-select/index.d.ts +11 -0
  35. package/dist/plugins/viz-components/cartesian/panel/scatter-size-select/static.d.ts +8 -0
  36. package/dist/plugins/viz-components/cartesian/panel/scatter-size-select/types.d.ts +13 -0
  37. package/dist/plugins/viz-components/cartesian/panel/series/fields.scatter.d.ts +3 -1
  38. package/dist/plugins/viz-components/cartesian/panel/stats/index.d.ts +1 -1
  39. package/dist/plugins/viz-components/cartesian/type.d.ts +2 -4
  40. package/dist/plugins/viz-components/stats/type.d.ts +0 -2
  41. package/dist/plugins/viz-components/stats/update/index.d.ts +1 -1
  42. package/dist/plugins/viz-manager/components.d.ts +3 -0
  43. package/dist/plugins/viz-manager/types.d.ts +1 -1
  44. package/dist/types/dashboard.d.ts +6 -3
  45. package/dist/types/plugin/index.d.ts +11 -2
  46. package/dist/utils/template/render/render-jsx.d.ts +1 -0
  47. package/package.json +2 -1
  48. package/dist/model/views/index.d.ts +0 -21911
  49. package/dist/plugins/viz-components/boxplot-chart/variables/index.d.ts +0 -10
  50. package/dist/plugins/viz-components/boxplot-chart/variables/variable.d.ts +0 -11
  51. package/dist/plugins/viz-components/cartesian/panel/stats/variable.d.ts +0 -11
  52. package/dist/plugins/viz-components/cartesian/panel/variables/index.d.ts +0 -10
  53. package/dist/plugins/viz-components/cartesian/panel/variables/variable.d.ts +0 -11
  54. package/dist/plugins/viz-components/stats/panel/variable.d.ts +0 -11
  55. package/dist/plugins/viz-components/stats/panel/variables.d.ts +0 -10
@@ -1,13 +1,16 @@
1
- interface IMigration {
1
+ import { PanelModelInstance } from '~/model/views/view/panels';
2
+ export interface IMigrationEnv {
3
+ panelModel: PanelModelInstance;
4
+ }
5
+ export interface IMigration {
2
6
  version: number;
3
- handler: (data: $TSFixMe) => $TSFixMe;
7
+ handler: (data: $TSFixMe, env: IMigrationEnv) => $TSFixMe;
4
8
  }
5
9
  export declare class PluginDataMigrator {
6
10
  protected migrations: IMigration[];
7
- version(version: number, handler: (data: $TSFixMe) => $TSFixMe): PluginDataMigrator;
11
+ version(version: number, handler: IMigration['handler']): PluginDataMigrator;
8
12
  run(migrationTarget: {
9
13
  from: number;
10
14
  to: number;
11
- }, val: $TSFixMe): any;
15
+ }, val: $TSFixMe, env: IMigrationEnv): $TSFixMe;
12
16
  }
13
- export {};
@@ -1,5 +1,5 @@
1
- import { IConfigMigrator, IConfigMigrationContext } from '~/types/plugin';
2
- import { PluginDataMigrator } from './plugin-data-migrator';
1
+ import { IConfigMigrationContext, IConfigMigrationExecContext, IPanelScopeConfigMigrator } from '~/types/plugin';
2
+ import { IMigration, PluginDataMigrator } from './plugin-data-migrator';
3
3
  /**
4
4
  * Instance version is read from the `instanceData.version` field.
5
5
  * Current version is read from the `VERSION` field.
@@ -8,11 +8,11 @@ import { PluginDataMigrator } from './plugin-data-migrator';
8
8
  * You can implement the `configVersions` method to
9
9
  * specify how migrations are performed.
10
10
  */
11
- export declare abstract class VersionBasedMigrator extends PluginDataMigrator implements IConfigMigrator {
11
+ export declare abstract class VersionBasedMigrator extends PluginDataMigrator implements IPanelScopeConfigMigrator {
12
12
  abstract readonly VERSION: number;
13
13
  abstract configVersions(): void;
14
14
  constructor();
15
- version(version: number, handler: (data: $TSFixMe) => $TSFixMe): PluginDataMigrator;
16
- migrate({ configData }: IConfigMigrationContext): Promise<void>;
15
+ version(version: number, handler: IMigration['handler']): PluginDataMigrator;
16
+ migrate({ configData, panelModel }: IConfigMigrationExecContext): Promise<void>;
17
17
  needMigration({ configData }: IConfigMigrationContext): Promise<boolean>;
18
18
  }
@@ -1,2 +1,7 @@
1
1
  import { VizComponent } from '~/types/plugin';
2
+ import { VersionBasedMigrator } from '~/plugins/plugin-data-migrator';
3
+ export declare class VizBoxplotChartMigrator extends VersionBasedMigrator {
4
+ readonly VERSION = 2;
5
+ configVersions(): void;
6
+ }
2
7
  export declare const BoxplotChartVizComponent: VizComponent;
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { Control, UseFormWatch } from 'react-hook-form';
3
3
  import { IBoxplotChartConf } from '../type';
4
+ import { ITemplateVariable } from '~/utils/template';
4
5
  interface IReferenceLinesField {
5
6
  control: Control<IBoxplotChartConf, $TSFixMe>;
6
7
  watch: UseFormWatch<IBoxplotChartConf>;
8
+ variables: ITemplateVariable[];
7
9
  }
8
- export declare function ReferenceLinesField({ control, watch }: IReferenceLinesField): JSX.Element;
10
+ export declare function ReferenceLinesField({ control, watch, variables }: IReferenceLinesField): JSX.Element;
9
11
  export {};
@@ -1,4 +1,3 @@
1
- import { ITemplateVariable } from '~/utils/template';
2
1
  export interface IBoxplotReferenceLine {
3
2
  name: string;
4
3
  template: string;
@@ -14,7 +13,6 @@ export interface IBoxplotChartConf {
14
13
  data_key: string;
15
14
  };
16
15
  color: string;
17
- variables: ITemplateVariable[];
18
16
  reference_lines: IBoxplotReferenceLine[];
19
17
  }
20
18
  export declare const DEFAULT_CONFIG: IBoxplotChartConf;
@@ -1,2 +1,7 @@
1
1
  import { VizComponent } from '~/types/plugin';
2
+ import { VersionBasedMigrator } from '~/plugins/plugin-data-migrator';
3
+ export declare class VizCartesianMigrator extends VersionBasedMigrator {
4
+ readonly VERSION = 2;
5
+ configVersions(): void;
6
+ }
2
7
  export declare const CartesianVizComponent: VizComponent;
@@ -1,2 +1,3 @@
1
1
  import { ICartesianChartConf } from '../type';
2
- export declare function getOption(conf: ICartesianChartConf, data: $TSFixMe[]): any;
2
+ import { ITemplateVariable } from '~/utils/template';
3
+ export declare function getOption(conf: ICartesianChartConf, data: $TSFixMe[], variables: ITemplateVariable[]): any;
@@ -1,2 +1,3 @@
1
+ import { ITemplateVariable } from '~/utils/template';
1
2
  import { ICartesianChartConf } from '../type';
2
- export declare function getSeries(conf: ICartesianChartConf, xAxisData: $TSFixMe[], data: $TSFixMe[], labelFormatters: Record<string, $TSFixMe>): any[];
3
+ export declare function getSeries(conf: ICartesianChartConf, xAxisData: $TSFixMe[], data: $TSFixMe[], labelFormatters: Record<string, $TSFixMe>, variables: ITemplateVariable[]): any[];
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { Control, UseFormWatch } from 'react-hook-form';
3
3
  import { ICartesianChartConf } from '../../type';
4
+ import { ITemplateVariable } from '~/utils/template';
4
5
  interface IReferenceAreasField {
5
6
  control: Control<ICartesianChartConf, $TSFixMe>;
6
7
  watch: UseFormWatch<ICartesianChartConf>;
8
+ variables: ITemplateVariable[];
7
9
  }
8
- export declare function ReferenceAreasField({ control, watch }: IReferenceAreasField): JSX.Element;
10
+ export declare function ReferenceAreasField({ control, watch, variables }: IReferenceAreasField): JSX.Element;
9
11
  export {};
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { Control, UseFormWatch } from 'react-hook-form';
3
3
  import { ICartesianChartConf } from '../../type';
4
+ import { ITemplateVariable } from '~/utils/template';
4
5
  interface IReferenceLinesField {
5
6
  control: Control<ICartesianChartConf, $TSFixMe>;
6
7
  watch: UseFormWatch<ICartesianChartConf>;
8
+ variables: ITemplateVariable[];
7
9
  }
8
- export declare function ReferenceLinesField({ control, watch }: IReferenceLinesField): JSX.Element;
10
+ export declare function ReferenceLinesField({ control, watch, variables }: IReferenceLinesField): JSX.Element;
9
11
  export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { TScatterSize_Dynamic } from './types';
3
+ interface IDynamicSizeFunctionEditor {
4
+ value: TScatterSize_Dynamic['func_content'];
5
+ onChange: (v: TScatterSize_Dynamic['func_content']) => void;
6
+ }
7
+ export declare const DynamicSizeFunctionEditor: ({ value, onChange }: IDynamicSizeFunctionEditor) => JSX.Element;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { AnyObject } from '~/types';
3
+ import { TScatterSize } from './types';
4
+ export interface IDynamicScatterSizeField {
5
+ value: TScatterSize;
6
+ onChange: (v: TScatterSize) => void;
7
+ data: AnyObject[];
8
+ }
9
+ export declare const DynamicScatterSizeField: ({ value, onChange, data }: IDynamicScatterSizeField) => JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ import { AnyObject } from '~/types';
2
+ import { TScatterSize } from './types';
3
+ export declare function getEchartsSymbolSize({ type, ...rest }: TScatterSize, data: AnyObject[], x_axis_data_key: string): number | ((_value: number, params: $TSFixMe) => any);
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { AnyObject } from '~/types';
3
+ import { TScatterSize } from './types';
4
+ interface IScatterSizeSelect {
5
+ label?: string;
6
+ value: TScatterSize;
7
+ onChange: (v: TScatterSize) => void;
8
+ data: AnyObject[];
9
+ }
10
+ export declare const ScatterSizeSelect: import("react").ForwardRefExoticComponent<IScatterSizeSelect & import("react").RefAttributes<HTMLInputElement>>;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { TScatterSize } from './types';
3
+ interface IStaticScatterSizeField {
4
+ value: TScatterSize;
5
+ onChange: (v: TScatterSize) => void;
6
+ }
7
+ export declare const StaticScatterSizeField: ({ value, onChange }: IStaticScatterSizeField) => JSX.Element | null;
8
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare type TScatterSize_Static = {
2
+ type: 'static';
3
+ size: number;
4
+ };
5
+ export declare type TScatterSize_Dynamic = {
6
+ type: 'dynamic';
7
+ func_content: string;
8
+ };
9
+ export declare type TScatterSize = TScatterSize_Static | TScatterSize_Dynamic;
10
+ export declare const DEFAULT_SCATTER_SIZE: {
11
+ static: TScatterSize_Static;
12
+ dynamic: TScatterSize_Dynamic;
13
+ };
@@ -1,9 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { Control } from 'react-hook-form';
3
+ import { AnyObject } from '~/types';
3
4
  import { ICartesianChartConf } from '../../type';
4
5
  interface IScatterFields {
5
6
  control: Control<ICartesianChartConf, $TSFixMe>;
6
7
  index: number;
8
+ data: AnyObject[];
7
9
  }
8
- export declare function ScatterFields({ control, index }: IScatterFields): JSX.Element;
10
+ export declare function ScatterFields({ control, index, data }: IScatterFields): JSX.Element;
9
11
  export {};
@@ -6,5 +6,5 @@ interface IVariablesField {
6
6
  watch: UseFormWatch<ICartesianChartConf>;
7
7
  data: $TSFixMe[];
8
8
  }
9
- export declare function StatsField({ control, watch, data }: IVariablesField): JSX.Element;
9
+ export declare function StatsField({ control }: IVariablesField): JSX.Element;
10
10
  export {};
@@ -1,11 +1,11 @@
1
1
  import { TNumbroFormat } from '~/panel/settings/common/numbro-format-selector';
2
- import { ITemplateVariable } from '~/utils/template';
2
+ import { TScatterSize } from './panel/scatter-size-select/types';
3
3
  export interface ICartesianChartSeriesItem {
4
4
  type: 'line' | 'bar' | 'scatter';
5
5
  name: string;
6
6
  display_name_on_line: boolean;
7
7
  showSymbol: false;
8
- symbolSize: number;
8
+ symbolSize: TScatterSize;
9
9
  y_axis_data_key: string;
10
10
  yAxisIndex: number;
11
11
  label_position?: string;
@@ -81,9 +81,7 @@ export interface ICartesianChartConf {
81
81
  top: string;
82
82
  bottom: string;
83
83
  };
84
- variables: ITemplateVariable[];
85
84
  };
86
- variables: ITemplateVariable[];
87
85
  reference_lines: ICartesianReferenceLine[];
88
86
  reference_areas: ICartesianReferenceArea[];
89
87
  }
@@ -1,7 +1,5 @@
1
- import { ITemplateVariable } from '~/utils/template';
2
1
  export declare const DEFAULT_CONFIG: IVizStatsConf;
3
2
  export interface IVizStatsConf {
4
3
  align: 'center';
5
4
  template: string;
6
- variables: ITemplateVariable[];
7
5
  }
@@ -1,5 +1,5 @@
1
1
  import { VersionBasedMigrator } from '~/plugins/plugin-data-migrator';
2
2
  export declare class VizStatsMigrator extends VersionBasedMigrator {
3
- readonly VERSION = 1;
3
+ readonly VERSION = 2;
4
4
  configVersions(): void;
5
5
  }
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { IPanelInfoEditor } from '~/types/plugin';
3
3
  import { IPanelInfo, IVizManager } from './types';
4
+ import { ITemplateVariable } from '~/utils/template';
4
5
  export declare type IViewPanelInfo = IPanelInfo & {
5
6
  layout: {
6
7
  w: number;
@@ -11,12 +12,14 @@ export declare type IViewComponentProps<TDebug = Record<string, unknown>> = {
11
12
  panel: IViewPanelInfo;
12
13
  data: $TSFixMe;
13
14
  vizManager: IVizManager;
15
+ variables: ITemplateVariable[];
14
16
  } & TDebug;
15
17
  export declare const VizViewComponent: <T>(props: IViewComponentProps<T>) => JSX.Element;
16
18
  export declare type IConfigComponentProps<TDebug = Record<string, unknown>> = {
17
19
  panel: IPanelInfo;
18
20
  panelInfoEditor: IPanelInfoEditor;
19
21
  vizManager: IVizManager;
22
+ variables: ITemplateVariable[];
20
23
  data: $TSFixMe;
21
24
  } & TDebug;
22
25
  export declare const VizConfigComponent: <T>(props: IConfigComponentProps<T>) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { IDashboardPanel } from '~/types';
2
2
  import { VizComponent, VizInstance } from '~/types/plugin';
3
- export declare type IPanelInfo = Omit<IDashboardPanel, 'layout'>;
3
+ export declare type IPanelInfo = Omit<IDashboardPanel, 'layout' | 'variables' | 'style'>;
4
4
  export interface IVizManager {
5
5
  readonly availableVizList: VizComponent[];
6
6
  resolveComponent(type: string): VizComponent;
@@ -1,6 +1,7 @@
1
1
  import { AnyObject } from '~/types/utils';
2
+ import { ITemplateVariable } from '~/utils/template';
2
3
  import { FilterModelInstance } from '../model';
3
- import { QueryModelInstance } from '../model/queries';
4
+ import { QueryModelSnapshotIn } from '../model/queries';
4
5
  import { SQLSnippetModelInstance } from '../model/sql-snippets';
5
6
  export interface IVizConfig {
6
7
  type: string;
@@ -26,6 +27,7 @@ export interface IDashboardPanel {
26
27
  queryID: string;
27
28
  viz: IVizConfig;
28
29
  style: IDashboardPanelStyle;
30
+ variables: ITemplateVariable[];
29
31
  }
30
32
  export declare enum DashboardMode {
31
33
  Use = "use",
@@ -33,7 +35,7 @@ export declare enum DashboardMode {
33
35
  }
34
36
  export interface IDashboardDefinition {
35
37
  sqlSnippets: SQLSnippetModelInstance[];
36
- queries: QueryModelInstance[];
38
+ queries: QueryModelSnapshotIn[];
37
39
  mock_context: Record<string, $TSFixMe>;
38
40
  }
39
41
  export declare enum EViewComponentType {
@@ -44,7 +46,7 @@ export interface IDashboardView {
44
46
  id: string;
45
47
  name: string;
46
48
  type: EViewComponentType;
47
- config: Record<string, any>;
49
+ config: Record<string, AnyObject>;
48
50
  panels: IDashboardPanel[];
49
51
  }
50
52
  export interface IDashboard {
@@ -53,6 +55,7 @@ export interface IDashboard {
53
55
  definition: IDashboardDefinition;
54
56
  views: IDashboardView[];
55
57
  filters: FilterModelInstance[];
58
+ variables: ITemplateVariable[];
56
59
  version: string;
57
60
  }
58
61
  export {};
@@ -2,6 +2,8 @@ import { EventEmitter2 } from 'eventemitter2';
2
2
  import React from 'react';
3
3
  import { IVizManager } from '~/plugins';
4
4
  import { AnyObject } from '~/types';
5
+ import { ITemplateVariable } from '~/utils/template';
6
+ import { PanelModelInstance } from '~/model/views/view/panels';
5
7
  /**
6
8
  * Basic information of a viz component instance
7
9
  */
@@ -57,6 +59,7 @@ export interface VizContext {
57
59
  pluginData: PluginStorage;
58
60
  instanceData: PluginStorage;
59
61
  colorPalette: ColorPalette;
62
+ variables: ITemplateVariable[];
60
63
  locale: string;
61
64
  msgChannels: IMessageChannels;
62
65
  data: unknown;
@@ -84,17 +87,23 @@ export interface VizConfigProps {
84
87
  export interface IConfigMigrationContext {
85
88
  configData: PluginStorage;
86
89
  }
90
+ export interface IConfigMigrationExecContext extends IConfigMigrationContext {
91
+ panelModel: PanelModelInstance;
92
+ }
87
93
  export interface VizComponent {
88
94
  name: string;
89
95
  displayName?: string;
90
96
  viewRender: React.ComponentType<VizViewProps>;
91
97
  configRender: React.ComponentType<VizConfigProps>;
92
- migrator: IConfigMigrator;
98
+ migrator: IPanelScopeConfigMigrator;
93
99
  createConfig: () => AnyObject;
94
100
  triggers?: ITriggerSchema[];
95
101
  }
96
- export interface IConfigMigrator {
102
+ export interface IPanelScopeConfigMigrator {
97
103
  needMigration(ctx: IConfigMigrationContext): Promise<boolean>;
104
+ migrate(ctx: IConfigMigrationExecContext): Promise<void>;
105
+ }
106
+ export interface IConfigMigrator extends IPanelScopeConfigMigrator {
98
107
  migrate(ctx: IConfigMigrationContext): Promise<void>;
99
108
  }
100
109
  export interface IPluginManifest {
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ITemplateVariable } from '../types';
3
+ export declare function variable2Jsx(variable: ITemplateVariable, data: Record<string, number>[]): JSX.Element;
3
4
  export declare function templateToJSX(template: string, variables: ITemplateVariable[], data: Record<string, number>[]): (JSX.Element | React.ReactNode[])[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "6.5.0",
3
+ "version": "6.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -34,6 +34,7 @@
34
34
  "@types/chroma-js": "^2.1.4",
35
35
  "file-saver": "2.0.5",
36
36
  "popmotion": "^11.0.3",
37
+ "@monaco-editor/react": "4.4.6",
37
38
  "stickybits": "3.7.11"
38
39
  },
39
40
  "devDependencies": {