@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.
- package/CHANGELOG.md +12 -9
- package/lib/__tests__/choice-utils.test.js +16 -0
- package/lib/__tests__/langs.test.js +55 -0
- package/lib/__tests__/number-text-field.test.js +128 -0
- package/lib/__tests__/settings-panel.test.js +201 -0
- package/lib/__tests__/two-choice.test.js +33 -0
- package/lib/alert-dialog.js +42 -23
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +71 -56
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/__tests__/feedback-menu.test.js +20 -0
- package/lib/choice-configuration/__tests__/index.test.js +119 -0
- package/lib/choice-configuration/feedback-menu.js +63 -24
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js +257 -201
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js +18 -6
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/__tests__/feedback-config.test.js +78 -0
- package/lib/feedback-config/__tests__/feedback-selector.test.js +71 -0
- package/lib/feedback-config/feedback-selector.js +114 -77
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js +40 -26
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js +90 -38
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js +33 -24
- package/lib/form-section.js.map +1 -1
- package/lib/help.js +80 -39
- package/lib/help.js.map +1 -1
- package/lib/index.js +31 -1
- package/lib/index.js.map +1 -1
- package/lib/input.js +54 -21
- package/lib/input.js.map +1 -1
- package/lib/inputs.js +95 -61
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js +100 -56
- package/lib/langs.js.map +1 -1
- package/lib/layout/__tests__/config.layout.test.js +33 -0
- package/lib/layout/__tests__/layout-content.test.js +6 -0
- package/lib/layout/config-layout.js +99 -48
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js +3 -0
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js +101 -72
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js +56 -27
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js +57 -41
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +161 -79
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +115 -57
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +31 -23
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js +32 -16
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js +47 -14
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +228 -142
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +30 -21
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +46 -34
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js +57 -22
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/__tests__/index.test.js +88 -0
- package/lib/tags-input/index.js +99 -50
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js +90 -46
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js +31 -8
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +10 -12
- package/src/__tests__/number-text-field.test.jsx +1 -1
- package/src/alert-dialog.jsx +18 -14
- package/src/checkbox.jsx +46 -42
- package/src/choice-configuration/feedback-menu.jsx +5 -5
- package/src/choice-configuration/index.jsx +193 -205
- package/src/feedback-config/feedback-selector.jsx +53 -51
- package/src/feedback-config/group.jsx +22 -21
- package/src/feedback-config/index.jsx +29 -27
- package/src/form-section.jsx +18 -18
- package/src/help.jsx +28 -20
- package/src/input.jsx +1 -1
- package/src/inputs.jsx +50 -34
- package/src/langs.jsx +46 -40
- package/src/layout/config-layout.jsx +36 -25
- package/src/layout/layout-contents.jsx +34 -34
- package/src/layout/settings-box.jsx +19 -16
- package/src/mui-box/index.jsx +43 -35
- package/src/number-text-field-custom.jsx +36 -30
- package/src/number-text-field.jsx +30 -22
- package/src/radio-with-label.jsx +13 -17
- package/src/settings/display-size.jsx +11 -12
- package/src/settings/panel.jsx +89 -83
- package/src/settings/settings-radio-label.jsx +13 -17
- package/src/settings/toggle.jsx +29 -29
- package/src/tabs/index.jsx +8 -8
- package/src/tags-input/index.jsx +38 -35
- package/src/two-choice.jsx +19 -15
- package/LICENSE.md +0 -5
- package/NEXT.CHANGELOG.json +0 -1
|
@@ -1,179 +1,117 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
-
import TextField from '@
|
|
5
|
-
import ActionDelete from '@
|
|
6
|
-
import ArrowRight from '@
|
|
7
|
-
import IconButton from '@
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
import TextField from '@material-ui/core/TextField';
|
|
5
|
+
import ActionDelete from '@material-ui/icons/Delete';
|
|
6
|
+
import ArrowRight from '@material-ui/icons/SubdirectoryArrowRight';
|
|
7
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { InputContainer } from '@pie-lib/render-ui';
|
|
10
|
-
|
|
10
|
+
import EditableHtml from '@pie-lib/editable-html-tip-tap';
|
|
11
11
|
import { InputCheckbox, InputRadio } from '../inputs';
|
|
12
12
|
import FeedbackMenu from './feedback-menu';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
mathMlOptions = {},
|
|
41
|
-
}) => {
|
|
42
|
-
const names = classNames(className);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<InputContainer label={label} className={names}>
|
|
46
|
-
<StyledEditorHolder>
|
|
47
|
-
<EditableHtml
|
|
48
|
-
markup={value || ''}
|
|
49
|
-
disabled={disabled}
|
|
50
|
-
spellCheck={spellCheck}
|
|
51
|
-
nonEmpty={nonEmpty}
|
|
52
|
-
onChange={onChange}
|
|
53
|
-
imageSupport={imageSupport}
|
|
54
|
-
disableImageAlignmentButtons={disableImageAlignmentButtons}
|
|
55
|
-
pluginProps={pluginOpts || {}}
|
|
56
|
-
toolbarOpts={toolbarOpts}
|
|
57
|
-
error={error}
|
|
58
|
-
maxImageWidth={maxImageWidth}
|
|
59
|
-
maxImageHeight={maxImageHeight}
|
|
60
|
-
uploadSoundSupport={uploadSoundSupport}
|
|
61
|
-
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
62
|
-
mathMlOptions={mathMlOptions}
|
|
63
|
-
/>
|
|
64
|
-
</StyledEditorHolder>
|
|
65
|
-
</InputContainer>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
14
|
+
const EditableHtmlContainer = withStyles((theme) => ({
|
|
15
|
+
labelContainer: {},
|
|
16
|
+
editorHolder: {
|
|
17
|
+
marginTop: theme.spacing.unit * 2,
|
|
18
|
+
},
|
|
19
|
+
}))(
|
|
20
|
+
({
|
|
21
|
+
label,
|
|
22
|
+
classes,
|
|
23
|
+
onChange,
|
|
24
|
+
value,
|
|
25
|
+
className,
|
|
26
|
+
imageSupport,
|
|
27
|
+
disableImageAlignmentButtons,
|
|
28
|
+
disabled,
|
|
29
|
+
spellCheck,
|
|
30
|
+
nonEmpty,
|
|
31
|
+
pluginOpts,
|
|
32
|
+
toolbarOpts,
|
|
33
|
+
error,
|
|
34
|
+
maxImageWidth,
|
|
35
|
+
maxImageHeight,
|
|
36
|
+
uploadSoundSupport,
|
|
37
|
+
mathMlOptions = {},
|
|
38
|
+
}) => {
|
|
39
|
+
const names = classNames(classes.labelContainer, className);
|
|
68
40
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
41
|
+
return (
|
|
42
|
+
<InputContainer label={label} className={names}>
|
|
43
|
+
<div className={classes.editorHolder}>
|
|
44
|
+
<EditableHtml
|
|
45
|
+
markup={value || ''}
|
|
46
|
+
disabled={disabled}
|
|
47
|
+
spellCheck={spellCheck}
|
|
48
|
+
nonEmpty={nonEmpty}
|
|
49
|
+
onChange={onChange}
|
|
50
|
+
imageSupport={imageSupport}
|
|
51
|
+
disableImageAlignmentButtons={disableImageAlignmentButtons}
|
|
52
|
+
className={classes.editor}
|
|
53
|
+
pluginProps={pluginOpts || {}}
|
|
54
|
+
toolbarOpts={toolbarOpts}
|
|
55
|
+
error={error}
|
|
56
|
+
maxImageWidth={maxImageWidth}
|
|
57
|
+
maxImageHeight={maxImageHeight}
|
|
58
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
59
|
+
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
60
|
+
mathMlOptions={mathMlOptions}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</InputContainer>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const Feedback = withStyles((theme) => ({
|
|
69
|
+
text: {
|
|
70
|
+
width: '100%',
|
|
71
|
+
},
|
|
72
|
+
feedbackContainer: {
|
|
73
|
+
position: 'relative',
|
|
74
|
+
},
|
|
75
|
+
arrowIcon: {
|
|
76
|
+
fill: theme.palette.grey[400],
|
|
77
|
+
left: -56,
|
|
78
|
+
position: 'absolute',
|
|
79
|
+
top: 20,
|
|
80
|
+
},
|
|
81
|
+
}))(({ value, onChange, type, correct, classes, defaults, toolbarOpts, mathMlOptions = {} }) => {
|
|
89
82
|
if (!type || type === 'none') {
|
|
90
83
|
return null;
|
|
91
84
|
} else if (type === 'default') {
|
|
92
85
|
return (
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
86
|
+
<div className={classes.feedbackContainer}>
|
|
87
|
+
<ArrowRight className={classes.arrowIcon} />
|
|
88
|
+
<TextField
|
|
89
|
+
className={classes.text}
|
|
96
90
|
label="Feedback Text"
|
|
97
91
|
value={correct ? defaults.correct : defaults.incorrect}
|
|
98
92
|
/>
|
|
99
|
-
</
|
|
93
|
+
</div>
|
|
100
94
|
);
|
|
101
95
|
} else {
|
|
102
96
|
return (
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
<
|
|
97
|
+
<div className={classes.feedbackContainer}>
|
|
98
|
+
<ArrowRight className={classes.arrowIcon} />
|
|
99
|
+
<EditableHtmlContainer
|
|
100
|
+
className={classes.text}
|
|
106
101
|
label="Feedback Text"
|
|
107
102
|
value={value}
|
|
108
103
|
onChange={onChange}
|
|
109
104
|
toolbarOpts={toolbarOpts}
|
|
110
105
|
mathMlOptions={mathMlOptions}
|
|
111
106
|
/>
|
|
112
|
-
</
|
|
107
|
+
</div>
|
|
113
108
|
);
|
|
114
109
|
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const StyledIndex = styled('span')(({ theme }) => ({
|
|
118
|
-
paddingRight: theme.spacing(1),
|
|
119
|
-
paddingTop: theme.spacing(3.5),
|
|
120
|
-
}));
|
|
121
|
-
|
|
122
|
-
const StyledTopRow = styled('div')(() => ({
|
|
123
|
-
display: 'flex',
|
|
124
|
-
}));
|
|
125
|
-
|
|
126
|
-
const StyledToggle = styled('div')(({ theme }) => ({
|
|
127
|
-
flex: '0 1 auto',
|
|
128
|
-
paddingTop: theme.spacing(0.5),
|
|
129
|
-
paddingBottom: 0,
|
|
130
|
-
marginRight: 0,
|
|
131
|
-
marginLeft: theme.spacing(1),
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
const StyledFeedback = styled('div')(({ theme }) => ({
|
|
135
|
-
flex: '0 1 auto',
|
|
136
|
-
paddingTop: theme.spacing(2),
|
|
137
|
-
paddingLeft: 0,
|
|
138
|
-
marginLeft: 0,
|
|
139
|
-
marginRight: theme.spacing(1),
|
|
140
|
-
}));
|
|
141
|
-
|
|
142
|
-
const StyledFeedbackIcon = styled('div')(() => ({
|
|
143
|
-
margin: 0,
|
|
144
|
-
width: 'inherit',
|
|
145
|
-
}));
|
|
146
|
-
|
|
147
|
-
const StyledDeleteIcon = styled('div')(() => ({
|
|
148
|
-
margin: 0,
|
|
149
|
-
width: 'inherit',
|
|
150
|
-
}));
|
|
151
|
-
|
|
152
|
-
const StyledDelete = styled('div')(({ theme }) => ({
|
|
153
|
-
flex: '0 1 auto',
|
|
154
|
-
paddingTop: theme.spacing(2),
|
|
155
|
-
paddingLeft: 0,
|
|
156
|
-
marginLeft: 0,
|
|
157
|
-
}));
|
|
158
|
-
|
|
159
|
-
const StyledMiddleColumn = styled('div')(({ theme }) => ({
|
|
160
|
-
display: 'flex',
|
|
161
|
-
flex: 1,
|
|
162
|
-
flexDirection: 'column',
|
|
163
|
-
marginRight: theme.spacing(1),
|
|
164
|
-
}));
|
|
165
|
-
|
|
166
|
-
const StyledInput = styled('div')(() => ({
|
|
167
|
-
marginRight: 0,
|
|
168
|
-
}));
|
|
169
|
-
|
|
170
|
-
const StyledErrorText = styled('div')(({ theme }) => ({
|
|
171
|
-
fontSize: theme.typography.fontSize - 2,
|
|
172
|
-
color: theme.palette.error.main,
|
|
173
|
-
}));
|
|
110
|
+
});
|
|
174
111
|
|
|
175
112
|
export class ChoiceConfiguration extends React.Component {
|
|
176
113
|
static propTypes = {
|
|
114
|
+
classes: PropTypes.object.isRequired,
|
|
177
115
|
noLabels: PropTypes.bool,
|
|
178
116
|
useLetterOrdering: PropTypes.bool,
|
|
179
117
|
className: PropTypes.string,
|
|
@@ -263,6 +201,7 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
263
201
|
render() {
|
|
264
202
|
const {
|
|
265
203
|
data,
|
|
204
|
+
classes,
|
|
266
205
|
mode,
|
|
267
206
|
onDelete,
|
|
268
207
|
defaultFeedback,
|
|
@@ -288,47 +227,45 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
288
227
|
} = this.props;
|
|
289
228
|
|
|
290
229
|
const InputToggle = mode === 'checkbox' ? InputCheckbox : InputRadio;
|
|
291
|
-
const names = classNames(className);
|
|
230
|
+
const names = classNames(classes.choiceConfiguration, className);
|
|
292
231
|
|
|
293
232
|
return (
|
|
294
233
|
<div className={names}>
|
|
295
|
-
<
|
|
234
|
+
<div className={classes.topRow}>
|
|
296
235
|
{index > 0 && (
|
|
297
|
-
<
|
|
236
|
+
<span className={classes.index} type="title">
|
|
298
237
|
{useLetterOrdering ? String.fromCharCode(96 + index).toUpperCase() : index}
|
|
299
|
-
</
|
|
238
|
+
</span>
|
|
300
239
|
)}
|
|
301
240
|
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
241
|
+
<InputToggle
|
|
242
|
+
className={classes.toggle}
|
|
243
|
+
onChange={this.onCheckedChange}
|
|
244
|
+
label={!noLabels ? 'Correct' : ''}
|
|
245
|
+
checked={!!data.correct}
|
|
246
|
+
error={noCorrectAnswerError}
|
|
247
|
+
/>
|
|
248
|
+
|
|
249
|
+
<div className={classes.middleColumn}>
|
|
250
|
+
<EditableHtmlContainer
|
|
251
|
+
className={classes.input}
|
|
252
|
+
label={!noLabels ? 'Label' : ''}
|
|
253
|
+
value={data.label}
|
|
254
|
+
onChange={this.onLabelChange}
|
|
255
|
+
imageSupport={imageSupport}
|
|
256
|
+
disableImageAlignmentButtons={disableImageAlignmentButtons}
|
|
257
|
+
disabled={disabled}
|
|
258
|
+
spellCheck={spellCheck}
|
|
259
|
+
nonEmpty={nonEmpty}
|
|
260
|
+
pluginOpts={pluginOpts}
|
|
261
|
+
toolbarOpts={toolbarOpts}
|
|
262
|
+
error={error}
|
|
263
|
+
uploadSoundSupport={uploadSoundSupport}
|
|
264
|
+
mathMlOptions={mathMlOptions}
|
|
265
|
+
maxImageWidth={maxImageWidth}
|
|
266
|
+
maxImageHeight={maxImageHeight}
|
|
308
267
|
/>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
<StyledMiddleColumn>
|
|
312
|
-
<StyledInput>
|
|
313
|
-
<EditableHtmlContainer
|
|
314
|
-
label={!noLabels ? 'Label' : ''}
|
|
315
|
-
value={data.label}
|
|
316
|
-
onChange={this.onLabelChange}
|
|
317
|
-
imageSupport={imageSupport}
|
|
318
|
-
disableImageAlignmentButtons={disableImageAlignmentButtons}
|
|
319
|
-
disabled={disabled}
|
|
320
|
-
spellCheck={spellCheck}
|
|
321
|
-
nonEmpty={nonEmpty}
|
|
322
|
-
pluginOpts={pluginOpts}
|
|
323
|
-
toolbarOpts={toolbarOpts}
|
|
324
|
-
error={error}
|
|
325
|
-
uploadSoundSupport={uploadSoundSupport}
|
|
326
|
-
mathMlOptions={mathMlOptions}
|
|
327
|
-
maxImageWidth={maxImageWidth}
|
|
328
|
-
maxImageHeight={maxImageHeight}
|
|
329
|
-
/>
|
|
330
|
-
</StyledInput>
|
|
331
|
-
{error && <StyledErrorText>{error}</StyledErrorText>}
|
|
268
|
+
{error && <div className={classes.errorText}>{error}</div>}
|
|
332
269
|
|
|
333
270
|
{allowFeedBack && (
|
|
334
271
|
<Feedback
|
|
@@ -339,39 +276,90 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
339
276
|
toolbarOpts={toolbarOpts}
|
|
340
277
|
/>
|
|
341
278
|
)}
|
|
342
|
-
</
|
|
279
|
+
</div>
|
|
343
280
|
|
|
344
281
|
{allowFeedBack && (
|
|
345
|
-
<
|
|
346
|
-
<
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
</StyledFeedback>
|
|
282
|
+
<InputContainer className={classes.feedback} label={!noLabels ? 'Feedback' : ''}>
|
|
283
|
+
<FeedbackMenu
|
|
284
|
+
onChange={this.onFeedbackTypeChange}
|
|
285
|
+
value={data.feedback}
|
|
286
|
+
classes={{
|
|
287
|
+
icon: classes.feedbackIcon,
|
|
288
|
+
}}
|
|
289
|
+
/>
|
|
290
|
+
</InputContainer>
|
|
355
291
|
)}
|
|
356
292
|
|
|
357
293
|
{allowDelete && (
|
|
358
|
-
<
|
|
359
|
-
<
|
|
360
|
-
<
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
onClick={onDelete}
|
|
364
|
-
size="large">
|
|
365
|
-
<ActionDelete />
|
|
366
|
-
</IconButton>
|
|
367
|
-
</StyledDeleteIcon>
|
|
368
|
-
</InputContainer>
|
|
369
|
-
</StyledDelete>
|
|
294
|
+
<InputContainer className={classes.delete} label={!noLabels ? 'Delete' : ''}>
|
|
295
|
+
<IconButton aria-label="delete" className={classes.deleteIcon} onClick={onDelete}>
|
|
296
|
+
<ActionDelete />
|
|
297
|
+
</IconButton>
|
|
298
|
+
</InputContainer>
|
|
370
299
|
)}
|
|
371
|
-
</
|
|
300
|
+
</div>
|
|
372
301
|
</div>
|
|
373
302
|
);
|
|
374
303
|
}
|
|
375
304
|
}
|
|
376
305
|
|
|
377
|
-
|
|
306
|
+
const styles = (theme) => ({
|
|
307
|
+
index: {
|
|
308
|
+
paddingRight: theme.spacing.unit,
|
|
309
|
+
paddingTop: theme.spacing.unit * 3.5,
|
|
310
|
+
},
|
|
311
|
+
choiceConfiguration: {},
|
|
312
|
+
topRow: {
|
|
313
|
+
display: 'flex',
|
|
314
|
+
},
|
|
315
|
+
value: {
|
|
316
|
+
flex: '0.5',
|
|
317
|
+
paddingRight: theme.spacing.unit,
|
|
318
|
+
},
|
|
319
|
+
editorHolder: {
|
|
320
|
+
marginTop: theme.spacing.unit * 2,
|
|
321
|
+
},
|
|
322
|
+
toggle: {
|
|
323
|
+
flex: '0 1 auto',
|
|
324
|
+
paddingTop: theme.spacing.unit / 2,
|
|
325
|
+
paddingBottom: 0,
|
|
326
|
+
marginRight: 0,
|
|
327
|
+
marginLeft: theme.spacing.unit,
|
|
328
|
+
},
|
|
329
|
+
feedback: {
|
|
330
|
+
flex: '0 1 auto',
|
|
331
|
+
paddingTop: theme.spacing.unit * 2,
|
|
332
|
+
paddingLeft: 0,
|
|
333
|
+
marginLeft: 0,
|
|
334
|
+
marginRight: theme.spacing.unit,
|
|
335
|
+
},
|
|
336
|
+
feedbackIcon: {
|
|
337
|
+
margin: 0,
|
|
338
|
+
width: 'inherit',
|
|
339
|
+
},
|
|
340
|
+
deleteIcon: {
|
|
341
|
+
margin: 0,
|
|
342
|
+
width: 'inherit',
|
|
343
|
+
},
|
|
344
|
+
delete: {
|
|
345
|
+
flex: '0 1 auto',
|
|
346
|
+
paddingTop: theme.spacing.unit * 2,
|
|
347
|
+
paddingLeft: 0,
|
|
348
|
+
marginLeft: 0,
|
|
349
|
+
},
|
|
350
|
+
middleColumn: {
|
|
351
|
+
display: 'flex',
|
|
352
|
+
flex: 1,
|
|
353
|
+
flexDirection: 'column',
|
|
354
|
+
marginRight: theme.spacing.unit,
|
|
355
|
+
},
|
|
356
|
+
input: {
|
|
357
|
+
marginRight: 0,
|
|
358
|
+
},
|
|
359
|
+
errorText: {
|
|
360
|
+
fontSize: theme.typography.fontSize - 2,
|
|
361
|
+
color: theme.palette.error.main,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
export default withStyles(styles)(ChoiceConfiguration);
|
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
|
|
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 {
|
|
5
|
+
import { withStyles } from '@material-ui/core/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
|
-
|
|
19
8
|
const feedbackLabels = {
|
|
20
9
|
default: 'Simple Feedback',
|
|
21
10
|
none: 'No Feedback',
|
|
22
11
|
custom: 'Customized Feedback',
|
|
23
12
|
};
|
|
24
13
|
|
|
25
|
-
const
|
|
26
|
-
marginBottom: theme.spacing(1),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
const StyledInputContainer = styled(InputContainer)(() => ({
|
|
30
|
-
paddingBottom: 0,
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
const StyledCustomHolder = styled('div')(({ theme }) => ({
|
|
14
|
+
const holder = (theme, extras) => ({
|
|
34
15
|
marginTop: '0px',
|
|
35
16
|
background: theme.palette.grey[300],
|
|
36
|
-
padding:
|
|
37
|
-
marginBottom: theme.spacing
|
|
17
|
+
padding: theme.spacing.unit,
|
|
18
|
+
marginBottom: theme.spacing.unit * 2,
|
|
38
19
|
borderRadius: '4px',
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
});
|
|
54
52
|
|
|
55
53
|
export const FeedbackType = {
|
|
56
54
|
type: PropTypes.oneOf(['default', 'custom', 'none']),
|
|
@@ -61,6 +59,7 @@ export const FeedbackType = {
|
|
|
61
59
|
export class FeedbackSelector extends React.Component {
|
|
62
60
|
static propTypes = {
|
|
63
61
|
keys: PropTypes.arrayOf(PropTypes.string),
|
|
62
|
+
classes: PropTypes.object.isRequired,
|
|
64
63
|
label: PropTypes.string.isRequired,
|
|
65
64
|
feedback: PropTypes.shape(FeedbackType).isRequired,
|
|
66
65
|
onChange: PropTypes.func.isRequired,
|
|
@@ -80,41 +79,44 @@ export class FeedbackSelector extends React.Component {
|
|
|
80
79
|
};
|
|
81
80
|
|
|
82
81
|
render() {
|
|
83
|
-
const { keys, label, feedback, toolbarOpts, mathMlOptions = {} } = this.props;
|
|
82
|
+
const { keys, classes, label, feedback, toolbarOpts, mathMlOptions = {} } = this.props;
|
|
84
83
|
|
|
85
84
|
const feedbackKeys = keys || Object.keys(feedbackLabels);
|
|
86
85
|
|
|
87
86
|
return (
|
|
88
|
-
<
|
|
89
|
-
<
|
|
87
|
+
<div className={classes.feedbackSelector}>
|
|
88
|
+
<InputContainer
|
|
90
89
|
label={label}
|
|
91
|
-
|
|
90
|
+
className={classes.feedbackInputContainer}
|
|
91
|
+
extraClasses={{ label: classes.inputContainerLabel }}
|
|
92
92
|
>
|
|
93
|
-
<
|
|
93
|
+
<Group
|
|
94
|
+
className={classes.group}
|
|
94
95
|
keys={feedbackKeys}
|
|
95
96
|
label={label}
|
|
96
97
|
value={feedback.type}
|
|
97
98
|
onChange={this.changeType}
|
|
98
99
|
feedbackLabels={feedbackLabels}
|
|
99
100
|
/>
|
|
100
|
-
</
|
|
101
|
+
</InputContainer>
|
|
101
102
|
|
|
102
103
|
{feedback.type === 'custom' && (
|
|
103
|
-
<
|
|
104
|
-
<
|
|
104
|
+
<div className={classes.customHolder}>
|
|
105
|
+
<EditableHTML
|
|
106
|
+
className={classes.editor}
|
|
105
107
|
onChange={this.changeCustom}
|
|
106
108
|
markup={feedback.custom || ''}
|
|
107
109
|
toolbarOpts={toolbarOpts}
|
|
108
110
|
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
109
111
|
mathMlOptions={mathMlOptions}
|
|
110
112
|
/>
|
|
111
|
-
</
|
|
113
|
+
</div>
|
|
112
114
|
)}
|
|
113
115
|
|
|
114
|
-
{feedback.type === 'default' && <
|
|
115
|
-
</
|
|
116
|
+
{feedback.type === 'default' && <div className={classes.defaultHolder}> {feedback.default}</div>}
|
|
117
|
+
</div>
|
|
116
118
|
);
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
export default FeedbackSelector;
|
|
122
|
+
export default withStyles(style)(FeedbackSelector);
|