@luzmo/embed 5.1.2 → 5.1.3-beta.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.libs.cjs CHANGED
@@ -39,7 +39,8 @@ var __decorateClass = (decorators, target, key, kind) => {
39
39
  // libs/embed-libs/embed/src/index.libs.ts
40
40
  var index_libs_exports = {};
41
41
  __export(index_libs_exports, {
42
- LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent
42
+ LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent,
43
+ LuzmoVizItemWebComponent: () => LuzmoVizItemWebComponent
43
44
  });
44
45
  module.exports = __toCommonJS(index_libs_exports);
45
46
 
@@ -54,7 +55,7 @@ var import_style_map = require("lit/directives/style-map.js");
54
55
  var import_shared_embed = require("@luzmo/shared-embed");
55
56
 
56
57
  // libs/embed-libs/embed/package.json
57
- var version = "5.1.2";
58
+ var version = "5.1.3-beta.0";
58
59
 
59
60
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
60
61
  var LuzmoService = class {
@@ -260,10 +261,6 @@ var dashboardStyles = import_lit.css`
260
261
  border: 0;
261
262
  }
262
263
 
263
- .luzmo-embed-dashboard-ede {
264
- min-height: 100vh;
265
- }
266
-
267
264
  .luzmo-embed-container-ede {
268
265
  width: 100%;
269
266
  height: 100%;
@@ -340,7 +337,7 @@ var dashboardStyles = import_lit.css`
340
337
 
341
338
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
342
339
  var LuzmoDashboard = class extends import_lit2.LitElement {
343
- constructor(inputParameters) {
340
+ constructor() {
344
341
  super();
345
342
  this.language = "auto";
346
343
  this.screenMode = "auto";
@@ -359,10 +356,11 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
359
356
  this.browserErrorMsg = "";
360
357
  this.dashboardError = false;
361
358
  this.browserNotSupported = [];
362
- this.VERSION = version + "-wc-luzmo";
359
+ this.version = version + "-wc-luzmo";
363
360
  this.isLibraryLoaded = false;
364
361
  this.currentAuthKey = null;
365
362
  this.currentAuthToken = null;
363
+ this.isInitCalled = false;
366
364
  this.attributesMap = {
367
365
  dashboardId: "dashboard-id",
368
366
  dashboardSlug: "dashboard-slug",
@@ -392,7 +390,6 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
392
390
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
393
391
  this.iframeLoaded = false;
394
392
  this.promises = {};
395
- this.setInputParameters(inputParameters);
396
393
  this.params = this._setOptions();
397
394
  this._onResize = () => {
398
395
  if (this.shadowRoot?.querySelector(".dashboard-container")) {
@@ -423,60 +420,6 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
423
420
  });
424
421
  });
425
422
  }
426
- loadLibrary(appServer) {
427
- if (import_shared_embed.remotesMap[appServer]) {
428
- return Promise.resolve(import_shared_embed.remotesMap[appServer].module);
429
- }
430
- import_shared_embed.remotesMap[appServer] = {
431
- url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
432
- format: "esm",
433
- from: "vite",
434
- module: void 0
435
- };
436
- return (0, import_shared_embed.__federationMethodGetRemote)(appServer, "./DashboardApp").then((module2) => {
437
- const wrappedModule = (0, import_shared_embed.__federationMethodWrapDefault)(module2, true);
438
- import_shared_embed.remotesMap[appServer].module = wrappedModule;
439
- return wrappedModule;
440
- });
441
- }
442
- setInputParameters(inputParameters) {
443
- if (!inputParameters) {
444
- return;
445
- }
446
- const params = [
447
- "dashboardId",
448
- "dashboardSlug",
449
- "itemId",
450
- "language",
451
- "qeVersion",
452
- "screenMode",
453
- "switchScreenModeOnResize",
454
- "accentColor",
455
- "mainColor",
456
- "authToken",
457
- "authKey",
458
- "editMode",
459
- "loaderBackground",
460
- "loaderFontColor",
461
- "loaderSpinnerColor",
462
- "loaderSpinnerBackground",
463
- "timezoneId",
464
- "itemDimensions",
465
- "apiHost"
466
- ];
467
- for (const key of params) {
468
- const value = inputParameters[key];
469
- if (value) {
470
- this[key] = value;
471
- }
472
- }
473
- if (inputParameters.experimental) {
474
- this.experimental = inputParameters.experimental;
475
- }
476
- if (inputParameters.appServer) {
477
- this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
478
- }
479
- }
480
423
  // Set resize event listener
481
424
  connectedCallback() {
482
425
  super.connectedCallback();
@@ -495,7 +438,6 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
495
438
  this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
496
439
  this._loaderStyles();
497
440
  luzmo_service_default._components.push(this);
498
- this.initComponent();
499
441
  if (this.luzmoEmbedContainer) {
500
442
  this._resizeObserver.observe(this.luzmoEmbedContainer);
501
443
  }
@@ -503,7 +445,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
503
445
  initComponent() {
504
446
  this.params = this._setOptions();
505
447
  if (this.getIsViewMode()) {
506
- this.loadLibrary(this.params.appServer).then(async () => {
448
+ SharedLib2.loadLibrary(this.params.appServer).then(async () => {
507
449
  this.isLibraryLoaded = true;
508
450
  await this.updateComplete;
509
451
  const oldReference = this.renderRoot.querySelector("dashboard-component");
@@ -575,11 +517,21 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
575
517
  "timezoneId",
576
518
  "itemDimensions"
577
519
  ]);
520
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
521
+ let callInitComponent = false;
522
+ for (const condition of conditionsToCheck) {
523
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition];
524
+ }
525
+ if (callInitComponent && !this.isInitCalled) {
526
+ this.initComponent();
527
+ this.isInitCalled = true;
528
+ return;
529
+ }
578
530
  if (this.getIsViewMode()) {
579
531
  if (this.dashboardReference) {
580
532
  for (const [propertyName] of changedProperties.entries()) {
581
533
  if (propertyName === "appSever") {
582
- this.loadLibrary(changedProperties[propertyName]).then(async () => {
534
+ SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
583
535
  this.isLibraryLoaded = true;
584
536
  await this.updateComplete;
585
537
  this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
@@ -787,7 +739,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
787
739
  ${this.dashboardId || this.dashboardSlug ? import_lit2.html`
788
740
  ${loader}
789
741
  <iframe
790
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
742
+ class="luzmo-embed-dashboard"
791
743
  id="${this._iframeId}"
792
744
  name="${this._iframeId}"
793
745
  style=${(0, import_style_map.styleMap)(this.iframeStyle)}
@@ -1078,7 +1030,7 @@ __decorateClass([
1078
1030
  ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1079
1031
  __decorateClass([
1080
1032
  (0, import_decorators.property)()
1081
- ], LuzmoDashboard.prototype, "VERSION", 2);
1033
+ ], LuzmoDashboard.prototype, "version", 2);
1082
1034
  __decorateClass([
1083
1035
  (0, import_decorators.state)()
1084
1036
  ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
@@ -1091,6 +1043,9 @@ __decorateClass([
1091
1043
  __decorateClass([
1092
1044
  (0, import_decorators.state)()
1093
1045
  ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1046
+ __decorateClass([
1047
+ (0, import_decorators.state)()
1048
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
1094
1049
 
1095
1050
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
1096
1051
  var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
@@ -1098,7 +1053,135 @@ var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
1098
1053
  LuzmoDashboardWebComponent = __decorateClass([
1099
1054
  (0, import_decorators2.customElement)("luzmo-dashboard-web-component")
1100
1055
  ], LuzmoDashboardWebComponent);
1056
+
1057
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
1058
+ var import_decorators4 = require("lit/decorators.js");
1059
+
1060
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1061
+ var import_decorators3 = require("lit/decorators.js");
1062
+ var import_lit3 = require("lit");
1063
+ var SharedLib3 = __toESM(require("@luzmo/shared-embed"), 1);
1064
+ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1065
+ constructor() {
1066
+ super();
1067
+ this.appServer = "https://app.luzmo.com";
1068
+ this.apiHost = "https://api.luzmo.com";
1069
+ this.slots = [];
1070
+ this.options = {
1071
+ title: {
1072
+ en: ""
1073
+ },
1074
+ theme: "default"
1075
+ };
1076
+ this.version = version + "-wc-luzmo";
1077
+ }
1078
+ static {
1079
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1080
+ this.styles = import_lit3.css`
1081
+ :host {
1082
+ display: block;
1083
+ width: 100%;
1084
+ height: 100%;
1085
+ }
1086
+ `;
1087
+ }
1088
+ async firstUpdated(_changedProperties) {
1089
+ super.firstUpdated(_changedProperties);
1090
+ if (this.type) {
1091
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1092
+ this.createAndAppendElement();
1093
+ }
1094
+ }
1095
+ createAndAppendElement() {
1096
+ if (!this.chartElement) {
1097
+ this.chartElement = document.createElement("chart-component");
1098
+ this.chartElement.setAttribute("embedding-mode", "chart");
1099
+ this.updateVizItemProperties();
1100
+ this.renderRoot.append(this.chartElement);
1101
+ }
1102
+ }
1103
+ updateVizItemProperties() {
1104
+ if (this.chartElement) {
1105
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1106
+ const value = this[key];
1107
+ if (value) {
1108
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
1109
+ this.chartElement.setAttribute(
1110
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1111
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1112
+ );
1113
+ }
1114
+ }
1115
+ }
1116
+ }
1117
+ async updated(changedProperties) {
1118
+ if (this.chartElement) {
1119
+ for (const [propertyName] of changedProperties.entries()) {
1120
+ const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
1121
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1122
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1123
+ }
1124
+ } else {
1125
+ if (this.type) {
1126
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1127
+ this.createAndAppendElement();
1128
+ }
1129
+ }
1130
+ }
1131
+ render() {
1132
+ return import_lit3.html` `;
1133
+ }
1134
+ };
1135
+ __decorateClass([
1136
+ (0, import_decorators3.property)()
1137
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
1138
+ __decorateClass([
1139
+ (0, import_decorators3.property)()
1140
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
1141
+ __decorateClass([
1142
+ (0, import_decorators3.property)({ type: Array })
1143
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
1144
+ __decorateClass([
1145
+ (0, import_decorators3.property)({ type: Object })
1146
+ ], LuzmoBaseVizItem.prototype, "options", 2);
1147
+ __decorateClass([
1148
+ (0, import_decorators3.property)()
1149
+ ], LuzmoBaseVizItem.prototype, "type", 2);
1150
+ __decorateClass([
1151
+ (0, import_decorators3.property)()
1152
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
1153
+ __decorateClass([
1154
+ (0, import_decorators3.property)()
1155
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
1156
+ __decorateClass([
1157
+ (0, import_decorators3.property)()
1158
+ ], LuzmoBaseVizItem.prototype, "version", 2);
1159
+ __decorateClass([
1160
+ (0, import_decorators3.property)()
1161
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
1162
+ __decorateClass([
1163
+ (0, import_decorators3.property)({
1164
+ converter: (value) => {
1165
+ try {
1166
+ return JSON.parse(value);
1167
+ } catch (exc) {
1168
+ return value;
1169
+ }
1170
+ }
1171
+ })
1172
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
1173
+ __decorateClass([
1174
+ (0, import_decorators3.property)({ type: Array })
1175
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
1176
+
1177
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
1178
+ var LuzmoVizItemWebComponent = class extends LuzmoBaseVizItem {
1179
+ };
1180
+ LuzmoVizItemWebComponent = __decorateClass([
1181
+ (0, import_decorators4.customElement)("luzmo-viz-item-web-component")
1182
+ ], LuzmoVizItemWebComponent);
1101
1183
  // Annotate the CommonJS export names for ESM import in node:
1102
1184
  0 && (module.exports = {
1103
- LuzmoDashboardWebComponent
1185
+ LuzmoDashboardWebComponent,
1186
+ LuzmoVizItemWebComponent
1104
1187
  });
package/index.libs.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './lib/dashboard-component/dashboard-web-component';
2
+ export * from './lib/viz-item/viz-item-web-component';
package/index.libs.js CHANGED
@@ -28,14 +28,11 @@ import {
28
28
  styleMap
29
29
  } from "lit/directives/style-map.js";
30
30
  import {
31
- __federationMethodGetRemote,
32
- __federationMethodWrapDefault,
33
- remotesMap,
34
31
  luzmoEmbedContainerClass
35
32
  } from "@luzmo/shared-embed";
36
33
 
37
34
  // libs/embed-libs/embed/package.json
38
- var version = "5.1.2";
35
+ var version = "5.1.3-beta.0";
39
36
 
40
37
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
41
38
  var LuzmoService = class {
@@ -241,10 +238,6 @@ var dashboardStyles = css`
241
238
  border: 0;
242
239
  }
243
240
 
244
- .luzmo-embed-dashboard-ede {
245
- min-height: 100vh;
246
- }
247
-
248
241
  .luzmo-embed-container-ede {
249
242
  width: 100%;
250
243
  height: 100%;
@@ -321,7 +314,7 @@ var dashboardStyles = css`
321
314
 
322
315
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
323
316
  var LuzmoDashboard = class extends LitElement {
324
- constructor(inputParameters) {
317
+ constructor() {
325
318
  super();
326
319
  this.language = "auto";
327
320
  this.screenMode = "auto";
@@ -340,10 +333,11 @@ var LuzmoDashboard = class extends LitElement {
340
333
  this.browserErrorMsg = "";
341
334
  this.dashboardError = false;
342
335
  this.browserNotSupported = [];
343
- this.VERSION = version + "-wc-luzmo";
336
+ this.version = version + "-wc-luzmo";
344
337
  this.isLibraryLoaded = false;
345
338
  this.currentAuthKey = null;
346
339
  this.currentAuthToken = null;
340
+ this.isInitCalled = false;
347
341
  this.attributesMap = {
348
342
  dashboardId: "dashboard-id",
349
343
  dashboardSlug: "dashboard-slug",
@@ -373,7 +367,6 @@ var LuzmoDashboard = class extends LitElement {
373
367
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
374
368
  this.iframeLoaded = false;
375
369
  this.promises = {};
376
- this.setInputParameters(inputParameters);
377
370
  this.params = this._setOptions();
378
371
  this._onResize = () => {
379
372
  if (this.shadowRoot?.querySelector(".dashboard-container")) {
@@ -404,60 +397,6 @@ var LuzmoDashboard = class extends LitElement {
404
397
  });
405
398
  });
406
399
  }
407
- loadLibrary(appServer) {
408
- if (remotesMap[appServer]) {
409
- return Promise.resolve(remotesMap[appServer].module);
410
- }
411
- remotesMap[appServer] = {
412
- url: appServer?.startsWith("http://localhost") ? `${SharedLib2.removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${SharedLib2.removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
413
- format: "esm",
414
- from: "vite",
415
- module: void 0
416
- };
417
- return __federationMethodGetRemote(appServer, "./DashboardApp").then((module) => {
418
- const wrappedModule = __federationMethodWrapDefault(module, true);
419
- remotesMap[appServer].module = wrappedModule;
420
- return wrappedModule;
421
- });
422
- }
423
- setInputParameters(inputParameters) {
424
- if (!inputParameters) {
425
- return;
426
- }
427
- const params = [
428
- "dashboardId",
429
- "dashboardSlug",
430
- "itemId",
431
- "language",
432
- "qeVersion",
433
- "screenMode",
434
- "switchScreenModeOnResize",
435
- "accentColor",
436
- "mainColor",
437
- "authToken",
438
- "authKey",
439
- "editMode",
440
- "loaderBackground",
441
- "loaderFontColor",
442
- "loaderSpinnerColor",
443
- "loaderSpinnerBackground",
444
- "timezoneId",
445
- "itemDimensions",
446
- "apiHost"
447
- ];
448
- for (const key of params) {
449
- const value = inputParameters[key];
450
- if (value) {
451
- this[key] = value;
452
- }
453
- }
454
- if (inputParameters.experimental) {
455
- this.experimental = inputParameters.experimental;
456
- }
457
- if (inputParameters.appServer) {
458
- this.appServer = SharedLib2.addTrailingSlash(inputParameters.appServer);
459
- }
460
- }
461
400
  // Set resize event listener
462
401
  connectedCallback() {
463
402
  super.connectedCallback();
@@ -476,7 +415,6 @@ var LuzmoDashboard = class extends LitElement {
476
415
  this._loaderMsg = SharedLib2.getLoader(this)?.loadingMsg;
477
416
  this._loaderStyles();
478
417
  luzmo_service_default._components.push(this);
479
- this.initComponent();
480
418
  if (this.luzmoEmbedContainer) {
481
419
  this._resizeObserver.observe(this.luzmoEmbedContainer);
482
420
  }
@@ -484,7 +422,7 @@ var LuzmoDashboard = class extends LitElement {
484
422
  initComponent() {
485
423
  this.params = this._setOptions();
486
424
  if (this.getIsViewMode()) {
487
- this.loadLibrary(this.params.appServer).then(async () => {
425
+ SharedLib2.loadLibrary(this.params.appServer).then(async () => {
488
426
  this.isLibraryLoaded = true;
489
427
  await this.updateComplete;
490
428
  const oldReference = this.renderRoot.querySelector("dashboard-component");
@@ -556,11 +494,21 @@ var LuzmoDashboard = class extends LitElement {
556
494
  "timezoneId",
557
495
  "itemDimensions"
558
496
  ]);
497
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
498
+ let callInitComponent = false;
499
+ for (const condition of conditionsToCheck) {
500
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition];
501
+ }
502
+ if (callInitComponent && !this.isInitCalled) {
503
+ this.initComponent();
504
+ this.isInitCalled = true;
505
+ return;
506
+ }
559
507
  if (this.getIsViewMode()) {
560
508
  if (this.dashboardReference) {
561
509
  for (const [propertyName] of changedProperties.entries()) {
562
510
  if (propertyName === "appSever") {
563
- this.loadLibrary(changedProperties[propertyName]).then(async () => {
511
+ SharedLib2.loadLibrary(changedProperties[propertyName]).then(async () => {
564
512
  this.isLibraryLoaded = true;
565
513
  await this.updateComplete;
566
514
  this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
@@ -768,7 +716,7 @@ var LuzmoDashboard = class extends LitElement {
768
716
  ${this.dashboardId || this.dashboardSlug ? html`
769
717
  ${loader}
770
718
  <iframe
771
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
719
+ class="luzmo-embed-dashboard"
772
720
  id="${this._iframeId}"
773
721
  name="${this._iframeId}"
774
722
  style=${styleMap(this.iframeStyle)}
@@ -1059,7 +1007,7 @@ __decorateClass([
1059
1007
  ], LuzmoDashboard.prototype, "browserNotSupported", 2);
1060
1008
  __decorateClass([
1061
1009
  property()
1062
- ], LuzmoDashboard.prototype, "VERSION", 2);
1010
+ ], LuzmoDashboard.prototype, "version", 2);
1063
1011
  __decorateClass([
1064
1012
  state()
1065
1013
  ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
@@ -1072,6 +1020,9 @@ __decorateClass([
1072
1020
  __decorateClass([
1073
1021
  state()
1074
1022
  ], LuzmoDashboard.prototype, "currentAuthToken", 2);
1023
+ __decorateClass([
1024
+ state()
1025
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
1075
1026
 
1076
1027
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
1077
1028
  var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
@@ -1079,6 +1030,134 @@ var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
1079
1030
  LuzmoDashboardWebComponent = __decorateClass([
1080
1031
  customElement("luzmo-dashboard-web-component")
1081
1032
  ], LuzmoDashboardWebComponent);
1033
+
1034
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
1035
+ import { customElement as customElement3 } from "lit/decorators.js";
1036
+
1037
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
1038
+ import { property as property2 } from "lit/decorators.js";
1039
+ import { LitElement as LitElement2, html as html2, css as css2 } from "lit";
1040
+ import * as SharedLib3 from "@luzmo/shared-embed";
1041
+ var LuzmoBaseVizItem = class extends LitElement2 {
1042
+ constructor() {
1043
+ super();
1044
+ this.appServer = "https://app.luzmo.com";
1045
+ this.apiHost = "https://api.luzmo.com";
1046
+ this.slots = [];
1047
+ this.options = {
1048
+ title: {
1049
+ en: ""
1050
+ },
1051
+ theme: "default"
1052
+ };
1053
+ this.version = version + "-wc-luzmo";
1054
+ }
1055
+ static {
1056
+ // Static styles to set host display to block, else it is not shown at all for some reason.
1057
+ this.styles = css2`
1058
+ :host {
1059
+ display: block;
1060
+ width: 100%;
1061
+ height: 100%;
1062
+ }
1063
+ `;
1064
+ }
1065
+ async firstUpdated(_changedProperties) {
1066
+ super.firstUpdated(_changedProperties);
1067
+ if (this.type) {
1068
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1069
+ this.createAndAppendElement();
1070
+ }
1071
+ }
1072
+ createAndAppendElement() {
1073
+ if (!this.chartElement) {
1074
+ this.chartElement = document.createElement("chart-component");
1075
+ this.chartElement.setAttribute("embedding-mode", "chart");
1076
+ this.updateVizItemProperties();
1077
+ this.renderRoot.append(this.chartElement);
1078
+ }
1079
+ }
1080
+ updateVizItemProperties() {
1081
+ if (this.chartElement) {
1082
+ for (const key in SharedLib3.libraryTypeToWebComponentTypeMapping) {
1083
+ const value = this[key];
1084
+ if (value) {
1085
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? SharedLib3.removeTrailingSlash(value) : value;
1086
+ this.chartElement.setAttribute(
1087
+ SharedLib3.libraryTypeToWebComponentTypeMapping[key],
1088
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
1089
+ );
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ async updated(changedProperties) {
1095
+ if (this.chartElement) {
1096
+ for (const [propertyName] of changedProperties.entries()) {
1097
+ const mappedAttributeName = SharedLib3.libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
1098
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1099
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1100
+ }
1101
+ } else {
1102
+ if (this.type) {
1103
+ await SharedLib3.loadLibrary(this.appServer, "DashboardApp");
1104
+ this.createAndAppendElement();
1105
+ }
1106
+ }
1107
+ }
1108
+ render() {
1109
+ return html2` `;
1110
+ }
1111
+ };
1112
+ __decorateClass([
1113
+ property2()
1114
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
1115
+ __decorateClass([
1116
+ property2()
1117
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
1118
+ __decorateClass([
1119
+ property2({ type: Array })
1120
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
1121
+ __decorateClass([
1122
+ property2({ type: Object })
1123
+ ], LuzmoBaseVizItem.prototype, "options", 2);
1124
+ __decorateClass([
1125
+ property2()
1126
+ ], LuzmoBaseVizItem.prototype, "type", 2);
1127
+ __decorateClass([
1128
+ property2()
1129
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
1130
+ __decorateClass([
1131
+ property2()
1132
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
1133
+ __decorateClass([
1134
+ property2()
1135
+ ], LuzmoBaseVizItem.prototype, "version", 2);
1136
+ __decorateClass([
1137
+ property2()
1138
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
1139
+ __decorateClass([
1140
+ property2({
1141
+ converter: (value) => {
1142
+ try {
1143
+ return JSON.parse(value);
1144
+ } catch (exc) {
1145
+ return value;
1146
+ }
1147
+ }
1148
+ })
1149
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
1150
+ __decorateClass([
1151
+ property2({ type: Array })
1152
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
1153
+
1154
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
1155
+ var LuzmoVizItemWebComponent = class extends LuzmoBaseVizItem {
1156
+ };
1157
+ LuzmoVizItemWebComponent = __decorateClass([
1158
+ customElement3("luzmo-viz-item-web-component")
1159
+ ], LuzmoVizItemWebComponent);
1082
1160
  export {
1083
- LuzmoDashboardWebComponent
1161
+ LuzmoDashboardWebComponent,
1162
+ LuzmoVizItemWebComponent
1084
1163
  };
@@ -51,11 +51,12 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
51
51
  browserErrorMsg: string;
52
52
  dashboardError: boolean;
53
53
  browserNotSupported: any[];
54
- VERSION: string;
54
+ version: string;
55
55
  protected isLibraryLoaded: boolean;
56
56
  protected dashboardReference: SharedLib.LuzmoElement;
57
57
  currentAuthKey: string;
58
58
  currentAuthToken: string;
59
+ isInitCalled: boolean;
59
60
  private attributesMap;
60
61
  _loadTimeoutHandle?: number;
61
62
  _onResize: () => void;
@@ -65,9 +66,7 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.ES6L
65
66
  iframeHeight?: string;
66
67
  iframeWidth?: string;
67
68
  _resizeObserver: ResizeObserver;
68
- constructor(inputParameters?: Record<keyof LuzmoDashboard, any>);
69
- private loadLibrary;
70
- private setInputParameters;
69
+ constructor();
71
70
  connectedCallback(): void;
72
71
  disconnectedCallback(): void;
73
72
  firstUpdated(): void;
@@ -0,0 +1,3 @@
1
+ import { LuzmoBaseVizItem } from './viz-item.base';
2
+ export declare class LuzmoVizItem extends LuzmoBaseVizItem {
3
+ }
@@ -0,0 +1,3 @@
1
+ import { LuzmoBaseVizItem } from './viz-item.base';
2
+ export declare class LuzmoVizItemWebComponent extends LuzmoBaseVizItem {
3
+ }