nicklabs-ui 1.0.43 → 1.0.44

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/README.md CHANGED
@@ -1786,7 +1786,7 @@ onUnmounted(() => clearSuffix())
1786
1786
 
1787
1787
  ### useSidebarManager
1788
1788
 
1789
- Manage sidebar open/close state and expandable menu groups, persisted to localStorage.
1789
+ Manage sidebar open/close state, expandable menu groups (persisted to localStorage), and active state logic.
1790
1790
 
1791
1791
  ```typescript
1792
1792
  import { useSidebarManager } from 'nicklabs-ui'
@@ -1796,6 +1796,8 @@ const {
1796
1796
  toggleMenu,
1797
1797
  isSidebarExpanded,
1798
1798
  toggleSidebar,
1799
+ setMenuActiveResolver,
1800
+ setItemActiveResolver,
1799
1801
  } = useSidebarManager(sidebarId?)
1800
1802
  ```
1801
1803
 
@@ -1813,6 +1815,26 @@ const {
1813
1815
  | `toggleMenu` | `(menuTitle: string) => void` | Toggle a menu group |
1814
1816
  | `isSidebarExpanded` | `() => boolean` | Check if sidebar is open |
1815
1817
  | `toggleSidebar` | `() => void` | Toggle sidebar open/close |
1818
+ | `setMenuActiveResolver` | `(fn: (menu: Menu, currentPath: string) => boolean) => void` | Override the active logic for a top-level menu group |
1819
+ | `setItemActiveResolver` | `(fn: (childMenu: MenuChild, currentPath: string) => boolean) => void` | Override the active logic for individual menu items |
1820
+
1821
+ **Custom active state**
1822
+
1823
+ By default, `NSidebar` marks a menu item active when its `route` exactly matches `currentPath`. Use the resolver setters to provide custom logic — for example, prefix matching for nested routes:
1824
+
1825
+ ```typescript
1826
+ import { useSidebarManager } from 'nicklabs-ui'
1827
+ import type { MenuChild } from 'nicklabs-ui'
1828
+
1829
+ const { setItemActiveResolver } = useSidebarManager()
1830
+
1831
+ // Highlight the item whenever the current path starts with its route
1832
+ setItemActiveResolver((childMenu: MenuChild, currentPath: string) => {
1833
+ return currentPath.startsWith(childMenu.route)
1834
+ })
1835
+ ```
1836
+
1837
+ Call the setters once at app initialisation (e.g. `main.ts` or `App.vue`) — the setting is global and persists for the lifetime of the page.
1816
1838
 
1817
1839
  ---
1818
1840