@mui/system 5.2.4 → 5.3.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.
@@ -7,13 +7,14 @@ const _excluded = ["colorSchemes"],
7
7
  import * as React from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { GlobalStyles } from '@mui/styled-engine';
10
- import { deepmerge } from '@mui/utils';
10
+ import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
11
11
  import createSpacing from '../createTheme/createSpacing';
12
12
  import createBreakpoints from '../createTheme/createBreakpoints';
13
13
  import cssVarsParser from './cssVarsParser';
14
14
  import ThemeProvider from '../ThemeProvider';
15
15
  import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
16
16
  import useCurrentColorScheme from './useCurrentColorScheme';
17
+ import createGetCssVar from './createGetCssVar';
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
20
  export const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
@@ -124,7 +125,8 @@ export default function createCssVarsProvider(options) {
124
125
  colorSchemes,
125
126
  vars: rootVars,
126
127
  spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
127
- breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints
128
+ breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
129
+ getCssVar: createGetCssVar(prefix)
128
130
  });
129
131
  const styleSheet = {};
130
132
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
@@ -162,7 +164,7 @@ export default function createCssVarsProvider(options) {
162
164
  document.documentElement.setAttribute(attribute, colorScheme);
163
165
  }
164
166
  }, [colorScheme, attribute]);
165
- React.useEffect(() => {
167
+ useEnhancedEffect(() => {
166
168
  if (!mode || !enableColorScheme) {
167
169
  return undefined;
168
170
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
3
+ * and they does not need to remember the prefix (defined once).
4
+ */
5
+ export default function createGetCssVar(prefix = '') {
6
+ function appendVar(...vars) {
7
+ if (!vars.length) {
8
+ return '';
9
+ }
10
+
11
+ return `, var(--${prefix ? `${prefix}-` : ''}${vars[0]}${appendVar(...vars.slice(1))})`;
12
+ } // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
13
+
14
+
15
+ const getCssVar = (field, ...vars) => {
16
+ return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...vars)})`;
17
+ };
18
+
19
+ return getCssVar;
20
+ }
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.2.4
1
+ /** @license MUI v5.3.0
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.
@@ -43,4 +43,5 @@ export { default as useTheme } from './useTheme';
43
43
  export { default as useThemeWithoutDefault } from './useThemeWithoutDefault';
44
44
  export * from './colorManipulator';
45
45
  export { default as ThemeProvider } from './ThemeProvider';
46
- export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
46
+ export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
47
+ export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
@@ -19,6 +19,9 @@ export const fontWeight = style({
19
19
  export const letterSpacing = style({
20
20
  prop: 'letterSpacing'
21
21
  });
22
+ export const textTransform = style({
23
+ prop: 'textTransform'
24
+ });
22
25
  export const lineHeight = style({
23
26
  prop: 'lineHeight'
24
27
  });
@@ -30,5 +33,5 @@ export const typographyVariant = style({
30
33
  cssProperty: false,
31
34
  themeKey: 'typography'
32
35
  });
33
- const typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign);
36
+ const typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, textTransform);
34
37
  export default typography;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.2.4",
3
+ "version": "5.3.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -29,7 +29,7 @@
29
29
  "@emotion/react": "^11.5.0",
30
30
  "@emotion/styled": "^11.3.0",
31
31
  "@types/react": "^16.8.6 || ^17.0.0",
32
- "react": "^17.0.2"
32
+ "react": "^17.0.0"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@types/react": {
@@ -43,11 +43,11 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@babel/runtime": "^7.16.3",
47
- "@mui/private-theming": "^5.2.3",
48
- "@mui/styled-engine": "^5.2.4",
46
+ "@babel/runtime": "^7.16.7",
47
+ "@mui/private-theming": "^5.3.0",
48
+ "@mui/styled-engine": "^5.3.0",
49
49
  "@mui/types": "^7.1.0",
50
- "@mui/utils": "^5.2.3",
50
+ "@mui/utils": "^5.3.0",
51
51
  "clsx": "^1.1.1",
52
52
  "csstype": "^3.0.10",
53
53
  "prop-types": "^15.7.2"
@@ -49,6 +49,7 @@ export type SystemStyleObject<Theme extends object = {}> =
49
49
  | SystemCssProperties<Theme>
50
50
  | CSSPseudoSelectorProps<Theme>
51
51
  | CSSSelectorObject<Theme>
52
+ | { [cssVariable: string]: string | number }
52
53
  | null;
53
54
 
54
55
  /**
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/typography.js CHANGED
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.typographyVariant = exports.textAlign = exports.lineHeight = exports.letterSpacing = exports.fontWeight = exports.fontStyle = exports.fontSize = exports.fontFamily = exports.default = void 0;
8
+ exports.typographyVariant = exports.textTransform = exports.textAlign = exports.lineHeight = exports.letterSpacing = exports.fontWeight = exports.fontStyle = exports.fontSize = exports.fontFamily = exports.default = void 0;
9
9
 
10
10
  var _style = _interopRequireDefault(require("./style"));
11
11
 
@@ -35,6 +35,10 @@ const letterSpacing = (0, _style.default)({
35
35
  prop: 'letterSpacing'
36
36
  });
37
37
  exports.letterSpacing = letterSpacing;
38
+ const textTransform = (0, _style.default)({
39
+ prop: 'textTransform'
40
+ });
41
+ exports.textTransform = textTransform;
38
42
  const lineHeight = (0, _style.default)({
39
43
  prop: 'lineHeight'
40
44
  });
@@ -49,6 +53,6 @@ const typographyVariant = (0, _style.default)({
49
53
  themeKey: 'typography'
50
54
  });
51
55
  exports.typographyVariant = typographyVariant;
52
- const typography = (0, _compose.default)(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign);
56
+ const typography = (0, _compose.default)(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, textTransform);
53
57
  var _default = typography;
54
58
  exports.default = _default;