@mui/system 5.0.3 → 5.1.0
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/CHANGELOG.md +274 -0
- package/borders.js +1 -1
- package/breakpoints.js +45 -11
- package/colorManipulator.js +8 -8
- package/createBox.d.ts +5 -1
- package/createBox.js +5 -3
- package/createStyled.d.ts +16 -190
- package/createStyled.js +6 -2
- package/createTheme/createBreakpoints.d.ts +53 -6
- package/createTheme/createBreakpoints.js +3 -3
- package/cssVars/createCssVarsProvider.d.ts +131 -0
- package/cssVars/createCssVarsProvider.js +228 -0
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -0
- package/cssVars/cssVarsParser.d.ts +68 -0
- package/cssVars/cssVarsParser.js +156 -0
- package/cssVars/getInitColorSchemeScript.d.ts +12 -0
- package/cssVars/getInitColorSchemeScript.js +60 -0
- package/cssVars/index.d.ts +2 -0
- package/cssVars/index.js +15 -0
- package/cssVars/package.json +6 -0
- package/cssVars/useCurrentColorScheme.d.ts +50 -0
- package/cssVars/useCurrentColorScheme.js +235 -0
- package/display.js +1 -1
- package/esm/breakpoints.js +39 -8
- package/esm/createBox.js +5 -3
- package/esm/createStyled.js +5 -1
- package/esm/createTheme/createBreakpoints.js +2 -2
- package/esm/cssVars/createCssVarsProvider.js +207 -0
- package/esm/cssVars/cssVarsParser.js +141 -0
- package/esm/cssVars/getInitColorSchemeScript.js +42 -0
- package/esm/cssVars/index.js +1 -0
- package/esm/cssVars/useCurrentColorScheme.js +217 -0
- package/esm/index.js +2 -1
- package/esm/styleFunctionSx/extendSxProp.js +20 -1
- package/esm/styleFunctionSx/styleFunctionSx.js +45 -35
- package/flexbox.js +1 -1
- package/getThemeValue.js +1 -1
- package/grid.js +1 -1
- package/index.d.ts +6 -0
- package/index.js +77 -68
- package/legacy/breakpoints.js +39 -8
- package/legacy/createBox.js +6 -3
- package/legacy/createStyled.js +5 -1
- package/legacy/createTheme/createBreakpoints.js +2 -2
- package/legacy/cssVars/createCssVarsProvider.js +215 -0
- package/legacy/cssVars/cssVarsParser.js +153 -0
- package/legacy/cssVars/getInitColorSchemeScript.js +27 -0
- package/legacy/cssVars/index.js +1 -0
- package/legacy/cssVars/useCurrentColorScheme.js +231 -0
- package/legacy/index.js +3 -2
- package/legacy/styleFunctionSx/extendSxProp.js +21 -1
- package/legacy/styleFunctionSx/styleFunctionSx.js +44 -34
- package/modern/breakpoints.js +39 -8
- package/modern/createBox.js +5 -3
- package/modern/createStyled.js +5 -1
- package/modern/createTheme/createBreakpoints.js +2 -2
- package/modern/cssVars/createCssVarsProvider.js +207 -0
- package/modern/cssVars/cssVarsParser.js +141 -0
- package/modern/cssVars/getInitColorSchemeScript.js +42 -0
- package/modern/cssVars/index.js +1 -0
- package/modern/cssVars/useCurrentColorScheme.js +217 -0
- package/modern/index.js +3 -2
- package/modern/styleFunctionSx/extendSxProp.js +20 -1
- package/modern/styleFunctionSx/styleFunctionSx.js +45 -35
- package/package.json +8 -8
- package/palette.js +1 -1
- package/positions.js +1 -1
- package/sizing.js +1 -1
- package/spacing.js +3 -3
- package/style.d.ts +2 -2
- package/style.js +1 -1
- package/styleFunctionSx/extendSxProp.js +21 -1
- package/styleFunctionSx/styleFunctionSx.d.ts +7 -1
- package/styleFunctionSx/styleFunctionSx.js +46 -36
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -0
- package/typography.js +1 -1
- package/useTheme.js +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.0
|
|
1
|
+
/** @license MUI v5.1.0
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -47,18 +47,13 @@ var _exportNames = {
|
|
|
47
47
|
getThemeProps: true,
|
|
48
48
|
useTheme: true,
|
|
49
49
|
useThemeWithoutDefault: true,
|
|
50
|
-
ThemeProvider: true
|
|
50
|
+
ThemeProvider: true,
|
|
51
|
+
unstable_createCssVarsProvider: true
|
|
51
52
|
};
|
|
52
|
-
Object.defineProperty(exports, "
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return _styledEngine.css;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(exports, "keyframes", {
|
|
53
|
+
Object.defineProperty(exports, "Box", {
|
|
59
54
|
enumerable: true,
|
|
60
55
|
get: function () {
|
|
61
|
-
return
|
|
56
|
+
return _Box.default;
|
|
62
57
|
}
|
|
63
58
|
});
|
|
64
59
|
Object.defineProperty(exports, "GlobalStyles", {
|
|
@@ -73,6 +68,12 @@ Object.defineProperty(exports, "StyledEngineProvider", {
|
|
|
73
68
|
return _styledEngine.StyledEngineProvider;
|
|
74
69
|
}
|
|
75
70
|
});
|
|
71
|
+
Object.defineProperty(exports, "ThemeProvider", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () {
|
|
74
|
+
return _ThemeProvider.default;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
76
77
|
Object.defineProperty(exports, "borders", {
|
|
77
78
|
enumerable: true,
|
|
78
79
|
get: function () {
|
|
@@ -85,130 +86,136 @@ Object.defineProperty(exports, "breakpoints", {
|
|
|
85
86
|
return _breakpoints.default;
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
|
-
Object.defineProperty(exports, "
|
|
89
|
+
Object.defineProperty(exports, "compose", {
|
|
89
90
|
enumerable: true,
|
|
90
91
|
get: function () {
|
|
91
|
-
return
|
|
92
|
+
return _compose.default;
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
|
-
Object.defineProperty(exports, "
|
|
95
|
+
Object.defineProperty(exports, "createBox", {
|
|
95
96
|
enumerable: true,
|
|
96
97
|
get: function () {
|
|
97
|
-
return
|
|
98
|
+
return _createBox.default;
|
|
98
99
|
}
|
|
99
100
|
});
|
|
100
|
-
Object.defineProperty(exports, "
|
|
101
|
+
Object.defineProperty(exports, "createBreakpoints", {
|
|
101
102
|
enumerable: true,
|
|
102
103
|
get: function () {
|
|
103
|
-
return
|
|
104
|
+
return _createBreakpoints.default;
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
|
-
Object.defineProperty(exports, "
|
|
107
|
+
Object.defineProperty(exports, "createSpacing", {
|
|
107
108
|
enumerable: true,
|
|
108
109
|
get: function () {
|
|
109
|
-
return
|
|
110
|
+
return _createSpacing.default;
|
|
110
111
|
}
|
|
111
112
|
});
|
|
112
|
-
Object.defineProperty(exports, "
|
|
113
|
+
Object.defineProperty(exports, "createStyled", {
|
|
113
114
|
enumerable: true,
|
|
114
115
|
get: function () {
|
|
115
|
-
return
|
|
116
|
+
return _createStyled.default;
|
|
116
117
|
}
|
|
117
118
|
});
|
|
118
|
-
Object.defineProperty(exports, "
|
|
119
|
+
Object.defineProperty(exports, "createTheme", {
|
|
119
120
|
enumerable: true,
|
|
120
121
|
get: function () {
|
|
121
|
-
return
|
|
122
|
+
return _createTheme.default;
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
|
-
Object.defineProperty(exports, "
|
|
125
|
+
Object.defineProperty(exports, "css", {
|
|
125
126
|
enumerable: true,
|
|
126
127
|
get: function () {
|
|
127
|
-
return
|
|
128
|
+
return _styledEngine.css;
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
|
-
Object.defineProperty(exports, "
|
|
131
|
+
Object.defineProperty(exports, "display", {
|
|
131
132
|
enumerable: true,
|
|
132
133
|
get: function () {
|
|
133
|
-
return
|
|
134
|
+
return _display.default;
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
|
-
Object.defineProperty(exports, "
|
|
137
|
+
Object.defineProperty(exports, "flexbox", {
|
|
137
138
|
enumerable: true,
|
|
138
139
|
get: function () {
|
|
139
|
-
return
|
|
140
|
+
return _flexbox.default;
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
|
-
Object.defineProperty(exports, "
|
|
143
|
+
Object.defineProperty(exports, "getPath", {
|
|
143
144
|
enumerable: true,
|
|
144
145
|
get: function () {
|
|
145
|
-
return
|
|
146
|
+
return _style.getPath;
|
|
146
147
|
}
|
|
147
148
|
});
|
|
148
|
-
Object.defineProperty(exports, "
|
|
149
|
+
Object.defineProperty(exports, "getThemeProps", {
|
|
149
150
|
enumerable: true,
|
|
150
151
|
get: function () {
|
|
151
|
-
return
|
|
152
|
+
return _useThemeProps.getThemeProps;
|
|
152
153
|
}
|
|
153
154
|
});
|
|
154
|
-
Object.defineProperty(exports, "
|
|
155
|
+
Object.defineProperty(exports, "grid", {
|
|
155
156
|
enumerable: true,
|
|
156
157
|
get: function () {
|
|
157
|
-
return
|
|
158
|
+
return _grid.default;
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
|
-
Object.defineProperty(exports, "
|
|
161
|
+
Object.defineProperty(exports, "handleBreakpoints", {
|
|
161
162
|
enumerable: true,
|
|
162
163
|
get: function () {
|
|
163
|
-
return
|
|
164
|
+
return _breakpoints.handleBreakpoints;
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
|
-
Object.defineProperty(exports, "
|
|
167
|
+
Object.defineProperty(exports, "keyframes", {
|
|
167
168
|
enumerable: true,
|
|
168
169
|
get: function () {
|
|
169
|
-
return
|
|
170
|
+
return _styledEngine.keyframes;
|
|
170
171
|
}
|
|
171
172
|
});
|
|
172
|
-
Object.defineProperty(exports, "
|
|
173
|
+
Object.defineProperty(exports, "mergeBreakpointsInOrder", {
|
|
173
174
|
enumerable: true,
|
|
174
175
|
get: function () {
|
|
175
|
-
return
|
|
176
|
+
return _breakpoints.mergeBreakpointsInOrder;
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
|
-
Object.defineProperty(exports, "
|
|
179
|
+
Object.defineProperty(exports, "palette", {
|
|
179
180
|
enumerable: true,
|
|
180
181
|
get: function () {
|
|
181
|
-
return
|
|
182
|
+
return _palette.default;
|
|
182
183
|
}
|
|
183
184
|
});
|
|
184
|
-
Object.defineProperty(exports, "
|
|
185
|
+
Object.defineProperty(exports, "positions", {
|
|
185
186
|
enumerable: true,
|
|
186
187
|
get: function () {
|
|
187
|
-
return
|
|
188
|
+
return _positions.default;
|
|
188
189
|
}
|
|
189
190
|
});
|
|
190
|
-
Object.defineProperty(exports, "
|
|
191
|
+
Object.defineProperty(exports, "shadows", {
|
|
191
192
|
enumerable: true,
|
|
192
193
|
get: function () {
|
|
193
|
-
return
|
|
194
|
+
return _shadows.default;
|
|
194
195
|
}
|
|
195
196
|
});
|
|
196
|
-
Object.defineProperty(exports, "
|
|
197
|
+
Object.defineProperty(exports, "shape", {
|
|
197
198
|
enumerable: true,
|
|
198
199
|
get: function () {
|
|
199
|
-
return
|
|
200
|
+
return _shape.default;
|
|
200
201
|
}
|
|
201
202
|
});
|
|
202
|
-
Object.defineProperty(exports, "
|
|
203
|
+
Object.defineProperty(exports, "sizing", {
|
|
203
204
|
enumerable: true,
|
|
204
205
|
get: function () {
|
|
205
|
-
return
|
|
206
|
+
return _sizing.default;
|
|
206
207
|
}
|
|
207
208
|
});
|
|
208
|
-
Object.defineProperty(exports, "
|
|
209
|
+
Object.defineProperty(exports, "spacing", {
|
|
209
210
|
enumerable: true,
|
|
210
211
|
get: function () {
|
|
211
|
-
return
|
|
212
|
+
return _spacing.default;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
Object.defineProperty(exports, "style", {
|
|
216
|
+
enumerable: true,
|
|
217
|
+
get: function () {
|
|
218
|
+
return _style.default;
|
|
212
219
|
}
|
|
213
220
|
});
|
|
214
221
|
Object.defineProperty(exports, "styled", {
|
|
@@ -217,40 +224,40 @@ Object.defineProperty(exports, "styled", {
|
|
|
217
224
|
return _styled.default;
|
|
218
225
|
}
|
|
219
226
|
});
|
|
220
|
-
Object.defineProperty(exports, "
|
|
227
|
+
Object.defineProperty(exports, "typography", {
|
|
221
228
|
enumerable: true,
|
|
222
229
|
get: function () {
|
|
223
|
-
return
|
|
230
|
+
return _typography.default;
|
|
224
231
|
}
|
|
225
232
|
});
|
|
226
|
-
Object.defineProperty(exports, "
|
|
233
|
+
Object.defineProperty(exports, "unstable_createCssVarsProvider", {
|
|
227
234
|
enumerable: true,
|
|
228
235
|
get: function () {
|
|
229
|
-
return
|
|
236
|
+
return _createCssVarsProvider.default;
|
|
230
237
|
}
|
|
231
238
|
});
|
|
232
|
-
Object.defineProperty(exports, "
|
|
239
|
+
Object.defineProperty(exports, "unstable_extendSxProp", {
|
|
233
240
|
enumerable: true,
|
|
234
241
|
get: function () {
|
|
235
|
-
return
|
|
242
|
+
return _styleFunctionSx.extendSxProp;
|
|
236
243
|
}
|
|
237
244
|
});
|
|
238
|
-
Object.defineProperty(exports, "
|
|
245
|
+
Object.defineProperty(exports, "unstable_getThemeValue", {
|
|
239
246
|
enumerable: true,
|
|
240
247
|
get: function () {
|
|
241
|
-
return
|
|
248
|
+
return _getThemeValue.default;
|
|
242
249
|
}
|
|
243
250
|
});
|
|
244
|
-
Object.defineProperty(exports, "
|
|
251
|
+
Object.defineProperty(exports, "unstable_resolveBreakpointValues", {
|
|
245
252
|
enumerable: true,
|
|
246
253
|
get: function () {
|
|
247
|
-
return
|
|
254
|
+
return _breakpoints.resolveBreakpointValues;
|
|
248
255
|
}
|
|
249
256
|
});
|
|
250
|
-
Object.defineProperty(exports, "
|
|
257
|
+
Object.defineProperty(exports, "unstable_styleFunctionSx", {
|
|
251
258
|
enumerable: true,
|
|
252
259
|
get: function () {
|
|
253
|
-
return
|
|
260
|
+
return _styleFunctionSx.default;
|
|
254
261
|
}
|
|
255
262
|
});
|
|
256
263
|
Object.defineProperty(exports, "useTheme", {
|
|
@@ -259,16 +266,16 @@ Object.defineProperty(exports, "useTheme", {
|
|
|
259
266
|
return _useTheme.default;
|
|
260
267
|
}
|
|
261
268
|
});
|
|
262
|
-
Object.defineProperty(exports, "
|
|
269
|
+
Object.defineProperty(exports, "useThemeProps", {
|
|
263
270
|
enumerable: true,
|
|
264
271
|
get: function () {
|
|
265
|
-
return
|
|
272
|
+
return _useThemeProps.default;
|
|
266
273
|
}
|
|
267
274
|
});
|
|
268
|
-
Object.defineProperty(exports, "
|
|
275
|
+
Object.defineProperty(exports, "useThemeWithoutDefault", {
|
|
269
276
|
enumerable: true,
|
|
270
277
|
get: function () {
|
|
271
|
-
return
|
|
278
|
+
return _useThemeWithoutDefault.default;
|
|
272
279
|
}
|
|
273
280
|
});
|
|
274
281
|
|
|
@@ -450,6 +457,8 @@ Object.keys(_colorManipulator).forEach(function (key) {
|
|
|
450
457
|
|
|
451
458
|
var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider"));
|
|
452
459
|
|
|
460
|
+
var _createCssVarsProvider = _interopRequireDefault(require("./cssVars/createCssVarsProvider"));
|
|
461
|
+
|
|
453
462
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
454
463
|
|
|
455
464
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/legacy/breakpoints.js
CHANGED
|
@@ -10,12 +10,12 @@ export var values = {
|
|
|
10
10
|
xs: 0,
|
|
11
11
|
// phone
|
|
12
12
|
sm: 600,
|
|
13
|
-
//
|
|
13
|
+
// tablet
|
|
14
14
|
md: 900,
|
|
15
15
|
// small laptop
|
|
16
16
|
lg: 1200,
|
|
17
17
|
// desktop
|
|
18
|
-
xl: 1536 // large
|
|
18
|
+
xl: 1536 // large screen
|
|
19
19
|
|
|
20
20
|
};
|
|
21
21
|
var defaultBreakpoints = {
|
|
@@ -122,10 +122,40 @@ export function mergeBreakpointsInOrder(breakpointsInput) {
|
|
|
122
122
|
return deepmerge(prev, next);
|
|
123
123
|
}, {});
|
|
124
124
|
return removeUnusedBreakpoints(Object.keys(emptyBreakpoints), mergedOutput);
|
|
125
|
+
} // compute base for responsive values; e.g.,
|
|
126
|
+
// [1,2,3] => {xs: true, sm: true, md: true}
|
|
127
|
+
// {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
|
|
128
|
+
|
|
129
|
+
export function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
|
|
130
|
+
// fixed value
|
|
131
|
+
if (_typeof(breakpointValues) !== 'object') {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
var base = {};
|
|
136
|
+
var breakpointsKeys = Object.keys(themeBreakpoints);
|
|
137
|
+
|
|
138
|
+
if (Array.isArray(breakpointValues)) {
|
|
139
|
+
breakpointsKeys.forEach(function (breakpoint, i) {
|
|
140
|
+
if (i < breakpointValues.length) {
|
|
141
|
+
base[breakpoint] = true;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
} else {
|
|
145
|
+
breakpointsKeys.forEach(function (breakpoint) {
|
|
146
|
+
if (breakpointValues[breakpoint] != null) {
|
|
147
|
+
base[breakpoint] = true;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return base;
|
|
125
153
|
}
|
|
126
154
|
export function resolveBreakpointValues(_ref) {
|
|
127
155
|
var breakpointValues = _ref.values,
|
|
128
|
-
|
|
156
|
+
themeBreakpoints = _ref.breakpoints,
|
|
157
|
+
customBase = _ref.base;
|
|
158
|
+
var base = customBase || computeBreakpointsBase(breakpointValues, themeBreakpoints);
|
|
129
159
|
var keys = Object.keys(base);
|
|
130
160
|
|
|
131
161
|
if (keys.length === 0) {
|
|
@@ -133,14 +163,15 @@ export function resolveBreakpointValues(_ref) {
|
|
|
133
163
|
}
|
|
134
164
|
|
|
135
165
|
var previous;
|
|
136
|
-
return keys.reduce(function (acc, breakpoint) {
|
|
137
|
-
if (
|
|
138
|
-
acc[breakpoint] = breakpointValues[
|
|
166
|
+
return keys.reduce(function (acc, breakpoint, i) {
|
|
167
|
+
if (Array.isArray(breakpointValues)) {
|
|
168
|
+
acc[breakpoint] = breakpointValues[i] != null ? breakpointValues[i] : breakpointValues[previous];
|
|
169
|
+
previous = i;
|
|
139
170
|
} else {
|
|
140
|
-
acc[breakpoint] = breakpointValues;
|
|
171
|
+
acc[breakpoint] = breakpointValues[breakpoint] != null ? breakpointValues[breakpoint] : breakpointValues[previous] || breakpointValues;
|
|
172
|
+
previous = breakpoint;
|
|
141
173
|
}
|
|
142
174
|
|
|
143
|
-
previous = breakpoint;
|
|
144
175
|
return acc;
|
|
145
176
|
}, {});
|
|
146
177
|
}
|
package/legacy/createBox.js
CHANGED
|
@@ -9,7 +9,10 @@ import useTheme from './useTheme';
|
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
export default function createBox() {
|
|
11
11
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
|
-
var defaultTheme = options.defaultTheme
|
|
12
|
+
var defaultTheme = options.defaultTheme,
|
|
13
|
+
_options$defaultClass = options.defaultClassName,
|
|
14
|
+
defaultClassName = _options$defaultClass === void 0 ? 'MuiBox-root' : _options$defaultClass,
|
|
15
|
+
generateClassName = options.generateClassName;
|
|
13
16
|
var BoxRoot = styled('div')(styleFunctionSx);
|
|
14
17
|
var Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
15
18
|
var theme = useTheme(defaultTheme);
|
|
@@ -23,7 +26,7 @@ export default function createBox() {
|
|
|
23
26
|
return /*#__PURE__*/_jsx(BoxRoot, _extends({
|
|
24
27
|
as: component,
|
|
25
28
|
ref: ref,
|
|
26
|
-
className: clsx(className,
|
|
29
|
+
className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
|
|
27
30
|
theme: theme
|
|
28
31
|
}, other));
|
|
29
32
|
});
|
|
@@ -49,7 +52,7 @@ export default function createBox() {
|
|
|
49
52
|
/**
|
|
50
53
|
* @ignore
|
|
51
54
|
*/
|
|
52
|
-
sx: PropTypes.object
|
|
55
|
+
sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
|
|
53
56
|
} : void 0;
|
|
54
57
|
return Box;
|
|
55
58
|
}
|
package/legacy/createStyled.js
CHANGED
|
@@ -118,7 +118,11 @@ export default function createStyled() {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
var expressionsWithDefaultTheme = expressions ? expressions.map(function (stylesArg) {
|
|
121
|
-
|
|
121
|
+
// On the server emotion doesn't use React.forwardRef for creating components, so the created
|
|
122
|
+
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
123
|
+
// which are basically components used as a selectors.
|
|
124
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
125
|
+
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? function (_ref) {
|
|
122
126
|
var themeInput = _ref.theme,
|
|
123
127
|
other = _objectWithoutProperties(_ref, ["theme"]);
|
|
124
128
|
|
|
@@ -10,12 +10,12 @@ export default function createBreakpoints(breakpoints) {
|
|
|
10
10
|
xs: 0,
|
|
11
11
|
// phone
|
|
12
12
|
sm: 600,
|
|
13
|
-
//
|
|
13
|
+
// tablet
|
|
14
14
|
md: 900,
|
|
15
15
|
// small laptop
|
|
16
16
|
lg: 1200,
|
|
17
17
|
// desktop
|
|
18
|
-
xl: 1536 // large
|
|
18
|
+
xl: 1536 // large screen
|
|
19
19
|
|
|
20
20
|
} : _breakpoints$values,
|
|
21
21
|
_breakpoints$unit = breakpoints.unit,
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
5
|
+
import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { GlobalStyles } from '@mui/styled-engine';
|
|
9
|
+
import { deepmerge } from '@mui/utils';
|
|
10
|
+
import cssVarsParser from './cssVarsParser';
|
|
11
|
+
import ThemeProvider from '../ThemeProvider';
|
|
12
|
+
import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
|
|
13
|
+
import useCurrentColorScheme from './useCurrentColorScheme';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
export default function createCssVarsProvider(options) {
|
|
17
|
+
var _options$theme = options.theme,
|
|
18
|
+
baseTheme = _options$theme === void 0 ? {} : _options$theme,
|
|
19
|
+
_options$defaultMode = options.defaultMode,
|
|
20
|
+
desisgnSystemMode = _options$defaultMode === void 0 ? 'light' : _options$defaultMode,
|
|
21
|
+
designSystemColorScheme = options.defaultColorScheme,
|
|
22
|
+
_options$prefix = options.prefix,
|
|
23
|
+
designSystemPrefix = _options$prefix === void 0 ? '' : _options$prefix,
|
|
24
|
+
shouldSkipGeneratingVar = options.shouldSkipGeneratingVar;
|
|
25
|
+
|
|
26
|
+
if (!baseTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !baseTheme.colorSchemes[designSystemColorScheme] || _typeof(designSystemColorScheme) === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || _typeof(designSystemColorScheme) === 'object' && !baseTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
|
|
27
|
+
console.error("MUI: `".concat(designSystemColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var ColorSchemeContext = /*#__PURE__*/React.createContext(undefined);
|
|
31
|
+
|
|
32
|
+
var useColorScheme = function useColorScheme() {
|
|
33
|
+
var value = React.useContext(ColorSchemeContext);
|
|
34
|
+
|
|
35
|
+
if (!value) {
|
|
36
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "MUI: `useColorScheme` must be called under <CssVarsProvider />" : _formatMuiErrorMessage(19));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return value;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function CssVarsProvider(_ref) {
|
|
43
|
+
var children = _ref.children,
|
|
44
|
+
_ref$theme = _ref.theme,
|
|
45
|
+
themeProp = _ref$theme === void 0 ? {} : _ref$theme,
|
|
46
|
+
_ref$prefix = _ref.prefix,
|
|
47
|
+
prefix = _ref$prefix === void 0 ? designSystemPrefix : _ref$prefix,
|
|
48
|
+
_ref$modeStorageKey = _ref.modeStorageKey,
|
|
49
|
+
modeStorageKey = _ref$modeStorageKey === void 0 ? DEFAULT_MODE_STORAGE_KEY : _ref$modeStorageKey,
|
|
50
|
+
_ref$attribute = _ref.attribute,
|
|
51
|
+
attribute = _ref$attribute === void 0 ? DEFAULT_ATTRIBUTE : _ref$attribute,
|
|
52
|
+
_ref$defaultMode = _ref.defaultMode,
|
|
53
|
+
defaultMode = _ref$defaultMode === void 0 ? desisgnSystemMode : _ref$defaultMode,
|
|
54
|
+
_ref$defaultColorSche = _ref.defaultColorScheme,
|
|
55
|
+
defaultColorScheme = _ref$defaultColorSche === void 0 ? designSystemColorScheme : _ref$defaultColorSche;
|
|
56
|
+
|
|
57
|
+
var _baseTheme$colorSchem = baseTheme.colorSchemes,
|
|
58
|
+
baseColorSchemes = _baseTheme$colorSchem === void 0 ? {} : _baseTheme$colorSchem,
|
|
59
|
+
restBaseTheme = _objectWithoutProperties(baseTheme, ["colorSchemes"]);
|
|
60
|
+
|
|
61
|
+
var _themeProp$colorSchem = themeProp.colorSchemes,
|
|
62
|
+
colorSchemesProp = _themeProp$colorSchem === void 0 ? {} : _themeProp$colorSchem,
|
|
63
|
+
restThemeProp = _objectWithoutProperties(themeProp, ["colorSchemes"]);
|
|
64
|
+
|
|
65
|
+
var mergedTheme = deepmerge(restBaseTheme, restThemeProp);
|
|
66
|
+
var colorSchemes = deepmerge(baseColorSchemes, colorSchemesProp);
|
|
67
|
+
var allColorSchemes = Object.keys(colorSchemes);
|
|
68
|
+
var defaultLightColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.light;
|
|
69
|
+
var defaultDarkColorScheme = typeof defaultColorScheme === 'string' ? defaultColorScheme : defaultColorScheme.dark;
|
|
70
|
+
|
|
71
|
+
var _useCurrentColorSchem = useCurrentColorScheme({
|
|
72
|
+
supportedColorSchemes: allColorSchemes,
|
|
73
|
+
defaultLightColorScheme: defaultLightColorScheme,
|
|
74
|
+
defaultDarkColorScheme: defaultDarkColorScheme,
|
|
75
|
+
modeStorageKey: modeStorageKey,
|
|
76
|
+
defaultMode: defaultMode
|
|
77
|
+
}),
|
|
78
|
+
mode = _useCurrentColorSchem.mode,
|
|
79
|
+
setMode = _useCurrentColorSchem.setMode,
|
|
80
|
+
lightColorScheme = _useCurrentColorSchem.lightColorScheme,
|
|
81
|
+
darkColorScheme = _useCurrentColorSchem.darkColorScheme,
|
|
82
|
+
colorScheme = _useCurrentColorSchem.colorScheme,
|
|
83
|
+
setColorScheme = _useCurrentColorSchem.setColorScheme;
|
|
84
|
+
|
|
85
|
+
var resolvedColorScheme = function () {
|
|
86
|
+
if (!colorScheme) {
|
|
87
|
+
// This scope occurs on the server
|
|
88
|
+
if (defaultMode === 'dark') {
|
|
89
|
+
return defaultDarkColorScheme;
|
|
90
|
+
} // use light color scheme, if default mode is 'light' | 'auto'
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
return defaultLightColorScheme;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return colorScheme;
|
|
97
|
+
}();
|
|
98
|
+
|
|
99
|
+
var _cssVarsParser = cssVarsParser(mergedTheme, {
|
|
100
|
+
prefix: prefix,
|
|
101
|
+
basePrefix: designSystemPrefix,
|
|
102
|
+
shouldSkipGeneratingVar: shouldSkipGeneratingVar
|
|
103
|
+
}),
|
|
104
|
+
rootCss = _cssVarsParser.css,
|
|
105
|
+
rootVars = _cssVarsParser.vars;
|
|
106
|
+
|
|
107
|
+
mergedTheme = _extends({}, mergedTheme, colorSchemes[resolvedColorScheme], {
|
|
108
|
+
vars: rootVars
|
|
109
|
+
});
|
|
110
|
+
var styleSheet = {};
|
|
111
|
+
Object.entries(colorSchemes).forEach(function (_ref2) {
|
|
112
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
113
|
+
key = _ref3[0],
|
|
114
|
+
scheme = _ref3[1];
|
|
115
|
+
|
|
116
|
+
var _cssVarsParser2 = cssVarsParser(scheme, {
|
|
117
|
+
prefix: prefix,
|
|
118
|
+
basePrefix: designSystemPrefix,
|
|
119
|
+
shouldSkipGeneratingVar: shouldSkipGeneratingVar
|
|
120
|
+
}),
|
|
121
|
+
css = _cssVarsParser2.css,
|
|
122
|
+
vars = _cssVarsParser2.vars;
|
|
123
|
+
|
|
124
|
+
if (key === resolvedColorScheme) {
|
|
125
|
+
mergedTheme.vars = _extends({}, mergedTheme.vars, vars);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var resolvedDefaultColorScheme = function () {
|
|
129
|
+
if (typeof defaultColorScheme === 'string') {
|
|
130
|
+
return defaultColorScheme;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (defaultMode === 'dark') {
|
|
134
|
+
return defaultColorScheme.dark;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return defaultColorScheme.light;
|
|
138
|
+
}();
|
|
139
|
+
|
|
140
|
+
if (key === resolvedDefaultColorScheme) {
|
|
141
|
+
styleSheet[':root'] = css;
|
|
142
|
+
} else {
|
|
143
|
+
styleSheet["[".concat(attribute, "=\"").concat(key, "\"]")] = css;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
React.useEffect(function () {
|
|
147
|
+
if (colorScheme) {
|
|
148
|
+
document.body.setAttribute(attribute, colorScheme);
|
|
149
|
+
}
|
|
150
|
+
}, [colorScheme, attribute]);
|
|
151
|
+
return /*#__PURE__*/_jsxs(ColorSchemeContext.Provider, {
|
|
152
|
+
value: {
|
|
153
|
+
mode: mode,
|
|
154
|
+
setMode: setMode,
|
|
155
|
+
lightColorScheme: lightColorScheme,
|
|
156
|
+
darkColorScheme: darkColorScheme,
|
|
157
|
+
colorScheme: colorScheme,
|
|
158
|
+
setColorScheme: setColorScheme,
|
|
159
|
+
allColorSchemes: allColorSchemes
|
|
160
|
+
},
|
|
161
|
+
children: [/*#__PURE__*/_jsx(GlobalStyles, {
|
|
162
|
+
styles: {
|
|
163
|
+
':root': rootCss
|
|
164
|
+
}
|
|
165
|
+
}), /*#__PURE__*/_jsx(GlobalStyles, {
|
|
166
|
+
styles: styleSheet
|
|
167
|
+
}), /*#__PURE__*/_jsx(ThemeProvider, {
|
|
168
|
+
theme: mergedTheme,
|
|
169
|
+
children: children
|
|
170
|
+
})]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
|
|
175
|
+
/**
|
|
176
|
+
* The body attribute name to attach colorScheme.
|
|
177
|
+
*/
|
|
178
|
+
attribute: PropTypes.string,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Your component tree.
|
|
182
|
+
*/
|
|
183
|
+
children: PropTypes.node,
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The initial color scheme used.
|
|
187
|
+
*/
|
|
188
|
+
defaultColorScheme: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The initial mode used.
|
|
192
|
+
*/
|
|
193
|
+
defaultMode: PropTypes.string,
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The key in the local storage used to store current color scheme.
|
|
197
|
+
*/
|
|
198
|
+
modeStorageKey: PropTypes.string,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* css variable prefix
|
|
202
|
+
*/
|
|
203
|
+
prefix: PropTypes.string,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The calculated theme object that will be passed through context.
|
|
207
|
+
*/
|
|
208
|
+
theme: PropTypes.object
|
|
209
|
+
} : void 0;
|
|
210
|
+
return {
|
|
211
|
+
CssVarsProvider: CssVarsProvider,
|
|
212
|
+
useColorScheme: useColorScheme,
|
|
213
|
+
getInitColorSchemeScript: getInitColorSchemeScript
|
|
214
|
+
};
|
|
215
|
+
}
|