deepspotscreen-sdk 0.1.2 → 0.2.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/dist/index.d.ts CHANGED
@@ -147,8 +147,11 @@ export declare interface FilterDefinition {
147
147
  options?: string[];
148
148
  defaultValue?: any;
149
149
  targetComponents: string[];
150
+ /** Per-component column overrides: { componentId → columnName } */
151
+ columnMappings?: Record<string, string>;
150
152
  filterOperator?: string;
151
153
  applyToField?: string;
154
+ filterLevel?: 'global' | 'component';
152
155
  }
153
156
 
154
157
  export declare interface PageTab {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function E({apiKey:f,baseUrl:l,dashboardId:p,userId:d,tenantId:m,embedLevel:y,theme:v,height:x,pageId:z,tabId:j,filters:i,hideFilters:q,hideExport:L,onReady:b,onFilterChange:n,onTabSwitch:g,onError:o,className:S,style:D,loadingNode:u}){const t=e.useRef(null),R=e.useRef(void 0),[s,r]=e.useState(!0),[c,k]=e.useState("");return e.useEffect(()=>{if(!t.current)return;let P=!1;async function $(){var w;if(t.current)try{r(!0),k("");const{DeepspotSDK:a}=await Promise.resolve().then(()=>require("../DeepspotSDK-1R3OY1xG.cjs"));if(P||!t.current)return;const C=await new a({apiKey:f,baseUrl:l}).embedDashboard({dashboardId:p,container:t.current,userId:d,tenantId:m,embedLevel:y,theme:v,height:x,pageId:z,tabId:j,filters:i,hideFilters:q,hideExport:L,onReady:b,onFilterChange:n,onTabSwitch:g,onError:o});if(P){C.destroy();return}R.current=C,r(!1)}catch(a){if(P)return;const B=(w=a==null?void 0:a.message)!=null?w:String(a);k(B),r(!1),o==null||o(B)}}return $(),()=>{var w;P=!0,(w=R.current)==null||w.destroy(),R.current=void 0}},[f,l,p,d,m,y,v,x,z,j,q,L]),e.createElement("div",{style:{position:"relative",width:"100%"}},s&&!c?u!=null?u:e.createElement("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.6)",zIndex:1,fontSize:"14px",color:"#666"}},"Loading dashboard…"):null,c?e.createElement("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:"6px",color:"#b91c1c",fontSize:"13px",marginBottom:"8px"}},`Deepspot error: ${c}`):null,e.createElement("div",{ref:t,className:S,style:D}))}function M({apiKey:f,baseUrl:l,dashboardId:p,componentId:d,userId:m,tenantId:y,theme:v,height:x,filters:z,onReady:j,onError:i,className:q,style:L,loadingNode:b}){const n=e.useRef(null),g=e.useRef(void 0),[o,S]=e.useState(!0),[D,u]=e.useState("");return e.useEffect(()=>{if(!n.current)return;let t=!1;async function R(){var s;if(n.current)try{S(!0),u("");const{DeepspotSDK:r}=await Promise.resolve().then(()=>require("../DeepspotSDK-1R3OY1xG.cjs"));if(t||!n.current)return;const k=await new r({apiKey:f,baseUrl:l}).embedReport({dashboardId:p,componentId:d,container:n.current,userId:m,tenantId:y,theme:v,height:x,filters:z,onReady:j,onError:i});if(t){k.destroy();return}g.current=k,S(!1)}catch(r){if(t)return;const c=(s=r==null?void 0:r.message)!=null?s:String(r);u(c),S(!1),i==null||i(c)}}return R(),()=>{var s;t=!0,(s=g.current)==null||s.destroy(),g.current=void 0}},[f,l,p,d,m,y,v,x]),e.createElement("div",{style:{position:"relative",width:"100%"}},o&&!D?b!=null?b:e.createElement("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.6)",zIndex:1,fontSize:"14px",color:"#666"}},"Loading…"):null,D?e.createElement("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:"6px",color:"#b91c1c",fontSize:"13px",marginBottom:"8px"}},`Deepspot error: ${D}`):null,e.createElement("div",{ref:n,className:q,style:L}))}exports.DeepspotDashboard=E;exports.DeepspotReport=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function E({apiKey:f,baseUrl:l,dashboardId:p,userId:d,tenantId:m,embedLevel:y,theme:v,height:x,pageId:z,tabId:j,filters:i,hideFilters:q,hideExport:L,onReady:b,onFilterChange:n,onTabSwitch:g,onError:o,className:S,style:D,loadingNode:u}){const t=e.useRef(null),R=e.useRef(void 0),[s,r]=e.useState(!0),[c,k]=e.useState("");return e.useEffect(()=>{if(!t.current)return;let P=!1;async function $(){var w;if(t.current)try{r(!0),k("");const{DeepspotSDK:a}=await Promise.resolve().then(()=>require("../DeepspotSDK-Ci6IqiPC.cjs"));if(P||!t.current)return;const C=await new a({apiKey:f,baseUrl:l}).embedDashboard({dashboardId:p,container:t.current,userId:d,tenantId:m,embedLevel:y,theme:v,height:x,pageId:z,tabId:j,filters:i,hideFilters:q,hideExport:L,onReady:b,onFilterChange:n,onTabSwitch:g,onError:o});if(P){C.destroy();return}R.current=C,r(!1)}catch(a){if(P)return;const B=(w=a==null?void 0:a.message)!=null?w:String(a);k(B),r(!1),o==null||o(B)}}return $(),()=>{var w;P=!0,(w=R.current)==null||w.destroy(),R.current=void 0}},[f,l,p,d,m,y,v,x,z,j,q,L]),e.createElement("div",{style:{position:"relative",width:"100%"}},s&&!c?u!=null?u:e.createElement("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.6)",zIndex:1,fontSize:"14px",color:"#666"}},"Loading dashboard…"):null,c?e.createElement("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:"6px",color:"#b91c1c",fontSize:"13px",marginBottom:"8px"}},`Deepspot error: ${c}`):null,e.createElement("div",{ref:t,className:S,style:D}))}function M({apiKey:f,baseUrl:l,dashboardId:p,componentId:d,userId:m,tenantId:y,theme:v,height:x,filters:z,onReady:j,onError:i,className:q,style:L,loadingNode:b}){const n=e.useRef(null),g=e.useRef(void 0),[o,S]=e.useState(!0),[D,u]=e.useState("");return e.useEffect(()=>{if(!n.current)return;let t=!1;async function R(){var s;if(n.current)try{S(!0),u("");const{DeepspotSDK:r}=await Promise.resolve().then(()=>require("../DeepspotSDK-Ci6IqiPC.cjs"));if(t||!n.current)return;const k=await new r({apiKey:f,baseUrl:l}).embedReport({dashboardId:p,componentId:d,container:n.current,userId:m,tenantId:y,theme:v,height:x,filters:z,onReady:j,onError:i});if(t){k.destroy();return}g.current=k,S(!1)}catch(r){if(t)return;const c=(s=r==null?void 0:r.message)!=null?s:String(r);u(c),S(!1),i==null||i(c)}}return R(),()=>{var s;t=!0,(s=g.current)==null||s.destroy(),g.current=void 0}},[f,l,p,d,m,y,v,x]),e.createElement("div",{style:{position:"relative",width:"100%"}},o&&!D?b!=null?b:e.createElement("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.6)",zIndex:1,fontSize:"14px",color:"#666"}},"Loading…"):null,D?e.createElement("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fca5a5",borderRadius:"6px",color:"#b91c1c",fontSize:"13px",marginBottom:"8px"}},`Deepspot error: ${D}`):null,e.createElement("div",{ref:n,className:q,style:L}))}exports.DeepspotDashboard=E;exports.DeepspotReport=M;
@@ -30,7 +30,7 @@ function M({
30
30
  if (t.current)
31
31
  try {
32
32
  e(!0), k("");
33
- const { DeepspotSDK: a } = await import("../DeepspotSDK-ClR0wrhx.js");
33
+ const { DeepspotSDK: a } = await import("../DeepspotSDK-smoJaflG.js");
34
34
  if (C || !t.current) return;
35
35
  const G = await new a({ apiKey: f, baseUrl: p }).embedDashboard({
36
36
  dashboardId: l,
@@ -123,7 +123,7 @@ function O({
123
123
  if (r.current)
124
124
  try {
125
125
  D(!0), u("");
126
- const { DeepspotSDK: e } = await import("../DeepspotSDK-ClR0wrhx.js");
126
+ const { DeepspotSDK: e } = await import("../DeepspotSDK-smoJaflG.js");
127
127
  if (t || !r.current) return;
128
128
  const k = await new e({ apiKey: f, baseUrl: p }).embedReport({
129
129
  dashboardId: l,
@@ -21,7 +21,10 @@ export interface DashboardRenderOptions {
21
21
  * The caller fetches options from
22
22
  * GET /dashboard-builder/{dashboardId}/filters/{filterId}/options
23
23
  */
24
- onFetchFilterOptions?: (filterId: string) => Promise<string[]>;
24
+ onFetchFilterOptions?: (filterId: string) => Promise<Array<string | {
25
+ value: string;
26
+ label: string;
27
+ }>>;
25
28
  /**
26
29
  * Called by TableRenderer when the user navigates to a page in an embedded table.
27
30
  */
@@ -39,6 +42,8 @@ export declare class DashboardRenderer {
39
42
  private activePageId;
40
43
  private activeTabId;
41
44
  private activeFilters;
45
+ private activeFilterOperators;
46
+ private activeLocalFilters;
42
47
  private chartRenderers;
43
48
  private filterRenderer;
44
49
  private tableRenderer;
@@ -53,6 +58,15 @@ export declare class DashboardRenderer {
53
58
  destroy(): void;
54
59
  exportPDF(): void;
55
60
  exportCSV(): void;
61
+ /** Returns a snapshot of the currently active filter values (used by DeepspotSDK onTabSwitch). */
62
+ getActiveFilters(): Record<string, any>;
63
+ /** Returns a snapshot of the active filter operators (=, LIKE, IN, etc.) keyed by applyToField. */
64
+ getActiveFilterOperators(): Record<string, string>;
65
+ /** Returns local (component-scoped) filter values keyed by filterId. */
66
+ getActiveLocalFilters(): Record<string, {
67
+ value: any;
68
+ operator: string;
69
+ }>;
56
70
  updateFilterValues(values: Record<string, any>): void;
57
71
  private buildShell;
58
72
  private buildExportToolbar;
@@ -64,11 +78,28 @@ export declare class DashboardRenderer {
64
78
  private syncNavHighlight;
65
79
  private renderFilterBar;
66
80
  private updateFilterBar;
67
- /** Convert inline-filter ComponentConfig entries to FilterDefinition shape */
81
+ /** Combines global activeFilters and local filter values (keyed by filterId)
82
+ * so FilterRenderer can show correct active state for targeted filters. */
83
+ private mergedFilterValues;
84
+ /**
85
+ * Returns true when a filter should appear in the global top filter bar.
86
+ * A filter is global when the matching inline-filter component has
87
+ * filter_scope/scope !== 'local' and filterLevel !== 'component'.
88
+ */
89
+ private filterIsGlobal;
90
+ /** Filters from renderData.filters[] that should appear in the global top panel. */
91
+ private globalFilters;
92
+ /**
93
+ * Filters that are component-scoped (filter_scope='local').
94
+ * Source of truth is filters[] — which has applyToField, targetComponents, etc.
95
+ * The matching inline-filter component in components[] provides the scope signal.
96
+ */
68
97
  private inlineFiltersAsDefinitions;
69
98
  private fetchFilterOptions;
70
99
  private renderGrid;
71
100
  private renderComponent;
101
+ private attachInlineFilterBtn;
102
+ private buildInlineFilterPop;
72
103
  private showTabSpinner;
73
104
  private hideTabSpinner;
74
105
  /**
@@ -1,20 +1,43 @@
1
1
  import { FilterDefinition } from '../types';
2
2
 
3
+ type FilterOption = string | {
4
+ value: string;
5
+ label: string;
6
+ };
3
7
  export declare class FilterRenderer {
4
8
  private container;
5
9
  private onFilterChange;
6
- private currentValues;
7
- constructor(container: HTMLElement, onFilterChange: (filterId: string, value: any) => void);
10
+ private filters;
11
+ private state;
12
+ private activePopoverId;
13
+ constructor(container: HTMLElement, onFilterChange: (filterId: string, value: any, operator?: string) => void);
8
14
  render(filters: FilterDefinition[], initialValues?: Record<string, any>): void;
9
- /**
10
- * Populate a dropdown / multi-select with options fetched from the API.
11
- * Called asynchronously after the filter bar is rendered.
12
- */
13
- updateOptions(filterId: string, options: string[]): void;
14
- /** Update the stored values without re-rendering (for programmatic setFilter) */
15
+ updateOptions(filterId: string, options: FilterOption[]): void;
16
+ setLoading(filterId: string, loading: boolean): void;
15
17
  updateValues(values: Record<string, any>): void;
16
- private renderFilter;
17
- private attachListeners;
18
+ private paint;
19
+ private renderBadge;
20
+ private renderPopoverHtml;
21
+ private renderValuesControl;
22
+ private renderMultiSelectControl;
23
+ private renderOpts;
24
+ private bindAll;
25
+ private bindPopover;
26
+ private bindOpts;
27
+ private bindChips;
28
+ private togglePopover;
29
+ private closePopover;
30
+ private closePopoverOnOutsideClick;
31
+ private applyFilter;
32
+ private clearFilter;
33
+ private repaintBadge;
34
+ private repaintBadges;
35
+ private repaintOpts;
36
+ private refreshPopoverOpts;
37
+ private repaintChips;
38
+ resetAll(): void;
39
+ private optLabel;
18
40
  private escAttr;
19
41
  private escText;
20
42
  }
43
+ export {};
package/dist/types.d.ts CHANGED
@@ -140,8 +140,11 @@ export interface FilterDefinition {
140
140
  options?: string[];
141
141
  defaultValue?: any;
142
142
  targetComponents: string[];
143
+ /** Per-component column overrides: { componentId → columnName } */
144
+ columnMappings?: Record<string, string>;
143
145
  filterOperator?: string;
144
146
  applyToField?: string;
147
+ filterLevel?: 'global' | 'component';
145
148
  }
146
149
  export interface RenderResponse {
147
150
  embedType: 'dashboard' | 'report';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),u=require("../DeepspotSDK-1R3OY1xG.cjs"),y=d.defineComponent({name:"DeepspotDashboard",props:{apiKey:{type:String,required:!0},baseUrl:{type:String,required:!0},dashboardId:{type:String,required:!0},userId:{type:String,default:void 0},tenantId:{type:String,default:void 0},embedLevel:{type:String,default:"dashboard"},theme:{type:String,default:"light"},height:{type:String,default:"600px"},pageId:{type:String,default:void 0},tabId:{type:String,default:void 0},hideFilters:{type:Boolean,default:!1},hideExport:{type:Boolean,default:!1},filters:{type:Object,default:()=>({})}},emits:["ready","filter-change","tab-switch","error"],setup(e,{emit:r}){const i=d.ref();let t;async function o(){var l;if(i.value){t==null||t.destroy(),t=void 0;try{t=await new u.DeepspotSDK({apiKey:e.apiKey,baseUrl:e.baseUrl}).embedDashboard({dashboardId:e.dashboardId,container:i.value,userId:e.userId,tenantId:e.tenantId,embedLevel:e.embedLevel,theme:e.theme,height:e.height,pageId:e.pageId,tabId:e.tabId,hideFilters:e.hideFilters,hideExport:e.hideExport,filters:e.filters,onReady:()=>r("ready"),onFilterChange:n=>r("filter-change",n),onTabSwitch:(n,h)=>r("tab-switch",n,h),onError:n=>r("error",n)})}catch(a){r("error",(l=a==null?void 0:a.message)!=null?l:String(a))}}}return d.onMounted(()=>{o()}),d.onUnmounted(()=>{t==null||t.destroy()}),d.watch(()=>[e.dashboardId,e.userId,e.tenantId,e.apiKey,e.baseUrl,e.embedLevel,e.theme,e.height,e.pageId,e.tabId,e.hideFilters,e.hideExport],()=>{o()}),()=>d.h("div",{ref:i,style:{display:"block"}})}}),g=d.defineComponent({name:"DeepspotReport",props:{apiKey:{type:String,required:!0},baseUrl:{type:String,required:!0},dashboardId:{type:String,required:!0},componentId:{type:String,required:!0},userId:{type:String,default:void 0},tenantId:{type:String,default:void 0},theme:{type:String,default:"light"},height:{type:String,default:"400px"},filters:{type:Object,default:()=>({})}},emits:["ready","error"],setup(e,{emit:r}){const i=d.ref();let t;async function o(){var l;if(i.value){t==null||t.destroy(),t=void 0;try{t=await new u.DeepspotSDK({apiKey:e.apiKey,baseUrl:e.baseUrl}).embedReport({dashboardId:e.dashboardId,componentId:e.componentId,container:i.value,userId:e.userId,tenantId:e.tenantId,theme:e.theme,height:e.height,filters:e.filters,onReady:()=>r("ready"),onError:n=>r("error",n)})}catch(a){r("error",(l=a==null?void 0:a.message)!=null?l:String(a))}}}return d.onMounted(()=>{o()}),d.onUnmounted(()=>{t==null||t.destroy()}),d.watch(()=>[e.dashboardId,e.componentId,e.userId,e.apiKey,e.baseUrl,e.theme,e.height],()=>{o()}),()=>d.h("div",{ref:i,style:{display:"block"}})}});exports.DeepspotDashboard=y;exports.DeepspotReport=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("vue"),u=require("../DeepspotSDK-Ci6IqiPC.cjs"),y=d.defineComponent({name:"DeepspotDashboard",props:{apiKey:{type:String,required:!0},baseUrl:{type:String,required:!0},dashboardId:{type:String,required:!0},userId:{type:String,default:void 0},tenantId:{type:String,default:void 0},embedLevel:{type:String,default:"dashboard"},theme:{type:String,default:"light"},height:{type:String,default:"600px"},pageId:{type:String,default:void 0},tabId:{type:String,default:void 0},hideFilters:{type:Boolean,default:!1},hideExport:{type:Boolean,default:!1},filters:{type:Object,default:()=>({})}},emits:["ready","filter-change","tab-switch","error"],setup(e,{emit:r}){const i=d.ref();let t;async function o(){var l;if(i.value){t==null||t.destroy(),t=void 0;try{t=await new u.DeepspotSDK({apiKey:e.apiKey,baseUrl:e.baseUrl}).embedDashboard({dashboardId:e.dashboardId,container:i.value,userId:e.userId,tenantId:e.tenantId,embedLevel:e.embedLevel,theme:e.theme,height:e.height,pageId:e.pageId,tabId:e.tabId,hideFilters:e.hideFilters,hideExport:e.hideExport,filters:e.filters,onReady:()=>r("ready"),onFilterChange:n=>r("filter-change",n),onTabSwitch:(n,h)=>r("tab-switch",n,h),onError:n=>r("error",n)})}catch(a){r("error",(l=a==null?void 0:a.message)!=null?l:String(a))}}}return d.onMounted(()=>{o()}),d.onUnmounted(()=>{t==null||t.destroy()}),d.watch(()=>[e.dashboardId,e.userId,e.tenantId,e.apiKey,e.baseUrl,e.embedLevel,e.theme,e.height,e.pageId,e.tabId,e.hideFilters,e.hideExport],()=>{o()}),()=>d.h("div",{ref:i,style:{display:"block"}})}}),g=d.defineComponent({name:"DeepspotReport",props:{apiKey:{type:String,required:!0},baseUrl:{type:String,required:!0},dashboardId:{type:String,required:!0},componentId:{type:String,required:!0},userId:{type:String,default:void 0},tenantId:{type:String,default:void 0},theme:{type:String,default:"light"},height:{type:String,default:"400px"},filters:{type:Object,default:()=>({})}},emits:["ready","error"],setup(e,{emit:r}){const i=d.ref();let t;async function o(){var l;if(i.value){t==null||t.destroy(),t=void 0;try{t=await new u.DeepspotSDK({apiKey:e.apiKey,baseUrl:e.baseUrl}).embedReport({dashboardId:e.dashboardId,componentId:e.componentId,container:i.value,userId:e.userId,tenantId:e.tenantId,theme:e.theme,height:e.height,filters:e.filters,onReady:()=>r("ready"),onError:n=>r("error",n)})}catch(a){r("error",(l=a==null?void 0:a.message)!=null?l:String(a))}}}return d.onMounted(()=>{o()}),d.onUnmounted(()=>{t==null||t.destroy()}),d.watch(()=>[e.dashboardId,e.componentId,e.userId,e.apiKey,e.baseUrl,e.theme,e.height],()=>{o()}),()=>d.h("div",{ref:i,style:{display:"block"}})}});exports.DeepspotDashboard=y;exports.DeepspotReport=g;
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as h, ref as o, onMounted as u, onUnmounted as y, watch as g, h as b } from "vue";
2
- import { DeepspotSDK as f } from "../DeepspotSDK-ClR0wrhx.js";
2
+ import { DeepspotSDK as f } from "../DeepspotSDK-smoJaflG.js";
3
3
  const m = h({
4
4
  name: "DeepspotDashboard",
5
5
  props: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepspotscreen-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Deepspot Embedded Analytics SDK — embed dashboards and reports in any website",
5
5
  "license": "MIT",
6
6
  "type": "module",