@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.js
CHANGED
|
@@ -727,22 +727,22 @@ function getIconComponent(icon) {
|
|
|
727
727
|
}
|
|
728
728
|
function NavMain({ items }) {
|
|
729
729
|
const pathname = usePathname();
|
|
730
|
-
const router = useRouter();
|
|
731
730
|
const { isMobile, setOpenMobile } = useSidebar();
|
|
732
|
-
const
|
|
733
|
-
|
|
731
|
+
const getCurrentContext = () => {
|
|
732
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
733
|
+
if (segments.length === 0) return null;
|
|
734
|
+
return `/${segments[0]}`;
|
|
734
735
|
};
|
|
735
|
-
const
|
|
736
|
-
|
|
736
|
+
const shouldUseLink = (url) => {
|
|
737
|
+
const currentContext = getCurrentContext();
|
|
738
|
+
if (!currentContext) return false;
|
|
739
|
+
if (url.startsWith(currentContext)) return true;
|
|
740
|
+
return false;
|
|
737
741
|
};
|
|
738
|
-
const
|
|
742
|
+
const handleClick = () => {
|
|
739
743
|
if (isMobile) {
|
|
740
744
|
setOpenMobile(false);
|
|
741
745
|
}
|
|
742
|
-
if (isCrossAppPath(url) && !isAbsoluteUrl(url)) {
|
|
743
|
-
e?.preventDefault();
|
|
744
|
-
router.push(url);
|
|
745
|
-
}
|
|
746
746
|
};
|
|
747
747
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
748
748
|
console.log("[NavMain] Received items:", {
|
|
@@ -821,18 +821,7 @@ function NavMain({ items }) {
|
|
|
821
821
|
group.label.title
|
|
822
822
|
] }),
|
|
823
823
|
group.items.length > 0 && /* @__PURE__ */ jsx(SidebarMenu, { children: group.items.map((item) => {
|
|
824
|
-
|
|
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
|
-
}
|
|
824
|
+
const isActive = pathname === item.url || item.isActive;
|
|
836
825
|
const hasSubItems = item.items && item.items.length > 0;
|
|
837
826
|
if (hasSubItems) {
|
|
838
827
|
return /* @__PURE__ */ jsx(
|
|
@@ -855,48 +844,27 @@ function NavMain({ items }) {
|
|
|
855
844
|
}
|
|
856
845
|
) }),
|
|
857
846
|
/* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => {
|
|
858
|
-
if (
|
|
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 })
|
|
865
|
-
}
|
|
866
|
-
) }) }, subItem.title);
|
|
847
|
+
if (shouldUseLink(subItem.url)) {
|
|
848
|
+
return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: subItem.url, onClick: handleClick, children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
867
849
|
}
|
|
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);
|
|
850
|
+
return /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx("a", { href: subItem.url, onClick: handleClick, children: /* @__PURE__ */ jsx("span", { children: subItem.title }) }) }) }, subItem.title);
|
|
876
851
|
}) }) })
|
|
877
852
|
] })
|
|
878
853
|
},
|
|
879
854
|
item.title
|
|
880
855
|
);
|
|
881
856
|
}
|
|
882
|
-
if (
|
|
857
|
+
if (shouldUseLink(item.url)) {
|
|
883
858
|
return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsx(
|
|
884
859
|
SidebarMenuButton,
|
|
885
860
|
{
|
|
886
861
|
asChild: true,
|
|
887
862
|
tooltip: item.title,
|
|
888
863
|
isActive,
|
|
889
|
-
children: /* @__PURE__ */ jsxs(
|
|
890
|
-
|
|
891
|
-
{
|
|
892
|
-
|
|
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
|
-
)
|
|
864
|
+
children: /* @__PURE__ */ jsxs(Link, { href: item.url, onClick: handleClick, children: [
|
|
865
|
+
item.icon && /* @__PURE__ */ jsx(item.icon, {}),
|
|
866
|
+
/* @__PURE__ */ jsx("span", { children: item.title })
|
|
867
|
+
] })
|
|
900
868
|
}
|
|
901
869
|
) }, item.title);
|
|
902
870
|
}
|
|
@@ -906,17 +874,10 @@ function NavMain({ items }) {
|
|
|
906
874
|
asChild: true,
|
|
907
875
|
tooltip: item.title,
|
|
908
876
|
isActive,
|
|
909
|
-
children: /* @__PURE__ */ jsxs(
|
|
910
|
-
|
|
911
|
-
{
|
|
912
|
-
|
|
913
|
-
onClick: () => handleNavigation(item.url),
|
|
914
|
-
children: [
|
|
915
|
-
item.icon && /* @__PURE__ */ jsx(item.icon, {}),
|
|
916
|
-
/* @__PURE__ */ jsx("span", { children: item.title })
|
|
917
|
-
]
|
|
918
|
-
}
|
|
919
|
-
)
|
|
877
|
+
children: /* @__PURE__ */ jsxs("a", { href: item.url, onClick: handleClick, children: [
|
|
878
|
+
item.icon && /* @__PURE__ */ jsx(item.icon, {}),
|
|
879
|
+
/* @__PURE__ */ jsx("span", { children: item.title })
|
|
880
|
+
] })
|
|
920
881
|
}
|
|
921
882
|
) }, item.title);
|
|
922
883
|
}) })
|