@mui/system 5.10.13 → 5.10.15
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/index.js +0 -2
- package/CHANGELOG.md +132 -2
- package/Container/Container.js +2 -17
- package/Container/containerClasses.js +0 -3
- package/Container/createContainer.js +15 -37
- package/Container/index.js +0 -6
- package/Stack/Stack.js +1 -12
- package/Stack/createStack.js +10 -48
- package/Stack/index.js +0 -9
- package/Stack/stackClasses.js +0 -3
- package/ThemeProvider/ThemeProvider.js +2 -22
- package/ThemeProvider/index.js +0 -2
- package/Unstable_Grid/Grid.js +6 -42
- package/Unstable_Grid/createGrid.js +19 -49
- package/Unstable_Grid/gridClasses.js +8 -7
- package/Unstable_Grid/gridGenerator.d.ts +4 -3
- package/Unstable_Grid/gridGenerator.js +22 -63
- 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/createStyled.js +27 -71
- package/createTheme/createBreakpoints.js +22 -37
- 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 +33 -74
- package/cssVars/createGetCssVar.js +2 -7
- package/cssVars/cssVarsParser.js +3 -15
- package/cssVars/getInitColorSchemeScript.js +0 -6
- package/cssVars/index.js +0 -3
- 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 +33 -60
- 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 +3 -3
- 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 +5 -22
- 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.d.ts +2 -0
- package/index.js +16 -55
- 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 +98 -130
- 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 +4 -4
- 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 +9 -27
- 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 +33 -60
- 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 +4 -4
- 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 +5 -22
- 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.d.ts +3 -0
- package/responsivePropType.js +0 -3
- package/shadows.js +0 -3
- package/sizing.js +0 -11
- package/spacing.d.ts +14 -0
- package/spacing.js +3 -37
- package/style.d.ts +6 -0
- package/style.js +6 -27
- package/styleFunctionSx/extendSxProp.js +3 -15
- package/styleFunctionSx/index.js +0 -5
- package/styleFunctionSx/styleFunctionSx.js +3 -21
- 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/createStyled.js
CHANGED
|
@@ -1,63 +1,47 @@
|
|
|
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.default = createStyled;
|
|
9
8
|
exports.shouldForwardProp = shouldForwardProp;
|
|
10
9
|
exports.systemDefaultTheme = void 0;
|
|
11
|
-
|
|
12
10
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
|
-
|
|
14
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
-
|
|
16
12
|
var _styledEngine = _interopRequireWildcard(require("@mui/styled-engine"));
|
|
17
|
-
|
|
18
13
|
var _utils = require("@mui/utils");
|
|
19
|
-
|
|
20
14
|
var _createTheme = _interopRequireDefault(require("./createTheme"));
|
|
21
|
-
|
|
22
15
|
var _propsToClassKey = _interopRequireDefault(require("./propsToClassKey"));
|
|
23
|
-
|
|
24
16
|
var _styleFunctionSx = _interopRequireDefault(require("./styleFunctionSx"));
|
|
25
|
-
|
|
26
17
|
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
_excluded2 = ["theme"],
|
|
19
|
+
_excluded3 = ["theme"];
|
|
30
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
22
|
function isEmpty(obj) {
|
|
35
23
|
return Object.keys(obj).length === 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
24
|
+
}
|
|
38
25
|
|
|
26
|
+
// https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
|
|
39
27
|
function isStringTag(tag) {
|
|
40
|
-
return typeof tag === 'string' &&
|
|
28
|
+
return typeof tag === 'string' &&
|
|
29
|
+
// 96 is one less than the char code
|
|
41
30
|
// for "a" so this is checking that
|
|
42
31
|
// it's a lowercase character
|
|
43
32
|
tag.charCodeAt(0) > 96;
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
const getStyleOverrides = (name, theme) => {
|
|
47
35
|
if (theme.components && theme.components[name] && theme.components[name].styleOverrides) {
|
|
48
36
|
return theme.components[name].styleOverrides;
|
|
49
37
|
}
|
|
50
|
-
|
|
51
38
|
return null;
|
|
52
39
|
};
|
|
53
|
-
|
|
54
40
|
const getVariantStyles = (name, theme) => {
|
|
55
41
|
let variants = [];
|
|
56
|
-
|
|
57
42
|
if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
|
|
58
43
|
variants = theme.components[name].variants;
|
|
59
44
|
}
|
|
60
|
-
|
|
61
45
|
const variantsStyles = {};
|
|
62
46
|
variants.forEach(definition => {
|
|
63
47
|
const key = (0, _propsToClassKey.default)(definition.props);
|
|
@@ -65,16 +49,13 @@ const getVariantStyles = (name, theme) => {
|
|
|
65
49
|
});
|
|
66
50
|
return variantsStyles;
|
|
67
51
|
};
|
|
68
|
-
|
|
69
52
|
const variantsResolver = (props, styles, theme, name) => {
|
|
70
53
|
var _theme$components, _theme$components$nam;
|
|
71
|
-
|
|
72
54
|
const {
|
|
73
55
|
ownerState = {}
|
|
74
56
|
} = props;
|
|
75
57
|
const variantsStyles = [];
|
|
76
58
|
const themeVariants = theme == null ? void 0 : (_theme$components = theme.components) == null ? void 0 : (_theme$components$nam = _theme$components[name]) == null ? void 0 : _theme$components$nam.variants;
|
|
77
|
-
|
|
78
59
|
if (themeVariants) {
|
|
79
60
|
themeVariants.forEach(themeVariant => {
|
|
80
61
|
let isMatch = true;
|
|
@@ -83,28 +64,23 @@ const variantsResolver = (props, styles, theme, name) => {
|
|
|
83
64
|
isMatch = false;
|
|
84
65
|
}
|
|
85
66
|
});
|
|
86
|
-
|
|
87
67
|
if (isMatch) {
|
|
88
68
|
variantsStyles.push(styles[(0, _propsToClassKey.default)(themeVariant.props)]);
|
|
89
69
|
}
|
|
90
70
|
});
|
|
91
71
|
}
|
|
92
|
-
|
|
93
72
|
return variantsStyles;
|
|
94
|
-
};
|
|
95
|
-
|
|
73
|
+
};
|
|
96
74
|
|
|
75
|
+
// Update /system/styled/#api in case if this changes
|
|
97
76
|
function shouldForwardProp(prop) {
|
|
98
77
|
return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
|
|
99
78
|
}
|
|
100
|
-
|
|
101
79
|
const systemDefaultTheme = (0, _createTheme.default)();
|
|
102
80
|
exports.systemDefaultTheme = systemDefaultTheme;
|
|
103
|
-
|
|
104
81
|
const lowercaseFirstLetter = string => {
|
|
105
82
|
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
106
83
|
};
|
|
107
|
-
|
|
108
84
|
function createStyled(input = {}) {
|
|
109
85
|
const {
|
|
110
86
|
defaultTheme = systemDefaultTheme,
|
|
@@ -112,39 +88,35 @@ function createStyled(input = {}) {
|
|
|
112
88
|
slotShouldForwardProp = shouldForwardProp,
|
|
113
89
|
styleFunctionSx = _styleFunctionSx.default
|
|
114
90
|
} = input;
|
|
115
|
-
|
|
116
91
|
const systemSx = props => {
|
|
117
92
|
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
118
93
|
return styleFunctionSx((0, _extends2.default)({}, props, {
|
|
119
94
|
theme
|
|
120
95
|
}));
|
|
121
96
|
};
|
|
122
|
-
|
|
123
97
|
systemSx.__mui_systemSx = true;
|
|
124
98
|
return (tag, inputOptions = {}) => {
|
|
125
99
|
// Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
|
|
126
100
|
(0, _styledEngine.internal_processStyles)(tag, styles => styles.filter(style => !(style != null && style.__mui_systemSx)));
|
|
127
101
|
const {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
102
|
+
name: componentName,
|
|
103
|
+
slot: componentSlot,
|
|
104
|
+
skipVariantsResolver: inputSkipVariantsResolver,
|
|
105
|
+
skipSx: inputSkipSx,
|
|
106
|
+
overridesResolver
|
|
107
|
+
} = inputOptions,
|
|
108
|
+
options = (0, _objectWithoutPropertiesLoose2.default)(inputOptions, _excluded);
|
|
109
|
+
|
|
110
|
+
// if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
|
|
136
111
|
const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver : componentSlot && componentSlot !== 'Root' || false;
|
|
137
112
|
const skipSx = inputSkipSx || false;
|
|
138
113
|
let label;
|
|
139
|
-
|
|
140
114
|
if (process.env.NODE_ENV !== 'production') {
|
|
141
115
|
if (componentName) {
|
|
142
116
|
label = `${componentName}-${lowercaseFirstLetter(componentSlot || 'Root')}`;
|
|
143
117
|
}
|
|
144
118
|
}
|
|
145
|
-
|
|
146
119
|
let shouldForwardPropOption = shouldForwardProp;
|
|
147
|
-
|
|
148
120
|
if (componentSlot === 'Root') {
|
|
149
121
|
shouldForwardPropOption = rootShouldForwardProp;
|
|
150
122
|
} else if (componentSlot) {
|
|
@@ -154,12 +126,10 @@ function createStyled(input = {}) {
|
|
|
154
126
|
// for string (html) tag, preserve the behavior in emotion & styled-components.
|
|
155
127
|
shouldForwardPropOption = undefined;
|
|
156
128
|
}
|
|
157
|
-
|
|
158
129
|
const defaultStyledResolver = (0, _styledEngine.default)(tag, (0, _extends2.default)({
|
|
159
130
|
shouldForwardProp: shouldForwardPropOption,
|
|
160
131
|
label
|
|
161
132
|
}, options));
|
|
162
|
-
|
|
163
133
|
const muiStyledResolver = (styleArg, ...expressions) => {
|
|
164
134
|
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => {
|
|
165
135
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
@@ -167,21 +137,19 @@ function createStyled(input = {}) {
|
|
|
167
137
|
// which are basically components used as a selectors.
|
|
168
138
|
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? _ref => {
|
|
169
139
|
let {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
140
|
+
theme: themeInput
|
|
141
|
+
} = _ref,
|
|
142
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
|
|
173
143
|
return stylesArg((0, _extends2.default)({
|
|
174
144
|
theme: isEmpty(themeInput) ? defaultTheme : themeInput
|
|
175
145
|
}, other));
|
|
176
146
|
} : stylesArg;
|
|
177
147
|
}) : [];
|
|
178
148
|
let transformedStyleArg = styleArg;
|
|
179
|
-
|
|
180
149
|
if (componentName && overridesResolver) {
|
|
181
150
|
expressionsWithDefaultTheme.push(props => {
|
|
182
151
|
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
183
152
|
const styleOverrides = getStyleOverrides(componentName, theme);
|
|
184
|
-
|
|
185
153
|
if (styleOverrides) {
|
|
186
154
|
const resolvedStyleOverrides = {};
|
|
187
155
|
Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
|
|
@@ -191,68 +159,56 @@ function createStyled(input = {}) {
|
|
|
191
159
|
});
|
|
192
160
|
return overridesResolver(props, resolvedStyleOverrides);
|
|
193
161
|
}
|
|
194
|
-
|
|
195
162
|
return null;
|
|
196
163
|
});
|
|
197
164
|
}
|
|
198
|
-
|
|
199
165
|
if (componentName && !skipVariantsResolver) {
|
|
200
166
|
expressionsWithDefaultTheme.push(props => {
|
|
201
167
|
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
202
168
|
return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
|
|
203
169
|
});
|
|
204
170
|
}
|
|
205
|
-
|
|
206
171
|
if (!skipSx) {
|
|
207
172
|
expressionsWithDefaultTheme.push(systemSx);
|
|
208
173
|
}
|
|
209
|
-
|
|
210
174
|
const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
|
|
211
|
-
|
|
212
175
|
if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
|
|
213
|
-
const placeholders = new Array(numOfCustomFnsApplied).fill('');
|
|
214
|
-
|
|
176
|
+
const placeholders = new Array(numOfCustomFnsApplied).fill('');
|
|
177
|
+
// If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
|
|
215
178
|
transformedStyleArg = [...styleArg, ...placeholders];
|
|
216
179
|
transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
|
|
217
|
-
} else if (typeof styleArg === 'function' &&
|
|
180
|
+
} else if (typeof styleArg === 'function' &&
|
|
181
|
+
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
218
182
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
219
183
|
// which are basically components used as a selectors.
|
|
220
184
|
styleArg.__emotion_real !== styleArg) {
|
|
221
185
|
// If the type is function, we need to define the default theme.
|
|
222
186
|
transformedStyleArg = _ref2 => {
|
|
223
187
|
let {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
188
|
+
theme: themeInput
|
|
189
|
+
} = _ref2,
|
|
190
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref2, _excluded3);
|
|
227
191
|
return styleArg((0, _extends2.default)({
|
|
228
192
|
theme: isEmpty(themeInput) ? defaultTheme : themeInput
|
|
229
193
|
}, other));
|
|
230
194
|
};
|
|
231
195
|
}
|
|
232
|
-
|
|
233
196
|
const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
234
|
-
|
|
235
197
|
if (process.env.NODE_ENV !== 'production') {
|
|
236
198
|
let displayName;
|
|
237
|
-
|
|
238
199
|
if (componentName) {
|
|
239
200
|
displayName = `${componentName}${componentSlot || ''}`;
|
|
240
201
|
}
|
|
241
|
-
|
|
242
202
|
if (displayName === undefined) {
|
|
243
203
|
displayName = `Styled(${(0, _utils.getDisplayName)(tag)})`;
|
|
244
204
|
}
|
|
245
|
-
|
|
246
205
|
Component.displayName = displayName;
|
|
247
206
|
}
|
|
248
|
-
|
|
249
207
|
return Component;
|
|
250
208
|
};
|
|
251
|
-
|
|
252
209
|
if (defaultStyledResolver.withConfig) {
|
|
253
210
|
muiStyledResolver.withConfig = defaultStyledResolver.withConfig;
|
|
254
211
|
}
|
|
255
|
-
|
|
256
212
|
return muiStyledResolver;
|
|
257
213
|
};
|
|
258
214
|
}
|
|
@@ -1,99 +1,84 @@
|
|
|
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.breakpointKeys = void 0;
|
|
9
8
|
exports.default = createBreakpoints;
|
|
10
|
-
|
|
11
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
|
-
|
|
13
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
-
|
|
15
11
|
const _excluded = ["values", "unit", "step"];
|
|
16
12
|
// Sorted ASC by size. That's important.
|
|
17
13
|
// It can't be configured as it's used statically for propTypes.
|
|
18
14
|
const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
19
15
|
exports.breakpointKeys = breakpointKeys;
|
|
20
|
-
|
|
21
16
|
const sortBreakpointsValues = values => {
|
|
22
17
|
const breakpointsAsArray = Object.keys(values).map(key => ({
|
|
23
18
|
key,
|
|
24
19
|
val: values[key]
|
|
25
|
-
})) || [];
|
|
26
|
-
|
|
20
|
+
})) || [];
|
|
21
|
+
// Sort in ascending order
|
|
27
22
|
breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
|
|
28
23
|
return breakpointsAsArray.reduce((acc, obj) => {
|
|
29
24
|
return (0, _extends2.default)({}, acc, {
|
|
30
25
|
[obj.key]: obj.val
|
|
31
26
|
});
|
|
32
27
|
}, {});
|
|
33
|
-
};
|
|
34
|
-
|
|
28
|
+
};
|
|
35
29
|
|
|
30
|
+
// Keep in mind that @media is inclusive by the CSS specification.
|
|
36
31
|
function createBreakpoints(breakpoints) {
|
|
37
32
|
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
// The breakpoint **start** at this value.
|
|
34
|
+
// For instance with the first breakpoint xs: [xs, sm).
|
|
35
|
+
values = {
|
|
36
|
+
xs: 0,
|
|
37
|
+
// phone
|
|
38
|
+
sm: 600,
|
|
39
|
+
// tablet
|
|
40
|
+
md: 900,
|
|
41
|
+
// small laptop
|
|
42
|
+
lg: 1200,
|
|
43
|
+
// desktop
|
|
44
|
+
xl: 1536 // large screen
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
unit = 'px',
|
|
48
|
+
step = 5
|
|
49
|
+
} = breakpoints,
|
|
50
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(breakpoints, _excluded);
|
|
56
51
|
const sortedValues = sortBreakpointsValues(values);
|
|
57
52
|
const keys = Object.keys(sortedValues);
|
|
58
|
-
|
|
59
53
|
function up(key) {
|
|
60
54
|
const value = typeof values[key] === 'number' ? values[key] : key;
|
|
61
55
|
return `@media (min-width:${value}${unit})`;
|
|
62
56
|
}
|
|
63
|
-
|
|
64
57
|
function down(key) {
|
|
65
58
|
const value = typeof values[key] === 'number' ? values[key] : key;
|
|
66
59
|
return `@media (max-width:${value - step / 100}${unit})`;
|
|
67
60
|
}
|
|
68
|
-
|
|
69
61
|
function between(start, end) {
|
|
70
62
|
const endIndex = keys.indexOf(end);
|
|
71
63
|
return `@media (min-width:${typeof values[start] === 'number' ? values[start] : start}${unit}) and ` + `(max-width:${(endIndex !== -1 && typeof values[keys[endIndex]] === 'number' ? values[keys[endIndex]] : end) - step / 100}${unit})`;
|
|
72
64
|
}
|
|
73
|
-
|
|
74
65
|
function only(key) {
|
|
75
66
|
if (keys.indexOf(key) + 1 < keys.length) {
|
|
76
67
|
return between(key, keys[keys.indexOf(key) + 1]);
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
return up(key);
|
|
80
70
|
}
|
|
81
|
-
|
|
82
71
|
function not(key) {
|
|
83
72
|
// handle first and last key separately, for better readability
|
|
84
73
|
const keyIndex = keys.indexOf(key);
|
|
85
|
-
|
|
86
74
|
if (keyIndex === 0) {
|
|
87
75
|
return up(keys[1]);
|
|
88
76
|
}
|
|
89
|
-
|
|
90
77
|
if (keyIndex === keys.length - 1) {
|
|
91
78
|
return down(keys[keyIndex]);
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
|
|
95
81
|
}
|
|
96
|
-
|
|
97
82
|
return (0, _extends2.default)({
|
|
98
83
|
keys,
|
|
99
84
|
values: sortedValues,
|
|
@@ -4,37 +4,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = createSpacing;
|
|
7
|
-
|
|
8
7
|
var _spacing = require("../spacing");
|
|
9
|
-
|
|
10
8
|
/* tslint:enable:unified-signatures */
|
|
9
|
+
|
|
11
10
|
function createSpacing(spacingInput = 8) {
|
|
12
11
|
// Already transformed.
|
|
13
12
|
if (spacingInput.mui) {
|
|
14
13
|
return spacingInput;
|
|
15
|
-
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Material Design layouts are visually balanced. Most measurements align to an 8dp grid, which aligns both spacing and the overall layout.
|
|
16
17
|
// Smaller components, such as icons, can align to a 4dp grid.
|
|
17
18
|
// https://m2.material.io/design/layout/understanding-layout.html
|
|
18
|
-
|
|
19
|
-
|
|
20
19
|
const transform = (0, _spacing.createUnarySpacing)({
|
|
21
20
|
spacing: spacingInput
|
|
22
21
|
});
|
|
23
|
-
|
|
24
22
|
const spacing = (...argsInput) => {
|
|
25
23
|
if (process.env.NODE_ENV !== 'production') {
|
|
26
24
|
if (!(argsInput.length <= 4)) {
|
|
27
25
|
console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${argsInput.length}`);
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
const args = argsInput.length === 0 ? [1] : argsInput;
|
|
32
29
|
return args.map(argument => {
|
|
33
30
|
const output = transform(argument);
|
|
34
31
|
return typeof output === 'number' ? `${output}px` : output;
|
|
35
32
|
}).join(' ');
|
|
36
33
|
};
|
|
37
|
-
|
|
38
34
|
spacing.mui = true;
|
|
39
35
|
return spacing;
|
|
40
36
|
}
|
|
@@ -1,34 +1,25 @@
|
|
|
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.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
|
-
|
|
14
10
|
var _utils = require("@mui/utils");
|
|
15
|
-
|
|
16
11
|
var _createBreakpoints = _interopRequireDefault(require("./createBreakpoints"));
|
|
17
|
-
|
|
18
12
|
var _shape = _interopRequireDefault(require("./shape"));
|
|
19
|
-
|
|
20
13
|
var _createSpacing = _interopRequireDefault(require("./createSpacing"));
|
|
21
|
-
|
|
22
14
|
const _excluded = ["breakpoints", "palette", "spacing", "shape"];
|
|
23
|
-
|
|
24
15
|
function createTheme(options = {}, ...args) {
|
|
25
16
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
breakpoints: breakpointsInput = {},
|
|
18
|
+
palette: paletteInput = {},
|
|
19
|
+
spacing: spacingInput,
|
|
20
|
+
shape: shapeInput = {}
|
|
21
|
+
} = options,
|
|
22
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(options, _excluded);
|
|
32
23
|
const breakpoints = (0, _createBreakpoints.default)(breakpointsInput);
|
|
33
24
|
const spacing = (0, _createSpacing.default)(spacingInput);
|
|
34
25
|
let muiTheme = (0, _utils.deepmerge)({
|
|
@@ -45,6 +36,5 @@ function createTheme(options = {}, ...args) {
|
|
|
45
36
|
muiTheme = args.reduce((acc, argument) => (0, _utils.deepmerge)(acc, argument), muiTheme);
|
|
46
37
|
return muiTheme;
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
var _default = createTheme;
|
|
50
40
|
exports.default = _default;
|
package/createTheme/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
|
});
|
|
@@ -11,5 +10,4 @@ Object.defineProperty(exports, "default", {
|
|
|
11
10
|
return _createTheme.default;
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
|
-
|
|
15
13
|
var _createTheme = _interopRequireDefault(require("./createTheme"));
|
package/cssGrid.js
CHANGED
|
@@ -1,76 +1,55 @@
|
|
|
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.rowGap = exports.gridTemplateRows = exports.gridTemplateColumns = exports.gridTemplateAreas = exports.gridRow = exports.gridColumn = exports.gridAutoRows = exports.gridAutoFlow = exports.gridAutoColumns = exports.gridArea = exports.gap = exports.default = exports.columnGap = void 0;
|
|
9
|
-
|
|
10
8
|
var _style = _interopRequireDefault(require("./style"));
|
|
11
|
-
|
|
12
9
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
13
|
-
|
|
14
10
|
var _spacing = require("./spacing");
|
|
15
|
-
|
|
16
11
|
var _breakpoints = require("./breakpoints");
|
|
17
|
-
|
|
18
12
|
var _responsivePropType = _interopRequireDefault(require("./responsivePropType"));
|
|
19
|
-
|
|
20
13
|
const gap = props => {
|
|
21
14
|
if (props.gap !== undefined && props.gap !== null) {
|
|
22
15
|
const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'spacing', 8, 'gap');
|
|
23
|
-
|
|
24
16
|
const styleFromPropValue = propValue => ({
|
|
25
17
|
gap: (0, _spacing.getValue)(transformer, propValue)
|
|
26
18
|
});
|
|
27
|
-
|
|
28
19
|
return (0, _breakpoints.handleBreakpoints)(props, props.gap, styleFromPropValue);
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
return null;
|
|
32
22
|
};
|
|
33
|
-
|
|
34
23
|
exports.gap = gap;
|
|
35
24
|
gap.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
36
25
|
gap: _responsivePropType.default
|
|
37
26
|
} : {};
|
|
38
27
|
gap.filterProps = ['gap'];
|
|
39
|
-
|
|
40
28
|
const columnGap = props => {
|
|
41
29
|
if (props.columnGap !== undefined && props.columnGap !== null) {
|
|
42
30
|
const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'spacing', 8, 'columnGap');
|
|
43
|
-
|
|
44
31
|
const styleFromPropValue = propValue => ({
|
|
45
32
|
columnGap: (0, _spacing.getValue)(transformer, propValue)
|
|
46
33
|
});
|
|
47
|
-
|
|
48
34
|
return (0, _breakpoints.handleBreakpoints)(props, props.columnGap, styleFromPropValue);
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
return null;
|
|
52
37
|
};
|
|
53
|
-
|
|
54
38
|
exports.columnGap = columnGap;
|
|
55
39
|
columnGap.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
56
40
|
columnGap: _responsivePropType.default
|
|
57
41
|
} : {};
|
|
58
42
|
columnGap.filterProps = ['columnGap'];
|
|
59
|
-
|
|
60
43
|
const rowGap = props => {
|
|
61
44
|
if (props.rowGap !== undefined && props.rowGap !== null) {
|
|
62
45
|
const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'spacing', 8, 'rowGap');
|
|
63
|
-
|
|
64
46
|
const styleFromPropValue = propValue => ({
|
|
65
47
|
rowGap: (0, _spacing.getValue)(transformer, propValue)
|
|
66
48
|
});
|
|
67
|
-
|
|
68
49
|
return (0, _breakpoints.handleBreakpoints)(props, props.rowGap, styleFromPropValue);
|
|
69
50
|
}
|
|
70
|
-
|
|
71
51
|
return null;
|
|
72
52
|
};
|
|
73
|
-
|
|
74
53
|
exports.rowGap = rowGap;
|
|
75
54
|
rowGap.propTypes = process.env.NODE_ENV !== 'production' ? {
|
|
76
55
|
rowGap: _responsivePropType.default
|