@etsoo/toolpad 1.0.26 → 1.0.28
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 +4 -3
- package/build/cjs/PageContainer/PageContainer.js +40 -39
- package/build/mjs/PageContainer/PageContainer.d.ts +4 -3
- package/build/mjs/PageContainer/PageContainer.js +40 -39
- package/package.json +19 -19
- package/src/PageContainer/PageContainer.tsx +92 -82
- package/vite.config.mts +1 -0
|
@@ -28,13 +28,13 @@ export type PageData = {
|
|
|
28
28
|
noBreadcrumbs?: boolean;
|
|
29
29
|
noPageHeader?: boolean;
|
|
30
30
|
};
|
|
31
|
-
type PageDataAction = PageData
|
|
31
|
+
type PageDataAction = PageData;
|
|
32
32
|
export declare const PageDataContext: React.Context<{
|
|
33
33
|
state: PageData;
|
|
34
34
|
dispatch: React.Dispatch<PageDataAction>;
|
|
35
35
|
}>;
|
|
36
36
|
export declare function PageDataContextProvider(props: React.PropsWithChildren<PageData>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
|
|
37
|
+
type PageContainerBarProps = {
|
|
38
38
|
/**
|
|
39
39
|
* The default title of the page.
|
|
40
40
|
*/
|
|
@@ -47,7 +47,8 @@ export type PageContainerProps = React.PropsWithChildren<StackProps & {
|
|
|
47
47
|
* The props used for each slot inside.
|
|
48
48
|
*/
|
|
49
49
|
slotProps?: PageContainerSlotProps;
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
|
+
export type PageContainerProps = React.PropsWithChildren<StackProps & PageContainerBarProps>;
|
|
51
52
|
/**
|
|
52
53
|
* A container component to provide a title and breadcrumbs for your pages.
|
|
53
54
|
*
|
|
@@ -60,19 +60,18 @@ const PageContentHeader = (0, styles_1.styled)("div")(({ theme }) => ({
|
|
|
60
60
|
}));
|
|
61
61
|
exports.PageDataContext = React.createContext({ state: {}, dispatch: (value) => value });
|
|
62
62
|
function reducer(state, action) {
|
|
63
|
-
if
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return state;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
return {};
|
|
63
|
+
// Check if the action is the same as the current state
|
|
64
|
+
let key;
|
|
65
|
+
let isSame = true;
|
|
66
|
+
for (key in action) {
|
|
67
|
+
if (action[key] !== state[key]) {
|
|
68
|
+
isSame = false;
|
|
69
|
+
break;
|
|
74
70
|
}
|
|
75
71
|
}
|
|
72
|
+
if (isSame) {
|
|
73
|
+
return state;
|
|
74
|
+
}
|
|
76
75
|
return { ...state, ...action };
|
|
77
76
|
}
|
|
78
77
|
function PageDataContextProvider(props) {
|
|
@@ -89,30 +88,17 @@ function PageDataContextProvider(props) {
|
|
|
89
88
|
// Provide the state and dispatch function to the context value
|
|
90
89
|
return (0, jsx_runtime_1.jsx)(exports.PageDataContext.Provider, { value: { state, dispatch }, ...rest });
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*
|
|
95
|
-
* Demos:
|
|
96
|
-
*
|
|
97
|
-
* - [Page Container](https://mui.com/toolpad/core/react-page-container/)
|
|
98
|
-
*
|
|
99
|
-
* API:
|
|
100
|
-
*
|
|
101
|
-
* - [PageContainer API](https://mui.com/toolpad/core/api/page-container)
|
|
102
|
-
*/
|
|
103
|
-
function PageContainer(props) {
|
|
104
|
-
const { children, defaultTitle, slots, slotProps, ...rest } = props;
|
|
105
|
-
const loaded = React.useRef(false);
|
|
91
|
+
function PageContainerBar(props) {
|
|
92
|
+
const { defaultTitle, slots, slotProps } = props;
|
|
106
93
|
const { state, dispatch } = React.useContext(exports.PageDataContext);
|
|
107
94
|
const activePage = (0, useActivePage_1.useActivePage)();
|
|
108
95
|
React.useLayoutEffect(() => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
96
|
+
// Reset the state when the active page changes without rerendering
|
|
97
|
+
state.breadcrumbs = undefined;
|
|
98
|
+
state.noBreadcrumbs = undefined;
|
|
99
|
+
state.noPageHeader = undefined;
|
|
100
|
+
state.page = undefined;
|
|
101
|
+
state.title = undefined;
|
|
116
102
|
}, [activePage?.sourcePath]);
|
|
117
103
|
let resolvedBreadcrumbs = state.breadcrumbs ?? activePage?.breadcrumbs ?? [];
|
|
118
104
|
const title = state.title ?? defaultTitle ?? activePage?.title ?? "";
|
|
@@ -122,16 +108,31 @@ function PageContainer(props) {
|
|
|
122
108
|
{ title: state.page, path: "#" }
|
|
123
109
|
];
|
|
124
110
|
}
|
|
125
|
-
const ToolbarComponent =
|
|
111
|
+
const ToolbarComponent = slots?.toolbar ?? PageContainerToolbar_1.PageContainerToolbar;
|
|
126
112
|
const toolbarSlotProps = (0, useSlotProps_1.default)({
|
|
127
113
|
elementType: ToolbarComponent,
|
|
128
114
|
ownerState: props,
|
|
129
|
-
externalSlotProps:
|
|
115
|
+
externalSlotProps: slotProps?.toolbar,
|
|
130
116
|
additionalProps: {}
|
|
131
117
|
});
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
return state.noPageHeader !== true ? ((0, jsx_runtime_1.jsxs)(Stack_1.default, { children: [state.noBreadcrumbs !== true && ((0, jsx_runtime_1.jsx)(Breadcrumbs_1.default, { "aria-label": "breadcrumb", children: resolvedBreadcrumbs
|
|
119
|
+
? resolvedBreadcrumbs.map((item, index) => {
|
|
120
|
+
return index < resolvedBreadcrumbs.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));
|
|
121
|
+
})
|
|
122
|
+
: null })), (0, jsx_runtime_1.jsxs)(PageContentHeader, { children: [title ? (0, jsx_runtime_1.jsx)(Typography_1.default, { variant: "h4", children: title }) : null, (0, jsx_runtime_1.jsx)(ToolbarComponent, { ...toolbarSlotProps })] })] })) : undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* A container component to provide a title and breadcrumbs for your pages.
|
|
126
|
+
*
|
|
127
|
+
* Demos:
|
|
128
|
+
*
|
|
129
|
+
* - [Page Container](https://mui.com/toolpad/core/react-page-container/)
|
|
130
|
+
*
|
|
131
|
+
* API:
|
|
132
|
+
*
|
|
133
|
+
* - [PageContainer API](https://mui.com/toolpad/core/api/page-container)
|
|
134
|
+
*/
|
|
135
|
+
function PageContainer(props) {
|
|
136
|
+
const { children, defaultTitle, slots, slotProps, ...rest } = props;
|
|
137
|
+
return ((0, jsx_runtime_1.jsxs)(Stack_1.default, { sx: { mx: 3, my: 2 }, spacing: 2, ...rest, children: [(0, jsx_runtime_1.jsx)(PageContainerBar, { defaultTitle: defaultTitle, slots: slots, slotProps: slotProps }), children] }));
|
|
137
138
|
}
|
|
@@ -28,13 +28,13 @@ export type PageData = {
|
|
|
28
28
|
noBreadcrumbs?: boolean;
|
|
29
29
|
noPageHeader?: boolean;
|
|
30
30
|
};
|
|
31
|
-
type PageDataAction = PageData
|
|
31
|
+
type PageDataAction = PageData;
|
|
32
32
|
export declare const PageDataContext: React.Context<{
|
|
33
33
|
state: PageData;
|
|
34
34
|
dispatch: React.Dispatch<PageDataAction>;
|
|
35
35
|
}>;
|
|
36
36
|
export declare function PageDataContextProvider(props: React.PropsWithChildren<PageData>): import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
|
|
37
|
+
type PageContainerBarProps = {
|
|
38
38
|
/**
|
|
39
39
|
* The default title of the page.
|
|
40
40
|
*/
|
|
@@ -47,7 +47,8 @@ export type PageContainerProps = React.PropsWithChildren<StackProps & {
|
|
|
47
47
|
* The props used for each slot inside.
|
|
48
48
|
*/
|
|
49
49
|
slotProps?: PageContainerSlotProps;
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
|
+
export type PageContainerProps = React.PropsWithChildren<StackProps & PageContainerBarProps>;
|
|
51
52
|
/**
|
|
52
53
|
* A container component to provide a title and breadcrumbs for your pages.
|
|
53
54
|
*
|
|
@@ -19,19 +19,18 @@ const PageContentHeader = styled("div")(({ theme }) => ({
|
|
|
19
19
|
}));
|
|
20
20
|
export const PageDataContext = React.createContext({ state: {}, dispatch: (value) => value });
|
|
21
21
|
function reducer(state, action) {
|
|
22
|
-
if
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return state;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return {};
|
|
22
|
+
// Check if the action is the same as the current state
|
|
23
|
+
let key;
|
|
24
|
+
let isSame = true;
|
|
25
|
+
for (key in action) {
|
|
26
|
+
if (action[key] !== state[key]) {
|
|
27
|
+
isSame = false;
|
|
28
|
+
break;
|
|
33
29
|
}
|
|
34
30
|
}
|
|
31
|
+
if (isSame) {
|
|
32
|
+
return state;
|
|
33
|
+
}
|
|
35
34
|
return { ...state, ...action };
|
|
36
35
|
}
|
|
37
36
|
export function PageDataContextProvider(props) {
|
|
@@ -48,30 +47,17 @@ export function PageDataContextProvider(props) {
|
|
|
48
47
|
// Provide the state and dispatch function to the context value
|
|
49
48
|
return _jsx(PageDataContext.Provider, { value: { state, dispatch }, ...rest });
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
* Demos:
|
|
55
|
-
*
|
|
56
|
-
* - [Page Container](https://mui.com/toolpad/core/react-page-container/)
|
|
57
|
-
*
|
|
58
|
-
* API:
|
|
59
|
-
*
|
|
60
|
-
* - [PageContainer API](https://mui.com/toolpad/core/api/page-container)
|
|
61
|
-
*/
|
|
62
|
-
function PageContainer(props) {
|
|
63
|
-
const { children, defaultTitle, slots, slotProps, ...rest } = props;
|
|
64
|
-
const loaded = React.useRef(false);
|
|
50
|
+
function PageContainerBar(props) {
|
|
51
|
+
const { defaultTitle, slots, slotProps } = props;
|
|
65
52
|
const { state, dispatch } = React.useContext(PageDataContext);
|
|
66
53
|
const activePage = useActivePage();
|
|
67
54
|
React.useLayoutEffect(() => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
55
|
+
// Reset the state when the active page changes without rerendering
|
|
56
|
+
state.breadcrumbs = undefined;
|
|
57
|
+
state.noBreadcrumbs = undefined;
|
|
58
|
+
state.noPageHeader = undefined;
|
|
59
|
+
state.page = undefined;
|
|
60
|
+
state.title = undefined;
|
|
75
61
|
}, [activePage?.sourcePath]);
|
|
76
62
|
let resolvedBreadcrumbs = state.breadcrumbs ?? activePage?.breadcrumbs ?? [];
|
|
77
63
|
const title = state.title ?? defaultTitle ?? activePage?.title ?? "";
|
|
@@ -81,17 +67,32 @@ function PageContainer(props) {
|
|
|
81
67
|
{ title: state.page, path: "#" }
|
|
82
68
|
];
|
|
83
69
|
}
|
|
84
|
-
const ToolbarComponent =
|
|
70
|
+
const ToolbarComponent = slots?.toolbar ?? PageContainerToolbar;
|
|
85
71
|
const toolbarSlotProps = useSlotProps({
|
|
86
72
|
elementType: ToolbarComponent,
|
|
87
73
|
ownerState: props,
|
|
88
|
-
externalSlotProps:
|
|
74
|
+
externalSlotProps: slotProps?.toolbar,
|
|
89
75
|
additionalProps: {}
|
|
90
76
|
});
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
return state.noPageHeader !== true ? (_jsxs(Stack, { children: [state.noBreadcrumbs !== true && (_jsx(Breadcrumbs, { "aria-label": "breadcrumb", children: resolvedBreadcrumbs
|
|
78
|
+
? resolvedBreadcrumbs.map((item, index) => {
|
|
79
|
+
return index < resolvedBreadcrumbs.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));
|
|
80
|
+
})
|
|
81
|
+
: null })), _jsxs(PageContentHeader, { children: [title ? _jsx(Typography, { variant: "h4", children: title }) : null, _jsx(ToolbarComponent, { ...toolbarSlotProps })] })] })) : undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A container component to provide a title and breadcrumbs for your pages.
|
|
85
|
+
*
|
|
86
|
+
* Demos:
|
|
87
|
+
*
|
|
88
|
+
* - [Page Container](https://mui.com/toolpad/core/react-page-container/)
|
|
89
|
+
*
|
|
90
|
+
* API:
|
|
91
|
+
*
|
|
92
|
+
* - [PageContainer API](https://mui.com/toolpad/core/api/page-container)
|
|
93
|
+
*/
|
|
94
|
+
function PageContainer(props) {
|
|
95
|
+
const { children, defaultTitle, slots, slotProps, ...rest } = props;
|
|
96
|
+
return (_jsxs(Stack, { sx: { mx: 3, my: 2 }, spacing: 2, ...rest, children: [_jsx(PageContainerBar, { defaultTitle: defaultTitle, slots: slots, slotProps: slotProps }), children] }));
|
|
96
97
|
}
|
|
97
98
|
export { PageContainer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/toolpad",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
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.0.
|
|
51
|
-
"@mui/material": "7.0.
|
|
52
|
-
"@mui/utils": "7.0.
|
|
50
|
+
"@mui/icons-material": "7.0.2",
|
|
51
|
+
"@mui/material": "7.0.2",
|
|
52
|
+
"@mui/utils": "7.0.2",
|
|
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
|
-
"@babel/cli": "^7.27.
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
61
|
-
"@babel/preset-env": "^7.
|
|
62
|
-
"@babel/runtime-corejs3": "^7.27.
|
|
58
|
+
"@babel/cli": "^7.27.1",
|
|
59
|
+
"@babel/core": "^7.27.1",
|
|
60
|
+
"@babel/plugin-transform-runtime": "^7.27.1",
|
|
61
|
+
"@babel/preset-env": "^7.27.1",
|
|
62
|
+
"@babel/runtime-corejs3": "^7.27.1",
|
|
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": "^22.
|
|
67
|
-
"@types/react": "19.1.
|
|
68
|
-
"@types/react-dom": "19.1.
|
|
69
|
-
"@vitejs/plugin-react": "4.
|
|
70
|
-
"@vitest/browser": "3.1.
|
|
71
|
-
"jsdom": "^26.
|
|
72
|
-
"next": "^15.
|
|
66
|
+
"@types/node": "^22.15.3",
|
|
67
|
+
"@types/react": "19.1.2",
|
|
68
|
+
"@types/react-dom": "19.1.3",
|
|
69
|
+
"@vitejs/plugin-react": "4.4.1",
|
|
70
|
+
"@vitest/browser": "3.1.2",
|
|
71
|
+
"jsdom": "^26.1.0",
|
|
72
|
+
"next": "^15.3.1",
|
|
73
73
|
"next-router-mock": "^0.9.13",
|
|
74
|
-
"playwright": "^1.
|
|
75
|
-
"react-router-dom": "7.
|
|
76
|
-
"vitest": "3.1.
|
|
74
|
+
"playwright": "^1.52.0",
|
|
75
|
+
"react-router-dom": "^7.5.3",
|
|
76
|
+
"vitest": "3.1.2"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"next": {
|
|
@@ -52,7 +52,7 @@ export type PageData = {
|
|
|
52
52
|
noPageHeader?: boolean;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
type PageDataAction = PageData
|
|
55
|
+
type PageDataAction = PageData;
|
|
56
56
|
|
|
57
57
|
export const PageDataContext = React.createContext<{
|
|
58
58
|
state: PageData;
|
|
@@ -60,21 +60,20 @@ export const PageDataContext = React.createContext<{
|
|
|
60
60
|
}>({ state: {}, dispatch: (value) => value });
|
|
61
61
|
|
|
62
62
|
function reducer(state: PageData, action: PageDataAction) {
|
|
63
|
-
if
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
state.noPageHeader == null
|
|
71
|
-
) {
|
|
72
|
-
return state;
|
|
73
|
-
} else {
|
|
74
|
-
return {};
|
|
63
|
+
// Check if the action is the same as the current state
|
|
64
|
+
let key: keyof PageDataAction;
|
|
65
|
+
let isSame = true;
|
|
66
|
+
for (key in action) {
|
|
67
|
+
if (action[key] !== state[key]) {
|
|
68
|
+
isSame = false;
|
|
69
|
+
break;
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
72
|
|
|
73
|
+
if (isSame) {
|
|
74
|
+
return state;
|
|
75
|
+
}
|
|
76
|
+
|
|
78
77
|
return { ...state, ...action };
|
|
79
78
|
}
|
|
80
79
|
|
|
@@ -98,49 +97,35 @@ export function PageDataContextProvider(
|
|
|
98
97
|
return <PageDataContext.Provider value={{ state, dispatch }} {...rest} />;
|
|
99
98
|
}
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
>;
|
|
100
|
+
type PageContainerBarProps = {
|
|
101
|
+
/**
|
|
102
|
+
* The default title of the page.
|
|
103
|
+
*/
|
|
104
|
+
defaultTitle?: string;
|
|
105
|
+
/**
|
|
106
|
+
* The components used for each slot inside.
|
|
107
|
+
*/
|
|
108
|
+
slots?: PageContainerSlots;
|
|
109
|
+
/**
|
|
110
|
+
* The props used for each slot inside.
|
|
111
|
+
*/
|
|
112
|
+
slotProps?: PageContainerSlotProps;
|
|
113
|
+
};
|
|
117
114
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*
|
|
121
|
-
* Demos:
|
|
122
|
-
*
|
|
123
|
-
* - [Page Container](https://mui.com/toolpad/core/react-page-container/)
|
|
124
|
-
*
|
|
125
|
-
* API:
|
|
126
|
-
*
|
|
127
|
-
* - [PageContainer API](https://mui.com/toolpad/core/api/page-container)
|
|
128
|
-
*/
|
|
129
|
-
function PageContainer(props: PageContainerProps) {
|
|
130
|
-
const { children, defaultTitle, slots, slotProps, ...rest } = props;
|
|
115
|
+
function PageContainerBar(props: PageContainerBarProps) {
|
|
116
|
+
const { defaultTitle, slots, slotProps } = props;
|
|
131
117
|
|
|
132
|
-
const loaded = React.useRef(false);
|
|
133
118
|
const { state, dispatch } = React.useContext(PageDataContext);
|
|
134
119
|
|
|
135
120
|
const activePage = useActivePage();
|
|
136
121
|
|
|
137
122
|
React.useLayoutEffect(() => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
123
|
+
// Reset the state when the active page changes without rerendering
|
|
124
|
+
state.breadcrumbs = undefined;
|
|
125
|
+
state.noBreadcrumbs = undefined;
|
|
126
|
+
state.noPageHeader = undefined;
|
|
127
|
+
state.page = undefined;
|
|
128
|
+
state.title = undefined;
|
|
144
129
|
}, [activePage?.sourcePath]);
|
|
145
130
|
|
|
146
131
|
let resolvedBreadcrumbs = state.breadcrumbs ?? activePage?.breadcrumbs ?? [];
|
|
@@ -153,47 +138,72 @@ function PageContainer(props: PageContainerProps) {
|
|
|
153
138
|
];
|
|
154
139
|
}
|
|
155
140
|
|
|
156
|
-
const ToolbarComponent =
|
|
141
|
+
const ToolbarComponent = slots?.toolbar ?? PageContainerToolbar;
|
|
157
142
|
const toolbarSlotProps = useSlotProps({
|
|
158
143
|
elementType: ToolbarComponent,
|
|
159
144
|
ownerState: props,
|
|
160
|
-
externalSlotProps:
|
|
145
|
+
externalSlotProps: slotProps?.toolbar,
|
|
161
146
|
additionalProps: {}
|
|
162
147
|
});
|
|
163
148
|
|
|
149
|
+
return state.noPageHeader !== true ? (
|
|
150
|
+
<Stack>
|
|
151
|
+
{state.noBreadcrumbs !== true && (
|
|
152
|
+
<Breadcrumbs aria-label="breadcrumb">
|
|
153
|
+
{resolvedBreadcrumbs
|
|
154
|
+
? resolvedBreadcrumbs.map((item, index) => {
|
|
155
|
+
return index < resolvedBreadcrumbs.length - 1 ? (
|
|
156
|
+
<Link
|
|
157
|
+
key={item.path}
|
|
158
|
+
component={ToolpadLink}
|
|
159
|
+
underline="hover"
|
|
160
|
+
color="inherit"
|
|
161
|
+
href={item.path}
|
|
162
|
+
>
|
|
163
|
+
{getItemTitle(item)}
|
|
164
|
+
</Link>
|
|
165
|
+
) : (
|
|
166
|
+
<Typography key={item.path} color="text.primary">
|
|
167
|
+
{getItemTitle(item)}
|
|
168
|
+
</Typography>
|
|
169
|
+
);
|
|
170
|
+
})
|
|
171
|
+
: null}
|
|
172
|
+
</Breadcrumbs>
|
|
173
|
+
)}
|
|
174
|
+
<PageContentHeader>
|
|
175
|
+
{title ? <Typography variant="h4">{title}</Typography> : null}
|
|
176
|
+
<ToolbarComponent {...toolbarSlotProps} />
|
|
177
|
+
</PageContentHeader>
|
|
178
|
+
</Stack>
|
|
179
|
+
) : undefined;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export type PageContainerProps = React.PropsWithChildren<
|
|
183
|
+
StackProps & PageContainerBarProps
|
|
184
|
+
>;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A container component to provide a title and breadcrumbs for your pages.
|
|
188
|
+
*
|
|
189
|
+
* Demos:
|
|
190
|
+
*
|
|
191
|
+
* - [Page Container](https://mui.com/toolpad/core/react-page-container/)
|
|
192
|
+
*
|
|
193
|
+
* API:
|
|
194
|
+
*
|
|
195
|
+
* - [PageContainer API](https://mui.com/toolpad/core/api/page-container)
|
|
196
|
+
*/
|
|
197
|
+
function PageContainer(props: PageContainerProps) {
|
|
198
|
+
const { children, defaultTitle, slots, slotProps, ...rest } = props;
|
|
199
|
+
|
|
164
200
|
return (
|
|
165
201
|
<Stack sx={{ mx: 3, my: 2 }} spacing={2} {...rest}>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
? resolvedBreadcrumbs.map((item, index) => {
|
|
172
|
-
return index < resolvedBreadcrumbs.length - 1 ? (
|
|
173
|
-
<Link
|
|
174
|
-
key={item.path}
|
|
175
|
-
component={ToolpadLink}
|
|
176
|
-
underline="hover"
|
|
177
|
-
color="inherit"
|
|
178
|
-
href={item.path}
|
|
179
|
-
>
|
|
180
|
-
{getItemTitle(item)}
|
|
181
|
-
</Link>
|
|
182
|
-
) : (
|
|
183
|
-
<Typography key={item.path} color="text.primary">
|
|
184
|
-
{getItemTitle(item)}
|
|
185
|
-
</Typography>
|
|
186
|
-
);
|
|
187
|
-
})
|
|
188
|
-
: null}
|
|
189
|
-
</Breadcrumbs>
|
|
190
|
-
)}
|
|
191
|
-
<PageContentHeader>
|
|
192
|
-
{title ? <Typography variant="h4">{title}</Typography> : null}
|
|
193
|
-
<ToolbarComponent {...toolbarSlotProps} />
|
|
194
|
-
</PageContentHeader>
|
|
195
|
-
</Stack>
|
|
196
|
-
)}
|
|
202
|
+
<PageContainerBar
|
|
203
|
+
defaultTitle={defaultTitle}
|
|
204
|
+
slots={slots}
|
|
205
|
+
slotProps={slotProps}
|
|
206
|
+
/>
|
|
197
207
|
{children}
|
|
198
208
|
</Stack>
|
|
199
209
|
);
|