@triptease/tt-navbar 0.0.34 → 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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @triptease/tt-navbar v0.0.36
3
+ */
4
+ //# sourceMappingURL=global.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/dist/web/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.34
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
  }
@@ -2143,16 +2174,18 @@ var TtNavbar = class extends i4 {
2143
2174
  }
2144
2175
  connectedCallback() {
2145
2176
  window.addEventListener("popstate", this.setActiveState);
2177
+ window.addEventListener("tetris:navigate", this.setActiveState);
2146
2178
  super.connectedCallback();
2147
2179
  }
2148
2180
  disconnectedCallback() {
2149
2181
  window.removeEventListener("popstate", this.setActiveState);
2182
+ window.removeEventListener("tetris:navigate", this.setActiveState);
2150
2183
  super.disconnectedCallback();
2151
2184
  }
2152
2185
  render() {
2153
2186
  return x`
2154
- <nav id=${this.id} class="${this.sidebarOpen ? "" : "sidebar-closed"}">
2155
- <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"}">
2156
2189
  <div class="logo">
2157
2190
  ${o8(tripteaseLogo)}
2158
2191
  </div>
@@ -2165,7 +2198,7 @@ var TtNavbar = class extends i4 {
2165
2198
  </button>
2166
2199
  </div>
2167
2200
 
2168
- <div class="nav-items ${this.sidebarOpen ? "" : "sidebar-closed"}">
2201
+ <div class="nav-items ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2169
2202
  <a
2170
2203
  class="nav-item"
2171
2204
  href=${this.buildUrl("/")}
@@ -2279,7 +2312,7 @@ var TtNavbar = class extends i4 {
2279
2312
  </div>
2280
2313
  </details>
2281
2314
  </div>
2282
- <div class="tertiary-nav ${this.sidebarOpen ? "" : "sidebar-closed"}">
2315
+ <div class="tertiary-nav ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2283
2316
  <div id="external-links" class="nav-items">
2284
2317
  <a
2285
2318
  class="nav-item external-link"
@@ -2313,22 +2346,24 @@ var TtNavbar = class extends i4 {
2313
2346
  <div class='nav-items'>
2314
2347
  <div id="client-selector">
2315
2348
  ${this.clients.length > 1 ? x`
2316
- <tt-combobox
2317
- .openUpward=${true}
2318
- .value=${this.clientKey ? [this.clientKey] : []}
2319
- @change=${this.handleClientChange}
2320
- >
2321
- ${this.clients.map((client) => x`
2322
- <option slot="option" value=${client.clientKey}>
2323
- ${client.displayName}
2324
- </option>
2325
- `)}
2326
- </tt-combobox>
2327
- ` : x`
2328
- <div class="single-client-name">
2329
- ${this.clients.find((m3) => m3.clientKey === this.clientKey)?.displayName}
2330
- </div>
2331
- `}
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
+ `}
2332
2367
  </div>
2333
2368
  <a
2334
2369
  id="logout-link"