@mui/system 5.15.7 → 5.15.8

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.
@@ -1,11 +1,12 @@
1
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
1
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["ownerState"],
4
+ _excluded2 = ["variants"],
5
+ _excluded3 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
4
6
  /* eslint-disable no-underscore-dangle */
5
7
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
6
- import { getDisplayName, unstable_capitalize as capitalize, isPlainObject, deepmerge } from '@mui/utils';
8
+ import { getDisplayName, unstable_capitalize as capitalize, isPlainObject } from '@mui/utils';
7
9
  import createTheme from './createTheme';
8
- import propsToClassKey from './propsToClassKey';
9
10
  import styleFunctionSx from './styleFunctionSx';
10
11
  function isEmpty(obj) {
11
12
  return Object.keys(obj).length === 0;
@@ -19,74 +20,6 @@ function isStringTag(tag) {
19
20
  // it's a lowercase character
20
21
  tag.charCodeAt(0) > 96;
21
22
  }
22
- const getStyleOverrides = (name, theme) => {
23
- if (theme.components && theme.components[name] && theme.components[name].styleOverrides) {
24
- return theme.components[name].styleOverrides;
25
- }
26
- return null;
27
- };
28
- const transformVariants = variants => {
29
- let numOfCallbacks = 0;
30
- const variantsStyles = {};
31
- if (variants) {
32
- variants.forEach(definition => {
33
- let key = '';
34
- if (typeof definition.props === 'function') {
35
- key = `callback${numOfCallbacks}`;
36
- numOfCallbacks += 1;
37
- } else {
38
- key = propsToClassKey(definition.props);
39
- }
40
- variantsStyles[key] = definition.style;
41
- });
42
- }
43
- return variantsStyles;
44
- };
45
- const getVariantStyles = (name, theme) => {
46
- let variants = [];
47
- if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
48
- variants = theme.components[name].variants;
49
- }
50
- return transformVariants(variants);
51
- };
52
- const variantsResolver = (props, styles, variants) => {
53
- const {
54
- ownerState = {}
55
- } = props;
56
- const variantsStyles = [];
57
- let numOfCallbacks = 0;
58
- if (variants) {
59
- variants.forEach(variant => {
60
- let isMatch = true;
61
- if (typeof variant.props === 'function') {
62
- const propsToCheck = _extends({}, props, ownerState);
63
- isMatch = variant.props(propsToCheck);
64
- } else {
65
- Object.keys(variant.props).forEach(key => {
66
- if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
67
- isMatch = false;
68
- }
69
- });
70
- }
71
- if (isMatch) {
72
- if (typeof variant.props === 'function') {
73
- variantsStyles.push(styles[`callback${numOfCallbacks}`]);
74
- } else {
75
- variantsStyles.push(styles[propsToClassKey(variant.props)]);
76
- }
77
- }
78
- if (typeof variant.props === 'function') {
79
- numOfCallbacks += 1;
80
- }
81
- });
82
- }
83
- return variantsStyles;
84
- };
85
- const themeVariantsResolver = (props, styles, theme, name) => {
86
- var _theme$components;
87
- const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
88
- return variantsResolver(props, styles, themeVariants);
89
- };
90
23
 
91
24
  // Update /system/styled/#api in case if this changes
92
25
  export function shouldForwardProp(prop) {
@@ -112,29 +45,51 @@ function defaultOverridesResolver(slot) {
112
45
  }
113
46
  return (props, styles) => styles[slot];
114
47
  }
115
- const muiStyledFunctionResolver = ({
116
- styledArg,
117
- props,
118
- defaultTheme,
119
- themeId
120
- }) => {
121
- const resolvedStyles = styledArg(_extends({}, props, {
122
- theme: resolveTheme(_extends({}, props, {
123
- defaultTheme,
124
- themeId
125
- }))
126
- }));
127
- let optionalVariants;
128
- if (resolvedStyles && resolvedStyles.variants) {
129
- optionalVariants = resolvedStyles.variants;
130
- delete resolvedStyles.variants;
48
+ function processStyleArg(callableStyle, _ref) {
49
+ let {
50
+ ownerState
51
+ } = _ref,
52
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
53
+ const resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle(_extends({
54
+ ownerState
55
+ }, props)) : callableStyle;
56
+ if (Array.isArray(resolvedStylesArg)) {
57
+ return resolvedStylesArg.flatMap(resolvedStyle => processStyleArg(resolvedStyle, _extends({
58
+ ownerState
59
+ }, props)));
131
60
  }
132
- if (optionalVariants) {
133
- const variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
134
- return [resolvedStyles, ...variantsStyles];
61
+ if (!!resolvedStylesArg && typeof resolvedStylesArg === 'object' && Array.isArray(resolvedStylesArg.variants)) {
62
+ const {
63
+ variants = []
64
+ } = resolvedStylesArg,
65
+ otherStyles = _objectWithoutPropertiesLoose(resolvedStylesArg, _excluded2);
66
+ let result = otherStyles;
67
+ variants.forEach(variant => {
68
+ let isMatch = true;
69
+ if (typeof variant.props === 'function') {
70
+ isMatch = variant.props(_extends({
71
+ ownerState
72
+ }, props));
73
+ } else {
74
+ Object.keys(variant.props).forEach(key => {
75
+ if ((ownerState == null ? void 0 : ownerState[key]) !== variant.props[key] && props[key] !== variant.props[key]) {
76
+ isMatch = false;
77
+ }
78
+ });
79
+ }
80
+ if (isMatch) {
81
+ if (!Array.isArray(result)) {
82
+ result = [result];
83
+ }
84
+ result.push(typeof variant.style === 'function' ? variant.style(_extends({
85
+ ownerState
86
+ }, props)) : variant.style);
87
+ }
88
+ });
89
+ return result;
135
90
  }
136
- return resolvedStyles;
137
- };
91
+ return resolvedStylesArg;
92
+ }
138
93
  export default function createStyled(input = {}) {
139
94
  const {
140
95
  themeId,
@@ -163,7 +118,7 @@ export default function createStyled(input = {}) {
163
118
  // For more details: https://github.com/mui/material-ui/pull/37908
164
119
  overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot))
165
120
  } = inputOptions,
166
- options = _objectWithoutPropertiesLoose(inputOptions, _excluded);
121
+ options = _objectWithoutPropertiesLoose(inputOptions, _excluded3);
167
122
 
168
123
  // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
169
124
  const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
@@ -196,92 +151,57 @@ export default function createStyled(input = {}) {
196
151
  shouldForwardProp: shouldForwardPropOption,
197
152
  label
198
153
  }, options));
199
- const muiStyledResolver = (styleArg, ...expressions) => {
200
- const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => {
201
- // On the server Emotion doesn't use React.forwardRef for creating components, so the created
202
- // component stays as a function. This condition makes sure that we do not interpolate functions
203
- // which are basically components used as a selectors.
204
- if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
205
- return props => muiStyledFunctionResolver({
206
- styledArg: stylesArg,
207
- props,
208
- defaultTheme,
209
- themeId
210
- });
211
- }
212
- if (isPlainObject(stylesArg)) {
213
- let transformedStylesArg = stylesArg;
214
- let styledArgVariants;
215
- if (stylesArg && stylesArg.variants) {
216
- styledArgVariants = stylesArg.variants;
217
- delete transformedStylesArg.variants;
218
- transformedStylesArg = props => {
219
- let result = stylesArg;
220
- const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
221
- variantStyles.forEach(variantStyle => {
222
- result = deepmerge(result, variantStyle);
223
- });
224
- return result;
225
- };
226
- }
227
- return transformedStylesArg;
228
- }
229
- return stylesArg;
230
- }) : [];
231
- let transformedStyleArg = styleArg;
232
- if (isPlainObject(styleArg)) {
233
- let styledArgVariants;
234
- if (styleArg && styleArg.variants) {
235
- styledArgVariants = styleArg.variants;
236
- delete transformedStyleArg.variants;
237
- transformedStyleArg = props => {
238
- let result = styleArg;
239
- const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
240
- variantStyles.forEach(variantStyle => {
241
- result = deepmerge(result, variantStyle);
242
- });
243
- return result;
244
- };
245
- }
246
- } else if (typeof styleArg === 'function' &&
154
+ const transformStyleArg = stylesArg => {
247
155
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
248
156
  // component stays as a function. This condition makes sure that we do not interpolate functions
249
157
  // which are basically components used as a selectors.
250
- styleArg.__emotion_real !== styleArg) {
251
- // If the type is function, we need to define the default theme.
252
- transformedStyleArg = props => muiStyledFunctionResolver({
253
- styledArg: styleArg,
254
- props,
255
- defaultTheme,
256
- themeId
257
- });
158
+ if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg || isPlainObject(stylesArg)) {
159
+ return props => processStyleArg(stylesArg, _extends({}, props, {
160
+ theme: resolveTheme({
161
+ theme: props.theme,
162
+ defaultTheme,
163
+ themeId
164
+ })
165
+ }));
258
166
  }
167
+ return stylesArg;
168
+ };
169
+ const muiStyledResolver = (styleArg, ...expressions) => {
170
+ let transformedStyleArg = transformStyleArg(styleArg);
171
+ const expressionsWithDefaultTheme = expressions ? expressions.map(transformStyleArg) : [];
259
172
  if (componentName && overridesResolver) {
260
173
  expressionsWithDefaultTheme.push(props => {
261
174
  const theme = resolveTheme(_extends({}, props, {
262
175
  defaultTheme,
263
176
  themeId
264
177
  }));
265
- const styleOverrides = getStyleOverrides(componentName, theme);
266
- if (styleOverrides) {
267
- const resolvedStyleOverrides = {};
268
- Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
269
- resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
270
- theme
271
- })) : slotStyle;
272
- });
273
- return overridesResolver(props, resolvedStyleOverrides);
178
+ if (!theme.components || !theme.components[componentName] || !theme.components[componentName].styleOverrides) {
179
+ return null;
274
180
  }
275
- return null;
181
+ const styleOverrides = theme.components[componentName].styleOverrides;
182
+ const resolvedStyleOverrides = {};
183
+ // TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly
184
+ Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
185
+ resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, _extends({}, props, {
186
+ theme
187
+ }));
188
+ });
189
+ return overridesResolver(props, resolvedStyleOverrides);
276
190
  });
277
191
  }
278
192
  if (componentName && !skipVariantsResolver) {
279
193
  expressionsWithDefaultTheme.push(props => {
194
+ var _theme$components;
280
195
  const theme = resolveTheme(_extends({}, props, {
281
196
  defaultTheme,
282
197
  themeId
283
198
  }));
284
- return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
199
+ const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[componentName]) == null ? void 0 : _theme$components.variants;
200
+ return processStyleArg({
201
+ variants: themeVariants
202
+ }, _extends({}, props, {
203
+ theme
204
+ }));
285
205
  });
286
206
  }
287
207
  if (!skipSx) {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.15.7
2
+ * @mui/system v5.15.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -331,4 +331,26 @@ export function private_safeEmphasize(color, coefficient, warning) {
331
331
  }
332
332
  return color;
333
333
  }
334
+ }
335
+
336
+ /**
337
+ * Blend a transparent overlay color with a background color, resulting in a single
338
+ * RGB color.
339
+ * @param {string} background - CSS color
340
+ * @param {string} overlay - CSS color
341
+ * @param {number} opacity - Opacity multiplier in the range 0 - 1
342
+ * @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
343
+ */
344
+ export function blend(background, overlay, opacity) {
345
+ var gamma = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1.0;
346
+ var blendChannel = function blendChannel(b, o) {
347
+ return Math.round(Math.pow(Math.pow(b, 1 / gamma) * (1 - opacity) + Math.pow(o, 1 / gamma) * opacity, gamma));
348
+ };
349
+ var backgroundColor = decomposeColor(background);
350
+ var overlayColor = decomposeColor(overlay);
351
+ var rgb = [blendChannel(backgroundColor.values[0], overlayColor.values[0]), blendChannel(backgroundColor.values[1], overlayColor.values[1]), blendChannel(backgroundColor.values[2], overlayColor.values[2])];
352
+ return recomposeColor({
353
+ type: 'rgb',
354
+ values: rgb
355
+ });
334
356
  }
@@ -1,12 +1,12 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
4
4
  import _extends from "@babel/runtime/helpers/esm/extends";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
6
  /* eslint-disable no-underscore-dangle */
6
7
  import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
7
- import { getDisplayName, unstable_capitalize as capitalize, isPlainObject, deepmerge } from '@mui/utils';
8
+ import { getDisplayName, unstable_capitalize as capitalize, isPlainObject } from '@mui/utils';
8
9
  import createTheme from './createTheme';
9
- import propsToClassKey from './propsToClassKey';
10
10
  import styleFunctionSx from './styleFunctionSx';
11
11
  function isEmpty(obj) {
12
12
  return Object.keys(obj).length === 0;
@@ -20,73 +20,6 @@ function isStringTag(tag) {
20
20
  // it's a lowercase character
21
21
  tag.charCodeAt(0) > 96;
22
22
  }
23
- var getStyleOverrides = function getStyleOverrides(name, theme) {
24
- if (theme.components && theme.components[name] && theme.components[name].styleOverrides) {
25
- return theme.components[name].styleOverrides;
26
- }
27
- return null;
28
- };
29
- var transformVariants = function transformVariants(variants) {
30
- var numOfCallbacks = 0;
31
- var variantsStyles = {};
32
- if (variants) {
33
- variants.forEach(function (definition) {
34
- var key = '';
35
- if (typeof definition.props === 'function') {
36
- key = "callback".concat(numOfCallbacks);
37
- numOfCallbacks += 1;
38
- } else {
39
- key = propsToClassKey(definition.props);
40
- }
41
- variantsStyles[key] = definition.style;
42
- });
43
- }
44
- return variantsStyles;
45
- };
46
- var getVariantStyles = function getVariantStyles(name, theme) {
47
- var variants = [];
48
- if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
49
- variants = theme.components[name].variants;
50
- }
51
- return transformVariants(variants);
52
- };
53
- var variantsResolver = function variantsResolver(props, styles, variants) {
54
- var _props$ownerState = props.ownerState,
55
- ownerState = _props$ownerState === void 0 ? {} : _props$ownerState;
56
- var variantsStyles = [];
57
- var numOfCallbacks = 0;
58
- if (variants) {
59
- variants.forEach(function (variant) {
60
- var isMatch = true;
61
- if (typeof variant.props === 'function') {
62
- var propsToCheck = _extends({}, props, ownerState);
63
- isMatch = variant.props(propsToCheck);
64
- } else {
65
- Object.keys(variant.props).forEach(function (key) {
66
- if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
67
- isMatch = false;
68
- }
69
- });
70
- }
71
- if (isMatch) {
72
- if (typeof variant.props === 'function') {
73
- variantsStyles.push(styles["callback".concat(numOfCallbacks)]);
74
- } else {
75
- variantsStyles.push(styles[propsToClassKey(variant.props)]);
76
- }
77
- }
78
- if (typeof variant.props === 'function') {
79
- numOfCallbacks += 1;
80
- }
81
- });
82
- }
83
- return variantsStyles;
84
- };
85
- var themeVariantsResolver = function themeVariantsResolver(props, styles, theme, name) {
86
- var _theme$components;
87
- var themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
88
- return variantsResolver(props, styles, themeVariants);
89
- };
90
23
 
91
24
  // Update /system/styled/#api in case if this changes
92
25
  export function shouldForwardProp(prop) {
@@ -113,28 +46,50 @@ function defaultOverridesResolver(slot) {
113
46
  return styles[slot];
114
47
  };
115
48
  }
116
- var muiStyledFunctionResolver = function muiStyledFunctionResolver(_ref2) {
117
- var styledArg = _ref2.styledArg,
118
- props = _ref2.props,
119
- defaultTheme = _ref2.defaultTheme,
120
- themeId = _ref2.themeId;
121
- var resolvedStyles = styledArg(_extends({}, props, {
122
- theme: resolveTheme(_extends({}, props, {
123
- defaultTheme: defaultTheme,
124
- themeId: themeId
125
- }))
126
- }));
127
- var optionalVariants;
128
- if (resolvedStyles && resolvedStyles.variants) {
129
- optionalVariants = resolvedStyles.variants;
130
- delete resolvedStyles.variants;
49
+ function processStyleArg(callableStyle, _ref2) {
50
+ var ownerState = _ref2.ownerState,
51
+ props = _objectWithoutProperties(_ref2, ["ownerState"]);
52
+ var resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle(_extends({
53
+ ownerState: ownerState
54
+ }, props)) : callableStyle;
55
+ if (Array.isArray(resolvedStylesArg)) {
56
+ return resolvedStylesArg.flatMap(function (resolvedStyle) {
57
+ return processStyleArg(resolvedStyle, _extends({
58
+ ownerState: ownerState
59
+ }, props));
60
+ });
131
61
  }
132
- if (optionalVariants) {
133
- var variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
134
- return [resolvedStyles].concat(_toConsumableArray(variantsStyles));
62
+ if (!!resolvedStylesArg && _typeof(resolvedStylesArg) === 'object' && Array.isArray(resolvedStylesArg.variants)) {
63
+ var _resolvedStylesArg$va = resolvedStylesArg.variants,
64
+ variants = _resolvedStylesArg$va === void 0 ? [] : _resolvedStylesArg$va,
65
+ otherStyles = _objectWithoutProperties(resolvedStylesArg, ["variants"]);
66
+ var result = otherStyles;
67
+ variants.forEach(function (variant) {
68
+ var isMatch = true;
69
+ if (typeof variant.props === 'function') {
70
+ isMatch = variant.props(_extends({
71
+ ownerState: ownerState
72
+ }, props));
73
+ } else {
74
+ Object.keys(variant.props).forEach(function (key) {
75
+ if ((ownerState == null ? void 0 : ownerState[key]) !== variant.props[key] && props[key] !== variant.props[key]) {
76
+ isMatch = false;
77
+ }
78
+ });
79
+ }
80
+ if (isMatch) {
81
+ if (!Array.isArray(result)) {
82
+ result = [result];
83
+ }
84
+ result.push(typeof variant.style === 'function' ? variant.style(_extends({
85
+ ownerState: ownerState
86
+ }, props)) : variant.style);
87
+ }
88
+ });
89
+ return result;
135
90
  }
136
- return resolvedStyles;
137
- };
91
+ return resolvedStylesArg;
92
+ }
138
93
  export default function createStyled() {
139
94
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
140
95
  var themeId = input.themeId,
@@ -198,102 +153,65 @@ export default function createStyled() {
198
153
  shouldForwardProp: shouldForwardPropOption,
199
154
  label: label
200
155
  }, options));
201
- var muiStyledResolver = function muiStyledResolver(styleArg) {
202
- for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
203
- expressions[_key - 1] = arguments[_key];
204
- }
205
- var expressionsWithDefaultTheme = expressions ? expressions.map(function (stylesArg) {
206
- // On the server Emotion doesn't use React.forwardRef for creating components, so the created
207
- // component stays as a function. This condition makes sure that we do not interpolate functions
208
- // which are basically components used as a selectors.
209
- if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
210
- return function (props) {
211
- return muiStyledFunctionResolver({
212
- styledArg: stylesArg,
213
- props: props,
214
- defaultTheme: defaultTheme,
215
- themeId: themeId
216
- });
217
- };
218
- }
219
- if (isPlainObject(stylesArg)) {
220
- var transformedStylesArg = stylesArg;
221
- var styledArgVariants;
222
- if (stylesArg && stylesArg.variants) {
223
- styledArgVariants = stylesArg.variants;
224
- delete transformedStylesArg.variants;
225
- transformedStylesArg = function transformedStylesArg(props) {
226
- var result = stylesArg;
227
- var variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
228
- variantStyles.forEach(function (variantStyle) {
229
- result = deepmerge(result, variantStyle);
230
- });
231
- return result;
232
- };
233
- }
234
- return transformedStylesArg;
235
- }
236
- return stylesArg;
237
- }) : [];
238
- var transformedStyleArg = styleArg;
239
- if (isPlainObject(styleArg)) {
240
- var styledArgVariants;
241
- if (styleArg && styleArg.variants) {
242
- styledArgVariants = styleArg.variants;
243
- delete transformedStyleArg.variants;
244
- transformedStyleArg = function transformedStyleArg(props) {
245
- var result = styleArg;
246
- var variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
247
- variantStyles.forEach(function (variantStyle) {
248
- result = deepmerge(result, variantStyle);
249
- });
250
- return result;
251
- };
252
- }
253
- } else if (typeof styleArg === 'function' &&
156
+ var transformStyleArg = function transformStyleArg(stylesArg) {
254
157
  // On the server Emotion doesn't use React.forwardRef for creating components, so the created
255
158
  // component stays as a function. This condition makes sure that we do not interpolate functions
256
159
  // which are basically components used as a selectors.
257
- styleArg.__emotion_real !== styleArg) {
258
- // If the type is function, we need to define the default theme.
259
- transformedStyleArg = function transformedStyleArg(props) {
260
- return muiStyledFunctionResolver({
261
- styledArg: styleArg,
262
- props: props,
263
- defaultTheme: defaultTheme,
264
- themeId: themeId
265
- });
160
+ if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg || isPlainObject(stylesArg)) {
161
+ return function (props) {
162
+ return processStyleArg(stylesArg, _extends({}, props, {
163
+ theme: resolveTheme({
164
+ theme: props.theme,
165
+ defaultTheme: defaultTheme,
166
+ themeId: themeId
167
+ })
168
+ }));
266
169
  };
267
170
  }
171
+ return stylesArg;
172
+ };
173
+ var muiStyledResolver = function muiStyledResolver(styleArg) {
174
+ var transformedStyleArg = transformStyleArg(styleArg);
175
+ for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
176
+ expressions[_key - 1] = arguments[_key];
177
+ }
178
+ var expressionsWithDefaultTheme = expressions ? expressions.map(transformStyleArg) : [];
268
179
  if (componentName && overridesResolver) {
269
180
  expressionsWithDefaultTheme.push(function (props) {
270
181
  var theme = resolveTheme(_extends({}, props, {
271
182
  defaultTheme: defaultTheme,
272
183
  themeId: themeId
273
184
  }));
274
- var styleOverrides = getStyleOverrides(componentName, theme);
275
- if (styleOverrides) {
276
- var resolvedStyleOverrides = {};
277
- Object.entries(styleOverrides).forEach(function (_ref3) {
278
- var _ref4 = _slicedToArray(_ref3, 2),
279
- slotKey = _ref4[0],
280
- slotStyle = _ref4[1];
281
- resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
282
- theme: theme
283
- })) : slotStyle;
284
- });
285
- return overridesResolver(props, resolvedStyleOverrides);
185
+ if (!theme.components || !theme.components[componentName] || !theme.components[componentName].styleOverrides) {
186
+ return null;
286
187
  }
287
- return null;
188
+ var styleOverrides = theme.components[componentName].styleOverrides;
189
+ var resolvedStyleOverrides = {};
190
+ // TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly
191
+ Object.entries(styleOverrides).forEach(function (_ref3) {
192
+ var _ref4 = _slicedToArray(_ref3, 2),
193
+ slotKey = _ref4[0],
194
+ slotStyle = _ref4[1];
195
+ resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, _extends({}, props, {
196
+ theme: theme
197
+ }));
198
+ });
199
+ return overridesResolver(props, resolvedStyleOverrides);
288
200
  });
289
201
  }
290
202
  if (componentName && !skipVariantsResolver) {
291
203
  expressionsWithDefaultTheme.push(function (props) {
204
+ var _theme$components;
292
205
  var theme = resolveTheme(_extends({}, props, {
293
206
  defaultTheme: defaultTheme,
294
207
  themeId: themeId
295
208
  }));
296
- return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
209
+ var themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[componentName]) == null ? void 0 : _theme$components.variants;
210
+ return processStyleArg({
211
+ variants: themeVariants
212
+ }, _extends({}, props, {
213
+ theme: theme
214
+ }));
297
215
  });
298
216
  }
299
217
  if (!skipSx) {
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.15.7
2
+ * @mui/system v5.15.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -323,4 +323,23 @@ export function private_safeEmphasize(color, coefficient, warning) {
323
323
  }
324
324
  return color;
325
325
  }
326
+ }
327
+
328
+ /**
329
+ * Blend a transparent overlay color with a background color, resulting in a single
330
+ * RGB color.
331
+ * @param {string} background - CSS color
332
+ * @param {string} overlay - CSS color
333
+ * @param {number} opacity - Opacity multiplier in the range 0 - 1
334
+ * @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
335
+ */
336
+ export function blend(background, overlay, opacity, gamma = 1.0) {
337
+ const blendChannel = (b, o) => Math.round((b ** (1 / gamma) * (1 - opacity) + o ** (1 / gamma) * opacity) ** gamma);
338
+ const backgroundColor = decomposeColor(background);
339
+ const overlayColor = decomposeColor(overlay);
340
+ const rgb = [blendChannel(backgroundColor.values[0], overlayColor.values[0]), blendChannel(backgroundColor.values[1], overlayColor.values[1]), blendChannel(backgroundColor.values[2], overlayColor.values[2])];
341
+ return recomposeColor({
342
+ type: 'rgb',
343
+ values: rgb
344
+ });
326
345
  }