@logickernel/bridge 0.11.4 → 0.11.6
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.cjs
CHANGED
|
@@ -756,22 +756,22 @@ function getIconComponent(icon) {
|
|
|
756
756
|
}
|
|
757
757
|
function NavMain({ items }) {
|
|
758
758
|
const pathname = navigation.usePathname();
|
|
759
|
-
const router = navigation.useRouter();
|
|
760
759
|
const { isMobile, setOpenMobile } = useSidebar();
|
|
761
|
-
const
|
|
762
|
-
|
|
760
|
+
const getCurrentContext = () => {
|
|
761
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
762
|
+
if (segments.length === 0) return null;
|
|
763
|
+
return `/${segments[0]}`;
|
|
763
764
|
};
|
|
764
|
-
const
|
|
765
|
-
|
|
765
|
+
const shouldUseLink = (url) => {
|
|
766
|
+
const currentContext = getCurrentContext();
|
|
767
|
+
if (!currentContext) return false;
|
|
768
|
+
if (url.startsWith(currentContext)) return true;
|
|
769
|
+
return false;
|
|
766
770
|
};
|
|
767
|
-
const
|
|
771
|
+
const handleClick = () => {
|
|
768
772
|
if (isMobile) {
|
|
769
773
|
setOpenMobile(false);
|
|
770
774
|
}
|
|
771
|
-
if (isCrossAppPath(url) && !isAbsoluteUrl(url)) {
|
|
772
|
-
e?.preventDefault();
|
|
773
|
-
router.push(url);
|
|
774
|
-
}
|
|
775
775
|
};
|
|
776
776
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
777
777
|
console.log("[NavMain] Received items:", {
|
|
@@ -850,18 +850,7 @@ function NavMain({ items }) {
|
|
|
850
850
|
group.label.title
|
|
851
851
|
] }),
|
|
852
852
|
group.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: group.items.map((item) => {
|
|
853
|
-
|
|
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
|
-
}
|
|
853
|
+
const isActive = pathname === item.url || item.isActive;
|
|
865
854
|
const hasSubItems = item.items && item.items.length > 0;
|
|
866
855
|
if (hasSubItems) {
|
|
867
856
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -884,48 +873,27 @@ function NavMain({ items }) {
|
|
|
884
873
|
}
|
|
885
874
|
) }),
|
|
886
875
|
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
|
|
887
|
-
if (
|
|
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 })
|
|
894
|
-
}
|
|
895
|
-
) }) }, subItem.title);
|
|
876
|
+
if (shouldUseLink(subItem.url)) {
|
|
877
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: subItem.url, onClick: handleClick, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
896
878
|
}
|
|
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);
|
|
879
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: subItem.url, onClick: handleClick, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
905
880
|
}) }) })
|
|
906
881
|
] })
|
|
907
882
|
},
|
|
908
883
|
item.title
|
|
909
884
|
);
|
|
910
885
|
}
|
|
911
|
-
if (
|
|
886
|
+
if (shouldUseLink(item.url)) {
|
|
912
887
|
return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
913
888
|
SidebarMenuButton,
|
|
914
889
|
{
|
|
915
890
|
asChild: true,
|
|
916
891
|
tooltip: item.title,
|
|
917
892
|
isActive,
|
|
918
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
919
|
-
|
|
920
|
-
{
|
|
921
|
-
|
|
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
|
-
)
|
|
893
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: item.url, onClick: handleClick, children: [
|
|
894
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
895
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
896
|
+
] })
|
|
929
897
|
}
|
|
930
898
|
) }, item.title);
|
|
931
899
|
}
|
|
@@ -935,17 +903,10 @@ function NavMain({ items }) {
|
|
|
935
903
|
asChild: true,
|
|
936
904
|
tooltip: item.title,
|
|
937
905
|
isActive,
|
|
938
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
939
|
-
|
|
940
|
-
{
|
|
941
|
-
|
|
942
|
-
onClick: () => handleNavigation(item.url),
|
|
943
|
-
children: [
|
|
944
|
-
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
945
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
946
|
-
]
|
|
947
|
-
}
|
|
948
|
-
)
|
|
906
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: item.url, onClick: handleClick, children: [
|
|
907
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
908
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
909
|
+
] })
|
|
949
910
|
}
|
|
950
911
|
) }, item.title);
|
|
951
912
|
}) })
|