Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui] Migrate components to support CSS extraction #42001

Merged
merged 66 commits into from May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b2507ee
migrate Icon
siriwatknp Apr 22, 2024
43803b1
migrate Dialog
siriwatknp Apr 22, 2024
317d955
migrate DialogActions
siriwatknp Apr 22, 2024
e59eee1
fix MemberExpression case
siriwatknp Apr 22, 2024
fc9c76d
migrate DialogContent
siriwatknp Apr 22, 2024
956f331
migrate DialogContentText
siriwatknp Apr 22, 2024
76a6ecb
migrate Drawer
siriwatknp Apr 22, 2024
83d8839
migrate Input
siriwatknp Apr 22, 2024
9206dd0
migrate InputAdornment
siriwatknp Apr 22, 2024
da3fef1
migrate InputBase
siriwatknp Apr 22, 2024
5f3d249
migrate OutlinedInput
siriwatknp Apr 22, 2024
2fce0ca
migrate TablePagination
siriwatknp Apr 22, 2024
41e9737
migrate InputLabel
siriwatknp Apr 22, 2024
eb821da
migrate Menu
siriwatknp Apr 22, 2024
c02207e
migrate Paper
siriwatknp Apr 22, 2024
ee3f1b6
migrate Skeleton
siriwatknp Apr 22, 2024
6d7989f
migrate Snackbar
siriwatknp Apr 22, 2024
f1eb8bf
migrate SpeedDial
siriwatknp Apr 22, 2024
988a6bf
migrate Tabs
siriwatknp Apr 22, 2024
a50ba76
migrate Tooltip
siriwatknp Apr 22, 2024
a6133d5
run docs:api
siriwatknp Apr 23, 2024
1c56fe5
fix lint
siriwatknp Apr 23, 2024
984e7ca
fix snackbar
siriwatknp Apr 23, 2024
6c17d04
remove xs
siriwatknp Apr 23, 2024
d9a858f
shorten icon
siriwatknp Apr 23, 2024
7c0fa9d
fix comment
siriwatknp Apr 23, 2024
6c2ea6f
fix Icon metadata
siriwatknp Apr 24, 2024
68c95ea
add explicit disableRipple
siriwatknp Apr 25, 2024
089feb5
migrate SwitchBase
siriwatknp Apr 25, 2024
942490b
add demo pages
siriwatknp Apr 25, 2024
c554e62
Merge branch 'next' of https://github.com/mui/material-ui into mui/cs…
siriwatknp Apr 29, 2024
3392cbe
migrate FilledInput
siriwatknp Apr 29, 2024
8685c92
use direct module
siriwatknp Apr 29, 2024
1a10ef5
migrate the rest
siriwatknp Apr 29, 2024
920a703
migrate Collapse
siriwatknp Apr 30, 2024
7e6e5fa
migrate BreadcrumbCollapsed
siriwatknp Apr 30, 2024
3727c6f
migrate the rest
siriwatknp Apr 30, 2024
6e2269d
fixes
siriwatknp Apr 30, 2024
023c2a8
remove unparsable sx demo
siriwatknp Apr 30, 2024
2b91598
add component check
siriwatknp Apr 30, 2024
7832e33
remove unparsable sx demos
siriwatknp May 1, 2024
91034bf
update pigment to latest
siriwatknp May 1, 2024
ea0a80d
pnpm dedupe
siriwatknp May 1, 2024
9e78be7
Merge branch 'next' of https://github.com/mui/material-ui into mui/cs…
siriwatknp May 1, 2024
33445aa
update lock file
siriwatknp May 1, 2024
6be45c1
fix FormLabel
siriwatknp May 1, 2024
fb84a93
Merge branch 'next' of https://github.com/mui/material-ui into mui/cs…
siriwatknp May 2, 2024
c62d85a
revert demo pages
siriwatknp May 2, 2024
002bf22
test ci without macos
siriwatknp May 2, 2024
f9e5c59
remove unnecessary change
siriwatknp May 2, 2024
e59210f
fix FormLabel
siriwatknp May 2, 2024
0cb1f75
Fix NativeSelectInput
siriwatknp May 2, 2024
f76758f
revert ci change
siriwatknp May 2, 2024
0eefa24
set mem to 4GB
siriwatknp May 2, 2024
2ea2584
migrate Typography
siriwatknp May 3, 2024
444a60f
migrate Link
siriwatknp May 3, 2024
d07e032
add workaround for toString error
siriwatknp May 3, 2024
15c782e
migrate LoadingButton
siriwatknp May 3, 2024
e7b3f84
fix test
siriwatknp May 3, 2024
1ea30b0
bring back sx insertion
siriwatknp May 3, 2024
11f5c47
run proptypes
siriwatknp May 3, 2024
6d0c54d
fix lint
siriwatknp May 3, 2024
279e4cc
Merge branch 'next' of https://github.com/mui/material-ui into mui/cs…
siriwatknp May 3, 2024
fb57ad7
move other.style to last
siriwatknp May 6, 2024
1276d4e
update comment as suggeste
siriwatknp May 6, 2024
cb85122
Merge branch 'next' of https://github.com/mui/material-ui into mui/cs…
siriwatknp May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pages/material-ui/api/input.json
Expand Up @@ -19,7 +19,7 @@
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
"disableUnderline": { "type": { "name": "bool" } },
"disableUnderline": { "type": { "name": "bool" }, "default": "false" },
"endAdornment": { "type": { "name": "node" } },
"error": { "type": { "name": "bool" } },
"fullWidth": { "type": { "name": "bool" }, "default": "false" },
Expand Down
63 changes: 33 additions & 30 deletions packages/mui-codemod/src/v6.0.0/styled/styled-v6.js
Expand Up @@ -15,7 +15,7 @@ export default function styledV6(file, api, options) {
if (key.type === 'Identifier' || key.type === 'StringLiteral') {
return upperBuildStyle(j.objectExpression([j.objectProperty(key, styleExpression)]));
}
if (key.type === 'TemplateLiteral') {
if (key.type === 'TemplateLiteral' || key.type === 'CallExpression') {
return upperBuildStyle(
j.objectExpression([
{
Expand Down Expand Up @@ -84,10 +84,10 @@ export default function styledV6(file, api, options) {

/**
*
* @param {import('ast-types').namedTypes.Identifier | import('ast-types').namedTypes.BinaryExpression | import('ast-types').namedTypes.UnaryExpression} node
* @param {import('ast-types').namedTypes.Identifier | import('ast-types').namedTypes.BinaryExpression | import('ast-types').namedTypes.UnaryExpression | import('ast-types').namedTypes.MemberExpression} node
*/
function inverseBinaryExpression(node) {
if (node.type === 'Identifier') {
if (node.type === 'Identifier' || node.type === 'MemberExpression') {
return j.unaryExpression('!', node);
}
if (node.operator === '===') {
Expand Down Expand Up @@ -343,7 +343,7 @@ export default function styledV6(file, api, options) {
return (
props &&
styleVal &&
styleVal.value.properties.length > 0 &&
(!styleVal.value.properties || styleVal.value.properties.length > 0) &&
(props.value.type === 'ArrowFunctionExpression' ||
props.value.properties.length > 0)
);
Expand Down Expand Up @@ -384,7 +384,7 @@ export default function styledV6(file, api, options) {
if (data.node.type === 'SpreadElement') {
if (data.node.argument.type === 'LogicalExpression') {
const paramName = getObjectKey(data.node.argument.left)?.name;
if (paramName && !parameters.has(paramName)) {
if (paramName && (paramName === 'theme' || !parameters.has(paramName))) {
return;
}

Expand All @@ -397,30 +397,32 @@ export default function styledV6(file, api, options) {
const lastLength = variants.push({}); // preserve the order of the recursive calls

const modeStyles = {}; // to collect styles from `theme.palette.mode === '...'`
variant.style.properties.forEach((prop) => {
if (prop.type === 'ObjectProperty') {
recurseObjectExpression({
...data,
node: prop.value,
parentNode: variant.style,
props: variant.props,
key: prop.key,
buildStyle: createBuildStyle(prop.key, data.buildStyle),
replaceValue: (newValue) => {
prop.value = newValue;
},
modeStyles,
});
} else {
recurseObjectExpression({
...data,
node: prop,
parentNode: variant.style,
props: variant.props,
buildStyle: createBuildStyle(prop.key, data.buildStyle),
});
}
});
if (variant.style.type === 'ObjectExpression') {
variant.style.properties.forEach((prop) => {
if (prop.type === 'ObjectProperty') {
recurseObjectExpression({
...data,
node: prop.value,
parentNode: variant.style,
props: variant.props,
key: prop.key,
buildStyle: createBuildStyle(prop.key, data.buildStyle),
replaceValue: (newValue) => {
prop.value = newValue;
},
modeStyles,
});
} else {
recurseObjectExpression({
...data,
node: prop,
parentNode: variant.style,
props: variant.props,
buildStyle: createBuildStyle(prop.key, data.buildStyle),
});
}
});
}
appendPaletteModeStyles(variant.style, modeStyles);
variant.style = data.buildStyle(variant.style);
variants[lastLength - 1] = buildObjectAST(variant);
Expand All @@ -439,7 +441,8 @@ export default function styledV6(file, api, options) {
if (
data.node.test.type === 'BinaryExpression' ||
data.node.test.type === 'UnaryExpression' ||
data.node.test.type === 'Identifier'
data.node.test.type === 'Identifier' ||
data.node.test.type === 'MemberExpression'
) {
let leftName = getObjectKey(data.node.test)?.name;
if (data.node.test.left) {
Expand Down
Expand Up @@ -123,3 +123,30 @@ const StyledAppContainer = styled(AppContainer, {
},
};
});

const DialogContentRoot = styled('div', {
name: 'MuiDialogContent',
slot: 'Root',
overridesResolver: (props, styles) => {
const { ownerState } = props;

return [styles.root, ownerState.dividers && styles.dividers];
},
})(({ theme, ownerState }) => ({
flex: '1 1 auto',
// Add iOS momentum scrolling for iOS < 13.0
WebkitOverflowScrolling: 'touch',
overflowY: 'auto',
padding: '20px 24px',
...(ownerState.dividers
? {
padding: '16px 24px',
borderTop: `1px solid ${(theme.vars || theme).palette.divider}`,
borderBottom: `1px solid ${(theme.vars || theme).palette.divider}`,
}
: {
[`.${dialogTitleClasses.root} + &`]: {
paddingTop: 0,
},
}),
}));
Expand Up @@ -230,3 +230,44 @@ const StyledAppContainer = styled(AppContainer, {
}]
};
});

const DialogContentRoot = styled('div', {
name: 'MuiDialogContent',
slot: 'Root',
overridesResolver: (props, styles) => {
const { ownerState } = props;

return [styles.root, ownerState.dividers && styles.dividers];
},
})(({
theme
}) => ({
flex: '1 1 auto',
// Add iOS momentum scrolling for iOS < 13.0
WebkitOverflowScrolling: 'touch',
overflowY: 'auto',
padding: '20px 24px',
variants: [{
props: (
{
ownerState
}
) => ownerState.dividers,
style: {
padding: '16px 24px',
borderTop: `1px solid ${(theme.vars || theme).palette.divider}`,
borderBottom: `1px solid ${(theme.vars || theme).palette.divider}`,
}
}, {
props: (
{
ownerState
}
) => !ownerState.dividers,
style: {
[`.${dialogTitleClasses.root} + &`]: {
paddingTop: 0,
},
}
}]
}));