@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/chunk-3JWXE2JW.mjs +5 -16
- package/dist/chunk-5B2NQDIH.js +145 -0
- package/dist/chunk-BN55HN4U.js +12 -0
- package/dist/chunk-F6JD4MSY.mjs +1 -3
- package/dist/chunk-LUTZBKSG.mjs +64 -138
- package/dist/chunk-PMIWCP25.mjs +4 -19
- package/dist/chunk-SITC3EZQ.js +2225 -0
- package/dist/chunk-SWAF5R4Y.js +686 -0
- package/dist/chunk-VMBNHIHN.js +84 -0
- package/dist/chunk-ZXM3V5SD.mjs +367 -552
- package/dist/core.js +126 -3100
- package/dist/core.mjs +4 -72
- package/dist/index.js +195 -3260
- package/dist/index.mjs +5 -110
- package/dist/nextjs.js +38 -771
- package/dist/nextjs.mjs +9 -19
- package/dist/utils.js +71 -213
- package/dist/utils.mjs +3 -42
- package/package.json +1 -1
package/dist/chunk-3JWXE2JW.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ReactIs from 'react-is';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
1
5
|
var __defProp = Object.defineProperty;
|
|
2
6
|
var __defProps = Object.defineProperties;
|
|
3
7
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -29,11 +33,6 @@ var __objRest = (source, exclude) => {
|
|
|
29
33
|
}
|
|
30
34
|
return target;
|
|
31
35
|
};
|
|
32
|
-
|
|
33
|
-
// src/toolpad-utils/react.tsx
|
|
34
|
-
import * as React from "react";
|
|
35
|
-
import * as ReactIs from "react-is";
|
|
36
|
-
import { jsx } from "react/jsx-runtime";
|
|
37
36
|
function interleave(items, separator) {
|
|
38
37
|
const result = [];
|
|
39
38
|
for (let i = 0; i < items.length; i += 1) {
|
|
@@ -112,14 +111,4 @@ function createGlobalState(initialState) {
|
|
|
112
111
|
};
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
export {
|
|
116
|
-
__spreadValues,
|
|
117
|
-
__spreadProps,
|
|
118
|
-
__objRest,
|
|
119
|
-
interleave,
|
|
120
|
-
useNonNullableContext,
|
|
121
|
-
createProvidedContext,
|
|
122
|
-
useAssertedContext,
|
|
123
|
-
useTraceUpdates,
|
|
124
|
-
createGlobalState
|
|
125
|
-
};
|
|
114
|
+
export { __objRest, __spreadProps, __spreadValues, createGlobalState, createProvidedContext, interleave, useAssertedContext, useNonNullableContext, useTraceUpdates };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var ReactIs = require('react-is');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
|
+
var ReactIs__namespace = /*#__PURE__*/_interopNamespace(ReactIs);
|
|
27
|
+
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __defProps = Object.defineProperties;
|
|
30
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
31
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
32
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
34
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
35
|
+
var __spreadValues = (a, b) => {
|
|
36
|
+
for (var prop in b || (b = {}))
|
|
37
|
+
if (__hasOwnProp.call(b, prop))
|
|
38
|
+
__defNormalProp(a, prop, b[prop]);
|
|
39
|
+
if (__getOwnPropSymbols)
|
|
40
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
41
|
+
if (__propIsEnum.call(b, prop))
|
|
42
|
+
__defNormalProp(a, prop, b[prop]);
|
|
43
|
+
}
|
|
44
|
+
return a;
|
|
45
|
+
};
|
|
46
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
47
|
+
var __objRest = (source, exclude) => {
|
|
48
|
+
var target = {};
|
|
49
|
+
for (var prop in source)
|
|
50
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
51
|
+
target[prop] = source[prop];
|
|
52
|
+
if (source != null && __getOwnPropSymbols)
|
|
53
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
54
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
55
|
+
target[prop] = source[prop];
|
|
56
|
+
}
|
|
57
|
+
return target;
|
|
58
|
+
};
|
|
59
|
+
function interleave(items, separator) {
|
|
60
|
+
const result = [];
|
|
61
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
62
|
+
if (i > 0) {
|
|
63
|
+
if (ReactIs__namespace.isElement(separator)) {
|
|
64
|
+
result.push(React__namespace.cloneElement(separator, { key: `separator-${i}` }));
|
|
65
|
+
} else {
|
|
66
|
+
result.push(separator);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const item = items[i];
|
|
70
|
+
result.push(item);
|
|
71
|
+
}
|
|
72
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React__namespace.Fragment, { children: result });
|
|
73
|
+
}
|
|
74
|
+
function useNonNullableContext(context, name) {
|
|
75
|
+
const maybeContext = React__namespace.useContext(context);
|
|
76
|
+
if (maybeContext === null || maybeContext === void 0) {
|
|
77
|
+
throw new Error(`context "${name}" was used without a Provider`);
|
|
78
|
+
}
|
|
79
|
+
return maybeContext;
|
|
80
|
+
}
|
|
81
|
+
function createProvidedContext(name) {
|
|
82
|
+
const context = React__namespace.createContext(void 0);
|
|
83
|
+
const useContext2 = () => useNonNullableContext(context, name);
|
|
84
|
+
return [useContext2, context.Provider];
|
|
85
|
+
}
|
|
86
|
+
function useAssertedContext(context) {
|
|
87
|
+
const value = React__namespace.useContext(context);
|
|
88
|
+
if (value === void 0) {
|
|
89
|
+
throw new Error("context was used without a Provider");
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
function useTraceUpdates(prefix, props) {
|
|
94
|
+
const prev = React__namespace.useRef(props);
|
|
95
|
+
React__namespace.useEffect(() => {
|
|
96
|
+
const changedProps = {};
|
|
97
|
+
for (const key of Object.keys(props)) {
|
|
98
|
+
if (!Object.is(prev.current[key], props[key])) {
|
|
99
|
+
changedProps[key] = props[key];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(changedProps).length > 0) {
|
|
103
|
+
console.log(`${prefix} changed props:`, changedProps);
|
|
104
|
+
}
|
|
105
|
+
prev.current = props;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function createGlobalState(initialState) {
|
|
109
|
+
let state = initialState;
|
|
110
|
+
const listeners = [];
|
|
111
|
+
const subscribe = (cb) => {
|
|
112
|
+
listeners.push(cb);
|
|
113
|
+
return () => {
|
|
114
|
+
const index = listeners.indexOf(cb);
|
|
115
|
+
listeners.splice(index, 1);
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
const getState = () => state;
|
|
119
|
+
const setState = (newState) => {
|
|
120
|
+
state = typeof newState === "function" ? newState(state) : newState;
|
|
121
|
+
listeners.forEach((cb) => cb(state));
|
|
122
|
+
};
|
|
123
|
+
const useValue = () => React__namespace.useSyncExternalStore(subscribe, getState, getState);
|
|
124
|
+
const useState = () => {
|
|
125
|
+
const value = useValue();
|
|
126
|
+
return [value, setState];
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
getState,
|
|
130
|
+
setState,
|
|
131
|
+
useValue,
|
|
132
|
+
useState,
|
|
133
|
+
subscribe
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
exports.__objRest = __objRest;
|
|
138
|
+
exports.__spreadProps = __spreadProps;
|
|
139
|
+
exports.__spreadValues = __spreadValues;
|
|
140
|
+
exports.createGlobalState = createGlobalState;
|
|
141
|
+
exports.createProvidedContext = createProvidedContext;
|
|
142
|
+
exports.interleave = interleave;
|
|
143
|
+
exports.useAssertedContext = useAssertedContext;
|
|
144
|
+
exports.useNonNullableContext = useNonNullableContext;
|
|
145
|
+
exports.useTraceUpdates = useTraceUpdates;
|
package/dist/chunk-F6JD4MSY.mjs
CHANGED
package/dist/chunk-LUTZBKSG.mjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from
|
|
1
|
+
import { __spreadValues, __spreadProps, __objRest, useNonNullableContext } from './chunk-3JWXE2JW.mjs';
|
|
2
|
+
import * as React3 from 'react';
|
|
3
|
+
import PropTypes2 from 'prop-types';
|
|
4
|
+
import { useTheme, createTheme, ThemeProvider, useColorScheme } from '@mui/material/styles';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
import { Button, IconButton, Snackbar, Badge, Alert, SnackbarContent, useMediaQuery } from '@mui/material';
|
|
7
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
8
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
9
|
+
import invariant from 'invariant';
|
|
10
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
11
|
+
import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';
|
|
12
|
+
import CssBaseline from '@mui/material/CssBaseline';
|
|
7
13
|
|
|
8
14
|
// src/toolpad-core/locales/getLocalization.ts
|
|
9
15
|
var getLocalization = (translations) => {
|
|
@@ -67,20 +73,14 @@ var enLabels = {
|
|
|
67
73
|
deletedItemMessage: "This item has been deleted."
|
|
68
74
|
};
|
|
69
75
|
var en_default = getLocalization(enLabels);
|
|
70
|
-
|
|
71
|
-
// src/toolpad-core/AppProvider/LocalizationProvider.tsx
|
|
72
|
-
import * as React from "react";
|
|
73
|
-
import PropTypes from "prop-types";
|
|
74
|
-
import { useTheme } from "@mui/material/styles";
|
|
75
|
-
import { jsx } from "react/jsx-runtime";
|
|
76
|
-
var LocalizationContext = React.createContext({});
|
|
76
|
+
var LocalizationContext = React3.createContext({});
|
|
77
77
|
var LocalizationProvider = function LocalizationProvider2(props) {
|
|
78
78
|
var _a, _b, _c;
|
|
79
79
|
const { localeText: propsLocaleText, children } = props;
|
|
80
80
|
const theme = useTheme();
|
|
81
81
|
const themeLocaleText = (_c = (_b = (_a = theme == null ? void 0 : theme.components) == null ? void 0 : _a.MuiLocalizationProvider) == null ? void 0 : _b.defaultProps) == null ? void 0 : _c.localeText;
|
|
82
82
|
const defaultLocaleText2 = en_default.components.MuiLocalizationProvider.defaultProps.localeText;
|
|
83
|
-
const localeText =
|
|
83
|
+
const localeText = React3.useMemo(
|
|
84
84
|
() => __spreadValues(__spreadValues(__spreadValues({}, defaultLocaleText2), themeLocaleText), propsLocaleText),
|
|
85
85
|
[defaultLocaleText2, themeLocaleText, propsLocaleText]
|
|
86
86
|
);
|
|
@@ -94,35 +94,16 @@ LocalizationProvider.propTypes = {
|
|
|
94
94
|
/**
|
|
95
95
|
* @ignore
|
|
96
96
|
*/
|
|
97
|
-
children:
|
|
97
|
+
children: PropTypes2.node,
|
|
98
98
|
/**
|
|
99
99
|
* Locale for components texts
|
|
100
100
|
*/
|
|
101
|
-
localeText:
|
|
101
|
+
localeText: PropTypes2.object
|
|
102
102
|
};
|
|
103
103
|
function useLocaleText() {
|
|
104
|
-
return
|
|
104
|
+
return React3.useContext(LocalizationContext);
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
// src/toolpad-core/useNotifications/NotificationsProvider.tsx
|
|
108
|
-
import * as React3 from "react";
|
|
109
|
-
import {
|
|
110
|
-
Alert,
|
|
111
|
-
Badge,
|
|
112
|
-
Button,
|
|
113
|
-
IconButton,
|
|
114
|
-
Snackbar,
|
|
115
|
-
SnackbarContent
|
|
116
|
-
} from "@mui/material";
|
|
117
|
-
import CloseIcon from "@mui/icons-material/Close";
|
|
118
|
-
import useSlotProps from "@mui/utils/useSlotProps";
|
|
119
|
-
|
|
120
|
-
// src/toolpad-core/useNotifications/NotificationsContext.ts
|
|
121
|
-
import * as React2 from "react";
|
|
122
|
-
var NotificationsContext = React2.createContext(null);
|
|
123
|
-
|
|
124
|
-
// src/toolpad-core/useNotifications/NotificationsProvider.tsx
|
|
125
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
106
|
+
var NotificationsContext = React3.createContext(null);
|
|
126
107
|
var RootPropsContext = React3.createContext(null);
|
|
127
108
|
var defaultLocaleText = {
|
|
128
109
|
close: "Close"
|
|
@@ -143,8 +124,8 @@ function Notification({ notificationKey, open, message, options, badge }) {
|
|
|
143
124
|
[notificationKey, close]
|
|
144
125
|
);
|
|
145
126
|
const action = /* @__PURE__ */ jsxs(React3.Fragment, { children: [
|
|
146
|
-
onAction ? /* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
127
|
+
onAction ? /* @__PURE__ */ jsx(Button, { color: "inherit", size: "small", onClick: onAction, children: actionText != null ? actionText : "Action" }) : null,
|
|
128
|
+
/* @__PURE__ */ jsx(
|
|
148
129
|
IconButton,
|
|
149
130
|
{
|
|
150
131
|
size: "small",
|
|
@@ -152,7 +133,7 @@ function Notification({ notificationKey, open, message, options, badge }) {
|
|
|
152
133
|
title: localeText == null ? void 0 : localeText.close,
|
|
153
134
|
color: "inherit",
|
|
154
135
|
onClick: handleClose,
|
|
155
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
|
|
156
137
|
}
|
|
157
138
|
)
|
|
158
139
|
] });
|
|
@@ -169,12 +150,12 @@ function Notification({ notificationKey, open, message, options, badge }) {
|
|
|
169
150
|
action
|
|
170
151
|
}
|
|
171
152
|
});
|
|
172
|
-
return /* @__PURE__ */
|
|
153
|
+
return /* @__PURE__ */ jsx(SnackbarComponent, __spreadProps(__spreadValues({}, snackbarSlotProps), { children: /* @__PURE__ */ jsx(Badge, { badgeContent: badge, color: "primary", sx: { width: "100%" }, children: severity ? /* @__PURE__ */ jsx(Alert, { severity, sx: { width: "100%" }, action, children: message }) : /* @__PURE__ */ jsx(SnackbarContent, { message, action }) }) }), notificationKey);
|
|
173
154
|
}
|
|
174
155
|
function Notifications({ state }) {
|
|
175
156
|
var _a;
|
|
176
157
|
const currentNotification = (_a = state.queue[0]) != null ? _a : null;
|
|
177
|
-
return currentNotification ? /* @__PURE__ */
|
|
158
|
+
return currentNotification ? /* @__PURE__ */ jsx(
|
|
178
159
|
Notification,
|
|
179
160
|
__spreadProps(__spreadValues({}, currentNotification), {
|
|
180
161
|
badge: state.queue.length > 1 ? String(state.queue.length) : null
|
|
@@ -209,29 +190,18 @@ function NotificationsProvider(props) {
|
|
|
209
190
|
}));
|
|
210
191
|
}, []);
|
|
211
192
|
const contextValue = React3.useMemo(() => ({ show, close }), [show, close]);
|
|
212
|
-
return /* @__PURE__ */
|
|
193
|
+
return /* @__PURE__ */ jsx(RootPropsContext.Provider, { value: props, children: /* @__PURE__ */ jsxs(NotificationsContext.Provider, { value: contextValue, children: [
|
|
213
194
|
children,
|
|
214
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ jsx(Notifications, { state })
|
|
215
196
|
] }) });
|
|
216
197
|
}
|
|
217
|
-
|
|
218
|
-
// src/toolpad-core/useDialogs/DialogsProvider.tsx
|
|
219
|
-
import invariant from "invariant";
|
|
220
|
-
import * as React5 from "react";
|
|
221
|
-
import useEventCallback from "@mui/utils/useEventCallback";
|
|
222
|
-
|
|
223
|
-
// src/toolpad-core/useDialogs/DialogsContext.tsx
|
|
224
|
-
import * as React4 from "react";
|
|
225
|
-
var DialogsContext = React4.createContext(null);
|
|
226
|
-
|
|
227
|
-
// src/toolpad-core/useDialogs/DialogsProvider.tsx
|
|
228
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
198
|
+
var DialogsContext = React3.createContext(null);
|
|
229
199
|
function DialogsProvider(props) {
|
|
230
200
|
const { children, unmountAfter = 1e3 } = props;
|
|
231
|
-
const [stack, setStack] =
|
|
232
|
-
const keyPrefix =
|
|
233
|
-
const nextId2 =
|
|
234
|
-
const dialogMetadata =
|
|
201
|
+
const [stack, setStack] = React3.useState([]);
|
|
202
|
+
const keyPrefix = React3.useId();
|
|
203
|
+
const nextId2 = React3.useRef(0);
|
|
204
|
+
const dialogMetadata = React3.useRef(/* @__PURE__ */ new WeakMap());
|
|
235
205
|
const requestDialog = useEventCallback(function open(Component, payload, options = {}) {
|
|
236
206
|
const { onClose = async () => {
|
|
237
207
|
} } = options;
|
|
@@ -274,13 +244,13 @@ function DialogsProvider(props) {
|
|
|
274
244
|
}
|
|
275
245
|
return dialog;
|
|
276
246
|
});
|
|
277
|
-
const contextValue =
|
|
247
|
+
const contextValue = React3.useMemo(
|
|
278
248
|
() => ({ open: requestDialog, close: closeDialog }),
|
|
279
249
|
[requestDialog, closeDialog]
|
|
280
250
|
);
|
|
281
|
-
return /* @__PURE__ */
|
|
251
|
+
return /* @__PURE__ */ jsxs(DialogsContext.Provider, { value: contextValue, children: [
|
|
282
252
|
children,
|
|
283
|
-
stack.map(({ key, open, Component, payload, promise }) => /* @__PURE__ */
|
|
253
|
+
stack.map(({ key, open, Component, payload, promise }) => /* @__PURE__ */ jsx(
|
|
284
254
|
Component,
|
|
285
255
|
{
|
|
286
256
|
payload,
|
|
@@ -294,9 +264,6 @@ function DialogsProvider(props) {
|
|
|
294
264
|
] });
|
|
295
265
|
}
|
|
296
266
|
|
|
297
|
-
// src/toolpad-core/persistence/useStorageState.tsx
|
|
298
|
-
import * as React6 from "react";
|
|
299
|
-
|
|
300
267
|
// src/toolpad-core/persistence/codec.tsx
|
|
301
268
|
var CODEC_STRING = {
|
|
302
269
|
parse: (value) => value,
|
|
@@ -394,32 +361,32 @@ var getKeyServerSnapshot = () => null;
|
|
|
394
361
|
function useStorageState(area, key, initializer = null, options) {
|
|
395
362
|
var _a;
|
|
396
363
|
const codec = (_a = options == null ? void 0 : options.codec) != null ? _a : CODEC_STRING;
|
|
397
|
-
const [initialValue] =
|
|
398
|
-
const encodedInitialValue =
|
|
364
|
+
const [initialValue] = React3.useState(initializer);
|
|
365
|
+
const encodedInitialValue = React3.useMemo(
|
|
399
366
|
() => encode(codec, initialValue),
|
|
400
367
|
[codec, initialValue]
|
|
401
368
|
);
|
|
402
|
-
const subscribeKey =
|
|
369
|
+
const subscribeKey = React3.useCallback(
|
|
403
370
|
(callback) => subscribe(area, key, callback),
|
|
404
371
|
[area, key]
|
|
405
372
|
);
|
|
406
|
-
const getKeySnapshot =
|
|
373
|
+
const getKeySnapshot = React3.useCallback(
|
|
407
374
|
() => {
|
|
408
375
|
var _a2;
|
|
409
376
|
return (_a2 = getSnapshot(area, key)) != null ? _a2 : encodedInitialValue;
|
|
410
377
|
},
|
|
411
378
|
[area, encodedInitialValue, key]
|
|
412
379
|
);
|
|
413
|
-
const encodedStoredValue =
|
|
380
|
+
const encodedStoredValue = React3.useSyncExternalStore(
|
|
414
381
|
subscribeKey,
|
|
415
382
|
getKeySnapshot,
|
|
416
383
|
getKeyServerSnapshot
|
|
417
384
|
);
|
|
418
|
-
const storedValue =
|
|
385
|
+
const storedValue = React3.useMemo(
|
|
419
386
|
() => decode(codec, encodedStoredValue),
|
|
420
387
|
[codec, encodedStoredValue]
|
|
421
388
|
);
|
|
422
|
-
const setStoredValue =
|
|
389
|
+
const setStoredValue = React3.useCallback(
|
|
423
390
|
(value) => {
|
|
424
391
|
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
425
392
|
const encodedValueToStore = encode(codec, valueToStore);
|
|
@@ -427,7 +394,7 @@ function useStorageState(area, key, initializer = null, options) {
|
|
|
427
394
|
},
|
|
428
395
|
[area, codec, storedValue, key]
|
|
429
396
|
);
|
|
430
|
-
const [nonStoredValue, setNonStoredValue] =
|
|
397
|
+
const [nonStoredValue, setNonStoredValue] = React3.useState(initialValue);
|
|
431
398
|
if (!key) {
|
|
432
399
|
return [nonStoredValue, setNonStoredValue];
|
|
433
400
|
}
|
|
@@ -437,34 +404,17 @@ function useStorageState(area, key, initializer = null, options) {
|
|
|
437
404
|
// src/toolpad-core/useLocalStorageState/useLocalStorageState.tsx
|
|
438
405
|
var useLocalStorageStateBrowser = (...args) => useStorageState(window.localStorage, ...args);
|
|
439
406
|
var useLocalStorageState = typeof window === "undefined" ? useStorageStateServer : useLocalStorageStateBrowser;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
import PropTypes2 from "prop-types";
|
|
444
|
-
import { createTheme } from "@mui/material/styles";
|
|
445
|
-
|
|
446
|
-
// src/toolpad-core/shared/context.ts
|
|
447
|
-
import * as React7 from "react";
|
|
448
|
-
var BrandingContext = React7.createContext(null);
|
|
449
|
-
var NavigationContext = React7.createContext([]);
|
|
450
|
-
var PaletteModeContext = React7.createContext({
|
|
407
|
+
var BrandingContext = React3.createContext(null);
|
|
408
|
+
var NavigationContext = React3.createContext([]);
|
|
409
|
+
var PaletteModeContext = React3.createContext({
|
|
451
410
|
paletteMode: "light",
|
|
452
411
|
setPaletteMode: () => {
|
|
453
412
|
},
|
|
454
413
|
isDualTheme: false
|
|
455
414
|
});
|
|
456
|
-
var RouterContext =
|
|
457
|
-
var DashboardSidebarPageItemContext =
|
|
458
|
-
var WindowContext =
|
|
459
|
-
|
|
460
|
-
// src/toolpad-core/AppProvider/AppThemeProvider.tsx
|
|
461
|
-
import * as React8 from "react";
|
|
462
|
-
import { useMediaQuery } from "@mui/material";
|
|
463
|
-
import { ThemeProvider, useColorScheme } from "@mui/material/styles";
|
|
464
|
-
import InitColorSchemeScript from "@mui/material/InitColorSchemeScript";
|
|
465
|
-
import CssBaseline from "@mui/material/CssBaseline";
|
|
466
|
-
import invariant2 from "invariant";
|
|
467
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
415
|
+
var RouterContext = React3.createContext(null);
|
|
416
|
+
var DashboardSidebarPageItemContext = React3.createContext(null);
|
|
417
|
+
var WindowContext = React3.createContext(void 0);
|
|
468
418
|
var COLOR_SCHEME_STORAGE_KEY = "toolpad-color-scheme";
|
|
469
419
|
var MODE_STORAGE_KEY = "toolpad-mode";
|
|
470
420
|
function usePreferredMode(window2) {
|
|
@@ -481,19 +431,19 @@ function isCssVarsTheme(theme) {
|
|
|
481
431
|
}
|
|
482
432
|
function LegacyThemeProvider(props) {
|
|
483
433
|
const { children, theme, window: appWindow } = props;
|
|
484
|
-
|
|
434
|
+
invariant(!isCssVarsTheme(theme), "This provider only accepts legacy themes.");
|
|
485
435
|
const isDualTheme = "light" in theme || "dark" in theme;
|
|
486
436
|
const preferredMode = usePreferredMode(appWindow);
|
|
487
437
|
const [userMode, setUserMode] = useLocalStorageState(MODE_STORAGE_KEY, "system");
|
|
488
438
|
const paletteMode = !userMode || userMode === "system" ? preferredMode : userMode;
|
|
489
|
-
const dualAwareTheme =
|
|
439
|
+
const dualAwareTheme = React3.useMemo(
|
|
490
440
|
() => {
|
|
491
441
|
var _a;
|
|
492
442
|
return isDualTheme ? (_a = theme[paletteMode === "dark" ? "dark" : "light"]) != null ? _a : theme[paletteMode === "dark" ? "light" : "dark"] : theme;
|
|
493
443
|
},
|
|
494
444
|
[isDualTheme, paletteMode, theme]
|
|
495
445
|
);
|
|
496
|
-
const paletteModeContextValue =
|
|
446
|
+
const paletteModeContextValue = React3.useMemo(
|
|
497
447
|
() => ({
|
|
498
448
|
paletteMode,
|
|
499
449
|
setPaletteMode: setUserMode,
|
|
@@ -501,8 +451,8 @@ function LegacyThemeProvider(props) {
|
|
|
501
451
|
}),
|
|
502
452
|
[isDualTheme, paletteMode, setUserMode]
|
|
503
453
|
);
|
|
504
|
-
return /* @__PURE__ */
|
|
505
|
-
/* @__PURE__ */
|
|
454
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme: dualAwareTheme, children: /* @__PURE__ */ jsxs(PaletteModeContext.Provider, { value: paletteModeContextValue, children: [
|
|
455
|
+
/* @__PURE__ */ jsx(CssBaseline, { enableColorScheme: true }),
|
|
506
456
|
children
|
|
507
457
|
] }) });
|
|
508
458
|
}
|
|
@@ -510,19 +460,19 @@ function CssVarsPaletteModeProvider(props) {
|
|
|
510
460
|
const { children, window: appWindow } = props;
|
|
511
461
|
const preferredMode = usePreferredMode(appWindow);
|
|
512
462
|
const { mode, setMode, allColorSchemes } = useColorScheme();
|
|
513
|
-
const paletteModeContextValue =
|
|
463
|
+
const paletteModeContextValue = React3.useMemo(() => {
|
|
514
464
|
return {
|
|
515
465
|
paletteMode: !mode || mode === "system" ? preferredMode : mode,
|
|
516
466
|
setPaletteMode: setMode,
|
|
517
467
|
isDualTheme: allColorSchemes.length > 1
|
|
518
468
|
};
|
|
519
469
|
}, [allColorSchemes, mode, preferredMode, setMode]);
|
|
520
|
-
return /* @__PURE__ */
|
|
470
|
+
return /* @__PURE__ */ jsx(PaletteModeContext.Provider, { value: paletteModeContextValue, children });
|
|
521
471
|
}
|
|
522
472
|
function CssVarsThemeProvider(props) {
|
|
523
473
|
const { children, theme, window: appWindow, nonce } = props;
|
|
524
|
-
|
|
525
|
-
return /* @__PURE__ */
|
|
474
|
+
invariant(isCssVarsTheme(theme), "This provider only accepts CSS vars themes.");
|
|
475
|
+
return /* @__PURE__ */ jsxs(
|
|
526
476
|
ThemeProvider,
|
|
527
477
|
{
|
|
528
478
|
theme,
|
|
@@ -532,7 +482,7 @@ function CssVarsThemeProvider(props) {
|
|
|
532
482
|
colorSchemeStorageKey: COLOR_SCHEME_STORAGE_KEY,
|
|
533
483
|
modeStorageKey: MODE_STORAGE_KEY,
|
|
534
484
|
children: [
|
|
535
|
-
/* @__PURE__ */
|
|
485
|
+
/* @__PURE__ */ jsx(
|
|
536
486
|
InitColorSchemeScript,
|
|
537
487
|
{
|
|
538
488
|
attribute: theme.colorSchemeSelector,
|
|
@@ -541,8 +491,8 @@ function CssVarsThemeProvider(props) {
|
|
|
541
491
|
nonce
|
|
542
492
|
}
|
|
543
493
|
),
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
-
/* @__PURE__ */
|
|
494
|
+
/* @__PURE__ */ jsxs(CssVarsPaletteModeProvider, { window: appWindow, children: [
|
|
495
|
+
/* @__PURE__ */ jsx(CssBaseline, { enableColorScheme: true }),
|
|
546
496
|
children
|
|
547
497
|
] })
|
|
548
498
|
]
|
|
@@ -552,13 +502,10 @@ function CssVarsThemeProvider(props) {
|
|
|
552
502
|
function AppThemeProvider(props) {
|
|
553
503
|
const _a = props, { children, theme } = _a, rest = __objRest(_a, ["children", "theme"]);
|
|
554
504
|
const useCssVarsProvider = isCssVarsTheme(theme);
|
|
555
|
-
return useCssVarsProvider ? /* @__PURE__ */
|
|
505
|
+
return useCssVarsProvider ? /* @__PURE__ */ jsx(CssVarsThemeProvider, __spreadProps(__spreadValues({ theme }, rest), { children })) : /* @__PURE__ */ jsx(LegacyThemeProvider, __spreadProps(__spreadValues({ theme }, rest), { children }));
|
|
556
506
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
560
|
-
var AuthenticationContext = React9.createContext(null);
|
|
561
|
-
var SessionContext = React9.createContext(null);
|
|
507
|
+
var AuthenticationContext = React3.createContext(null);
|
|
508
|
+
var SessionContext = React3.createContext(null);
|
|
562
509
|
function createDefaultTheme() {
|
|
563
510
|
return createTheme({
|
|
564
511
|
cssVariables: {
|
|
@@ -580,7 +527,7 @@ function AppProvider(props) {
|
|
|
580
527
|
window: appWindow,
|
|
581
528
|
nonce
|
|
582
529
|
} = props;
|
|
583
|
-
return /* @__PURE__ */
|
|
530
|
+
return /* @__PURE__ */ jsx(WindowContext.Provider, { value: appWindow, children: /* @__PURE__ */ jsx(AuthenticationContext.Provider, { value: authentication, children: /* @__PURE__ */ jsx(SessionContext.Provider, { value: session, children: /* @__PURE__ */ jsx(RouterContext.Provider, { value: router, children: /* @__PURE__ */ jsx(AppThemeProvider, { theme, window: appWindow, nonce, children: /* @__PURE__ */ jsx(LocalizationProvider, { localeText, children: /* @__PURE__ */ jsx(NotificationsProvider, { children: /* @__PURE__ */ jsx(DialogsProvider, { children: /* @__PURE__ */ jsx(BrandingContext.Provider, { value: branding, children: /* @__PURE__ */ jsx(NavigationContext.Provider, { value: navigation, children }) }) }) }) }) }) }) }) }) });
|
|
584
531
|
}
|
|
585
532
|
AppProvider.propTypes = {
|
|
586
533
|
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
@@ -686,25 +633,4 @@ AppProvider.propTypes = {
|
|
|
686
633
|
window: PropTypes2.object
|
|
687
634
|
};
|
|
688
635
|
|
|
689
|
-
export {
|
|
690
|
-
NotificationsContext,
|
|
691
|
-
en_default,
|
|
692
|
-
LocalizationContext,
|
|
693
|
-
LocalizationProvider,
|
|
694
|
-
useLocaleText,
|
|
695
|
-
NotificationsProvider,
|
|
696
|
-
DialogsContext,
|
|
697
|
-
BrandingContext,
|
|
698
|
-
NavigationContext,
|
|
699
|
-
PaletteModeContext,
|
|
700
|
-
RouterContext,
|
|
701
|
-
DashboardSidebarPageItemContext,
|
|
702
|
-
WindowContext,
|
|
703
|
-
DialogsProvider,
|
|
704
|
-
useStorageStateServer,
|
|
705
|
-
useStorageState,
|
|
706
|
-
useLocalStorageState,
|
|
707
|
-
AuthenticationContext,
|
|
708
|
-
SessionContext,
|
|
709
|
-
AppProvider
|
|
710
|
-
};
|
|
636
|
+
export { AppProvider, AuthenticationContext, BrandingContext, DashboardSidebarPageItemContext, DialogsContext, DialogsProvider, LocalizationContext, LocalizationProvider, NavigationContext, NotificationsContext, NotificationsProvider, PaletteModeContext, RouterContext, SessionContext, WindowContext, en_default, useLocalStorageState, useLocaleText, useStorageState, useStorageStateServer };
|
package/dist/chunk-PMIWCP25.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
1
3
|
// src/toolpad-utils/collections.ts
|
|
2
4
|
function asArray(maybeArray) {
|
|
3
5
|
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
@@ -31,9 +33,6 @@ function equalProperties(obj1, obj2, subset) {
|
|
|
31
33
|
);
|
|
32
34
|
return Array.from(keysToCheck).every((key) => Object.is(obj1[key], obj2[key]));
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
// src/toolpad-utils/hooks/useBoolean.ts
|
|
36
|
-
import * as React from "react";
|
|
37
36
|
function useBoolean(initialValue) {
|
|
38
37
|
const [value, setValue] = React.useState(initialValue);
|
|
39
38
|
const toggle = React.useCallback(() => setValue((existing) => !existing), []);
|
|
@@ -41,11 +40,8 @@ function useBoolean(initialValue) {
|
|
|
41
40
|
const setFalse = React.useCallback(() => setValue(false), []);
|
|
42
41
|
return { value, setValue, toggle, setTrue, setFalse };
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
// src/toolpad-utils/hooks/usePageTitle.ts
|
|
46
|
-
import * as React2 from "react";
|
|
47
43
|
function usePageTitle(title) {
|
|
48
|
-
|
|
44
|
+
React.useEffect(() => {
|
|
49
45
|
const original = document.title;
|
|
50
46
|
document.title = title;
|
|
51
47
|
return () => {
|
|
@@ -54,15 +50,4 @@ function usePageTitle(title) {
|
|
|
54
50
|
}, [title]);
|
|
55
51
|
}
|
|
56
52
|
|
|
57
|
-
export {
|
|
58
|
-
asArray,
|
|
59
|
-
hasOwnProperty,
|
|
60
|
-
mapProperties,
|
|
61
|
-
mapKeys,
|
|
62
|
-
mapValues,
|
|
63
|
-
filterValues,
|
|
64
|
-
filterKeys,
|
|
65
|
-
equalProperties,
|
|
66
|
-
useBoolean,
|
|
67
|
-
usePageTitle
|
|
68
|
-
};
|
|
53
|
+
export { asArray, equalProperties, filterKeys, filterValues, hasOwnProperty, mapKeys, mapProperties, mapValues, useBoolean, usePageTitle };
|