@mui/system 5.9.2 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +196 -5
- package/Container/Container.d.ts +13 -13
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/createContainer.d.ts +18 -18
- package/Container/index.d.ts +1 -1
- package/README.md +1 -1
- package/Stack/Stack.d.ts +12 -0
- package/Stack/Stack.js +62 -0
- package/Stack/StackProps.d.ts +42 -0
- package/Stack/StackProps.js +5 -0
- package/Stack/createStack.d.ts +21 -0
- package/Stack/createStack.js +209 -0
- package/Stack/index.d.ts +5 -0
- package/Stack/index.js +65 -0
- package/Stack/package.json +6 -0
- package/Stack/stackClasses.d.ts +8 -0
- package/Stack/stackClasses.js +17 -0
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +26 -26
- package/Unstable_Grid/index.d.ts +5 -5
- package/breakpoints.d.ts +21 -0
- package/createBox.js +3 -1
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +30 -11
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.js +1 -1
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/getInitColorSchemeScript.d.ts +45 -45
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/Stack/Stack.js +51 -0
- package/esm/Stack/StackProps.js +1 -0
- package/esm/Stack/createStack.js +179 -0
- package/esm/Stack/index.js +5 -0
- package/esm/Stack/stackClasses.js +6 -0
- package/esm/createBox.js +3 -1
- package/esm/createStyled.js +28 -10
- package/esm/cssVars/createCssVarsProvider.js +1 -1
- package/esm/index.js +3 -1
- package/index.d.ts +4 -6
- package/index.js +25 -2
- package/index.spec.d.ts +1 -1
- package/legacy/Stack/Stack.js +51 -0
- package/legacy/Stack/StackProps.js +1 -0
- package/legacy/Stack/createStack.js +187 -0
- package/legacy/Stack/index.js +5 -0
- package/legacy/Stack/stackClasses.js +6 -0
- package/legacy/createBox.js +5 -1
- package/legacy/createStyled.js +31 -10
- package/legacy/cssVars/createCssVarsProvider.js +1 -1
- package/legacy/index.js +4 -2
- package/modern/Stack/Stack.js +51 -0
- package/modern/Stack/StackProps.js +1 -0
- package/modern/Stack/createStack.js +179 -0
- package/modern/Stack/index.js +5 -0
- package/modern/Stack/stackClasses.js +6 -0
- package/modern/createBox.js +3 -1
- package/modern/createStyled.js +28 -10
- package/modern/cssVars/createCssVarsProvider.js +1 -1
- package/modern/index.js +4 -2
- package/package.json +5 -5
- package/spacing.d.ts +6 -0
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { deepmerge, unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
|
|
9
|
+
import systemStyled from '../styled';
|
|
10
|
+
import useThemePropsSystem from '../useThemeProps';
|
|
11
|
+
import { extendSxProp } from '../styleFunctionSx';
|
|
12
|
+
import createTheme from '../createTheme';
|
|
13
|
+
import { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues } from '../breakpoints';
|
|
14
|
+
import { createUnarySpacing, getValue } from '../spacing';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
var defaultTheme = createTheme();
|
|
17
|
+
// widening Theme to any so that the consumer can own the theme structure.
|
|
18
|
+
var defaultCreateStyledComponent = systemStyled('div', {
|
|
19
|
+
name: 'MuiStack',
|
|
20
|
+
slot: 'Root',
|
|
21
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
22
|
+
return styles.root;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function useThemePropsDefault(props) {
|
|
27
|
+
return useThemePropsSystem({
|
|
28
|
+
props: props,
|
|
29
|
+
name: 'MuiStack',
|
|
30
|
+
defaultTheme: defaultTheme
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return an array with the separator React element interspersed between
|
|
35
|
+
* each React node of the input children.
|
|
36
|
+
*
|
|
37
|
+
* > joinChildren([1,2,3], 0)
|
|
38
|
+
* [1,0,2,0,3]
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
function joinChildren(children, separator) {
|
|
43
|
+
var childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
44
|
+
return childrenArray.reduce(function (output, child, index) {
|
|
45
|
+
output.push(child);
|
|
46
|
+
|
|
47
|
+
if (index < childrenArray.length - 1) {
|
|
48
|
+
output.push( /*#__PURE__*/React.cloneElement(separator, {
|
|
49
|
+
key: "separator-".concat(index)
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return output;
|
|
54
|
+
}, []);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var getSideFromDirection = function getSideFromDirection(direction) {
|
|
58
|
+
return {
|
|
59
|
+
row: 'Left',
|
|
60
|
+
'row-reverse': 'Right',
|
|
61
|
+
column: 'Top',
|
|
62
|
+
'column-reverse': 'Bottom'
|
|
63
|
+
}[direction];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export var style = function style(_ref) {
|
|
67
|
+
var ownerState = _ref.ownerState,
|
|
68
|
+
theme = _ref.theme;
|
|
69
|
+
|
|
70
|
+
var styles = _extends({
|
|
71
|
+
display: 'flex',
|
|
72
|
+
flexDirection: 'column'
|
|
73
|
+
}, handleBreakpoints({
|
|
74
|
+
theme: theme
|
|
75
|
+
}, resolveBreakpointValues({
|
|
76
|
+
values: ownerState.direction,
|
|
77
|
+
breakpoints: theme.breakpoints.values
|
|
78
|
+
}), function (propValue) {
|
|
79
|
+
return {
|
|
80
|
+
flexDirection: propValue
|
|
81
|
+
};
|
|
82
|
+
}));
|
|
83
|
+
|
|
84
|
+
if (ownerState.spacing) {
|
|
85
|
+
var transformer = createUnarySpacing(theme);
|
|
86
|
+
var base = Object.keys(theme.breakpoints.values).reduce(function (acc, breakpoint) {
|
|
87
|
+
if (_typeof(ownerState.spacing) === 'object' && ownerState.spacing[breakpoint] != null || _typeof(ownerState.direction) === 'object' && ownerState.direction[breakpoint] != null) {
|
|
88
|
+
acc[breakpoint] = true;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return acc;
|
|
92
|
+
}, {});
|
|
93
|
+
var directionValues = resolveBreakpointValues({
|
|
94
|
+
values: ownerState.direction,
|
|
95
|
+
base: base
|
|
96
|
+
});
|
|
97
|
+
var spacingValues = resolveBreakpointValues({
|
|
98
|
+
values: ownerState.spacing,
|
|
99
|
+
base: base
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (_typeof(directionValues) === 'object') {
|
|
103
|
+
Object.keys(directionValues).forEach(function (breakpoint, index, breakpoints) {
|
|
104
|
+
var directionValue = directionValues[breakpoint];
|
|
105
|
+
|
|
106
|
+
if (!directionValue) {
|
|
107
|
+
var previousDirectionValue = index > 0 ? directionValues[breakpoints[index - 1]] : 'column';
|
|
108
|
+
directionValues[breakpoint] = previousDirectionValue;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
var styleFromPropValue = function styleFromPropValue(propValue, breakpoint) {
|
|
114
|
+
return {
|
|
115
|
+
'& > :not(style) + :not(style)': _defineProperty({
|
|
116
|
+
margin: 0
|
|
117
|
+
}, "margin".concat(getSideFromDirection(breakpoint ? directionValues[breakpoint] : ownerState.direction)), getValue(transformer, propValue))
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
styles = deepmerge(styles, handleBreakpoints({
|
|
122
|
+
theme: theme
|
|
123
|
+
}, spacingValues, styleFromPropValue));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
styles = mergeBreakpointsInOrder(theme.breakpoints, styles);
|
|
127
|
+
return styles;
|
|
128
|
+
};
|
|
129
|
+
export default function createStack() {
|
|
130
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
131
|
+
var _options$createStyled = options.createStyledComponent,
|
|
132
|
+
createStyledComponent = _options$createStyled === void 0 ? defaultCreateStyledComponent : _options$createStyled,
|
|
133
|
+
_options$useThemeProp = options.useThemeProps,
|
|
134
|
+
useThemeProps = _options$useThemeProp === void 0 ? useThemePropsDefault : _options$useThemeProp,
|
|
135
|
+
_options$componentNam = options.componentName,
|
|
136
|
+
componentName = _options$componentNam === void 0 ? 'MuiStack' : _options$componentNam;
|
|
137
|
+
|
|
138
|
+
var useUtilityClasses = function useUtilityClasses() {
|
|
139
|
+
var slots = {
|
|
140
|
+
root: ['root']
|
|
141
|
+
};
|
|
142
|
+
return composeClasses(slots, function (slot) {
|
|
143
|
+
return generateUtilityClass(componentName, slot);
|
|
144
|
+
}, {});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
var StackRoot = createStyledComponent(style);
|
|
148
|
+
var Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
149
|
+
var themeProps = useThemeProps(inProps);
|
|
150
|
+
var props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
151
|
+
|
|
152
|
+
var _props$component = props.component,
|
|
153
|
+
component = _props$component === void 0 ? 'div' : _props$component,
|
|
154
|
+
_props$direction = props.direction,
|
|
155
|
+
direction = _props$direction === void 0 ? 'column' : _props$direction,
|
|
156
|
+
_props$spacing = props.spacing,
|
|
157
|
+
spacing = _props$spacing === void 0 ? 0 : _props$spacing,
|
|
158
|
+
divider = props.divider,
|
|
159
|
+
children = props.children,
|
|
160
|
+
className = props.className,
|
|
161
|
+
other = _objectWithoutProperties(props, ["component", "direction", "spacing", "divider", "children", "className"]);
|
|
162
|
+
|
|
163
|
+
var ownerState = {
|
|
164
|
+
direction: direction,
|
|
165
|
+
spacing: spacing
|
|
166
|
+
};
|
|
167
|
+
var classes = useUtilityClasses();
|
|
168
|
+
return /*#__PURE__*/_jsx(StackRoot, _extends({
|
|
169
|
+
as: component,
|
|
170
|
+
ownerState: ownerState,
|
|
171
|
+
ref: ref,
|
|
172
|
+
className: clsx(classes.root, className)
|
|
173
|
+
}, other, {
|
|
174
|
+
children: divider ? joinChildren(children, divider) : children
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
process.env.NODE_ENV !== "production" ? Stack.propTypes
|
|
178
|
+
/* remove-proptypes */
|
|
179
|
+
= {
|
|
180
|
+
children: PropTypes.node,
|
|
181
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
182
|
+
divider: PropTypes.node,
|
|
183
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
184
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
185
|
+
} : void 0;
|
|
186
|
+
return Stack;
|
|
187
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
2
|
+
export function getStackUtilityClass(slot) {
|
|
3
|
+
return generateUtilityClass('MuiStack', slot);
|
|
4
|
+
}
|
|
5
|
+
var stackClasses = generateUtilityClasses('MuiStack', ['root']);
|
|
6
|
+
export default stackClasses;
|
package/legacy/createBox.js
CHANGED
|
@@ -14,7 +14,11 @@ export default function createBox() {
|
|
|
14
14
|
generateClassName = options.generateClassName,
|
|
15
15
|
_options$styleFunctio = options.styleFunctionSx,
|
|
16
16
|
styleFunctionSx = _options$styleFunctio === void 0 ? defaultStyleFunctionSx : _options$styleFunctio;
|
|
17
|
-
var BoxRoot = styled('div'
|
|
17
|
+
var BoxRoot = styled('div', {
|
|
18
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
19
|
+
return prop !== 'theme' && prop !== 'sx' && prop !== 'as';
|
|
20
|
+
}
|
|
21
|
+
})(styleFunctionSx);
|
|
18
22
|
var Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
19
23
|
var theme = useTheme(defaultTheme);
|
|
20
24
|
|
package/legacy/createStyled.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
import
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
|
|
6
|
+
/* eslint-disable no-underscore-dangle */
|
|
7
|
+
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
6
8
|
import { getDisplayName } from '@mui/utils';
|
|
7
9
|
import createTheme from './createTheme';
|
|
8
10
|
import propsToClassKey from './propsToClassKey';
|
|
@@ -10,6 +12,14 @@ import defaultStyleFunctionSx from './styleFunctionSx';
|
|
|
10
12
|
|
|
11
13
|
function isEmpty(obj) {
|
|
12
14
|
return Object.keys(obj).length === 0;
|
|
15
|
+
} // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function isStringTag(tag) {
|
|
19
|
+
return typeof tag === 'string' && // 96 is one less than the char code
|
|
20
|
+
// for "a" so this is checking that
|
|
21
|
+
// it's a lowercase character
|
|
22
|
+
tag.charCodeAt(0) > 96;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
var getStyleOverrides = function getStyleOverrides(name, theme) {
|
|
@@ -81,8 +91,23 @@ export default function createStyled() {
|
|
|
81
91
|
slotShouldForwardProp = _input$slotShouldForw === void 0 ? shouldForwardProp : _input$slotShouldForw,
|
|
82
92
|
_input$styleFunctionS = input.styleFunctionSx,
|
|
83
93
|
styleFunctionSx = _input$styleFunctionS === void 0 ? defaultStyleFunctionSx : _input$styleFunctionS;
|
|
94
|
+
|
|
95
|
+
var systemSx = function systemSx(props) {
|
|
96
|
+
var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
97
|
+
return styleFunctionSx(_extends({}, props, {
|
|
98
|
+
theme: theme
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
systemSx.__mui_systemSx = true;
|
|
84
103
|
return function (tag) {
|
|
85
104
|
var inputOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
105
|
+
// Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
|
|
106
|
+
processStyles(tag, function (styles) {
|
|
107
|
+
return styles.filter(function (style) {
|
|
108
|
+
return !(style != null && style.__mui_systemSx);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
86
111
|
|
|
87
112
|
var componentName = inputOptions.name,
|
|
88
113
|
componentSlot = inputOptions.slot,
|
|
@@ -109,6 +134,9 @@ export default function createStyled() {
|
|
|
109
134
|
} else if (componentSlot) {
|
|
110
135
|
// any other slot specified
|
|
111
136
|
shouldForwardPropOption = slotShouldForwardProp;
|
|
137
|
+
} else if (isStringTag(tag)) {
|
|
138
|
+
// for string (html) tag, preserve the behavior in emotion & styled-components.
|
|
139
|
+
shouldForwardPropOption = undefined;
|
|
112
140
|
}
|
|
113
141
|
|
|
114
142
|
var defaultStyledResolver = styledEngineStyled(tag, _extends({
|
|
@@ -125,7 +153,6 @@ export default function createStyled() {
|
|
|
125
153
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
126
154
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
127
155
|
// which are basically components used as a selectors.
|
|
128
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
129
156
|
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? function (_ref) {
|
|
130
157
|
var themeInput = _ref.theme,
|
|
131
158
|
other = _objectWithoutProperties(_ref, ["theme"]);
|
|
@@ -168,12 +195,7 @@ export default function createStyled() {
|
|
|
168
195
|
}
|
|
169
196
|
|
|
170
197
|
if (!skipSx) {
|
|
171
|
-
expressionsWithDefaultTheme.push(
|
|
172
|
-
var theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
173
|
-
return styleFunctionSx(_extends({}, props, {
|
|
174
|
-
theme: theme
|
|
175
|
-
}));
|
|
176
|
-
});
|
|
198
|
+
expressionsWithDefaultTheme.push(systemSx);
|
|
177
199
|
}
|
|
178
200
|
|
|
179
201
|
var numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
|
|
@@ -186,7 +208,6 @@ export default function createStyled() {
|
|
|
186
208
|
} else if (typeof styleArg === 'function' && // On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
187
209
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
188
210
|
// which are basically components used as a selectors.
|
|
189
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
190
211
|
styleArg.__emotion_real !== styleArg) {
|
|
191
212
|
// If the type is function, we need to define the default theme.
|
|
192
213
|
transformedStyleArg = function transformedStyleArg(_ref4) {
|
|
@@ -181,7 +181,7 @@ export default function createCssVarsProvider(options) {
|
|
|
181
181
|
}();
|
|
182
182
|
|
|
183
183
|
if (key === resolvedDefaultColorScheme) {
|
|
184
|
-
defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
|
|
184
|
+
defaultColorSchemeStyleSheet["".concat(colorSchemeSelector, ", [").concat(attribute, "=\"").concat(key, "\"]")] = css;
|
|
185
185
|
} else {
|
|
186
186
|
otherColorSchemesStyleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
|
|
187
187
|
}
|
package/legacy/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license MUI v5.
|
|
1
|
+
/** @license MUI v5.10.1
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -53,4 +53,6 @@ export { default as createContainer } from './Container/createContainer';
|
|
|
53
53
|
export { default as Container } from './Container';
|
|
54
54
|
export * from './Container';
|
|
55
55
|
export { default as Unstable_Grid } from './Unstable_Grid/Grid';
|
|
56
|
-
export * from './Unstable_Grid';
|
|
56
|
+
export * from './Unstable_Grid';
|
|
57
|
+
export { default as Stack } from './Stack/Stack';
|
|
58
|
+
export * from './Stack';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import createStack from './createStack';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Demos:
|
|
6
|
+
*
|
|
7
|
+
* - [Stack (Material UI)](https://mui.com/material-ui/react-stack/)
|
|
8
|
+
*
|
|
9
|
+
* API:
|
|
10
|
+
*
|
|
11
|
+
* - [Stack API](https://mui.com/system/api/stack/)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const Stack = createStack();
|
|
15
|
+
process.env.NODE_ENV !== "production" ? Stack.propTypes
|
|
16
|
+
/* remove-proptypes */
|
|
17
|
+
= {
|
|
18
|
+
// ----------------------------- Warning --------------------------------
|
|
19
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
20
|
+
// | To update them edit TypeScript types and run "yarn proptypes" |
|
|
21
|
+
// ----------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The content of the component.
|
|
25
|
+
*/
|
|
26
|
+
children: PropTypes.node,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Defines the `flex-direction` style property.
|
|
30
|
+
* It is applied for all screen sizes.
|
|
31
|
+
* @default 'column'
|
|
32
|
+
*/
|
|
33
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Add an element between each child.
|
|
37
|
+
*/
|
|
38
|
+
divider: PropTypes.node,
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Defines the space between immediate children.
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The system prop, which allows defining system overrides as well as additional CSS styles.
|
|
48
|
+
*/
|
|
49
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
50
|
+
} : void 0;
|
|
51
|
+
export default Stack;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["component", "direction", "spacing", "divider", "children", "className"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { deepmerge, unstable_composeClasses as composeClasses, unstable_generateUtilityClass as generateUtilityClass } from '@mui/utils';
|
|
8
|
+
import systemStyled from '../styled';
|
|
9
|
+
import useThemePropsSystem from '../useThemeProps';
|
|
10
|
+
import { extendSxProp } from '../styleFunctionSx';
|
|
11
|
+
import createTheme from '../createTheme';
|
|
12
|
+
import { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues } from '../breakpoints';
|
|
13
|
+
import { createUnarySpacing, getValue } from '../spacing';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
const defaultTheme = createTheme();
|
|
16
|
+
// widening Theme to any so that the consumer can own the theme structure.
|
|
17
|
+
const defaultCreateStyledComponent = systemStyled('div', {
|
|
18
|
+
name: 'MuiStack',
|
|
19
|
+
slot: 'Root',
|
|
20
|
+
overridesResolver: (props, styles) => styles.root
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function useThemePropsDefault(props) {
|
|
24
|
+
return useThemePropsSystem({
|
|
25
|
+
props,
|
|
26
|
+
name: 'MuiStack',
|
|
27
|
+
defaultTheme
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Return an array with the separator React element interspersed between
|
|
32
|
+
* each React node of the input children.
|
|
33
|
+
*
|
|
34
|
+
* > joinChildren([1,2,3], 0)
|
|
35
|
+
* [1,0,2,0,3]
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function joinChildren(children, separator) {
|
|
40
|
+
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
41
|
+
return childrenArray.reduce((output, child, index) => {
|
|
42
|
+
output.push(child);
|
|
43
|
+
|
|
44
|
+
if (index < childrenArray.length - 1) {
|
|
45
|
+
output.push( /*#__PURE__*/React.cloneElement(separator, {
|
|
46
|
+
key: `separator-${index}`
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return output;
|
|
51
|
+
}, []);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const getSideFromDirection = direction => {
|
|
55
|
+
return {
|
|
56
|
+
row: 'Left',
|
|
57
|
+
'row-reverse': 'Right',
|
|
58
|
+
column: 'Top',
|
|
59
|
+
'column-reverse': 'Bottom'
|
|
60
|
+
}[direction];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const style = ({
|
|
64
|
+
ownerState,
|
|
65
|
+
theme
|
|
66
|
+
}) => {
|
|
67
|
+
let styles = _extends({
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column'
|
|
70
|
+
}, handleBreakpoints({
|
|
71
|
+
theme
|
|
72
|
+
}, resolveBreakpointValues({
|
|
73
|
+
values: ownerState.direction,
|
|
74
|
+
breakpoints: theme.breakpoints.values
|
|
75
|
+
}), propValue => ({
|
|
76
|
+
flexDirection: propValue
|
|
77
|
+
})));
|
|
78
|
+
|
|
79
|
+
if (ownerState.spacing) {
|
|
80
|
+
const transformer = createUnarySpacing(theme);
|
|
81
|
+
const base = Object.keys(theme.breakpoints.values).reduce((acc, breakpoint) => {
|
|
82
|
+
if (typeof ownerState.spacing === 'object' && ownerState.spacing[breakpoint] != null || typeof ownerState.direction === 'object' && ownerState.direction[breakpoint] != null) {
|
|
83
|
+
acc[breakpoint] = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return acc;
|
|
87
|
+
}, {});
|
|
88
|
+
const directionValues = resolveBreakpointValues({
|
|
89
|
+
values: ownerState.direction,
|
|
90
|
+
base
|
|
91
|
+
});
|
|
92
|
+
const spacingValues = resolveBreakpointValues({
|
|
93
|
+
values: ownerState.spacing,
|
|
94
|
+
base
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (typeof directionValues === 'object') {
|
|
98
|
+
Object.keys(directionValues).forEach((breakpoint, index, breakpoints) => {
|
|
99
|
+
const directionValue = directionValues[breakpoint];
|
|
100
|
+
|
|
101
|
+
if (!directionValue) {
|
|
102
|
+
const previousDirectionValue = index > 0 ? directionValues[breakpoints[index - 1]] : 'column';
|
|
103
|
+
directionValues[breakpoint] = previousDirectionValue;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const styleFromPropValue = (propValue, breakpoint) => {
|
|
109
|
+
return {
|
|
110
|
+
'& > :not(style) + :not(style)': {
|
|
111
|
+
margin: 0,
|
|
112
|
+
[`margin${getSideFromDirection(breakpoint ? directionValues[breakpoint] : ownerState.direction)}`]: getValue(transformer, propValue)
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
styles = deepmerge(styles, handleBreakpoints({
|
|
118
|
+
theme
|
|
119
|
+
}, spacingValues, styleFromPropValue));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
styles = mergeBreakpointsInOrder(theme.breakpoints, styles);
|
|
123
|
+
return styles;
|
|
124
|
+
};
|
|
125
|
+
export default function createStack(options = {}) {
|
|
126
|
+
const {
|
|
127
|
+
// This will allow adding custom styled fn (for example for custom sx style function)
|
|
128
|
+
createStyledComponent = defaultCreateStyledComponent,
|
|
129
|
+
useThemeProps = useThemePropsDefault,
|
|
130
|
+
componentName = 'MuiStack'
|
|
131
|
+
} = options;
|
|
132
|
+
|
|
133
|
+
const useUtilityClasses = () => {
|
|
134
|
+
const slots = {
|
|
135
|
+
root: ['root']
|
|
136
|
+
};
|
|
137
|
+
return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const StackRoot = createStyledComponent(style);
|
|
141
|
+
const Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
|
|
142
|
+
const themeProps = useThemeProps(inProps);
|
|
143
|
+
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
144
|
+
|
|
145
|
+
const {
|
|
146
|
+
component = 'div',
|
|
147
|
+
direction = 'column',
|
|
148
|
+
spacing = 0,
|
|
149
|
+
divider,
|
|
150
|
+
children,
|
|
151
|
+
className
|
|
152
|
+
} = props,
|
|
153
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
154
|
+
|
|
155
|
+
const ownerState = {
|
|
156
|
+
direction,
|
|
157
|
+
spacing
|
|
158
|
+
};
|
|
159
|
+
const classes = useUtilityClasses();
|
|
160
|
+
return /*#__PURE__*/_jsx(StackRoot, _extends({
|
|
161
|
+
as: component,
|
|
162
|
+
ownerState: ownerState,
|
|
163
|
+
ref: ref,
|
|
164
|
+
className: clsx(classes.root, className)
|
|
165
|
+
}, other, {
|
|
166
|
+
children: divider ? joinChildren(children, divider) : children
|
|
167
|
+
}));
|
|
168
|
+
});
|
|
169
|
+
process.env.NODE_ENV !== "production" ? Stack.propTypes
|
|
170
|
+
/* remove-proptypes */
|
|
171
|
+
= {
|
|
172
|
+
children: PropTypes.node,
|
|
173
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
174
|
+
divider: PropTypes.node,
|
|
175
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
176
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
177
|
+
} : void 0;
|
|
178
|
+
return Stack;
|
|
179
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { unstable_generateUtilityClass as generateUtilityClass, unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
|
|
2
|
+
export function getStackUtilityClass(slot) {
|
|
3
|
+
return generateUtilityClass('MuiStack', slot);
|
|
4
|
+
}
|
|
5
|
+
const stackClasses = generateUtilityClasses('MuiStack', ['root']);
|
|
6
|
+
export default stackClasses;
|
package/modern/createBox.js
CHANGED
|
@@ -14,7 +14,9 @@ export default function createBox(options = {}) {
|
|
|
14
14
|
generateClassName,
|
|
15
15
|
styleFunctionSx = defaultStyleFunctionSx
|
|
16
16
|
} = options;
|
|
17
|
-
const BoxRoot = styled('div'
|
|
17
|
+
const BoxRoot = styled('div', {
|
|
18
|
+
shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
|
|
19
|
+
})(styleFunctionSx);
|
|
18
20
|
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
19
21
|
const theme = useTheme(defaultTheme);
|
|
20
22
|
|
package/modern/createStyled.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"],
|
|
4
4
|
_excluded2 = ["theme"],
|
|
5
5
|
_excluded3 = ["theme"];
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
/* eslint-disable no-underscore-dangle */
|
|
8
|
+
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
7
9
|
import { getDisplayName } from '@mui/utils';
|
|
8
10
|
import createTheme from './createTheme';
|
|
9
11
|
import propsToClassKey from './propsToClassKey';
|
|
@@ -11,6 +13,14 @@ import defaultStyleFunctionSx from './styleFunctionSx';
|
|
|
11
13
|
|
|
12
14
|
function isEmpty(obj) {
|
|
13
15
|
return Object.keys(obj).length === 0;
|
|
16
|
+
} // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function isStringTag(tag) {
|
|
20
|
+
return typeof tag === 'string' && // 96 is one less than the char code
|
|
21
|
+
// for "a" so this is checking that
|
|
22
|
+
// it's a lowercase character
|
|
23
|
+
tag.charCodeAt(0) > 96;
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
const getStyleOverrides = (name, theme) => {
|
|
@@ -78,7 +88,19 @@ export default function createStyled(input = {}) {
|
|
|
78
88
|
slotShouldForwardProp = shouldForwardProp,
|
|
79
89
|
styleFunctionSx = defaultStyleFunctionSx
|
|
80
90
|
} = input;
|
|
91
|
+
|
|
92
|
+
const systemSx = props => {
|
|
93
|
+
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
94
|
+
return styleFunctionSx(_extends({}, props, {
|
|
95
|
+
theme
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
systemSx.__mui_systemSx = true;
|
|
81
100
|
return (tag, inputOptions = {}) => {
|
|
101
|
+
// Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
|
|
102
|
+
processStyles(tag, styles => styles.filter(style => !style?.__mui_systemSx));
|
|
103
|
+
|
|
82
104
|
const {
|
|
83
105
|
name: componentName,
|
|
84
106
|
slot: componentSlot,
|
|
@@ -106,6 +128,9 @@ export default function createStyled(input = {}) {
|
|
|
106
128
|
} else if (componentSlot) {
|
|
107
129
|
// any other slot specified
|
|
108
130
|
shouldForwardPropOption = slotShouldForwardProp;
|
|
131
|
+
} else if (isStringTag(tag)) {
|
|
132
|
+
// for string (html) tag, preserve the behavior in emotion & styled-components.
|
|
133
|
+
shouldForwardPropOption = undefined;
|
|
109
134
|
}
|
|
110
135
|
|
|
111
136
|
const defaultStyledResolver = styledEngineStyled(tag, _extends({
|
|
@@ -118,7 +143,6 @@ export default function createStyled(input = {}) {
|
|
|
118
143
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
119
144
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
120
145
|
// which are basically components used as a selectors.
|
|
121
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
122
146
|
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? _ref => {
|
|
123
147
|
let {
|
|
124
148
|
theme: themeInput
|
|
@@ -159,12 +183,7 @@ export default function createStyled(input = {}) {
|
|
|
159
183
|
}
|
|
160
184
|
|
|
161
185
|
if (!skipSx) {
|
|
162
|
-
expressionsWithDefaultTheme.push(
|
|
163
|
-
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
164
|
-
return styleFunctionSx(_extends({}, props, {
|
|
165
|
-
theme
|
|
166
|
-
}));
|
|
167
|
-
});
|
|
186
|
+
expressionsWithDefaultTheme.push(systemSx);
|
|
168
187
|
}
|
|
169
188
|
|
|
170
189
|
const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
|
|
@@ -177,7 +196,6 @@ export default function createStyled(input = {}) {
|
|
|
177
196
|
} else if (typeof styleArg === 'function' && // On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
178
197
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
179
198
|
// which are basically components used as a selectors.
|
|
180
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
181
199
|
styleArg.__emotion_real !== styleArg) {
|
|
182
200
|
// If the type is function, we need to define the default theme.
|
|
183
201
|
transformedStyleArg = _ref2 => {
|