@krak-stack/registry 0.1.45 → 0.1.46

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @krak-stack/registry
2
2
 
3
+ ## 0.1.46
4
+
5
+ ### Patch Changes
6
+
7
+ - Highlight sidebar sections on nested routes using TanStack Router's built-in link matching. Add an exact option for overview and index links that should only highlight their own page. Ignore search parameters when determining active links.
8
+
3
9
  ## 0.1.45
4
10
 
5
11
  ### Patch Changes
@@ -2,6 +2,8 @@ import type { LucideIcon } from "lucide-react";
2
2
  type NavItem = {
3
3
  label: () => string;
4
4
  href: string;
5
+ /** Match only this page instead of also highlighting its nested routes. */
6
+ exact?: boolean;
5
7
  icon?: LucideIcon;
6
8
  badge?: () => string;
7
9
  external?: boolean;
@@ -1,5 +1,5 @@
1
1
  // ../../src/components/ui/sidebar-layout.tsx
2
- import { Link, Outlet, useRouterState } from "@tanstack/react-router";
2
+ import { Link, Outlet } from "@tanstack/react-router";
3
3
  import { Option, Schema as Schema2 } from "effect";
4
4
  import { Cookies } from "effect/http";
5
5
  import { useState as useState3 } from "react";
@@ -607,9 +607,6 @@ var useSidebarLayout = () => {
607
607
  };
608
608
  function AppSidebar({ collapsible, footer, groups, header }) {
609
609
  const { isMobile, setOpenMobile } = useSidebar();
610
- const pathname = useRouterState({
611
- select: (state) => state.location.pathname
612
- });
613
610
  const closeMobileSidebar = () => {
614
611
  if (isMobile)
615
612
  setOpenMobile(false);
@@ -635,11 +632,15 @@ function AppSidebar({ collapsible, footer, groups, header }) {
635
632
  target: "_blank",
636
633
  rel: "noreferrer"
637
634
  }) : /* @__PURE__ */ jsx5(Link, {
638
- to: item.href
635
+ to: item.href,
636
+ activeOptions: {
637
+ exact: item.exact ?? false,
638
+ includeSearch: false
639
+ },
640
+ activeProps: { "data-active": "" }
639
641
  });
640
642
  return /* @__PURE__ */ jsx5(SidebarMenuItem, {
641
643
  children: /* @__PURE__ */ jsxs4(SidebarMenuButton, {
642
- isActive: !item.external && pathname === item.href,
643
644
  onClick: closeMobileSidebar,
644
645
  render,
645
646
  tooltip: item.label(),
package/dist/lib/docs.js CHANGED
@@ -799,7 +799,7 @@ function SearchMenu({
799
799
  }
800
800
 
801
801
  // ../../src/components/ui/sidebar-layout.tsx
802
- import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
802
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
803
803
  import { Option, Schema as Schema2 } from "effect";
804
804
  import { Cookies } from "effect/http";
805
805
  import { useState as useState5 } from "react";
@@ -1317,9 +1317,6 @@ var getSidebarDefaultOpen = (defaultOpen) => {
1317
1317
  };
1318
1318
  function AppSidebar({ collapsible, footer, groups, header }) {
1319
1319
  const { isMobile, setOpenMobile } = useSidebar();
1320
- const pathname = useRouterState({
1321
- select: (state) => state.location.pathname
1322
- });
1323
1320
  const closeMobileSidebar = () => {
1324
1321
  if (isMobile)
1325
1322
  setOpenMobile(false);
@@ -1345,11 +1342,15 @@ function AppSidebar({ collapsible, footer, groups, header }) {
1345
1342
  target: "_blank",
1346
1343
  rel: "noreferrer"
1347
1344
  }) : /* @__PURE__ */ jsx13(Link2, {
1348
- to: item.href
1345
+ to: item.href,
1346
+ activeOptions: {
1347
+ exact: item.exact ?? false,
1348
+ includeSearch: false
1349
+ },
1350
+ activeProps: { "data-active": "" }
1349
1351
  });
1350
1352
  return /* @__PURE__ */ jsx13(SidebarMenuItem, {
1351
1353
  children: /* @__PURE__ */ jsxs10(SidebarMenuButton, {
1352
- isActive: !item.external && pathname === item.href,
1353
1354
  onClick: closeMobileSidebar,
1354
1355
  render,
1355
1356
  tooltip: item.label(),
@@ -119,7 +119,7 @@ import { XIcon } from "lucide-react";
119
119
  import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
120
120
 
121
121
  // ../../src/components/ui/sidebar-layout.tsx
122
- import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
122
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
123
123
  import { Option, Schema as Schema2 } from "effect";
124
124
  import { Cookies } from "effect/http";
125
125
  import { useState as useState5 } from "react";
@@ -119,7 +119,7 @@ import { XIcon } from "lucide-react";
119
119
  import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
120
120
 
121
121
  // ../../src/components/ui/sidebar-layout.tsx
122
- import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
122
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
123
123
  import { Option, Schema as Schema2 } from "effect";
124
124
  import { Cookies } from "effect/http";
125
125
  import { useState as useState5 } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {