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