@logickernel/bridge 0.12.9 → 0.13.1
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/index.cjs +9 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -9
- package/dist/index.d.ts +3 -9
- package/dist/index.js +10 -37
- package/dist/index.js.map +1 -1
- package/dist/next/components.cjs +2 -173
- package/dist/next/components.cjs.map +1 -1
- package/dist/next/components.js +2 -173
- package/dist/next/components.js.map +1 -1
- package/dist/next/index.cjs +9 -47
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +9 -47
- package/dist/next/index.js.map +1 -1
- package/package.json +3 -2
package/dist/next/components.js
CHANGED
|
@@ -742,18 +742,6 @@ function NavMain({ items }) {
|
|
|
742
742
|
const shouldUseLink = (url) => {
|
|
743
743
|
const currentContext = getCurrentContext();
|
|
744
744
|
const urlContext = getContextFromPath(url);
|
|
745
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
746
|
-
const willUseLink = currentContext && urlContext && currentContext === urlContext;
|
|
747
|
-
console.log("[NavMain] shouldUseLink check:", {
|
|
748
|
-
url,
|
|
749
|
-
currentPathname: pathname,
|
|
750
|
-
windowPathname: typeof window !== "undefined" ? window.location.pathname : "N/A",
|
|
751
|
-
currentContext,
|
|
752
|
-
urlContext,
|
|
753
|
-
contextsMatch: currentContext === urlContext,
|
|
754
|
-
willUseLink
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
745
|
if (currentContext && urlContext && currentContext === urlContext) {
|
|
758
746
|
return true;
|
|
759
747
|
}
|
|
@@ -764,33 +752,11 @@ function NavMain({ items }) {
|
|
|
764
752
|
if (!urlContext) return url;
|
|
765
753
|
return url.substring(urlContext.length) || "/";
|
|
766
754
|
};
|
|
767
|
-
const handleClick = (
|
|
755
|
+
const handleClick = () => {
|
|
768
756
|
if (isMobile) {
|
|
769
757
|
setOpenMobile(false);
|
|
770
758
|
}
|
|
771
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
772
|
-
const target = e?.currentTarget;
|
|
773
|
-
const url = target.getAttribute("href") || target.closest("a")?.getAttribute("href");
|
|
774
|
-
const isLink = target.closest("a")?.tagName === "A" && !target.closest("a")?.hasAttribute("data-next-link");
|
|
775
|
-
console.log("[NavMain] Click:", {
|
|
776
|
-
url,
|
|
777
|
-
isLinkComponent: !isLink,
|
|
778
|
-
isAnchorTag: isLink,
|
|
779
|
-
willReload: isLink
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
759
|
};
|
|
783
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
784
|
-
console.log("[NavMain] Received items:", {
|
|
785
|
-
itemsCount: items.length,
|
|
786
|
-
items: items.map((item) => ({
|
|
787
|
-
title: item.title,
|
|
788
|
-
url: item.url,
|
|
789
|
-
icon: item.icon,
|
|
790
|
-
hasSubItems: !!(item.items && item.items.length > 0)
|
|
791
|
-
}))
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
760
|
const groups = [];
|
|
795
761
|
let currentGroup = {
|
|
796
762
|
items: []
|
|
@@ -818,39 +784,10 @@ function NavMain({ items }) {
|
|
|
818
784
|
if (currentGroup.items.length > 0 || currentGroup.label) {
|
|
819
785
|
groups.push(currentGroup);
|
|
820
786
|
}
|
|
821
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
822
|
-
console.log("[NavMain] Groups:", {
|
|
823
|
-
groupsCount: groups.length,
|
|
824
|
-
groups: groups.map((group) => ({
|
|
825
|
-
hasLabel: !!group.label,
|
|
826
|
-
labelTitle: group.label?.title,
|
|
827
|
-
itemsCount: group.items.length,
|
|
828
|
-
items: group.items.map((item) => item.title)
|
|
829
|
-
}))
|
|
830
|
-
});
|
|
831
|
-
const firstGroup = groups.length > 0 ? groups[0] : null;
|
|
832
|
-
console.log("[NavMain] Will render:", {
|
|
833
|
-
groupsLength: groups.length,
|
|
834
|
-
willRender: groups.length > 0,
|
|
835
|
-
firstGroupHasItems: firstGroup ? firstGroup.items.length > 0 : false,
|
|
836
|
-
firstGroupHasLabel: !!firstGroup?.label
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
787
|
if (groups.length === 0) {
|
|
840
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
841
|
-
console.warn("[NavMain] No groups to render, returning null");
|
|
842
|
-
}
|
|
843
788
|
return null;
|
|
844
789
|
}
|
|
845
790
|
return /* @__PURE__ */ jsx(Fragment, { children: groups.map((group, groupIndex) => {
|
|
846
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
847
|
-
console.log(`[NavMain] Rendering group ${groupIndex}:`, {
|
|
848
|
-
hasLabel: !!group.label,
|
|
849
|
-
itemsCount: group.items.length,
|
|
850
|
-
willRenderLabel: !!group.label,
|
|
851
|
-
willRenderItems: group.items.length > 0
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
791
|
return /* @__PURE__ */ jsxs(SidebarGroup, { children: [
|
|
855
792
|
group.label && /* @__PURE__ */ jsxs(SidebarGroupLabel, { children: [
|
|
856
793
|
group.label.icon && /* @__PURE__ */ jsx(group.label.icon, { className: "mr-2" }),
|
|
@@ -882,16 +819,6 @@ function NavMain({ items }) {
|
|
|
882
819
|
/* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
|
|
883
820
|
const useLink2 = shouldUseLink(subItem.url);
|
|
884
821
|
const linkHref2 = useLink2 ? stripContextFromUrl(subItem.url) : subItem.url;
|
|
885
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
886
|
-
console.log("[NavMain] SubItem navigation:", {
|
|
887
|
-
title: subItem.title,
|
|
888
|
-
originalUrl: subItem.url,
|
|
889
|
-
linkHref: linkHref2,
|
|
890
|
-
currentContext: getCurrentContext(),
|
|
891
|
-
useLink: useLink2,
|
|
892
|
-
willReload: !useLink2
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
822
|
if (useLink2) {
|
|
896
823
|
return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: linkHref2, onClick: handleClick, children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
897
824
|
}
|
|
@@ -904,17 +831,6 @@ function NavMain({ items }) {
|
|
|
904
831
|
}
|
|
905
832
|
const useLink = shouldUseLink(item.url);
|
|
906
833
|
const linkHref = useLink ? stripContextFromUrl(item.url) : item.url;
|
|
907
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
908
|
-
console.log("[NavMain] Item navigation:", {
|
|
909
|
-
title: item.title,
|
|
910
|
-
originalUrl: item.url,
|
|
911
|
-
linkHref,
|
|
912
|
-
currentContext: getCurrentContext(),
|
|
913
|
-
currentPathname: pathname,
|
|
914
|
-
useLink,
|
|
915
|
-
willReload: !useLink
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
834
|
if (useLink) {
|
|
919
835
|
return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(
|
|
920
836
|
SidebarMenuButton,
|
|
@@ -1277,18 +1193,7 @@ function useNavigation({
|
|
|
1277
1193
|
const [loading, setLoading] = useState(false);
|
|
1278
1194
|
const [error, setError] = useState(null);
|
|
1279
1195
|
useEffect(() => {
|
|
1280
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1281
|
-
console.log("[useNavigation] Hook called:", {
|
|
1282
|
-
enabled,
|
|
1283
|
-
organizationId,
|
|
1284
|
-
apiBaseUrl,
|
|
1285
|
-
willFetch: enabled
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
1196
|
if (!enabled) {
|
|
1289
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1290
|
-
console.log("[useNavigation] Skipping fetch: disabled");
|
|
1291
|
-
}
|
|
1292
1197
|
setItems([]);
|
|
1293
1198
|
setOrganizations([]);
|
|
1294
1199
|
setUser(null);
|
|
@@ -1296,9 +1201,6 @@ function useNavigation({
|
|
|
1296
1201
|
}
|
|
1297
1202
|
const fetchNavigation = async () => {
|
|
1298
1203
|
const url = organizationId ? `${apiBaseUrl}/navigation/${organizationId}` : `${apiBaseUrl}/navigation`;
|
|
1299
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1300
|
-
console.log("[useNavigation] Fetching navigation:", url);
|
|
1301
|
-
}
|
|
1302
1204
|
setLoading(true);
|
|
1303
1205
|
setError(null);
|
|
1304
1206
|
try {
|
|
@@ -1319,26 +1221,11 @@ function useNavigation({
|
|
|
1319
1221
|
throw new Error(`Failed to fetch navigation: ${response.statusText}`);
|
|
1320
1222
|
}
|
|
1321
1223
|
const data = await response.json();
|
|
1322
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1323
|
-
console.log("[useNavigation] Navigation data received:", {
|
|
1324
|
-
itemsCount: data.items?.length || 0,
|
|
1325
|
-
organizationsCount: data.organizations?.length || 0,
|
|
1326
|
-
hasUser: !!data.user,
|
|
1327
|
-
organizationId: data.organizationId
|
|
1328
|
-
});
|
|
1329
|
-
}
|
|
1330
1224
|
setItems(data.items || []);
|
|
1331
1225
|
setOrganizations(data.organizations || []);
|
|
1332
1226
|
setUser(data.user || null);
|
|
1333
1227
|
} catch (err) {
|
|
1334
1228
|
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
1335
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1336
|
-
console.error("[useNavigation] Fetch error:", {
|
|
1337
|
-
error: error2.message,
|
|
1338
|
-
url,
|
|
1339
|
-
organizationId
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
1229
|
setError(error2);
|
|
1343
1230
|
setItems([]);
|
|
1344
1231
|
setOrganizations([]);
|
|
@@ -1370,58 +1257,16 @@ function AppSidebar({
|
|
|
1370
1257
|
}
|
|
1371
1258
|
}
|
|
1372
1259
|
const detectedOrgId = organizationId || pathOrgId || void 0;
|
|
1373
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1374
|
-
console.log("[AppSidebar] Debug:", {
|
|
1375
|
-
currentPathname,
|
|
1376
|
-
pathSegments,
|
|
1377
|
-
pathOrgId,
|
|
1378
|
-
organizationId,
|
|
1379
|
-
detectedOrgId,
|
|
1380
|
-
apiBaseUrl
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
1260
|
const {
|
|
1384
1261
|
items: apiNavigationItems,
|
|
1385
1262
|
organizations: apiOrganizations,
|
|
1386
1263
|
user: navigationUser,
|
|
1387
|
-
loading: navigationLoading
|
|
1388
|
-
error: navigationError
|
|
1264
|
+
loading: navigationLoading
|
|
1389
1265
|
} = useNavigation({
|
|
1390
1266
|
organizationId: detectedOrgId,
|
|
1391
1267
|
apiBaseUrl,
|
|
1392
1268
|
enabled: true
|
|
1393
1269
|
});
|
|
1394
|
-
React2.useEffect(() => {
|
|
1395
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1396
|
-
const orgIds = apiOrganizations.map((org) => org.id);
|
|
1397
|
-
const pathOrgIdInList = pathOrgId ? apiOrganizations.some((org) => org.id === pathOrgId) : false;
|
|
1398
|
-
const computedCurrentOrgId = organizationId || (pathOrgId && (apiOrganizations.length === 0 || apiOrganizations.some((org) => org.id === pathOrgId)) ? pathOrgId : void 0) || (detectedOrgId && apiNavigationItems.length > 0 ? detectedOrgId : void 0);
|
|
1399
|
-
console.log("[AppSidebar] Navigation state (ENHANCED):", {
|
|
1400
|
-
currentPathname,
|
|
1401
|
-
pathOrgId,
|
|
1402
|
-
organizationId,
|
|
1403
|
-
detectedOrgId,
|
|
1404
|
-
apiBaseUrl,
|
|
1405
|
-
itemsCount: apiNavigationItems.length,
|
|
1406
|
-
organizationsCount: apiOrganizations.length,
|
|
1407
|
-
organizationIds: orgIds,
|
|
1408
|
-
pathOrgIdInList,
|
|
1409
|
-
computedCurrentOrgId,
|
|
1410
|
-
displayItemsCount: computedCurrentOrgId ? apiNavigationItems.length : 0,
|
|
1411
|
-
loading: navigationLoading,
|
|
1412
|
-
error: navigationError?.message,
|
|
1413
|
-
navigationUrl: detectedOrgId ? `${apiBaseUrl}/navigation/${detectedOrgId}` : "N/A"
|
|
1414
|
-
});
|
|
1415
|
-
console.log("[AppSidebar] KEY VALUES:", {
|
|
1416
|
-
"computedCurrentOrgId": computedCurrentOrgId,
|
|
1417
|
-
"apiNavigationItems.length": apiNavigationItems.length,
|
|
1418
|
-
"apiOrganizations.length": apiOrganizations.length,
|
|
1419
|
-
"pathOrgIdInList": pathOrgIdInList,
|
|
1420
|
-
"organizationIds": orgIds,
|
|
1421
|
-
"willDisplayItems": !!computedCurrentOrgId && apiNavigationItems.length > 0
|
|
1422
|
-
});
|
|
1423
|
-
}
|
|
1424
|
-
}, [currentPathname, pathOrgId, organizationId, detectedOrgId, apiBaseUrl, apiNavigationItems, apiOrganizations, navigationLoading, navigationError]);
|
|
1425
1270
|
const user = navigationUser || userProp;
|
|
1426
1271
|
const currentOrgId = organizationId || (pathOrgId && (apiOrganizations.length === 0 || apiOrganizations.some((org) => org.id === pathOrgId)) ? pathOrgId : void 0) || (detectedOrgId && apiNavigationItems.length > 0 ? detectedOrgId : void 0);
|
|
1427
1272
|
let navigationItems = apiNavigationItems;
|
|
@@ -1436,22 +1281,6 @@ function AppSidebar({
|
|
|
1436
1281
|
}));
|
|
1437
1282
|
}
|
|
1438
1283
|
const displayNavigationItems = currentOrgId ? navigationItems : [];
|
|
1439
|
-
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1440
|
-
console.log("[AppSidebar] currentOrgId calculation:", {
|
|
1441
|
-
"organizationId prop": organizationId,
|
|
1442
|
-
"pathOrgId": pathOrgId,
|
|
1443
|
-
"detectedOrgId": detectedOrgId,
|
|
1444
|
-
"apiOrganizations.length": apiOrganizations.length,
|
|
1445
|
-
"apiNavigationItems.length": apiNavigationItems.length,
|
|
1446
|
-
"pathOrgIdInList": pathOrgId ? apiOrganizations.some((org) => org.id === pathOrgId) : false,
|
|
1447
|
-
"FINAL currentOrgId": currentOrgId,
|
|
1448
|
-
"navigationItems.length": navigationItems.length,
|
|
1449
|
-
"displayNavigationItems.length": displayNavigationItems.length,
|
|
1450
|
-
"willDisplayItems": displayNavigationItems.length > 0
|
|
1451
|
-
});
|
|
1452
|
-
console.log("[AppSidebar] FINAL currentOrgId:", currentOrgId);
|
|
1453
|
-
console.log("[AppSidebar] displayNavigationItems.length:", displayNavigationItems.length);
|
|
1454
|
-
}
|
|
1455
1284
|
return /* @__PURE__ */ jsxs(Sidebar, { collapsible: "icon", ...props, children: [
|
|
1456
1285
|
/* @__PURE__ */ jsx(SidebarHeader, { children: /* @__PURE__ */ jsx(
|
|
1457
1286
|
TeamSwitcher,
|