@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.rn.cjs CHANGED
@@ -431,41 +431,46 @@ var createIframeUrl = (dashboardContent) => {
431
431
  // libs/embed-libs/embed/src/lib/shared/helpers/get-loader.ts
432
432
  var getLoader = (dashboardComponent) => {
433
433
  let errorMsg;
434
- if (dashboardComponent.params.error || dashboardComponent.browserNotSupported.length > 0) {
435
- dashboardComponent.params.error = true;
434
+ if (dashboardComponent.params?.error || (dashboardComponent.browserNotSupported?.length ?? 0) > 0) {
435
+ if (dashboardComponent.params) {
436
+ dashboardComponent.params.error = true;
437
+ }
436
438
  if (dashboardComponent.browserNotSupported) {
437
439
  errorMsg = "Browser is not supported.";
438
440
  }
439
441
  }
440
- const loadingMsg = translations_default.initializing[dashboardComponent.params.language] || translations_default.initializing.en;
441
- return dashboardComponent.browserNotSupported || dashboardComponent.params.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
442
+ const language = dashboardComponent.params?.language;
443
+ const loadingMsg = (language ? translations_default.initializing[language] : void 0) || translations_default.initializing.en;
444
+ return dashboardComponent.browserNotSupported || dashboardComponent.params?.error ? { loadingMsg, errorMsg } : { loadingMsg, errorMsg: "" };
442
445
  };
443
446
 
444
447
  // libs/embed-libs/embed/src/lib/shared/helpers/promise-dispatch.ts
445
448
  function resolvePromise(dashboardComponent, requestId, data) {
446
- if (dashboardComponent.promises[requestId]) {
447
- dashboardComponent.promises[requestId].resolve(data);
448
- delete dashboardComponent.promises[requestId];
449
+ const promises = dashboardComponent.promises;
450
+ if (promises?.[requestId]) {
451
+ promises[requestId].resolve(data);
452
+ delete promises[requestId];
449
453
  }
450
454
  }
451
455
  function rejectPromise(dashboardComponent, requestId, data) {
452
- if (dashboardComponent.promises[requestId]) {
453
- dashboardComponent.promises[requestId].reject(data);
454
- delete dashboardComponent.promises[requestId];
456
+ const promises = dashboardComponent.promises;
457
+ if (promises?.[requestId]) {
458
+ promises[requestId].reject(data);
459
+ delete promises[requestId];
455
460
  }
456
461
  }
457
462
 
458
463
  // libs/embed-libs/embed/src/lib/shared/helpers/styles.ts
459
464
  function containerStyles(dashboardComponent) {
460
465
  const styles = {};
461
- if (dashboardComponent.params.loaderBackground && !dashboardComponent.iframeLoaded) {
466
+ if (dashboardComponent.params?.loaderBackground && !dashboardComponent.iframeLoaded) {
462
467
  styles.background = dashboardComponent.params.loaderBackground;
463
468
  }
464
469
  return styles;
465
470
  }
466
471
  function containerLoaderStyles(dashboardComponent) {
467
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
468
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
472
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
473
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
469
474
  const display = dashboardComponent.iframeLoaded ? "none" : "";
470
475
  return {
471
476
  display,
@@ -473,8 +478,8 @@ function containerLoaderStyles(dashboardComponent) {
473
478
  };
474
479
  }
475
480
  function loaderStyles(dashboardComponent) {
476
- const background = dashboardComponent.params.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
477
- if (dashboardComponent.params.itemEmbedding) {
481
+ const background = dashboardComponent.params?.loaderBackground || DEFAULT_PARAMETERS.loaderBackground;
482
+ if (dashboardComponent.params?.itemEmbedding) {
478
483
  dashboardComponent.loaderSize = 24;
479
484
  dashboardComponent.borderWidth = 4;
480
485
  dashboardComponent.minHeight = 200;
@@ -503,11 +508,11 @@ function plStyles(dashboardComponent) {
503
508
  } = DEFAULT_PARAMETERS;
504
509
  const spinnerColorBorder = generateBorderStyle(
505
510
  dashboardComponent.borderWidth,
506
- dashboardComponent.params.loaderSpinnerColor || defaultSpinnerColor
511
+ dashboardComponent.params?.loaderSpinnerColor || defaultSpinnerColor
507
512
  );
508
513
  const spinnerBackgroundBorder = generateBorderStyle(
509
514
  dashboardComponent.borderWidth,
510
- dashboardComponent.params.loaderSpinnerBackground || defaultSpinnerBackground
515
+ dashboardComponent.params?.loaderSpinnerBackground || defaultSpinnerBackground
511
516
  );
512
517
  const size = `${dashboardComponent.loaderSize}px`;
513
518
  return {
@@ -520,27 +525,28 @@ function plStyles(dashboardComponent) {
520
525
  };
521
526
  }
522
527
  function lcStyles(dashboardComponent) {
523
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
524
- const chartHeightDefined = dashboardComponent.params.itemEmbedding && height !== "auto";
525
- const getPaddingStr = (value) => `${(value - dashboardComponent.loaderSize - 32) / 2}px`;
526
- const verticalPadding = dashboardComponent.params.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
528
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
529
+ const chartHeightDefined = dashboardComponent.params?.itemEmbedding && height !== "auto";
530
+ const getPaddingStr = (value) => `${((value ?? Number.NaN) - (dashboardComponent.loaderSize ?? Number.NaN) - 32) / 2}px`;
531
+ const verticalPadding = dashboardComponent.params?.itemId ? chartHeightDefined ? getPaddingStr(Number.parseInt(`${height}`, 10)) : getPaddingStr(dashboardComponent.minHeight) : "128px";
527
532
  return {
528
533
  padding: `${verticalPadding} 16px`
529
534
  };
530
535
  }
531
536
  function calculateIframeStyles(dashboardComponent) {
532
- const height = dashboardComponent.params.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
533
- const width = dashboardComponent.params.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
534
- if (dashboardComponent.params.itemEmbedding && height !== "auto") {
537
+ const height = dashboardComponent.params?.itemDimensions?.height || DEFAULT_PARAMETERS.itemDimensions.height;
538
+ const width = dashboardComponent.params?.itemDimensions?.width || DEFAULT_PARAMETERS.itemDimensions.width;
539
+ const editMode = dashboardComponent.params?.editMode;
540
+ if (dashboardComponent.params?.itemEmbedding && height !== "auto") {
535
541
  dashboardComponent.iframeHeight = `${height}px`;
536
- } else if (dashboardComponent.params.itemEmbedding) {
542
+ } else if (dashboardComponent.params?.itemEmbedding) {
537
543
  dashboardComponent.iframeHeight = "200px";
538
- } else if (["editFull", "editLimited"].includes(dashboardComponent.params.editMode)) {
544
+ } else if (editMode != null && ["editFull", "editLimited"].includes(editMode)) {
539
545
  dashboardComponent.iframeHeight = "100%";
540
546
  } else {
541
547
  dashboardComponent.iframeHeight = "400px";
542
548
  }
543
- dashboardComponent.iframeWidth = dashboardComponent.params.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
549
+ dashboardComponent.iframeWidth = dashboardComponent.params?.itemEmbedding && width !== "auto" ? `${width}px` : "100%";
544
550
  const styles = {
545
551
  height: dashboardComponent.iframeHeight,
546
552
  width: dashboardComponent.iframeWidth
@@ -559,7 +565,7 @@ function calculateIframeStyles(dashboardComponent) {
559
565
 
560
566
  // libs/embed-libs/embed/src/lib/shared/helpers/update-iframe-url.ts
561
567
  var updateIframeUrl = (iframe, iframeUrl) => {
562
- if (iframe?.contentWindow) {
568
+ if (iframe?.contentWindow && iframeUrl !== void 0) {
563
569
  iframe.contentWindow.location.replace(iframeUrl);
564
570
  }
565
571
  };
@@ -568,7 +574,7 @@ var updateIframeUrl = (iframe, iframeUrl) => {
568
574
  var selectedDataUtils = {
569
575
  merge(...filters) {
570
576
  return filters.reduce((acc, filter) => {
571
- acc.and.push(...filter.and);
577
+ (acc.and ??= []).push(...filter.and ?? []);
572
578
  return acc;
573
579
  }, {
574
580
  and: []
@@ -631,43 +637,46 @@ var selectedDataUtils = {
631
637
  // libs/embed-libs/embed/src/lib/shared/methods/export-dashboard.ts
632
638
  var exportDashboard = (dashboardComponent, iframe, format) => {
633
639
  const requestId = uuidv4();
634
- if (iframe?.contentWindow) {
635
- iframe.contentWindow.postMessage(
636
- {
637
- action: "exportDashboard",
638
- format: format || "png",
639
- _version: dashboardComponent.libVersion,
640
- requestId
641
- },
642
- "*"
643
- );
644
- return new Promise((resolve, reject) => {
645
- dashboardComponent.promises[requestId] = { resolve, reject };
646
- setTimeout(() => {
647
- if (dashboardComponent.promises[requestId]) {
648
- const errorMessage = "exportDashboard request timed out.";
649
- dashboardComponent.promises[requestId].reject(
650
- new Error(errorMessage)
651
- );
652
- delete dashboardComponent.promises[requestId];
653
- }
654
- }, 12e5);
655
- });
640
+ if (!iframe?.contentWindow) {
641
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
656
642
  }
657
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
643
+ const { promises } = dashboardComponent;
644
+ if (!promises) {
645
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
646
+ }
647
+ iframe.contentWindow.postMessage(
648
+ {
649
+ action: "exportDashboard",
650
+ format: format || "png",
651
+ _version: dashboardComponent.libVersion,
652
+ requestId
653
+ },
654
+ "*"
655
+ );
656
+ return new Promise((resolve, reject) => {
657
+ promises[requestId] = { resolve, reject };
658
+ setTimeout(() => {
659
+ if (promises[requestId]) {
660
+ const errorMessage = "exportDashboard request timed out.";
661
+ promises[requestId].reject(new Error(errorMessage));
662
+ delete promises[requestId];
663
+ }
664
+ }, 12e5);
665
+ });
658
666
  };
659
667
 
660
668
  // libs/embed-libs/embed/src/lib/shared/methods/get-accessible-dashboards.ts
661
669
  var getAccessibleDashboards = async (dashboardComponent) => {
662
670
  await dashboardComponent.updateComplete;
663
- if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken)) {
671
+ if ((dashboardComponent.currentAuthKey ?? dashboardComponent.authKey) && (dashboardComponent.currentAuthToken ?? dashboardComponent.authToken) && dashboardComponent.params) {
672
+ const { params } = dashboardComponent;
664
673
  const fetchUser = new Promise((resolve, reject) => {
665
674
  void (() => {
666
675
  try {
667
676
  const responsePromise = window.fetch(
668
677
  // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
669
678
  // Fixes incorrect url with embedMode="webComponent"
670
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/authorization`,
679
+ `${addTrailingSlash(params.apiHost)}0.1.0/authorization`,
671
680
  {
672
681
  method: "POST",
673
682
  mode: "cors",
@@ -712,136 +721,144 @@ var getAccessibleDashboards = async (dashboardComponent) => {
712
721
  }
713
722
  })();
714
723
  });
715
- return new Promise((resolve, reject) => void (() => {
716
- try {
717
- fetchUser.then((authorizationData) => {
718
- const responsePromise = window.fetch(
719
- // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
720
- // Fixes incorrect url with embedMode="webComponent"
721
- `${addTrailingSlash(dashboardComponent.params.apiHost)}0.1.0/securable`,
722
- {
723
- method: "POST",
724
- mode: "cors",
725
- cache: "no-cache",
726
- headers: { "Content-Type": "application/json" },
727
- redirect: "follow",
728
- body: JSON.stringify({
729
- action: "get",
730
- version: "0.1.0",
731
- key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
732
- token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
733
- find: {
734
- where: { type: "dashboard", is_variant: false },
735
- attributes: ["id", "name", "modified_at"],
736
- order: [["modified_at", "desc"]],
737
- include: [
738
- { model: "Tag", attributes: ["tag"] },
739
- { model: "User", attributes: ["id", "name"] },
740
- {
741
- model: "Group",
742
- attributes: ["id", "name", "public"]
743
- },
744
- { model: "Integration", attributes: ["id", "name"] }
745
- ]
746
- }
747
- })
748
- }
749
- );
750
- responsePromise.then((response) => response.json()).then((data) => {
751
- const dashboardList = data.rows.length > 0 ? formatDashboardList(
752
- data.rows,
753
- authorizationData.integrationId,
754
- authorizationData.user,
755
- dashboardComponent
756
- ) : [];
757
- resolve(dashboardList);
724
+ return new Promise((resolve, reject) => {
725
+ void (() => {
726
+ try {
727
+ fetchUser.then((authorizationData) => {
728
+ const responsePromise = window.fetch(
729
+ // With embedMode="webComponent" URLs remove the trailing slash, since the web component expects them to not have it.
730
+ // Fixes incorrect url with embedMode="webComponent"
731
+ `${addTrailingSlash(params.apiHost)}0.1.0/securable`,
732
+ {
733
+ method: "POST",
734
+ mode: "cors",
735
+ cache: "no-cache",
736
+ headers: { "Content-Type": "application/json" },
737
+ redirect: "follow",
738
+ body: JSON.stringify({
739
+ action: "get",
740
+ version: "0.1.0",
741
+ key: dashboardComponent.currentAuthKey ?? dashboardComponent.authKey,
742
+ token: dashboardComponent.currentAuthToken ?? dashboardComponent.authToken,
743
+ find: {
744
+ where: { type: "dashboard", is_variant: false },
745
+ attributes: ["id", "name", "modified_at"],
746
+ order: [["modified_at", "desc"]],
747
+ include: [
748
+ { model: "Tag", attributes: ["tag"] },
749
+ { model: "User", attributes: ["id", "name"] },
750
+ {
751
+ model: "Group",
752
+ attributes: ["id", "name", "public"]
753
+ },
754
+ { model: "Integration", attributes: ["id", "name"] }
755
+ ]
756
+ }
757
+ })
758
+ }
759
+ );
760
+ responsePromise.then((response) => response.json()).then((data) => {
761
+ const dashboardList = data.rows.length > 0 ? formatDashboardList(
762
+ data.rows,
763
+ authorizationData.integrationId,
764
+ authorizationData.user,
765
+ dashboardComponent
766
+ ) : [];
767
+ resolve(dashboardList);
768
+ });
769
+ }).catch((error) => {
770
+ reject(error);
758
771
  });
759
- }).catch((error) => {
772
+ } catch (error) {
760
773
  reject(error);
761
- });
762
- } catch (error) {
763
- reject(error);
764
- }
765
- })());
774
+ }
775
+ })();
776
+ });
766
777
  }
767
778
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
768
779
  };
769
780
 
770
781
  // libs/embed-libs/embed/src/lib/shared/methods/get-dashboard-context.ts
771
782
  var getDashboardContext = (dashboardComponent, iframe) => {
772
- if (iframe?.contentWindow) {
773
- const requestId = uuidv4();
774
- iframe.contentWindow.postMessage(
775
- { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
776
- "*"
777
- );
778
- return new Promise((resolve, reject) => {
779
- dashboardComponent.promises[requestId] = { resolve, reject };
780
- setTimeout(() => {
781
- if (dashboardComponent.promises[requestId]) {
782
- const errorMessage = "getDashboardContext request timed out.";
783
- dashboardComponent.promises[requestId].reject(
784
- new Error(errorMessage)
785
- );
786
- delete dashboardComponent.promises[requestId];
787
- }
788
- }, 2e3);
789
- });
783
+ if (!iframe?.contentWindow) {
784
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
790
785
  }
791
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
786
+ const { promises } = dashboardComponent;
787
+ if (!promises) {
788
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
789
+ }
790
+ const requestId = uuidv4();
791
+ iframe.contentWindow.postMessage(
792
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
793
+ "*"
794
+ );
795
+ return new Promise((resolve, reject) => {
796
+ promises[requestId] = { resolve, reject };
797
+ setTimeout(() => {
798
+ if (promises[requestId]) {
799
+ const errorMessage = "getDashboardContext request timed out.";
800
+ promises[requestId].reject(new Error(errorMessage));
801
+ delete promises[requestId];
802
+ }
803
+ }, 2e3);
804
+ });
792
805
  };
793
806
 
794
807
  // libs/embed-libs/embed/src/lib/shared/methods/get-data.ts
795
808
  var getData = (dashboardComponent, iframe, itemId) => {
796
- if (iframe?.contentWindow) {
797
- const requestId = uuidv4();
798
- iframe.contentWindow.postMessage(
799
- {
800
- action: "getData",
801
- id: itemId,
802
- _version: dashboardComponent.libVersion,
803
- requestId
804
- },
805
- "*"
806
- );
807
- return new Promise((resolve, reject) => {
808
- dashboardComponent.promises[requestId] = { resolve, reject };
809
- setTimeout(() => {
810
- if (dashboardComponent.promises[requestId]) {
811
- const errorMessage = "getData request timed out.";
812
- dashboardComponent.promises[requestId].reject(
813
- new Error(errorMessage)
814
- );
815
- delete dashboardComponent.promises[requestId];
816
- }
817
- }, 2e3);
818
- });
809
+ if (!iframe?.contentWindow) {
810
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
819
811
  }
820
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
812
+ const { promises } = dashboardComponent;
813
+ if (!promises) {
814
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
815
+ }
816
+ const requestId = uuidv4();
817
+ iframe.contentWindow.postMessage(
818
+ {
819
+ action: "getData",
820
+ id: itemId,
821
+ _version: dashboardComponent.libVersion,
822
+ requestId
823
+ },
824
+ "*"
825
+ );
826
+ return new Promise((resolve, reject) => {
827
+ promises[requestId] = { resolve, reject };
828
+ setTimeout(() => {
829
+ if (promises[requestId]) {
830
+ const errorMessage = "getData request timed out.";
831
+ promises[requestId].reject(new Error(errorMessage));
832
+ delete promises[requestId];
833
+ }
834
+ }, 2e3);
835
+ });
821
836
  };
822
837
 
823
838
  // libs/embed-libs/embed/src/lib/shared/methods/get-filters.ts
824
839
  var getFilters = (dashboardComponent, iframe) => {
825
- if (iframe?.contentWindow) {
826
- const requestId = uuidv4();
827
- iframe.contentWindow.postMessage(
828
- { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
829
- "*"
830
- );
831
- return new Promise((resolve, reject) => {
832
- dashboardComponent.promises[requestId] = { resolve, reject };
833
- setTimeout(() => {
834
- if (dashboardComponent.promises[requestId]) {
835
- const errorMessage = "getFilters request timed out.";
836
- dashboardComponent.promises[requestId].reject(
837
- new Error(errorMessage)
838
- );
839
- delete dashboardComponent.promises[requestId];
840
- }
841
- }, 2e3);
842
- });
840
+ if (!iframe?.contentWindow) {
841
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
843
842
  }
844
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
843
+ const { promises } = dashboardComponent;
844
+ if (!promises) {
845
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
846
+ }
847
+ const requestId = uuidv4();
848
+ iframe.contentWindow.postMessage(
849
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
850
+ "*"
851
+ );
852
+ return new Promise((resolve, reject) => {
853
+ promises[requestId] = { resolve, reject };
854
+ setTimeout(() => {
855
+ if (promises[requestId]) {
856
+ const errorMessage = "getFilters request timed out.";
857
+ promises[requestId].reject(new Error(errorMessage));
858
+ delete promises[requestId];
859
+ }
860
+ }, 2e3);
861
+ });
845
862
  };
846
863
 
847
864
  // libs/embed-libs/embed/src/lib/shared/methods/get-insights.ts
@@ -849,6 +866,10 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
849
866
  if (!iframe?.contentWindow) {
850
867
  return Promise.reject(new Error("Cannot retrieve contentWindow."));
851
868
  }
869
+ const { promises } = dashboardComponent;
870
+ if (!promises) {
871
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
872
+ }
852
873
  const requestId = uuidv4();
853
874
  iframe.contentWindow.postMessage(
854
875
  {
@@ -860,11 +881,11 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
860
881
  "*"
861
882
  );
862
883
  return new Promise((resolve, reject) => {
863
- dashboardComponent.promises[requestId] = { resolve, reject };
884
+ promises[requestId] = { resolve, reject };
864
885
  setTimeout(() => {
865
- if (dashboardComponent.promises[requestId]) {
866
- dashboardComponent.promises[requestId].reject(new Error("getInsights request timed out."));
867
- delete dashboardComponent.promises[requestId];
886
+ if (promises[requestId]) {
887
+ promises[requestId].reject(new Error("getInsights request timed out."));
888
+ delete promises[requestId];
868
889
  }
869
890
  }, 6e4);
870
891
  });
@@ -872,7 +893,7 @@ var getInsights = (dashboardComponent, iframe, options = {}) => {
872
893
 
873
894
  // libs/embed-libs/embed/src/lib/shared/methods/refresh-data.ts
874
895
  var refreshData = (dashboardComponent, iframe, itemId) => {
875
- if (iframe) {
896
+ if (iframe?.contentWindow) {
876
897
  iframe.contentWindow.postMessage(
877
898
  {
878
899
  action: "refreshData",
@@ -888,7 +909,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
888
909
 
889
910
  // libs/embed-libs/embed/src/lib/shared/methods/reload-dashboard.ts
890
911
  var reloadDashboard = (dashboardComponent, iframe) => {
891
- if (iframe) {
912
+ if (iframe?.contentWindow) {
892
913
  iframe.contentWindow.postMessage(
893
914
  { action: "reloadDashboard", _version: dashboardComponent.libVersion },
894
915
  "*"
@@ -900,7 +921,7 @@ var reloadDashboard = (dashboardComponent, iframe) => {
900
921
 
901
922
  // libs/embed-libs/embed/src/lib/shared/methods/send-export-email.ts
902
923
  var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
903
- if (iframe) {
924
+ if (iframe?.contentWindow) {
904
925
  iframe.contentWindow.postMessage(
905
926
  {
906
927
  action: "sendExportEmail",
@@ -918,7 +939,7 @@ var sendExportEmail = (dashboardComponent, iframe, type, subject, message) => {
918
939
 
919
940
  // libs/embed-libs/embed/src/lib/shared/methods/set-authorization.ts
920
941
  var setAuthorization = (dashboardComponent, iframe, key, token) => {
921
- if (iframe) {
942
+ if (iframe?.contentWindow) {
922
943
  iframe.contentWindow.postMessage(
923
944
  {
924
945
  action: "setAuthorization",
@@ -935,92 +956,100 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
935
956
 
936
957
  // libs/embed-libs/embed/src/lib/shared/methods/set-edit-mode.ts
937
958
  var setEditMode = (dashboardComponent, iframe, editMode) => {
938
- if (iframe && iframe.contentWindow) {
939
- const requestId = uuidv4();
940
- if (dashboardComponent.params.editMode === editMode) {
941
- return Promise.reject(
942
- new Error("editMode parameter is currently already set to " + editMode)
943
- );
944
- } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
945
- return Promise.reject(
946
- new Error(
947
- "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
948
- )
949
- );
950
- }
951
- iframe.contentWindow.postMessage(
952
- {
953
- action: "setEditMode",
954
- editMode,
955
- _version: dashboardComponent.libVersion,
956
- requestId
957
- },
958
- "*"
959
+ if (!iframe?.contentWindow) {
960
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
961
+ }
962
+ const { params, promises } = dashboardComponent;
963
+ if (!params || !promises) {
964
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
965
+ }
966
+ const requestId = uuidv4();
967
+ if (params.editMode === editMode) {
968
+ return Promise.reject(
969
+ new Error("editMode parameter is currently already set to " + editMode)
970
+ );
971
+ } else if (editMode !== "editFull" && editMode !== "editLimited" && editMode !== "view") {
972
+ return Promise.reject(
973
+ new Error(
974
+ "The editMode parameter must be one of the following values: 'editFull', 'editLimited' or 'view'."
975
+ )
959
976
  );
960
- return new Promise((resolve, reject) => {
961
- dashboardComponent.promises[requestId] = { resolve, reject };
962
- });
963
977
  }
964
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
978
+ iframe.contentWindow.postMessage(
979
+ {
980
+ action: "setEditMode",
981
+ editMode,
982
+ _version: dashboardComponent.libVersion,
983
+ requestId
984
+ },
985
+ "*"
986
+ );
987
+ return new Promise((resolve, reject) => {
988
+ promises[requestId] = { resolve, reject };
989
+ });
965
990
  };
966
991
 
967
992
  // libs/embed-libs/embed/src/lib/shared/methods/set-preview.ts
968
993
  var setPreview = (dashboardComponent, iframe, preview) => {
969
- if (iframe) {
970
- const requestId = uuidv4();
971
- iframe.contentWindow.postMessage(
972
- {
973
- action: "setPreview",
974
- preview,
975
- requestId,
976
- _version: dashboardComponent.libVersion
977
- },
978
- "*"
979
- );
980
- return new Promise((resolve, reject) => {
981
- dashboardComponent.promises[requestId] = { resolve, reject };
982
- setTimeout(() => {
983
- if (dashboardComponent.promises[requestId]) {
984
- const errorMessage = "setPreview request timed out.";
985
- dashboardComponent.promises[requestId].reject(
986
- new Error(errorMessage)
987
- );
988
- delete dashboardComponent.promises[requestId];
989
- }
990
- }, 2e3);
991
- });
994
+ if (!iframe?.contentWindow) {
995
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
992
996
  }
993
- return Promise.reject(new Error("Cannot retrieve contentWindow."));
997
+ const { promises } = dashboardComponent;
998
+ if (!promises) {
999
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
1000
+ }
1001
+ const requestId = uuidv4();
1002
+ iframe.contentWindow.postMessage(
1003
+ {
1004
+ action: "setPreview",
1005
+ preview,
1006
+ requestId,
1007
+ _version: dashboardComponent.libVersion
1008
+ },
1009
+ "*"
1010
+ );
1011
+ return new Promise((resolve, reject) => {
1012
+ promises[requestId] = { resolve, reject };
1013
+ setTimeout(() => {
1014
+ if (promises[requestId]) {
1015
+ const errorMessage = "setPreview request timed out.";
1016
+ promises[requestId].reject(new Error(errorMessage));
1017
+ delete promises[requestId];
1018
+ }
1019
+ }, 2e3);
1020
+ });
994
1021
  };
995
1022
 
996
1023
  // libs/embed-libs/embed/src/lib/shared/methods/set-selected-data.ts
997
1024
  var setSelectedData = (dashboardComponent, iframe, itemId, filters) => {
998
- if (iframe) {
999
- const requestId = uuidv4();
1000
- iframe.contentWindow.postMessage(
1001
- {
1002
- action: "setSelectedData",
1003
- itemId,
1004
- filters,
1005
- _version: dashboardComponent.libVersion,
1006
- requestId
1007
- },
1008
- "*"
1009
- );
1010
- return new Promise((resolve, reject) => {
1011
- dashboardComponent.promises[requestId] = { resolve, reject };
1012
- setTimeout(() => {
1013
- if (dashboardComponent.promises[requestId]) {
1014
- const errorMessage = "setSelectedData request timed out.";
1015
- dashboardComponent.promises[requestId].reject(
1016
- new Error(errorMessage)
1017
- );
1018
- delete dashboardComponent.promises[requestId];
1019
- }
1020
- }, 2e3);
1021
- });
1025
+ if (!iframe?.contentWindow) {
1026
+ return Promise.reject();
1027
+ }
1028
+ const { promises } = dashboardComponent;
1029
+ if (!promises) {
1030
+ return Promise.reject();
1022
1031
  }
1023
- return Promise.reject();
1032
+ const requestId = uuidv4();
1033
+ iframe.contentWindow.postMessage(
1034
+ {
1035
+ action: "setSelectedData",
1036
+ itemId,
1037
+ filters,
1038
+ _version: dashboardComponent.libVersion,
1039
+ requestId
1040
+ },
1041
+ "*"
1042
+ );
1043
+ return new Promise((resolve, reject) => {
1044
+ promises[requestId] = { resolve, reject };
1045
+ setTimeout(() => {
1046
+ if (promises[requestId]) {
1047
+ const errorMessage = "setSelectedData request timed out.";
1048
+ promises[requestId].reject(new Error(errorMessage));
1049
+ delete promises[requestId];
1050
+ }
1051
+ }, 2e3);
1052
+ });
1024
1053
  };
1025
1054
 
1026
1055
  // libs/embed-libs/embed/src/lib/shared/service/calculate-dimensions.ts
@@ -1066,6 +1095,9 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1066
1095
  for (const key of dashboardDimensionKeys) {
1067
1096
  if (screenModes.includes(key)) {
1068
1097
  const screenMode = EXTENTS.find((extent) => extent.mode === key);
1098
+ if (!screenMode) {
1099
+ continue;
1100
+ }
1069
1101
  availableScreenModeExtents.push({
1070
1102
  ...screenMode,
1071
1103
  height: dashboardComponent.dimensions[key][1] || 50
@@ -1120,24 +1152,27 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1120
1152
  ),
1121
1153
  screenModeExtentMinWidth
1122
1154
  );
1123
- currentHeight = screenModeExtent.height;
1155
+ currentHeight = screenModeExtent.height ?? 0;
1124
1156
  }
1125
1157
  }
1126
1158
  }
1127
1159
  }
1128
1160
  } else {
1129
- const {
1130
- height: chosenModeHeight,
1131
- width: [chosenModeMinWidth, chosenModeMaxWidth]
1132
- } = availableScreenModeExtents.find(
1161
+ const chosenModeExtent = availableScreenModeExtents.find(
1133
1162
  (d) => d.mode === dashboardComponent.params.screenMode
1134
1163
  );
1135
- currentMode = dashboardComponent.params.screenMode;
1136
- currentWidth = Math.max(
1137
- Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1138
- chosenModeMinWidth
1139
- );
1140
- currentHeight = chosenModeHeight;
1164
+ if (chosenModeExtent) {
1165
+ const {
1166
+ height: chosenModeHeight,
1167
+ width: [chosenModeMinWidth, chosenModeMaxWidth]
1168
+ } = chosenModeExtent;
1169
+ currentMode = dashboardComponent.params.screenMode;
1170
+ currentWidth = Math.max(
1171
+ Math.min(chosenModeMaxWidth, dashboardComponent.containerWidth),
1172
+ chosenModeMinWidth
1173
+ );
1174
+ currentHeight = chosenModeHeight ?? 0;
1175
+ }
1141
1176
  if (dashboardComponent.params.itemEmbedding) {
1142
1177
  if (dashboardComponent.params.itemDimensions?.width && dashboardComponent.params.itemDimensions?.width !== "auto") {
1143
1178
  currentWidth = Number.parseInt(
@@ -1157,7 +1192,7 @@ var _setCalculatedDimensions = (dashboardComponent) => {
1157
1192
  const [lowestModeExtent] = availableScreenModeExtents;
1158
1193
  currentMode = lowestModeExtent.mode;
1159
1194
  currentWidth = lowestModeExtent.width[0];
1160
- currentHeight = lowestModeExtent.height;
1195
+ currentHeight = lowestModeExtent.height ?? 0;
1161
1196
  }
1162
1197
  }
1163
1198
  dashboardComponent.currentScreenMode = currentMode;
@@ -1219,6 +1254,9 @@ var _extendAndValidate = (dashboardContent) => {
1219
1254
  "fixed",
1220
1255
  "auto"
1221
1256
  ];
1257
+ if (!dashboardContent.params) {
1258
+ dashboardContent.params = {};
1259
+ }
1222
1260
  for (const key of defaultKeys) {
1223
1261
  if (dashboardContent.params[key] === null) {
1224
1262
  delete dashboardContent.params[key];
@@ -1286,17 +1324,20 @@ var _extendAndValidate = (dashboardContent) => {
1286
1324
  if (dashboardContent.params.screenMode && dashboardContent.params.screenMode !== "auto") {
1287
1325
  dashboardContent.params.switchScreenModeOnResize = false;
1288
1326
  }
1289
- if (dashboardContent.params.itemDimensions.width !== "auto") {
1290
- dashboardContent.params.itemDimensions.width = Number.parseInt(
1291
- `${dashboardContent.params.itemDimensions.width}`.replace("px", ""),
1292
- 10
1293
- ) || "auto";
1294
- }
1295
- if (dashboardContent.params.itemDimensions.height !== "auto") {
1296
- dashboardContent.params.itemDimensions.height = Number.parseInt(
1297
- `${dashboardContent.params.itemDimensions.height}`.replace("px", ""),
1298
- 10
1299
- ) || "auto";
1327
+ const itemDimensions = dashboardContent.params.itemDimensions;
1328
+ if (itemDimensions) {
1329
+ if (itemDimensions.width !== "auto") {
1330
+ itemDimensions.width = Number.parseInt(
1331
+ `${itemDimensions.width}`.replace("px", ""),
1332
+ 10
1333
+ ) || "auto";
1334
+ }
1335
+ if (itemDimensions.height !== "auto") {
1336
+ itemDimensions.height = Number.parseInt(
1337
+ `${itemDimensions.height}`.replace("px", ""),
1338
+ 10
1339
+ ) || "auto";
1340
+ }
1300
1341
  }
1301
1342
  dashboardContent.params.itemEmbedding = !!dashboardContent.params.itemId;
1302
1343
  if (dashboardContent.params.error || errorMessages.length > 0) {
@@ -1308,6 +1349,7 @@ var _extendAndValidate = (dashboardContent) => {
1308
1349
  var libraryTypeToWebComponentTypeMapping = {
1309
1350
  type: "type",
1310
1351
  slots: "slots",
1352
+ inlineData: "inline-data",
1311
1353
  options: "options",
1312
1354
  appServer: "app-server",
1313
1355
  apiHost: "api-host",
@@ -1322,7 +1364,23 @@ var libraryTypeToWebComponentTypeMapping = {
1322
1364
  dashboardContentsVersion: "dashboard-contents-version",
1323
1365
  libVersion: "lib-version"
1324
1366
  };
1325
- var libraryAcceptedParametersList = ["appServer", "apiHost", "options", "type", "authKey", "authToken", "slots", "filters", "canFilter", "contextId", "itemId", "dashboardId", "aiMessageAssetId", "libVersion"];
1367
+ var libraryAcceptedParametersList = [
1368
+ "appServer",
1369
+ "apiHost",
1370
+ "options",
1371
+ "type",
1372
+ "authKey",
1373
+ "authToken",
1374
+ "slots",
1375
+ "inlineData",
1376
+ "filters",
1377
+ "canFilter",
1378
+ "contextId",
1379
+ "itemId",
1380
+ "dashboardId",
1381
+ "aiMessageAssetId",
1382
+ "libVersion"
1383
+ ];
1326
1384
 
1327
1385
  // libs/embed-libs/embed/src/lib/shared/constants/class-constants.ts
1328
1386
  var luzmoEmbedContainerClass = "luzmo-embed-container";