@swisspost/internet-header 1.15.12 → 1.15.14

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.
Files changed (42) hide show
  1. package/dist/cjs/index.cjs.js +2 -2
  2. package/dist/cjs/{post-internet-header-73538cc1.js → post-internet-header-47db5e7d.js} +43 -38
  3. package/dist/cjs/post-search-5990da07.js +603 -0
  4. package/dist/cjs/post-search.cjs.entry.js +1 -1
  5. package/dist/cjs/swisspost-internet-header.cjs.entry.js +1 -1
  6. package/dist/collection/components/post-search/post-search.css +1 -1
  7. package/dist/collection/services/route.service.js +41 -36
  8. package/dist/components/post-search2.js +1 -1
  9. package/dist/components/swisspost-internet-header.js +43 -38
  10. package/dist/docs.json +1 -1
  11. package/dist/esm/index.js +2 -2
  12. package/dist/esm/{post-internet-header-96053f9b.js → post-internet-header-9d752aa2.js} +43 -38
  13. package/dist/esm/post-search-814427e8.js +601 -0
  14. package/dist/esm/post-search.entry.js +1 -1
  15. package/dist/esm/swisspost-internet-header.entry.js +1 -1
  16. package/dist/esm-es5/index.js +1 -1
  17. package/dist/esm-es5/post-internet-header-9d752aa2.js +1 -0
  18. package/dist/esm-es5/post-search-814427e8.js +1 -0
  19. package/dist/esm-es5/post-search.entry.js +1 -1
  20. package/dist/esm-es5/swisspost-internet-header.entry.js +1 -1
  21. package/dist/swisspost-internet-header/index.esm.js +1 -1
  22. package/dist/swisspost-internet-header/{p-fcdc1363.entry.js → p-0518eae1.entry.js} +1 -1
  23. package/dist/swisspost-internet-header/{p-e5cbad90.system.js → p-3a52d871.system.js} +1 -1
  24. package/dist/swisspost-internet-header/p-46fb08ff.system.js +1 -0
  25. package/dist/swisspost-internet-header/p-4dbf53e6.system.js +1 -0
  26. package/dist/swisspost-internet-header/p-695fe962.system.js +1 -1
  27. package/dist/swisspost-internet-header/p-75fb959c.js +1 -0
  28. package/dist/swisspost-internet-header/{p-41799f6b.system.entry.js → p-899a3c69.system.entry.js} +1 -1
  29. package/dist/swisspost-internet-header/{p-eb84e447.entry.js → p-9a8c8349.entry.js} +1 -1
  30. package/dist/swisspost-internet-header/{p-54a5d06a.system.entry.js → p-caf85cd6.system.entry.js} +1 -1
  31. package/dist/swisspost-internet-header/p-ed62821f.js +1 -0
  32. package/dist/swisspost-internet-header/swisspost-internet-header.esm.js +1 -1
  33. package/dist/types/services/route.service.d.ts +11 -11
  34. package/package.json +2 -2
  35. package/dist/cjs/post-search-b188f1a0.js +0 -603
  36. package/dist/esm/post-search-5ebe2715.js +0 -601
  37. package/dist/esm-es5/post-internet-header-96053f9b.js +0 -1
  38. package/dist/esm-es5/post-search-5ebe2715.js +0 -1
  39. package/dist/swisspost-internet-header/p-2e092180.js +0 -1
  40. package/dist/swisspost-internet-header/p-c073b381.system.js +0 -1
  41. package/dist/swisspost-internet-header/p-c164ea99.system.js +0 -1
  42. package/dist/swisspost-internet-header/p-c2ec169e.js +0 -1
@@ -17,7 +17,7 @@ import { d as defineCustomElement$2 } from './post-skiplinks2.js';
17
17
  /**
18
18
  * Activate the current route based on the config and the match mode
19
19
  * @param config Main Navigation Config
20
- * @param activeRouteProp Match mode
20
+ * @param activeRouteProp Match mode or custom URL to compare against
21
21
  * @returns Modified Main Navigation Config
22
22
  */
23
23
  const markActiveRoute = (config, activeRouteProp) => {
@@ -25,26 +25,28 @@ const markActiveRoute = (config, activeRouteProp) => {
25
25
  if (activeRouteProp === false) {
26
26
  return config;
27
27
  }
28
- // Set compare URL and check if activeRouteProp is valid
29
- let compareUrl;
28
+ // Set reference URL to compare nav items against
29
+ let referenceUrl;
30
+ let isRelativeReference = false;
30
31
  config = resetOverrideConfig(config);
31
32
  if (activeRouteProp === 'auto' || activeRouteProp === 'exact') {
32
33
  // Check if an active route is already configured, set override to that and return
33
34
  if (hasActivePortalRoute(config)) {
34
35
  return resetActiveStateToPortalConfig(config);
35
36
  }
36
- compareUrl = new URL(window.location.href);
37
+ referenceUrl = new URL(window.location.href);
37
38
  }
38
39
  else {
39
40
  try {
40
- compareUrl = new URL(activeRouteProp, document.location.origin);
41
+ isRelativeReference = activeRouteProp.startsWith('/') || activeRouteProp.startsWith('./');
42
+ referenceUrl = new URL(activeRouteProp, window.location.href);
41
43
  }
42
44
  catch (error) {
43
45
  console.warn(`Active Route: ${activeRouteProp} is not a valid URL. Navigation highlighting has been disabled.`);
44
46
  return config;
45
47
  }
46
48
  }
47
- const scoreList = compileScoreList(config, compareUrl, activeRouteProp);
49
+ const scoreList = compileScoreList(config, referenceUrl, activeRouteProp, isRelativeReference);
48
50
  if (scoreList.length === 0) {
49
51
  // No match found or already active links defined
50
52
  return config;
@@ -78,13 +80,13 @@ const resetOverrideConfig = (config) => {
78
80
  });
79
81
  };
80
82
  /**
81
- * Compile a list of scores based on the map mode, sorted in descending order
83
+ * Compile a list of scores based on how well nav items match the reference URL
82
84
  * @param config Main Nav Config
83
- * @param compareUrl Current Browser URL or a custom URL
85
+ * @param referenceUrl URL to compare nav items against (window.location or custom)
84
86
  * @param activeRouteProp Match mode
85
87
  * @returns A list of scored URLs if any matched
86
88
  */
87
- const compileScoreList = (config, compareUrl, activeRouteProp) => {
89
+ const compileScoreList = (config, referenceUrl, activeRouteProp, isRelativeReference) => {
88
90
  // Flag to check if the Portal set any active links or if there are any exact matches
89
91
  let hadAnyActiveLink = false;
90
92
  const scoreList = [];
@@ -93,7 +95,8 @@ const compileScoreList = (config, compareUrl, activeRouteProp) => {
93
95
  .forEach(mainNav => {
94
96
  var _a;
95
97
  try {
96
- const score = compareRoutes(compareUrl, new URL(mainNav.url), activeRouteProp);
98
+ const navItemUrl = new URL(mainNav.url);
99
+ const score = compareRoutes(referenceUrl, navItemUrl, isRelativeReference, activeRouteProp);
97
100
  hadAnyActiveLink = updateScoreList(scoreList, score, { main: mainNav, score }, hadAnyActiveLink);
98
101
  }
99
102
  catch (_b) {
@@ -109,8 +112,8 @@ const compileScoreList = (config, compareUrl, activeRouteProp) => {
109
112
  return;
110
113
  }
111
114
  try {
112
- const url = new URL(linklist.url);
113
- const score = compareRoutes(compareUrl, url, activeRouteProp);
115
+ const flyoutNavUrl = new URL(linklist.url);
116
+ const score = compareRoutes(referenceUrl, flyoutNavUrl, isRelativeReference, activeRouteProp);
114
117
  hadAnyActiveLink = updateScoreList(scoreList, score, { main: mainNav, sub: linklist, score }, hadAnyActiveLink);
115
118
  }
116
119
  catch (_a) {
@@ -135,46 +138,48 @@ function updateScoreList(scoreList, score, scoreListItem, hadAnyActiveLink) {
135
138
  return hadActiveLink;
136
139
  }
137
140
  /**
138
- * Compare two URLs for similarity based on a match mode
139
- * @param baseUrl Browser URL
140
- * @param compareUrl Navigatgion URL
141
+ * Compare a nav item URL against the reference URL for similarity
142
+ * @param referenceUrl URL we're comparing against (from window.location or custom)
143
+ * @param navItemUrl URL from the navigation item
141
144
  * @param matchMode exact or auto matching
142
- * @returns Score
145
+ * @returns Score indicating how well the URLs match
143
146
  */
144
- const compareRoutes = (baseUrl, compareUrl, matchMode) => {
145
- // One url is not defined or they don't share the same orign
146
- if (baseUrl === null || compareUrl === null || baseUrl.origin !== compareUrl.origin) {
147
+ const compareRoutes = (referenceUrl, navItemUrl, isRelativeReference, matchMode) => {
148
+ if (referenceUrl === null || navItemUrl === null) {
149
+ return 0;
150
+ }
151
+ // Only compare origins if reference URL is not relative
152
+ if (!isRelativeReference && referenceUrl.origin !== navItemUrl.origin) {
147
153
  return 0;
148
154
  }
149
- const baseUrlPath = baseUrl.pathname.toLocaleLowerCase();
150
- const compareUrlPath = compareUrl.pathname.toLocaleLowerCase();
151
- // Exact match, origin and pathname are the same
152
- if (baseUrlPath === compareUrlPath) {
155
+ const referenceUrlPath = referenceUrl.pathname.toLocaleLowerCase();
156
+ const navItemUrlPath = navItemUrl.pathname.toLocaleLowerCase();
157
+ // Exact match, pathname is the same
158
+ if (referenceUrlPath === navItemUrlPath) {
153
159
  return Infinity;
154
160
  }
155
- // The basepath is longer than the comparison, a match is impossible
156
- if (baseUrl.pathname.length < compareUrl.pathname.length) {
161
+ // The reference path is shorter than nav item path, a match is impossible
162
+ if (referenceUrl.pathname.length < navItemUrl.pathname.length) {
157
163
  return 0;
158
164
  }
159
165
  if (matchMode === 'auto') {
160
- const baseSegments = [
161
- baseUrl.origin.toLocaleLowerCase(),
162
- ...baseUrlPath.split('/').filter(x => x !== null && x !== ''),
166
+ const referenceSegments = [
167
+ referenceUrl.origin.toLocaleLowerCase(),
168
+ ...referenceUrlPath.split('/').filter(x => x !== null && x !== ''),
163
169
  ];
164
- const compareSegments = [
165
- compareUrl.origin.toLocaleLowerCase(),
166
- ...compareUrlPath.split('/').filter(x => x !== null && x !== ''),
170
+ const navItemSegments = [
171
+ navItemUrl.origin.toLocaleLowerCase(),
172
+ ...navItemUrlPath.split('/').filter(x => x !== null && x !== ''),
167
173
  ];
168
- const score = getSimilarityScore(baseSegments, compareSegments);
169
- // If only some segments match, but not the whole smaller array, it's not a match
170
- return Math.min(baseSegments.length, compareSegments.length) === score ? score : 0;
174
+ const score = getSimilarityScore(referenceSegments, navItemSegments);
175
+ return Math.min(referenceSegments.length, navItemSegments.length) === score ? score : 0;
171
176
  }
172
177
  return 0;
173
178
  };
174
179
  /**
175
180
  * Check how many items in an array match
176
- * @param a Base array
177
- * @param b Compare array
181
+ * @param a Reference array
182
+ * @param b Nav item array to compare
178
183
  * @returns Score
179
184
  */
180
185
  const getSimilarityScore = (a, b) => {
@@ -373,7 +378,7 @@ const setMainNavigationIds = (navMainEntities) => {
373
378
  };
374
379
 
375
380
  const name = "@swisspost/internet-header";
376
- const version = "1.15.12";
381
+ const version = "1.15.14";
377
382
  const description = "The header for client facing applications.";
378
383
  const author = "Swiss Post <design-system@post.ch>";
379
384
  const license = "Apache-2.0";
@@ -414,7 +419,7 @@ const scripts = {
414
419
  generate: "stencil generate"
415
420
  };
416
421
  const dependencies = {
417
- "@swisspost/design-system-styles": "workspace:8.9.4",
422
+ "@swisspost/design-system-styles": "workspace:9.0.0",
418
423
  "body-scroll-lock": "4.0.0-beta.0",
419
424
  "iframe-resizer": "4.4.5",
420
425
  jquery: "3.7.1",
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2025-04-28T10:55:50",
2
+ "timestamp": "2025-05-12T14:46:26",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "4.19.2",
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { P as PostInternetHeader } from './post-internet-header-96053f9b.js';
1
+ export { P as PostInternetHeader } from './post-internet-header-9d752aa2.js';
2
2
  export { P as PostInternetBreadcrumbs } from './post-internet-breadcrumbs-853096c4.js';
3
3
  export { P as PostInternetFooter } from './post-internet-footer-3a7024bf.js';
4
4
  export { P as PostSkiplinks } from './post-skiplinks-8c64cda3.js';
@@ -6,7 +6,7 @@ export { P as PostMetaNavigation } from './post-meta-navigation-f2660b07.js';
6
6
  export { P as PostLanguageSwitch } from './post-language-switch-c6015c5b.js';
7
7
  export { P as PostLogo } from './post-logo-ca6f588b.js';
8
8
  export { P as PostMainNavigation } from './post-main-navigation-605861c5.js';
9
- export { P as PostSearch } from './post-search-5ebe2715.js';
9
+ export { P as PostSearch } from './post-search-814427e8.js';
10
10
  export { P as PostKlpLoginWidget } from './post-klp-login-widget-61768d66.js';
11
11
  import './index-bb0e68fd.js';
12
12
  import './index-d3f1363d.js';
@@ -10,7 +10,7 @@ import { I as If } from './if.component-d88d9e48.js';
10
10
  /**
11
11
  * Activate the current route based on the config and the match mode
12
12
  * @param config Main Navigation Config
13
- * @param activeRouteProp Match mode
13
+ * @param activeRouteProp Match mode or custom URL to compare against
14
14
  * @returns Modified Main Navigation Config
15
15
  */
16
16
  const markActiveRoute = (config, activeRouteProp) => {
@@ -18,26 +18,28 @@ const markActiveRoute = (config, activeRouteProp) => {
18
18
  if (activeRouteProp === false) {
19
19
  return config;
20
20
  }
21
- // Set compare URL and check if activeRouteProp is valid
22
- let compareUrl;
21
+ // Set reference URL to compare nav items against
22
+ let referenceUrl;
23
+ let isRelativeReference = false;
23
24
  config = resetOverrideConfig(config);
24
25
  if (activeRouteProp === 'auto' || activeRouteProp === 'exact') {
25
26
  // Check if an active route is already configured, set override to that and return
26
27
  if (hasActivePortalRoute(config)) {
27
28
  return resetActiveStateToPortalConfig(config);
28
29
  }
29
- compareUrl = new URL(window.location.href);
30
+ referenceUrl = new URL(window.location.href);
30
31
  }
31
32
  else {
32
33
  try {
33
- compareUrl = new URL(activeRouteProp, document.location.origin);
34
+ isRelativeReference = activeRouteProp.startsWith('/') || activeRouteProp.startsWith('./');
35
+ referenceUrl = new URL(activeRouteProp, window.location.href);
34
36
  }
35
37
  catch (error) {
36
38
  console.warn(`Active Route: ${activeRouteProp} is not a valid URL. Navigation highlighting has been disabled.`);
37
39
  return config;
38
40
  }
39
41
  }
40
- const scoreList = compileScoreList(config, compareUrl, activeRouteProp);
42
+ const scoreList = compileScoreList(config, referenceUrl, activeRouteProp, isRelativeReference);
41
43
  if (scoreList.length === 0) {
42
44
  // No match found or already active links defined
43
45
  return config;
@@ -71,13 +73,13 @@ const resetOverrideConfig = (config) => {
71
73
  });
72
74
  };
73
75
  /**
74
- * Compile a list of scores based on the map mode, sorted in descending order
76
+ * Compile a list of scores based on how well nav items match the reference URL
75
77
  * @param config Main Nav Config
76
- * @param compareUrl Current Browser URL or a custom URL
78
+ * @param referenceUrl URL to compare nav items against (window.location or custom)
77
79
  * @param activeRouteProp Match mode
78
80
  * @returns A list of scored URLs if any matched
79
81
  */
80
- const compileScoreList = (config, compareUrl, activeRouteProp) => {
82
+ const compileScoreList = (config, referenceUrl, activeRouteProp, isRelativeReference) => {
81
83
  // Flag to check if the Portal set any active links or if there are any exact matches
82
84
  let hadAnyActiveLink = false;
83
85
  const scoreList = [];
@@ -86,7 +88,8 @@ const compileScoreList = (config, compareUrl, activeRouteProp) => {
86
88
  .forEach(mainNav => {
87
89
  var _a;
88
90
  try {
89
- const score = compareRoutes(compareUrl, new URL(mainNav.url), activeRouteProp);
91
+ const navItemUrl = new URL(mainNav.url);
92
+ const score = compareRoutes(referenceUrl, navItemUrl, isRelativeReference, activeRouteProp);
90
93
  hadAnyActiveLink = updateScoreList(scoreList, score, { main: mainNav, score }, hadAnyActiveLink);
91
94
  }
92
95
  catch (_b) {
@@ -102,8 +105,8 @@ const compileScoreList = (config, compareUrl, activeRouteProp) => {
102
105
  return;
103
106
  }
104
107
  try {
105
- const url = new URL(linklist.url);
106
- const score = compareRoutes(compareUrl, url, activeRouteProp);
108
+ const flyoutNavUrl = new URL(linklist.url);
109
+ const score = compareRoutes(referenceUrl, flyoutNavUrl, isRelativeReference, activeRouteProp);
107
110
  hadAnyActiveLink = updateScoreList(scoreList, score, { main: mainNav, sub: linklist, score }, hadAnyActiveLink);
108
111
  }
109
112
  catch (_a) {
@@ -128,46 +131,48 @@ function updateScoreList(scoreList, score, scoreListItem, hadAnyActiveLink) {
128
131
  return hadActiveLink;
129
132
  }
130
133
  /**
131
- * Compare two URLs for similarity based on a match mode
132
- * @param baseUrl Browser URL
133
- * @param compareUrl Navigatgion URL
134
+ * Compare a nav item URL against the reference URL for similarity
135
+ * @param referenceUrl URL we're comparing against (from window.location or custom)
136
+ * @param navItemUrl URL from the navigation item
134
137
  * @param matchMode exact or auto matching
135
- * @returns Score
138
+ * @returns Score indicating how well the URLs match
136
139
  */
137
- const compareRoutes = (baseUrl, compareUrl, matchMode) => {
138
- // One url is not defined or they don't share the same orign
139
- if (baseUrl === null || compareUrl === null || baseUrl.origin !== compareUrl.origin) {
140
+ const compareRoutes = (referenceUrl, navItemUrl, isRelativeReference, matchMode) => {
141
+ if (referenceUrl === null || navItemUrl === null) {
142
+ return 0;
143
+ }
144
+ // Only compare origins if reference URL is not relative
145
+ if (!isRelativeReference && referenceUrl.origin !== navItemUrl.origin) {
140
146
  return 0;
141
147
  }
142
- const baseUrlPath = baseUrl.pathname.toLocaleLowerCase();
143
- const compareUrlPath = compareUrl.pathname.toLocaleLowerCase();
144
- // Exact match, origin and pathname are the same
145
- if (baseUrlPath === compareUrlPath) {
148
+ const referenceUrlPath = referenceUrl.pathname.toLocaleLowerCase();
149
+ const navItemUrlPath = navItemUrl.pathname.toLocaleLowerCase();
150
+ // Exact match, pathname is the same
151
+ if (referenceUrlPath === navItemUrlPath) {
146
152
  return Infinity;
147
153
  }
148
- // The basepath is longer than the comparison, a match is impossible
149
- if (baseUrl.pathname.length < compareUrl.pathname.length) {
154
+ // The reference path is shorter than nav item path, a match is impossible
155
+ if (referenceUrl.pathname.length < navItemUrl.pathname.length) {
150
156
  return 0;
151
157
  }
152
158
  if (matchMode === 'auto') {
153
- const baseSegments = [
154
- baseUrl.origin.toLocaleLowerCase(),
155
- ...baseUrlPath.split('/').filter(x => x !== null && x !== ''),
159
+ const referenceSegments = [
160
+ referenceUrl.origin.toLocaleLowerCase(),
161
+ ...referenceUrlPath.split('/').filter(x => x !== null && x !== ''),
156
162
  ];
157
- const compareSegments = [
158
- compareUrl.origin.toLocaleLowerCase(),
159
- ...compareUrlPath.split('/').filter(x => x !== null && x !== ''),
163
+ const navItemSegments = [
164
+ navItemUrl.origin.toLocaleLowerCase(),
165
+ ...navItemUrlPath.split('/').filter(x => x !== null && x !== ''),
160
166
  ];
161
- const score = getSimilarityScore(baseSegments, compareSegments);
162
- // If only some segments match, but not the whole smaller array, it's not a match
163
- return Math.min(baseSegments.length, compareSegments.length) === score ? score : 0;
167
+ const score = getSimilarityScore(referenceSegments, navItemSegments);
168
+ return Math.min(referenceSegments.length, navItemSegments.length) === score ? score : 0;
164
169
  }
165
170
  return 0;
166
171
  };
167
172
  /**
168
173
  * Check how many items in an array match
169
- * @param a Base array
170
- * @param b Compare array
174
+ * @param a Reference array
175
+ * @param b Nav item array to compare
171
176
  * @returns Score
172
177
  */
173
178
  const getSimilarityScore = (a, b) => {
@@ -366,7 +371,7 @@ const setMainNavigationIds = (navMainEntities) => {
366
371
  };
367
372
 
368
373
  const name = "@swisspost/internet-header";
369
- const version = "1.15.12";
374
+ const version = "1.15.14";
370
375
  const description = "The header for client facing applications.";
371
376
  const author = "Swiss Post <design-system@post.ch>";
372
377
  const license = "Apache-2.0";
@@ -407,7 +412,7 @@ const scripts = {
407
412
  generate: "stencil generate"
408
413
  };
409
414
  const dependencies = {
410
- "@swisspost/design-system-styles": "workspace:8.9.4",
415
+ "@swisspost/design-system-styles": "workspace:9.0.0",
411
416
  "body-scroll-lock": "4.0.0-beta.0",
412
417
  "iframe-resizer": "4.4.5",
413
418
  jquery: "3.7.1",