@logickernel/bridge 0.11.8 → 0.11.10
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/next/components.js
CHANGED
|
@@ -728,27 +728,43 @@ function getIconComponent(icon) {
|
|
|
728
728
|
function NavMain({ items }) {
|
|
729
729
|
const pathname = usePathname();
|
|
730
730
|
const { isMobile, setOpenMobile } = useSidebar();
|
|
731
|
-
const
|
|
732
|
-
const segments =
|
|
731
|
+
const getContextFromPath = (path) => {
|
|
732
|
+
const segments = path.split("/").filter(Boolean);
|
|
733
733
|
if (segments.length === 0) return null;
|
|
734
734
|
return `/${segments[0]}`;
|
|
735
735
|
};
|
|
736
|
+
const getCurrentContext = () => {
|
|
737
|
+
if (typeof window !== "undefined") {
|
|
738
|
+
const fullPath = window.location.pathname;
|
|
739
|
+
return getContextFromPath(fullPath);
|
|
740
|
+
}
|
|
741
|
+
return getContextFromPath(pathname);
|
|
742
|
+
};
|
|
736
743
|
const shouldUseLink = (url) => {
|
|
737
744
|
const currentContext = getCurrentContext();
|
|
745
|
+
const urlContext = getContextFromPath(url);
|
|
738
746
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
739
|
-
const willUseLink = currentContext
|
|
747
|
+
const willUseLink = currentContext && urlContext && currentContext === urlContext;
|
|
740
748
|
console.log("[NavMain] shouldUseLink check:", {
|
|
741
749
|
url,
|
|
742
750
|
currentPathname: pathname,
|
|
751
|
+
windowPathname: typeof window !== "undefined" ? window.location.pathname : "N/A",
|
|
743
752
|
currentContext,
|
|
744
|
-
|
|
753
|
+
urlContext,
|
|
754
|
+
contextsMatch: currentContext === urlContext,
|
|
745
755
|
willUseLink
|
|
746
756
|
});
|
|
747
757
|
}
|
|
748
|
-
if (
|
|
749
|
-
|
|
758
|
+
if (currentContext && urlContext && currentContext === urlContext) {
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
750
761
|
return false;
|
|
751
762
|
};
|
|
763
|
+
const stripContextFromUrl = (url) => {
|
|
764
|
+
const urlContext = getContextFromPath(url);
|
|
765
|
+
if (!urlContext) return url;
|
|
766
|
+
return url.substring(urlContext.length) || "/";
|
|
767
|
+
};
|
|
752
768
|
const handleClick = (e) => {
|
|
753
769
|
if (isMobile) {
|
|
754
770
|
setOpenMobile(false);
|
|
@@ -866,17 +882,19 @@ function NavMain({ items }) {
|
|
|
866
882
|
) }),
|
|
867
883
|
/* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
|
|
868
884
|
const useLink2 = shouldUseLink(subItem.url);
|
|
885
|
+
const linkHref2 = useLink2 ? stripContextFromUrl(subItem.url) : subItem.url;
|
|
869
886
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
870
887
|
console.log("[NavMain] SubItem navigation:", {
|
|
871
888
|
title: subItem.title,
|
|
872
|
-
|
|
889
|
+
originalUrl: subItem.url,
|
|
890
|
+
linkHref: linkHref2,
|
|
873
891
|
currentContext: getCurrentContext(),
|
|
874
892
|
useLink: useLink2,
|
|
875
893
|
willReload: !useLink2
|
|
876
894
|
});
|
|
877
895
|
}
|
|
878
896
|
if (useLink2) {
|
|
879
|
-
return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href:
|
|
897
|
+
return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: linkHref2, onClick: handleClick, className: "text-blue-500", children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
880
898
|
}
|
|
881
899
|
return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx("a", { href: subItem.url, className: "text-red-500", onClick: handleClick, children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
882
900
|
}) }) })
|
|
@@ -886,10 +904,12 @@ function NavMain({ items }) {
|
|
|
886
904
|
);
|
|
887
905
|
}
|
|
888
906
|
const useLink = shouldUseLink(item.url);
|
|
907
|
+
const linkHref = useLink ? stripContextFromUrl(item.url) : item.url;
|
|
889
908
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
890
909
|
console.log("[NavMain] Item navigation:", {
|
|
891
910
|
title: item.title,
|
|
892
|
-
|
|
911
|
+
originalUrl: item.url,
|
|
912
|
+
linkHref,
|
|
893
913
|
currentContext: getCurrentContext(),
|
|
894
914
|
currentPathname: pathname,
|
|
895
915
|
useLink,
|
|
@@ -903,7 +923,7 @@ function NavMain({ items }) {
|
|
|
903
923
|
asChild: true,
|
|
904
924
|
tooltip: item.title,
|
|
905
925
|
isActive,
|
|
906
|
-
children: /* @__PURE__ */ jsxs(Link, { href:
|
|
926
|
+
children: /* @__PURE__ */ jsxs(Link, { href: linkHref, onClick: handleClick, className: "text-blue-500", children: [
|
|
907
927
|
item.icon && /* @__PURE__ */ jsx(item.icon, {}),
|
|
908
928
|
/* @__PURE__ */ jsx("span", { children: item.title })
|
|
909
929
|
] })
|