@mercurjs/admin 2.0.0-canary.51 → 2.0.0-canary.52

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1620,6 +1620,12 @@ var NavItem = ({
1620
1620
  useEffect7(() => {
1621
1621
  setOpen(getIsOpen(to, items, pathname));
1622
1622
  }, [pathname, to, items]);
1623
+ const isNestedActive = useCallback5(
1624
+ (nestedTo) => {
1625
+ return pathname === nestedTo || pathname.startsWith(nestedTo + "/");
1626
+ },
1627
+ [pathname]
1628
+ );
1623
1629
  const navLinkClassNames = useCallback5(
1624
1630
  ({
1625
1631
  to: to2,
@@ -1628,14 +1634,13 @@ var NavItem = ({
1628
1634
  isSetting: isSetting2 = false
1629
1635
  }) => {
1630
1636
  if (["core", "setting"].includes(type)) {
1631
- isActive = pathname.startsWith(to2);
1632
- if (isActive && !isNested && items?.length) {
1633
- const nestedMatch = items.some(
1634
- (item) => pathname.startsWith(item.to)
1635
- );
1636
- if (nestedMatch) {
1637
- isActive = false;
1638
- }
1637
+ if (isNested) {
1638
+ isActive = isNestedActive(to2);
1639
+ } else if (items?.length) {
1640
+ const nestedMatch = items.some((item) => isNestedActive(item.to));
1641
+ isActive = pathname.startsWith(to2) && !nestedMatch;
1642
+ } else {
1643
+ isActive = pathname.startsWith(to2);
1639
1644
  }
1640
1645
  }
1641
1646
  return clx2(BASE_NAV_LINK_CLASSES, {
@@ -1644,7 +1649,7 @@ var NavItem = ({
1644
1649
  [SETTING_NAV_LINK_CLASSES]: isSetting2
1645
1650
  });
1646
1651
  },
1647
- [type, pathname, items]
1652
+ [type, pathname, items, isNestedActive]
1648
1653
  );
1649
1654
  const isSetting = type === "setting";
1650
1655
  return /* @__PURE__ */ jsxs3(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/admin",
3
- "version": "2.0.0-canary.51",
3
+ "version": "2.0.0-canary.52",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",