@pie-lib/config-ui 11.3.13-next.0 → 12.0.0-beta.2
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 +0 -332
- package/lib/alert-dialog.js +1 -1
- package/lib/alert-dialog.js.map +1 -1
- package/lib/checkbox.js +3 -3
- package/lib/checkbox.js.map +1 -1
- package/lib/choice-configuration/feedback-menu.js +1 -1
- package/lib/choice-configuration/feedback-menu.js.map +1 -1
- package/lib/choice-configuration/index.js +10 -24
- package/lib/choice-configuration/index.js.map +1 -1
- package/lib/choice-utils.js +1 -1
- package/lib/choice-utils.js.map +1 -1
- package/lib/feedback-config/feedback-selector.js +6 -12
- package/lib/feedback-config/feedback-selector.js.map +1 -1
- package/lib/feedback-config/group.js +3 -3
- package/lib/feedback-config/group.js.map +1 -1
- package/lib/feedback-config/index.js +1 -1
- package/lib/feedback-config/index.js.map +1 -1
- package/lib/form-section.js +1 -1
- package/lib/form-section.js.map +1 -1
- package/lib/help.js +6 -8
- package/lib/help.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/input.js +1 -1
- package/lib/input.js.map +1 -1
- package/lib/inputs.js +10 -12
- package/lib/inputs.js.map +1 -1
- package/lib/langs.js +1 -1
- package/lib/langs.js.map +1 -1
- package/lib/layout/config-layout.js +16 -28
- package/lib/layout/config-layout.js.map +1 -1
- package/lib/layout/index.js +1 -1
- package/lib/layout/index.js.map +1 -1
- package/lib/layout/layout-contents.js +16 -85
- package/lib/layout/layout-contents.js.map +1 -1
- package/lib/layout/settings-box.js +6 -5
- package/lib/layout/settings-box.js.map +1 -1
- package/lib/mui-box/index.js +1 -1
- package/lib/mui-box/index.js.map +1 -1
- package/lib/number-text-field-custom.js +1 -1
- package/lib/number-text-field-custom.js.map +1 -1
- package/lib/number-text-field.js +1 -1
- package/lib/number-text-field.js.map +1 -1
- package/lib/radio-with-label.js +1 -1
- package/lib/radio-with-label.js.map +1 -1
- package/lib/settings/display-size.js +1 -1
- package/lib/settings/display-size.js.map +1 -1
- package/lib/settings/index.js +1 -1
- package/lib/settings/index.js.map +1 -1
- package/lib/settings/panel.js +58 -78
- package/lib/settings/panel.js.map +1 -1
- package/lib/settings/settings-radio-label.js +8 -10
- package/lib/settings/settings-radio-label.js.map +1 -1
- package/lib/settings/toggle.js +2 -2
- package/lib/settings/toggle.js.map +1 -1
- package/lib/tabs/index.js +2 -6
- package/lib/tabs/index.js.map +1 -1
- package/lib/tags-input/index.js +3 -3
- package/lib/tags-input/index.js.map +1 -1
- package/lib/two-choice.js +1 -1
- package/lib/two-choice.js.map +1 -1
- package/lib/with-stateful-model.js +1 -1
- package/lib/with-stateful-model.js.map +1 -1
- package/package.json +5 -5
- package/src/alert-dialog.jsx +9 -2
- package/src/checkbox.jsx +10 -10
- package/src/choice-configuration/feedback-menu.jsx +23 -10
- package/src/choice-configuration/index.jsx +49 -66
- package/src/choice-utils.js +1 -1
- package/src/feedback-config/feedback-selector.jsx +22 -26
- package/src/feedback-config/group.jsx +12 -10
- package/src/feedback-config/index.jsx +8 -14
- package/src/form-section.jsx +4 -4
- package/src/help.jsx +15 -14
- package/src/index.js +5 -2
- package/src/input.jsx +7 -7
- package/src/inputs.jsx +20 -15
- package/src/langs.jsx +39 -28
- package/src/layout/config-layout.jsx +20 -17
- package/src/layout/layout-contents.jsx +19 -65
- package/src/layout/settings-box.jsx +8 -12
- package/src/mui-box/index.jsx +9 -9
- package/src/number-text-field-custom.jsx +25 -25
- package/src/number-text-field.jsx +12 -12
- package/src/radio-with-label.jsx +2 -2
- package/src/settings/display-size.jsx +5 -5
- package/src/settings/index.js +11 -12
- package/src/settings/panel.jsx +59 -64
- package/src/settings/settings-radio-label.jsx +5 -5
- package/src/settings/toggle.jsx +7 -7
- package/src/tabs/index.jsx +15 -11
- package/src/tags-input/index.jsx +19 -17
- package/src/two-choice.jsx +8 -8
- package/src/with-stateful-model.jsx +4 -4
- package/LICENSE.md +0 -5
|
@@ -11,29 +11,27 @@ import ActionDelete from '@material-ui/icons/Delete';
|
|
|
11
11
|
import ArrowRight from '@material-ui/icons/SubdirectoryArrowRight';
|
|
12
12
|
import IconButton from '@material-ui/core/IconButton';
|
|
13
13
|
|
|
14
|
-
const EditableHtmlContainer = withStyles(
|
|
14
|
+
const EditableHtmlContainer = withStyles(theme => ({
|
|
15
15
|
labelContainer: {},
|
|
16
16
|
editorHolder: {
|
|
17
|
-
marginTop: theme.spacing.unit * 2
|
|
18
|
-
}
|
|
17
|
+
marginTop: theme.spacing.unit * 2
|
|
18
|
+
}
|
|
19
19
|
}))(
|
|
20
20
|
({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
uploadSoundSupport,
|
|
36
|
-
}) => {
|
|
21
|
+
label,
|
|
22
|
+
classes,
|
|
23
|
+
onChange,
|
|
24
|
+
value,
|
|
25
|
+
className,
|
|
26
|
+
imageSupport,
|
|
27
|
+
disabled,
|
|
28
|
+
spellCheck,
|
|
29
|
+
nonEmpty,
|
|
30
|
+
toolbarOpts,
|
|
31
|
+
error,
|
|
32
|
+
maxImageWidth,
|
|
33
|
+
maxImageHeight
|
|
34
|
+
}) => {
|
|
37
35
|
const names = classNames(classes.labelContainer, className);
|
|
38
36
|
|
|
39
37
|
return (
|
|
@@ -46,34 +44,31 @@ const EditableHtmlContainer = withStyles((theme) => ({
|
|
|
46
44
|
nonEmpty={nonEmpty}
|
|
47
45
|
onChange={onChange}
|
|
48
46
|
imageSupport={imageSupport}
|
|
49
|
-
disableImageAlignmentButtons={disableImageAlignmentButtons}
|
|
50
47
|
className={classes.editor}
|
|
51
48
|
toolbarOpts={toolbarOpts}
|
|
52
49
|
error={error}
|
|
53
50
|
maxImageWidth={maxImageWidth}
|
|
54
51
|
maxImageHeight={maxImageHeight}
|
|
55
|
-
uploadSoundSupport={uploadSoundSupport}
|
|
56
|
-
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
57
52
|
/>
|
|
58
53
|
</div>
|
|
59
54
|
</InputContainer>
|
|
60
55
|
);
|
|
61
|
-
}
|
|
56
|
+
}
|
|
62
57
|
);
|
|
63
58
|
|
|
64
|
-
const Feedback = withStyles((
|
|
59
|
+
const Feedback = withStyles(() => ({
|
|
65
60
|
text: {
|
|
66
|
-
width: '100%'
|
|
61
|
+
width: '100%'
|
|
67
62
|
},
|
|
68
63
|
feedbackContainer: {
|
|
69
|
-
position: 'relative'
|
|
64
|
+
position: 'relative'
|
|
70
65
|
},
|
|
71
66
|
arrowIcon: {
|
|
72
|
-
fill:
|
|
67
|
+
fill: '#ccc',
|
|
73
68
|
left: -56,
|
|
74
69
|
position: 'absolute',
|
|
75
|
-
top: 20
|
|
76
|
-
}
|
|
70
|
+
top: 20
|
|
71
|
+
}
|
|
77
72
|
}))(({ value, onChange, type, correct, classes, defaults, toolbarOpts }) => {
|
|
78
73
|
if (!type || type === 'none') {
|
|
79
74
|
return null;
|
|
@@ -120,20 +115,19 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
120
115
|
correct: PropTypes.bool,
|
|
121
116
|
feedback: PropTypes.shape({
|
|
122
117
|
type: PropTypes.string,
|
|
123
|
-
value: PropTypes.string
|
|
124
|
-
})
|
|
118
|
+
value: PropTypes.string
|
|
119
|
+
})
|
|
125
120
|
}),
|
|
126
121
|
onDelete: PropTypes.func,
|
|
127
122
|
onChange: PropTypes.func,
|
|
128
123
|
index: PropTypes.number,
|
|
129
124
|
imageSupport: PropTypes.shape({
|
|
130
125
|
add: PropTypes.func.isRequired,
|
|
131
|
-
delete: PropTypes.func.isRequired
|
|
126
|
+
delete: PropTypes.func.isRequired
|
|
132
127
|
}),
|
|
133
|
-
disableImageAlignmentButtons: PropTypes.bool,
|
|
134
128
|
allowFeedBack: PropTypes.bool,
|
|
135
129
|
allowDelete: PropTypes.bool,
|
|
136
|
-
toolbarOpts: PropTypes.object
|
|
130
|
+
toolbarOpts: PropTypes.object
|
|
137
131
|
};
|
|
138
132
|
|
|
139
133
|
static defaultProps = {
|
|
@@ -141,12 +135,11 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
141
135
|
noLabels: false,
|
|
142
136
|
useLetterOrdering: false,
|
|
143
137
|
allowFeedBack: true,
|
|
144
|
-
allowDelete: true
|
|
138
|
+
allowDelete: true
|
|
145
139
|
};
|
|
146
140
|
|
|
147
|
-
_changeFn =
|
|
141
|
+
_changeFn = key => update => {
|
|
148
142
|
const { data, onChange } = this.props;
|
|
149
|
-
|
|
150
143
|
if (onChange) {
|
|
151
144
|
onChange({ ...data, [key]: update });
|
|
152
145
|
}
|
|
@@ -154,7 +147,7 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
154
147
|
|
|
155
148
|
onLabelChange = this._changeFn('label');
|
|
156
149
|
|
|
157
|
-
onCheckedChange =
|
|
150
|
+
onCheckedChange = event => {
|
|
158
151
|
const correct = event.target.checked;
|
|
159
152
|
const { data, onChange } = this.props;
|
|
160
153
|
|
|
@@ -163,7 +156,7 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
163
156
|
}
|
|
164
157
|
};
|
|
165
158
|
|
|
166
|
-
onFeedbackValueChange =
|
|
159
|
+
onFeedbackValueChange = v => {
|
|
167
160
|
const { data, onChange } = this.props;
|
|
168
161
|
|
|
169
162
|
if (data.feedback.type !== 'custom') {
|
|
@@ -175,10 +168,9 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
175
168
|
if (onChange) onChange({ ...data, feedback: fb });
|
|
176
169
|
};
|
|
177
170
|
|
|
178
|
-
onFeedbackTypeChange =
|
|
171
|
+
onFeedbackTypeChange = t => {
|
|
179
172
|
const { data, onChange } = this.props;
|
|
180
173
|
const fb = { ...data.feedback, type: t };
|
|
181
|
-
|
|
182
174
|
if (fb.type !== 'custom') {
|
|
183
175
|
fb.value = undefined;
|
|
184
176
|
}
|
|
@@ -198,7 +190,6 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
198
190
|
noLabels,
|
|
199
191
|
useLetterOrdering,
|
|
200
192
|
imageSupport,
|
|
201
|
-
disableImageAlignmentButtons,
|
|
202
193
|
disabled,
|
|
203
194
|
spellCheck,
|
|
204
195
|
nonEmpty,
|
|
@@ -206,13 +197,11 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
206
197
|
allowDelete,
|
|
207
198
|
toolbarOpts,
|
|
208
199
|
error,
|
|
209
|
-
noCorrectAnswerError
|
|
210
|
-
uploadSoundSupport,
|
|
200
|
+
noCorrectAnswerError
|
|
211
201
|
} = this.props;
|
|
212
202
|
|
|
213
203
|
const InputToggle = mode === 'checkbox' ? InputCheckbox : InputRadio;
|
|
214
204
|
const names = classNames(classes.choiceConfiguration, className);
|
|
215
|
-
|
|
216
205
|
return (
|
|
217
206
|
<div className={names}>
|
|
218
207
|
<div className={classes.topRow}>
|
|
@@ -221,7 +210,6 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
221
210
|
{useLetterOrdering ? String.fromCharCode(96 + index).toUpperCase() : index}
|
|
222
211
|
</span>
|
|
223
212
|
)}
|
|
224
|
-
|
|
225
213
|
<InputToggle
|
|
226
214
|
className={classes.toggle}
|
|
227
215
|
onChange={this.onCheckedChange}
|
|
@@ -229,20 +217,17 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
229
217
|
checked={!!data.correct}
|
|
230
218
|
error={noCorrectAnswerError}
|
|
231
219
|
/>
|
|
232
|
-
|
|
233
220
|
<div className={classes.middleColumn}>
|
|
234
221
|
<EditableHtmlContainer
|
|
235
222
|
label={!noLabels ? 'Label' : ''}
|
|
236
223
|
value={data.label}
|
|
237
224
|
onChange={this.onLabelChange}
|
|
238
225
|
imageSupport={imageSupport}
|
|
239
|
-
disableImageAlignmentButtons={disableImageAlignmentButtons}
|
|
240
226
|
disabled={disabled}
|
|
241
227
|
spellCheck={spellCheck}
|
|
242
228
|
nonEmpty={nonEmpty}
|
|
243
229
|
toolbarOpts={toolbarOpts}
|
|
244
230
|
error={error}
|
|
245
|
-
uploadSoundSupport={uploadSoundSupport}
|
|
246
231
|
/>
|
|
247
232
|
{error && <div className={classes.errorText}>{error}</div>}
|
|
248
233
|
|
|
@@ -256,19 +241,17 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
256
241
|
/>
|
|
257
242
|
)}
|
|
258
243
|
</div>
|
|
259
|
-
|
|
260
244
|
{allowFeedBack && (
|
|
261
245
|
<InputContainer className={classes.feedback} label={!noLabels ? 'Feedback' : ''}>
|
|
262
246
|
<FeedbackMenu
|
|
263
247
|
onChange={this.onFeedbackTypeChange}
|
|
264
248
|
value={data.feedback}
|
|
265
249
|
classes={{
|
|
266
|
-
icon: classes.feedbackIcon
|
|
250
|
+
icon: classes.feedbackIcon
|
|
267
251
|
}}
|
|
268
252
|
/>
|
|
269
253
|
</InputContainer>
|
|
270
254
|
)}
|
|
271
|
-
|
|
272
255
|
{allowDelete && (
|
|
273
256
|
<InputContainer className={classes.delete} label={!noLabels ? 'Delete' : ''}>
|
|
274
257
|
<IconButton aria-label="delete" className={classes.deleteIcon} onClick={onDelete}>
|
|
@@ -282,55 +265,55 @@ export class ChoiceConfiguration extends React.Component {
|
|
|
282
265
|
}
|
|
283
266
|
}
|
|
284
267
|
|
|
285
|
-
const styles =
|
|
268
|
+
const styles = theme => ({
|
|
286
269
|
index: {
|
|
287
|
-
padding: '24px
|
|
270
|
+
padding: '24px 10px 0 0'
|
|
288
271
|
},
|
|
289
272
|
choiceConfiguration: {},
|
|
290
273
|
topRow: {
|
|
291
|
-
display: 'flex'
|
|
274
|
+
display: 'flex'
|
|
292
275
|
},
|
|
293
276
|
value: {
|
|
294
277
|
flex: '0.5',
|
|
295
|
-
paddingRight: theme.spacing.unit
|
|
278
|
+
paddingRight: theme.spacing.unit
|
|
296
279
|
},
|
|
297
280
|
editorHolder: {
|
|
298
|
-
marginTop: theme.spacing.unit * 2
|
|
281
|
+
marginTop: theme.spacing.unit * 2
|
|
299
282
|
},
|
|
300
283
|
toggle: {
|
|
301
|
-
flex: '0 1 auto'
|
|
284
|
+
flex: '0 1 auto'
|
|
302
285
|
},
|
|
303
286
|
feedback: {
|
|
304
287
|
flex: '0 1 auto',
|
|
305
288
|
paddingTop: theme.spacing.unit,
|
|
306
289
|
paddingLeft: 0,
|
|
307
290
|
marginLeft: 0,
|
|
308
|
-
paddingRight: theme.spacing.unit * 3
|
|
291
|
+
paddingRight: theme.spacing.unit * 3
|
|
309
292
|
},
|
|
310
293
|
feedbackIcon: {
|
|
311
294
|
margin: 0,
|
|
312
295
|
paddingLeft: 0,
|
|
313
|
-
width: 'inherit'
|
|
296
|
+
width: 'inherit'
|
|
314
297
|
},
|
|
315
298
|
deleteIcon: {
|
|
316
299
|
margin: 0,
|
|
317
|
-
width: 'inherit'
|
|
300
|
+
width: 'inherit'
|
|
318
301
|
},
|
|
319
302
|
delete: {
|
|
320
303
|
flex: '0 1 auto',
|
|
321
304
|
paddingTop: theme.spacing.unit,
|
|
322
305
|
paddingLeft: 0,
|
|
323
|
-
marginLeft: 0
|
|
306
|
+
marginLeft: 0
|
|
324
307
|
},
|
|
325
308
|
middleColumn: {
|
|
326
309
|
display: 'flex',
|
|
327
310
|
flex: 1,
|
|
328
|
-
flexDirection: 'column'
|
|
311
|
+
flexDirection: 'column'
|
|
329
312
|
},
|
|
330
313
|
errorText: {
|
|
331
|
-
fontSize:
|
|
332
|
-
color:
|
|
333
|
-
}
|
|
314
|
+
fontSize: '12px',
|
|
315
|
+
color: 'red'
|
|
316
|
+
}
|
|
334
317
|
});
|
|
335
318
|
|
|
336
319
|
export default withStyles(styles)(ChoiceConfiguration);
|
package/src/choice-utils.js
CHANGED
|
@@ -5,7 +5,7 @@ import includes from 'lodash/includes';
|
|
|
5
5
|
* @param {Object} model the model to normalize
|
|
6
6
|
* @return {Object} the updated model
|
|
7
7
|
*/
|
|
8
|
-
export const normalizeChoices =
|
|
8
|
+
export const normalizeChoices = model => {
|
|
9
9
|
const choices = model.choices.map((c, index) => {
|
|
10
10
|
if (!c.value) {
|
|
11
11
|
c.value = `${index}`;
|
|
@@ -8,51 +8,50 @@ import Group from './group';
|
|
|
8
8
|
const feedbackLabels = {
|
|
9
9
|
default: 'Simple Feedback',
|
|
10
10
|
none: 'No Feedback',
|
|
11
|
-
custom: 'Customized Feedback'
|
|
11
|
+
custom: 'Customized Feedback'
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const holder = (theme, extras) => ({
|
|
15
15
|
marginTop: '0px',
|
|
16
|
-
background:
|
|
17
|
-
padding: theme.spacing.unit,
|
|
16
|
+
background: '#e0dee0',
|
|
17
|
+
padding: theme.spacing.unit * 0.9,
|
|
18
18
|
marginBottom: theme.spacing.unit * 2,
|
|
19
|
-
|
|
20
|
-
...extras,
|
|
19
|
+
...extras
|
|
21
20
|
});
|
|
22
21
|
|
|
23
|
-
const style =
|
|
22
|
+
const style = theme => ({
|
|
24
23
|
feedbackSelector: {
|
|
25
|
-
marginBottom: theme.spacing.unit
|
|
24
|
+
marginBottom: theme.spacing.unit
|
|
26
25
|
},
|
|
27
26
|
label: {
|
|
28
|
-
cursor: 'pointer'
|
|
27
|
+
cursor: 'pointer'
|
|
29
28
|
},
|
|
30
29
|
inputContainerLabel: {
|
|
31
|
-
transform: 'translateY(-20%)'
|
|
30
|
+
transform: 'translateY(-20%)'
|
|
32
31
|
},
|
|
33
32
|
feedbackInputContainer: {
|
|
34
|
-
paddingBottom: 0
|
|
33
|
+
paddingBottom: 0
|
|
35
34
|
},
|
|
36
35
|
customHolder: holder(theme, {
|
|
37
|
-
background:
|
|
38
|
-
padding: 0
|
|
36
|
+
background: '#e0dee0',
|
|
37
|
+
padding: 0
|
|
39
38
|
}),
|
|
40
39
|
defaultHolder: holder(theme, {
|
|
41
40
|
fontFamily: theme.typography.fontFamily,
|
|
42
|
-
cursor: 'default'
|
|
41
|
+
cursor: 'default'
|
|
43
42
|
}),
|
|
44
43
|
editor: {
|
|
45
|
-
fontFamily: theme.typography.fontFamily
|
|
44
|
+
fontFamily: theme.typography.fontFamily
|
|
46
45
|
},
|
|
47
46
|
group: {
|
|
48
|
-
paddingTop: theme.spacing.unit
|
|
49
|
-
}
|
|
47
|
+
paddingTop: theme.spacing.unit
|
|
48
|
+
}
|
|
50
49
|
});
|
|
51
50
|
|
|
52
51
|
export const FeedbackType = {
|
|
53
52
|
type: PropTypes.oneOf(['default', 'custom', 'none']),
|
|
54
53
|
default: PropTypes.string,
|
|
55
|
-
custom: PropTypes.string
|
|
54
|
+
custom: PropTypes.string
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
export class FeedbackSelector extends React.Component {
|
|
@@ -62,18 +61,16 @@ export class FeedbackSelector extends React.Component {
|
|
|
62
61
|
label: PropTypes.string.isRequired,
|
|
63
62
|
feedback: PropTypes.shape(FeedbackType).isRequired,
|
|
64
63
|
onChange: PropTypes.func.isRequired,
|
|
65
|
-
toolbarOpts: PropTypes.object
|
|
64
|
+
toolbarOpts: PropTypes.object
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
changeType =
|
|
67
|
+
changeType = type => {
|
|
69
68
|
const { onChange, feedback } = this.props;
|
|
70
|
-
|
|
71
69
|
onChange({ ...feedback, type });
|
|
72
70
|
};
|
|
73
71
|
|
|
74
|
-
changeCustom =
|
|
72
|
+
changeCustom = custom => {
|
|
75
73
|
const { onChange, feedback } = this.props;
|
|
76
|
-
|
|
77
74
|
onChange({ ...feedback, type: 'custom', custom });
|
|
78
75
|
};
|
|
79
76
|
|
|
@@ -98,7 +95,6 @@ export class FeedbackSelector extends React.Component {
|
|
|
98
95
|
feedbackLabels={feedbackLabels}
|
|
99
96
|
/>
|
|
100
97
|
</InputContainer>
|
|
101
|
-
|
|
102
98
|
{feedback.type === 'custom' && (
|
|
103
99
|
<div className={classes.customHolder}>
|
|
104
100
|
<EditableHTML
|
|
@@ -106,12 +102,12 @@ export class FeedbackSelector extends React.Component {
|
|
|
106
102
|
onChange={this.changeCustom}
|
|
107
103
|
markup={feedback.custom || ''}
|
|
108
104
|
toolbarOpts={toolbarOpts}
|
|
109
|
-
languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}
|
|
110
105
|
/>
|
|
111
106
|
</div>
|
|
112
107
|
)}
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
{feedback.type === 'default' && (
|
|
109
|
+
<div className={classes.defaultHolder}> {feedback.default}</div>
|
|
110
|
+
)}
|
|
115
111
|
</div>
|
|
116
112
|
);
|
|
117
113
|
}
|
|
@@ -4,33 +4,35 @@ import React from 'react';
|
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
|
|
7
|
-
const styles = (
|
|
7
|
+
const styles = () => ({
|
|
8
8
|
radioLabel: {
|
|
9
|
-
fontSize:
|
|
9
|
+
fontSize: '12px'
|
|
10
10
|
},
|
|
11
11
|
choice: {
|
|
12
12
|
display: 'flex',
|
|
13
|
-
alignItems: 'center'
|
|
13
|
+
alignItems: 'center'
|
|
14
14
|
},
|
|
15
15
|
choiceHolder: {
|
|
16
16
|
display: 'flex',
|
|
17
|
-
alignItems: 'center'
|
|
18
|
-
}
|
|
17
|
+
alignItems: 'center'
|
|
18
|
+
}
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
const Group =
|
|
21
|
+
const Group = props => {
|
|
22
22
|
const { feedbackLabels, value, classes, className, onChange, keys } = props;
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<div className={classNames(classes.choiceHolder, className)}>
|
|
26
|
-
{keys.map(
|
|
26
|
+
{keys.map(key => {
|
|
27
27
|
return (
|
|
28
28
|
<div className={classes.choice} key={key}>
|
|
29
29
|
<RadioWithLabel
|
|
30
30
|
value={key}
|
|
31
31
|
checked={value === key}
|
|
32
|
-
classes={{
|
|
33
|
-
|
|
32
|
+
classes={{
|
|
33
|
+
label: classes.radioLabel
|
|
34
|
+
}}
|
|
35
|
+
onChange={e => onChange(e.currentTarget.value)}
|
|
34
36
|
label={feedbackLabels[key]}
|
|
35
37
|
/>
|
|
36
38
|
</div>
|
|
@@ -46,7 +48,7 @@ Group.propTypes = {
|
|
|
46
48
|
value: PropTypes.string.isRequired,
|
|
47
49
|
classes: PropTypes.object.isRequired,
|
|
48
50
|
keys: PropTypes.arrayOf(PropTypes.string),
|
|
49
|
-
onChange: PropTypes.func
|
|
51
|
+
onChange: PropTypes.func
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
export default withStyles(styles)(Group);
|
|
@@ -14,19 +14,19 @@ export { FeedbackSelector };
|
|
|
14
14
|
const style = {
|
|
15
15
|
feedbackContainer: {
|
|
16
16
|
display: 'flex',
|
|
17
|
-
flexDirection: 'column'
|
|
18
|
-
}
|
|
17
|
+
flexDirection: 'column'
|
|
18
|
+
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const buildDefaults =
|
|
21
|
+
export const buildDefaults = input => {
|
|
22
22
|
return merge(
|
|
23
23
|
{},
|
|
24
24
|
{
|
|
25
25
|
correct: { type: 'default', default: 'Correct' },
|
|
26
26
|
incorrect: { type: 'default', default: 'Incorrect' },
|
|
27
|
-
partial: { type: 'default', default: 'Nearly' }
|
|
27
|
+
partial: { type: 'default', default: 'Nearly' }
|
|
28
28
|
},
|
|
29
|
-
input
|
|
29
|
+
input
|
|
30
30
|
);
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -36,29 +36,26 @@ export class FeedbackConfig extends React.Component {
|
|
|
36
36
|
feedback: PropTypes.shape({
|
|
37
37
|
correct: PropTypes.shape(FeedbackType),
|
|
38
38
|
incorrect: PropTypes.shape(FeedbackType),
|
|
39
|
-
partial: PropTypes.shape(FeedbackType)
|
|
39
|
+
partial: PropTypes.shape(FeedbackType)
|
|
40
40
|
}),
|
|
41
41
|
onChange: PropTypes.func.isRequired,
|
|
42
42
|
classes: PropTypes.object.isRequired,
|
|
43
|
-
toolbarOpts: PropTypes.object
|
|
43
|
+
toolbarOpts: PropTypes.object
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
static defaultProps = {
|
|
47
47
|
allowPartial: true,
|
|
48
|
-
feedback: buildDefaults()
|
|
48
|
+
feedback: buildDefaults()
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
onChange(key, config) {
|
|
52
52
|
const { feedback, onChange } = this.props;
|
|
53
53
|
const update = { ...feedback, [key]: config };
|
|
54
|
-
|
|
55
54
|
onChange(update);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
onCorrectChange = this.onChange.bind(this, 'correct');
|
|
59
|
-
|
|
60
58
|
onIncorrectChange = this.onChange.bind(this, 'incorrect');
|
|
61
|
-
|
|
62
59
|
onPartialChange = this.onChange.bind(this, 'partial');
|
|
63
60
|
|
|
64
61
|
render() {
|
|
@@ -69,7 +66,6 @@ export class FeedbackConfig extends React.Component {
|
|
|
69
66
|
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
|
|
70
67
|
<Typography className={classes.heading}>Feedback</Typography>
|
|
71
68
|
</ExpansionPanelSummary>
|
|
72
|
-
|
|
73
69
|
<ExpansionPanelDetails>
|
|
74
70
|
<div className={classes.feedbackContainer}>
|
|
75
71
|
<FeedbackSelector
|
|
@@ -78,7 +74,6 @@ export class FeedbackConfig extends React.Component {
|
|
|
78
74
|
onChange={this.onCorrectChange}
|
|
79
75
|
toolbarOpts={toolbarOpts}
|
|
80
76
|
/>
|
|
81
|
-
|
|
82
77
|
{allowPartial && (
|
|
83
78
|
<FeedbackSelector
|
|
84
79
|
label="If partially correct, show"
|
|
@@ -87,7 +82,6 @@ export class FeedbackConfig extends React.Component {
|
|
|
87
82
|
toolbarOpts={toolbarOpts}
|
|
88
83
|
/>
|
|
89
84
|
)}
|
|
90
|
-
|
|
91
85
|
<FeedbackSelector
|
|
92
86
|
label="If incorrect, show"
|
|
93
87
|
feedback={feedback.incorrect}
|
package/src/form-section.jsx
CHANGED
|
@@ -3,14 +3,14 @@ import Typography from '@material-ui/core/Typography';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { withStyles } from '@material-ui/core/styles';
|
|
5
5
|
|
|
6
|
-
const styles =
|
|
6
|
+
const styles = theme => ({
|
|
7
7
|
formSection: {
|
|
8
8
|
marginTop: theme.spacing.unit * 2,
|
|
9
|
-
marginBottom: theme.spacing.unit * 2
|
|
9
|
+
marginBottom: theme.spacing.unit * 2
|
|
10
10
|
},
|
|
11
11
|
label: {
|
|
12
|
-
marginBottom: theme.spacing.unit
|
|
13
|
-
}
|
|
12
|
+
marginBottom: theme.spacing.unit
|
|
13
|
+
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export default withStyles(styles)(({ className, classes, label, children, labelExtraStyle }) => (
|
package/src/help.jsx
CHANGED
|
@@ -14,26 +14,25 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
14
14
|
const RawHelpButton = ({ onClick, classes }) => (
|
|
15
15
|
<IconButton
|
|
16
16
|
classes={{
|
|
17
|
-
label: classes.icon
|
|
17
|
+
label: classes.icon
|
|
18
18
|
}}
|
|
19
19
|
onClick={onClick}
|
|
20
20
|
>
|
|
21
21
|
<HelpIcon />
|
|
22
22
|
</IconButton>
|
|
23
23
|
);
|
|
24
|
-
|
|
25
24
|
RawHelpButton.propTypes = {
|
|
26
25
|
onClick: PropTypes.func,
|
|
27
|
-
classes: PropTypes.object.isRequired
|
|
26
|
+
classes: PropTypes.object.isRequired
|
|
28
27
|
};
|
|
29
28
|
|
|
30
|
-
export const HelpButton = withStyles(
|
|
29
|
+
export const HelpButton = withStyles({
|
|
31
30
|
icon: {
|
|
32
31
|
'&:hover': {
|
|
33
|
-
color:
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
})
|
|
32
|
+
color: '#ddd'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})(RawHelpButton);
|
|
37
36
|
|
|
38
37
|
export const HelpDialog = ({ open, onClose, children, title }) => (
|
|
39
38
|
<Dialog open={open} onRequestClose={onClose}>
|
|
@@ -53,30 +52,32 @@ HelpDialog.propTypes = {
|
|
|
53
52
|
open: PropTypes.bool,
|
|
54
53
|
onClose: PropTypes.func,
|
|
55
54
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
56
|
-
title: PropTypes.string.isRequired
|
|
55
|
+
title: PropTypes.string.isRequired
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
class Help extends React.Component {
|
|
60
59
|
static propTypes = {
|
|
61
60
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
62
|
-
title: PropTypes.string
|
|
61
|
+
title: PropTypes.string
|
|
63
62
|
};
|
|
64
63
|
|
|
65
64
|
constructor(props) {
|
|
66
65
|
super(props);
|
|
67
66
|
this.state = {
|
|
68
|
-
open: false
|
|
67
|
+
open: false
|
|
69
68
|
};
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
render() {
|
|
73
72
|
const { children, title } = this.props;
|
|
74
|
-
|
|
75
73
|
return (
|
|
76
74
|
<div>
|
|
77
75
|
<HelpButton color="accent" onClick={() => this.setState({ open: true })} />
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
<HelpDialog
|
|
77
|
+
open={this.state.open}
|
|
78
|
+
title={title}
|
|
79
|
+
onClose={() => this.setState({ open: false })}
|
|
80
|
+
>
|
|
80
81
|
{children}
|
|
81
82
|
</HelpDialog>
|
|
82
83
|
</div>
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import AlertDialog from './alert-dialog';
|
|
2
|
-
import FeedbackConfig, {
|
|
2
|
+
import FeedbackConfig, {
|
|
3
|
+
FeedbackSelector,
|
|
4
|
+
buildDefaults as feedbackConfigDefaults
|
|
5
|
+
} from './feedback-config';
|
|
3
6
|
import { InputCheckbox, InputSwitch, InputRadio } from './inputs';
|
|
4
7
|
import Langs, { LanguageControls } from './langs';
|
|
5
8
|
import Tabs from './tabs';
|
|
@@ -51,5 +54,5 @@ export {
|
|
|
51
54
|
withStatefulModel,
|
|
52
55
|
Toggle,
|
|
53
56
|
DisplaySize,
|
|
54
|
-
settings
|
|
57
|
+
settings
|
|
55
58
|
};
|