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