@pie-lib/config-ui 12.0.0-beta.5 → 12.1.0-next.0

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 (139) hide show
  1. package/CHANGELOG.json +8 -1653
  2. package/CHANGELOG.md +345 -4
  3. package/LICENSE.md +5 -0
  4. package/NEXT.CHANGELOG.json +1 -0
  5. package/lib/__tests__/alert-dialog.test.js +262 -0
  6. package/lib/__tests__/checkbox.test.js +227 -0
  7. package/lib/__tests__/choice-utils.test.js +14 -0
  8. package/lib/__tests__/form-section.test.js +252 -0
  9. package/lib/__tests__/help.test.js +270 -0
  10. package/lib/__tests__/input.test.js +268 -0
  11. package/lib/__tests__/langs.test.js +541 -0
  12. package/lib/__tests__/number-text-field-custom.test.js +362 -0
  13. package/lib/__tests__/number-text-field.test.js +421 -0
  14. package/lib/__tests__/radio-with-label.test.js +233 -0
  15. package/lib/__tests__/settings-panel.test.js +184 -0
  16. package/lib/__tests__/settings.test.js +653 -0
  17. package/lib/__tests__/tabs.test.js +211 -0
  18. package/lib/__tests__/two-choice.test.js +124 -0
  19. package/lib/__tests__/with-stateful-model.test.js +221 -0
  20. package/lib/alert-dialog.js +41 -11
  21. package/lib/alert-dialog.js.map +1 -1
  22. package/lib/checkbox.js +59 -49
  23. package/lib/checkbox.js.map +1 -1
  24. package/lib/choice-configuration/__tests__/feedback-menu.test.js +287 -0
  25. package/lib/choice-configuration/__tests__/index.test.js +253 -0
  26. package/lib/choice-configuration/feedback-menu.js +25 -27
  27. package/lib/choice-configuration/feedback-menu.js.map +1 -1
  28. package/lib/choice-configuration/index.js +183 -186
  29. package/lib/choice-configuration/index.js.map +1 -1
  30. package/lib/choice-utils.js +6 -8
  31. package/lib/choice-utils.js.map +1 -1
  32. package/lib/feedback-config/__tests__/feedback-config.test.js +201 -0
  33. package/lib/feedback-config/__tests__/feedback-selector.test.js +177 -0
  34. package/lib/feedback-config/feedback-selector.js +70 -74
  35. package/lib/feedback-config/feedback-selector.js.map +1 -1
  36. package/lib/feedback-config/group.js +23 -26
  37. package/lib/feedback-config/group.js.map +1 -1
  38. package/lib/feedback-config/index.js +42 -45
  39. package/lib/feedback-config/index.js.map +1 -1
  40. package/lib/form-section.js +32 -26
  41. package/lib/form-section.js.map +1 -1
  42. package/lib/help.js +38 -48
  43. package/lib/help.js.map +1 -1
  44. package/lib/index.js +2 -3
  45. package/lib/index.js.map +1 -1
  46. package/lib/input.js +13 -18
  47. package/lib/input.js.map +1 -1
  48. package/lib/inputs.js +59 -68
  49. package/lib/inputs.js.map +1 -1
  50. package/lib/langs.js +57 -71
  51. package/lib/langs.js.map +1 -1
  52. package/lib/layout/__tests__/config.layout.test.js +70 -0
  53. package/lib/layout/__tests__/layout-content.test.js +6 -0
  54. package/lib/layout/config-layout.js +79 -48
  55. package/lib/layout/config-layout.js.map +1 -1
  56. package/lib/layout/index.js +1 -1
  57. package/lib/layout/index.js.map +1 -1
  58. package/lib/layout/layout-contents.js +59 -61
  59. package/lib/layout/layout-contents.js.map +1 -1
  60. package/lib/layout/settings-box.js +26 -34
  61. package/lib/layout/settings-box.js.map +1 -1
  62. package/lib/mui-box/index.js +42 -51
  63. package/lib/mui-box/index.js.map +1 -1
  64. package/lib/number-text-field-custom.js +152 -90
  65. package/lib/number-text-field-custom.js.map +1 -1
  66. package/lib/number-text-field.js +75 -64
  67. package/lib/number-text-field.js.map +1 -1
  68. package/lib/radio-with-label.js +31 -17
  69. package/lib/radio-with-label.js.map +1 -1
  70. package/lib/settings/display-size.js +17 -21
  71. package/lib/settings/display-size.js.map +1 -1
  72. package/lib/settings/index.js +14 -20
  73. package/lib/settings/index.js.map +1 -1
  74. package/lib/settings/panel.js +141 -142
  75. package/lib/settings/panel.js.map +1 -1
  76. package/lib/settings/settings-radio-label.js +30 -17
  77. package/lib/settings/settings-radio-label.js.map +1 -1
  78. package/lib/settings/toggle.js +40 -26
  79. package/lib/settings/toggle.js.map +1 -1
  80. package/lib/tabs/index.js +19 -31
  81. package/lib/tabs/index.js.map +1 -1
  82. package/lib/tags-input/__tests__/index.test.js +183 -0
  83. package/lib/tags-input/index.js +50 -62
  84. package/lib/tags-input/index.js.map +1 -1
  85. package/lib/two-choice.js +34 -44
  86. package/lib/two-choice.js.map +1 -1
  87. package/lib/with-stateful-model.js +9 -13
  88. package/lib/with-stateful-model.js.map +1 -1
  89. package/package.json +14 -11
  90. package/src/__tests__/alert-dialog.test.jsx +283 -0
  91. package/src/__tests__/checkbox.test.jsx +249 -0
  92. package/src/__tests__/choice-utils.test.js +12 -0
  93. package/src/__tests__/form-section.test.jsx +334 -0
  94. package/src/__tests__/help.test.jsx +184 -0
  95. package/src/__tests__/input.test.jsx +192 -0
  96. package/src/__tests__/langs.test.jsx +457 -0
  97. package/src/__tests__/number-text-field-custom.test.jsx +438 -0
  98. package/src/__tests__/number-text-field.test.jsx +341 -0
  99. package/src/__tests__/radio-with-label.test.jsx +259 -0
  100. package/src/__tests__/settings-panel.test.js +187 -0
  101. package/src/__tests__/settings.test.jsx +515 -0
  102. package/src/__tests__/tabs.test.jsx +193 -0
  103. package/src/__tests__/two-choice.test.js +110 -0
  104. package/src/__tests__/with-stateful-model.test.jsx +145 -0
  105. package/src/alert-dialog.jsx +30 -8
  106. package/src/checkbox.jsx +43 -37
  107. package/src/choice-configuration/__tests__/feedback-menu.test.jsx +163 -0
  108. package/src/choice-configuration/__tests__/index.test.jsx +234 -0
  109. package/src/choice-configuration/feedback-menu.jsx +6 -6
  110. package/src/choice-configuration/index.jsx +208 -199
  111. package/src/feedback-config/__tests__/feedback-config.test.jsx +141 -0
  112. package/src/feedback-config/__tests__/feedback-selector.test.jsx +97 -0
  113. package/src/feedback-config/feedback-selector.jsx +50 -55
  114. package/src/feedback-config/group.jsx +21 -22
  115. package/src/feedback-config/index.jsx +27 -29
  116. package/src/form-section.jsx +26 -18
  117. package/src/help.jsx +20 -28
  118. package/src/input.jsx +1 -1
  119. package/src/inputs.jsx +35 -44
  120. package/src/langs.jsx +41 -46
  121. package/src/layout/__tests__/config.layout.test.jsx +59 -0
  122. package/src/layout/__tests__/layout-content.test.jsx +3 -0
  123. package/src/layout/config-layout.jsx +53 -23
  124. package/src/layout/layout-contents.jsx +38 -40
  125. package/src/layout/settings-box.jsx +16 -19
  126. package/src/mui-box/index.jsx +35 -43
  127. package/src/number-text-field-custom.jsx +117 -65
  128. package/src/number-text-field.jsx +51 -34
  129. package/src/radio-with-label.jsx +26 -10
  130. package/src/settings/display-size.jsx +12 -11
  131. package/src/settings/index.js +2 -1
  132. package/src/settings/panel.jsx +101 -92
  133. package/src/settings/settings-radio-label.jsx +26 -10
  134. package/src/settings/toggle.jsx +37 -18
  135. package/src/tabs/index.jsx +8 -8
  136. package/src/tags-input/__tests__/index.test.jsx +113 -0
  137. package/src/tags-input/index.jsx +35 -38
  138. package/src/two-choice.jsx +15 -19
  139. package/README.md +0 -12
@@ -0,0 +1,97 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import React from 'react';
4
+ import { FeedbackSelector } from '../feedback-selector';
5
+
6
+ // Mock the editable-html component to avoid window dependencies in tests
7
+ jest.mock('@pie-lib/editable-html-tip-tap', () => {
8
+ return {
9
+ __esModule: true,
10
+ default: ({ markup, onChange }) => (
11
+ <textarea data-testid="editable-html" defaultValue={markup || ''} onChange={(e) => onChange(e.target.value)} />
12
+ ),
13
+ };
14
+ });
15
+
16
+ describe('feedback-selector', () => {
17
+ let onChange;
18
+
19
+ const renderComponent = (feedback = { type: 'default', default: 'hi' }) => {
20
+ return render(<FeedbackSelector label={'Feedback'} onChange={onChange} feedback={feedback} />);
21
+ };
22
+
23
+ beforeEach(() => {
24
+ onChange = jest.fn();
25
+ });
26
+
27
+ describe('rendering', () => {
28
+ it('renders feedback type selector', () => {
29
+ renderComponent();
30
+ expect(screen.getByText('Simple Feedback')).toBeInTheDocument();
31
+ expect(screen.getByText('No Feedback')).toBeInTheDocument();
32
+ expect(screen.getByText('Customized Feedback')).toBeInTheDocument();
33
+ });
34
+
35
+ it('shows default feedback text when type is default', () => {
36
+ renderComponent({ type: 'default', default: 'hi' });
37
+ expect(screen.getByText('hi')).toBeInTheDocument();
38
+ });
39
+
40
+ it('shows editable html when type is custom', () => {
41
+ renderComponent({ type: 'custom', default: 'hi', custom: 'custom text' });
42
+ expect(screen.getByTestId('editable-html')).toBeInTheDocument();
43
+ expect(screen.getByTestId('editable-html')).toHaveValue('custom text');
44
+ });
45
+
46
+ it('does not show default feedback when type is none', () => {
47
+ renderComponent({ type: 'none', default: 'hi' });
48
+ expect(screen.queryByText('hi')).not.toBeInTheDocument();
49
+ });
50
+ });
51
+
52
+ describe('user interactions', () => {
53
+ it('calls onChange when switching to default feedback', async () => {
54
+ const user = userEvent.setup();
55
+ renderComponent({ type: 'custom', default: 'hi' });
56
+
57
+ await user.click(screen.getByLabelText('Simple Feedback'));
58
+
59
+ expect(onChange).toHaveBeenCalledWith({ type: 'default', default: 'hi' });
60
+ });
61
+
62
+ it('calls onChange when switching to custom feedback', async () => {
63
+ const user = userEvent.setup();
64
+ renderComponent({ type: 'default', default: 'hi' });
65
+
66
+ await user.click(screen.getByLabelText('Customized Feedback'));
67
+
68
+ expect(onChange).toHaveBeenCalledWith({ type: 'custom', default: 'hi' });
69
+ });
70
+
71
+ it('calls onChange when switching to no feedback', async () => {
72
+ const user = userEvent.setup();
73
+ renderComponent({ type: 'default', default: 'hi' });
74
+
75
+ await user.click(screen.getByLabelText('No Feedback'));
76
+
77
+ expect(onChange).toHaveBeenCalledWith({ type: 'none', default: 'hi' });
78
+ });
79
+
80
+ it('calls onChange with custom text when editing custom feedback', async () => {
81
+ const user = userEvent.setup();
82
+ renderComponent({ type: 'custom', default: 'hi', custom: '' });
83
+
84
+ const editor = screen.getByTestId('editable-html');
85
+ await user.clear(editor);
86
+ await user.type(editor, 'text');
87
+
88
+ // user.type triggers onChange for each character, so check that onChange was called
89
+ // and that the last call has 'text' in custom field
90
+ expect(onChange).toHaveBeenCalled();
91
+ const lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0];
92
+ expect(lastCall.type).toBe('custom');
93
+ expect(lastCall.custom).toBe('text');
94
+ expect(lastCall.default).toBe('hi');
95
+ });
96
+ });
97
+ });
@@ -1,54 +1,55 @@
1
- import EditableHTML from '@pie-lib/editable-html';
1
+ //import EditableHTML from '@pie-lib/editable-html-tip-tap';
2
2
  import { InputContainer } from '@pie-lib/render-ui';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
- import { withStyles } from '@material-ui/core/styles';
5
+ import { styled } from '@mui/material/styles';
6
6
  import Group from './group';
7
7
 
8
+ // - mathquill error window not defined
9
+ let EditableHtml;
10
+ let StyledEditableHTML;
11
+ if (typeof window !== 'undefined') {
12
+ EditableHtml = require('@pie-lib/editable-html-tip-tap')['default'];
13
+ StyledEditableHTML = styled(EditableHtml)(({ theme }) => ({
14
+ fontFamily: theme.typography.fontFamily,
15
+ }));
16
+ }
17
+
8
18
  const feedbackLabels = {
9
19
  default: 'Simple Feedback',
10
20
  none: 'No Feedback',
11
21
  custom: 'Customized Feedback',
12
22
  };
13
23
 
14
- const holder = (theme, extras) => ({
24
+ const StyledFeedbackSelector = styled('div')(({ theme }) => ({
25
+ marginBottom: theme.spacing(1),
26
+ }));
27
+
28
+ const StyledInputContainer = styled(InputContainer)(() => ({
29
+ paddingBottom: 0,
30
+ }));
31
+
32
+ const StyledCustomHolder = styled('div')(({ theme }) => ({
15
33
  marginTop: '0px',
16
34
  background: theme.palette.grey[300],
17
- padding: theme.spacing.unit,
18
- marginBottom: theme.spacing.unit * 2,
35
+ padding: 0,
36
+ marginBottom: theme.spacing(2),
19
37
  borderRadius: '4px',
20
- ...extras,
21
- });
22
-
23
- const style = (theme) => ({
24
- feedbackSelector: {
25
- marginBottom: theme.spacing.unit,
26
- },
27
- label: {
28
- cursor: 'pointer',
29
- },
30
- inputContainerLabel: {
31
- transform: 'translateY(-20%)',
32
- },
33
- feedbackInputContainer: {
34
- paddingBottom: 0,
35
- },
36
- customHolder: holder(theme, {
37
- background: theme.palette.grey[300],
38
- padding: 0,
39
- }),
40
- defaultHolder: holder(theme, {
41
- fontFamily: theme.typography.fontFamily,
42
- padding: theme.spacing.unit * 2,
43
- cursor: 'default',
44
- }),
45
- editor: {
46
- fontFamily: theme.typography.fontFamily,
47
- },
48
- group: {
49
- paddingTop: theme.spacing.unit,
50
- },
51
- });
38
+ }));
39
+
40
+ const StyledDefaultHolder = styled('div')(({ theme }) => ({
41
+ marginTop: '0px',
42
+ background: theme.palette.grey[300],
43
+ padding: theme.spacing(2),
44
+ marginBottom: theme.spacing(2),
45
+ borderRadius: '4px',
46
+ fontFamily: theme.typography.fontFamily,
47
+ cursor: 'default',
48
+ }));
49
+
50
+ const StyledGroup = styled(Group)(({ theme }) => ({
51
+ paddingTop: theme.spacing(1),
52
+ }));
52
53
 
53
54
  export const FeedbackType = {
54
55
  type: PropTypes.oneOf(['default', 'custom', 'none']),
@@ -59,11 +60,11 @@ export const FeedbackType = {
59
60
  export class FeedbackSelector extends React.Component {
60
61
  static propTypes = {
61
62
  keys: PropTypes.arrayOf(PropTypes.string),
62
- classes: PropTypes.object.isRequired,
63
63
  label: PropTypes.string.isRequired,
64
64
  feedback: PropTypes.shape(FeedbackType).isRequired,
65
65
  onChange: PropTypes.func.isRequired,
66
66
  toolbarOpts: PropTypes.object,
67
+ mathMlOptions: PropTypes.object,
67
68
  };
68
69
 
69
70
  changeType = (type) => {
@@ -79,44 +80,38 @@ export class FeedbackSelector extends React.Component {
79
80
  };
80
81
 
81
82
  render() {
82
- const { keys, classes, label, feedback, toolbarOpts, mathMlOptions = {} } = this.props;
83
+ const { keys, label, feedback, toolbarOpts, mathMlOptions = {} } = this.props;
83
84
 
84
85
  const feedbackKeys = keys || Object.keys(feedbackLabels);
85
86
 
86
87
  return (
87
- <div className={classes.feedbackSelector}>
88
- <InputContainer
89
- label={label}
90
- className={classes.feedbackInputContainer}
91
- extraClasses={{ label: classes.inputContainerLabel }}
92
- >
93
- <Group
94
- className={classes.group}
88
+ <StyledFeedbackSelector>
89
+ <StyledInputContainer label={label} extraClasses={{ label: { transform: 'translateY(-20%)' } }}>
90
+ <StyledGroup
95
91
  keys={feedbackKeys}
96
92
  label={label}
97
93
  value={feedback.type}
98
94
  onChange={this.changeType}
99
95
  feedbackLabels={feedbackLabels}
100
96
  />
101
- </InputContainer>
97
+ </StyledInputContainer>
102
98
 
103
99
  {feedback.type === 'custom' && (
104
- <div className={classes.customHolder}>
105
- <EditableHTML
106
- className={classes.editor}
100
+ <StyledCustomHolder>
101
+ <StyledEditableHTML
107
102
  onChange={this.changeCustom}
108
103
  markup={feedback.custom || ''}
109
104
  toolbarOpts={toolbarOpts}
110
105
  languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
111
106
  mathMlOptions={mathMlOptions}
112
107
  />
113
- </div>
108
+ </StyledCustomHolder>
114
109
  )}
115
110
 
116
- {feedback.type === 'default' && <div className={classes.defaultHolder}> {feedback.default}</div>}
117
- </div>
111
+ {feedback.type === 'default' && <StyledDefaultHolder> {feedback.default}</StyledDefaultHolder>}
112
+ </StyledFeedbackSelector>
118
113
  );
119
114
  }
120
115
  }
121
116
 
122
- export default withStyles(style)(FeedbackSelector);
117
+ export default FeedbackSelector;
@@ -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 { withStyles } from '@material-ui/core/styles';
5
- import classNames from 'classnames';
4
+ import { styled } from '@mui/material/styles';
6
5
 
7
- const styles = (theme) => ({
8
- radioLabel: {
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': {
9
18
  fontSize: theme.typography.fontSize - 2,
10
19
  },
11
- choice: {
12
- display: 'flex',
13
- alignItems: 'center',
14
- },
15
- choiceHolder: {
16
- display: 'flex',
17
- alignItems: 'center',
18
- },
19
- });
20
+ }));
20
21
 
21
22
  const Group = (props) => {
22
- const { feedbackLabels, value, classes, className, onChange, keys } = props;
23
+ const { feedbackLabels, value, className, onChange, keys } = props;
23
24
 
24
25
  return (
25
- <div className={classNames(classes.choiceHolder, className)}>
26
+ <StyledChoiceHolder className={className}>
26
27
  {keys.map((key) => {
27
28
  return (
28
- <div className={classes.choice} key={key}>
29
- <RadioWithLabel
29
+ <StyledChoice key={key}>
30
+ <StyledRadioWithLabel
30
31
  value={key}
31
32
  checked={value === key}
32
- classes={{ label: classes.radioLabel }}
33
33
  onChange={(e) => onChange(e.currentTarget.value)}
34
34
  label={feedbackLabels[key]}
35
35
  />
36
- </div>
36
+ </StyledChoice>
37
37
  );
38
38
  })}
39
- </div>
39
+ </StyledChoiceHolder>
40
40
  );
41
41
  };
42
42
 
@@ -44,9 +44,8 @@ Group.propTypes = {
44
44
  className: PropTypes.string,
45
45
  feedbackLabels: PropTypes.object.isRequired,
46
46
  value: PropTypes.string.isRequired,
47
- classes: PropTypes.object.isRequired,
48
47
  keys: PropTypes.arrayOf(PropTypes.string),
49
48
  onChange: PropTypes.func,
50
49
  };
51
50
 
52
- export default withStyles(styles)(Group);
51
+ export default Group;
@@ -1,27 +1,26 @@
1
1
  import FeedbackSelector, { FeedbackType } from './feedback-selector';
2
2
  import PropTypes from 'prop-types';
3
3
  import React from 'react';
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';
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';
10
10
  import merge from 'lodash/merge';
11
11
 
12
12
  export { FeedbackSelector };
13
13
 
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
- };
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
+ }));
25
24
 
26
25
  export const buildDefaults = (input) => {
27
26
  return merge(
@@ -45,7 +44,6 @@ export class FeedbackConfig extends React.Component {
45
44
  partial: PropTypes.shape(FeedbackType),
46
45
  }),
47
46
  onChange: PropTypes.func.isRequired,
48
- classes: PropTypes.object.isRequired,
49
47
  toolbarOpts: PropTypes.object,
50
48
  };
51
49
 
@@ -68,17 +66,17 @@ export class FeedbackConfig extends React.Component {
68
66
  onPartialChange = this.onChange.bind(this, 'partial');
69
67
 
70
68
  render() {
71
- const { classes, className, allowPartial, feedback, toolbarOpts } = this.props;
69
+ const { className, allowPartial, feedback, toolbarOpts } = this.props;
72
70
 
73
71
  return (
74
72
  <div className={className}>
75
- <ExpansionPanel>
76
- <ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
77
- <Typography className={classes.heading}>Feedback</Typography>
78
- </ExpansionPanelSummary>
73
+ <Accordion slotProps={{ transition: { timeout: { enter: 225, exit: 195 } } }}>
74
+ <AccordionSummary expandIcon={<ExpandMoreIcon />}>
75
+ <Typography>Feedback</Typography>
76
+ </AccordionSummary>
79
77
 
80
- <ExpansionPanelDetails className={classes.panelDetails}>
81
- <div className={classes.feedbackContainer}>
78
+ <StyledAccordionDetails>
79
+ <StyledFeedbackContainer>
82
80
  <FeedbackSelector
83
81
  label="If correct, show"
84
82
  feedback={feedback.correct}
@@ -101,12 +99,12 @@ export class FeedbackConfig extends React.Component {
101
99
  onChange={this.onIncorrectChange}
102
100
  toolbarOpts={toolbarOpts}
103
101
  />
104
- </div>
105
- </ExpansionPanelDetails>
106
- </ExpansionPanel>
102
+ </StyledFeedbackContainer>
103
+ </StyledAccordionDetails>
104
+ </Accordion>
107
105
  </div>
108
106
  );
109
107
  }
110
108
  }
111
109
 
112
- export default withStyles(style)(FeedbackConfig);
110
+ export default FeedbackConfig;
@@ -1,23 +1,31 @@
1
1
  import React from 'react';
2
- import Typography from '@material-ui/core/Typography';
3
- import classNames from 'classnames';
4
- import { withStyles } from '@material-ui/core/styles';
2
+ import PropTypes from 'prop-types';
3
+ import Typography from '@mui/material/Typography';
4
+ import { styled } from '@mui/material/styles';
5
5
 
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
- });
6
+ const StyledFormSection = styled('div')(({ theme }) => ({
7
+ marginTop: theme.spacing(2),
8
+ marginBottom: theme.spacing(2),
9
+ }));
15
10
 
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}>
11
+ const StyledTypography = styled(Typography)(({ theme }) => ({
12
+ marginBottom: theme.spacing(1),
13
+ }));
14
+
15
+ const FormSection = ({ className, label, children, labelExtraStyle }) => (
16
+ <StyledFormSection className={className}>
17
+ <StyledTypography variant="subtitle1" style={labelExtraStyle}>
19
18
  {label}
20
- </Typography>
19
+ </StyledTypography>
21
20
  {children}
22
- </div>
23
- ));
21
+ </StyledFormSection>
22
+ );
23
+
24
+ FormSection.propTypes = {
25
+ className: PropTypes.string,
26
+ label: PropTypes.string,
27
+ children: PropTypes.node,
28
+ labelExtraStyle: PropTypes.object,
29
+ };
30
+
31
+ export default FormSection;
package/src/help.jsx CHANGED
@@ -1,42 +1,34 @@
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';
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';
6
6
  import PropTypes from 'prop-types';
7
7
 
8
- import Button from '@material-ui/core/Button';
9
- import HelpIcon from '@material-ui/icons/Help';
10
- import IconButton from '@material-ui/core/IconButton';
8
+ import Button from '@mui/material/Button';
9
+ import HelpIcon from '@mui/icons-material/Help';
10
+ import IconButton from '@mui/material/IconButton';
11
11
  import React from 'react';
12
- import { withStyles } from '@material-ui/core/styles';
12
+ import { styled } from '@mui/material/styles';
13
13
 
14
- const RawHelpButton = ({ onClick, classes }) => (
15
- <IconButton
16
- classes={{
17
- label: classes.icon,
18
- }}
19
- onClick={onClick}
20
- >
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">
21
22
  <HelpIcon />
22
- </IconButton>
23
+ </StyledIconButton>
23
24
  );
24
25
 
25
- RawHelpButton.propTypes = {
26
+ HelpButton.propTypes = {
26
27
  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
-
38
30
  export const HelpDialog = ({ open, onClose, children, title }) => (
39
- <Dialog open={open} onRequestClose={onClose}>
31
+ <Dialog open={open} onClose={onClose}>
40
32
  <DialogTitle>{title}</DialogTitle>
41
33
  <DialogContent>
42
34
  <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 '@material-ui/core/Input';
3
+ import { default as MaterialInput } from '@mui/material/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,14 +1,13 @@
1
- import Checkbox from '@material-ui/core/Checkbox';
2
- import Radio from '@material-ui/core/Radio';
1
+ import Checkbox from '@mui/material/Checkbox';
2
+ import Radio from '@mui/material/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 '@material-ui/core/Switch';
7
- import { withStyles } from '@material-ui/core/styles';
8
- import classNames from 'classnames';
6
+ import Switch from '@mui/material/Switch';
7
+ import { styled } from '@mui/material/styles';
8
+ import { color } from '@pie-lib/render-ui';
9
9
 
10
10
  const InputTypes = {
11
- classes: PropTypes.object.isRequired,
12
11
  className: PropTypes.string,
13
12
  label: PropTypes.string,
14
13
  checked: PropTypes.bool,
@@ -17,75 +16,67 @@ const InputTypes = {
17
16
  error: PropTypes.string,
18
17
  };
19
18
 
20
- const RawInputSwitch = ({ classes, className, label, checked, onChange }) => {
19
+ const StyledSwitch = styled(Switch)(() => ({
20
+ justifyContent: 'inherit',
21
+ transform: 'translate(-20%, 20%)',
22
+ }));
23
+
24
+ const InputSwitch = ({ className, label, checked, onChange }) => {
21
25
  return (
22
26
  <InputContainer className={className} label={label}>
23
- <Switch className={classes.switchRoot} checked={checked} onChange={onChange} aria-label={label} />
27
+ <StyledSwitch checked={checked} onChange={onChange} aria-label={label} />
24
28
  </InputContainer>
25
29
  );
26
30
  };
27
31
 
28
- RawInputSwitch.propTypes = { ...InputTypes };
29
-
30
- const InputSwitch = withStyles({
31
- switchRoot: {
32
- justifyContent: 'inherit',
33
- transform: 'translate(-20%, 20%)',
34
- },
35
- })(RawInputSwitch);
32
+ InputSwitch.propTypes = { ...InputTypes };
36
33
 
37
- const RawInputCheckbox = (props) => {
38
- const { classes, className, label, checked, onChange, disabled, error } = props;
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
+ }));
39
41
 
42
+ const InputCheckbox = ({ className, label, checked, onChange, disabled, error }) => {
40
43
  return (
41
44
  <InputContainer className={className} label={label}>
42
- <Checkbox
43
- className={classNames(classes.checkboxRoot, error && classes.error)}
45
+ <StyledCheckbox
44
46
  disabled={disabled}
45
47
  checked={checked}
46
48
  onChange={onChange}
47
49
  aria-label={label}
50
+ error={error}
48
51
  />
49
52
  </InputContainer>
50
53
  );
51
54
  };
52
55
 
53
- RawInputCheckbox.propTypes = { ...InputTypes };
56
+ InputCheckbox.propTypes = { ...InputTypes };
54
57
 
55
- const RawInputRadio = (props) => {
56
- const { classes, className, label, checked, onChange, disabled, error } = props;
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
+ }));
57
65
 
66
+ const InputRadio = ({ className, label, checked, onChange, disabled, error }) => {
58
67
  return (
59
68
  <InputContainer className={className} label={label}>
60
- <Radio
61
- className={classNames(classes.radioRoot, error && classes.error)}
69
+ <StyledRadio
62
70
  disabled={disabled}
63
71
  checked={checked}
64
72
  onChange={onChange}
65
73
  aria-label={label}
74
+ error={error}
66
75
  />
67
76
  </InputContainer>
68
77
  );
69
78
  };
70
79
 
71
- RawInputRadio.propTypes = { ...InputTypes };
72
-
73
- const InputCheckbox = withStyles((theme) => ({
74
- checkboxRoot: {
75
- transform: 'translate(-25%, 20%)',
76
- },
77
- error: {
78
- color: theme.palette.error.main,
79
- },
80
- }))(RawInputCheckbox);
81
-
82
- const InputRadio = withStyles((theme) => ({
83
- radioRoot: {
84
- transform: 'translate(-20%, 20%)',
85
- },
86
- error: {
87
- color: theme.palette.error.main,
88
- },
89
- }))(RawInputRadio);
80
+ InputRadio.propTypes = { ...InputTypes };
90
81
 
91
82
  export { InputSwitch, InputCheckbox, InputRadio };