Skip to content

Commit 8b19c64

Browse files
authored
react-material: upgrade to Material UI v9 (#2614)
* upgrade @mui dependencies from v7 to v9. This drops support for v7 * migrate deprecated props to slotProps * chore(review): apply requested changes * use Stack for vertical layouts instead of Grid because Grid no longer supports direction column * remove obsolete direction "row" definitions for Grid components * add migration info for the upgrade
1 parent 141f288 commit 8b19c64

16 files changed

Lines changed: 241 additions & 217 deletions

MIGRATION.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ When a missing intermediate container is created, the JSON Schema decides whethe
1212

1313
If you dispatch update actions yourself, make sure to use dot-separated paths (e.g. `update('list.0.name', ...)`) instead of lodash bracket syntax (e.g. `update('list[0].name', ...)`), which is no longer interpreted.
1414

15+
### React Material renderers now require Material UI v9
16+
17+
The React Material renderers (`@jsonforms/material-renderers`) were upgraded from Material UI v7 to v9.
18+
When using JSON Forms 3.9, your application now needs to provide `@mui/material` and `@mui/icons-material` in version 9, as well as `@mui/x-date-pickers` in version 9 (previously version 8).
19+
20+
To upgrade your application, follow the official [Material UI upgrade guide](https://mui.com/material-ui/migration/upgrade-to-v9/) and the [MUI X Date Pickers migration guide](https://mui.com/x/migration/migration-pickers-v8/).
21+
22+
Use JSON Forms 3.8 if you need to stay on Material UI v7.
23+
24+
As part of this upgrade, layouts that arrange their children vertically (e.g. `VerticalLayout`, `Group`, `Categorization`) now render a MUI `Stack` instead of a `Grid` container with `direction="column"`, and their children are no longer wrapped in `Grid` items.
25+
If you apply custom styling that relies on the previous `Grid`-based DOM structure of these layouts, verify that it still works as expected.
26+
Furthermore, if you use exported method `renderLayoutElements`, it no longer wraps children in `Grid` items for direction `column`.
27+
This should not affect you except if you explicitly use this method in custom renderers.
28+
1529
## Migrating to JSON Forms 3.8
1630

1731
### `Translator` type changed from overloaded signatures to a generic conditional type

packages/examples-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"@jsonforms/core": "workspace:*",
77
"@jsonforms/examples": "workspace:*",
88
"@jsonforms/react": "workspace:*",
9-
"@mui/material": "^7.3.0",
9+
"@mui/material": "^9.2.0",
1010
"@types/react-highlight": "^0.12.5",
1111
"@types/react-tabs": "^2.3.3",
1212
"highlight.js": "^11.3.1",

packages/material-renderers/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@
9595
"@emotion/styled": "^11.3.0",
9696
"@jsonforms/core": "3.9.0-alpha.0",
9797
"@jsonforms/react": "3.9.0-alpha.0",
98-
"@mui/icons-material": "^7.0.0",
99-
"@mui/material": "^7.0.0",
100-
"@mui/x-date-pickers": "^8.0.0",
98+
"@mui/icons-material": "^9.0.0",
99+
"@mui/material": "^9.0.0",
100+
"@mui/x-date-pickers": "^9.0.0",
101101
"react": "^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
102102
},
103103
"devDependencies": {
104104
"@emotion/react": "^11.5.0",
105105
"@emotion/styled": "^11.3.0",
106106
"@jsonforms/core": "workspace:*",
107107
"@jsonforms/react": "workspace:*",
108-
"@mui/icons-material": "^7.3.0",
109-
"@mui/material": "^7.3.0",
110-
"@mui/x-date-pickers": "^8.11.3",
108+
"@mui/icons-material": "^9.2.0",
109+
"@mui/material": "^9.2.0",
110+
"@mui/x-date-pickers": "^9.10.1",
111111
"@rollup/plugin-commonjs": "^23.0.3",
112112
"@rollup/plugin-json": "^5.0.2",
113113
"@rollup/plugin-node-resolve": "^15.0.1",

packages/material-renderers/src/additional/MaterialListWithDetailRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const MaterialListWithDetailRenderer = ({
134134
createDefault={handleCreateDefaultValue}
135135
disableAdd={doDisableAdd}
136136
/>
137-
<Grid container direction='row' spacing={2}>
137+
<Grid container spacing={2}>
138138
<Grid size={3}>
139139
<List>
140140
{data > 0 ? (

packages/material-renderers/src/complex/MaterialTableControl.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ const NonEmptyRowComponent = ({
309309
>
310310
<Grid
311311
container
312-
direction='row'
313-
justifyContent='flex-end'
314-
alignItems='center'
312+
sx={{ justifyContent: 'flex-end', alignItems: 'center' }}
315313
>
316314
{showSortButtons ? (
317315
<Fragment>

packages/material-renderers/src/complex/TableToolbar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ const TableToolbar = React.memo(function TableToolbar({
8181
<Stack>
8282
<Grid
8383
container
84-
justifyContent={'flex-start'}
85-
alignItems={'center'}
84+
sx={{ justifyContent: 'flex-start', alignItems: 'center' }}
8685
spacing={2}
8786
>
8887
<Grid>

packages/material-renderers/src/complex/ValidationIcon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
import React from 'react';
2626

27-
import { ErrorOutline } from '@mui/icons-material';
27+
import { ErrorOutlineOutlined } from '@mui/icons-material';
2828
import { Badge, Tooltip, styled } from '@mui/material';
2929

3030
const StyledBadge = styled(Badge)(({ theme }: any) => ({
@@ -40,7 +40,7 @@ const ValidationIcon: React.FC<ValidationProps> = ({ errorMessages, id }) => {
4040
return (
4141
<Tooltip id={id} title={errorMessages}>
4242
<StyledBadge badgeContent={errorMessages.split('\n').length}>
43-
<ErrorOutline color='inherit' />
43+
<ErrorOutlineOutlined color='inherit' />
4444
</StyledBadge>
4545
</Tooltip>
4646
);

packages/material-renderers/src/controls/MaterialDateControl.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@ export const MaterialDateControl = (props: ControlProps) => {
136136
error: !isValid,
137137
fullWidth: !appliedUiSchemaOptions.trim,
138138
variant: inputVariant,
139-
inputProps: {
140-
autoFocus: appliedUiSchemaOptions.focus,
141-
type: 'text',
142-
onFocus: onFocus,
143-
onBlur: onBlurHandler,
139+
slotProps: {
140+
htmlInput: {
141+
autoFocus: appliedUiSchemaOptions.focus,
142+
type: 'text',
143+
onFocus: onFocus,
144+
onBlur: onBlurHandler,
145+
},
146+
inputLabel: data ? { shrink: true } : undefined,
144147
},
145-
InputLabelProps: data ? { shrink: true } : undefined,
146148
},
147149
}}
148150
/>

packages/material-renderers/src/controls/MaterialDateTimeControl.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,15 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
144144
error: !isValid,
145145
fullWidth: !appliedUiSchemaOptions.trim,
146146
variant: inputVariant,
147-
inputProps: {
148-
autoFocus: appliedUiSchemaOptions.focus,
149-
type: 'text',
150-
onFocus: onFocus,
151-
onBlur: onBlurHandler,
147+
slotProps: {
148+
htmlInput: {
149+
autoFocus: appliedUiSchemaOptions.focus,
150+
type: 'text',
151+
onFocus: onFocus,
152+
onBlur: onBlurHandler,
153+
},
154+
inputLabel: data ? { shrink: true } : undefined,
152155
},
153-
InputLabelProps: data ? { shrink: true } : undefined,
154156
},
155157
}}
156158
/>

packages/material-renderers/src/controls/MaterialNativeControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const MaterialNativeControl = (props: ControlProps) => {
9393
onFocus={onFocus}
9494
onBlur={onBlur}
9595
helperText={!isValid ? errors : showDescription ? description : null}
96-
InputLabelProps={{ shrink: true }}
96+
slotProps={{ inputLabel: { shrink: true } }}
9797
value={inputValue}
9898
onChange={onChange}
9999
/>

0 commit comments

Comments
 (0)