@devtable/dashboard 2.5.0 → 3.1.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 (157) hide show
  1. package/README.md +25 -1
  2. package/dist/api-caller/index.d.ts +26 -0
  3. package/dist/api-caller/request.d.ts +5 -0
  4. package/dist/api-caller/types.d.ts +11 -0
  5. package/dist/contexts/dashboard-action-context.d.ts +9 -0
  6. package/dist/contexts/index.d.ts +3 -0
  7. package/dist/contexts/layout-state-context.d.ts +11 -0
  8. package/dist/contexts/model-context.d.ts +24165 -0
  9. package/dist/contexts/panel-context.d.ts +16 -0
  10. package/dist/dashboard.es.js +9526 -9191
  11. package/dist/dashboard.umd.js +22 -22
  12. package/dist/definition-editor/data-editor-modal.d.ts +7 -0
  13. package/dist/definition-editor/global-variables-guide.d.ts +8 -0
  14. package/dist/definition-editor/index.d.ts +1 -0
  15. package/dist/definition-editor/query-editor/data-preview.d.ts +4 -0
  16. package/dist/definition-editor/query-editor/editor.d.ts +7 -0
  17. package/dist/definition-editor/query-editor/form.d.ts +7 -0
  18. package/dist/definition-editor/query-editor/index.d.ts +5 -0
  19. package/dist/definition-editor/query-editor/preview-sql.d.ts +6 -0
  20. package/dist/definition-editor/query-editor/select-or-add-query.d.ts +7 -0
  21. package/dist/definition-editor/sql-snippet-editor/editor.d.ts +5 -0
  22. package/dist/definition-editor/sql-snippet-editor/index.d.ts +5 -0
  23. package/dist/definition-editor/sql-snippet-editor/preview-snippet.d.ts +6 -0
  24. package/dist/filter/filter-checkbox/editor.d.ts +8 -0
  25. package/dist/filter/filter-checkbox/render.d.ts +10 -0
  26. package/dist/filter/filter-date-range/editor.d.ts +7 -0
  27. package/dist/filter/filter-date-range/render.d.ts +10 -0
  28. package/dist/filter/filter-multi-select/editor.d.ts +7 -0
  29. package/dist/filter/filter-multi-select/render.d.ts +10 -0
  30. package/dist/filter/filter-query-field/index.d.ts +8 -0
  31. package/dist/filter/filter-query-field/select-data-source.d.ts +8 -0
  32. package/dist/filter/filter-query-field/test-query.d.ts +7 -0
  33. package/dist/filter/filter-select/editor.d.ts +7 -0
  34. package/dist/filter/filter-select/render.d.ts +10 -0
  35. package/dist/filter/filter-settings/filter-setting.d.ts +8 -0
  36. package/dist/filter/filter-settings/filter-settings.d.ts +5 -0
  37. package/dist/filter/filter-settings/index.d.ts +7 -0
  38. package/dist/filter/filter-settings/preview-filter.d.ts +7 -0
  39. package/dist/filter/filter-text-input/editor.d.ts +7 -0
  40. package/dist/filter/filter-text-input/render.d.ts +10 -0
  41. package/dist/filter/filter.d.ts +9 -0
  42. package/dist/filter/index.d.ts +5 -0
  43. package/dist/index.d.ts +6 -0
  44. package/dist/layout/index.d.ts +12 -0
  45. package/dist/layout/read-only.d.ts +9 -0
  46. package/dist/main/actions.d.ts +12 -0
  47. package/dist/main/full-screen-panel.d.ts +6 -0
  48. package/dist/main/index.d.ts +2 -0
  49. package/dist/main/main.d.ts +12 -0
  50. package/dist/main/read-only.d.ts +11 -0
  51. package/dist/main/toggle-mode.d.ts +8 -0
  52. package/dist/main/use-panel-full-screen.d.ts +7 -0
  53. package/dist/main/use-sticky-area-style.d.ts +1 -0
  54. package/dist/main/view-schema-modal.d.ts +8 -0
  55. package/dist/model/context.d.ts +11 -0
  56. package/dist/model/dashboard.d.ts +15998 -0
  57. package/dist/model/filters/filter/checkbox.d.ts +16 -0
  58. package/dist/model/filters/filter/common.d.ts +14 -0
  59. package/dist/model/filters/filter/date-range.d.ts +28 -0
  60. package/dist/model/filters/filter/index.d.ts +172 -0
  61. package/dist/model/filters/filter/multi-select.d.ts +81 -0
  62. package/dist/model/filters/filter/select.d.ts +95 -0
  63. package/dist/model/filters/filter/text-input.d.ts +22 -0
  64. package/dist/model/filters/index.d.ts +3542 -0
  65. package/dist/model/index.d.ts +5 -0
  66. package/dist/model/queries/index.d.ts +116 -0
  67. package/dist/model/queries/mute-query.d.ts +17 -0
  68. package/dist/model/queries/query.d.ts +31 -0
  69. package/dist/model/queries/types.d.ts +5 -0
  70. package/dist/model/sql-snippets/index.d.ts +26 -0
  71. package/dist/model/sql-snippets/sql-snippet.d.ts +9 -0
  72. package/dist/panel/error-boundary.d.ts +13 -0
  73. package/dist/panel/index.d.ts +7 -0
  74. package/dist/panel/panel-description.d.ts +5 -0
  75. package/dist/panel/plugin-adaptor.d.ts +7 -0
  76. package/dist/panel/settings/common/aggregation-selector.d.ts +9 -0
  77. package/dist/panel/settings/common/color-array-input.d.ts +8 -0
  78. package/dist/panel/settings/common/data-field-selector.d.ts +12 -0
  79. package/dist/panel/settings/common/mantine-color.d.ts +7 -0
  80. package/dist/panel/settings/common/mantine-font-weight.d.ts +8 -0
  81. package/dist/panel/settings/common/numbro-format-selector.d.ts +13 -0
  82. package/dist/panel/settings/common/text-array-input.d.ts +8 -0
  83. package/dist/panel/settings/index.d.ts +7 -0
  84. package/dist/panel/settings/panel-config/description.d.ts +2 -0
  85. package/dist/panel/settings/panel-config/index.d.ts +5 -0
  86. package/dist/panel/settings/panel-config/preview-panel.d.ts +2 -0
  87. package/dist/panel/settings/panel-config/title.d.ts +2 -0
  88. package/dist/panel/settings/pick-query/index.d.ts +5 -0
  89. package/dist/panel/settings/viz-config/index.d.ts +5 -0
  90. package/dist/panel/settings/viz-config/preview-viz.d.ts +5 -0
  91. package/dist/panel/settings/viz-config/viz-conf.d.ts +2 -0
  92. package/dist/panel/title-bar.d.ts +5 -0
  93. package/dist/panel/viz/bar-3d/index.d.ts +9 -0
  94. package/dist/panel/viz/bar-3d/panel.d.ts +3 -0
  95. package/dist/panel/viz/cartesian/index.d.ts +10 -0
  96. package/dist/panel/viz/cartesian/option/regression.d.ts +20 -0
  97. package/dist/panel/viz/cartesian/panel/index.d.ts +3 -0
  98. package/dist/panel/viz/cartesian/panel/regressions/index.d.ts +11 -0
  99. package/dist/panel/viz/cartesian/panel/regressions/regression-item.d.ts +16 -0
  100. package/dist/panel/viz/cartesian/panel/series/fields.bar.d.ts +9 -0
  101. package/dist/panel/viz/cartesian/panel/series/fields.line.d.ts +9 -0
  102. package/dist/panel/viz/cartesian/panel/series/fields.scatter.d.ts +9 -0
  103. package/dist/panel/viz/cartesian/panel/series/index.d.ts +11 -0
  104. package/dist/panel/viz/cartesian/panel/series/series-item.d.ts +16 -0
  105. package/dist/panel/viz/cartesian/panel/stats/index.d.ts +10 -0
  106. package/dist/panel/viz/cartesian/panel/stats/variable.d.ts +11 -0
  107. package/dist/panel/viz/cartesian/panel/y-axes.d.ts +9 -0
  108. package/dist/panel/viz/cartesian/type.d.ts +58 -0
  109. package/dist/panel/viz/index.d.ts +9 -0
  110. package/dist/panel/viz/pie/index.d.ts +9 -0
  111. package/dist/panel/viz/pie/panel.d.ts +3 -0
  112. package/dist/panel/viz/rich-text/index.d.ts +10 -0
  113. package/dist/panel/viz/rich-text/panel.d.ts +3 -0
  114. package/dist/panel/viz/rich-text/type.d.ts +8 -0
  115. package/dist/panel/viz/stats/index.d.ts +10 -0
  116. package/dist/panel/viz/stats/panel/index.d.ts +10 -0
  117. package/dist/panel/viz/stats/panel/variable.d.ts +11 -0
  118. package/dist/panel/viz/stats/panel/variables.d.ts +10 -0
  119. package/dist/panel/viz/stats/types.d.ts +6 -0
  120. package/dist/panel/viz/stats/update/index.d.ts +15 -0
  121. package/dist/panel/viz/sunburst/index.d.ts +9 -0
  122. package/dist/panel/viz/sunburst/panel.d.ts +3 -0
  123. package/dist/plugins/hooks/index.d.ts +2 -0
  124. package/dist/plugins/hooks/use-channel-event.d.ts +2 -0
  125. package/dist/plugins/hooks/use-storage-data.d.ts +6 -0
  126. package/dist/plugins/index.d.ts +4 -0
  127. package/dist/plugins/json-plugin-storage.d.ts +12 -0
  128. package/dist/plugins/message-channels.d.ts +7 -0
  129. package/dist/plugins/plugin-context.d.ts +12 -0
  130. package/dist/plugins/plugin-data-migrator/index.d.ts +1 -0
  131. package/dist/plugins/plugin-data-migrator/plugin-data-migrator.d.ts +13 -0
  132. package/dist/plugins/plugin-manager.d.ts +18 -0
  133. package/dist/plugins/viz-components/table/index.d.ts +2 -0
  134. package/dist/plugins/viz-components/table/type.d.ts +22 -0
  135. package/dist/plugins/viz-components/table/value-type-selector.d.ts +10 -0
  136. package/dist/plugins/viz-components/table/value.d.ts +8 -0
  137. package/dist/plugins/viz-components/table/viz-table-panel.d.ts +3 -0
  138. package/dist/plugins/viz-components/table/viz-table.d.ts +3 -0
  139. package/dist/plugins/viz-manager/components.d.ts +22 -0
  140. package/dist/plugins/viz-manager/impl.d.ts +10 -0
  141. package/dist/plugins/viz-manager/index.d.ts +4 -0
  142. package/dist/plugins/viz-manager/types.d.ts +12 -0
  143. package/dist/style.css +1 -1
  144. package/dist/types/dashboard.d.ts +41 -0
  145. package/dist/types/filter.d.ts +7 -0
  146. package/dist/types/index.d.ts +3 -0
  147. package/dist/types/plugin/index.d.ts +101 -0
  148. package/dist/types/viz-panel.d.ts +6 -0
  149. package/dist/utils/aggregation.d.ts +2 -0
  150. package/dist/utils/color-mapping.d.ts +9 -0
  151. package/dist/utils/download.d.ts +6 -0
  152. package/dist/utils/sql.d.ts +9 -0
  153. package/dist/utils/template/editor.d.ts +16 -0
  154. package/dist/utils/template/render.d.ts +3 -0
  155. package/dist/utils/template/types.d.ts +21 -0
  156. package/dist/vite-env.d.ts +1 -0
  157. package/package.json +9 -4
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { IVizConfig } from '../../types';
3
+ interface IViz {
4
+ viz: IVizConfig;
5
+ data: any;
6
+ loading: boolean;
7
+ }
8
+ export declare const Viz: React.FunctionComponent<IViz>;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ interface IVizPie {
3
+ conf: any;
4
+ data: any[];
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare function VizPie({ conf, data, width, height }: IVizPie): JSX.Element;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { IVizPanelProps } from '../../../types/viz-panel';
3
+ export declare function VizPiePanel({ conf: { label_field, value_field }, setConf, data }: IVizPanelProps): JSX.Element;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { IRichTextConf } from './type';
3
+ interface IRichText {
4
+ conf: IRichTextConf;
5
+ data: any[];
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export declare function VizRichText({ conf, width, height }: IRichText): JSX.Element | null;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { IVizRichTextPanel } from './type';
3
+ export declare function VizRichTextPanel({ conf, setConf }: IVizRichTextPanel): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { IVizPanelProps } from '../../../types';
2
+ export interface IRichTextConf {
3
+ content: '';
4
+ }
5
+ export interface IVizRichTextPanel extends Omit<IVizPanelProps, 'conf' | 'setConf'> {
6
+ conf: IRichTextConf;
7
+ setConf: (values: IRichTextConf) => void;
8
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { IVizStatsConf } from './types';
3
+ interface IVizStats {
4
+ conf: IVizStatsConf;
5
+ data: any;
6
+ width: number;
7
+ height: number;
8
+ }
9
+ export declare function VizStats({ conf: { template, variables, align }, data }: IVizStats): JSX.Element;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { IVizPanelProps } from '../../../../types/viz-panel';
3
+ import { IVizStatsConf } from '../types';
4
+ import { ILegacyStatsConf } from '../update';
5
+ interface IVizStatsPanel extends Omit<IVizPanelProps, 'conf' | 'setConf'> {
6
+ conf: IVizStatsConf | ILegacyStatsConf;
7
+ setConf: (conf: IVizStatsConf) => void;
8
+ }
9
+ export declare function VizStatsPanel({ conf, setConf, data }: IVizStatsPanel): JSX.Element;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { Control, UseFieldArrayRemove } from 'react-hook-form';
3
+ import { IVizStatsConf } from '../types';
4
+ interface VariableField {
5
+ control: Control<IVizStatsConf, any>;
6
+ index: number;
7
+ remove: UseFieldArrayRemove;
8
+ data: any[];
9
+ }
10
+ export declare function VariableField({ control, index, remove, data }: VariableField): JSX.Element;
11
+ export {};
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { Control, UseFormWatch } from 'react-hook-form';
3
+ import { IVizStatsConf } from '../types';
4
+ interface IVariablesField {
5
+ control: Control<IVizStatsConf, any>;
6
+ watch: UseFormWatch<IVizStatsConf>;
7
+ data: any[];
8
+ }
9
+ export declare function VariablesField({ control, watch, data }: IVariablesField): JSX.Element;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ import { ITemplateVariable } from '../../../utils/template/types';
2
+ export interface IVizStatsConf {
3
+ align: 'center';
4
+ template: string;
5
+ variables: ITemplateVariable[];
6
+ }
@@ -0,0 +1,15 @@
1
+ import { TNumbroFormat } from '../../../settings/common/numbro-format-selector';
2
+ import { IVizStatsConf } from '../types';
3
+ export interface ILegacyStatsConf {
4
+ align: 'center';
5
+ size: string;
6
+ weight: string;
7
+ color: any;
8
+ content: {
9
+ prefix: string;
10
+ data_field: string;
11
+ formatter: TNumbroFormat;
12
+ postfix: string;
13
+ };
14
+ }
15
+ export declare function updateSchema(legacyConf: IVizStatsConf | ILegacyStatsConf): IVizStatsConf;
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ interface ISunbrust {
3
+ conf: any;
4
+ data: any[];
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare function Sunbrust({ conf, data, width, height }: ISunbrust): JSX.Element;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { IVizPanelProps } from '../../../types/viz-panel';
3
+ export declare function SunburstPanel({ conf: { label_field, value_field }, setConf, data }: IVizPanelProps): JSX.Element;
@@ -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';
@@ -0,0 +1,12 @@
1
+ import { PluginStorage } from '../types/plugin';
2
+ export declare class JsonPluginStorage implements PluginStorage {
3
+ protected rootRef: {
4
+ current: Record<string, any>;
5
+ };
6
+ constructor(initValue: Record<string, any>);
7
+ deleteItem(key: string): Promise<void>;
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;
12
+ }
@@ -0,0 +1,7 @@
1
+ import EventEmitter2 from 'eventemitter2';
2
+ import { IMessageChannels } from '../types/plugin';
3
+ export declare class MessageChannels implements IMessageChannels {
4
+ private channels;
5
+ globalChannel: EventEmitter2;
6
+ getChannel(name: string): EventEmitter2;
7
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { IPluginManager } from '../types/plugin';
3
+ import { PluginManager } from './plugin-manager';
4
+ import { VizManager } from './viz-manager';
5
+ interface IPluginContextProps {
6
+ pluginManager: IPluginManager;
7
+ vizManager: VizManager;
8
+ }
9
+ export declare const pluginManager: PluginManager;
10
+ export declare const createPluginContext: () => IPluginContextProps;
11
+ export declare const PluginContext: import("react").Context<IPluginContextProps>;
12
+ export {};
@@ -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,18 @@
1
+ import { IDashboardPlugin, IPluginManager, VizComponent } from '../types/plugin';
2
+ export declare class PluginManager implements IPluginManager {
3
+ /**
4
+ * Id to plugin map
5
+ * @private
6
+ */
7
+ private plugins;
8
+ /**
9
+ * Name to component map
10
+ */
11
+ private vizComponents;
12
+ constructor();
13
+ factory: {
14
+ viz: (name: string) => VizComponent;
15
+ };
16
+ install(plugin: IDashboardPlugin): void;
17
+ get installedPlugins(): IDashboardPlugin[];
18
+ }
@@ -0,0 +1,2 @@
1
+ import { VizComponent } from '../../../types/plugin';
2
+ export declare const TableVizComponent: VizComponent;
@@ -0,0 +1,22 @@
1
+ export declare enum ValueType {
2
+ string = "string",
3
+ number = "number",
4
+ eloc = "eloc",
5
+ percentage = "percentage"
6
+ }
7
+ export interface IColumnConf {
8
+ label: string;
9
+ value_field: string;
10
+ value_type: ValueType;
11
+ }
12
+ export interface ITableConf {
13
+ id_field: string;
14
+ use_raw_columns: boolean;
15
+ columns: IColumnConf[];
16
+ fontSize: string;
17
+ horizontalSpacing: string;
18
+ verticalSpacing: string;
19
+ striped: boolean;
20
+ highlightOnHover: boolean;
21
+ }
22
+ export declare const DEFAULT_CONFIG: ITableConf;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { Sx } from '@mantine/core';
3
+ interface IValueTypeSelector {
4
+ label: string;
5
+ value: string;
6
+ onChange: (value: string) => void;
7
+ sx?: Sx;
8
+ }
9
+ export declare function ValueTypeSelector({ label, value, onChange, sx }: IValueTypeSelector): JSX.Element;
10
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { ValueType } from './type';
3
+ interface ICellValue {
4
+ value: any;
5
+ type: ValueType;
6
+ }
7
+ export declare function CellValue({ value, type }: ICellValue): JSX.Element;
8
+ export {};
@@ -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;
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { IPanelInfoEditor } from '../../types/plugin';
3
+ import { IPanelInfo, IVizManager } from './types';
4
+ export declare type IViewPanelInfo = IPanelInfo & {
5
+ layout: {
6
+ w: number;
7
+ h: number;
8
+ };
9
+ };
10
+ export declare type IViewComponentProps<TDebug = {}> = {
11
+ panel: IViewPanelInfo;
12
+ data: any;
13
+ vizManager: IVizManager;
14
+ } & TDebug;
15
+ export declare const VizViewComponent: <T>(props: IViewComponentProps<T>) => JSX.Element;
16
+ export declare type IConfigComponentProps<TDebug = {}> = {
17
+ panel: IPanelInfo;
18
+ panelInfoEditor: IPanelInfoEditor;
19
+ vizManager: IVizManager;
20
+ data: any;
21
+ } & TDebug;
22
+ export declare const VizConfigComponent: <T>(props: IConfigComponentProps<T>) => JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { IPluginManager, VizComponent } from '../../types/plugin';
2
+ import { IPanelInfo, IVizManager, VizInstanceInfo } from './types';
3
+ export declare class VizManager implements IVizManager {
4
+ private pluginManager;
5
+ private instances;
6
+ constructor(pluginManager: IPluginManager);
7
+ get availableVizList(): VizComponent[];
8
+ resolveComponent(name: string): VizComponent;
9
+ getOrCreateInstance(panel: IPanelInfo): VizInstanceInfo;
10
+ }
@@ -0,0 +1,4 @@
1
+ export { VizManager } from './impl';
2
+ export type { IVizManager, IPanelInfo } from './types';
3
+ export { VizConfigComponent, VizViewComponent } from './components';
4
+ export type { IViewPanelInfo, IViewComponentProps } from './components';
@@ -0,0 +1,12 @@
1
+ import { IDashboardPanel } from '../../types';
2
+ import { IMessageChannels, PluginStorage, VizComponent, VizInstance } from '../../types/plugin';
3
+ export declare type IPanelInfo = Omit<IDashboardPanel, 'layout'>;
4
+ export interface IVizManager {
5
+ readonly availableVizList: VizComponent[];
6
+ resolveComponent(type: string): VizComponent;
7
+ getOrCreateInstance(panel: IPanelInfo): VizInstanceInfo;
8
+ }
9
+ export interface VizInstanceInfo extends VizInstance {
10
+ messageChannels: IMessageChannels;
11
+ instanceData: PluginStorage;
12
+ }
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .viz-root{width:100%;overflow:scroll;padding-top:5px;height:calc(100% - 25px);background-color:#fff}.panel-title-wrapper{text-align:center;transition:background-color .3s ease}.panel-title-wrapper:hover{cursor:pointer;background-color:#6464640d}.panel-root{padding:5px;height:100%;width:100%;max-width:100%;background:transparent;border-radius:5px;box-shadow:0 0 10px #0003}.mantine-Tabs-root{width:100%;height:calc(100% - 25px);overflow:hidden;display:flex;justify-content:flex-start;flex-direction:column;flex-wrap:nowrap}.mantine-Tabs-tabsListWrapper{flex:0}.mantine-Tabs-body{flex:1;overflow:scroll}.dashboard-layout{margin-left:-10px;margin-right:-10px}.react-grid-item{padding:0}.remove-panel{position:absolute;right:2px;top:0;cursor:pointer}.code-textarea textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}
1
+ .viz-root{width:100%;overflow:scroll;padding-top:5px;height:calc(100% - 25px);background-color:#fff}.panel-title-wrapper{text-align:center;transition:background-color .3s ease}.panel-title-wrapper:hover{cursor:pointer;background-color:#6464640d}.panel-root{padding:5px;height:100%;width:100%;max-width:100%;background:transparent;border-radius:5px;box-shadow:0 0 10px #0003}.panel-settings-tabs{width:100%;height:100%}.panel-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.panel-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.panel-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.dashboard-layout{margin-left:-10px;margin-right:-10px}.react-grid-item{padding:0}.remove-panel{position:absolute;right:2px;top:0;cursor:pointer}.code-textarea textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.filter-settings-tabs{width:100%;height:100%}.filter-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.filter-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.filter-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.dashboard-root{overflow:scroll;padding:0 10px 10px}.dashboard-sticky-area{z-index:100;background:white;margin:0 -10px;padding:0 10px 10px}
@@ -0,0 +1,41 @@
1
+ import { FilterModelInstance } from '../model';
2
+ import { QueryModelInstance } from '../model/queries';
3
+ import { SQLSnippetModelInstance } from '../model/sql-snippets';
4
+ export interface IVizConfig {
5
+ type: string;
6
+ conf: Record<string, any>;
7
+ }
8
+ export interface IDashboardPanel {
9
+ id: string;
10
+ title: string;
11
+ description: string;
12
+ layout: {
13
+ x: number;
14
+ y: number;
15
+ w: number;
16
+ h: number;
17
+ moved?: boolean;
18
+ static?: boolean;
19
+ };
20
+ queryID: string;
21
+ viz: IVizConfig;
22
+ }
23
+ export declare enum DashboardMode {
24
+ Use = "use",
25
+ Layout = "layout",
26
+ Edit = "edit"
27
+ }
28
+ export interface IDashboardDefinition {
29
+ sqlSnippets: SQLSnippetModelInstance[];
30
+ queries: QueryModelInstance[];
31
+ }
32
+ export interface IDashboard {
33
+ id: string;
34
+ name: string;
35
+ definition: IDashboardDefinition;
36
+ panels: IDashboardPanel[];
37
+ filters: FilterModelInstance[];
38
+ }
39
+ export interface IDashboardConfig {
40
+ apiBaseURL: string;
41
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum DashboardFilterType {
2
+ Select = "select",
3
+ MultiSelect = "multi-select",
4
+ TextInput = "text-input",
5
+ Checkbox = "checkbox",
6
+ DateRange = "date-range"
7
+ }
@@ -0,0 +1,3 @@
1
+ export * from './dashboard';
2
+ export * from './filter';
3
+ export * from './viz-panel';
@@ -0,0 +1,101 @@
1
+ import EventEmitter2 from 'eventemitter2';
2
+ import React from 'react';
3
+ /**
4
+ * Basic information of a viz component instance
5
+ */
6
+ export interface VizInstance {
7
+ id: string;
8
+ name: string;
9
+ type: string;
10
+ }
11
+ /**
12
+ * Props to render the view of viz component
13
+ */
14
+ export interface VizViewProps {
15
+ instance: VizInstance;
16
+ context: VizViewContext;
17
+ }
18
+ export interface PluginStorage {
19
+ getItem<T>(key: string | null): Promise<T>;
20
+ setItem<T>(key: string | null, item: T): Promise<T>;
21
+ deleteItem(key: string): Promise<void>;
22
+ watchItem<T>(key: string | null, callback: (value: T, previous?: T) => void): () => void;
23
+ }
24
+ export interface ColorPaletteItem {
25
+ name: string;
26
+ type: string;
27
+ category: string;
28
+ }
29
+ export interface SingleColor extends ColorPaletteItem {
30
+ type: 'single';
31
+ value: string;
32
+ }
33
+ export interface ColorInterpolation extends ColorPaletteItem {
34
+ type: 'interpolation';
35
+ interpolation: (value: number) => string;
36
+ }
37
+ export interface ColorPalette {
38
+ getColor(colorInfo: ColorPaletteItem): (value: unknown) => string;
39
+ }
40
+ export interface IMessageChannels {
41
+ globalChannel: EventEmitter2;
42
+ getChannel(name: string): EventEmitter2;
43
+ }
44
+ export interface VizContext {
45
+ pluginData: PluginStorage;
46
+ instanceData: PluginStorage;
47
+ colorPalette: ColorPalette;
48
+ locale: string;
49
+ msgChannels: IMessageChannels;
50
+ data: unknown;
51
+ }
52
+ declare type Setter<T> = (val: string) => void;
53
+ export interface IPanelInfoEditor {
54
+ setTitle: Setter<string>;
55
+ setDescription: Setter<string>;
56
+ setQueryID: Setter<string>;
57
+ }
58
+ export interface VizConfigContext extends VizContext {
59
+ panelInfoEditor: IPanelInfoEditor;
60
+ }
61
+ export interface VizViewContext extends VizContext {
62
+ viewport: {
63
+ width: number;
64
+ height: number;
65
+ };
66
+ }
67
+ export interface VizConfigProps {
68
+ instance: VizInstance;
69
+ context: VizConfigContext;
70
+ }
71
+ export interface VizComponentMigrationContext {
72
+ instanceData: PluginStorage;
73
+ }
74
+ export interface VizComponent {
75
+ name: string;
76
+ displayName?: string;
77
+ viewRender: React.ComponentType<VizViewProps>;
78
+ configRender: React.ComponentType<VizConfigProps>;
79
+ migrator: IVizComponentMigrator;
80
+ }
81
+ export interface IVizComponentMigrator {
82
+ needMigration(ctx: VizComponentMigrationContext): Promise<boolean>;
83
+ migrate(ctx: VizComponentMigrationContext): Promise<void>;
84
+ }
85
+ export interface IPluginManifest {
86
+ viz: VizComponent[];
87
+ color: ColorPaletteItem[];
88
+ }
89
+ export interface IDashboardPlugin {
90
+ id: string;
91
+ version: string;
92
+ manifest: IPluginManifest;
93
+ }
94
+ export interface IPluginManager {
95
+ install(plugin: IDashboardPlugin): void;
96
+ installedPlugins: IDashboardPlugin[];
97
+ factory: {
98
+ viz: (name: string) => VizComponent;
99
+ };
100
+ }
101
+ export {};
@@ -0,0 +1,6 @@
1
+ import { IVizConfig } from './dashboard';
2
+ export interface IVizPanelProps {
3
+ conf: IVizConfig['conf'];
4
+ setConf: (conf: IVizConfig['conf']) => void;
5
+ data: any[];
6
+ }
@@ -0,0 +1,2 @@
1
+ export declare type AggregationType = 'none' | 'sum' | 'mean' | 'median' | 'max' | 'min';
2
+ export declare function aggregateValue(data: Record<string, number>[], data_field: string, aggregation: AggregationType): number;
@@ -0,0 +1,9 @@
1
+ export interface InterpolateColorOption {
2
+ valueRange: number[];
3
+ colorRange: string[];
4
+ }
5
+ export declare class InterpolateColor {
6
+ mapper: (v: number) => string;
7
+ constructor({ valueRange, colorRange }: InterpolateColorOption);
8
+ getColor(value: number): string;
9
+ }
@@ -0,0 +1,6 @@
1
+ export declare function downloadCSV(id: string, csv: string): void;
2
+ export declare function downloadDataListAsZip(idDataList: Array<{
3
+ id: string;
4
+ data: any[];
5
+ }>): void;
6
+ export declare function makeCSV(data: any | any[]): string;
@@ -0,0 +1,9 @@
1
+ import { FilterValuesType } from '../model';
2
+ import { ContextInfoType } from '../model/context';
3
+ import { SQLSnippetModelInstance } from '../model/sql-snippets';
4
+ export declare function explainSQLSnippet(snippet: string, context: ContextInfoType): any;
5
+ export declare function formatSQL(sql: string, params: Record<string, any>): any;
6
+ export declare function getSQLParams(context: ContextInfoType, sqlSnippets: SQLSnippetModelInstance[], filterValues: FilterValuesType): Record<string, any> & ContextInfoType & {
7
+ filters: FilterValuesType;
8
+ };
9
+ export declare function explainSQL(sql: string, context: ContextInfoType, sqlSnippets: SQLSnippetModelInstance[], filterValues: FilterValuesType): any;
@@ -0,0 +1,16 @@
1
+ import { TextInputProps } from '@mantine/core';
2
+ import React, { ChangeEventHandler } from 'react';
3
+ import { ITemplateVariable } from './types';
4
+ export declare function getANewVariable(): ITemplateVariable;
5
+ interface ITemplateInput extends Omit<TextInputProps, 'value' | 'onChange'> {
6
+ value: string;
7
+ onChange: ChangeEventHandler<HTMLInputElement>;
8
+ }
9
+ export declare const TemplateInput: React.ForwardRefExoticComponent<ITemplateInput & React.RefAttributes<unknown>>;
10
+ interface ITemplateVariableField {
11
+ value: ITemplateVariable;
12
+ onChange: (v: ITemplateVariable) => void;
13
+ data: any[];
14
+ }
15
+ export declare const TemplateVariableField: React.ForwardRefExoticComponent<ITemplateVariableField & React.RefAttributes<unknown>>;
16
+ export {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { ITemplateVariable } from './types';
3
+ export declare function templateToJSX(template: string, variables: ITemplateVariable[], data: Record<string, number>[]): (JSX.Element | import("react").ReactNode[])[];
@@ -0,0 +1,21 @@
1
+ import { TNumbroFormat } from '../../panel/settings/common/numbro-format-selector';
2
+ import { AggregationType } from '../aggregation';
3
+ export declare type ColorConfType = {
4
+ type: 'static';
5
+ staticColor: string;
6
+ } | {
7
+ type: 'continuous';
8
+ valueRange: number[];
9
+ colorRange: string[];
10
+ } | {
11
+ type: 'piecewise';
12
+ };
13
+ export interface ITemplateVariable {
14
+ name: string;
15
+ data_field: string;
16
+ aggregation: AggregationType;
17
+ formatter: TNumbroFormat;
18
+ color: ColorConfType;
19
+ size: string;
20
+ weight: string;
21
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />