@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.
@@ -756,7 +756,23 @@ function getIconComponent(icon) {
756
756
  }
757
757
  function NavMain({ items }) {
758
758
  const pathname = navigation.usePathname();
759
+ const router = navigation.useRouter();
759
760
  const { isMobile, setOpenMobile } = useSidebar();
761
+ const isAbsoluteUrl = (url) => {
762
+ return url.startsWith("http://") || url.startsWith("https://");
763
+ };
764
+ const isCrossAppPath = (url) => {
765
+ return url.startsWith("/core") || url.startsWith("/aura");
766
+ };
767
+ const handleNavigation = (url, e) => {
768
+ if (isMobile) {
769
+ setOpenMobile(false);
770
+ }
771
+ if (isCrossAppPath(url) && !isAbsoluteUrl(url)) {
772
+ e?.preventDefault();
773
+ router.push(url);
774
+ }
775
+ };
760
776
  if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
761
777
  console.log("[NavMain] Received items:", {
762
778
  itemsCount: items.length,
@@ -834,7 +850,18 @@ function NavMain({ items }) {
834
850
  group.label.title
835
851
  ] }),
836
852
  group.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: group.items.map((item) => {
837
- const isActive = pathname === item.url || item.isActive;
853
+ let isActive = item.isActive || false;
854
+ if (!isActive) {
855
+ if (isAbsoluteUrl(item.url)) {
856
+ if (typeof window !== "undefined") {
857
+ isActive = window.location.href === item.url;
858
+ }
859
+ } else if (isCrossAppPath(item.url)) {
860
+ isActive = pathname === item.url;
861
+ } else {
862
+ isActive = pathname === item.url;
863
+ }
864
+ }
838
865
  const hasSubItems = item.items && item.items.length > 0;
839
866
  if (hasSubItems) {
840
867
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -856,23 +883,52 @@ function NavMain({ items }) {
856
883
  ]
857
884
  }
858
885
  ) }),
859
- /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
860
- Link__default.default,
861
- {
862
- href: subItem.url,
863
- onClick: () => {
864
- if (isMobile) {
865
- setOpenMobile(false);
886
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
887
+ if (isCrossAppPath(subItem.url) && !isAbsoluteUrl(subItem.url)) {
888
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
889
+ "a",
890
+ {
891
+ href: subItem.url,
892
+ onClick: (e) => handleNavigation(subItem.url, e),
893
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title })
866
894
  }
867
- },
868
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title })
895
+ ) }) }, subItem.title);
869
896
  }
870
- ) }) }, subItem.title)) }) })
897
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
898
+ Link__default.default,
899
+ {
900
+ href: subItem.url,
901
+ onClick: () => handleNavigation(subItem.url),
902
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title })
903
+ }
904
+ ) }) }, subItem.title);
905
+ }) }) })
871
906
  ] })
872
907
  },
873
908
  item.title
874
909
  );
875
910
  }
911
+ if (isCrossAppPath(item.url) && !isAbsoluteUrl(item.url)) {
912
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
913
+ SidebarMenuButton,
914
+ {
915
+ asChild: true,
916
+ tooltip: item.title,
917
+ isActive,
918
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
919
+ "a",
920
+ {
921
+ href: item.url,
922
+ onClick: (e) => handleNavigation(item.url, e),
923
+ children: [
924
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
925
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
926
+ ]
927
+ }
928
+ )
929
+ }
930
+ ) }, item.title);
931
+ }
876
932
  return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
877
933
  SidebarMenuButton,
878
934
  {
@@ -883,11 +939,7 @@ function NavMain({ items }) {
883
939
  Link__default.default,
884
940
  {
885
941
  href: item.url,
886
- onClick: () => {
887
- if (isMobile) {
888
- setOpenMobile(false);
889
- }
890
- },
942
+ onClick: () => handleNavigation(item.url),
891
943
  children: [
892
944
  item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
893
945
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })