@iowas/toolpad 1.0.4 → 1.0.5

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.
@@ -0,0 +1,686 @@
1
+ 'use strict';
2
+
3
+ var chunk5B2NQDIH_js = require('./chunk-5B2NQDIH.js');
4
+ var React3 = require('react');
5
+ var PropTypes2 = require('prop-types');
6
+ var styles = require('@mui/material/styles');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+ var material = require('@mui/material');
9
+ var CloseIcon = require('@mui/icons-material/Close');
10
+ var useSlotProps = require('@mui/utils/useSlotProps');
11
+ var invariant = require('invariant');
12
+ var useEventCallback = require('@mui/utils/useEventCallback');
13
+ var InitColorSchemeScript = require('@mui/material/InitColorSchemeScript');
14
+ var CssBaseline = require('@mui/material/CssBaseline');
15
+
16
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n.default = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
37
+ var PropTypes2__default = /*#__PURE__*/_interopDefault(PropTypes2);
38
+ var CloseIcon__default = /*#__PURE__*/_interopDefault(CloseIcon);
39
+ var useSlotProps__default = /*#__PURE__*/_interopDefault(useSlotProps);
40
+ var invariant__default = /*#__PURE__*/_interopDefault(invariant);
41
+ var useEventCallback__default = /*#__PURE__*/_interopDefault(useEventCallback);
42
+ var InitColorSchemeScript__default = /*#__PURE__*/_interopDefault(InitColorSchemeScript);
43
+ var CssBaseline__default = /*#__PURE__*/_interopDefault(CssBaseline);
44
+
45
+ // src/toolpad-core/locales/getLocalization.ts
46
+ var getLocalization = (translations) => {
47
+ return {
48
+ components: {
49
+ MuiLocalizationProvider: {
50
+ defaultProps: {
51
+ localeText: chunk5B2NQDIH_js.__spreadValues({}, translations)
52
+ }
53
+ }
54
+ }
55
+ };
56
+ };
57
+
58
+ // src/toolpad-core/locales/en.tsx
59
+ var enLabels = {
60
+ // Account
61
+ accountSignInLabel: "Sign In",
62
+ accountSignOutLabel: "Sign Out",
63
+ // AccountPreview
64
+ accountPreviewTitle: "Account",
65
+ accountPreviewIconButtonLabel: "Current User",
66
+ // SignInPage
67
+ signInTitle: (brandingTitle) => brandingTitle ? `Sign in to ${brandingTitle}` : "Sign in",
68
+ signInSubtitle: "Welcome user, please sign in to continue",
69
+ signInRememberMe: "Remember Me",
70
+ providerSignInTitle: (provider) => `Sign in with ${provider}`,
71
+ // Common authentication labels
72
+ email: "Email",
73
+ password: "Password",
74
+ username: "Username",
75
+ passkey: "Passkey",
76
+ // Common action labels
77
+ save: "Save",
78
+ cancel: "Cancel",
79
+ ok: "Ok",
80
+ or: "Or",
81
+ to: "To",
82
+ with: "With",
83
+ close: "Close",
84
+ delete: "Delete",
85
+ alert: "Alert",
86
+ confirm: "Confirm",
87
+ loading: "Loading...",
88
+ // CRUD
89
+ createNewButtonLabel: "Create new",
90
+ reloadButtonLabel: "Reload data",
91
+ createLabel: "Create",
92
+ createSuccessMessage: "Item created successfully.",
93
+ createErrorMessage: "Failed to create item. Reason:",
94
+ editLabel: "Edit",
95
+ editSuccessMessage: "Item edited successfully.",
96
+ editErrorMessage: "Failed to edit item. Reason:",
97
+ deleteLabel: "Delete",
98
+ deleteConfirmTitle: "Delete item?",
99
+ deleteConfirmMessage: "Do you wish to delete this item?",
100
+ deleteConfirmLabel: "Delete",
101
+ deleteCancelLabel: "Cancel",
102
+ deleteSuccessMessage: "Item deleted successfully.",
103
+ deleteErrorMessage: "Failed to delete item. Reason:",
104
+ deletedItemMessage: "This item has been deleted."
105
+ };
106
+ var en_default = getLocalization(enLabels);
107
+ var LocalizationContext = React3__namespace.createContext({});
108
+ var LocalizationProvider = function LocalizationProvider2(props) {
109
+ var _a, _b, _c;
110
+ const { localeText: propsLocaleText, children } = props;
111
+ const theme = styles.useTheme();
112
+ const themeLocaleText = (_c = (_b = (_a = theme == null ? void 0 : theme.components) == null ? void 0 : _a.MuiLocalizationProvider) == null ? void 0 : _b.defaultProps) == null ? void 0 : _c.localeText;
113
+ const defaultLocaleText2 = en_default.components.MuiLocalizationProvider.defaultProps.localeText;
114
+ const localeText = React3__namespace.useMemo(
115
+ () => chunk5B2NQDIH_js.__spreadValues(chunk5B2NQDIH_js.__spreadValues(chunk5B2NQDIH_js.__spreadValues({}, defaultLocaleText2), themeLocaleText), propsLocaleText),
116
+ [defaultLocaleText2, themeLocaleText, propsLocaleText]
117
+ );
118
+ return /* @__PURE__ */ jsxRuntime.jsx(LocalizationContext.Provider, { value: localeText, children });
119
+ };
120
+ LocalizationProvider.propTypes = {
121
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
122
+ // │ These PropTypes are generated from the TypeScript type definitions. │
123
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
124
+ // └─────────────────────────────────────────────────────────────────────┘
125
+ /**
126
+ * @ignore
127
+ */
128
+ children: PropTypes2__default.default.node,
129
+ /**
130
+ * Locale for components texts
131
+ */
132
+ localeText: PropTypes2__default.default.object
133
+ };
134
+ function useLocaleText() {
135
+ return React3__namespace.useContext(LocalizationContext);
136
+ }
137
+ var NotificationsContext = React3__namespace.createContext(null);
138
+ var RootPropsContext = React3__namespace.createContext(null);
139
+ var defaultLocaleText = {
140
+ close: "Close"
141
+ };
142
+ function Notification({ notificationKey, open, message, options, badge }) {
143
+ var _a, _b, _c;
144
+ const globalLocaleText = useLocaleText();
145
+ const localeText = chunk5B2NQDIH_js.__spreadValues(chunk5B2NQDIH_js.__spreadValues({}, defaultLocaleText), globalLocaleText);
146
+ const { close } = chunk5B2NQDIH_js.useNonNullableContext(NotificationsContext);
147
+ const { severity, actionText, onAction, autoHideDuration } = options;
148
+ const handleClose = React3__namespace.useCallback(
149
+ (event, reason) => {
150
+ if (reason === "clickaway") {
151
+ return;
152
+ }
153
+ close(notificationKey);
154
+ },
155
+ [notificationKey, close]
156
+ );
157
+ const action = /* @__PURE__ */ jsxRuntime.jsxs(React3__namespace.Fragment, { children: [
158
+ onAction ? /* @__PURE__ */ jsxRuntime.jsx(material.Button, { color: "inherit", size: "small", onClick: onAction, children: actionText != null ? actionText : "Action" }) : null,
159
+ /* @__PURE__ */ jsxRuntime.jsx(
160
+ material.IconButton,
161
+ {
162
+ size: "small",
163
+ "aria-label": localeText == null ? void 0 : localeText.close,
164
+ title: localeText == null ? void 0 : localeText.close,
165
+ color: "inherit",
166
+ onClick: handleClose,
167
+ children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon__default.default, { fontSize: "small" })
168
+ }
169
+ )
170
+ ] });
171
+ const props = React3__namespace.useContext(RootPropsContext);
172
+ const SnackbarComponent = (_b = (_a = props == null ? void 0 : props.slots) == null ? void 0 : _a.snackbar) != null ? _b : material.Snackbar;
173
+ const snackbarSlotProps = useSlotProps__default.default({
174
+ elementType: SnackbarComponent,
175
+ ownerState: props,
176
+ externalSlotProps: (_c = props == null ? void 0 : props.slotProps) == null ? void 0 : _c.snackbar,
177
+ additionalProps: {
178
+ open,
179
+ autoHideDuration,
180
+ onClose: handleClose,
181
+ action
182
+ }
183
+ });
184
+ return /* @__PURE__ */ jsxRuntime.jsx(SnackbarComponent, chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({}, snackbarSlotProps), { children: /* @__PURE__ */ jsxRuntime.jsx(material.Badge, { badgeContent: badge, color: "primary", sx: { width: "100%" }, children: severity ? /* @__PURE__ */ jsxRuntime.jsx(material.Alert, { severity, sx: { width: "100%" }, action, children: message }) : /* @__PURE__ */ jsxRuntime.jsx(material.SnackbarContent, { message, action }) }) }), notificationKey);
185
+ }
186
+ function Notifications({ state }) {
187
+ var _a;
188
+ const currentNotification = (_a = state.queue[0]) != null ? _a : null;
189
+ return currentNotification ? /* @__PURE__ */ jsxRuntime.jsx(
190
+ Notification,
191
+ chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({}, currentNotification), {
192
+ badge: state.queue.length > 1 ? String(state.queue.length) : null
193
+ })
194
+ ) : null;
195
+ }
196
+ var nextId = 0;
197
+ var generateId = () => {
198
+ const id = nextId;
199
+ nextId += 1;
200
+ return id;
201
+ };
202
+ function NotificationsProvider(props) {
203
+ const { children } = props;
204
+ const [state, setState] = React3__namespace.useState({ queue: [] });
205
+ const show = React3__namespace.useCallback((message, options = {}) => {
206
+ var _a;
207
+ const notificationKey = (_a = options.key) != null ? _a : `::toolpad-internal::notification::${generateId()}`;
208
+ setState((prev) => {
209
+ if (prev.queue.some((n) => n.notificationKey === notificationKey)) {
210
+ return prev;
211
+ }
212
+ return chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({}, prev), {
213
+ queue: [...prev.queue, { message, options, notificationKey, open: true }]
214
+ });
215
+ });
216
+ return notificationKey;
217
+ }, []);
218
+ const close = React3__namespace.useCallback((key) => {
219
+ setState((prev) => chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({}, prev), {
220
+ queue: prev.queue.filter((n) => n.notificationKey !== key)
221
+ }));
222
+ }, []);
223
+ const contextValue = React3__namespace.useMemo(() => ({ show, close }), [show, close]);
224
+ return /* @__PURE__ */ jsxRuntime.jsx(RootPropsContext.Provider, { value: props, children: /* @__PURE__ */ jsxRuntime.jsxs(NotificationsContext.Provider, { value: contextValue, children: [
225
+ children,
226
+ /* @__PURE__ */ jsxRuntime.jsx(Notifications, { state })
227
+ ] }) });
228
+ }
229
+ var DialogsContext = React3__namespace.createContext(null);
230
+ function DialogsProvider(props) {
231
+ const { children, unmountAfter = 1e3 } = props;
232
+ const [stack, setStack] = React3__namespace.useState([]);
233
+ const keyPrefix = React3__namespace.useId();
234
+ const nextId2 = React3__namespace.useRef(0);
235
+ const dialogMetadata = React3__namespace.useRef(/* @__PURE__ */ new WeakMap());
236
+ const requestDialog = useEventCallback__default.default(function open(Component, payload, options = {}) {
237
+ const { onClose = async () => {
238
+ } } = options;
239
+ let resolve;
240
+ const promise = new Promise((resolveImpl) => {
241
+ resolve = resolveImpl;
242
+ });
243
+ invariant__default.default(resolve, "resolve not set");
244
+ const key = `${keyPrefix}-${nextId2.current}`;
245
+ nextId2.current += 1;
246
+ const newEntry = {
247
+ key,
248
+ open: true,
249
+ promise,
250
+ Component,
251
+ payload,
252
+ onClose,
253
+ resolve
254
+ };
255
+ dialogMetadata.current.set(promise, newEntry);
256
+ setStack((prevStack) => [...prevStack, newEntry]);
257
+ return promise;
258
+ });
259
+ const closeDialogUi = useEventCallback__default.default(function closeDialogUi2(dialog) {
260
+ setStack(
261
+ (prevStack) => prevStack.map((entry) => entry.promise === dialog ? chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({}, entry), { open: false }) : entry)
262
+ );
263
+ setTimeout(() => {
264
+ setStack((prevStack) => prevStack.filter((entry) => entry.promise !== dialog));
265
+ }, unmountAfter);
266
+ });
267
+ const closeDialog = useEventCallback__default.default(async function closeDialog2(dialog, result) {
268
+ const entryToClose = dialogMetadata.current.get(dialog);
269
+ invariant__default.default(entryToClose, "dialog not found");
270
+ try {
271
+ await entryToClose.onClose(result);
272
+ } finally {
273
+ entryToClose.resolve(result);
274
+ closeDialogUi(dialog);
275
+ }
276
+ return dialog;
277
+ });
278
+ const contextValue = React3__namespace.useMemo(
279
+ () => ({ open: requestDialog, close: closeDialog }),
280
+ [requestDialog, closeDialog]
281
+ );
282
+ return /* @__PURE__ */ jsxRuntime.jsxs(DialogsContext.Provider, { value: contextValue, children: [
283
+ children,
284
+ stack.map(({ key, open, Component, payload, promise }) => /* @__PURE__ */ jsxRuntime.jsx(
285
+ Component,
286
+ {
287
+ payload,
288
+ open,
289
+ onClose: async (result) => {
290
+ await closeDialog(promise, result);
291
+ }
292
+ },
293
+ key
294
+ ))
295
+ ] });
296
+ }
297
+
298
+ // src/toolpad-core/persistence/codec.tsx
299
+ var CODEC_STRING = {
300
+ parse: (value) => value,
301
+ stringify: (value) => value
302
+ };
303
+
304
+ // src/toolpad-core/persistence/useStorageState.tsx
305
+ var currentTabChangeListeners = /* @__PURE__ */ new Map();
306
+ function onCurrentTabStorageChange(key, handler) {
307
+ let listeners = currentTabChangeListeners.get(key);
308
+ if (!listeners) {
309
+ listeners = /* @__PURE__ */ new Set();
310
+ currentTabChangeListeners.set(key, listeners);
311
+ }
312
+ listeners.add(handler);
313
+ }
314
+ function offCurrentTabStorageChange(key, handler) {
315
+ const listeners = currentTabChangeListeners.get(key);
316
+ if (!listeners) {
317
+ return;
318
+ }
319
+ listeners.delete(handler);
320
+ if (listeners.size === 0) {
321
+ currentTabChangeListeners.delete(key);
322
+ }
323
+ }
324
+ function emitCurrentTabStorageChange(key) {
325
+ const listeners = currentTabChangeListeners.get(key);
326
+ if (listeners) {
327
+ listeners.forEach((listener) => listener());
328
+ }
329
+ }
330
+ if (typeof window !== "undefined") {
331
+ const origSetItem = window.localStorage.setItem;
332
+ window.localStorage.setItem = function setItem(key, value) {
333
+ const result = origSetItem.call(this, key, value);
334
+ emitCurrentTabStorageChange(key);
335
+ return result;
336
+ };
337
+ }
338
+ function subscribe(area, key, callback) {
339
+ if (!key) {
340
+ return () => {
341
+ };
342
+ }
343
+ const storageHandler = (event) => {
344
+ if (event.storageArea === area && event.key === key) {
345
+ callback();
346
+ }
347
+ };
348
+ window.addEventListener("storage", storageHandler);
349
+ onCurrentTabStorageChange(key, callback);
350
+ return () => {
351
+ window.removeEventListener("storage", storageHandler);
352
+ offCurrentTabStorageChange(key, callback);
353
+ };
354
+ }
355
+ function getSnapshot(area, key) {
356
+ if (!key) {
357
+ return null;
358
+ }
359
+ try {
360
+ return area.getItem(key);
361
+ } catch (e) {
362
+ return null;
363
+ }
364
+ }
365
+ function setValue(area, key, value) {
366
+ if (!key) {
367
+ return;
368
+ }
369
+ try {
370
+ if (value === null) {
371
+ area.removeItem(key);
372
+ } else {
373
+ area.setItem(key, String(value));
374
+ }
375
+ } catch (e) {
376
+ return;
377
+ }
378
+ emitCurrentTabStorageChange(key);
379
+ }
380
+ var serverValue = [null, () => {
381
+ }];
382
+ function useStorageStateServer() {
383
+ return serverValue;
384
+ }
385
+ function encode(codec, value) {
386
+ return value === null ? null : codec.stringify(value);
387
+ }
388
+ function decode(codec, value) {
389
+ return value === null ? null : codec.parse(value);
390
+ }
391
+ var getKeyServerSnapshot = () => null;
392
+ function useStorageState(area, key, initializer = null, options) {
393
+ var _a;
394
+ const codec = (_a = options == null ? void 0 : options.codec) != null ? _a : CODEC_STRING;
395
+ const [initialValue] = React3__namespace.useState(initializer);
396
+ const encodedInitialValue = React3__namespace.useMemo(
397
+ () => encode(codec, initialValue),
398
+ [codec, initialValue]
399
+ );
400
+ const subscribeKey = React3__namespace.useCallback(
401
+ (callback) => subscribe(area, key, callback),
402
+ [area, key]
403
+ );
404
+ const getKeySnapshot = React3__namespace.useCallback(
405
+ () => {
406
+ var _a2;
407
+ return (_a2 = getSnapshot(area, key)) != null ? _a2 : encodedInitialValue;
408
+ },
409
+ [area, encodedInitialValue, key]
410
+ );
411
+ const encodedStoredValue = React3__namespace.useSyncExternalStore(
412
+ subscribeKey,
413
+ getKeySnapshot,
414
+ getKeyServerSnapshot
415
+ );
416
+ const storedValue = React3__namespace.useMemo(
417
+ () => decode(codec, encodedStoredValue),
418
+ [codec, encodedStoredValue]
419
+ );
420
+ const setStoredValue = React3__namespace.useCallback(
421
+ (value) => {
422
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
423
+ const encodedValueToStore = encode(codec, valueToStore);
424
+ setValue(area, key, encodedValueToStore);
425
+ },
426
+ [area, codec, storedValue, key]
427
+ );
428
+ const [nonStoredValue, setNonStoredValue] = React3__namespace.useState(initialValue);
429
+ if (!key) {
430
+ return [nonStoredValue, setNonStoredValue];
431
+ }
432
+ return [storedValue, setStoredValue];
433
+ }
434
+
435
+ // src/toolpad-core/useLocalStorageState/useLocalStorageState.tsx
436
+ var useLocalStorageStateBrowser = (...args) => useStorageState(window.localStorage, ...args);
437
+ var useLocalStorageState = typeof window === "undefined" ? useStorageStateServer : useLocalStorageStateBrowser;
438
+ var BrandingContext = React3__namespace.createContext(null);
439
+ var NavigationContext = React3__namespace.createContext([]);
440
+ var PaletteModeContext = React3__namespace.createContext({
441
+ paletteMode: "light",
442
+ setPaletteMode: () => {
443
+ },
444
+ isDualTheme: false
445
+ });
446
+ var RouterContext = React3__namespace.createContext(null);
447
+ var DashboardSidebarPageItemContext = React3__namespace.createContext(null);
448
+ var WindowContext = React3__namespace.createContext(void 0);
449
+ var COLOR_SCHEME_STORAGE_KEY = "toolpad-color-scheme";
450
+ var MODE_STORAGE_KEY = "toolpad-mode";
451
+ function usePreferredMode(window2) {
452
+ const prefersDarkMode = material.useMediaQuery(
453
+ "(prefers-color-scheme: dark)",
454
+ window2 && {
455
+ matchMedia: window2.matchMedia
456
+ }
457
+ );
458
+ return prefersDarkMode ? "dark" : "light";
459
+ }
460
+ function isCssVarsTheme(theme) {
461
+ return "vars" in theme;
462
+ }
463
+ function LegacyThemeProvider(props) {
464
+ const { children, theme, window: appWindow } = props;
465
+ invariant__default.default(!isCssVarsTheme(theme), "This provider only accepts legacy themes.");
466
+ const isDualTheme = "light" in theme || "dark" in theme;
467
+ const preferredMode = usePreferredMode(appWindow);
468
+ const [userMode, setUserMode] = useLocalStorageState(MODE_STORAGE_KEY, "system");
469
+ const paletteMode = !userMode || userMode === "system" ? preferredMode : userMode;
470
+ const dualAwareTheme = React3__namespace.useMemo(
471
+ () => {
472
+ var _a;
473
+ return isDualTheme ? (_a = theme[paletteMode === "dark" ? "dark" : "light"]) != null ? _a : theme[paletteMode === "dark" ? "light" : "dark"] : theme;
474
+ },
475
+ [isDualTheme, paletteMode, theme]
476
+ );
477
+ const paletteModeContextValue = React3__namespace.useMemo(
478
+ () => ({
479
+ paletteMode,
480
+ setPaletteMode: setUserMode,
481
+ isDualTheme
482
+ }),
483
+ [isDualTheme, paletteMode, setUserMode]
484
+ );
485
+ return /* @__PURE__ */ jsxRuntime.jsx(styles.ThemeProvider, { theme: dualAwareTheme, children: /* @__PURE__ */ jsxRuntime.jsxs(PaletteModeContext.Provider, { value: paletteModeContextValue, children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx(CssBaseline__default.default, { enableColorScheme: true }),
487
+ children
488
+ ] }) });
489
+ }
490
+ function CssVarsPaletteModeProvider(props) {
491
+ const { children, window: appWindow } = props;
492
+ const preferredMode = usePreferredMode(appWindow);
493
+ const { mode, setMode, allColorSchemes } = styles.useColorScheme();
494
+ const paletteModeContextValue = React3__namespace.useMemo(() => {
495
+ return {
496
+ paletteMode: !mode || mode === "system" ? preferredMode : mode,
497
+ setPaletteMode: setMode,
498
+ isDualTheme: allColorSchemes.length > 1
499
+ };
500
+ }, [allColorSchemes, mode, preferredMode, setMode]);
501
+ return /* @__PURE__ */ jsxRuntime.jsx(PaletteModeContext.Provider, { value: paletteModeContextValue, children });
502
+ }
503
+ function CssVarsThemeProvider(props) {
504
+ const { children, theme, window: appWindow, nonce } = props;
505
+ invariant__default.default(isCssVarsTheme(theme), "This provider only accepts CSS vars themes.");
506
+ return /* @__PURE__ */ jsxRuntime.jsxs(
507
+ styles.ThemeProvider,
508
+ {
509
+ theme,
510
+ documentNode: appWindow == null ? void 0 : appWindow.document,
511
+ colorSchemeNode: appWindow == null ? void 0 : appWindow.document.documentElement,
512
+ disableNestedContext: true,
513
+ colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY,
514
+ modeStorageKey: MODE_STORAGE_KEY,
515
+ children: [
516
+ /* @__PURE__ */ jsxRuntime.jsx(
517
+ InitColorSchemeScript__default.default,
518
+ {
519
+ attribute: theme.colorSchemeSelector,
520
+ colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY,
521
+ modeStorageKey: MODE_STORAGE_KEY,
522
+ nonce
523
+ }
524
+ ),
525
+ /* @__PURE__ */ jsxRuntime.jsxs(CssVarsPaletteModeProvider, { window: appWindow, children: [
526
+ /* @__PURE__ */ jsxRuntime.jsx(CssBaseline__default.default, { enableColorScheme: true }),
527
+ children
528
+ ] })
529
+ ]
530
+ }
531
+ );
532
+ }
533
+ function AppThemeProvider(props) {
534
+ const _a = props, { children, theme } = _a, rest = chunk5B2NQDIH_js.__objRest(_a, ["children", "theme"]);
535
+ const useCssVarsProvider = isCssVarsTheme(theme);
536
+ return useCssVarsProvider ? /* @__PURE__ */ jsxRuntime.jsx(CssVarsThemeProvider, chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({ theme }, rest), { children })) : /* @__PURE__ */ jsxRuntime.jsx(LegacyThemeProvider, chunk5B2NQDIH_js.__spreadProps(chunk5B2NQDIH_js.__spreadValues({ theme }, rest), { children }));
537
+ }
538
+ var AuthenticationContext = React3__namespace.createContext(null);
539
+ var SessionContext = React3__namespace.createContext(null);
540
+ function createDefaultTheme() {
541
+ return styles.createTheme({
542
+ cssVariables: {
543
+ colorSchemeSelector: "data-toolpad-color-scheme"
544
+ },
545
+ colorSchemes: { dark: true }
546
+ });
547
+ }
548
+ function AppProvider(props) {
549
+ const {
550
+ children,
551
+ theme = createDefaultTheme(),
552
+ branding = null,
553
+ navigation = [],
554
+ localeText,
555
+ router = null,
556
+ authentication = null,
557
+ session = null,
558
+ window: appWindow,
559
+ nonce
560
+ } = props;
561
+ return /* @__PURE__ */ jsxRuntime.jsx(WindowContext.Provider, { value: appWindow, children: /* @__PURE__ */ jsxRuntime.jsx(AuthenticationContext.Provider, { value: authentication, children: /* @__PURE__ */ jsxRuntime.jsx(SessionContext.Provider, { value: session, children: /* @__PURE__ */ jsxRuntime.jsx(RouterContext.Provider, { value: router, children: /* @__PURE__ */ jsxRuntime.jsx(AppThemeProvider, { theme, window: appWindow, nonce, children: /* @__PURE__ */ jsxRuntime.jsx(LocalizationProvider, { localeText, children: /* @__PURE__ */ jsxRuntime.jsx(NotificationsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DialogsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(BrandingContext.Provider, { value: branding, children: /* @__PURE__ */ jsxRuntime.jsx(NavigationContext.Provider, { value: navigation, children }) }) }) }) }) }) }) }) }) });
562
+ }
563
+ AppProvider.propTypes = {
564
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
565
+ // │ These PropTypes are generated from the TypeScript type definitions. │
566
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
567
+ // └─────────────────────────────────────────────────────────────────────┘
568
+ /**
569
+ * Authentication methods.
570
+ * @default null
571
+ */
572
+ authentication: PropTypes2__default.default.shape({
573
+ signIn: PropTypes2__default.default.func.isRequired,
574
+ signOut: PropTypes2__default.default.func.isRequired
575
+ }),
576
+ /**
577
+ * Branding options for the app.
578
+ * @default null
579
+ */
580
+ branding: PropTypes2__default.default.shape({
581
+ homeUrl: PropTypes2__default.default.string,
582
+ logo: PropTypes2__default.default.node,
583
+ title: PropTypes2__default.default.string
584
+ }),
585
+ /**
586
+ * The content of the app provider.
587
+ */
588
+ children: PropTypes2__default.default.node,
589
+ /**
590
+ * Locale text for components
591
+ */
592
+ localeText: PropTypes2__default.default.object,
593
+ /**
594
+ * Navigation definition for the app. [Find out more](https://mui.com/toolpad/core/react-app-provider/#navigation).
595
+ * @default []
596
+ */
597
+ navigation: PropTypes2__default.default.arrayOf(
598
+ PropTypes2__default.default.oneOfType([
599
+ PropTypes2__default.default.shape({
600
+ action: PropTypes2__default.default.node,
601
+ children: PropTypes2__default.default.arrayOf(
602
+ PropTypes2__default.default.oneOfType([
603
+ PropTypes2__default.default.object,
604
+ PropTypes2__default.default.shape({
605
+ kind: PropTypes2__default.default.oneOf(["header"]).isRequired,
606
+ title: PropTypes2__default.default.string.isRequired
607
+ }),
608
+ PropTypes2__default.default.shape({
609
+ kind: PropTypes2__default.default.oneOf(["divider"]).isRequired
610
+ })
611
+ ]).isRequired
612
+ ),
613
+ icon: PropTypes2__default.default.node,
614
+ kind: PropTypes2__default.default.oneOf(["page"]),
615
+ pattern: PropTypes2__default.default.string,
616
+ segment: PropTypes2__default.default.string,
617
+ title: PropTypes2__default.default.string
618
+ }),
619
+ PropTypes2__default.default.shape({
620
+ kind: PropTypes2__default.default.oneOf(["header"]).isRequired,
621
+ title: PropTypes2__default.default.string.isRequired
622
+ }),
623
+ PropTypes2__default.default.shape({
624
+ kind: PropTypes2__default.default.oneOf(["divider"]).isRequired
625
+ })
626
+ ]).isRequired
627
+ ),
628
+ /**
629
+ * The nonce to be used for inline scripts.
630
+ */
631
+ nonce: PropTypes2__default.default.string,
632
+ /**
633
+ * Router implementation used inside Toolpad components.
634
+ * @default null
635
+ */
636
+ router: PropTypes2__default.default.shape({
637
+ Link: PropTypes2__default.default.elementType,
638
+ navigate: PropTypes2__default.default.func.isRequired,
639
+ pathname: PropTypes2__default.default.string.isRequired,
640
+ searchParams: PropTypes2__default.default.instanceOf(URLSearchParams).isRequired
641
+ }),
642
+ /**
643
+ * Session info about the current user.
644
+ * @default null
645
+ */
646
+ session: PropTypes2__default.default.shape({
647
+ user: PropTypes2__default.default.shape({
648
+ email: PropTypes2__default.default.string,
649
+ id: PropTypes2__default.default.string,
650
+ image: PropTypes2__default.default.string,
651
+ name: PropTypes2__default.default.string
652
+ })
653
+ }),
654
+ /**
655
+ * [Theme or themes](https://mui.com/toolpad/core/react-app-provider/#theming) to be used by the app in light/dark mode. A [CSS variables theme](https://mui.com/material-ui/customization/css-theme-variables/overview/) is recommended.
656
+ * @default createDefaultTheme()
657
+ */
658
+ theme: PropTypes2__default.default.object,
659
+ /**
660
+ * The window where the application is rendered.
661
+ * This is needed when rendering the app inside an iframe, for example.
662
+ * @default window
663
+ */
664
+ window: PropTypes2__default.default.object
665
+ };
666
+
667
+ exports.AppProvider = AppProvider;
668
+ exports.AuthenticationContext = AuthenticationContext;
669
+ exports.BrandingContext = BrandingContext;
670
+ exports.DashboardSidebarPageItemContext = DashboardSidebarPageItemContext;
671
+ exports.DialogsContext = DialogsContext;
672
+ exports.DialogsProvider = DialogsProvider;
673
+ exports.LocalizationContext = LocalizationContext;
674
+ exports.LocalizationProvider = LocalizationProvider;
675
+ exports.NavigationContext = NavigationContext;
676
+ exports.NotificationsContext = NotificationsContext;
677
+ exports.NotificationsProvider = NotificationsProvider;
678
+ exports.PaletteModeContext = PaletteModeContext;
679
+ exports.RouterContext = RouterContext;
680
+ exports.SessionContext = SessionContext;
681
+ exports.WindowContext = WindowContext;
682
+ exports.en_default = en_default;
683
+ exports.useLocalStorageState = useLocalStorageState;
684
+ exports.useLocaleText = useLocaleText;
685
+ exports.useStorageState = useStorageState;
686
+ exports.useStorageStateServer = useStorageStateServer;