@logickernel/bridge 0.11.3 → 0.11.4

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.
@@ -727,7 +727,23 @@ function getIconComponent(icon) {
727
727
  }
728
728
  function NavMain({ items }) {
729
729
  const pathname = usePathname();
730
+ const router = useRouter();
730
731
  const { isMobile, setOpenMobile } = useSidebar();
732
+ const isAbsoluteUrl = (url) => {
733
+ return url.startsWith("http://") || url.startsWith("https://");
734
+ };
735
+ const isCrossAppPath = (url) => {
736
+ return url.startsWith("/core") || url.startsWith("/aura");
737
+ };
738
+ const handleNavigation = (url, e) => {
739
+ if (isMobile) {
740
+ setOpenMobile(false);
741
+ }
742
+ if (isCrossAppPath(url) && !isAbsoluteUrl(url)) {
743
+ e?.preventDefault();
744
+ router.push(url);
745
+ }
746
+ };
731
747
  if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
732
748
  console.log("[NavMain] Received items:", {
733
749
  itemsCount: items.length,
@@ -805,7 +821,18 @@ function NavMain({ items }) {
805
821
  group.label.title
806
822
  ] }),
807
823
  group.items.length > 0 && /* @__PURE__ */ jsx(SidebarMenu, { children: group.items.map((item) => {
808
- const isActive = pathname === item.url || item.isActive;
824
+ let isActive = item.isActive || false;
825
+ if (!isActive) {
826
+ if (isAbsoluteUrl(item.url)) {
827
+ if (typeof window !== "undefined") {
828
+ isActive = window.location.href === item.url;
829
+ }
830
+ } else if (isCrossAppPath(item.url)) {
831
+ isActive = pathname === item.url;
832
+ } else {
833
+ isActive = pathname === item.url;
834
+ }
835
+ }
809
836
  const hasSubItems = item.items && item.items.length > 0;
810
837
  if (hasSubItems) {
811
838
  return /* @__PURE__ */ jsx(
@@ -827,23 +854,52 @@ function NavMain({ items }) {
827
854
  ]
828
855
  }
829
856
  ) }),
830
- /* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(
831
- Link,
832
- {
833
- href: subItem.url,
834
- onClick: () => {
835
- if (isMobile) {
836
- setOpenMobile(false);
857
+ /* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
858
+ if (isCrossAppPath(subItem.url) && !isAbsoluteUrl(subItem.url)) {
859
+ return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(
860
+ "a",
861
+ {
862
+ href: subItem.url,
863
+ onClick: (e) => handleNavigation(subItem.url, e),
864
+ children: /* @__PURE__ */ jsx("span", { children: subItem.title })
837
865
  }
838
- },
839
- children: /* @__PURE__ */ jsx("span", { children: subItem.title })
866
+ ) }) }, subItem.title);
840
867
  }
841
- ) }) }, subItem.title)) }) })
868
+ return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(
869
+ Link,
870
+ {
871
+ href: subItem.url,
872
+ onClick: () => handleNavigation(subItem.url),
873
+ children: /* @__PURE__ */ jsx("span", { children: subItem.title })
874
+ }
875
+ ) }) }, subItem.title);
876
+ }) }) })
842
877
  ] })
843
878
  },
844
879
  item.title
845
880
  );
846
881
  }
882
+ if (isCrossAppPath(item.url) && !isAbsoluteUrl(item.url)) {
883
+ return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(
884
+ SidebarMenuButton,
885
+ {
886
+ asChild: true,
887
+ tooltip: item.title,
888
+ isActive,
889
+ children: /* @__PURE__ */ jsxs(
890
+ "a",
891
+ {
892
+ href: item.url,
893
+ onClick: (e) => handleNavigation(item.url, e),
894
+ children: [
895
+ item.icon && /* @__PURE__ */ jsx(item.icon, {}),
896
+ /* @__PURE__ */ jsx("span", { children: item.title })
897
+ ]
898
+ }
899
+ )
900
+ }
901
+ ) }, item.title);
902
+ }
847
903
  return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(
848
904
  SidebarMenuButton,
849
905
  {
@@ -854,11 +910,7 @@ function NavMain({ items }) {
854
910
  Link,
855
911
  {
856
912
  href: item.url,
857
- onClick: () => {
858
- if (isMobile) {
859
- setOpenMobile(false);
860
- }
861
- },
913
+ onClick: () => handleNavigation(item.url),
862
914
  children: [
863
915
  item.icon && /* @__PURE__ */ jsx(item.icon, {}),
864
916
  /* @__PURE__ */ jsx("span", { children: item.title })