@visma-swno/vsn-navigation 1.0.0-beta.4 → 1.1.0-beta.1

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.
@@ -62,6 +62,10 @@ export declare class VSNNavigation extends LitElement {
62
62
  notificationActive: boolean;
63
63
  private _currentItem;
64
64
  private _sideBarOpen;
65
+ private _resolvedModules;
66
+ private _modulesLoading;
67
+ private _modulesLoadToken;
68
+ private _resolveModules;
65
69
  static styles: CSSResult[];
66
70
  willUpdate(changed: Map<string, unknown>): void;
67
71
  private _getFirstLeafId;
@@ -25,7 +25,24 @@ function u(e, t, n, r) {
25
25
  //#region src/components/vsn-navigation.ts
26
26
  var d = class extends e {
27
27
  constructor(...e) {
28
- super(...e), this.lang = "en", this.showHelp = !1, this.feedback = null, this.showNotification = !1, this.notificationActive = !1, this._currentItem = "", this._sideBarOpen = !1;
28
+ super(...e), this.lang = "en", this.showHelp = !1, this.feedback = null, this.showNotification = !1, this.notificationActive = !1, this._currentItem = "", this._sideBarOpen = !1, this._resolvedModules = [], this._modulesLoading = !1, this._modulesLoadToken = 0;
29
+ }
30
+ _resolveModules() {
31
+ let e = this.modules?.modules;
32
+ if (!e) {
33
+ this._resolvedModules = [], this._modulesLoading = !1;
34
+ return;
35
+ }
36
+ if (Array.isArray(e)) {
37
+ this._resolvedModules = e, this._modulesLoading = !1;
38
+ return;
39
+ }
40
+ let t = ++this._modulesLoadToken;
41
+ this._resolvedModules = [], this._modulesLoading = !0, e().then((e) => {
42
+ t === this._modulesLoadToken && (this._resolvedModules = e, this._modulesLoading = !1);
43
+ }).catch(() => {
44
+ t === this._modulesLoadToken && (this._resolvedModules = [], this._modulesLoading = !1);
45
+ });
29
46
  }
30
47
  static {
31
48
  this.styles = [s, t`
@@ -50,7 +67,7 @@ var d = class extends e {
50
67
  `];
51
68
  }
52
69
  willUpdate(e) {
53
- e.has("tree") && this.tree && (this.tree.currentItem ? this._currentItem = this.tree.currentItem : this.tree.items.length > 0 && (this._currentItem = this._getFirstLeafId(this.tree.items[0])));
70
+ e.has("tree") && this.tree && (this.tree.currentItem ? this._currentItem = this.tree.currentItem : this.tree.items.length > 0 && (this._currentItem = this._getFirstLeafId(this.tree.items[0]))), e.has("modules") && this._resolveModules();
54
71
  }
55
72
  _getFirstLeafId(e) {
56
73
  if (c(e)) return e.id;
@@ -78,7 +95,7 @@ var d = class extends e {
78
95
  return n`
79
96
  <vsn-top-bar
80
97
  .tree=${this.tree}
81
- .modules=${this.modules?.items ?? []}
98
+ .modules=${this._resolvedModules}
82
99
  landing-page-url=${this.landingPageUrl ?? ""}
83
100
  ?show-help=${this.showHelp}
84
101
  help-url=${this.helpUrl ?? ""}
@@ -92,8 +109,10 @@ var d = class extends e {
92
109
  <div class="vsn-navigation__content">
93
110
  <vsn-side-bar
94
111
  .menu=${this._sideBarMenu}
95
- .modules=${this.modules?.items ?? []}
112
+ .modules=${this._resolvedModules}
96
113
  .activeModuleId=${this.modules?.activeModuleId}
114
+ .activeModuleLabel=${this.modules?.activeModuleLabel}
115
+ .modulesLoading=${this._modulesLoading}
97
116
  .auth=${this.auth}
98
117
  ?open=${this._sideBarOpen}
99
118
  @vsn-close=${this._onSideBarClose}
@@ -113,6 +132,6 @@ u([a()], d.prototype, "lang", void 0), u([a({ attribute: !1 })], d.prototype, "t
113
132
  })], d.prototype, "showNotification", void 0), u([a({
114
133
  type: Boolean,
115
134
  attribute: "notification-active"
116
- })], d.prototype, "notificationActive", void 0), u([o()], d.prototype, "_currentItem", void 0), u([o()], d.prototype, "_sideBarOpen", void 0), d = u([i("vsn-navigation")], d);
135
+ })], d.prototype, "notificationActive", void 0), u([o()], d.prototype, "_currentItem", void 0), u([o()], d.prototype, "_sideBarOpen", void 0), u([o()], d.prototype, "_resolvedModules", void 0), u([o()], d.prototype, "_modulesLoading", void 0), d = u([i("vsn-navigation")], d);
117
136
  //#endregion
118
137
  export { d as VSNNavigation, c as isTreeLeaf, l as isTreeParent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visma-swno/vsn-navigation",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.1.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {