@mui/system 5.5.1 → 5.6.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,220 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## 5.6.0
4
+
5
+ <!-- generated comparing v5.5.3..master -->
6
+
7
+ _Apr 5, 2022_
8
+
9
+ A big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - 🧰 Update peer dependencies to support React 18 (#32063) @eps1lon
12
+ - 🚀 Added the experimental `CssVarsProvider` in `@mui/material` for generating theme CSS variables (#31138) @mnajdova
13
+ - 📣 Moved date and time pickers from the lab to MUI X (#31984) @flaviendelangle
14
+ - Several 🐛 bug fixes and 📚 documentation improvements
15
+
16
+ ### `@mui/material@5.6.0`
17
+
18
+ - &#8203;<!-- 25 -->[CssVarsProvider] Add experimental CssVarsProvider in @mui/material (#31138) @mnajdova
19
+ - &#8203;<!-- 06 -->[Link] Fix `sx` color to support callback (#32123) @siriwatknp
20
+ - &#8203;<!-- 05 -->[Link] Fix color transformation (#32045) @siriwatknp
21
+ - &#8203;<!-- 04 -->[ListItemButton] Specified width so that text would ellide (#32083) @MatthijsMud
22
+ - &#8203;<!-- 03 -->[TablePagination] Fixed the etEE locale (#32052) @raigoinabox
23
+
24
+ ### `@mui/base@5.0.0-alpha.75`
25
+
26
+ - &#8203;<!-- 31 -->[Badge] Simplify unstyled API (#31974) @michaldudak
27
+
28
+ ### `@mui/codemod@5.6.0`
29
+
30
+ - &#8203;<!-- 29 -->[codemod] Add v5.0.0/date-pickers-moved-to-x codemod (#31373) @flaviendelangle
31
+
32
+ ### `@mui/lab@5.0.0-alpha.76`
33
+
34
+ - &#8203;<!-- 24 -->[DatePicker] Remove date and time pickers from the lab (#31984) @flaviendelangle
35
+
36
+ ### `@mui/joy@5.0.0-alpha.22`
37
+
38
+ - &#8203;<!-- 07 -->[Joy] Add `Card` components (#32027) @siriwatknp
39
+
40
+ ### Docs
41
+
42
+ - &#8203;<!-- 30 -->[blog] New article for the date pickers migration to X (#31831) @flaviendelangle
43
+ - &#8203;<!-- 33 -->[docs] Base Menu style revisions and final review (#32097) @samuelsycamore
44
+ - &#8203;<!-- 32 -->[docs] Base Select style revisions and final review (#32095) @samuelsycamore
45
+ - &#8203;<!-- 31 -->[docs] Base Input style revisions and final review (#32096) @samuelsycamore
46
+ - &#8203;<!-- 30 -->[docs] Base Slider style revisions and final review (#32140) @samuelsycamore
47
+ - &#8203;<!-- 29 -->[docs] Base Modal style revisions and final review (#32093) @samuelsycamore
48
+ - &#8203;<!-- 28 -->[docs] Add page for CSS variables support in @mui/material (#32050) @mnajdova
49
+ - &#8203;<!-- 27 -->[docs] Add TSS support for theme style overrides (#31918) @garronej
50
+ - &#8203;<!-- 23 -->[docs] Simplify customization examples in ButtonUnstyled demos (#32092) @michaldudak
51
+ - &#8203;<!-- 22 -->[docs] Fix linking issues for the redirects (#32101) @siriwatknp
52
+ - &#8203;<!-- 21 -->[docs] Create the FormControl page (#32073) @michaldudak
53
+ - &#8203;<!-- 20 -->[docs] Remove trap-focus from the navigation (#32079) @psjishnu
54
+ - &#8203;<!-- 19 -->[docs] Add date-pickers product identifier (#32076) @siriwatknp
55
+ - &#8203;<!-- 18 -->[docs] Move SwitchUnstyled docs to the Base space (#31964) @michaldudak
56
+ - &#8203;<!-- 17 -->[docs] Add docs page for unstyled popper (#31813) @siriwatknp
57
+ - &#8203;<!-- 16 -->[docs] Copy TextareaAutosize docs to Base (#32034) @michaldudak
58
+ - &#8203;<!-- 15 -->[docs] Add react-hook-form-mui to Complementary projects #32015 @TkaczykAdam
59
+ - &#8203;<!-- 14 -->[docs] Improve the translation experience (#32021) @oliviertassinari
60
+ - &#8203;<!-- 13 -->[docs] Add small size Select demo (#32060) @ivan-ngchakming
61
+ - &#8203;<!-- 12 -->[docs] Correct typos (#32029) @apeltop
62
+ - &#8203;<!-- 11 -->[docs] Create SliderUnstyled docs (#31850) @michaldudak
63
+ - &#8203;<!-- 10 -->[docs] Create TablePaginationUnstyled docs (#32018) @michaldudak
64
+ - &#8203;<!-- 09 -->[docs] Move SelectUnstyled docs to the Base space (#31816) @michaldudak
65
+ - &#8203;<!-- 08 -->[docs] Create the TabsUnstyled docs (#32023) @michaldudak
66
+ - &#8203;<!-- 02 -->[website] The studio finally has a name, use it (#32105) @oliviertassinari
67
+ - &#8203;<!-- 01 -->[website] Disable job ad @oliviertassinari
68
+
69
+ ### Core
70
+
71
+ - &#8203;<!-- 28 -->[core] Update peer deps to support React 18 (#32063) @eps1lon
72
+ - &#8203;<!-- 27 -->[core] Fix running docs:api on Windows (#32091) @michaldudak
73
+ - &#8203;<!-- 26 -->[core] Fix api build script for MUI Base (#32081) @siriwatknp
74
+
75
+ All contributors of this release in alphabetical order: @apeltop, @eps1lon, @flaviendelangle, @garronej, @ivan-ngchakming, @m4theushw, @MatthijsMud, @michaldudak, @mnajdova, @oliviertassinari, @psjishnu, @raigoinabox, @samuelsycamore, @siriwatknp, @TkaczykAdam
76
+
77
+ ## 5.5.3
78
+
79
+ <!-- generated comparing v5.5.2..master -->
80
+
81
+ _Mar 28, 2022_
82
+
83
+ A big thanks to the 17 contributors who made this release possible. Here are some highlights ✨:
84
+
85
+ - ♿️ improved the a11y on some docs demos
86
+ - Several 🐛 bug fixes and 📚 documentation improvements
87
+
88
+ ### `@mui/material@5.5.3`
89
+
90
+ - &#8203;<!-- 32 -->[ButtonBase] Start ripple only after mount (#31950) @m4theushw
91
+ - &#8203;<!-- 11 -->[FormControlLabel] Fix label prop type to be in-line with other label prop types (#31139) @jannes-io
92
+ - &#8203;<!-- 10 -->[Grow] Add a workaround for Safari 15.4 CSS transition bug (#31975) @igordanchenko
93
+
94
+ ### `@mui/codemod@5.5.3`
95
+
96
+ - &#8203;<!-- 31 -->[codemod] Fix variant prop placement (#31990) @ryancogswell
97
+
98
+ ### `@mui/utils@5.5.3`
99
+
100
+ - &#8203;<!-- 02 -->[utils] Improve type inference of useForkRef (#31845) @eps1lon
101
+
102
+ ### `@mui/base@5.0.0-alpha.74`
103
+
104
+ #### Breaking changes
105
+
106
+ - &#8203;<!-- 34 -->[base] Remove `BackdropUnstyled` component (#31923) @mnajdova
107
+
108
+ The `BackdropUnstyled` component was removed from the `@mui/base` package, as it did not have any specific logic, except adding an `aria-hidden` attribute on the div it rendered. This is not enough to justify it's existence in the base package. Here is an example alternative component you can use:
109
+
110
+ ```tsx
111
+ const BackdropUnstyled = React.forwardRef<HTMLDivElement, { open?: boolean; className: string }>(
112
+ (props, ref) => {
113
+ const { open, className, ...other } = props;
114
+ return <div className={clsx({ 'MuiBackdrop-open': open }, className)} ref={ref} {...other} />;
115
+ },
116
+ );
117
+ ```
118
+
119
+ - &#8203;<!-- 03 -->[TrapFocus] Move docs to Base and drop the Unstyled prefix (#31954) @michaldudak
120
+
121
+ Removed the `Unstyled_` prefix from the Base export (it remains in the Material UI export, though).
122
+
123
+ ```diff
124
+ -import { Unstyled_TrapFocus } from '@mui/base';
125
+ +import { TrapFocus } from '@mui/base';
126
+
127
+ // or
128
+
129
+ -import TrapFocus from '@mui/base/Unstyled_TrapFocus';
130
+ +import TrapFocus from '@mui/base/TrapFocus';
131
+ ```
132
+
133
+ #### Changes
134
+
135
+ - &#8203;<!-- 33 -->[base] Add @mui/types to dependencies (#31951) @bicstone
136
+
137
+ ### `@mui/joy@5.0.0-alpha.21`
138
+
139
+ - &#8203;<!-- 09 -->[Joy] Add `AvatarGroup` component (#31980) @siriwatknp
140
+ - &#8203;<!-- 07 -->[Joy] Miscellaneous fixes (#31873) @siriwatknp
141
+ - &#8203;<!-- 08 -->[Joy] Miscellaneous fixes 2 (#31971) @siriwatknp
142
+
143
+ ### Docs
144
+
145
+ - &#8203;<!-- 27 -->[docs] Improve the a11y on the hover rating demo (#31970) @mnajdova
146
+ - &#8203;<!-- 26 -->[docs] Improve a11y on the `SplitButton` demo (#31969) @mnajdova
147
+ - &#8203;<!-- 25 -->[docs] Improve the color description in the API pages (#30976) @mnajdova
148
+ - &#8203;<!-- 24 -->[docs] Add docs page for unstyled Modal (#31417) @mnajdova
149
+ - &#8203;<!-- 23 -->[docs] Add InputUnstyled docs (#31881) @mnajdova
150
+ - &#8203;<!-- 22 -->[docs] Remove "Work in biotech" from the showcase (#31942) @oliviertassinari
151
+ - &#8203;<!-- 21 -->[docs] Fix in-house ad for the design kits (#31965) @oliviertassinari
152
+ - &#8203;<!-- 20 -->[docs] Fix the documentation for filterOptions in Autocomplete API page (#31416) @santhoshbala0178
153
+ - &#8203;<!-- 19 -->[docs] Update href for 'TypeScript guide on theme customization' (#31880) @NickFoden
154
+ - &#8203;<!-- 18 -->[docs] Fix the CSS modules example in the Interoperability page (#31935) @WilsonNet
155
+ - &#8203;<!-- 17 -->[docs] Fix small typo in the `styled()` utility page (#31967) @jason1985
156
+ - &#8203;<!-- 16 -->[docs] Update mui-x on material-ui navigation (#31810) @siriwatknp
157
+ - &#8203;<!-- 15 -->[docs] Copy ClickAwayListener docs to Base (#31878) @michaldudak
158
+ - &#8203;<!-- 14 -->[docs] Refine the redirects (#31939) @siriwatknp
159
+ - &#8203;<!-- 13 -->[docs] Fix TOC layout for large screen (#31953) @siriwatknp
160
+ - &#8203;<!-- 12 -->[examples] Update remix example to not use NODE_ENV guard for `LiveReload` (#31269) @eswarclynn
161
+ - &#8203;<!-- 06 -->[NoSsr] Copy docs to the Base space (#31956) @michaldudak
162
+ - &#8203;<!-- 05 -->[Portal] Copy Portal docs to the Base space (#31959) @michaldudak
163
+ - &#8203;<!-- 01 -->[website] Remove X-Frame-Options @oliviertassinari
164
+ - &#8203;<!-- 35 -->Revert "[website] Remove X-Frame-Options" @oliviertassinari
165
+
166
+ ### Core
167
+
168
+ - &#8203;<!-- 30 -->[core] Fixes error in changelog generator for item sorting/padding (#30088) @dimitropoulos
169
+ - &#8203;<!-- 29 -->[core] Fix typo in issue template @oliviertassinari
170
+ - &#8203;<!-- 28 -->[core] Replace deprecated String.prototype.substr() (#31806) @CommanderRoot
171
+ - &#8203;<!-- 04 -->[test] Add tests for component using `StandardProps` and polymorphic components (#31945) @mnajdova
172
+
173
+ All contributors of this release in alphabetical order: @bicstone, @CommanderRoot, @dimitropoulos, @eps1lon, @eswarclynn, @igordanchenko, @jannes-io, @jason1985, @m4theushw, @michaldudak, @mnajdova, @NickFoden, @oliviertassinari, @ryancogswell, @santhoshbala0178, @siriwatknp, @WilsonNet
174
+
175
+ ## 5.5.2
176
+
177
+ <!-- generated comparing v5.5.1..master -->
178
+
179
+ _Mar 21, 2022_
180
+
181
+ A big thanks to the 7 contributors who made this release possible. This is a small release focused on some 🐛 bug fixes and 📚 documentation improvements.
182
+
183
+ ### `@mui/material@5.5.2`
184
+
185
+ - &#8203;<!-- 04 -->[Popper] Expose the `sx` prop (#31833) @ivan-ngchakming
186
+
187
+ ### `@mui/joy@5.0.0-alpha.20`
188
+
189
+ - &#8203;<!-- 06 -->[Joy] Add default color to `Input` and `ListItemButton` (#31826) @siriwatknp
190
+ - &#8203;<!-- 05 -->[Joy] Add Avatar component (#31303) @hbjORbj
191
+
192
+ ### `@mui/base@5.0.0-alpha.73`
193
+
194
+ - &#8203;<!-- 03 -->[SliderUnstyled] Fix dragging on disabled sliders (#31882) @mnajdova
195
+
196
+ ### `@mui/styled-engine-sc@5.5.2`
197
+
198
+ - &#8203;<!-- 02 -->[styled-engine-sc] GlobalStylesProps inconsistent between the different packages (#31814) @mnajdova
199
+
200
+ ### Docs
201
+
202
+ - &#8203;<!-- 15 -->[data-grid] Fix print export feature (#31807) @oliviertassinari
203
+ - &#8203;<!-- 14 -->[docs] Move BadgeUnstyled docs to Base space (#31872) @michaldudak
204
+ - &#8203;<!-- 13 -->[docs] Solve duplication of content (#31917) @oliviertassinari
205
+ - &#8203;<!-- 12 -->[docs] Fix side nav capitalization of API (#31916) @oliviertassinari
206
+ - &#8203;<!-- 11 -->[docs] Use TypeScript demos by default (#31808) @oliviertassinari
207
+ - &#8203;<!-- 10 -->[docs] New search experience for multiple products (#31811) @siriwatknp
208
+ - &#8203;<!-- 09 -->[docs] Make LTS searchable (#31804) @oliviertassinari
209
+ - &#8203;<!-- 08 -->[docs] Fix demo filename on zh markdown (#31790) @nnmax
210
+ - &#8203;<!-- 01 -->[website] Highlight the date picker (#31889) @oliviertassinari
211
+
212
+ ### Core
213
+
214
+ - &#8203;<!-- 07 -->[core] Add tests for Avatar component (#31829) @hbjORbj
215
+
216
+ All contributors of this release in alphabetical order: @hbjORbj, @ivan-ngchakming, @michaldudak, @mnajdova, @nnmax, @oliviertassinari, @siriwatknp
217
+
3
218
  ## 5.5.1
4
219
 
5
220
  <!-- generated comparing v5.5.0..master -->
@@ -9,6 +9,7 @@ export function hexToRgb(hex: string): string;
9
9
  export function rgbToHex(color: string): string;
10
10
  export function hslToRgb(color: string): string;
11
11
  export function decomposeColor(color: string): ColorObject;
12
+ export function colorChannel(color: string): string;
12
13
  export function recomposeColor(color: ColorObject): string;
13
14
  export function getContrastRatio(foreground: string, background: string): number;
14
15
  export function getLuminance(color: string): number;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.alpha = alpha;
7
+ exports.colorChannel = void 0;
7
8
  exports.darken = darken;
8
9
  exports.decomposeColor = decomposeColor;
9
10
  exports.emphasize = emphasize;
@@ -41,7 +42,7 @@ function clamp(value, min = 0, max = 1) {
41
42
 
42
43
 
43
44
  function hexToRgb(color) {
44
- color = color.substr(1);
45
+ color = color.slice(1);
45
46
  const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
46
47
  let colors = color.match(re);
47
48
 
@@ -93,7 +94,7 @@ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
93
94
  colorSpace = values.shift();
94
95
 
95
96
  if (values.length === 4 && values[3].charAt(0) === '/') {
96
- values[3] = values[3].substr(1);
97
+ values[3] = values[3].slice(1);
97
98
  }
98
99
 
99
100
  if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
@@ -111,6 +112,18 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
111
112
  colorSpace
112
113
  };
113
114
  }
115
+ /**
116
+ * Returns a channel created from the input color.
117
+ *
118
+ * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
119
+ * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
120
+ */
121
+
122
+
123
+ const colorChannel = color => {
124
+ const decomposedColor = decomposeColor(color);
125
+ return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
126
+ };
114
127
  /**
115
128
  * Converts a color object with type and values to a string.
116
129
  * @param {object} color - Decomposed color
@@ -120,6 +133,8 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
120
133
  */
121
134
 
122
135
 
136
+ exports.colorChannel = colorChannel;
137
+
123
138
  function recomposeColor(color) {
124
139
  const {
125
140
  type,
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -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;
@@ -36,6 +36,28 @@ export interface CssVarsProviderConfig<ColorScheme extends string> {
36
36
  prefix?: string;
37
37
  }
38
38
 
39
+ export interface CreateCssVarsProviderResult<ColorScheme extends string, ThemeInput> {
40
+ CssVarsProvider: (
41
+ props: React.PropsWithChildren<
42
+ Partial<CssVarsProviderConfig<ColorScheme>> & {
43
+ theme?: ThemeInput;
44
+ /**
45
+ * localStorage key used to store application `mode`
46
+ * @default 'mui-mode'
47
+ */
48
+ modeStorageKey?: string;
49
+ /**
50
+ * DOM attribute for applying color scheme
51
+ * @default 'data-mui-color-scheme'
52
+ */
53
+ attribute?: string;
54
+ }
55
+ >,
56
+ ) => React.ReactElement;
57
+ useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
58
+ getInitColorSchemeScript: typeof getInitColorSchemeScript;
59
+ }
60
+
39
61
  export default function createCssVarsProvider<
40
62
  ColorScheme extends string,
41
63
  ThemeInput extends { colorSchemes?: Partial<Record<ColorScheme, any>> },
@@ -83,27 +105,7 @@ export default function createCssVarsProvider<
83
105
  */
84
106
  resolveTheme?: (theme: any) => any; // the type is any because it depends on the design system.
85
107
  },
86
- ): {
87
- CssVarsProvider: (
88
- props: React.PropsWithChildren<
89
- Partial<CssVarsProviderConfig<ColorScheme>> & {
90
- theme?: ThemeInput;
91
- /**
92
- * localStorage key used to store application `mode`
93
- * @default 'mui-mode'
94
- */
95
- modeStorageKey?: string;
96
- /**
97
- * DOM attribute for applying color scheme
98
- * @default 'data-mui-color-scheme'
99
- */
100
- attribute?: string;
101
- }
102
- >,
103
- ) => React.ReactElement;
104
- useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
105
- getInitColorSchemeScript: typeof getInitColorSchemeScript;
106
- };
108
+ ): CreateCssVarsProviderResult<ColorScheme, ThemeInput>;
107
109
 
108
110
  // disable automatic export
109
111
  export {};
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,5 +1,5 @@
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<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...vars: (T | AdditionalVars)[]) => string;
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<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...vars: (T | AdditionalVars)[]) => string;
@@ -1,70 +1,70 @@
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
- * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
47
- *
48
- * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
49
- *
50
- * @example
51
- * const { css, vars, parsedTheme } = parser({
52
- * fontSize: 12,
53
- * lineHeight: 1.2,
54
- * palette: { primary: { 500: 'var(--color)' } }
55
- * }, { prefix: 'foo' })
56
- *
57
- * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
- * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
- * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
60
- */
61
- export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
- prefix?: string;
63
- basePrefix?: string;
64
- shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
- }): {
66
- css: NestedRecord<string>;
67
- vars: NestedRecord<string>;
68
- parsedTheme: T;
69
- };
70
- 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
+ * the CSS variable value will be adjusted based on the provided `basePrefix` & `prefix` which can be found in `parsedTheme`.
47
+ *
48
+ * @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
49
+ *
50
+ * @example
51
+ * const { css, vars, parsedTheme } = parser({
52
+ * fontSize: 12,
53
+ * lineHeight: 1.2,
54
+ * palette: { primary: { 500: 'var(--color)' } }
55
+ * }, { prefix: 'foo' })
56
+ *
57
+ * console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--foo-color)' }
58
+ * console.log(vars) // { fontSize: '--foo-fontSize', lineHeight: '--foo-lineHeight', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
59
+ * console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--foo-color)' } } }
60
+ */
61
+ export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
62
+ prefix?: string;
63
+ basePrefix?: string;
64
+ shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
65
+ }): {
66
+ css: NestedRecord<string>;
67
+ vars: NestedRecord<string>;
68
+ parsedTheme: T;
69
+ };
70
+ export {};
@@ -82,6 +82,13 @@ const getCssValue = (keys, value) => {
82
82
  return value;
83
83
  }
84
84
 
85
+ const lastKey = keys[keys.length - 1];
86
+
87
+ if (lastKey.toLowerCase().indexOf('opacity') >= 0) {
88
+ // opacity values are unitless
89
+ return value;
90
+ }
91
+
85
92
  return `${value}px`;
86
93
  }
87
94
 
@@ -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 +1,2 @@
1
- export { default } from './createCssVarsProvider';
1
+ export { default } from './createCssVarsProvider';
2
+ export type { CreateCssVarsProviderResult } 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>;
@@ -24,7 +24,7 @@ function clamp(value, min = 0, max = 1) {
24
24
 
25
25
 
26
26
  export function hexToRgb(color) {
27
- color = color.substr(1);
27
+ color = color.slice(1);
28
28
  const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
29
29
  let colors = color.match(re);
30
30
 
@@ -76,7 +76,7 @@ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
76
76
  colorSpace = values.shift();
77
77
 
78
78
  if (values.length === 4 && values[3].charAt(0) === '/') {
79
- values[3] = values[3].substr(1);
79
+ values[3] = values[3].slice(1);
80
80
  }
81
81
 
82
82
  if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
@@ -94,6 +94,17 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
94
94
  colorSpace
95
95
  };
96
96
  }
97
+ /**
98
+ * Returns a channel created from the input color.
99
+ *
100
+ * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
101
+ * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
102
+ */
103
+
104
+ export const colorChannel = color => {
105
+ const decomposedColor = decomposeColor(color);
106
+ return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
107
+ };
97
108
  /**
98
109
  * Converts a color object with type and values to a string.
99
110
  * @param {object} color - Decomposed color
@@ -68,6 +68,13 @@ const getCssValue = (keys, value) => {
68
68
  return value;
69
69
  }
70
70
 
71
+ const lastKey = keys[keys.length - 1];
72
+
73
+ if (lastKey.toLowerCase().indexOf('opacity') >= 0) {
74
+ // opacity values are unitless
75
+ return value;
76
+ }
77
+
71
78
  return `${value}px`;
72
79
  }
73
80
 
package/index.d.ts CHANGED
@@ -162,6 +162,6 @@ export * from './colorManipulator';
162
162
  export { default as ThemeProvider } from './ThemeProvider';
163
163
  export * from './ThemeProvider';
164
164
 
165
- export { default as unstable_createCssVarsProvider } from './cssVars';
165
+ export { default as unstable_createCssVarsProvider, CreateCssVarsProviderResult } from './cssVars';
166
166
  export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
167
167
  export * from './cssVars';
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.5.1
1
+ /** @license MUI v5.6.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 {};
@@ -27,7 +27,7 @@ function clamp(value) {
27
27
 
28
28
 
29
29
  export function hexToRgb(color) {
30
- color = color.substr(1);
30
+ color = color.slice(1);
31
31
  var re = new RegExp(".{1,".concat(color.length >= 6 ? 2 : 1, "}"), 'g');
32
32
  var colors = color.match(re);
33
33
 
@@ -80,7 +80,7 @@ export function decomposeColor(color) {
80
80
  colorSpace = values.shift();
81
81
 
82
82
  if (values.length === 4 && values[3].charAt(0) === '/') {
83
- values[3] = values[3].substr(1);
83
+ values[3] = values[3].slice(1);
84
84
  }
85
85
 
86
86
  if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
@@ -99,6 +99,19 @@ export function decomposeColor(color) {
99
99
  colorSpace: colorSpace
100
100
  };
101
101
  }
102
+ /**
103
+ * Returns a channel created from the input color.
104
+ *
105
+ * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
106
+ * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
107
+ */
108
+
109
+ export var colorChannel = function colorChannel(color) {
110
+ var decomposedColor = decomposeColor(color);
111
+ return decomposedColor.values.slice(0, 3).map(function (val, idx) {
112
+ return decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? "".concat(val, "%") : val;
113
+ }).join(' ');
114
+ };
102
115
  /**
103
116
  * Converts a color object with type and values to a string.
104
117
  * @param {object} color - Decomposed color
@@ -81,6 +81,13 @@ var getCssValue = function getCssValue(keys, value) {
81
81
  return value;
82
82
  }
83
83
 
84
+ var lastKey = keys[keys.length - 1];
85
+
86
+ if (lastKey.toLowerCase().indexOf('opacity') >= 0) {
87
+ // opacity values are unitless
88
+ return value;
89
+ }
90
+
84
91
  return "".concat(value, "px");
85
92
  }
86
93
 
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.5.1
1
+ /** @license MUI v5.6.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.
@@ -24,7 +24,7 @@ function clamp(value, min = 0, max = 1) {
24
24
 
25
25
 
26
26
  export function hexToRgb(color) {
27
- color = color.substr(1);
27
+ color = color.slice(1);
28
28
  const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
29
29
  let colors = color.match(re);
30
30
 
@@ -76,7 +76,7 @@ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
76
76
  colorSpace = values.shift();
77
77
 
78
78
  if (values.length === 4 && values[3].charAt(0) === '/') {
79
- values[3] = values[3].substr(1);
79
+ values[3] = values[3].slice(1);
80
80
  }
81
81
 
82
82
  if (['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].indexOf(colorSpace) === -1) {
@@ -94,6 +94,17 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
94
94
  colorSpace
95
95
  };
96
96
  }
97
+ /**
98
+ * Returns a channel created from the input color.
99
+ *
100
+ * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
101
+ * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
102
+ */
103
+
104
+ export const colorChannel = color => {
105
+ const decomposedColor = decomposeColor(color);
106
+ return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
107
+ };
97
108
  /**
98
109
  * Converts a color object with type and values to a string.
99
110
  * @param {object} color - Decomposed color
@@ -68,6 +68,13 @@ const getCssValue = (keys, value) => {
68
68
  return value;
69
69
  }
70
70
 
71
+ const lastKey = keys[keys.length - 1];
72
+
73
+ if (lastKey.toLowerCase().indexOf('opacity') >= 0) {
74
+ // opacity values are unitless
75
+ return value;
76
+ }
77
+
71
78
  return `${value}px`;
72
79
  }
73
80
 
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.5.1
1
+ /** @license MUI v5.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "5.5.1",
3
+ "version": "5.6.0",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "CSS utilities for rapidly laying out custom designs.",
@@ -28,8 +28,8 @@
28
28
  "peerDependencies": {
29
29
  "@emotion/react": "^11.5.0",
30
30
  "@emotion/styled": "^11.3.0",
31
- "@types/react": "^16.8.6 || ^17.0.0",
32
- "react": "^17.0.0"
31
+ "@types/react": "^16.8.6 || ^17.0.0 || ^18.0.0",
32
+ "react": "^17.0.0 || ^18.0.0"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@types/react": {
@@ -44,10 +44,10 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.17.2",
47
- "@mui/private-theming": "^5.4.4",
48
- "@mui/styled-engine": "^5.4.4",
47
+ "@mui/private-theming": "^5.6.0",
48
+ "@mui/styled-engine": "^5.6.0",
49
49
  "@mui/types": "^7.1.3",
50
- "@mui/utils": "^5.4.4",
50
+ "@mui/utils": "^5.6.0",
51
51
  "clsx": "^1.1.1",
52
52
  "csstype": "^3.0.11",
53
53
  "prop-types": "^15.7.2"
@@ -1 +1 @@
1
- export {};
1
+ export {};