@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.
package/dist/next/components.js
CHANGED
|
@@ -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
|
-
|
|
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) =>
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
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
|
-
|
|
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 })
|
|
@@ -1096,22 +1148,23 @@ function TeamSwitcher({
|
|
|
1096
1148
|
const isMobile = sidebar?.isMobile ?? false;
|
|
1097
1149
|
const pathname = usePathname();
|
|
1098
1150
|
const router = useRouter();
|
|
1099
|
-
const pathSegments = pathname.split("/");
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1151
|
+
const pathSegments = pathname.split("/").filter(Boolean);
|
|
1152
|
+
const skipSegments = ["user", "api", "auth", "dashboard", "settings", "app"];
|
|
1153
|
+
const potentialOrgId = pathSegments.length >= 1 ? pathSegments[0] : null;
|
|
1154
|
+
const pathOrgId = potentialOrgId && !skipSegments.includes(potentialOrgId) && (potentialOrgId.includes("-") || potentialOrgId.length >= 8) ? potentialOrgId : null;
|
|
1102
1155
|
const currentOrgId = organizationId || (pathOrgId && teams.some((team) => team.id === pathOrgId) ? pathOrgId : null);
|
|
1103
1156
|
const handleTeamChange = (teamId) => {
|
|
1104
1157
|
if (isMobile && sidebar?.setOpenMobile) {
|
|
1105
1158
|
sidebar.setOpenMobile(false);
|
|
1106
1159
|
}
|
|
1107
|
-
router.push(
|
|
1160
|
+
router.push(`/${teamId}/home`);
|
|
1108
1161
|
router.refresh();
|
|
1109
1162
|
};
|
|
1110
1163
|
const handleManageOrganizations = () => {
|
|
1111
1164
|
if (isMobile && sidebar?.setOpenMobile) {
|
|
1112
1165
|
sidebar.setOpenMobile(false);
|
|
1113
1166
|
}
|
|
1114
|
-
router.push("/
|
|
1167
|
+
router.push("/user/organizations");
|
|
1115
1168
|
};
|
|
1116
1169
|
const teamsWithLogo = teams.map((org) => {
|
|
1117
1170
|
const logoIcon = org.logo ? getIconComponent(org.logo) : GalleryVerticalEnd;
|
|
@@ -1289,12 +1342,7 @@ function AppSidebar({
|
|
|
1289
1342
|
const currentPathname = usePathname();
|
|
1290
1343
|
const pathSegments = currentPathname.split("/").filter(Boolean);
|
|
1291
1344
|
let pathOrgId = null;
|
|
1292
|
-
if (pathSegments.length >=
|
|
1293
|
-
const potentialOrgId = pathSegments[1];
|
|
1294
|
-
if (potentialOrgId && potentialOrgId !== "user") {
|
|
1295
|
-
pathOrgId = potentialOrgId;
|
|
1296
|
-
}
|
|
1297
|
-
} else if (pathSegments.length >= 1) {
|
|
1345
|
+
if (pathSegments.length >= 1) {
|
|
1298
1346
|
const potentialOrgId = pathSegments[0];
|
|
1299
1347
|
const skipSegments = ["user", "api", "auth", "dashboard", "settings", "app"];
|
|
1300
1348
|
if (potentialOrgId && !skipSegments.includes(potentialOrgId)) {
|