@iowas/toolpad 1.0.1 → 1.0.2

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