@pnkx-lib/ui 1.9.445 → 1.9.446

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.
@@ -53,14 +53,24 @@ function validateAbsolutePaths(menu, nearestAncestorPath) {
53
53
  }
54
54
  }
55
55
 
56
+ const escapeRegex = (s) => s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
57
+ const pathToRegex = (pattern) => {
58
+ const escaped = escapeRegex(pattern).replace(/\\:([^/]+)/g, "[^/]+");
59
+ return new RegExp(`^${escaped}$`);
60
+ };
56
61
  const full = (itemPath) => normalize(itemPath ?? "/");
62
+ const matchPath = (configPath, pathname) => {
63
+ const p = normalize(configPath);
64
+ const rx = pathToRegex(p);
65
+ return rx.test(normalize(pathname));
66
+ };
57
67
  function findTrail(menu, pathUrl) {
58
68
  const trail = [];
59
69
  const walk = (items) => {
60
70
  for (const item of items) {
61
71
  const fullPath = full(item.path);
62
72
  trail.push({ ...item, fullPath });
63
- if (fullPath === pathUrl) return true;
73
+ if (item.path && matchPath(fullPath, pathUrl)) return true;
64
74
  if (item.children?.length && walk(item.children)) return true;
65
75
  trail.pop();
66
76
  }
package/es/index.js CHANGED
@@ -84,7 +84,7 @@ export { Cascader } from './fields/CascaderField.js';
84
84
  export { InputRangePicker } from './fields/InputRangePicker.js';
85
85
  export { useToast } from './hooks/useToast.js';
86
86
  export { useMessage } from './hooks/useMessage.js';
87
- export { c as createComponentWithProps, e as extractRoutesFromMenu, n as normalize, v as validateAbsolutePaths } from './chunks/useBreadcrumb-Cor4nvR1.js';
87
+ export { c as createComponentWithProps, e as extractRoutesFromMenu, n as normalize, v as validateAbsolutePaths } from './chunks/useBreadcrumb-DWHss9HZ.js';
88
88
 
89
89
  const generateId = (name, path) => {
90
90
  const source = `${name}-${path || ""}`;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { r } from '../chunks/index-t0ynpS_n.js';
3
3
  import { Breadcrumb } from './Breadcrumb.js';
4
- import { u as useBreadcrumb } from '../chunks/useBreadcrumb-Cor4nvR1.js';
4
+ import { u as useBreadcrumb } from '../chunks/useBreadcrumb-DWHss9HZ.js';
5
5
 
6
6
  const BreadcrumbHeading = (props) => {
7
7
  const { menu, customBreadcum } = props;
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { u as useBreadcrumb } from '../chunks/useBreadcrumb-Cor4nvR1.js';
2
+ import { u as useBreadcrumb } from '../chunks/useBreadcrumb-DWHss9HZ.js';
3
3
  import { Breadcrumb } from './Breadcrumb.js';
4
4
 
5
5
  const WrapperBreadcrumb = ({ menu }) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pnkx-lib/ui",
3
3
  "private": false,
4
- "version": "1.9.445",
4
+ "version": "1.9.446",
5
5
  "type": "module",
6
6
  "main": "./es/index.js",
7
7
  "module": "./es/index.js",
@@ -6,7 +6,8 @@ type CustomBreadcrumbItem = {
6
6
  /**
7
7
  * Quy tắc hiển thị:
8
8
  * - Chỉ hiển thị khi leaf.isShowBreadcrumb === true.
9
- * - Khi hiển thị: ancestor có `path` (absolute) + leaf.
9
+ * - Khi hiển thị: ancestor có `path` + leaf (ancestor không path bị loại).
10
+ * - Hỗ trợ path động có `:id`, `:slug`, ...
10
11
  */
11
12
  export declare function useBreadcrumb(menuRouter: MenuType[], customBreadcrumb?: CustomBreadcrumbItem[]): BreadcrumbItemType[];
12
13
  export {};