@logickernel/bridge 0.11.7 → 0.11.9
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,21 +757,53 @@ 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();
|
|
767
|
-
|
|
768
|
-
if (
|
|
774
|
+
const urlContext = getContextFromPath(url);
|
|
775
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
776
|
+
const willUseLink = currentContext && urlContext && currentContext === urlContext;
|
|
777
|
+
console.log("[NavMain] shouldUseLink check:", {
|
|
778
|
+
url,
|
|
779
|
+
currentPathname: pathname,
|
|
780
|
+
windowPathname: typeof window !== "undefined" ? window.location.pathname : "N/A",
|
|
781
|
+
currentContext,
|
|
782
|
+
urlContext,
|
|
783
|
+
contextsMatch: currentContext === urlContext,
|
|
784
|
+
willUseLink
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
if (currentContext && urlContext && currentContext === urlContext) {
|
|
788
|
+
return true;
|
|
789
|
+
}
|
|
769
790
|
return false;
|
|
770
791
|
};
|
|
771
|
-
const handleClick = () => {
|
|
792
|
+
const handleClick = (e) => {
|
|
772
793
|
if (isMobile) {
|
|
773
794
|
setOpenMobile(false);
|
|
774
795
|
}
|
|
796
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
797
|
+
const target = e?.currentTarget;
|
|
798
|
+
const url = target.getAttribute("href") || target.closest("a")?.getAttribute("href");
|
|
799
|
+
const isLink = target.closest("a")?.tagName === "A" && !target.closest("a")?.hasAttribute("data-next-link");
|
|
800
|
+
console.log("[NavMain] Click:", {
|
|
801
|
+
url,
|
|
802
|
+
isLinkComponent: !isLink,
|
|
803
|
+
isAnchorTag: isLink,
|
|
804
|
+
willReload: isLink
|
|
805
|
+
});
|
|
806
|
+
}
|
|
775
807
|
};
|
|
776
808
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
777
809
|
console.log("[NavMain] Received items:", {
|
|
@@ -873,8 +905,18 @@ function NavMain({ items }) {
|
|
|
873
905
|
}
|
|
874
906
|
) }),
|
|
875
907
|
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
|
|
876
|
-
|
|
877
|
-
|
|
908
|
+
const useLink2 = shouldUseLink(subItem.url);
|
|
909
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
910
|
+
console.log("[NavMain] SubItem navigation:", {
|
|
911
|
+
title: subItem.title,
|
|
912
|
+
url: subItem.url,
|
|
913
|
+
currentContext: getCurrentContext(),
|
|
914
|
+
useLink: useLink2,
|
|
915
|
+
willReload: !useLink2
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
if (useLink2) {
|
|
919
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: subItem.url, onClick: handleClick, className: "text-blue-500", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
878
920
|
}
|
|
879
921
|
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);
|
|
880
922
|
}) }) })
|
|
@@ -883,14 +925,25 @@ function NavMain({ items }) {
|
|
|
883
925
|
item.title
|
|
884
926
|
);
|
|
885
927
|
}
|
|
886
|
-
|
|
928
|
+
const useLink = shouldUseLink(item.url);
|
|
929
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
930
|
+
console.log("[NavMain] Item navigation:", {
|
|
931
|
+
title: item.title,
|
|
932
|
+
url: item.url,
|
|
933
|
+
currentContext: getCurrentContext(),
|
|
934
|
+
currentPathname: pathname,
|
|
935
|
+
useLink,
|
|
936
|
+
willReload: !useLink
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
if (useLink) {
|
|
887
940
|
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
888
941
|
SidebarMenuButton,
|
|
889
942
|
{
|
|
890
943
|
asChild: true,
|
|
891
944
|
tooltip: item.title,
|
|
892
945
|
isActive,
|
|
893
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: item.url, onClick: handleClick, children: [
|
|
946
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: item.url, onClick: handleClick, className: "text-blue-500", children: [
|
|
894
947
|
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
895
948
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
896
949
|
] })
|
|
@@ -903,7 +956,7 @@ function NavMain({ items }) {
|
|
|
903
956
|
asChild: true,
|
|
904
957
|
tooltip: item.title,
|
|
905
958
|
isActive,
|
|
906
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: item.url, onClick: handleClick, children: [
|
|
959
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: item.url, className: "text-red-500", onClick: handleClick, children: [
|
|
907
960
|
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
908
961
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
909
962
|
] })
|