Skip to content

Commit

Permalink
Remove React Material extended renderer set
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdirix committed Dec 22, 2021
1 parent fee3cc3 commit 2a63010
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 178 deletions.
9 changes: 9 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Migrating to JSON Forms 3.0 for React users

### Removal of React Material extended renderer set

Previously we maintained a separate 'extended' renderer set to not force all consumers of JSON Forms to consume the Material UI lab dependency.
With the update to Material UI v5 the lab dependency became more important as it also contains all date and time pickers.
Therefore we now require the lab dependency and removed the no longer needed extended renderer set.

If you consumed the extended renderer set then just revert to the normal renderer set.
There should not be any behavior changes.

### Removal of Class Components in React Material

With Version 3.0 of JSON Forms we removed all React Material class components.
Expand Down
5 changes: 2 additions & 3 deletions packages/material/example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
THE SOFTWARE.
*/
import { renderExample } from '../../example/src/index';
import { materialCells } from '../src';
import { extendedMaterialRenderers } from '../src/extended';
import { materialRenderers, materialCells } from '../src';

renderExample(
extendedMaterialRenderers,
materialRenderers,
materialCells
);
15 changes: 12 additions & 3 deletions packages/material/src/controls/MaterialEnumControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ import {
} from '@jsonforms/core';
import { withJsonFormsEnumProps } from '@jsonforms/react';
import { MuiSelect } from '../mui-controls/MuiSelect';
import merge from 'lodash/merge';
import { MaterialInputControl } from './MaterialInputControl';
import { MuiAutocomplete, WithOptionLabel } from '../mui-controls/MuiAutocomplete';

export const MaterialEnumControl = (props: ControlProps & OwnPropsOfEnum) => (
<MaterialInputControl {...props} input={MuiSelect} />
);
export const MaterialEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel) => {
const {config, uischema} = props;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
return (
<MaterialInputControl
{...props}
input={appliedUiSchemaOptions.autocomplete === false ? MuiSelect : MuiAutocomplete}
/>
);
};

export const materialEnumControlTester: RankedTester = rankWith(
2,
Expand Down
17 changes: 13 additions & 4 deletions packages/material/src/controls/MaterialOneOfEnumControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ import {
rankWith,
} from '@jsonforms/core';
import { withJsonFormsOneOfEnumProps } from '@jsonforms/react';
import { MuiAutocomplete, WithOptionLabel } from '../mui-controls/MuiAutocomplete';
import { MuiSelect } from '../mui-controls/MuiSelect';
import { MaterialInputControl } from './MaterialInputControl';
import { MaterialInputControl } from '../controls/MaterialInputControl';
import merge from 'lodash/merge';

export const MaterialOneOfEnumControl = (props: ControlProps & OwnPropsOfEnum) => (
<MaterialInputControl {...props} input={MuiSelect} />
);
export const MaterialOneOfEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel) => {
const {config, uischema} = props;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
return (
<MaterialInputControl
{...props}
input={appliedUiSchemaOptions.autocomplete === false ? MuiSelect : MuiAutocomplete}
/>
);
};

export const materialOneOfEnumControlTester: RankedTester = rankWith(
5,
Expand Down
55 changes: 0 additions & 55 deletions packages/material/src/extended/MaterialAutocompleteEnumControl.tsx

This file was deleted.

This file was deleted.

56 changes: 0 additions & 56 deletions packages/material/src/extended/index.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/material/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"node_modules"
],
"files": [
"./src/index.ts",
"./src/extended/index.ts"
"./src/index.ts"
]
}

0 comments on commit 2a63010

Please sign in to comment.