Skip to content

feat(mui): v5 #313

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
},
"dependencies": {
"@date-io/date-fns": "^1.3.13",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^4.11.0",
"@material-ui/lab": "^4.0.0-alpha.60",
"@material-ui/pickers": "^3.2.10",
"@mui/lab": "^5.0.0-alpha.50",
"@mui/material": "^5.0.3",
"@mui/styles": "^5.0.1",
"classnames": "^2.2.6",
"date-fns": "^2.15.0",
"lodash": "^4.17.20",
Expand Down
2 changes: 1 addition & 1 deletion src/alert.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import useComponent from './use-component';
import Component from './component';
import MuiAlert from '@material-ui/lab/Alert';
import MuiAlert from '@mui/material/Alert';

export default function Alert(props) {
const { severity, content } = useComponent(props.component, [
Expand Down
21 changes: 11 additions & 10 deletions src/app-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
// hides title and allows for search string to be entered.

import React, { Fragment } from 'react';
import MuiAppBar from '@material-ui/core/AppBar';
import Tooltip from '@material-ui/core/Tooltip';
import MuiToolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import MuiAppBar from '@mui/material/AppBar';
import Tooltip from '@mui/material/Tooltip';
import MuiToolbar from '@mui/material/Toolbar';
import Typography from '@mui/material/Typography';
import IconButton from '@mui/material/IconButton';
import Icon from './icon';
import SearchBar from './search-bar';
import MuiSwitch from '@material-ui/core/Switch';
import { styled } from '@material-ui/core/styles';
import { useTheme } from '@material-ui/core/styles';
import useMediaQuery from '@material-ui/core/useMediaQuery';
import MuiSwitch from '@mui/material/Switch';
import { styled } from '@mui/material/styles';
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';

const ResponsiveIconButton = styled(IconButton)(({ theme }) => ({
[theme.breakpoints.up('md')]: {
Expand Down Expand Up @@ -129,6 +129,7 @@ function Toolbar(props) {
color="inherit"
aria-label="close search"
onClick={onToggleShowSearch}
size="large"
>
<Icon icon="ArrowBack" />
</IconButton>
Expand Down Expand Up @@ -222,7 +223,7 @@ export default function AppBar(props) {
} = props;

const theme = useTheme();
const onMobile = useMediaQuery(theme.breakpoints.down('sm'));
const onMobile = useMediaQuery(theme.breakpoints.down('md'));

return (
<StyledMuiAppBar
Expand Down
68 changes: 38 additions & 30 deletions src/app-container.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import React from 'react';
import AppUI from './app';
import CssBaseline from '@material-ui/core/CssBaseline';
import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles';
import { createTheme } from '@material-ui/core/styles';
import blueGrey from '@material-ui/core/colors/blueGrey';
import lightBlue from '@material-ui/core/colors/lightBlue';
import CssBaseline from '@mui/material/CssBaseline';
import {
ThemeProvider as MuiThemeProvider,
StyledEngineProvider,
adaptV4Theme,
} from '@mui/material/styles';
import { createTheme } from '@mui/material/styles';
import { BrowserRouter, Prompt } from 'react-router-dom';
import globals from 'mson/lib/globals';
import attach from './attach';

const theme = createTheme({
palette: {
primary: blueGrey,
// primary: blue,
// type: 'dark',
// secondary: cyan
secondary: lightBlue,
},
import { blueGrey, lightBlue } from '@mui/material/colors';

// shadows: ['none']
});
const theme = createTheme(
adaptV4Theme({
palette: {
primary: blueGrey,
// primary: blue,
// type: 'dark',
// secondary: cyan
secondary: lightBlue,
},

// shadows: ['none']
})
);

// Note: BrowserRouter needs to be outside of App so that we can use withRouter
class AppContainer extends React.Component {
Expand All @@ -30,22 +36,24 @@ class AppContainer extends React.Component {
render() {
const { component, basename } = this.props;
return (
<MuiThemeProvider theme={theme}>
<CssBaseline />
<BrowserRouter
getUserConfirmation={this.onNavigate}
basename={basename}
>
{/* Wrapping div required by BrowserRouter */}
<div>
<AppUI component={component} />
<StyledEngineProvider injectFirst>
<MuiThemeProvider theme={theme}>
<CssBaseline />
<BrowserRouter
getUserConfirmation={this.onNavigate}
basename={basename}
>
{/* Wrapping div required by BrowserRouter */}
<div>
<AppUI component={component} />

{/* A Prompt is needed to capture back/forward button events with ReactRouter. message
is required, but the value is arbitrary */}
<Prompt message="foo" />
</div>
</BrowserRouter>
</MuiThemeProvider>
{/* A Prompt is needed to capture back/forward button events with ReactRouter. message
is required, but the value is arbitrary */}
<Prompt message="foo" />
</div>
</BrowserRouter>
</MuiThemeProvider>
</StyledEngineProvider>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import withStyles from '@material-ui/core/styles/withStyles';
import withStyles from '@mui/styles/withStyles';
import Menu from './menu';
import { Switch, Route } from 'react-router-dom';
import Component from './component';
Expand Down
9 changes: 8 additions & 1 deletion src/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ const Button = (props) => {
/>
);
} else {
return <IconButton onClick={onClick} icon={icon} tooltip={tooltip} />;
return (
<IconButton
onClick={onClick}
icon={icon}
tooltip={tooltip}
size="large"
/>
);
}
};

Expand Down
10 changes: 5 additions & 5 deletions src/card.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import withStyles from '@material-ui/core/styles/withStyles';
import Grid from '@material-ui/core/Grid';
import Paper from '@material-ui/core/Paper';
import withStyles from '@mui/styles/withStyles';
import Grid from '@mui/material/Grid';
import Paper from '@mui/material/Paper';
import Component from './component';
import Typography from '@material-ui/core/Typography';
import Typography from '@mui/material/Typography';

const styles = (theme) => ({
paper: {
Expand All @@ -23,7 +23,7 @@ class Card extends React.PureComponent {
const title = component.get('title');

return (
<Grid container spacing={0} justify="center">
<Grid container spacing={0} justifyContent="center">
<Grid item xs={12} sm={9} md={6} lg={6}>
<Paper className={classes.paper}>
<Grid container wrap="nowrap">
Expand Down
2 changes: 1 addition & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import InnerComponent from './inner-component';
import compiler from 'mson/lib/compiler';
import useComponent from './use-component';
import { makeStyles } from '@material-ui/core/styles';
import makeStyles from '@mui/styles/makeStyles';

const getOrZero = (value) => (value ? value : 0);

Expand Down
12 changes: 6 additions & 6 deletions src/confirmation-dialog.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';

export default class ConfirmationDialog extends React.PureComponent {
handleClose = (yes) => {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/custom-component-attach.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import attach from '../../attach';
import Typography from '@material-ui/core/Typography';
import Typography from '@mui/material/Typography';
import compile from 'mson/lib/compiler/compile';

let ReactCustomComponentAttach = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/custom-component-js.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import attach from '../../attach';
import Typography from '@material-ui/core/Typography';
import Typography from '@mui/material/Typography';

import UIComponent from 'mson/lib/ui-component';
import Form from 'mson/lib/form';
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/custom-component-no-props.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import Typography from '@mui/material/Typography';
import compile from 'mson/lib/compiler/compile';

const ReactCustomComponentNoProps = (/* props */) => {
Expand Down
2 changes: 1 addition & 1 deletion src/demo/components/custom-component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import useComponent from '../../use-component';
import Typography from '@material-ui/core/Typography';
import Typography from '@mui/material/Typography';
import compile from 'mson/lib/compiler/compile';

const CustomComponent = compile({
Expand Down
8 changes: 4 additions & 4 deletions src/field-editor-form.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import Typography from '@material-ui/core/Typography';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Typography from '@mui/material/Typography';
import Form from './form';
import withStyles from '@material-ui/core/styles/withStyles';
import withStyles from '@mui/styles/withStyles';
import Field from './fields/field';
import compiler from 'mson/lib/compiler';
import each from 'lodash/each';
Expand Down
20 changes: 10 additions & 10 deletions src/fields/autocomplete-select.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import classNames from 'classnames';
import Select from 'react-select';
import { withStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import TextField from '@material-ui/core/TextField';
import Paper from '@material-ui/core/Paper';
import Chip from '@material-ui/core/Chip';
import MenuItem from '@material-ui/core/MenuItem';
import { emphasize } from '@mui/material/styles';
import withStyles from '@mui/styles/withStyles';
import Typography from '@mui/material/Typography';
import TextField from '@mui/material/TextField';
import Paper from '@mui/material/Paper';
import Chip from '@mui/material/Chip';
import MenuItem from '@mui/material/MenuItem';
import Icon from '../icon';
import { emphasize } from '@material-ui/core/styles/colorManipulator';

const styles = (theme) => ({
input: {
Expand All @@ -27,18 +27,18 @@ const styles = (theme) => ({
marginTop: theme.spacing(2) + 5,
},
chip: {
margin: `${theme.spacing(1)}px ${theme.spacing(0.25)}px`,
margin: `${theme.spacing(1)} ${theme.spacing(0.25)}`,
},
chipFocused: {
backgroundColor: emphasize(
theme.palette.type === 'light'
theme.palette.mode === 'light'
? theme.palette.grey[300]
: theme.palette.grey[700],
0.08
),
},
noOptionsMessage: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: `${theme.spacing(1)} ${theme.spacing(2)}`,
},
singleValue: {
fontSize: theme.typography.subtitle1.fontSize,
Expand Down
14 changes: 4 additions & 10 deletions src/fields/boolean-field.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import Switch from '@material-ui/core/Switch';
import Switch from '@mui/material/Switch';
import CommonField from './common-field';
import attach from '../attach';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControlLabel from '@mui/material/FormControlLabel';
import DisplayValueTypography from './display-value-typography';

class BooleanField extends React.PureComponent {
Expand All @@ -11,14 +11,8 @@ class BooleanField extends React.PureComponent {
};

render() {
const {
value,
disabled,
component,
editable,
useDisplayValue,
label,
} = this.props;
const { value, disabled, component, editable, useDisplayValue, label } =
this.props;

let hideLabelUI = null;

Expand Down
8 changes: 4 additions & 4 deletions src/fields/collection-field.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Grid from '@mui/material/Grid';
import FormCard from '../form-card';
import FormDialog from '../form-dialog';
import attach from '../attach';
import Button from '../button';
import Typography from '@material-ui/core/Typography';
import Typography from '@mui/material/Typography';
import ConfirmationDialog from '../confirmation-dialog';
import access from 'mson/lib/access';
import withStyles from '@material-ui/core/styles/withStyles';
import withStyles from '@mui/styles/withStyles';
import './collection-field.css';
import SelectOrder from './select-order';
import ButtonField from 'mson/lib/fields/button-field';
Expand All @@ -20,7 +20,7 @@ const getItemStyle = (isDragging, draggableStyle, theme) => ({
// some basic styles to make the items look a bit nicer
userSelect: 'none',
padding: theme.spacing(0.125),
margin: `0 0 ${theme.spacing(0.125)}px 0`,
margin: `0 0 ${theme.spacing(0.125)} 0`,

// change background colour if dragging
background: isDragging ? theme.palette.secondary[400] : undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/fields/common-field.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import InputLabel from '@material-ui/core/InputLabel';
import FormHelperText from '@material-ui/core/FormHelperText';
import InputLabel from '@mui/material/InputLabel';
import FormHelperText from '@mui/material/FormHelperText';
import FormControl from '../form-control';
import attach from '../attach';
import HelpToolTip from './help-tool-tip';
Expand Down
2 changes: 1 addition & 1 deletion src/fields/component-field.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import attach from '../attach';
import Component from '../component';
import withStyles from '@material-ui/core/styles/withStyles';
import withStyles from '@mui/styles/withStyles';

const styles = (theme) => ({
root: {
Expand Down
2 changes: 1 addition & 1 deletion src/fields/date-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
DatePicker,
} from '@material-ui/pickers';
import DateFnsUtils from '@date-io/date-fns';
import withStyles from '@material-ui/core/styles/withStyles';
import withStyles from '@mui/styles/withStyles';
import DisplayValueTypography from './display-value-typography';

const styles = (theme) => ({
Expand Down
Loading