@pie-lib/config-ui 11.30.0-mui-update.0 → 11.30.1-beta-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +12 -9
  2. package/lib/__tests__/choice-utils.test.js +16 -0
  3. package/lib/__tests__/langs.test.js +55 -0
  4. package/lib/__tests__/number-text-field.test.js +128 -0
  5. package/lib/__tests__/settings-panel.test.js +201 -0
  6. package/lib/__tests__/two-choice.test.js +33 -0
  7. package/lib/alert-dialog.js +42 -23
  8. package/lib/alert-dialog.js.map +1 -1
  9. package/lib/checkbox.js +71 -56
  10. package/lib/checkbox.js.map +1 -1
  11. package/lib/choice-configuration/__tests__/feedback-menu.test.js +20 -0
  12. package/lib/choice-configuration/__tests__/index.test.js +119 -0
  13. package/lib/choice-configuration/feedback-menu.js +63 -24
  14. package/lib/choice-configuration/feedback-menu.js.map +1 -1
  15. package/lib/choice-configuration/index.js +257 -201
  16. package/lib/choice-configuration/index.js.map +1 -1
  17. package/lib/choice-utils.js +18 -6
  18. package/lib/choice-utils.js.map +1 -1
  19. package/lib/feedback-config/__tests__/feedback-config.test.js +78 -0
  20. package/lib/feedback-config/__tests__/feedback-selector.test.js +71 -0
  21. package/lib/feedback-config/feedback-selector.js +114 -77
  22. package/lib/feedback-config/feedback-selector.js.map +1 -1
  23. package/lib/feedback-config/group.js +40 -26
  24. package/lib/feedback-config/group.js.map +1 -1
  25. package/lib/feedback-config/index.js +90 -38
  26. package/lib/feedback-config/index.js.map +1 -1
  27. package/lib/form-section.js +33 -24
  28. package/lib/form-section.js.map +1 -1
  29. package/lib/help.js +80 -39
  30. package/lib/help.js.map +1 -1
  31. package/lib/index.js +31 -1
  32. package/lib/index.js.map +1 -1
  33. package/lib/input.js +54 -21
  34. package/lib/input.js.map +1 -1
  35. package/lib/inputs.js +95 -61
  36. package/lib/inputs.js.map +1 -1
  37. package/lib/langs.js +100 -56
  38. package/lib/langs.js.map +1 -1
  39. package/lib/layout/__tests__/config.layout.test.js +33 -0
  40. package/lib/layout/__tests__/layout-content.test.js +6 -0
  41. package/lib/layout/config-layout.js +99 -48
  42. package/lib/layout/config-layout.js.map +1 -1
  43. package/lib/layout/index.js +3 -0
  44. package/lib/layout/index.js.map +1 -1
  45. package/lib/layout/layout-contents.js +101 -72
  46. package/lib/layout/layout-contents.js.map +1 -1
  47. package/lib/layout/settings-box.js +56 -27
  48. package/lib/layout/settings-box.js.map +1 -1
  49. package/lib/mui-box/index.js +57 -41
  50. package/lib/mui-box/index.js.map +1 -1
  51. package/lib/number-text-field-custom.js +161 -79
  52. package/lib/number-text-field-custom.js.map +1 -1
  53. package/lib/number-text-field.js +115 -57
  54. package/lib/number-text-field.js.map +1 -1
  55. package/lib/radio-with-label.js +31 -23
  56. package/lib/radio-with-label.js.map +1 -1
  57. package/lib/settings/display-size.js +32 -16
  58. package/lib/settings/display-size.js.map +1 -1
  59. package/lib/settings/index.js +47 -14
  60. package/lib/settings/index.js.map +1 -1
  61. package/lib/settings/panel.js +228 -142
  62. package/lib/settings/panel.js.map +1 -1
  63. package/lib/settings/settings-radio-label.js +30 -21
  64. package/lib/settings/settings-radio-label.js.map +1 -1
  65. package/lib/settings/toggle.js +46 -34
  66. package/lib/settings/toggle.js.map +1 -1
  67. package/lib/tabs/index.js +57 -22
  68. package/lib/tabs/index.js.map +1 -1
  69. package/lib/tags-input/__tests__/index.test.js +88 -0
  70. package/lib/tags-input/index.js +99 -50
  71. package/lib/tags-input/index.js.map +1 -1
  72. package/lib/two-choice.js +90 -46
  73. package/lib/two-choice.js.map +1 -1
  74. package/lib/with-stateful-model.js +31 -8
  75. package/lib/with-stateful-model.js.map +1 -1
  76. package/package.json +10 -12
  77. package/src/__tests__/number-text-field.test.jsx +1 -1
  78. package/src/alert-dialog.jsx +18 -14
  79. package/src/checkbox.jsx +46 -42
  80. package/src/choice-configuration/feedback-menu.jsx +5 -5
  81. package/src/choice-configuration/index.jsx +193 -205
  82. package/src/feedback-config/feedback-selector.jsx +53 -51
  83. package/src/feedback-config/group.jsx +22 -21
  84. package/src/feedback-config/index.jsx +29 -27
  85. package/src/form-section.jsx +18 -18
  86. package/src/help.jsx +28 -20
  87. package/src/input.jsx +1 -1
  88. package/src/inputs.jsx +50 -34
  89. package/src/langs.jsx +46 -40
  90. package/src/layout/config-layout.jsx +36 -25
  91. package/src/layout/layout-contents.jsx +34 -34
  92. package/src/layout/settings-box.jsx +19 -16
  93. package/src/mui-box/index.jsx +43 -35
  94. package/src/number-text-field-custom.jsx +36 -30
  95. package/src/number-text-field.jsx +30 -22
  96. package/src/radio-with-label.jsx +13 -17
  97. package/src/settings/display-size.jsx +11 -12
  98. package/src/settings/panel.jsx +89 -83
  99. package/src/settings/settings-radio-label.jsx +13 -17
  100. package/src/settings/toggle.jsx +29 -29
  101. package/src/tabs/index.jsx +8 -8
  102. package/src/tags-input/index.jsx +38 -35
  103. package/src/two-choice.jsx +19 -15
  104. package/LICENSE.md +0 -5
  105. package/NEXT.CHANGELOG.json +0 -1
@@ -1,42 +1,42 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import RadioWithLabel from '../radio-with-label';
3
3
  import React from 'react';
4
- import { styled } from '@mui/material/styles';
4
+ import { withStyles } from '@material-ui/core/styles';
5
+ import classNames from 'classnames';
5
6
 
6
- const StyledChoiceHolder = styled('div')(() => ({
7
- display: 'flex',
8
- alignItems: 'center',
9
- }));
10
-
11
- const StyledChoice = styled('div')(() => ({
12
- display: 'flex',
13
- alignItems: 'center',
14
- }));
15
-
16
- const StyledRadioWithLabel = styled(RadioWithLabel)(({ theme }) => ({
17
- '& .MuiFormControlLabel-label': {
7
+ const styles = (theme) => ({
8
+ radioLabel: {
18
9
  fontSize: theme.typography.fontSize - 2,
19
10
  },
20
- }));
11
+ choice: {
12
+ display: 'flex',
13
+ alignItems: 'center',
14
+ },
15
+ choiceHolder: {
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ },
19
+ });
21
20
 
22
21
  const Group = (props) => {
23
- const { feedbackLabels, value, className, onChange, keys } = props;
22
+ const { feedbackLabels, value, classes, className, onChange, keys } = props;
24
23
 
25
24
  return (
26
- <StyledChoiceHolder className={className}>
25
+ <div className={classNames(classes.choiceHolder, className)}>
27
26
  {keys.map((key) => {
28
27
  return (
29
- <StyledChoice key={key}>
30
- <StyledRadioWithLabel
28
+ <div className={classes.choice} key={key}>
29
+ <RadioWithLabel
31
30
  value={key}
32
31
  checked={value === key}
32
+ classes={{ label: classes.radioLabel }}
33
33
  onChange={(e) => onChange(e.currentTarget.value)}
34
34
  label={feedbackLabels[key]}
35
35
  />
36
- </StyledChoice>
36
+ </div>
37
37
  );
38
38
  })}
39
- </StyledChoiceHolder>
39
+ </div>
40
40
  );
41
41
  };
42
42
 
@@ -44,8 +44,9 @@ Group.propTypes = {
44
44
  className: PropTypes.string,
45
45
  feedbackLabels: PropTypes.object.isRequired,
46
46
  value: PropTypes.string.isRequired,
47
+ classes: PropTypes.object.isRequired,
47
48
  keys: PropTypes.arrayOf(PropTypes.string),
48
49
  onChange: PropTypes.func,
49
50
  };
50
51
 
51
- export default Group;
52
+ export default withStyles(styles)(Group);
@@ -1,26 +1,27 @@
1
1
  import FeedbackSelector, { FeedbackType } from './feedback-selector';
2
2
  import PropTypes from 'prop-types';
3
3
  import React from 'react';
4
- import { styled } from '@mui/material/styles';
5
- import Accordion from '@mui/material/Accordion';
6
- import AccordionSummary from '@mui/material/AccordionSummary';
7
- import AccordionDetails from '@mui/material/AccordionDetails';
8
- import Typography from '@mui/material/Typography';
9
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
4
+ import { withStyles } from '@material-ui/core/styles';
5
+ import ExpansionPanel from '@material-ui/core/ExpansionPanel';
6
+ import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
7
+ import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
8
+ import Typography from '@material-ui/core/Typography';
9
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
10
10
  import merge from 'lodash/merge';
11
11
 
12
12
  export { FeedbackSelector };
13
13
 
14
- const StyledFeedbackContainer = styled('div')(() => ({
15
- display: 'flex',
16
- flex: 1,
17
- flexDirection: 'column',
18
- }));
19
-
20
- const StyledAccordionDetails = styled(AccordionDetails)(() => ({
21
- paddingTop: 0,
22
- paddingBottom: 0,
23
- }));
14
+ const style = {
15
+ feedbackContainer: {
16
+ display: 'flex',
17
+ flex: 1,
18
+ flexDirection: 'column',
19
+ },
20
+ panelDetails: {
21
+ paddingTop: 0,
22
+ paddingBottom: 0,
23
+ },
24
+ };
24
25
 
25
26
  export const buildDefaults = (input) => {
26
27
  return merge(
@@ -44,6 +45,7 @@ export class FeedbackConfig extends React.Component {
44
45
  partial: PropTypes.shape(FeedbackType),
45
46
  }),
46
47
  onChange: PropTypes.func.isRequired,
48
+ classes: PropTypes.object.isRequired,
47
49
  toolbarOpts: PropTypes.object,
48
50
  };
49
51
 
@@ -66,17 +68,17 @@ export class FeedbackConfig extends React.Component {
66
68
  onPartialChange = this.onChange.bind(this, 'partial');
67
69
 
68
70
  render() {
69
- const { className, allowPartial, feedback, toolbarOpts } = this.props;
71
+ const { classes, className, allowPartial, feedback, toolbarOpts } = this.props;
70
72
 
71
73
  return (
72
74
  <div className={className}>
73
- <Accordion>
74
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
75
- <Typography>Feedback</Typography>
76
- </AccordionSummary>
75
+ <ExpansionPanel>
76
+ <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
77
+ <Typography className={classes.heading}>Feedback</Typography>
78
+ </ExpansionPanelSummary>
77
79
 
78
- <StyledAccordionDetails>
79
- <StyledFeedbackContainer>
80
+ <ExpansionPanelDetails className={classes.panelDetails}>
81
+ <div className={classes.feedbackContainer}>
80
82
  <FeedbackSelector
81
83
  label="If correct, show"
82
84
  feedback={feedback.correct}
@@ -99,12 +101,12 @@ export class FeedbackConfig extends React.Component {
99
101
  onChange={this.onIncorrectChange}
100
102
  toolbarOpts={toolbarOpts}
101
103
  />
102
- </StyledFeedbackContainer>
103
- </StyledAccordionDetails>
104
- </Accordion>
104
+ </div>
105
+ </ExpansionPanelDetails>
106
+ </ExpansionPanel>
105
107
  </div>
106
108
  );
107
109
  }
108
110
  }
109
111
 
110
- export default FeedbackConfig;
112
+ export default withStyles(style)(FeedbackConfig);
@@ -1,23 +1,23 @@
1
1
  import React from 'react';
2
- import Typography from '@mui/material/Typography';
3
- import { styled } from '@mui/material/styles';
2
+ import Typography from '@material-ui/core/Typography';
3
+ import classNames from 'classnames';
4
+ import { withStyles } from '@material-ui/core/styles';
4
5
 
5
- const StyledFormSection = styled('div')(({ theme }) => ({
6
- marginTop: theme.spacing(2),
7
- marginBottom: theme.spacing(2),
8
- }));
6
+ const styles = (theme) => ({
7
+ formSection: {
8
+ marginTop: theme.spacing.unit * 2,
9
+ marginBottom: theme.spacing.unit * 2,
10
+ },
11
+ label: {
12
+ marginBottom: theme.spacing.unit,
13
+ },
14
+ });
9
15
 
10
- const StyledTypography = styled(Typography)(({ theme }) => ({
11
- marginBottom: theme.spacing(1),
12
- }));
13
-
14
- const FormSection = ({ className, label, children, labelExtraStyle }) => (
15
- <StyledFormSection className={className}>
16
- <StyledTypography variant="subtitle1" style={labelExtraStyle}>
16
+ export default withStyles(styles)(({ className, classes, label, children, labelExtraStyle }) => (
17
+ <div className={classNames(classes.formSection, className)}>
18
+ <Typography className={classes.label} type="subheading" style={labelExtraStyle}>
17
19
  {label}
18
- </StyledTypography>
20
+ </Typography>
19
21
  {children}
20
- </StyledFormSection>
21
- );
22
-
23
- export default FormSection;
22
+ </div>
23
+ ));
package/src/help.jsx CHANGED
@@ -1,34 +1,42 @@
1
- import Dialog from '@mui/material/Dialog';
2
- import DialogTitle from '@mui/material/DialogTitle';
3
- import DialogContentText from '@mui/material/DialogContentText';
4
- import DialogContent from '@mui/material/DialogContent';
5
- import DialogActions from '@mui/material/DialogActions';
1
+ import Dialog from '@material-ui/core/Dialog';
2
+ import DialogTitle from '@material-ui/core/DialogTitle';
3
+ import DialogContentText from '@material-ui/core/DialogContentText';
4
+ import DialogContent from '@material-ui/core/DialogContent';
5
+ import DialogActions from '@material-ui/core/DialogActions';
6
6
  import PropTypes from 'prop-types';
7
7
 
8
- import Button from '@mui/material/Button';
9
- import HelpIcon from '@mui/icons-material/Help';
10
- import IconButton from '@mui/material/IconButton';
8
+ import Button from '@material-ui/core/Button';
9
+ import HelpIcon from '@material-ui/icons/Help';
10
+ import IconButton from '@material-ui/core/IconButton';
11
11
  import React from 'react';
12
- import { styled } from '@mui/material/styles';
12
+ import { withStyles } from '@material-ui/core/styles';
13
13
 
14
- const StyledIconButton = styled(IconButton)(({ theme }) => ({
15
- '&:hover': {
16
- color: theme.palette.grey[300],
17
- },
18
- }));
19
-
20
- export const HelpButton = ({ onClick }) => (
21
- <StyledIconButton onClick={onClick} size="large">
14
+ const RawHelpButton = ({ onClick, classes }) => (
15
+ <IconButton
16
+ classes={{
17
+ label: classes.icon,
18
+ }}
19
+ onClick={onClick}
20
+ >
22
21
  <HelpIcon />
23
- </StyledIconButton>
22
+ </IconButton>
24
23
  );
25
24
 
26
- HelpButton.propTypes = {
25
+ RawHelpButton.propTypes = {
27
26
  onClick: PropTypes.func,
27
+ classes: PropTypes.object.isRequired,
28
28
  };
29
29
 
30
+ export const HelpButton = withStyles((theme) => ({
31
+ icon: {
32
+ '&:hover': {
33
+ color: theme.palette.grey[300],
34
+ },
35
+ },
36
+ }))(RawHelpButton);
37
+
30
38
  export const HelpDialog = ({ open, onClose, children, title }) => (
31
- <Dialog open={open} onClose={onClose}>
39
+ <Dialog open={open} onRequestClose={onClose}>
32
40
  <DialogTitle>{title}</DialogTitle>
33
41
  <DialogContent>
34
42
  <DialogContentText>{children}</DialogContentText>
package/src/input.jsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { default as MaterialInput } from '@mui/material/Input';
3
+ import { default as MaterialInput } from '@material-ui/core/Input';
4
4
  import { InputContainer } from '@pie-lib/render-ui';
5
5
 
6
6
  export default class Input extends React.Component {
package/src/inputs.jsx CHANGED
@@ -1,13 +1,15 @@
1
- import Checkbox from '@mui/material/Checkbox';
2
- import Radio from '@mui/material/Radio';
1
+ import Checkbox from '@material-ui/core/Checkbox';
2
+ import Radio from '@material-ui/core/Radio';
3
3
  import { InputContainer } from '@pie-lib/render-ui';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
- import Switch from '@mui/material/Switch';
7
- import { styled } from '@mui/material/styles';
6
+ import Switch from '@material-ui/core/Switch';
7
+ import { withStyles } from '@material-ui/core/styles';
8
+ import classNames from 'classnames';
8
9
  import { color } from '@pie-lib/render-ui';
9
10
 
10
11
  const InputTypes = {
12
+ classes: PropTypes.object.isRequired,
11
13
  className: PropTypes.string,
12
14
  label: PropTypes.string,
13
15
  checked: PropTypes.bool,
@@ -16,67 +18,81 @@ const InputTypes = {
16
18
  error: PropTypes.string,
17
19
  };
18
20
 
19
- const StyledSwitch = styled(Switch)(() => ({
20
- justifyContent: 'inherit',
21
- transform: 'translate(-20%, 20%)',
22
- }));
23
-
24
- const InputSwitch = ({ className, label, checked, onChange }) => {
21
+ const RawInputSwitch = ({ classes, className, label, checked, onChange }) => {
25
22
  return (
26
23
  <InputContainer className={className} label={label}>
27
- <StyledSwitch checked={checked} onChange={onChange} aria-label={label} />
24
+ <Switch className={classes.switchRoot} checked={checked} onChange={onChange} aria-label={label} />
28
25
  </InputContainer>
29
26
  );
30
27
  };
31
28
 
32
- InputSwitch.propTypes = { ...InputTypes };
29
+ RawInputSwitch.propTypes = { ...InputTypes };
30
+
31
+ const InputSwitch = withStyles({
32
+ switchRoot: {
33
+ justifyContent: 'inherit',
34
+ transform: 'translate(-20%, 20%)',
35
+ },
36
+ })(RawInputSwitch);
33
37
 
34
- const StyledCheckbox = styled(Checkbox)(({ theme, error }) => ({
35
- transform: 'translate(-25%, 20%)',
36
- color: `${color.tertiary()} !important`,
37
- ...(error && {
38
- color: `${theme.palette.error.main} !important`,
39
- }),
40
- }));
38
+ const RawInputCheckbox = (props) => {
39
+ const { classes, className, label, checked, onChange, disabled, error } = props;
41
40
 
42
- const InputCheckbox = ({ className, label, checked, onChange, disabled, error }) => {
43
41
  return (
44
42
  <InputContainer className={className} label={label}>
45
- <StyledCheckbox
43
+ <Checkbox
44
+ className={classNames(classes.checkboxRoot, classes.customColor, error && classes.error)}
46
45
  disabled={disabled}
47
46
  checked={checked}
48
47
  onChange={onChange}
49
48
  aria-label={label}
50
- error={error}
51
49
  />
52
50
  </InputContainer>
53
51
  );
54
52
  };
55
53
 
56
- InputCheckbox.propTypes = { ...InputTypes };
54
+ RawInputCheckbox.propTypes = { ...InputTypes };
57
55
 
58
- const StyledRadio = styled(Radio)(({ theme, error }) => ({
59
- transform: 'translate(-20%, 20%)',
60
- color: `${color.tertiary()} !important`,
61
- ...(error && {
62
- color: `${theme.palette.error.main} !important`,
63
- }),
64
- }));
56
+ const RawInputRadio = (props) => {
57
+ const { classes, className, label, checked, onChange, disabled, error } = props;
65
58
 
66
- const InputRadio = ({ className, label, checked, onChange, disabled, error }) => {
67
59
  return (
68
60
  <InputContainer className={className} label={label}>
69
- <StyledRadio
61
+ <Radio
62
+ className={classNames(classes.radioRoot, classes.customColor, error && classes.error)}
70
63
  disabled={disabled}
71
64
  checked={checked}
72
65
  onChange={onChange}
73
66
  aria-label={label}
74
- error={error}
75
67
  />
76
68
  </InputContainer>
77
69
  );
78
70
  };
79
71
 
80
- InputRadio.propTypes = { ...InputTypes };
72
+ RawInputRadio.propTypes = { ...InputTypes };
73
+
74
+ const InputCheckbox = withStyles((theme) => ({
75
+ checkboxRoot: {
76
+ transform: 'translate(-25%, 20%)',
77
+ },
78
+ error: {
79
+ color: theme.palette.error.main,
80
+ },
81
+ customColor: {
82
+ color: `${color.tertiary()} !important`,
83
+ },
84
+ }))(RawInputCheckbox);
85
+
86
+ const InputRadio = withStyles((theme) => ({
87
+ radioRoot: {
88
+ transform: 'translate(-20%, 20%)',
89
+ },
90
+ error: {
91
+ color: theme.palette.error.main,
92
+ },
93
+ customColor: {
94
+ color: `${color.tertiary()} !important`,
95
+ },
96
+ }))(RawInputRadio);
81
97
 
82
98
  export { InputSwitch, InputCheckbox, InputRadio };
package/src/langs.jsx CHANGED
@@ -1,38 +1,40 @@
1
- import Input from '@mui/material/Input';
2
- import InputLabel from '@mui/material/InputLabel';
1
+ import Input from '@material-ui/core/Input';
2
+ import InputLabel from '@material-ui/core/InputLabel';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
- import { styled } from '@mui/material/styles';
6
- import Select from '@mui/material/Select';
7
- import MenuItem from '@mui/material/MenuItem';
8
- import FormControl from '@mui/material/FormControl';
5
+ import classNames from 'classnames';
6
+ import { withStyles } from '@material-ui/core/styles';
7
+ import Select from '@material-ui/core/Select';
8
+ import MenuItem from '@material-ui/core/MenuItem';
9
+ import FormControl from '@material-ui/core/FormControl';
9
10
  import debug from 'debug';
10
11
 
11
12
  const log = debug('pie-elements:config-ui:langs');
12
13
 
13
- const StyledRoot = styled('div')(() => ({
14
- flexDirection: 'column',
15
- alignItems: 'start',
16
- display: 'flex',
17
- position: 'relative',
18
- paddingTop: '0px',
19
- paddingRight: '0px',
20
- }));
14
+ const styles = (theme) => ({
15
+ root: {
16
+ flexDirection: 'column',
17
+ alignItems: 'start',
18
+ display: 'flex',
19
+ position: 'relative',
20
+ paddingTop: '0px',
21
+ paddingRight: '0px',
22
+ },
23
+ formControl: {
24
+ position: 'initial',
25
+ },
26
+ inputLabel: {
27
+ paddingBottom: theme.spacing.unit,
28
+ },
29
+ });
21
30
 
22
- const StyledFormControl = styled(FormControl)(() => ({
23
- position: 'initial',
24
- }));
25
-
26
- const StyledInputLabel = styled(InputLabel)(({ theme }) => ({
27
- paddingBottom: theme.spacing(1),
28
- }));
29
-
30
- export class Langs extends React.Component {
31
+ export class RawLangs extends React.Component {
31
32
  static propTypes = {
32
33
  onChange: PropTypes.func,
33
34
  langs: PropTypes.array,
34
35
  selected: PropTypes.string,
35
36
  label: PropTypes.string,
37
+ classes: PropTypes.object.isRequired,
36
38
  uid: PropTypes.string,
37
39
  };
38
40
 
@@ -50,16 +52,16 @@ export class Langs extends React.Component {
50
52
  };
51
53
 
52
54
  render() {
53
- let { langs, selected, label } = this.props;
55
+ let { langs, selected, label, classes } = this.props;
54
56
 
55
57
  log('[render] selected:', selected);
56
58
 
57
59
  return (
58
- <StyledRoot>
59
- <StyledFormControl>
60
- <StyledInputLabel htmlFor={this.uid}>
60
+ <div className={classes.root}>
61
+ <FormControl className={classes.formControl}>
62
+ <InputLabel className={classes.inputLabel} htmlFor={this.uid}>
61
63
  {label}
62
- </StyledInputLabel>
64
+ </InputLabel>
63
65
 
64
66
  <Select value={selected} onChange={this.choose} input={<Input id={this.uid} />}>
65
67
  {langs.map((l, index) => (
@@ -68,23 +70,27 @@ export class Langs extends React.Component {
68
70
  </MenuItem>
69
71
  ))}
70
72
  </Select>
71
- </StyledFormControl>
72
- </StyledRoot>
73
+ </FormControl>
74
+ </div>
73
75
  );
74
76
  }
75
77
  }
78
+
79
+ const Langs = withStyles(styles, { name: 'Langs' })(RawLangs);
76
80
  export default Langs;
77
81
 
78
- const StyledLanguageControls = styled('div')(() => ({
79
- display: 'grid',
80
- gridAutoFlow: 'column',
81
- gridAutoColumns: '1fr',
82
- gridGap: '8px',
83
- }));
82
+ export const LanguageControls = withStyles({
83
+ languageControls: {
84
+ display: 'grid',
85
+ gridAutoFlow: 'column',
86
+ gridAutoColumns: '1fr',
87
+ gridGap: '8px',
88
+ },
89
+ })(({ classes, langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
90
+ const names = classNames(classes.languageControls, className);
84
91
 
85
- export const LanguageControls = ({ langs, activeLang, defaultLang, onActiveLangChange, onDefaultLangChange, className }) => {
86
92
  return (
87
- <StyledLanguageControls className={className}>
93
+ <div className={names}>
88
94
  <Langs
89
95
  label="Choose language to edit"
90
96
  langs={langs}
@@ -92,9 +98,9 @@ export const LanguageControls = ({ langs, activeLang, defaultLang, onActiveLangC
92
98
  onChange={(l) => onActiveLangChange(l)}
93
99
  />
94
100
  <Langs label="Default language" langs={langs} selected={defaultLang} onChange={(l) => onDefaultLangChange(l)} />
95
- </StyledLanguageControls>
101
+ </div>
96
102
  );
97
- };
103
+ });
98
104
 
99
105
  LanguageControls.propTypes = {
100
106
  langs: PropTypes.array,
@@ -1,15 +1,22 @@
1
1
  import React from 'react';
2
2
  import Measure from 'react-measure';
3
- import { createTheme, ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
3
+ import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';
4
4
  import { withContentRect } from 'react-measure';
5
+ import { withStyles } from '@material-ui/core/styles';
5
6
  import PropTypes from 'prop-types';
6
7
  import classNames from 'classnames';
7
8
  import LayoutContents from './layout-contents';
8
9
  import SettingsBox from './settings-box';
9
10
  import { AppendCSSRules } from '@pie-lib/render-ui';
10
11
 
11
- const theme = createTheme({
12
+ const styles = {
13
+ extraCSSRules: {},
14
+ };
15
+
16
+ const theme = createMuiTheme({
12
17
  typography: {
18
+ // In MUI v3, this opts into the h1–h6 variants; otherwise use display1/headline/etc.
19
+ useNextVariants: true,
13
20
  fontFamily: 'inherit',
14
21
  },
15
22
  });
@@ -18,6 +25,7 @@ class MeasuredConfigLayout extends AppendCSSRules {
18
25
  static propTypes = {
19
26
  children: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.element), PropTypes.element]),
20
27
  className: PropTypes.string,
28
+ classes: PropTypes.object,
21
29
  dimensions: PropTypes.object,
22
30
  settings: PropTypes.element,
23
31
  sidePanelMinWidth: PropTypes.number,
@@ -43,38 +51,41 @@ class MeasuredConfigLayout extends AppendCSSRules {
43
51
  const layoutMode =
44
52
  bounds.width > sidePanelMinWidth && (maxWidth ? maxWidth > sidePanelMinWidth : true) ? 'inline' : 'tabbed';
45
53
 
46
- this.setState({ layoutMode });
54
+ // Only update state (and cause a re-render) if the computed layoutMode changed.
55
+ if (layoutMode !== this.state.layoutMode) {
56
+ this.setState({ layoutMode });
57
+ }
47
58
  };
48
59
 
49
60
  render() {
50
61
  return (
51
- <StyledEngineProvider injectFirst>
52
- <ThemeProvider theme={theme}>
53
- <Measure bounds onResize={this.onResize}>
54
- {({ measureRef }) => {
55
- const { children, settings, hideSettings, dimensions } = this.props;
56
- const { layoutMode } = this.state;
62
+ // TODO: REVIEW MuiThemeProvider usage
63
+ // Different theme object identities will force theme consumers to re-render.
64
+ <MuiThemeProvider theme={theme}>
65
+ <Measure bounds onResize={this.onResize}>
66
+ {({ measureRef }) => {
67
+ const { children, settings, hideSettings, dimensions, classes } = this.props;
68
+ const { layoutMode } = this.state;
57
69
 
58
- const settingsPanel =
59
- layoutMode === 'inline' ? <SettingsBox className="settings-box">{settings}</SettingsBox> : settings;
60
- const secondaryContent = hideSettings ? null : settingsPanel;
61
- const finalClass = classNames('main-container');
70
+ const settingsPanel =
71
+ layoutMode === 'inline' ? <SettingsBox className="settings-box">{settings}</SettingsBox> : settings;
72
+ const secondaryContent = hideSettings ? null : settingsPanel;
73
+ const finalClass = classNames('main-container', classes.extraCSSRules);
62
74
 
63
- return (
64
- <div ref={measureRef} className={finalClass}>
65
- <LayoutContents mode={layoutMode} secondary={secondaryContent} dimensions={dimensions}>
66
- {children}
67
- </LayoutContents>
68
- </div>
69
- );
70
- }}
71
- </Measure>
72
- </ThemeProvider>
73
- </StyledEngineProvider>
75
+ return (
76
+ <div ref={measureRef} className={finalClass}>
77
+ <LayoutContents mode={layoutMode} secondary={secondaryContent} dimensions={dimensions}>
78
+ {children}
79
+ </LayoutContents>
80
+ </div>
81
+ );
82
+ }}
83
+ </Measure>
84
+ </MuiThemeProvider>
74
85
  );
75
86
  }
76
87
  }
77
88
 
78
- const ConfigLayout = withContentRect('bounds')(MeasuredConfigLayout);
89
+ const ConfigLayout = withStyles(styles)(withContentRect('bounds')(MeasuredConfigLayout));
79
90
 
80
91
  export default ConfigLayout;