@pnkx-lib/ui 1.9.445 → 1.9.447
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
3
4
|
import { useLocation, Link } from 'react-router';
|
|
4
5
|
|
|
5
6
|
const extractRoutesFromMenu = (menuItems) => {
|
|
@@ -53,14 +54,24 @@ function validateAbsolutePaths(menu, nearestAncestorPath) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
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
|
+
};
|
|
56
63
|
const full = (itemPath) => normalize(itemPath ?? "/");
|
|
64
|
+
const matchPath = (configPath, pathname) => {
|
|
65
|
+
const rx = pathToRegex(configPath);
|
|
66
|
+
return rx.test(normalize(pathname));
|
|
67
|
+
};
|
|
57
68
|
function findTrail(menu, pathUrl) {
|
|
58
69
|
const trail = [];
|
|
59
70
|
const walk = (items) => {
|
|
60
71
|
for (const item of items) {
|
|
61
72
|
const fullPath = full(item.path);
|
|
62
73
|
trail.push({ ...item, fullPath });
|
|
63
|
-
if (fullPath
|
|
74
|
+
if (item.path && matchPath(fullPath, pathUrl)) return true;
|
|
64
75
|
if (item.children?.length && walk(item.children)) return true;
|
|
65
76
|
trail.pop();
|
|
66
77
|
}
|
|
@@ -71,8 +82,8 @@ function findTrail(menu, pathUrl) {
|
|
|
71
82
|
}
|
|
72
83
|
function useBreadcrumb(menuRouter, customBreadcrumb) {
|
|
73
84
|
const { pathname } = useLocation();
|
|
74
|
-
const normalizedPath = useMemo(() => normalize(pathname), [pathname]);
|
|
75
|
-
const trail = useMemo(
|
|
85
|
+
const normalizedPath = React.useMemo(() => normalize(pathname), [pathname]);
|
|
86
|
+
const trail = React.useMemo(
|
|
76
87
|
() => findTrail(menuRouter, normalizedPath),
|
|
77
88
|
[menuRouter, normalizedPath]
|
|
78
89
|
);
|
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-
|
|
87
|
+
export { c as createComponentWithProps, e as extractRoutesFromMenu, n as normalize, v as validateAbsolutePaths } from './chunks/useBreadcrumb-CpCPSE3S.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-
|
|
4
|
+
import { u as useBreadcrumb } from '../chunks/useBreadcrumb-CpCPSE3S.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-
|
|
2
|
+
import { u as useBreadcrumb } from '../chunks/useBreadcrumb-CpCPSE3S.js';
|
|
3
3
|
import { Breadcrumb } from './Breadcrumb.js';
|
|
4
4
|
|
|
5
5
|
const WrapperBreadcrumb = ({ menu }) => {
|
package/package.json
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { BreadcrumbItemType, MenuType } from '../ui';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
|
|
3
|
+
export declare function useBreadcrumb(menuRouter: MenuType[], customBreadcrumb?: {
|
|
4
4
|
title: React.ReactNode;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Quy tắc hiển thị:
|
|
8
|
-
* - Chỉ hiển thị khi leaf.isShowBreadcrumb === true.
|
|
9
|
-
* - Khi hiển thị: ancestor có `path` (absolute) + leaf.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useBreadcrumb(menuRouter: MenuType[], customBreadcrumb?: CustomBreadcrumbItem[]): BreadcrumbItemType[];
|
|
12
|
-
export {};
|
|
5
|
+
}[]): BreadcrumbItemType[];
|