@iowas/toolpad 1.0.0
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/README.md +57 -0
- package/dist/AppProvider-CIyOzZv_.d.mts +201 -0
- package/dist/AppProvider-CIyOzZv_.d.ts +201 -0
- package/dist/chunk-3JWXE2JW.mjs +125 -0
- package/dist/chunk-CENJI4RY.mjs +26 -0
- package/dist/chunk-F6JD4MSY.mjs +12 -0
- package/dist/chunk-LUTZBKSG.mjs +710 -0
- package/dist/chunk-UNVYOWC2.mjs +44 -0
- package/dist/chunk-ZXM3V5SD.mjs +2325 -0
- package/dist/core.d.mts +995 -0
- package/dist/core.d.ts +995 -0
- package/dist/core.js +3111 -0
- package/dist/core.mjs +72 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +3271 -0
- package/dist/index.mjs +112 -0
- package/dist/nextjs.d.mts +8 -0
- package/dist/nextjs.d.ts +8 -0
- package/dist/nextjs.js +858 -0
- package/dist/nextjs.mjs +106 -0
- package/dist/utils.d.mts +98 -0
- package/dist/utils.d.ts +98 -0
- package/dist/utils.js +218 -0
- package/dist/utils.mjs +44 -0
- package/package.json +87 -0
|
@@ -0,0 +1,2325 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthenticationContext,
|
|
3
|
+
BrandingContext,
|
|
4
|
+
DashboardSidebarPageItemContext,
|
|
5
|
+
DialogsContext,
|
|
6
|
+
NavigationContext,
|
|
7
|
+
NotificationsContext,
|
|
8
|
+
PaletteModeContext,
|
|
9
|
+
RouterContext,
|
|
10
|
+
SessionContext,
|
|
11
|
+
WindowContext,
|
|
12
|
+
useLocaleText
|
|
13
|
+
} from "./chunk-LUTZBKSG.mjs";
|
|
14
|
+
import {
|
|
15
|
+
warnOnce
|
|
16
|
+
} from "./chunk-F6JD4MSY.mjs";
|
|
17
|
+
import {
|
|
18
|
+
__objRest,
|
|
19
|
+
__spreadProps,
|
|
20
|
+
__spreadValues,
|
|
21
|
+
useNonNullableContext
|
|
22
|
+
} from "./chunk-3JWXE2JW.mjs";
|
|
23
|
+
|
|
24
|
+
// src/toolpad-core/Account/Account.tsx
|
|
25
|
+
import * as React7 from "react";
|
|
26
|
+
import PropTypes6 from "prop-types";
|
|
27
|
+
import Popover from "@mui/material/Popover";
|
|
28
|
+
import Divider from "@mui/material/Divider";
|
|
29
|
+
import Stack3 from "@mui/material/Stack";
|
|
30
|
+
|
|
31
|
+
// src/toolpad-core/Account/SignInButton.tsx
|
|
32
|
+
import * as React4 from "react";
|
|
33
|
+
import PropTypes from "prop-types";
|
|
34
|
+
import Button2 from "@mui/material/Button";
|
|
35
|
+
|
|
36
|
+
// src/toolpad-core/useNotifications/useNotifications.tsx
|
|
37
|
+
import * as React from "react";
|
|
38
|
+
var serverNotifications = {
|
|
39
|
+
show: () => {
|
|
40
|
+
throw new Error("Not supported on server side");
|
|
41
|
+
},
|
|
42
|
+
close: () => {
|
|
43
|
+
throw new Error("Not supported on server side");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
function useNotifications() {
|
|
47
|
+
const context = React.useContext(NotificationsContext);
|
|
48
|
+
if (context) {
|
|
49
|
+
return context;
|
|
50
|
+
}
|
|
51
|
+
return serverNotifications;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/toolpad-core/useDialogs/useDialogs.tsx
|
|
55
|
+
import Button from "@mui/material/Button";
|
|
56
|
+
import Dialog from "@mui/material/Dialog";
|
|
57
|
+
import DialogTitle from "@mui/material/DialogTitle";
|
|
58
|
+
import DialogContent from "@mui/material/DialogContent";
|
|
59
|
+
import DialogActions from "@mui/material/DialogActions";
|
|
60
|
+
import TextField from "@mui/material/TextField";
|
|
61
|
+
import DialogContentText from "@mui/material/DialogContentText";
|
|
62
|
+
import invariant from "invariant";
|
|
63
|
+
import * as React2 from "react";
|
|
64
|
+
import useEventCallback from "@mui/utils/useEventCallback";
|
|
65
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
66
|
+
var defaultLocaleText = {
|
|
67
|
+
alert: "Alert",
|
|
68
|
+
confirm: "Confirm",
|
|
69
|
+
cancel: "Cancel",
|
|
70
|
+
ok: "Ok"
|
|
71
|
+
};
|
|
72
|
+
function useDialogLoadingButton(onClose) {
|
|
73
|
+
const [loading, setLoading] = React2.useState(false);
|
|
74
|
+
const handleClick = async () => {
|
|
75
|
+
try {
|
|
76
|
+
setLoading(true);
|
|
77
|
+
await onClose();
|
|
78
|
+
} finally {
|
|
79
|
+
setLoading(false);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
onClick: handleClick,
|
|
84
|
+
loading
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function AlertDialog({ open, payload, onClose }) {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const appWindowContext = React2.useContext(WindowContext);
|
|
90
|
+
const globalLocaleText = useLocaleText();
|
|
91
|
+
const localeText = __spreadValues(__spreadValues({}, defaultLocaleText), globalLocaleText);
|
|
92
|
+
const okButtonProps = useDialogLoadingButton(() => onClose());
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
94
|
+
Dialog,
|
|
95
|
+
{
|
|
96
|
+
maxWidth: "xs",
|
|
97
|
+
fullWidth: true,
|
|
98
|
+
open,
|
|
99
|
+
onClose: () => onClose(),
|
|
100
|
+
container: appWindowContext == null ? void 0 : appWindowContext.document.body,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: (_a = payload.title) != null ? _a : localeText.alert }),
|
|
103
|
+
/* @__PURE__ */ jsx(DialogContent, { children: payload.msg }),
|
|
104
|
+
/* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({ disabled: !open }, okButtonProps), { children: (_b = payload.okText) != null ? _b : localeText.ok })) })
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
function ConfirmDialog({ open, payload, onClose }) {
|
|
110
|
+
var _a, _b, _c;
|
|
111
|
+
const appWindowContext = React2.useContext(WindowContext);
|
|
112
|
+
const globalLocaleText = useLocaleText();
|
|
113
|
+
const localeText = __spreadValues(__spreadValues({}, defaultLocaleText), globalLocaleText);
|
|
114
|
+
const cancelButtonProps = useDialogLoadingButton(() => onClose(false));
|
|
115
|
+
const okButtonProps = useDialogLoadingButton(() => onClose(true));
|
|
116
|
+
return /* @__PURE__ */ jsxs(
|
|
117
|
+
Dialog,
|
|
118
|
+
{
|
|
119
|
+
maxWidth: "xs",
|
|
120
|
+
fullWidth: true,
|
|
121
|
+
open,
|
|
122
|
+
onClose: () => onClose(false),
|
|
123
|
+
container: appWindowContext == null ? void 0 : appWindowContext.document.body,
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: (_a = payload.title) != null ? _a : localeText.confirm }),
|
|
126
|
+
/* @__PURE__ */ jsx(DialogContent, { children: payload.msg }),
|
|
127
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({ autoFocus: true, disabled: !open }, cancelButtonProps), { children: (_b = payload.cancelText) != null ? _b : localeText.cancel })),
|
|
129
|
+
/* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({ color: payload.severity, disabled: !open }, okButtonProps), { children: (_c = payload.okText) != null ? _c : localeText.ok }))
|
|
130
|
+
] })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function PromptDialog({ open, payload, onClose }) {
|
|
136
|
+
var _a, _b, _c;
|
|
137
|
+
const appWindowContext = React2.useContext(WindowContext);
|
|
138
|
+
const globalLocaleText = useLocaleText();
|
|
139
|
+
const localeText = __spreadValues(__spreadValues({}, defaultLocaleText), globalLocaleText);
|
|
140
|
+
const [input, setInput] = React2.useState("");
|
|
141
|
+
const cancelButtonProps = useDialogLoadingButton(() => onClose(null));
|
|
142
|
+
const [loading, setLoading] = React2.useState(false);
|
|
143
|
+
const name = "input";
|
|
144
|
+
return /* @__PURE__ */ jsxs(
|
|
145
|
+
Dialog,
|
|
146
|
+
{
|
|
147
|
+
maxWidth: "xs",
|
|
148
|
+
fullWidth: true,
|
|
149
|
+
open,
|
|
150
|
+
onClose: () => onClose(null),
|
|
151
|
+
PaperProps: {
|
|
152
|
+
component: "form",
|
|
153
|
+
onSubmit: async (event) => {
|
|
154
|
+
var _a2;
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
try {
|
|
157
|
+
setLoading(true);
|
|
158
|
+
const formData = new FormData(event.currentTarget);
|
|
159
|
+
const value = (_a2 = formData.get(name)) != null ? _a2 : "";
|
|
160
|
+
invariant(typeof value === "string", "Value must come from a text input");
|
|
161
|
+
await onClose(value);
|
|
162
|
+
} finally {
|
|
163
|
+
setLoading(false);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
container: appWindowContext == null ? void 0 : appWindowContext.document.body,
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: (_a = payload.title) != null ? _a : localeText.confirm }),
|
|
170
|
+
/* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
171
|
+
/* @__PURE__ */ jsxs(DialogContentText, { children: [
|
|
172
|
+
payload.msg,
|
|
173
|
+
" "
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
TextField,
|
|
177
|
+
{
|
|
178
|
+
autoFocus: true,
|
|
179
|
+
required: true,
|
|
180
|
+
margin: "dense",
|
|
181
|
+
id: "name",
|
|
182
|
+
name,
|
|
183
|
+
type: "text",
|
|
184
|
+
fullWidth: true,
|
|
185
|
+
variant: "standard",
|
|
186
|
+
value: input,
|
|
187
|
+
onChange: (event) => setInput(event.target.value)
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] }),
|
|
191
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [
|
|
192
|
+
/* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({ disabled: !open }, cancelButtonProps), { children: (_b = payload.cancelText) != null ? _b : localeText.cancel })),
|
|
193
|
+
/* @__PURE__ */ jsx(Button, { disabled: !open, loading, type: "submit", children: (_c = payload.okText) != null ? _c : localeText.ok })
|
|
194
|
+
] })
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
function useDialogs() {
|
|
200
|
+
const { open, close } = useNonNullableContext(DialogsContext);
|
|
201
|
+
const alert = useEventCallback(
|
|
202
|
+
(msg, _a = {}) => {
|
|
203
|
+
var _b = _a, { onClose } = _b, options = __objRest(_b, ["onClose"]);
|
|
204
|
+
return open(AlertDialog, __spreadProps(__spreadValues({}, options), { msg }), { onClose });
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
const confirm = useEventCallback(
|
|
208
|
+
(msg, _c = {}) => {
|
|
209
|
+
var _d = _c, { onClose } = _d, options = __objRest(_d, ["onClose"]);
|
|
210
|
+
return open(ConfirmDialog, __spreadProps(__spreadValues({}, options), { msg }), { onClose });
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
const prompt = useEventCallback(
|
|
214
|
+
(msg, _e = {}) => {
|
|
215
|
+
var _f = _e, { onClose } = _f, options = __objRest(_f, ["onClose"]);
|
|
216
|
+
return open(PromptDialog, __spreadProps(__spreadValues({}, options), { msg }), { onClose });
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
return React2.useMemo(
|
|
220
|
+
() => ({
|
|
221
|
+
alert,
|
|
222
|
+
confirm,
|
|
223
|
+
prompt,
|
|
224
|
+
open,
|
|
225
|
+
close
|
|
226
|
+
}),
|
|
227
|
+
[alert, close, confirm, open, prompt]
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/toolpad-core/Account/AccountLocaleContext.tsx
|
|
232
|
+
import * as React3 from "react";
|
|
233
|
+
var AccountLocaleContext = React3.createContext(null);
|
|
234
|
+
|
|
235
|
+
// src/toolpad-core/Account/SignInButton.tsx
|
|
236
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
237
|
+
function SignInButton(props) {
|
|
238
|
+
const authentication = React4.useContext(AuthenticationContext);
|
|
239
|
+
const globalLocaleText = useLocaleText();
|
|
240
|
+
const accountLocaleText = React4.useContext(AccountLocaleContext);
|
|
241
|
+
const localeText = __spreadValues(__spreadValues({}, globalLocaleText), accountLocaleText);
|
|
242
|
+
return /* @__PURE__ */ jsx2(
|
|
243
|
+
Button2,
|
|
244
|
+
__spreadProps(__spreadValues({
|
|
245
|
+
disableElevation: true,
|
|
246
|
+
variant: "contained",
|
|
247
|
+
size: "small",
|
|
248
|
+
onClick: authentication == null ? void 0 : authentication.signIn,
|
|
249
|
+
sx: {
|
|
250
|
+
textTransform: "capitalize",
|
|
251
|
+
filter: "opacity(0.9)",
|
|
252
|
+
width: "50%",
|
|
253
|
+
margin: (theme) => `${theme.spacing(1)} auto`,
|
|
254
|
+
transition: "filter 0.2s ease-in",
|
|
255
|
+
"&:hover": {
|
|
256
|
+
filter: "opacity(1)"
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}, props), {
|
|
260
|
+
children: localeText == null ? void 0 : localeText.accountSignInLabel
|
|
261
|
+
})
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
SignInButton.propTypes = {
|
|
265
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
266
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
267
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
268
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
269
|
+
/**
|
|
270
|
+
* The content of the component.
|
|
271
|
+
*/
|
|
272
|
+
children: PropTypes.node
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// src/toolpad-core/Account/SignOutButton.tsx
|
|
276
|
+
import * as React5 from "react";
|
|
277
|
+
import PropTypes2 from "prop-types";
|
|
278
|
+
import Button3 from "@mui/material/Button";
|
|
279
|
+
import LogoutIcon from "@mui/icons-material/Logout";
|
|
280
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
281
|
+
function SignOutButton(props) {
|
|
282
|
+
const authentication = React5.useContext(AuthenticationContext);
|
|
283
|
+
const globalLocaleText = useLocaleText();
|
|
284
|
+
const accountLocaleText = React5.useContext(AccountLocaleContext);
|
|
285
|
+
const localeText = __spreadValues(__spreadValues({}, globalLocaleText), accountLocaleText);
|
|
286
|
+
return /* @__PURE__ */ jsx3(
|
|
287
|
+
Button3,
|
|
288
|
+
__spreadProps(__spreadValues({
|
|
289
|
+
disabled: !authentication,
|
|
290
|
+
variant: "outlined",
|
|
291
|
+
size: "small",
|
|
292
|
+
disableElevation: true,
|
|
293
|
+
onClick: authentication == null ? void 0 : authentication.signOut,
|
|
294
|
+
sx: {
|
|
295
|
+
textTransform: "capitalize",
|
|
296
|
+
fontWeight: "normal",
|
|
297
|
+
filter: "opacity(0.9)",
|
|
298
|
+
transition: "filter 0.2s ease-in",
|
|
299
|
+
"&:hover": {
|
|
300
|
+
filter: "opacity(1)"
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
startIcon: /* @__PURE__ */ jsx3(LogoutIcon, {})
|
|
304
|
+
}, props), {
|
|
305
|
+
children: localeText == null ? void 0 : localeText.accountSignOutLabel
|
|
306
|
+
})
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
SignOutButton.propTypes = {
|
|
310
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
311
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
312
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
313
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
314
|
+
/**
|
|
315
|
+
* The content of the component.
|
|
316
|
+
*/
|
|
317
|
+
children: PropTypes2.node
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// src/toolpad-core/Account/AccountPreview.tsx
|
|
321
|
+
import * as React6 from "react";
|
|
322
|
+
import PropTypes3 from "prop-types";
|
|
323
|
+
import Avatar from "@mui/material/Avatar";
|
|
324
|
+
import Typography from "@mui/material/Typography";
|
|
325
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
326
|
+
import Stack from "@mui/material/Stack";
|
|
327
|
+
import IconButton from "@mui/material/IconButton";
|
|
328
|
+
import MoreVertIcon from "@mui/icons-material/MoreVert";
|
|
329
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
330
|
+
function AccountPreview(props) {
|
|
331
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
332
|
+
const { slots, variant = "condensed", slotProps, open, handleClick, sx } = props;
|
|
333
|
+
const session = React6.useContext(SessionContext);
|
|
334
|
+
const globalLocaleText = useLocaleText();
|
|
335
|
+
const accountLocaleText = React6.useContext(AccountLocaleContext);
|
|
336
|
+
const localeText = __spreadValues(__spreadValues({}, globalLocaleText), accountLocaleText);
|
|
337
|
+
if (!session || !session.user) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
const avatarContent = (slots == null ? void 0 : slots.avatar) ? /* @__PURE__ */ jsx4(slots.avatar, {}) : /* @__PURE__ */ jsx4(
|
|
341
|
+
Avatar,
|
|
342
|
+
__spreadValues({
|
|
343
|
+
src: ((_a = session.user) == null ? void 0 : _a.image) || "",
|
|
344
|
+
alt: ((_b = session.user) == null ? void 0 : _b.name) || ((_c = session.user) == null ? void 0 : _c.email) || "",
|
|
345
|
+
sx: { height: variant === "expanded" ? 48 : 32, width: variant === "expanded" ? 48 : 32 }
|
|
346
|
+
}, slotProps == null ? void 0 : slotProps.avatar)
|
|
347
|
+
);
|
|
348
|
+
if (variant === "expanded") {
|
|
349
|
+
return /* @__PURE__ */ jsxs2(Stack, { direction: "row", justifyContent: "space-between", sx: __spreadValues({ py: 1, px: 2, gap: 2 }, sx), children: [
|
|
350
|
+
/* @__PURE__ */ jsxs2(Stack, { direction: "row", justifyContent: "flex-start", spacing: 2, overflow: "hidden", children: [
|
|
351
|
+
avatarContent,
|
|
352
|
+
/* @__PURE__ */ jsxs2(Stack, { direction: "column", justifyContent: "space-evenly", overflow: "hidden", children: [
|
|
353
|
+
/* @__PURE__ */ jsx4(Typography, { variant: "body2", fontWeight: "bolder", noWrap: true, children: (_d = session.user) == null ? void 0 : _d.name }),
|
|
354
|
+
/* @__PURE__ */ jsx4(Typography, { variant: "caption", noWrap: true, children: (_e = session.user) == null ? void 0 : _e.email })
|
|
355
|
+
] })
|
|
356
|
+
] }),
|
|
357
|
+
handleClick && ((slots == null ? void 0 : slots.moreIconButton) ? /* @__PURE__ */ jsx4(slots.moreIconButton, {}) : /* @__PURE__ */ jsx4(
|
|
358
|
+
IconButton,
|
|
359
|
+
__spreadProps(__spreadValues({
|
|
360
|
+
size: "small",
|
|
361
|
+
onClick: handleClick
|
|
362
|
+
}, slotProps == null ? void 0 : slotProps.moreIconButton), {
|
|
363
|
+
sx: __spreadValues({ alignSelf: "center" }, (_f = slotProps == null ? void 0 : slotProps.moreIconButton) == null ? void 0 : _f.sx),
|
|
364
|
+
children: /* @__PURE__ */ jsx4(MoreVertIcon, { fontSize: "small" })
|
|
365
|
+
})
|
|
366
|
+
))
|
|
367
|
+
] });
|
|
368
|
+
}
|
|
369
|
+
return /* @__PURE__ */ jsx4(Tooltip, { title: (_g = session.user.name) != null ? _g : accountLocaleText == null ? void 0 : accountLocaleText.accountPreviewTitle, children: (slots == null ? void 0 : slots.avatarIconButton) ? /* @__PURE__ */ jsx4(slots.avatarIconButton, __spreadValues({}, slotProps == null ? void 0 : slotProps.avatarIconButton)) : /* @__PURE__ */ jsx4(Stack, { sx: __spreadValues({ py: 0.5 }, sx), children: /* @__PURE__ */ jsx4(
|
|
370
|
+
IconButton,
|
|
371
|
+
__spreadProps(__spreadValues({
|
|
372
|
+
onClick: handleClick,
|
|
373
|
+
"aria-label": localeText == null ? void 0 : localeText.accountPreviewIconButtonLabel,
|
|
374
|
+
size: "small",
|
|
375
|
+
"aria-controls": open ? "account-menu" : void 0,
|
|
376
|
+
"aria-haspopup": "true",
|
|
377
|
+
"aria-expanded": open ? "true" : void 0
|
|
378
|
+
}, slotProps == null ? void 0 : slotProps.avatarIconButton), {
|
|
379
|
+
sx: __spreadValues({ width: "fit-content", margin: "0 auto" }, (_h = slotProps == null ? void 0 : slotProps.avatarIconButton) == null ? void 0 : _h.sx),
|
|
380
|
+
children: avatarContent
|
|
381
|
+
})
|
|
382
|
+
) }) });
|
|
383
|
+
}
|
|
384
|
+
AccountPreview.propTypes = {
|
|
385
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
386
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
387
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
388
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
389
|
+
/**
|
|
390
|
+
* The handler used when the preview is expanded
|
|
391
|
+
*/
|
|
392
|
+
handleClick: PropTypes3.func,
|
|
393
|
+
/**
|
|
394
|
+
* The state of the Account popover
|
|
395
|
+
* @default false
|
|
396
|
+
*/
|
|
397
|
+
open: PropTypes3.bool,
|
|
398
|
+
/**
|
|
399
|
+
* The props used for each slot inside.
|
|
400
|
+
*/
|
|
401
|
+
slotProps: PropTypes3.shape({
|
|
402
|
+
avatar: PropTypes3.object,
|
|
403
|
+
avatarIconButton: PropTypes3.object,
|
|
404
|
+
moreIconButton: PropTypes3.object
|
|
405
|
+
}),
|
|
406
|
+
/**
|
|
407
|
+
* The components used for each slot inside.
|
|
408
|
+
*/
|
|
409
|
+
slots: PropTypes3.shape({
|
|
410
|
+
avatar: PropTypes3.elementType,
|
|
411
|
+
avatarIconButton: PropTypes3.elementType,
|
|
412
|
+
moreIconButton: PropTypes3.elementType
|
|
413
|
+
}),
|
|
414
|
+
/**
|
|
415
|
+
* The prop used to customize the styling of the preview
|
|
416
|
+
*/
|
|
417
|
+
sx: PropTypes3.oneOfType([
|
|
418
|
+
PropTypes3.arrayOf(PropTypes3.oneOfType([PropTypes3.func, PropTypes3.object, PropTypes3.bool])),
|
|
419
|
+
PropTypes3.func,
|
|
420
|
+
PropTypes3.object
|
|
421
|
+
]),
|
|
422
|
+
/**
|
|
423
|
+
* The type of account details to display.
|
|
424
|
+
* @property {'condensed'} condensed - Shows only the user's avatar.
|
|
425
|
+
* @property {'expanded'} expanded - Displays the user's avatar, name, and email if available.
|
|
426
|
+
* @default 'condensed'
|
|
427
|
+
*/
|
|
428
|
+
variant: PropTypes3.oneOf(["condensed", "expanded"])
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// src/toolpad-core/Account/AccountPopoverHeader.tsx
|
|
432
|
+
import PropTypes4 from "prop-types";
|
|
433
|
+
import Stack2 from "@mui/material/Stack";
|
|
434
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
435
|
+
function AccountPopoverHeader(props) {
|
|
436
|
+
const _a = props, { children } = _a, rest = __objRest(_a, ["children"]);
|
|
437
|
+
return /* @__PURE__ */ jsx5(Stack2, __spreadProps(__spreadValues({}, rest), { children }));
|
|
438
|
+
}
|
|
439
|
+
AccountPopoverHeader.propTypes = {
|
|
440
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
441
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
442
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
443
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
444
|
+
/**
|
|
445
|
+
* The content of the component.
|
|
446
|
+
*/
|
|
447
|
+
children: PropTypes4.node
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
// src/toolpad-core/Account/AccountPopoverFooter.tsx
|
|
451
|
+
import PropTypes5 from "prop-types";
|
|
452
|
+
import Box from "@mui/material/Box";
|
|
453
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
454
|
+
function AccountPopoverFooter(props) {
|
|
455
|
+
const _a = props, { children } = _a, rest = __objRest(_a, ["children"]);
|
|
456
|
+
return /* @__PURE__ */ jsx6(
|
|
457
|
+
Box,
|
|
458
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
459
|
+
sx: __spreadValues({ display: "flex", flexDirection: "row", p: 1, justifyContent: "flex-end" }, rest.sx),
|
|
460
|
+
children
|
|
461
|
+
})
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
AccountPopoverFooter.propTypes = {
|
|
465
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
466
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
467
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
468
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
469
|
+
/**
|
|
470
|
+
* @ignore
|
|
471
|
+
*/
|
|
472
|
+
children: PropTypes5.node,
|
|
473
|
+
/**
|
|
474
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
475
|
+
*/
|
|
476
|
+
sx: PropTypes5.oneOfType([
|
|
477
|
+
PropTypes5.arrayOf(PropTypes5.oneOfType([PropTypes5.func, PropTypes5.object, PropTypes5.bool])),
|
|
478
|
+
PropTypes5.func,
|
|
479
|
+
PropTypes5.object
|
|
480
|
+
])
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// src/toolpad-core/Account/Account.tsx
|
|
484
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
485
|
+
var defaultAccountLocaleText = {
|
|
486
|
+
accountPreviewIconButtonLabel: "Current User",
|
|
487
|
+
accountPreviewTitle: "Account",
|
|
488
|
+
accountSignInLabel: "Sign in",
|
|
489
|
+
accountSignOutLabel: "Sign out"
|
|
490
|
+
};
|
|
491
|
+
function Account(props) {
|
|
492
|
+
var _a;
|
|
493
|
+
const { localeText: propsLocaleText } = props;
|
|
494
|
+
const globalLocaleText = useLocaleText();
|
|
495
|
+
const localeText = React7.useMemo(
|
|
496
|
+
() => __spreadValues(__spreadValues(__spreadValues({}, defaultAccountLocaleText), globalLocaleText), propsLocaleText),
|
|
497
|
+
[globalLocaleText, propsLocaleText]
|
|
498
|
+
);
|
|
499
|
+
const { slots, slotProps } = props;
|
|
500
|
+
const [anchorEl, setAnchorEl] = React7.useState(null);
|
|
501
|
+
const session = React7.useContext(SessionContext);
|
|
502
|
+
const authentication = React7.useContext(AuthenticationContext);
|
|
503
|
+
const open = Boolean(anchorEl);
|
|
504
|
+
const handleClick = (event) => {
|
|
505
|
+
setAnchorEl(event.currentTarget);
|
|
506
|
+
};
|
|
507
|
+
const handleClose = () => {
|
|
508
|
+
setAnchorEl(null);
|
|
509
|
+
};
|
|
510
|
+
if (!authentication) {
|
|
511
|
+
return null;
|
|
512
|
+
}
|
|
513
|
+
let accountContent = null;
|
|
514
|
+
if (!(session == null ? void 0 : session.user)) {
|
|
515
|
+
accountContent = (slots == null ? void 0 : slots.signInButton) ? /* @__PURE__ */ jsx7(slots.signInButton, { onClick: authentication.signIn }) : /* @__PURE__ */ jsx7(SignInButton, __spreadValues({}, slotProps == null ? void 0 : slotProps.signInButton));
|
|
516
|
+
} else {
|
|
517
|
+
accountContent = /* @__PURE__ */ jsxs3(React7.Fragment, { children: [
|
|
518
|
+
(slots == null ? void 0 : slots.preview) ? /* @__PURE__ */ jsx7(slots.preview, { handleClick, open }) : /* @__PURE__ */ jsx7(
|
|
519
|
+
AccountPreview,
|
|
520
|
+
__spreadValues({
|
|
521
|
+
variant: "condensed",
|
|
522
|
+
handleClick,
|
|
523
|
+
open
|
|
524
|
+
}, slotProps == null ? void 0 : slotProps.preview)
|
|
525
|
+
),
|
|
526
|
+
(slots == null ? void 0 : slots.popover) ? /* @__PURE__ */ jsx7(
|
|
527
|
+
slots.popover,
|
|
528
|
+
__spreadValues({
|
|
529
|
+
open,
|
|
530
|
+
onClick: handleClick,
|
|
531
|
+
onClose: handleClose
|
|
532
|
+
}, slotProps == null ? void 0 : slotProps.popover)
|
|
533
|
+
) : /* @__PURE__ */ jsx7(
|
|
534
|
+
Popover,
|
|
535
|
+
__spreadProps(__spreadValues({
|
|
536
|
+
anchorEl,
|
|
537
|
+
id: "account-menu",
|
|
538
|
+
open,
|
|
539
|
+
onClose: handleClose,
|
|
540
|
+
onClick: handleClose,
|
|
541
|
+
transformOrigin: { horizontal: "right", vertical: "top" },
|
|
542
|
+
anchorOrigin: { horizontal: "right", vertical: "bottom" }
|
|
543
|
+
}, slotProps == null ? void 0 : slotProps.popover), {
|
|
544
|
+
slotProps: __spreadValues({
|
|
545
|
+
paper: {
|
|
546
|
+
elevation: 0,
|
|
547
|
+
sx: {
|
|
548
|
+
overflow: "visible",
|
|
549
|
+
filter: (theme) => `drop-shadow(0px 2px 8px ${theme.palette.mode === "dark" ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.32)"})`,
|
|
550
|
+
mt: 1,
|
|
551
|
+
"&::before": {
|
|
552
|
+
content: '""',
|
|
553
|
+
display: "block",
|
|
554
|
+
position: "absolute",
|
|
555
|
+
top: 0,
|
|
556
|
+
right: 14,
|
|
557
|
+
width: 10,
|
|
558
|
+
height: 10,
|
|
559
|
+
bgcolor: "background.paper",
|
|
560
|
+
transform: "translateY(-50%) rotate(45deg)",
|
|
561
|
+
zIndex: 0
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}, (_a = slotProps == null ? void 0 : slotProps.popover) == null ? void 0 : _a.slotProps),
|
|
566
|
+
children: (slots == null ? void 0 : slots.popoverContent) ? /* @__PURE__ */ jsx7(slots.popoverContent, __spreadValues({}, slotProps == null ? void 0 : slotProps.popoverContent)) : /* @__PURE__ */ jsxs3(Stack3, __spreadProps(__spreadValues({ direction: "column" }, slotProps == null ? void 0 : slotProps.popoverContent), { children: [
|
|
567
|
+
/* @__PURE__ */ jsx7(AccountPopoverHeader, { children: /* @__PURE__ */ jsx7(AccountPreview, { variant: "expanded" }) }),
|
|
568
|
+
/* @__PURE__ */ jsx7(Divider, {}),
|
|
569
|
+
/* @__PURE__ */ jsx7(AccountPopoverFooter, { children: /* @__PURE__ */ jsx7(SignOutButton, __spreadValues({}, slotProps == null ? void 0 : slotProps.signOutButton)) })
|
|
570
|
+
] }))
|
|
571
|
+
})
|
|
572
|
+
)
|
|
573
|
+
] });
|
|
574
|
+
}
|
|
575
|
+
return /* @__PURE__ */ jsx7(AccountLocaleContext.Provider, { value: localeText, children: accountContent });
|
|
576
|
+
}
|
|
577
|
+
Account.propTypes = {
|
|
578
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
579
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
580
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
581
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
582
|
+
/**
|
|
583
|
+
* The labels for the account component.
|
|
584
|
+
*/
|
|
585
|
+
localeText: PropTypes6.object,
|
|
586
|
+
/**
|
|
587
|
+
* The props used for each slot inside.
|
|
588
|
+
*/
|
|
589
|
+
slotProps: PropTypes6.shape({
|
|
590
|
+
popover: PropTypes6.object,
|
|
591
|
+
popoverContent: PropTypes6.object,
|
|
592
|
+
preview: PropTypes6.shape({
|
|
593
|
+
handleClick: PropTypes6.func,
|
|
594
|
+
open: PropTypes6.bool,
|
|
595
|
+
slotProps: PropTypes6.shape({
|
|
596
|
+
avatar: PropTypes6.object,
|
|
597
|
+
avatarIconButton: PropTypes6.object,
|
|
598
|
+
moreIconButton: PropTypes6.object
|
|
599
|
+
}),
|
|
600
|
+
slots: PropTypes6.shape({
|
|
601
|
+
avatar: PropTypes6.elementType,
|
|
602
|
+
avatarIconButton: PropTypes6.elementType,
|
|
603
|
+
moreIconButton: PropTypes6.elementType
|
|
604
|
+
}),
|
|
605
|
+
sx: PropTypes6.oneOfType([
|
|
606
|
+
PropTypes6.arrayOf(PropTypes6.oneOfType([PropTypes6.func, PropTypes6.object, PropTypes6.bool])),
|
|
607
|
+
PropTypes6.func,
|
|
608
|
+
PropTypes6.object
|
|
609
|
+
]),
|
|
610
|
+
variant: PropTypes6.oneOf(["condensed", "expanded"])
|
|
611
|
+
}),
|
|
612
|
+
signInButton: PropTypes6.object,
|
|
613
|
+
signOutButton: PropTypes6.object
|
|
614
|
+
}),
|
|
615
|
+
/**
|
|
616
|
+
* The components used for each slot inside.
|
|
617
|
+
*/
|
|
618
|
+
slots: PropTypes6.shape({
|
|
619
|
+
popover: PropTypes6.elementType,
|
|
620
|
+
popoverContent: PropTypes6.elementType,
|
|
621
|
+
preview: PropTypes6.elementType,
|
|
622
|
+
signInButton: PropTypes6.elementType,
|
|
623
|
+
signOutButton: PropTypes6.elementType
|
|
624
|
+
})
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
// src/toolpad-core/DashboardLayout/DashboardLayout.tsx
|
|
628
|
+
import * as React16 from "react";
|
|
629
|
+
import PropTypes9 from "prop-types";
|
|
630
|
+
import { useTheme as useTheme3 } from "@mui/material/styles";
|
|
631
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
632
|
+
import Box4 from "@mui/material/Box";
|
|
633
|
+
import Drawer from "@mui/material/Drawer";
|
|
634
|
+
import Toolbar2 from "@mui/material/Toolbar";
|
|
635
|
+
|
|
636
|
+
// src/toolpad-core/DashboardLayout/DashboardHeader.tsx
|
|
637
|
+
import * as React12 from "react";
|
|
638
|
+
import PropTypes7 from "prop-types";
|
|
639
|
+
import { styled as styled2 } from "@mui/material/styles";
|
|
640
|
+
import Box2 from "@mui/material/Box";
|
|
641
|
+
import MuiAppBar from "@mui/material/AppBar";
|
|
642
|
+
import IconButton3 from "@mui/material/IconButton";
|
|
643
|
+
import Toolbar from "@mui/material/Toolbar";
|
|
644
|
+
import Tooltip3 from "@mui/material/Tooltip";
|
|
645
|
+
import MenuIcon from "@mui/icons-material/Menu";
|
|
646
|
+
import MenuOpenIcon from "@mui/icons-material/MenuOpen";
|
|
647
|
+
import Stack6 from "@mui/material/Stack";
|
|
648
|
+
|
|
649
|
+
// src/toolpad-core/DashboardLayout/AppTitle.tsx
|
|
650
|
+
import Typography2 from "@mui/material/Typography";
|
|
651
|
+
import Stack4 from "@mui/material/Stack";
|
|
652
|
+
import { styled, useTheme } from "@mui/material";
|
|
653
|
+
|
|
654
|
+
// src/toolpad-core/shared/Link.tsx
|
|
655
|
+
import * as React8 from "react";
|
|
656
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
657
|
+
var DefaultLink = React8.forwardRef(function Link(props, ref) {
|
|
658
|
+
const _a = props, { children, href, onClick, history } = _a, rest = __objRest(_a, ["children", "href", "onClick", "history"]);
|
|
659
|
+
const routerContext = React8.useContext(RouterContext);
|
|
660
|
+
const handleLinkClick = React8.useMemo(() => {
|
|
661
|
+
if (!routerContext) {
|
|
662
|
+
return onClick;
|
|
663
|
+
}
|
|
664
|
+
return (event) => {
|
|
665
|
+
event.preventDefault();
|
|
666
|
+
const url = new URL(event.currentTarget.href);
|
|
667
|
+
routerContext.navigate(url.pathname, { history });
|
|
668
|
+
onClick == null ? void 0 : onClick(event);
|
|
669
|
+
};
|
|
670
|
+
}, [routerContext, onClick, history]);
|
|
671
|
+
return /* @__PURE__ */ jsx8("a", __spreadProps(__spreadValues({ ref, href }, rest), { onClick: handleLinkClick, children }));
|
|
672
|
+
});
|
|
673
|
+
var Link2 = React8.forwardRef(function Link3(props, ref) {
|
|
674
|
+
var _a;
|
|
675
|
+
const routerContext = React8.useContext(RouterContext);
|
|
676
|
+
const LinkComponent = (_a = routerContext == null ? void 0 : routerContext.Link) != null ? _a : DefaultLink;
|
|
677
|
+
return /* @__PURE__ */ jsx8(LinkComponent, __spreadProps(__spreadValues({ ref }, props), { children: props.children }));
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
// src/toolpad-core/DashboardLayout/ToolpadLogo.tsx
|
|
681
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
682
|
+
function ToolpadLogo({ size = 40 }) {
|
|
683
|
+
return /* @__PURE__ */ jsxs4("svg", { width: size, height: size, fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
684
|
+
/* @__PURE__ */ jsxs4("g", { mask: "url(#a)", children: [
|
|
685
|
+
/* @__PURE__ */ jsx9("path", { d: "M22.74 27.73v-7.6l6.64-3.79v7.6l-6.64 3.79Z", fill: "#007FFF" }),
|
|
686
|
+
/* @__PURE__ */ jsx9("path", { d: "M16.1 23.93v-7.59l6.64 3.8v7.59l-6.65-3.8Z", fill: "#39F" }),
|
|
687
|
+
/* @__PURE__ */ jsx9("path", { d: "m16.1 16.34 6.64-3.8 6.64 3.8-6.64 3.8-6.65-3.8Z", fill: "#A5D8FF" })
|
|
688
|
+
] }),
|
|
689
|
+
/* @__PURE__ */ jsx9(
|
|
690
|
+
"mask",
|
|
691
|
+
{
|
|
692
|
+
id: "b",
|
|
693
|
+
style: {
|
|
694
|
+
maskType: "alpha"
|
|
695
|
+
},
|
|
696
|
+
maskUnits: "userSpaceOnUse",
|
|
697
|
+
x: "8",
|
|
698
|
+
y: "17",
|
|
699
|
+
width: "14",
|
|
700
|
+
height: "15",
|
|
701
|
+
children: /* @__PURE__ */ jsx9(
|
|
702
|
+
"path",
|
|
703
|
+
{
|
|
704
|
+
d: "M8.5 22.3c0-1.05.56-2 1.46-2.53l3.75-2.14c.89-.5 1.98-.5 2.87 0l3.75 2.14a2.9 2.9 0 0 1 1.46 2.52v4.23c0 1.04-.56 2-1.46 2.52l-3.75 2.14c-.89.5-1.98.5-2.87 0l-3.75-2.14a2.9 2.9 0 0 1-1.46-2.52v-4.23Z",
|
|
705
|
+
fill: "#D7DCE1"
|
|
706
|
+
}
|
|
707
|
+
)
|
|
708
|
+
}
|
|
709
|
+
),
|
|
710
|
+
/* @__PURE__ */ jsxs4("g", { mask: "url(#b)", children: [
|
|
711
|
+
/* @__PURE__ */ jsx9("path", { d: "M15.14 32v-7.6l6.65-3.8v7.6L15.14 32Z", fill: "#007FFF" }),
|
|
712
|
+
/* @__PURE__ */ jsx9("path", { d: "M8.5 28.2v-7.6l6.64 3.8V32L8.5 28.2Z", fill: "#39F" }),
|
|
713
|
+
/* @__PURE__ */ jsx9("path", { d: "m8.5 20.6 6.64-3.79 6.65 3.8-6.65 3.8-6.64-3.8Z", fill: "#A5D8FF" })
|
|
714
|
+
] }),
|
|
715
|
+
/* @__PURE__ */ jsx9(
|
|
716
|
+
"mask",
|
|
717
|
+
{
|
|
718
|
+
id: "c",
|
|
719
|
+
style: {
|
|
720
|
+
maskType: "alpha"
|
|
721
|
+
},
|
|
722
|
+
maskUnits: "userSpaceOnUse",
|
|
723
|
+
x: "8",
|
|
724
|
+
y: "4",
|
|
725
|
+
width: "22",
|
|
726
|
+
height: "20",
|
|
727
|
+
children: /* @__PURE__ */ jsx9(
|
|
728
|
+
"path",
|
|
729
|
+
{
|
|
730
|
+
d: "M24.17 4.82a2.9 2.9 0 0 0-2.87 0L9.97 11.22a2.9 2.9 0 0 0-1.47 2.53v4.22c0 1.04.56 2 1.46 2.52l3.75 2.14c.89.5 1.98.5 2.87 0l11.33-6.42a2.9 2.9 0 0 0 1.47-2.52V9.48c0-1.04-.56-2-1.46-2.52l-3.75-2.14Z",
|
|
731
|
+
fill: "#D7DCE1"
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
}
|
|
735
|
+
),
|
|
736
|
+
/* @__PURE__ */ jsxs4("g", { mask: "url(#c)", children: [
|
|
737
|
+
/* @__PURE__ */ jsx9("path", { d: "M15.14 23.46v-7.6L29.38 7.8v7.59l-14.24 8.07Z", fill: "#007FFF" }),
|
|
738
|
+
/* @__PURE__ */ jsx9("path", { d: "M8.5 19.66v-7.6l6.64 3.8v7.6l-6.64-3.8Z", fill: "#39F" }),
|
|
739
|
+
/* @__PURE__ */ jsx9("path", { d: "M8.5 12.07 22.74 4l6.64 3.8-14.24 8.06-6.64-3.8Z", fill: "#A5D8FF" })
|
|
740
|
+
] })
|
|
741
|
+
] });
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// src/toolpad-core/shared/branding.ts
|
|
745
|
+
import * as React9 from "react";
|
|
746
|
+
function useApplicationTitle() {
|
|
747
|
+
var _a;
|
|
748
|
+
const branding = React9.useContext(BrandingContext);
|
|
749
|
+
return (_a = branding == null ? void 0 : branding.title) != null ? _a : "Toolpad";
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// src/toolpad-core/DashboardLayout/AppTitle.tsx
|
|
753
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
754
|
+
var LogoContainer = styled("div")({
|
|
755
|
+
position: "relative",
|
|
756
|
+
height: 40,
|
|
757
|
+
display: "flex",
|
|
758
|
+
alignItems: "center",
|
|
759
|
+
"& img": {
|
|
760
|
+
maxHeight: 40
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
function AppTitle(props) {
|
|
764
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
765
|
+
const theme = useTheme();
|
|
766
|
+
const defaultTitle = useApplicationTitle();
|
|
767
|
+
const title = (_b = (_a = props == null ? void 0 : props.branding) == null ? void 0 : _a.title) != null ? _b : defaultTitle;
|
|
768
|
+
return /* @__PURE__ */ jsx10(Link2, { href: (_d = (_c = props == null ? void 0 : props.branding) == null ? void 0 : _c.homeUrl) != null ? _d : "/", style: { textDecoration: "none" }, children: /* @__PURE__ */ jsxs5(Stack4, { direction: "row", alignItems: "center", children: [
|
|
769
|
+
/* @__PURE__ */ jsx10(LogoContainer, { children: (_f = (_e = props == null ? void 0 : props.branding) == null ? void 0 : _e.logo) != null ? _f : /* @__PURE__ */ jsx10(ToolpadLogo, { size: 40 }) }),
|
|
770
|
+
/* @__PURE__ */ jsx10(
|
|
771
|
+
Typography2,
|
|
772
|
+
{
|
|
773
|
+
variant: "h6",
|
|
774
|
+
sx: {
|
|
775
|
+
color: ((_g = theme.vars) != null ? _g : theme).palette.primary.main,
|
|
776
|
+
fontWeight: "700",
|
|
777
|
+
ml: 1,
|
|
778
|
+
whiteSpace: "nowrap",
|
|
779
|
+
lineHeight: 1
|
|
780
|
+
},
|
|
781
|
+
children: title
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
] }) });
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/toolpad-core/DashboardLayout/ToolbarActions.tsx
|
|
788
|
+
import Stack5 from "@mui/material/Stack";
|
|
789
|
+
|
|
790
|
+
// src/toolpad-core/DashboardLayout/ThemeSwitcher.tsx
|
|
791
|
+
import * as React11 from "react";
|
|
792
|
+
import { useTheme as useTheme2 } from "@mui/material";
|
|
793
|
+
import IconButton2 from "@mui/material/IconButton";
|
|
794
|
+
import Tooltip2 from "@mui/material/Tooltip";
|
|
795
|
+
import DarkModeIcon from "@mui/icons-material/DarkMode";
|
|
796
|
+
import LightModeIcon from "@mui/icons-material/LightMode";
|
|
797
|
+
|
|
798
|
+
// src/toolpad-utils/hooks/useSsr.ts
|
|
799
|
+
import * as React10 from "react";
|
|
800
|
+
function subscribe() {
|
|
801
|
+
return () => {
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function getSnapshot() {
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
function getServerSnapshot() {
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
function useSsr() {
|
|
811
|
+
return React10.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// src/toolpad-core/DashboardLayout/ThemeSwitcher.tsx
|
|
815
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
816
|
+
function ThemeSwitcher() {
|
|
817
|
+
var _a;
|
|
818
|
+
const isSsr = useSsr();
|
|
819
|
+
const theme = useTheme2();
|
|
820
|
+
const { paletteMode, setPaletteMode, isDualTheme } = React11.useContext(PaletteModeContext);
|
|
821
|
+
const toggleMode = React11.useCallback(() => {
|
|
822
|
+
setPaletteMode(paletteMode === "dark" ? "light" : "dark");
|
|
823
|
+
}, [paletteMode, setPaletteMode]);
|
|
824
|
+
return isDualTheme ? /* @__PURE__ */ jsx11(
|
|
825
|
+
Tooltip2,
|
|
826
|
+
{
|
|
827
|
+
title: isSsr ? "Switch mode" : `${paletteMode === "dark" ? "Light" : "Dark"} mode`,
|
|
828
|
+
enterDelay: 1e3,
|
|
829
|
+
children: /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsx11(
|
|
830
|
+
IconButton2,
|
|
831
|
+
{
|
|
832
|
+
"aria-label": isSsr ? "Switch theme mode" : `Switch to ${paletteMode === "dark" ? "light" : "dark"} mode`,
|
|
833
|
+
onClick: toggleMode,
|
|
834
|
+
sx: {
|
|
835
|
+
color: ((_a = theme.vars) != null ? _a : theme).palette.primary.dark
|
|
836
|
+
},
|
|
837
|
+
children: theme.getColorSchemeSelector ? /* @__PURE__ */ jsxs6(React11.Fragment, { children: [
|
|
838
|
+
/* @__PURE__ */ jsx11(
|
|
839
|
+
DarkModeIcon,
|
|
840
|
+
{
|
|
841
|
+
sx: {
|
|
842
|
+
display: "inline",
|
|
843
|
+
[theme.getColorSchemeSelector("dark")]: {
|
|
844
|
+
display: "none"
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
),
|
|
849
|
+
/* @__PURE__ */ jsx11(
|
|
850
|
+
LightModeIcon,
|
|
851
|
+
{
|
|
852
|
+
sx: {
|
|
853
|
+
display: "none",
|
|
854
|
+
[theme.getColorSchemeSelector("dark")]: {
|
|
855
|
+
display: "inline"
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
] }) : /* @__PURE__ */ jsx11(React11.Fragment, { children: isSsr || paletteMode !== "dark" ? /* @__PURE__ */ jsx11(DarkModeIcon, {}) : /* @__PURE__ */ jsx11(LightModeIcon, {}) })
|
|
861
|
+
}
|
|
862
|
+
) })
|
|
863
|
+
}
|
|
864
|
+
) : null;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// src/toolpad-core/DashboardLayout/ToolbarActions.tsx
|
|
868
|
+
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
869
|
+
function ToolbarActions() {
|
|
870
|
+
return /* @__PURE__ */ jsxs7(Stack5, { direction: "row", alignItems: "center", children: [
|
|
871
|
+
/* @__PURE__ */ jsx12(ThemeSwitcher, {}),
|
|
872
|
+
/* @__PURE__ */ jsx12(Account, {})
|
|
873
|
+
] });
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// src/toolpad-core/DashboardLayout/DashboardHeader.tsx
|
|
877
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
878
|
+
var AppBar = styled2(MuiAppBar)(({ theme }) => {
|
|
879
|
+
var _a;
|
|
880
|
+
return {
|
|
881
|
+
borderWidth: 0,
|
|
882
|
+
borderBottomWidth: 1,
|
|
883
|
+
borderStyle: "solid",
|
|
884
|
+
borderColor: ((_a = theme.vars) != null ? _a : theme).palette.divider,
|
|
885
|
+
boxShadow: "none",
|
|
886
|
+
zIndex: theme.zIndex.drawer + 1
|
|
887
|
+
};
|
|
888
|
+
});
|
|
889
|
+
function DashboardHeader(props) {
|
|
890
|
+
var _a, _b;
|
|
891
|
+
const {
|
|
892
|
+
branding: brandingProp,
|
|
893
|
+
menuOpen,
|
|
894
|
+
onToggleMenu,
|
|
895
|
+
hideMenuButton,
|
|
896
|
+
slots,
|
|
897
|
+
slotProps
|
|
898
|
+
} = props;
|
|
899
|
+
const brandingContext = React12.useContext(BrandingContext);
|
|
900
|
+
const branding = __spreadValues(__spreadValues({}, brandingContext), brandingProp);
|
|
901
|
+
const handleMenuOpen = React12.useCallback(() => {
|
|
902
|
+
onToggleMenu(!menuOpen);
|
|
903
|
+
}, [menuOpen, onToggleMenu]);
|
|
904
|
+
const getMenuIcon = React12.useCallback(
|
|
905
|
+
(isExpanded) => {
|
|
906
|
+
const expandMenuActionText = "Expand";
|
|
907
|
+
const collapseMenuActionText = "Collapse";
|
|
908
|
+
return /* @__PURE__ */ jsx13(
|
|
909
|
+
Tooltip3,
|
|
910
|
+
{
|
|
911
|
+
title: `${isExpanded ? collapseMenuActionText : expandMenuActionText} menu`,
|
|
912
|
+
enterDelay: 1e3,
|
|
913
|
+
children: /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13(
|
|
914
|
+
IconButton3,
|
|
915
|
+
{
|
|
916
|
+
"aria-label": `${isExpanded ? collapseMenuActionText : expandMenuActionText} navigation menu`,
|
|
917
|
+
onClick: handleMenuOpen,
|
|
918
|
+
children: isExpanded ? /* @__PURE__ */ jsx13(MenuOpenIcon, {}) : /* @__PURE__ */ jsx13(MenuIcon, {})
|
|
919
|
+
}
|
|
920
|
+
) })
|
|
921
|
+
}
|
|
922
|
+
);
|
|
923
|
+
},
|
|
924
|
+
[handleMenuOpen]
|
|
925
|
+
);
|
|
926
|
+
const ToolbarActionsSlot = (_a = slots == null ? void 0 : slots.toolbarActions) != null ? _a : ToolbarActions;
|
|
927
|
+
const ToolbarAccountSlot = (_b = slots == null ? void 0 : slots.toolbarAccount) != null ? _b : (() => null);
|
|
928
|
+
return /* @__PURE__ */ jsx13(AppBar, { color: "inherit", position: "absolute", sx: { displayPrint: "none" }, children: /* @__PURE__ */ jsx13(Toolbar, { sx: { backgroundColor: "inherit", mx: { xs: -0.75, sm: -1 } }, children: /* @__PURE__ */ jsxs8(
|
|
929
|
+
Stack6,
|
|
930
|
+
{
|
|
931
|
+
direction: "row",
|
|
932
|
+
justifyContent: "space-between",
|
|
933
|
+
alignItems: "center",
|
|
934
|
+
sx: {
|
|
935
|
+
flexWrap: "wrap",
|
|
936
|
+
width: "100%"
|
|
937
|
+
},
|
|
938
|
+
children: [
|
|
939
|
+
/* @__PURE__ */ jsxs8(Stack6, { direction: "row", children: [
|
|
940
|
+
!hideMenuButton ? /* @__PURE__ */ jsxs8(React12.Fragment, { children: [
|
|
941
|
+
/* @__PURE__ */ jsx13(
|
|
942
|
+
Box2,
|
|
943
|
+
{
|
|
944
|
+
sx: {
|
|
945
|
+
display: { xs: "block", md: "none" },
|
|
946
|
+
mr: { sm: 1 }
|
|
947
|
+
},
|
|
948
|
+
children: getMenuIcon(menuOpen)
|
|
949
|
+
}
|
|
950
|
+
),
|
|
951
|
+
/* @__PURE__ */ jsx13(
|
|
952
|
+
Box2,
|
|
953
|
+
{
|
|
954
|
+
sx: {
|
|
955
|
+
display: { xs: "none", md: "block" },
|
|
956
|
+
mr: 1
|
|
957
|
+
},
|
|
958
|
+
children: getMenuIcon(menuOpen)
|
|
959
|
+
}
|
|
960
|
+
)
|
|
961
|
+
] }) : null,
|
|
962
|
+
(slots == null ? void 0 : slots.appTitle) ? /* @__PURE__ */ jsx13(slots.appTitle, __spreadValues({}, slotProps == null ? void 0 : slotProps.appTitle)) : (
|
|
963
|
+
/* Hierarchy of application of `branding`
|
|
964
|
+
* 1. Branding prop passed in the `slotProps.appTitle`
|
|
965
|
+
* 2. Branding prop passed to the `DashboardLayout`
|
|
966
|
+
* 3. Branding prop passed to the `AppProvider`
|
|
967
|
+
*/
|
|
968
|
+
/* @__PURE__ */ jsx13(AppTitle, __spreadValues({ branding }, slotProps == null ? void 0 : slotProps.appTitle))
|
|
969
|
+
)
|
|
970
|
+
] }),
|
|
971
|
+
/* @__PURE__ */ jsxs8(Stack6, { direction: "row", alignItems: "center", spacing: 1, sx: { marginLeft: "auto" }, children: [
|
|
972
|
+
/* @__PURE__ */ jsx13(ToolbarActionsSlot, __spreadValues({}, slotProps == null ? void 0 : slotProps.toolbarActions)),
|
|
973
|
+
/* @__PURE__ */ jsx13(ToolbarAccountSlot, __spreadValues({}, slotProps == null ? void 0 : slotProps.toolbarAccount))
|
|
974
|
+
] })
|
|
975
|
+
]
|
|
976
|
+
}
|
|
977
|
+
) }) });
|
|
978
|
+
}
|
|
979
|
+
DashboardHeader.propTypes = {
|
|
980
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
981
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
982
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
983
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
984
|
+
/**
|
|
985
|
+
* Branding options for the header.
|
|
986
|
+
* @default null
|
|
987
|
+
*/
|
|
988
|
+
branding: PropTypes7.shape({
|
|
989
|
+
homeUrl: PropTypes7.string,
|
|
990
|
+
logo: PropTypes7.node,
|
|
991
|
+
title: PropTypes7.string
|
|
992
|
+
}),
|
|
993
|
+
/**
|
|
994
|
+
* Whether the menu icon should always be hidden.
|
|
995
|
+
* @default false
|
|
996
|
+
*/
|
|
997
|
+
hideMenuButton: PropTypes7.bool,
|
|
998
|
+
/**
|
|
999
|
+
* If `true`, show menu button as if menu is expanded, otherwise show it as if menu is collapsed.
|
|
1000
|
+
*/
|
|
1001
|
+
menuOpen: PropTypes7.bool.isRequired,
|
|
1002
|
+
/**
|
|
1003
|
+
* Callback fired when the menu button is clicked.
|
|
1004
|
+
*/
|
|
1005
|
+
onToggleMenu: PropTypes7.func.isRequired,
|
|
1006
|
+
/**
|
|
1007
|
+
* The props used for each slot inside.
|
|
1008
|
+
* @default {}
|
|
1009
|
+
*/
|
|
1010
|
+
slotProps: PropTypes7.shape({
|
|
1011
|
+
appTitle: PropTypes7.shape({
|
|
1012
|
+
branding: PropTypes7.shape({
|
|
1013
|
+
homeUrl: PropTypes7.string,
|
|
1014
|
+
logo: PropTypes7.node,
|
|
1015
|
+
title: PropTypes7.string
|
|
1016
|
+
})
|
|
1017
|
+
}),
|
|
1018
|
+
toolbarAccount: PropTypes7.shape({
|
|
1019
|
+
localeText: PropTypes7.object,
|
|
1020
|
+
slotProps: PropTypes7.shape({
|
|
1021
|
+
popover: PropTypes7.object,
|
|
1022
|
+
popoverContent: PropTypes7.object,
|
|
1023
|
+
preview: PropTypes7.object,
|
|
1024
|
+
signInButton: PropTypes7.object,
|
|
1025
|
+
signOutButton: PropTypes7.object
|
|
1026
|
+
}),
|
|
1027
|
+
slots: PropTypes7.shape({
|
|
1028
|
+
popover: PropTypes7.elementType,
|
|
1029
|
+
popoverContent: PropTypes7.elementType,
|
|
1030
|
+
preview: PropTypes7.elementType,
|
|
1031
|
+
signInButton: PropTypes7.elementType,
|
|
1032
|
+
signOutButton: PropTypes7.elementType
|
|
1033
|
+
})
|
|
1034
|
+
}),
|
|
1035
|
+
toolbarActions: PropTypes7.object
|
|
1036
|
+
}),
|
|
1037
|
+
/**
|
|
1038
|
+
* The components used for each slot inside.
|
|
1039
|
+
* @default {}
|
|
1040
|
+
*/
|
|
1041
|
+
slots: PropTypes7.shape({
|
|
1042
|
+
appTitle: PropTypes7.elementType,
|
|
1043
|
+
toolbarAccount: PropTypes7.elementType,
|
|
1044
|
+
toolbarActions: PropTypes7.elementType
|
|
1045
|
+
})
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// src/toolpad-core/DashboardLayout/DashboardSidebarSubNavigation.tsx
|
|
1049
|
+
import * as React15 from "react";
|
|
1050
|
+
import Divider2 from "@mui/material/Divider";
|
|
1051
|
+
import List from "@mui/material/List";
|
|
1052
|
+
import ListSubheader from "@mui/material/ListSubheader";
|
|
1053
|
+
|
|
1054
|
+
// src/toolpad-core/shared/navigation.tsx
|
|
1055
|
+
import { pathToRegexp } from "path-to-regexp";
|
|
1056
|
+
import invariant2 from "invariant";
|
|
1057
|
+
var getItemKind = (item) => {
|
|
1058
|
+
var _a;
|
|
1059
|
+
return (_a = item.kind) != null ? _a : "page";
|
|
1060
|
+
};
|
|
1061
|
+
var isPageItem = (item) => getItemKind(item) === "page";
|
|
1062
|
+
var getItemTitle = (item) => {
|
|
1063
|
+
var _a, _b;
|
|
1064
|
+
return isPageItem(item) ? (_b = (_a = item.title) != null ? _a : item.segment) != null ? _b : "" : item.title;
|
|
1065
|
+
};
|
|
1066
|
+
function buildItemToPathMap(navigation) {
|
|
1067
|
+
const map = /* @__PURE__ */ new Map();
|
|
1068
|
+
const visit = (item, base) => {
|
|
1069
|
+
if (isPageItem(item)) {
|
|
1070
|
+
const path = `${base.startsWith("/") ? base : `/${base}`}${base && base !== "/" && item.segment ? "/" : ""}${item.segment || ""}` || "/";
|
|
1071
|
+
map.set(item, path);
|
|
1072
|
+
if (item.children) {
|
|
1073
|
+
for (const child of item.children) {
|
|
1074
|
+
visit(child, path);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
for (const item of navigation) {
|
|
1080
|
+
visit(item, "");
|
|
1081
|
+
}
|
|
1082
|
+
return map;
|
|
1083
|
+
}
|
|
1084
|
+
var itemToPathMapCache = /* @__PURE__ */ new WeakMap();
|
|
1085
|
+
function getItemToPathMap(navigation) {
|
|
1086
|
+
let map = itemToPathMapCache.get(navigation);
|
|
1087
|
+
if (!map) {
|
|
1088
|
+
map = buildItemToPathMap(navigation);
|
|
1089
|
+
itemToPathMapCache.set(navigation, map);
|
|
1090
|
+
}
|
|
1091
|
+
return map;
|
|
1092
|
+
}
|
|
1093
|
+
function buildItemLookup(navigation) {
|
|
1094
|
+
const map = /* @__PURE__ */ new Map();
|
|
1095
|
+
const visit = (item) => {
|
|
1096
|
+
if (isPageItem(item)) {
|
|
1097
|
+
const path = getItemPath(navigation, item);
|
|
1098
|
+
if (map.has(path)) {
|
|
1099
|
+
console.warn(`Duplicate path in navigation: ${path}`);
|
|
1100
|
+
}
|
|
1101
|
+
map.set(path, item);
|
|
1102
|
+
if (item.pattern) {
|
|
1103
|
+
const basePath = item.segment ? path.slice(0, -item.segment.length) : path;
|
|
1104
|
+
map.set(pathToRegexp(basePath + item.pattern).regexp, item);
|
|
1105
|
+
}
|
|
1106
|
+
if (item.children) {
|
|
1107
|
+
for (const child of item.children) {
|
|
1108
|
+
visit(child);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
for (const item of navigation) {
|
|
1114
|
+
visit(item);
|
|
1115
|
+
}
|
|
1116
|
+
return map;
|
|
1117
|
+
}
|
|
1118
|
+
var itemLookupMapCache = /* @__PURE__ */ new WeakMap();
|
|
1119
|
+
function getItemLookup(navigation) {
|
|
1120
|
+
let map = itemLookupMapCache.get(navigation);
|
|
1121
|
+
if (!map) {
|
|
1122
|
+
map = buildItemLookup(navigation);
|
|
1123
|
+
itemLookupMapCache.set(navigation, map);
|
|
1124
|
+
}
|
|
1125
|
+
return map;
|
|
1126
|
+
}
|
|
1127
|
+
function matchPath(navigation, path) {
|
|
1128
|
+
const lookup = getItemLookup(navigation);
|
|
1129
|
+
for (const [key, item] of lookup.entries()) {
|
|
1130
|
+
if (typeof key === "string" && key === path) {
|
|
1131
|
+
return item;
|
|
1132
|
+
}
|
|
1133
|
+
if (key instanceof RegExp && key.test(path)) {
|
|
1134
|
+
return item;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return null;
|
|
1138
|
+
}
|
|
1139
|
+
function getItemPath(navigation, item) {
|
|
1140
|
+
const map = getItemToPathMap(navigation);
|
|
1141
|
+
const path = map.get(item);
|
|
1142
|
+
invariant2(path, `Item not found in navigation: ${item.title}`);
|
|
1143
|
+
return path;
|
|
1144
|
+
}
|
|
1145
|
+
function hasSelectedNavigationChildren(navigation, item, activePagePath) {
|
|
1146
|
+
if (item.children) {
|
|
1147
|
+
return item.children.some((nestedItem) => {
|
|
1148
|
+
if (!isPageItem(nestedItem)) {
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
if (nestedItem.children) {
|
|
1152
|
+
return hasSelectedNavigationChildren(navigation, nestedItem, activePagePath);
|
|
1153
|
+
}
|
|
1154
|
+
return activePagePath === getItemPath(navigation, nestedItem);
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
return false;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
// src/toolpad-core/DashboardLayout/utils.ts
|
|
1161
|
+
function getDrawerSxTransitionMixin(isExpanded, property) {
|
|
1162
|
+
return {
|
|
1163
|
+
transition: (theme) => theme.transitions.create(property, {
|
|
1164
|
+
easing: theme.transitions.easing.sharp,
|
|
1165
|
+
duration: isExpanded ? theme.transitions.duration.enteringScreen : theme.transitions.duration.leavingScreen
|
|
1166
|
+
})
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
function getDrawerWidthTransitionMixin(isExpanded) {
|
|
1170
|
+
return __spreadProps(__spreadValues({}, getDrawerSxTransitionMixin(isExpanded, "width")), {
|
|
1171
|
+
overflowX: "hidden"
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// src/toolpad-core/useActivePage/useActivePage.ts
|
|
1176
|
+
import * as React13 from "react";
|
|
1177
|
+
function useActivePage() {
|
|
1178
|
+
var _a;
|
|
1179
|
+
const navigationContext = React13.useContext(NavigationContext);
|
|
1180
|
+
const routerContext = React13.useContext(RouterContext);
|
|
1181
|
+
const pathname = (_a = routerContext == null ? void 0 : routerContext.pathname) != null ? _a : "/";
|
|
1182
|
+
const activeItem = matchPath(navigationContext, pathname);
|
|
1183
|
+
const rootItem = matchPath(navigationContext, "/");
|
|
1184
|
+
return React13.useMemo(() => {
|
|
1185
|
+
if (!activeItem) {
|
|
1186
|
+
return null;
|
|
1187
|
+
}
|
|
1188
|
+
const breadcrumbs = [];
|
|
1189
|
+
if (rootItem) {
|
|
1190
|
+
breadcrumbs.push({
|
|
1191
|
+
title: getItemTitle(rootItem),
|
|
1192
|
+
path: "/"
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
1196
|
+
let prefix = "";
|
|
1197
|
+
for (const segment of segments) {
|
|
1198
|
+
const path = `${prefix}/${segment}`;
|
|
1199
|
+
prefix = path;
|
|
1200
|
+
const item = matchPath(navigationContext, path);
|
|
1201
|
+
if (!item) {
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1204
|
+
const itemPath = getItemPath(navigationContext, item);
|
|
1205
|
+
const lastCrumb = breadcrumbs[breadcrumbs.length - 1];
|
|
1206
|
+
if ((lastCrumb == null ? void 0 : lastCrumb.path) !== itemPath) {
|
|
1207
|
+
breadcrumbs.push({
|
|
1208
|
+
title: getItemTitle(item),
|
|
1209
|
+
path: itemPath
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
return {
|
|
1214
|
+
title: getItemTitle(activeItem),
|
|
1215
|
+
path: getItemPath(navigationContext, activeItem),
|
|
1216
|
+
breadcrumbs
|
|
1217
|
+
};
|
|
1218
|
+
}, [activeItem, rootItem, pathname, navigationContext]);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// src/toolpad-core/DashboardLayout/DashboardSidebarPageItem.tsx
|
|
1222
|
+
import * as React14 from "react";
|
|
1223
|
+
import PropTypes8 from "prop-types";
|
|
1224
|
+
import { styled as styled3 } from "@mui/material";
|
|
1225
|
+
import Avatar2 from "@mui/material/Avatar";
|
|
1226
|
+
import Box3 from "@mui/material/Box";
|
|
1227
|
+
import Collapse from "@mui/material/Collapse";
|
|
1228
|
+
import Grow from "@mui/material/Grow";
|
|
1229
|
+
import ListItem from "@mui/material/ListItem";
|
|
1230
|
+
import ListItemButton from "@mui/material/ListItemButton";
|
|
1231
|
+
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
1232
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
1233
|
+
import Paper from "@mui/material/Paper";
|
|
1234
|
+
import Typography3 from "@mui/material/Typography";
|
|
1235
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
1236
|
+
import invariant3 from "invariant";
|
|
1237
|
+
|
|
1238
|
+
// src/toolpad-core/DashboardLayout/shared.ts
|
|
1239
|
+
var MINI_DRAWER_WIDTH = 84;
|
|
1240
|
+
|
|
1241
|
+
// src/toolpad-core/DashboardLayout/DashboardSidebarPageItem.tsx
|
|
1242
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1243
|
+
var NavigationListItemButton = styled3(ListItemButton)(({ theme }) => {
|
|
1244
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1245
|
+
return {
|
|
1246
|
+
borderRadius: 8,
|
|
1247
|
+
"&.Mui-selected": {
|
|
1248
|
+
"& .MuiListItemIcon-root": {
|
|
1249
|
+
color: ((_a = theme.vars) != null ? _a : theme).palette.primary.dark
|
|
1250
|
+
},
|
|
1251
|
+
"& .MuiTypography-root": {
|
|
1252
|
+
color: ((_b = theme.vars) != null ? _b : theme).palette.primary.dark
|
|
1253
|
+
},
|
|
1254
|
+
"& .MuiSvgIcon-root": {
|
|
1255
|
+
color: ((_c = theme.vars) != null ? _c : theme).palette.primary.dark
|
|
1256
|
+
},
|
|
1257
|
+
"& .MuiAvatar-root": {
|
|
1258
|
+
backgroundColor: ((_d = theme.vars) != null ? _d : theme).palette.primary.dark
|
|
1259
|
+
},
|
|
1260
|
+
"& .MuiTouchRipple-child": {
|
|
1261
|
+
backgroundColor: ((_e = theme.vars) != null ? _e : theme).palette.primary.dark
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
"& .MuiSvgIcon-root": {
|
|
1265
|
+
color: ((_f = theme.vars) != null ? _f : theme).palette.action.active
|
|
1266
|
+
},
|
|
1267
|
+
"& .MuiAvatar-root": {
|
|
1268
|
+
backgroundColor: ((_g = theme.vars) != null ? _g : theme).palette.action.active
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
});
|
|
1272
|
+
var LIST_ITEM_ICON_SIZE = 34;
|
|
1273
|
+
function DashboardSidebarPageItem(props) {
|
|
1274
|
+
var _a;
|
|
1275
|
+
const navigationContext = React14.useContext(NavigationContext);
|
|
1276
|
+
const pageItemContextProps = React14.useContext(DashboardSidebarPageItemContext);
|
|
1277
|
+
invariant3(pageItemContextProps, "No navigation page item context provided.");
|
|
1278
|
+
const contextAwareProps = __spreadValues(__spreadValues({}, pageItemContextProps), props);
|
|
1279
|
+
const {
|
|
1280
|
+
item,
|
|
1281
|
+
href = getItemPath(navigationContext, item),
|
|
1282
|
+
LinkComponent: LinkComponentProp,
|
|
1283
|
+
expanded = false,
|
|
1284
|
+
selected = false,
|
|
1285
|
+
disabled = false,
|
|
1286
|
+
id,
|
|
1287
|
+
onClick,
|
|
1288
|
+
isMini = false,
|
|
1289
|
+
isSidebarFullyExpanded = true,
|
|
1290
|
+
isSidebarFullyCollapsed = false,
|
|
1291
|
+
renderNestedNavigation
|
|
1292
|
+
} = contextAwareProps;
|
|
1293
|
+
const [hoveredMiniSidebarItemId, setHoveredMiniSidebarItemId] = React14.useState(
|
|
1294
|
+
null
|
|
1295
|
+
);
|
|
1296
|
+
const handleClick = React14.useCallback(() => {
|
|
1297
|
+
onClick(id, item);
|
|
1298
|
+
}, [id, item, onClick]);
|
|
1299
|
+
let nestedNavigationCollapseSx = { display: "none" };
|
|
1300
|
+
if (isMini && isSidebarFullyCollapsed) {
|
|
1301
|
+
nestedNavigationCollapseSx = {
|
|
1302
|
+
fontSize: 18,
|
|
1303
|
+
position: "absolute",
|
|
1304
|
+
top: "41.5%",
|
|
1305
|
+
right: "2px",
|
|
1306
|
+
transform: "translateY(-50%) rotate(-90deg)"
|
|
1307
|
+
};
|
|
1308
|
+
} else if (!isMini && isSidebarFullyExpanded) {
|
|
1309
|
+
nestedNavigationCollapseSx = {
|
|
1310
|
+
ml: 0.5,
|
|
1311
|
+
transform: `rotate(${expanded ? 0 : -90}deg)`,
|
|
1312
|
+
transition: (theme) => theme.transitions.create("transform", {
|
|
1313
|
+
easing: theme.transitions.easing.sharp,
|
|
1314
|
+
duration: 100
|
|
1315
|
+
})
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
const hasExternalHref = href.startsWith("http://") || href.startsWith("https://");
|
|
1319
|
+
const LinkComponent = LinkComponentProp != null ? LinkComponentProp : hasExternalHref ? "a" : Link2;
|
|
1320
|
+
const title = getItemTitle(item);
|
|
1321
|
+
const listItem = /* @__PURE__ */ jsxs9(
|
|
1322
|
+
ListItem,
|
|
1323
|
+
__spreadProps(__spreadValues({}, item.children && isMini ? {
|
|
1324
|
+
onMouseEnter: () => {
|
|
1325
|
+
setHoveredMiniSidebarItemId(id);
|
|
1326
|
+
},
|
|
1327
|
+
onMouseLeave: () => {
|
|
1328
|
+
setHoveredMiniSidebarItemId(null);
|
|
1329
|
+
}
|
|
1330
|
+
} : {}), {
|
|
1331
|
+
sx: {
|
|
1332
|
+
py: 0,
|
|
1333
|
+
px: 1,
|
|
1334
|
+
overflowX: "hidden"
|
|
1335
|
+
},
|
|
1336
|
+
children: [
|
|
1337
|
+
/* @__PURE__ */ jsxs9(
|
|
1338
|
+
NavigationListItemButton,
|
|
1339
|
+
__spreadProps(__spreadValues(__spreadValues({
|
|
1340
|
+
selected,
|
|
1341
|
+
disabled,
|
|
1342
|
+
sx: {
|
|
1343
|
+
px: 1.4,
|
|
1344
|
+
height: isMini ? 60 : 48
|
|
1345
|
+
}
|
|
1346
|
+
}, item.children && !isMini ? {
|
|
1347
|
+
onClick: handleClick
|
|
1348
|
+
} : {}), !item.children ? __spreadProps(__spreadValues({
|
|
1349
|
+
LinkComponent
|
|
1350
|
+
}, hasExternalHref ? {
|
|
1351
|
+
target: "_blank",
|
|
1352
|
+
rel: "noopener noreferrer"
|
|
1353
|
+
} : {}), {
|
|
1354
|
+
href,
|
|
1355
|
+
onClick: handleClick
|
|
1356
|
+
}) : {}), {
|
|
1357
|
+
children: [
|
|
1358
|
+
item.icon || isMini ? /* @__PURE__ */ jsxs9(
|
|
1359
|
+
Box3,
|
|
1360
|
+
{
|
|
1361
|
+
sx: isMini ? {
|
|
1362
|
+
position: "absolute",
|
|
1363
|
+
left: "50%",
|
|
1364
|
+
top: "calc(50% - 6px)",
|
|
1365
|
+
transform: "translate(-50%, -50%)"
|
|
1366
|
+
} : {},
|
|
1367
|
+
children: [
|
|
1368
|
+
/* @__PURE__ */ jsxs9(
|
|
1369
|
+
ListItemIcon,
|
|
1370
|
+
{
|
|
1371
|
+
sx: {
|
|
1372
|
+
display: "flex",
|
|
1373
|
+
alignItems: "center",
|
|
1374
|
+
justifyContent: "center",
|
|
1375
|
+
minWidth: LIST_ITEM_ICON_SIZE
|
|
1376
|
+
},
|
|
1377
|
+
children: [
|
|
1378
|
+
(_a = item.icon) != null ? _a : null,
|
|
1379
|
+
!item.icon && isMini ? /* @__PURE__ */ jsx14(
|
|
1380
|
+
Avatar2,
|
|
1381
|
+
{
|
|
1382
|
+
sx: {
|
|
1383
|
+
width: LIST_ITEM_ICON_SIZE - 7,
|
|
1384
|
+
height: LIST_ITEM_ICON_SIZE - 7,
|
|
1385
|
+
fontSize: 12
|
|
1386
|
+
},
|
|
1387
|
+
children: title.split(" ").slice(0, 2).map((titleWord) => titleWord.charAt(0).toUpperCase())
|
|
1388
|
+
}
|
|
1389
|
+
) : null
|
|
1390
|
+
]
|
|
1391
|
+
}
|
|
1392
|
+
),
|
|
1393
|
+
isMini ? /* @__PURE__ */ jsx14(
|
|
1394
|
+
Typography3,
|
|
1395
|
+
{
|
|
1396
|
+
variant: "caption",
|
|
1397
|
+
sx: {
|
|
1398
|
+
position: "absolute",
|
|
1399
|
+
bottom: -18,
|
|
1400
|
+
left: "50%",
|
|
1401
|
+
transform: "translateX(-50%)",
|
|
1402
|
+
fontSize: 10,
|
|
1403
|
+
fontWeight: 500,
|
|
1404
|
+
textAlign: "center",
|
|
1405
|
+
whiteSpace: "nowrap",
|
|
1406
|
+
overflow: "hidden",
|
|
1407
|
+
textOverflow: "ellipsis",
|
|
1408
|
+
maxWidth: MINI_DRAWER_WIDTH - 28
|
|
1409
|
+
},
|
|
1410
|
+
children: title
|
|
1411
|
+
}
|
|
1412
|
+
) : null
|
|
1413
|
+
]
|
|
1414
|
+
}
|
|
1415
|
+
) : null,
|
|
1416
|
+
!isMini ? /* @__PURE__ */ jsx14(
|
|
1417
|
+
ListItemText,
|
|
1418
|
+
{
|
|
1419
|
+
primary: title,
|
|
1420
|
+
sx: {
|
|
1421
|
+
ml: 1.2,
|
|
1422
|
+
whiteSpace: "nowrap",
|
|
1423
|
+
zIndex: 1
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
) : null,
|
|
1427
|
+
item.action && !isMini && isSidebarFullyExpanded ? item.action : null,
|
|
1428
|
+
item.children ? /* @__PURE__ */ jsx14(ExpandMoreIcon, { sx: nestedNavigationCollapseSx }) : null
|
|
1429
|
+
]
|
|
1430
|
+
})
|
|
1431
|
+
),
|
|
1432
|
+
item.children && isMini ? /* @__PURE__ */ jsx14(Grow, { in: id === hoveredMiniSidebarItemId, children: /* @__PURE__ */ jsx14(
|
|
1433
|
+
Box3,
|
|
1434
|
+
{
|
|
1435
|
+
sx: {
|
|
1436
|
+
position: "fixed",
|
|
1437
|
+
left: MINI_DRAWER_WIDTH - 2,
|
|
1438
|
+
pl: "6px"
|
|
1439
|
+
},
|
|
1440
|
+
children: /* @__PURE__ */ jsx14(
|
|
1441
|
+
Paper,
|
|
1442
|
+
{
|
|
1443
|
+
sx: {
|
|
1444
|
+
pt: 0.5,
|
|
1445
|
+
pb: 0.5,
|
|
1446
|
+
transform: "translateY(calc(50% - 30px))"
|
|
1447
|
+
},
|
|
1448
|
+
children: renderNestedNavigation(item.children)
|
|
1449
|
+
}
|
|
1450
|
+
)
|
|
1451
|
+
}
|
|
1452
|
+
) }) : null
|
|
1453
|
+
]
|
|
1454
|
+
})
|
|
1455
|
+
);
|
|
1456
|
+
return /* @__PURE__ */ jsxs9(React14.Fragment, { children: [
|
|
1457
|
+
listItem,
|
|
1458
|
+
item.children && !isMini ? /* @__PURE__ */ jsx14(Collapse, { in: expanded, timeout: "auto", unmountOnExit: true, children: renderNestedNavigation(item.children) }) : null
|
|
1459
|
+
] }, id);
|
|
1460
|
+
}
|
|
1461
|
+
DashboardSidebarPageItem.propTypes = {
|
|
1462
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
1463
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
1464
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
1465
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
1466
|
+
/**
|
|
1467
|
+
* If `true`, the item is disabled.
|
|
1468
|
+
* @default false
|
|
1469
|
+
*/
|
|
1470
|
+
disabled: PropTypes8.bool,
|
|
1471
|
+
/**
|
|
1472
|
+
* If `true`, expands any nested navigation in the item, otherwise collapse it.
|
|
1473
|
+
* @default false
|
|
1474
|
+
*/
|
|
1475
|
+
expanded: PropTypes8.bool,
|
|
1476
|
+
/**
|
|
1477
|
+
* Link `href` for when the item is rendered as a link.
|
|
1478
|
+
* @default getItemPath(navigationContext, item)
|
|
1479
|
+
*/
|
|
1480
|
+
href: PropTypes8.string,
|
|
1481
|
+
/**
|
|
1482
|
+
* Navigation page item definition.
|
|
1483
|
+
*/
|
|
1484
|
+
item: PropTypes8.shape({
|
|
1485
|
+
action: PropTypes8.node,
|
|
1486
|
+
children: PropTypes8.arrayOf(
|
|
1487
|
+
PropTypes8.oneOfType([
|
|
1488
|
+
PropTypes8.object,
|
|
1489
|
+
PropTypes8.shape({
|
|
1490
|
+
kind: PropTypes8.oneOf(["header"]).isRequired,
|
|
1491
|
+
title: PropTypes8.string.isRequired
|
|
1492
|
+
}),
|
|
1493
|
+
PropTypes8.shape({
|
|
1494
|
+
kind: PropTypes8.oneOf(["divider"]).isRequired
|
|
1495
|
+
})
|
|
1496
|
+
]).isRequired
|
|
1497
|
+
),
|
|
1498
|
+
icon: PropTypes8.node,
|
|
1499
|
+
kind: PropTypes8.oneOf(["page"]),
|
|
1500
|
+
pattern: PropTypes8.string,
|
|
1501
|
+
segment: PropTypes8.string,
|
|
1502
|
+
title: PropTypes8.string
|
|
1503
|
+
}).isRequired,
|
|
1504
|
+
/**
|
|
1505
|
+
* The component used to render the item as a link.
|
|
1506
|
+
* @default Link
|
|
1507
|
+
*/
|
|
1508
|
+
LinkComponent: PropTypes8.elementType,
|
|
1509
|
+
/**
|
|
1510
|
+
* Use to apply selected styling.
|
|
1511
|
+
* @default false
|
|
1512
|
+
*/
|
|
1513
|
+
selected: PropTypes8.bool
|
|
1514
|
+
};
|
|
1515
|
+
|
|
1516
|
+
// src/toolpad-core/DashboardLayout/DashboardSidebarSubNavigation.tsx
|
|
1517
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1518
|
+
function DashboardSidebarSubNavigationPageItem({
|
|
1519
|
+
id,
|
|
1520
|
+
item,
|
|
1521
|
+
isExpanded,
|
|
1522
|
+
onClick,
|
|
1523
|
+
depth,
|
|
1524
|
+
onLinkClick,
|
|
1525
|
+
isMini,
|
|
1526
|
+
isFullyExpanded,
|
|
1527
|
+
isFullyCollapsed,
|
|
1528
|
+
sidebarExpandedWidth,
|
|
1529
|
+
renderPageItem
|
|
1530
|
+
}) {
|
|
1531
|
+
const navigationContext = React15.useContext(NavigationContext);
|
|
1532
|
+
const activePage = useActivePage();
|
|
1533
|
+
const isActive = !!activePage && activePage.path === getItemPath(navigationContext, item);
|
|
1534
|
+
const isSelected = activePage && item.children && isMini ? hasSelectedNavigationChildren(navigationContext, item, activePage.path) : isActive && !item.children;
|
|
1535
|
+
const pageItemContextProps = React15.useMemo(
|
|
1536
|
+
() => ({
|
|
1537
|
+
expanded: isExpanded,
|
|
1538
|
+
selected: isSelected,
|
|
1539
|
+
id,
|
|
1540
|
+
onClick,
|
|
1541
|
+
isMini,
|
|
1542
|
+
isSidebarFullyExpanded: isFullyExpanded,
|
|
1543
|
+
isSidebarFullyCollapsed: isFullyCollapsed,
|
|
1544
|
+
renderNestedNavigation: () => {
|
|
1545
|
+
var _a;
|
|
1546
|
+
return /* @__PURE__ */ jsx15(
|
|
1547
|
+
DashboardSidebarSubNavigation,
|
|
1548
|
+
{
|
|
1549
|
+
subNavigation: (_a = item.children) != null ? _a : [],
|
|
1550
|
+
depth: depth + 1,
|
|
1551
|
+
onLinkClick,
|
|
1552
|
+
isPopover: isMini,
|
|
1553
|
+
sidebarExpandedWidth
|
|
1554
|
+
}
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
}),
|
|
1558
|
+
[
|
|
1559
|
+
depth,
|
|
1560
|
+
id,
|
|
1561
|
+
isExpanded,
|
|
1562
|
+
isFullyCollapsed,
|
|
1563
|
+
isFullyExpanded,
|
|
1564
|
+
isMini,
|
|
1565
|
+
isSelected,
|
|
1566
|
+
item.children,
|
|
1567
|
+
onClick,
|
|
1568
|
+
onLinkClick,
|
|
1569
|
+
sidebarExpandedWidth
|
|
1570
|
+
]
|
|
1571
|
+
);
|
|
1572
|
+
return /* @__PURE__ */ jsx15(DashboardSidebarPageItemContext.Provider, { value: pageItemContextProps, children: renderPageItem ? renderPageItem(item, { mini: isMini }) : /* @__PURE__ */ jsx15(DashboardSidebarPageItem, { item }) });
|
|
1573
|
+
}
|
|
1574
|
+
function DashboardSidebarSubNavigation({
|
|
1575
|
+
subNavigation,
|
|
1576
|
+
depth = 0,
|
|
1577
|
+
onLinkClick,
|
|
1578
|
+
isMini = false,
|
|
1579
|
+
isPopover = false,
|
|
1580
|
+
isFullyExpanded = true,
|
|
1581
|
+
isFullyCollapsed = false,
|
|
1582
|
+
hasDrawerTransitions = false,
|
|
1583
|
+
sidebarExpandedWidth,
|
|
1584
|
+
renderPageItem
|
|
1585
|
+
}) {
|
|
1586
|
+
const navigationContext = React15.useContext(NavigationContext);
|
|
1587
|
+
const activePage = useActivePage();
|
|
1588
|
+
const initialExpandedItemIds = React15.useMemo(
|
|
1589
|
+
() => subNavigation.map((navigationItem, navigationItemIndex) => ({
|
|
1590
|
+
navigationItem,
|
|
1591
|
+
originalIndex: navigationItemIndex
|
|
1592
|
+
})).filter(
|
|
1593
|
+
({ navigationItem }) => isPageItem(navigationItem) && !!activePage && hasSelectedNavigationChildren(navigationContext, navigationItem, activePage.path)
|
|
1594
|
+
).map(({ originalIndex }) => `page-${depth}-${originalIndex}`),
|
|
1595
|
+
[activePage, depth, navigationContext, subNavigation]
|
|
1596
|
+
);
|
|
1597
|
+
const [expandedItemIds, setExpandedItemIds] = React15.useState(initialExpandedItemIds);
|
|
1598
|
+
const handlePageItemClick = React15.useCallback(
|
|
1599
|
+
(itemId, item) => {
|
|
1600
|
+
if (item.children && !isMini) {
|
|
1601
|
+
setExpandedItemIds(
|
|
1602
|
+
(previousValue) => previousValue.includes(itemId) ? previousValue.filter((previousValueItemId) => previousValueItemId !== itemId) : [...previousValue, itemId]
|
|
1603
|
+
);
|
|
1604
|
+
} else if (!item.children) {
|
|
1605
|
+
onLinkClick();
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
[isMini, onLinkClick]
|
|
1609
|
+
);
|
|
1610
|
+
return /* @__PURE__ */ jsx15(
|
|
1611
|
+
List,
|
|
1612
|
+
{
|
|
1613
|
+
sx: {
|
|
1614
|
+
padding: 0,
|
|
1615
|
+
mt: isPopover && depth === 1 ? 0.5 : 0,
|
|
1616
|
+
mb: depth === 0 && !isPopover ? 4 : 0.5,
|
|
1617
|
+
pl: (isPopover ? 1 : 2) * (isPopover ? depth - 1 : depth),
|
|
1618
|
+
minWidth: isPopover && depth === 1 ? 240 : "auto",
|
|
1619
|
+
width: isMini ? MINI_DRAWER_WIDTH : "auto"
|
|
1620
|
+
},
|
|
1621
|
+
children: subNavigation.map((navigationItem, navigationItemIndex) => {
|
|
1622
|
+
if (navigationItem.kind === "header") {
|
|
1623
|
+
return /* @__PURE__ */ jsx15(
|
|
1624
|
+
ListSubheader,
|
|
1625
|
+
{
|
|
1626
|
+
sx: __spreadProps(__spreadValues({
|
|
1627
|
+
fontSize: 12,
|
|
1628
|
+
fontWeight: "700",
|
|
1629
|
+
height: isMini ? 0 : 40
|
|
1630
|
+
}, hasDrawerTransitions ? getDrawerSxTransitionMixin(isFullyExpanded, "height") : {}), {
|
|
1631
|
+
px: 2,
|
|
1632
|
+
minWidth: sidebarExpandedWidth,
|
|
1633
|
+
overflow: "hidden",
|
|
1634
|
+
textOverflow: "ellipsis",
|
|
1635
|
+
whiteSpace: "nowrap",
|
|
1636
|
+
zIndex: 2
|
|
1637
|
+
}),
|
|
1638
|
+
children: getItemTitle(navigationItem)
|
|
1639
|
+
},
|
|
1640
|
+
`subheader-${depth}-${navigationItemIndex}`
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
if (navigationItem.kind === "divider") {
|
|
1644
|
+
const nextItem = subNavigation[navigationItemIndex + 1];
|
|
1645
|
+
return /* @__PURE__ */ jsx15("li", { children: /* @__PURE__ */ jsx15(
|
|
1646
|
+
Divider2,
|
|
1647
|
+
{
|
|
1648
|
+
sx: __spreadValues({
|
|
1649
|
+
borderBottomWidth: 2,
|
|
1650
|
+
mx: 1,
|
|
1651
|
+
mt: 1,
|
|
1652
|
+
mb: (nextItem == null ? void 0 : nextItem.kind) === "header" && !isMini ? 0 : 1
|
|
1653
|
+
}, hasDrawerTransitions ? getDrawerSxTransitionMixin(isFullyExpanded, "margin") : {})
|
|
1654
|
+
}
|
|
1655
|
+
) }, `divider-${depth}-${navigationItemIndex}`);
|
|
1656
|
+
}
|
|
1657
|
+
const pageItemId = `page-${depth}-${navigationItemIndex}`;
|
|
1658
|
+
return /* @__PURE__ */ jsx15(
|
|
1659
|
+
DashboardSidebarSubNavigationPageItem,
|
|
1660
|
+
{
|
|
1661
|
+
id: pageItemId,
|
|
1662
|
+
item: navigationItem,
|
|
1663
|
+
isExpanded: expandedItemIds.includes(pageItemId),
|
|
1664
|
+
onClick: handlePageItemClick,
|
|
1665
|
+
depth,
|
|
1666
|
+
onLinkClick,
|
|
1667
|
+
isMini,
|
|
1668
|
+
isFullyExpanded,
|
|
1669
|
+
isFullyCollapsed,
|
|
1670
|
+
sidebarExpandedWidth,
|
|
1671
|
+
renderPageItem
|
|
1672
|
+
},
|
|
1673
|
+
pageItemId
|
|
1674
|
+
);
|
|
1675
|
+
})
|
|
1676
|
+
}
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
// src/toolpad-core/DashboardLayout/DashboardLayout.tsx
|
|
1681
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1682
|
+
function DashboardLayout(props) {
|
|
1683
|
+
var _a, _b;
|
|
1684
|
+
const {
|
|
1685
|
+
children,
|
|
1686
|
+
branding,
|
|
1687
|
+
navigation: navigationProp,
|
|
1688
|
+
defaultSidebarCollapsed = false,
|
|
1689
|
+
disableCollapsibleSidebar = false,
|
|
1690
|
+
hideNavigation = false,
|
|
1691
|
+
sidebarExpandedWidth = 320,
|
|
1692
|
+
renderPageItem,
|
|
1693
|
+
slots,
|
|
1694
|
+
slotProps,
|
|
1695
|
+
sx
|
|
1696
|
+
} = props;
|
|
1697
|
+
if (navigationProp && process.env.NODE_ENV !== "production") {
|
|
1698
|
+
warnOnce(
|
|
1699
|
+
"The navigation prop in the DashboardLayout component is deprecated and will eventually be removed. Set the navigation prop in the AppProvider instead (https://mui.com/toolpad/core/react-app-provider/#navigation)."
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
const theme = useTheme3();
|
|
1703
|
+
const navigationContext = React16.useContext(NavigationContext);
|
|
1704
|
+
const appWindowContext = React16.useContext(WindowContext);
|
|
1705
|
+
const navigation = navigationProp != null ? navigationProp : navigationContext;
|
|
1706
|
+
const [isDesktopNavigationExpanded, setIsDesktopNavigationExpanded] = React16.useState(!defaultSidebarCollapsed);
|
|
1707
|
+
const [isMobileNavigationExpanded, setIsMobileNavigationExpanded] = React16.useState(false);
|
|
1708
|
+
const isOverSmViewport = useMediaQuery(
|
|
1709
|
+
theme.breakpoints.up("sm"),
|
|
1710
|
+
appWindowContext && {
|
|
1711
|
+
matchMedia: appWindowContext.matchMedia
|
|
1712
|
+
}
|
|
1713
|
+
);
|
|
1714
|
+
const isOverMdViewport = useMediaQuery(
|
|
1715
|
+
theme.breakpoints.up("md"),
|
|
1716
|
+
appWindowContext && {
|
|
1717
|
+
matchMedia: appWindowContext.matchMedia
|
|
1718
|
+
}
|
|
1719
|
+
);
|
|
1720
|
+
const isNavigationExpanded = isOverMdViewport ? isDesktopNavigationExpanded : isMobileNavigationExpanded;
|
|
1721
|
+
const setIsNavigationExpanded = React16.useCallback(
|
|
1722
|
+
(newExpanded) => {
|
|
1723
|
+
if (isOverMdViewport) {
|
|
1724
|
+
setIsDesktopNavigationExpanded(newExpanded);
|
|
1725
|
+
} else {
|
|
1726
|
+
setIsMobileNavigationExpanded(newExpanded);
|
|
1727
|
+
}
|
|
1728
|
+
},
|
|
1729
|
+
[isOverMdViewport]
|
|
1730
|
+
);
|
|
1731
|
+
const [isNavigationFullyExpanded, setIsNavigationFullyExpanded] = React16.useState(isNavigationExpanded);
|
|
1732
|
+
const [isNavigationFullyCollapsed, setIsNavigationFullyCollapsed] = React16.useState(!isNavigationExpanded);
|
|
1733
|
+
React16.useEffect(() => {
|
|
1734
|
+
if (isNavigationExpanded) {
|
|
1735
|
+
const drawerWidthTransitionTimeout = setTimeout(() => {
|
|
1736
|
+
setIsNavigationFullyExpanded(true);
|
|
1737
|
+
}, theme.transitions.duration.enteringScreen);
|
|
1738
|
+
return () => clearTimeout(drawerWidthTransitionTimeout);
|
|
1739
|
+
}
|
|
1740
|
+
setIsNavigationFullyExpanded(false);
|
|
1741
|
+
return () => {
|
|
1742
|
+
};
|
|
1743
|
+
}, [isNavigationExpanded, theme]);
|
|
1744
|
+
React16.useEffect(() => {
|
|
1745
|
+
if (!isNavigationExpanded) {
|
|
1746
|
+
const drawerWidthTransitionTimeout = setTimeout(() => {
|
|
1747
|
+
setIsNavigationFullyCollapsed(true);
|
|
1748
|
+
}, theme.transitions.duration.leavingScreen);
|
|
1749
|
+
return () => clearTimeout(drawerWidthTransitionTimeout);
|
|
1750
|
+
}
|
|
1751
|
+
setIsNavigationFullyCollapsed(false);
|
|
1752
|
+
return () => {
|
|
1753
|
+
};
|
|
1754
|
+
}, [isNavigationExpanded, theme]);
|
|
1755
|
+
const handleSetNavigationExpanded = React16.useCallback(
|
|
1756
|
+
(newExpanded) => () => {
|
|
1757
|
+
setIsNavigationExpanded(newExpanded);
|
|
1758
|
+
},
|
|
1759
|
+
[setIsNavigationExpanded]
|
|
1760
|
+
);
|
|
1761
|
+
const handleToggleHeaderMenu = React16.useCallback(
|
|
1762
|
+
(isExpanded) => {
|
|
1763
|
+
setIsNavigationExpanded(isExpanded);
|
|
1764
|
+
},
|
|
1765
|
+
[setIsNavigationExpanded]
|
|
1766
|
+
);
|
|
1767
|
+
const handleNavigationLinkClick = React16.useCallback(() => {
|
|
1768
|
+
setIsMobileNavigationExpanded(false);
|
|
1769
|
+
}, [setIsMobileNavigationExpanded]);
|
|
1770
|
+
const isDesktopMini = !disableCollapsibleSidebar && !isDesktopNavigationExpanded;
|
|
1771
|
+
const isMobileMini = !disableCollapsibleSidebar && !isMobileNavigationExpanded;
|
|
1772
|
+
const hasDrawerTransitions = isOverSmViewport && (!disableCollapsibleSidebar || isOverMdViewport);
|
|
1773
|
+
const SidebarFooterSlot = (_a = slots == null ? void 0 : slots.sidebarFooter) != null ? _a : null;
|
|
1774
|
+
const HeaderSlot = (_b = slots == null ? void 0 : slots.header) != null ? _b : DashboardHeader;
|
|
1775
|
+
const headerSlotProps = React16.useMemo(
|
|
1776
|
+
() => __spreadValues({
|
|
1777
|
+
branding,
|
|
1778
|
+
menuOpen: isNavigationExpanded,
|
|
1779
|
+
onToggleMenu: handleToggleHeaderMenu,
|
|
1780
|
+
hideMenuButton: hideNavigation || isOverMdViewport && disableCollapsibleSidebar,
|
|
1781
|
+
slots: {
|
|
1782
|
+
appTitle: slots == null ? void 0 : slots.appTitle,
|
|
1783
|
+
toolbarActions: slots == null ? void 0 : slots.toolbarActions,
|
|
1784
|
+
toolbarAccount: slots == null ? void 0 : slots.toolbarAccount
|
|
1785
|
+
},
|
|
1786
|
+
slotProps: {
|
|
1787
|
+
appTitle: slotProps == null ? void 0 : slotProps.appTitle,
|
|
1788
|
+
toolbarActions: slotProps == null ? void 0 : slotProps.toolbarActions,
|
|
1789
|
+
toolbarAccount: slotProps == null ? void 0 : slotProps.toolbarAccount
|
|
1790
|
+
}
|
|
1791
|
+
}, slotProps == null ? void 0 : slotProps.header),
|
|
1792
|
+
[
|
|
1793
|
+
branding,
|
|
1794
|
+
isNavigationExpanded,
|
|
1795
|
+
handleToggleHeaderMenu,
|
|
1796
|
+
hideNavigation,
|
|
1797
|
+
isOverMdViewport,
|
|
1798
|
+
disableCollapsibleSidebar,
|
|
1799
|
+
slotProps,
|
|
1800
|
+
slots
|
|
1801
|
+
]
|
|
1802
|
+
);
|
|
1803
|
+
const getDrawerContent = React16.useCallback(
|
|
1804
|
+
(isMini, viewport) => {
|
|
1805
|
+
var _a2;
|
|
1806
|
+
return /* @__PURE__ */ jsxs10(React16.Fragment, { children: [
|
|
1807
|
+
/* @__PURE__ */ jsx16(Toolbar2, {}),
|
|
1808
|
+
/* @__PURE__ */ jsxs10(
|
|
1809
|
+
Box4,
|
|
1810
|
+
{
|
|
1811
|
+
component: "nav",
|
|
1812
|
+
"aria-label": `${viewport.charAt(0).toUpperCase()}${viewport.slice(1)}`,
|
|
1813
|
+
sx: __spreadValues({
|
|
1814
|
+
height: "100%",
|
|
1815
|
+
display: "flex",
|
|
1816
|
+
flexDirection: "column",
|
|
1817
|
+
justifyContent: "space-between",
|
|
1818
|
+
overflow: "auto",
|
|
1819
|
+
scrollbarGutter: isMini ? "stable" : "auto",
|
|
1820
|
+
overflowX: "hidden",
|
|
1821
|
+
pt: ((_a2 = navigation[0]) == null ? void 0 : _a2.kind) === "header" && !isMini ? 0 : 2
|
|
1822
|
+
}, hasDrawerTransitions ? getDrawerSxTransitionMixin(isNavigationFullyExpanded, "padding") : {}),
|
|
1823
|
+
children: [
|
|
1824
|
+
/* @__PURE__ */ jsx16(
|
|
1825
|
+
DashboardSidebarSubNavigation,
|
|
1826
|
+
{
|
|
1827
|
+
subNavigation: navigation,
|
|
1828
|
+
onLinkClick: handleNavigationLinkClick,
|
|
1829
|
+
isMini,
|
|
1830
|
+
isFullyExpanded: isNavigationFullyExpanded,
|
|
1831
|
+
isFullyCollapsed: isNavigationFullyCollapsed,
|
|
1832
|
+
hasDrawerTransitions,
|
|
1833
|
+
sidebarExpandedWidth,
|
|
1834
|
+
renderPageItem
|
|
1835
|
+
}
|
|
1836
|
+
),
|
|
1837
|
+
SidebarFooterSlot ? /* @__PURE__ */ jsx16(SidebarFooterSlot, __spreadValues({ mini: isMini }, slotProps == null ? void 0 : slotProps.sidebarFooter)) : null
|
|
1838
|
+
]
|
|
1839
|
+
}
|
|
1840
|
+
)
|
|
1841
|
+
] });
|
|
1842
|
+
},
|
|
1843
|
+
[
|
|
1844
|
+
SidebarFooterSlot,
|
|
1845
|
+
handleNavigationLinkClick,
|
|
1846
|
+
hasDrawerTransitions,
|
|
1847
|
+
isNavigationFullyCollapsed,
|
|
1848
|
+
isNavigationFullyExpanded,
|
|
1849
|
+
navigation,
|
|
1850
|
+
sidebarExpandedWidth,
|
|
1851
|
+
renderPageItem,
|
|
1852
|
+
slotProps == null ? void 0 : slotProps.sidebarFooter
|
|
1853
|
+
]
|
|
1854
|
+
);
|
|
1855
|
+
const getDrawerSharedSx = React16.useCallback(
|
|
1856
|
+
(isMini, isTemporary) => {
|
|
1857
|
+
const drawerWidth = isMini ? MINI_DRAWER_WIDTH : sidebarExpandedWidth;
|
|
1858
|
+
return __spreadProps(__spreadValues(__spreadValues({
|
|
1859
|
+
displayPrint: "none",
|
|
1860
|
+
width: drawerWidth,
|
|
1861
|
+
flexShrink: 0
|
|
1862
|
+
}, getDrawerWidthTransitionMixin(isNavigationExpanded)), isTemporary ? { position: "absolute" } : {}), {
|
|
1863
|
+
[`& .MuiDrawer-paper`]: __spreadValues({
|
|
1864
|
+
position: "absolute",
|
|
1865
|
+
width: drawerWidth,
|
|
1866
|
+
boxSizing: "border-box",
|
|
1867
|
+
backgroundImage: "none"
|
|
1868
|
+
}, getDrawerWidthTransitionMixin(isNavigationExpanded))
|
|
1869
|
+
});
|
|
1870
|
+
},
|
|
1871
|
+
[isNavigationExpanded, sidebarExpandedWidth]
|
|
1872
|
+
);
|
|
1873
|
+
return /* @__PURE__ */ jsxs10(
|
|
1874
|
+
Box4,
|
|
1875
|
+
{
|
|
1876
|
+
sx: __spreadValues({
|
|
1877
|
+
position: "relative",
|
|
1878
|
+
display: "flex",
|
|
1879
|
+
overflow: "hidden",
|
|
1880
|
+
height: "100vh",
|
|
1881
|
+
width: "100vw"
|
|
1882
|
+
}, sx),
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsx16(HeaderSlot, __spreadValues({}, headerSlotProps)),
|
|
1885
|
+
!hideNavigation ? /* @__PURE__ */ jsxs10(React16.Fragment, { children: [
|
|
1886
|
+
/* @__PURE__ */ jsx16(
|
|
1887
|
+
Drawer,
|
|
1888
|
+
{
|
|
1889
|
+
container: appWindowContext == null ? void 0 : appWindowContext.document.body,
|
|
1890
|
+
variant: "temporary",
|
|
1891
|
+
open: isMobileNavigationExpanded,
|
|
1892
|
+
onClose: handleSetNavigationExpanded(false),
|
|
1893
|
+
ModalProps: {
|
|
1894
|
+
keepMounted: true
|
|
1895
|
+
// Better open performance on mobile.
|
|
1896
|
+
},
|
|
1897
|
+
sx: __spreadValues({
|
|
1898
|
+
display: {
|
|
1899
|
+
xs: "block",
|
|
1900
|
+
sm: disableCollapsibleSidebar ? "block" : "none",
|
|
1901
|
+
md: "none"
|
|
1902
|
+
}
|
|
1903
|
+
}, getDrawerSharedSx(false, true)),
|
|
1904
|
+
children: getDrawerContent(false, "phone")
|
|
1905
|
+
}
|
|
1906
|
+
),
|
|
1907
|
+
/* @__PURE__ */ jsx16(
|
|
1908
|
+
Drawer,
|
|
1909
|
+
{
|
|
1910
|
+
variant: "permanent",
|
|
1911
|
+
sx: __spreadValues({
|
|
1912
|
+
display: {
|
|
1913
|
+
xs: "none",
|
|
1914
|
+
sm: disableCollapsibleSidebar ? "none" : "block",
|
|
1915
|
+
md: "none"
|
|
1916
|
+
}
|
|
1917
|
+
}, getDrawerSharedSx(isMobileMini, false)),
|
|
1918
|
+
children: getDrawerContent(isMobileMini, "tablet")
|
|
1919
|
+
}
|
|
1920
|
+
),
|
|
1921
|
+
/* @__PURE__ */ jsx16(
|
|
1922
|
+
Drawer,
|
|
1923
|
+
{
|
|
1924
|
+
variant: "permanent",
|
|
1925
|
+
sx: __spreadValues({
|
|
1926
|
+
display: { xs: "none", md: "block" }
|
|
1927
|
+
}, getDrawerSharedSx(isDesktopMini, false)),
|
|
1928
|
+
children: getDrawerContent(isDesktopMini, "desktop")
|
|
1929
|
+
}
|
|
1930
|
+
)
|
|
1931
|
+
] }) : null,
|
|
1932
|
+
/* @__PURE__ */ jsxs10(
|
|
1933
|
+
Box4,
|
|
1934
|
+
{
|
|
1935
|
+
sx: {
|
|
1936
|
+
display: "flex",
|
|
1937
|
+
flexDirection: "column",
|
|
1938
|
+
flex: 1,
|
|
1939
|
+
minWidth: 0
|
|
1940
|
+
},
|
|
1941
|
+
children: [
|
|
1942
|
+
/* @__PURE__ */ jsx16(Toolbar2, { sx: { displayPrint: "none" } }),
|
|
1943
|
+
/* @__PURE__ */ jsx16(
|
|
1944
|
+
Box4,
|
|
1945
|
+
{
|
|
1946
|
+
component: "main",
|
|
1947
|
+
sx: {
|
|
1948
|
+
display: "flex",
|
|
1949
|
+
flexDirection: "column",
|
|
1950
|
+
flex: 1,
|
|
1951
|
+
overflow: "auto"
|
|
1952
|
+
},
|
|
1953
|
+
children
|
|
1954
|
+
}
|
|
1955
|
+
)
|
|
1956
|
+
]
|
|
1957
|
+
}
|
|
1958
|
+
)
|
|
1959
|
+
]
|
|
1960
|
+
}
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1963
|
+
DashboardLayout.propTypes = {
|
|
1964
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
1965
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
1966
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
1967
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
1968
|
+
/**
|
|
1969
|
+
* Branding options for the dashboard.
|
|
1970
|
+
* @default null
|
|
1971
|
+
*/
|
|
1972
|
+
branding: PropTypes9.shape({
|
|
1973
|
+
homeUrl: PropTypes9.string,
|
|
1974
|
+
logo: PropTypes9.node,
|
|
1975
|
+
title: PropTypes9.string
|
|
1976
|
+
}),
|
|
1977
|
+
/**
|
|
1978
|
+
* The content of the dashboard.
|
|
1979
|
+
*/
|
|
1980
|
+
children: PropTypes9.node,
|
|
1981
|
+
/**
|
|
1982
|
+
* Whether the sidebar should start collapsed in desktop size screens.
|
|
1983
|
+
* @default false
|
|
1984
|
+
*/
|
|
1985
|
+
defaultSidebarCollapsed: PropTypes9.bool,
|
|
1986
|
+
/**
|
|
1987
|
+
* Whether the sidebar should not be collapsible to a mini variant in desktop and tablet viewports.
|
|
1988
|
+
* @default false
|
|
1989
|
+
*/
|
|
1990
|
+
disableCollapsibleSidebar: PropTypes9.bool,
|
|
1991
|
+
/**
|
|
1992
|
+
* Whether the navigation bar and menu icon should be hidden.
|
|
1993
|
+
* @default false
|
|
1994
|
+
*/
|
|
1995
|
+
hideNavigation: PropTypes9.bool,
|
|
1996
|
+
/**
|
|
1997
|
+
* Navigation definition for the dashboard. [Find out more](https://mui.com/toolpad/core/react-dashboard-layout/#navigation).
|
|
1998
|
+
* @default []
|
|
1999
|
+
* @deprecated Set the navigation in the [AppProvider](https://mui.com/toolpad/core/react-app-provider/#navigation) instead.
|
|
2000
|
+
*/
|
|
2001
|
+
navigation: PropTypes9.arrayOf(
|
|
2002
|
+
PropTypes9.oneOfType([
|
|
2003
|
+
PropTypes9.shape({
|
|
2004
|
+
action: PropTypes9.node,
|
|
2005
|
+
children: PropTypes9.arrayOf(
|
|
2006
|
+
PropTypes9.oneOfType([
|
|
2007
|
+
PropTypes9.object,
|
|
2008
|
+
PropTypes9.shape({
|
|
2009
|
+
kind: PropTypes9.oneOf(["header"]).isRequired,
|
|
2010
|
+
title: PropTypes9.string.isRequired
|
|
2011
|
+
}),
|
|
2012
|
+
PropTypes9.shape({
|
|
2013
|
+
kind: PropTypes9.oneOf(["divider"]).isRequired
|
|
2014
|
+
})
|
|
2015
|
+
]).isRequired
|
|
2016
|
+
),
|
|
2017
|
+
icon: PropTypes9.node,
|
|
2018
|
+
kind: PropTypes9.oneOf(["page"]),
|
|
2019
|
+
pattern: PropTypes9.string,
|
|
2020
|
+
segment: PropTypes9.string,
|
|
2021
|
+
title: PropTypes9.string
|
|
2022
|
+
}),
|
|
2023
|
+
PropTypes9.shape({
|
|
2024
|
+
kind: PropTypes9.oneOf(["header"]).isRequired,
|
|
2025
|
+
title: PropTypes9.string.isRequired
|
|
2026
|
+
}),
|
|
2027
|
+
PropTypes9.shape({
|
|
2028
|
+
kind: PropTypes9.oneOf(["divider"]).isRequired
|
|
2029
|
+
})
|
|
2030
|
+
]).isRequired
|
|
2031
|
+
),
|
|
2032
|
+
/**
|
|
2033
|
+
* Render each page item.
|
|
2034
|
+
*
|
|
2035
|
+
* @param {NavigationPageItem} item
|
|
2036
|
+
* @param {{ mini: boolean }} params
|
|
2037
|
+
* @returns {ReactNode}
|
|
2038
|
+
*/
|
|
2039
|
+
renderPageItem: PropTypes9.func,
|
|
2040
|
+
/**
|
|
2041
|
+
* Width of the sidebar when expanded.
|
|
2042
|
+
* @default 320
|
|
2043
|
+
*/
|
|
2044
|
+
sidebarExpandedWidth: PropTypes9.oneOfType([PropTypes9.number, PropTypes9.string]),
|
|
2045
|
+
/**
|
|
2046
|
+
* The props used for each slot inside.
|
|
2047
|
+
* @default {}
|
|
2048
|
+
*/
|
|
2049
|
+
slotProps: PropTypes9.shape({
|
|
2050
|
+
appTitle: PropTypes9.shape({
|
|
2051
|
+
branding: PropTypes9.shape({
|
|
2052
|
+
homeUrl: PropTypes9.string,
|
|
2053
|
+
logo: PropTypes9.node,
|
|
2054
|
+
title: PropTypes9.string
|
|
2055
|
+
})
|
|
2056
|
+
}),
|
|
2057
|
+
header: PropTypes9.shape({
|
|
2058
|
+
branding: PropTypes9.shape({
|
|
2059
|
+
homeUrl: PropTypes9.string,
|
|
2060
|
+
logo: PropTypes9.node,
|
|
2061
|
+
title: PropTypes9.string
|
|
2062
|
+
}),
|
|
2063
|
+
hideMenuButton: PropTypes9.bool,
|
|
2064
|
+
menuOpen: PropTypes9.bool.isRequired,
|
|
2065
|
+
onToggleMenu: PropTypes9.func.isRequired,
|
|
2066
|
+
slotProps: PropTypes9.shape({
|
|
2067
|
+
appTitle: PropTypes9.object,
|
|
2068
|
+
toolbarAccount: PropTypes9.object,
|
|
2069
|
+
toolbarActions: PropTypes9.object
|
|
2070
|
+
}),
|
|
2071
|
+
slots: PropTypes9.shape({
|
|
2072
|
+
appTitle: PropTypes9.elementType,
|
|
2073
|
+
toolbarAccount: PropTypes9.elementType,
|
|
2074
|
+
toolbarActions: PropTypes9.elementType
|
|
2075
|
+
})
|
|
2076
|
+
}),
|
|
2077
|
+
sidebarFooter: PropTypes9.shape({
|
|
2078
|
+
mini: PropTypes9.bool.isRequired
|
|
2079
|
+
}),
|
|
2080
|
+
toolbarAccount: PropTypes9.shape({
|
|
2081
|
+
localeText: PropTypes9.object,
|
|
2082
|
+
slotProps: PropTypes9.shape({
|
|
2083
|
+
popover: PropTypes9.object,
|
|
2084
|
+
popoverContent: PropTypes9.object,
|
|
2085
|
+
preview: PropTypes9.object,
|
|
2086
|
+
signInButton: PropTypes9.object,
|
|
2087
|
+
signOutButton: PropTypes9.object
|
|
2088
|
+
}),
|
|
2089
|
+
slots: PropTypes9.shape({
|
|
2090
|
+
popover: PropTypes9.elementType,
|
|
2091
|
+
popoverContent: PropTypes9.elementType,
|
|
2092
|
+
preview: PropTypes9.elementType,
|
|
2093
|
+
signInButton: PropTypes9.elementType,
|
|
2094
|
+
signOutButton: PropTypes9.elementType
|
|
2095
|
+
})
|
|
2096
|
+
}),
|
|
2097
|
+
toolbarActions: PropTypes9.object
|
|
2098
|
+
}),
|
|
2099
|
+
/**
|
|
2100
|
+
* The components used for each slot inside.
|
|
2101
|
+
* @default {}
|
|
2102
|
+
*/
|
|
2103
|
+
slots: PropTypes9.shape({
|
|
2104
|
+
appTitle: PropTypes9.elementType,
|
|
2105
|
+
header: PropTypes9.elementType,
|
|
2106
|
+
sidebarFooter: PropTypes9.elementType,
|
|
2107
|
+
toolbarAccount: PropTypes9.elementType,
|
|
2108
|
+
toolbarActions: PropTypes9.elementType
|
|
2109
|
+
}),
|
|
2110
|
+
/**
|
|
2111
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
2112
|
+
*/
|
|
2113
|
+
sx: PropTypes9.oneOfType([
|
|
2114
|
+
PropTypes9.arrayOf(PropTypes9.oneOfType([PropTypes9.func, PropTypes9.object, PropTypes9.bool])),
|
|
2115
|
+
PropTypes9.func,
|
|
2116
|
+
PropTypes9.object
|
|
2117
|
+
])
|
|
2118
|
+
};
|
|
2119
|
+
|
|
2120
|
+
// src/toolpad-core/PageContainer/PageContainer.tsx
|
|
2121
|
+
import PropTypes12 from "prop-types";
|
|
2122
|
+
import Box5 from "@mui/material/Box";
|
|
2123
|
+
import Container from "@mui/material/Container";
|
|
2124
|
+
import Stack8 from "@mui/material/Stack";
|
|
2125
|
+
|
|
2126
|
+
// src/toolpad-core/PageContainer/PageHeader.tsx
|
|
2127
|
+
import PropTypes11 from "prop-types";
|
|
2128
|
+
import Breadcrumbs from "@mui/material/Breadcrumbs";
|
|
2129
|
+
import Link4 from "@mui/material/Link";
|
|
2130
|
+
import Stack7 from "@mui/material/Stack";
|
|
2131
|
+
import Typography4 from "@mui/material/Typography";
|
|
2132
|
+
import useSlotProps from "@mui/utils/useSlotProps";
|
|
2133
|
+
import { styled as styled5 } from "@mui/material";
|
|
2134
|
+
|
|
2135
|
+
// src/toolpad-core/PageContainer/PageHeaderToolbar.tsx
|
|
2136
|
+
import PropTypes10 from "prop-types";
|
|
2137
|
+
import { styled as styled4 } from "@mui/material";
|
|
2138
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
2139
|
+
var PageHeaderToolbarRoot = styled4("div")(({ theme }) => ({
|
|
2140
|
+
display: "flex",
|
|
2141
|
+
flexDirection: "row",
|
|
2142
|
+
gap: theme.spacing(1),
|
|
2143
|
+
// Ensure the toolbar is always on the right side, even after wrapping
|
|
2144
|
+
marginLeft: "auto"
|
|
2145
|
+
}));
|
|
2146
|
+
function PageHeaderToolbar(props) {
|
|
2147
|
+
return /* @__PURE__ */ jsx17(PageHeaderToolbarRoot, __spreadValues({}, props));
|
|
2148
|
+
}
|
|
2149
|
+
PageHeaderToolbar.propTypes = {
|
|
2150
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
2151
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
2152
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
2153
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
2154
|
+
/**
|
|
2155
|
+
* @ignore
|
|
2156
|
+
*/
|
|
2157
|
+
children: PropTypes10.node
|
|
2158
|
+
};
|
|
2159
|
+
|
|
2160
|
+
// src/toolpad-core/PageContainer/PageHeader.tsx
|
|
2161
|
+
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2162
|
+
var PageContentHeader = styled5("div")(({ theme }) => ({
|
|
2163
|
+
display: "flex",
|
|
2164
|
+
flexDirection: "row",
|
|
2165
|
+
justifyContent: "space-between",
|
|
2166
|
+
gap: theme.spacing(2)
|
|
2167
|
+
}));
|
|
2168
|
+
function PageHeader(props) {
|
|
2169
|
+
var _a, _b, _c, _d, _e;
|
|
2170
|
+
const { breadcrumbs, title } = props;
|
|
2171
|
+
const activePage = useActivePage();
|
|
2172
|
+
const resolvedBreadcrumbs = (_a = breadcrumbs != null ? breadcrumbs : activePage == null ? void 0 : activePage.breadcrumbs) != null ? _a : [];
|
|
2173
|
+
const resolvedTitle = (_b = title != null ? title : activePage == null ? void 0 : activePage.title) != null ? _b : "";
|
|
2174
|
+
const ToolbarComponent = (_d = (_c = props == null ? void 0 : props.slots) == null ? void 0 : _c.toolbar) != null ? _d : PageHeaderToolbar;
|
|
2175
|
+
const toolbarSlotProps = useSlotProps({
|
|
2176
|
+
elementType: ToolbarComponent,
|
|
2177
|
+
ownerState: props,
|
|
2178
|
+
externalSlotProps: (_e = props == null ? void 0 : props.slotProps) == null ? void 0 : _e.toolbar,
|
|
2179
|
+
additionalProps: {}
|
|
2180
|
+
});
|
|
2181
|
+
return /* @__PURE__ */ jsxs11(Stack7, { children: [
|
|
2182
|
+
/* @__PURE__ */ jsx18(Breadcrumbs, { "aria-label": "breadcrumb", children: resolvedBreadcrumbs ? resolvedBreadcrumbs.map((item, index) => {
|
|
2183
|
+
return item.path ? /* @__PURE__ */ jsx18(
|
|
2184
|
+
Link4,
|
|
2185
|
+
{
|
|
2186
|
+
component: Link2,
|
|
2187
|
+
underline: "hover",
|
|
2188
|
+
color: "inherit",
|
|
2189
|
+
href: item.path,
|
|
2190
|
+
children: getItemTitle(item)
|
|
2191
|
+
},
|
|
2192
|
+
index
|
|
2193
|
+
) : /* @__PURE__ */ jsx18(Typography4, { color: "text.primary", children: getItemTitle(item) }, index);
|
|
2194
|
+
}) : null }),
|
|
2195
|
+
/* @__PURE__ */ jsxs11(PageContentHeader, { children: [
|
|
2196
|
+
resolvedTitle ? /* @__PURE__ */ jsx18(Typography4, { variant: "h4", children: resolvedTitle }) : null,
|
|
2197
|
+
/* @__PURE__ */ jsx18(ToolbarComponent, __spreadValues({}, toolbarSlotProps))
|
|
2198
|
+
] })
|
|
2199
|
+
] });
|
|
2200
|
+
}
|
|
2201
|
+
PageHeader.propTypes = {
|
|
2202
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
2203
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
2204
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
2205
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
2206
|
+
/**
|
|
2207
|
+
* The breadcrumbs of the page. Leave blank to use the active page breadcrumbs.
|
|
2208
|
+
*/
|
|
2209
|
+
breadcrumbs: PropTypes11.arrayOf(
|
|
2210
|
+
PropTypes11.shape({
|
|
2211
|
+
path: PropTypes11.string,
|
|
2212
|
+
title: PropTypes11.string.isRequired
|
|
2213
|
+
})
|
|
2214
|
+
),
|
|
2215
|
+
/**
|
|
2216
|
+
* The props used for each slot inside.
|
|
2217
|
+
*/
|
|
2218
|
+
slotProps: PropTypes11.shape({
|
|
2219
|
+
toolbar: PropTypes11.shape({
|
|
2220
|
+
children: PropTypes11.node
|
|
2221
|
+
}).isRequired
|
|
2222
|
+
}),
|
|
2223
|
+
/**
|
|
2224
|
+
* The components used for each slot inside.
|
|
2225
|
+
*/
|
|
2226
|
+
slots: PropTypes11.shape({
|
|
2227
|
+
toolbar: PropTypes11.elementType
|
|
2228
|
+
}),
|
|
2229
|
+
/**
|
|
2230
|
+
* The title of the page. Leave blank to use the active page title.
|
|
2231
|
+
*/
|
|
2232
|
+
title: PropTypes11.string
|
|
2233
|
+
};
|
|
2234
|
+
|
|
2235
|
+
// src/toolpad-core/PageContainer/PageContainer.tsx
|
|
2236
|
+
import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2237
|
+
function PageContainer(props) {
|
|
2238
|
+
var _b;
|
|
2239
|
+
const _a = props, { children, breadcrumbs, slots, slotProps, title } = _a, rest = __objRest(_a, ["children", "breadcrumbs", "slots", "slotProps", "title"]);
|
|
2240
|
+
const PageHeaderSlot = (_b = slots == null ? void 0 : slots.header) != null ? _b : PageHeader;
|
|
2241
|
+
return /* @__PURE__ */ jsx19(Container, __spreadProps(__spreadValues({}, rest), { sx: __spreadValues({ flex: 1, display: "flex", flexDirection: "column" }, rest.sx), children: /* @__PURE__ */ jsxs12(Stack8, { sx: { flex: 1, my: 2 }, spacing: 2, children: [
|
|
2242
|
+
/* @__PURE__ */ jsx19(PageHeaderSlot, __spreadValues({ title, breadcrumbs }, slotProps == null ? void 0 : slotProps.header)),
|
|
2243
|
+
/* @__PURE__ */ jsx19(Box5, { sx: { flex: 1, display: "flex", flexDirection: "column" }, children })
|
|
2244
|
+
] }) }));
|
|
2245
|
+
}
|
|
2246
|
+
PageContainer.propTypes = {
|
|
2247
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
2248
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
2249
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
2250
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
2251
|
+
/**
|
|
2252
|
+
* The breadcrumbs of the page. Leave blank to use the active page breadcrumbs.
|
|
2253
|
+
*/
|
|
2254
|
+
breadcrumbs: PropTypes12.arrayOf(
|
|
2255
|
+
PropTypes12.shape({
|
|
2256
|
+
path: PropTypes12.string,
|
|
2257
|
+
title: PropTypes12.string.isRequired
|
|
2258
|
+
})
|
|
2259
|
+
),
|
|
2260
|
+
/**
|
|
2261
|
+
* @ignore
|
|
2262
|
+
*/
|
|
2263
|
+
children: PropTypes12.node,
|
|
2264
|
+
/**
|
|
2265
|
+
* The props used for each slot inside.
|
|
2266
|
+
*/
|
|
2267
|
+
slotProps: PropTypes12.shape({
|
|
2268
|
+
header: PropTypes12.shape({
|
|
2269
|
+
breadcrumbs: PropTypes12.arrayOf(
|
|
2270
|
+
PropTypes12.shape({
|
|
2271
|
+
path: PropTypes12.string,
|
|
2272
|
+
title: PropTypes12.string.isRequired
|
|
2273
|
+
})
|
|
2274
|
+
),
|
|
2275
|
+
slotProps: PropTypes12.shape({
|
|
2276
|
+
toolbar: PropTypes12.object.isRequired
|
|
2277
|
+
}),
|
|
2278
|
+
slots: PropTypes12.shape({
|
|
2279
|
+
toolbar: PropTypes12.elementType
|
|
2280
|
+
}),
|
|
2281
|
+
title: PropTypes12.string
|
|
2282
|
+
}).isRequired
|
|
2283
|
+
}),
|
|
2284
|
+
/**
|
|
2285
|
+
* The components used for each slot inside.
|
|
2286
|
+
*/
|
|
2287
|
+
slots: PropTypes12.shape({
|
|
2288
|
+
header: PropTypes12.elementType
|
|
2289
|
+
}),
|
|
2290
|
+
/**
|
|
2291
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
2292
|
+
*/
|
|
2293
|
+
sx: PropTypes12.oneOfType([
|
|
2294
|
+
PropTypes12.arrayOf(PropTypes12.oneOfType([PropTypes12.func, PropTypes12.object, PropTypes12.bool])),
|
|
2295
|
+
PropTypes12.func,
|
|
2296
|
+
PropTypes12.object
|
|
2297
|
+
]),
|
|
2298
|
+
/**
|
|
2299
|
+
* The title of the page. Leave blank to use the active page title.
|
|
2300
|
+
*/
|
|
2301
|
+
title: PropTypes12.string
|
|
2302
|
+
};
|
|
2303
|
+
|
|
2304
|
+
export {
|
|
2305
|
+
useNotifications,
|
|
2306
|
+
AlertDialog,
|
|
2307
|
+
ConfirmDialog,
|
|
2308
|
+
PromptDialog,
|
|
2309
|
+
useDialogs,
|
|
2310
|
+
SignInButton,
|
|
2311
|
+
SignOutButton,
|
|
2312
|
+
AccountPreview,
|
|
2313
|
+
AccountPopoverHeader,
|
|
2314
|
+
AccountPopoverFooter,
|
|
2315
|
+
Account,
|
|
2316
|
+
ThemeSwitcher,
|
|
2317
|
+
ToolbarActions,
|
|
2318
|
+
DashboardHeader,
|
|
2319
|
+
useActivePage,
|
|
2320
|
+
DashboardSidebarPageItem,
|
|
2321
|
+
DashboardLayout,
|
|
2322
|
+
PageHeaderToolbar,
|
|
2323
|
+
PageHeader,
|
|
2324
|
+
PageContainer
|
|
2325
|
+
};
|