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