@kopexa/sidebar 17.2.1 → 17.3.1

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.
@@ -32,7 +32,10 @@ type SidebarV2PanelItem = {
32
32
  label: string;
33
33
  href: string;
34
34
  icon?: SidebarV2Icon;
35
+ /** Count pill after the label (e.g. number of open items). */
35
36
  badge?: number | string;
37
+ /** Status chip after the label, e.g. "Preview", "Beta", "Neu". */
38
+ tag?: string;
36
39
  /** Stable key; defaults to href. */
37
40
  value?: string;
38
41
  } | {
@@ -72,9 +75,25 @@ type SidebarV2RailEntry = {
72
75
  slot?: "top" | "bottom";
73
76
  };
74
77
  type SidebarV2Nav = SidebarV2RailEntry[];
78
+ /**
79
+ * A route's identity is its pathname — query (`?`) and hash (`#`) are transient
80
+ * (filters, tabs-by-query, scroll anchors) and never part of nav identity. Strip
81
+ * them (and any trailing slash) before comparing, so a nav href that carries an
82
+ * incidental `?param` still matches the bare route. `/` is preserved.
83
+ */
84
+ declare function normalizePath(href: string): string;
85
+ /**
86
+ * Length of the match between an already-normalized `currentPath` and a target
87
+ * `href`, or `-1` when it doesn't match. Exact and ancestor-prefix matches both
88
+ * return the target's length; callers keep the longest (most specific) one so the
89
+ * panel/item that owns the deepest matching route wins — never a shorter prefix
90
+ * from an unrelated entry. The boundary is `/`, so `/risks` never matches
91
+ * `/risks-archive`.
92
+ */
93
+ declare function pathMatchLength(currentPath: string, href: string): number;
75
94
  declare function panelItemHasChildren(item: SidebarV2PanelItem): item is Extract<SidebarV2PanelItem, {
76
95
  children: SidebarV2SubItem[];
77
96
  }>;
78
97
  declare function panelItemIsSection(item: SidebarV2PanelItem): item is SidebarV2PanelSection;
79
98
 
80
- export { type SidebarV2Icon, type SidebarV2LinkProps, type SidebarV2Nav, type SidebarV2PanelItem, type SidebarV2PanelSection, type SidebarV2RailEntry, type SidebarV2SubItem, panelItemHasChildren, panelItemIsSection };
99
+ export { type SidebarV2Icon, type SidebarV2LinkProps, type SidebarV2Nav, type SidebarV2PanelItem, type SidebarV2PanelSection, type SidebarV2RailEntry, type SidebarV2SubItem, normalizePath, panelItemHasChildren, panelItemIsSection, pathMatchLength };
@@ -32,7 +32,10 @@ type SidebarV2PanelItem = {
32
32
  label: string;
33
33
  href: string;
34
34
  icon?: SidebarV2Icon;
35
+ /** Count pill after the label (e.g. number of open items). */
35
36
  badge?: number | string;
37
+ /** Status chip after the label, e.g. "Preview", "Beta", "Neu". */
38
+ tag?: string;
36
39
  /** Stable key; defaults to href. */
37
40
  value?: string;
38
41
  } | {
@@ -72,9 +75,25 @@ type SidebarV2RailEntry = {
72
75
  slot?: "top" | "bottom";
73
76
  };
74
77
  type SidebarV2Nav = SidebarV2RailEntry[];
78
+ /**
79
+ * A route's identity is its pathname — query (`?`) and hash (`#`) are transient
80
+ * (filters, tabs-by-query, scroll anchors) and never part of nav identity. Strip
81
+ * them (and any trailing slash) before comparing, so a nav href that carries an
82
+ * incidental `?param` still matches the bare route. `/` is preserved.
83
+ */
84
+ declare function normalizePath(href: string): string;
85
+ /**
86
+ * Length of the match between an already-normalized `currentPath` and a target
87
+ * `href`, or `-1` when it doesn't match. Exact and ancestor-prefix matches both
88
+ * return the target's length; callers keep the longest (most specific) one so the
89
+ * panel/item that owns the deepest matching route wins — never a shorter prefix
90
+ * from an unrelated entry. The boundary is `/`, so `/risks` never matches
91
+ * `/risks-archive`.
92
+ */
93
+ declare function pathMatchLength(currentPath: string, href: string): number;
75
94
  declare function panelItemHasChildren(item: SidebarV2PanelItem): item is Extract<SidebarV2PanelItem, {
76
95
  children: SidebarV2SubItem[];
77
96
  }>;
78
97
  declare function panelItemIsSection(item: SidebarV2PanelItem): item is SidebarV2PanelSection;
79
98
 
80
- export { type SidebarV2Icon, type SidebarV2LinkProps, type SidebarV2Nav, type SidebarV2PanelItem, type SidebarV2PanelSection, type SidebarV2RailEntry, type SidebarV2SubItem, panelItemHasChildren, panelItemIsSection };
99
+ export { type SidebarV2Icon, type SidebarV2LinkProps, type SidebarV2Nav, type SidebarV2PanelItem, type SidebarV2PanelSection, type SidebarV2RailEntry, type SidebarV2SubItem, normalizePath, panelItemHasChildren, panelItemIsSection, pathMatchLength };
package/dist/v2/types.js CHANGED
@@ -21,10 +21,23 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/v2/types.ts
22
22
  var types_exports = {};
23
23
  __export(types_exports, {
24
+ normalizePath: () => normalizePath,
24
25
  panelItemHasChildren: () => panelItemHasChildren,
25
- panelItemIsSection: () => panelItemIsSection
26
+ panelItemIsSection: () => panelItemIsSection,
27
+ pathMatchLength: () => pathMatchLength
26
28
  });
27
29
  module.exports = __toCommonJS(types_exports);
30
+ function normalizePath(href) {
31
+ const path = href.split("#")[0].split("?")[0].replace(/\/+$/, "");
32
+ return path === "" ? "/" : path;
33
+ }
34
+ function pathMatchLength(currentPath, href) {
35
+ const target = normalizePath(href);
36
+ if (currentPath === target) return target.length;
37
+ if (target !== "/" && currentPath.startsWith(`${target}/`))
38
+ return target.length;
39
+ return -1;
40
+ }
28
41
  function panelItemHasChildren(item) {
29
42
  return "children" in item && Array.isArray(item.children);
30
43
  }
@@ -33,6 +46,8 @@ function panelItemIsSection(item) {
33
46
  }
34
47
  // Annotate the CommonJS export names for ESM import in node:
35
48
  0 && (module.exports = {
49
+ normalizePath,
36
50
  panelItemHasChildren,
37
- panelItemIsSection
51
+ panelItemIsSection,
52
+ pathMatchLength
38
53
  });
package/dist/v2/types.mjs CHANGED
@@ -1,9 +1,13 @@
1
1
  "use client";
2
2
  import {
3
+ normalizePath,
3
4
  panelItemHasChildren,
4
- panelItemIsSection
5
- } from "../chunk-SDMGFB6V.mjs";
5
+ panelItemIsSection,
6
+ pathMatchLength
7
+ } from "../chunk-BFZFZSUC.mjs";
6
8
  export {
9
+ normalizePath,
7
10
  panelItemHasChildren,
8
- panelItemIsSection
11
+ panelItemIsSection,
12
+ pathMatchLength
9
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/sidebar",
3
- "version": "17.2.1",
3
+ "version": "17.3.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sidebar"
@@ -28,19 +28,19 @@
28
28
  "motion": ">=12.23.6",
29
29
  "react": ">=19.0.0-rc.0",
30
30
  "react-dom": ">=19.0.0-rc.0",
31
- "@kopexa/theme": "17.33.1"
31
+ "@kopexa/theme": "17.35.0"
32
32
  },
33
33
  "dependencies": {
34
34
  "@radix-ui/react-slot": "^1.2.4",
35
- "@kopexa/button": "17.0.92",
36
- "@kopexa/drawer": "17.2.57",
37
- "@kopexa/icons": "17.10.21",
38
- "@kopexa/react-utils": "17.1.34",
39
- "@kopexa/input": "17.0.92",
40
- "@kopexa/separator": "17.0.92",
41
- "@kopexa/shared-utils": "17.0.92",
42
- "@kopexa/tooltip": "17.2.57",
43
- "@kopexa/use-is-mobile": "17.0.92"
35
+ "@kopexa/button": "17.0.94",
36
+ "@kopexa/drawer": "17.2.59",
37
+ "@kopexa/input": "17.0.94",
38
+ "@kopexa/react-utils": "17.1.36",
39
+ "@kopexa/shared-utils": "17.0.94",
40
+ "@kopexa/separator": "17.0.94",
41
+ "@kopexa/use-is-mobile": "17.0.94",
42
+ "@kopexa/icons": "17.10.23",
43
+ "@kopexa/tooltip": "17.2.59"
44
44
  },
45
45
  "clean-package": "../../../clean-package.config.json",
46
46
  "module": "dist/index.mjs",
@@ -1,14 +0,0 @@
1
- "use client";
2
-
3
- // src/v2/types.ts
4
- function panelItemHasChildren(item) {
5
- return "children" in item && Array.isArray(item.children);
6
- }
7
- function panelItemIsSection(item) {
8
- return "section" in item;
9
- }
10
-
11
- export {
12
- panelItemHasChildren,
13
- panelItemIsSection
14
- };