@pie-lib/config-ui 12.0.0-beta.5 → 12.0.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.
- package/CHANGELOG.json +8 -1653
- package/CHANGELOG.md +345 -4
- package/LICENSE.md +5 -0
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/alert-dialog.js +40 -10
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +58 -48
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/feedback-menu.js +24 -26
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js +182 -185
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js +5 -7
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js +69 -73
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js +22 -25
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js +41 -44
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js +31 -25
- package/lib/form-section.js.map +1 -1
- package/lib/help.js +37 -47
- package/lib/help.js.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/input.js +12 -17
- package/lib/input.js.map +1 -1
- package/lib/inputs.js +58 -67
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js +56 -70
- package/lib/langs.js.map +1 -1
- package/lib/layout/config-layout.js +78 -47
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js +58 -60
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js +25 -33
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js +41 -50
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +151 -89
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +74 -63
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +30 -16
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js +16 -20
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js +13 -19
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +140 -141
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +29 -16
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +39 -25
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js +18 -30
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/index.js +49 -61
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js +33 -43
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js +8 -12
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +22 -11
- package/src/__tests__/alert-dialog.test.jsx +283 -0
- package/src/__tests__/checkbox.test.jsx +249 -0
- package/src/__tests__/choice-utils.test.js +12 -0
- package/src/__tests__/form-section.test.jsx +334 -0
- package/src/__tests__/help.test.jsx +184 -0
- package/src/__tests__/input.test.jsx +192 -0
- package/src/__tests__/langs.test.jsx +457 -0
- package/src/__tests__/number-text-field-custom.test.jsx +438 -0
- package/src/__tests__/number-text-field.test.jsx +341 -0
- package/src/__tests__/radio-with-label.test.jsx +259 -0
- package/src/__tests__/settings-panel.test.js +187 -0
- package/src/__tests__/settings.test.jsx +515 -0
- package/src/__tests__/tabs.test.jsx +193 -0
- package/src/__tests__/two-choice.test.js +110 -0
- package/src/__tests__/with-stateful-model.test.jsx +145 -0
- package/src/alert-dialog.jsx +30 -8
- package/src/checkbox.jsx +43 -37
- package/src/choice-configuration/__tests__/feedback-menu.test.jsx +163 -0
- package/src/choice-configuration/__tests__/index.test.jsx +234 -0
- package/src/choice-configuration/feedback-menu.jsx +6 -6
- package/src/choice-configuration/index.jsx +208 -192
- package/src/feedback-config/__tests__/feedback-config.test.jsx +141 -0
- package/src/feedback-config/__tests__/feedback-selector.test.jsx +107 -0
- package/src/feedback-config/feedback-selector.jsx +52 -53
- package/src/feedback-config/group.jsx +21 -22
- package/src/feedback-config/index.jsx +27 -29
- package/src/form-section.jsx +26 -18
- package/src/help.jsx +20 -28
- package/src/input.jsx +1 -1
- package/src/inputs.jsx +35 -44
- package/src/langs.jsx +41 -46
- package/src/layout/__tests__/config.layout.test.jsx +59 -0
- package/src/layout/__tests__/layout-content.test.jsx +3 -0
- package/src/layout/config-layout.jsx +53 -23
- package/src/layout/layout-contents.jsx +38 -40
- package/src/layout/settings-box.jsx +16 -19
- package/src/mui-box/index.jsx +35 -43
- package/src/number-text-field-custom.jsx +117 -65
- package/src/number-text-field.jsx +51 -34
- package/src/radio-with-label.jsx +26 -10
- package/src/settings/display-size.jsx +12 -11
- package/src/settings/index.js +2 -1
- package/src/settings/panel.jsx +101 -92
- package/src/settings/settings-radio-label.jsx +26 -10
- package/src/settings/toggle.jsx +37 -18
- package/src/tabs/index.jsx +8 -8
- package/src/tags-input/__tests__/index.test.jsx +113 -0
- package/src/tags-input/index.jsx +35 -38
- package/src/two-choice.jsx +15 -19
- package/README.md +0 -12
|
@@ -0,0 +1,107 @@
|
|
|
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', () => {
|
|
8
|
+
return {
|
|
9
|
+
__esModule: true,
|
|
10
|
+
default: ({ markup, onChange }) => (
|
|
11
|
+
<textarea
|
|
12
|
+
data-testid="editable-html"
|
|
13
|
+
defaultValue={markup || ''}
|
|
14
|
+
onChange={(e) => onChange(e.target.value)}
|
|
15
|
+
/>
|
|
16
|
+
),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('feedback-selector', () => {
|
|
21
|
+
let onChange;
|
|
22
|
+
|
|
23
|
+
const renderComponent = (feedback = { type: 'default', default: 'hi' }) => {
|
|
24
|
+
return render(
|
|
25
|
+
<FeedbackSelector
|
|
26
|
+
label={'Feedback'}
|
|
27
|
+
onChange={onChange}
|
|
28
|
+
feedback={feedback}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
onChange = jest.fn();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('rendering', () => {
|
|
38
|
+
it('renders feedback type selector', () => {
|
|
39
|
+
renderComponent();
|
|
40
|
+
expect(screen.getByText('Simple Feedback')).toBeInTheDocument();
|
|
41
|
+
expect(screen.getByText('No Feedback')).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByText('Customized Feedback')).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('shows default feedback text when type is default', () => {
|
|
46
|
+
renderComponent({ type: 'default', default: 'hi' });
|
|
47
|
+
expect(screen.getByText('hi')).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('shows editable html when type is custom', () => {
|
|
51
|
+
renderComponent({ type: 'custom', default: 'hi', custom: 'custom text' });
|
|
52
|
+
expect(screen.getByTestId('editable-html')).toBeInTheDocument();
|
|
53
|
+
expect(screen.getByTestId('editable-html')).toHaveValue('custom text');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('does not show default feedback when type is none', () => {
|
|
57
|
+
renderComponent({ type: 'none', default: 'hi' });
|
|
58
|
+
expect(screen.queryByText('hi')).not.toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('user interactions', () => {
|
|
63
|
+
it('calls onChange when switching to default feedback', async () => {
|
|
64
|
+
const user = userEvent.setup();
|
|
65
|
+
renderComponent({ type: 'custom', default: 'hi' });
|
|
66
|
+
|
|
67
|
+
await user.click(screen.getByLabelText('Simple Feedback'));
|
|
68
|
+
|
|
69
|
+
expect(onChange).toHaveBeenCalledWith({ type: 'default', default: 'hi' });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('calls onChange when switching to custom feedback', async () => {
|
|
73
|
+
const user = userEvent.setup();
|
|
74
|
+
renderComponent({ type: 'default', default: 'hi' });
|
|
75
|
+
|
|
76
|
+
await user.click(screen.getByLabelText('Customized Feedback'));
|
|
77
|
+
|
|
78
|
+
expect(onChange).toHaveBeenCalledWith({ type: 'custom', default: 'hi' });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('calls onChange when switching to no feedback', async () => {
|
|
82
|
+
const user = userEvent.setup();
|
|
83
|
+
renderComponent({ type: 'default', default: 'hi' });
|
|
84
|
+
|
|
85
|
+
await user.click(screen.getByLabelText('No Feedback'));
|
|
86
|
+
|
|
87
|
+
expect(onChange).toHaveBeenCalledWith({ type: 'none', default: 'hi' });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('calls onChange with custom text when editing custom feedback', async () => {
|
|
91
|
+
const user = userEvent.setup();
|
|
92
|
+
renderComponent({ type: 'custom', default: 'hi', custom: '' });
|
|
93
|
+
|
|
94
|
+
const editor = screen.getByTestId('editable-html');
|
|
95
|
+
await user.clear(editor);
|
|
96
|
+
await user.type(editor, 'text');
|
|
97
|
+
|
|
98
|
+
// user.type triggers onChange for each character, so check that onChange was called
|
|
99
|
+
// and that the last call has 'text' in custom field
|
|
100
|
+
expect(onChange).toHaveBeenCalled();
|
|
101
|
+
const lastCall = onChange.mock.calls[onChange.mock.calls.length - 1][0];
|
|
102
|
+
expect(lastCall.type).toBe('custom');
|
|
103
|
+
expect(lastCall.custom).toBe('text');
|
|
104
|
+
expect(lastCall.default).toBe('hi');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
import EditableHTML from '@pie-lib/editable-html';
|
|
1
|
+
//import EditableHTML from '@pie-lib/editable-html';
|
|
2
2
|
import { InputContainer } from '@pie-lib/render-ui';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
6
|
import Group from './group';
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
// - mathquill error window not defined
|
|
10
|
+
let EditableHtml;
|
|
11
|
+
let StyledEditableHTML;
|
|
12
|
+
if (typeof window !== 'undefined') {
|
|
13
|
+
EditableHtml = require('@pie-lib/editable-html')['default'];
|
|
14
|
+
StyledEditableHTML = styled(EditableHtml)(({ theme }) => ({
|
|
15
|
+
fontFamily: theme.typography.fontFamily,
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
const feedbackLabels = {
|
|
9
20
|
default: 'Simple Feedback',
|
|
10
21
|
none: 'No Feedback',
|
|
11
22
|
custom: 'Customized Feedback',
|
|
12
23
|
};
|
|
13
24
|
|
|
14
|
-
const
|
|
25
|
+
const StyledFeedbackSelector = styled('div')(({ theme }) => ({
|
|
26
|
+
marginBottom: theme.spacing(1),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const StyledInputContainer = styled(InputContainer)(() => ({
|
|
30
|
+
paddingBottom: 0,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
const StyledCustomHolder = styled('div')(({ theme }) => ({
|
|
15
34
|
marginTop: '0px',
|
|
16
35
|
background: theme.palette.grey[300],
|
|
17
|
-
padding:
|
|
18
|
-
marginBottom: theme.spacing
|
|
36
|
+
padding: 0,
|
|
37
|
+
marginBottom: theme.spacing(2),
|
|
19
38
|
borderRadius: '4px',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
});
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const StyledDefaultHolder = styled('div')(({ theme }) => ({
|
|
42
|
+
marginTop: '0px',
|
|
43
|
+
background: theme.palette.grey[300],
|
|
44
|
+
padding: theme.spacing(2),
|
|
45
|
+
marginBottom: theme.spacing(2),
|
|
46
|
+
borderRadius: '4px',
|
|
47
|
+
fontFamily: theme.typography.fontFamily,
|
|
48
|
+
cursor: 'default',
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const StyledGroup = styled(Group)(({ theme }) => ({
|
|
52
|
+
paddingTop: theme.spacing(1),
|
|
53
|
+
}));
|
|
52
54
|
|
|
53
55
|
export const FeedbackType = {
|
|
54
56
|
type: PropTypes.oneOf(['default', 'custom', 'none']),
|
|
@@ -59,11 +61,11 @@ export const FeedbackType = {
|
|
|
59
61
|
export class FeedbackSelector extends React.Component {
|
|
60
62
|
static propTypes = {
|
|
61
63
|
keys: PropTypes.arrayOf(PropTypes.string),
|
|
62
|
-
classes: PropTypes.object.isRequired,
|
|
63
64
|
label: PropTypes.string.isRequired,
|
|
64
65
|
feedback: PropTypes.shape(FeedbackType).isRequired,
|
|
65
66
|
onChange: PropTypes.func.isRequired,
|
|
66
67
|
toolbarOpts: PropTypes.object,
|
|
68
|
+
mathMlOptions: PropTypes.object,
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
changeType = (type) => {
|
|
@@ -79,44 +81,41 @@ export class FeedbackSelector extends React.Component {
|
|
|
79
81
|
};
|
|
80
82
|
|
|
81
83
|
render() {
|
|
82
|
-
const { keys,
|
|
84
|
+
const { keys, label, feedback, toolbarOpts, mathMlOptions = {} } = this.props;
|
|
83
85
|
|
|
84
86
|
const feedbackKeys = keys || Object.keys(feedbackLabels);
|
|
85
87
|
|
|
86
88
|
return (
|
|
87
|
-
<
|
|
88
|
-
<
|
|
89
|
+
<StyledFeedbackSelector>
|
|
90
|
+
<StyledInputContainer
|
|
89
91
|
label={label}
|
|
90
|
-
|
|
91
|
-
extraClasses={{ label: classes.inputContainerLabel }}
|
|
92
|
+
extraClasses={{ label: { transform: 'translateY(-20%)' } }}
|
|
92
93
|
>
|
|
93
|
-
<
|
|
94
|
-
className={classes.group}
|
|
94
|
+
<StyledGroup
|
|
95
95
|
keys={feedbackKeys}
|
|
96
96
|
label={label}
|
|
97
97
|
value={feedback.type}
|
|
98
98
|
onChange={this.changeType}
|
|
99
99
|
feedbackLabels={feedbackLabels}
|
|
100
100
|
/>
|
|
101
|
-
</
|
|
101
|
+
</StyledInputContainer>
|
|
102
102
|
|
|
103
103
|
{feedback.type === 'custom' && (
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
className={classes.editor}
|
|
104
|
+
<StyledCustomHolder>
|
|
105
|
+
<StyledEditableHTML
|
|
107
106
|
onChange={this.changeCustom}
|
|
108
107
|
markup={feedback.custom || ''}
|
|
109
108
|
toolbarOpts={toolbarOpts}
|
|
110
109
|
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
111
110
|
mathMlOptions={mathMlOptions}
|
|
112
111
|
/>
|
|
113
|
-
</
|
|
112
|
+
</StyledCustomHolder>
|
|
114
113
|
)}
|
|
115
114
|
|
|
116
|
-
{feedback.type === 'default' && <
|
|
117
|
-
</
|
|
115
|
+
{feedback.type === 'default' && <StyledDefaultHolder> {feedback.default}</StyledDefaultHolder>}
|
|
116
|
+
</StyledFeedbackSelector>
|
|
118
117
|
);
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
|
|
122
|
-
export default
|
|
121
|
+
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 {
|
|
5
|
-
import classNames from 'classnames';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
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
|
-
|
|
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,
|
|
23
|
+
const { feedbackLabels, value, className, onChange, keys } = props;
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<
|
|
26
|
+
<StyledChoiceHolder className={className}>
|
|
26
27
|
{keys.map((key) => {
|
|
27
28
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
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
|
-
</
|
|
36
|
+
</StyledChoice>
|
|
37
37
|
);
|
|
38
38
|
})}
|
|
39
|
-
</
|
|
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
|
|
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 {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import Typography from '@material
|
|
9
|
-
import ExpandMoreIcon from '@
|
|
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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 {
|
|
69
|
+
const { className, allowPartial, feedback, toolbarOpts } = this.props;
|
|
72
70
|
|
|
73
71
|
return (
|
|
74
72
|
<div className={className}>
|
|
75
|
-
<
|
|
76
|
-
<
|
|
77
|
-
<Typography
|
|
78
|
-
</
|
|
73
|
+
<Accordion slotProps={{ transition: { timeout: { enter: 225, exit: 195 } } }}>
|
|
74
|
+
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
75
|
+
<Typography>Feedback</Typography>
|
|
76
|
+
</AccordionSummary>
|
|
79
77
|
|
|
80
|
-
<
|
|
81
|
-
<
|
|
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
|
-
</
|
|
105
|
-
</
|
|
106
|
-
</
|
|
102
|
+
</StyledFeedbackContainer>
|
|
103
|
+
</StyledAccordionDetails>
|
|
104
|
+
</Accordion>
|
|
107
105
|
</div>
|
|
108
106
|
);
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
|
|
112
|
-
export default
|
|
110
|
+
export default FeedbackConfig;
|
package/src/form-section.jsx
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Typography from '@mui/material/Typography';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
</
|
|
19
|
+
</StyledTypography>
|
|
21
20
|
{children}
|
|
22
|
-
</
|
|
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
|
|
2
|
-
import DialogTitle from '@material
|
|
3
|
-
import DialogContentText from '@material
|
|
4
|
-
import DialogContent from '@material
|
|
5
|
-
import DialogActions from '@material
|
|
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
|
|
9
|
-
import HelpIcon from '@
|
|
10
|
-
import IconButton from '@material
|
|
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 {
|
|
12
|
+
import { styled } from '@mui/material/styles';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
</
|
|
23
|
+
</StyledIconButton>
|
|
23
24
|
);
|
|
24
25
|
|
|
25
|
-
|
|
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}
|
|
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
|
|
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 {
|