@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.
- package/dist/src/Routes.d.ts +4 -0
- package/dist/src/Routes.js +5 -0
- package/dist/src/Routes.js.map +1 -0
- package/dist/src/TtNavbar.d.ts +4 -1
- package/dist/src/TtNavbar.js +41 -14
- package/dist/src/TtNavbar.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/urlMappings.d.ts +3 -0
- package/dist/src/urlMappings.js +11 -0
- package/dist/src/urlMappings.js.map +1 -0
- package/dist/stories/index.stories.js +4 -1
- package/dist/stories/index.stories.js.map +1 -1
- package/dist/test/tt-navbar.test.js +16 -4
- package/dist/test/tt-navbar.test.js.map +1 -1
- package/dist/web/Routes.js +12 -0
- package/dist/web/Routes.js.map +7 -0
- package/dist/web/TtNavbar.js +54 -15
- package/dist/web/TtNavbar.js.map +3 -3
- package/dist/web/index.js +55 -15
- package/dist/web/index.js.map +3 -3
- package/dist/web/styles.js +1 -1
- package/dist/web/triptease-logo.js +1 -1
- package/dist/web/tt-navbar.js +54 -15
- package/dist/web/tt-navbar.js.map +3 -3
- package/dist/web/urlMappings.js +18 -0
- package/dist/web/urlMappings.js.map +7 -0
- package/package.json +1 -1
- package/src/Routes.ts +5 -0
- package/src/TtNavbar.ts +42 -14
- package/src/index.ts +1 -0
- package/src/urlMappings.ts +13 -0
- package/stories/index.stories.ts +4 -1
- package/test/tt-navbar.test.ts +20 -4
package/dist/web/styles.js
CHANGED
package/dist/web/tt-navbar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @triptease/tt-navbar v0.0.
|
|
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
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
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
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
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.
|
|
1136
|
-
return new URL(formattedPath, this.
|
|
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
|
|
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: "
|
|
1329
|
-
], TtNavbar.prototype, "
|
|
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);
|