@etsoo/toolpad 1.0.39 → 1.0.40
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/build/cjs/PageContainer/PageContainer.d.ts +1 -1
- package/build/cjs/PageContainer/PageContainer.js +6 -10
- package/build/mjs/PageContainer/PageContainer.d.ts +1 -1
- package/build/mjs/PageContainer/PageContainer.js +6 -10
- package/package.json +17 -17
- package/src/PageContainer/PageContainer.tsx +10 -16
|
@@ -24,7 +24,7 @@ export interface Breadcrumb {
|
|
|
24
24
|
export type PageData = {
|
|
25
25
|
title?: string;
|
|
26
26
|
page?: string;
|
|
27
|
-
breadcrumbs?: Breadcrumb[];
|
|
27
|
+
breadcrumbs?: Breadcrumb[] | ((source: Breadcrumb[]) => Breadcrumb[]);
|
|
28
28
|
pageHeader?: React.ReactNode;
|
|
29
29
|
};
|
|
30
30
|
type PageDataAction = PageData | true;
|
|
@@ -58,19 +58,12 @@ const PageContentHeader = (0, styles_1.styled)("div")(({ theme }) => ({
|
|
|
58
58
|
justifyContent: "space-between",
|
|
59
59
|
gap: theme.spacing(2)
|
|
60
60
|
}));
|
|
61
|
-
function jsonSerialize(obj) {
|
|
62
|
-
return JSON.stringify(obj, (_key, value) => value == null ? undefined : value);
|
|
63
|
-
}
|
|
64
61
|
exports.PageDataContext = React.createContext({ state: {}, dispatch: (value) => value });
|
|
65
62
|
function reducer(state, action) {
|
|
66
63
|
// Check if the action is 'reset'
|
|
67
64
|
if (action === true) {
|
|
68
65
|
return {};
|
|
69
66
|
}
|
|
70
|
-
// Check if the action is the same as the current state
|
|
71
|
-
if (jsonSerialize(state) === jsonSerialize(action)) {
|
|
72
|
-
return state;
|
|
73
|
-
}
|
|
74
67
|
return { ...state, ...action };
|
|
75
68
|
}
|
|
76
69
|
function PageDataContextProvider(props) {
|
|
@@ -97,7 +90,7 @@ function PageContainerBar(props) {
|
|
|
97
90
|
externalSlotProps: slotProps?.toolbar,
|
|
98
91
|
additionalProps: {}
|
|
99
92
|
});
|
|
100
|
-
const breadcrumbs = [...(
|
|
93
|
+
const breadcrumbs = [...(activePage?.breadcrumbs ?? [])];
|
|
101
94
|
const title = state.title ?? activePage?.title ?? "";
|
|
102
95
|
const pageHeader = state.pageHeader ?? activePage?.pageHeader ?? null;
|
|
103
96
|
// No page header
|
|
@@ -109,8 +102,11 @@ function PageContainerBar(props) {
|
|
|
109
102
|
if (state.page) {
|
|
110
103
|
breadcrumbs.push({ title: state.page, path: "#" });
|
|
111
104
|
}
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
const bc = typeof state.breadcrumbs === "function"
|
|
106
|
+
? state.breadcrumbs(breadcrumbs)
|
|
107
|
+
: state.breadcrumbs ?? breadcrumbs;
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)(Stack_1.default, { children: [bc.length > 0 && ((0, jsx_runtime_1.jsx)(Breadcrumbs_1.default, { "aria-label": "breadcrumb", children: bc.map((item, index) => {
|
|
109
|
+
return index < bc.length - 1 ? ((0, jsx_runtime_1.jsx)(Link_1.default, { component: Link_2.Link, underline: "hover", color: "inherit", href: item.path, children: (0, navigation_1.getItemTitle)(item) }, item.path)) : ((0, jsx_runtime_1.jsx)(Typography_1.default, { color: "text.primary", children: (0, navigation_1.getItemTitle)(item) }, item.path));
|
|
114
110
|
}) })), (0, jsx_runtime_1.jsxs)(PageContentHeader, { children: [typeof titleBar === "function" ? (titleBar(title)) : titleBar === false ? undefined : ((0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "h4", children: title })), (0, jsx_runtime_1.jsx)(ToolbarComponent, { ...toolbarSlotProps })] })] }));
|
|
115
111
|
}
|
|
116
112
|
/**
|
|
@@ -24,7 +24,7 @@ export interface Breadcrumb {
|
|
|
24
24
|
export type PageData = {
|
|
25
25
|
title?: string;
|
|
26
26
|
page?: string;
|
|
27
|
-
breadcrumbs?: Breadcrumb[];
|
|
27
|
+
breadcrumbs?: Breadcrumb[] | ((source: Breadcrumb[]) => Breadcrumb[]);
|
|
28
28
|
pageHeader?: React.ReactNode;
|
|
29
29
|
};
|
|
30
30
|
type PageDataAction = PageData | true;
|
|
@@ -17,19 +17,12 @@ const PageContentHeader = styled("div")(({ theme }) => ({
|
|
|
17
17
|
justifyContent: "space-between",
|
|
18
18
|
gap: theme.spacing(2)
|
|
19
19
|
}));
|
|
20
|
-
function jsonSerialize(obj) {
|
|
21
|
-
return JSON.stringify(obj, (_key, value) => value == null ? undefined : value);
|
|
22
|
-
}
|
|
23
20
|
export const PageDataContext = React.createContext({ state: {}, dispatch: (value) => value });
|
|
24
21
|
function reducer(state, action) {
|
|
25
22
|
// Check if the action is 'reset'
|
|
26
23
|
if (action === true) {
|
|
27
24
|
return {};
|
|
28
25
|
}
|
|
29
|
-
// Check if the action is the same as the current state
|
|
30
|
-
if (jsonSerialize(state) === jsonSerialize(action)) {
|
|
31
|
-
return state;
|
|
32
|
-
}
|
|
33
26
|
return { ...state, ...action };
|
|
34
27
|
}
|
|
35
28
|
export function PageDataContextProvider(props) {
|
|
@@ -56,7 +49,7 @@ function PageContainerBar(props) {
|
|
|
56
49
|
externalSlotProps: slotProps?.toolbar,
|
|
57
50
|
additionalProps: {}
|
|
58
51
|
});
|
|
59
|
-
const breadcrumbs = [...(
|
|
52
|
+
const breadcrumbs = [...(activePage?.breadcrumbs ?? [])];
|
|
60
53
|
const title = state.title ?? activePage?.title ?? "";
|
|
61
54
|
const pageHeader = state.pageHeader ?? activePage?.pageHeader ?? null;
|
|
62
55
|
// No page header
|
|
@@ -68,8 +61,11 @@ function PageContainerBar(props) {
|
|
|
68
61
|
if (state.page) {
|
|
69
62
|
breadcrumbs.push({ title: state.page, path: "#" });
|
|
70
63
|
}
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
const bc = typeof state.breadcrumbs === "function"
|
|
65
|
+
? state.breadcrumbs(breadcrumbs)
|
|
66
|
+
: state.breadcrumbs ?? breadcrumbs;
|
|
67
|
+
return (_jsxs(Stack, { children: [bc.length > 0 && (_jsx(Breadcrumbs, { "aria-label": "breadcrumb", children: bc.map((item, index) => {
|
|
68
|
+
return index < bc.length - 1 ? (_jsx(Link, { component: ToolpadLink, underline: "hover", color: "inherit", href: item.path, children: getItemTitle(item) }, item.path)) : (_jsx(Typography, { color: "text.primary", children: getItemTitle(item) }, item.path));
|
|
73
69
|
}) })), _jsxs(PageContentHeader, { children: [typeof titleBar === "function" ? (titleBar(title)) : titleBar === false ? undefined : (_jsx(Typography, { variant: "h4", children: title })), _jsx(ToolbarComponent, { ...toolbarSlotProps })] })] }));
|
|
74
70
|
}
|
|
75
71
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/toolpad",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"author": "ETSOO",
|
|
5
5
|
"description": "Dashboard framework extention based on Toolpad Core",
|
|
6
6
|
"main": "build/cjs/index.js",
|
|
@@ -47,33 +47,33 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@emotion/react": "^11.14.0",
|
|
49
49
|
"@emotion/styled": "^11.14.0",
|
|
50
|
-
"@mui/icons-material": "7.1.
|
|
51
|
-
"@mui/material": "7.1.
|
|
52
|
-
"@mui/utils": "7.1.
|
|
50
|
+
"@mui/icons-material": "7.1.2",
|
|
51
|
+
"@mui/material": "7.1.2",
|
|
52
|
+
"@mui/utils": "7.1.1",
|
|
53
53
|
"invariant": "2.2.4",
|
|
54
54
|
"path-to-regexp": "6.3.0",
|
|
55
55
|
"react": "^19.1.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/cli": "^7.27.2",
|
|
59
|
-
"@babel/core": "^7.27.
|
|
60
|
-
"@babel/plugin-transform-runtime": "^7.27.
|
|
59
|
+
"@babel/core": "^7.27.4",
|
|
60
|
+
"@babel/plugin-transform-runtime": "^7.27.4",
|
|
61
61
|
"@babel/preset-env": "^7.27.2",
|
|
62
|
-
"@babel/runtime-corejs3": "^7.27.
|
|
62
|
+
"@babel/runtime-corejs3": "^7.27.6",
|
|
63
63
|
"@testing-library/jest-dom": "^6.6.3",
|
|
64
64
|
"@testing-library/react": "^16.3.0",
|
|
65
65
|
"@types/invariant": "2.2.37",
|
|
66
|
-
"@types/node": "^
|
|
67
|
-
"@types/react": "19.1.
|
|
68
|
-
"@types/react-dom": "19.1.
|
|
69
|
-
"@vitejs/plugin-react": "4.
|
|
70
|
-
"@vitest/browser": "3.
|
|
66
|
+
"@types/node": "^24.0.4",
|
|
67
|
+
"@types/react": "19.1.8",
|
|
68
|
+
"@types/react-dom": "19.1.6",
|
|
69
|
+
"@vitejs/plugin-react": "4.6.0",
|
|
70
|
+
"@vitest/browser": "3.2.4",
|
|
71
71
|
"jsdom": "^26.1.0",
|
|
72
|
-
"next": "^15.3.
|
|
73
|
-
"next-router-mock": "^1.0.
|
|
74
|
-
"playwright": "^1.
|
|
75
|
-
"react-router-dom": "^7.6.
|
|
76
|
-
"vitest": "3.
|
|
72
|
+
"next": "^15.3.4",
|
|
73
|
+
"next-router-mock": "^1.0.2",
|
|
74
|
+
"playwright": "^1.53.1",
|
|
75
|
+
"react-router-dom": "^7.6.2",
|
|
76
|
+
"vitest": "3.2.4"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"next": {
|
|
@@ -47,18 +47,12 @@ export interface Breadcrumb {
|
|
|
47
47
|
export type PageData = {
|
|
48
48
|
title?: string;
|
|
49
49
|
page?: string;
|
|
50
|
-
breadcrumbs?: Breadcrumb[];
|
|
50
|
+
breadcrumbs?: Breadcrumb[] | ((source: Breadcrumb[]) => Breadcrumb[]);
|
|
51
51
|
pageHeader?: React.ReactNode;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
type PageDataAction = PageData | true;
|
|
55
55
|
|
|
56
|
-
function jsonSerialize(obj: unknown) {
|
|
57
|
-
return JSON.stringify(obj, (_key, value) =>
|
|
58
|
-
value == null ? undefined : value
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
56
|
export const PageDataContext = React.createContext<{
|
|
63
57
|
state: PageData;
|
|
64
58
|
dispatch: React.Dispatch<PageDataAction>;
|
|
@@ -70,11 +64,6 @@ function reducer(state: PageData, action: PageDataAction) {
|
|
|
70
64
|
return {};
|
|
71
65
|
}
|
|
72
66
|
|
|
73
|
-
// Check if the action is the same as the current state
|
|
74
|
-
if (jsonSerialize(state) === jsonSerialize(action)) {
|
|
75
|
-
return state;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
67
|
return { ...state, ...action };
|
|
79
68
|
}
|
|
80
69
|
|
|
@@ -128,7 +117,7 @@ function PageContainerBar(props: PageContainerBarProps) {
|
|
|
128
117
|
additionalProps: {}
|
|
129
118
|
});
|
|
130
119
|
|
|
131
|
-
const breadcrumbs = [...(
|
|
120
|
+
const breadcrumbs = [...(activePage?.breadcrumbs ?? [])];
|
|
132
121
|
const title = state.title ?? activePage?.title ?? "";
|
|
133
122
|
const pageHeader = state.pageHeader ?? activePage?.pageHeader ?? null;
|
|
134
123
|
|
|
@@ -142,12 +131,17 @@ function PageContainerBar(props: PageContainerBarProps) {
|
|
|
142
131
|
breadcrumbs.push({ title: state.page, path: "#" });
|
|
143
132
|
}
|
|
144
133
|
|
|
134
|
+
const bc =
|
|
135
|
+
typeof state.breadcrumbs === "function"
|
|
136
|
+
? state.breadcrumbs(breadcrumbs)
|
|
137
|
+
: state.breadcrumbs ?? breadcrumbs;
|
|
138
|
+
|
|
145
139
|
return (
|
|
146
140
|
<Stack>
|
|
147
|
-
{
|
|
141
|
+
{bc.length > 0 && (
|
|
148
142
|
<Breadcrumbs aria-label="breadcrumb">
|
|
149
|
-
{
|
|
150
|
-
return index <
|
|
143
|
+
{bc.map((item, index) => {
|
|
144
|
+
return index < bc.length - 1 ? (
|
|
151
145
|
<Link
|
|
152
146
|
key={item.path}
|
|
153
147
|
component={ToolpadLink}
|