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