Skip to content

Commit

Permalink
Made @rjsf/material-ui only be for Material UI 4 (rjsf-team#2949)
Browse files Browse the repository at this point in the history
- Deleted the `MuiComponentContext`, `MuiForm5`, `Theme5` and `ThemeCommon` directories (moving the contents of `ThemeCommon/index.js` directly into `Theme`)
- Deleted the `MaterialUIContext` and `MaterialUIContextProps` files and everything in `Theme.tsx` that related to them
- Replaced all fetching of the Material UI components from the `useMuiComponent()` hook with actual imports from `@material-ui/core` and `@material-ui/icons`
- Deleted the `tests/mui-5` directory and fixed up the tests to work with the simple `Form`
- Regenerated the `package-lock.json` file with node-16
- Added the `cs-check`, `cs-format` and `lint` scripts along with `lint-staged` to the `package.json` file
- Copied the `.eslintrc` file from `core`
  - This involved adding `@typescript-eslint`, `eslint` and `eslint-plugin-*`
- Ran `eslint --fix` and `cs-format` over the `src` and `test` directories to fix the build
  • Loading branch information
heath-freenome committed Aug 27, 2022
1 parent 81ae0ff commit e0d32f4
Show file tree
Hide file tree
Showing 78 changed files with 150,929 additions and 15,249 deletions.
38 changes: 38 additions & 0 deletions packages/material-ui/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"parser": "@typescript-eslint/parser",
"rules": {
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,
"react/jsx-tag-spacing": [1, {
"beforeSelfClosing": "always"
}],
"curly": [2],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"comma-dangle": [0],
"no-unused-vars": [2, {
"vars": "all",
"args": "none",
"ignoreRestSiblings": true
}],
"no-console": [0],
"object-curly-spacing": [2, "always"],
"keyword-spacing": ["error"],
"no-prototype-builtins": "warn",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/no-var-requires": "warn"
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"plugins": [
"@typescript-eslint",
"jsx-a11y",
"react",
"import"
]
}
118 changes: 9 additions & 109 deletions packages/material-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h3 align="center">@rjsf/material-ui</h3>

<p align="center">
Material UI 4 and 5 themes, fields and widgets for <a href="https://github.com/rjsf-team/react-jsonschema-form/"><code>react-jsonschema-form</code></a>.
Material UI 4 theme, fields and widgets for <a href="https://github.com/rjsf-team/react-jsonschema-form/"><code>react-jsonschema-form</code></a>.
<br />
<a href="https://react-jsonschema-form.readthedocs.io/en/latest/"><strong>Explore the docs »</strong></a>
<br />
Expand Down Expand Up @@ -46,13 +46,12 @@

[![@rjsf/material-ui Screen Shot][product-screenshot]](https://rjsf-team.github.io/@rjsf/material-ui)

Exports `material-ui` version 4 and 5 themes, fields and widgets for `react-jsonschema-form`.
Exports `material-ui` version 4 theme, fields and widgets for `react-jsonschema-form`.

### Built With

- [react-jsonschema-form](https://github.com/rjsf-team/react-jsonschema-form/)
- [Material UI](https://material-ui.com/)
- [Mui](https://mui.com/)
- [TypeScript](https://www.typescriptlang.org/)

<!-- GETTING STARTED -->
Expand All @@ -61,28 +60,14 @@ Exports `material-ui` version 4 and 5 themes, fields and widgets for `react-json

### Prerequisites

#### Material UI version 4

- `@material-ui/core >= 4.12.0` (in 4.12.0, the library developers made it forward compatible with Material-UI V5)
- `@material-ui/icons >= 4.11.0` (in 4.11.0, the library developers made it forward compatible with Material-UI V5)
- `@rjsf/core >= 4.0.0`

```bash
yarn add @material-ui/core @material-ui/icons @rjsf/core
```

#### Material UI version 5

NOTE: Material UI 5 requires React 17, so you will need to upgrade

- `@mui/material`
- `@mui/icons-material`
- `@emotion/react`
- `@emotion/styled`
- `@rjsf/core >= 4.0.0`
- `@rjsf/core >= 5.0.0`
- `@rjsf/utils >= 5.0.0`
- `@rjsf/validator-ajv6 >= 5.0.0`

```bash
yarn add @mui/material @mui/icons-material @emotion/react @emotion/styled @rjsf/core
yarn add @material-ui/core @material-ui/icons @rjsf/core @rjsf/utils @rjsf/validator-ajv6
```

### Installation
Expand All @@ -95,106 +80,21 @@ yarn add @rjsf/material-ui

## Usage

### Material UI version 4

```js
import Form from '@rjsf/material-ui/v4';
```

or

```js
import { withTheme } from '@rjsf/core';
import Theme from '@rjsf/material-ui/v4';

// Make modifications to the theme with your own fields and widgets

const Form = withTheme(Theme);
```

### Typescript configuration adjustments

If you are using Typescript you may have to update your `tsconfig.json` file in to avoid problems with import aliasing.

If you are experiencing an error that is similar to `TS2307: Cannot find module '@rjsf/material-ui/v4' or its corresponding type declarations.` you can add the following:

```
{
...
"compilerOptions": {
...
"baseUrl": ".",
"paths": {
"@rjsf/material-ui/*": ["node_modules/@rjsf/material-ui/dist/*"]
}
}
}
```

### Jest configuration adjustments

If you are using Jest you may have to update your `jest.config.json` file in to avoid problems with import aliasing.

If you are experiencing an error that is similar to `Cannot find module '@rjsf/material-ui/v4' from '<file path>'` you can add the following:

```
{
"moduleNameMapper": {
"@rjsf/material-ui/v4": "<rootDir>/node_modules/@rjsf/material-ui/dist/v4.js"
},
}
```

### Material UI version 5

```js
import Form from '@rjsf/material-ui/v5';
import Form from '@rjsf/material-ui';
```

or

```js
import { withTheme } from '@rjsf/core';
import Theme from '@rjsf/material-ui/v5';
import Theme from '@rjsf/material-ui';

// Make modifications to the theme with your own fields and widgets

const Form = withTheme(Theme);
```

### Typescript configuration adjustments

If you are using Typescript you may have to update your `tsconfig.json` file in to avoid problems with import aliasing.

If you are experiencing an error that is similar to `TS2307: Cannot find module '@rjsf/material-ui/v5' or its corresponding type declarations.` you can add the following:

```
{
...
"compilerOptions": {
...
"baseUrl": ".",
"paths": {
"@rjsf/material-ui/*": ["node_modules/@rjsf/material-ui/dist/*"]
}
}
}
```

### Jest configuration adjustments

If you are using Jest you may have to update your `jest.config.json` file in to avoid problems with import aliasing.

If you are experiencing an error that is similar to `Cannot find module '@rjsf/material-ui/v5' from '<file path>'` you can add the following:

```
{
"moduleNameMapper": {
"@rjsf/material-ui/v5": "<rootDir>/node_modules/@rjsf/material-ui/dist/v5.js"
},
}
```

<!-- ROADMAP -->

## Roadmap
Expand Down Expand Up @@ -228,4 +128,4 @@ GitHub repository: [https://github.com/rjsf-team/react-jsonschema-form](https://
[npm-url]: https://www.npmjs.com/package/@rjsf/material-ui
[npm-dl-shield]: https://img.shields.io/npm/dm/@rjsf/material-ui.svg?style=flat-square
[npm-dl-url]: https://www.npmjs.com/package/@rjsf/material-ui
[product-screenshot]: https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/e2e1181d1020f18cad0c80c661ddae28edb9794e/packages/material-ui/screenshot5.png
[product-screenshot]: https://raw.githubusercontent.com/rjsf-team/react-jsonschema-form/e2e1181d1020f18cad0c80c661ddae28edb9794e/packages/material-ui/screenshot.png
Loading

0 comments on commit e0d32f4

Please sign in to comment.