@mui/system 5.10.15 → 5.10.17
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/CHANGELOG.md +121 -1
- package/Container/ContainerProps.d.ts +1 -1
- package/Container/containerClasses.d.ts +1 -1
- package/Container/createContainer.d.ts +1 -1
- package/Stack/StackProps.d.ts +1 -1
- package/Stack/stackClasses.d.ts +1 -1
- package/Unstable_Grid/GridProps.d.ts +8 -8
- package/Unstable_Grid/gridClasses.d.ts +1 -1
- package/colorManipulator.d.ts +10 -0
- package/colorManipulator.js +57 -1
- package/createTheme/createSpacing.d.ts +2 -2
- package/cssVars/createCssVarsProvider.d.ts +66 -8
- package/cssVars/createCssVarsProvider.js +54 -22
- package/cssVars/cssVarsParser.d.ts +3 -5
- package/cssVars/cssVarsParser.js +3 -7
- package/cssVars/useCurrentColorScheme.d.ts +3 -3
- package/esm/colorManipulator.js +50 -0
- package/esm/cssVars/createCssVarsProvider.js +54 -22
- package/esm/cssVars/cssVarsParser.js +3 -7
- package/index.js +1 -1
- package/legacy/colorManipulator.js +50 -0
- package/legacy/cssVars/createCssVarsProvider.js +54 -20
- package/legacy/cssVars/cssVarsParser.js +3 -7
- package/legacy/index.js +1 -1
- package/modern/colorManipulator.js +50 -0
- package/modern/cssVars/createCssVarsProvider.js +54 -22
- package/modern/cssVars/cssVarsParser.js +3 -7
- package/modern/index.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## 5.10.17
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v5.10.16..master -->
|
|
6
|
+
|
|
7
|
+
_Dec 6, 2022_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
|
|
10
|
+
|
|
11
|
+
- ✨ @mnajdova added a [Material You Button playground](https://mui.com/material-ui/react-button/#material-you-version) (#35222)
|
|
12
|
+
- 🔧 @hbjORbj renamed `components` / `componentProps` to `slots` / `slotProps` prop in Joy UI to create consistency across products (#34997)
|
|
13
|
+
- Many other 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements
|
|
14
|
+
|
|
15
|
+
### `@mui/material@5.10.17`
|
|
16
|
+
|
|
17
|
+
- ​<!-- 31 -->[Slider] Fix `markActive` theme class not getting applied (#35067) @ZeeshanTamboli
|
|
18
|
+
- ​<!-- 30 -->[SwipeableDrawer] Fix missing close animation when initial open is true (#35010) @sai6855
|
|
19
|
+
- ​<!-- 28 -->[material-ui] Add channel colors if possible (#35178) @siriwatknp
|
|
20
|
+
- ​<!-- 10 -->[Fab] Increase disabled styles precedence (#35304) @Uzwername
|
|
21
|
+
- ​<!-- 05 -->[Rating] Apply `labelEmptyValueActive` style overrides from theme (#35315) @sai6855
|
|
22
|
+
|
|
23
|
+
### `@mui/system@5.10.17`
|
|
24
|
+
|
|
25
|
+
- ​<!-- 04 -->[system] Add support for nested CssVarsProvider (#35277) @siriwatknp
|
|
26
|
+
|
|
27
|
+
### `@mui/joy@5.0.0-alpha.57`
|
|
28
|
+
|
|
29
|
+
#### BREAKING CHANGE
|
|
30
|
+
|
|
31
|
+
- ​<!-- 08 -->[Joy] Add `slots`/`slotProps` props to the typing of all components and apply `useSlot` to all components (#34997) @hbjORbj
|
|
32
|
+
|
|
33
|
+
- Change all occurrences of `components` and `componentsProps` props in Joy UI components to `slots` and `slotProps`, respectively.
|
|
34
|
+
|
|
35
|
+
```diff
|
|
36
|
+
-<Autocomplete components={{listbox: CustomListbox}} componentsProps={{listbox: { className: 'custom-listbox' }}} />
|
|
37
|
+
+<Autocomplete slots={{listbox: CustomListbox}} slotProps={{listbox: { className: 'custom-listbox' }}} />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
You can use this [codemod](https://github.com/mui/material-ui/blob/master/packages/mui-codemod/README.md#joy-rename-components-to-slots) to help with the migration.
|
|
41
|
+
|
|
42
|
+
#### Changes
|
|
43
|
+
|
|
44
|
+
- ​<!-- 07 -->[Joy] Miscellaneous fixes (#35345) @siriwatknp
|
|
45
|
+
- ​<!-- 06 -->[Joy][textarea] Expose decorator classes (#35247) @zignis
|
|
46
|
+
|
|
47
|
+
### Docs
|
|
48
|
+
|
|
49
|
+
- ​<!-- 29 -->[docs] Improve spacing with ul (#35302) @oliviertassinari
|
|
50
|
+
- ​<!-- 23 -->[docs] Correct grammatically incorrect sentences in CONTRIBUTING.md (#34949) @Pandey-utkarsh
|
|
51
|
+
- ​<!-- 22 -->[docs] Move the demo higher in the API TOC (#35202) @oliviertassinari
|
|
52
|
+
- ​<!-- 21 -->[docs] Fix incorrect link in minimizing-bundle-size (#35297) @Juneezee
|
|
53
|
+
- ​<!-- 20 -->[docs] Revise and expand Joy UI "Breadcrumbs" page (#35292) @samuelsycamore
|
|
54
|
+
- ​<!-- 19 -->[docs] Fix wrong import in the unstyled tabs page (#35310) @guotie
|
|
55
|
+
- ​<!-- 18 -->[docs] Disable translations (#34820) @mnajdova
|
|
56
|
+
- ​<!-- 17 -->[docs] Fix typo (#35312) @flaviendelangle
|
|
57
|
+
- ​<!-- 16 -->[docs] Add Material You Button playground (#35222) @mnajdova
|
|
58
|
+
- ​<!-- 15 -->[docs] Fix experimental API page duplication (#35213) @oliviertassinari
|
|
59
|
+
- ​<!-- 14 -->[docs] Improve the autogenerated "Unstyled" and "API" text (#35185) @samuelsycamore
|
|
60
|
+
- ​<!-- 13 -->[docs] Fix ad margin on API pages (#35201) @oliviertassinari
|
|
61
|
+
- ​<!-- 12 -->[docs] Revise and expand the Joy UI "Badge" page (#35199) @samuelsycamore
|
|
62
|
+
- ​<!-- 11 -->[docs] Update MUI Base docs with latest style conventions (#35034) @samuelsycamore
|
|
63
|
+
- ​<!-- 09 -->[l10n] Improve Chinese (Taiwan) zh-TW locale (#35328) @happyincent
|
|
64
|
+
- ​<!-- 02 -->[website] Update MUI stats: GitHub stars, Twitter followers, etc. (#35318) @nomandhoni-cs
|
|
65
|
+
|
|
66
|
+
### Core
|
|
67
|
+
|
|
68
|
+
- ​<!-- 27 -->[core] Use componentStyles.name over componentName (#35303) @oliviertassinari
|
|
69
|
+
- ​<!-- 26 -->[core] Fix warning leak in production (#35313) @oliviertassinari
|
|
70
|
+
- ​<!-- 25 -->[core] Move the internal packages from docs/packages (#35305) @michaldudak
|
|
71
|
+
- ​<!-- 24 -->[core] Clean up the API docs generation scripts (#35244) @michaldudak
|
|
72
|
+
- ​<!-- 03 -->[test] Scope the tests to just Material UI components (#35219) @siriwatknp
|
|
73
|
+
- ​<!-- 01 -->[website] Remove BlackFriday notification @oliviertassinari
|
|
74
|
+
|
|
75
|
+
All contributors of this release in alphabetical order: @flaviendelangle, @guotie, @happyincent, @hbjORbj, @Juneezee, @michaldudak, @mnajdova, @nomandhoni-cs, @oliviertassinari, @Pandey-utkarsh, @sai6855, @samuelsycamore, @siriwatknp, @Uzwername, @zignis
|
|
76
|
+
|
|
77
|
+
## 5.10.16
|
|
78
|
+
|
|
79
|
+
<!-- generated comparing v5.10.15..master -->
|
|
80
|
+
|
|
81
|
+
_Nov 28, 2022_
|
|
82
|
+
|
|
83
|
+
A big thanks to the 13 contributors who made this release possible. This release contains various 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements.
|
|
84
|
+
|
|
85
|
+
### `@mui/material@5.10.16`
|
|
86
|
+
|
|
87
|
+
- ​<!-- 21 -->[Autocomplete] Fix inferred value type when `multiple` prop is `true` (#35275) @fenghan34
|
|
88
|
+
- ​<!-- 19 -->[Chip] Add `skipFocusWhenDisabled` prop to not allow focussing deletable chip if disabled (#35065) @sai6855
|
|
89
|
+
- ​<!-- 18 -->[Chip] Remove unnecessary handleKeyDown event handler (#35231) @ZeeshanTamboli
|
|
90
|
+
- ​<!-- 05 -->[FormControl] Add missing types in `useFormControl` (#35168) @ZeeshanTamboli
|
|
91
|
+
- ​<!-- 04 -->[IconButton] Add missing color classes (#33820) @Zetta56
|
|
92
|
+
- ​<!-- 03 -->[SwipeableDrawer] Make paper ref accessible (#35082) @sai6855
|
|
93
|
+
|
|
94
|
+
### `@mui/system@5.10.16`
|
|
95
|
+
|
|
96
|
+
- ​<!-- 02 -->[system] Remove unnecessary parsed theme (#35239) @siriwatknp
|
|
97
|
+
- ​<!-- 01 -->[theme] Fix TypeScript type for custom variants in responsive font sizes (#35057) @ZeeshanTamboli
|
|
98
|
+
|
|
99
|
+
### `@mui/base@5.0.0-alpha.108`
|
|
100
|
+
|
|
101
|
+
- ​<!-- 20 -->[Base] Allow useSlotProps to receive undefined elementType (#35192) @leventdeniz
|
|
102
|
+
|
|
103
|
+
### Docs
|
|
104
|
+
|
|
105
|
+
- ​<!-- 13 -->[docs] Improve feedback precision (#34641) @alexfauquette
|
|
106
|
+
- ​<!-- 12 -->[docs] Add Black Friday notification @oliviertassinari
|
|
107
|
+
- ​<!-- 11 -->[docs] Fix migration feedback (#35232) @alexfauquette
|
|
108
|
+
- ​<!-- 10 -->[docs] Improve the useSelect demo styling (#33883) @michaldudak
|
|
109
|
+
- ​<!-- 09 -->[docs] Fix layout jump on first mistake (#35215) @oliviertassinari
|
|
110
|
+
- ​<!-- 08 -->[docs] Support demos with side effect imports (#35177) @m4theushw
|
|
111
|
+
- ​<!-- 07 -->[examples] Fix Next.js errors (#35246) @oliviertassinari
|
|
112
|
+
- ​<!-- 06 -->[examples] Updated Remix examples with the lates changes using React 18 (#35092) @58bits
|
|
113
|
+
|
|
114
|
+
### Core
|
|
115
|
+
|
|
116
|
+
- ​<!-- 17 -->[core] Remove unused pattern (#35165) @iamxukai
|
|
117
|
+
- ​<!-- 16 -->[core] Fix Base version in changelog (#35224) @siriwatknp
|
|
118
|
+
- ​<!-- 15 -->[core] Migrate `describeConformance` to TypeScript (#35193) @flaviendelangle
|
|
119
|
+
- ​<!-- 14 -->[core] Skip CI for docs and examples paths (#35225) @siriwatknp
|
|
120
|
+
|
|
121
|
+
All contributors of this release in alphabetical order: @58bits, @alexfauquette, @fenghan34, @flaviendelangle, @iamxukai, @leventdeniz, @m4theushw, @michaldudak, @oliviertassinari, @sai6855, @siriwatknp, @ZeeshanTamboli, @Zetta56
|
|
122
|
+
|
|
3
123
|
## 5.10.15
|
|
4
124
|
|
|
5
125
|
<!-- generated comparing v5.10.14..master -->
|
|
@@ -26,7 +146,7 @@ A big thanks to the 9 contributors who made this release possible. Here are some
|
|
|
26
146
|
|
|
27
147
|
- [Material You] Add theme structure & Button component (#34650) @mnajdova
|
|
28
148
|
|
|
29
|
-
### `@mui/base@5.0.0-alpha.
|
|
149
|
+
### `@mui/base@5.0.0-alpha.107`
|
|
30
150
|
|
|
31
151
|
- [Select] Add attributes to conform with ARIA 1.2 (#35182) @michaldudak
|
|
32
152
|
|
|
@@ -37,4 +37,4 @@ export interface ContainerTypeMap<P = {}, D extends React.ElementType = 'div'> {
|
|
|
37
37
|
};
|
|
38
38
|
defaultComponent: D;
|
|
39
39
|
}
|
|
40
|
-
export
|
|
40
|
+
export type ContainerProps<D extends React.ElementType = ContainerTypeMap['defaultComponent'], P = {}> = OverrideProps<ContainerTypeMap<P, D>, D>;
|
|
@@ -16,7 +16,7 @@ export interface ContainerClasses {
|
|
|
16
16
|
/** Styles applied to the root element if `maxWidth="xl"`. */
|
|
17
17
|
maxWidthXl: string;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export type ContainerClassKey = keyof ContainerClasses;
|
|
20
20
|
export declare function getContainerUtilityClass(slot: string): string;
|
|
21
21
|
declare const containerClasses: ContainerClasses;
|
|
22
22
|
export default containerClasses;
|
|
@@ -7,7 +7,7 @@ interface StyleFnProps<Theme> extends ContainerProps {
|
|
|
7
7
|
theme: Theme;
|
|
8
8
|
ownerState: ContainerProps;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
type RequiredThemeStructure = Pick<DefaultTheme, 'breakpoints' | 'spacing'>;
|
|
11
11
|
export default function createContainer<Theme extends RequiredThemeStructure = DefaultTheme>(options?: {
|
|
12
12
|
createStyledComponent?: (...styles: Array<Interpolation<StyleFnProps<Theme>>>) => StyledComponent<ContainerProps>;
|
|
13
13
|
useThemeProps?: (inProps: ContainerProps) => ContainerProps & {
|
package/Stack/StackProps.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface StackTypeMap<P = {}, D extends React.ElementType = 'div'> {
|
|
|
33
33
|
} & SystemProps<Theme>;
|
|
34
34
|
defaultComponent: D;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type StackProps<D extends React.ElementType = StackTypeMap['defaultComponent'], P = {
|
|
37
37
|
component?: React.ElementType;
|
|
38
38
|
}> = OverrideProps<StackTypeMap<P, D>, D>;
|
|
39
39
|
export interface StackOwnerState {
|
package/Stack/stackClasses.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export interface StackClasses {
|
|
|
2
2
|
/** Styles applied to the root element. */
|
|
3
3
|
root: string;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export type StackClassKey = keyof StackClasses;
|
|
6
6
|
export declare function getStackUtilityClass(slot: string): string;
|
|
7
7
|
declare const stackClasses: StackClasses;
|
|
8
8
|
export default stackClasses;
|
|
@@ -3,13 +3,13 @@ import { OverrideProps, IfEquals } from '@mui/types';
|
|
|
3
3
|
import { SxProps } from '../styleFunctionSx';
|
|
4
4
|
import { Theme, Breakpoint, BreakpointOverrides } from '../createTheme';
|
|
5
5
|
import { SystemProps } from '../Box';
|
|
6
|
-
|
|
6
|
+
type ResponsiveStyleValue<T> = T | Array<T | null> | {
|
|
7
7
|
[key in Breakpoint]?: T | null;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
9
|
+
export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
|
|
10
|
+
export type GridSpacing = number | string;
|
|
11
|
+
export type GridWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
12
|
+
export type GridSize = 'auto' | number;
|
|
13
13
|
export interface GridDefaultBreakpoints {
|
|
14
14
|
/**
|
|
15
15
|
* If a number, it sets the number of columns the grid item uses.
|
|
@@ -92,10 +92,10 @@ export interface GridDefaultBreakpoints {
|
|
|
92
92
|
*/
|
|
93
93
|
xsOffset?: GridSize;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
type CustomBreakpoints = Partial<Record<Breakpoint, boolean | GridSize> & Record<`${Breakpoint}Offset`, GridSize>>;
|
|
96
96
|
interface BreakpointOverridesEmpty {
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
type Breakpoints = IfEquals<BreakpointOverrides, BreakpointOverridesEmpty, GridDefaultBreakpoints, CustomBreakpoints>;
|
|
99
99
|
export interface GridBaseProps extends Breakpoints {
|
|
100
100
|
/**
|
|
101
101
|
* The content of the component.
|
|
@@ -156,7 +156,7 @@ export interface GridTypeMap<P = {}, D extends React.ElementType = 'div'> {
|
|
|
156
156
|
} & SystemProps<Theme>;
|
|
157
157
|
defaultComponent: D;
|
|
158
158
|
}
|
|
159
|
-
export
|
|
159
|
+
export type GridProps<D extends React.ElementType = GridTypeMap['defaultComponent'], P = {
|
|
160
160
|
component?: React.ElementType;
|
|
161
161
|
}> = OverrideProps<GridTypeMap<P, D>, D>;
|
|
162
162
|
export {};
|
|
@@ -14,7 +14,7 @@ export interface GridClasses {
|
|
|
14
14
|
/** Styles applied to the root element if `wrap="reverse"`. */
|
|
15
15
|
'wrap-xs-wrap-reverse': string;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type GridClassKey = keyof GridClasses;
|
|
18
18
|
export declare function getGridUtilityClass(slot: string): string;
|
|
19
19
|
declare const gridClasses: GridClasses;
|
|
20
20
|
export default gridClasses;
|
package/colorManipulator.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
export type ColorFormat = 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'color';
|
|
2
3
|
export interface ColorObject {
|
|
3
4
|
type: ColorFormat;
|
|
@@ -10,10 +11,19 @@ export function rgbToHex(color: string): string;
|
|
|
10
11
|
export function hslToRgb(color: string): string;
|
|
11
12
|
export function decomposeColor(color: string): ColorObject;
|
|
12
13
|
export function colorChannel(color: string): string;
|
|
14
|
+
export function private_safeColorChannel(color: string, warning?: string): string;
|
|
13
15
|
export function recomposeColor(color: ColorObject): string;
|
|
14
16
|
export function getContrastRatio(foreground: string, background: string): number;
|
|
15
17
|
export function getLuminance(color: string): number;
|
|
16
18
|
export function emphasize(color: string, coefficient?: number): string;
|
|
19
|
+
export function private_safeEmphasize(
|
|
20
|
+
color: string,
|
|
21
|
+
coefficient?: number,
|
|
22
|
+
warning?: string,
|
|
23
|
+
): string;
|
|
17
24
|
export function alpha(color: string, value: number): string;
|
|
25
|
+
export function private_safeAlpha(color: string, value: number, warning?: string): string;
|
|
18
26
|
export function darken(color: string, coefficient: number): string;
|
|
27
|
+
export function private_safeDarken(color: string, coefficient: number, warning?: string): string;
|
|
19
28
|
export function lighten(color: string, coefficient: number): string;
|
|
29
|
+
export function private_safeLighten(color: string, coefficient: number, warning?: string): string;
|
package/colorManipulator.js
CHANGED
|
@@ -13,6 +13,11 @@ exports.getLuminance = getLuminance;
|
|
|
13
13
|
exports.hexToRgb = hexToRgb;
|
|
14
14
|
exports.hslToRgb = hslToRgb;
|
|
15
15
|
exports.lighten = lighten;
|
|
16
|
+
exports.private_safeAlpha = private_safeAlpha;
|
|
17
|
+
exports.private_safeColorChannel = void 0;
|
|
18
|
+
exports.private_safeDarken = private_safeDarken;
|
|
19
|
+
exports.private_safeEmphasize = private_safeEmphasize;
|
|
20
|
+
exports.private_safeLighten = private_safeLighten;
|
|
16
21
|
exports.recomposeColor = recomposeColor;
|
|
17
22
|
exports.rgbToHex = rgbToHex;
|
|
18
23
|
var _utils = require("@mui/utils");
|
|
@@ -107,6 +112,17 @@ const colorChannel = color => {
|
|
|
107
112
|
const decomposedColor = decomposeColor(color);
|
|
108
113
|
return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.indexOf('hsl') !== -1 && idx !== 0 ? `${val}%` : val).join(' ');
|
|
109
114
|
};
|
|
115
|
+
exports.colorChannel = colorChannel;
|
|
116
|
+
const private_safeColorChannel = (color, warning) => {
|
|
117
|
+
try {
|
|
118
|
+
return colorChannel(color);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
121
|
+
console.warn(warning);
|
|
122
|
+
}
|
|
123
|
+
return color;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
110
126
|
|
|
111
127
|
/**
|
|
112
128
|
* Converts a color object with type and values to a string.
|
|
@@ -115,7 +131,7 @@ const colorChannel = color => {
|
|
|
115
131
|
* @param {array} color.values - [n,n,n] or [n,n,n,n]
|
|
116
132
|
* @returns {string} A CSS color string
|
|
117
133
|
*/
|
|
118
|
-
exports.
|
|
134
|
+
exports.private_safeColorChannel = private_safeColorChannel;
|
|
119
135
|
function recomposeColor(color) {
|
|
120
136
|
const {
|
|
121
137
|
type,
|
|
@@ -238,6 +254,16 @@ function alpha(color, value) {
|
|
|
238
254
|
}
|
|
239
255
|
return recomposeColor(color);
|
|
240
256
|
}
|
|
257
|
+
function private_safeAlpha(color, value, warning) {
|
|
258
|
+
try {
|
|
259
|
+
return alpha(color, value);
|
|
260
|
+
} catch (error) {
|
|
261
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
262
|
+
console.warn(warning);
|
|
263
|
+
}
|
|
264
|
+
return color;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
241
267
|
|
|
242
268
|
/**
|
|
243
269
|
* Darkens a color.
|
|
@@ -257,6 +283,16 @@ function darken(color, coefficient) {
|
|
|
257
283
|
}
|
|
258
284
|
return recomposeColor(color);
|
|
259
285
|
}
|
|
286
|
+
function private_safeDarken(color, coefficient, warning) {
|
|
287
|
+
try {
|
|
288
|
+
return darken(color, coefficient);
|
|
289
|
+
} catch (error) {
|
|
290
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
291
|
+
console.warn(warning);
|
|
292
|
+
}
|
|
293
|
+
return color;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
260
296
|
|
|
261
297
|
/**
|
|
262
298
|
* Lightens a color.
|
|
@@ -280,6 +316,16 @@ function lighten(color, coefficient) {
|
|
|
280
316
|
}
|
|
281
317
|
return recomposeColor(color);
|
|
282
318
|
}
|
|
319
|
+
function private_safeLighten(color, coefficient, warning) {
|
|
320
|
+
try {
|
|
321
|
+
return lighten(color, coefficient);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
324
|
+
console.warn(warning);
|
|
325
|
+
}
|
|
326
|
+
return color;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
283
329
|
|
|
284
330
|
/**
|
|
285
331
|
* Darken or lighten a color, depending on its luminance.
|
|
@@ -290,4 +336,14 @@ function lighten(color, coefficient) {
|
|
|
290
336
|
*/
|
|
291
337
|
function emphasize(color, coefficient = 0.15) {
|
|
292
338
|
return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
|
|
339
|
+
}
|
|
340
|
+
function private_safeEmphasize(color, coefficient, warning) {
|
|
341
|
+
try {
|
|
342
|
+
return private_safeEmphasize(color, coefficient);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (warning && process.env.NODE_ENV !== 'production') {
|
|
345
|
+
console.warn(warning);
|
|
346
|
+
}
|
|
347
|
+
return color;
|
|
348
|
+
}
|
|
293
349
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
+
export type SpacingArgument = number | string;
|
|
3
3
|
export interface Spacing {
|
|
4
4
|
(): string;
|
|
5
5
|
(value: number): string;
|
|
@@ -66,7 +66,7 @@ export interface CreateCssVarsProviderResult<ColorScheme extends string> {
|
|
|
66
66
|
* The node used to attach the color-scheme attribute
|
|
67
67
|
* @default document
|
|
68
68
|
*/
|
|
69
|
-
colorSchemeNode?:
|
|
69
|
+
colorSchemeNode?: Element | null;
|
|
70
70
|
/**
|
|
71
71
|
* The CSS selector for attaching the generated custom properties
|
|
72
72
|
* @default ':root'
|
|
@@ -77,10 +77,63 @@ export interface CreateCssVarsProviderResult<ColorScheme extends string> {
|
|
|
77
77
|
* @default window
|
|
78
78
|
*/
|
|
79
79
|
storageWindow?: Window | null;
|
|
80
|
+
/**
|
|
81
|
+
* If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
|
|
82
|
+
*/
|
|
83
|
+
disableNestedContext?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* If `true`, the style sheet won't be generated.
|
|
86
|
+
*
|
|
87
|
+
* This is useful for controlling nested CssVarsProvider behavior.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
disableStyleSheetGeneration?: boolean;
|
|
80
91
|
}
|
|
81
92
|
>,
|
|
82
93
|
) => React.ReactElement;
|
|
83
94
|
useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
|
|
95
|
+
generateCssThemeVars: (options?: {
|
|
96
|
+
/**
|
|
97
|
+
* Design system default color scheme.
|
|
98
|
+
* - provides string if the design system has one default color scheme (either light or dark)
|
|
99
|
+
* - provides object if the design system has default light & dark color schemes
|
|
100
|
+
*/
|
|
101
|
+
defaultColorScheme?: ColorScheme | { light: ColorScheme; dark: ColorScheme };
|
|
102
|
+
/**
|
|
103
|
+
* @default 'light'
|
|
104
|
+
*/
|
|
105
|
+
defaultMode?: 'light' | 'dark';
|
|
106
|
+
/**
|
|
107
|
+
* The selector for attaching CSS variables that are **outside** of `theme.colorSchemes.*`.
|
|
108
|
+
* @default ':root'
|
|
109
|
+
*/
|
|
110
|
+
rootSelector: string;
|
|
111
|
+
/**
|
|
112
|
+
* The selector for attaching CSS variables that are **outside** of `theme.colorSchemes.*`.
|
|
113
|
+
* @default (key) => `[data-color-scheme="${key}"]`
|
|
114
|
+
*/
|
|
115
|
+
colorSchemeSelector: (key: ColorScheme) => string;
|
|
116
|
+
/**
|
|
117
|
+
* A function to determine if the key, value should be attached as CSS Variable
|
|
118
|
+
* `keys` is an array that represents the object path keys.
|
|
119
|
+
* Ex, if the theme is { foo: { bar: 'var(--test)' } }
|
|
120
|
+
* then, keys = ['foo', 'bar']
|
|
121
|
+
* value = 'var(--test)'
|
|
122
|
+
*/
|
|
123
|
+
shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Controlled mode. If not provided, it will try to read the value from the upper CssVarsProvider.
|
|
126
|
+
*/
|
|
127
|
+
mode?: Mode;
|
|
128
|
+
/**
|
|
129
|
+
* Controlled color scheme. If not provided, it will try to read the value from the upper CssVarsProvider.
|
|
130
|
+
*/
|
|
131
|
+
colorScheme?: ColorScheme;
|
|
132
|
+
theme?: {
|
|
133
|
+
cssVarPrefix?: string;
|
|
134
|
+
colorSchemes: Record<ColorScheme, Record<string, any>>;
|
|
135
|
+
};
|
|
136
|
+
}) => Record<string, any>;
|
|
84
137
|
getInitColorSchemeScript: typeof getInitColorSchemeScript;
|
|
85
138
|
}
|
|
86
139
|
|
|
@@ -89,7 +142,7 @@ export default function createCssVarsProvider<ColorScheme extends string>(
|
|
|
89
142
|
/**
|
|
90
143
|
* Design system default theme
|
|
91
144
|
*
|
|
92
|
-
* The structure inside `theme.colorSchemes[colorScheme]` should be exactly the same in all color schemes because
|
|
145
|
+
* - The structure inside `theme.colorSchemes[colorScheme]` should be exactly the same in all color schemes because
|
|
93
146
|
* those object of the color scheme will be used when the color scheme is active.
|
|
94
147
|
*
|
|
95
148
|
* {
|
|
@@ -99,16 +152,21 @@ export default function createCssVarsProvider<ColorScheme extends string>(
|
|
|
99
152
|
* }
|
|
100
153
|
* }
|
|
101
154
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
155
|
+
* - If colorScheme is 'light', the `lightColorSchemeValues` will be merged to theme as `{ ...theme, ...lightColorSchemeValues }`
|
|
156
|
+
* likewise, if colorScheme is 'dark', the `darkColorSchemeValues` will be merged to theme as `{ ...theme, ...darkColorSchemeValues }`
|
|
104
157
|
*
|
|
105
|
-
*
|
|
158
|
+
* - If the theme contains the same keys as the color scheme, their values will be merged.
|
|
106
159
|
* Ex. {
|
|
107
160
|
* colorSchemes: {
|
|
108
|
-
* light: { palette: { ... } },
|
|
109
|
-
* dark: { palette: { ... } }
|
|
161
|
+
* light: { palette: { primary: { ... } } },
|
|
162
|
+
* dark: { palette: { primary: { ...} } }
|
|
110
163
|
* },
|
|
111
|
-
* palette: { ... }
|
|
164
|
+
* palette: { shared: { ... } }
|
|
165
|
+
* }
|
|
166
|
+
*
|
|
167
|
+
* becomes: {
|
|
168
|
+
* colorSchemes: { ... },
|
|
169
|
+
* palette: { shared: { ... }, primary: { ... } }
|
|
112
170
|
* }
|
|
113
171
|
*/
|
|
114
172
|
theme: any;
|
|
@@ -12,6 +12,7 @@ var _utils = require("@mui/utils");
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _styledEngine = require("@mui/styled-engine");
|
|
15
|
+
var _privateTheming = require("@mui/private-theming");
|
|
15
16
|
var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
|
|
16
17
|
var _ThemeProvider = _interopRequireDefault(require("../ThemeProvider"));
|
|
17
18
|
var _getInitColorSchemeScript = _interopRequireWildcard(require("./getInitColorSchemeScript"));
|
|
@@ -59,9 +60,14 @@ function createCssVarsProvider(options) {
|
|
|
59
60
|
documentNode = typeof document === 'undefined' ? undefined : document,
|
|
60
61
|
colorSchemeNode = typeof document === 'undefined' ? undefined : document.documentElement,
|
|
61
62
|
colorSchemeSelector = ':root',
|
|
62
|
-
shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar
|
|
63
|
+
shouldSkipGeneratingVar = designSystemShouldSkipGeneratingVar,
|
|
64
|
+
disableNestedContext = false,
|
|
65
|
+
disableStyleSheetGeneration = false
|
|
63
66
|
}) {
|
|
64
67
|
const hasMounted = React.useRef(false);
|
|
68
|
+
const upperTheme = (0, _privateTheming.useTheme)();
|
|
69
|
+
const ctx = React.useContext(ColorSchemeContext);
|
|
70
|
+
const nested = !!ctx && !disableNestedContext;
|
|
65
71
|
const {
|
|
66
72
|
colorSchemes = {},
|
|
67
73
|
components = {},
|
|
@@ -74,12 +80,12 @@ function createCssVarsProvider(options) {
|
|
|
74
80
|
|
|
75
81
|
// 1. Get the data about the `mode`, `colorScheme`, and setter functions.
|
|
76
82
|
const {
|
|
77
|
-
mode,
|
|
83
|
+
mode: stateMode,
|
|
78
84
|
setMode,
|
|
79
85
|
systemMode,
|
|
80
86
|
lightColorScheme,
|
|
81
87
|
darkColorScheme,
|
|
82
|
-
colorScheme,
|
|
88
|
+
colorScheme: stateColorScheme,
|
|
83
89
|
setColorScheme
|
|
84
90
|
} = (0, _useCurrentColorScheme.default)({
|
|
85
91
|
supportedColorSchemes: allColorSchemes,
|
|
@@ -90,6 +96,12 @@ function createCssVarsProvider(options) {
|
|
|
90
96
|
defaultMode,
|
|
91
97
|
storageWindow
|
|
92
98
|
});
|
|
99
|
+
let mode = stateMode;
|
|
100
|
+
let colorScheme = stateColorScheme;
|
|
101
|
+
if (nested) {
|
|
102
|
+
mode = ctx.mode;
|
|
103
|
+
colorScheme = ctx.colorScheme;
|
|
104
|
+
}
|
|
93
105
|
const calculatedMode = (() => {
|
|
94
106
|
if (!mode) {
|
|
95
107
|
// This scope occurs on the server
|
|
@@ -115,15 +127,14 @@ function createCssVarsProvider(options) {
|
|
|
115
127
|
// 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
116
128
|
const {
|
|
117
129
|
css: rootCss,
|
|
118
|
-
vars: rootVars
|
|
119
|
-
parsedTheme
|
|
130
|
+
vars: rootVars
|
|
120
131
|
} = (0, _cssVarsParser.default)(restThemeProp, {
|
|
121
132
|
prefix: cssVarPrefix,
|
|
122
133
|
shouldSkipGeneratingVar
|
|
123
134
|
});
|
|
124
135
|
|
|
125
136
|
// 3. Start composing the theme object
|
|
126
|
-
const theme = (0, _extends2.default)({},
|
|
137
|
+
const theme = (0, _extends2.default)({}, restThemeProp, {
|
|
127
138
|
components,
|
|
128
139
|
colorSchemes,
|
|
129
140
|
cssVarPrefix,
|
|
@@ -139,8 +150,7 @@ function createCssVarsProvider(options) {
|
|
|
139
150
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
140
151
|
const {
|
|
141
152
|
css,
|
|
142
|
-
vars
|
|
143
|
-
parsedTheme: parsedScheme
|
|
153
|
+
vars
|
|
144
154
|
} = (0, _cssVarsParser.default)(scheme, {
|
|
145
155
|
prefix: cssVarPrefix,
|
|
146
156
|
shouldSkipGeneratingVar
|
|
@@ -148,12 +158,12 @@ function createCssVarsProvider(options) {
|
|
|
148
158
|
theme.vars = (0, _utils.deepmerge)(theme.vars, vars);
|
|
149
159
|
if (key === calculatedColorScheme) {
|
|
150
160
|
// 4.1 Merge the selected color scheme to the theme
|
|
151
|
-
Object.keys(
|
|
152
|
-
if (
|
|
161
|
+
Object.keys(scheme).forEach(schemeKey => {
|
|
162
|
+
if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
|
|
153
163
|
// shallow merge the 1st level structure of the theme.
|
|
154
|
-
theme[schemeKey] = (0, _extends2.default)({}, theme[schemeKey],
|
|
164
|
+
theme[schemeKey] = (0, _extends2.default)({}, theme[schemeKey], scheme[schemeKey]);
|
|
155
165
|
} else {
|
|
156
|
-
theme[schemeKey] =
|
|
166
|
+
theme[schemeKey] = scheme[schemeKey];
|
|
157
167
|
}
|
|
158
168
|
});
|
|
159
169
|
if (theme.palette) {
|
|
@@ -228,21 +238,33 @@ function createCssVarsProvider(options) {
|
|
|
228
238
|
setColorScheme,
|
|
229
239
|
allColorSchemes
|
|
230
240
|
}), [allColorSchemes, colorScheme, darkColorScheme, lightColorScheme, mode, setColorScheme, setMode, systemMode]);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
let shouldGenerateStyleSheet = true;
|
|
242
|
+
if (disableStyleSheetGeneration || nested && (upperTheme == null ? void 0 : upperTheme.cssVarPrefix) === cssVarPrefix) {
|
|
243
|
+
shouldGenerateStyleSheet = false;
|
|
244
|
+
}
|
|
245
|
+
const element = /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
246
|
+
children: [shouldGenerateStyleSheet && /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
247
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
|
|
248
|
+
styles: {
|
|
249
|
+
[colorSchemeSelector]: rootCss
|
|
250
|
+
}
|
|
251
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
|
|
252
|
+
styles: defaultColorSchemeStyleSheet
|
|
253
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_styledEngine.GlobalStyles, {
|
|
254
|
+
styles: otherColorSchemesStyleSheet
|
|
255
|
+
})]
|
|
241
256
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProvider.default, {
|
|
242
257
|
theme: resolveTheme ? resolveTheme(theme) : theme,
|
|
243
258
|
children: children
|
|
244
259
|
})]
|
|
245
260
|
});
|
|
261
|
+
if (nested) {
|
|
262
|
+
return element;
|
|
263
|
+
}
|
|
264
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ColorSchemeContext.Provider, {
|
|
265
|
+
value: contextValue,
|
|
266
|
+
children: element
|
|
267
|
+
});
|
|
246
268
|
}
|
|
247
269
|
process.env.NODE_ENV !== "production" ? CssVarsProvider.propTypes = {
|
|
248
270
|
/**
|
|
@@ -273,6 +295,16 @@ function createCssVarsProvider(options) {
|
|
|
273
295
|
* The initial mode used.
|
|
274
296
|
*/
|
|
275
297
|
defaultMode: _propTypes.default.string,
|
|
298
|
+
/**
|
|
299
|
+
* If `true`, the provider creates its own context and generate stylesheet as if it is a root `CssVarsProvider`.
|
|
300
|
+
*/
|
|
301
|
+
disableNestedContext: _propTypes.default.bool,
|
|
302
|
+
/**
|
|
303
|
+
* If `true`, the style sheet won't be generated.
|
|
304
|
+
*
|
|
305
|
+
* This is useful for controlling nested CssVarsProvider behavior.
|
|
306
|
+
*/
|
|
307
|
+
disableStyleSheetGeneration: _propTypes.default.bool,
|
|
276
308
|
/**
|
|
277
309
|
* Disable CSS transitions when switching between modes or color schemes
|
|
278
310
|
*/
|