@mui/system 6.0.0-alpha.0 → 6.0.0-alpha.1
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 +129 -2
- package/createTheme/createSpacing.d.ts +2 -2
- package/createTheme/createSpacing.js +7 -8
- package/cssVars/createCssVarsProvider.js +3 -0
- package/cssVars/cssVarsParser.js +3 -2
- package/index.js +1 -1
- package/legacy/createTheme/createSpacing.js +3 -7
- package/legacy/cssVars/createCssVarsProvider.js +3 -0
- package/legacy/cssVars/cssVarsParser.js +3 -2
- package/legacy/index.js +1 -1
- package/legacy/spacing/spacing.js +24 -21
- package/modern/createTheme/createSpacing.js +7 -8
- package/modern/cssVars/createCssVarsProvider.js +3 -0
- package/modern/cssVars/cssVarsParser.js +3 -2
- package/modern/index.js +1 -1
- package/modern/spacing/spacing.js +24 -21
- package/node/createTheme/createSpacing.js +7 -8
- package/node/cssVars/createCssVarsProvider.js +3 -0
- package/node/cssVars/cssVarsParser.js +3 -2
- package/node/index.js +1 -1
- package/node/spacing/spacing.js +24 -21
- package/package.json +6 -6
- package/spacing/spacing.js +24 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,92 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## v6.0.0-alpha.1
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v6.0.0-alpha.0..next -->
|
|
6
|
+
|
|
7
|
+
_Apr 5, 2024_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 19 contributors who made this release possible. Here are some highlights ✨:
|
|
10
|
+
|
|
11
|
+
- 🔥 Converted 3 more Material UI components to use Pigment CSS. Current progress is 36%!
|
|
12
|
+
- 🚀 Added a spacing CSS variable to the Material UI and Joy UI themes.
|
|
13
|
+
- 💫 Added 3 redesigned free Material UI templates: [Sign-in](https://next.mui.com/material-ui/getting-started/templates/sign-in/), [Sign-in side](https://next.mui.com/material-ui/getting-started/templates/sign-in-side/), and [Sign-up](https://next.mui.com/material-ui/getting-started/templates/sign-up/).
|
|
14
|
+
|
|
15
|
+
### `@mui/material@6.0.0-alpha.1`
|
|
16
|
+
|
|
17
|
+
- [AppBar] Convert to support CSS extraction (#41247) @mnajdova
|
|
18
|
+
- [Badge] Deprecate components and componentsProps (#41655) @skmanoj322
|
|
19
|
+
- [Button] Convert to support CSS extraction (#41378) @siriwatknp
|
|
20
|
+
- [ButtonGroup] Convert to support CSS extraction (#41666) @zanivan
|
|
21
|
+
- [RadioGroup] Apply classnames (#41610) @ZeeshanTamboli
|
|
22
|
+
- [Slider] Move palette styles to the bottom (#41676) @siriwatknp
|
|
23
|
+
- Add the `spacing` theme token (#40224) @siriwatknp
|
|
24
|
+
|
|
25
|
+
### `@mui/system@6.0.0-alpha.1`
|
|
26
|
+
|
|
27
|
+
- Add the `spacing` theme token to be used in `theme.spacing()` (#40224) @siriwatknp
|
|
28
|
+
|
|
29
|
+
### `@mui/codemod@6.0.0-alpha.1`
|
|
30
|
+
|
|
31
|
+
- [codemod] Setup v6 codemod structure (#41668) @DiegoAndai
|
|
32
|
+
|
|
33
|
+
### `@mui/lab@6.0.0-alpha.1`
|
|
34
|
+
|
|
35
|
+
- [TabPanel] Add keepMounted prop to match Joy UI (#41651) @ppaskaris-plooto
|
|
36
|
+
|
|
37
|
+
### `@mui/joy@5.0.0-beta.34`
|
|
38
|
+
|
|
39
|
+
- Add `spacing` theme token (#40224) @siriwatknp
|
|
40
|
+
|
|
41
|
+
### `@pigment-css/react@0.0.5`
|
|
42
|
+
|
|
43
|
+
- Improve sx prop support (#41589) @brijeshb42
|
|
44
|
+
- Fix Emotion styled error (#41699) @siriwatknp
|
|
45
|
+
- Fix propTypes removal during eval stage (#41695) @brijeshb42
|
|
46
|
+
- Fix props forwarding (#41688) @siriwatknp
|
|
47
|
+
- Fix sx prop transformation on Box (#41705) @brijeshb42
|
|
48
|
+
|
|
49
|
+
### `@pigment-css/vite-plugin@0.0.5`
|
|
50
|
+
|
|
51
|
+
- Use constant filename for pigment styles (#41667) @brijeshb42
|
|
52
|
+
|
|
53
|
+
### `@pigment-css/nextjs-plugin@0.0.5`
|
|
54
|
+
|
|
55
|
+
- Add missing RTL implementation (#41751) @brijeshb42
|
|
56
|
+
|
|
57
|
+
### Docs
|
|
58
|
+
|
|
59
|
+
- [pigment-css] Update README.md installation to use the next tag (#41649) @mnajdova
|
|
60
|
+
- [pigment-css] Add "Building design system components" guide with Pigment CSS (#41635) @siriwatknp
|
|
61
|
+
- Continue migration of Base UI to sperate repository @oliviertassinari
|
|
62
|
+
- Stick to one way to write IE 11 @oliviertassinari
|
|
63
|
+
- Fix typo in CONTRIBUTING.md (#41670) @adriancuadrado
|
|
64
|
+
- Drop IE 11 official support (#41611) @iammminzzy
|
|
65
|
+
- [material-ui] Fix typo on the Accordion page (#41687) @connorshea
|
|
66
|
+
- [pigment-css] Add small edits on the README (#41646) @danilo-leal
|
|
67
|
+
- [pigment-css] Edit the example app's README files (#41639) @danilo-leal
|
|
68
|
+
|
|
69
|
+
### Core
|
|
70
|
+
|
|
71
|
+
- [code-infra] Move BrandingProvider/brandingTheme/InfoCard to @mui/docs (#41206) @Janpot
|
|
72
|
+
- [core] Automate cherry-pick of PRs from `next` -> `master` (#41741) @aarongarciah
|
|
73
|
+
- [core] Update the prettier script to use the next branch (#41637) @mnajdova
|
|
74
|
+
- [docs-infra] Skip loading source for non-editable modules (#41588) @bharatkashyap
|
|
75
|
+
- [docs-infra] Vale rule for M3 (#41737) @oliviertassinari
|
|
76
|
+
- [docs-infra] Allows to remove edit button (#41702) @alexfauquette
|
|
77
|
+
- [pigment-css][examples] Add example project with Remix (#41700) @brijeshb42
|
|
78
|
+
- [examples] Update MUI's packages to the next version (#41701) @mnajdova
|
|
79
|
+
- [material-ui] Refine the Sign-in and Sign-up templates (#41192) @zanivan
|
|
80
|
+
- [test] Add test to display options provided to the options prop even if loading is true. (#41675) @ZeeshanTamboli
|
|
81
|
+
- [blog] Refresh the design slightly (#41697) @danilo-leal
|
|
82
|
+
- [website] Use en-US over en-UK for career link @oliviertassinari
|
|
83
|
+
- [website] Add Aarón to About Us (#41736) @aarongarciah
|
|
84
|
+
- [website] Refine button design and other details (#41686) @danilo-leal
|
|
85
|
+
- [website] Improve job og image (#41672) @oliviertassinari
|
|
86
|
+
- [website] Page <title> should have no dots @oliviertassinari
|
|
87
|
+
|
|
88
|
+
All contributors of this release in alphabetical order: @aarongarciah, @adriancuadrado, @alexfauquette, @bharatkashyap, @brijeshb42, @connorshea, @danilo-leal, @DiegoAndai, @iammminzzy, @Janpot, @JCQuintas, @levigunz, @mnajdova, @oliviertassinari, @ppaskaris-plooto, @siriwatknp, @skmanoj322, @zanivan, @ZeeshanTamboli
|
|
89
|
+
|
|
3
90
|
## v6.0.0-alpha.0
|
|
4
91
|
|
|
5
92
|
<!-- generated comparing v5.15.14..next -->
|
|
@@ -79,6 +166,46 @@ A big thanks to the 18 contributors who made this release possible. Here are som
|
|
|
79
166
|
|
|
80
167
|
All contributors of this release in alphabetical order: @aacevski, @brijeshb42, @cherniavskii, @cipherlogs, @danilo-leal, @DiegoAndai, @harry-whorlow, @Janpot, @joserodolfofreitas, @michael-land, @michaldudak, @mnajdova, @nekoya, @sai6855, @siriwatknp, @StylesTrip, @zanivan, @ZeeshanTamboli
|
|
81
168
|
|
|
169
|
+
## v5.15.15
|
|
170
|
+
|
|
171
|
+
<!-- generated comparing v5.15.14..master -->
|
|
172
|
+
|
|
173
|
+
_Apr 4, 2024_
|
|
174
|
+
|
|
175
|
+
A big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
|
|
176
|
+
This release was mostly about 🐛 bug fixes and 📚 documentation improvements.
|
|
177
|
+
|
|
178
|
+
### `@mui/material@5.15.15`
|
|
179
|
+
|
|
180
|
+
- [Autocomplete] Display options provided to the `options` prop even if loading is true (#41677) @ZeeshanTamboli
|
|
181
|
+
- [RadioGroup] Apply classnames (#41681) @ZeeshanTamboli
|
|
182
|
+
|
|
183
|
+
### `@mui/system@5.15.15`
|
|
184
|
+
|
|
185
|
+
- Fix typo to avoid infinite recursion in function call (#41678) @ZeeshanTamboli
|
|
186
|
+
|
|
187
|
+
### Docs
|
|
188
|
+
|
|
189
|
+
- [material-ui][Slider] Remove `valueLabelFormat` from restricted values demo so that the tooltip thumb label displays the same as the value text (#41679) @ZeeshanTamboli
|
|
190
|
+
- [material-ui] Remove deleted page from the sidenav (#41594) @danilo-leal
|
|
191
|
+
- [material-ui] Fix typo in CSS theme variables customization (#41680) @ZeeshanTamboli
|
|
192
|
+
- Continue migration of Base UI to sperate repository @oliviertassinari
|
|
193
|
+
- Add notification for MUI X v7 blog post (#41587) (#41605) @cherniavskii
|
|
194
|
+
- Update the versions dropdown to show v6 (#41557) @mnajdova
|
|
195
|
+
|
|
196
|
+
### Core
|
|
197
|
+
|
|
198
|
+
- [blog] Link to Romain's blog post in MUI X v7 announcement post (#41641) @cherniavskii
|
|
199
|
+
- [blog] Blog post with MUI X v7.0.0 annoucement (#41563) (#41604) @cherniavskii
|
|
200
|
+
- [blog] Add post about remote (#41565) @danilo-leal
|
|
201
|
+
- [core] Continue rename of Toolpad @oliviertassinari
|
|
202
|
+
- [docs-infra] Add Toolpad product/category IDs to types (#41551) @bharatkashyap
|
|
203
|
+
- [website] Add Aarón to About Us (#41747) @aarongarciah
|
|
204
|
+
- [website] Add stray design adjustments throughout the site (#41642) @mnajdova
|
|
205
|
+
- [website] Update pricing table (#41606) @cherniavskii
|
|
206
|
+
|
|
207
|
+
All contributors of this release in alphabetical order: @aarongarciah, @bharatkashyap, @cherniavskii, @danilo-leal, @mnajdova, @oliviertassinari, @ZeeshanTamboli
|
|
208
|
+
|
|
82
209
|
## v5.15.14
|
|
83
210
|
|
|
84
211
|
<!-- generated comparing v5.15.13..master -->
|
|
@@ -893,7 +1020,7 @@ A big thanks to the 22 contributors who made this release possible. Here are som
|
|
|
893
1020
|
- [material-ui] Revise the Alert demo page (#34892) @samuelsycamore
|
|
894
1021
|
- [material-ui] Revise the Accordion page (#40284) @anle9650
|
|
895
1022
|
- [material-ui] Add docs for complementary Card components (#40346) @anle9650
|
|
896
|
-
- [material-ui] Add Material 3 components page (#40350) @DiegoAndai
|
|
1023
|
+
- [material-ui] Add Material Design 3 components page (#40350) @DiegoAndai
|
|
897
1024
|
- Fix strange italic style @oliviertassinari
|
|
898
1025
|
- Fix references to ESLint @oliviertassinari
|
|
899
1026
|
- Fix 301 redirections @oliviertassinari
|
|
@@ -13057,7 +13184,7 @@ Here are some highlights ✨:
|
|
|
13057
13184
|
|
|
13058
13185
|
1. `stable` (default, formerly `esm`) which targets a snapshot (on release) of `> 0.5%, last 2 versions, Firefox ESR, not dead, not IE 11"`
|
|
13059
13186
|
2. `node` (formerly default) which targets a snapshot (on release) of `maintained node versions`
|
|
13060
|
-
3. `legacy` (new) which is `stable` +
|
|
13187
|
+
3. `legacy` (new) which is `stable` + IE 11
|
|
13061
13188
|
4. `modern` (formerly `es`) which targets the last 1 version of evergreen browsers and active node (currently that is 14
|
|
13062
13189
|
|
|
13063
13190
|
The change yields a 6% reduction in bundle size 📦 (Babel only).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
1
|
+
export type SpacingOptions = number | string | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
2
|
export type SpacingArgument = number | string;
|
|
3
3
|
export interface Spacing {
|
|
4
4
|
(): string;
|
|
@@ -7,4 +7,4 @@ export interface Spacing {
|
|
|
7
7
|
(top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
|
|
8
8
|
(top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
|
|
9
9
|
}
|
|
10
|
-
export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
|
|
10
|
+
export default function createSpacing(spacingInput?: SpacingOptions, transform?: Spacing | (() => undefined) | ((abs: string | number) => number)): Spacing;
|
|
@@ -3,18 +3,17 @@ import { createUnarySpacing } from '../spacing';
|
|
|
3
3
|
// The different signatures imply different meaning for their arguments that can't be expressed structurally.
|
|
4
4
|
// We express the difference with variable names.
|
|
5
5
|
|
|
6
|
-
export default function createSpacing(spacingInput = 8
|
|
6
|
+
export default function createSpacing(spacingInput = 8,
|
|
7
|
+
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
8
|
+
// Smaller components, such as icons, can align to a 4dp grid.
|
|
9
|
+
// https://m2.material.io/design/layout/understanding-layout.html
|
|
10
|
+
transform = createUnarySpacing({
|
|
11
|
+
spacing: spacingInput
|
|
12
|
+
})) {
|
|
7
13
|
// Already transformed.
|
|
8
14
|
if (spacingInput.mui) {
|
|
9
15
|
return spacingInput;
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
13
|
-
// Smaller components, such as icons, can align to a 4dp grid.
|
|
14
|
-
// https://m2.material.io/design/layout/understanding-layout.html
|
|
15
|
-
const transform = createUnarySpacing({
|
|
16
|
-
spacing: spacingInput
|
|
17
|
-
});
|
|
18
17
|
const spacing = (...argsInput) => {
|
|
19
18
|
if (process.env.NODE_ENV !== 'production') {
|
|
20
19
|
if (!(argsInput.length <= 4)) {
|
|
@@ -132,6 +132,9 @@ export default function createCssVarsProvider(options) {
|
|
|
132
132
|
cssVarPrefix,
|
|
133
133
|
vars: themeVars
|
|
134
134
|
});
|
|
135
|
+
if (typeof theme.generateSpacing === 'function') {
|
|
136
|
+
theme.spacing = theme.generateSpacing();
|
|
137
|
+
}
|
|
135
138
|
|
|
136
139
|
// 4. Resolve the color scheme and merge it to the theme
|
|
137
140
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
package/cssVars/cssVarsParser.js
CHANGED
|
@@ -111,11 +111,12 @@ export default function cssVarsParser(theme, options) {
|
|
|
111
111
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
112
112
|
// only create css & var if `shouldSkipGeneratingVar` return false
|
|
113
113
|
const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;
|
|
114
|
+
const resolvedValue = getCssValue(keys, value);
|
|
114
115
|
Object.assign(css, {
|
|
115
|
-
[cssVar]:
|
|
116
|
+
[cssVar]: resolvedValue
|
|
116
117
|
});
|
|
117
118
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
118
|
-
assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${
|
|
119
|
+
assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${resolvedValue})`, arrayKeys);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
package/index.js
CHANGED
|
@@ -5,17 +5,13 @@ import { createUnarySpacing } from '../spacing';
|
|
|
5
5
|
|
|
6
6
|
export default function createSpacing() {
|
|
7
7
|
var spacingInput = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
|
|
8
|
+
var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createUnarySpacing({
|
|
9
|
+
spacing: spacingInput
|
|
10
|
+
});
|
|
8
11
|
// Already transformed.
|
|
9
12
|
if (spacingInput.mui) {
|
|
10
13
|
return spacingInput;
|
|
11
14
|
}
|
|
12
|
-
|
|
13
|
-
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
14
|
-
// Smaller components, such as icons, can align to a 4dp grid.
|
|
15
|
-
// https://m2.material.io/design/layout/understanding-layout.html
|
|
16
|
-
var transform = createUnarySpacing({
|
|
17
|
-
spacing: spacingInput
|
|
18
|
-
});
|
|
19
15
|
var spacing = function spacing() {
|
|
20
16
|
for (var _len = arguments.length, argsInput = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
21
17
|
argsInput[_key] = arguments[_key];
|
|
@@ -142,6 +142,9 @@ export default function createCssVarsProvider(options) {
|
|
|
142
142
|
cssVarPrefix: cssVarPrefix,
|
|
143
143
|
vars: themeVars
|
|
144
144
|
});
|
|
145
|
+
if (typeof theme.generateSpacing === 'function') {
|
|
146
|
+
theme.spacing = theme.generateSpacing();
|
|
147
|
+
}
|
|
145
148
|
|
|
146
149
|
// 4. Resolve the color scheme and merge it to the theme
|
|
147
150
|
Object.entries(colorSchemes).forEach(function (_ref2) {
|
|
@@ -123,9 +123,10 @@ export default function cssVarsParser(theme, options) {
|
|
|
123
123
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
124
124
|
// only create css & var if `shouldSkipGeneratingVar` return false
|
|
125
125
|
var cssVar = "--".concat(prefix ? "".concat(prefix, "-") : '').concat(keys.join('-'));
|
|
126
|
-
|
|
126
|
+
var resolvedValue = getCssValue(keys, value);
|
|
127
|
+
_extends(css, _defineProperty({}, cssVar, resolvedValue));
|
|
127
128
|
assignNestedKeys(vars, keys, "var(".concat(cssVar, ")"), arrayKeys);
|
|
128
|
-
assignNestedKeys(varsWithDefaults, keys, "var(".concat(cssVar, ", ").concat(
|
|
129
|
+
assignNestedKeys(varsWithDefaults, keys, "var(".concat(cssVar, ", ").concat(resolvedValue, ")"), arrayKeys);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
}, function (keys) {
|
package/legacy/index.js
CHANGED
|
@@ -50,25 +50,29 @@ export var paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'p
|
|
|
50
50
|
var spacingKeys = [].concat(marginKeys, paddingKeys);
|
|
51
51
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
52
52
|
var _getPath;
|
|
53
|
-
var themeSpacing = (_getPath = getPath(theme, themeKey,
|
|
54
|
-
if (typeof themeSpacing === 'number') {
|
|
55
|
-
return function (
|
|
56
|
-
if (typeof
|
|
57
|
-
return
|
|
53
|
+
var themeSpacing = (_getPath = getPath(theme, themeKey, true)) != null ? _getPath : defaultValue;
|
|
54
|
+
if (typeof themeSpacing === 'number' || typeof themeSpacing === 'string') {
|
|
55
|
+
return function (val) {
|
|
56
|
+
if (typeof val === 'string') {
|
|
57
|
+
return val;
|
|
58
58
|
}
|
|
59
59
|
if (process.env.NODE_ENV !== 'production') {
|
|
60
|
-
if (typeof
|
|
61
|
-
console.error("MUI: Expected ".concat(propName, " argument to be a number or a string, got ").concat(
|
|
60
|
+
if (typeof val !== 'number') {
|
|
61
|
+
console.error("MUI: Expected ".concat(propName, " argument to be a number or a string, got ").concat(val, "."));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
if (typeof themeSpacing === 'string') {
|
|
65
|
+
return "calc(".concat(val, " * ").concat(themeSpacing, ")");
|
|
66
|
+
}
|
|
67
|
+
return themeSpacing * val;
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
if (Array.isArray(themeSpacing)) {
|
|
68
|
-
return function (
|
|
69
|
-
if (typeof
|
|
70
|
-
return
|
|
71
|
+
return function (val) {
|
|
72
|
+
if (typeof val === 'string') {
|
|
73
|
+
return val;
|
|
71
74
|
}
|
|
75
|
+
var abs = Math.abs(val);
|
|
72
76
|
if (process.env.NODE_ENV !== 'production') {
|
|
73
77
|
if (!Number.isInteger(abs)) {
|
|
74
78
|
console.error(["MUI: The `theme.".concat(themeKey, "` array type cannot be combined with non integer values.") + "You should either use an integer value that can be used as index, or define the `theme.".concat(themeKey, "` as a number.")].join('\n'));
|
|
@@ -76,7 +80,14 @@ export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
|
76
80
|
console.error(["MUI: The value provided (".concat(abs, ") overflows."), "The supported values are: ".concat(JSON.stringify(themeSpacing), "."), "".concat(abs, " > ").concat(themeSpacing.length - 1, ", you need to add the missing values.")].join('\n'));
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
|
-
|
|
83
|
+
var transformed = themeSpacing[abs];
|
|
84
|
+
if (val >= 0) {
|
|
85
|
+
return transformed;
|
|
86
|
+
}
|
|
87
|
+
if (typeof transformed === 'number') {
|
|
88
|
+
return -transformed;
|
|
89
|
+
}
|
|
90
|
+
return "-".concat(transformed);
|
|
80
91
|
};
|
|
81
92
|
}
|
|
82
93
|
if (typeof themeSpacing === 'function') {
|
|
@@ -96,15 +107,7 @@ export function getValue(transformer, propValue) {
|
|
|
96
107
|
if (typeof propValue === 'string' || propValue == null) {
|
|
97
108
|
return propValue;
|
|
98
109
|
}
|
|
99
|
-
|
|
100
|
-
var transformed = transformer(abs);
|
|
101
|
-
if (propValue >= 0) {
|
|
102
|
-
return transformed;
|
|
103
|
-
}
|
|
104
|
-
if (typeof transformed === 'number') {
|
|
105
|
-
return -transformed;
|
|
106
|
-
}
|
|
107
|
-
return "-".concat(transformed);
|
|
110
|
+
return transformer(propValue);
|
|
108
111
|
}
|
|
109
112
|
export function getStyleFromPropValue(cssProperties, transformer) {
|
|
110
113
|
return function (propValue) {
|
|
@@ -3,18 +3,17 @@ import { createUnarySpacing } from '../spacing';
|
|
|
3
3
|
// The different signatures imply different meaning for their arguments that can't be expressed structurally.
|
|
4
4
|
// We express the difference with variable names.
|
|
5
5
|
|
|
6
|
-
export default function createSpacing(spacingInput = 8
|
|
6
|
+
export default function createSpacing(spacingInput = 8,
|
|
7
|
+
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
8
|
+
// Smaller components, such as icons, can align to a 4dp grid.
|
|
9
|
+
// https://m2.material.io/design/layout/understanding-layout.html
|
|
10
|
+
transform = createUnarySpacing({
|
|
11
|
+
spacing: spacingInput
|
|
12
|
+
})) {
|
|
7
13
|
// Already transformed.
|
|
8
14
|
if (spacingInput.mui) {
|
|
9
15
|
return spacingInput;
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
13
|
-
// Smaller components, such as icons, can align to a 4dp grid.
|
|
14
|
-
// https://m2.material.io/design/layout/understanding-layout.html
|
|
15
|
-
const transform = createUnarySpacing({
|
|
16
|
-
spacing: spacingInput
|
|
17
|
-
});
|
|
18
17
|
const spacing = (...argsInput) => {
|
|
19
18
|
if (process.env.NODE_ENV !== 'production') {
|
|
20
19
|
if (!(argsInput.length <= 4)) {
|
|
@@ -132,6 +132,9 @@ export default function createCssVarsProvider(options) {
|
|
|
132
132
|
cssVarPrefix,
|
|
133
133
|
vars: themeVars
|
|
134
134
|
});
|
|
135
|
+
if (typeof theme.generateSpacing === 'function') {
|
|
136
|
+
theme.spacing = theme.generateSpacing();
|
|
137
|
+
}
|
|
135
138
|
|
|
136
139
|
// 4. Resolve the color scheme and merge it to the theme
|
|
137
140
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
@@ -111,11 +111,12 @@ export default function cssVarsParser(theme, options) {
|
|
|
111
111
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
112
112
|
// only create css & var if `shouldSkipGeneratingVar` return false
|
|
113
113
|
const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;
|
|
114
|
+
const resolvedValue = getCssValue(keys, value);
|
|
114
115
|
Object.assign(css, {
|
|
115
|
-
[cssVar]:
|
|
116
|
+
[cssVar]: resolvedValue
|
|
116
117
|
});
|
|
117
118
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
118
|
-
assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${
|
|
119
|
+
assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${resolvedValue})`, arrayKeys);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
package/modern/index.js
CHANGED
|
@@ -43,25 +43,29 @@ export const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'm
|
|
|
43
43
|
export const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
44
44
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
45
45
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
46
|
-
const themeSpacing = getPath(theme, themeKey,
|
|
47
|
-
if (typeof themeSpacing === 'number') {
|
|
48
|
-
return
|
|
49
|
-
if (typeof
|
|
50
|
-
return
|
|
46
|
+
const themeSpacing = getPath(theme, themeKey, true) ?? defaultValue;
|
|
47
|
+
if (typeof themeSpacing === 'number' || typeof themeSpacing === 'string') {
|
|
48
|
+
return val => {
|
|
49
|
+
if (typeof val === 'string') {
|
|
50
|
+
return val;
|
|
51
51
|
}
|
|
52
52
|
if (process.env.NODE_ENV !== 'production') {
|
|
53
|
-
if (typeof
|
|
54
|
-
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${
|
|
53
|
+
if (typeof val !== 'number') {
|
|
54
|
+
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${val}.`);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
if (typeof themeSpacing === 'string') {
|
|
58
|
+
return `calc(${val} * ${themeSpacing})`;
|
|
59
|
+
}
|
|
60
|
+
return themeSpacing * val;
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
if (Array.isArray(themeSpacing)) {
|
|
61
|
-
return
|
|
62
|
-
if (typeof
|
|
63
|
-
return
|
|
64
|
+
return val => {
|
|
65
|
+
if (typeof val === 'string') {
|
|
66
|
+
return val;
|
|
64
67
|
}
|
|
68
|
+
const abs = Math.abs(val);
|
|
65
69
|
if (process.env.NODE_ENV !== 'production') {
|
|
66
70
|
if (!Number.isInteger(abs)) {
|
|
67
71
|
console.error([`MUI: The \`theme.${themeKey}\` array type cannot be combined with non integer values.` + `You should either use an integer value that can be used as index, or define the \`theme.${themeKey}\` as a number.`].join('\n'));
|
|
@@ -69,7 +73,14 @@ export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
|
69
73
|
console.error([`MUI: The value provided (${abs}) overflows.`, `The supported values are: ${JSON.stringify(themeSpacing)}.`, `${abs} > ${themeSpacing.length - 1}, you need to add the missing values.`].join('\n'));
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
|
|
76
|
+
const transformed = themeSpacing[abs];
|
|
77
|
+
if (val >= 0) {
|
|
78
|
+
return transformed;
|
|
79
|
+
}
|
|
80
|
+
if (typeof transformed === 'number') {
|
|
81
|
+
return -transformed;
|
|
82
|
+
}
|
|
83
|
+
return `-${transformed}`;
|
|
73
84
|
};
|
|
74
85
|
}
|
|
75
86
|
if (typeof themeSpacing === 'function') {
|
|
@@ -87,15 +98,7 @@ export function getValue(transformer, propValue) {
|
|
|
87
98
|
if (typeof propValue === 'string' || propValue == null) {
|
|
88
99
|
return propValue;
|
|
89
100
|
}
|
|
90
|
-
|
|
91
|
-
const transformed = transformer(abs);
|
|
92
|
-
if (propValue >= 0) {
|
|
93
|
-
return transformed;
|
|
94
|
-
}
|
|
95
|
-
if (typeof transformed === 'number') {
|
|
96
|
-
return -transformed;
|
|
97
|
-
}
|
|
98
|
-
return `-${transformed}`;
|
|
101
|
+
return transformer(propValue);
|
|
99
102
|
}
|
|
100
103
|
export function getStyleFromPropValue(cssProperties, transformer) {
|
|
101
104
|
return propValue => cssProperties.reduce((acc, cssProperty) => {
|
|
@@ -8,18 +8,17 @@ var _spacing = require("../spacing");
|
|
|
8
8
|
// The different signatures imply different meaning for their arguments that can't be expressed structurally.
|
|
9
9
|
// We express the difference with variable names.
|
|
10
10
|
|
|
11
|
-
function createSpacing(spacingInput = 8
|
|
11
|
+
function createSpacing(spacingInput = 8,
|
|
12
|
+
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
13
|
+
// Smaller components, such as icons, can align to a 4dp grid.
|
|
14
|
+
// https://m2.material.io/design/layout/understanding-layout.html
|
|
15
|
+
transform = (0, _spacing.createUnarySpacing)({
|
|
16
|
+
spacing: spacingInput
|
|
17
|
+
})) {
|
|
12
18
|
// Already transformed.
|
|
13
19
|
if (spacingInput.mui) {
|
|
14
20
|
return spacingInput;
|
|
15
21
|
}
|
|
16
|
-
|
|
17
|
-
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
18
|
-
// Smaller components, such as icons, can align to a 4dp grid.
|
|
19
|
-
// https://m2.material.io/design/layout/understanding-layout.html
|
|
20
|
-
const transform = (0, _spacing.createUnarySpacing)({
|
|
21
|
-
spacing: spacingInput
|
|
22
|
-
});
|
|
23
22
|
const spacing = (...argsInput) => {
|
|
24
23
|
if (process.env.NODE_ENV !== 'production') {
|
|
25
24
|
if (!(argsInput.length <= 4)) {
|
|
@@ -143,6 +143,9 @@ function createCssVarsProvider(options) {
|
|
|
143
143
|
cssVarPrefix,
|
|
144
144
|
vars: themeVars
|
|
145
145
|
});
|
|
146
|
+
if (typeof theme.generateSpacing === 'function') {
|
|
147
|
+
theme.spacing = theme.generateSpacing();
|
|
148
|
+
}
|
|
146
149
|
|
|
147
150
|
// 4. Resolve the color scheme and merge it to the theme
|
|
148
151
|
Object.entries(colorSchemes).forEach(([key, scheme]) => {
|
|
@@ -121,11 +121,12 @@ function cssVarsParser(theme, options) {
|
|
|
121
121
|
if (!shouldSkipGeneratingVar || !shouldSkipGeneratingVar(keys, value)) {
|
|
122
122
|
// only create css & var if `shouldSkipGeneratingVar` return false
|
|
123
123
|
const cssVar = `--${prefix ? `${prefix}-` : ''}${keys.join('-')}`;
|
|
124
|
+
const resolvedValue = getCssValue(keys, value);
|
|
124
125
|
Object.assign(css, {
|
|
125
|
-
[cssVar]:
|
|
126
|
+
[cssVar]: resolvedValue
|
|
126
127
|
});
|
|
127
128
|
assignNestedKeys(vars, keys, `var(${cssVar})`, arrayKeys);
|
|
128
|
-
assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${
|
|
129
|
+
assignNestedKeys(varsWithDefaults, keys, `var(${cssVar}, ${resolvedValue})`, arrayKeys);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
}, keys => keys[0] === 'vars' // skip 'vars/*' paths
|
package/node/index.js
CHANGED
package/node/spacing/spacing.js
CHANGED
|
@@ -59,25 +59,29 @@ const paddingKeys = exports.paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'p
|
|
|
59
59
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
60
60
|
function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
61
61
|
var _getPath;
|
|
62
|
-
const themeSpacing = (_getPath = (0, _style.getPath)(theme, themeKey,
|
|
63
|
-
if (typeof themeSpacing === 'number') {
|
|
64
|
-
return
|
|
65
|
-
if (typeof
|
|
66
|
-
return
|
|
62
|
+
const themeSpacing = (_getPath = (0, _style.getPath)(theme, themeKey, true)) != null ? _getPath : defaultValue;
|
|
63
|
+
if (typeof themeSpacing === 'number' || typeof themeSpacing === 'string') {
|
|
64
|
+
return val => {
|
|
65
|
+
if (typeof val === 'string') {
|
|
66
|
+
return val;
|
|
67
67
|
}
|
|
68
68
|
if (process.env.NODE_ENV !== 'production') {
|
|
69
|
-
if (typeof
|
|
70
|
-
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${
|
|
69
|
+
if (typeof val !== 'number') {
|
|
70
|
+
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${val}.`);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
if (typeof themeSpacing === 'string') {
|
|
74
|
+
return `calc(${val} * ${themeSpacing})`;
|
|
75
|
+
}
|
|
76
|
+
return themeSpacing * val;
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
if (Array.isArray(themeSpacing)) {
|
|
77
|
-
return
|
|
78
|
-
if (typeof
|
|
79
|
-
return
|
|
80
|
+
return val => {
|
|
81
|
+
if (typeof val === 'string') {
|
|
82
|
+
return val;
|
|
80
83
|
}
|
|
84
|
+
const abs = Math.abs(val);
|
|
81
85
|
if (process.env.NODE_ENV !== 'production') {
|
|
82
86
|
if (!Number.isInteger(abs)) {
|
|
83
87
|
console.error([`MUI: The \`theme.${themeKey}\` array type cannot be combined with non integer values.` + `You should either use an integer value that can be used as index, or define the \`theme.${themeKey}\` as a number.`].join('\n'));
|
|
@@ -85,7 +89,14 @@ function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
|
85
89
|
console.error([`MUI: The value provided (${abs}) overflows.`, `The supported values are: ${JSON.stringify(themeSpacing)}.`, `${abs} > ${themeSpacing.length - 1}, you need to add the missing values.`].join('\n'));
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
|
-
|
|
92
|
+
const transformed = themeSpacing[abs];
|
|
93
|
+
if (val >= 0) {
|
|
94
|
+
return transformed;
|
|
95
|
+
}
|
|
96
|
+
if (typeof transformed === 'number') {
|
|
97
|
+
return -transformed;
|
|
98
|
+
}
|
|
99
|
+
return `-${transformed}`;
|
|
89
100
|
};
|
|
90
101
|
}
|
|
91
102
|
if (typeof themeSpacing === 'function') {
|
|
@@ -103,15 +114,7 @@ function getValue(transformer, propValue) {
|
|
|
103
114
|
if (typeof propValue === 'string' || propValue == null) {
|
|
104
115
|
return propValue;
|
|
105
116
|
}
|
|
106
|
-
|
|
107
|
-
const transformed = transformer(abs);
|
|
108
|
-
if (propValue >= 0) {
|
|
109
|
-
return transformed;
|
|
110
|
-
}
|
|
111
|
-
if (typeof transformed === 'number') {
|
|
112
|
-
return -transformed;
|
|
113
|
-
}
|
|
114
|
-
return `-${transformed}`;
|
|
117
|
+
return transformer(propValue);
|
|
115
118
|
}
|
|
116
119
|
function getStyleFromPropValue(cssProperties, transformer) {
|
|
117
120
|
return propValue => cssProperties.reduce((acc, cssProperty) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"url": "https://opencollective.com/mui-org"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "^7.
|
|
29
|
+
"@babel/runtime": "^7.24.4",
|
|
30
30
|
"clsx": "^2.1.0",
|
|
31
31
|
"csstype": "^3.1.3",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
33
|
-
"@mui/
|
|
34
|
-
"@mui/
|
|
35
|
-
"@mui/
|
|
36
|
-
"@mui/
|
|
33
|
+
"@mui/private-theming": "^6.0.0-alpha.1",
|
|
34
|
+
"@mui/styled-engine": "^6.0.0-alpha.1",
|
|
35
|
+
"@mui/utils": "^6.0.0-alpha.1",
|
|
36
|
+
"@mui/types": "^7.2.14"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@emotion/react": "^11.5.0",
|
package/spacing/spacing.js
CHANGED
|
@@ -43,25 +43,29 @@ export const marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'm
|
|
|
43
43
|
export const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
|
|
44
44
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
45
45
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
46
|
-
const themeSpacing = getPath(theme, themeKey,
|
|
47
|
-
if (typeof themeSpacing === 'number') {
|
|
48
|
-
return
|
|
49
|
-
if (typeof
|
|
50
|
-
return
|
|
46
|
+
const themeSpacing = getPath(theme, themeKey, true) ?? defaultValue;
|
|
47
|
+
if (typeof themeSpacing === 'number' || typeof themeSpacing === 'string') {
|
|
48
|
+
return val => {
|
|
49
|
+
if (typeof val === 'string') {
|
|
50
|
+
return val;
|
|
51
51
|
}
|
|
52
52
|
if (process.env.NODE_ENV !== 'production') {
|
|
53
|
-
if (typeof
|
|
54
|
-
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${
|
|
53
|
+
if (typeof val !== 'number') {
|
|
54
|
+
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${val}.`);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
if (typeof themeSpacing === 'string') {
|
|
58
|
+
return `calc(${val} * ${themeSpacing})`;
|
|
59
|
+
}
|
|
60
|
+
return themeSpacing * val;
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
63
|
if (Array.isArray(themeSpacing)) {
|
|
61
|
-
return
|
|
62
|
-
if (typeof
|
|
63
|
-
return
|
|
64
|
+
return val => {
|
|
65
|
+
if (typeof val === 'string') {
|
|
66
|
+
return val;
|
|
64
67
|
}
|
|
68
|
+
const abs = Math.abs(val);
|
|
65
69
|
if (process.env.NODE_ENV !== 'production') {
|
|
66
70
|
if (!Number.isInteger(abs)) {
|
|
67
71
|
console.error([`MUI: The \`theme.${themeKey}\` array type cannot be combined with non integer values.` + `You should either use an integer value that can be used as index, or define the \`theme.${themeKey}\` as a number.`].join('\n'));
|
|
@@ -69,7 +73,14 @@ export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
|
69
73
|
console.error([`MUI: The value provided (${abs}) overflows.`, `The supported values are: ${JSON.stringify(themeSpacing)}.`, `${abs} > ${themeSpacing.length - 1}, you need to add the missing values.`].join('\n'));
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
|
|
76
|
+
const transformed = themeSpacing[abs];
|
|
77
|
+
if (val >= 0) {
|
|
78
|
+
return transformed;
|
|
79
|
+
}
|
|
80
|
+
if (typeof transformed === 'number') {
|
|
81
|
+
return -transformed;
|
|
82
|
+
}
|
|
83
|
+
return `-${transformed}`;
|
|
73
84
|
};
|
|
74
85
|
}
|
|
75
86
|
if (typeof themeSpacing === 'function') {
|
|
@@ -87,15 +98,7 @@ export function getValue(transformer, propValue) {
|
|
|
87
98
|
if (typeof propValue === 'string' || propValue == null) {
|
|
88
99
|
return propValue;
|
|
89
100
|
}
|
|
90
|
-
|
|
91
|
-
const transformed = transformer(abs);
|
|
92
|
-
if (propValue >= 0) {
|
|
93
|
-
return transformed;
|
|
94
|
-
}
|
|
95
|
-
if (typeof transformed === 'number') {
|
|
96
|
-
return -transformed;
|
|
97
|
-
}
|
|
98
|
-
return `-${transformed}`;
|
|
101
|
+
return transformer(propValue);
|
|
99
102
|
}
|
|
100
103
|
export function getStyleFromPropValue(cssProperties, transformer) {
|
|
101
104
|
return propValue => cssProperties.reduce((acc, cssProperty) => {
|