@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.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = createGetCssVar;
7
+
8
+ /**
9
+ * The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
10
+ * and they does not need to remember the prefix (defined once).
11
+ */
12
+ function createGetCssVar(prefix = '') {
13
+ function appendVar(...vars) {
14
+ if (!vars.length) {
15
+ return '';
16
+ }
17
+
18
+ return `, var(--${prefix ? `${prefix}-` : ''}${vars[0]}${appendVar(...vars.slice(1))})`;
19
+ } // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
20
+
21
+
22
+ const getCssVar = (field, ...vars) => {
23
+ return `var(--${prefix ? `${prefix}-` : ''}${field}${appendVar(...vars)})`;
24
+ };
25
+
26
+ return getCssVar;
27
+ }
@@ -1,68 +1,68 @@
1
- declare type NestedRecord<V = any> = {
2
- [k: string | number]: NestedRecord<V> | V;
3
- };
4
- /**
5
- * This function create an object from keys, value and then assign to target
6
- *
7
- * @param {Object} obj : the target object to be assigned
8
- * @param {string[]} keys
9
- * @param {string | number} value
10
- *
11
- * @example
12
- * const source = {}
13
- * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
14
- * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
15
- *
16
- * @example
17
- * const source = { palette: { primary: 'var(--palette-primary)' } }
18
- * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
19
- * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
20
- */
21
- export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value) => void;
22
- /**
23
- *
24
- * @param {Object} obj : source object
25
- * @param {Function} callback : a function that will be called when
26
- * - the deepest key in source object is reached
27
- * - the value of the deepest key is NOT `undefined` | `null`
28
- *
29
- * @example
30
- * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
- * // ['palette', 'primary', 'main'] '#000000'
32
- */
33
- export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, scope: Record<string, string | number>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
34
- /**
35
- * a function that parse theme and return { css, vars }
36
- *
37
- * @param {Object} theme
38
- * @param {{
39
- * prefix?: string,
40
- * basePrefix?: string,
41
- * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
- * }} options.
43
- * `basePrefix`: defined by design system.
44
- * `prefix`: defined by application
45
- *
46
- * This function also mutate the string value of theme input by replacing `basePrefix` (if existed) with `prefix`
47
- *
48
- * @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme)
49
- *
50
- * @example
51
- * const { css, vars } = parser({
52
- * fontSize: 12,
53
- * lineHeight: 1.2,
54
- * palette: { primary: { 500: '#000000' } }
55
- * })
56
- *
57
- * console.log(css) // { '--fontSize': '12px', '--lineHeight': 1.2, '--palette-primary-500': '#000000' }
58
- * console.log(vars) // { fontSize: '--fontSize', lineHeight: '--lineHeight', palette: { primary: { 500: 'var(--palette-primary-500)' } } }
59
- */
60
- export default function cssVarsParser(theme: Record<string, any>, options?: {
61
- prefix?: string;
62
- basePrefix?: string;
63
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
64
- }): {
65
- css: NestedRecord<string>;
66
- vars: NestedRecord<string>;
67
- };
68
- export {};
1
+ declare type NestedRecord<V = any> = {
2
+ [k: string | number]: NestedRecord<V> | V;
3
+ };
4
+ /**
5
+ * This function create an object from keys, value and then assign to target
6
+ *
7
+ * @param {Object} obj : the target object to be assigned
8
+ * @param {string[]} keys
9
+ * @param {string | number} value
10
+ *
11
+ * @example
12
+ * const source = {}
13
+ * assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
14
+ * console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
15
+ *
16
+ * @example
17
+ * const source = { palette: { primary: 'var(--palette-primary)' } }
18
+ * assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
19
+ * console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
20
+ */
21
+ export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value) => void;
22
+ /**
23
+ *
24
+ * @param {Object} obj : source object
25
+ * @param {Function} callback : a function that will be called when
26
+ * - the deepest key in source object is reached
27
+ * - the value of the deepest key is NOT `undefined` | `null`
28
+ *
29
+ * @example
30
+ * walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
31
+ * // ['palette', 'primary', 'main'] '#000000'
32
+ */
33
+ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, scope: Record<string, string | number>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
34
+ /**
35
+ * a function that parse theme and return { css, vars }
36
+ *
37
+ * @param {Object} theme
38
+ * @param {{
39
+ * prefix?: string,
40
+ * basePrefix?: string,
41
+ * shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
42
+ * }} options.
43
+ * `basePrefix`: defined by design system.
44
+ * `prefix`: defined by application
45
+ *
46
+ * This function also mutate the string value of theme input by replacing `basePrefix` (if existed) with `prefix`
47
+ *
48
+ * @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme)
49
+ *
50
+ * @example
51
+ * const { css, vars } = parser({
52
+ * fontSize: 12,
53
+ * lineHeight: 1.2,
54
+ * palette: { primary: { 500: '#000000' } }
55
+ * })
56
+ *
57
+ * console.log(css) // { '--fontSize': '12px', '--lineHeight': 1.2, '--palette-primary-500': '#000000' }
58
+ * console.log(vars) // { fontSize: '--fontSize', lineHeight: '--lineHeight', palette: { primary: { 500: 'var(--palette-primary-500)' } } }
59
+ */
60
+ export default function cssVarsParser(theme: Record<string, any>, options?: {
61
+ prefix?: string;
62
+ basePrefix?: string;
63
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
64
+ }): {
65
+ css: NestedRecord<string>;
66
+ vars: NestedRecord<string>;
67
+ };
68
+ export {};
@@ -1,12 +1,12 @@
1
- /// <reference types="react" />
2
- export declare const DEFAULT_MODE_STORAGE_KEY = "mui-mode";
3
- export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "mui-color-scheme";
4
- export declare const DEFAULT_ATTRIBUTE = "data-mui-color-scheme";
5
- export default function getInitColorSchemeScript(options?: {
6
- enableSystem?: boolean;
7
- defaultLightColorScheme?: string;
8
- defaultDarkColorScheme?: string;
9
- modeStorageKey?: string;
10
- colorSchemeStorageKey?: string;
11
- attribute?: string;
12
- }): JSX.Element;
1
+ /// <reference types="react" />
2
+ export declare const DEFAULT_MODE_STORAGE_KEY = "mui-mode";
3
+ export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "mui-color-scheme";
4
+ export declare const DEFAULT_ATTRIBUTE = "data-mui-color-scheme";
5
+ export default function getInitColorSchemeScript(options?: {
6
+ enableSystem?: boolean;
7
+ defaultLightColorScheme?: string;
8
+ defaultDarkColorScheme?: string;
9
+ modeStorageKey?: string;
10
+ colorSchemeStorageKey?: string;
11
+ attribute?: string;
12
+ }): JSX.Element;
@@ -1,2 +1,2 @@
1
- export { default } from './createCssVarsProvider';
2
- export type { BuildCssVarsTheme } from './createCssVarsProvider';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { BuildCssVarsTheme } from './createCssVarsProvider';
@@ -1,50 +1,50 @@
1
- export declare type Mode = 'light' | 'dark' | 'system';
2
- export declare type SystemMode = Exclude<Mode, 'system'>;
3
- export interface State<SupportedColorScheme extends string> {
4
- /**
5
- * User selected mode.
6
- * Note: on the server, mode is always undefined
7
- */
8
- mode: Mode | undefined;
9
- /**
10
- * Only valid if `mode: 'system'`, either 'light' | 'dark'.
11
- */
12
- systemMode: SystemMode | undefined;
13
- /**
14
- * The color scheme for the light mode.
15
- */
16
- lightColorScheme: SupportedColorScheme;
17
- /**
18
- * The color scheme for the dark mode.
19
- */
20
- darkColorScheme: SupportedColorScheme;
21
- }
22
- export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
23
- /**
24
- * The current application color scheme. It is always `undefined` on the server.
25
- */
26
- colorScheme: SupportedColorScheme | undefined;
27
- /**
28
- * `mode` is saved to internal state and localStorage
29
- * If `mode` is null, it will be reset to the defaultMode
30
- */
31
- setMode: (mode: Mode | null) => void;
32
- /**
33
- * `colorScheme` is saved to internal state and localStorage
34
- * If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
35
- */
36
- setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
37
- light: SupportedColorScheme | null;
38
- dark: SupportedColorScheme | null;
39
- }> | null) => void;
40
- };
41
- export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
42
- export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
43
- export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: {
44
- defaultLightColorScheme: SupportedColorScheme;
45
- defaultDarkColorScheme: SupportedColorScheme;
46
- supportedColorSchemes: Array<SupportedColorScheme>;
47
- defaultMode?: Mode;
48
- modeStorageKey?: string;
49
- colorSchemeStorageKey?: string;
50
- }): Result<SupportedColorScheme>;
1
+ export declare type Mode = 'light' | 'dark' | 'system';
2
+ export declare type SystemMode = Exclude<Mode, 'system'>;
3
+ export interface State<SupportedColorScheme extends string> {
4
+ /**
5
+ * User selected mode.
6
+ * Note: on the server, mode is always undefined
7
+ */
8
+ mode: Mode | undefined;
9
+ /**
10
+ * Only valid if `mode: 'system'`, either 'light' | 'dark'.
11
+ */
12
+ systemMode: SystemMode | undefined;
13
+ /**
14
+ * The color scheme for the light mode.
15
+ */
16
+ lightColorScheme: SupportedColorScheme;
17
+ /**
18
+ * The color scheme for the dark mode.
19
+ */
20
+ darkColorScheme: SupportedColorScheme;
21
+ }
22
+ export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
23
+ /**
24
+ * The current application color scheme. It is always `undefined` on the server.
25
+ */
26
+ colorScheme: SupportedColorScheme | undefined;
27
+ /**
28
+ * `mode` is saved to internal state and localStorage
29
+ * If `mode` is null, it will be reset to the defaultMode
30
+ */
31
+ setMode: (mode: Mode | null) => void;
32
+ /**
33
+ * `colorScheme` is saved to internal state and localStorage
34
+ * If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
35
+ */
36
+ setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
37
+ light: SupportedColorScheme | null;
38
+ dark: SupportedColorScheme | null;
39
+ }> | null) => void;
40
+ };
41
+ export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
42
+ export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
43
+ export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: {
44
+ defaultLightColorScheme: SupportedColorScheme;
45
+ defaultDarkColorScheme: SupportedColorScheme;
46
+ supportedColorSchemes: Array<SupportedColorScheme>;
47
+ defaultMode?: Mode;
48
+ modeStorageKey?: string;
49
+ colorSchemeStorageKey?: string;
50
+ }): Result<SupportedColorScheme>;
@@ -138,7 +138,11 @@ export default function createStyled(input = {}) {
138
138
  const styleOverrides = getStyleOverrides(componentName, theme);
139
139
 
140
140
  if (styleOverrides) {
141
- return overridesResolver(props, styleOverrides);
141
+ const resolvedStyleOverrides = {};
142
+ Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
143
+ resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props) : slotStyle;
144
+ });
145
+ return overridesResolver(props, resolvedStyleOverrides);
142
146
  }
143
147
 
144
148
  return null;
@@ -201,6 +205,10 @@ export default function createStyled(input = {}) {
201
205
  return Component;
202
206
  };
203
207
 
208
+ if (defaultStyledResolver.withConfig) {
209
+ muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
210
+ }
211
+
204
212
  return muiStyledResolver;
205
213
  };
206
214
  }
@@ -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}';
@@ -126,7 +127,8 @@ export default function createCssVarsProvider(options) {
126
127
  colorSchemes,
127
128
  vars: rootVars,
128
129
  spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
129
- breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints
130
+ breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
131
+ getCssVar: createGetCssVar(prefix)
130
132
  });
131
133
  const styleSheet = {};
132
134
  Object.entries(colorSchemes).forEach(([key, scheme]) => {
@@ -164,7 +166,7 @@ export default function createCssVarsProvider(options) {
164
166
  document.documentElement.setAttribute(attribute, colorScheme);
165
167
  }
166
168
  }, [colorScheme, attribute]);
167
- React.useEffect(() => {
169
+ useEnhancedEffect(() => {
168
170
  if (!mode || !enableColorScheme) {
169
171
  return undefined;
170
172
  }
@@ -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/esm/index.js CHANGED
@@ -38,4 +38,5 @@ export { default as useTheme } from './useTheme';
38
38
  export { default as useThemeWithoutDefault } from './useThemeWithoutDefault';
39
39
  export * from './colorManipulator';
40
40
  export { default as ThemeProvider } from './ThemeProvider';
41
- export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
41
+ export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
42
+ export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
package/esm/typography.js CHANGED
@@ -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/index.d.ts CHANGED
@@ -88,6 +88,7 @@ export const fontWeight: SimpleStyleFunction<'fontWeight'>;
88
88
  export const letterSpacing: SimpleStyleFunction<'letterSpacing'>;
89
89
  export const lineHeight: SimpleStyleFunction<'lineHeight'>;
90
90
  export const textAlign: SimpleStyleFunction<'textAlign'>;
91
+ export const textTransform: SimpleStyleFunction<'textTransform'>;
91
92
  export type TypographyProps = PropsFor<typeof typography>;
92
93
 
93
94
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -161,4 +162,5 @@ export { default as ThemeProvider } from './ThemeProvider';
161
162
  export * from './ThemeProvider';
162
163
 
163
164
  export { default as unstable_createCssVarsProvider } from './cssVars';
165
+ export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
164
166
  export * from './cssVars';
package/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.
@@ -49,7 +49,8 @@ var _exportNames = {
49
49
  useTheme: true,
50
50
  useThemeWithoutDefault: true,
51
51
  ThemeProvider: true,
52
- unstable_createCssVarsProvider: true
52
+ unstable_createCssVarsProvider: true,
53
+ unstable_createGetCssVar: true
53
54
  };
54
55
  Object.defineProperty(exports, "Box", {
55
56
  enumerable: true,
@@ -243,6 +244,12 @@ Object.defineProperty(exports, "unstable_createCssVarsProvider", {
243
244
  return _createCssVarsProvider.default;
244
245
  }
245
246
  });
247
+ Object.defineProperty(exports, "unstable_createGetCssVar", {
248
+ enumerable: true,
249
+ get: function () {
250
+ return _createGetCssVar.default;
251
+ }
252
+ });
246
253
  Object.defineProperty(exports, "unstable_extendSxProp", {
247
254
  enumerable: true,
248
255
  get: function () {
@@ -468,6 +475,8 @@ var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider"));
468
475
 
469
476
  var _createCssVarsProvider = _interopRequireDefault(require("./cssVars/createCssVarsProvider"));
470
477
 
478
+ var _createGetCssVar = _interopRequireDefault(require("./cssVars/createGetCssVar"));
479
+
471
480
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
472
481
 
473
482
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
  import _extends from "@babel/runtime/helpers/esm/extends";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
5
  import styledEngineStyled from '@mui/styled-engine';
@@ -139,7 +140,15 @@ export default function createStyled() {
139
140
  var styleOverrides = getStyleOverrides(componentName, theme);
140
141
 
141
142
  if (styleOverrides) {
142
- return overridesResolver(props, styleOverrides);
143
+ var resolvedStyleOverrides = {};
144
+ Object.entries(styleOverrides).forEach(function (_ref2) {
145
+ var _ref3 = _slicedToArray(_ref2, 2),
146
+ slotKey = _ref3[0],
147
+ slotStyle = _ref3[1];
148
+
149
+ resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props) : slotStyle;
150
+ });
151
+ return overridesResolver(props, resolvedStyleOverrides);
143
152
  }
144
153
 
145
154
  return null;
@@ -171,9 +180,9 @@ export default function createStyled() {
171
180
  transformedStyleArg.raw = [].concat(_toConsumableArray(styleArg.raw), _toConsumableArray(placeholders));
172
181
  } else if (typeof styleArg === 'function') {
173
182
  // If the type is function, we need to define the default theme.
174
- transformedStyleArg = function transformedStyleArg(_ref2) {
175
- var themeInput = _ref2.theme,
176
- other = _objectWithoutProperties(_ref2, ["theme"]);
183
+ transformedStyleArg = function transformedStyleArg(_ref4) {
184
+ var themeInput = _ref4.theme,
185
+ other = _objectWithoutProperties(_ref4, ["theme"]);
177
186
 
178
187
  return styleArg(_extends({
179
188
  theme: isEmpty(themeInput) ? defaultTheme : themeInput
@@ -200,6 +209,10 @@ export default function createStyled() {
200
209
  return Component;
201
210
  };
202
211
 
212
+ if (defaultStyledResolver.withConfig) {
213
+ muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
214
+ }
215
+
203
216
  return muiStyledResolver;
204
217
  };
205
218
  }
@@ -6,13 +6,14 @@ import { formatMuiErrorMessage as _formatMuiErrorMessage } from "@mui/utils";
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { GlobalStyles } from '@mui/styled-engine';
9
- import { deepmerge } from '@mui/utils';
9
+ import { deepmerge, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
10
10
  import createSpacing from '../createTheme/createSpacing';
11
11
  import createBreakpoints from '../createTheme/createBreakpoints';
12
12
  import cssVarsParser from './cssVarsParser';
13
13
  import ThemeProvider from '../ThemeProvider';
14
14
  import getInitColorSchemeScript, { DEFAULT_ATTRIBUTE, DEFAULT_MODE_STORAGE_KEY } from './getInitColorSchemeScript';
15
15
  import useCurrentColorScheme from './useCurrentColorScheme';
16
+ import createGetCssVar from './createGetCssVar';
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
19
  export var DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
@@ -132,7 +133,8 @@ export default function createCssVarsProvider(options) {
132
133
  colorSchemes: colorSchemes,
133
134
  vars: rootVars,
134
135
  spacing: themeProp.spacing ? createSpacing(themeProp.spacing) : systemSpacing,
135
- breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints
136
+ breakpoints: themeProp.breakpoints ? createBreakpoints(themeProp.breakpoints) : systemBreakpoints,
137
+ getCssVar: createGetCssVar(prefix)
136
138
  });
137
139
  var styleSheet = {};
138
140
  Object.entries(colorSchemes).forEach(function (_ref2) {
@@ -174,7 +176,7 @@ export default function createCssVarsProvider(options) {
174
176
  document.documentElement.setAttribute(attribute, colorScheme);
175
177
  }
176
178
  }, [colorScheme, attribute]);
177
- React.useEffect(function () {
179
+ useEnhancedEffect(function () {
178
180
  if (!mode || !enableColorScheme) {
179
181
  return undefined;
180
182
  }
@@ -0,0 +1,32 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+
3
+ /**
4
+ * The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
5
+ * and they does not need to remember the prefix (defined once).
6
+ */
7
+ export default function createGetCssVar() {
8
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
9
+
10
+ function appendVar() {
11
+ for (var _len = arguments.length, vars = new Array(_len), _key = 0; _key < _len; _key++) {
12
+ vars[_key] = arguments[_key];
13
+ }
14
+
15
+ if (!vars.length) {
16
+ return '';
17
+ }
18
+
19
+ return ", var(--".concat(prefix ? "".concat(prefix, "-") : '').concat(vars[0]).concat(appendVar.apply(void 0, _toConsumableArray(vars.slice(1))), ")");
20
+ } // AdditionalVars makes `getCssVar` less strict, so it can be use like this `getCssVar('non-mui-variable')` without type error.
21
+
22
+
23
+ var getCssVar = function getCssVar(field) {
24
+ for (var _len2 = arguments.length, vars = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
25
+ vars[_key2 - 1] = arguments[_key2];
26
+ }
27
+
28
+ return "var(--".concat(prefix ? "".concat(prefix, "-") : '').concat(field).concat(appendVar.apply(void 0, vars), ")");
29
+ };
30
+
31
+ return getCssVar;
32
+ }
package/legacy/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 var fontWeight = style({
19
19
  export var letterSpacing = style({
20
20
  prop: 'letterSpacing'
21
21
  });
22
+ export var textTransform = style({
23
+ prop: 'textTransform'
24
+ });
22
25
  export var lineHeight = style({
23
26
  prop: 'lineHeight'
24
27
  });
@@ -30,5 +33,5 @@ export var typographyVariant = style({
30
33
  cssProperty: false,
31
34
  themeKey: 'typography'
32
35
  });
33
- var typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign);
36
+ var typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, textTransform);
34
37
  export default typography;
@@ -136,7 +136,11 @@ export default function createStyled(input = {}) {
136
136
  const styleOverrides = getStyleOverrides(componentName, theme);
137
137
 
138
138
  if (styleOverrides) {
139
- return overridesResolver(props, styleOverrides);
139
+ const resolvedStyleOverrides = {};
140
+ Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
141
+ resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(props) : slotStyle;
142
+ });
143
+ return overridesResolver(props, resolvedStyleOverrides);
140
144
  }
141
145
 
142
146
  return null;
@@ -199,6 +203,10 @@ export default function createStyled(input = {}) {
199
203
  return Component;
200
204
  };
201
205
 
206
+ if (defaultStyledResolver.withConfig) {
207
+ muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
208
+ }
209
+
202
210
  return muiStyledResolver;
203
211
  };
204
212
  }