@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.
@@ -0,0 +1,23 @@
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import * as SharedLib from '@luzmo/shared-embed';
3
+ export declare class LuzmoBaseVizItem extends LitElement {
4
+ appServer: string;
5
+ apiHost: string;
6
+ slots: SharedLib.Slots;
7
+ options: SharedLib.VizItemOptions;
8
+ type?: SharedLib.ItemType;
9
+ authKey?: string;
10
+ authToken?: string;
11
+ version?: string;
12
+ contextId?: string;
13
+ canFilter?: SharedLib.CanFilter;
14
+ filters?: SharedLib.FilterGroup[];
15
+ chartElement: HTMLElement;
16
+ static styles: import("lit").CSSResult;
17
+ constructor();
18
+ protected firstUpdated(_changedProperties: PropertyValues): Promise<void>;
19
+ private createAndAppendElement;
20
+ private updateVizItemProperties;
21
+ updated(changedProperties: PropertyValues): Promise<void>;
22
+ protected render(): unknown;
23
+ }
@@ -42,7 +42,8 @@ var __decorateClass = (decorators, target, key, kind) => {
42
42
  // libs/embed-libs/embed/src/index.libs.ts
43
43
  var index_libs_exports = {};
44
44
  __export(index_libs_exports, {
45
- LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent
45
+ LuzmoDashboardWebComponent: () => LuzmoDashboardWebComponent,
46
+ LuzmoVizItemWebComponent: () => LuzmoVizItemWebComponent
46
47
  });
47
48
  module.exports = __toCommonJS(index_libs_exports);
48
49
 
@@ -1489,6 +1490,21 @@ var _extendAndValidate = (dashboardContent) => {
1489
1490
  }
1490
1491
  };
1491
1492
 
1493
+ // libs/embed-libs/shared-embed/src/lib/models/viz-item.model.ts
1494
+ var libraryTypeToWebComponentTypeMapping = {
1495
+ type: "type",
1496
+ theme: "theme",
1497
+ slots: "slots",
1498
+ options: "options",
1499
+ appServer: "app-server",
1500
+ apiHost: "api-host",
1501
+ authKey: "auth-key",
1502
+ authToken: "auth-token",
1503
+ contextId: "context-id",
1504
+ canFilter: "can-filter",
1505
+ filters: "filters"
1506
+ };
1507
+
1492
1508
  // libs/embed-libs/shared-embed/src/lib/constants/class-constants.ts
1493
1509
  var luzmoEmbedContainerClass = "luzmo-embed-container";
1494
1510
 
@@ -1556,6 +1572,21 @@ function __federationMethodWrapDefault(module2, need) {
1556
1572
  async function __federationMethodGetRemote(remoteName, componentName) {
1557
1573
  return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
1558
1574
  }
1575
+ async function loadLibrary(appServer, componentName = "DashboardApp") {
1576
+ if (remotesMap[appServer]) {
1577
+ return remotesMap[appServer].module;
1578
+ }
1579
+ remotesMap[appServer] = {
1580
+ url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
1581
+ format: "esm",
1582
+ from: "vite",
1583
+ module: void 0
1584
+ };
1585
+ const module2 = await __federationMethodGetRemote(appServer, `./${componentName}`);
1586
+ const wrappedModule = __federationMethodWrapDefault(module2, true);
1587
+ remotesMap[appServer].module = wrappedModule;
1588
+ return wrappedModule;
1589
+ }
1559
1590
 
1560
1591
  // node_modules/lit-html/lit-html.js
1561
1592
  var t3 = globalThis;
@@ -1906,7 +1937,7 @@ var o5 = e6(class extends i4 {
1906
1937
  });
1907
1938
 
1908
1939
  // libs/embed-libs/embed/package.json
1909
- var version = "5.1.2";
1940
+ var version = "5.1.3-beta.0";
1910
1941
 
1911
1942
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
1912
1943
  var LuzmoService = class {
@@ -2110,10 +2141,6 @@ var dashboardStyles = i`
2110
2141
  border: 0;
2111
2142
  }
2112
2143
 
2113
- .luzmo-embed-dashboard-ede {
2114
- min-height: 100vh;
2115
- }
2116
-
2117
2144
  .luzmo-embed-container-ede {
2118
2145
  width: 100%;
2119
2146
  height: 100%;
@@ -2190,7 +2217,7 @@ var dashboardStyles = i`
2190
2217
 
2191
2218
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
2192
2219
  var LuzmoDashboard = class extends s3 {
2193
- constructor(inputParameters) {
2220
+ constructor() {
2194
2221
  super();
2195
2222
  this.language = "auto";
2196
2223
  this.screenMode = "auto";
@@ -2209,10 +2236,11 @@ var LuzmoDashboard = class extends s3 {
2209
2236
  this.browserErrorMsg = "";
2210
2237
  this.dashboardError = false;
2211
2238
  this.browserNotSupported = [];
2212
- this.VERSION = version + "-wc-luzmo";
2239
+ this.version = version + "-wc-luzmo";
2213
2240
  this.isLibraryLoaded = false;
2214
2241
  this.currentAuthKey = null;
2215
2242
  this.currentAuthToken = null;
2243
+ this.isInitCalled = false;
2216
2244
  this.attributesMap = {
2217
2245
  dashboardId: "dashboard-id",
2218
2246
  dashboardSlug: "dashboard-slug",
@@ -2242,7 +2270,6 @@ var LuzmoDashboard = class extends s3 {
2242
2270
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
2243
2271
  this.iframeLoaded = false;
2244
2272
  this.promises = {};
2245
- this.setInputParameters(inputParameters);
2246
2273
  this.params = this._setOptions();
2247
2274
  this._onResize = () => {
2248
2275
  if (this.shadowRoot?.querySelector(".dashboard-container")) {
@@ -2273,60 +2300,6 @@ var LuzmoDashboard = class extends s3 {
2273
2300
  });
2274
2301
  });
2275
2302
  }
2276
- loadLibrary(appServer) {
2277
- if (remotesMap[appServer]) {
2278
- return Promise.resolve(remotesMap[appServer].module);
2279
- }
2280
- remotesMap[appServer] = {
2281
- url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
2282
- format: "esm",
2283
- from: "vite",
2284
- module: void 0
2285
- };
2286
- return __federationMethodGetRemote(appServer, "./DashboardApp").then((module2) => {
2287
- const wrappedModule = __federationMethodWrapDefault(module2, true);
2288
- remotesMap[appServer].module = wrappedModule;
2289
- return wrappedModule;
2290
- });
2291
- }
2292
- setInputParameters(inputParameters) {
2293
- if (!inputParameters) {
2294
- return;
2295
- }
2296
- const params = [
2297
- "dashboardId",
2298
- "dashboardSlug",
2299
- "itemId",
2300
- "language",
2301
- "qeVersion",
2302
- "screenMode",
2303
- "switchScreenModeOnResize",
2304
- "accentColor",
2305
- "mainColor",
2306
- "authToken",
2307
- "authKey",
2308
- "editMode",
2309
- "loaderBackground",
2310
- "loaderFontColor",
2311
- "loaderSpinnerColor",
2312
- "loaderSpinnerBackground",
2313
- "timezoneId",
2314
- "itemDimensions",
2315
- "apiHost"
2316
- ];
2317
- for (const key of params) {
2318
- const value = inputParameters[key];
2319
- if (value) {
2320
- this[key] = value;
2321
- }
2322
- }
2323
- if (inputParameters.experimental) {
2324
- this.experimental = inputParameters.experimental;
2325
- }
2326
- if (inputParameters.appServer) {
2327
- this.appServer = addTrailingSlash(inputParameters.appServer);
2328
- }
2329
- }
2330
2303
  // Set resize event listener
2331
2304
  connectedCallback() {
2332
2305
  super.connectedCallback();
@@ -2345,7 +2318,6 @@ var LuzmoDashboard = class extends s3 {
2345
2318
  this._loaderMsg = getLoader(this)?.loadingMsg;
2346
2319
  this._loaderStyles();
2347
2320
  luzmo_service_default._components.push(this);
2348
- this.initComponent();
2349
2321
  if (this.luzmoEmbedContainer) {
2350
2322
  this._resizeObserver.observe(this.luzmoEmbedContainer);
2351
2323
  }
@@ -2353,7 +2325,7 @@ var LuzmoDashboard = class extends s3 {
2353
2325
  initComponent() {
2354
2326
  this.params = this._setOptions();
2355
2327
  if (this.getIsViewMode()) {
2356
- this.loadLibrary(this.params.appServer).then(async () => {
2328
+ loadLibrary(this.params.appServer).then(async () => {
2357
2329
  this.isLibraryLoaded = true;
2358
2330
  await this.updateComplete;
2359
2331
  const oldReference = this.renderRoot.querySelector("dashboard-component");
@@ -2425,11 +2397,21 @@ var LuzmoDashboard = class extends s3 {
2425
2397
  "timezoneId",
2426
2398
  "itemDimensions"
2427
2399
  ]);
2400
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
2401
+ let callInitComponent = false;
2402
+ for (const condition of conditionsToCheck) {
2403
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition];
2404
+ }
2405
+ if (callInitComponent && !this.isInitCalled) {
2406
+ this.initComponent();
2407
+ this.isInitCalled = true;
2408
+ return;
2409
+ }
2428
2410
  if (this.getIsViewMode()) {
2429
2411
  if (this.dashboardReference) {
2430
2412
  for (const [propertyName] of changedProperties.entries()) {
2431
2413
  if (propertyName === "appSever") {
2432
- this.loadLibrary(changedProperties[propertyName]).then(async () => {
2414
+ loadLibrary(changedProperties[propertyName]).then(async () => {
2433
2415
  this.isLibraryLoaded = true;
2434
2416
  await this.updateComplete;
2435
2417
  this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
@@ -2637,7 +2619,7 @@ var LuzmoDashboard = class extends s3 {
2637
2619
  ${this.dashboardId || this.dashboardSlug ? x`
2638
2620
  ${loader}
2639
2621
  <iframe
2640
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
2622
+ class="luzmo-embed-dashboard"
2641
2623
  id="${this._iframeId}"
2642
2624
  name="${this._iframeId}"
2643
2625
  style=${o5(this.iframeStyle)}
@@ -2928,7 +2910,7 @@ __decorateClass([
2928
2910
  ], LuzmoDashboard.prototype, "browserNotSupported", 2);
2929
2911
  __decorateClass([
2930
2912
  n3()
2931
- ], LuzmoDashboard.prototype, "VERSION", 2);
2913
+ ], LuzmoDashboard.prototype, "version", 2);
2932
2914
  __decorateClass([
2933
2915
  r4()
2934
2916
  ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
@@ -2941,6 +2923,9 @@ __decorateClass([
2941
2923
  __decorateClass([
2942
2924
  r4()
2943
2925
  ], LuzmoDashboard.prototype, "currentAuthToken", 2);
2926
+ __decorateClass([
2927
+ r4()
2928
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
2944
2929
 
2945
2930
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-web-component.ts
2946
2931
  var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
@@ -2948,6 +2933,127 @@ var LuzmoDashboardWebComponent = class extends LuzmoDashboard {
2948
2933
  LuzmoDashboardWebComponent = __decorateClass([
2949
2934
  t("luzmo-dashboard-web-component")
2950
2935
  ], LuzmoDashboardWebComponent);
2936
+
2937
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
2938
+ var LuzmoBaseVizItem = class extends s3 {
2939
+ constructor() {
2940
+ super();
2941
+ this.appServer = "https://app.luzmo.com";
2942
+ this.apiHost = "https://api.luzmo.com";
2943
+ this.slots = [];
2944
+ this.options = {
2945
+ title: {
2946
+ en: ""
2947
+ },
2948
+ theme: "default"
2949
+ };
2950
+ this.version = version + "-wc-luzmo";
2951
+ }
2952
+ static {
2953
+ // Static styles to set host display to block, else it is not shown at all for some reason.
2954
+ this.styles = i`
2955
+ :host {
2956
+ display: block;
2957
+ width: 100%;
2958
+ height: 100%;
2959
+ }
2960
+ `;
2961
+ }
2962
+ async firstUpdated(_changedProperties) {
2963
+ super.firstUpdated(_changedProperties);
2964
+ if (this.type) {
2965
+ await loadLibrary(this.appServer, "DashboardApp");
2966
+ this.createAndAppendElement();
2967
+ }
2968
+ }
2969
+ createAndAppendElement() {
2970
+ if (!this.chartElement) {
2971
+ this.chartElement = document.createElement("chart-component");
2972
+ this.chartElement.setAttribute("embedding-mode", "chart");
2973
+ this.updateVizItemProperties();
2974
+ this.renderRoot.append(this.chartElement);
2975
+ }
2976
+ }
2977
+ updateVizItemProperties() {
2978
+ if (this.chartElement) {
2979
+ for (const key in libraryTypeToWebComponentTypeMapping) {
2980
+ const value = this[key];
2981
+ if (value) {
2982
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
2983
+ this.chartElement.setAttribute(
2984
+ libraryTypeToWebComponentTypeMapping[key],
2985
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
2986
+ );
2987
+ }
2988
+ }
2989
+ }
2990
+ }
2991
+ async updated(changedProperties) {
2992
+ if (this.chartElement) {
2993
+ for (const [propertyName] of changedProperties.entries()) {
2994
+ const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
2995
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
2996
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
2997
+ }
2998
+ } else {
2999
+ if (this.type) {
3000
+ await loadLibrary(this.appServer, "DashboardApp");
3001
+ this.createAndAppendElement();
3002
+ }
3003
+ }
3004
+ }
3005
+ render() {
3006
+ return x` `;
3007
+ }
3008
+ };
3009
+ __decorateClass([
3010
+ n3()
3011
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
3012
+ __decorateClass([
3013
+ n3()
3014
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
3015
+ __decorateClass([
3016
+ n3({ type: Array })
3017
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
3018
+ __decorateClass([
3019
+ n3({ type: Object })
3020
+ ], LuzmoBaseVizItem.prototype, "options", 2);
3021
+ __decorateClass([
3022
+ n3()
3023
+ ], LuzmoBaseVizItem.prototype, "type", 2);
3024
+ __decorateClass([
3025
+ n3()
3026
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
3027
+ __decorateClass([
3028
+ n3()
3029
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
3030
+ __decorateClass([
3031
+ n3()
3032
+ ], LuzmoBaseVizItem.prototype, "version", 2);
3033
+ __decorateClass([
3034
+ n3()
3035
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
3036
+ __decorateClass([
3037
+ n3({
3038
+ converter: (value) => {
3039
+ try {
3040
+ return JSON.parse(value);
3041
+ } catch (exc) {
3042
+ return value;
3043
+ }
3044
+ }
3045
+ })
3046
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
3047
+ __decorateClass([
3048
+ n3({ type: Array })
3049
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
3050
+
3051
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-web-component.ts
3052
+ var LuzmoVizItemWebComponent = class extends LuzmoBaseVizItem {
3053
+ };
3054
+ LuzmoVizItemWebComponent = __decorateClass([
3055
+ t("luzmo-viz-item-web-component")
3056
+ ], LuzmoVizItemWebComponent);
2951
3057
  /*! Bundled license information:
2952
3058
 
2953
3059
  @lit/reactive-element/decorators/custom-element.js: