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

Update MUI to version 5 #1812

Merged
merged 18 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3,101 changes: 2,589 additions & 512 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"@jsonforms/core": "^3.0.0-alpha.2",
"@jsonforms/examples": "^3.0.0-alpha.2",
"@jsonforms/react": "^3.0.0-alpha.2",
"@material-ui/core": "^4.7.0",
"@mui/material": "^5.2.2",
"lodash": "^4.17.15",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"redux": "^4.0.4"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/material/example/CustomAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { ExtendedUnwrapped } from '../src/extended';
import { materialAutocompleteOneOfEnumControlTester } from '../src/extended/MaterialAutocompleteOneOfEnumControl';
import { withJsonFormsOneOfEnumProps } from '@jsonforms/react';
import React from 'react';
import Typography from '@material-ui/core/Typography';
import { Typography } from '@mui/material';
const MyAutocompleteControl = (props: ControlProps & OwnPropsOfEnum) => {
return (
<ExtendedUnwrapped.MaterialAutocompleteOneOfEnumControl
{...props}
renderOption={option => (<Typography>{`${option?.value}\t-\t${option?.label}`}</Typography>)}
renderOption={({}, option) => (<Typography>{`${option?.value}\t-\t${option?.label}`}</Typography>)}
filterOptions={(options, state) => options.filter(o => o.label.includes(state.inputValue) || o.value.includes(state.inputValue))}
/>
);
Expand Down
29 changes: 13 additions & 16 deletions packages/material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,29 @@
"peerDependencies": {
"@jsonforms/core": "^3.0.0-alpha.0",
"@jsonforms/react": "^3.0.0-alpha.0",
"@material-ui/core": "^4.7.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/pickers": "^3.3.10"
},
"optionalPeerDependencies": {
"@material-ui/lab": "^4.0.0-alpha.56"
"@mui/icons-material": "^5.0.0",
"@mui/lab": "^5.0.0-alpha.54",
"@mui/material": "^5.0.0"
},
"devDependencies": {
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@jsonforms/core": "^3.0.0-alpha.2",
"@jsonforms/react": "^3.0.0-alpha.2",
"@material-ui/core": "^4.7.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.8",
"@mui/icons-material": "^5.2.0",
"@mui/lab": "^5.0.0-alpha.58",
"@mui/material": "^5.2.2",
"@types/enzyme": "^3.10.3",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/react-dom": "^16.8.0",
"@types/react-dom": "^17.0.9",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"copy-webpack-plugin": "^5.0.5",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"jest": "^24.9.0",
"jest": "^26.6.3",
"nyc": "^14.1.1",
"react-dom": "^16.12.0",
"react-dom": "^17.0.2",
"rimraf": "^3.0.2",
"source-map-loader": "^0.2.4",
"ts-jest": "^24.2.0",
"ts-jest": "^26.4.4",
"ts-loader": "^6.2.1",
"tslint": "^5.20.1",
"tslint-loader": "^3.5.4",
Expand Down
9 changes: 3 additions & 6 deletions packages/material/src/additional/ListWithDetailMasterItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {
ListItemAvatar,
ListItemSecondaryAction,
ListItemText,
} from '@material-ui/core';
import DeleteIcon from '@material-ui/icons/Delete';
} from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import React from 'react';

const ListWithDetailMasterItem = ({ index, childLabel, selected, handleSelect, removeItem, path }: StatePropsOfMasterItem) => {
Expand All @@ -47,10 +47,7 @@ const ListWithDetailMasterItem = ({ index, childLabel, selected, handleSelect, r
</ListItemAvatar>
<ListItemText primary={childLabel} />
<ListItemSecondaryAction>
<IconButton
aria-label='Delete'
onClick={removeItem(path, index)}
>
<IconButton aria-label='Delete' onClick={removeItem(path, index)} size='large'>
<DeleteIcon />
</IconButton>
</ListItemSecondaryAction>
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/additional/MaterialLabelRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { withJsonFormsLayoutProps } from '@jsonforms/react';
import {
Hidden,
Typography
} from '@material-ui/core';
} from '@mui/material';

/**
* Default tester for a label.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
JsonFormsDispatch,
withJsonFormsArrayLayoutProps
} from '@jsonforms/react';
import { Grid, Hidden, List, Typography } from '@material-ui/core';
import { Grid, Hidden, List, Typography } from '@mui/material';
import map from 'lodash/map';
import range from 'lodash/range';
import React, { useCallback, useMemo, useState } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/cells/MaterialDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
WithClassname
} from '@jsonforms/core';
import { withJsonFormsCellProps } from '@jsonforms/react';
import Input from '@material-ui/core/Input';
import Input from '@mui/material/Input';
import merge from 'lodash/merge';

export const MaterialDateCell = (props: CellProps & WithClassname) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/material/src/complex/DeleteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
THE SOFTWARE.
*/
import React from 'react';
import Button from '@material-ui/core/Button';
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle,
} from '@material-ui/core';
} from '@mui/material';

export interface DeleteDialogProps {
open: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/complex/MaterialAllOfRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
THE SOFTWARE.
*/
import React from 'react';
import { Hidden } from '@material-ui/core';
import { Hidden } from '@mui/material';

import {
createCombinatorRenderInfos,
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/complex/MaterialAnyOfRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
StatePropsOfCombinator
} from '@jsonforms/core';
import { JsonFormsDispatch, withJsonFormsAnyOfProps } from '@jsonforms/react';
import { Hidden, Tab, Tabs } from '@material-ui/core';
import { Hidden, Tab, Tabs } from '@mui/material';
import CombinatorProperties from './CombinatorProperties';

export const MaterialAnyOfRenderer = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import React, { useCallback, useState } from 'react';
import { ArrayLayoutProps } from '@jsonforms/core';
import { withJsonFormsArrayLayoutProps } from '@jsonforms/react';
import { MaterialTableControl } from './MaterialTableControl';
import { Hidden } from '@material-ui/core';
import { Hidden } from '@mui/material';
import { DeleteDialog } from './DeleteDialog';

export const MaterialArrayControlRenderer = (props: ArrayLayoutProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
FormGroup,
FormHelperText,
Hidden
} from '@material-ui/core';
} from '@mui/material';
import { startCase } from 'lodash';
import { isEmpty } from 'lodash';
import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/complex/MaterialObjectRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
StatePropsOfControlWithDetail
} from '@jsonforms/core';
import { JsonFormsDispatch, withJsonFormsDetailProps } from '@jsonforms/react';
import { Hidden } from '@material-ui/core';
import { Hidden } from '@mui/material';
import React, { useMemo } from 'react';

export const MaterialObjectRenderer = ({
Expand Down
2 changes: 1 addition & 1 deletion packages/material/src/complex/MaterialOneOfRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
Hidden,
Tab,
Tabs
} from '@material-ui/core';
} from '@mui/material';
import {
JsonFormsDispatch,
withJsonFormsOneOfProps
Expand Down
22 changes: 9 additions & 13 deletions packages/material/src/complex/MaterialTableControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ import {
FormHelperText,
Grid,
Hidden,
IconButton,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Typography
} from '@material-ui/core';
} from '@mui/material';
import {
ArrayLayoutProps,
ControlElement,
Expand All @@ -54,10 +55,9 @@ import {
JsonFormsRendererRegistryEntry,
JsonFormsCellRendererRegistryEntry
} from '@jsonforms/core';
import IconButton from '@material-ui/core/IconButton';
import DeleteIcon from '@material-ui/icons/Delete';
import ArrowDownward from '@material-ui/icons/ArrowDownward';
import ArrowUpward from '@material-ui/icons/ArrowUpward';
import DeleteIcon from '@mui/icons-material/Delete';
import ArrowDownward from '@mui/icons-material/ArrowDownward';
import ArrowUpward from '@mui/icons-material/ArrowUpward';

import { WithDeleteDialogSupport } from './DeleteDialog';
import NoBorderTableCell from './NoBorderTableCell';
Expand Down Expand Up @@ -287,17 +287,13 @@ const NonEmptyRowComponent =
<Grid
container
direction='row'
justify='flex-end'
justifyContent='flex-end'
alignItems='center'
>
{showSortButtons ? (
<Fragment>
<Grid item>
<IconButton
aria-label={`Move up`}
onClick={moveUp}
disabled={!enableUp}
>
<IconButton aria-label={`Move up`} onClick={moveUp} disabled={!enableUp} size='large'>
<ArrowUpward />
</IconButton>
</Grid>
Expand All @@ -306,7 +302,7 @@ const NonEmptyRowComponent =
aria-label={`Move down`}
onClick={moveDown}
disabled={!enableDown}
>
size='large'>
<ArrowDownward />
</IconButton>
</Grid>
Expand All @@ -316,7 +312,7 @@ const NonEmptyRowComponent =
<IconButton
aria-label={`Delete`}
onClick={() => openDeleteDialog(childPath, rowIndex)}
>
size='large'>
<DeleteIcon />
</IconButton>
</Grid>
Expand Down
22 changes: 10 additions & 12 deletions packages/material/src/complex/NoBorderTableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { withStyles } from '@material-ui/core/styles';
import { TableCell } from '@material-ui/core';
import { styled } from '@mui/material/styles';
import { TableCell } from '@mui/material';
import React from 'react';

const styles = {
noBottomBorder: {
borderBottom: 'none'
}
};
const StyledTableCell = styled(TableCell)({
borderBottom: 'none'
});

const NoBorderTableCell = ({ classes, children, ...otherProps }: any) => (
<TableCell className={classes.noBottomBorder} {...otherProps}>
{children}
</TableCell>
const NoBorderTableCell = ({ children, ...otherProps }: any) => (
<StyledTableCell {...otherProps}>
{children}
</StyledTableCell>
);

export default withStyles(styles)(NoBorderTableCell);
export default (NoBorderTableCell);
16 changes: 9 additions & 7 deletions packages/material/src/complex/TableToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ import {
createDefaultValue,
JsonSchema,
} from '@jsonforms/core';
import IconButton from '@material-ui/core/IconButton';
import { Grid, Hidden, Typography } from '@material-ui/core';
import TableRow from '@material-ui/core/TableRow';
import Tooltip from '@material-ui/core/Tooltip';
import AddIcon from '@material-ui/icons/Add';
import {
IconButton,
TableRow,
Tooltip
} from '@mui/material';
import { Grid, Hidden, Typography } from '@mui/material';
import AddIcon from '@mui/icons-material/Add';
import ValidationIcon from './ValidationIcon';
import NoBorderTableCell from './NoBorderTableCell';

Expand Down Expand Up @@ -67,7 +69,7 @@ const TableToolbar = React.memo(
<NoBorderTableCell colSpan={numColumns}>
<Grid
container
justify={'flex-start'}
justifyContent={'flex-start'}
alignItems={'center'}
spacing={2}
>
Expand Down Expand Up @@ -96,7 +98,7 @@ const TableToolbar = React.memo(
<IconButton
aria-label={`Add to ${label}`}
onClick={addItem(path, createDefaultValue(schema))}
>
size='large'>
<AddIcon />
</IconButton>
</Tooltip>
Expand Down
31 changes: 12 additions & 19 deletions packages/material/src/complex/ValidationIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,34 @@
*/
import React from 'react';

import Badge from '@material-ui/core/Badge';
import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';
import Tooltip from '@material-ui/core/Tooltip';
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
import {
StyledComponentProps,
withStyles,
WithStyles,
createStyles,
Theme
} from '@material-ui/core/styles';
Badge,
Tooltip,
styled
} from '@mui/material';

export { StyledComponentProps };
const styles = createStyles(({ palette }: Theme) => ({
badge: {
color: palette.error.main
}
const StyledBadge = styled(Badge)(({ theme }: any) => ({
color: theme.palette.error.main
}));

export interface ValidationProps {
errorMessages: string;
id: string;
}

const ValidationIcon: React.FC<ValidationProps & WithStyles<'badge'>> =
({ classes, errorMessages, id }) => {
const ValidationIcon: React.FC<ValidationProps> =
({ errorMessages, id }) => {
return (
<Tooltip
id={id}
title={errorMessages}
>
<Badge className={classes.badge} badgeContent={errorMessages.split('\n').length}>
<StyledBadge badgeContent={errorMessages.split('\n').length}>
<ErrorOutlineIcon color='inherit'/>
</Badge>
</StyledBadge>
</Tooltip>
);
};

export default withStyles(styles, { name: 'ValidationIcon' })(ValidationIcon);
export default ValidationIcon;
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ import {
WithClassname
} from '@jsonforms/core';
import { Control, withJsonFormsControlProps } from '@jsonforms/react';
import { Input } from '@material-ui/core';
import { InputBaseComponentProps } from '@material-ui/core/InputBase';
import { Input, InputBaseComponentProps } from '@mui/material';
import merge from 'lodash/merge';
import React, { useMemo } from 'react';
import { useDebouncedChange } from '../util';
Expand Down
Loading