@triptease/tt-navbar 0.0.19 → 0.0.21

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.19
2
+ * @triptease/tt-navbar v0.0.21
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.19
2
+ * @triptease/tt-navbar v0.0.21
3
3
  */
4
4
 
5
5
  // src/triptease-logo.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.19
2
+ * @triptease/tt-navbar v0.0.21
3
3
  */
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1059,10 +1059,27 @@ var tripteaseLogo = `<svg width="112" height="32" viewBox="0 0 112 32" fill="no
1059
1059
  </defs>
1060
1060
  </svg>`;
1061
1061
 
1062
+ // src/urlMappings.ts
1063
+ var urlMappings = {
1064
+ "/paidsearch/$CLIENT_KEY/performance": "/channels",
1065
+ "/meta/$CLIENT_KEY/performance": "/channels",
1066
+ "/retargeting/$CLIENT_KEY/performance": "/channels",
1067
+ "/messages/$CLIENT_KEY/messages": "/channels",
1068
+ "/$CLIENT_KEY/email": "/channels",
1069
+ "/pricematch/$CLIENT_KEY/performance": "/channels",
1070
+ "/chat/insights/$CLIENT_KEY": "/channels"
1071
+ };
1072
+
1073
+ // src/Routes.ts
1074
+ var Routes = {
1075
+ CampaignManager: "CampaignManager"
1076
+ };
1077
+
1062
1078
  // src/TtNavbar.ts
1063
1079
  var TtNavbar = class extends i4 {
1064
1080
  constructor() {
1065
1081
  super(...arguments);
1082
+ this.campaignManagerUrl = "https://app.campaign-manager.triptease.io";
1066
1083
  this.sidebarOpen = true;
1067
1084
  /*
1068
1085
  * Set the active state for the current page.
@@ -1088,22 +1105,38 @@ var TtNavbar = class extends i4 {
1088
1105
  const currentPath = window.location.pathname;
1089
1106
  let bestMatch;
1090
1107
  let bestMatchLength = 0;
1091
- for (const link of this.allNavLinks) {
1092
- link.classList.remove("current-page");
1093
- if (link.hasAttribute("aria-current")) {
1094
- link.attributes.removeNamedItem("aria-current");
1108
+ if (this.activeRoute === Routes.CampaignManager) {
1109
+ const links = Object.values(this.allNavLinks);
1110
+ bestMatch = links.find((link) => link.id === Routes.CampaignManager);
1111
+ }
1112
+ if (!bestMatch && this.clientKey) {
1113
+ const parsedPath = currentPath.replace(this.clientKey, "$CLIENT_KEY");
1114
+ const mappedUrl = urlMappings[parsedPath];
1115
+ if (mappedUrl) {
1116
+ const links = Object.values(this.allNavLinks);
1117
+ bestMatch = links.find((link) => link.href.includes(mappedUrl));
1095
1118
  }
1096
- const linkPath = new URL(link.href).pathname;
1097
- if (currentPath.startsWith(linkPath)) {
1098
- if (linkPath.length > bestMatchLength) {
1099
- bestMatch = link;
1100
- bestMatchLength = linkPath.length;
1119
+ }
1120
+ if (!bestMatch) {
1121
+ for (const link of this.allNavLinks) {
1122
+ link.classList.remove("current-page");
1123
+ if (link.hasAttribute("aria-current")) {
1124
+ link.attributes.removeNamedItem("aria-current");
1125
+ }
1126
+ const linkPath = new URL(link.href).pathname;
1127
+ if (currentPath.startsWith(linkPath)) {
1128
+ if (linkPath.length > bestMatchLength) {
1129
+ bestMatch = link;
1130
+ bestMatchLength = linkPath.length;
1131
+ }
1101
1132
  }
1102
1133
  }
1103
1134
  }
1104
1135
  if (bestMatch) {
1105
1136
  bestMatch.classList.add("current-page");
1106
1137
  bestMatch.setAttribute("aria-current", "page");
1138
+ } else {
1139
+ console.error(`No matching nav link found for path: ${currentPath}`);
1107
1140
  }
1108
1141
  };
1109
1142
  this.closeAllDetails = (element) => {
@@ -1132,8 +1165,8 @@ var TtNavbar = class extends i4 {
1132
1165
  this.buildUrl = (path) => {
1133
1166
  if (!this.clientKey) throw new Error("clientKey is required");
1134
1167
  const formattedPath = path.replace("$CLIENT_KEY", this.clientKey);
1135
- if (!this.baseUrl) return formattedPath;
1136
- return new URL(formattedPath, this.baseUrl).toString();
1168
+ if (!this.platformUrl) return formattedPath;
1169
+ return new URL(formattedPath, this.platformUrl).toString();
1137
1170
  };
1138
1171
  this.onAnchorClick = (e8) => {
1139
1172
  if (this.navigate) {
@@ -1168,7 +1201,7 @@ var TtNavbar = class extends i4 {
1168
1201
  @click=${this.onAnchorClick}
1169
1202
  >${o7(home)}<span>Dashboard</span></a
1170
1203
  >
1171
- <a class="nav-item" href="https://app.campaign-manager.triptease.io"
1204
+ <a id="${Routes.CampaignManager}" class="nav-item" href=${this.campaignManagerUrl}
1172
1205
  >${o7(campaigns)}<span>Campaigns</span></a
1173
1206
  >
1174
1207
  <a
@@ -1325,11 +1358,17 @@ __decorateClass([
1325
1358
  n4({ type: Function })
1326
1359
  ], TtNavbar.prototype, "navigate", 2);
1327
1360
  __decorateClass([
1328
- n4({ type: String, attribute: "base-url" })
1329
- ], TtNavbar.prototype, "baseUrl", 2);
1361
+ n4({ type: String, attribute: "campaign-manager-url" })
1362
+ ], TtNavbar.prototype, "campaignManagerUrl", 2);
1363
+ __decorateClass([
1364
+ n4({ type: String, attribute: "platform-url" })
1365
+ ], TtNavbar.prototype, "platformUrl", 2);
1330
1366
  __decorateClass([
1331
1367
  n4({ type: String, attribute: "client-key" })
1332
1368
  ], TtNavbar.prototype, "clientKey", 2);
1369
+ __decorateClass([
1370
+ n4({ type: String, attribute: "active-route" })
1371
+ ], TtNavbar.prototype, "activeRoute", 2);
1333
1372
  __decorateClass([
1334
1373
  r6("details")
1335
1374
  ], TtNavbar.prototype, "allDetailsElements", 2);