@mui/system 5.1.1 โ†’ 5.2.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.
package/Box/Box.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/CHANGELOG.md CHANGED
@@ -1,5 +1,87 @@
1
1
  ### [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.2.0
4
+
5
+ <!-- generated comparing v5.1.1..master -->
6
+
7
+ _Nov 23, 2021_
8
+
9
+ A big thanks to the 18 contributors who made this release possible. Here are some highlights โœจ:
10
+
11
+ - ๐Ÿงช Created another unstyled component: [TabsUnstyled](https://mui.com/components/tabs/#unstyled) (#29597) @mnajdova.
12
+ - ๐ŸŽ‰ Updated the Material Icons set with the latest changes from Google (#29328) @michaldudak / (#29818) @chao813.
13
+ This update adds 200 new icons and tweaks the appearance of many more.
14
+ With it, we're getting close to having 2000 icons in our set.
15
+ - ๐Ÿ› Fixed bugs and improved the infrastructure and documentation ๐Ÿ“š.
16
+
17
+ ### `@mui/material@5.2.0`
18
+
19
+ - [IconButton] Remove on hover effect when `disableRipple` is set (#29298) @adamfitzgibbon
20
+ - [i18n] Add the amharic language (#29153) @NatiG100
21
+ - [material] Fix types for `variants.style` to accept callbacks (#29610) @mnajdova
22
+ - [Popper] Simplify prop types (#29680) @michaldudak
23
+ - [Select] Include aria-selected=false when option not selected (#29695) @michaldudak
24
+ - [useMediaQuery] Fix crash in Safari < 14 and IE 11 (#29776) @eps1lon
25
+ - [useMediaQuery] Ensure no tearing in React 18 (#28491) @eps1lon
26
+
27
+ ### `@mui/codemod@5.2.0`
28
+
29
+ - [codemod] Fix `jss-to-styled` to support multiple withStyles (#29824) @siriwatknp
30
+
31
+ ### `@mui/icons-material@5.2.0`
32
+
33
+ - [icons] Sync new Google Material Icons (#29818) @chao813
34
+ - [icons] Sync recent Material Icons from Google (#29328) @michaldudak
35
+
36
+ ### `@mui/system@5.2.0`
37
+
38
+ - [Box] Fix `sx` prop runtime issue when used as function (#29830) @mnajdova
39
+ - [system] Fix `sx` throw error when value is `null` or `undefined` (#29756) @siriwatknp
40
+ - [system] Fix minor CssVars issues (#29747) @siriwatknp
41
+
42
+ ### `@mui/styled-engine@5.2.0`
43
+
44
+ - [styled-engine] Fix props inference in styled-engine (#29739) @Janpot
45
+
46
+ ### `@mui/base@5.0.0-alpha.56`
47
+
48
+ - [FormControlUnstyled] `focused` is always false unless explicitly set to `true` @mwilkins91
49
+ - [TabsUnstyled] Introduce new component (#29597) @mnajdova
50
+
51
+ ### `@mui/lab@5.0.0-alpha.56`
52
+
53
+ - [DatePicker][timepicker] Add missing component declarations (#29517) @longzheng
54
+ - [Masonry] exports from root package (#29754) @abhinav-22-tech
55
+ - [pickers] Widen accepted `luxon` version range (#29761) @eps1lon
56
+
57
+ ### Docs
58
+
59
+ - [blog] MUI X v5 blog post (#29590) @DanailH
60
+ - [blog] Polish the Benny Joo joins MUI post (#29697) @oliviertassinari
61
+ - [CHANGELOG] Explain why we do breaking changes @oliviertassinari
62
+ - [core] Update latest issue template for codesandbox CI (#29783) @eps1lon
63
+ - [core] Ensure `@mui/core` is an alias for `@mui/base` (#29762) @eps1lon
64
+ - [docs] Fix broken Next and Previous links (#29711) @scallaway
65
+ - [docs] Add a note that ToggleButton exclusive does not enforce selection (#29812) @mmacu
66
+ - [docs] Update the list of supported locales (#29831) @michaldudak
67
+ - [docs] Update tooltip doc to better define touch action (#29717) @gnowland
68
+ - [website] Standardize the background color from the MUI team photos (#29738) @danilo-leal
69
+ - [website] Add Bharat to the About Us Page (#29714) @bharatkashyap
70
+ - [website] Add about page entry for jan (#29701) @Janpot
71
+ - [website] Adding Prakhar to the about page (#29737) @danilo-leal
72
+
73
+ ### Core
74
+
75
+ - [test] Allow debugging with Chrome and VSCode inspector (#29777) @eps1lon
76
+ - [test] Use renderer clock instead of custom useFakeTimers call (#29778) @eps1lon
77
+ - [test] Only mock Date in regression tests (#29763) @eps1lon
78
+ - [test] Disable nightly integration tests on `next` branch (#29748) @eps1lon
79
+ - [test] Allow configuring clock directly from `createRenderer` (#29684) @eps1lon
80
+ - [test] Accept backslashes as path separators in test CLI (#29694) @michaldudak
81
+ - [utils] Use built-in hook when available for useId (#26489) @eps1lon
82
+
83
+ All contributors of this release in alphabetical order: @abhinav-22-tech, @adamfitzgibbon, @bharatkashyap, @chao813, @DanailH, @danilo-leal, @eps1lon, @gnowland, @Janpot, @longzheng, @michaldudak, @mmacu, @mnajdova, @mwilkins91, @NatiG100, @oliviertassinari, @scallaway, @siriwatknp
84
+
3
85
  ## 5.1.1
4
86
 
5
87
  <!-- generated comparing v5.1.0..master -->
@@ -8,7 +90,7 @@ _Nov 16, 2021_
8
90
 
9
91
  A big thanks to the 15 contributors who made this release possible. Here are some highlights โœจ:
10
92
 
11
- - ๐Ÿ›  Rename `@mui/core` to `@mui/base`. (#29585) @michaldudak
93
+ - ๐Ÿ›  Renamed `@mui/core` to `@mui/base` (#29585) @michaldudak.
12
94
  - And many more ๐Ÿ› bug fixes and ๐Ÿ“š improvements.
13
95
 
14
96
  ### `@mui/material@5.1.1`
@@ -22,10 +104,19 @@ A big thanks to the 15 contributors who made this release possible. Here are som
22
104
 
23
105
  ### `@mui/base@5.0.0-alpha.55`
24
106
 
25
- #### BREAKING CHANGE
107
+ #### Breaking changes
26
108
 
27
109
  - &#8203;<!-- 27 -->[core] Rename mui/core to mui/base (#29585) @michaldudak
28
110
 
111
+ Based on the results of the [poll](https://twitter.com/michaldudak/status/1452630484706635779) and our internal discussions, we decided to rename the `@mui/core` package to `@mui/base`. The main rationale for this is the fact that we use the term "Core" to refer to the core components product family, the one that includes Material Design components, unstyled components, System utilities, etc. Therefore, @mui/core was effectively a subset of MUI Core. This was confusing.
112
+
113
+ The new name better reflects the purpose of the package: it contains unstyled components, hooks, and utilities that serve as a **base** to build on.
114
+
115
+ ```diff
116
+ -importย { useSwitch } from '@mui/core/SwitchUnstyled';
117
+ +importย { useSwitch } from '@mui/base/SwitchUnstyled';
118
+ ```
119
+
29
120
  ### `@mui/lab@5.0.0-alpha.55`
30
121
 
31
122
  - &#8203;<!-- 12 -->[LoadingButton] Text variant spacing fixed for both start and end (#29194) @joshua-lawrence
package/breakpoints.js CHANGED
@@ -118,7 +118,7 @@ function createEmptyBreakpointObject(breakpointsInput = {}) {
118
118
  function removeUnusedBreakpoints(breakpointKeys, style) {
119
119
  return breakpointKeys.reduce((acc, key) => {
120
120
  const breakpointOutput = acc[key];
121
- const isBreakpointUnused = Object.keys(breakpointOutput).length === 0;
121
+ const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
122
122
 
123
123
  if (isBreakpointUnused) {
124
124
  delete acc[key];
package/createBox.js CHANGED
@@ -77,7 +77,7 @@ function createBox(options = {}) {
77
77
  /**
78
78
  * @ignore
79
79
  */
80
- sx: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array])
80
+ sx: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array, _propTypes.default.func])
81
81
  } : void 0;
82
82
  return Box;
83
83
  }
@@ -1,10 +1,10 @@
1
- export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
2
- export declare type SpacingArgument = number | string;
3
- export interface Spacing {
4
- (): string;
5
- (value: number): string;
6
- (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
7
- (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
8
- (top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
9
- }
10
- export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
1
+ export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
2
+ export declare type SpacingArgument = number | string;
3
+ export interface Spacing {
4
+ (): string;
5
+ (value: number): string;
6
+ (topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
7
+ (top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
8
+ (top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
9
+ }
10
+ export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
@@ -121,6 +121,7 @@ function createCssVarsProvider(options) {
121
121
  shouldSkipGeneratingVar
122
122
  });
123
123
  mergedTheme = (0, _extends2.default)({}, mergedTheme, colorSchemes[resolvedColorScheme], {
124
+ colorSchemes,
124
125
  vars: rootVars
125
126
  });
126
127
  const styleSheet = {};
@@ -133,10 +134,7 @@ function createCssVarsProvider(options) {
133
134
  basePrefix: designSystemPrefix,
134
135
  shouldSkipGeneratingVar
135
136
  });
136
-
137
- if (key === resolvedColorScheme) {
138
- mergedTheme.vars = (0, _extends2.default)({}, mergedTheme.vars, vars);
139
- }
137
+ mergedTheme.vars = (0, _utils.deepmerge)(mergedTheme.vars, vars);
140
138
 
141
139
  const resolvedDefaultColorScheme = (() => {
142
140
  if (typeof defaultColorScheme === 'string') {
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -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) => 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) => 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
- defaultMode?: 'light' | 'dark' | 'system';
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;
@@ -23,7 +23,7 @@ exports.DEFAULT_ATTRIBUTE = DEFAULT_ATTRIBUTE;
23
23
 
24
24
  function getInitColorSchemeScript(options) {
25
25
  const {
26
- defaultMode = 'light',
26
+ enableSystem,
27
27
  defaultLightColorScheme = 'light',
28
28
  defaultDarkColorScheme = 'dark',
29
29
  modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
@@ -36,20 +36,20 @@ function getInitColorSchemeScript(options) {
36
36
  __html: `(function() { try {
37
37
  var mode = localStorage.getItem('${modeStorageKey}');
38
38
  var colorScheme = '';
39
- if (mode === 'system' || (!mode && ${defaultMode} === 'system')) {
39
+ if (mode === 'system' || (!mode && !!${enableSystem})) {
40
40
  // handle system mode
41
41
  var mql = window.matchMedia('(prefers-color-scheme: dark)');
42
42
  if (mql.matches) {
43
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || ${defaultLightColorScheme};
43
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
44
44
  } else {
45
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || ${defaultDarkColorScheme};
45
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
46
46
  }
47
47
  }
48
48
  if (mode === 'light') {
49
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || ${defaultLightColorScheme};
49
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
50
50
  }
51
51
  if (mode === 'dark') {
52
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || ${defaultDarkColorScheme};
52
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
53
53
  }
54
54
  if (colorScheme) {
55
55
  document.body.setAttribute('${attribute}', colorScheme);
@@ -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>;
@@ -95,7 +95,7 @@ export function createEmptyBreakpointObject(breakpointsInput = {}) {
95
95
  export function removeUnusedBreakpoints(breakpointKeys, style) {
96
96
  return breakpointKeys.reduce((acc, key) => {
97
97
  const breakpointOutput = acc[key];
98
- const isBreakpointUnused = Object.keys(breakpointOutput).length === 0;
98
+ const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
99
99
 
100
100
  if (isBreakpointUnused) {
101
101
  delete acc[key];
package/esm/createBox.js CHANGED
@@ -54,7 +54,7 @@ export default function createBox(options = {}) {
54
54
  /**
55
55
  * @ignore
56
56
  */
57
- sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
57
+ sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func])
58
58
  } : void 0;
59
59
  return Box;
60
60
  }
@@ -100,6 +100,7 @@ export default function createCssVarsProvider(options) {
100
100
  shouldSkipGeneratingVar
101
101
  });
102
102
  mergedTheme = _extends({}, mergedTheme, colorSchemes[resolvedColorScheme], {
103
+ colorSchemes,
103
104
  vars: rootVars
104
105
  });
105
106
  const styleSheet = {};
@@ -112,10 +113,7 @@ export default function createCssVarsProvider(options) {
112
113
  basePrefix: designSystemPrefix,
113
114
  shouldSkipGeneratingVar
114
115
  });
115
-
116
- if (key === resolvedColorScheme) {
117
- mergedTheme.vars = _extends({}, mergedTheme.vars, vars);
118
- }
116
+ mergedTheme.vars = deepmerge(mergedTheme.vars, vars);
119
117
 
120
118
  const resolvedDefaultColorScheme = (() => {
121
119
  if (typeof defaultColorScheme === 'string') {
@@ -5,7 +5,7 @@ export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
5
  export const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  const {
8
- defaultMode = 'light',
8
+ enableSystem,
9
9
  defaultLightColorScheme = 'light',
10
10
  defaultDarkColorScheme = 'dark',
11
11
  modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
@@ -18,20 +18,20 @@ export default function getInitColorSchemeScript(options) {
18
18
  __html: `(function() { try {
19
19
  var mode = localStorage.getItem('${modeStorageKey}');
20
20
  var colorScheme = '';
21
- if (mode === 'system' || (!mode && ${defaultMode} === 'system')) {
21
+ if (mode === 'system' || (!mode && !!${enableSystem})) {
22
22
  // handle system mode
23
23
  var mql = window.matchMedia('(prefers-color-scheme: dark)');
24
24
  if (mql.matches) {
25
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || ${defaultLightColorScheme};
25
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
26
26
  } else {
27
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || ${defaultDarkColorScheme};
27
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
28
28
  }
29
29
  }
30
30
  if (mode === 'light') {
31
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || ${defaultLightColorScheme};
31
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
32
32
  }
33
33
  if (mode === 'dark') {
34
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || ${defaultDarkColorScheme};
34
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
35
35
  }
36
36
  if (colorScheme) {
37
37
  document.body.setAttribute('${attribute}', colorScheme);
@@ -44,27 +44,29 @@ function styleFunctionSx(props) {
44
44
  Object.keys(sxObject).forEach(styleKey => {
45
45
  const value = callIfFn(sxObject[styleKey], theme);
46
46
 
47
- if (typeof value === 'object') {
48
- if (propToStyleFunction[styleKey]) {
49
- css = merge(css, getThemeValue(styleKey, value, theme));
50
- } else {
51
- const breakpointsValues = handleBreakpoints({
52
- theme
53
- }, value, x => ({
54
- [styleKey]: x
55
- }));
56
-
57
- if (objectsHaveSameKeys(breakpointsValues, value)) {
58
- css[styleKey] = styleFunctionSx({
59
- sx: value,
60
- theme
61
- });
47
+ if (value !== null && value !== undefined) {
48
+ if (typeof value === 'object') {
49
+ if (propToStyleFunction[styleKey]) {
50
+ css = merge(css, getThemeValue(styleKey, value, theme));
62
51
  } else {
63
- css = merge(css, breakpointsValues);
52
+ const breakpointsValues = handleBreakpoints({
53
+ theme
54
+ }, value, x => ({
55
+ [styleKey]: x
56
+ }));
57
+
58
+ if (objectsHaveSameKeys(breakpointsValues, value)) {
59
+ css[styleKey] = styleFunctionSx({
60
+ sx: value,
61
+ theme
62
+ });
63
+ } else {
64
+ css = merge(css, breakpointsValues);
65
+ }
64
66
  }
67
+ } else {
68
+ css = merge(css, getThemeValue(styleKey, value, theme));
65
69
  }
66
- } else {
67
- css = merge(css, getThemeValue(styleKey, value, theme));
68
70
  }
69
71
  });
70
72
  return removeUnusedBreakpoints(breakpointsKeys, css);
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.1.1
1
+ /** @license MUI v5.2.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.
package/index.spec.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -102,7 +102,7 @@ export function createEmptyBreakpointObject() {
102
102
  export function removeUnusedBreakpoints(breakpointKeys, style) {
103
103
  return breakpointKeys.reduce(function (acc, key) {
104
104
  var breakpointOutput = acc[key];
105
- var isBreakpointUnused = Object.keys(breakpointOutput).length === 0;
105
+ var isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
106
106
 
107
107
  if (isBreakpointUnused) {
108
108
  delete acc[key];
@@ -52,7 +52,7 @@ export default function createBox() {
52
52
  /**
53
53
  * @ignore
54
54
  */
55
- sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
55
+ sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func])
56
56
  } : void 0;
57
57
  return Box;
58
58
  }
@@ -105,6 +105,7 @@ export default function createCssVarsProvider(options) {
105
105
  rootVars = _cssVarsParser.vars;
106
106
 
107
107
  mergedTheme = _extends({}, mergedTheme, colorSchemes[resolvedColorScheme], {
108
+ colorSchemes: colorSchemes,
108
109
  vars: rootVars
109
110
  });
110
111
  var styleSheet = {};
@@ -121,9 +122,7 @@ export default function createCssVarsProvider(options) {
121
122
  css = _cssVarsParser2.css,
122
123
  vars = _cssVarsParser2.vars;
123
124
 
124
- if (key === resolvedColorScheme) {
125
- mergedTheme.vars = _extends({}, mergedTheme.vars, vars);
126
- }
125
+ mergedTheme.vars = deepmerge(mergedTheme.vars, vars);
127
126
 
128
127
  var resolvedDefaultColorScheme = function () {
129
128
  if (typeof defaultColorScheme === 'string') {
@@ -5,8 +5,7 @@ export var DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
5
  export var DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  var _ref = options || {},
8
- _ref$defaultMode = _ref.defaultMode,
9
- defaultMode = _ref$defaultMode === void 0 ? 'light' : _ref$defaultMode,
8
+ enableSystem = _ref.enableSystem,
10
9
  _ref$defaultLightColo = _ref.defaultLightColorScheme,
11
10
  defaultLightColorScheme = _ref$defaultLightColo === void 0 ? 'light' : _ref$defaultLightColo,
12
11
  _ref$defaultDarkColor = _ref.defaultDarkColorScheme,
@@ -21,7 +20,7 @@ export default function getInitColorSchemeScript(options) {
21
20
  return /*#__PURE__*/_jsx("script", {
22
21
  // eslint-disable-next-line react/no-danger
23
22
  dangerouslySetInnerHTML: {
24
- __html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var colorScheme = '';\n if (mode === 'system' || (!mode && ").concat(defaultMode, " === 'system')) {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || ").concat(defaultLightColorScheme, ";\n } else {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || ").concat(defaultDarkColorScheme, ";\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || ").concat(defaultLightColorScheme, ";\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || ").concat(defaultDarkColorScheme, ";\n }\n if (colorScheme) {\n document.body.setAttribute('").concat(attribute, "', colorScheme);\n }\n } catch (e) {} })();")
23
+ __html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var colorScheme = '';\n if (mode === 'system' || (!mode && !!").concat(enableSystem, ")) {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n } else {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n }\n if (colorScheme) {\n document.body.setAttribute('").concat(attribute, "', colorScheme);\n }\n } catch (e) {} })();")
25
24
  }
26
25
  });
27
26
  }
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.1.1
1
+ /** @license MUI v5.2.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.
@@ -54,27 +54,29 @@ function styleFunctionSx(props) {
54
54
  Object.keys(sxObject).forEach(function (styleKey) {
55
55
  var value = callIfFn(sxObject[styleKey], theme);
56
56
 
57
- if (_typeof(value) === 'object') {
58
- if (propToStyleFunction[styleKey]) {
59
- css = merge(css, getThemeValue(styleKey, value, theme));
60
- } else {
61
- var breakpointsValues = handleBreakpoints({
62
- theme: theme
63
- }, value, function (x) {
64
- return _defineProperty({}, styleKey, x);
65
- });
66
-
67
- if (objectsHaveSameKeys(breakpointsValues, value)) {
68
- css[styleKey] = styleFunctionSx({
69
- sx: value,
57
+ if (value !== null && value !== undefined) {
58
+ if (_typeof(value) === 'object') {
59
+ if (propToStyleFunction[styleKey]) {
60
+ css = merge(css, getThemeValue(styleKey, value, theme));
61
+ } else {
62
+ var breakpointsValues = handleBreakpoints({
70
63
  theme: theme
64
+ }, value, function (x) {
65
+ return _defineProperty({}, styleKey, x);
71
66
  });
72
- } else {
73
- css = merge(css, breakpointsValues);
67
+
68
+ if (objectsHaveSameKeys(breakpointsValues, value)) {
69
+ css[styleKey] = styleFunctionSx({
70
+ sx: value,
71
+ theme: theme
72
+ });
73
+ } else {
74
+ css = merge(css, breakpointsValues);
75
+ }
74
76
  }
77
+ } else {
78
+ css = merge(css, getThemeValue(styleKey, value, theme));
75
79
  }
76
- } else {
77
- css = merge(css, getThemeValue(styleKey, value, theme));
78
80
  }
79
81
  });
80
82
  return removeUnusedBreakpoints(breakpointsKeys, css);
@@ -93,7 +93,7 @@ export function createEmptyBreakpointObject(breakpointsInput = {}) {
93
93
  export function removeUnusedBreakpoints(breakpointKeys, style) {
94
94
  return breakpointKeys.reduce((acc, key) => {
95
95
  const breakpointOutput = acc[key];
96
- const isBreakpointUnused = Object.keys(breakpointOutput).length === 0;
96
+ const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
97
97
 
98
98
  if (isBreakpointUnused) {
99
99
  delete acc[key];
@@ -54,7 +54,7 @@ export default function createBox(options = {}) {
54
54
  /**
55
55
  * @ignore
56
56
  */
57
- sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array])
57
+ sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func])
58
58
  } : void 0;
59
59
  return Box;
60
60
  }
@@ -100,6 +100,7 @@ export default function createCssVarsProvider(options) {
100
100
  shouldSkipGeneratingVar
101
101
  });
102
102
  mergedTheme = _extends({}, mergedTheme, colorSchemes[resolvedColorScheme], {
103
+ colorSchemes,
103
104
  vars: rootVars
104
105
  });
105
106
  const styleSheet = {};
@@ -112,10 +113,7 @@ export default function createCssVarsProvider(options) {
112
113
  basePrefix: designSystemPrefix,
113
114
  shouldSkipGeneratingVar
114
115
  });
115
-
116
- if (key === resolvedColorScheme) {
117
- mergedTheme.vars = _extends({}, mergedTheme.vars, vars);
118
- }
116
+ mergedTheme.vars = deepmerge(mergedTheme.vars, vars);
119
117
 
120
118
  const resolvedDefaultColorScheme = (() => {
121
119
  if (typeof defaultColorScheme === 'string') {
@@ -5,7 +5,7 @@ export const DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'mui-color-scheme';
5
5
  export const DEFAULT_ATTRIBUTE = 'data-mui-color-scheme';
6
6
  export default function getInitColorSchemeScript(options) {
7
7
  const {
8
- defaultMode = 'light',
8
+ enableSystem,
9
9
  defaultLightColorScheme = 'light',
10
10
  defaultDarkColorScheme = 'dark',
11
11
  modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
@@ -18,20 +18,20 @@ export default function getInitColorSchemeScript(options) {
18
18
  __html: `(function() { try {
19
19
  var mode = localStorage.getItem('${modeStorageKey}');
20
20
  var colorScheme = '';
21
- if (mode === 'system' || (!mode && ${defaultMode} === 'system')) {
21
+ if (mode === 'system' || (!mode && !!${enableSystem})) {
22
22
  // handle system mode
23
23
  var mql = window.matchMedia('(prefers-color-scheme: dark)');
24
24
  if (mql.matches) {
25
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || ${defaultLightColorScheme};
25
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
26
26
  } else {
27
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || ${defaultDarkColorScheme};
27
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
28
28
  }
29
29
  }
30
30
  if (mode === 'light') {
31
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || ${defaultLightColorScheme};
31
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-light') || '${defaultLightColorScheme}';
32
32
  }
33
33
  if (mode === 'dark') {
34
- colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || ${defaultDarkColorScheme};
34
+ colorScheme = localStorage.getItem('${colorSchemeStorageKey}-dark') || '${defaultDarkColorScheme}';
35
35
  }
36
36
  if (colorScheme) {
37
37
  document.body.setAttribute('${attribute}', colorScheme);
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.1.1
1
+ /** @license MUI v5.2.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.
@@ -44,27 +44,29 @@ function styleFunctionSx(props) {
44
44
  Object.keys(sxObject).forEach(styleKey => {
45
45
  const value = callIfFn(sxObject[styleKey], theme);
46
46
 
47
- if (typeof value === 'object') {
48
- if (propToStyleFunction[styleKey]) {
49
- css = merge(css, getThemeValue(styleKey, value, theme));
50
- } else {
51
- const breakpointsValues = handleBreakpoints({
52
- theme
53
- }, value, x => ({
54
- [styleKey]: x
55
- }));
56
-
57
- if (objectsHaveSameKeys(breakpointsValues, value)) {
58
- css[styleKey] = styleFunctionSx({
59
- sx: value,
60
- theme
61
- });
47
+ if (value !== null && value !== undefined) {
48
+ if (typeof value === 'object') {
49
+ if (propToStyleFunction[styleKey]) {
50
+ css = merge(css, getThemeValue(styleKey, value, theme));
62
51
  } else {
63
- css = merge(css, breakpointsValues);
52
+ const breakpointsValues = handleBreakpoints({
53
+ theme
54
+ }, value, x => ({
55
+ [styleKey]: x
56
+ }));
57
+
58
+ if (objectsHaveSameKeys(breakpointsValues, value)) {
59
+ css[styleKey] = styleFunctionSx({
60
+ sx: value,
61
+ theme
62
+ });
63
+ } else {
64
+ css = merge(css, breakpointsValues);
65
+ }
64
66
  }
67
+ } else {
68
+ css = merge(css, getThemeValue(styleKey, value, theme));
65
69
  }
66
- } else {
67
- css = merge(css, getThemeValue(styleKey, value, theme));
68
70
  }
69
71
  });
70
72
  return removeUnusedBreakpoints(breakpointsKeys, css);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -44,12 +44,12 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.16.3",
47
- "@mui/private-theming": "^5.1.1",
48
- "@mui/styled-engine": "^5.1.1",
47
+ "@mui/private-theming": "^5.2.0",
48
+ "@mui/styled-engine": "^5.2.0",
49
49
  "@mui/types": "^7.1.0",
50
- "@mui/utils": "^5.1.1",
50
+ "@mui/utils": "^5.2.0",
51
51
  "clsx": "^1.1.1",
52
- "csstype": "^3.0.9",
52
+ "csstype": "^3.0.10",
53
53
  "prop-types": "^15.7.2"
54
54
  },
55
55
  "sideEffects": false,
@@ -59,27 +59,29 @@ function styleFunctionSx(props) {
59
59
  Object.keys(sxObject).forEach(styleKey => {
60
60
  const value = callIfFn(sxObject[styleKey], theme);
61
61
 
62
- if (typeof value === 'object') {
63
- if (_getThemeValue.propToStyleFunction[styleKey]) {
64
- css = (0, _merge.default)(css, (0, _getThemeValue.default)(styleKey, value, theme));
65
- } else {
66
- const breakpointsValues = (0, _breakpoints.handleBreakpoints)({
67
- theme
68
- }, value, x => ({
69
- [styleKey]: x
70
- }));
71
-
72
- if (objectsHaveSameKeys(breakpointsValues, value)) {
73
- css[styleKey] = styleFunctionSx({
74
- sx: value,
75
- theme
76
- });
62
+ if (value !== null && value !== undefined) {
63
+ if (typeof value === 'object') {
64
+ if (_getThemeValue.propToStyleFunction[styleKey]) {
65
+ css = (0, _merge.default)(css, (0, _getThemeValue.default)(styleKey, value, theme));
77
66
  } else {
78
- css = (0, _merge.default)(css, breakpointsValues);
67
+ const breakpointsValues = (0, _breakpoints.handleBreakpoints)({
68
+ theme
69
+ }, value, x => ({
70
+ [styleKey]: x
71
+ }));
72
+
73
+ if (objectsHaveSameKeys(breakpointsValues, value)) {
74
+ css[styleKey] = styleFunctionSx({
75
+ sx: value,
76
+ theme
77
+ });
78
+ } else {
79
+ css = (0, _merge.default)(css, breakpointsValues);
80
+ }
79
81
  }
82
+ } else {
83
+ css = (0, _merge.default)(css, (0, _getThemeValue.default)(styleKey, value, theme));
80
84
  }
81
- } else {
82
- css = (0, _merge.default)(css, (0, _getThemeValue.default)(styleKey, value, theme));
83
85
  }
84
86
  });
85
87
  return (0, _breakpoints.removeUnusedBreakpoints)(breakpointsKeys, css);
@@ -1 +1 @@
1
- export {};
1
+ export {};