@axos-web-dev/shared-components 2.0.0-dev.2 → 2.0.0-queryparams.2
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/README.md +111 -111
- package/dist/Avatar/Avatar.module.js +7 -7
- package/dist/Blockquote/Blockquote.module.js +3 -3
- package/dist/Button/Button.js +19 -1
- package/dist/Chevron/index.js +12 -0
- package/dist/FdicCallout/FdicCallout.module.js +2 -2
- package/dist/Hyperlink/index.js +12 -0
- package/dist/Interstitial/Interstitial.module.js +10 -10
- package/dist/NavigationMenu/AxosALTS/NavBar.module.js +23 -23
- package/dist/NavigationMenu/AxosAdvisor/NavBar.module.js +52 -52
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.module.js +53 -53
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +27 -27
- package/dist/NavigationMenu/AxosBank/NavBar.module.js +39 -39
- package/dist/NavigationMenu/AxosClearing/NavBar.module.js +37 -37
- package/dist/NavigationMenu/AxosFiduciary/NavBar.module.js +41 -41
- package/dist/NavigationMenu/LaVictoire/NavBar.module.js +37 -37
- package/dist/WalnutIframe/wrapper.module.js +3 -3
- package/dist/assets/Avatar/Avatar.css +59 -59
- package/dist/assets/Blockquote/Blockquote.css +72 -72
- package/dist/assets/FdicCallout/FdicCallout.css +48 -48
- package/dist/assets/Interstitial/Interstitial.css +142 -142
- package/dist/assets/NavigationMenu/AxosALTS/NavBar.css +264 -264
- package/dist/assets/NavigationMenu/AxosAdvisor/NavBar.css +609 -609
- package/dist/assets/NavigationMenu/AxosAdvisorServices/NavBar.css +630 -630
- package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css +353 -353
- package/dist/assets/NavigationMenu/AxosBank/NavBar.css +445 -445
- package/dist/assets/NavigationMenu/AxosClearing/NavBar.css +484 -484
- package/dist/assets/NavigationMenu/AxosFiduciary/NavBar.css +427 -427
- package/dist/assets/NavigationMenu/LaVictoire/NavBar.css +429 -429
- package/dist/assets/WalnutIframe/wrapper.css +48 -48
- package/dist/assets/utils/optimizeImage/optimizeImage.css +47 -47
- package/dist/main.js +5 -0
- package/dist/utils/appendQueryParams.js +16 -53
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/optimizeImage/optimizeImage.module.js +3 -3
- package/dist/utils/samePageNavigation.d.ts +3 -0
- package/dist/utils/samePageNavigation.js +23 -0
- package/dist/utils/samePageQueryParamsNavigation.d.ts +4 -0
- package/dist/utils/samePageQueryParamsNavigation.js +63 -0
- package/package.json +149 -148
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
@keyframes
|
|
2
|
-
from {
|
|
3
|
-
transform: translateX(-100%);
|
|
4
|
-
}
|
|
5
|
-
to {
|
|
6
|
-
transform: translateX(100%);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
background: #1e3860;
|
|
12
|
-
border-radius: 8px;
|
|
13
|
-
height: 555px;
|
|
14
|
-
isolation: isolate;
|
|
15
|
-
margin-block: 48px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
section > .
|
|
19
|
-
margin-top: 0 !important;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
content: "";
|
|
24
|
-
position: absolute;
|
|
25
|
-
top: 0;
|
|
26
|
-
left: 0;
|
|
27
|
-
width: 190%;
|
|
28
|
-
height: 100%;
|
|
29
|
-
background: linear-gradient(
|
|
30
|
-
65deg,
|
|
31
|
-
rgba(255, 255, 255, 0) 20%,
|
|
32
|
-
rgba(255, 255, 255, 0.5) 50%,
|
|
33
|
-
rgba(255, 255, 255, 0) 80%
|
|
34
|
-
);
|
|
35
|
-
animation:
|
|
36
|
-
z-index: -1;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
height: 100%;
|
|
41
|
-
width: 100%;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@media (max-width: 1023px) {
|
|
45
|
-
.
|
|
46
|
-
display: none;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
@keyframes _shimmer_1wqdl_1 {
|
|
2
|
+
from {
|
|
3
|
+
transform: translateX(-100%);
|
|
4
|
+
}
|
|
5
|
+
to {
|
|
6
|
+
transform: translateX(100%);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
._wrapper_1wqdl_19 {
|
|
11
|
+
background: #1e3860;
|
|
12
|
+
border-radius: 8px;
|
|
13
|
+
height: 555px;
|
|
14
|
+
isolation: isolate;
|
|
15
|
+
margin-block: 48px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
section > ._wrapper_1wqdl_19:first-child {
|
|
19
|
+
margin-top: 0 !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
._wrapper_1wqdl_19::before {
|
|
23
|
+
content: "";
|
|
24
|
+
position: absolute;
|
|
25
|
+
top: 0;
|
|
26
|
+
left: 0;
|
|
27
|
+
width: 190%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
background: linear-gradient(
|
|
30
|
+
65deg,
|
|
31
|
+
rgba(255, 255, 255, 0) 20%,
|
|
32
|
+
rgba(255, 255, 255, 0.5) 50%,
|
|
33
|
+
rgba(255, 255, 255, 0) 80%
|
|
34
|
+
);
|
|
35
|
+
animation: _shimmer_1wqdl_1 1.3s infinite linear;
|
|
36
|
+
z-index: -1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
._wrapper_control_1wqdl_77 {
|
|
40
|
+
height: 100%;
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (max-width: 1023px) {
|
|
45
|
+
._wrapper_1wqdl_19 {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
@keyframes
|
|
2
|
-
from {
|
|
3
|
-
transform: translateX(-100%);
|
|
4
|
-
}
|
|
5
|
-
to {
|
|
6
|
-
transform: translateX(100%);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
height: 100%;
|
|
12
|
-
width: 100%;
|
|
13
|
-
inset: 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
position: relative;
|
|
18
|
-
width: 100%;
|
|
19
|
-
height: 100%;
|
|
20
|
-
overflow: hidden;
|
|
21
|
-
background: #1e3860;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
._1es6o1h0 .
|
|
25
|
-
background-color: var(--_1073cm8f);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.fl2fv50 .
|
|
29
|
-
background-color: #28587d;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
content: "";
|
|
34
|
-
position: absolute;
|
|
35
|
-
top: 0;
|
|
36
|
-
left: 0;
|
|
37
|
-
width: 190%;
|
|
38
|
-
height: 100%;
|
|
39
|
-
background: linear-gradient(
|
|
40
|
-
65deg,
|
|
41
|
-
rgba(255, 255, 255, 0) 20%,
|
|
42
|
-
rgba(255, 255, 255, 0.5) 50%,
|
|
43
|
-
rgba(255, 255, 255, 0) 80%
|
|
44
|
-
);
|
|
45
|
-
animation:
|
|
46
|
-
z-index: 1;
|
|
47
|
-
}
|
|
1
|
+
@keyframes _shimmer_1cu2x_1 {
|
|
2
|
+
from {
|
|
3
|
+
transform: translateX(-100%);
|
|
4
|
+
}
|
|
5
|
+
to {
|
|
6
|
+
transform: translateX(100%);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
._loader_1cu2x_19 {
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
inset: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
._loading_1cu2x_31 {
|
|
17
|
+
position: relative;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
background: #1e3860;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
._1es6o1h0 ._loading_1cu2x_31 {
|
|
25
|
+
background-color: var(--_1073cm8f);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.fl2fv50 ._loading_1cu2x_31 {
|
|
29
|
+
background-color: #28587d;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
._loading_1cu2x_31::before {
|
|
33
|
+
content: "";
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
width: 190%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
background: linear-gradient(
|
|
40
|
+
65deg,
|
|
41
|
+
rgba(255, 255, 255, 0) 20%,
|
|
42
|
+
rgba(255, 255, 255, 0.5) 50%,
|
|
43
|
+
rgba(255, 255, 255, 0) 80%
|
|
44
|
+
);
|
|
45
|
+
animation: _shimmer_1cu2x_1 1.3s infinite linear;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -209,6 +209,7 @@ import { Tab } from "./Tab/Tab.js";
|
|
|
209
209
|
import { TabContainer } from "./Tab/TabContainer.js";
|
|
210
210
|
import { findMoreAxosDomains, getMoreDomains, isAllowedUrl } from "./utils/allowedAxosDomains.js";
|
|
211
211
|
import { appendQueryParams } from "./utils/appendQueryParams.js";
|
|
212
|
+
import { isInternalSamePathHref, isSkippableAnchorHref, mergeHrefWithCurrentSearch, performSamePageQueryParamNavigation } from "./utils/samePageQueryParamsNavigation.js";
|
|
212
213
|
import { createCachedEmailValidator } from "./utils/emailValidation.js";
|
|
213
214
|
import { associatedEmail } from "./utils/EverestValidity.js";
|
|
214
215
|
import { getVariant, getVariantWithRegex } from "./utils/getVariant.js";
|
|
@@ -676,7 +677,9 @@ export {
|
|
|
676
677
|
isAbsoluteUrl,
|
|
677
678
|
isAllowedUrl,
|
|
678
679
|
isEmailLink,
|
|
680
|
+
isInternalSamePathHref,
|
|
679
681
|
isPhoneLink,
|
|
682
|
+
isSkippableAnchorHref,
|
|
680
683
|
isValidHoneyPot,
|
|
681
684
|
is_bg_img,
|
|
682
685
|
isolate_container,
|
|
@@ -702,6 +705,7 @@ export {
|
|
|
702
705
|
mb_8,
|
|
703
706
|
mb_form,
|
|
704
707
|
media,
|
|
708
|
+
mergeHrefWithCurrentSearch,
|
|
705
709
|
messageStyle,
|
|
706
710
|
messagesContainerStyle,
|
|
707
711
|
mh_330,
|
|
@@ -723,6 +727,7 @@ export {
|
|
|
723
727
|
padding,
|
|
724
728
|
padding_in_footer,
|
|
725
729
|
paragraph,
|
|
730
|
+
performSamePageQueryParamNavigation,
|
|
726
731
|
person,
|
|
727
732
|
picker_arrow,
|
|
728
733
|
picker_container,
|
|
@@ -1,72 +1,35 @@
|
|
|
1
|
+
import { isSkippableAnchorHref, mergeHrefWithCurrentSearch, performSamePageQueryParamNavigation } from "./samePageQueryParamsNavigation.js";
|
|
2
|
+
let samePageQueryClickListenerAttached = false;
|
|
1
3
|
const appendQueryParams = () => {
|
|
2
|
-
|
|
3
|
-
const currentPathname = window.location.pathname;
|
|
4
|
-
const filterParams = (href, currentSearch) => {
|
|
5
|
-
try {
|
|
6
|
-
const search = currentSearch ?? window.location.search;
|
|
7
|
-
const searchParams = new URLSearchParams(search);
|
|
8
|
-
const base = window.location.origin + window.location.pathname + window.location.search;
|
|
9
|
-
const url = new URL(href, base);
|
|
10
|
-
const existingParams = new URLSearchParams(url.search);
|
|
11
|
-
const newParams = new URLSearchParams();
|
|
12
|
-
const addedKeys = /* @__PURE__ */ new Set();
|
|
13
|
-
for (const key of existingParams.keys()) {
|
|
14
|
-
addedKeys.add(decodeURIComponent(key));
|
|
15
|
-
}
|
|
16
|
-
for (const [key, value] of searchParams.entries()) {
|
|
17
|
-
const decodedKey = decodeURIComponent(key);
|
|
18
|
-
const decodedValue = decodeURIComponent(value);
|
|
19
|
-
const lowerKey = decodedKey.toLowerCase();
|
|
20
|
-
if (!addedKeys.has(lowerKey) && !decodedKey.includes("[]")) {
|
|
21
|
-
newParams.append(lowerKey, decodedValue);
|
|
22
|
-
addedKeys.add(lowerKey);
|
|
23
|
-
} else if (decodedKey.includes("[]")) {
|
|
24
|
-
const existingValues = existingParams.getAll(key).map(decodeURIComponent);
|
|
25
|
-
if (!existingValues.includes(decodedValue)) {
|
|
26
|
-
newParams.append(decodedKey, decodedValue);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const mergedParams = new URLSearchParams(existingParams);
|
|
31
|
-
newParams.forEach((value, key) => mergedParams.append(key, value));
|
|
32
|
-
return `${url.origin}${url.pathname}?${mergedParams.toString()}${url.hash}`;
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.error(e);
|
|
35
|
-
return href;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
4
|
+
if (typeof window === "undefined") return;
|
|
38
5
|
const handleSamePageClick = (e) => {
|
|
39
6
|
const anchor = e.target?.closest?.("a[href]");
|
|
40
7
|
if (!anchor || anchor.classList.contains("ext-link"))
|
|
41
8
|
return;
|
|
42
9
|
const href = anchor.getAttribute("href")?.trim();
|
|
43
|
-
if (
|
|
44
|
-
return;
|
|
10
|
+
if (isSkippableAnchorHref(href)) return;
|
|
45
11
|
const base = window.location.origin + window.location.pathname + window.location.search;
|
|
46
12
|
const url = new URL(href, base);
|
|
47
|
-
if (url.origin !==
|
|
13
|
+
if (url.origin !== window.location.origin || url.pathname !== window.location.pathname)
|
|
48
14
|
return;
|
|
49
15
|
e.preventDefault();
|
|
50
16
|
e.stopImmediatePropagation();
|
|
51
|
-
const merged =
|
|
52
|
-
|
|
53
|
-
const fullUrl = `${mergedUrl.pathname}${mergedUrl.search}${mergedUrl.hash}`;
|
|
54
|
-
window.history.replaceState({ ...window.history.state }, "", fullUrl);
|
|
55
|
-
window.dispatchEvent(
|
|
56
|
-
new PopStateEvent("popstate", { state: window.history.state })
|
|
57
|
-
);
|
|
58
|
-
if (mergedUrl.hash) {
|
|
59
|
-
const el = document.querySelector(mergedUrl.hash);
|
|
60
|
-
el?.scrollIntoView({ behavior: "smooth" });
|
|
61
|
-
}
|
|
17
|
+
const merged = mergeHrefWithCurrentSearch(href, window.location.search);
|
|
18
|
+
performSamePageQueryParamNavigation(merged);
|
|
62
19
|
};
|
|
63
|
-
|
|
20
|
+
if (!samePageQueryClickListenerAttached) {
|
|
21
|
+
samePageQueryClickListenerAttached = true;
|
|
22
|
+
window.addEventListener("click", handleSamePageClick, true);
|
|
23
|
+
}
|
|
64
24
|
if (window.location.search.length) {
|
|
65
25
|
const searchParams = new URLSearchParams(window.location.search);
|
|
66
26
|
document.querySelectorAll("a[href]:not(.ext-link)").forEach((anchor) => {
|
|
67
27
|
const href = anchor.getAttribute("href")?.trim();
|
|
68
|
-
if (
|
|
69
|
-
anchor.href =
|
|
28
|
+
if (!isSkippableAnchorHref(href)) {
|
|
29
|
+
anchor.href = mergeHrefWithCurrentSearch(
|
|
30
|
+
href,
|
|
31
|
+
searchParams.toString()
|
|
32
|
+
);
|
|
70
33
|
}
|
|
71
34
|
});
|
|
72
35
|
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { findMoreAxosDomains, getMoreDomains, isAllowedUrl } from "./allowedAxosDomains.js";
|
|
3
3
|
import { appendQueryParams } from "./appendQueryParams.js";
|
|
4
|
+
import { isInternalSamePathHref, isSkippableAnchorHref, mergeHrefWithCurrentSearch, performSamePageQueryParamNavigation } from "./samePageQueryParamsNavigation.js";
|
|
4
5
|
import { createCachedEmailValidator } from "./emailValidation.js";
|
|
5
6
|
import { associatedEmail } from "./EverestValidity.js";
|
|
6
7
|
import { getVariant, getVariantWithRegex } from "./getVariant.js";
|
|
@@ -21,7 +22,11 @@ export {
|
|
|
21
22
|
isAbsoluteUrl,
|
|
22
23
|
isAllowedUrl,
|
|
23
24
|
isEmailLink,
|
|
25
|
+
isInternalSamePathHref,
|
|
24
26
|
isPhoneLink,
|
|
27
|
+
isSkippableAnchorHref,
|
|
28
|
+
mergeHrefWithCurrentSearch,
|
|
29
|
+
performSamePageQueryParamNavigation,
|
|
25
30
|
shortUrl,
|
|
26
31
|
useCachedEmailValidator,
|
|
27
32
|
useCachedNMLSValidator,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '../../assets/utils/optimizeImage/optimizeImage.css';const loader = "
|
|
2
|
-
const loading = "
|
|
3
|
-
const shimmer = "
|
|
1
|
+
import '../../assets/utils/optimizeImage/optimizeImage.css';const loader = "_loader_1cu2x_19";
|
|
2
|
+
const loading = "_loading_1cu2x_31";
|
|
3
|
+
const shimmer = "_shimmer_1cu2x_1";
|
|
4
4
|
const css = {
|
|
5
5
|
loader,
|
|
6
6
|
loading,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const isSamePageSameQueryUrl = (href) => {
|
|
2
|
+
const base = window.location.origin + window.location.pathname + window.location.search;
|
|
3
|
+
const target = new URL(href, base);
|
|
4
|
+
return target.origin === window.location.origin && target.pathname === window.location.pathname && target.search === window.location.search;
|
|
5
|
+
};
|
|
6
|
+
const handleSamePageNavigation = (e) => {
|
|
7
|
+
e.preventDefault();
|
|
8
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
9
|
+
window.dispatchEvent(
|
|
10
|
+
new PopStateEvent("popstate", { state: window.history.state })
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
const shouldIgnoreClick = (href) => {
|
|
14
|
+
if (href.startsWith("#")) return true;
|
|
15
|
+
const base = window.location.origin + window.location.pathname + window.location.search;
|
|
16
|
+
const target = new URL(href, base);
|
|
17
|
+
return target.origin === window.location.origin && target.pathname === window.location.pathname && target.search === window.location.search && target.hash !== "";
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
handleSamePageNavigation,
|
|
21
|
+
isSamePageSameQueryUrl,
|
|
22
|
+
shouldIgnoreClick
|
|
23
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function mergeHrefWithCurrentSearch(href: string, currentSearch?: string): string;
|
|
2
|
+
export declare function isSkippableAnchorHref(href: string | undefined | null): boolean;
|
|
3
|
+
export declare function isInternalSamePathHref(href: string): boolean;
|
|
4
|
+
export declare function performSamePageQueryParamNavigation(mergedHref: string): void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
function mergeHrefWithCurrentSearch(href, currentSearch) {
|
|
2
|
+
try {
|
|
3
|
+
const search = currentSearch ?? window.location.search;
|
|
4
|
+
const searchParams = new URLSearchParams(search);
|
|
5
|
+
const base = window.location.origin + window.location.pathname + window.location.search;
|
|
6
|
+
const url = new URL(href.trim(), base);
|
|
7
|
+
const existingParams = new URLSearchParams(url.search);
|
|
8
|
+
const newParams = new URLSearchParams();
|
|
9
|
+
const addedKeys = /* @__PURE__ */ new Set();
|
|
10
|
+
for (const key of existingParams.keys()) {
|
|
11
|
+
addedKeys.add(decodeURIComponent(key));
|
|
12
|
+
}
|
|
13
|
+
for (const [key, value] of searchParams.entries()) {
|
|
14
|
+
const decodedKey = decodeURIComponent(key);
|
|
15
|
+
const decodedValue = decodeURIComponent(value);
|
|
16
|
+
const lowerKey = decodedKey.toLowerCase();
|
|
17
|
+
if (!addedKeys.has(lowerKey) && !decodedKey.includes("[]")) {
|
|
18
|
+
newParams.append(lowerKey, decodedValue);
|
|
19
|
+
addedKeys.add(lowerKey);
|
|
20
|
+
} else if (decodedKey.includes("[]")) {
|
|
21
|
+
const existingValues = existingParams.getAll(key).map(decodeURIComponent);
|
|
22
|
+
if (!existingValues.includes(decodedValue)) {
|
|
23
|
+
newParams.append(decodedKey, decodedValue);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const mergedParams = new URLSearchParams(existingParams);
|
|
28
|
+
newParams.forEach((value, key) => mergedParams.append(key, value));
|
|
29
|
+
return `${url.origin}${url.pathname}?${mergedParams.toString()}${url.hash}`;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error(e);
|
|
32
|
+
return href;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isSkippableAnchorHref(href) {
|
|
36
|
+
if (!href) return true;
|
|
37
|
+
const h = href.trim();
|
|
38
|
+
return !h || h.startsWith("tel:") || h.startsWith("mailto:") || h === "#" || h === "" || h.startsWith("#");
|
|
39
|
+
}
|
|
40
|
+
function isInternalSamePathHref(href) {
|
|
41
|
+
if (isSkippableAnchorHref(href)) return false;
|
|
42
|
+
const base = window.location.origin + window.location.pathname + window.location.search;
|
|
43
|
+
const url = new URL(href.trim(), base);
|
|
44
|
+
return url.origin === window.location.origin && url.pathname === window.location.pathname;
|
|
45
|
+
}
|
|
46
|
+
function performSamePageQueryParamNavigation(mergedHref) {
|
|
47
|
+
const mergedUrl = new URL(mergedHref, window.location.origin);
|
|
48
|
+
const fullUrl = `${mergedUrl.pathname}${mergedUrl.search}${mergedUrl.hash}`;
|
|
49
|
+
window.history.replaceState({ ...window.history.state }, "", fullUrl);
|
|
50
|
+
window.dispatchEvent(
|
|
51
|
+
new PopStateEvent("popstate", { state: window.history.state })
|
|
52
|
+
);
|
|
53
|
+
if (mergedUrl.hash) {
|
|
54
|
+
const el = document.querySelector(mergedUrl.hash);
|
|
55
|
+
el?.scrollIntoView({ behavior: "smooth" });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
isInternalSamePathHref,
|
|
60
|
+
isSkippableAnchorHref,
|
|
61
|
+
mergeHrefWithCurrentSearch,
|
|
62
|
+
performSamePageQueryParamNavigation
|
|
63
|
+
};
|