nicklabs-ui 1.0.42 → 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
@@ -314,6 +314,7 @@ Checkbox input supporting both single and multi-option modes.
314
314
  | `inline` | `boolean` | `false` | Display title and options on the same line |
315
315
  | `direction` | `"row" \| "column"` | `"row"` | Layout direction for options |
316
316
  | `autofocus` | `boolean` | `false` | Auto-focus on mount |
317
+ | `allowDeselect` | `boolean` | `true` | Allow deselecting in single mode; set to `false` to prevent unchecking once checked |
317
318
  | `formatLabel` | `(option: any) => string` | `(opt) => opt.label` | Function to extract display text from an option |
318
319
  | `formatValue` | `(option: any) => any` | `(opt) => opt.value` | Function to extract the value from an option |
319
320
 
@@ -1785,7 +1786,7 @@ onUnmounted(() => clearSuffix())
1785
1786
 
1786
1787
  ### useSidebarManager
1787
1788
 
1788
- 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.
1789
1790
 
1790
1791
  ```typescript
1791
1792
  import { useSidebarManager } from 'nicklabs-ui'
@@ -1795,6 +1796,8 @@ const {
1795
1796
  toggleMenu,
1796
1797
  isSidebarExpanded,
1797
1798
  toggleSidebar,
1799
+ setMenuActiveResolver,
1800
+ setItemActiveResolver,
1798
1801
  } = useSidebarManager(sidebarId?)
1799
1802
  ```
1800
1803
 
@@ -1812,6 +1815,26 @@ const {
1812
1815
  | `toggleMenu` | `(menuTitle: string) => void` | Toggle a menu group |
1813
1816
  | `isSidebarExpanded` | `() => boolean` | Check if sidebar is open |
1814
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.
1815
1838
 
1816
1839
  ---
1817
1840