@pnkx-lib/ui 1.9.449 → 1.9.450

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.
@@ -54,24 +54,31 @@ function validateAbsolutePaths(menu, nearestAncestorPath) {
54
54
  }
55
55
  }
56
56
 
57
- const pathToRegex = (pattern) => {
58
- const normalized = normalize(pattern);
59
- const escaped = normalized.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
60
- const withParams = escaped.replace(/:([^/]+)/g, "[^/]+");
61
- return new RegExp(`^${withParams}/?$`);
62
- };
63
- const full = (itemPath) => normalize(itemPath ?? "/");
64
- const matchPath = (configPath, pathname) => pathToRegex(configPath).test(normalize(pathname));
65
- function extractParams(pattern, pathname) {
57
+ function compilePattern(pattern) {
66
58
  const pat = normalize(pattern);
67
- const path = normalize(pathname);
59
+ const keys = [];
68
60
  const escaped = pat.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
69
- const named = escaped.replace(/:([^/]+)/g, (_, key) => `(?<${key}>[^/]+)`);
70
- const rx = new RegExp(`^${named}/?$`);
71
- const m = rx.exec(path);
72
- return m?.groups ?? {};
61
+ const withCaptures = escaped.replace(/:([^/]+)/g, (_m, key) => {
62
+ keys.push(key);
63
+ return "([^/]+)";
64
+ });
65
+ const regex = new RegExp(`^${withCaptures}/?$`);
66
+ return { regex, keys };
67
+ }
68
+ function matchPath(pattern, pathname) {
69
+ const { regex } = compilePattern(pattern);
70
+ return regex.test(normalize(pathname));
71
+ }
72
+ function extractParams(pattern, pathname) {
73
+ const { regex, keys } = compilePattern(pattern);
74
+ const m = regex.exec(normalize(pathname));
75
+ if (!m) return {};
76
+ const out = {};
77
+ for (let i = 0; i < keys.length; i++) out[keys[i]] = m[i + 1];
78
+ return out;
73
79
  }
74
80
  const hasParams = (p) => !!p && /:([^/]+)/.test(p ?? "");
81
+ const full = (itemPath) => normalize(itemPath ?? "/");
75
82
  function findTrail(menu, pathUrl) {
76
83
  const trail = [];
77
84
  const walk = (items) => {
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-CQA2mBvb.js';
87
+ export { c as createComponentWithProps, e as extractRoutesFromMenu, n as normalize, v as validateAbsolutePaths } from './chunks/useBreadcrumb-DtXCsh1h.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-CQA2mBvb.js';
4
+ import { u as useBreadcrumb } from '../chunks/useBreadcrumb-DtXCsh1h.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-CQA2mBvb.js';
2
+ import { u as useBreadcrumb } from '../chunks/useBreadcrumb-DtXCsh1h.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.449",
4
+ "version": "1.9.450",
5
5
  "type": "module",
6
6
  "main": "./es/index.js",
7
7
  "module": "./es/index.js",