@mui/system 5.14.10 → 5.14.12
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.d.ts +12 -0
- package/Box/Box.js +1 -2
- package/CHANGELOG.md +159 -0
- package/Container/Container.js +1 -2
- package/Container/containerClasses.js +1 -2
- package/GlobalStyles/GlobalStyles.js +1 -2
- package/Stack/Stack.js +1 -2
- package/Stack/stackClasses.js +1 -2
- package/ThemeProvider/ThemeProvider.js +1 -2
- package/Unstable_Grid/Grid.js +1 -2
- package/Unstable_Grid/gridClasses.js +1 -2
- package/borders.js +11 -22
- package/breakpoints.js +3 -4
- package/compose.js +1 -2
- package/createStyled.js +100 -37
- package/createTheme/createBreakpoints.js +1 -2
- package/createTheme/createTheme.js +1 -2
- package/createTheme/shape.js +1 -2
- package/cssGrid.js +10 -20
- package/cssVars/createCssVarsProvider.js +4 -5
- package/cssVars/createCssVarsTheme.js +1 -2
- package/cssVars/getInitColorSchemeScript.js +3 -6
- package/cssVars/prepareCssVars.js +1 -2
- package/display.js +7 -14
- package/esm/createStyled.js +100 -36
- package/esm/cssVars/createCssVarsProvider.js +3 -3
- package/flexbox.js +14 -28
- package/getThemeValue.js +3 -6
- package/index.js +1 -1
- package/legacy/createStyled.js +106 -41
- package/legacy/cssVars/createCssVarsProvider.js +3 -3
- package/legacy/index.js +1 -1
- package/merge.js +1 -2
- package/modern/createStyled.js +99 -35
- package/modern/cssVars/createCssVarsProvider.js +3 -3
- package/modern/index.js +1 -1
- package/package.json +6 -6
- package/palette.js +4 -8
- package/positions.js +7 -14
- package/responsivePropType.js +1 -2
- package/shadows.js +1 -2
- package/sizing.js +9 -18
- package/spacing.js +3 -6
- package/style.js +1 -2
- package/styleFunctionSx/defaultSxConfig.js +1 -2
- package/styleFunctionSx/styleFunctionSx.js +1 -2
- package/styled.js +1 -2
- package/typography.js +10 -20
- package/useTheme.js +2 -4
- package/useThemeWithoutDefault.js +1 -2
|
@@ -20,8 +20,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
const _excluded = ["colorSchemes", "components", "generateCssVars", "cssVarPrefix"];
|
|
21
21
|
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); }
|
|
22
22
|
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; }
|
|
23
|
-
const DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
24
|
-
exports.DISABLE_CSS_TRANSITION = DISABLE_CSS_TRANSITION;
|
|
23
|
+
const DISABLE_CSS_TRANSITION = exports.DISABLE_CSS_TRANSITION = '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}';
|
|
25
24
|
function createCssVarsProvider(options) {
|
|
26
25
|
const {
|
|
27
26
|
themeId,
|
|
@@ -312,11 +311,11 @@ function createCssVarsProvider(options) {
|
|
|
312
311
|
*/
|
|
313
312
|
disableStyleSheetGeneration: _propTypes.default.bool,
|
|
314
313
|
/**
|
|
315
|
-
* Disable CSS transitions when switching between modes or color schemes
|
|
314
|
+
* Disable CSS transitions when switching between modes or color schemes.
|
|
316
315
|
*/
|
|
317
316
|
disableTransitionOnChange: _propTypes.default.bool,
|
|
318
317
|
/**
|
|
319
|
-
* The document to attach the attribute to
|
|
318
|
+
* The document to attach the attribute to.
|
|
320
319
|
*/
|
|
321
320
|
documentNode: _propTypes.default.any,
|
|
322
321
|
/**
|
|
@@ -324,7 +323,7 @@ function createCssVarsProvider(options) {
|
|
|
324
323
|
*/
|
|
325
324
|
modeStorageKey: _propTypes.default.string,
|
|
326
325
|
/**
|
|
327
|
-
* The window that attaches the 'storage' event listener
|
|
326
|
+
* The window that attaches the 'storage' event listener.
|
|
328
327
|
* @default window
|
|
329
328
|
*/
|
|
330
329
|
storageWindow: _propTypes.default.any,
|
|
@@ -9,12 +9,9 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
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); }
|
|
11
11
|
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; }
|
|
12
|
-
const DEFAULT_MODE_STORAGE_KEY = 'mode';
|
|
13
|
-
exports.
|
|
14
|
-
const
|
|
15
|
-
exports.DEFAULT_COLOR_SCHEME_STORAGE_KEY = DEFAULT_COLOR_SCHEME_STORAGE_KEY;
|
|
16
|
-
const DEFAULT_ATTRIBUTE = 'data-color-scheme';
|
|
17
|
-
exports.DEFAULT_ATTRIBUTE = DEFAULT_ATTRIBUTE;
|
|
12
|
+
const DEFAULT_MODE_STORAGE_KEY = exports.DEFAULT_MODE_STORAGE_KEY = 'mode';
|
|
13
|
+
const DEFAULT_COLOR_SCHEME_STORAGE_KEY = exports.DEFAULT_COLOR_SCHEME_STORAGE_KEY = 'color-scheme';
|
|
14
|
+
const DEFAULT_ATTRIBUTE = exports.DEFAULT_ATTRIBUTE = 'data-color-scheme';
|
|
18
15
|
function getInitColorSchemeScript(options) {
|
|
19
16
|
const {
|
|
20
17
|
defaultMode = 'light',
|
package/display.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.whiteSpace = exports.visibility = exports.textOverflow = exports.overflow = exports.displayRaw = exports.displayPrint = exports.default = void 0;
|
|
8
8
|
var _style = _interopRequireDefault(require("./style"));
|
|
9
9
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
10
|
-
const displayPrint = (0, _style.default)({
|
|
10
|
+
const displayPrint = exports.displayPrint = (0, _style.default)({
|
|
11
11
|
prop: 'displayPrint',
|
|
12
12
|
cssProperty: false,
|
|
13
13
|
transform: value => ({
|
|
@@ -16,26 +16,19 @@ const displayPrint = (0, _style.default)({
|
|
|
16
16
|
}
|
|
17
17
|
})
|
|
18
18
|
});
|
|
19
|
-
exports.
|
|
20
|
-
const displayRaw = (0, _style.default)({
|
|
19
|
+
const displayRaw = exports.displayRaw = (0, _style.default)({
|
|
21
20
|
prop: 'display'
|
|
22
21
|
});
|
|
23
|
-
exports.
|
|
24
|
-
const overflow = (0, _style.default)({
|
|
22
|
+
const overflow = exports.overflow = (0, _style.default)({
|
|
25
23
|
prop: 'overflow'
|
|
26
24
|
});
|
|
27
|
-
exports.
|
|
28
|
-
const textOverflow = (0, _style.default)({
|
|
25
|
+
const textOverflow = exports.textOverflow = (0, _style.default)({
|
|
29
26
|
prop: 'textOverflow'
|
|
30
27
|
});
|
|
31
|
-
exports.
|
|
32
|
-
const visibility = (0, _style.default)({
|
|
28
|
+
const visibility = exports.visibility = (0, _style.default)({
|
|
33
29
|
prop: 'visibility'
|
|
34
30
|
});
|
|
35
|
-
exports.
|
|
36
|
-
const whiteSpace = (0, _style.default)({
|
|
31
|
+
const whiteSpace = exports.whiteSpace = (0, _style.default)({
|
|
37
32
|
prop: 'whiteSpace'
|
|
38
33
|
});
|
|
39
|
-
exports.
|
|
40
|
-
var _default = (0, _compose.default)(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
|
|
41
|
-
exports.default = _default;
|
|
34
|
+
var _default = exports.default = (0, _compose.default)(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
|
package/esm/createStyled.js
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
6
|
-
import { getDisplayName, unstable_capitalize as capitalize } from '@mui/utils';
|
|
6
|
+
import { getDisplayName, unstable_capitalize as capitalize, isPlainObject, deepmerge } from '@mui/utils';
|
|
7
7
|
import createTheme from './createTheme';
|
|
8
8
|
import propsToClassKey from './propsToClassKey';
|
|
9
9
|
import styleFunctionSx from './styleFunctionSx';
|
|
@@ -25,40 +25,48 @@ const getStyleOverrides = (name, theme) => {
|
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
27
27
|
};
|
|
28
|
+
const transformVariants = variants => {
|
|
29
|
+
const variantsStyles = {};
|
|
30
|
+
if (variants) {
|
|
31
|
+
variants.forEach(definition => {
|
|
32
|
+
const key = propsToClassKey(definition.props);
|
|
33
|
+
variantsStyles[key] = definition.style;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return variantsStyles;
|
|
37
|
+
};
|
|
28
38
|
const getVariantStyles = (name, theme) => {
|
|
29
39
|
let variants = [];
|
|
30
40
|
if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
|
|
31
41
|
variants = theme.components[name].variants;
|
|
32
42
|
}
|
|
33
|
-
|
|
34
|
-
variants.forEach(definition => {
|
|
35
|
-
const key = propsToClassKey(definition.props);
|
|
36
|
-
variantsStyles[key] = definition.style;
|
|
37
|
-
});
|
|
38
|
-
return variantsStyles;
|
|
43
|
+
return transformVariants(variants);
|
|
39
44
|
};
|
|
40
|
-
const variantsResolver = (props, styles,
|
|
41
|
-
var _theme$components;
|
|
45
|
+
const variantsResolver = (props, styles, variants) => {
|
|
42
46
|
const {
|
|
43
47
|
ownerState = {}
|
|
44
48
|
} = props;
|
|
45
49
|
const variantsStyles = [];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
themeVariants.forEach(themeVariant => {
|
|
50
|
+
if (variants) {
|
|
51
|
+
variants.forEach(variant => {
|
|
49
52
|
let isMatch = true;
|
|
50
|
-
Object.keys(
|
|
51
|
-
if (ownerState[key] !==
|
|
53
|
+
Object.keys(variant.props).forEach(key => {
|
|
54
|
+
if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
|
|
52
55
|
isMatch = false;
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
58
|
if (isMatch) {
|
|
56
|
-
variantsStyles.push(styles[propsToClassKey(
|
|
59
|
+
variantsStyles.push(styles[propsToClassKey(variant.props)]);
|
|
57
60
|
}
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
return variantsStyles;
|
|
61
64
|
};
|
|
65
|
+
const themeVariantsResolver = (props, styles, theme, name) => {
|
|
66
|
+
var _theme$components;
|
|
67
|
+
const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
|
|
68
|
+
return variantsResolver(props, styles, themeVariants);
|
|
69
|
+
};
|
|
62
70
|
|
|
63
71
|
// Update /system/styled/#api in case if this changes
|
|
64
72
|
export function shouldForwardProp(prop) {
|
|
@@ -84,6 +92,29 @@ function defaultOverridesResolver(slot) {
|
|
|
84
92
|
}
|
|
85
93
|
return (props, styles) => styles[slot];
|
|
86
94
|
}
|
|
95
|
+
const muiStyledFunctionResolver = ({
|
|
96
|
+
styledArg,
|
|
97
|
+
props,
|
|
98
|
+
defaultTheme,
|
|
99
|
+
themeId
|
|
100
|
+
}) => {
|
|
101
|
+
const resolvedStyles = styledArg(_extends({}, props, {
|
|
102
|
+
theme: resolveTheme(_extends({}, props, {
|
|
103
|
+
defaultTheme,
|
|
104
|
+
themeId
|
|
105
|
+
}))
|
|
106
|
+
}));
|
|
107
|
+
let optionalVariants;
|
|
108
|
+
if (resolvedStyles && resolvedStyles.variants) {
|
|
109
|
+
optionalVariants = resolvedStyles.variants;
|
|
110
|
+
delete resolvedStyles.variants;
|
|
111
|
+
}
|
|
112
|
+
if (optionalVariants) {
|
|
113
|
+
const variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
|
|
114
|
+
return [resolvedStyles, ...variantsStyles];
|
|
115
|
+
}
|
|
116
|
+
return resolvedStyles;
|
|
117
|
+
};
|
|
87
118
|
export default function createStyled(input = {}) {
|
|
88
119
|
const {
|
|
89
120
|
themeId,
|
|
@@ -150,16 +181,61 @@ export default function createStyled(input = {}) {
|
|
|
150
181
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
151
182
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
152
183
|
// which are basically components used as a selectors.
|
|
153
|
-
|
|
154
|
-
return
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
})
|
|
160
|
-
}
|
|
184
|
+
if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
|
|
185
|
+
return props => muiStyledFunctionResolver({
|
|
186
|
+
styledArg: stylesArg,
|
|
187
|
+
props,
|
|
188
|
+
defaultTheme,
|
|
189
|
+
themeId
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (isPlainObject(stylesArg)) {
|
|
193
|
+
let transformedStylesArg = stylesArg;
|
|
194
|
+
let styledArgVariants;
|
|
195
|
+
if (stylesArg && stylesArg.variants) {
|
|
196
|
+
styledArgVariants = stylesArg.variants;
|
|
197
|
+
delete transformedStylesArg.variants;
|
|
198
|
+
transformedStylesArg = props => {
|
|
199
|
+
let result = stylesArg;
|
|
200
|
+
const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
|
|
201
|
+
variantStyles.forEach(variantStyle => {
|
|
202
|
+
result = deepmerge(result, variantStyle);
|
|
203
|
+
});
|
|
204
|
+
return result;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return transformedStylesArg;
|
|
208
|
+
}
|
|
209
|
+
return stylesArg;
|
|
161
210
|
}) : [];
|
|
162
211
|
let transformedStyleArg = styleArg;
|
|
212
|
+
if (isPlainObject(styleArg)) {
|
|
213
|
+
let styledArgVariants;
|
|
214
|
+
if (styleArg && styleArg.variants) {
|
|
215
|
+
styledArgVariants = styleArg.variants;
|
|
216
|
+
delete transformedStyleArg.variants;
|
|
217
|
+
transformedStyleArg = props => {
|
|
218
|
+
let result = styleArg;
|
|
219
|
+
const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
|
|
220
|
+
variantStyles.forEach(variantStyle => {
|
|
221
|
+
result = deepmerge(result, variantStyle);
|
|
222
|
+
});
|
|
223
|
+
return result;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
} else if (typeof styleArg === 'function' &&
|
|
227
|
+
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
228
|
+
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
229
|
+
// which are basically components used as a selectors.
|
|
230
|
+
styleArg.__emotion_real !== styleArg) {
|
|
231
|
+
// If the type is function, we need to define the default theme.
|
|
232
|
+
transformedStyleArg = props => muiStyledFunctionResolver({
|
|
233
|
+
styledArg: styleArg,
|
|
234
|
+
props,
|
|
235
|
+
defaultTheme,
|
|
236
|
+
themeId
|
|
237
|
+
});
|
|
238
|
+
}
|
|
163
239
|
if (componentName && overridesResolver) {
|
|
164
240
|
expressionsWithDefaultTheme.push(props => {
|
|
165
241
|
const theme = resolveTheme(_extends({}, props, {
|
|
@@ -185,7 +261,7 @@ export default function createStyled(input = {}) {
|
|
|
185
261
|
defaultTheme,
|
|
186
262
|
themeId
|
|
187
263
|
}));
|
|
188
|
-
return
|
|
264
|
+
return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
|
|
189
265
|
});
|
|
190
266
|
}
|
|
191
267
|
if (!skipSx) {
|
|
@@ -197,18 +273,6 @@ export default function createStyled(input = {}) {
|
|
|
197
273
|
// If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
|
|
198
274
|
transformedStyleArg = [...styleArg, ...placeholders];
|
|
199
275
|
transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
|
|
200
|
-
} else if (typeof styleArg === 'function' &&
|
|
201
|
-
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
202
|
-
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
203
|
-
// which are basically components used as a selectors.
|
|
204
|
-
styleArg.__emotion_real !== styleArg) {
|
|
205
|
-
// If the type is function, we need to define the default theme.
|
|
206
|
-
transformedStyleArg = props => styleArg(_extends({}, props, {
|
|
207
|
-
theme: resolveTheme(_extends({}, props, {
|
|
208
|
-
defaultTheme,
|
|
209
|
-
themeId
|
|
210
|
-
}))
|
|
211
|
-
}));
|
|
212
276
|
}
|
|
213
277
|
const Component = defaultStyledResolver(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
214
278
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -303,11 +303,11 @@ export default function createCssVarsProvider(options) {
|
|
|
303
303
|
*/
|
|
304
304
|
disableStyleSheetGeneration: PropTypes.bool,
|
|
305
305
|
/**
|
|
306
|
-
* Disable CSS transitions when switching between modes or color schemes
|
|
306
|
+
* Disable CSS transitions when switching between modes or color schemes.
|
|
307
307
|
*/
|
|
308
308
|
disableTransitionOnChange: PropTypes.bool,
|
|
309
309
|
/**
|
|
310
|
-
* The document to attach the attribute to
|
|
310
|
+
* The document to attach the attribute to.
|
|
311
311
|
*/
|
|
312
312
|
documentNode: PropTypes.any,
|
|
313
313
|
/**
|
|
@@ -315,7 +315,7 @@ export default function createCssVarsProvider(options) {
|
|
|
315
315
|
*/
|
|
316
316
|
modeStorageKey: PropTypes.string,
|
|
317
317
|
/**
|
|
318
|
-
* The window that attaches the 'storage' event listener
|
|
318
|
+
* The window that attaches the 'storage' event listener.
|
|
319
319
|
* @default window
|
|
320
320
|
*/
|
|
321
321
|
storageWindow: PropTypes.any,
|
package/flexbox.js
CHANGED
|
@@ -7,58 +7,44 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
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;
|
|
8
8
|
var _style = _interopRequireDefault(require("./style"));
|
|
9
9
|
var _compose = _interopRequireDefault(require("./compose"));
|
|
10
|
-
const flexBasis = (0, _style.default)({
|
|
10
|
+
const flexBasis = exports.flexBasis = (0, _style.default)({
|
|
11
11
|
prop: 'flexBasis'
|
|
12
12
|
});
|
|
13
|
-
exports.
|
|
14
|
-
const flexDirection = (0, _style.default)({
|
|
13
|
+
const flexDirection = exports.flexDirection = (0, _style.default)({
|
|
15
14
|
prop: 'flexDirection'
|
|
16
15
|
});
|
|
17
|
-
exports.
|
|
18
|
-
const flexWrap = (0, _style.default)({
|
|
16
|
+
const flexWrap = exports.flexWrap = (0, _style.default)({
|
|
19
17
|
prop: 'flexWrap'
|
|
20
18
|
});
|
|
21
|
-
exports.
|
|
22
|
-
const justifyContent = (0, _style.default)({
|
|
19
|
+
const justifyContent = exports.justifyContent = (0, _style.default)({
|
|
23
20
|
prop: 'justifyContent'
|
|
24
21
|
});
|
|
25
|
-
exports.
|
|
26
|
-
const alignItems = (0, _style.default)({
|
|
22
|
+
const alignItems = exports.alignItems = (0, _style.default)({
|
|
27
23
|
prop: 'alignItems'
|
|
28
24
|
});
|
|
29
|
-
exports.
|
|
30
|
-
const alignContent = (0, _style.default)({
|
|
25
|
+
const alignContent = exports.alignContent = (0, _style.default)({
|
|
31
26
|
prop: 'alignContent'
|
|
32
27
|
});
|
|
33
|
-
exports.
|
|
34
|
-
const order = (0, _style.default)({
|
|
28
|
+
const order = exports.order = (0, _style.default)({
|
|
35
29
|
prop: 'order'
|
|
36
30
|
});
|
|
37
|
-
exports.
|
|
38
|
-
const flex = (0, _style.default)({
|
|
31
|
+
const flex = exports.flex = (0, _style.default)({
|
|
39
32
|
prop: 'flex'
|
|
40
33
|
});
|
|
41
|
-
exports.
|
|
42
|
-
const flexGrow = (0, _style.default)({
|
|
34
|
+
const flexGrow = exports.flexGrow = (0, _style.default)({
|
|
43
35
|
prop: 'flexGrow'
|
|
44
36
|
});
|
|
45
|
-
exports.
|
|
46
|
-
const flexShrink = (0, _style.default)({
|
|
37
|
+
const flexShrink = exports.flexShrink = (0, _style.default)({
|
|
47
38
|
prop: 'flexShrink'
|
|
48
39
|
});
|
|
49
|
-
exports.
|
|
50
|
-
const alignSelf = (0, _style.default)({
|
|
40
|
+
const alignSelf = exports.alignSelf = (0, _style.default)({
|
|
51
41
|
prop: 'alignSelf'
|
|
52
42
|
});
|
|
53
|
-
exports.
|
|
54
|
-
const justifyItems = (0, _style.default)({
|
|
43
|
+
const justifyItems = exports.justifyItems = (0, _style.default)({
|
|
55
44
|
prop: 'justifyItems'
|
|
56
45
|
});
|
|
57
|
-
exports.
|
|
58
|
-
const justifySelf = (0, _style.default)({
|
|
46
|
+
const justifySelf = exports.justifySelf = (0, _style.default)({
|
|
59
47
|
prop: 'justifySelf'
|
|
60
48
|
});
|
|
61
|
-
exports.justifySelf = justifySelf;
|
|
62
49
|
const flexbox = (0, _compose.default)(flexBasis, flexDirection, flexWrap, justifyContent, alignItems, alignContent, order, flex, flexGrow, flexShrink, alignSelf, justifyItems, justifySelf);
|
|
63
|
-
var _default = flexbox;
|
|
64
|
-
exports.default = _default;
|
|
50
|
+
var _default = exports.default = flexbox;
|
package/getThemeValue.js
CHANGED
|
@@ -27,7 +27,7 @@ const filterPropsMapping = {
|
|
|
27
27
|
spacing: _spacing.default.filterProps,
|
|
28
28
|
typography: _typography.default.filterProps
|
|
29
29
|
};
|
|
30
|
-
const styleFunctionMapping = {
|
|
30
|
+
const styleFunctionMapping = exports.styleFunctionMapping = {
|
|
31
31
|
borders: _borders.default,
|
|
32
32
|
display: _display.default,
|
|
33
33
|
flexbox: _flexbox.default,
|
|
@@ -39,14 +39,12 @@ const styleFunctionMapping = {
|
|
|
39
39
|
spacing: _spacing.default,
|
|
40
40
|
typography: _typography.default
|
|
41
41
|
};
|
|
42
|
-
exports.
|
|
43
|
-
const propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFnName) => {
|
|
42
|
+
const propToStyleFunction = exports.propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFnName) => {
|
|
44
43
|
filterPropsMapping[styleFnName].forEach(propName => {
|
|
45
44
|
acc[propName] = styleFunctionMapping[styleFnName];
|
|
46
45
|
});
|
|
47
46
|
return acc;
|
|
48
47
|
}, {});
|
|
49
|
-
exports.propToStyleFunction = propToStyleFunction;
|
|
50
48
|
function getThemeValue(prop, value, theme) {
|
|
51
49
|
const inputProps = {
|
|
52
50
|
[prop]: value,
|
|
@@ -57,5 +55,4 @@ function getThemeValue(prop, value, theme) {
|
|
|
57
55
|
[prop]: value
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
|
-
var _default = getThemeValue;
|
|
61
|
-
exports.default = _default;
|
|
58
|
+
var _default = exports.default = getThemeValue;
|
package/index.js
CHANGED
package/legacy/createStyled.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
/* eslint-disable no-underscore-dangle */
|
|
6
6
|
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
7
|
-
import { getDisplayName, unstable_capitalize as capitalize } from '@mui/utils';
|
|
7
|
+
import { getDisplayName, unstable_capitalize as capitalize, isPlainObject, deepmerge } from '@mui/utils';
|
|
8
8
|
import createTheme from './createTheme';
|
|
9
9
|
import propsToClassKey from './propsToClassKey';
|
|
10
10
|
import styleFunctionSx from './styleFunctionSx';
|
|
@@ -26,39 +26,47 @@ var getStyleOverrides = function getStyleOverrides(name, theme) {
|
|
|
26
26
|
}
|
|
27
27
|
return null;
|
|
28
28
|
};
|
|
29
|
+
var transformVariants = function transformVariants(variants) {
|
|
30
|
+
var variantsStyles = {};
|
|
31
|
+
if (variants) {
|
|
32
|
+
variants.forEach(function (definition) {
|
|
33
|
+
var key = propsToClassKey(definition.props);
|
|
34
|
+
variantsStyles[key] = definition.style;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return variantsStyles;
|
|
38
|
+
};
|
|
29
39
|
var getVariantStyles = function getVariantStyles(name, theme) {
|
|
30
40
|
var variants = [];
|
|
31
41
|
if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
|
|
32
42
|
variants = theme.components[name].variants;
|
|
33
43
|
}
|
|
34
|
-
|
|
35
|
-
variants.forEach(function (definition) {
|
|
36
|
-
var key = propsToClassKey(definition.props);
|
|
37
|
-
variantsStyles[key] = definition.style;
|
|
38
|
-
});
|
|
39
|
-
return variantsStyles;
|
|
44
|
+
return transformVariants(variants);
|
|
40
45
|
};
|
|
41
|
-
var variantsResolver = function variantsResolver(props, styles,
|
|
42
|
-
var _theme$components;
|
|
46
|
+
var variantsResolver = function variantsResolver(props, styles, variants) {
|
|
43
47
|
var _props$ownerState = props.ownerState,
|
|
44
48
|
ownerState = _props$ownerState === void 0 ? {} : _props$ownerState;
|
|
45
49
|
var variantsStyles = [];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
themeVariants.forEach(function (themeVariant) {
|
|
50
|
+
if (variants) {
|
|
51
|
+
variants.forEach(function (variant) {
|
|
49
52
|
var isMatch = true;
|
|
50
|
-
Object.keys(
|
|
51
|
-
if (ownerState[key] !==
|
|
53
|
+
Object.keys(variant.props).forEach(function (key) {
|
|
54
|
+
if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
|
|
52
55
|
isMatch = false;
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
58
|
if (isMatch) {
|
|
56
|
-
variantsStyles.push(styles[propsToClassKey(
|
|
59
|
+
variantsStyles.push(styles[propsToClassKey(variant.props)]);
|
|
57
60
|
}
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
return variantsStyles;
|
|
61
64
|
};
|
|
65
|
+
var themeVariantsResolver = function themeVariantsResolver(props, styles, theme, name) {
|
|
66
|
+
var _theme$components;
|
|
67
|
+
var themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
|
|
68
|
+
return variantsResolver(props, styles, themeVariants);
|
|
69
|
+
};
|
|
62
70
|
|
|
63
71
|
// Update /system/styled/#api in case if this changes
|
|
64
72
|
export function shouldForwardProp(prop) {
|
|
@@ -85,6 +93,28 @@ function defaultOverridesResolver(slot) {
|
|
|
85
93
|
return styles[slot];
|
|
86
94
|
};
|
|
87
95
|
}
|
|
96
|
+
var muiStyledFunctionResolver = function muiStyledFunctionResolver(_ref2) {
|
|
97
|
+
var styledArg = _ref2.styledArg,
|
|
98
|
+
props = _ref2.props,
|
|
99
|
+
defaultTheme = _ref2.defaultTheme,
|
|
100
|
+
themeId = _ref2.themeId;
|
|
101
|
+
var resolvedStyles = styledArg(_extends({}, props, {
|
|
102
|
+
theme: resolveTheme(_extends({}, props, {
|
|
103
|
+
defaultTheme: defaultTheme,
|
|
104
|
+
themeId: themeId
|
|
105
|
+
}))
|
|
106
|
+
}));
|
|
107
|
+
var optionalVariants;
|
|
108
|
+
if (resolvedStyles && resolvedStyles.variants) {
|
|
109
|
+
optionalVariants = resolvedStyles.variants;
|
|
110
|
+
delete resolvedStyles.variants;
|
|
111
|
+
}
|
|
112
|
+
if (optionalVariants) {
|
|
113
|
+
var variantsStyles = variantsResolver(props, transformVariants(optionalVariants), optionalVariants);
|
|
114
|
+
return [resolvedStyles].concat(_toConsumableArray(variantsStyles));
|
|
115
|
+
}
|
|
116
|
+
return resolvedStyles;
|
|
117
|
+
};
|
|
88
118
|
export default function createStyled() {
|
|
89
119
|
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
90
120
|
var themeId = input.themeId,
|
|
@@ -156,16 +186,65 @@ export default function createStyled() {
|
|
|
156
186
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
157
187
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
158
188
|
// which are basically components used as a selectors.
|
|
159
|
-
|
|
160
|
-
return
|
|
161
|
-
|
|
189
|
+
if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
|
|
190
|
+
return function (props) {
|
|
191
|
+
return muiStyledFunctionResolver({
|
|
192
|
+
styledArg: stylesArg,
|
|
193
|
+
props: props,
|
|
162
194
|
defaultTheme: defaultTheme,
|
|
163
195
|
themeId: themeId
|
|
164
|
-
})
|
|
165
|
-
}
|
|
166
|
-
}
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (isPlainObject(stylesArg)) {
|
|
200
|
+
var transformedStylesArg = stylesArg;
|
|
201
|
+
var styledArgVariants;
|
|
202
|
+
if (stylesArg && stylesArg.variants) {
|
|
203
|
+
styledArgVariants = stylesArg.variants;
|
|
204
|
+
delete transformedStylesArg.variants;
|
|
205
|
+
transformedStylesArg = function transformedStylesArg(props) {
|
|
206
|
+
var result = stylesArg;
|
|
207
|
+
var variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
|
|
208
|
+
variantStyles.forEach(function (variantStyle) {
|
|
209
|
+
result = deepmerge(result, variantStyle);
|
|
210
|
+
});
|
|
211
|
+
return result;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return transformedStylesArg;
|
|
215
|
+
}
|
|
216
|
+
return stylesArg;
|
|
167
217
|
}) : [];
|
|
168
218
|
var transformedStyleArg = styleArg;
|
|
219
|
+
if (isPlainObject(styleArg)) {
|
|
220
|
+
var styledArgVariants;
|
|
221
|
+
if (styleArg && styleArg.variants) {
|
|
222
|
+
styledArgVariants = styleArg.variants;
|
|
223
|
+
delete transformedStyleArg.variants;
|
|
224
|
+
transformedStyleArg = function transformedStyleArg(props) {
|
|
225
|
+
var result = styleArg;
|
|
226
|
+
var variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
|
|
227
|
+
variantStyles.forEach(function (variantStyle) {
|
|
228
|
+
result = deepmerge(result, variantStyle);
|
|
229
|
+
});
|
|
230
|
+
return result;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
} else if (typeof styleArg === 'function' &&
|
|
234
|
+
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
235
|
+
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
236
|
+
// which are basically components used as a selectors.
|
|
237
|
+
styleArg.__emotion_real !== styleArg) {
|
|
238
|
+
// If the type is function, we need to define the default theme.
|
|
239
|
+
transformedStyleArg = function transformedStyleArg(props) {
|
|
240
|
+
return muiStyledFunctionResolver({
|
|
241
|
+
styledArg: styleArg,
|
|
242
|
+
props: props,
|
|
243
|
+
defaultTheme: defaultTheme,
|
|
244
|
+
themeId: themeId
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
}
|
|
169
248
|
if (componentName && overridesResolver) {
|
|
170
249
|
expressionsWithDefaultTheme.push(function (props) {
|
|
171
250
|
var theme = resolveTheme(_extends({}, props, {
|
|
@@ -175,10 +254,10 @@ export default function createStyled() {
|
|
|
175
254
|
var styleOverrides = getStyleOverrides(componentName, theme);
|
|
176
255
|
if (styleOverrides) {
|
|
177
256
|
var resolvedStyleOverrides = {};
|
|
178
|
-
Object.entries(styleOverrides).forEach(function (
|
|
179
|
-
var
|
|
180
|
-
slotKey =
|
|
181
|
-
slotStyle =
|
|
257
|
+
Object.entries(styleOverrides).forEach(function (_ref3) {
|
|
258
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
259
|
+
slotKey = _ref4[0],
|
|
260
|
+
slotStyle = _ref4[1];
|
|
182
261
|
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle(_extends({}, props, {
|
|
183
262
|
theme: theme
|
|
184
263
|
})) : slotStyle;
|
|
@@ -194,7 +273,7 @@ export default function createStyled() {
|
|
|
194
273
|
defaultTheme: defaultTheme,
|
|
195
274
|
themeId: themeId
|
|
196
275
|
}));
|
|
197
|
-
return
|
|
276
|
+
return themeVariantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
|
|
198
277
|
});
|
|
199
278
|
}
|
|
200
279
|
if (!skipSx) {
|
|
@@ -206,20 +285,6 @@ export default function createStyled() {
|
|
|
206
285
|
// If the type is array, than we need to add placeholders in the template for the overrides, variants and the sx styles.
|
|
207
286
|
transformedStyleArg = [].concat(_toConsumableArray(styleArg), _toConsumableArray(placeholders));
|
|
208
287
|
transformedStyleArg.raw = [].concat(_toConsumableArray(styleArg.raw), _toConsumableArray(placeholders));
|
|
209
|
-
} else if (typeof styleArg === 'function' &&
|
|
210
|
-
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
211
|
-
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
212
|
-
// which are basically components used as a selectors.
|
|
213
|
-
styleArg.__emotion_real !== styleArg) {
|
|
214
|
-
// If the type is function, we need to define the default theme.
|
|
215
|
-
transformedStyleArg = function transformedStyleArg(props) {
|
|
216
|
-
return styleArg(_extends({}, props, {
|
|
217
|
-
theme: resolveTheme(_extends({}, props, {
|
|
218
|
-
defaultTheme: defaultTheme,
|
|
219
|
-
themeId: themeId
|
|
220
|
-
}))
|
|
221
|
-
}));
|
|
222
|
-
};
|
|
223
288
|
}
|
|
224
289
|
var Component = defaultStyledResolver.apply(void 0, [transformedStyleArg].concat(_toConsumableArray(expressionsWithDefaultTheme)));
|
|
225
290
|
if (process.env.NODE_ENV !== 'production') {
|