@pie-element/likert 2.0.1-next.0 → 2.0.2-esm.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/configure/package.json +4 -4
- package/controller/package.json +1 -1
- package/esm/configure.js +890 -0
- package/esm/configure.js.map +1 -0
- package/esm/controller.js +96 -0
- package/esm/controller.js.map +1 -0
- package/esm/element.js +322 -0
- package/esm/element.js.map +1 -0
- package/package.json +22 -5
package/esm/configure.js
ADDED
|
@@ -0,0 +1,890 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import debug from 'debug';
|
|
4
|
+
import { ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import EditableHtml from '@pie-lib/editable-html';
|
|
7
|
+
import Radio from '@material-ui/core/Radio';
|
|
8
|
+
import RadioGroup from '@material-ui/core/RadioGroup';
|
|
9
|
+
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
10
|
+
import { layout, InputContainer, NumberTextField, settings } from '@pie-lib/config-ui';
|
|
11
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
12
|
+
import merge from 'lodash/merge';
|
|
13
|
+
import { color } from '@pie-lib/render-ui';
|
|
14
|
+
import defaults from 'lodash/defaults';
|
|
15
|
+
|
|
16
|
+
function _extends() {
|
|
17
|
+
_extends = Object.assign || function (target) {
|
|
18
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
19
|
+
var source = arguments[i];
|
|
20
|
+
|
|
21
|
+
for (var key in source) {
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
23
|
+
target[key] = source[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return target;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return _extends.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const LIKERT_SCALE = {
|
|
35
|
+
likert3: 'likert3',
|
|
36
|
+
likert5: 'likert5',
|
|
37
|
+
likert7: 'likert7'
|
|
38
|
+
};
|
|
39
|
+
const LIKERT_TYPE = {
|
|
40
|
+
agreement: 'agreement',
|
|
41
|
+
frequency: 'frequency',
|
|
42
|
+
yesNo: 'yesNo',
|
|
43
|
+
importance: 'importance',
|
|
44
|
+
likelihood: 'likelihood',
|
|
45
|
+
like: 'like'
|
|
46
|
+
};
|
|
47
|
+
const LIKERT_ORIENTATION = {
|
|
48
|
+
horizontal: 'horizontal',
|
|
49
|
+
vertical: 'vertical'
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const likert3Agreement = [{
|
|
53
|
+
label: 'Disagree',
|
|
54
|
+
value: -1
|
|
55
|
+
}, {
|
|
56
|
+
label: 'Unsure',
|
|
57
|
+
value: 0
|
|
58
|
+
}, {
|
|
59
|
+
label: 'Agree',
|
|
60
|
+
value: 1
|
|
61
|
+
}];
|
|
62
|
+
const likert5Agreement = [{
|
|
63
|
+
label: 'Strongly Disagree',
|
|
64
|
+
value: -2
|
|
65
|
+
}, ...likert3Agreement, {
|
|
66
|
+
label: 'Strongly Agree',
|
|
67
|
+
value: 2
|
|
68
|
+
}];
|
|
69
|
+
const likert7Agreement = [{
|
|
70
|
+
label: 'Extremely Disagree',
|
|
71
|
+
value: -3
|
|
72
|
+
}, ...likert5Agreement, {
|
|
73
|
+
label: 'Extremely Agree',
|
|
74
|
+
value: 3
|
|
75
|
+
}];
|
|
76
|
+
const likert3Frequency = [{
|
|
77
|
+
label: 'Infrequently',
|
|
78
|
+
value: -1
|
|
79
|
+
}, {
|
|
80
|
+
label: 'Unsure',
|
|
81
|
+
value: 0
|
|
82
|
+
}, {
|
|
83
|
+
label: 'Frequently',
|
|
84
|
+
value: 1
|
|
85
|
+
}];
|
|
86
|
+
const likert5Frequency = [{
|
|
87
|
+
label: 'Very Infrequently',
|
|
88
|
+
value: -2
|
|
89
|
+
}, ...likert3Frequency, {
|
|
90
|
+
label: 'Very Frequently',
|
|
91
|
+
value: 2
|
|
92
|
+
}];
|
|
93
|
+
const likert7Frequency = [{
|
|
94
|
+
label: 'Never',
|
|
95
|
+
value: -3
|
|
96
|
+
}, ...likert5Frequency, {
|
|
97
|
+
label: 'Always',
|
|
98
|
+
value: 3
|
|
99
|
+
}];
|
|
100
|
+
const likert3YesNo = [{
|
|
101
|
+
label: 'No',
|
|
102
|
+
value: -1
|
|
103
|
+
}, {
|
|
104
|
+
label: 'Unsure',
|
|
105
|
+
value: 0
|
|
106
|
+
}, {
|
|
107
|
+
label: 'Yes',
|
|
108
|
+
value: 1
|
|
109
|
+
}];
|
|
110
|
+
const likert5YesNo = [{
|
|
111
|
+
label: 'No',
|
|
112
|
+
value: -2
|
|
113
|
+
}, {
|
|
114
|
+
label: 'Not really',
|
|
115
|
+
value: -1
|
|
116
|
+
}, {
|
|
117
|
+
label: 'Unsure',
|
|
118
|
+
value: 0
|
|
119
|
+
}, {
|
|
120
|
+
label: 'Sometimes',
|
|
121
|
+
value: 1
|
|
122
|
+
}, {
|
|
123
|
+
label: 'Yes',
|
|
124
|
+
value: 2
|
|
125
|
+
}];
|
|
126
|
+
const likert7YesNo = [{
|
|
127
|
+
label: 'No',
|
|
128
|
+
value: -3
|
|
129
|
+
}, {
|
|
130
|
+
label: 'Rarely',
|
|
131
|
+
value: -2
|
|
132
|
+
}, {
|
|
133
|
+
label: 'Not really',
|
|
134
|
+
value: -1
|
|
135
|
+
}, {
|
|
136
|
+
label: 'Unsure',
|
|
137
|
+
value: 0
|
|
138
|
+
}, {
|
|
139
|
+
label: 'Sometimes',
|
|
140
|
+
value: 1
|
|
141
|
+
}, {
|
|
142
|
+
label: 'Very Often',
|
|
143
|
+
value: 2
|
|
144
|
+
}, {
|
|
145
|
+
label: 'Always',
|
|
146
|
+
value: 3
|
|
147
|
+
}];
|
|
148
|
+
const likert3Likelihood = [{
|
|
149
|
+
label: 'Not Likely',
|
|
150
|
+
value: -1
|
|
151
|
+
}, {
|
|
152
|
+
label: 'Unsure',
|
|
153
|
+
value: 0
|
|
154
|
+
}, {
|
|
155
|
+
label: 'Likely',
|
|
156
|
+
value: 1
|
|
157
|
+
}];
|
|
158
|
+
const likert5Likelihood = [{
|
|
159
|
+
label: 'Very Unlikely',
|
|
160
|
+
value: -2
|
|
161
|
+
}, ...likert3Likelihood, {
|
|
162
|
+
label: 'Very Likely',
|
|
163
|
+
value: 2
|
|
164
|
+
}];
|
|
165
|
+
const likert7Likelihood = [{
|
|
166
|
+
label: 'Extremely Unlikely',
|
|
167
|
+
value: -3
|
|
168
|
+
}, ...likert5Likelihood, {
|
|
169
|
+
label: 'Extremely Likely',
|
|
170
|
+
value: 3
|
|
171
|
+
}];
|
|
172
|
+
const likert3Importance = [{
|
|
173
|
+
label: 'Not Important',
|
|
174
|
+
value: -1
|
|
175
|
+
}, {
|
|
176
|
+
label: 'Unsure',
|
|
177
|
+
value: 0
|
|
178
|
+
}, {
|
|
179
|
+
label: 'Important',
|
|
180
|
+
value: 1
|
|
181
|
+
}];
|
|
182
|
+
const likert5Importance = [{
|
|
183
|
+
label: 'Very Not Important',
|
|
184
|
+
value: -2
|
|
185
|
+
}, ...likert3Importance, {
|
|
186
|
+
label: 'Very Important',
|
|
187
|
+
value: 2
|
|
188
|
+
}];
|
|
189
|
+
const likert7Importance = [{
|
|
190
|
+
label: 'Extremely Not Important',
|
|
191
|
+
value: -3
|
|
192
|
+
}, ...likert5Importance, {
|
|
193
|
+
label: 'Extremely Important',
|
|
194
|
+
value: 3
|
|
195
|
+
}];
|
|
196
|
+
const likert3Like = [{
|
|
197
|
+
label: 'Dislike',
|
|
198
|
+
value: -1
|
|
199
|
+
}, {
|
|
200
|
+
label: 'Unsure',
|
|
201
|
+
value: 0
|
|
202
|
+
}, {
|
|
203
|
+
label: 'Like',
|
|
204
|
+
value: 1
|
|
205
|
+
}];
|
|
206
|
+
const likert5Like = [{
|
|
207
|
+
label: 'Really Dislike',
|
|
208
|
+
value: -2
|
|
209
|
+
}, ...likert3Like, {
|
|
210
|
+
label: 'Really Like',
|
|
211
|
+
value: 2
|
|
212
|
+
}];
|
|
213
|
+
const likert7Like = [{
|
|
214
|
+
label: 'Extremely Dislike',
|
|
215
|
+
value: -3
|
|
216
|
+
}, ...likert5Like, {
|
|
217
|
+
label: 'Extremely Like',
|
|
218
|
+
value: 3
|
|
219
|
+
}];
|
|
220
|
+
|
|
221
|
+
const generateChoices = (likertScale, likertType) => {
|
|
222
|
+
switch (`${likertScale}-${likertType}`) {
|
|
223
|
+
case `${LIKERT_SCALE.likert3}-${LIKERT_TYPE.agreement}`:
|
|
224
|
+
return [...likert3Agreement];
|
|
225
|
+
|
|
226
|
+
case `${LIKERT_SCALE.likert5}-${LIKERT_TYPE.agreement}`:
|
|
227
|
+
return [...likert5Agreement];
|
|
228
|
+
|
|
229
|
+
case `${LIKERT_SCALE.likert7}-${LIKERT_TYPE.agreement}`:
|
|
230
|
+
return [...likert7Agreement];
|
|
231
|
+
|
|
232
|
+
case `${LIKERT_SCALE.likert3}-${LIKERT_TYPE.frequency}`:
|
|
233
|
+
return [...likert3Frequency];
|
|
234
|
+
|
|
235
|
+
case `${LIKERT_SCALE.likert5}-${LIKERT_TYPE.frequency}`:
|
|
236
|
+
return [...likert5Frequency];
|
|
237
|
+
|
|
238
|
+
case `${LIKERT_SCALE.likert7}-${LIKERT_TYPE.frequency}`:
|
|
239
|
+
return [...likert7Frequency];
|
|
240
|
+
|
|
241
|
+
case `${LIKERT_SCALE.likert3}-${LIKERT_TYPE.yesNo}`:
|
|
242
|
+
return [...likert3YesNo];
|
|
243
|
+
|
|
244
|
+
case `${LIKERT_SCALE.likert5}-${LIKERT_TYPE.yesNo}`:
|
|
245
|
+
return [...likert5YesNo];
|
|
246
|
+
|
|
247
|
+
case `${LIKERT_SCALE.likert7}-${LIKERT_TYPE.yesNo}`:
|
|
248
|
+
return [...likert7YesNo];
|
|
249
|
+
|
|
250
|
+
case `${LIKERT_SCALE.likert3}-${LIKERT_TYPE.likelihood}`:
|
|
251
|
+
return [...likert3Likelihood];
|
|
252
|
+
|
|
253
|
+
case `${LIKERT_SCALE.likert5}-${LIKERT_TYPE.likelihood}`:
|
|
254
|
+
return [...likert5Likelihood];
|
|
255
|
+
|
|
256
|
+
case `${LIKERT_SCALE.likert7}-${LIKERT_TYPE.likelihood}`:
|
|
257
|
+
return [...likert7Likelihood];
|
|
258
|
+
|
|
259
|
+
case `${LIKERT_SCALE.likert3}-${LIKERT_TYPE.importance}`:
|
|
260
|
+
return [...likert3Importance];
|
|
261
|
+
|
|
262
|
+
case `${LIKERT_SCALE.likert5}-${LIKERT_TYPE.importance}`:
|
|
263
|
+
return [...likert5Importance];
|
|
264
|
+
|
|
265
|
+
case `${LIKERT_SCALE.likert7}-${LIKERT_TYPE.importance}`:
|
|
266
|
+
return [...likert7Importance];
|
|
267
|
+
|
|
268
|
+
case `${LIKERT_SCALE.likert3}-${LIKERT_TYPE.like}`:
|
|
269
|
+
return [...likert3Like];
|
|
270
|
+
|
|
271
|
+
case `${LIKERT_SCALE.likert5}-${LIKERT_TYPE.like}`:
|
|
272
|
+
return [...likert5Like];
|
|
273
|
+
|
|
274
|
+
case `${LIKERT_SCALE.likert7}-${LIKERT_TYPE.like}`:
|
|
275
|
+
return [...likert7Like];
|
|
276
|
+
|
|
277
|
+
default:
|
|
278
|
+
return [];
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const {
|
|
283
|
+
Panel,
|
|
284
|
+
toggle,
|
|
285
|
+
radio
|
|
286
|
+
} = settings;
|
|
287
|
+
|
|
288
|
+
const styles = theme => ({
|
|
289
|
+
promptHolder: {
|
|
290
|
+
width: '100%',
|
|
291
|
+
paddingTop: theme.spacing.unit * 2,
|
|
292
|
+
marginBottom: theme.spacing.unit * 2
|
|
293
|
+
},
|
|
294
|
+
radioButtonsWrapper: {
|
|
295
|
+
display: 'flex',
|
|
296
|
+
flexDirection: 'column'
|
|
297
|
+
},
|
|
298
|
+
radioButtonsColumnHeader: {
|
|
299
|
+
color: theme.palette.grey[400],
|
|
300
|
+
fontSize: theme.typography.fontSize - 2
|
|
301
|
+
},
|
|
302
|
+
likertLabelHolder: {
|
|
303
|
+
display: 'flex',
|
|
304
|
+
width: '100%',
|
|
305
|
+
alignItems: 'flex-start',
|
|
306
|
+
marginBottom: theme.spacing.unit * 2
|
|
307
|
+
},
|
|
308
|
+
likertOptionsHolder: {
|
|
309
|
+
display: 'flex',
|
|
310
|
+
width: '100%',
|
|
311
|
+
justifyContent: 'space-around',
|
|
312
|
+
marginBottom: theme.spacing.unit * 2.5
|
|
313
|
+
},
|
|
314
|
+
likertLabelInput: {
|
|
315
|
+
width: 'calc(100% - 200px)',
|
|
316
|
+
marginRight: 0
|
|
317
|
+
},
|
|
318
|
+
errorMessage: {
|
|
319
|
+
color: theme.palette.error.main,
|
|
320
|
+
fontSize: theme.typography.fontSize - 2
|
|
321
|
+
},
|
|
322
|
+
width100: {
|
|
323
|
+
width: '100%'
|
|
324
|
+
},
|
|
325
|
+
flexRow: {
|
|
326
|
+
display: 'flex',
|
|
327
|
+
flexDirection: 'row'
|
|
328
|
+
},
|
|
329
|
+
likertValueHolder: {
|
|
330
|
+
paddingLeft: theme.spacing.unit * 2.5,
|
|
331
|
+
width: '150px'
|
|
332
|
+
},
|
|
333
|
+
likertLabelEditableHtml: {
|
|
334
|
+
paddingTop: theme.spacing.unit * 2
|
|
335
|
+
},
|
|
336
|
+
inputFormGroupIndex: {
|
|
337
|
+
width: '30px',
|
|
338
|
+
paddingTop: theme.spacing.unit * 4
|
|
339
|
+
},
|
|
340
|
+
errorText: {
|
|
341
|
+
fontSize: theme.typography.fontSize - 2,
|
|
342
|
+
color: theme.palette.error.main,
|
|
343
|
+
paddingTop: theme.spacing.unit
|
|
344
|
+
},
|
|
345
|
+
customColor: {
|
|
346
|
+
color: `${color.tertiary()} !important`
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
const LikertOrientation = withStyles(styles)(props => {
|
|
351
|
+
const {
|
|
352
|
+
classes,
|
|
353
|
+
model,
|
|
354
|
+
onChangeModel
|
|
355
|
+
} = props;
|
|
356
|
+
|
|
357
|
+
const onChangeLikertOrientation = e => {
|
|
358
|
+
const likertOrientation = e.target.value;
|
|
359
|
+
onChangeModel(_extends({}, model, {
|
|
360
|
+
likertOrientation
|
|
361
|
+
}));
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
365
|
+
className: classes.radioButtonsWrapper
|
|
366
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
367
|
+
className: classes.radioButtonsColumnHeader
|
|
368
|
+
}, "Likert Orientation"), /*#__PURE__*/React.createElement(RadioGroup, {
|
|
369
|
+
"aria-label": "likertOrientation",
|
|
370
|
+
name: "likertOrientation",
|
|
371
|
+
value: model.likertOrientation,
|
|
372
|
+
onChange: onChangeLikertOrientation
|
|
373
|
+
}, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
374
|
+
value: LIKERT_ORIENTATION.horizontal,
|
|
375
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
376
|
+
className: classes.customColor
|
|
377
|
+
}),
|
|
378
|
+
label: "Horizontal"
|
|
379
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
380
|
+
value: LIKERT_ORIENTATION.vertical,
|
|
381
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
382
|
+
className: classes.customColor
|
|
383
|
+
}),
|
|
384
|
+
label: "Vertical"
|
|
385
|
+
})));
|
|
386
|
+
});
|
|
387
|
+
const LikertScale = withStyles(styles)(props => {
|
|
388
|
+
const {
|
|
389
|
+
classes,
|
|
390
|
+
model,
|
|
391
|
+
onChangeModel
|
|
392
|
+
} = props;
|
|
393
|
+
|
|
394
|
+
const onChangeLikertScale = e => {
|
|
395
|
+
const likertScale = e.target.value;
|
|
396
|
+
onChangeModel(_extends({}, model, {
|
|
397
|
+
likertScale,
|
|
398
|
+
choices: generateChoices(likertScale, model.likertType)
|
|
399
|
+
}));
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
403
|
+
className: classes.radioButtonsWrapper
|
|
404
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
405
|
+
className: classes.radioButtonsColumnHeader
|
|
406
|
+
}, "Likert Scale"), /*#__PURE__*/React.createElement(RadioGroup, {
|
|
407
|
+
"aria-label": "likertScale",
|
|
408
|
+
name: "likertScale",
|
|
409
|
+
value: model.likertScale,
|
|
410
|
+
onChange: onChangeLikertScale
|
|
411
|
+
}, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
412
|
+
value: LIKERT_SCALE.likert3,
|
|
413
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
414
|
+
className: classes.customColor
|
|
415
|
+
}),
|
|
416
|
+
label: "Likert 3"
|
|
417
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
418
|
+
value: LIKERT_SCALE.likert5,
|
|
419
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
420
|
+
className: classes.customColor
|
|
421
|
+
}),
|
|
422
|
+
label: "Likert 5"
|
|
423
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
424
|
+
value: LIKERT_SCALE.likert7,
|
|
425
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
426
|
+
className: classes.customColor
|
|
427
|
+
}),
|
|
428
|
+
label: "Likert 7"
|
|
429
|
+
})));
|
|
430
|
+
});
|
|
431
|
+
const LikertType = withStyles(styles)(props => {
|
|
432
|
+
const {
|
|
433
|
+
classes,
|
|
434
|
+
model,
|
|
435
|
+
onChangeModel
|
|
436
|
+
} = props;
|
|
437
|
+
|
|
438
|
+
const onChangeLikertType = e => {
|
|
439
|
+
const likertType = e.target.value;
|
|
440
|
+
onChangeModel(_extends({}, model, {
|
|
441
|
+
likertType,
|
|
442
|
+
choices: generateChoices(model.likertScale, likertType)
|
|
443
|
+
}));
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
447
|
+
className: classes.radioButtonsWrapper
|
|
448
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
449
|
+
className: classes.radioButtonsColumnHeader
|
|
450
|
+
}, "Label Type"), /*#__PURE__*/React.createElement("div", {
|
|
451
|
+
className: classes.flexRow
|
|
452
|
+
}, /*#__PURE__*/React.createElement(RadioGroup, {
|
|
453
|
+
"aria-label": "likertLabelType",
|
|
454
|
+
name: "likertLabelType",
|
|
455
|
+
value: model.likertType,
|
|
456
|
+
onChange: onChangeLikertType
|
|
457
|
+
}, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
458
|
+
value: LIKERT_TYPE.agreement,
|
|
459
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
460
|
+
className: classes.customColor
|
|
461
|
+
}),
|
|
462
|
+
label: "Agreement"
|
|
463
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
464
|
+
value: LIKERT_TYPE.frequency,
|
|
465
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
466
|
+
className: classes.customColor
|
|
467
|
+
}),
|
|
468
|
+
label: "Frequency"
|
|
469
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
470
|
+
value: LIKERT_TYPE.yesNo,
|
|
471
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
472
|
+
className: classes.customColor
|
|
473
|
+
}),
|
|
474
|
+
label: "Yes/No"
|
|
475
|
+
})), /*#__PURE__*/React.createElement(RadioGroup, {
|
|
476
|
+
"aria-label": "likertLabelType",
|
|
477
|
+
name: "likertLabelType",
|
|
478
|
+
value: model.likertType,
|
|
479
|
+
onChange: onChangeLikertType
|
|
480
|
+
}, /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
481
|
+
value: LIKERT_TYPE.importance,
|
|
482
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
483
|
+
className: classes.customColor
|
|
484
|
+
}),
|
|
485
|
+
label: "Importance"
|
|
486
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
487
|
+
value: LIKERT_TYPE.likelihood,
|
|
488
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
489
|
+
className: classes.customColor
|
|
490
|
+
}),
|
|
491
|
+
label: "Likelihood"
|
|
492
|
+
}), /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
493
|
+
value: LIKERT_TYPE.like,
|
|
494
|
+
control: /*#__PURE__*/React.createElement(Radio, {
|
|
495
|
+
className: classes.customColor
|
|
496
|
+
}),
|
|
497
|
+
label: "Like"
|
|
498
|
+
}))));
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const buildValuesMap = model => model.choices.reduce((acc, choice) => {
|
|
502
|
+
const accClone = _extends({}, acc);
|
|
503
|
+
|
|
504
|
+
const choiceValue = parseInt(choice.value);
|
|
505
|
+
|
|
506
|
+
if (!accClone[choiceValue]) {
|
|
507
|
+
accClone[choiceValue] = 0;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return _extends({}, accClone, {
|
|
511
|
+
[choiceValue]: accClone[choiceValue] + 1
|
|
512
|
+
});
|
|
513
|
+
}, {});
|
|
514
|
+
|
|
515
|
+
const Design = withStyles(styles)(props => {
|
|
516
|
+
const {
|
|
517
|
+
classes,
|
|
518
|
+
configuration,
|
|
519
|
+
imageSupport,
|
|
520
|
+
model,
|
|
521
|
+
onChangeModel,
|
|
522
|
+
onChoiceChanged,
|
|
523
|
+
onConfigurationChanged,
|
|
524
|
+
onPromptChanged,
|
|
525
|
+
onTeacherInstructionsChanged,
|
|
526
|
+
uploadSoundSupport
|
|
527
|
+
} = props;
|
|
528
|
+
const {
|
|
529
|
+
contentDimensions = {},
|
|
530
|
+
prompt = {},
|
|
531
|
+
scoringType = {},
|
|
532
|
+
settingsPanelDisabled,
|
|
533
|
+
spellCheck = {},
|
|
534
|
+
teacherInstructions = {},
|
|
535
|
+
baseInputConfiguration = {},
|
|
536
|
+
likertChoice = {}
|
|
537
|
+
} = configuration || {};
|
|
538
|
+
const {
|
|
539
|
+
errors = {},
|
|
540
|
+
extraCSSRules,
|
|
541
|
+
spellCheckEnabled,
|
|
542
|
+
teacherInstructionsEnabled
|
|
543
|
+
} = model || {};
|
|
544
|
+
const {
|
|
545
|
+
prompt: promptError,
|
|
546
|
+
teacherInstructions: teacherInstructionsError
|
|
547
|
+
} = errors;
|
|
548
|
+
const valuesMap = buildValuesMap(model);
|
|
549
|
+
const panelProperties = {
|
|
550
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
551
|
+
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
552
|
+
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric'])
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
const getPluginProps = (props = {}) => {
|
|
556
|
+
return Object.assign(_extends({}, baseInputConfiguration), props || {});
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
return /*#__PURE__*/React.createElement(layout.ConfigLayout, {
|
|
560
|
+
extraCSSRules: extraCSSRules,
|
|
561
|
+
dimensions: contentDimensions,
|
|
562
|
+
hideSettings: settingsPanelDisabled,
|
|
563
|
+
settings: /*#__PURE__*/React.createElement(Panel, {
|
|
564
|
+
model: model,
|
|
565
|
+
onChangeModel: onChangeModel,
|
|
566
|
+
configuration: configuration,
|
|
567
|
+
onChangeConfiguration: onConfigurationChanged,
|
|
568
|
+
groups: {
|
|
569
|
+
Properties: panelProperties
|
|
570
|
+
}
|
|
571
|
+
})
|
|
572
|
+
}, teacherInstructionsEnabled && /*#__PURE__*/React.createElement(InputContainer, {
|
|
573
|
+
label: teacherInstructions.label,
|
|
574
|
+
className: classes.promptHolder
|
|
575
|
+
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
576
|
+
className: classes.prompt,
|
|
577
|
+
markup: model.teacherInstructions || '',
|
|
578
|
+
onChange: onTeacherInstructionsChanged,
|
|
579
|
+
imageSupport: imageSupport,
|
|
580
|
+
nonEmpty: false,
|
|
581
|
+
error: teacherInstructionsError,
|
|
582
|
+
spellCheck: spellCheckEnabled,
|
|
583
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
584
|
+
pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration)
|
|
585
|
+
}), teacherInstructionsError && /*#__PURE__*/React.createElement("div", {
|
|
586
|
+
className: classes.errorText
|
|
587
|
+
}, teacherInstructionsError)), /*#__PURE__*/React.createElement(InputContainer, {
|
|
588
|
+
label: prompt.label,
|
|
589
|
+
className: classes.promptHolder
|
|
590
|
+
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
591
|
+
className: classes.prompt,
|
|
592
|
+
markup: model.prompt,
|
|
593
|
+
onChange: onPromptChanged,
|
|
594
|
+
imageSupport: imageSupport,
|
|
595
|
+
nonEmpty: false,
|
|
596
|
+
error: promptError,
|
|
597
|
+
spellCheck: spellCheckEnabled,
|
|
598
|
+
disableUnderline: true,
|
|
599
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
600
|
+
pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration)
|
|
601
|
+
}), promptError && /*#__PURE__*/React.createElement("div", {
|
|
602
|
+
className: classes.errorText
|
|
603
|
+
}, promptError)), /*#__PURE__*/React.createElement("div", {
|
|
604
|
+
className: classes.likertOptionsHolder
|
|
605
|
+
}, /*#__PURE__*/React.createElement(LikertScale, {
|
|
606
|
+
model: model,
|
|
607
|
+
onChangeModel: onChangeModel
|
|
608
|
+
}), /*#__PURE__*/React.createElement(LikertType, {
|
|
609
|
+
model: model,
|
|
610
|
+
onChangeModel: onChangeModel
|
|
611
|
+
}), /*#__PURE__*/React.createElement(LikertOrientation, {
|
|
612
|
+
model: model,
|
|
613
|
+
onChangeModel: onChangeModel
|
|
614
|
+
})), model.choices.map((choice, index) => /*#__PURE__*/React.createElement("div", {
|
|
615
|
+
key: `choice-${index}`,
|
|
616
|
+
className: classes.likertLabelHolder
|
|
617
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
618
|
+
className: classes.inputFormGroupIndex
|
|
619
|
+
}, index + 1, "."), /*#__PURE__*/React.createElement(InputContainer, {
|
|
620
|
+
key: `likert-label-${index}`,
|
|
621
|
+
label: 'Likert Label',
|
|
622
|
+
className: classes.likertLabelInput
|
|
623
|
+
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
624
|
+
className: classes.likertLabelEditableHtml,
|
|
625
|
+
markup: choice.label || '',
|
|
626
|
+
onChange: c => onChoiceChanged(index, _extends({}, choice, {
|
|
627
|
+
label: c
|
|
628
|
+
})),
|
|
629
|
+
imageSupport: imageSupport,
|
|
630
|
+
spellCheck: spellCheckEnabled,
|
|
631
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
632
|
+
pluginProps: getPluginProps(likertChoice == null ? void 0 : likertChoice.inputConfiguration)
|
|
633
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
634
|
+
className: classes.likertValueHolder
|
|
635
|
+
}, /*#__PURE__*/React.createElement(NumberTextField, {
|
|
636
|
+
label: 'Likert Value',
|
|
637
|
+
value: choice.value,
|
|
638
|
+
className: classes.width100,
|
|
639
|
+
max: 100,
|
|
640
|
+
min: -100,
|
|
641
|
+
onChange: (e, t) => {
|
|
642
|
+
onChoiceChanged(index, _extends({}, choice, {
|
|
643
|
+
value: t
|
|
644
|
+
}));
|
|
645
|
+
},
|
|
646
|
+
imageSupport: imageSupport
|
|
647
|
+
}), valuesMap[choice.value] && valuesMap[choice.value] > 1 && /*#__PURE__*/React.createElement("p", {
|
|
648
|
+
className: classes.errorMessage
|
|
649
|
+
}, "Value should be unique")))));
|
|
650
|
+
});
|
|
651
|
+
class Main extends React.Component {
|
|
652
|
+
constructor(...args) {
|
|
653
|
+
super(...args);
|
|
654
|
+
|
|
655
|
+
this.onChoiceChanged = (index, choice) => {
|
|
656
|
+
const {
|
|
657
|
+
model,
|
|
658
|
+
onModelChanged
|
|
659
|
+
} = this.props;
|
|
660
|
+
model.choices = model.choices.map(choice => merge({}, choice));
|
|
661
|
+
model.choices.splice(index, 1, choice);
|
|
662
|
+
onModelChanged(model);
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
this.onPromptChanged = prompt => {
|
|
666
|
+
this.props.onModelChanged(_extends({}, this.props.model, {
|
|
667
|
+
prompt
|
|
668
|
+
}));
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
this.onTeacherInstructionsChanged = teacherInstructions => {
|
|
672
|
+
this.props.onModelChanged(_extends({}, this.props.model, {
|
|
673
|
+
teacherInstructions
|
|
674
|
+
}));
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
render() {
|
|
679
|
+
return /*#__PURE__*/React.createElement(Design, _extends({}, this.props, {
|
|
680
|
+
onChangeModel: this.props.onModelChanged,
|
|
681
|
+
onChoiceChanged: this.onChoiceChanged,
|
|
682
|
+
onPromptChanged: this.onPromptChanged,
|
|
683
|
+
onTeacherInstructionsChanged: this.onTeacherInstructionsChanged
|
|
684
|
+
}));
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
}
|
|
688
|
+
Main.propTypes = {
|
|
689
|
+
model: PropTypes.object.isRequired,
|
|
690
|
+
disableSidePanel: PropTypes.bool,
|
|
691
|
+
onModelChanged: PropTypes.func.isRequired,
|
|
692
|
+
onConfigurationChanged: PropTypes.func.isRequired,
|
|
693
|
+
classes: PropTypes.object.isRequired,
|
|
694
|
+
imageSupport: PropTypes.shape({
|
|
695
|
+
add: PropTypes.func.isRequired,
|
|
696
|
+
delete: PropTypes.func.isRequired
|
|
697
|
+
})
|
|
698
|
+
};
|
|
699
|
+
const Styled = withStyles(styles)(Main);
|
|
700
|
+
|
|
701
|
+
/** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
|
|
702
|
+
* functionalities are not defined yet - the value for those can belong to
|
|
703
|
+
* model or to configure
|
|
704
|
+
*/
|
|
705
|
+
var sensibleDefaults = {
|
|
706
|
+
model: {
|
|
707
|
+
choices: [],
|
|
708
|
+
likertOrientation: 'horizontal',
|
|
709
|
+
likertScale: 'likert3',
|
|
710
|
+
likertType: 'agreement',
|
|
711
|
+
prompt: '',
|
|
712
|
+
promptEnabled: true,
|
|
713
|
+
teacherInstructions: '',
|
|
714
|
+
teacherInstructionsEnabled: true
|
|
715
|
+
},
|
|
716
|
+
configuration: {
|
|
717
|
+
baseInputConfiguration: {
|
|
718
|
+
audio: {
|
|
719
|
+
disabled: false
|
|
720
|
+
},
|
|
721
|
+
video: {
|
|
722
|
+
disabled: false
|
|
723
|
+
},
|
|
724
|
+
image: {
|
|
725
|
+
disabled: false
|
|
726
|
+
},
|
|
727
|
+
textAlign: {
|
|
728
|
+
disabled: true
|
|
729
|
+
},
|
|
730
|
+
showParagraphs: {
|
|
731
|
+
disabled: false
|
|
732
|
+
},
|
|
733
|
+
separateParagraphs: {
|
|
734
|
+
disabled: true
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
prompt: {
|
|
738
|
+
settings: true,
|
|
739
|
+
label: 'Prompt',
|
|
740
|
+
inputConfiguration: {
|
|
741
|
+
audio: {
|
|
742
|
+
disabled: false
|
|
743
|
+
},
|
|
744
|
+
video: {
|
|
745
|
+
disabled: false
|
|
746
|
+
},
|
|
747
|
+
image: {
|
|
748
|
+
disabled: false
|
|
749
|
+
}
|
|
750
|
+
},
|
|
751
|
+
required: false
|
|
752
|
+
},
|
|
753
|
+
settingsPanelDisabled: false,
|
|
754
|
+
spellCheck: {
|
|
755
|
+
label: 'Spellcheck',
|
|
756
|
+
settings: false,
|
|
757
|
+
enabled: true
|
|
758
|
+
},
|
|
759
|
+
teacherInstructions: {
|
|
760
|
+
settings: true,
|
|
761
|
+
label: 'Teacher Instructions',
|
|
762
|
+
inputConfiguration: {
|
|
763
|
+
audio: {
|
|
764
|
+
disabled: false
|
|
765
|
+
},
|
|
766
|
+
video: {
|
|
767
|
+
disabled: false
|
|
768
|
+
},
|
|
769
|
+
image: {
|
|
770
|
+
disabled: false
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
required: false
|
|
774
|
+
},
|
|
775
|
+
likertChoice: {
|
|
776
|
+
label: 'Choice',
|
|
777
|
+
inputConfiguration: {
|
|
778
|
+
audio: {
|
|
779
|
+
disabled: false
|
|
780
|
+
},
|
|
781
|
+
video: {
|
|
782
|
+
disabled: false
|
|
783
|
+
},
|
|
784
|
+
image: {
|
|
785
|
+
disabled: false
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
const log = debug('likert:configure');
|
|
793
|
+
|
|
794
|
+
const prepareCustomizationObject = (config, model) => {
|
|
795
|
+
const configuration = defaults(config, sensibleDefaults.configuration);
|
|
796
|
+
return {
|
|
797
|
+
configuration,
|
|
798
|
+
model
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
class Likert extends HTMLElement {
|
|
803
|
+
constructor() {
|
|
804
|
+
super();
|
|
805
|
+
this._model = Likert.createDefaultModel();
|
|
806
|
+
this._configuration = sensibleDefaults.configuration;
|
|
807
|
+
this.onModelChanged = this.onModelChanged.bind(this);
|
|
808
|
+
this.onConfigurationChanged = this.onConfigurationChanged.bind(this);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
set model(s) {
|
|
812
|
+
this._model = Likert.createDefaultModel(s);
|
|
813
|
+
this._model = _extends({}, this._model, {
|
|
814
|
+
choices: this._model.choices.map(choice => _extends({}, choice, {
|
|
815
|
+
value: parseInt(choice.value)
|
|
816
|
+
}))
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
this._render();
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
set configuration(c) {
|
|
823
|
+
const info = prepareCustomizationObject(c, this._model);
|
|
824
|
+
this.onModelChanged(info.model);
|
|
825
|
+
this._configuration = info.configuration;
|
|
826
|
+
|
|
827
|
+
this._render();
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
set disableSidePanel(s) {
|
|
831
|
+
this._disableSidePanel = s;
|
|
832
|
+
|
|
833
|
+
this._render();
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
dispatchModelUpdated(reset) {
|
|
837
|
+
const resetValue = !!reset;
|
|
838
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
onModelChanged(m, reset) {
|
|
842
|
+
this._model = m;
|
|
843
|
+
|
|
844
|
+
this._render();
|
|
845
|
+
|
|
846
|
+
this.dispatchModelUpdated(reset);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
onConfigurationChanged(c) {
|
|
850
|
+
this._configuration = prepareCustomizationObject(c, this._model).configuration;
|
|
851
|
+
|
|
852
|
+
if (this._model) {
|
|
853
|
+
this.onModelChanged(this._model);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
this._render();
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
insertSound(handler) {
|
|
860
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
onDeleteSound(src, done) {
|
|
864
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
_render() {
|
|
868
|
+
log('_render');
|
|
869
|
+
let element = /*#__PURE__*/React.createElement(Styled, {
|
|
870
|
+
model: this._model,
|
|
871
|
+
configuration: this._configuration,
|
|
872
|
+
onModelChanged: this.onModelChanged,
|
|
873
|
+
onConfigurationChanged: this.onConfigurationChanged,
|
|
874
|
+
disableSidePanel: this._disableSidePanel,
|
|
875
|
+
uploadSoundSupport: {
|
|
876
|
+
add: this.insertSound.bind(this),
|
|
877
|
+
delete: this.onDeleteSound.bind(this)
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
ReactDOM.render(element, this);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
Likert.createDefaultModel = (model = {}) => _extends({}, sensibleDefaults.model, model, {
|
|
886
|
+
choices: model && model.choices || []
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
export { Likert as default };
|
|
890
|
+
//# sourceMappingURL=configure.js.map
|