@databrainhq/plugin 0.9.48 → 0.10.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.
package/README.md CHANGED
@@ -12,12 +12,68 @@ npm install @databrainhq/plugin
12
12
 
13
13
  ## Usage
14
14
 
15
+ Integrating Dashboard
16
+
15
17
  ```tsx
16
18
  import { Dashboard } from '@databrainhq/plugin';
17
19
  import '@databrainhq/plugin/dist/style.css';
18
20
 
19
21
  const Example = () => {
20
- return <Dashboard token={/* Your Guest Token */} />;
22
+ return (
23
+ <Dashboard
24
+ token="Your Guest Token"
25
+ dashboardId="Your Dashboard Id"
26
+ options={{
27
+ disableMetricCreation: false,
28
+ disableMetricUpdation: false,
29
+ disableMetricDeletion: false,
30
+ disableLayoutCustomization: false,
31
+ chartColors: [
32
+ 'violet',
33
+ 'indigo',
34
+ 'blue',
35
+ 'green',
36
+ 'yellow',
37
+ 'orange',
38
+ 'red',
39
+ 'pink',
40
+ 'gray',
41
+ ],
42
+ }}
43
+ theme={YOUR_THEME}
44
+ />
45
+ );
46
+ };
47
+ ```
48
+
49
+ Integrating Metric
50
+
51
+ ```tsx
52
+ import { Metric } from '@databrainhq/plugin';
53
+ import '@databrainhq/plugin/dist/style.css';
54
+
55
+ const Example = () => {
56
+ return (
57
+ <Metric
58
+ token="Your Guest Token"
59
+ metricId="Your Metric Id"
60
+ width="500px"
61
+ height="300px"
62
+ chartRendererType="canvas"
63
+ chartColors={[
64
+ 'violet',
65
+ 'indigo',
66
+ 'blue',
67
+ 'green',
68
+ 'yellow',
69
+ 'orange',
70
+ 'red',
71
+ 'pink',
72
+ 'gray',
73
+ ]}
74
+ theme={YOUR_THEME}
75
+ />
76
+ );
21
77
  };
22
78
  ```
23
79
 
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Loader: () => JSX.Element;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { ExternalMetrics } from '@/utils/generated/graphql';
3
3
  import { ClientType } from '@/types/app';
4
4
  import { FilterFieldType } from '@/components/FilterField';
@@ -19,5 +19,7 @@ export type MetricCardProps = {
19
19
  renderHeaderName?: (name: string) => JSX.Element;
20
20
  onArchive?: (metricId: string) => void;
21
21
  isDisableCardClick?: boolean;
22
+ chartRendererType?: 'svg' | 'canvas';
23
+ isDisableMorePopup?: boolean;
22
24
  };
23
- export declare const MetricCard: React.FC<MetricCardProps>;
25
+ export declare const MetricCard: ({ globalFilters, metricItem, onMaximize, client, colors, param, companyTenancyType, renderHeaderName, isDisableCardClick, onArchive, chartRendererType, isDisableMorePopup, }: MetricCardProps) => JSX.Element;
@@ -36,3 +36,4 @@ export * from './ChartSettingsPopup';
36
36
  export * from './Portal';
37
37
  export * from './GlobalFilters/NumberFilterField';
38
38
  export * from './DateRangePicker';
39
+ export * from './Loader';
@@ -1,7 +1,8 @@
1
- import React, { PropsWithChildren } from 'react';
1
+ import React from 'react';
2
2
  import { ThemeType } from '@/utils/theme';
3
3
  export interface DashboardProps {
4
4
  token: string;
5
+ dashboardId?: string;
5
6
  options?: {
6
7
  headerVariant?: 'static' | 'floating';
7
8
  disableMetricCreation?: boolean;
@@ -12,7 +13,11 @@ export interface DashboardProps {
12
13
  };
13
14
  theme?: ThemeType;
14
15
  }
15
- type PluginProviderProps = PropsWithChildren & Omit<DashboardProps, 'token'>;
16
- export declare const PluginProvider: ({ children, theme }: PluginProviderProps) => JSX.Element;
17
- export declare const Dashboard: React.MemoExoticComponent<({ token, options, theme }: DashboardProps) => JSX.Element>;
18
- export {};
16
+ /**
17
+ * @name Dashboard - A react component to display the dashboard.
18
+ * @prop {string} token - A client based guest token.
19
+ * @prop {string} dashboardId (optional) - A dashboard id (one which you have provided at the time of creating it) of the dashboard you want to see.
20
+ * @prop {object} options (optional) - Additional options like access permissions e.g. metric creation, updation, archiving and layout customization.
21
+ * @prop {object} theme (optional) - A theme object to customize the theme.
22
+ */
23
+ export declare const Dashboard: React.MemoExoticComponent<({ token, options, theme, dashboardId }: DashboardProps) => JSX.Element>;
@@ -1,6 +1,7 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  type DashboardProviderProps = PropsWithChildren & {
3
3
  token: string;
4
+ dashboardId?: string;
4
5
  };
5
- declare const DashboardProvider: ({ token, children }: DashboardProviderProps) => JSX.Element;
6
+ declare const DashboardProvider: ({ token, dashboardId, children, }: DashboardProviderProps) => JSX.Element;
6
7
  export default DashboardProvider;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface EmbeddedMetricProps {
3
+ token: string;
4
+ chartColors?: string[];
5
+ metricId: string;
6
+ chartRendererType?: 'svg' | 'canvas';
7
+ }
8
+ export declare const EmbeddedMetric: React.MemoExoticComponent<({ token, chartColors, metricId, chartRendererType, }: EmbeddedMetricProps) => JSX.Element>;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { EmbeddedMetricProps } from './EmbeddedMetric';
3
+ import { ThemeType } from '@/utils/theme';
4
+ export interface MetricProps extends EmbeddedMetricProps {
5
+ theme?: ThemeType;
6
+ width?: string;
7
+ height?: string;
8
+ }
9
+ /**
10
+ * @name Metric - A react component to display a single metric card.
11
+ * @prop {string} token - A client based guest token.
12
+ * @prop {string} metricId - A metric id (one which you have provided at the time of it's creation) of the metric you want to display.
13
+ * @prop {array} chartColors (optional) - An array of colors to be used to visualize the chart.
14
+ * @prop {string} chartRendererType (optional) - Whether to display chart as svg or canvas. In case of low end devices or in general svg is better and in case of frequent data changes or high size data visualization canvas is better. Defaults to canvas.
15
+ * @prop {string} width (optional) - The width of the metric card e.g. 500px, 75vw, 50%, 4rem, 3em, etc. Defaults to 100%.
16
+ * @prop {string} height (optional) - The height of the metric card e.g. 500px, 75vh, 50%, 4rem, 3em, etc. Defaults to 100%.
17
+ * @prop {object} theme (optional) - Theme config object to apply to the UI.
18
+ */
19
+ export declare const Metric: React.MemoExoticComponent<({ theme, width, height, ...metricProps }: MetricProps) => JSX.Element>;
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { ThemeType } from '@/utils';
3
+ type PluginProviderProps = PropsWithChildren & {
4
+ theme?: ThemeType;
5
+ };
6
+ export declare const PluginProvider: ({ children, theme }: PluginProviderProps) => JSX.Element;
7
+ export {};
@@ -1 +1,3 @@
1
1
  export * from './Dashboard';
2
+ export * from './PluginProvider';
3
+ export * from './Metric';
@@ -8,3 +8,4 @@ export * from './useClientDashboardLayout';
8
8
  export * from './useUnderlyingData';
9
9
  export * from './useMetricCard';
10
10
  export * from './useArchiveMetric';
11
+ export * from './useEmbeddedMetric';
@@ -1,4 +1,7 @@
1
- export declare const useEmbeddedDashboard: (token: string) => {
1
+ export declare const useEmbeddedDashboard: ({ token, dashboardId, }: {
2
+ token: string;
3
+ dashboardId?: string | undefined;
4
+ }) => {
2
5
  isLoading: boolean;
3
6
  data: {
4
7
  clientId: string | undefined;
@@ -0,0 +1,19 @@
1
+ import { ExternalMetrics } from '@/utils/generated/graphql';
2
+ export interface UseEmbeddedMetricProps {
3
+ token: string;
4
+ metricId: string;
5
+ }
6
+ export declare const useEmbeddedMetric: ({ token, metricId, }: UseEmbeddedMetricProps) => {
7
+ externalMetric: ExternalMetrics | undefined;
8
+ sharingSettingsId: string;
9
+ adminColors: string[] | null;
10
+ companyId: string;
11
+ clientId: string;
12
+ rlsSettings: {
13
+ metricId: string;
14
+ values: Record<string, any>;
15
+ } | undefined;
16
+ tenancyLevel: any;
17
+ isLoading: boolean;
18
+ errorMsg: string | undefined;
19
+ };