@mui/system 5.10.14 → 5.10.16
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 +108 -0
- 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/createTheme/createSpacing.d.ts +2 -2
- package/cssVars/createCssVarsProvider.d.ts +12 -7
- package/cssVars/createCssVarsProvider.js +11 -6
- package/cssVars/cssVarsParser.d.ts +3 -5
- package/cssVars/cssVarsParser.js +3 -7
- package/cssVars/useCurrentColorScheme.d.ts +3 -3
- package/esm/cssVars/createCssVarsProvider.js +11 -6
- package/esm/cssVars/cssVarsParser.js +3 -7
- package/esm/index.js +2 -1
- package/esm/style.js +3 -3
- package/index.d.ts +2 -0
- package/index.js +16 -1
- package/legacy/cssVars/createCssVarsProvider.js +11 -6
- package/legacy/cssVars/cssVarsParser.js +3 -7
- package/legacy/index.js +3 -2
- package/legacy/style.js +3 -3
- package/modern/cssVars/createCssVarsProvider.js +11 -6
- package/modern/cssVars/cssVarsParser.js +3 -7
- package/modern/index.js +3 -2
- package/modern/style.js +3 -3
- package/package.json +5 -5
- package/responsivePropType.d.ts +3 -0
- package/spacing.d.ts +14 -0
- package/style.d.ts +6 -0
- package/style.js +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,113 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## 5.10.16
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v5.10.15..master -->
|
|
6
|
+
|
|
7
|
+
_Nov 28, 2022_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 13 contributors who made this release possible. This release contains various 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements.
|
|
10
|
+
|
|
11
|
+
### `@mui/material@5.10.16`
|
|
12
|
+
|
|
13
|
+
- ​<!-- 21 -->[Autocomplete] Fix inferred value type when `multiple` prop is `true` (#35275) @fenghan34
|
|
14
|
+
- ​<!-- 19 -->[Chip] Add `skipFocusWhenDisabled` prop to not allow focussing deletable chip if disabled (#35065) @sai6855
|
|
15
|
+
- ​<!-- 18 -->[Chip] Remove unnecessary handleKeyDown event handler (#35231) @ZeeshanTamboli
|
|
16
|
+
- ​<!-- 05 -->[FormControl] Add missing types in `useFormControl` (#35168) @ZeeshanTamboli
|
|
17
|
+
- ​<!-- 04 -->[IconButton] Add missing color classes (#33820) @Zetta56
|
|
18
|
+
- ​<!-- 03 -->[SwipeableDrawer] Make paper ref accessible (#35082) @sai6855
|
|
19
|
+
|
|
20
|
+
### `@mui/system@5.10.16`
|
|
21
|
+
|
|
22
|
+
- ​<!-- 02 -->[system] Remove unnecessary parsed theme (#35239) @siriwatknp
|
|
23
|
+
- ​<!-- 01 -->[theme] Fix TypeScript type for custom variants in responsive font sizes (#35057) @ZeeshanTamboli
|
|
24
|
+
|
|
25
|
+
### `@mui/base@5.0.0-alpha.108`
|
|
26
|
+
|
|
27
|
+
- ​<!-- 20 -->[Base] Allow useSlotProps to receive undefined elementType (#35192) @leventdeniz
|
|
28
|
+
|
|
29
|
+
### Docs
|
|
30
|
+
|
|
31
|
+
- ​<!-- 13 -->[docs] Improve feedback precision (#34641) @alexfauquette
|
|
32
|
+
- ​<!-- 12 -->[docs] Add Black Friday notification @oliviertassinari
|
|
33
|
+
- ​<!-- 11 -->[docs] Fix migration feedback (#35232) @alexfauquette
|
|
34
|
+
- ​<!-- 10 -->[docs] Improve the useSelect demo styling (#33883) @michaldudak
|
|
35
|
+
- ​<!-- 09 -->[docs] Fix layout jump on first mistake (#35215) @oliviertassinari
|
|
36
|
+
- ​<!-- 08 -->[docs] Support demos with side effect imports (#35177) @m4theushw
|
|
37
|
+
- ​<!-- 07 -->[examples] Fix Next.js errors (#35246) @oliviertassinari
|
|
38
|
+
- ​<!-- 06 -->[examples] Updated Remix examples with the lates changes using React 18 (#35092) @58bits
|
|
39
|
+
|
|
40
|
+
### Core
|
|
41
|
+
|
|
42
|
+
- ​<!-- 17 -->[core] Remove unused pattern (#35165) @iamxukai
|
|
43
|
+
- ​<!-- 16 -->[core] Fix Base version in changelog (#35224) @siriwatknp
|
|
44
|
+
- ​<!-- 15 -->[core] Migrate `describeConformance` to TypeScript (#35193) @flaviendelangle
|
|
45
|
+
- ​<!-- 14 -->[core] Skip CI for docs and examples paths (#35225) @siriwatknp
|
|
46
|
+
|
|
47
|
+
All contributors of this release in alphabetical order: @58bits, @alexfauquette, @fenghan34, @flaviendelangle, @iamxukai, @leventdeniz, @m4theushw, @michaldudak, @oliviertassinari, @sai6855, @siriwatknp, @ZeeshanTamboli, @Zetta56
|
|
48
|
+
|
|
49
|
+
## 5.10.15
|
|
50
|
+
|
|
51
|
+
<!-- generated comparing v5.10.14..master -->
|
|
52
|
+
|
|
53
|
+
_Nov 21, 2022_
|
|
54
|
+
|
|
55
|
+
A big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
|
|
56
|
+
|
|
57
|
+
- 🚀 @mnajdova added the button as the first component that implements [Material You](https://m3.material.io/) design (MD3)
|
|
58
|
+
- 🌐 @MBilalShafi added Urdu (Pakistan) localization
|
|
59
|
+
- Many other 🐛 bug fixes, 📚 documentation, and ⚙️ infrastructure improvements
|
|
60
|
+
|
|
61
|
+
### `@mui/material@5.10.15`
|
|
62
|
+
|
|
63
|
+
- [Autocomplete] Fix keyboard navigation when using custom popover (#35160) @sai6855
|
|
64
|
+
- [typescript] Add `background.defaultChannel` to `CssVarsPalette` (#35174) @alexfauquette
|
|
65
|
+
- [l10n] Add Urdu (ur-PK) locale (#35154) @MBilalShafi
|
|
66
|
+
|
|
67
|
+
### `@mui/icons-material@5.10.15`
|
|
68
|
+
|
|
69
|
+
- [icons] Update the Material Design icons (#35194) @michaldudak
|
|
70
|
+
|
|
71
|
+
### `@mui/material-next@6.0.0-alpha.63`
|
|
72
|
+
|
|
73
|
+
- [Material You] Add theme structure & Button component (#34650) @mnajdova
|
|
74
|
+
|
|
75
|
+
### `@mui/base@5.0.0-alpha.107`
|
|
76
|
+
|
|
77
|
+
- [Select] Add attributes to conform with ARIA 1.2 (#35182) @michaldudak
|
|
78
|
+
|
|
79
|
+
### Docs
|
|
80
|
+
|
|
81
|
+
- [docs] Fix a couple documentation errors (#35217) @danilo-leal
|
|
82
|
+
- [docs] Change MUI -> Material UI in icons-material's readme (#35220) @michaldudak
|
|
83
|
+
- [docs] the pages have no <link rel=canonical so we need to tell Google to not index the staging envs @oliviertassinari
|
|
84
|
+
- [docs] Fix confusion in TOCs when reaching scroll bottom (#35214) @oliviertassinari
|
|
85
|
+
- [docs] Fix typos in section titles (#35025) @iamxukai
|
|
86
|
+
- [docs] Fix typo in legacy date picker migration guide @oliviertassinari
|
|
87
|
+
- [docs] Iterating on recent Joy UI Component page updates (#35162) @samuelsycamore
|
|
88
|
+
- [docs] Inform that pickers are in X repository (#35189) @alexfauquette
|
|
89
|
+
- [docs] Explain how the `error` prop works in the Unstyled Input (#35171) @michaldudak
|
|
90
|
+
- [docs] Hotfix missing styles in dark mode (#35179) @siriwatknp
|
|
91
|
+
- [docs] Add Joy UI theme typography page (#34811) @siriwatknp
|
|
92
|
+
- [docs] Fix undo/redo in live editor (#35163) @oliviertassinari
|
|
93
|
+
- [docs] Revise the Joy UI "Avatar" component page (#35152) @samuelsycamore
|
|
94
|
+
- [docs] Make navbar backdrop filter consistent with website (#35157) @danilo-leal
|
|
95
|
+
- [docs] Host CodeSandbox on MUI org (#35110) @oliviertassinari
|
|
96
|
+
- [docs] Uplift introduction demos & make consistent with Base (#34316) @danilo-leal
|
|
97
|
+
- [website] Add Security questionnaire in pricing (#35172) @oliviertassinari
|
|
98
|
+
- [website] Fix theme mode toggle state (#35216) @siriwatknp
|
|
99
|
+
- [website] Exclude experiment pages in production (#35180) @siriwatknp
|
|
100
|
+
- [website] Disable SEO for performance pages (#35173) @oliviertassinari
|
|
101
|
+
|
|
102
|
+
### Core
|
|
103
|
+
|
|
104
|
+
- [core] Convert icons scripts to ESM (#35101) @Janpot
|
|
105
|
+
- [core] Group renovate GitHub Action dependency updates @oliviertassinari
|
|
106
|
+
- [core] Upgrade eslint-config-airbnb-typescript (#34642) @Janpot
|
|
107
|
+
- [core] Ensure that prettier CI step fails when code is badly formatted (#35170) @michaldudak
|
|
108
|
+
|
|
109
|
+
All contributors of this release in alphabetical order: @alexfauquette, @danilo-leal, @iamxukai, @Janpot, @MBilalShafi, @michaldudak, @oliviertassinari, @samuelsycamore, @siriwatknp
|
|
110
|
+
|
|
3
111
|
## v5.10.14
|
|
4
112
|
|
|
5
113
|
<!-- generated comparing v5.10.13..master -->
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -89,7 +89,7 @@ export default function createCssVarsProvider<ColorScheme extends string>(
|
|
|
89
89
|
/**
|
|
90
90
|
* Design system default theme
|
|
91
91
|
*
|
|
92
|
-
* The structure inside `theme.colorSchemes[colorScheme]` should be exactly the same in all color schemes because
|
|
92
|
+
* - The structure inside `theme.colorSchemes[colorScheme]` should be exactly the same in all color schemes because
|
|
93
93
|
* those object of the color scheme will be used when the color scheme is active.
|
|
94
94
|
*
|
|
95
95
|
* {
|
|
@@ -99,16 +99,21 @@ export default function createCssVarsProvider<ColorScheme extends string>(
|
|
|
99
99
|
* }
|
|
100
100
|
* }
|
|
101
101
|
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
102
|
+
* - If colorScheme is 'light', the `lightColorSchemeValues` will be merged to theme as `{ ...theme, ...lightColorSchemeValues }`
|
|
103
|
+
* likewise, if colorScheme is 'dark', the `darkColorSchemeValues` will be merged to theme as `{ ...theme, ...darkColorSchemeValues }`
|
|
104
104
|
*
|
|
105
|
-
*
|
|
105
|
+
* - If the theme contains the same keys as the color scheme, their values will be merged.
|
|
106
106
|
* Ex. {
|
|
107
107
|
* colorSchemes: {
|
|
108
|
-
* light: { palette: { ... } },
|
|
109
|
-
* dark: { palette: { ... } }
|
|
108
|
+
* light: { palette: { primary: { ... } } },
|
|
109
|
+
* dark: { palette: { primary: { ...} } }
|
|
110
110
|
* },
|
|
111
|
-
* palette: { ... }
|
|
111
|
+
* palette: { shared: { ... } }
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* becomes: {
|
|
115
|
+
* colorSchemes: { ... },
|
|
116
|
+
* palette: { shared: { ... }, primary: { ... } }
|
|
112
117
|
* }
|
|
113
118
|
*/
|
|
114
119
|
theme: any;
|
|
@@ -115,15 +115,14 @@ function createCssVarsProvider(options) {
|
|
|
115
115
|
// 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
116
116
|
const {
|
|
117
117
|
css: rootCss,
|
|
118
|
-
vars: rootVars
|
|
119
|
-
parsedTheme
|
|
118
|
+
vars: rootVars
|
|
120
119
|
} = (0, _cssVarsParser.default)(restThemeProp, {
|
|
121
120
|
prefix: cssVarPrefix,
|
|
122
121
|
shouldSkipGeneratingVar
|
|
123
122
|
});
|
|
124
123
|
|
|
125
124
|
// 3. Start composing the theme object
|
|
126
|
-
|
|
125
|
+
const theme = (0, _extends2.default)({}, restThemeProp, {
|
|
127
126
|
components,
|
|
128
127
|
colorSchemes,
|
|
129
128
|
cssVarPrefix,
|
|
@@ -139,8 +138,7 @@ function createCssVarsProvider(options) {
|
|
|
139
138
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
140
139
|
const {
|
|
141
140
|
css,
|
|
142
|
-
vars
|
|
143
|
-
parsedTheme: parsedScheme
|
|
141
|
+
vars
|
|
144
142
|
} = (0, _cssVarsParser.default)(scheme, {
|
|
145
143
|
prefix: cssVarPrefix,
|
|
146
144
|
shouldSkipGeneratingVar
|
|
@@ -148,7 +146,14 @@ function createCssVarsProvider(options) {
|
|
|
148
146
|
theme.vars = (0, _utils.deepmerge)(theme.vars, vars);
|
|
149
147
|
if (key === calculatedColorScheme) {
|
|
150
148
|
// 4.1 Merge the selected color scheme to the theme
|
|
151
|
-
|
|
149
|
+
Object.keys(scheme).forEach(schemeKey => {
|
|
150
|
+
if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
|
|
151
|
+
// shallow merge the 1st level structure of the theme.
|
|
152
|
+
theme[schemeKey] = (0, _extends2.default)({}, theme[schemeKey], scheme[schemeKey]);
|
|
153
|
+
} else {
|
|
154
|
+
theme[schemeKey] = scheme[schemeKey];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
152
157
|
if (theme.palette) {
|
|
153
158
|
theme.palette.colorScheme = key;
|
|
154
159
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type NestedRecord<V = any> = {
|
|
2
2
|
[k: string | number]: NestedRecord<V> | V;
|
|
3
3
|
};
|
|
4
4
|
/**
|
|
@@ -41,10 +41,10 @@ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, ca
|
|
|
41
41
|
* }} options.
|
|
42
42
|
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
43
|
*
|
|
44
|
-
* @returns {{ css: Object, vars: Object
|
|
44
|
+
* @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
|
-
* const { css, vars
|
|
47
|
+
* const { css, vars } = parser({
|
|
48
48
|
* fontSize: 12,
|
|
49
49
|
* lineHeight: 1.2,
|
|
50
50
|
* palette: { primary: { 500: 'var(--color)' } }
|
|
@@ -52,7 +52,6 @@ export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, ca
|
|
|
52
52
|
*
|
|
53
53
|
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
54
|
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
55
|
*/
|
|
57
56
|
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
57
|
prefix?: string;
|
|
@@ -60,6 +59,5 @@ export default function cssVarsParser<T extends Record<string, any>>(theme: T, o
|
|
|
60
59
|
}): {
|
|
61
60
|
css: Record<string, string | number>;
|
|
62
61
|
vars: NestedRecord<string>;
|
|
63
|
-
parsedTheme: T;
|
|
64
62
|
};
|
|
65
63
|
export {};
|
package/cssVars/cssVarsParser.js
CHANGED
|
@@ -96,10 +96,10 @@ const getCssValue = (keys, value) => {
|
|
|
96
96
|
* }} options.
|
|
97
97
|
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
98
98
|
*
|
|
99
|
-
* @returns {{ css: Object, vars: Object
|
|
99
|
+
* @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
100
100
|
*
|
|
101
101
|
* @example
|
|
102
|
-
* const { css, vars
|
|
102
|
+
* const { css, vars } = parser({
|
|
103
103
|
* fontSize: 12,
|
|
104
104
|
* lineHeight: 1.2,
|
|
105
105
|
* palette: { primary: { 500: 'var(--color)' } }
|
|
@@ -107,7 +107,6 @@ const getCssValue = (keys, value) => {
|
|
|
107
107
|
*
|
|
108
108
|
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
109
109
|
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
110
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
111
110
|
*/
|
|
112
111
|
function cssVarsParser(theme, options) {
|
|
113
112
|
const {
|
|
@@ -116,7 +115,6 @@ function cssVarsParser(theme, options) {
|
|
|
116
115
|
} = options || {};
|
|
117
116
|
const css = {};
|
|
118
117
|
const vars = {};
|
|
119
|
-
const parsedTheme = {};
|
|
120
118
|
walkObjectDeep(theme, (keys, value, arrayKeys) => {
|
|
121
119
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
122
120
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
@@ -128,13 +126,11 @@ function cssVarsParser(theme, options) {
|
|
|
128
126
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
|
-
assignNestedKeys(parsedTheme, keys, value, arrayKeys);
|
|
132
129
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
|
133
130
|
);
|
|
134
131
|
|
|
135
132
|
return {
|
|
136
133
|
css,
|
|
137
|
-
vars
|
|
138
|
-
parsedTheme
|
|
134
|
+
vars
|
|
139
135
|
};
|
|
140
136
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type Mode = 'light' | 'dark' | 'system';
|
|
2
|
+
export type SystemMode = Exclude<Mode, 'system'>;
|
|
3
3
|
export interface State<SupportedColorScheme extends string> {
|
|
4
4
|
/**
|
|
5
5
|
* User selected mode.
|
|
@@ -19,7 +19,7 @@ export interface State<SupportedColorScheme extends string> {
|
|
|
19
19
|
*/
|
|
20
20
|
darkColorScheme: SupportedColorScheme;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
|
|
23
23
|
/**
|
|
24
24
|
* The current application color scheme. It is always `undefined` on the server.
|
|
25
25
|
*/
|
|
@@ -106,15 +106,14 @@ export default function createCssVarsProvider(options) {
|
|
|
106
106
|
// 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
107
107
|
const {
|
|
108
108
|
css: rootCss,
|
|
109
|
-
vars: rootVars
|
|
110
|
-
parsedTheme
|
|
109
|
+
vars: rootVars
|
|
111
110
|
} = cssVarsParser(restThemeProp, {
|
|
112
111
|
prefix: cssVarPrefix,
|
|
113
112
|
shouldSkipGeneratingVar
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
// 3. Start composing the theme object
|
|
117
|
-
|
|
116
|
+
const theme = _extends({}, restThemeProp, {
|
|
118
117
|
components,
|
|
119
118
|
colorSchemes,
|
|
120
119
|
cssVarPrefix,
|
|
@@ -130,8 +129,7 @@ export default function createCssVarsProvider(options) {
|
|
|
130
129
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
131
130
|
const {
|
|
132
131
|
css,
|
|
133
|
-
vars
|
|
134
|
-
parsedTheme: parsedScheme
|
|
132
|
+
vars
|
|
135
133
|
} = cssVarsParser(scheme, {
|
|
136
134
|
prefix: cssVarPrefix,
|
|
137
135
|
shouldSkipGeneratingVar
|
|
@@ -139,7 +137,14 @@ export default function createCssVarsProvider(options) {
|
|
|
139
137
|
theme.vars = deepmerge(theme.vars, vars);
|
|
140
138
|
if (key === calculatedColorScheme) {
|
|
141
139
|
// 4.1 Merge the selected color scheme to the theme
|
|
142
|
-
|
|
140
|
+
Object.keys(scheme).forEach(schemeKey => {
|
|
141
|
+
if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
|
|
142
|
+
// shallow merge the 1st level structure of the theme.
|
|
143
|
+
theme[schemeKey] = _extends({}, theme[schemeKey], scheme[schemeKey]);
|
|
144
|
+
} else {
|
|
145
|
+
theme[schemeKey] = scheme[schemeKey];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
143
148
|
if (theme.palette) {
|
|
144
149
|
theme.palette.colorScheme = key;
|
|
145
150
|
}
|
|
@@ -86,10 +86,10 @@ const getCssValue = (keys, value) => {
|
|
|
86
86
|
* }} options.
|
|
87
87
|
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
88
88
|
*
|
|
89
|
-
* @returns {{ css: Object, vars: Object
|
|
89
|
+
* @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
|
-
* const { css, vars
|
|
92
|
+
* const { css, vars } = parser({
|
|
93
93
|
* fontSize: 12,
|
|
94
94
|
* lineHeight: 1.2,
|
|
95
95
|
* palette: { primary: { 500: 'var(--color)' } }
|
|
@@ -97,7 +97,6 @@ const getCssValue = (keys, value) => {
|
|
|
97
97
|
*
|
|
98
98
|
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
99
99
|
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
100
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
101
100
|
*/
|
|
102
101
|
export default function cssVarsParser(theme, options) {
|
|
103
102
|
const {
|
|
@@ -106,7 +105,6 @@ export default function cssVarsParser(theme, options) {
|
|
|
106
105
|
} = options || {};
|
|
107
106
|
const css = {};
|
|
108
107
|
const vars = {};
|
|
109
|
-
const parsedTheme = {};
|
|
110
108
|
walkObjectDeep(theme, (keys, value, arrayKeys) => {
|
|
111
109
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
112
110
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
@@ -118,13 +116,11 @@ export default function cssVarsParser(theme, options) {
|
|
|
118
116
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
|
-
assignNestedKeys(parsedTheme, keys, value, arrayKeys);
|
|
122
119
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
|
123
120
|
);
|
|
124
121
|
|
|
125
122
|
return {
|
|
126
123
|
css,
|
|
127
|
-
vars
|
|
128
|
-
parsedTheme
|
|
124
|
+
vars
|
|
129
125
|
};
|
|
130
126
|
}
|
package/esm/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export { default as sizing } from './sizing';
|
|
|
18
18
|
export * from './sizing';
|
|
19
19
|
export { default as spacing } from './spacing';
|
|
20
20
|
export * from './spacing';
|
|
21
|
-
export { default as style, getPath } from './style';
|
|
21
|
+
export { default as style, getPath, getStyleValue } from './style';
|
|
22
22
|
export { default as typography } from './typography';
|
|
23
23
|
export * from './typography';
|
|
24
24
|
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
@@ -40,6 +40,7 @@ export * from './colorManipulator';
|
|
|
40
40
|
export { default as ThemeProvider } from './ThemeProvider';
|
|
41
41
|
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
42
42
|
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
|
43
|
+
export { default as responsivePropType } from './responsivePropType';
|
|
43
44
|
|
|
44
45
|
/** ----------------- */
|
|
45
46
|
/** Layout components */
|
package/esm/style.js
CHANGED
|
@@ -20,7 +20,7 @@ export function getPath(obj, path, checkVars = true) {
|
|
|
20
20
|
return null;
|
|
21
21
|
}, obj);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
export function getStyleValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
|
|
24
24
|
let value;
|
|
25
25
|
if (typeof themeMapping === 'function') {
|
|
26
26
|
value = themeMapping(propValueFinal);
|
|
@@ -49,10 +49,10 @@ function style(options) {
|
|
|
49
49
|
const theme = props.theme;
|
|
50
50
|
const themeMapping = getPath(theme, themeKey) || {};
|
|
51
51
|
const styleFromPropValue = propValueFinal => {
|
|
52
|
-
let value =
|
|
52
|
+
let value = getStyleValue(themeMapping, transform, propValueFinal);
|
|
53
53
|
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
54
54
|
// Haven't found value
|
|
55
|
-
value =
|
|
55
|
+
value = getStyleValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
|
|
56
56
|
}
|
|
57
57
|
if (cssProperty === false) {
|
|
58
58
|
return value;
|
package/index.d.ts
CHANGED
|
@@ -165,6 +165,8 @@ export { default as unstable_createCssVarsProvider, CreateCssVarsProviderResult
|
|
|
165
165
|
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
|
166
166
|
export * from './cssVars';
|
|
167
167
|
|
|
168
|
+
export { default as responsivePropType } from './responsivePropType';
|
|
169
|
+
|
|
168
170
|
export { default as createContainer } from './Container/createContainer';
|
|
169
171
|
export * from './Container/createContainer';
|
|
170
172
|
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.10.
|
|
1
|
+
/** @license MUI v5.10.16
|
|
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.
|
|
@@ -30,6 +30,7 @@ var _exportNames = {
|
|
|
30
30
|
spacing: true,
|
|
31
31
|
style: true,
|
|
32
32
|
getPath: true,
|
|
33
|
+
getStyleValue: true,
|
|
33
34
|
typography: true,
|
|
34
35
|
unstable_styleFunctionSx: true,
|
|
35
36
|
unstable_createStyleFunctionSx: true,
|
|
@@ -51,6 +52,7 @@ var _exportNames = {
|
|
|
51
52
|
ThemeProvider: true,
|
|
52
53
|
unstable_createCssVarsProvider: true,
|
|
53
54
|
unstable_createGetCssVar: true,
|
|
55
|
+
responsivePropType: true,
|
|
54
56
|
createContainer: true,
|
|
55
57
|
Container: true,
|
|
56
58
|
Unstable_Grid: true,
|
|
@@ -182,6 +184,12 @@ Object.defineProperty(exports, "getPath", {
|
|
|
182
184
|
return _style.getPath;
|
|
183
185
|
}
|
|
184
186
|
});
|
|
187
|
+
Object.defineProperty(exports, "getStyleValue", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function () {
|
|
190
|
+
return _style.getStyleValue;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
185
193
|
Object.defineProperty(exports, "getThemeProps", {
|
|
186
194
|
enumerable: true,
|
|
187
195
|
get: function () {
|
|
@@ -224,6 +232,12 @@ Object.defineProperty(exports, "positions", {
|
|
|
224
232
|
return _positions.default;
|
|
225
233
|
}
|
|
226
234
|
});
|
|
235
|
+
Object.defineProperty(exports, "responsivePropType", {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function () {
|
|
238
|
+
return _responsivePropType.default;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
227
241
|
Object.defineProperty(exports, "shadows", {
|
|
228
242
|
enumerable: true,
|
|
229
243
|
get: function () {
|
|
@@ -468,6 +482,7 @@ Object.keys(_colorManipulator).forEach(function (key) {
|
|
|
468
482
|
var _ThemeProvider = _interopRequireDefault(require("./ThemeProvider"));
|
|
469
483
|
var _createCssVarsProvider = _interopRequireDefault(require("./cssVars/createCssVarsProvider"));
|
|
470
484
|
var _createGetCssVar = _interopRequireDefault(require("./cssVars/createGetCssVar"));
|
|
485
|
+
var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
|
|
471
486
|
var _createContainer = _interopRequireDefault(require("./Container/createContainer"));
|
|
472
487
|
var _Container = _interopRequireWildcard(require("./Container"));
|
|
473
488
|
Object.keys(_Container).forEach(function (key) {
|
|
@@ -125,9 +125,8 @@ export default function createCssVarsProvider(options) {
|
|
|
125
125
|
shouldSkipGeneratingVar: shouldSkipGeneratingVar
|
|
126
126
|
}),
|
|
127
127
|
rootCss = _cssVarsParser.css,
|
|
128
|
-
rootVars = _cssVarsParser.vars
|
|
129
|
-
|
|
130
|
-
var theme = _extends({}, parsedTheme, {
|
|
128
|
+
rootVars = _cssVarsParser.vars; // 3. Start composing the theme object
|
|
129
|
+
var theme = _extends({}, restThemeProp, {
|
|
131
130
|
components: components,
|
|
132
131
|
colorSchemes: colorSchemes,
|
|
133
132
|
cssVarPrefix: cssVarPrefix,
|
|
@@ -151,12 +150,18 @@ export default function createCssVarsProvider(options) {
|
|
|
151
150
|
shouldSkipGeneratingVar: shouldSkipGeneratingVar
|
|
152
151
|
}),
|
|
153
152
|
css = _cssVarsParser2.css,
|
|
154
|
-
vars = _cssVarsParser2.vars
|
|
155
|
-
parsedScheme = _cssVarsParser2.parsedTheme;
|
|
153
|
+
vars = _cssVarsParser2.vars;
|
|
156
154
|
theme.vars = deepmerge(theme.vars, vars);
|
|
157
155
|
if (key === calculatedColorScheme) {
|
|
158
156
|
// 4.1 Merge the selected color scheme to the theme
|
|
159
|
-
|
|
157
|
+
Object.keys(scheme).forEach(function (schemeKey) {
|
|
158
|
+
if (scheme[schemeKey] && _typeof(scheme[schemeKey]) === 'object') {
|
|
159
|
+
// shallow merge the 1st level structure of the theme.
|
|
160
|
+
theme[schemeKey] = _extends({}, theme[schemeKey], scheme[schemeKey]);
|
|
161
|
+
} else {
|
|
162
|
+
theme[schemeKey] = scheme[schemeKey];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
160
165
|
if (theme.palette) {
|
|
161
166
|
theme.palette.colorScheme = key;
|
|
162
167
|
}
|
|
@@ -99,10 +99,10 @@ var getCssValue = function getCssValue(keys, value) {
|
|
|
99
99
|
* }} options.
|
|
100
100
|
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
101
101
|
*
|
|
102
|
-
* @returns {{ css: Object, vars: Object
|
|
102
|
+
* @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
|
-
* const { css, vars
|
|
105
|
+
* const { css, vars } = parser({
|
|
106
106
|
* fontSize: 12,
|
|
107
107
|
* lineHeight: 1.2,
|
|
108
108
|
* palette: { primary: { 500: 'var(--color)' } }
|
|
@@ -110,7 +110,6 @@ var getCssValue = function getCssValue(keys, value) {
|
|
|
110
110
|
*
|
|
111
111
|
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
112
112
|
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
113
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
114
113
|
*/
|
|
115
114
|
export default function cssVarsParser(theme, options) {
|
|
116
115
|
var _ref3 = options || {},
|
|
@@ -118,7 +117,6 @@ export default function cssVarsParser(theme, options) {
|
|
|
118
117
|
shouldSkipGeneratingVar = _ref3.shouldSkipGeneratingVar;
|
|
119
118
|
var css = {};
|
|
120
119
|
var vars = {};
|
|
121
|
-
var parsedTheme = {};
|
|
122
120
|
walkObjectDeep(theme, function (keys, value, arrayKeys) {
|
|
123
121
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
124
122
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
@@ -128,7 +126,6 @@ export default function cssVarsParser(theme, options) {
|
|
|
128
126
|
assignNestedKeys(vars, keys, "var(".concat(cssVar, ")"), arrayKeys);
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
|
-
assignNestedKeys(parsedTheme, keys, value, arrayKeys);
|
|
132
129
|
}, function (keys) {
|
|
133
130
|
return keys[0] === 'vars';
|
|
134
131
|
} // skip 'vars/*' paths
|
|
@@ -136,7 +133,6 @@ export default function cssVarsParser(theme, options) {
|
|
|
136
133
|
|
|
137
134
|
return {
|
|
138
135
|
css: css,
|
|
139
|
-
vars: vars
|
|
140
|
-
parsedTheme: parsedTheme
|
|
136
|
+
vars: vars
|
|
141
137
|
};
|
|
142
138
|
}
|
package/legacy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.10.
|
|
1
|
+
/** @license MUI v5.10.16
|
|
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.
|
|
@@ -23,7 +23,7 @@ export { default as sizing } from './sizing';
|
|
|
23
23
|
export * from './sizing';
|
|
24
24
|
export { default as spacing } from './spacing';
|
|
25
25
|
export * from './spacing';
|
|
26
|
-
export { default as style, getPath } from './style';
|
|
26
|
+
export { default as style, getPath, getStyleValue } from './style';
|
|
27
27
|
export { default as typography } from './typography';
|
|
28
28
|
export * from './typography';
|
|
29
29
|
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
@@ -45,6 +45,7 @@ export * from './colorManipulator';
|
|
|
45
45
|
export { default as ThemeProvider } from './ThemeProvider';
|
|
46
46
|
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
47
47
|
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
|
48
|
+
export { default as responsivePropType } from './responsivePropType';
|
|
48
49
|
|
|
49
50
|
/** ----------------- */
|
|
50
51
|
/** Layout components */
|
package/legacy/style.js
CHANGED
|
@@ -24,7 +24,7 @@ export function getPath(obj, path) {
|
|
|
24
24
|
return null;
|
|
25
25
|
}, obj);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
export function getStyleValue(themeMapping, transform, propValueFinal) {
|
|
28
28
|
var userValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : propValueFinal;
|
|
29
29
|
var value;
|
|
30
30
|
if (typeof themeMapping === 'function') {
|
|
@@ -53,10 +53,10 @@ function style(options) {
|
|
|
53
53
|
var theme = props.theme;
|
|
54
54
|
var themeMapping = getPath(theme, themeKey) || {};
|
|
55
55
|
var styleFromPropValue = function styleFromPropValue(propValueFinal) {
|
|
56
|
-
var value =
|
|
56
|
+
var value = getStyleValue(themeMapping, transform, propValueFinal);
|
|
57
57
|
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
58
58
|
// Haven't found value
|
|
59
|
-
value =
|
|
59
|
+
value = getStyleValue(themeMapping, transform, "".concat(prop).concat(propValueFinal === 'default' ? '' : capitalize(propValueFinal)), propValueFinal);
|
|
60
60
|
}
|
|
61
61
|
if (cssProperty === false) {
|
|
62
62
|
return value;
|
|
@@ -106,15 +106,14 @@ export default function createCssVarsProvider(options) {
|
|
|
106
106
|
// 2. Create CSS variables and store them in objects (to be generated in stylesheets in the final step)
|
|
107
107
|
const {
|
|
108
108
|
css: rootCss,
|
|
109
|
-
vars: rootVars
|
|
110
|
-
parsedTheme
|
|
109
|
+
vars: rootVars
|
|
111
110
|
} = cssVarsParser(restThemeProp, {
|
|
112
111
|
prefix: cssVarPrefix,
|
|
113
112
|
shouldSkipGeneratingVar
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
// 3. Start composing the theme object
|
|
117
|
-
|
|
116
|
+
const theme = _extends({}, restThemeProp, {
|
|
118
117
|
components,
|
|
119
118
|
colorSchemes,
|
|
120
119
|
cssVarPrefix,
|
|
@@ -130,8 +129,7 @@ export default function createCssVarsProvider(options) {
|
|
|
130
129
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
131
130
|
const {
|
|
132
131
|
css,
|
|
133
|
-
vars
|
|
134
|
-
parsedTheme: parsedScheme
|
|
132
|
+
vars
|
|
135
133
|
} = cssVarsParser(scheme, {
|
|
136
134
|
prefix: cssVarPrefix,
|
|
137
135
|
shouldSkipGeneratingVar
|
|
@@ -139,7 +137,14 @@ export default function createCssVarsProvider(options) {
|
|
|
139
137
|
theme.vars = deepmerge(theme.vars, vars);
|
|
140
138
|
if (key === calculatedColorScheme) {
|
|
141
139
|
// 4.1 Merge the selected color scheme to the theme
|
|
142
|
-
|
|
140
|
+
Object.keys(scheme).forEach(schemeKey => {
|
|
141
|
+
if (scheme[schemeKey] && typeof scheme[schemeKey] === 'object') {
|
|
142
|
+
// shallow merge the 1st level structure of the theme.
|
|
143
|
+
theme[schemeKey] = _extends({}, theme[schemeKey], scheme[schemeKey]);
|
|
144
|
+
} else {
|
|
145
|
+
theme[schemeKey] = scheme[schemeKey];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
143
148
|
if (theme.palette) {
|
|
144
149
|
theme.palette.colorScheme = key;
|
|
145
150
|
}
|
|
@@ -86,10 +86,10 @@ const getCssValue = (keys, value) => {
|
|
|
86
86
|
* }} options.
|
|
87
87
|
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
88
88
|
*
|
|
89
|
-
* @returns {{ css: Object, vars: Object
|
|
89
|
+
* @returns {{ css: Object, vars: Object }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
90
90
|
*
|
|
91
91
|
* @example
|
|
92
|
-
* const { css, vars
|
|
92
|
+
* const { css, vars } = parser({
|
|
93
93
|
* fontSize: 12,
|
|
94
94
|
* lineHeight: 1.2,
|
|
95
95
|
* palette: { primary: { 500: 'var(--color)' } }
|
|
@@ -97,7 +97,6 @@ const getCssValue = (keys, value) => {
|
|
|
97
97
|
*
|
|
98
98
|
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
99
99
|
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
100
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
101
100
|
*/
|
|
102
101
|
export default function cssVarsParser(theme, options) {
|
|
103
102
|
const {
|
|
@@ -106,7 +105,6 @@ export default function cssVarsParser(theme, options) {
|
|
|
106
105
|
} = options || {};
|
|
107
106
|
const css = {};
|
|
108
107
|
const vars = {};
|
|
109
|
-
const parsedTheme = {};
|
|
110
108
|
walkObjectDeep(theme, (keys, value, arrayKeys) => {
|
|
111
109
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
112
110
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
@@ -118,13 +116,11 @@ export default function cssVarsParser(theme, options) {
|
|
|
118
116
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
|
-
assignNestedKeys(parsedTheme, keys, value, arrayKeys);
|
|
122
119
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
|
123
120
|
);
|
|
124
121
|
|
|
125
122
|
return {
|
|
126
123
|
css,
|
|
127
|
-
vars
|
|
128
|
-
parsedTheme
|
|
124
|
+
vars
|
|
129
125
|
};
|
|
130
126
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.10.
|
|
1
|
+
/** @license MUI v5.10.16
|
|
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.
|
|
@@ -23,7 +23,7 @@ export { default as sizing } from './sizing';
|
|
|
23
23
|
export * from './sizing';
|
|
24
24
|
export { default as spacing } from './spacing';
|
|
25
25
|
export * from './spacing';
|
|
26
|
-
export { default as style, getPath } from './style';
|
|
26
|
+
export { default as style, getPath, getStyleValue } from './style';
|
|
27
27
|
export { default as typography } from './typography';
|
|
28
28
|
export * from './typography';
|
|
29
29
|
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp } from './styleFunctionSx';
|
|
@@ -45,6 +45,7 @@ export * from './colorManipulator';
|
|
|
45
45
|
export { default as ThemeProvider } from './ThemeProvider';
|
|
46
46
|
export { default as unstable_createCssVarsProvider } from './cssVars/createCssVarsProvider';
|
|
47
47
|
export { default as unstable_createGetCssVar } from './cssVars/createGetCssVar';
|
|
48
|
+
export { default as responsivePropType } from './responsivePropType';
|
|
48
49
|
|
|
49
50
|
/** ----------------- */
|
|
50
51
|
/** Layout components */
|
package/modern/style.js
CHANGED
|
@@ -20,7 +20,7 @@ export function getPath(obj, path, checkVars = true) {
|
|
|
20
20
|
return null;
|
|
21
21
|
}, obj);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
export function getStyleValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
|
|
24
24
|
let value;
|
|
25
25
|
if (typeof themeMapping === 'function') {
|
|
26
26
|
value = themeMapping(propValueFinal);
|
|
@@ -49,10 +49,10 @@ function style(options) {
|
|
|
49
49
|
const theme = props.theme;
|
|
50
50
|
const themeMapping = getPath(theme, themeKey) || {};
|
|
51
51
|
const styleFromPropValue = propValueFinal => {
|
|
52
|
-
let value =
|
|
52
|
+
let value = getStyleValue(themeMapping, transform, propValueFinal);
|
|
53
53
|
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
54
54
|
// Haven't found value
|
|
55
|
-
value =
|
|
55
|
+
value = getStyleValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
|
|
56
56
|
}
|
|
57
57
|
if (cssProperty === false) {
|
|
58
58
|
return value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.20.1",
|
|
47
|
-
"@mui/private-theming": "^5.10.
|
|
48
|
-
"@mui/styled-engine": "^5.10.
|
|
49
|
-
"@mui/types": "^7.2.
|
|
50
|
-
"@mui/utils": "^5.10.
|
|
47
|
+
"@mui/private-theming": "^5.10.16",
|
|
48
|
+
"@mui/styled-engine": "^5.10.16",
|
|
49
|
+
"@mui/types": "^7.2.2",
|
|
50
|
+
"@mui/utils": "^5.10.16",
|
|
51
51
|
"clsx": "^1.2.1",
|
|
52
52
|
"csstype": "^3.1.1",
|
|
53
53
|
"prop-types": "^15.8.1"
|
package/spacing.d.ts
CHANGED
|
@@ -10,6 +10,20 @@ export function createUnarySpacing<Spacing>(theme: { spacing: Spacing }): Spacin
|
|
|
10
10
|
: // warns in Dev
|
|
11
11
|
() => undefined;
|
|
12
12
|
|
|
13
|
+
export function createUnaryUnit<Spacing>(
|
|
14
|
+
theme: { spacing: Spacing },
|
|
15
|
+
themeKey: string,
|
|
16
|
+
defaultValue: Spacing,
|
|
17
|
+
propName: string,
|
|
18
|
+
): Spacing extends number
|
|
19
|
+
? (abs: number | string) => number | number
|
|
20
|
+
: Spacing extends any[]
|
|
21
|
+
? <Index extends number>(abs: Index | string) => Spacing[Index] | string
|
|
22
|
+
: Spacing extends (...args: unknown[]) => unknown
|
|
23
|
+
? Spacing
|
|
24
|
+
: // warns in Dev
|
|
25
|
+
() => undefined;
|
|
26
|
+
|
|
13
27
|
export const margin: SimpleStyleFunction<
|
|
14
28
|
| 'm'
|
|
15
29
|
| 'mt'
|
package/style.d.ts
CHANGED
|
@@ -17,3 +17,9 @@ export function style<PropKey extends string, Theme extends object>(
|
|
|
17
17
|
options: StyleOptions<PropKey>,
|
|
18
18
|
): StyleFunction<{ [K in PropKey]?: unknown } & { theme?: Theme }> & { filterProps: string[] };
|
|
19
19
|
export function getPath<T>(obj: T, path: string | undefined, checkVars?: boolean): null | unknown;
|
|
20
|
+
export function getStyleValue(
|
|
21
|
+
themeMapping: object | ((val: any) => any),
|
|
22
|
+
transform?: (val: any, userVal: any) => any,
|
|
23
|
+
propValueFinal?: any,
|
|
24
|
+
userValue?: any,
|
|
25
|
+
): any;
|
package/style.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
exports.getPath = getPath;
|
|
9
|
+
exports.getStyleValue = getStyleValue;
|
|
9
10
|
var _utils = require("@mui/utils");
|
|
10
11
|
var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
|
|
11
12
|
var _breakpoints = require("./breakpoints");
|
|
@@ -28,7 +29,7 @@ function getPath(obj, path, checkVars = true) {
|
|
|
28
29
|
return null;
|
|
29
30
|
}, obj);
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function getStyleValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
|
|
32
33
|
let value;
|
|
33
34
|
if (typeof themeMapping === 'function') {
|
|
34
35
|
value = themeMapping(propValueFinal);
|
|
@@ -57,10 +58,10 @@ function style(options) {
|
|
|
57
58
|
const theme = props.theme;
|
|
58
59
|
const themeMapping = getPath(theme, themeKey) || {};
|
|
59
60
|
const styleFromPropValue = propValueFinal => {
|
|
60
|
-
let value =
|
|
61
|
+
let value = getStyleValue(themeMapping, transform, propValueFinal);
|
|
61
62
|
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
62
63
|
// Haven't found value
|
|
63
|
-
value =
|
|
64
|
+
value = getStyleValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : (0, _utils.unstable_capitalize)(propValueFinal)}`, propValueFinal);
|
|
64
65
|
}
|
|
65
66
|
if (cssProperty === false) {
|
|
66
67
|
return value;
|