@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.cjs
CHANGED
|
@@ -757,27 +757,43 @@ function getIconComponent(icon) {
|
|
|
757
757
|
function NavMain({ items }) {
|
|
758
758
|
const pathname = navigation.usePathname();
|
|
759
759
|
const { isMobile, setOpenMobile } = useSidebar();
|
|
760
|
-
const
|
|
761
|
-
const segments =
|
|
760
|
+
const getContextFromPath = (path) => {
|
|
761
|
+
const segments = path.split("/").filter(Boolean);
|
|
762
762
|
if (segments.length === 0) return null;
|
|
763
763
|
return `/${segments[0]}`;
|
|
764
764
|
};
|
|
765
|
+
const getCurrentContext = () => {
|
|
766
|
+
if (typeof window !== "undefined") {
|
|
767
|
+
const fullPath = window.location.pathname;
|
|
768
|
+
return getContextFromPath(fullPath);
|
|
769
|
+
}
|
|
770
|
+
return getContextFromPath(pathname);
|
|
771
|
+
};
|
|
765
772
|
const shouldUseLink = (url) => {
|
|
766
773
|
const currentContext = getCurrentContext();
|
|
774
|
+
const urlContext = getContextFromPath(url);
|
|
767
775
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
768
|
-
const willUseLink = currentContext
|
|
776
|
+
const willUseLink = currentContext && urlContext && currentContext === urlContext;
|
|
769
777
|
console.log("[NavMain] shouldUseLink check:", {
|
|
770
778
|
url,
|
|
771
779
|
currentPathname: pathname,
|
|
780
|
+
windowPathname: typeof window !== "undefined" ? window.location.pathname : "N/A",
|
|
772
781
|
currentContext,
|
|
773
|
-
|
|
782
|
+
urlContext,
|
|
783
|
+
contextsMatch: currentContext === urlContext,
|
|
774
784
|
willUseLink
|
|
775
785
|
});
|
|
776
786
|
}
|
|
777
|
-
if (
|
|
778
|
-
|
|
787
|
+
if (currentContext && urlContext && currentContext === urlContext) {
|
|
788
|
+
return true;
|
|
789
|
+
}
|
|
779
790
|
return false;
|
|
780
791
|
};
|
|
792
|
+
const stripContextFromUrl = (url) => {
|
|
793
|
+
const urlContext = getContextFromPath(url);
|
|
794
|
+
if (!urlContext) return url;
|
|
795
|
+
return url.substring(urlContext.length) || "/";
|
|
796
|
+
};
|
|
781
797
|
const handleClick = (e) => {
|
|
782
798
|
if (isMobile) {
|
|
783
799
|
setOpenMobile(false);
|
|
@@ -895,17 +911,19 @@ function NavMain({ items }) {
|
|
|
895
911
|
) }),
|
|
896
912
|
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
|
|
897
913
|
const useLink2 = shouldUseLink(subItem.url);
|
|
914
|
+
const linkHref2 = useLink2 ? stripContextFromUrl(subItem.url) : subItem.url;
|
|
898
915
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
899
916
|
console.log("[NavMain] SubItem navigation:", {
|
|
900
917
|
title: subItem.title,
|
|
901
|
-
|
|
918
|
+
originalUrl: subItem.url,
|
|
919
|
+
linkHref: linkHref2,
|
|
902
920
|
currentContext: getCurrentContext(),
|
|
903
921
|
useLink: useLink2,
|
|
904
922
|
willReload: !useLink2
|
|
905
923
|
});
|
|
906
924
|
}
|
|
907
925
|
if (useLink2) {
|
|
908
|
-
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href:
|
|
926
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: linkHref2, onClick: handleClick, className: "text-blue-500", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
909
927
|
}
|
|
910
928
|
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: subItem.url, className: "text-red-500", onClick: handleClick, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
911
929
|
}) }) })
|
|
@@ -915,10 +933,12 @@ function NavMain({ items }) {
|
|
|
915
933
|
);
|
|
916
934
|
}
|
|
917
935
|
const useLink = shouldUseLink(item.url);
|
|
936
|
+
const linkHref = useLink ? stripContextFromUrl(item.url) : item.url;
|
|
918
937
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
919
938
|
console.log("[NavMain] Item navigation:", {
|
|
920
939
|
title: item.title,
|
|
921
|
-
|
|
940
|
+
originalUrl: item.url,
|
|
941
|
+
linkHref,
|
|
922
942
|
currentContext: getCurrentContext(),
|
|
923
943
|
currentPathname: pathname,
|
|
924
944
|
useLink,
|
|
@@ -932,7 +952,7 @@ function NavMain({ items }) {
|
|
|
932
952
|
asChild: true,
|
|
933
953
|
tooltip: item.title,
|
|
934
954
|
isActive,
|
|
935
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href:
|
|
955
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: linkHref, onClick: handleClick, className: "text-blue-500", children: [
|
|
936
956
|
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
937
957
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
938
958
|
] })
|