@pie-element/inline-dropdown 4.7.1-beta.1 → 4.7.1-beta.4

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.
@@ -0,0 +1,636 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.Main = void 0;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _react = _interopRequireDefault(require("react"));
17
+ var _reactDom = _interopRequireDefault(require("react-dom"));
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+ var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
20
+ var _configUi = require("@pie-lib/config-ui");
21
+ var _mathRendering = require("@pie-lib/math-rendering");
22
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
23
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
24
+ var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
25
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
26
+ var _reduce = _interopRequireDefault(require("lodash/reduce"));
27
+ var _max = _interopRequireDefault(require("lodash/max"));
28
+ var _styles = require("@material-ui/core/styles");
29
+ var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
30
+ var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
31
+ var _ExpansionPanel = _interopRequireDefault(require("@material-ui/core/ExpansionPanel"));
32
+ var _ExpansionPanelSummary = _interopRequireDefault(require("@material-ui/core/ExpansionPanelSummary"));
33
+ var _ExpansionPanelDetails = _interopRequireDefault(require("@material-ui/core/ExpansionPanelDetails"));
34
+ var _ExpandMore = _interopRequireDefault(require("@material-ui/icons/ExpandMore"));
35
+ var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
36
+ var _inlineDropdownToolbar = _interopRequireDefault(require("./inline-dropdown-toolbar"));
37
+ var _utils = require("./utils");
38
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
42
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
43
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
44
+ var toggle = _configUi.settings.toggle,
45
+ Panel = _configUi.settings.Panel;
46
+ var styles = function styles(theme) {
47
+ return {
48
+ promptHolder: {
49
+ width: '100%',
50
+ paddingBottom: theme.spacing.unit * 2,
51
+ marginBottom: theme.spacing.unit * 2
52
+ },
53
+ prompt: {
54
+ paddingTop: theme.spacing.unit * 2,
55
+ width: '100%'
56
+ },
57
+ markup: {
58
+ minHeight: '100px',
59
+ paddingTop: theme.spacing.unit * 2,
60
+ width: '100%',
61
+ '& [data-slate-editor="true"]': {
62
+ minHeight: '100px'
63
+ }
64
+ },
65
+ design: {
66
+ paddingTop: theme.spacing.unit * 3
67
+ },
68
+ choiceConfiguration: {
69
+ paddingTop: theme.spacing.unit * 2,
70
+ paddingBottom: theme.spacing.unit * 2
71
+ },
72
+ switchElement: {
73
+ justifyContent: 'space-between',
74
+ margin: 0
75
+ },
76
+ addButton: {
77
+ "float": 'right'
78
+ },
79
+ text: {
80
+ fontFamily: 'Cerebri Sans',
81
+ fontSize: theme.typography.fontSize + 2,
82
+ lineHeight: '19px',
83
+ color: '#495B8F',
84
+ marginRight: theme.spacing.unit
85
+ },
86
+ rationaleLabel: {
87
+ display: 'flex',
88
+ whiteSpace: 'break-spaces'
89
+ },
90
+ rationaleChoices: {
91
+ marginTop: theme.spacing.unit * 2
92
+ },
93
+ panelDetails: {
94
+ display: 'block'
95
+ },
96
+ flexContainer: {
97
+ display: 'flex',
98
+ alignItems: 'center',
99
+ marginBottom: theme.spacing.unit
100
+ },
101
+ tooltip: {
102
+ fontSize: theme.typography.fontSize - 2,
103
+ whiteSpace: 'pre',
104
+ maxWidth: '500px'
105
+ },
106
+ errorText: {
107
+ fontSize: theme.typography.fontSize - 2,
108
+ color: 'red',
109
+ paddingTop: theme.spacing.unit
110
+ }
111
+ };
112
+ };
113
+ var createElementFromHTML = function createElementFromHTML(htmlString) {
114
+ var div = document.createElement('div');
115
+ div.innerHTML = (htmlString || '').trim();
116
+ return div;
117
+ };
118
+ var prepareVal = function prepareVal(html) {
119
+ var tmp = document.createElement('DIV');
120
+ tmp.innerHTML = html;
121
+ var value = tmp.textContent || tmp.innerText || '';
122
+ return value.trim();
123
+ };
124
+ var Main = /*#__PURE__*/function (_React$Component) {
125
+ (0, _inherits2["default"])(Main, _React$Component);
126
+ var _super = _createSuper(Main);
127
+ function Main() {
128
+ var _this;
129
+ (0, _classCallCheck2["default"])(this, Main);
130
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
131
+ args[_key] = arguments[_key];
132
+ }
133
+ _this = _super.call.apply(_super, [this].concat(args));
134
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
135
+ warning: {
136
+ open: false
137
+ }
138
+ });
139
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChange", function (newVal) {
140
+ _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), newVal));
141
+ });
142
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
143
+ _this.onModelChange({
144
+ prompt: prompt
145
+ });
146
+ });
147
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
148
+ _this.onModelChange({
149
+ rationale: rationale
150
+ });
151
+ });
152
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceRationaleChanged", function (index, choice) {
153
+ var model = _this.props.model;
154
+ var indexOfChoice = model.choices && model.choices[index] && model.choices[index].findIndex(function (elem) {
155
+ return elem.label === choice.label && elem.value === choice.value;
156
+ });
157
+ model.choices[index] && model.choices[index].splice(indexOfChoice, 1, choice);
158
+ _this.onModelChange(model);
159
+ });
160
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
161
+ _this.onModelChange({
162
+ teacherInstructions: teacherInstructions
163
+ });
164
+ });
165
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMarkupChanged", function (slateMarkup) {
166
+ _this.onModelChange({
167
+ slateMarkup: slateMarkup
168
+ });
169
+ });
170
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCheck", function (callback) {
171
+ _this.setState({
172
+ warning: {
173
+ open: true,
174
+ text: 'Response areas with under 2 options or with no correct answers will be discarded.',
175
+ onClose: function onClose() {
176
+ _this.setState({
177
+ warning: {
178
+ open: false
179
+ }
180
+ });
181
+ },
182
+ onConfirm: function onConfirm() {
183
+ _this.setState({
184
+ warning: {
185
+ open: false
186
+ }
187
+ }, callback);
188
+ }
189
+ }
190
+ });
191
+ });
192
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
193
+ var respAreaChoices = _this.state.respAreaChoices;
194
+ var domMarkup = createElementFromHTML(markup);
195
+ var allRespAreas = domMarkup.querySelectorAll('[data-type="inline_dropdown"]');
196
+ var allChoices = {};
197
+ allRespAreas.forEach(function (el) {
198
+ allChoices[el.dataset.index] = el.dataset.value || '';
199
+ });
200
+ var existingRespAreaChoices = (0, _reduce["default"])(respAreaChoices, function (obj, choices, key) {
201
+ if (!(0, _isUndefined["default"])(allChoices[key])) {
202
+ obj[key] = respAreaChoices[key];
203
+ }
204
+ return obj;
205
+ }, {});
206
+ var newRespAreaChoices = {};
207
+ var shouldWarn = false;
208
+ allRespAreas.forEach(function (el, index) {
209
+ var newChoices = existingRespAreaChoices[el.dataset.index] || [];
210
+ if (newChoices.length < 2 || !newChoices.find(function (c) {
211
+ return c.correct;
212
+ })) {
213
+ el.remove();
214
+ shouldWarn = true;
215
+ } else {
216
+ newRespAreaChoices[index] = existingRespAreaChoices[el.dataset.index] || [];
217
+ el.dataset.index = index;
218
+ }
219
+ });
220
+ if (shouldWarn) {
221
+ _this.setState({
222
+ warning: {
223
+ open: true,
224
+ text: 'Response areas with under 2 options or with no correct answers will be discarded.',
225
+ onClose: function onClose() {
226
+ _this.setState({
227
+ warning: {
228
+ open: false
229
+ }
230
+ });
231
+ },
232
+ onConfirm: function onConfirm() {
233
+ _this.setState({
234
+ warning: {
235
+ open: false
236
+ }
237
+ }, function () {
238
+ return _this.onModelChange({
239
+ choices: (0, _cloneDeep["default"])(newRespAreaChoices),
240
+ slateMarkup: domMarkup.innerHTML
241
+ });
242
+ });
243
+ }
244
+ }
245
+ });
246
+ } else {
247
+ _this.onModelChange({
248
+ choices: (0, _cloneDeep["default"])(newRespAreaChoices),
249
+ slateMarkup: domMarkup.innerHTML
250
+ });
251
+ }
252
+ });
253
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function (index, label) {
254
+ var respAreaChoices = _this.state.respAreaChoices;
255
+ var maxResponseAreaChoices = _this.props.configuration.maxResponseAreaChoices;
256
+ if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {
257
+ _this.setState({
258
+ warning: {
259
+ open: true,
260
+ text: "There are only ".concat(maxResponseAreaChoices, " answers allowed per choice."),
261
+ onClose: undefined,
262
+ onConfirm: function onConfirm() {
263
+ _this.setState({
264
+ warning: {
265
+ open: false
266
+ }
267
+ });
268
+ }
269
+ }
270
+ });
271
+ return;
272
+ }
273
+ if (!respAreaChoices[index]) {
274
+ respAreaChoices[index] = [];
275
+ }
276
+ if ((respAreaChoices[index] || []).find(function (r) {
277
+ return prepareVal(r.label) === prepareVal(label);
278
+ })) {
279
+ _this.setState({
280
+ warning: {
281
+ open: true,
282
+ text: 'Duplicate answers are not allowed.',
283
+ onClose: undefined,
284
+ onConfirm: function onConfirm() {
285
+ _this.setState({
286
+ warning: {
287
+ open: false
288
+ }
289
+ });
290
+ }
291
+ }
292
+ });
293
+ return;
294
+ }
295
+ var value = respAreaChoices[index] && (0, _max["default"])(respAreaChoices[index].map(function (c) {
296
+ return parseInt(c.value);
297
+ }).filter(function (val) {
298
+ return !isNaN(val);
299
+ })) || 0;
300
+ respAreaChoices[index].push({
301
+ label: label,
302
+ value: "".concat(value + 1),
303
+ correct: false
304
+ });
305
+ _this.onModelChange({
306
+ choices: (0, _cloneDeep["default"])(respAreaChoices)
307
+ });
308
+ });
309
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveChoice", function (respIndex, index) {
310
+ var respAreaChoices = _this.state.respAreaChoices;
311
+ respAreaChoices[respIndex].splice(index, 1);
312
+ _this.onModelChange({
313
+ choices: (0, _cloneDeep["default"])(respAreaChoices)
314
+ });
315
+ });
316
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSelectChoice", function (respIndex, selectedIndex) {
317
+ var respAreaChoices = _this.state.respAreaChoices;
318
+ respAreaChoices[respIndex] = respAreaChoices[respIndex].map(function (choice, index) {
319
+ return _objectSpread(_objectSpread({}, choice), {}, {
320
+ correct: index === selectedIndex
321
+ });
322
+ });
323
+ _this.onModelChange({
324
+ choices: (0, _cloneDeep["default"])(respAreaChoices)
325
+ });
326
+ });
327
+ return _this;
328
+ }
329
+ (0, _createClass2["default"])(Main, [{
330
+ key: "componentDidMount",
331
+ value: function componentDidMount() {
332
+ var choices = this.props.model.choices;
333
+ this.setState({
334
+ respAreaChoices: (0, _cloneDeep["default"])(choices)
335
+ });
336
+ }
337
+ }, {
338
+ key: "UNSAFE_componentWillReceiveProps",
339
+ value: function UNSAFE_componentWillReceiveProps(nProps) {
340
+ var newState = {};
341
+ if (!(0, _isEqual["default"])(nProps.model.choices, this.props.model.choices) || !(0, _isEqual["default"])(nProps.model.choices, this.state.respAreaChoices)) {
342
+ newState.respAreaChoices = (0, _cloneDeep["default"])(nProps.model.choices);
343
+ }
344
+ if (!(0, _isEmpty["default"])(newState)) {
345
+ this.setState(newState);
346
+ }
347
+ }
348
+ }, {
349
+ key: "componentDidUpdate",
350
+ value: function componentDidUpdate() {
351
+ //eslint-disable-next-line
352
+ var domNode = _reactDom["default"].findDOMNode(this);
353
+ (0, _mathRendering.renderMath)(domNode);
354
+ }
355
+ }, {
356
+ key: "render",
357
+ value: function render() {
358
+ var _this2 = this;
359
+ var warning = this.state.warning;
360
+ var _this$props = this.props,
361
+ classes = _this$props.classes,
362
+ model = _this$props.model,
363
+ configuration = _this$props.configuration,
364
+ onConfigurationChanged = _this$props.onConfigurationChanged,
365
+ imageSupport = _this$props.imageSupport,
366
+ uploadSoundSupport = _this$props.uploadSoundSupport;
367
+ var _ref = configuration || {},
368
+ _ref$choiceRationale = _ref.choiceRationale,
369
+ choiceRationale = _ref$choiceRationale === void 0 ? {} : _ref$choiceRationale,
370
+ _ref$lockChoiceOrder = _ref.lockChoiceOrder,
371
+ lockChoiceOrder = _ref$lockChoiceOrder === void 0 ? {} : _ref$lockChoiceOrder,
372
+ maxResponseAreas = _ref.maxResponseAreas,
373
+ _ref$maxImageWidth = _ref.maxImageWidth,
374
+ maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
375
+ _ref$maxImageHeight = _ref.maxImageHeight,
376
+ maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
377
+ _ref$partialScoring = _ref.partialScoring,
378
+ partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
379
+ _ref$prompt = _ref.prompt,
380
+ prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
381
+ _ref$rationale = _ref.rationale,
382
+ rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
383
+ settingsPanelDisabled = _ref.settingsPanelDisabled,
384
+ _ref$spellCheck = _ref.spellCheck,
385
+ spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
386
+ _ref$teacherInstructi = _ref.teacherInstructions,
387
+ teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
388
+ _ref$withRubric = _ref.withRubric,
389
+ withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric;
390
+ var _ref2 = model || {},
391
+ choiceRationaleEnabled = _ref2.choiceRationaleEnabled,
392
+ choices = _ref2.choices,
393
+ errors = _ref2.errors,
394
+ promptEnabled = _ref2.promptEnabled,
395
+ rationaleEnabled = _ref2.rationaleEnabled,
396
+ spellCheckEnabled = _ref2.spellCheckEnabled,
397
+ teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
398
+ toolbarEditorPosition = _ref2.toolbarEditorPosition;
399
+ var _ref3 = errors || {},
400
+ responseAreasError = _ref3.responseAreasError,
401
+ responseAreaChoicesError = _ref3.responseAreaChoicesError;
402
+ var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
403
+ var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
404
+ var renderChoiceRationale = function renderChoiceRationale() {
405
+ return (Object.keys(choices) || []).map(function (key, index) {
406
+ return /*#__PURE__*/_react["default"].createElement("div", {
407
+ key: key,
408
+ className: classes.rationaleChoices
409
+ }, /*#__PURE__*/_react["default"].createElement(_ExpansionPanel["default"], null, /*#__PURE__*/_react["default"].createElement(_ExpansionPanelSummary["default"], {
410
+ expandIcon: /*#__PURE__*/_react["default"].createElement(_ExpandMore["default"], null)
411
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
412
+ className: classes.text
413
+ }, "Rationale for response area #".concat(index + 1))), /*#__PURE__*/_react["default"].createElement(_ExpansionPanelDetails["default"], {
414
+ className: classes.panelDetails
415
+ }, (choices[key] || []).map(function (choice) {
416
+ return /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
417
+ key: choice.label,
418
+ label: /*#__PURE__*/_react["default"].createElement("span", {
419
+ className: classes.rationaleLabel,
420
+ dangerouslySetInnerHTML: {
421
+ __html: "".concat(rationale.label, " for ").concat(choice.label, " (").concat(choice.correct ? 'correct' : 'incorrect', ")")
422
+ }
423
+ }),
424
+ className: classes.promptHolder
425
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
426
+ className: classes.prompt,
427
+ markup: choice.rationale || '',
428
+ spellCheck: spellCheckEnabled,
429
+ onChange: function onChange(c) {
430
+ return _this2.onChoiceRationaleChanged(key, _objectSpread(_objectSpread({}, choice), {}, {
431
+ rationale: c
432
+ }));
433
+ },
434
+ imageSupport: imageSupport,
435
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
436
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
437
+ uploadSoundSupport: uploadSoundSupport
438
+ }));
439
+ }))));
440
+ });
441
+ };
442
+ var toolbarOpts = {
443
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
444
+ };
445
+ var validationMessage = (0, _utils.generateValidationMessage)(configuration);
446
+ var panelSettings = {
447
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
448
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label)
449
+ };
450
+ var panelProperties = {
451
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
452
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
453
+ choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),
454
+ promptEnabled: prompt.settings && toggle(prompt.label),
455
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
456
+ rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
457
+ };
458
+ return /*#__PURE__*/_react["default"].createElement("div", {
459
+ className: classes.design
460
+ }, /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
461
+ hideSettings: settingsPanelDisabled,
462
+ settings: /*#__PURE__*/_react["default"].createElement(Panel, {
463
+ model: model,
464
+ configuration: configuration,
465
+ onChangeModel: function onChangeModel(model) {
466
+ return _this2.onModelChange(model);
467
+ },
468
+ onChangeConfiguration: function onChangeConfiguration(configuration) {
469
+ return onConfigurationChanged(configuration, true);
470
+ },
471
+ groups: {
472
+ Settings: panelSettings,
473
+ Properties: panelProperties
474
+ }
475
+ })
476
+ }, /*#__PURE__*/_react["default"].createElement("div", null, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
477
+ label: teacherInstructions.label,
478
+ className: classes.promptHolder
479
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
480
+ className: classes.prompt,
481
+ markup: model.teacherInstructions || '',
482
+ onChange: this.onTeacherInstructionsChanged,
483
+ imageSupport: imageSupport,
484
+ nonEmpty: false,
485
+ toolbarOpts: toolbarOpts,
486
+ spellCheck: spellCheckEnabled,
487
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
488
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
489
+ uploadSoundSupport: uploadSoundSupport,
490
+ languageCharactersProps: [{
491
+ language: 'spanish'
492
+ }, {
493
+ language: 'special'
494
+ }]
495
+ })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
496
+ label: prompt.label,
497
+ className: classes.promptHolder
498
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
499
+ className: classes.prompt,
500
+ markup: model.prompt,
501
+ onChange: this.onPromptChanged,
502
+ imageSupport: imageSupport,
503
+ nonEmpty: false,
504
+ disableUnderline: true,
505
+ toolbarOpts: toolbarOpts,
506
+ spellCheck: spellCheckEnabled,
507
+ maxImageWidth: defaultImageMaxWidth,
508
+ maxImageHeight: defaultImageMaxHeight,
509
+ uploadSoundSupport: uploadSoundSupport,
510
+ languageCharactersProps: [{
511
+ language: 'spanish'
512
+ }, {
513
+ language: 'special'
514
+ }]
515
+ })), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
516
+ label: rationale.label,
517
+ className: classes.promptHolder
518
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
519
+ className: classes.prompt,
520
+ markup: model.rationale || '',
521
+ onChange: this.onRationaleChanged,
522
+ imageSupport: imageSupport,
523
+ toolbarOpts: toolbarOpts,
524
+ spellCheck: spellCheckEnabled,
525
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
526
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
527
+ uploadSoundSupport: uploadSoundSupport,
528
+ languageCharactersProps: [{
529
+ language: 'spanish'
530
+ }, {
531
+ language: 'special'
532
+ }]
533
+ })), /*#__PURE__*/_react["default"].createElement("div", {
534
+ className: classes.flexContainer
535
+ }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
536
+ className: classes.text
537
+ }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
538
+ classes: {
539
+ tooltip: classes.tooltip
540
+ },
541
+ disableFocusListener: true,
542
+ disableTouchListener: true,
543
+ placement: 'right',
544
+ title: validationMessage
545
+ }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
546
+ fontSize: 'small',
547
+ color: 'primary'
548
+ }))), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
549
+ activePlugins: _editableHtml.ALL_PLUGINS,
550
+ toolbarOpts: {
551
+ position: 'top'
552
+ },
553
+ ref: function ref(_ref4) {
554
+ window.editorRef = _ref4;
555
+ },
556
+ responseAreaProps: {
557
+ type: 'inline-dropdown',
558
+ options: {
559
+ duplicates: true
560
+ },
561
+ maxResponseAreas: maxResponseAreas,
562
+ respAreaToolbar: function respAreaToolbar(node, nodePath, editor, onToolbarDone) {
563
+ var respAreaChoices = _this2.state.respAreaChoices;
564
+ return function () {
565
+ return /*#__PURE__*/_react["default"].createElement(_inlineDropdownToolbar["default"], {
566
+ onAddChoice: _this2.onAddChoice,
567
+ onCheck: _this2.onCheck,
568
+ onRemoveChoice: function onRemoveChoice(index) {
569
+ return _this2.onRemoveChoice(node.data.index, index);
570
+ },
571
+ onSelectChoice: function onSelectChoice(index) {
572
+ return _this2.onSelectChoice(node.data.index, index);
573
+ },
574
+ editor: editor,
575
+ node: node,
576
+ nodePath: nodePath,
577
+ onToolbarDone: onToolbarDone,
578
+ choices: respAreaChoices[node.data.index],
579
+ spellCheck: spellCheckEnabled,
580
+ uploadSoundSupport: uploadSoundSupport
581
+ });
582
+ };
583
+ }
584
+ },
585
+ spellCheck: spellCheckEnabled,
586
+ className: classes.markup,
587
+ markup: model.slateMarkup || '',
588
+ onChange: this.onChange,
589
+ imageSupport: imageSupport,
590
+ disableImageAlignmentButtons: true,
591
+ onBlur: this.onBlur,
592
+ disabled: false,
593
+ highlightShape: false,
594
+ error: responseAreasError,
595
+ uploadSoundSupport: uploadSoundSupport,
596
+ languageCharactersProps: [{
597
+ language: 'spanish'
598
+ }, {
599
+ language: 'special'
600
+ }]
601
+ }), responseAreasError && /*#__PURE__*/_react["default"].createElement("div", {
602
+ className: classes.errorText
603
+ }, responseAreasError), responseAreaChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
604
+ className: classes.errorText
605
+ }, responseAreaChoicesError), /*#__PURE__*/_react["default"].createElement("br", null), choiceRationaleEnabled && renderChoiceRationale(), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
606
+ open: warning.open,
607
+ title: "Warning",
608
+ text: warning.text,
609
+ onClose: warning.onClose,
610
+ onConfirm: warning.onConfirm
611
+ }))));
612
+ }
613
+ }]);
614
+ return Main;
615
+ }(_react["default"].Component);
616
+ exports.Main = Main;
617
+ (0, _defineProperty2["default"])(Main, "propTypes", {
618
+ configuration: _propTypes["default"].object.isRequired,
619
+ model: _propTypes["default"].object.isRequired,
620
+ disableSidePanel: _propTypes["default"].bool,
621
+ onModelChanged: _propTypes["default"].func.isRequired,
622
+ onConfigurationChanged: _propTypes["default"].func.isRequired,
623
+ classes: _propTypes["default"].object.isRequired,
624
+ imageSupport: _propTypes["default"].shape({
625
+ add: _propTypes["default"].func.isRequired,
626
+ "delete": _propTypes["default"].func.isRequired
627
+ }),
628
+ uploadSoundSupport: _propTypes["default"].shape({
629
+ add: _propTypes["default"].func.isRequired,
630
+ "delete": _propTypes["default"].func.isRequired
631
+ })
632
+ });
633
+ var Styled = (0, _styles.withStyles)(styles)(Main);
634
+ var _default = Styled;
635
+ exports["default"] = _default;
636
+ //# sourceMappingURL=main.js.map