paradiego
This commit is contained in:
294
node_modules/@mui/system/modern/styleFunctionSx/defaultSxConfig.js
generated
vendored
Normal file
294
node_modules/@mui/system/modern/styleFunctionSx/defaultSxConfig.js
generated
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
import { padding, margin } from "../spacing/index.js";
|
||||
import { borderRadius, borderTransform } from "../borders/index.js";
|
||||
import { gap, rowGap, columnGap } from "../cssGrid/index.js";
|
||||
import { paletteTransform } from "../palette/index.js";
|
||||
import { maxWidth, sizingTransform } from "../sizing/index.js";
|
||||
const defaultSxConfig = {
|
||||
// borders
|
||||
border: {
|
||||
themeKey: 'borders',
|
||||
transform: borderTransform
|
||||
},
|
||||
borderTop: {
|
||||
themeKey: 'borders',
|
||||
transform: borderTransform
|
||||
},
|
||||
borderRight: {
|
||||
themeKey: 'borders',
|
||||
transform: borderTransform
|
||||
},
|
||||
borderBottom: {
|
||||
themeKey: 'borders',
|
||||
transform: borderTransform
|
||||
},
|
||||
borderLeft: {
|
||||
themeKey: 'borders',
|
||||
transform: borderTransform
|
||||
},
|
||||
borderColor: {
|
||||
themeKey: 'palette'
|
||||
},
|
||||
borderTopColor: {
|
||||
themeKey: 'palette'
|
||||
},
|
||||
borderRightColor: {
|
||||
themeKey: 'palette'
|
||||
},
|
||||
borderBottomColor: {
|
||||
themeKey: 'palette'
|
||||
},
|
||||
borderLeftColor: {
|
||||
themeKey: 'palette'
|
||||
},
|
||||
outline: {
|
||||
themeKey: 'borders',
|
||||
transform: borderTransform
|
||||
},
|
||||
outlineColor: {
|
||||
themeKey: 'palette'
|
||||
},
|
||||
borderRadius: {
|
||||
themeKey: 'shape.borderRadius',
|
||||
style: borderRadius
|
||||
},
|
||||
// palette
|
||||
color: {
|
||||
themeKey: 'palette',
|
||||
transform: paletteTransform
|
||||
},
|
||||
bgcolor: {
|
||||
themeKey: 'palette',
|
||||
cssProperty: 'backgroundColor',
|
||||
transform: paletteTransform
|
||||
},
|
||||
backgroundColor: {
|
||||
themeKey: 'palette',
|
||||
transform: paletteTransform
|
||||
},
|
||||
// spacing
|
||||
p: {
|
||||
style: padding
|
||||
},
|
||||
pt: {
|
||||
style: padding
|
||||
},
|
||||
pr: {
|
||||
style: padding
|
||||
},
|
||||
pb: {
|
||||
style: padding
|
||||
},
|
||||
pl: {
|
||||
style: padding
|
||||
},
|
||||
px: {
|
||||
style: padding
|
||||
},
|
||||
py: {
|
||||
style: padding
|
||||
},
|
||||
padding: {
|
||||
style: padding
|
||||
},
|
||||
paddingTop: {
|
||||
style: padding
|
||||
},
|
||||
paddingRight: {
|
||||
style: padding
|
||||
},
|
||||
paddingBottom: {
|
||||
style: padding
|
||||
},
|
||||
paddingLeft: {
|
||||
style: padding
|
||||
},
|
||||
paddingX: {
|
||||
style: padding
|
||||
},
|
||||
paddingY: {
|
||||
style: padding
|
||||
},
|
||||
paddingInline: {
|
||||
style: padding
|
||||
},
|
||||
paddingInlineStart: {
|
||||
style: padding
|
||||
},
|
||||
paddingInlineEnd: {
|
||||
style: padding
|
||||
},
|
||||
paddingBlock: {
|
||||
style: padding
|
||||
},
|
||||
paddingBlockStart: {
|
||||
style: padding
|
||||
},
|
||||
paddingBlockEnd: {
|
||||
style: padding
|
||||
},
|
||||
m: {
|
||||
style: margin
|
||||
},
|
||||
mt: {
|
||||
style: margin
|
||||
},
|
||||
mr: {
|
||||
style: margin
|
||||
},
|
||||
mb: {
|
||||
style: margin
|
||||
},
|
||||
ml: {
|
||||
style: margin
|
||||
},
|
||||
mx: {
|
||||
style: margin
|
||||
},
|
||||
my: {
|
||||
style: margin
|
||||
},
|
||||
margin: {
|
||||
style: margin
|
||||
},
|
||||
marginTop: {
|
||||
style: margin
|
||||
},
|
||||
marginRight: {
|
||||
style: margin
|
||||
},
|
||||
marginBottom: {
|
||||
style: margin
|
||||
},
|
||||
marginLeft: {
|
||||
style: margin
|
||||
},
|
||||
marginX: {
|
||||
style: margin
|
||||
},
|
||||
marginY: {
|
||||
style: margin
|
||||
},
|
||||
marginInline: {
|
||||
style: margin
|
||||
},
|
||||
marginInlineStart: {
|
||||
style: margin
|
||||
},
|
||||
marginInlineEnd: {
|
||||
style: margin
|
||||
},
|
||||
marginBlock: {
|
||||
style: margin
|
||||
},
|
||||
marginBlockStart: {
|
||||
style: margin
|
||||
},
|
||||
marginBlockEnd: {
|
||||
style: margin
|
||||
},
|
||||
// display
|
||||
displayPrint: {
|
||||
cssProperty: false,
|
||||
transform: value => ({
|
||||
'@media print': {
|
||||
display: value
|
||||
}
|
||||
})
|
||||
},
|
||||
display: {},
|
||||
overflow: {},
|
||||
textOverflow: {},
|
||||
visibility: {},
|
||||
whiteSpace: {},
|
||||
// flexbox
|
||||
flexBasis: {},
|
||||
flexDirection: {},
|
||||
flexWrap: {},
|
||||
justifyContent: {},
|
||||
alignItems: {},
|
||||
alignContent: {},
|
||||
order: {},
|
||||
flex: {},
|
||||
flexGrow: {},
|
||||
flexShrink: {},
|
||||
alignSelf: {},
|
||||
justifyItems: {},
|
||||
justifySelf: {},
|
||||
// grid
|
||||
gap: {
|
||||
style: gap
|
||||
},
|
||||
rowGap: {
|
||||
style: rowGap
|
||||
},
|
||||
columnGap: {
|
||||
style: columnGap
|
||||
},
|
||||
gridColumn: {},
|
||||
gridRow: {},
|
||||
gridAutoFlow: {},
|
||||
gridAutoColumns: {},
|
||||
gridAutoRows: {},
|
||||
gridTemplateColumns: {},
|
||||
gridTemplateRows: {},
|
||||
gridTemplateAreas: {},
|
||||
gridArea: {},
|
||||
// positions
|
||||
position: {},
|
||||
zIndex: {
|
||||
themeKey: 'zIndex'
|
||||
},
|
||||
top: {},
|
||||
right: {},
|
||||
bottom: {},
|
||||
left: {},
|
||||
// shadows
|
||||
boxShadow: {
|
||||
themeKey: 'shadows'
|
||||
},
|
||||
// sizing
|
||||
width: {
|
||||
transform: sizingTransform
|
||||
},
|
||||
maxWidth: {
|
||||
style: maxWidth
|
||||
},
|
||||
minWidth: {
|
||||
transform: sizingTransform
|
||||
},
|
||||
height: {
|
||||
transform: sizingTransform
|
||||
},
|
||||
maxHeight: {
|
||||
transform: sizingTransform
|
||||
},
|
||||
minHeight: {
|
||||
transform: sizingTransform
|
||||
},
|
||||
boxSizing: {},
|
||||
// typography
|
||||
font: {
|
||||
themeKey: 'font'
|
||||
},
|
||||
fontFamily: {
|
||||
themeKey: 'typography'
|
||||
},
|
||||
fontSize: {
|
||||
themeKey: 'typography'
|
||||
},
|
||||
fontStyle: {
|
||||
themeKey: 'typography'
|
||||
},
|
||||
fontWeight: {
|
||||
themeKey: 'typography'
|
||||
},
|
||||
letterSpacing: {},
|
||||
textTransform: {},
|
||||
lineHeight: {},
|
||||
textAlign: {},
|
||||
typography: {
|
||||
cssProperty: false,
|
||||
themeKey: 'typography'
|
||||
}
|
||||
};
|
||||
export default defaultSxConfig;
|
||||
51
node_modules/@mui/system/modern/styleFunctionSx/extendSxProp.js
generated
vendored
Normal file
51
node_modules/@mui/system/modern/styleFunctionSx/extendSxProp.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { isPlainObject } from '@mui/utils/deepmerge';
|
||||
import defaultSxConfig from "./defaultSxConfig.js";
|
||||
const splitProps = props => {
|
||||
const result = {
|
||||
systemProps: {},
|
||||
otherProps: {}
|
||||
};
|
||||
const config = props?.theme?.unstable_sxConfig ?? defaultSxConfig;
|
||||
Object.keys(props).forEach(prop => {
|
||||
if (config[prop]) {
|
||||
result.systemProps[prop] = props[prop];
|
||||
} else {
|
||||
result.otherProps[prop] = props[prop];
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
export default function extendSxProp(props) {
|
||||
const {
|
||||
sx: inSx,
|
||||
...other
|
||||
} = props;
|
||||
const {
|
||||
systemProps,
|
||||
otherProps
|
||||
} = splitProps(other);
|
||||
let finalSx;
|
||||
if (Array.isArray(inSx)) {
|
||||
finalSx = [systemProps, ...inSx];
|
||||
} else if (typeof inSx === 'function') {
|
||||
finalSx = (...args) => {
|
||||
const result = inSx(...args);
|
||||
if (!isPlainObject(result)) {
|
||||
return systemProps;
|
||||
}
|
||||
return {
|
||||
...systemProps,
|
||||
...result
|
||||
};
|
||||
};
|
||||
} else {
|
||||
finalSx = {
|
||||
...systemProps,
|
||||
...inSx
|
||||
};
|
||||
}
|
||||
return {
|
||||
...otherProps,
|
||||
sx: finalSx
|
||||
};
|
||||
}
|
||||
4
node_modules/@mui/system/modern/styleFunctionSx/index.js
generated
vendored
Normal file
4
node_modules/@mui/system/modern/styleFunctionSx/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { default } from "./styleFunctionSx.js";
|
||||
export { unstable_createStyleFunctionSx } from "./styleFunctionSx.js";
|
||||
export { default as extendSxProp } from "./extendSxProp.js";
|
||||
export { default as unstable_defaultSxConfig } from "./defaultSxConfig.js";
|
||||
127
node_modules/@mui/system/modern/styleFunctionSx/styleFunctionSx.js
generated
vendored
Normal file
127
node_modules/@mui/system/modern/styleFunctionSx/styleFunctionSx.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import capitalize from '@mui/utils/capitalize';
|
||||
import merge from "../merge/index.js";
|
||||
import { getPath, getStyleValue as getValue } from "../style/index.js";
|
||||
import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from "../breakpoints/index.js";
|
||||
import { sortContainerQueries } from "../cssContainerQueries/index.js";
|
||||
import defaultSxConfig from "./defaultSxConfig.js";
|
||||
function objectsHaveSameKeys(...objects) {
|
||||
const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
|
||||
const union = new Set(allKeys);
|
||||
return objects.every(object => union.size === Object.keys(object).length);
|
||||
}
|
||||
function callIfFn(maybeFn, arg) {
|
||||
return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export function unstable_createStyleFunctionSx() {
|
||||
function getThemeValue(prop, val, theme, config) {
|
||||
const props = {
|
||||
[prop]: val,
|
||||
theme
|
||||
};
|
||||
const options = config[prop];
|
||||
if (!options) {
|
||||
return {
|
||||
[prop]: val
|
||||
};
|
||||
}
|
||||
const {
|
||||
cssProperty = prop,
|
||||
themeKey,
|
||||
transform,
|
||||
style
|
||||
} = options;
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO v6: remove, see https://github.com/mui/material-ui/pull/38123
|
||||
if (themeKey === 'typography' && val === 'inherit') {
|
||||
return {
|
||||
[prop]: val
|
||||
};
|
||||
}
|
||||
const themeMapping = getPath(theme, themeKey) || {};
|
||||
if (style) {
|
||||
return style(props);
|
||||
}
|
||||
const styleFromPropValue = propValueFinal => {
|
||||
let value = getValue(themeMapping, transform, propValueFinal);
|
||||
if (propValueFinal === value && typeof propValueFinal === 'string') {
|
||||
// Haven't found value
|
||||
value = getValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
|
||||
}
|
||||
if (cssProperty === false) {
|
||||
return value;
|
||||
}
|
||||
return {
|
||||
[cssProperty]: value
|
||||
};
|
||||
};
|
||||
return handleBreakpoints(props, val, styleFromPropValue);
|
||||
}
|
||||
function styleFunctionSx(props) {
|
||||
const {
|
||||
sx,
|
||||
theme = {}
|
||||
} = props || {};
|
||||
if (!sx) {
|
||||
return null; // Emotion & styled-components will neglect null
|
||||
}
|
||||
const config = theme.unstable_sxConfig ?? defaultSxConfig;
|
||||
|
||||
/*
|
||||
* Receive `sxInput` as object or callback
|
||||
* and then recursively check keys & values to create media query object styles.
|
||||
* (the result will be used in `styled`)
|
||||
*/
|
||||
function traverse(sxInput) {
|
||||
let sxObject = sxInput;
|
||||
if (typeof sxInput === 'function') {
|
||||
sxObject = sxInput(theme);
|
||||
} else if (typeof sxInput !== 'object') {
|
||||
// value
|
||||
return sxInput;
|
||||
}
|
||||
if (!sxObject) {
|
||||
return null;
|
||||
}
|
||||
const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
|
||||
const breakpointsKeys = Object.keys(emptyBreakpoints);
|
||||
let css = emptyBreakpoints;
|
||||
Object.keys(sxObject).forEach(styleKey => {
|
||||
const value = callIfFn(sxObject[styleKey], theme);
|
||||
if (value !== null && value !== undefined) {
|
||||
if (typeof value === 'object') {
|
||||
if (config[styleKey]) {
|
||||
css = merge(css, getThemeValue(styleKey, value, theme, config));
|
||||
} else {
|
||||
const breakpointsValues = handleBreakpoints({
|
||||
theme
|
||||
}, value, x => ({
|
||||
[styleKey]: x
|
||||
}));
|
||||
if (objectsHaveSameKeys(breakpointsValues, value)) {
|
||||
css[styleKey] = styleFunctionSx({
|
||||
sx: value,
|
||||
theme
|
||||
});
|
||||
} else {
|
||||
css = merge(css, breakpointsValues);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
css = merge(css, getThemeValue(styleKey, value, theme, config));
|
||||
}
|
||||
}
|
||||
});
|
||||
return sortContainerQueries(theme, removeUnusedBreakpoints(breakpointsKeys, css));
|
||||
}
|
||||
return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
|
||||
}
|
||||
return styleFunctionSx;
|
||||
}
|
||||
const styleFunctionSx = unstable_createStyleFunctionSx();
|
||||
styleFunctionSx.filterProps = ['sx'];
|
||||
export default styleFunctionSx;
|
||||
Reference in New Issue
Block a user