baaz-custom-components 3.2.13 → 3.2.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/index.js +17 -23
- package/dist/index.mjs +17 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -786,31 +786,25 @@ function treeContainsPath({
|
|
|
786
786
|
}
|
|
787
787
|
return false;
|
|
788
788
|
}
|
|
789
|
-
function
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
if (pathname === hrefPath || pathname.startsWith(hrefPath + "/")) {
|
|
798
|
-
}
|
|
799
|
-
} else {
|
|
800
|
-
const firstChild = node.routes[0];
|
|
801
|
-
const maybePath = typeof firstChild.routes === "string" ? firstChild.routes : "";
|
|
802
|
-
const full = buildFullHref(parentBase, maybePath);
|
|
803
|
-
let hrefPath = extractPathname(full);
|
|
804
|
-
if (hrefPath.endsWith("/-")) hrefPath = hrefPath.slice(0, -2);
|
|
805
|
-
if (pathname.startsWith(hrefPath)) {
|
|
806
|
-
result = { base: parentBase, children: node.routes };
|
|
807
|
-
dfs(node.routes, parentBase);
|
|
808
|
-
}
|
|
789
|
+
function getActiveRouteSiblings(data, base, pathname) {
|
|
790
|
+
for (const node of data) {
|
|
791
|
+
if (typeof node.routes === "string") {
|
|
792
|
+
const full = buildFullHref(base, node.routes);
|
|
793
|
+
let hrefPath = extractPathname(full);
|
|
794
|
+
if (hrefPath.endsWith("/-")) hrefPath = hrefPath.slice(0, -2);
|
|
795
|
+
if (pathname === hrefPath || pathname.startsWith(hrefPath + "/")) {
|
|
796
|
+
return { base, children: data };
|
|
809
797
|
}
|
|
798
|
+
} else {
|
|
799
|
+
const childMatch = getActiveRouteSiblings(
|
|
800
|
+
node.routes,
|
|
801
|
+
base,
|
|
802
|
+
pathname
|
|
803
|
+
);
|
|
804
|
+
if (childMatch) return childMatch;
|
|
810
805
|
}
|
|
811
806
|
}
|
|
812
|
-
|
|
813
|
-
return result;
|
|
807
|
+
return null;
|
|
814
808
|
}
|
|
815
809
|
|
|
816
810
|
// src/components/custom/navbar/customMenu.tsx
|
|
@@ -982,7 +976,7 @@ function DesktopNavbar({
|
|
|
982
976
|
}, [navbarData, pathname]);
|
|
983
977
|
const subNavData = (0, import_react2.useMemo)(() => {
|
|
984
978
|
if (!activeEntry) return null;
|
|
985
|
-
return
|
|
979
|
+
return getActiveRouteSiblings(
|
|
986
980
|
activeEntry.routes,
|
|
987
981
|
activeEntry.url,
|
|
988
982
|
pathname
|
package/dist/index.mjs
CHANGED
|
@@ -752,31 +752,25 @@ function treeContainsPath({
|
|
|
752
752
|
}
|
|
753
753
|
return false;
|
|
754
754
|
}
|
|
755
|
-
function
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (pathname === hrefPath || pathname.startsWith(hrefPath + "/")) {
|
|
764
|
-
}
|
|
765
|
-
} else {
|
|
766
|
-
const firstChild = node.routes[0];
|
|
767
|
-
const maybePath = typeof firstChild.routes === "string" ? firstChild.routes : "";
|
|
768
|
-
const full = buildFullHref(parentBase, maybePath);
|
|
769
|
-
let hrefPath = extractPathname(full);
|
|
770
|
-
if (hrefPath.endsWith("/-")) hrefPath = hrefPath.slice(0, -2);
|
|
771
|
-
if (pathname.startsWith(hrefPath)) {
|
|
772
|
-
result = { base: parentBase, children: node.routes };
|
|
773
|
-
dfs(node.routes, parentBase);
|
|
774
|
-
}
|
|
755
|
+
function getActiveRouteSiblings(data, base, pathname) {
|
|
756
|
+
for (const node of data) {
|
|
757
|
+
if (typeof node.routes === "string") {
|
|
758
|
+
const full = buildFullHref(base, node.routes);
|
|
759
|
+
let hrefPath = extractPathname(full);
|
|
760
|
+
if (hrefPath.endsWith("/-")) hrefPath = hrefPath.slice(0, -2);
|
|
761
|
+
if (pathname === hrefPath || pathname.startsWith(hrefPath + "/")) {
|
|
762
|
+
return { base, children: data };
|
|
775
763
|
}
|
|
764
|
+
} else {
|
|
765
|
+
const childMatch = getActiveRouteSiblings(
|
|
766
|
+
node.routes,
|
|
767
|
+
base,
|
|
768
|
+
pathname
|
|
769
|
+
);
|
|
770
|
+
if (childMatch) return childMatch;
|
|
776
771
|
}
|
|
777
772
|
}
|
|
778
|
-
|
|
779
|
-
return result;
|
|
773
|
+
return null;
|
|
780
774
|
}
|
|
781
775
|
|
|
782
776
|
// src/components/custom/navbar/customMenu.tsx
|
|
@@ -948,7 +942,7 @@ function DesktopNavbar({
|
|
|
948
942
|
}, [navbarData, pathname]);
|
|
949
943
|
const subNavData = useMemo(() => {
|
|
950
944
|
if (!activeEntry) return null;
|
|
951
|
-
return
|
|
945
|
+
return getActiveRouteSiblings(
|
|
952
946
|
activeEntry.routes,
|
|
953
947
|
activeEntry.url,
|
|
954
948
|
pathname
|