@luzmo/embed 8.0.0 → 8.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.
package/index.js CHANGED
@@ -371,41 +371,46 @@ var createIframeUrl = (dashboardContent) => {
371
371
  // libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
372
372
  var getLoader = (dashboardComponent) => {
373
373
  let errorMsg;
374
- if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
375
- dashboardComponent.params.error = true;
374
+ if (dashboardComponent.params?.error || (dashboardComponent.browserNotSupported?.length ?? 0) > 0) {
375
+ if (dashboardComponent.params) {
376
+ dashboardComponent.params.error = true;
377
+ }
376
378
  if (dashboardComponent.browserNotSupported) {
377
379
  errorMsg = "Browser is not supported.";
378
380
  }
379
381
  }
380
- const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
381
- return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
382
+ const language = dashboardComponent.params?.language;
383
+ const loadingMsg = (language ? translations_default.initializing[language] : void 0) || translations_default.initializing.en;
384
+ return dashboardComponent.browserNotSupported || dashboardComponent.params?.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
382
385
  };
383
386
 
384
387
  // libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
385
388
  function resolvePromise(dashboardComponent, requestId, data) {
386
- if (dashboardComponent.promises[requestId]) {
387
- dashboardComponent.promises[requestId].resolve(data);
388
- delete dashboardComponent.promises[requestId];
389
+ const promises = dashboardComponent.promises;
390
+ if (promises?.[requestId]) {
391
+ promises[requestId].resolve(data);
392
+ delete promises[requestId];
389
393
  }
390
394
  }
391
395
  function rejectPromise(dashboardComponent, requestId, data) {
392
- if (dashboardComponent.promises[requestId]) {
393
- dashboardComponent.promises[requestId].reject(data);
394
- delete dashboardComponent.promises[requestId];
396
+ const promises = dashboardComponent.promises;
397
+ if (promises?.[requestId]) {
398
+ promises[requestId].reject(data);
399
+ delete promises[requestId];
395
400
  }
396
401
  }
397
402
 
398
403
  // libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
399
404
  function containerStyles(dashboardComponent) {
400
405
  const styles = {};
401
- if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
406
+ if (dashboardComponent.params?.loaderBackground && !dashboardComponent.iframeLoaded) {
402
407
  styles.background = dashboardComponent.params.loaderBackground;
403
408
  }
404
409
  return styles;
405
410
  }
406
411
  function containerLoaderStyles(dashboardComponent) {
407
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
408
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
412
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
413
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
409
414
  const display = dashboardComponent.iframeLoaded ? "none" : "";
410
415
  return {
411
416
  display,
@@ -413,8 +418,8 @@ function containerLoaderStyles(dashboardComponent) {
413
418
  };
414
419
  }
415
420
  function loaderStyles(dashboardComponent) {
416
- const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
417
- if (dashboardComponent.params.itemEmbedding) {
421
+ const background = dashboardComponent.params?.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
422
+ if (dashboardComponent.params?.itemEmbedding) {
418
423
  dashboardComponent.loaderSize = 24;
419
424
  dashboardComponent.borderWidth = 4;
420
425
  dashboardComponent.minHeight = 200;
@@ -443,11 +448,11 @@ function plStyles(dashboardComponent) {
443
448
  } = DEFAULT_PARAMETERS;
444
449
  const spinnerColorBorder = generateBorderStyle(
445
450
  dashboardComponent.borderWidth,
446
- dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
451
+ dashboardComponent.params?.loaderSpinnerColor || defaultSpinnerColor
447
452
  );
448
453
  const spinnerBackgroundBorder = generateBorderStyle(
449
454
  dashboardComponent.borderWidth,
450
- dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
455
+ dashboardComponent.params?.loaderSpinnerBackground || defaultSpinnerBackground
451
456
  );
452
457
  const size = `${dashboardComponent.loaderSize}px`;
453
458
  return {
@@ -460,27 +465,28 @@ function plStyles(dashboardComponent) {
460
465
  };
461
466
  }
462
467
  function lcStyles(dashboardComponent) {
463
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
464
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
465
- const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
466
- const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
468
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
469
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
470
+ const getPaddingStr = (value) => `${((value ?? Number.NaN) - (dashboardComponent.loaderSize ?? Number.NaN) - 32) / 2}px`;
471
+ const verticalPadding = dashboardComponent.params?.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
467
472
  return {
468
473
  padding: `${verticalPadding} 16px`
469
474
  };
470
475
  }
471
476
  function calculateIframeStyles(dashboardComponent) {
472
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
473
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
474
- if (dashboardComponent.params.itemEmbedding && height !== "auto") {
477
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
478
+ const width = dashboardComponent.params?.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
479
+ const editMode = dashboardComponent.params?.editMode;
480
+ if (dashboardComponent.params?.itemEmbedding && height !== "auto") {
475
481
  dashboardComponent.iframeHeight = `${height}px`;
476
- } else if (dashboardComponent.params.itemEmbedding) {
482
+ } else if (dashboardComponent.params?.itemEmbedding) {
477
483
  dashboardComponent.iframeHeight = "200px";
478
- } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
484
+ } else if (editMode != null && ["editFull", "editLimited"].includes(editMode)) {
479
485
  dashboardComponent.iframeHeight = "100%";
480
486
  } else {
481
487
  dashboardComponent.iframeHeight = "400px";
482
488
  }
483
- dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
489
+ dashboardComponent.iframeWidth = dashboardComponent.params?.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
484
490
  const styles = {
485
491
  height: dashboardComponent.iframeHeight,
486
492
  width: dashboardComponent.iframeWidth
@@ -499,7 +505,7 @@ function calculateIframeStyles(dashboardComponent) {
499
505
 
500
506
  // libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
501
507
  var updateIframeUrl = (iframe, iframeUrl) => {
502
- if (iframe?.contentWindow) {
508
+ if (iframe?.contentWindow && iframeUrl !== void 0) {
503
509
  iframe.contentWindow.location.replace(iframeUrl);
504
510
  }
505
511
  };
@@ -508,7 +514,7 @@ var updateIframeUrl = (iframe, iframeUrl) => {
508
514
  var selectedDataUtils = {
509
515
  merge(...filters) {
510
516
  return filters.reduce((acc, filter) => {
511
- acc.and.push(...filter.and);
517
+ (acc.and ??= []).push(...filter.and ?? []);
512
518
  return acc;
513
519
  }, {
514
520
  and: []
@@ -571,43 +577,46 @@ var selectedDataUtils = {
571
577
  // libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
572
578
  var exportDashboard = (dashboardComponent, iframe, format) => {
573
579
  const requestId = uuidv4();
574
- if (iframe?.contentWindow) {
575
- iframe.contentWindow.postMessage(
576
- {
577
- action: "exportDashboard",
578
- format: format || "png",
579
- _version: dashboardComponent.libVersion,
580
- requestId
581
- },
582
- "*"
583
- );
584
- return new Promise((resolve, reject) => {
585
- dashboardComponent.promises[requestId] = { resolve, reject };
586
- setTimeout(() => {
587
- if (dashboardComponent.promises[requestId]) {
588
- const errorMessage = "exportDashboard request timed out.";
589
- dashboardComponent.promises[requestId].reject(
590
- new Error(errorMessage)
591
- );
592
- delete dashboardComponent.promises[requestId];
593
- }
594
- }, 12e5);
595
- });
580
+ if (!iframe?.contentWindow) {
581
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
596
582
  }
597
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
583
+ const { promises } = dashboardComponent;
584
+ if (!promises) {
585
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
586
+ }
587
+ iframe.contentWindow.postMessage(
588
+ {
589
+ action: "exportDashboard",
590
+ format: format || "png",
591
+ _version: dashboardComponent.libVersion,
592
+ requestId
593
+ },
594
+ "*"
595
+ );
596
+ return new Promise((resolve, reject) => {
597
+ promises[requestId] = { resolve, reject };
598
+ setTimeout(() => {
599
+ if (promises[requestId]) {
600
+ const errorMessage = "exportDashboard request timed out.";
601
+ promises[requestId].reject(new Error(errorMessage));
602
+ delete promises[requestId];
603
+ }
604
+ }, 12e5);
605
+ });
598
606
  };
599
607
 
600
608
  // libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
601
609
  var getAccessibleDashboards = async (dashboardComponent) => {
602
610
  await dashboardComponent.updateComplete;
603
- if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
611
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken) && dashboardComponent.params) {
612
+ const { params } = dashboardComponent;
604
613
  const fetchUser = new Promise((resolve, reject) => {
605
614
  void (() => {
606
615
  try {
607
616
  const responsePromise = window.fetch(
608
617
  // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
609
618
  // Fixes incorrect url with embedMode="webComponent"
610
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
619
+ `${addTrailingSlash(params.apiHost)}0.1.0/authorization`,
611
620
  {
612
621
  method: "POST",
613
622
  mode: "cors",
@@ -652,136 +661,144 @@ var getAccessibleDashboards = async (dashboardComponent) => {
652
661
  }
653
662
  })();
654
663
  });
655
- return new Promise((resolve, reject) => void (() => {
656
- try {
657
- fetchUser.then((authorizationData) => {
658
- const responsePromise = window.fetch(
659
- // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
660
- // Fixes incorrect url with embedMode="webComponent"
661
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
662
- {
663
- method: "POST",
664
- mode: "cors",
665
- cache: "no-cache",
666
- headers: { "Content-Type": "application/json" },
667
- redirect: "follow",
668
- body: JSON.stringify({
669
- action: "get",
670
- version: "0.1.0",
671
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
672
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
673
- find: {
674
- where: { type: "dashboard", is_variant: false },
675
- attributes: ["id", "name", "modified_at"],
676
- order: [["modified_at", "desc"]],
677
- include: [
678
- { model: "Tag", attributes: ["tag"] },
679
- { model: "User", attributes: ["id", "name"] },
680
- {
681
- model: "Group",
682
- attributes: ["id", "name", "public"]
683
- },
684
- { model: "Integration", attributes: ["id", "name"] }
685
- ]
686
- }
687
- })
688
- }
689
- );
690
- responsePromise.then((response) => response.json()).then((data) => {
691
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
692
- data.rows,
693
- authorizationData.integrationId,
694
- authorizationData.user,
695
- dashboardComponent
696
- ) : [];
697
- resolve(dashboardList);
664
+ return new Promise((resolve, reject) => {
665
+ void (() => {
666
+ try {
667
+ fetchUser.then((authorizationData) => {
668
+ const responsePromise = window.fetch(
669
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
670
+ // Fixes incorrect url with embedMode="webComponent"
671
+ `${addTrailingSlash(params.apiHost)}0.1.0/securable`,
672
+ {
673
+ method: "POST",
674
+ mode: "cors",
675
+ cache: "no-cache",
676
+ headers: { "Content-Type": "application/json" },
677
+ redirect: "follow",
678
+ body: JSON.stringify({
679
+ action: "get",
680
+ version: "0.1.0",
681
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
682
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
683
+ find: {
684
+ where: { type: "dashboard", is_variant: false },
685
+ attributes: ["id", "name", "modified_at"],
686
+ order: [["modified_at", "desc"]],
687
+ include: [
688
+ { model: "Tag", attributes: ["tag"] },
689
+ { model: "User", attributes: ["id", "name"] },
690
+ {
691
+ model: "Group",
692
+ attributes: ["id", "name", "public"]
693
+ },
694
+ { model: "Integration", attributes: ["id", "name"] }
695
+ ]
696
+ }
697
+ })
698
+ }
699
+ );
700
+ responsePromise.then((response) => response.json()).then((data) => {
701
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
702
+ data.rows,
703
+ authorizationData.integrationId,
704
+ authorizationData.user,
705
+ dashboardComponent
706
+ ) : [];
707
+ resolve(dashboardList);
708
+ });
709
+ }).catch((error) => {
710
+ reject(error);
698
711
  });
699
- }).catch((error) => {
712
+ } catch (error) {
700
713
  reject(error);
701
- });
702
- } catch (error) {
703
- reject(error);
704
- }
705
- })());
714
+ }
715
+ })();
716
+ });
706
717
  }
707
718
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
708
719
  };
709
720
 
710
721
  // libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
711
722
  var getDashboardContext = (dashboardComponent, iframe) => {
712
- if (iframe?.contentWindow) {
713
- const requestId = uuidv4();
714
- iframe.contentWindow.postMessage(
715
- { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
716
- "*"
717
- );
718
- return new Promise((resolve, reject) => {
719
- dashboardComponent.promises[requestId] = { resolve, reject };
720
- setTimeout(() => {
721
- if (dashboardComponent.promises[requestId]) {
722
- const errorMessage = "getDashboardContext request timed out.";
723
- dashboardComponent.promises[requestId].reject(
724
- new Error(errorMessage)
725
- );
726
- delete dashboardComponent.promises[requestId];
727
- }
728
- }, 2e3);
729
- });
723
+ if (!iframe?.contentWindow) {
724
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
730
725
  }
731
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
726
+ const { promises } = dashboardComponent;
727
+ if (!promises) {
728
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
729
+ }
730
+ const requestId = uuidv4();
731
+ iframe.contentWindow.postMessage(
732
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
733
+ "*"
734
+ );
735
+ return new Promise((resolve, reject) => {
736
+ promises[requestId] = { resolve, reject };
737
+ setTimeout(() => {
738
+ if (promises[requestId]) {
739
+ const errorMessage = "getDashboardContext request timed out.";
740
+ promises[requestId].reject(new Error(errorMessage));
741
+ delete promises[requestId];
742
+ }
743
+ }, 2e3);
744
+ });
732
745
  };
733
746
 
734
747
  // libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
735
748
  var getData = (dashboardComponent, iframe, itemId) => {
736
- if (iframe?.contentWindow) {
737
- const requestId = uuidv4();
738
- iframe.contentWindow.postMessage(
739
- {
740
- action: "getData",
741
- id: itemId,
742
- _version: dashboardComponent.libVersion,
743
- requestId
744
- },
745
- "*"
746
- );
747
- return new Promise((resolve, reject) => {
748
- dashboardComponent.promises[requestId] = { resolve, reject };
749
- setTimeout(() => {
750
- if (dashboardComponent.promises[requestId]) {
751
- const errorMessage = "getData request timed out.";
752
- dashboardComponent.promises[requestId].reject(
753
- new Error(errorMessage)
754
- );
755
- delete dashboardComponent.promises[requestId];
756
- }
757
- }, 2e3);
758
- });
749
+ if (!iframe?.contentWindow) {
750
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
759
751
  }
760
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
752
+ const { promises } = dashboardComponent;
753
+ if (!promises) {
754
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
755
+ }
756
+ const requestId = uuidv4();
757
+ iframe.contentWindow.postMessage(
758
+ {
759
+ action: "getData",
760
+ id: itemId,
761
+ _version: dashboardComponent.libVersion,
762
+ requestId
763
+ },
764
+ "*"
765
+ );
766
+ return new Promise((resolve, reject) => {
767
+ promises[requestId] = { resolve, reject };
768
+ setTimeout(() => {
769
+ if (promises[requestId]) {
770
+ const errorMessage = "getData request timed out.";
771
+ promises[requestId].reject(new Error(errorMessage));
772
+ delete promises[requestId];
773
+ }
774
+ }, 2e3);
775
+ });
761
776
  };
762
777
 
763
778
  // libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
764
779
  var getFilters = (dashboardComponent, iframe) => {
765
- if (iframe?.contentWindow) {
766
- const requestId = uuidv4();
767
- iframe.contentWindow.postMessage(
768
- { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
769
- "*"
770
- );
771
- return new Promise((resolve, reject) => {
772
- dashboardComponent.promises[requestId] = { resolve, reject };
773
- setTimeout(() => {
774
- if (dashboardComponent.promises[requestId]) {
775
- const errorMessage = "getFilters request timed out.";
776
- dashboardComponent.promises[requestId].reject(
777
- new Error(errorMessage)
778
- );
779
- delete dashboardComponent.promises[requestId];
780
- }
781
- }, 2e3);
782
- });
780
+ if (!iframe?.contentWindow) {
781
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
783
782
  }
784
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
783
+ const { promises } = dashboardComponent;
784
+ if (!promises) {
785
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
786
+ }
787
+ const requestId = uuidv4();
788
+ iframe.contentWindow.postMessage(
789
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
790
+ "*"
791
+ );
792
+ return new Promise((resolve, reject) => {
793
+ promises[requestId] = { resolve, reject };
794
+ setTimeout(() => {
795
+ if (promises[requestId]) {
796
+ const errorMessage = "getFilters request timed out.";
797
+ promises[requestId].reject(new Error(errorMessage));
798
+ delete promises[requestId];
799
+ }
800
+ }, 2e3);
801
+ });
785
802
  };
786
803
 
787
804
  // libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
@@ -789,6 +806,10 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
789
806
  if (!iframe?.contentWindow) {
790
807
  return Promise.reject(new Error("Cannot retrieve contentWindow."));
791
808
  }
809
+ const { promises } = dashboardComponent;
810
+ if (!promises) {
811
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
812
+ }
792
813
  const requestId = uuidv4();
793
814
  iframe.contentWindow.postMessage(
794
815
  {
@@ -800,11 +821,11 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
800
821
  "*"
801
822
  );
802
823
  return new Promise((resolve, reject) => {
803
- dashboardComponent.promises[requestId] = { resolve, reject };
824
+ promises[requestId] = { resolve, reject };
804
825
  setTimeout(() => {
805
- if (dashboardComponent.promises[requestId]) {
806
- dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
807
- delete dashboardComponent.promises[requestId];
826
+ if (promises[requestId]) {
827
+ promises[requestId].reject(new Error("getInsights request timed out."));
828
+ delete promises[requestId];
808
829
  }
809
830
  }, 6e4);
810
831
  });
@@ -812,7 +833,7 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
812
833
 
813
834
  // libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
814
835
  var refreshData = (dashboardComponent, iframe, itemId) => {
815
- if (iframe) {
836
+ if (iframe?.contentWindow) {
816
837
  iframe.contentWindow.postMessage(
817
838
  {
818
839
  action: "refreshData",
@@ -828,7 +849,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
828
849
 
829
850
  // libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
830
851
  var reloadDashboard = (dashboardComponent, iframe) => {
831
- if (iframe) {
852
+ if (iframe?.contentWindow) {
832
853
  iframe.contentWindow.postMessage(
833
854
  { action: "reloadDashboard", _version: dashboardComponent.libVersion },
834
855
  "*"
@@ -840,7 +861,7 @@ var reloadDashboard = (dashboardComponent, iframe) => {
840
861
 
841
862
  // libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
842
863
  var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
843
- if (iframe) {
864
+ if (iframe?.contentWindow) {
844
865
  iframe.contentWindow.postMessage(
845
866
  {
846
867
  action: "sendExportEmail",
@@ -858,7 +879,7 @@ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
858
879
 
859
880
  // libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
860
881
  var setAuthorization = (dashboardComponent, iframe, key, token) => {
861
- if (iframe) {
882
+ if (iframe?.contentWindow) {
862
883
  iframe.contentWindow.postMessage(
863
884
  {
864
885
  action: "setAuthorization",
@@ -875,92 +896,100 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
875
896
 
876
897
  // libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
877
898
  var setEditMode = (dashboardComponent, iframe, editMode) => {
878
- if (iframe && iframe.contentWindow) {
879
- const requestId = uuidv4();
880
- if (dashboardComponent.params.editMode === editMode) {
881
- return Promise.reject(
882
- new Error("editMode parameter is currently already set to " + editMode)
883
- );
884
- } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
885
- return Promise.reject(
886
- new Error(
887
- "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
888
- )
889
- );
890
- }
891
- iframe.contentWindow.postMessage(
892
- {
893
- action: "setEditMode",
894
- editMode,
895
- _version: dashboardComponent.libVersion,
896
- requestId
897
- },
898
- "*"
899
+ if (!iframe?.contentWindow) {
900
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
901
+ }
902
+ const { params, promises } = dashboardComponent;
903
+ if (!params || !promises) {
904
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
905
+ }
906
+ const requestId = uuidv4();
907
+ if (params.editMode === editMode) {
908
+ return Promise.reject(
909
+ new Error("editMode parameter is currently already set to " + editMode)
910
+ );
911
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
912
+ return Promise.reject(
913
+ new Error(
914
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
915
+ )
899
916
  );
900
- return new Promise((resolve, reject) => {
901
- dashboardComponent.promises[requestId] = { resolve, reject };
902
- });
903
917
  }
904
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
918
+ iframe.contentWindow.postMessage(
919
+ {
920
+ action: "setEditMode",
921
+ editMode,
922
+ _version: dashboardComponent.libVersion,
923
+ requestId
924
+ },
925
+ "*"
926
+ );
927
+ return new Promise((resolve, reject) => {
928
+ promises[requestId] = { resolve, reject };
929
+ });
905
930
  };
906
931
 
907
932
  // libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
908
933
  var setPreview = (dashboardComponent, iframe, preview) => {
909
- if (iframe) {
910
- const requestId = uuidv4();
911
- iframe.contentWindow.postMessage(
912
- {
913
- action: "setPreview",
914
- preview,
915
- requestId,
916
- _version: dashboardComponent.libVersion
917
- },
918
- "*"
919
- );
920
- return new Promise((resolve, reject) => {
921
- dashboardComponent.promises[requestId] = { resolve, reject };
922
- setTimeout(() => {
923
- if (dashboardComponent.promises[requestId]) {
924
- const errorMessage = "setPreview request timed out.";
925
- dashboardComponent.promises[requestId].reject(
926
- new Error(errorMessage)
927
- );
928
- delete dashboardComponent.promises[requestId];
929
- }
930
- }, 2e3);
931
- });
934
+ if (!iframe?.contentWindow) {
935
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
932
936
  }
933
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
937
+ const { promises } = dashboardComponent;
938
+ if (!promises) {
939
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
940
+ }
941
+ const requestId = uuidv4();
942
+ iframe.contentWindow.postMessage(
943
+ {
944
+ action: "setPreview",
945
+ preview,
946
+ requestId,
947
+ _version: dashboardComponent.libVersion
948
+ },
949
+ "*"
950
+ );
951
+ return new Promise((resolve, reject) => {
952
+ promises[requestId] = { resolve, reject };
953
+ setTimeout(() => {
954
+ if (promises[requestId]) {
955
+ const errorMessage = "setPreview request timed out.";
956
+ promises[requestId].reject(new Error(errorMessage));
957
+ delete promises[requestId];
958
+ }
959
+ }, 2e3);
960
+ });
934
961
  };
935
962
 
936
963
  // libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
937
964
  var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
938
- if (iframe) {
939
- const requestId = uuidv4();
940
- iframe.contentWindow.postMessage(
941
- {
942
- action: "setSelectedData",
943
- itemId,
944
- filters,
945
- _version: dashboardComponent.libVersion,
946
- requestId
947
- },
948
- "*"
949
- );
950
- return new Promise((resolve, reject) => {
951
- dashboardComponent.promises[requestId] = { resolve, reject };
952
- setTimeout(() => {
953
- if (dashboardComponent.promises[requestId]) {
954
- const errorMessage = "setSelectedData request timed out.";
955
- dashboardComponent.promises[requestId].reject(
956
- new Error(errorMessage)
957
- );
958
- delete dashboardComponent.promises[requestId];
959
- }
960
- }, 2e3);
961
- });
965
+ if (!iframe?.contentWindow) {
966
+ return Promise.reject();
967
+ }
968
+ const { promises } = dashboardComponent;
969
+ if (!promises) {
970
+ return Promise.reject();
962
971
  }
963
- return Promise.reject();
972
+ const requestId = uuidv4();
973
+ iframe.contentWindow.postMessage(
974
+ {
975
+ action: "setSelectedData",
976
+ itemId,
977
+ filters,
978
+ _version: dashboardComponent.libVersion,
979
+ requestId
980
+ },
981
+ "*"
982
+ );
983
+ return new Promise((resolve, reject) => {
984
+ promises[requestId] = { resolve, reject };
985
+ setTimeout(() => {
986
+ if (promises[requestId]) {
987
+ const errorMessage = "setSelectedData request timed out.";
988
+ promises[requestId].reject(new Error(errorMessage));
989
+ delete promises[requestId];
990
+ }
991
+ }, 2e3);
992
+ });
964
993
  };
965
994
 
966
995
  // libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
@@ -1006,6 +1035,9 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1006
1035
  for (const key of dashboardDimensionKeys) {
1007
1036
  if (screenModes.includes(key)) {
1008
1037
  const screenMode = EXTENTS.find((extent) => extent.mode === key);
1038
+ if (!screenMode) {
1039
+ continue;
1040
+ }
1009
1041
  availableScreenModeExtents.push({
1010
1042
  ...screenMode,
1011
1043
  height: dashboardComponent.dimensions[key][1] || 50
@@ -1060,24 +1092,27 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1060
1092
  ),
1061
1093
  screenModeExtentMinWidth
1062
1094
  );
1063
- currentHeight = screenModeExtent.height;
1095
+ currentHeight = screenModeExtent.height ?? 0;
1064
1096
  }
1065
1097
  }
1066
1098
  }
1067
1099
  }
1068
1100
  } else {
1069
- const {
1070
- height: chosenModeHeight,
1071
- width: [chosenModeMinWidth, chosenModeMaxWidth]
1072
- } = availableScreenModeExtents.find(
1101
+ const chosenModeExtent = availableScreenModeExtents.find(
1073
1102
  (d) => d.mode === dashboardComponent.params.screenMode
1074
1103
  );
1075
- currentMode = dashboardComponent.params.screenMode;
1076
- currentWidth = Math.max(
1077
- Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1078
- chosenModeMinWidth
1079
- );
1080
- currentHeight = chosenModeHeight;
1104
+ if (chosenModeExtent) {
1105
+ const {
1106
+ height: chosenModeHeight,
1107
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
1108
+ } = chosenModeExtent;
1109
+ currentMode = dashboardComponent.params.screenMode;
1110
+ currentWidth = Math.max(
1111
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1112
+ chosenModeMinWidth
1113
+ );
1114
+ currentHeight = chosenModeHeight ?? 0;
1115
+ }
1081
1116
  if (dashboardComponent.params.itemEmbedding) {
1082
1117
  if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1083
1118
  currentWidth = Number.parseInt(
@@ -1097,7 +1132,7 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1097
1132
  const [lowestModeExtent] = availableScreenModeExtents;
1098
1133
  currentMode = lowestModeExtent.mode;
1099
1134
  currentWidth = lowestModeExtent.width[0];
1100
- currentHeight = lowestModeExtent.height;
1135
+ currentHeight = lowestModeExtent.height ?? 0;
1101
1136
  }
1102
1137
  }
1103
1138
  dashboardComponent.currentScreenMode = currentMode;
@@ -1159,6 +1194,9 @@ var _extendAndValidate = (dashboardContent) => {
1159
1194
  "fixed",
1160
1195
  "auto"
1161
1196
  ];
1197
+ if (!dashboardContent.params) {
1198
+ dashboardContent.params = {};
1199
+ }
1162
1200
  for (const key of defaultKeys) {
1163
1201
  if (dashboardContent.params[key] === null) {
1164
1202
  delete dashboardContent.params[key];
@@ -1226,17 +1264,20 @@ var _extendAndValidate = (dashboardContent) => {
1226
1264
  if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1227
1265
  dashboardContent.params.switchScreenModeOnResize = false;
1228
1266
  }
1229
- if (dashboardContent.params.itemDimensions.width !== "auto") {
1230
- dashboardContent.params.itemDimensions.width = Number.parseInt(
1231
- `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1232
- 10
1233
- ) || "auto";
1234
- }
1235
- if (dashboardContent.params.itemDimensions.height !== "auto") {
1236
- dashboardContent.params.itemDimensions.height = Number.parseInt(
1237
- `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1238
- 10
1239
- ) || "auto";
1267
+ const itemDimensions = dashboardContent.params.itemDimensions;
1268
+ if (itemDimensions) {
1269
+ if (itemDimensions.width !== "auto") {
1270
+ itemDimensions.width = Number.parseInt(
1271
+ `${itemDimensions.width}`.replace("px", ""),
1272
+ 10
1273
+ ) || "auto";
1274
+ }
1275
+ if (itemDimensions.height !== "auto") {
1276
+ itemDimensions.height = Number.parseInt(
1277
+ `${itemDimensions.height}`.replace("px", ""),
1278
+ 10
1279
+ ) || "auto";
1280
+ }
1240
1281
  }
1241
1282
  dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1242
1283
  if (dashboardContent.params.error || errorMessages.length > 0) {
@@ -1248,6 +1289,7 @@ var _extendAndValidate = (dashboardContent) => {
1248
1289
  var libraryTypeToWebComponentTypeMapping = {
1249
1290
  type: "type",
1250
1291
  slots: "slots",
1292
+ inlineData: "inline-data",
1251
1293
  options: "options",
1252
1294
  appServer: "app-server",
1253
1295
  apiHost: "api-host",
@@ -1378,7 +1420,7 @@ import { property, query, state } from "lit/decorators.js";
1378
1420
  import { styleMap } from "lit/directives/style-map.js";
1379
1421
 
1380
1422
  // libs/embed-libs/embed/package.json
1381
- var version = "8.0.0";
1423
+ var version = "8.1.0";
1382
1424
 
1383
1425
  // libs/embed-libs/embed/src/lib/utils/embed-error.utils.ts
1384
1426
  function buildEmbedErrorDetail(errorMsg) {
@@ -1797,8 +1839,8 @@ var LuzmoDashboard = class extends LitElement {
1797
1839
  this.browserNotSupported = [];
1798
1840
  this.libVersion = version + "-wc-luzmo";
1799
1841
  this.isLibraryLoaded = false;
1800
- this.currentAuthKey = null;
1801
- this.currentAuthToken = null;
1842
+ this.currentAuthKey = void 0;
1843
+ this.currentAuthToken = void 0;
1802
1844
  this.isInitCalled = false;
1803
1845
  this.attributesMap = {
1804
1846
  dashboardId: "dashboard-id",
@@ -1936,6 +1978,9 @@ var LuzmoDashboard = class extends LitElement {
1936
1978
  this.dashboardErrorMsg = "";
1937
1979
  const appServer = this.params.appServer;
1938
1980
  const libraryLoadId = ++this._webComponentLibraryLoadId;
1981
+ if (!appServer) {
1982
+ return;
1983
+ }
1939
1984
  loadLibrary(appServer, dashboardRemote).then(async () => {
1940
1985
  if (libraryLoadId !== this._webComponentLibraryLoadId || !this.isWebComponentViewMode() || this.params.appServer !== appServer) {
1941
1986
  return;
@@ -2392,8 +2437,9 @@ var LuzmoDashboard = class extends LitElement {
2392
2437
  }
2393
2438
  // Public methods
2394
2439
  getData(itemId) {
2395
- if (this.isWebComponentViewMode() && this.dashboardReference) {
2396
- return Promise.resolve().then(() => this.dashboardReference.getData(itemId));
2440
+ const dashboardReference = this.dashboardReference;
2441
+ if (this.isWebComponentViewMode() && dashboardReference) {
2442
+ return Promise.resolve().then(() => dashboardReference.getData(itemId));
2397
2443
  }
2398
2444
  if (!this.isWebComponentViewMode()) {
2399
2445
  return getData(this, this.iframe, itemId);
@@ -2478,6 +2524,9 @@ var LuzmoDashboard = class extends LitElement {
2478
2524
  return getAccessibleDashboards(this);
2479
2525
  }
2480
2526
  addFilters(itemId, filters) {
2527
+ if (!this.dashboardReference) {
2528
+ return Promise.reject();
2529
+ }
2481
2530
  return this.dashboardReference.addFilters(itemId, filters);
2482
2531
  }
2483
2532
  setEditMode(editMode) {
@@ -2490,7 +2539,7 @@ var LuzmoDashboard = class extends LitElement {
2490
2539
  editMode
2491
2540
  });
2492
2541
  }
2493
- if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
2542
+ if (this.dashboardReference && editMode && ["editFull", "editLimited"].includes(editMode)) {
2494
2543
  this.editMode = editMode;
2495
2544
  this.params.editMode = editMode;
2496
2545
  this.initComponent();
@@ -2499,7 +2548,7 @@ var LuzmoDashboard = class extends LitElement {
2499
2548
  editMode
2500
2549
  });
2501
2550
  }
2502
- if (this.isWebComponentViewMode() && this.dashboardReference) {
2551
+ if (this.isWebComponentViewMode() && this.dashboardReference && editMode) {
2503
2552
  return this.dashboardReference.setEditMode(editMode);
2504
2553
  }
2505
2554
  if (!this.isWebComponentViewMode()) {
@@ -2514,7 +2563,7 @@ var LuzmoDashboard = class extends LitElement {
2514
2563
  return setPreview(this, this.iframe, preview);
2515
2564
  }
2516
2565
  sendExportEmail(type, subject, message) {
2517
- if (this.isWebComponentViewMode() && this.dashboardReference) {
2566
+ if (this.isWebComponentViewMode() && this.dashboardReference && type) {
2518
2567
  return this.dashboardReference.sendExportEmail(type, subject, message);
2519
2568
  } else if (!this.isWebComponentViewMode()) {
2520
2569
  return sendExportEmail(this, this.iframe, type, subject, message);
@@ -2771,6 +2820,7 @@ var LuzmoBaseVizItem = class extends LitElement2 {
2771
2820
  id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
2772
2821
  type: this.type,
2773
2822
  slots,
2823
+ inlineData: this.inlineData,
2774
2824
  options: this.options,
2775
2825
  filters: typeof this.chartElement?.getContextFilters === "function" ? this.chartElement.getContextFilters() : typeof this.chartElement?.getFilters === "function" ? this.getFilters() : [],
2776
2826
  datasetIds: collectVizItemDatasetIds(slots)
@@ -2833,18 +2883,31 @@ var LuzmoBaseVizItem = class extends LitElement2 {
2833
2883
  });
2834
2884
  this.chartElement.addEventListener("changedFilters", (payload) => {
2835
2885
  this.dispatchEvent(new CustomEvent("changedFilters", payload));
2836
- this.dispatchEvent(new CustomEvent("contextChanged", {
2837
- detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
2838
- }));
2886
+ this.dispatchEvent(
2887
+ new CustomEvent("contextChanged", {
2888
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
2889
+ })
2890
+ );
2839
2891
  });
2840
- this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
2841
- this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
2892
+ this.chartElement.addEventListener(
2893
+ "exported",
2894
+ (payload) => this.dispatchEvent(new CustomEvent("exported", payload))
2895
+ );
2896
+ this.chartElement.addEventListener(
2897
+ "customEvent",
2898
+ (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload))
2899
+ );
2842
2900
  this.chartElement.addEventListener("error", (event) => {
2843
- this.dispatchEvent(new CustomEvent("error", {
2844
- detail: normalizeEmbedErrorDetail(event.detail)
2845
- }));
2901
+ this.dispatchEvent(
2902
+ new CustomEvent("error", {
2903
+ detail: normalizeEmbedErrorDetail(event.detail)
2904
+ })
2905
+ );
2846
2906
  });
2847
- this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
2907
+ this.chartElement.addEventListener(
2908
+ "authorizationExpired",
2909
+ (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload))
2910
+ );
2848
2911
  this.updateVizItemProperties();
2849
2912
  this.renderRoot.append(this.chartElement);
2850
2913
  }
@@ -2867,8 +2930,21 @@ var LuzmoBaseVizItem = class extends LitElement2 {
2867
2930
  if (this.chartElement) {
2868
2931
  for (const [propertyName] of changedProperties.entries()) {
2869
2932
  const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
2870
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
2871
- this.chartElement.setAttribute(mappedAttributeName, attributeValue);
2933
+ const value = this[propertyName];
2934
+ if (propertyName === "inlineData" && (value === void 0 || value === null)) {
2935
+ this.inlineData = void 0;
2936
+ this.chartElement.removeAttribute(mappedAttributeName);
2937
+ } else {
2938
+ const attributeValue = typeof value === "object" ? JSON.stringify(value) : value?.toString() ?? value;
2939
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
2940
+ }
2941
+ }
2942
+ if (["inlineData", "options", "slots"].some((propertyName) => changedProperties.has(propertyName))) {
2943
+ this.dispatchEvent(
2944
+ new CustomEvent("contextChanged", {
2945
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
2946
+ })
2947
+ );
2872
2948
  }
2873
2949
  } else {
2874
2950
  if (this.canInitializeVizItem()) {
@@ -2878,7 +2954,7 @@ var LuzmoBaseVizItem = class extends LitElement2 {
2878
2954
  }
2879
2955
  }
2880
2956
  render() {
2881
- return html2` `;
2957
+ return html2``;
2882
2958
  }
2883
2959
  };
2884
2960
  __decorateClass([
@@ -2890,6 +2966,9 @@ __decorateClass([
2890
2966
  __decorateClass([
2891
2967
  property2({ type: Array })
2892
2968
  ], LuzmoBaseVizItem.prototype, "slots", 2);
2969
+ __decorateClass([
2970
+ property2({ type: Object })
2971
+ ], LuzmoBaseVizItem.prototype, "inlineData", 2);
2893
2972
  __decorateClass([
2894
2973
  property2({ type: Object })
2895
2974
  ], LuzmoBaseVizItem.prototype, "options", 2);
@@ -2911,6 +2990,9 @@ __decorateClass([
2911
2990
  __decorateClass([
2912
2991
  property2({
2913
2992
  converter: (value) => {
2993
+ if (value == null) {
2994
+ return value;
2995
+ }
2914
2996
  try {
2915
2997
  return JSON.parse(value);
2916
2998
  } catch {