@triptease/tt-navbar 0.0.35 → 0.0.37

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.37
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.35
2
+ * @triptease/tt-navbar v0.0.37
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -865,7 +865,7 @@ var i6 = e7(class extends i5 {
865
865
  }
866
866
  });
867
867
 
868
- // node_modules/@triptease/tt-combobox/node_modules/@triptease/icons/dist/src/icons/chevron-down.js
868
+ // ../../node_modules/@triptease/icons/dist/src/icons/chevron-down.js
869
869
  var chevronDown2 = `
870
870
  <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" class="bi bi-chevron-down chevron-down"
871
871
  viewBox="0 0 16 16" role="presentation">
@@ -874,12 +874,12 @@ var chevronDown2 = `
874
874
  stroke="currentColor"/>
875
875
  </svg>`;
876
876
 
877
- // node_modules/@triptease/tt-combobox/node_modules/@triptease/icons/dist/src/icons/alert.js
877
+ // ../../node_modules/@triptease/icons/dist/src/icons/alert.js
878
878
  var alert2 = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
879
879
  <path fill-rule="evenodd" clip-rule="evenodd" d="M10 20C15.5228 20 20 15.5228 20 10C20 4.47715 15.5228 0 10 0C4.47715 0 0 4.47715 0 10C0 15.5228 4.47715 20 10 20ZM9.25 5.75C9.25 5.33579 9.58579 5 10 5C10.4142 5 10.75 5.33579 10.75 5.75V11.25C10.75 11.6642 10.4142 12 10 12C9.58579 12 9.25 11.6642 9.25 11.25V5.75ZM10.75 13.75C10.75 14.1642 10.4142 14.5 10 14.5C9.58579 14.5 9.25 14.1642 9.25 13.75C9.25 13.3358 9.58579 13 10 13C10.4142 13 10.75 13.3358 10.75 13.75Z" fill="#3B353B"/>
880
880
  </svg>`;
881
881
 
882
- // node_modules/@triptease/tt-combobox/dist/src/styles.js
882
+ // ../../node_modules/@triptease/tt-combobox/dist/src/styles.js
883
883
  var styles = i`
884
884
  :host {
885
885
  display: flex;
@@ -1161,7 +1161,7 @@ var styles = i`
1161
1161
  }
1162
1162
  `;
1163
1163
 
1164
- // node_modules/@triptease/tt-combobox/dist/src/TtCombobox.js
1164
+ // ../../node_modules/@triptease/tt-combobox/dist/src/TtCombobox.js
1165
1165
  var TtCombobox = class extends i4 {
1166
1166
  get form() {
1167
1167
  return this.internals.form;
@@ -1604,7 +1604,7 @@ __decorate([
1604
1604
  n4({ type: Array, attribute: "value" })
1605
1605
  ], TtCombobox.prototype, "value", void 0);
1606
1606
 
1607
- // node_modules/@triptease/tt-combobox/dist/src/tt-combobox.js
1607
+ // ../../node_modules/@triptease/tt-combobox/dist/src/tt-combobox.js
1608
1608
  if (typeof window !== "undefined") {
1609
1609
  if (!window.customElements.get("tt-combobox")) {
1610
1610
  window.customElements.define("tt-combobox", TtCombobox);
@@ -2018,6 +2018,45 @@ 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: {
2045
+ ...window.Clerk.user?.unsafeMetadata,
2046
+ preferences: {
2047
+ ...window.Clerk.user?.unsafeMetadata?.preferences,
2048
+ ui: {
2049
+ ...window.Clerk.user?.unsafeMetadata?.preferences?.ui,
2050
+ navigationOpen: newState
2051
+ }
2052
+ }
2053
+ }
2054
+ });
2055
+ }
2056
+ this.host.requestUpdate();
2057
+ }
2058
+ };
2059
+
2021
2060
  // src/TtNavbar.ts
2022
2061
  var jsonArrayConverter = (value) => {
2023
2062
  if (!value) return [];
@@ -2033,6 +2072,7 @@ var TtNavbar = class extends i4 {
2033
2072
  this.campaignManagerUrl = "https://app.campaign-manager.triptease.io";
2034
2073
  this.clients = [];
2035
2074
  this.sidebarOpen = true;
2075
+ this.navbarController = new NavbarController(this);
2036
2076
  /*
2037
2077
  * Set the active state for the current page.
2038
2078
  *
@@ -2106,14 +2146,14 @@ var TtNavbar = class extends i4 {
2106
2146
  };
2107
2147
  this.toggleSidebar = () => {
2108
2148
  this.closeAllDetails();
2109
- this.sidebarOpen = !this.sidebarOpen;
2149
+ this.navbarController.toggle();
2110
2150
  };
2111
2151
  this.handleToggle = (e10) => {
2112
2152
  const { newState } = e10;
2113
2153
  const target = e10.currentTarget;
2114
2154
  if (newState === "open") {
2115
- if (!this.sidebarOpen) {
2116
- this.sidebarOpen = true;
2155
+ if (!this.navbarController.isOpen) {
2156
+ this.navbarController.toggle();
2117
2157
  }
2118
2158
  this.closeAllDetails(target);
2119
2159
  }
@@ -2153,8 +2193,8 @@ var TtNavbar = class extends i4 {
2153
2193
  }
2154
2194
  render() {
2155
2195
  return x`
2156
- <nav id=${this.id} class="${this.sidebarOpen ? "" : "sidebar-closed"}">
2157
- <div class="sidebar-header ${this.sidebarOpen ? "" : "sidebar-closed"}">
2196
+ <nav id=${this.id} class="${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2197
+ <div class="sidebar-header ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2158
2198
  <div class="logo">
2159
2199
  ${o8(tripteaseLogo)}
2160
2200
  </div>
@@ -2167,7 +2207,7 @@ var TtNavbar = class extends i4 {
2167
2207
  </button>
2168
2208
  </div>
2169
2209
 
2170
- <div class="nav-items ${this.sidebarOpen ? "" : "sidebar-closed"}">
2210
+ <div class="nav-items ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2171
2211
  <a
2172
2212
  class="nav-item"
2173
2213
  href=${this.buildUrl("/")}
@@ -2281,7 +2321,7 @@ var TtNavbar = class extends i4 {
2281
2321
  </div>
2282
2322
  </details>
2283
2323
  </div>
2284
- <div class="tertiary-nav ${this.sidebarOpen ? "" : "sidebar-closed"}">
2324
+ <div class="tertiary-nav ${this.navbarController.isOpen ? "" : "sidebar-closed"}">
2285
2325
  <div id="external-links" class="nav-items">
2286
2326
  <a
2287
2327
  class="nav-item external-link"
@@ -2315,22 +2355,24 @@ var TtNavbar = class extends i4 {
2315
2355
  <div class='nav-items'>
2316
2356
  <div id="client-selector">
2317
2357
  ${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
- `}
2358
+ <tt-combobox
2359
+ .openUpward=${true}
2360
+ .value=${this.clientKey ? [this.clientKey] : []}
2361
+ @change=${this.handleClientChange}
2362
+ >
2363
+ ${this.clients.map(
2364
+ (client) => x`
2365
+ <option slot="option" value=${client.clientKey}>
2366
+ ${client.displayName}
2367
+ </option>
2368
+ `
2369
+ )}
2370
+ </tt-combobox>
2371
+ ` : x`
2372
+ <div class="single-client-name">
2373
+ ${this.clients.find((m3) => m3.clientKey === this.clientKey)?.displayName}
2374
+ </div>
2375
+ `}
2334
2376
  </div>
2335
2377
  <a
2336
2378
  id="logout-link"