@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.
@@ -728,21 +728,53 @@ function getIconComponent(icon) {
728
728
  function NavMain({ items }) {
729
729
  const pathname = usePathname();
730
730
  const { isMobile, setOpenMobile } = useSidebar();
731
- const getCurrentContext = () => {
732
- const segments = pathname.split("/").filter(Boolean);
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();
738
- if (!currentContext) return false;
739
- if (url.startsWith(currentContext)) return true;
745
+ const urlContext = getContextFromPath(url);
746
+ if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
747
+ const willUseLink = currentContext && urlContext && currentContext === urlContext;
748
+ console.log("[NavMain] shouldUseLink check:", {
749
+ url,
750
+ currentPathname: pathname,
751
+ windowPathname: typeof window !== "undefined" ? window.location.pathname : "N/A",
752
+ currentContext,
753
+ urlContext,
754
+ contextsMatch: currentContext === urlContext,
755
+ willUseLink
756
+ });
757
+ }
758
+ if (currentContext && urlContext && currentContext === urlContext) {
759
+ return true;
760
+ }
740
761
  return false;
741
762
  };
742
- const handleClick = () => {
763
+ const handleClick = (e) => {
743
764
  if (isMobile) {
744
765
  setOpenMobile(false);
745
766
  }
767
+ if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
768
+ const target = e?.currentTarget;
769
+ const url = target.getAttribute("href") || target.closest("a")?.getAttribute("href");
770
+ const isLink = target.closest("a")?.tagName === "A" && !target.closest("a")?.hasAttribute("data-next-link");
771
+ console.log("[NavMain] Click:", {
772
+ url,
773
+ isLinkComponent: !isLink,
774
+ isAnchorTag: isLink,
775
+ willReload: isLink
776
+ });
777
+ }
746
778
  };
747
779
  if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
748
780
  console.log("[NavMain] Received items:", {
@@ -844,8 +876,18 @@ function NavMain({ items }) {
844
876
  }
845
877
  ) }),
846
878
  /* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
847
- if (shouldUseLink(subItem.url)) {
848
- return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: subItem.url, onClick: handleClick, children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
879
+ const useLink2 = shouldUseLink(subItem.url);
880
+ if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
881
+ console.log("[NavMain] SubItem navigation:", {
882
+ title: subItem.title,
883
+ url: subItem.url,
884
+ currentContext: getCurrentContext(),
885
+ useLink: useLink2,
886
+ willReload: !useLink2
887
+ });
888
+ }
889
+ if (useLink2) {
890
+ return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: subItem.url, onClick: handleClick, className: "text-blue-500", children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
849
891
  }
850
892
  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);
851
893
  }) }) })
@@ -854,14 +896,25 @@ function NavMain({ items }) {
854
896
  item.title
855
897
  );
856
898
  }
857
- if (shouldUseLink(item.url)) {
899
+ const useLink = shouldUseLink(item.url);
900
+ if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
901
+ console.log("[NavMain] Item navigation:", {
902
+ title: item.title,
903
+ url: item.url,
904
+ currentContext: getCurrentContext(),
905
+ currentPathname: pathname,
906
+ useLink,
907
+ willReload: !useLink
908
+ });
909
+ }
910
+ if (useLink) {
858
911
  return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(
859
912
  SidebarMenuButton,
860
913
  {
861
914
  asChild: true,
862
915
  tooltip: item.title,
863
916
  isActive,
864
- children: /* @__PURE__ */ jsxs(Link, { href: item.url, onClick: handleClick, children: [
917
+ children: /* @__PURE__ */ jsxs(Link, { href: item.url, onClick: handleClick, className: "text-blue-500", children: [
865
918
  item.icon && /* @__PURE__ */ jsx(item.icon, {}),
866
919
  /* @__PURE__ */ jsx("span", { children: item.title })
867
920
  ] })
@@ -874,7 +927,7 @@ function NavMain({ items }) {
874
927
  asChild: true,
875
928
  tooltip: item.title,
876
929
  isActive,
877
- children: /* @__PURE__ */ jsxs("a", { href: item.url, onClick: handleClick, children: [
930
+ children: /* @__PURE__ */ jsxs("a", { href: item.url, className: "text-red-500", onClick: handleClick, children: [
878
931
  item.icon && /* @__PURE__ */ jsx(item.icon, {}),
879
932
  /* @__PURE__ */ jsx("span", { children: item.title })
880
933
  ] })