@triptease/tt-navbar 0.0.35 → 0.0.36

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.35
2
+ * @triptease/tt-navbar v0.0.36
3
3
  */
4
4
 
5
5
  // ../../node_modules/@lit/reactive-element/css-tag.js
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.35
2
+ * @triptease/tt-navbar v0.0.36
3
3
  */
4
4
 
5
5
  // src/triptease-logo.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.35
2
+ * @triptease/tt-navbar v0.0.36
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -2018,6 +2018,36 @@ var Routes = {
2018
2018
  CampaignManager: "CampaignManager"
2019
2019
  };
2020
2020
 
2021
+ // src/NavbarController.ts
2022
+ var NavbarController = class {
2023
+ constructor(host) {
2024
+ this._isOpen = true;
2025
+ (this.host = host).addController(this);
2026
+ }
2027
+ get isOpen() {
2028
+ return this._isOpen;
2029
+ }
2030
+ hostConnected() {
2031
+ if (window.Clerk) {
2032
+ const userSetting = window.Clerk.user?.unsafeMetadata?.preferences?.ui?.navigationOpen;
2033
+ if (userSetting !== void 0) {
2034
+ this._isOpen = userSetting;
2035
+ this.host.requestUpdate();
2036
+ }
2037
+ }
2038
+ }
2039
+ async toggle() {
2040
+ const newState = !this._isOpen;
2041
+ this._isOpen = newState;
2042
+ if (window.Clerk) {
2043
+ await window.Clerk.user?.update({
2044
+ unsafeMetadata: { preferences: { ui: { navigationOpen: newState } } }
2045
+ });
2046
+ }
2047
+ this.host.requestUpdate();
2048
+ }
2049
+ };
2050
+
2021
2051
  // src/TtNavbar.ts
2022
2052
  var jsonArrayConverter = (value) => {
2023
2053
  if (!value) return [];
@@ -2033,6 +2063,7 @@ var TtNavbar = class extends i4 {
2033
2063
  this.campaignManagerUrl = "https://app.campaign-manager.triptease.io";
2034
2064
  this.clients = [];
2035
2065
  this.sidebarOpen = true;
2066
+ this.navbarController = new NavbarController(this);
2036
2067
  /*
2037
2068
  * Set the active state for the current page.
2038
2069
  *
@@ -2106,14 +2137,14 @@ var TtNavbar = class extends i4 {
2106
2137
  };
2107
2138
  this.toggleSidebar = () => {
2108
2139
  this.closeAllDetails();
2109
- this.sidebarOpen = !this.sidebarOpen;
2140
+ this.navbarController.toggle();
2110
2141
  };
2111
2142
  this.handleToggle = (e10) => {
2112
2143
  const { newState } = e10;
2113
2144
  const target = e10.currentTarget;
2114
2145
  if (newState === "open") {
2115
- if (!this.sidebarOpen) {
2116
- this.sidebarOpen = true;
2146
+ if (!this.navbarController.isOpen) {
2147
+ this.navbarController.toggle();
2117
2148
  }
2118
2149
  this.closeAllDetails(target);
2119
2150
  }
@@ -2153,8 +2184,8 @@ var TtNavbar = class extends i4 {
2153
2184
  }
2154
2185
  render() {
2155
2186
  return x`
2156
- <nav id=${this.id} class="${this.sidebarOpen ? "" : "sidebar-closed"}">
2157
- <div class="sidebar-header ${this.sidebarOpen ? "" : "sidebar-closed"}">
2187
+ <nav id=${this.id} class="${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2188
+ <div class="sidebar-header ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2158
2189
  <div class="logo">
2159
2190
  ${o8(tripteaseLogo)}
2160
2191
  </div>
@@ -2167,7 +2198,7 @@ var TtNavbar = class extends i4 {
2167
2198
  </button>
2168
2199
  </div>
2169
2200
 
2170
- <div class="nav-items ${this.sidebarOpen ? "" : "sidebar-closed"}">
2201
+ <div class="nav-items ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2171
2202
  <a
2172
2203
  class="nav-item"
2173
2204
  href=${this.buildUrl("/")}
@@ -2281,7 +2312,7 @@ var TtNavbar = class extends i4 {
2281
2312
  </div>
2282
2313
  </details>
2283
2314
  </div>
2284
- <div class="tertiary-nav ${this.sidebarOpen ? "" : "sidebar-closed"}">
2315
+ <div class="tertiary-nav ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2285
2316
  <div id="external-links" class="nav-items">
2286
2317
  <a
2287
2318
  class="nav-item external-link"
@@ -2315,22 +2346,24 @@ var TtNavbar = class extends i4 {
2315
2346
  <div class='nav-items'>
2316
2347
  <div id="client-selector">
2317
2348
  ${this.clients.length > 1 ? x`
2318
- <tt-combobox
2319
- .openUpward=${true}
2320
- .value=${this.clientKey ? [this.clientKey] : []}
2321
- @change=${this.handleClientChange}
2322
- >
2323
- ${this.clients.map((client) => x`
2324
- <option slot="option" value=${client.clientKey}>
2325
- ${client.displayName}
2326
- </option>
2327
- `)}
2328
- </tt-combobox>
2329
- ` : x`
2330
- <div class="single-client-name">
2331
- ${this.clients.find((m3) => m3.clientKey === this.clientKey)?.displayName}
2332
- </div>
2333
- `}
2349
+ <tt-combobox
2350
+ .openUpward=${true}
2351
+ .value=${this.clientKey ? [this.clientKey] : []}
2352
+ @change=${this.handleClientChange}
2353
+ >
2354
+ ${this.clients.map(
2355
+ (client) => x`
2356
+ <option slot="option" value=${client.clientKey}>
2357
+ ${client.displayName}
2358
+ </option>
2359
+ `
2360
+ )}
2361
+ </tt-combobox>
2362
+ ` : x`
2363
+ <div class="single-client-name">
2364
+ ${this.clients.find((m3) => m3.clientKey === this.clientKey)?.displayName}
2365
+ </div>
2366
+ `}
2334
2367
  </div>
2335
2368
  <a
2336
2369
  id="logout-link"