@mui/system 5.10.16 → 5.11.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 (94) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/borders.js +12 -7
  3. package/breakpoints.js +2 -0
  4. package/colorManipulator.d.ts +10 -0
  5. package/colorManipulator.js +57 -1
  6. package/compose.js +3 -0
  7. package/createBox.d.ts +0 -2
  8. package/createBox.js +2 -3
  9. package/createStyled.js +2 -3
  10. package/createTheme/createTheme.d.ts +5 -0
  11. package/createTheme/createTheme.js +9 -0
  12. package/cssGrid.js +8 -0
  13. package/cssVars/createCssVarsProvider.d.ts +54 -1
  14. package/cssVars/createCssVarsProvider.js +47 -13
  15. package/esm/borders.js +9 -6
  16. package/esm/breakpoints.js +2 -0
  17. package/esm/colorManipulator.js +50 -0
  18. package/esm/compose.js +3 -0
  19. package/esm/createBox.js +2 -3
  20. package/esm/createStyled.js +2 -3
  21. package/esm/createTheme/createTheme.js +9 -0
  22. package/esm/cssGrid.js +9 -0
  23. package/esm/cssVars/createCssVarsProvider.js +47 -13
  24. package/esm/index.js +1 -2
  25. package/esm/palette.js +4 -4
  26. package/esm/sizing.js +9 -9
  27. package/esm/spacing.js +2 -2
  28. package/esm/style.js +4 -1
  29. package/esm/styleFunctionSx/defaultSxConfig.js +284 -0
  30. package/esm/styleFunctionSx/extendSxProp.js +4 -2
  31. package/esm/styleFunctionSx/index.js +2 -1
  32. package/esm/styleFunctionSx/styleFunctionSx.js +45 -17
  33. package/index.d.ts +1 -2
  34. package/index.js +8 -9
  35. package/legacy/borders.js +9 -6
  36. package/legacy/breakpoints.js +2 -0
  37. package/legacy/colorManipulator.js +50 -0
  38. package/legacy/compose.js +3 -0
  39. package/legacy/createBox.js +2 -4
  40. package/legacy/createStyled.js +2 -4
  41. package/legacy/createTheme/createTheme.js +9 -0
  42. package/legacy/cssGrid.js +9 -0
  43. package/legacy/cssVars/createCssVarsProvider.js +47 -11
  44. package/legacy/index.js +2 -3
  45. package/legacy/palette.js +4 -4
  46. package/legacy/sizing.js +9 -9
  47. package/legacy/spacing.js +2 -2
  48. package/legacy/style.js +3 -2
  49. package/legacy/styleFunctionSx/defaultSxConfig.js +286 -0
  50. package/legacy/styleFunctionSx/extendSxProp.js +4 -2
  51. package/legacy/styleFunctionSx/index.js +2 -1
  52. package/legacy/styleFunctionSx/styleFunctionSx.js +44 -20
  53. package/modern/borders.js +9 -6
  54. package/modern/breakpoints.js +2 -0
  55. package/modern/colorManipulator.js +50 -0
  56. package/modern/compose.js +3 -0
  57. package/modern/createBox.js +2 -3
  58. package/modern/createStyled.js +2 -3
  59. package/modern/createTheme/createTheme.js +9 -0
  60. package/modern/cssGrid.js +9 -0
  61. package/modern/cssVars/createCssVarsProvider.js +47 -13
  62. package/modern/index.js +2 -3
  63. package/modern/palette.js +4 -4
  64. package/modern/sizing.js +9 -9
  65. package/modern/spacing.js +2 -2
  66. package/modern/style.js +4 -1
  67. package/modern/styleFunctionSx/defaultSxConfig.js +284 -0
  68. package/modern/styleFunctionSx/extendSxProp.js +3 -2
  69. package/modern/styleFunctionSx/index.js +2 -1
  70. package/modern/styleFunctionSx/styleFunctionSx.js +44 -17
  71. package/package.json +6 -6
  72. package/palette.js +5 -4
  73. package/sizing.js +12 -10
  74. package/spacing.js +4 -0
  75. package/style.d.ts +10 -8
  76. package/style.js +4 -1
  77. package/styleFunctionSx/defaultSxConfig.d.ts +20 -0
  78. package/styleFunctionSx/defaultSxConfig.js +291 -0
  79. package/styleFunctionSx/extendSxProp.js +4 -2
  80. package/styleFunctionSx/index.d.ts +4 -0
  81. package/styleFunctionSx/index.js +7 -0
  82. package/styleFunctionSx/styleFunctionSx.d.ts +2 -1
  83. package/styleFunctionSx/styleFunctionSx.js +45 -17
  84. package/esm/sx/index.js +0 -1
  85. package/esm/sx/sx.js +0 -10
  86. package/legacy/sx/index.js +0 -1
  87. package/legacy/sx/sx.js +0 -11
  88. package/modern/sx/index.js +0 -1
  89. package/modern/sx/sx.js +0 -10
  90. package/sx/index.d.ts +0 -1
  91. package/sx/index.js +0 -13
  92. package/sx/package.json +0 -6
  93. package/sx/sx.d.ts +0 -4
  94. package/sx/sx.js +0 -18
package/CHANGELOG.md CHANGED
@@ -1,5 +1,153 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.11.0
4
+
5
+ <!-- generated comparing v5.10.17..master -->
6
+
7
+ _Dec 13, 2022_
8
+
9
+ A big thanks to the 19 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 🔥 @mnajdova enabled configuration of the `sx` prop in the `theme` (#35150)
12
+ - Many other 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements.
13
+
14
+ ### `@mui/material@5.11.0`
15
+
16
+ - [Alert] Update icon color in all variants (#35414) @danilo-leal
17
+ - [Select] Fix `MenuProps.PopoverClasses` being overriden (#35394) @vitorfrs-dev
18
+ - [SwipeableDrawer] Fixed typescript warning "prop open undefined" (#34710) @kraftware
19
+
20
+ ### `@mui/icons-material@5.11.0`
21
+
22
+ - [icons] Restore the PhoneInTalk icons (#35409) @michaldudak
23
+
24
+ ### `@mui/system@5.11.0`
25
+
26
+ #### BREAKING CHANGES
27
+
28
+ - [system] Enable configuring the `sx` prop in the `theme` (#35150) @mnajdova
29
+
30
+ The breaking change is regarding an experimental API:
31
+
32
+ ```diff
33
+ -import { styled, experimental_sx } from '@mui/material/styles';
34
+ +import { styled } from '@mui/material/styles';
35
+
36
+ -const Component = styled('div)(experimental_sx({ p: 1 }});
37
+ +const Component = styled('div)(({ theme }) => theme.unstable_sx({ p: 1 }});
38
+ ```
39
+
40
+ ### `@mui/joy@5.0.0-alpha.58`
41
+
42
+ - [Joy] Miscellaneous fixes (#35447) @siriwatknp
43
+
44
+ ### `@mui/base@5.0.0-alpha.110`
45
+
46
+ - [PopperUnstyled] Update PopperTooltip to have correct width when closing with transition (#34714) @EduardoSCosta
47
+
48
+ ### `@mui/material-next@6.0.0-alpha.66`
49
+
50
+ - [Material You] Add ripple on the button (#35299) @mnajdova
51
+
52
+ ### Docs
53
+
54
+ - [docs] Simplify state management in Text Field demo page (#35051) @PratikDev
55
+ - [docs] Improve `Responsive App bar with Drawer` demo (#35418) @ZeeshanTamboli
56
+ - [docs] Improve line-height readability (#35387) @oliviertassinari
57
+ - [docs] Improve a bit the Composition docs (#35329) @oliviertassinari
58
+ - [docs] Refactor `ToggleButtonSizes` demo (#35375) @Armanio
59
+ - [docs] Standardize the usage of callouts in the MUI Core docs (#35361) @samuelsycamore
60
+ - [docs] Format feedback to add a link to the commented section (#35381) @alexfauquette
61
+ - [docs] Direct users from Material UI to MUI Base for duplicated components (#35293) @samuelsycamore
62
+ - [docs] Fix typo in FormControl API docs (#35449) @Spanishiwa
63
+ - [docs] Update callouts design (#35390) @danilo-leal
64
+ - [website] New wave of open roles (#35240) @mnajdova
65
+ - [website] Developer survey 2022 (#35407) @joserodolfofreitas
66
+
67
+ ### Core
68
+
69
+ - [core] Fix @mui/material package building (#35324) @timbset
70
+ - [core] Fix leaking theme color override (#35444) @oliviertassinari
71
+ - [typescript] Add null to return type of OverridableComponent (#35311) @tsollbach
72
+ - [website] Migrate X page to use CSS theme variables (#34922) @jesrodri
73
+ - [website] Migrate `/core` page to use CSS variables (#35366) @siriwatknp
74
+
75
+ All contributors of this release in alphabetical order: @alexfauquette, @Armanio, @danilo-leal, @EduardoSCosta, @flaviendelangle, @jesrodri, @joserodolfofreitas, @kraftware, @michaldudak, @mnajdova, @oliviertassinari, @PratikDev, @samuelsycamore, @siriwatknp, @Spanishiwa, @timbset, @tsollbach, @vitorfrs-dev, @ZeeshanTamboli
76
+
77
+ ## 5.10.17
78
+
79
+ <!-- generated comparing v5.10.16..master -->
80
+
81
+ _Dec 6, 2022_
82
+
83
+ A big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
84
+
85
+ - ✨ @mnajdova added a [Material You Button playground](https://mui.com/material-ui/react-button/#material-you-version) (#35222)
86
+ - 🔧 @hbjORbj renamed `components` / `componentProps` to `slots` / `slotProps` prop in Joy UI to create consistency across products (#34997)
87
+ - Many other 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements
88
+
89
+ ### `@mui/material@5.10.17`
90
+
91
+ - &#8203;<!-- 31 -->[Slider] Fix `markActive` theme class not getting applied (#35067) @ZeeshanTamboli
92
+ - &#8203;<!-- 30 -->[SwipeableDrawer] Fix missing close animation when initial open is true (#35010) @sai6855
93
+ - &#8203;<!-- 28 -->[material-ui] Add channel colors if possible (#35178) @siriwatknp
94
+ - &#8203;<!-- 10 -->[Fab] Increase disabled styles precedence (#35304) @Uzwername
95
+ - &#8203;<!-- 05 -->[Rating] Apply `labelEmptyValueActive` style overrides from theme (#35315) @sai6855
96
+
97
+ ### `@mui/system@5.10.17`
98
+
99
+ - &#8203;<!-- 04 -->[system] Add support for nested CssVarsProvider (#35277) @siriwatknp
100
+
101
+ ### `@mui/joy@5.0.0-alpha.57`
102
+
103
+ #### BREAKING CHANGE
104
+
105
+ - &#8203;<!-- 08 -->[Joy] Add `slots`/`slotProps` props to the typing of all components and apply `useSlot` to all components (#34997) @hbjORbj
106
+
107
+ - Change all occurrences of `components` and `componentsProps` props in Joy UI components to `slots` and `slotProps`, respectively.
108
+
109
+ ```diff
110
+ -<Autocomplete components={{listbox: CustomListbox}} componentsProps={{listbox: { className: 'custom-listbox' }}} />
111
+ +<Autocomplete slots={{listbox: CustomListbox}} slotProps={{listbox: { className: 'custom-listbox' }}} />
112
+ ```
113
+
114
+ You can use this [codemod](https://github.com/mui/material-ui/blob/master/packages/mui-codemod/README.md#joy-rename-components-to-slots) to help with the migration.
115
+
116
+ #### Changes
117
+
118
+ - &#8203;<!-- 07 -->[Joy] Miscellaneous fixes (#35345) @siriwatknp
119
+ - &#8203;<!-- 06 -->[Joy][textarea] Expose decorator classes (#35247) @zignis
120
+
121
+ ### Docs
122
+
123
+ - &#8203;<!-- 29 -->[docs] Improve spacing with ul (#35302) @oliviertassinari
124
+ - &#8203;<!-- 23 -->[docs] Correct grammatically incorrect sentences in CONTRIBUTING.md (#34949) @Pandey-utkarsh
125
+ - &#8203;<!-- 22 -->[docs] Move the demo higher in the API TOC (#35202) @oliviertassinari
126
+ - &#8203;<!-- 21 -->[docs] Fix incorrect link in minimizing-bundle-size (#35297) @Juneezee
127
+ - &#8203;<!-- 20 -->[docs] Revise and expand Joy UI "Breadcrumbs" page (#35292) @samuelsycamore
128
+ - &#8203;<!-- 19 -->[docs] Fix wrong import in the unstyled tabs page (#35310) @guotie
129
+ - &#8203;<!-- 18 -->[docs] Disable translations (#34820) @mnajdova
130
+ - &#8203;<!-- 17 -->[docs] Fix typo (#35312) @flaviendelangle
131
+ - &#8203;<!-- 16 -->[docs] Add Material You Button playground (#35222) @mnajdova
132
+ - &#8203;<!-- 15 -->[docs] Fix experimental API page duplication (#35213) @oliviertassinari
133
+ - &#8203;<!-- 14 -->[docs] Improve the autogenerated "Unstyled" and "API" text (#35185) @samuelsycamore
134
+ - &#8203;<!-- 13 -->[docs] Fix ad margin on API pages (#35201) @oliviertassinari
135
+ - &#8203;<!-- 12 -->[docs] Revise and expand the Joy UI "Badge" page (#35199) @samuelsycamore
136
+ - &#8203;<!-- 11 -->[docs] Update MUI Base docs with latest style conventions (#35034) @samuelsycamore
137
+ - &#8203;<!-- 09 -->[l10n] Improve Chinese (Taiwan) zh-TW locale (#35328) @happyincent
138
+ - &#8203;<!-- 02 -->[website] Update MUI stats: GitHub stars, Twitter followers, etc. (#35318) @nomandhoni-cs
139
+
140
+ ### Core
141
+
142
+ - &#8203;<!-- 27 -->[core] Use componentStyles.name over componentName (#35303) @oliviertassinari
143
+ - &#8203;<!-- 26 -->[core] Fix warning leak in production (#35313) @oliviertassinari
144
+ - &#8203;<!-- 25 -->[core] Move the internal packages from docs/packages (#35305) @michaldudak
145
+ - &#8203;<!-- 24 -->[core] Clean up the API docs generation scripts (#35244) @michaldudak
146
+ - &#8203;<!-- 03 -->[test] Scope the tests to just Material UI components (#35219) @siriwatknp
147
+ - &#8203;<!-- 01 -->[website] Remove BlackFriday notification @oliviertassinari
148
+
149
+ All contributors of this release in alphabetical order: @flaviendelangle, @guotie, @happyincent, @hbjORbj, @Juneezee, @michaldudak, @mnajdova, @nomandhoni-cs, @oliviertassinari, @Pandey-utkarsh, @sai6855, @samuelsycamore, @siriwatknp, @Uzwername, @zignis
150
+
3
151
  ## 5.10.16
4
152
 
5
153
  <!-- generated comparing v5.10.15..master -->
package/borders.js CHANGED
@@ -4,13 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.borderTopColor = exports.borderTop = exports.borderRightColor = exports.borderRight = exports.borderRadius = exports.borderLeftColor = exports.borderLeft = exports.borderColor = exports.borderBottomColor = exports.borderBottom = exports.border = void 0;
7
+ exports.borderTopColor = exports.borderTop = exports.borderRightColor = exports.borderRight = exports.borderRadius = exports.borderLeftColor = exports.borderLeft = exports.borderColor = exports.borderBottomColor = exports.borderBottom = exports.border = void 0;
8
+ exports.borderTransform = borderTransform;
9
+ exports.default = void 0;
8
10
  var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
9
11
  var _style = _interopRequireDefault(require("./style"));
10
12
  var _compose = _interopRequireDefault(require("./compose"));
11
13
  var _spacing = require("./spacing");
12
14
  var _breakpoints = require("./breakpoints");
13
- function getBorder(value) {
15
+ function borderTransform(value) {
14
16
  if (typeof value !== 'number') {
15
17
  return value;
16
18
  }
@@ -19,31 +21,31 @@ function getBorder(value) {
19
21
  const border = (0, _style.default)({
20
22
  prop: 'border',
21
23
  themeKey: 'borders',
22
- transform: getBorder
24
+ transform: borderTransform
23
25
  });
24
26
  exports.border = border;
25
27
  const borderTop = (0, _style.default)({
26
28
  prop: 'borderTop',
27
29
  themeKey: 'borders',
28
- transform: getBorder
30
+ transform: borderTransform
29
31
  });
30
32
  exports.borderTop = borderTop;
31
33
  const borderRight = (0, _style.default)({
32
34
  prop: 'borderRight',
33
35
  themeKey: 'borders',
34
- transform: getBorder
36
+ transform: borderTransform
35
37
  });
36
38
  exports.borderRight = borderRight;
37
39
  const borderBottom = (0, _style.default)({
38
40
  prop: 'borderBottom',
39
41
  themeKey: 'borders',
40
- transform: getBorder
42
+ transform: borderTransform
41
43
  });
42
44
  exports.borderBottom = borderBottom;
43
45
  const borderLeft = (0, _style.default)({
44
46
  prop: 'borderLeft',
45
47
  themeKey: 'borders',
46
- transform: getBorder
48
+ transform: borderTransform
47
49
  });
48
50
  exports.borderLeft = borderLeft;
49
51
  const borderColor = (0, _style.default)({
@@ -70,6 +72,9 @@ const borderLeftColor = (0, _style.default)({
70
72
  prop: 'borderLeftColor',
71
73
  themeKey: 'palette'
72
74
  });
75
+
76
+ // false positive
77
+ // eslint-disable-next-line react/function-component-definition
73
78
  exports.borderLeftColor = borderLeftColor;
74
79
  const borderRadius = props => {
75
80
  if (props.borderRadius !== undefined && props.borderRadius !== null) {
package/breakpoints.js CHANGED
@@ -63,6 +63,8 @@ function handleBreakpoints(props, propValue, styleFromPropValue) {
63
63
  return output;
64
64
  }
65
65
  function breakpoints(styleFunction) {
66
+ // false positive
67
+ // eslint-disable-next-line react/function-component-definition
66
68
  const newStyleFunction = props => {
67
69
  const theme = props.theme || {};
68
70
  const base = styleFunction(props);
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
  export type ColorFormat = 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'color';
2
3
  export interface ColorObject {
3
4
  type: ColorFormat;
@@ -10,10 +11,19 @@ export function rgbToHex(color: string): string;
10
11
  export function hslToRgb(color: string): string;
11
12
  export function decomposeColor(color: string): ColorObject;
12
13
  export function colorChannel(color: string): string;
14
+ export function private_safeColorChannel(color: string, warning?: string): string;
13
15
  export function recomposeColor(color: ColorObject): string;
14
16
  export function getContrastRatio(foreground: string, background: string): number;
15
17
  export function getLuminance(color: string): number;
16
18
  export function emphasize(color: string, coefficient?: number): string;
19
+ export function private_safeEmphasize(
20
+ color: string,
21
+ coefficient?: number,
22
+ warning?: string,
23
+ ): string;
17
24
  export function alpha(color: string, value: number): string;
25
+ export function private_safeAlpha(color: string, value: number, warning?: string): string;
18
26
  export function darken(color: string, coefficient: number): string;
27
+ export function private_safeDarken(color: string, coefficient: number, warning?: string): string;
19
28
  export function lighten(color: string, coefficient: number): string;
29
+ export function private_safeLighten(color: string, coefficient: number, warning?: string): string;
@@ -13,6 +13,11 @@ exports.getLuminance = getLuminance;
13
13
  exports.hexToRgb = hexToRgb;
14
14
  exports.hslToRgb = hslToRgb;
15
15
  exports.lighten = lighten;
16
+ exports.private_safeAlpha = private_safeAlpha;
17
+ exports.private_safeColorChannel = void 0;
18
+ exports.private_safeDarken = private_safeDarken;
19
+ exports.private_safeEmphasize = private_safeEmphasize;
20
+ exports.private_safeLighten = private_safeLighten;
16
21
  exports.recomposeColor = recomposeColor;
17
22
  exports.rgbToHex = rgbToHex;
18
23
  var _utils = require("@mui/utils");
@@ -107,6 +112,17 @@ const colorChannel = color => {
107
112
  const decomposedColor = decomposeColor(color);
108
113
  return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
109
114
  };
115
+ exports.colorChannel = colorChannel;
116
+ const private_safeColorChannel = (color, warning) => {
117
+ try {
118
+ return colorChannel(color);
119
+ } catch (error) {
120
+ if (warning && process.env.NODE_ENV !== 'production') {
121
+ console.warn(warning);
122
+ }
123
+ return color;
124
+ }
125
+ };
110
126
 
111
127
  /**
112
128
  * Converts a color object with type and values to a string.
@@ -115,7 +131,7 @@ const colorChannel = color => {
115
131
  * @param {array} color.values - [n,n,n] or [n,n,n,n]
116
132
  * @returns {string} A CSS color string
117
133
  */
118
- exports.colorChannel = colorChannel;
134
+ exports.private_safeColorChannel = private_safeColorChannel;
119
135
  function recomposeColor(color) {
120
136
  const {
121
137
  type,
@@ -238,6 +254,16 @@ function alpha(color, value) {
238
254
  }
239
255
  return recomposeColor(color);
240
256
  }
257
+ function private_safeAlpha(color, value, warning) {
258
+ try {
259
+ return alpha(color, value);
260
+ } catch (error) {
261
+ if (warning && process.env.NODE_ENV !== 'production') {
262
+ console.warn(warning);
263
+ }
264
+ return color;
265
+ }
266
+ }
241
267
 
242
268
  /**
243
269
  * Darkens a color.
@@ -257,6 +283,16 @@ function darken(color, coefficient) {
257
283
  }
258
284
  return recomposeColor(color);
259
285
  }
286
+ function private_safeDarken(color, coefficient, warning) {
287
+ try {
288
+ return darken(color, coefficient);
289
+ } catch (error) {
290
+ if (warning && process.env.NODE_ENV !== 'production') {
291
+ console.warn(warning);
292
+ }
293
+ return color;
294
+ }
295
+ }
260
296
 
261
297
  /**
262
298
  * Lightens a color.
@@ -280,6 +316,16 @@ function lighten(color, coefficient) {
280
316
  }
281
317
  return recomposeColor(color);
282
318
  }
319
+ function private_safeLighten(color, coefficient, warning) {
320
+ try {
321
+ return lighten(color, coefficient);
322
+ } catch (error) {
323
+ if (warning && process.env.NODE_ENV !== 'production') {
324
+ console.warn(warning);
325
+ }
326
+ return color;
327
+ }
328
+ }
283
329
 
284
330
  /**
285
331
  * Darken or lighten a color, depending on its luminance.
@@ -290,4 +336,14 @@ function lighten(color, coefficient) {
290
336
  */
291
337
  function emphasize(color, coefficient = 0.15) {
292
338
  return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
339
+ }
340
+ function private_safeEmphasize(color, coefficient, warning) {
341
+ try {
342
+ return private_safeEmphasize(color, coefficient);
343
+ } catch (error) {
344
+ if (warning && process.env.NODE_ENV !== 'production') {
345
+ console.warn(warning);
346
+ }
347
+ return color;
348
+ }
293
349
  }
package/compose.js CHANGED
@@ -13,6 +13,9 @@ function compose(...styles) {
13
13
  });
14
14
  return acc;
15
15
  }, {});
16
+
17
+ // false positive
18
+ // eslint-disable-next-line react/function-component-definition
16
19
  const fn = props => {
17
20
  return Object.keys(props).reduce((acc, prop) => {
18
21
  if (handlers[prop]) {
package/createBox.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import Box from './Box';
2
- import styleFunctionSx from './styleFunctionSx';
3
2
 
4
3
  export default function createBox(options?: {
5
4
  defaultTheme: object;
6
5
  defaultClassName?: string;
7
6
  generateClassName?: (componentName: string) => string;
8
- styleFunctionSx?: typeof styleFunctionSx;
9
7
  }): typeof Box;
package/createBox.js CHANGED
@@ -20,12 +20,11 @@ function createBox(options = {}) {
20
20
  const {
21
21
  defaultTheme,
22
22
  defaultClassName = 'MuiBox-root',
23
- generateClassName,
24
- styleFunctionSx = _styleFunctionSx.default
23
+ generateClassName
25
24
  } = options;
26
25
  const BoxRoot = (0, _styledEngine.default)('div', {
27
26
  shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
28
- })(styleFunctionSx);
27
+ })(_styleFunctionSx.default);
29
28
  const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
30
29
  const theme = (0, _useTheme.default)(defaultTheme);
31
30
  const _extendSxProp = (0, _styleFunctionSx.extendSxProp)(inProps),
package/createStyled.js CHANGED
@@ -85,12 +85,11 @@ function createStyled(input = {}) {
85
85
  const {
86
86
  defaultTheme = systemDefaultTheme,
87
87
  rootShouldForwardProp = shouldForwardProp,
88
- slotShouldForwardProp = shouldForwardProp,
89
- styleFunctionSx = _styleFunctionSx.default
88
+ slotShouldForwardProp = shouldForwardProp
90
89
  } = input;
91
90
  const systemSx = props => {
92
91
  const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
93
- return styleFunctionSx((0, _extends2.default)({}, props, {
92
+ return (0, _styleFunctionSx.default)((0, _extends2.default)({}, props, {
94
93
  theme
95
94
  }));
96
95
  };
@@ -1,6 +1,8 @@
1
+ import { CSSObject } from '@mui/styled-engine';
1
2
  import { Breakpoints, BreakpointsOptions } from './createBreakpoints';
2
3
  import { Shape, ShapeOptions } from './shape';
3
4
  import { Spacing, SpacingOptions } from './createSpacing';
5
+ import { SxConfig, SxProps } from '../styleFunctionSx';
4
6
 
5
7
  export { Breakpoint, BreakpointOverrides } from './createBreakpoints';
6
8
 
@@ -18,6 +20,7 @@ export interface ThemeOptions {
18
20
  components?: Record<string, any>;
19
21
  typography?: unknown;
20
22
  zIndex?: Record<string, number>;
23
+ unstable_sxConfig?: SxConfig;
21
24
  }
22
25
 
23
26
  export interface Theme {
@@ -32,6 +35,8 @@ export interface Theme {
32
35
  mixins?: unknown;
33
36
  typography?: unknown;
34
37
  zIndex?: unknown;
38
+ unstable_sxConfig: SxConfig;
39
+ unstable_sx: (props: SxProps<Theme>) => CSSObject;
35
40
  }
36
41
 
37
42
  /**
@@ -11,6 +11,8 @@ var _utils = require("@mui/utils");
11
11
  var _createBreakpoints = _interopRequireDefault(require("./createBreakpoints"));
12
12
  var _shape = _interopRequireDefault(require("./shape"));
13
13
  var _createSpacing = _interopRequireDefault(require("./createSpacing"));
14
+ var _styleFunctionSx = _interopRequireDefault(require("../styleFunctionSx/styleFunctionSx"));
15
+ var _defaultSxConfig = _interopRequireDefault(require("../styleFunctionSx/defaultSxConfig"));
14
16
  const _excluded = ["breakpoints", "palette", "spacing", "shape"];
15
17
  function createTheme(options = {}, ...args) {
16
18
  const {
@@ -34,6 +36,13 @@ function createTheme(options = {}, ...args) {
34
36
  shape: (0, _extends2.default)({}, _shape.default, shapeInput)
35
37
  }, other);
36
38
  muiTheme = args.reduce((acc, argument) => (0, _utils.deepmerge)(acc, argument), muiTheme);
39
+ muiTheme.unstable_sxConfig = (0, _extends2.default)({}, _defaultSxConfig.default, other == null ? void 0 : other.unstable_sxConfig);
40
+ muiTheme.unstable_sx = function sx(props) {
41
+ return (0, _styleFunctionSx.default)({
42
+ sx: props,
43
+ theme: this
44
+ });
45
+ };
37
46
  return muiTheme;
38
47
  }
39
48
  var _default = createTheme;
package/cssGrid.js CHANGED
@@ -10,6 +10,8 @@ var _compose = _interopRequireDefault(require("./compose"));
10
10
  var _spacing = require("./spacing");
11
11
  var _breakpoints = require("./breakpoints");
12
12
  var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
13
+ // false positive
14
+ // eslint-disable-next-line react/function-component-definition
13
15
  const gap = props => {
14
16
  if (props.gap !== undefined && props.gap !== null) {
15
17
  const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'spacing', 8, 'gap');
@@ -25,6 +27,9 @@ gap.propTypes = process.env.NODE_ENV !== 'production' ? {
25
27
  gap: _responsivePropType.default
26
28
  } : {};
27
29
  gap.filterProps = ['gap'];
30
+
31
+ // false positive
32
+ // eslint-disable-next-line react/function-component-definition
28
33
  const columnGap = props => {
29
34
  if (props.columnGap !== undefined && props.columnGap !== null) {
30
35
  const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'spacing', 8, 'columnGap');
@@ -40,6 +45,9 @@ columnGap.propTypes = process.env.NODE_ENV !== 'production' ? {
40
45
  columnGap: _responsivePropType.default
41
46
  } : {};
42
47
  columnGap.filterProps = ['columnGap'];
48
+
49
+ // false positive
50
+ // eslint-disable-next-line react/function-component-definition
43
51
  const rowGap = props => {
44
52
  if (props.rowGap !== undefined && props.rowGap !== null) {
45
53
  const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'spacing', 8, 'rowGap');
@@ -66,7 +66,7 @@ export interface CreateCssVarsProviderResult<ColorScheme extends string> {
66
66
  * The node used to attach the color-scheme attribute
67
67
  * @default document
68
68
  */
69
- colorSchemeNode?: Document | HTMLElement | null;
69
+ colorSchemeNode?: Element | null;
70
70
  /**
71
71
  * The CSS selector for attaching the generated custom properties
72
72
  * @default ':root'
@@ -77,10 +77,63 @@ export interface CreateCssVarsProviderResult<ColorScheme extends string> {
77
77
  * @default window
78
78
  */
79
79
  storageWindow?: Window | null;
80
+ /**
81
+ * If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
82
+ */
83
+ disableNestedContext?: boolean;
84
+ /**
85
+ * If `true`, the style sheet won't be generated.
86
+ *
87
+ * This is useful for controlling nested CssVarsProvider behavior.
88
+ * @default false
89
+ */
90
+ disableStyleSheetGeneration?: boolean;
80
91
  }
81
92
  >,
82
93
  ) => React.ReactElement;
83
94
  useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
95
+ generateCssThemeVars: (options?: {
96
+ /**
97
+ * Design system default color scheme.
98
+ * - provides string if the design system has one default color scheme (either light or dark)
99
+ * - provides object if the design system has default light & dark color schemes
100
+ */
101
+ defaultColorScheme?: ColorScheme | { light: ColorScheme; dark: ColorScheme };
102
+ /**
103
+ * @default 'light'
104
+ */
105
+ defaultMode?: 'light' | 'dark';
106
+ /**
107
+ * The selector for attaching CSS variables that are **outside** of `theme.colorSchemes.*`.
108
+ * @default ':root'
109
+ */
110
+ rootSelector: string;
111
+ /**
112
+ * The selector for attaching CSS variables that are **outside** of `theme.colorSchemes.*`.
113
+ * @default (key) => `[data-color-scheme="${key}"]`
114
+ */
115
+ colorSchemeSelector: (key: ColorScheme) => string;
116
+ /**
117
+ * A function to determine if the key, value should be attached as CSS Variable
118
+ * `keys` is an array that represents the object path keys.
119
+ * Ex, if the theme is { foo: { bar: 'var(--test)' } }
120
+ * then, keys = ['foo', 'bar']
121
+ * value = 'var(--test)'
122
+ */
123
+ shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
124
+ /**
125
+ * Controlled mode. If not provided, it will try to read the value from the upper CssVarsProvider.
126
+ */
127
+ mode?: Mode;
128
+ /**
129
+ * Controlled color scheme. If not provided, it will try to read the value from the upper CssVarsProvider.
130
+ */
131
+ colorScheme?: ColorScheme;
132
+ theme?: {
133
+ cssVarPrefix?: string;
134
+ colorSchemes: Record<ColorScheme, Record<string, any>>;
135
+ };
136
+ }) => Record<string, any>;
84
137
  getInitColorSchemeScript: typeof getInitColorSchemeScript;
85
138
  }
86
139
 
@@ -12,6 +12,7 @@ var _utils = require("@mui/utils");
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
14
  var _styledEngine = require("@mui/styled-engine");
15
+ var _privateTheming = require("@mui/private-theming");
15
16
  var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
16
17
  var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
17
18
  var _getInitColorSchemeScript = _interopRequireWildcard(require("./getInitColorSchemeScript"));
@@ -59,9 +60,14 @@ function createCssVarsProvider(options) {
59
60
  documentNode = typeof document === 'undefined' ? undefined : document,
60
61
  colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
61
62
  colorSchemeSelector = ':root',
62
- shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar
63
+ shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar,
64
+ disableNestedContext = false,
65
+ disableStyleSheetGeneration = false
63
66
  }) {
64
67
  const hasMounted = React.useRef(false);
68
+ const upperTheme = (0, _privateTheming.useTheme)();
69
+ const ctx = React.useContext(ColorSchemeContext);
70
+ const nested = !!ctx && !disableNestedContext;
65
71
  const {
66
72
  colorSchemes = {},
67
73
  components = {},
@@ -74,12 +80,12 @@ function createCssVarsProvider(options) {
74
80
 
75
81
  // 1. Get the data about the `mode`, `colorScheme`, and setter functions.
76
82
  const {
77
- mode,
83
+ mode: stateMode,
78
84
  setMode,
79
85
  systemMode,
80
86
  lightColorScheme,
81
87
  darkColorScheme,
82
- colorScheme,
88
+ colorScheme: stateColorScheme,
83
89
  setColorScheme
84
90
  } = (0, _useCurrentColorScheme.default)({
85
91
  supportedColorSchemes: allColorSchemes,
@@ -90,6 +96,12 @@ function createCssVarsProvider(options) {
90
96
  defaultMode,
91
97
  storageWindow
92
98
  });
99
+ let mode = stateMode;
100
+ let colorScheme = stateColorScheme;
101
+ if (nested) {
102
+ mode = ctx.mode;
103
+ colorScheme = ctx.colorScheme;
104
+ }
93
105
  const calculatedMode = (() => {
94
106
  if (!mode) {
95
107
  // This scope occurs on the server
@@ -226,21 +238,33 @@ function createCssVarsProvider(options) {
226
238
  setColorScheme,
227
239
  allColorSchemes
228
240
  }), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode]);
229
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ColorSchemeContext.Provider, {
230
- value: contextValue,
231
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
232
- styles: {
233
- [colorSchemeSelector]: rootCss
234
- }
235
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
236
- styles: defaultColorSchemeStyleSheet
237
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
238
- styles: otherColorSchemesStyleSheet
241
+ let shouldGenerateStyleSheet = true;
242
+ if (disableStyleSheetGeneration || nested && (upperTheme == null ? void 0 : upperTheme.cssVarPrefix) === cssVarPrefix) {
243
+ shouldGenerateStyleSheet = false;
244
+ }
245
+ const element = /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
246
+ children: [shouldGenerateStyleSheet && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
247
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
248
+ styles: {
249
+ [colorSchemeSelector]: rootCss
250
+ }
251
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
252
+ styles: defaultColorSchemeStyleSheet
253
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
254
+ styles: otherColorSchemesStyleSheet
255
+ })]
239
256
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
240
257
  theme: resolveTheme ? resolveTheme(theme) : theme,
241
258
  children: children
242
259
  })]
243
260
  });
261
+ if (nested) {
262
+ return element;
263
+ }
264
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorSchemeContext.Provider, {
265
+ value: contextValue,
266
+ children: element
267
+ });
244
268
  }
245
269
  process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
246
270
  /**
@@ -271,6 +295,16 @@ function createCssVarsProvider(options) {
271
295
  * The initial mode used.
272
296
  */
273
297
  defaultMode: _propTypes.default.string,
298
+ /**
299
+ * If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
300
+ */
301
+ disableNestedContext: _propTypes.default.bool,
302
+ /**
303
+ * If `true`, the style sheet won't be generated.
304
+ *
305
+ * This is useful for controlling nested CssVarsProvider behavior.
306
+ */
307
+ disableStyleSheetGeneration: _propTypes.default.bool,
274
308
  /**
275
309
  * Disable CSS transitions when switching between modes or color schemes
276
310
  */