Skip to content

Commit 773ad93

Browse files
committed
Remove React Material extended renderer set
As '@mui/lab' is now a core dependency we no longer need to maintain two different renderer sets. The autocomplete renderers are now part of the normal renderer set.
1 parent ef7c79a commit 773ad93

File tree

9 files changed

+37
-178
lines changed

9 files changed

+37
-178
lines changed

MIGRATION.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## Migrating to JSON Forms 3.0 for React users
44

5+
### Removal of React Material extended renderer set
6+
7+
Previously we maintained a separate 'extended' renderer set to not force all consumers of JSON Forms to consume the Material UI lab dependency.
8+
With the update to Material UI v5 the lab dependency became more important as it also contains all date and time pickers.
9+
Therefore we now require the lab dependency and removed the no longer needed extended renderer set.
10+
11+
If you consumed the extended renderer set then just revert to the normal renderer set.
12+
There should not be any behavior changes.
13+
514
### Removal of Class Components in React Material
615

716
With Version 3.0 of JSON Forms we removed all React Material class components.

packages/material/example/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
THE SOFTWARE.
2424
*/
2525
import { renderExample } from '../../example/src/index';
26-
import { materialCells } from '../src';
27-
import { extendedMaterialRenderers } from '../src/extended';
26+
import { materialRenderers, materialCells } from '../src';
2827

2928
renderExample(
30-
extendedMaterialRenderers,
29+
materialRenderers,
3130
materialCells
3231
);

packages/material/src/controls/MaterialEnumControl.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,20 @@ import {
3232
} from '@jsonforms/core';
3333
import { withJsonFormsEnumProps } from '@jsonforms/react';
3434
import { MuiSelect } from '../mui-controls/MuiSelect';
35+
import merge from 'lodash/merge';
3536
import { MaterialInputControl } from './MaterialInputControl';
37+
import { MuiAutocomplete, WithOptionLabel } from '../mui-controls/MuiAutocomplete';
3638

37-
export const MaterialEnumControl = (props: ControlProps & OwnPropsOfEnum) => (
38-
<MaterialInputControl {...props} input={MuiSelect} />
39-
);
39+
export const MaterialEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel) => {
40+
const {config, uischema} = props;
41+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
42+
return (
43+
<MaterialInputControl
44+
{...props}
45+
input={appliedUiSchemaOptions.autocomplete === false ? MuiSelect : MuiAutocomplete}
46+
/>
47+
);
48+
};
4049

4150
export const materialEnumControlTester: RankedTester = rankWith(
4251
2,

packages/material/src/controls/MaterialOneOfEnumControl.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ import {
3131
rankWith,
3232
} from '@jsonforms/core';
3333
import { withJsonFormsOneOfEnumProps } from '@jsonforms/react';
34+
import { MuiAutocomplete, WithOptionLabel } from '../mui-controls/MuiAutocomplete';
3435
import { MuiSelect } from '../mui-controls/MuiSelect';
35-
import { MaterialInputControl } from './MaterialInputControl';
36+
import { MaterialInputControl } from '../controls/MaterialInputControl';
37+
import merge from 'lodash/merge';
3638

37-
export const MaterialOneOfEnumControl = (props: ControlProps & OwnPropsOfEnum) => (
38-
<MaterialInputControl {...props} input={MuiSelect} />
39-
);
39+
export const MaterialOneOfEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel) => {
40+
const {config, uischema} = props;
41+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
42+
return (
43+
<MaterialInputControl
44+
{...props}
45+
input={appliedUiSchemaOptions.autocomplete === false ? MuiSelect : MuiAutocomplete}
46+
/>
47+
);
48+
};
4049

4150
export const materialOneOfEnumControlTester: RankedTester = rankWith(
4251
5,

packages/material/src/extended/MaterialAutocompleteEnumControl.tsx

Lines changed: 0 additions & 55 deletions
This file was deleted.

packages/material/src/extended/MaterialAutocompleteOneOfEnumControl.tsx

Lines changed: 0 additions & 55 deletions
This file was deleted.

packages/material/src/extended/index.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

packages/material/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"node_modules"
99
],
1010
"files": [
11-
"./src/index.ts",
12-
"./src/extended/index.ts"
11+
"./src/index.ts"
1312
]
1413
}

0 commit comments

Comments
 (0)