@mui/system 5.11.11 → 5.11.13

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 (40) hide show
  1. package/CHANGELOG.md +187 -2
  2. package/cssVars/createCssVarsProvider.d.ts +0 -50
  3. package/cssVars/createCssVarsProvider.js +8 -16
  4. package/cssVars/createCssVarsTheme.d.ts +13 -0
  5. package/cssVars/createCssVarsTheme.js +24 -0
  6. package/cssVars/createGetCssVar.js +1 -1
  7. package/cssVars/cssVarsParser.d.ts +3 -2
  8. package/cssVars/cssVarsParser.js +4 -1
  9. package/cssVars/index.d.ts +2 -0
  10. package/cssVars/index.js +15 -1
  11. package/cssVars/prepareCssVars.d.ts +14 -0
  12. package/cssVars/prepareCssVars.js +70 -0
  13. package/esm/cssVars/createCssVarsProvider.js +8 -16
  14. package/esm/cssVars/createCssVarsTheme.js +16 -0
  15. package/esm/cssVars/createGetCssVar.js +1 -1
  16. package/esm/cssVars/cssVarsParser.js +4 -1
  17. package/esm/cssVars/index.js +3 -1
  18. package/esm/cssVars/prepareCssVars.js +62 -0
  19. package/esm/index.js +3 -0
  20. package/esm/styleFunctionSx/defaultSxConfig.js +30 -3
  21. package/index.d.ts +3 -0
  22. package/index.js +25 -1
  23. package/legacy/cssVars/createCssVarsProvider.js +15 -21
  24. package/legacy/cssVars/createCssVarsTheme.js +13 -0
  25. package/legacy/cssVars/createGetCssVar.js +1 -1
  26. package/legacy/cssVars/cssVarsParser.js +4 -1
  27. package/legacy/cssVars/index.js +3 -1
  28. package/legacy/cssVars/prepareCssVars.js +59 -0
  29. package/legacy/index.js +4 -1
  30. package/legacy/styleFunctionSx/defaultSxConfig.js +29 -3
  31. package/modern/cssVars/createCssVarsProvider.js +8 -16
  32. package/modern/cssVars/createCssVarsTheme.js +16 -0
  33. package/modern/cssVars/createGetCssVar.js +1 -1
  34. package/modern/cssVars/cssVarsParser.js +4 -1
  35. package/modern/cssVars/index.js +3 -1
  36. package/modern/cssVars/prepareCssVars.js +62 -0
  37. package/modern/index.js +4 -1
  38. package/modern/styleFunctionSx/defaultSxConfig.js +28 -3
  39. package/package.json +3 -3
  40. package/styleFunctionSx/defaultSxConfig.js +30 -3
@@ -105,6 +105,7 @@ export default function cssVarsParser(theme, options) {
105
105
  } = options || {};
106
106
  const css = {};
107
107
  const vars = {};
108
+ const varsWithDefaults = {};
108
109
  walkObjectDeep(theme, (keys, value, arrayKeys) => {
109
110
  if (typeof value === 'string' || typeof value === 'number') {
110
111
  if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
@@ -114,6 +115,7 @@ export default function cssVarsParser(theme, options) {
114
115
  [cssVar]: getCssValue(keys, value)
115
116
  });
116
117
  assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
118
+ assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${value})`, arrayKeys);
117
119
  }
118
120
  }
119
121
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
@@ -121,6 +123,7 @@ export default function cssVarsParser(theme, options) {
121
123
 
122
124
  return {
123
125
  css,
124
- vars
126
+ vars,
127
+ varsWithDefaults
125
128
  };
126
129
  }
@@ -1,2 +1,4 @@
1
1
  export { default } from './createCssVarsProvider';
2
- export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
2
+ export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
3
+ export { default as prepareCssVars } from './prepareCssVars';
4
+ export { default as createCssVarsTheme } from './createCssVarsTheme';
@@ -0,0 +1,62 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ const _excluded = ["colorSchemes", "components"],
3
+ _excluded2 = ["light"];
4
+ import { deepmerge } from '@mui/utils';
5
+ import cssVarsParser from './cssVarsParser';
6
+ function prepareCssVars(theme, parserConfig) {
7
+ // @ts-ignore - ignore components do not exist
8
+ const {
9
+ colorSchemes = {}
10
+ } = theme,
11
+ otherTheme = _objectWithoutPropertiesLoose(theme, _excluded);
12
+ const {
13
+ vars: rootVars,
14
+ css: rootCss,
15
+ varsWithDefaults: rootVarsWithDefaults
16
+ } = cssVarsParser(otherTheme, parserConfig);
17
+ let themeVars = rootVarsWithDefaults;
18
+ const colorSchemesMap = {};
19
+ const {
20
+ light
21
+ } = colorSchemes,
22
+ otherColorSchemes = _objectWithoutPropertiesLoose(colorSchemes, _excluded2);
23
+ Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
24
+ const {
25
+ vars,
26
+ css,
27
+ varsWithDefaults
28
+ } = cssVarsParser(scheme, parserConfig);
29
+ themeVars = deepmerge(themeVars, varsWithDefaults);
30
+ colorSchemesMap[key] = {
31
+ css,
32
+ vars
33
+ };
34
+ });
35
+ if (light) {
36
+ // light color scheme vars should be merged last to set as default
37
+ const {
38
+ css,
39
+ vars,
40
+ varsWithDefaults
41
+ } = cssVarsParser(light, parserConfig);
42
+ themeVars = deepmerge(themeVars, varsWithDefaults);
43
+ colorSchemesMap.light = {
44
+ css,
45
+ vars
46
+ };
47
+ }
48
+ const generateCssVars = colorScheme => {
49
+ if (!colorScheme) {
50
+ return {
51
+ css: rootCss,
52
+ vars: rootVars
53
+ };
54
+ }
55
+ return colorSchemesMap[colorScheme];
56
+ };
57
+ return {
58
+ vars: themeVars,
59
+ generateCssVars
60
+ };
61
+ }
62
+ export default prepareCssVars;
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v5.11.11
2
+ * @mui/system v5.11.13
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -52,6 +52,9 @@ export * from './colorManipulator';
52
52
  export { default as ThemeProvider } from './ThemeProvider';
53
53
  export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
54
54
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
55
+ export { default as unstable_cssVarsParser } from './cssVars/cssVarsParser';
56
+ export { default as unstable_prepareCssVars } from './cssVars/prepareCssVars';
57
+ export { default as unstable_createCssVarsTheme } from './cssVars/createCssVarsTheme';
55
58
  export { default as responsivePropType } from './responsivePropType';
56
59
 
57
60
  /** ----------------- */
@@ -1,8 +1,30 @@
1
+ import { unstable_capitalize as capitalize } from '@mui/utils';
1
2
  import { padding, margin } from '../spacing';
3
+ import { handleBreakpoints } from '../breakpoints';
2
4
  import { borderRadius, borderTransform } from '../borders';
3
5
  import { gap, rowGap, columnGap } from '../cssGrid';
4
6
  import { paletteTransform } from '../palette';
5
7
  import { maxWidth, sizingTransform } from '../sizing';
8
+ const createFontStyleFunction = prop => {
9
+ return props => {
10
+ if (props[prop] !== undefined && props[prop] !== null) {
11
+ const styleFromPropValue = propValue => {
12
+ let value = props.theme.typography?.[`${prop}${props[prop] === 'default' || props[prop] === prop ? '' : capitalize(props[prop]?.toString())}`];
13
+ if (!value) {
14
+ value = props.theme.typography?.[propValue]?.[prop];
15
+ }
16
+ if (!value) {
17
+ value = propValue;
18
+ }
19
+ return {
20
+ [prop]: value
21
+ };
22
+ };
23
+ return handleBreakpoints(props, props[prop], styleFromPropValue);
24
+ }
25
+ return null;
26
+ };
27
+ };
6
28
  const defaultSxConfig = {
7
29
  // borders
8
30
  border: {
@@ -261,16 +283,19 @@ const defaultSxConfig = {
261
283
  boxSizing: {},
262
284
  // typography
263
285
  fontFamily: {
264
- themeKey: 'typography'
286
+ themeKey: 'typography',
287
+ style: createFontStyleFunction('fontFamily')
265
288
  },
266
289
  fontSize: {
267
- themeKey: 'typography'
290
+ themeKey: 'typography',
291
+ style: createFontStyleFunction('fontSize')
268
292
  },
269
293
  fontStyle: {
270
294
  themeKey: 'typography'
271
295
  },
272
296
  fontWeight: {
273
- themeKey: 'typography'
297
+ themeKey: 'typography',
298
+ style: createFontStyleFunction('fontWeight')
274
299
  },
275
300
  letterSpacing: {},
276
301
  textTransform: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.11.11",
3
+ "version": "5.11.13",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.21.0",
47
- "@mui/private-theming": "^5.11.11",
47
+ "@mui/private-theming": "^5.11.13",
48
48
  "@mui/styled-engine": "^5.11.11",
49
49
  "@mui/types": "^7.2.3",
50
- "@mui/utils": "^5.11.11",
50
+ "@mui/utils": "^5.11.13",
51
51
  "clsx": "^1.2.1",
52
52
  "csstype": "^3.1.1",
53
53
  "prop-types": "^15.8.1"
@@ -4,11 +4,35 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _utils = require("@mui/utils");
7
8
  var _spacing = require("../spacing");
9
+ var _breakpoints = require("../breakpoints");
8
10
  var _borders = require("../borders");
9
11
  var _cssGrid = require("../cssGrid");
10
12
  var _palette = require("../palette");
11
13
  var _sizing = require("../sizing");
14
+ const createFontStyleFunction = prop => {
15
+ return props => {
16
+ if (props[prop] !== undefined && props[prop] !== null) {
17
+ const styleFromPropValue = propValue => {
18
+ var _props$theme$typograp, _props$prop;
19
+ let value = (_props$theme$typograp = props.theme.typography) == null ? void 0 : _props$theme$typograp[`${prop}${props[prop] === 'default' || props[prop] === prop ? '' : (0, _utils.unstable_capitalize)((_props$prop = props[prop]) == null ? void 0 : _props$prop.toString())}`];
20
+ if (!value) {
21
+ var _props$theme$typograp2, _props$theme$typograp3;
22
+ value = (_props$theme$typograp2 = props.theme.typography) == null ? void 0 : (_props$theme$typograp3 = _props$theme$typograp2[propValue]) == null ? void 0 : _props$theme$typograp3[prop];
23
+ }
24
+ if (!value) {
25
+ value = propValue;
26
+ }
27
+ return {
28
+ [prop]: value
29
+ };
30
+ };
31
+ return (0, _breakpoints.handleBreakpoints)(props, props[prop], styleFromPropValue);
32
+ }
33
+ return null;
34
+ };
35
+ };
12
36
  const defaultSxConfig = {
13
37
  // borders
14
38
  border: {
@@ -267,16 +291,19 @@ const defaultSxConfig = {
267
291
  boxSizing: {},
268
292
  // typography
269
293
  fontFamily: {
270
- themeKey: 'typography'
294
+ themeKey: 'typography',
295
+ style: createFontStyleFunction('fontFamily')
271
296
  },
272
297
  fontSize: {
273
- themeKey: 'typography'
298
+ themeKey: 'typography',
299
+ style: createFontStyleFunction('fontSize')
274
300
  },
275
301
  fontStyle: {
276
302
  themeKey: 'typography'
277
303
  },
278
304
  fontWeight: {
279
- themeKey: 'typography'
305
+ themeKey: 'typography',
306
+ style: createFontStyleFunction('fontWeight')
280
307
  },
281
308
  letterSpacing: {},
282
309
  textTransform: {},