@logickernel/bridge 0.11.2 → 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 })
@@ -1125,22 +1177,23 @@ function TeamSwitcher({
1125
1177
  const isMobile = sidebar?.isMobile ?? false;
1126
1178
  const pathname = navigation.usePathname();
1127
1179
  const router = navigation.useRouter();
1128
- const pathSegments = pathname.split("/");
1129
- const isAppOrgRoute = pathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1130
- const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1180
+ const pathSegments = pathname.split("/").filter(Boolean);
1181
+ const skipSegments = ["user", "api", "auth", "dashboard", "settings", "app"];
1182
+ const potentialOrgId = pathSegments.length >= 1 ? pathSegments[0] : null;
1183
+ const pathOrgId = potentialOrgId && !skipSegments.includes(potentialOrgId) && (potentialOrgId.includes("-") || potentialOrgId.length >= 8) ? potentialOrgId : null;
1131
1184
  const currentOrgId = organizationId || (pathOrgId && teams.some((team) => team.id === pathOrgId) ? pathOrgId : null);
1132
1185
  const handleTeamChange = (teamId) => {
1133
1186
  if (isMobile && sidebar?.setOpenMobile) {
1134
1187
  sidebar.setOpenMobile(false);
1135
1188
  }
1136
- router.push(`/app/${teamId}/home`);
1189
+ router.push(`/${teamId}/home`);
1137
1190
  router.refresh();
1138
1191
  };
1139
1192
  const handleManageOrganizations = () => {
1140
1193
  if (isMobile && sidebar?.setOpenMobile) {
1141
1194
  sidebar.setOpenMobile(false);
1142
1195
  }
1143
- router.push("/app/user/organizations");
1196
+ router.push("/user/organizations");
1144
1197
  };
1145
1198
  const teamsWithLogo = teams.map((org) => {
1146
1199
  const logoIcon = org.logo ? getIconComponent(org.logo) : LucideIcons.GalleryVerticalEnd;
@@ -1318,12 +1371,7 @@ function AppSidebar({
1318
1371
  const currentPathname = navigation.usePathname();
1319
1372
  const pathSegments = currentPathname.split("/").filter(Boolean);
1320
1373
  let pathOrgId = null;
1321
- if (pathSegments.length >= 2 && pathSegments[0] === "app") {
1322
- const potentialOrgId = pathSegments[1];
1323
- if (potentialOrgId && potentialOrgId !== "user") {
1324
- pathOrgId = potentialOrgId;
1325
- }
1326
- } else if (pathSegments.length >= 1) {
1374
+ if (pathSegments.length >= 1) {
1327
1375
  const potentialOrgId = pathSegments[0];
1328
1376
  const skipSegments = ["user", "api", "auth", "dashboard", "settings", "app"];
1329
1377
  if (potentialOrgId && !skipSegments.includes(potentialOrgId)) {