@triptease/tt-navbar 0.0.40 → 0.0.42

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.40
2
+ * @triptease/tt-navbar v0.0.42
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -2027,23 +2027,34 @@ var Routes = {
2027
2027
  var NavbarController = class {
2028
2028
  constructor(host) {
2029
2029
  this._isOpen = true;
2030
+ this._hasInitialized = false;
2030
2031
  (this.host = host).addController(this);
2031
2032
  }
2032
2033
  get isOpen() {
2033
2034
  return this._isOpen;
2034
2035
  }
2035
- hostConnected() {
2036
- if (window.Clerk) {
2037
- const userSetting = window.Clerk.user?.unsafeMetadata?.preferences?.ui?.navigationOpen;
2038
- if (userSetting !== void 0) {
2039
- this._isOpen = userSetting;
2040
- this.host.requestUpdate();
2041
- }
2036
+ hostUpdate() {
2037
+ if (!this._hasInitialized && window.Clerk) {
2038
+ this._removeClerkListener = window.Clerk.addListener((resources) => {
2039
+ const { user: user2 } = resources;
2040
+ if (user2 && !this._hasInitialized) {
2041
+ const navigationOpen = user2.unsafeMetadata?.preferences?.ui?.navigationOpen;
2042
+ if (navigationOpen !== void 0) {
2043
+ this._isOpen = navigationOpen;
2044
+ this.host.requestUpdate();
2045
+ }
2046
+ this._hasInitialized = true;
2047
+ }
2048
+ });
2049
+ }
2050
+ }
2051
+ hostDisconnected() {
2052
+ if (this._removeClerkListener) {
2053
+ this._removeClerkListener();
2042
2054
  }
2043
2055
  }
2044
2056
  async toggle() {
2045
- const newState = !this._isOpen;
2046
- this._isOpen = newState;
2057
+ this._isOpen = !this._isOpen;
2047
2058
  if (window.Clerk) {
2048
2059
  await window.Clerk.user?.update({
2049
2060
  unsafeMetadata: {
@@ -2052,7 +2063,7 @@ var NavbarController = class {
2052
2063
  ...window.Clerk.user?.unsafeMetadata?.preferences,
2053
2064
  ui: {
2054
2065
  ...window.Clerk.user?.unsafeMetadata?.preferences?.ui,
2055
- navigationOpen: newState
2066
+ navigationOpen: this.isOpen
2056
2067
  }
2057
2068
  }
2058
2069
  }
@@ -2113,7 +2124,6 @@ var TtNavbar = class extends i4 {
2113
2124
  const clientSpecificUrl = mappedUrl.includes("$CLIENT_KEY") ? mappedUrl.replace("$CLIENT_KEY", this.clientKey) : mappedUrl;
2114
2125
  const links = Object.values(this.allNavLinks);
2115
2126
  bestMatch = links.find((link) => link.href.includes(clientSpecificUrl));
2116
- console.log({ mappedUrl, clientSpecificUrl, bestMatch });
2117
2127
  }
2118
2128
  }
2119
2129
  if (!bestMatch) {
@@ -2375,24 +2385,24 @@ var TtNavbar = class extends i4 {
2375
2385
  <div class='nav-items'>
2376
2386
  <div id="client-selector">
2377
2387
  ${this.clients.length > 1 ? x`
2378
- <tt-combobox
2379
- .openUpward=${true}
2380
- .value=${this.clientKey ? [this.clientKey] : []}
2381
- @change=${this.handleClientChange}
2382
- >
2383
- ${this.clients.map(
2388
+ <tt-combobox
2389
+ .openUpward=${true}
2390
+ .value=${this.clientKey ? [this.clientKey] : []}
2391
+ @change=${this.handleClientChange}
2392
+ >
2393
+ ${this.clients.map(
2384
2394
  (client) => x`
2385
- <option slot="option" value=${client.clientKey}>
2386
- ${client.displayName}
2387
- </option>
2388
- `
2395
+ <option slot="option" value=${client.clientKey}>
2396
+ ${client.displayName}
2397
+ </option>
2398
+ `
2389
2399
  )}
2390
- </tt-combobox>
2391
- ` : x`
2392
- <div class="single-client-name">
2393
- ${this.clients.find((m3) => m3.clientKey === this.clientKey)?.displayName}
2394
- </div>
2395
- `}
2400
+ </tt-combobox>
2401
+ ` : x`
2402
+ <div class="single-client-name">
2403
+ ${this.clients.find((m3) => m3.clientKey === this.clientKey)?.displayName}
2404
+ </div>
2405
+ `}
2396
2406
  </div>
2397
2407
  <a
2398
2408
  id="logout-link"