@pnkx-lib/ui 1.9.196 → 1.9.199
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/es/chunks/useBreadcrumb-IwFmXF85.js +55 -0
- package/es/fields/TimePicker.js +9 -14
- package/es/ui/BreadcrumbHeading.js +3 -44
- package/es/ui/Heading.js +3 -40
- package/es/ui/index.js +2 -2
- package/package.json +1 -1
- package/types/components/hooks/useBreadcrumb.d.ts +6 -0
- package/types/components/ui/BulkActions/index.d.ts +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useLocation, Link } from 'react-router';
|
|
3
|
+
|
|
4
|
+
const useBreadcrumb = (menuRouter, customBreadcrumb) => {
|
|
5
|
+
const location = useLocation();
|
|
6
|
+
const pathUrl = location.pathname;
|
|
7
|
+
const findPath = (items, targetPath, parentTrail = []) => {
|
|
8
|
+
for (const item of items) {
|
|
9
|
+
const currentTrail = [...parentTrail, item];
|
|
10
|
+
if (item.path === targetPath) {
|
|
11
|
+
return currentTrail;
|
|
12
|
+
}
|
|
13
|
+
if (item.path?.includes(":") && matchDynamicPath(item.path, targetPath)) {
|
|
14
|
+
return currentTrail;
|
|
15
|
+
}
|
|
16
|
+
if (item.children) {
|
|
17
|
+
const found = findPath(item.children, targetPath, currentTrail);
|
|
18
|
+
if (found) return found;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
const matchDynamicPath = (routePath, currentPath) => {
|
|
24
|
+
const regex = new RegExp(
|
|
25
|
+
"^" + routePath.replace(/:[^\s/]+/g, "([^/]+)").replace(/\/$/, "") + "$"
|
|
26
|
+
);
|
|
27
|
+
return regex.test(currentPath);
|
|
28
|
+
};
|
|
29
|
+
const matchedTrail = findPath(menuRouter, pathUrl) || [];
|
|
30
|
+
const visibleTrail = matchedTrail.filter((item) => item.isShowLabel === true);
|
|
31
|
+
const lastIndex = visibleTrail.length - 1;
|
|
32
|
+
const baseItems = visibleTrail.map((item, index) => {
|
|
33
|
+
const isLast = index === lastIndex;
|
|
34
|
+
if (customBreadcrumb?.length) {
|
|
35
|
+
return {
|
|
36
|
+
title: /* @__PURE__ */ jsx(Link, { to: item.path, children: item.name })
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
title: isLast ? /* @__PURE__ */ jsx("span", { style: { fontWeight: "bold" }, children: item.name }) : /* @__PURE__ */ jsx(Link, { to: item.path, children: item.name })
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const breadcrumbItems = [
|
|
44
|
+
{ title: /* @__PURE__ */ jsx(Link, { to: "/", children: "Trang chủ" }) },
|
|
45
|
+
...baseItems,
|
|
46
|
+
...customBreadcrumb?.length ? [
|
|
47
|
+
{
|
|
48
|
+
title: /* @__PURE__ */ jsx("span", { style: { fontWeight: "bold" }, children: customBreadcrumb[customBreadcrumb.length - 1].title })
|
|
49
|
+
}
|
|
50
|
+
] : []
|
|
51
|
+
];
|
|
52
|
+
return breadcrumbItems;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { useBreadcrumb as u };
|
package/es/fields/TimePicker.js
CHANGED
|
@@ -6,23 +6,18 @@ import { g as get } from '../chunks/get-C880miVG.js';
|
|
|
6
6
|
|
|
7
7
|
const TimePicker = (props) => {
|
|
8
8
|
const { field, afterOnChange, formState, label, required, ...rest } = props;
|
|
9
|
-
const
|
|
10
|
-
const fieldValue = field?.value;
|
|
11
|
-
const fieldOnChange = field?.onChange;
|
|
12
|
-
const fieldOnBlur = field?.onBlur;
|
|
9
|
+
const { name, value, onChange, onBlur } = field || {};
|
|
13
10
|
const { touchedFields, errors, isSubmitted } = formState || {};
|
|
14
|
-
const isTouched =
|
|
15
|
-
const errorMessage =
|
|
11
|
+
const isTouched = get(touchedFields, name);
|
|
12
|
+
const errorMessage = get(errors, name)?.message;
|
|
16
13
|
const handleChange = (dates) => {
|
|
17
|
-
if (
|
|
18
|
-
|
|
14
|
+
if (onChange) {
|
|
15
|
+
onChange(dates);
|
|
19
16
|
}
|
|
20
17
|
afterOnChange?.(dates);
|
|
21
18
|
};
|
|
22
19
|
const handleBlur = () => {
|
|
23
|
-
|
|
24
|
-
fieldOnBlur();
|
|
25
|
-
}
|
|
20
|
+
onBlur?.();
|
|
26
21
|
};
|
|
27
22
|
const renderErrorMessage = () => {
|
|
28
23
|
if (!errorMessage) return null;
|
|
@@ -40,11 +35,11 @@ const TimePicker = (props) => {
|
|
|
40
35
|
/* @__PURE__ */ jsx(
|
|
41
36
|
TimePicker$1,
|
|
42
37
|
{
|
|
43
|
-
|
|
44
|
-
value: fieldValue || null,
|
|
38
|
+
value: value || null,
|
|
45
39
|
onChange: handleChange,
|
|
46
40
|
onBlur: handleBlur,
|
|
47
|
-
status: (isTouched || isSubmitted) && errorMessage ? "error" : void 0
|
|
41
|
+
status: (isTouched || isSubmitted) && errorMessage ? "error" : void 0,
|
|
42
|
+
...rest
|
|
48
43
|
}
|
|
49
44
|
),
|
|
50
45
|
renderErrorMessage()
|
|
@@ -1,54 +1,13 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { c as className } from '../chunks/index-mzHK7Za8.js';
|
|
3
3
|
import { Breadcrumb } from './Breadcrumb.js';
|
|
4
|
-
import {
|
|
4
|
+
import { u as useBreadcrumb } from '../chunks/useBreadcrumb-IwFmXF85.js';
|
|
5
5
|
|
|
6
6
|
const BreadcrumbHeading = (props) => {
|
|
7
7
|
const { menu, customBreadcum } = props;
|
|
8
|
-
const
|
|
9
|
-
const pathUrl = location.pathname;
|
|
10
|
-
const breadcrumbsItem = [
|
|
11
|
-
{ title: /* @__PURE__ */ jsx(Link, { to: "/", children: "Trang chủ" }) }
|
|
12
|
-
];
|
|
13
|
-
function findBreadcrumbs(items, currentPath, trail = []) {
|
|
14
|
-
for (const item of items) {
|
|
15
|
-
if (!item || !item.path) continue;
|
|
16
|
-
if (currentPath === item.path) {
|
|
17
|
-
document.title = item.name;
|
|
18
|
-
if (!Object.prototype.hasOwnProperty.call(item, "isShowLabel") || item.isShowLabel) {
|
|
19
|
-
return [...trail, { title: /* @__PURE__ */ jsx(Link, { to: item.path, children: item.name }) }];
|
|
20
|
-
}
|
|
21
|
-
return trail;
|
|
22
|
-
}
|
|
23
|
-
if (currentPath.startsWith(item.path)) {
|
|
24
|
-
const newTrail = [...trail];
|
|
25
|
-
if (!Object.prototype.hasOwnProperty.call(item, "isShowLabel") || item.isShowLabel) {
|
|
26
|
-
newTrail.push({
|
|
27
|
-
title: /* @__PURE__ */ jsx(Link, { to: item.path, children: item.name })
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (item.children && item.children.length > 0) {
|
|
31
|
-
const childTrail = findBreadcrumbs(
|
|
32
|
-
item.children,
|
|
33
|
-
currentPath,
|
|
34
|
-
newTrail
|
|
35
|
-
);
|
|
36
|
-
if (childTrail) return childTrail;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const dynamicBreadcrumbs = findBreadcrumbs(menu, pathUrl);
|
|
43
|
-
if (dynamicBreadcrumbs) {
|
|
44
|
-
breadcrumbsItem.push(...dynamicBreadcrumbs);
|
|
45
|
-
}
|
|
46
|
-
const dataBreadcum = [
|
|
47
|
-
...breadcrumbsItem,
|
|
48
|
-
...customBreadcum ?? []
|
|
49
|
-
];
|
|
8
|
+
const mappingBreadcrumb = useBreadcrumb(menu, customBreadcum);
|
|
50
9
|
//! Render
|
|
51
|
-
return /* @__PURE__ */ jsx("div", { className: className("flex justify-between items-
|
|
10
|
+
return /* @__PURE__ */ jsx("div", { className: className("flex justify-between items-center"), children: /* @__PURE__ */ jsx(Breadcrumb, { items: mappingBreadcrumb }) });
|
|
52
11
|
};
|
|
53
12
|
|
|
54
13
|
export { BreadcrumbHeading };
|
package/es/ui/Heading.js
CHANGED
|
@@ -1,49 +1,12 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { c as className } from '../chunks/index-mzHK7Za8.js';
|
|
3
3
|
import { Breadcrumb } from './Breadcrumb.js';
|
|
4
|
-
import {
|
|
4
|
+
import { u as useBreadcrumb } from '../chunks/useBreadcrumb-IwFmXF85.js';
|
|
5
5
|
|
|
6
6
|
const Heading = (props) => {
|
|
7
7
|
const { rightContent, children, noBreadcum, classNameWrapHeading, menu } = props;
|
|
8
8
|
//! State
|
|
9
|
-
const
|
|
10
|
-
const pathUrl = location.pathname;
|
|
11
|
-
const breadcrumbsItem = [
|
|
12
|
-
{ title: /* @__PURE__ */ jsx(Link, { to: "/", children: "Trang chủ" }) }
|
|
13
|
-
];
|
|
14
|
-
function findBreadcrumbs(items, currentPath, trail = []) {
|
|
15
|
-
for (const item of items) {
|
|
16
|
-
if (!item || !item.path) continue;
|
|
17
|
-
if (currentPath === item.path) {
|
|
18
|
-
if (!Object.prototype.hasOwnProperty.call(item, "isShowLabel") || item.isShowLabel) {
|
|
19
|
-
return [...trail, { title: /* @__PURE__ */ jsx(Link, { to: item.path, children: item.name }) }];
|
|
20
|
-
}
|
|
21
|
-
return trail;
|
|
22
|
-
}
|
|
23
|
-
if (currentPath.startsWith(item.path)) {
|
|
24
|
-
const newTrail = [...trail];
|
|
25
|
-
if (!Object.prototype.hasOwnProperty.call(item, "isShowLabel") || item.isShowLabel) {
|
|
26
|
-
newTrail.push({
|
|
27
|
-
title: /* @__PURE__ */ jsx(Link, { to: item.path, children: item.name })
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (item.children && item.children.length > 0) {
|
|
31
|
-
const childTrail = findBreadcrumbs(
|
|
32
|
-
item.children,
|
|
33
|
-
currentPath,
|
|
34
|
-
newTrail
|
|
35
|
-
);
|
|
36
|
-
if (childTrail) return childTrail;
|
|
37
|
-
}
|
|
38
|
-
document.title = item.name;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const dynamicBreadcrumbs = findBreadcrumbs(menu, pathUrl);
|
|
44
|
-
if (dynamicBreadcrumbs) {
|
|
45
|
-
breadcrumbsItem.push(...dynamicBreadcrumbs);
|
|
46
|
-
}
|
|
9
|
+
const mappingBreadcrumb = useBreadcrumb(menu);
|
|
47
10
|
//! Function
|
|
48
11
|
//! Render
|
|
49
12
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -55,7 +18,7 @@ const Heading = (props) => {
|
|
|
55
18
|
classNameWrapHeading
|
|
56
19
|
),
|
|
57
20
|
children: [
|
|
58
|
-
!noBreadcum && /* @__PURE__ */ jsx(Breadcrumb, { items:
|
|
21
|
+
!noBreadcum && /* @__PURE__ */ jsx(Breadcrumb, { items: mappingBreadcrumb }),
|
|
59
22
|
rightContent
|
|
60
23
|
]
|
|
61
24
|
}
|
package/es/ui/index.js
CHANGED
|
@@ -4878,7 +4878,7 @@ const BulkActions = ({
|
|
|
4878
4878
|
handleApprove,
|
|
4879
4879
|
handleCancelApproval,
|
|
4880
4880
|
handleReject,
|
|
4881
|
-
|
|
4881
|
+
handleDeActivate,
|
|
4882
4882
|
handleActivate,
|
|
4883
4883
|
handleRestore,
|
|
4884
4884
|
status
|
|
@@ -4981,7 +4981,7 @@ const BulkActions = ({
|
|
|
4981
4981
|
icon: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "white" }),
|
|
4982
4982
|
iconDropList: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "#0F1D40" }),
|
|
4983
4983
|
iconDisable: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "#B2B7C2" }),
|
|
4984
|
-
action:
|
|
4984
|
+
action: handleDeActivate,
|
|
4985
4985
|
name: "Vô hiệu hóa",
|
|
4986
4986
|
typeIcon: "info",
|
|
4987
4987
|
title: "Xác nhận vô hiệu hóa",
|
package/package.json
CHANGED
|
@@ -18,5 +18,5 @@ export type TListIcon = {
|
|
|
18
18
|
typeIcon?: ConfirmModalProps["typeIcon"];
|
|
19
19
|
name?: string;
|
|
20
20
|
};
|
|
21
|
-
export declare const BulkActions: ({ quantity, handleDelete, handleSubmitForApproval, handleCancelSubmission, handleApprove, handleCancelApproval, handleReject,
|
|
21
|
+
export declare const BulkActions: ({ quantity, handleDelete, handleSubmitForApproval, handleCancelSubmission, handleApprove, handleCancelApproval, handleReject, handleDeActivate, handleActivate, handleRestore, status, }: IBulkActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
22
|
export {};
|