@mui/system 5.6.1 → 5.6.4

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 (52) hide show
  1. package/Box/Box.d.ts +18 -1
  2. package/Box/Box.js +26 -0
  3. package/Box/Box.spec.d.ts +1 -1
  4. package/CHANGELOG.md +185 -2
  5. package/ThemeProvider/ThemeProvider.d.ts +6 -0
  6. package/ThemeProvider/ThemeProvider.js +9 -2
  7. package/createBox.js +0 -26
  8. package/createBox.spec.d.ts +1 -1
  9. package/createStyled.js +3 -1
  10. package/createTheme/createSpacing.d.ts +10 -10
  11. package/cssVars/createCssVarsProvider.js +20 -36
  12. package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
  13. package/cssVars/createGetCssVar.d.ts +5 -5
  14. package/cssVars/cssVarsParser.d.ts +70 -70
  15. package/cssVars/cssVarsParser.js +11 -9
  16. package/cssVars/getInitColorSchemeScript.d.ts +12 -12
  17. package/cssVars/index.d.ts +2 -2
  18. package/cssVars/useCurrentColorScheme.d.ts +50 -50
  19. package/esm/Box/Box.js +25 -0
  20. package/esm/ThemeProvider/ThemeProvider.js +9 -2
  21. package/esm/createBox.js +0 -25
  22. package/esm/createStyled.js +3 -1
  23. package/esm/cssVars/createCssVarsProvider.js +21 -35
  24. package/esm/cssVars/cssVarsParser.js +11 -9
  25. package/esm/spacing.js +3 -1
  26. package/esm/style.js +16 -1
  27. package/index.d.ts +4 -0
  28. package/index.js +1 -1
  29. package/index.spec.d.ts +1 -1
  30. package/legacy/Box/Box.js +25 -0
  31. package/legacy/ThemeProvider/ThemeProvider.js +9 -2
  32. package/legacy/createBox.js +0 -25
  33. package/legacy/createStyled.js +3 -1
  34. package/legacy/cssVars/createCssVarsProvider.js +22 -31
  35. package/legacy/cssVars/cssVarsParser.js +11 -7
  36. package/legacy/index.js +1 -1
  37. package/legacy/spacing.js +3 -1
  38. package/legacy/style.js +16 -1
  39. package/modern/Box/Box.js +25 -0
  40. package/modern/ThemeProvider/ThemeProvider.js +9 -2
  41. package/modern/createBox.js +0 -25
  42. package/modern/createStyled.js +3 -1
  43. package/modern/cssVars/createCssVarsProvider.js +21 -33
  44. package/modern/cssVars/cssVarsParser.js +11 -9
  45. package/modern/index.js +1 -1
  46. package/modern/spacing.js +1 -1
  47. package/modern/style.js +16 -1
  48. package/package.json +2 -2
  49. package/spacing.js +3 -1
  50. package/style.js +16 -1
  51. package/styleFunctionSx/styleFunctionSx.d.ts +3 -1
  52. package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
@@ -15,16 +15,18 @@
15
15
  * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
16
16
  * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
17
17
  */
18
- export const assignNestedKeys = (obj, keys, value) => {
18
+ export const assignNestedKeys = (obj, keys, value, arrayKeys = []) => {
19
19
  let temp = obj;
20
20
  keys.forEach((k, index) => {
21
21
  if (index === keys.length - 1) {
22
- if (temp && typeof temp === 'object') {
22
+ if (Array.isArray(temp)) {
23
+ temp[Number(k)] = value;
24
+ } else if (temp && typeof temp === 'object') {
23
25
  temp[k] = value;
24
26
  }
25
27
  } else if (temp && typeof temp === 'object') {
26
28
  if (!temp[k]) {
27
- temp[k] = {};
29
+ temp[k] = arrayKeys.includes(k) ? [] : {};
28
30
  }
29
31
 
30
32
  temp = temp[k];
@@ -44,14 +46,14 @@ export const assignNestedKeys = (obj, keys, value) => {
44
46
  */
45
47
 
46
48
  export const walkObjectDeep = (obj, callback, shouldSkipPaths) => {
47
- function recurse(object, parentKeys = []) {
49
+ function recurse(object, parentKeys = [], arrayKeys = []) {
48
50
  Object.entries(object).forEach(([key, value]) => {
49
51
  if (!shouldSkipPaths || shouldSkipPaths && !shouldSkipPaths([...parentKeys, key])) {
50
52
  if (value !== undefined && value !== null) {
51
53
  if (typeof value === 'object' && Object.keys(value).length > 0) {
52
- recurse(value, [...parentKeys, key]);
54
+ recurse(value, [...parentKeys, key], Array.isArray(value) ? [...arrayKeys, key] : arrayKeys);
53
55
  } else {
54
- callback([...parentKeys, key], value, object);
56
+ callback([...parentKeys, key], value, arrayKeys);
55
57
  }
56
58
  }
57
59
  }
@@ -118,7 +120,7 @@ export default function cssVarsParser(theme, options) {
118
120
  const css = {};
119
121
  const vars = {};
120
122
  const parsedTheme = {};
121
- walkObjectDeep(theme, (keys, value) => {
123
+ walkObjectDeep(theme, (keys, value, arrayKeys) => {
122
124
  if (typeof value === 'string' || typeof value === 'number') {
123
125
  if (typeof value === 'string' && value.match(/var\(\s*--/)) {
124
126
  // for CSS variable, apply prefix or remove basePrefix from the variable
@@ -136,11 +138,11 @@ export default function cssVarsParser(theme, options) {
136
138
  Object.assign(css, {
137
139
  [cssVar]: getCssValue(keys, value)
138
140
  });
139
- assignNestedKeys(vars, keys, `var(${cssVar})`);
141
+ assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
140
142
  }
141
143
  }
142
144
 
143
- assignNestedKeys(parsedTheme, keys, value);
145
+ assignNestedKeys(parsedTheme, keys, value, arrayKeys);
144
146
  }, keys => keys[0] === 'vars' // skip 'vars/*' paths
145
147
  );
146
148
  return {
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.1
1
+ /** @license MUI v5.6.4
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/modern/spacing.js CHANGED
@@ -43,7 +43,7 @@ const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTo
43
43
  const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
44
44
  const spacingKeys = [...marginKeys, ...paddingKeys];
45
45
  export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
46
- const themeSpacing = getPath(theme, themeKey) || defaultValue;
46
+ const themeSpacing = getPath(theme, themeKey) ?? defaultValue;
47
47
 
48
48
  if (typeof themeSpacing === 'number') {
49
49
  return abs => {
package/modern/style.js CHANGED
@@ -4,9 +4,24 @@ import { handleBreakpoints } from './breakpoints';
4
4
  export function getPath(obj, path) {
5
5
  if (!path || typeof path !== 'string') {
6
6
  return null;
7
+ } // Check if CSS variables are used
8
+
9
+
10
+ if (obj && obj.vars) {
11
+ const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
12
+
13
+ if (val != null) {
14
+ return val;
15
+ }
7
16
  }
8
17
 
9
- return path.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
18
+ return path.split('.').reduce((acc, item) => {
19
+ if (acc && acc[item] != null) {
20
+ return acc[item];
21
+ }
22
+
23
+ return null;
24
+ }, obj);
10
25
  }
11
26
 
12
27
  function getValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.6.1",
3
+ "version": "5.6.4",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.17.2",
47
- "@mui/private-theming": "^5.6.1",
47
+ "@mui/private-theming": "^5.6.2",
48
48
  "@mui/styled-engine": "^5.6.1",
49
49
  "@mui/types": "^7.1.3",
50
50
  "@mui/utils": "^5.6.1",
package/spacing.js CHANGED
@@ -64,7 +64,9 @@ const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddin
64
64
  const spacingKeys = [...marginKeys, ...paddingKeys];
65
65
 
66
66
  function createUnaryUnit(theme, themeKey, defaultValue, propName) {
67
- const themeSpacing = (0, _style.getPath)(theme, themeKey) || defaultValue;
67
+ var _getPath;
68
+
69
+ const themeSpacing = (_getPath = (0, _style.getPath)(theme, themeKey)) != null ? _getPath : defaultValue;
68
70
 
69
71
  if (typeof themeSpacing === 'number') {
70
72
  return abs => {
package/style.js CHANGED
@@ -17,9 +17,24 @@ var _breakpoints = require("./breakpoints");
17
17
  function getPath(obj, path) {
18
18
  if (!path || typeof path !== 'string') {
19
19
  return null;
20
+ } // Check if CSS variables are used
21
+
22
+
23
+ if (obj && obj.vars) {
24
+ const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
25
+
26
+ if (val != null) {
27
+ return val;
28
+ }
20
29
  }
21
30
 
22
- return path.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
31
+ return path.split('.').reduce((acc, item) => {
32
+ if (acc && acc[item] != null) {
33
+ return acc[item];
34
+ }
35
+
36
+ return null;
37
+ }, obj);
23
38
  }
24
39
 
25
40
  function getValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
@@ -69,7 +69,9 @@ export type SystemStyleObject<Theme extends object = {}> =
69
69
  export type SxProps<Theme extends object = {}> =
70
70
  | SystemStyleObject<Theme>
71
71
  | ((theme: Theme) => SystemStyleObject<Theme>)
72
- | Array<boolean | SystemStyleObject<Theme> | ((theme: Theme) => SystemStyleObject<Theme>)>;
72
+ | ReadonlyArray<
73
+ boolean | SystemStyleObject<Theme> | ((theme: Theme) => SystemStyleObject<Theme>)
74
+ >;
73
75
 
74
76
  export interface StyleFunctionSx {
75
77
  (props: object): object;
@@ -1 +1 @@
1
- export {};
1
+ export {};