@mui/material 5.17.0 → 5.18.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.
Files changed (38) hide show
  1. package/Breadcrumbs/BreadcrumbCollapsed.js +3 -1
  2. package/CHANGELOG.md +34 -0
  3. package/OutlinedInput/NotchedOutline.js +2 -0
  4. package/Radio/RadioButtonIcon.js +7 -2
  5. package/SwipeableDrawer/SwipeArea.js +1 -0
  6. package/index.js +1 -1
  7. package/internal/SwitchBase.js +4 -1
  8. package/legacy/Breadcrumbs/BreadcrumbCollapsed.js +3 -1
  9. package/legacy/OutlinedInput/NotchedOutline.js +2 -0
  10. package/legacy/Radio/RadioButtonIcon.js +7 -2
  11. package/legacy/SwipeableDrawer/SwipeArea.js +1 -0
  12. package/legacy/index.js +1 -1
  13. package/legacy/internal/SwitchBase.js +4 -1
  14. package/legacy/styles/shouldSkipGeneratingVar.js +1 -1
  15. package/legacy/version/index.js +2 -2
  16. package/modern/Breadcrumbs/BreadcrumbCollapsed.js +3 -1
  17. package/modern/OutlinedInput/NotchedOutline.js +2 -0
  18. package/modern/Radio/RadioButtonIcon.js +7 -2
  19. package/modern/SwipeableDrawer/SwipeArea.js +1 -0
  20. package/modern/index.js +1 -1
  21. package/modern/internal/SwitchBase.js +4 -1
  22. package/modern/styles/shouldSkipGeneratingVar.js +1 -1
  23. package/modern/version/index.js +2 -2
  24. package/node/Breadcrumbs/BreadcrumbCollapsed.js +3 -1
  25. package/node/OutlinedInput/NotchedOutline.js +2 -0
  26. package/node/Radio/RadioButtonIcon.js +7 -2
  27. package/node/SwipeableDrawer/SwipeArea.js +1 -0
  28. package/node/index.js +1 -1
  29. package/node/internal/SwitchBase.js +4 -1
  30. package/node/styles/shouldSkipGeneratingVar.js +1 -1
  31. package/node/version/index.js +2 -2
  32. package/package.json +5 -5
  33. package/styles/createTheme.d.ts +1 -0
  34. package/styles/experimental_extendTheme.d.ts +5 -0
  35. package/styles/shouldSkipGeneratingVar.js +1 -1
  36. package/umd/material-ui.development.js +172 -33
  37. package/umd/material-ui.production.min.js +2 -2
  38. package/version/index.js +2 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.17.0
2
+ * @mui/material v5.18.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -5160,26 +5160,58 @@
5160
5160
 
5161
5161
  var jsxRuntimeExports = requireJsxRuntime();
5162
5162
 
5163
- var cache;
5164
- if ((typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object') {
5165
- cache = createCache({
5163
+ function getCache(injectFirst, enableCssLayer) {
5164
+ var emotionCache = createCache({
5166
5165
  key: 'css',
5167
- prepend: true
5166
+ prepend: injectFirst
5168
5167
  });
5168
+ if (enableCssLayer) {
5169
+ var prevInsert = emotionCache.insert;
5170
+ emotionCache.insert = function () {
5171
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5172
+ args[_key] = arguments[_key];
5173
+ }
5174
+ if (!args[1].styles.match(/^@layer\s+[^{]*$/)) {
5175
+ // avoid nested @layer
5176
+ args[1].styles = "@layer mui {".concat(args[1].styles, "}");
5177
+ }
5178
+ return prevInsert.apply(void 0, args);
5179
+ };
5180
+ }
5181
+ return emotionCache;
5169
5182
  }
5183
+ var cacheMap = new Map();
5170
5184
  function StyledEngineProvider(props) {
5171
5185
  var injectFirst = props.injectFirst,
5186
+ enableCssLayer = props.enableCssLayer,
5172
5187
  children = props.children;
5173
- return injectFirst && cache ? /*#__PURE__*/jsxRuntimeExports.jsx(CacheProvider, {
5174
- value: cache,
5175
- children: children
5176
- }) : children;
5188
+ var cache = React__namespace.useMemo(function () {
5189
+ var cacheKey = "".concat(injectFirst, "-").concat(enableCssLayer);
5190
+ if ((typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && cacheMap.has(cacheKey)) {
5191
+ return cacheMap.get(cacheKey);
5192
+ }
5193
+ var fresh = getCache(injectFirst, enableCssLayer);
5194
+ cacheMap.set(cacheKey, fresh);
5195
+ return fresh;
5196
+ }, [injectFirst, enableCssLayer]);
5197
+ if (injectFirst || enableCssLayer) {
5198
+ return /*#__PURE__*/jsxRuntimeExports.jsx(CacheProvider, {
5199
+ value: cache,
5200
+ children: children
5201
+ });
5202
+ }
5203
+ return children;
5177
5204
  }
5178
5205
  StyledEngineProvider.propTypes = {
5179
5206
  /**
5180
5207
  * Your component tree.
5181
5208
  */
5182
5209
  children: PropTypes.node,
5210
+ /**
5211
+ * If true, MUI styles are wrapped in CSS `@layer mui` rule.
5212
+ * It helps to override MUI styles when using CSS Modules, Tailwind CSS, plain CSS, or any other styling solution.
5213
+ */
5214
+ enableCssLayer: PropTypes.bool,
5183
5215
  /**
5184
5216
  * By default, the styles are injected last in the <head> element of the page.
5185
5217
  * As a result, they gain more specificity than any other style sheet.
@@ -5236,6 +5268,14 @@
5236
5268
  }
5237
5269
  };
5238
5270
 
5271
+ // Emotion only accepts an array, but we want to avoid allocations
5272
+ var wrapper = [];
5273
+ // eslint-disable-next-line @typescript-eslint/naming-convention
5274
+ function internal_serializeStyles(styles) {
5275
+ wrapper[0] = styles;
5276
+ return serializeStyles(wrapper);
5277
+ }
5278
+
5239
5279
  // https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
5240
5280
  function isPlainObject(item) {
5241
5281
  if (_typeof(item) !== 'object' || item === null) {
@@ -6439,7 +6479,8 @@
6439
6479
  var _ref4 = props || {},
6440
6480
  sx = _ref4.sx,
6441
6481
  _ref4$theme = _ref4.theme,
6442
- theme = _ref4$theme === void 0 ? {} : _ref4$theme;
6482
+ theme = _ref4$theme === void 0 ? {} : _ref4$theme,
6483
+ nested = _ref4.nested;
6443
6484
  if (!sx) {
6444
6485
  return null; // Emotion & styled-components will neglect null
6445
6486
  }
@@ -6479,7 +6520,8 @@
6479
6520
  if (objectsHaveSameKeys(breakpointsValues, value)) {
6480
6521
  css[styleKey] = styleFunctionSx({
6481
6522
  sx: value,
6482
- theme: theme
6523
+ theme: theme,
6524
+ nested: true
6483
6525
  });
6484
6526
  } else {
6485
6527
  css = merge(css, breakpointsValues);
@@ -6490,6 +6532,11 @@
6490
6532
  }
6491
6533
  }
6492
6534
  });
6535
+ if (!nested && theme.modularCssLayers) {
6536
+ return {
6537
+ '@layer sx': removeUnusedBreakpoints(breakpointsKeys, css)
6538
+ };
6539
+ }
6493
6540
  return removeUnusedBreakpoints(breakpointsKeys, css);
6494
6541
  }
6495
6542
  return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
@@ -6628,13 +6675,37 @@
6628
6675
  return useTheme$3(defaultTheme);
6629
6676
  }
6630
6677
 
6678
+ function wrapGlobalLayer(styles) {
6679
+ var serialized = internal_serializeStyles(styles);
6680
+ if (styles !== serialized && serialized.styles) {
6681
+ if (!serialized.styles.match(/^@layer\s+[^{]*$/)) {
6682
+ // If the styles are not already wrapped in a layer, wrap them in a global layer.
6683
+ serialized.styles = "@layer global{".concat(serialized.styles, "}");
6684
+ }
6685
+ return serialized;
6686
+ }
6687
+ return styles;
6688
+ }
6631
6689
  function GlobalStyles$1(_ref) {
6632
6690
  var styles = _ref.styles,
6633
6691
  themeId = _ref.themeId,
6634
6692
  _ref$defaultTheme = _ref.defaultTheme,
6635
6693
  defaultTheme = _ref$defaultTheme === void 0 ? {} : _ref$defaultTheme;
6636
6694
  var upperTheme = useTheme$2(defaultTheme);
6637
- var globalStyles = typeof styles === 'function' ? styles(themeId ? upperTheme[themeId] || upperTheme : upperTheme) : styles;
6695
+ var resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
6696
+ var globalStyles = typeof styles === 'function' ? styles(resolvedTheme) : styles;
6697
+ if (resolvedTheme.modularCssLayers) {
6698
+ if (Array.isArray(globalStyles)) {
6699
+ globalStyles = globalStyles.map(function (styleArg) {
6700
+ if (typeof styleArg === 'function') {
6701
+ return wrapGlobalLayer(styleArg(resolvedTheme));
6702
+ }
6703
+ return wrapGlobalLayer(styleArg);
6704
+ });
6705
+ } else {
6706
+ globalStyles = wrapGlobalLayer(globalStyles);
6707
+ }
6708
+ }
6638
6709
  return /*#__PURE__*/jsxRuntimeExports.jsx(GlobalStyles$2, {
6639
6710
  styles: globalStyles
6640
6711
  });
@@ -6989,6 +7060,13 @@
6989
7060
  function shouldForwardProp(prop) {
6990
7061
  return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
6991
7062
  }
7063
+ function shallowLayer(serialized, layerName) {
7064
+ if (layerName && serialized && _typeof(serialized) === 'object' && serialized.styles && !serialized.styles.startsWith('@layer') // only add the layer if it is not already there.
7065
+ ) {
7066
+ serialized.styles = "@layer ".concat(layerName, "{").concat(String(serialized.styles), "}");
7067
+ }
7068
+ return serialized;
7069
+ }
6992
7070
  var systemDefaultTheme = createTheme$1();
6993
7071
  var lowercaseFirstLetter = function lowercaseFirstLetter(string) {
6994
7072
  if (!string) {
@@ -7010,7 +7088,7 @@
7010
7088
  return styles[slot];
7011
7089
  };
7012
7090
  }
7013
- function processStyleArg(callableStyle, _ref2) {
7091
+ function processStyleArg(callableStyle, _ref2, layerName) {
7014
7092
  var ownerState = _ref2.ownerState,
7015
7093
  props = _objectWithoutProperties(_ref2, ["ownerState"]);
7016
7094
  var resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle(_extends({
@@ -7020,7 +7098,7 @@
7020
7098
  return resolvedStylesArg.flatMap(function (resolvedStyle) {
7021
7099
  return processStyleArg(resolvedStyle, _extends({
7022
7100
  ownerState: ownerState
7023
- }, props));
7101
+ }, props), layerName);
7024
7102
  });
7025
7103
  }
7026
7104
  if (!!resolvedStylesArg && _typeof(resolvedStylesArg) === 'object' && Array.isArray(resolvedStylesArg.variants)) {
@@ -7045,14 +7123,15 @@
7045
7123
  if (!Array.isArray(result)) {
7046
7124
  result = [result];
7047
7125
  }
7048
- result.push(typeof variant.style === 'function' ? variant.style(_extends({
7126
+ var variantStyle = typeof variant.style === 'function' ? variant.style(_extends({
7049
7127
  ownerState: ownerState
7050
- }, props, ownerState)) : variant.style);
7128
+ }, props, ownerState)) : variant.style;
7129
+ result.push(layerName ? shallowLayer(internal_serializeStyles(variantStyle), layerName) : variantStyle);
7051
7130
  }
7052
7131
  });
7053
7132
  return result;
7054
7133
  }
7055
- return resolvedStylesArg;
7134
+ return layerName ? shallowLayer(internal_serializeStyles(resolvedStylesArg), layerName) : resolvedStylesArg;
7056
7135
  }
7057
7136
  function createStyled() {
7058
7137
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -7086,7 +7165,10 @@
7086
7165
  inputSkipSx = inputOptions.skipSx,
7087
7166
  _inputOptions$overrid = inputOptions.overridesResolver,
7088
7167
  overridesResolver = _inputOptions$overrid === void 0 ? defaultOverridesResolver(lowercaseFirstLetter(componentSlot)) : _inputOptions$overrid,
7089
- options = _objectWithoutProperties(inputOptions, ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"]); // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
7168
+ options = _objectWithoutProperties(inputOptions, ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"]);
7169
+ var layerName = componentName && componentName.startsWith('Mui') || !!componentSlot ? 'components' : 'custom';
7170
+
7171
+ // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
7090
7172
  var skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
7091
7173
  // TODO v6: remove `Root` in the next major release
7092
7174
  // For more details: https://github.com/mui/material-ui/pull/37908
@@ -7123,13 +7205,14 @@
7123
7205
  // which are basically components used as a selectors.
7124
7206
  if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg || isPlainObject(stylesArg)) {
7125
7207
  return function (props) {
7208
+ var theme = resolveTheme({
7209
+ theme: props.theme,
7210
+ defaultTheme: defaultTheme,
7211
+ themeId: themeId
7212
+ });
7126
7213
  return processStyleArg(stylesArg, _extends({}, props, {
7127
- theme: resolveTheme({
7128
- theme: props.theme,
7129
- defaultTheme: defaultTheme,
7130
- themeId: themeId
7131
- })
7132
- }));
7214
+ theme: theme
7215
+ }), theme.modularCssLayers ? layerName : undefined);
7133
7216
  };
7134
7217
  }
7135
7218
  return stylesArg;
@@ -7158,7 +7241,7 @@
7158
7241
  slotStyle = _ref4[1];
7159
7242
  resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, _extends({}, props, {
7160
7243
  theme: theme
7161
- }));
7244
+ }), theme.modularCssLayers ? 'theme' : undefined);
7162
7245
  });
7163
7246
  return overridesResolver(props, resolvedStyleOverrides);
7164
7247
  });
@@ -7175,7 +7258,7 @@
7175
7258
  variants: themeVariants
7176
7259
  }, _extends({}, props, {
7177
7260
  theme: theme
7178
- }));
7261
+ }), theme.modularCssLayers ? 'theme' : undefined);
7179
7262
  });
7180
7263
  }
7181
7264
  if (!skipSx) {
@@ -8891,6 +8974,48 @@
8891
8974
  });
8892
8975
  }
8893
8976
 
8977
+ function useLayerOrder(theme) {
8978
+ var upperTheme = useTheme$3();
8979
+ var id = useId() || '';
8980
+ var modularCssLayers = theme.modularCssLayers;
8981
+ var layerOrder = 'mui.global, mui.components, mui.theme, mui.custom, mui.sx';
8982
+ if (!modularCssLayers || upperTheme !== null) {
8983
+ // skip this hook if upper theme exists.
8984
+ layerOrder = '';
8985
+ } else if (typeof modularCssLayers === 'string') {
8986
+ layerOrder = modularCssLayers.replace(/mui(?!\.)/g, layerOrder);
8987
+ } else {
8988
+ layerOrder = "@layer ".concat(layerOrder, ";");
8989
+ }
8990
+ useEnhancedEffect$1(function () {
8991
+ var head = document.querySelector('head');
8992
+ if (!head) {
8993
+ return;
8994
+ }
8995
+ var firstChild = head.firstChild;
8996
+ if (layerOrder) {
8997
+ var _firstChild$hasAttrib;
8998
+ // Only insert if first child doesn't have data-mui-layer-order attribute
8999
+ if (firstChild && (_firstChild$hasAttrib = firstChild.hasAttribute) != null && _firstChild$hasAttrib.call(firstChild, 'data-mui-layer-order') && firstChild.getAttribute('data-mui-layer-order') === id) {
9000
+ return;
9001
+ }
9002
+ var styleElement = document.createElement('style');
9003
+ styleElement.setAttribute('data-mui-layer-order', id);
9004
+ styleElement.textContent = layerOrder;
9005
+ head.prepend(styleElement);
9006
+ } else {
9007
+ var _head$querySelector;
9008
+ (_head$querySelector = head.querySelector("style[data-mui-layer-order=\"".concat(id, "\"]"))) == null || _head$querySelector.remove();
9009
+ }
9010
+ }, [layerOrder, id]);
9011
+ if (!layerOrder) {
9012
+ return null;
9013
+ }
9014
+ return /*#__PURE__*/jsxRuntimeExports.jsx(GlobalStyles$1, {
9015
+ styles: layerOrder
9016
+ });
9017
+ }
9018
+
8894
9019
  var EMPTY_THEME = {};
8895
9020
  function useThemeScoping(themeId, upperTheme, localTheme) {
8896
9021
  var isPrivate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
@@ -8933,15 +9058,16 @@
8933
9058
  var engineTheme = useThemeScoping(themeId, upperTheme, localTheme);
8934
9059
  var privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);
8935
9060
  var rtlValue = engineTheme.direction === 'rtl';
9061
+ var layerOrder = useLayerOrder(engineTheme);
8936
9062
  return /*#__PURE__*/jsxRuntimeExports.jsx(ThemeProvider$2, {
8937
9063
  theme: privateTheme,
8938
9064
  children: /*#__PURE__*/jsxRuntimeExports.jsx(ThemeContext$2.Provider, {
8939
9065
  value: engineTheme,
8940
9066
  children: /*#__PURE__*/jsxRuntimeExports.jsx(RtlProvider, {
8941
9067
  value: rtlValue,
8942
- children: /*#__PURE__*/jsxRuntimeExports.jsx(DefaultPropsProvider, {
9068
+ children: /*#__PURE__*/jsxRuntimeExports.jsxs(DefaultPropsProvider, {
8943
9069
  value: engineTheme == null ? void 0 : engineTheme.components,
8944
- children: children
9070
+ children: [layerOrder, children]
8945
9071
  })
8946
9072
  })
8947
9073
  })
@@ -11504,7 +11630,7 @@
11504
11630
 
11505
11631
  function shouldSkipGeneratingVar(keys) {
11506
11632
  var _keys$;
11507
- return !!keys[0].match(/(cssVarPrefix|typography|mixins|breakpoints|direction|transitions)/) || !!keys[0].match(/sxConfig$/) ||
11633
+ return !!keys[0].match(/(cssVarPrefix|modularCssLayers|typography|mixins|breakpoints|direction|transitions)/) || !!keys[0].match(/sxConfig$/) ||
11508
11634
  // ends with sxConfig
11509
11635
  keys[0] === 'palette' && !!((_keys$ = keys[1]) != null && _keys$.match(/(mode|contrastThreshold|tonalOffset)/));
11510
11636
  }
@@ -24028,7 +24154,9 @@
24028
24154
  d: "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
24029
24155
  }), 'MoreHoriz');
24030
24156
 
24031
- var BreadcrumbCollapsedButton = styled$1(ButtonBase$1)(function (_ref) {
24157
+ var BreadcrumbCollapsedButton = styled$1(ButtonBase$1, {
24158
+ name: 'MuiBreadcrumbCollapsed'
24159
+ })(function (_ref) {
24032
24160
  var theme = _ref.theme;
24033
24161
  return _extends({
24034
24162
  display: 'flex',
@@ -25673,7 +25801,9 @@
25673
25801
  };
25674
25802
  return composeClasses(slots, getSwitchBaseUtilityClass, classes);
25675
25803
  };
25676
- var SwitchBaseRoot = styled$1(ButtonBase$1)(function (_ref) {
25804
+ var SwitchBaseRoot = styled$1(ButtonBase$1, {
25805
+ name: 'MuiSwitchBase'
25806
+ })(function (_ref) {
25677
25807
  var ownerState = _ref.ownerState;
25678
25808
  return _extends({
25679
25809
  padding: 9,
@@ -25685,6 +25815,7 @@
25685
25815
  });
25686
25816
  });
25687
25817
  var SwitchBaseInput = styled$1('input', {
25818
+ name: 'MuiSwitchBase',
25688
25819
  shouldForwardProp: rootShouldForwardProp$1
25689
25820
  })({
25690
25821
  cursor: 'inherit',
@@ -37354,6 +37485,7 @@
37354
37485
 
37355
37486
  var _span$1;
37356
37487
  var NotchedOutlineRoot$1 = styled$1('fieldset', {
37488
+ name: 'MuiNotchedOutlined',
37357
37489
  shouldForwardProp: rootShouldForwardProp$1
37358
37490
  })({
37359
37491
  textAlign: 'left',
@@ -37372,6 +37504,7 @@
37372
37504
  minWidth: '0%'
37373
37505
  });
37374
37506
  var NotchedOutlineLegend = styled$1('legend', {
37507
+ name: 'MuiNotchedOutlined',
37375
37508
  shouldForwardProp: rootShouldForwardProp$1
37376
37509
  })(function (_ref) {
37377
37510
  var ownerState = _ref.ownerState,
@@ -38542,16 +38675,21 @@
38542
38675
  }), 'RadioButtonChecked');
38543
38676
 
38544
38677
  var RadioButtonIconRoot = styled$1('span', {
38678
+ name: 'MuiRadioButtonIcon',
38545
38679
  shouldForwardProp: rootShouldForwardProp$1
38546
38680
  })({
38547
38681
  position: 'relative',
38548
38682
  display: 'flex'
38549
38683
  });
38550
- var RadioButtonIconBackground = styled$1(RadioButtonUncheckedIcon)({
38684
+ var RadioButtonIconBackground = styled$1(RadioButtonUncheckedIcon, {
38685
+ name: 'MuiRadioButtonIcon'
38686
+ })({
38551
38687
  // Scale applied to prevent dot misalignment in Safari
38552
38688
  transform: 'scale(1)'
38553
38689
  });
38554
- var RadioButtonIconDot = styled$1(RadioButtonCheckedIcon)(function (_ref) {
38690
+ var RadioButtonIconDot = styled$1(RadioButtonCheckedIcon, {
38691
+ name: 'MuiRadioButtonIcon'
38692
+ })(function (_ref) {
38555
38693
  var theme = _ref.theme,
38556
38694
  ownerState = _ref.ownerState;
38557
38695
  return _extends({
@@ -46000,6 +46138,7 @@
46000
46138
  var Stepper$1 = Stepper;
46001
46139
 
46002
46140
  var SwipeAreaRoot = styled$1('div', {
46141
+ name: 'MuiSwipeArea',
46003
46142
  shouldForwardProp: rootShouldForwardProp$1
46004
46143
  })(function (_ref) {
46005
46144
  var theme = _ref.theme,