@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.
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{post-internet-header-73538cc1.js → post-internet-header-47db5e7d.js} +43 -38
- package/dist/cjs/post-search-5990da07.js +603 -0
- package/dist/cjs/post-search.cjs.entry.js +1 -1
- package/dist/cjs/swisspost-internet-header.cjs.entry.js +1 -1
- package/dist/collection/components/post-search/post-search.css +1 -1
- package/dist/collection/services/route.service.js +41 -36
- package/dist/components/post-search2.js +1 -1
- package/dist/components/swisspost-internet-header.js +43 -38
- package/dist/docs.json +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/{post-internet-header-96053f9b.js → post-internet-header-9d752aa2.js} +43 -38
- package/dist/esm/post-search-814427e8.js +601 -0
- package/dist/esm/post-search.entry.js +1 -1
- package/dist/esm/swisspost-internet-header.entry.js +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/post-internet-header-9d752aa2.js +1 -0
- package/dist/esm-es5/post-search-814427e8.js +1 -0
- package/dist/esm-es5/post-search.entry.js +1 -1
- package/dist/esm-es5/swisspost-internet-header.entry.js +1 -1
- package/dist/swisspost-internet-header/index.esm.js +1 -1
- package/dist/swisspost-internet-header/{p-fcdc1363.entry.js → p-0518eae1.entry.js} +1 -1
- package/dist/swisspost-internet-header/{p-e5cbad90.system.js → p-3a52d871.system.js} +1 -1
- package/dist/swisspost-internet-header/p-46fb08ff.system.js +1 -0
- package/dist/swisspost-internet-header/p-4dbf53e6.system.js +1 -0
- package/dist/swisspost-internet-header/p-695fe962.system.js +1 -1
- package/dist/swisspost-internet-header/p-75fb959c.js +1 -0
- package/dist/swisspost-internet-header/{p-41799f6b.system.entry.js → p-899a3c69.system.entry.js} +1 -1
- package/dist/swisspost-internet-header/{p-eb84e447.entry.js → p-9a8c8349.entry.js} +1 -1
- package/dist/swisspost-internet-header/{p-54a5d06a.system.entry.js → p-caf85cd6.system.entry.js} +1 -1
- package/dist/swisspost-internet-header/p-ed62821f.js +1 -0
- package/dist/swisspost-internet-header/swisspost-internet-header.esm.js +1 -1
- package/dist/types/services/route.service.d.ts +11 -11
- package/package.json +2 -2
- package/dist/cjs/post-search-b188f1a0.js +0 -603
- package/dist/esm/post-search-5ebe2715.js +0 -601
- package/dist/esm-es5/post-internet-header-96053f9b.js +0 -1
- package/dist/esm-es5/post-search-5ebe2715.js +0 -1
- package/dist/swisspost-internet-header/p-2e092180.js +0 -1
- package/dist/swisspost-internet-header/p-c073b381.system.js +0 -1
- package/dist/swisspost-internet-header/p-c164ea99.system.js +0 -1
- 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
|
|
29
|
-
let
|
|
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
|
-
|
|
37
|
+
referenceUrl = new URL(window.location.href);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
40
|
try {
|
|
40
|
-
|
|
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,
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
113
|
-
const score = compareRoutes(
|
|
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
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
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 = (
|
|
145
|
-
|
|
146
|
-
|
|
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
|
|
150
|
-
const
|
|
151
|
-
// Exact match,
|
|
152
|
-
if (
|
|
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
|
|
156
|
-
if (
|
|
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
|
|
161
|
-
|
|
162
|
-
...
|
|
166
|
+
const referenceSegments = [
|
|
167
|
+
referenceUrl.origin.toLocaleLowerCase(),
|
|
168
|
+
...referenceUrlPath.split('/').filter(x => x !== null && x !== ''),
|
|
163
169
|
];
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
...
|
|
170
|
+
const navItemSegments = [
|
|
171
|
+
navItemUrl.origin.toLocaleLowerCase(),
|
|
172
|
+
...navItemUrlPath.split('/').filter(x => x !== null && x !== ''),
|
|
167
173
|
];
|
|
168
|
-
const score = getSimilarityScore(
|
|
169
|
-
|
|
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
|
|
177
|
-
* @param b
|
|
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.
|
|
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:
|
|
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
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { P as PostInternetHeader } from './post-internet-header-
|
|
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-
|
|
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
|
|
22
|
-
let
|
|
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
|
-
|
|
30
|
+
referenceUrl = new URL(window.location.href);
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
33
|
try {
|
|
33
|
-
|
|
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,
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
106
|
-
const score = compareRoutes(
|
|
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
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
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 = (
|
|
138
|
-
|
|
139
|
-
|
|
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
|
|
143
|
-
const
|
|
144
|
-
// Exact match,
|
|
145
|
-
if (
|
|
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
|
|
149
|
-
if (
|
|
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
|
|
154
|
-
|
|
155
|
-
...
|
|
159
|
+
const referenceSegments = [
|
|
160
|
+
referenceUrl.origin.toLocaleLowerCase(),
|
|
161
|
+
...referenceUrlPath.split('/').filter(x => x !== null && x !== ''),
|
|
156
162
|
];
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
...
|
|
163
|
+
const navItemSegments = [
|
|
164
|
+
navItemUrl.origin.toLocaleLowerCase(),
|
|
165
|
+
...navItemUrlPath.split('/').filter(x => x !== null && x !== ''),
|
|
160
166
|
];
|
|
161
|
-
const score = getSimilarityScore(
|
|
162
|
-
|
|
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
|
|
170
|
-
* @param b
|
|
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.
|
|
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:
|
|
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",
|