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 57 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
- run: pnpm install
- run: pnpm build:ci
env:
NODE_OPTIONS: --max_old_space_size=4096
- run: pnpm release:changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
27 changes: 27 additions & 0 deletions apps/pigment-css-next-app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ theme.getColorSchemeSelector = (colorScheme) => {
return `@media (prefers-color-scheme: ${colorScheme})`;
};

function innerNoop() {
return null;
}
function outerNoop() {
return innerNoop;
}

/**
* @type {PigmentOptions}
*/
Expand All @@ -104,6 +111,26 @@ const pigmentOptions = {
transformLibraries: ['local-ui-lib'],
sourceMap: true,
displayName: true,
overrideContext: (context) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A workaround for mui/pigment-css#10

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this here fixes the issue? Should this then be made part of the library itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can confirm that this prevents the error. I added here just to be a workaround but if you think it should be a part of Pigment, I am happy to add it. However, I think it should be a separate package for integrating with MUI system, not a part of nextjs/vite plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this would be required for every project that uses Material UI and Pigment CSS, we should make it part of the library. Do we know why it is required tough? Maybe we are fixing a symptom, not the problem

Copy link
Contributor

@o-alexandrov o-alexandrov May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably related issue: mui/pigment-css#8

if (!context.$RefreshSig$) {
context.$RefreshSig$ = outerNoop;
}
return {
...context,
require: (id) => {
if (id === '@mui/styled-engine' || id === '@mui/styled-engine-sc') {
return {
__esModule: true,
default: () => () => () => null,
internal_processStyles: () => {},
keyframes: () => '',
css: () => '',
};
}
return context.require(id);
},
};
},
};

/** @type {import('next').NextConfig} */
Expand Down
4 changes: 2 additions & 2 deletions apps/pigment-css-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"clean": "rimraf .next"
},
"dependencies": {
"@pigment-css/react": "^0.0.9",
"@pigment-css/react": "^0.0.10",
"@mui/utils": "workspace:^",
"@mui/base": "workspace:^",
"@mui/lab": "workspace:^",
Expand All @@ -24,7 +24,7 @@
"next": "latest"
},
"devDependencies": {
"@pigment-css/nextjs-plugin": "^0.0.9",
"@pigment-css/nextjs-plugin": "^0.0.10",
"@types/node": "^20.5.7",
"@types/react": "^18.2.55",
"@types/react-dom": "^18.3.0",
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/material-ui/api/filled-input.json
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion docs/pages/material-ui/api/input.json
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@mui/utils": "workspace:^",
"@next/eslint-plugin-next": "^14.2.3",
"@octokit/rest": "^20.1.0",
"@pigment-css/react": "^0.0.9",
"@pigment-css/react": "^0.0.10",
"@playwright/test": "1.43.1",
"@types/enzyme": "^3.10.18",
"@types/fs-extra": "^11.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { emphasize } from '@mui/system/colorManipulator';
import styled from '../styles/styled';
import { styled } from '../zero-styled';
import MoreHorizIcon from '../internal/svg-icons/MoreHoriz';
import ButtonBase from '../ButtonBase';

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import clsx from 'clsx';
import resolveProps from '@mui/utils/resolveProps';
import composeClasses from '@mui/utils/composeClasses';
import { alpha } from '@mui/system/colorManipulator';
import { rootShouldForwardProp } from '../styles/styled';
import rootShouldForwardProp from '../styles/rootShouldForwardProp';
import { styled, createUseThemeProps } from '../zero-styled';
import ButtonBase from '../ButtonBase';
import capitalize from '../utils/capitalize';
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-material/src/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const Checkbox = React.forwardRef(function Checkbox(inProps, ref) {
indeterminateIcon: indeterminateIconProp = defaultIndeterminateIcon,
inputProps,
size = 'medium',
disableRipple = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with this change?

Copy link
Member Author

@siriwatknp siriwatknp May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, variants won't work because disabled=undefined

variants: [
  { props: { color: 'default', disableRipple: false } }, style: {} },
]

className,
...other
} = props;
Expand All @@ -126,6 +127,7 @@ const Checkbox = React.forwardRef(function Checkbox(inProps, ref) {

const ownerState = {
...props,
disableRipple,
color,
indeterminate,
size,
Expand Down
103 changes: 70 additions & 33 deletions packages/mui-material/src/Collapse/Collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { Transition } from 'react-transition-group';
import useTimeout from '@mui/utils/useTimeout';
import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
import composeClasses from '@mui/utils/composeClasses';
import styled from '../styles/styled';
import useThemeProps from '../styles/useThemeProps';
import { styled, createUseThemeProps } from '../zero-styled';
import { duration } from '../styles/createTransitions';
import { getTransitionProps } from '../transitions/utils';
import useTheme from '../styles/useTheme';
import { useForkRef } from '../utils';
import { getCollapseUtilityClass } from './collapseClasses';

const useThemeProps = createUseThemeProps('MuiCollapse');

const useUtilityClasses = (ownerState) => {
const { orientation, classes } = ownerState;

Expand Down Expand Up @@ -44,54 +45,88 @@ const CollapseRoot = styled('div', {
styles.hidden,
];
},
})(({ theme, ownerState }) => ({
})(({ theme }) => ({
height: 0,
overflow: 'hidden',
transition: theme.transitions.create('height'),
...(ownerState.orientation === 'horizontal' && {
height: 'auto',
width: 0,
transition: theme.transitions.create('width'),
}),
...(ownerState.state === 'entered' && {
height: 'auto',
overflow: 'visible',
...(ownerState.orientation === 'horizontal' && {
width: 'auto',
}),
}),
...(ownerState.state === 'exited' &&
!ownerState.in &&
ownerState.collapsedSize === '0px' && {
visibility: 'hidden',
}),
variants: [
{
props: {
orientation: 'horizontal',
},
style: {
height: 'auto',
width: 0,
transition: theme.transitions.create('width'),
},
},
{
props: {
state: 'entered',
},
style: {
height: 'auto',
overflow: 'visible',
},
},
{
props: {
state: 'entered',
orientation: 'horizontal',
},
style: {
width: 'auto',
},
},
{
props: ({ ownerState }) =>
ownerState.state === 'exited' && !ownerState.in && ownerState.collapsedSize === '0px',
style: {
visibility: 'hidden',
},
},
],
}));

const CollapseWrapper = styled('div', {
name: 'MuiCollapse',
slot: 'Wrapper',
overridesResolver: (props, styles) => styles.wrapper,
})(({ ownerState }) => ({
})({
// Hack to get children with a negative margin to not falsify the height computation.
display: 'flex',
width: '100%',
...(ownerState.orientation === 'horizontal' && {
width: 'auto',
height: '100%',
}),
}));
variants: [
{
props: {
orientation: 'horizontal',
},
style: {
width: 'auto',
height: '100%',
},
},
],
});

const CollapseWrapperInner = styled('div', {
name: 'MuiCollapse',
slot: 'WrapperInner',
overridesResolver: (props, styles) => styles.wrapperInner,
})(({ ownerState }) => ({
})({
width: '100%',
...(ownerState.orientation === 'horizontal' && {
width: 'auto',
height: '100%',
}),
}));
variants: [
{
props: {
orientation: 'horizontal',
},
style: {
width: 'auto',
height: '100%',
},
},
],
});

/**
* The Collapse transition is used by the
Expand Down Expand Up @@ -418,6 +453,8 @@ Collapse.propTypes /* remove-proptypes */ = {
]),
};

Collapse.muiSupportAuto = true;
if (Collapse) {
Collapse.muiSupportAuto = true;
}

export default Collapse;
Loading
Loading