@mui/system 5.10.13 → 5.10.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Box/Box.js +1 -10
- package/Box/Box.spec.d.ts +1 -1
- package/Box/index.js +0 -2
- package/CHANGELOG.md +70 -2
- package/Container/Container.d.ts +13 -13
- package/Container/Container.js +2 -17
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/containerClasses.js +0 -3
- package/Container/createContainer.d.ts +18 -18
- package/Container/createContainer.js +15 -37
- package/Container/index.js +0 -6
- package/Stack/Stack.d.ts +13 -13
- package/Stack/Stack.js +1 -12
- package/Stack/StackProps.d.ts +42 -42
- package/Stack/createStack.d.ts +21 -21
- package/Stack/createStack.js +10 -48
- package/Stack/index.d.ts +5 -5
- package/Stack/index.js +0 -9
- package/Stack/stackClasses.d.ts +8 -8
- package/Stack/stackClasses.js +0 -3
- package/ThemeProvider/ThemeProvider.js +2 -22
- package/ThemeProvider/index.js +0 -2
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/Grid.js +6 -42
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/createGrid.js +19 -49
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridClasses.js +8 -7
- package/Unstable_Grid/gridGenerator.d.ts +29 -28
- package/Unstable_Grid/gridGenerator.js +22 -63
- package/Unstable_Grid/index.d.ts +5 -5
- package/Unstable_Grid/index.js +0 -9
- package/borders.js +0 -14
- package/breakpoints.js +3 -32
- package/colorManipulator.js +13 -55
- package/compose.js +0 -7
- package/createBox.js +5 -20
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +27 -71
- package/createTheme/createBreakpoints.js +22 -37
- package/createTheme/createSpacing.d.ts +10 -10
- package/createTheme/createSpacing.js +4 -8
- package/createTheme/createTheme.js +6 -16
- package/createTheme/index.js +0 -2
- package/cssGrid.js +0 -21
- package/cssVars/createCssVarsProvider.js +24 -72
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/createGetCssVar.js +2 -7
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/cssVarsParser.js +3 -15
- package/cssVars/getInitColorSchemeScript.d.ts +42 -42
- package/cssVars/getInitColorSchemeScript.js +0 -6
- package/cssVars/index.d.ts +3 -3
- package/cssVars/index.js +0 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/cssVars/useCurrentColorScheme.js +20 -49
- package/display.js +0 -6
- package/esm/Box/Box.js +1 -6
- package/esm/Container/Container.js +3 -14
- package/esm/Container/createContainer.js +15 -25
- package/esm/Stack/Stack.js +1 -9
- package/esm/Stack/createStack.js +10 -29
- package/esm/ThemeProvider/ThemeProvider.js +2 -11
- package/esm/Unstable_Grid/Grid.js +6 -39
- package/esm/Unstable_Grid/createGrid.js +18 -35
- package/esm/Unstable_Grid/gridClasses.js +8 -4
- package/esm/Unstable_Grid/gridGenerator.js +20 -38
- package/esm/borders.js +0 -6
- package/esm/breakpoints.js +7 -22
- package/esm/colorManipulator.js +13 -43
- package/esm/compose.js +0 -5
- package/esm/createBox.js +5 -7
- package/esm/createStyled.js +27 -64
- package/esm/createTheme/createBreakpoints.js +22 -34
- package/esm/createTheme/createSpacing.js +4 -7
- package/esm/createTheme/createTheme.js +6 -9
- package/esm/cssGrid.js +0 -9
- package/esm/cssVars/createCssVarsProvider.js +24 -58
- package/esm/cssVars/createGetCssVar.js +2 -6
- package/esm/cssVars/cssVarsParser.js +3 -11
- package/esm/cssVars/useCurrentColorScheme.js +20 -44
- package/esm/getThemeValue.js +0 -2
- package/esm/index.js +1 -2
- package/esm/memoize.js +0 -1
- package/esm/merge.js +0 -3
- package/esm/palette.js +0 -3
- package/esm/propsToClassKey.js +4 -7
- package/esm/sizing.js +0 -5
- package/esm/spacing.js +3 -23
- package/esm/style.js +2 -19
- package/esm/styleFunctionSx/extendSxProp.js +3 -10
- package/esm/styleFunctionSx/styleFunctionSx.js +3 -16
- package/esm/sx/sx.js +0 -2
- package/esm/useTheme.js +0 -2
- package/esm/useThemeProps/getThemeProps.js +0 -2
- package/esm/useThemeWithoutDefault.js +0 -3
- package/flexbox.js +0 -4
- package/getThemeValue.js +0 -14
- package/index.js +1 -55
- package/index.spec.d.ts +1 -1
- package/legacy/Box/Box.js +1 -6
- package/legacy/Container/Container.js +3 -14
- package/legacy/Container/createContainer.js +29 -39
- package/legacy/Stack/Stack.js +1 -9
- package/legacy/Stack/createStack.js +17 -37
- package/legacy/ThemeProvider/ThemeProvider.js +3 -12
- package/legacy/Unstable_Grid/Grid.js +6 -39
- package/legacy/Unstable_Grid/createGrid.js +34 -53
- package/legacy/Unstable_Grid/gridGenerator.js +36 -58
- package/legacy/borders.js +0 -6
- package/legacy/breakpoints.js +9 -28
- package/legacy/colorManipulator.js +16 -48
- package/legacy/compose.js +0 -6
- package/legacy/createBox.js +9 -11
- package/legacy/createStyled.js +27 -68
- package/legacy/createTheme/createBreakpoints.js +20 -33
- package/legacy/createTheme/createSpacing.js +4 -9
- package/legacy/createTheme/createTheme.js +7 -13
- package/legacy/cssGrid.js +0 -9
- package/legacy/cssVars/createCssVarsProvider.js +90 -129
- package/legacy/cssVars/createGetCssVar.js +2 -10
- package/legacy/cssVars/cssVarsParser.js +7 -20
- package/legacy/cssVars/getInitColorSchemeScript.js +14 -15
- package/legacy/cssVars/useCurrentColorScheme.js +43 -69
- package/legacy/getThemeValue.js +0 -3
- package/legacy/index.js +2 -3
- package/legacy/memoize.js +0 -1
- package/legacy/merge.js +0 -3
- package/legacy/palette.js +0 -3
- package/legacy/propsToClassKey.js +2 -5
- package/legacy/sizing.js +0 -5
- package/legacy/spacing.js +6 -27
- package/legacy/style.js +6 -24
- package/legacy/styleFunctionSx/extendSxProp.js +3 -11
- package/legacy/styleFunctionSx/styleFunctionSx.js +6 -21
- package/legacy/sx/sx.js +0 -2
- package/legacy/useTheme.js +0 -2
- package/legacy/useThemeProps/getThemeProps.js +2 -4
- package/legacy/useThemeProps/useThemeProps.js +2 -2
- package/legacy/useThemeWithoutDefault.js +0 -3
- package/memoize.js +0 -2
- package/merge.js +0 -5
- package/modern/Box/Box.js +1 -6
- package/modern/Container/Container.js +3 -14
- package/modern/Container/createContainer.js +15 -25
- package/modern/Stack/Stack.js +1 -9
- package/modern/Stack/createStack.js +10 -29
- package/modern/ThemeProvider/ThemeProvider.js +2 -11
- package/modern/Unstable_Grid/Grid.js +6 -39
- package/modern/Unstable_Grid/createGrid.js +18 -34
- package/modern/Unstable_Grid/gridClasses.js +8 -4
- package/modern/Unstable_Grid/gridGenerator.js +20 -36
- package/modern/borders.js +0 -6
- package/modern/breakpoints.js +7 -21
- package/modern/colorManipulator.js +13 -43
- package/modern/compose.js +0 -5
- package/modern/createBox.js +5 -7
- package/modern/createStyled.js +27 -63
- package/modern/createTheme/createBreakpoints.js +22 -34
- package/modern/createTheme/createSpacing.js +4 -7
- package/modern/createTheme/createTheme.js +6 -9
- package/modern/cssGrid.js +0 -9
- package/modern/cssVars/createCssVarsProvider.js +24 -58
- package/modern/cssVars/createGetCssVar.js +2 -6
- package/modern/cssVars/cssVarsParser.js +3 -11
- package/modern/cssVars/useCurrentColorScheme.js +20 -44
- package/modern/getThemeValue.js +0 -2
- package/modern/index.js +2 -3
- package/modern/memoize.js +0 -1
- package/modern/merge.js +0 -3
- package/modern/palette.js +0 -3
- package/modern/propsToClassKey.js +4 -7
- package/modern/sizing.js +0 -4
- package/modern/spacing.js +3 -22
- package/modern/style.js +2 -19
- package/modern/styleFunctionSx/extendSxProp.js +3 -10
- package/modern/styleFunctionSx/styleFunctionSx.js +3 -16
- package/modern/sx/sx.js +0 -2
- package/modern/useTheme.js +0 -2
- package/modern/useThemeProps/getThemeProps.js +0 -2
- package/modern/useThemeWithoutDefault.js +0 -3
- package/package.json +6 -6
- package/palette.js +0 -6
- package/positions.js +0 -6
- package/propsToClassKey.js +4 -10
- package/responsivePropType.js +0 -3
- package/shadows.js +0 -3
- package/sizing.js +0 -11
- package/spacing.js +3 -37
- package/style.js +2 -24
- package/styleFunctionSx/extendSxProp.js +3 -15
- package/styleFunctionSx/index.js +0 -5
- package/styleFunctionSx/styleFunctionSx.js +3 -21
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
- package/styled.js +0 -3
- package/sx/index.js +0 -2
- package/sx/sx.js +0 -4
- package/typography.js +0 -4
- package/useTheme.js +0 -6
- package/useThemeProps/getThemeProps.js +0 -4
- package/useThemeProps/index.js +0 -3
- package/useThemeProps/useThemeProps.js +0 -4
- package/useThemeWithoutDefault.js +0 -4
package/esm/sizing.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import style from './style';
|
|
2
2
|
import compose from './compose';
|
|
3
3
|
import { handleBreakpoints, values as breakpointsValues } from './breakpoints';
|
|
4
|
-
|
|
5
4
|
function transform(value) {
|
|
6
5
|
return value <= 1 && value !== 0 ? `${value * 100}%` : value;
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
export const width = style({
|
|
10
8
|
prop: 'width',
|
|
11
9
|
transform
|
|
@@ -14,16 +12,13 @@ export const maxWidth = props => {
|
|
|
14
12
|
if (props.maxWidth !== undefined && props.maxWidth !== null) {
|
|
15
13
|
const styleFromPropValue = propValue => {
|
|
16
14
|
var _props$theme, _props$theme$breakpoi, _props$theme$breakpoi2;
|
|
17
|
-
|
|
18
15
|
const breakpoint = ((_props$theme = props.theme) == null ? void 0 : (_props$theme$breakpoi = _props$theme.breakpoints) == null ? void 0 : (_props$theme$breakpoi2 = _props$theme$breakpoi.values) == null ? void 0 : _props$theme$breakpoi2[propValue]) || breakpointsValues[propValue];
|
|
19
16
|
return {
|
|
20
17
|
maxWidth: breakpoint || transform(propValue)
|
|
21
18
|
};
|
|
22
19
|
};
|
|
23
|
-
|
|
24
20
|
return handleBreakpoints(props, props.maxWidth, styleFromPropValue);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
return null;
|
|
28
23
|
};
|
|
29
24
|
maxWidth.filterProps = ['maxWidth'];
|
package/esm/spacing.js
CHANGED
|
@@ -20,10 +20,11 @@ const aliases = {
|
|
|
20
20
|
marginY: 'my',
|
|
21
21
|
paddingX: 'px',
|
|
22
22
|
paddingY: 'py'
|
|
23
|
-
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// memoize() impact:
|
|
24
26
|
// From 300,000 ops/sec
|
|
25
27
|
// To 350,000 ops/sec
|
|
26
|
-
|
|
27
28
|
const getCssProperties = memoize(prop => {
|
|
28
29
|
// It's not a shorthand notation.
|
|
29
30
|
if (prop.length > 2) {
|
|
@@ -33,7 +34,6 @@ const getCssProperties = memoize(prop => {
|
|
|
33
34
|
return [prop];
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
|
|
37
37
|
const [a, b] = prop.split('');
|
|
38
38
|
const property = properties[a];
|
|
39
39
|
const direction = directions[b] || '';
|
|
@@ -44,31 +44,25 @@ const paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddin
|
|
|
44
44
|
const spacingKeys = [...marginKeys, ...paddingKeys];
|
|
45
45
|
export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
46
46
|
var _getPath;
|
|
47
|
-
|
|
48
47
|
const themeSpacing = (_getPath = getPath(theme, themeKey, false)) != null ? _getPath : defaultValue;
|
|
49
|
-
|
|
50
48
|
if (typeof themeSpacing === 'number') {
|
|
51
49
|
return abs => {
|
|
52
50
|
if (typeof abs === 'string') {
|
|
53
51
|
return abs;
|
|
54
52
|
}
|
|
55
|
-
|
|
56
53
|
if (process.env.NODE_ENV !== 'production') {
|
|
57
54
|
if (typeof abs !== 'number') {
|
|
58
55
|
console.error(`MUI: Expected ${propName} argument to be a number or a string, got ${abs}.`);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
|
-
|
|
62
58
|
return themeSpacing * abs;
|
|
63
59
|
};
|
|
64
60
|
}
|
|
65
|
-
|
|
66
61
|
if (Array.isArray(themeSpacing)) {
|
|
67
62
|
return abs => {
|
|
68
63
|
if (typeof abs === 'string') {
|
|
69
64
|
return abs;
|
|
70
65
|
}
|
|
71
|
-
|
|
72
66
|
if (process.env.NODE_ENV !== 'production') {
|
|
73
67
|
if (!Number.isInteger(abs)) {
|
|
74
68
|
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'));
|
|
@@ -76,19 +70,15 @@ export function createUnaryUnit(theme, themeKey, defaultValue, propName) {
|
|
|
76
70
|
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'));
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
|
-
|
|
80
73
|
return themeSpacing[abs];
|
|
81
74
|
};
|
|
82
75
|
}
|
|
83
|
-
|
|
84
76
|
if (typeof themeSpacing === 'function') {
|
|
85
77
|
return themeSpacing;
|
|
86
78
|
}
|
|
87
|
-
|
|
88
79
|
if (process.env.NODE_ENV !== 'production') {
|
|
89
80
|
console.error([`MUI: The \`theme.${themeKey}\` value (${themeSpacing}) is invalid.`, 'It should be a number, an array or a function.'].join('\n'));
|
|
90
81
|
}
|
|
91
|
-
|
|
92
82
|
return () => undefined;
|
|
93
83
|
}
|
|
94
84
|
export function createUnarySpacing(theme) {
|
|
@@ -98,18 +88,14 @@ export function getValue(transformer, propValue) {
|
|
|
98
88
|
if (typeof propValue === 'string' || propValue == null) {
|
|
99
89
|
return propValue;
|
|
100
90
|
}
|
|
101
|
-
|
|
102
91
|
const abs = Math.abs(propValue);
|
|
103
92
|
const transformed = transformer(abs);
|
|
104
|
-
|
|
105
93
|
if (propValue >= 0) {
|
|
106
94
|
return transformed;
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
if (typeof transformed === 'number') {
|
|
110
97
|
return -transformed;
|
|
111
98
|
}
|
|
112
|
-
|
|
113
99
|
return `-${transformed}`;
|
|
114
100
|
}
|
|
115
101
|
export function getStyleFromPropValue(cssProperties, transformer) {
|
|
@@ -118,25 +104,21 @@ export function getStyleFromPropValue(cssProperties, transformer) {
|
|
|
118
104
|
return acc;
|
|
119
105
|
}, {});
|
|
120
106
|
}
|
|
121
|
-
|
|
122
107
|
function resolveCssProperty(props, keys, prop, transformer) {
|
|
123
108
|
// Using a hash computation over an array iteration could be faster, but with only 28 items,
|
|
124
109
|
// it's doesn't worth the bundle size.
|
|
125
110
|
if (keys.indexOf(prop) === -1) {
|
|
126
111
|
return null;
|
|
127
112
|
}
|
|
128
|
-
|
|
129
113
|
const cssProperties = getCssProperties(prop);
|
|
130
114
|
const styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
|
|
131
115
|
const propValue = props[prop];
|
|
132
116
|
return handleBreakpoints(props, propValue, styleFromPropValue);
|
|
133
117
|
}
|
|
134
|
-
|
|
135
118
|
function style(props, keys) {
|
|
136
119
|
const transformer = createUnarySpacing(props.theme);
|
|
137
120
|
return Object.keys(props).map(prop => resolveCssProperty(props, keys, prop, transformer)).reduce(merge, {});
|
|
138
121
|
}
|
|
139
|
-
|
|
140
122
|
export function margin(props) {
|
|
141
123
|
return style(props, marginKeys);
|
|
142
124
|
}
|
|
@@ -153,11 +135,9 @@ padding.propTypes = process.env.NODE_ENV !== 'production' ? paddingKeys.reduce((
|
|
|
153
135
|
return obj;
|
|
154
136
|
}, {}) : {};
|
|
155
137
|
padding.filterProps = paddingKeys;
|
|
156
|
-
|
|
157
138
|
function spacing(props) {
|
|
158
139
|
return style(props, spacingKeys);
|
|
159
140
|
}
|
|
160
|
-
|
|
161
141
|
spacing.propTypes = process.env.NODE_ENV !== 'production' ? spacingKeys.reduce((obj, key) => {
|
|
162
142
|
obj[key] = responsivePropType;
|
|
163
143
|
return obj;
|
package/esm/style.js
CHANGED
|
@@ -4,29 +4,24 @@ import { handleBreakpoints } from './breakpoints';
|
|
|
4
4
|
export function getPath(obj, path, checkVars = true) {
|
|
5
5
|
if (!path || typeof path !== 'string') {
|
|
6
6
|
return null;
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
}
|
|
9
8
|
|
|
9
|
+
// Check if CSS variables are used
|
|
10
10
|
if (obj && obj.vars && checkVars) {
|
|
11
11
|
const val = `vars.${path}`.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
|
|
12
|
-
|
|
13
12
|
if (val != null) {
|
|
14
13
|
return val;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
|
|
18
16
|
return path.split('.').reduce((acc, item) => {
|
|
19
17
|
if (acc && acc[item] != null) {
|
|
20
18
|
return acc[item];
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
return null;
|
|
24
21
|
}, obj);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
function getValue(themeMapping, transform, propValueFinal, userValue = propValueFinal) {
|
|
28
24
|
let value;
|
|
29
|
-
|
|
30
25
|
if (typeof themeMapping === 'function') {
|
|
31
26
|
value = themeMapping(propValueFinal);
|
|
32
27
|
} else if (Array.isArray(themeMapping)) {
|
|
@@ -34,14 +29,11 @@ function getValue(themeMapping, transform, propValueFinal, userValue = propValue
|
|
|
34
29
|
} else {
|
|
35
30
|
value = getPath(themeMapping, propValueFinal) || userValue;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
if (transform) {
|
|
39
33
|
value = transform(value, userValue);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return value;
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
function style(options) {
|
|
46
38
|
const {
|
|
47
39
|
prop,
|
|
@@ -49,41 +41,32 @@ function style(options) {
|
|
|
49
41
|
themeKey,
|
|
50
42
|
transform
|
|
51
43
|
} = options;
|
|
52
|
-
|
|
53
44
|
const fn = props => {
|
|
54
45
|
if (props[prop] == null) {
|
|
55
46
|
return null;
|
|
56
47
|
}
|
|
57
|
-
|
|
58
48
|
const propValue = props[prop];
|
|
59
49
|
const theme = props.theme;
|
|
60
50
|
const themeMapping = getPath(theme, themeKey) || {};
|
|
61
|
-
|
|
62
51
|
const styleFromPropValue = propValueFinal => {
|
|
63
52
|
let value = getValue(themeMapping, transform, propValueFinal);
|
|
64
|
-
|
|
65
53
|
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
|
66
54
|
// Haven't found value
|
|
67
55
|
value = getValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
if (cssProperty === false) {
|
|
71
58
|
return value;
|
|
72
59
|
}
|
|
73
|
-
|
|
74
60
|
return {
|
|
75
61
|
[cssProperty]: value
|
|
76
62
|
};
|
|
77
63
|
};
|
|
78
|
-
|
|
79
64
|
return handleBreakpoints(props, propValue, styleFromPropValue);
|
|
80
65
|
};
|
|
81
|
-
|
|
82
66
|
fn.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
83
67
|
[prop]: responsivePropType
|
|
84
68
|
} : {};
|
|
85
69
|
fn.filterProps = [prop];
|
|
86
70
|
return fn;
|
|
87
71
|
}
|
|
88
|
-
|
|
89
72
|
export default style;
|
|
@@ -3,7 +3,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["sx"];
|
|
4
4
|
import { isPlainObject } from '@mui/utils';
|
|
5
5
|
import { propToStyleFunction } from '../getThemeValue';
|
|
6
|
-
|
|
7
6
|
const splitProps = props => {
|
|
8
7
|
const result = {
|
|
9
8
|
systemProps: {},
|
|
@@ -18,35 +17,29 @@ const splitProps = props => {
|
|
|
18
17
|
});
|
|
19
18
|
return result;
|
|
20
19
|
};
|
|
21
|
-
|
|
22
20
|
export default function extendSxProp(props) {
|
|
23
21
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
sx: inSx
|
|
23
|
+
} = props,
|
|
24
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
28
25
|
const {
|
|
29
26
|
systemProps,
|
|
30
27
|
otherProps
|
|
31
28
|
} = splitProps(other);
|
|
32
29
|
let finalSx;
|
|
33
|
-
|
|
34
30
|
if (Array.isArray(inSx)) {
|
|
35
31
|
finalSx = [systemProps, ...inSx];
|
|
36
32
|
} else if (typeof inSx === 'function') {
|
|
37
33
|
finalSx = (...args) => {
|
|
38
34
|
const result = inSx(...args);
|
|
39
|
-
|
|
40
35
|
if (!isPlainObject(result)) {
|
|
41
36
|
return systemProps;
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
return _extends({}, systemProps, result);
|
|
45
39
|
};
|
|
46
40
|
} else {
|
|
47
41
|
finalSx = _extends({}, systemProps, inSx);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
return _extends({}, otherProps, {
|
|
51
44
|
sx: finalSx
|
|
52
45
|
});
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import merge from '../merge';
|
|
2
2
|
import { styleFunctionMapping as defaultStyleFunctionMapping } from '../getThemeValue';
|
|
3
3
|
import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from '../breakpoints';
|
|
4
|
-
|
|
5
4
|
function objectsHaveSameKeys(...objects) {
|
|
6
5
|
const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
|
|
7
6
|
const union = new Set(allKeys);
|
|
8
7
|
return objects.every(object => union.size === Object.keys(object).length);
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
function callIfFn(maybeFn, arg) {
|
|
12
10
|
return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
|
|
13
|
-
}
|
|
14
|
-
|
|
11
|
+
}
|
|
15
12
|
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
14
|
export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultStyleFunctionMapping) {
|
|
17
15
|
const propToStyleFunction = Object.keys(styleFunctionMapping).reduce((acc, styleFnName) => {
|
|
18
16
|
styleFunctionMapping[styleFnName].filterProps.forEach(propName => {
|
|
@@ -20,7 +18,6 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
20
18
|
});
|
|
21
19
|
return acc;
|
|
22
20
|
}, {});
|
|
23
|
-
|
|
24
21
|
function getThemeValue(prop, value, theme) {
|
|
25
22
|
const inputProps = {
|
|
26
23
|
[prop]: value,
|
|
@@ -31,43 +28,36 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
31
28
|
[prop]: value
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
|
-
|
|
35
31
|
function styleFunctionSx(props) {
|
|
36
32
|
const {
|
|
37
33
|
sx,
|
|
38
34
|
theme = {}
|
|
39
35
|
} = props || {};
|
|
40
|
-
|
|
41
36
|
if (!sx) {
|
|
42
37
|
return null; // Emotion & styled-components will neglect null
|
|
43
38
|
}
|
|
39
|
+
|
|
44
40
|
/*
|
|
45
41
|
* Receive `sxInput` as object or callback
|
|
46
42
|
* and then recursively check keys & values to create media query object styles.
|
|
47
43
|
* (the result will be used in `styled`)
|
|
48
44
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
45
|
function traverse(sxInput) {
|
|
52
46
|
let sxObject = sxInput;
|
|
53
|
-
|
|
54
47
|
if (typeof sxInput === 'function') {
|
|
55
48
|
sxObject = sxInput(theme);
|
|
56
49
|
} else if (typeof sxInput !== 'object') {
|
|
57
50
|
// value
|
|
58
51
|
return sxInput;
|
|
59
52
|
}
|
|
60
|
-
|
|
61
53
|
if (!sxObject) {
|
|
62
54
|
return null;
|
|
63
55
|
}
|
|
64
|
-
|
|
65
56
|
const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
|
|
66
57
|
const breakpointsKeys = Object.keys(emptyBreakpoints);
|
|
67
58
|
let css = emptyBreakpoints;
|
|
68
59
|
Object.keys(sxObject).forEach(styleKey => {
|
|
69
60
|
const value = callIfFn(sxObject[styleKey], theme);
|
|
70
|
-
|
|
71
61
|
if (value !== null && value !== undefined) {
|
|
72
62
|
if (typeof value === 'object') {
|
|
73
63
|
if (propToStyleFunction[styleKey]) {
|
|
@@ -78,7 +68,6 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
78
68
|
}, value, x => ({
|
|
79
69
|
[styleKey]: x
|
|
80
70
|
}));
|
|
81
|
-
|
|
82
71
|
if (objectsHaveSameKeys(breakpointsValues, value)) {
|
|
83
72
|
css[styleKey] = styleFunctionSx({
|
|
84
73
|
sx: value,
|
|
@@ -95,10 +84,8 @@ export function unstable_createStyleFunctionSx(styleFunctionMapping = defaultSty
|
|
|
95
84
|
});
|
|
96
85
|
return removeUnusedBreakpoints(breakpointsKeys, css);
|
|
97
86
|
}
|
|
98
|
-
|
|
99
87
|
return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
return styleFunctionSx;
|
|
103
90
|
}
|
|
104
91
|
const styleFunctionSx = unstable_createStyleFunctionSx();
|
package/esm/sx/sx.js
CHANGED
package/esm/useTheme.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import createTheme from './createTheme';
|
|
2
2
|
import useThemeWithoutDefault from './useThemeWithoutDefault';
|
|
3
3
|
export const systemDefaultTheme = createTheme();
|
|
4
|
-
|
|
5
4
|
function useTheme(defaultTheme = systemDefaultTheme) {
|
|
6
5
|
return useThemeWithoutDefault(defaultTheme);
|
|
7
6
|
}
|
|
8
|
-
|
|
9
7
|
export default useTheme;
|
|
@@ -5,10 +5,8 @@ export default function getThemeProps(params) {
|
|
|
5
5
|
name,
|
|
6
6
|
props
|
|
7
7
|
} = params;
|
|
8
|
-
|
|
9
8
|
if (!theme || !theme.components || !theme.components[name] || !theme.components[name].defaultProps) {
|
|
10
9
|
return props;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return resolveProps(theme.components[name].defaultProps, props);
|
|
14
12
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { useTheme as muiUseTheme } from '@mui/private-theming';
|
|
2
|
-
|
|
3
2
|
function isObjectEmpty(obj) {
|
|
4
3
|
return Object.keys(obj).length === 0;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
function useTheme(defaultTheme = null) {
|
|
8
6
|
const contextTheme = muiUseTheme();
|
|
9
7
|
return !contextTheme || isObjectEmpty(contextTheme) ? defaultTheme : contextTheme;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
export default useTheme;
|
package/flexbox.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.order = exports.justifySelf = exports.justifyItems = exports.justifyContent = exports.flexWrap = exports.flexShrink = exports.flexGrow = exports.flexDirection = exports.flexBasis = exports.flex = exports.default = exports.alignSelf = exports.alignItems = exports.alignContent = void 0;
|
|
9
|
-
|
|
10
8
|
var _style = _interopRequireDefault(require("./style"));
|
|
11
|
-
|
|
12
9
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
13
|
-
|
|
14
10
|
const flexBasis = (0, _style.default)({
|
|
15
11
|
prop: 'flexBasis'
|
|
16
12
|
});
|
package/getThemeValue.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.styleFunctionMapping = exports.propToStyleFunction = exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _borders = _interopRequireDefault(require("./borders"));
|
|
11
|
-
|
|
12
9
|
var _display = _interopRequireDefault(require("./display"));
|
|
13
|
-
|
|
14
10
|
var _flexbox = _interopRequireDefault(require("./flexbox"));
|
|
15
|
-
|
|
16
11
|
var _cssGrid = _interopRequireDefault(require("./cssGrid"));
|
|
17
|
-
|
|
18
12
|
var _positions = _interopRequireDefault(require("./positions"));
|
|
19
|
-
|
|
20
13
|
var _palette = _interopRequireDefault(require("./palette"));
|
|
21
|
-
|
|
22
14
|
var _shadows = _interopRequireDefault(require("./shadows"));
|
|
23
|
-
|
|
24
15
|
var _sizing = _interopRequireDefault(require("./sizing"));
|
|
25
|
-
|
|
26
16
|
var _spacing = _interopRequireDefault(require("./spacing"));
|
|
27
|
-
|
|
28
17
|
var _typography = _interopRequireDefault(require("./typography"));
|
|
29
|
-
|
|
30
18
|
const filterPropsMapping = {
|
|
31
19
|
borders: _borders.default.filterProps,
|
|
32
20
|
display: _display.default.filterProps,
|
|
@@ -59,7 +47,6 @@ const propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFn
|
|
|
59
47
|
return acc;
|
|
60
48
|
}, {});
|
|
61
49
|
exports.propToStyleFunction = propToStyleFunction;
|
|
62
|
-
|
|
63
50
|
function getThemeValue(prop, value, theme) {
|
|
64
51
|
const inputProps = {
|
|
65
52
|
[prop]: value,
|
|
@@ -70,6 +57,5 @@ function getThemeValue(prop, value, theme) {
|
|
|
70
57
|
[prop]: value
|
|
71
58
|
};
|
|
72
59
|
}
|
|
73
|
-
|
|
74
60
|
var _default = getThemeValue;
|
|
75
61
|
exports.default = _default;
|