@luzmo/embed 8.0.0-es2021 → 8.1.0-es2021

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.
@@ -408,41 +408,46 @@ var createIframeUrl = (dashboardContent) => {
408
408
  // libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
409
409
  var getLoader = (dashboardComponent) => {
410
410
  let errorMsg;
411
- if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
412
- dashboardComponent.params.error = true;
411
+ if (dashboardComponent.params?.error || (dashboardComponent.browserNotSupported?.length ?? 0) > 0) {
412
+ if (dashboardComponent.params) {
413
+ dashboardComponent.params.error = true;
414
+ }
413
415
  if (dashboardComponent.browserNotSupported) {
414
416
  errorMsg = "Browser is not supported.";
415
417
  }
416
418
  }
417
- const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
418
- return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
419
+ const language = dashboardComponent.params?.language;
420
+ const loadingMsg = (language ? translations_default.initializing[language] : void 0) || translations_default.initializing.en;
421
+ return dashboardComponent.browserNotSupported || dashboardComponent.params?.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
419
422
  };
420
423
 
421
424
  // libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
422
425
  function resolvePromise(dashboardComponent, requestId, data) {
423
- if (dashboardComponent.promises[requestId]) {
424
- dashboardComponent.promises[requestId].resolve(data);
425
- delete dashboardComponent.promises[requestId];
426
+ const promises = dashboardComponent.promises;
427
+ if (promises?.[requestId]) {
428
+ promises[requestId].resolve(data);
429
+ delete promises[requestId];
426
430
  }
427
431
  }
428
432
  function rejectPromise(dashboardComponent, requestId, data) {
429
- if (dashboardComponent.promises[requestId]) {
430
- dashboardComponent.promises[requestId].reject(data);
431
- delete dashboardComponent.promises[requestId];
433
+ const promises = dashboardComponent.promises;
434
+ if (promises?.[requestId]) {
435
+ promises[requestId].reject(data);
436
+ delete promises[requestId];
432
437
  }
433
438
  }
434
439
 
435
440
  // libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
436
441
  function containerStyles(dashboardComponent) {
437
442
  const styles = {};
438
- if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
443
+ if (dashboardComponent.params?.loaderBackground && !dashboardComponent.iframeLoaded) {
439
444
  styles.background = dashboardComponent.params.loaderBackground;
440
445
  }
441
446
  return styles;
442
447
  }
443
448
  function containerLoaderStyles(dashboardComponent) {
444
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
445
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
449
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
450
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
446
451
  const display = dashboardComponent.iframeLoaded ? "none" : "";
447
452
  return {
448
453
  display,
@@ -450,8 +455,8 @@ function containerLoaderStyles(dashboardComponent) {
450
455
  };
451
456
  }
452
457
  function loaderStyles(dashboardComponent) {
453
- const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
454
- if (dashboardComponent.params.itemEmbedding) {
458
+ const background = dashboardComponent.params?.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
459
+ if (dashboardComponent.params?.itemEmbedding) {
455
460
  dashboardComponent.loaderSize = 24;
456
461
  dashboardComponent.borderWidth = 4;
457
462
  dashboardComponent.minHeight = 200;
@@ -480,11 +485,11 @@ function plStyles(dashboardComponent) {
480
485
  } = DEFAULT_PARAMETERS;
481
486
  const spinnerColorBorder = generateBorderStyle(
482
487
  dashboardComponent.borderWidth,
483
- dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
488
+ dashboardComponent.params?.loaderSpinnerColor || defaultSpinnerColor
484
489
  );
485
490
  const spinnerBackgroundBorder = generateBorderStyle(
486
491
  dashboardComponent.borderWidth,
487
- dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
492
+ dashboardComponent.params?.loaderSpinnerBackground || defaultSpinnerBackground
488
493
  );
489
494
  const size = `${dashboardComponent.loaderSize}px`;
490
495
  return {
@@ -497,27 +502,28 @@ function plStyles(dashboardComponent) {
497
502
  };
498
503
  }
499
504
  function lcStyles(dashboardComponent) {
500
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
501
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
502
- const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
503
- const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
505
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
506
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
507
+ const getPaddingStr = (value) => `${((value ?? Number.NaN) - (dashboardComponent.loaderSize ?? Number.NaN) - 32) / 2}px`;
508
+ const verticalPadding = dashboardComponent.params?.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
504
509
  return {
505
510
  padding: `${verticalPadding} 16px`
506
511
  };
507
512
  }
508
513
  function calculateIframeStyles(dashboardComponent) {
509
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
510
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
511
- if (dashboardComponent.params.itemEmbedding && height !== "auto") {
514
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
515
+ const width = dashboardComponent.params?.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
516
+ const editMode = dashboardComponent.params?.editMode;
517
+ if (dashboardComponent.params?.itemEmbedding && height !== "auto") {
512
518
  dashboardComponent.iframeHeight = `${height}px`;
513
- } else if (dashboardComponent.params.itemEmbedding) {
519
+ } else if (dashboardComponent.params?.itemEmbedding) {
514
520
  dashboardComponent.iframeHeight = "200px";
515
- } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
521
+ } else if (editMode != null && ["editFull", "editLimited"].includes(editMode)) {
516
522
  dashboardComponent.iframeHeight = "100%";
517
523
  } else {
518
524
  dashboardComponent.iframeHeight = "400px";
519
525
  }
520
- dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
526
+ dashboardComponent.iframeWidth = dashboardComponent.params?.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
521
527
  const styles = {
522
528
  height: dashboardComponent.iframeHeight,
523
529
  width: dashboardComponent.iframeWidth
@@ -536,7 +542,7 @@ function calculateIframeStyles(dashboardComponent) {
536
542
 
537
543
  // libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
538
544
  var updateIframeUrl = (iframe, iframeUrl) => {
539
- if (iframe?.contentWindow) {
545
+ if (iframe?.contentWindow && iframeUrl !== void 0) {
540
546
  iframe.contentWindow.location.replace(iframeUrl);
541
547
  }
542
548
  };
@@ -545,7 +551,7 @@ var updateIframeUrl = (iframe, iframeUrl) => {
545
551
  var selectedDataUtils = {
546
552
  merge(...filters) {
547
553
  return filters.reduce((acc, filter) => {
548
- acc.and.push(...filter.and);
554
+ (acc.and ??= []).push(...filter.and ?? []);
549
555
  return acc;
550
556
  }, {
551
557
  and: []
@@ -608,43 +614,46 @@ var selectedDataUtils = {
608
614
  // libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
609
615
  var exportDashboard = (dashboardComponent, iframe, format) => {
610
616
  const requestId = uuidv4();
611
- if (iframe?.contentWindow) {
612
- iframe.contentWindow.postMessage(
613
- {
614
- action: "exportDashboard",
615
- format: format || "png",
616
- _version: dashboardComponent.libVersion,
617
- requestId
618
- },
619
- "*"
620
- );
621
- return new Promise((resolve, reject) => {
622
- dashboardComponent.promises[requestId] = { resolve, reject };
623
- setTimeout(() => {
624
- if (dashboardComponent.promises[requestId]) {
625
- const errorMessage = "exportDashboard request timed out.";
626
- dashboardComponent.promises[requestId].reject(
627
- new Error(errorMessage)
628
- );
629
- delete dashboardComponent.promises[requestId];
630
- }
631
- }, 12e5);
632
- });
617
+ if (!iframe?.contentWindow) {
618
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
633
619
  }
634
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
620
+ const { promises } = dashboardComponent;
621
+ if (!promises) {
622
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
623
+ }
624
+ iframe.contentWindow.postMessage(
625
+ {
626
+ action: "exportDashboard",
627
+ format: format || "png",
628
+ _version: dashboardComponent.libVersion,
629
+ requestId
630
+ },
631
+ "*"
632
+ );
633
+ return new Promise((resolve, reject) => {
634
+ promises[requestId] = { resolve, reject };
635
+ setTimeout(() => {
636
+ if (promises[requestId]) {
637
+ const errorMessage = "exportDashboard request timed out.";
638
+ promises[requestId].reject(new Error(errorMessage));
639
+ delete promises[requestId];
640
+ }
641
+ }, 12e5);
642
+ });
635
643
  };
636
644
 
637
645
  // libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
638
646
  var getAccessibleDashboards = async (dashboardComponent) => {
639
647
  await dashboardComponent.updateComplete;
640
- if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
648
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken) && dashboardComponent.params) {
649
+ const { params } = dashboardComponent;
641
650
  const fetchUser = new Promise((resolve, reject) => {
642
651
  void (() => {
643
652
  try {
644
653
  const responsePromise = window.fetch(
645
654
  // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
646
655
  // Fixes incorrect url with embedMode="webComponent"
647
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
656
+ `${addTrailingSlash(params.apiHost)}0.1.0/authorization`,
648
657
  {
649
658
  method: "POST",
650
659
  mode: "cors",
@@ -689,136 +698,144 @@ var getAccessibleDashboards = async (dashboardComponent) => {
689
698
  }
690
699
  })();
691
700
  });
692
- return new Promise((resolve, reject) => void (() => {
693
- try {
694
- fetchUser.then((authorizationData) => {
695
- const responsePromise = window.fetch(
696
- // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
697
- // Fixes incorrect url with embedMode="webComponent"
698
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
699
- {
700
- method: "POST",
701
- mode: "cors",
702
- cache: "no-cache",
703
- headers: { "Content-Type": "application/json" },
704
- redirect: "follow",
705
- body: JSON.stringify({
706
- action: "get",
707
- version: "0.1.0",
708
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
709
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
710
- find: {
711
- where: { type: "dashboard", is_variant: false },
712
- attributes: ["id", "name", "modified_at"],
713
- order: [["modified_at", "desc"]],
714
- include: [
715
- { model: "Tag", attributes: ["tag"] },
716
- { model: "User", attributes: ["id", "name"] },
717
- {
718
- model: "Group",
719
- attributes: ["id", "name", "public"]
720
- },
721
- { model: "Integration", attributes: ["id", "name"] }
722
- ]
723
- }
724
- })
725
- }
726
- );
727
- responsePromise.then((response) => response.json()).then((data) => {
728
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
729
- data.rows,
730
- authorizationData.integrationId,
731
- authorizationData.user,
732
- dashboardComponent
733
- ) : [];
734
- resolve(dashboardList);
701
+ return new Promise((resolve, reject) => {
702
+ void (() => {
703
+ try {
704
+ fetchUser.then((authorizationData) => {
705
+ const responsePromise = window.fetch(
706
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
707
+ // Fixes incorrect url with embedMode="webComponent"
708
+ `${addTrailingSlash(params.apiHost)}0.1.0/securable`,
709
+ {
710
+ method: "POST",
711
+ mode: "cors",
712
+ cache: "no-cache",
713
+ headers: { "Content-Type": "application/json" },
714
+ redirect: "follow",
715
+ body: JSON.stringify({
716
+ action: "get",
717
+ version: "0.1.0",
718
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
719
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
720
+ find: {
721
+ where: { type: "dashboard", is_variant: false },
722
+ attributes: ["id", "name", "modified_at"],
723
+ order: [["modified_at", "desc"]],
724
+ include: [
725
+ { model: "Tag", attributes: ["tag"] },
726
+ { model: "User", attributes: ["id", "name"] },
727
+ {
728
+ model: "Group",
729
+ attributes: ["id", "name", "public"]
730
+ },
731
+ { model: "Integration", attributes: ["id", "name"] }
732
+ ]
733
+ }
734
+ })
735
+ }
736
+ );
737
+ responsePromise.then((response) => response.json()).then((data) => {
738
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
739
+ data.rows,
740
+ authorizationData.integrationId,
741
+ authorizationData.user,
742
+ dashboardComponent
743
+ ) : [];
744
+ resolve(dashboardList);
745
+ });
746
+ }).catch((error3) => {
747
+ reject(error3);
735
748
  });
736
- }).catch((error3) => {
749
+ } catch (error3) {
737
750
  reject(error3);
738
- });
739
- } catch (error3) {
740
- reject(error3);
741
- }
742
- })());
751
+ }
752
+ })();
753
+ });
743
754
  }
744
755
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
745
756
  };
746
757
 
747
758
  // libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
748
759
  var getDashboardContext = (dashboardComponent, iframe) => {
749
- if (iframe?.contentWindow) {
750
- const requestId = uuidv4();
751
- iframe.contentWindow.postMessage(
752
- { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
753
- "*"
754
- );
755
- return new Promise((resolve, reject) => {
756
- dashboardComponent.promises[requestId] = { resolve, reject };
757
- setTimeout(() => {
758
- if (dashboardComponent.promises[requestId]) {
759
- const errorMessage = "getDashboardContext request timed out.";
760
- dashboardComponent.promises[requestId].reject(
761
- new Error(errorMessage)
762
- );
763
- delete dashboardComponent.promises[requestId];
764
- }
765
- }, 2e3);
766
- });
760
+ if (!iframe?.contentWindow) {
761
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
767
762
  }
768
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
763
+ const { promises } = dashboardComponent;
764
+ if (!promises) {
765
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
766
+ }
767
+ const requestId = uuidv4();
768
+ iframe.contentWindow.postMessage(
769
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
770
+ "*"
771
+ );
772
+ return new Promise((resolve, reject) => {
773
+ promises[requestId] = { resolve, reject };
774
+ setTimeout(() => {
775
+ if (promises[requestId]) {
776
+ const errorMessage = "getDashboardContext request timed out.";
777
+ promises[requestId].reject(new Error(errorMessage));
778
+ delete promises[requestId];
779
+ }
780
+ }, 2e3);
781
+ });
769
782
  };
770
783
 
771
784
  // libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
772
785
  var getData = (dashboardComponent, iframe, itemId) => {
773
- if (iframe?.contentWindow) {
774
- const requestId = uuidv4();
775
- iframe.contentWindow.postMessage(
776
- {
777
- action: "getData",
778
- id: itemId,
779
- _version: dashboardComponent.libVersion,
780
- requestId
781
- },
782
- "*"
783
- );
784
- return new Promise((resolve, reject) => {
785
- dashboardComponent.promises[requestId] = { resolve, reject };
786
- setTimeout(() => {
787
- if (dashboardComponent.promises[requestId]) {
788
- const errorMessage = "getData request timed out.";
789
- dashboardComponent.promises[requestId].reject(
790
- new Error(errorMessage)
791
- );
792
- delete dashboardComponent.promises[requestId];
793
- }
794
- }, 2e3);
795
- });
786
+ if (!iframe?.contentWindow) {
787
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
796
788
  }
797
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
789
+ const { promises } = dashboardComponent;
790
+ if (!promises) {
791
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
792
+ }
793
+ const requestId = uuidv4();
794
+ iframe.contentWindow.postMessage(
795
+ {
796
+ action: "getData",
797
+ id: itemId,
798
+ _version: dashboardComponent.libVersion,
799
+ requestId
800
+ },
801
+ "*"
802
+ );
803
+ return new Promise((resolve, reject) => {
804
+ promises[requestId] = { resolve, reject };
805
+ setTimeout(() => {
806
+ if (promises[requestId]) {
807
+ const errorMessage = "getData request timed out.";
808
+ promises[requestId].reject(new Error(errorMessage));
809
+ delete promises[requestId];
810
+ }
811
+ }, 2e3);
812
+ });
798
813
  };
799
814
 
800
815
  // libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
801
816
  var getFilters = (dashboardComponent, iframe) => {
802
- if (iframe?.contentWindow) {
803
- const requestId = uuidv4();
804
- iframe.contentWindow.postMessage(
805
- { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
806
- "*"
807
- );
808
- return new Promise((resolve, reject) => {
809
- dashboardComponent.promises[requestId] = { resolve, reject };
810
- setTimeout(() => {
811
- if (dashboardComponent.promises[requestId]) {
812
- const errorMessage = "getFilters request timed out.";
813
- dashboardComponent.promises[requestId].reject(
814
- new Error(errorMessage)
815
- );
816
- delete dashboardComponent.promises[requestId];
817
- }
818
- }, 2e3);
819
- });
817
+ if (!iframe?.contentWindow) {
818
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
820
819
  }
821
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
820
+ const { promises } = dashboardComponent;
821
+ if (!promises) {
822
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
823
+ }
824
+ const requestId = uuidv4();
825
+ iframe.contentWindow.postMessage(
826
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
827
+ "*"
828
+ );
829
+ return new Promise((resolve, reject) => {
830
+ promises[requestId] = { resolve, reject };
831
+ setTimeout(() => {
832
+ if (promises[requestId]) {
833
+ const errorMessage = "getFilters request timed out.";
834
+ promises[requestId].reject(new Error(errorMessage));
835
+ delete promises[requestId];
836
+ }
837
+ }, 2e3);
838
+ });
822
839
  };
823
840
 
824
841
  // libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
@@ -826,6 +843,10 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
826
843
  if (!iframe?.contentWindow) {
827
844
  return Promise.reject(new Error("Cannot retrieve contentWindow."));
828
845
  }
846
+ const { promises } = dashboardComponent;
847
+ if (!promises) {
848
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
849
+ }
829
850
  const requestId = uuidv4();
830
851
  iframe.contentWindow.postMessage(
831
852
  {
@@ -837,11 +858,11 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
837
858
  "*"
838
859
  );
839
860
  return new Promise((resolve, reject) => {
840
- dashboardComponent.promises[requestId] = { resolve, reject };
861
+ promises[requestId] = { resolve, reject };
841
862
  setTimeout(() => {
842
- if (dashboardComponent.promises[requestId]) {
843
- dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
844
- delete dashboardComponent.promises[requestId];
863
+ if (promises[requestId]) {
864
+ promises[requestId].reject(new Error("getInsights request timed out."));
865
+ delete promises[requestId];
845
866
  }
846
867
  }, 6e4);
847
868
  });
@@ -849,7 +870,7 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
849
870
 
850
871
  // libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
851
872
  var refreshData = (dashboardComponent, iframe, itemId) => {
852
- if (iframe) {
873
+ if (iframe?.contentWindow) {
853
874
  iframe.contentWindow.postMessage(
854
875
  {
855
876
  action: "refreshData",
@@ -865,7 +886,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
865
886
 
866
887
  // libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
867
888
  var reloadDashboard = (dashboardComponent, iframe) => {
868
- if (iframe) {
889
+ if (iframe?.contentWindow) {
869
890
  iframe.contentWindow.postMessage(
870
891
  { action: "reloadDashboard", _version: dashboardComponent.libVersion },
871
892
  "*"
@@ -877,7 +898,7 @@ var reloadDashboard = (dashboardComponent, iframe) => {
877
898
 
878
899
  // libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
879
900
  var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
880
- if (iframe) {
901
+ if (iframe?.contentWindow) {
881
902
  iframe.contentWindow.postMessage(
882
903
  {
883
904
  action: "sendExportEmail",
@@ -895,7 +916,7 @@ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
895
916
 
896
917
  // libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
897
918
  var setAuthorization = (dashboardComponent, iframe, key, token) => {
898
- if (iframe) {
919
+ if (iframe?.contentWindow) {
899
920
  iframe.contentWindow.postMessage(
900
921
  {
901
922
  action: "setAuthorization",
@@ -912,92 +933,100 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
912
933
 
913
934
  // libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
914
935
  var setEditMode = (dashboardComponent, iframe, editMode) => {
915
- if (iframe && iframe.contentWindow) {
916
- const requestId = uuidv4();
917
- if (dashboardComponent.params.editMode === editMode) {
918
- return Promise.reject(
919
- new Error("editMode parameter is currently already set to " + editMode)
920
- );
921
- } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
922
- return Promise.reject(
923
- new Error(
924
- "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
925
- )
926
- );
927
- }
928
- iframe.contentWindow.postMessage(
929
- {
930
- action: "setEditMode",
931
- editMode,
932
- _version: dashboardComponent.libVersion,
933
- requestId
934
- },
935
- "*"
936
+ if (!iframe?.contentWindow) {
937
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
938
+ }
939
+ const { params, promises } = dashboardComponent;
940
+ if (!params || !promises) {
941
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
942
+ }
943
+ const requestId = uuidv4();
944
+ if (params.editMode === editMode) {
945
+ return Promise.reject(
946
+ new Error("editMode parameter is currently already set to " + editMode)
947
+ );
948
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
949
+ return Promise.reject(
950
+ new Error(
951
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
952
+ )
936
953
  );
937
- return new Promise((resolve, reject) => {
938
- dashboardComponent.promises[requestId] = { resolve, reject };
939
- });
940
954
  }
941
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
955
+ iframe.contentWindow.postMessage(
956
+ {
957
+ action: "setEditMode",
958
+ editMode,
959
+ _version: dashboardComponent.libVersion,
960
+ requestId
961
+ },
962
+ "*"
963
+ );
964
+ return new Promise((resolve, reject) => {
965
+ promises[requestId] = { resolve, reject };
966
+ });
942
967
  };
943
968
 
944
969
  // libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
945
970
  var setPreview = (dashboardComponent, iframe, preview) => {
946
- if (iframe) {
947
- const requestId = uuidv4();
948
- iframe.contentWindow.postMessage(
949
- {
950
- action: "setPreview",
951
- preview,
952
- requestId,
953
- _version: dashboardComponent.libVersion
954
- },
955
- "*"
956
- );
957
- return new Promise((resolve, reject) => {
958
- dashboardComponent.promises[requestId] = { resolve, reject };
959
- setTimeout(() => {
960
- if (dashboardComponent.promises[requestId]) {
961
- const errorMessage = "setPreview request timed out.";
962
- dashboardComponent.promises[requestId].reject(
963
- new Error(errorMessage)
964
- );
965
- delete dashboardComponent.promises[requestId];
966
- }
967
- }, 2e3);
968
- });
971
+ if (!iframe?.contentWindow) {
972
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
969
973
  }
970
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
974
+ const { promises } = dashboardComponent;
975
+ if (!promises) {
976
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
977
+ }
978
+ const requestId = uuidv4();
979
+ iframe.contentWindow.postMessage(
980
+ {
981
+ action: "setPreview",
982
+ preview,
983
+ requestId,
984
+ _version: dashboardComponent.libVersion
985
+ },
986
+ "*"
987
+ );
988
+ return new Promise((resolve, reject) => {
989
+ promises[requestId] = { resolve, reject };
990
+ setTimeout(() => {
991
+ if (promises[requestId]) {
992
+ const errorMessage = "setPreview request timed out.";
993
+ promises[requestId].reject(new Error(errorMessage));
994
+ delete promises[requestId];
995
+ }
996
+ }, 2e3);
997
+ });
971
998
  };
972
999
 
973
1000
  // libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
974
1001
  var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
975
- if (iframe) {
976
- const requestId = uuidv4();
977
- iframe.contentWindow.postMessage(
978
- {
979
- action: "setSelectedData",
980
- itemId,
981
- filters,
982
- _version: dashboardComponent.libVersion,
983
- requestId
984
- },
985
- "*"
986
- );
987
- return new Promise((resolve, reject) => {
988
- dashboardComponent.promises[requestId] = { resolve, reject };
989
- setTimeout(() => {
990
- if (dashboardComponent.promises[requestId]) {
991
- const errorMessage = "setSelectedData request timed out.";
992
- dashboardComponent.promises[requestId].reject(
993
- new Error(errorMessage)
994
- );
995
- delete dashboardComponent.promises[requestId];
996
- }
997
- }, 2e3);
998
- });
1002
+ if (!iframe?.contentWindow) {
1003
+ return Promise.reject();
1004
+ }
1005
+ const { promises } = dashboardComponent;
1006
+ if (!promises) {
1007
+ return Promise.reject();
999
1008
  }
1000
- return Promise.reject();
1009
+ const requestId = uuidv4();
1010
+ iframe.contentWindow.postMessage(
1011
+ {
1012
+ action: "setSelectedData",
1013
+ itemId,
1014
+ filters,
1015
+ _version: dashboardComponent.libVersion,
1016
+ requestId
1017
+ },
1018
+ "*"
1019
+ );
1020
+ return new Promise((resolve, reject) => {
1021
+ promises[requestId] = { resolve, reject };
1022
+ setTimeout(() => {
1023
+ if (promises[requestId]) {
1024
+ const errorMessage = "setSelectedData request timed out.";
1025
+ promises[requestId].reject(new Error(errorMessage));
1026
+ delete promises[requestId];
1027
+ }
1028
+ }, 2e3);
1029
+ });
1001
1030
  };
1002
1031
 
1003
1032
  // libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
@@ -1043,6 +1072,9 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1043
1072
  for (const key of dashboardDimensionKeys) {
1044
1073
  if (screenModes.includes(key)) {
1045
1074
  const screenMode = EXTENTS.find((extent) => extent.mode === key);
1075
+ if (!screenMode) {
1076
+ continue;
1077
+ }
1046
1078
  availableScreenModeExtents.push({
1047
1079
  ...screenMode,
1048
1080
  height: dashboardComponent.dimensions[key][1] || 50
@@ -1097,24 +1129,27 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1097
1129
  ),
1098
1130
  screenModeExtentMinWidth
1099
1131
  );
1100
- currentHeight = screenModeExtent.height;
1132
+ currentHeight = screenModeExtent.height ?? 0;
1101
1133
  }
1102
1134
  }
1103
1135
  }
1104
1136
  }
1105
1137
  } else {
1106
- const {
1107
- height: chosenModeHeight,
1108
- width: [chosenModeMinWidth, chosenModeMaxWidth]
1109
- } = availableScreenModeExtents.find(
1138
+ const chosenModeExtent = availableScreenModeExtents.find(
1110
1139
  (d3) => d3.mode === dashboardComponent.params.screenMode
1111
1140
  );
1112
- currentMode = dashboardComponent.params.screenMode;
1113
- currentWidth = Math.max(
1114
- Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1115
- chosenModeMinWidth
1116
- );
1117
- currentHeight = chosenModeHeight;
1141
+ if (chosenModeExtent) {
1142
+ const {
1143
+ height: chosenModeHeight,
1144
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
1145
+ } = chosenModeExtent;
1146
+ currentMode = dashboardComponent.params.screenMode;
1147
+ currentWidth = Math.max(
1148
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1149
+ chosenModeMinWidth
1150
+ );
1151
+ currentHeight = chosenModeHeight ?? 0;
1152
+ }
1118
1153
  if (dashboardComponent.params.itemEmbedding) {
1119
1154
  if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1120
1155
  currentWidth = Number.parseInt(
@@ -1134,7 +1169,7 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1134
1169
  const [lowestModeExtent] = availableScreenModeExtents;
1135
1170
  currentMode = lowestModeExtent.mode;
1136
1171
  currentWidth = lowestModeExtent.width[0];
1137
- currentHeight = lowestModeExtent.height;
1172
+ currentHeight = lowestModeExtent.height ?? 0;
1138
1173
  }
1139
1174
  }
1140
1175
  dashboardComponent.currentScreenMode = currentMode;
@@ -1196,6 +1231,9 @@ var _extendAndValidate = (dashboardContent) => {
1196
1231
  "fixed",
1197
1232
  "auto"
1198
1233
  ];
1234
+ if (!dashboardContent.params) {
1235
+ dashboardContent.params = {};
1236
+ }
1199
1237
  for (const key of defaultKeys) {
1200
1238
  if (dashboardContent.params[key] === null) {
1201
1239
  delete dashboardContent.params[key];
@@ -1263,17 +1301,20 @@ var _extendAndValidate = (dashboardContent) => {
1263
1301
  if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1264
1302
  dashboardContent.params.switchScreenModeOnResize = false;
1265
1303
  }
1266
- if (dashboardContent.params.itemDimensions.width !== "auto") {
1267
- dashboardContent.params.itemDimensions.width = Number.parseInt(
1268
- `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1269
- 10
1270
- ) || "auto";
1271
- }
1272
- if (dashboardContent.params.itemDimensions.height !== "auto") {
1273
- dashboardContent.params.itemDimensions.height = Number.parseInt(
1274
- `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1275
- 10
1276
- ) || "auto";
1304
+ const itemDimensions = dashboardContent.params.itemDimensions;
1305
+ if (itemDimensions) {
1306
+ if (itemDimensions.width !== "auto") {
1307
+ itemDimensions.width = Number.parseInt(
1308
+ `${itemDimensions.width}`.replace("px", ""),
1309
+ 10
1310
+ ) || "auto";
1311
+ }
1312
+ if (itemDimensions.height !== "auto") {
1313
+ itemDimensions.height = Number.parseInt(
1314
+ `${itemDimensions.height}`.replace("px", ""),
1315
+ 10
1316
+ ) || "auto";
1317
+ }
1277
1318
  }
1278
1319
  dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1279
1320
  if (dashboardContent.params.error || errorMessages.length > 0) {
@@ -1285,6 +1326,7 @@ var _extendAndValidate = (dashboardContent) => {
1285
1326
  var libraryTypeToWebComponentTypeMapping = {
1286
1327
  type: "type",
1287
1328
  slots: "slots",
1329
+ inlineData: "inline-data",
1288
1330
  options: "options",
1289
1331
  appServer: "app-server",
1290
1332
  apiHost: "api-host",
@@ -6118,7 +6160,7 @@ var o6 = e6(class extends i5 {
6118
6160
  });
6119
6161
 
6120
6162
  // libs/embed-libs/embed/package.json
6121
- var version = "8.0.0";
6163
+ var version = "8.1.0";
6122
6164
 
6123
6165
  // libs/embed-libs/embed/src/lib/utils/embed-error.utils.ts
6124
6166
  function buildEmbedErrorDetail(errorMsg) {
@@ -6536,8 +6578,8 @@ var LuzmoDashboard = class extends i4 {
6536
6578
  this.browserNotSupported = [];
6537
6579
  this.libVersion = version + "-wc-luzmo";
6538
6580
  this.isLibraryLoaded = false;
6539
- this.currentAuthKey = null;
6540
- this.currentAuthToken = null;
6581
+ this.currentAuthKey = void 0;
6582
+ this.currentAuthToken = void 0;
6541
6583
  this.isInitCalled = false;
6542
6584
  this.attributesMap = {
6543
6585
  dashboardId: "dashboard-id",
@@ -6675,6 +6717,9 @@ var LuzmoDashboard = class extends i4 {
6675
6717
  this.dashboardErrorMsg = "";
6676
6718
  const appServer = this.params.appServer;
6677
6719
  const libraryLoadId = ++this._webComponentLibraryLoadId;
6720
+ if (!appServer) {
6721
+ return;
6722
+ }
6678
6723
  loadLibrary(appServer, dashboardRemote).then(async () => {
6679
6724
  if (libraryLoadId !== this._webComponentLibraryLoadId || !this.isWebComponentViewMode() || this.params.appServer !== appServer) {
6680
6725
  return;
@@ -7131,8 +7176,9 @@ var LuzmoDashboard = class extends i4 {
7131
7176
  }
7132
7177
  // Public methods
7133
7178
  getData(itemId) {
7134
- if (this.isWebComponentViewMode() && this.dashboardReference) {
7135
- return Promise.resolve().then(() => this.dashboardReference.getData(itemId));
7179
+ const dashboardReference = this.dashboardReference;
7180
+ if (this.isWebComponentViewMode() && dashboardReference) {
7181
+ return Promise.resolve().then(() => dashboardReference.getData(itemId));
7136
7182
  }
7137
7183
  if (!this.isWebComponentViewMode()) {
7138
7184
  return getData(this, this.iframe, itemId);
@@ -7217,6 +7263,9 @@ var LuzmoDashboard = class extends i4 {
7217
7263
  return getAccessibleDashboards(this);
7218
7264
  }
7219
7265
  addFilters(itemId, filters) {
7266
+ if (!this.dashboardReference) {
7267
+ return Promise.reject();
7268
+ }
7220
7269
  return this.dashboardReference.addFilters(itemId, filters);
7221
7270
  }
7222
7271
  setEditMode(editMode) {
@@ -7229,7 +7278,7 @@ var LuzmoDashboard = class extends i4 {
7229
7278
  editMode
7230
7279
  });
7231
7280
  }
7232
- if (this.dashboardReference && ["editFull", "editLimited"].includes(editMode)) {
7281
+ if (this.dashboardReference && editMode && ["editFull", "editLimited"].includes(editMode)) {
7233
7282
  this.editMode = editMode;
7234
7283
  this.params.editMode = editMode;
7235
7284
  this.initComponent();
@@ -7238,7 +7287,7 @@ var LuzmoDashboard = class extends i4 {
7238
7287
  editMode
7239
7288
  });
7240
7289
  }
7241
- if (this.isWebComponentViewMode() && this.dashboardReference) {
7290
+ if (this.isWebComponentViewMode() && this.dashboardReference && editMode) {
7242
7291
  return this.dashboardReference.setEditMode(editMode);
7243
7292
  }
7244
7293
  if (!this.isWebComponentViewMode()) {
@@ -7253,7 +7302,7 @@ var LuzmoDashboard = class extends i4 {
7253
7302
  return setPreview(this, this.iframe, preview);
7254
7303
  }
7255
7304
  sendExportEmail(type, subject, message) {
7256
- if (this.isWebComponentViewMode() && this.dashboardReference) {
7305
+ if (this.isWebComponentViewMode() && this.dashboardReference && type) {
7257
7306
  return this.dashboardReference.sendExportEmail(type, subject, message);
7258
7307
  } else if (!this.isWebComponentViewMode()) {
7259
7308
  return sendExportEmail(this, this.iframe, type, subject, message);
@@ -7434,7 +7483,7 @@ if (!customElements.get("luzmo-embed-dashboard")) {
7434
7483
  }
7435
7484
 
7436
7485
  // libs/dashboard-contents-types/src/lib/shared/version.ts
7437
- var CONTENTS_VERSION = "0.1.104";
7486
+ var CONTENTS_VERSION = "0.1.106";
7438
7487
 
7439
7488
  // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
7440
7489
  var dashboardContentsVersion = CONTENTS_VERSION;
@@ -7492,6 +7541,7 @@ var LuzmoBaseVizItem = class extends i4 {
7492
7541
  id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
7493
7542
  type: this.type,
7494
7543
  slots,
7544
+ inlineData: this.inlineData,
7495
7545
  options: this.options,
7496
7546
  filters: typeof this.chartElement?.getContextFilters === "function" ? this.chartElement.getContextFilters() : typeof this.chartElement?.getFilters === "function" ? this.getFilters() : [],
7497
7547
  datasetIds: collectVizItemDatasetIds(slots)
@@ -7554,18 +7604,31 @@ var LuzmoBaseVizItem = class extends i4 {
7554
7604
  });
7555
7605
  this.chartElement.addEventListener("changedFilters", (payload) => {
7556
7606
  this.dispatchEvent(new CustomEvent("changedFilters", payload));
7557
- this.dispatchEvent(new CustomEvent("contextChanged", {
7558
- detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
7559
- }));
7607
+ this.dispatchEvent(
7608
+ new CustomEvent("contextChanged", {
7609
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
7610
+ })
7611
+ );
7560
7612
  });
7561
- this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
7562
- this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
7613
+ this.chartElement.addEventListener(
7614
+ "exported",
7615
+ (payload) => this.dispatchEvent(new CustomEvent("exported", payload))
7616
+ );
7617
+ this.chartElement.addEventListener(
7618
+ "customEvent",
7619
+ (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload))
7620
+ );
7563
7621
  this.chartElement.addEventListener("error", (event) => {
7564
- this.dispatchEvent(new CustomEvent("error", {
7565
- detail: normalizeEmbedErrorDetail(event.detail)
7566
- }));
7622
+ this.dispatchEvent(
7623
+ new CustomEvent("error", {
7624
+ detail: normalizeEmbedErrorDetail(event.detail)
7625
+ })
7626
+ );
7567
7627
  });
7568
- this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
7628
+ this.chartElement.addEventListener(
7629
+ "authorizationExpired",
7630
+ (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload))
7631
+ );
7569
7632
  this.updateVizItemProperties();
7570
7633
  this.renderRoot.append(this.chartElement);
7571
7634
  }
@@ -7588,8 +7651,21 @@ var LuzmoBaseVizItem = class extends i4 {
7588
7651
  if (this.chartElement) {
7589
7652
  for (const [propertyName] of changedProperties.entries()) {
7590
7653
  const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
7591
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
7592
- this.chartElement.setAttribute(mappedAttributeName, attributeValue);
7654
+ const value = this[propertyName];
7655
+ if (propertyName === "inlineData" && (value === void 0 || value === null)) {
7656
+ this.inlineData = void 0;
7657
+ this.chartElement.removeAttribute(mappedAttributeName);
7658
+ } else {
7659
+ const attributeValue = typeof value === "object" ? JSON.stringify(value) : value?.toString() ?? value;
7660
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
7661
+ }
7662
+ }
7663
+ if (["inlineData", "options", "slots"].some((propertyName) => changedProperties.has(propertyName))) {
7664
+ this.dispatchEvent(
7665
+ new CustomEvent("contextChanged", {
7666
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
7667
+ })
7668
+ );
7593
7669
  }
7594
7670
  } else {
7595
7671
  if (this.canInitializeVizItem()) {
@@ -7599,7 +7675,7 @@ var LuzmoBaseVizItem = class extends i4 {
7599
7675
  }
7600
7676
  }
7601
7677
  render() {
7602
- return b2` `;
7678
+ return b2``;
7603
7679
  }
7604
7680
  };
7605
7681
  // Static styles to set host display to block, else it is not shown at all for some reason.
@@ -7625,6 +7701,9 @@ __decorateClass([
7625
7701
  __decorateClass([
7626
7702
  n4({ type: Array })
7627
7703
  ], LuzmoBaseVizItem.prototype, "slots", 2);
7704
+ __decorateClass([
7705
+ n4({ type: Object })
7706
+ ], LuzmoBaseVizItem.prototype, "inlineData", 2);
7628
7707
  __decorateClass([
7629
7708
  n4({ type: Object })
7630
7709
  ], LuzmoBaseVizItem.prototype, "options", 2);
@@ -7646,6 +7725,9 @@ __decorateClass([
7646
7725
  __decorateClass([
7647
7726
  n4({
7648
7727
  converter: (value) => {
7728
+ if (value == null) {
7729
+ return value;
7730
+ }
7649
7731
  try {
7650
7732
  return JSON.parse(value);
7651
7733
  } catch {