@pie-element/inline-dropdown 8.3.4-next.3 → 9.0.0-beta.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.
@@ -1,226 +1,166 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
4
  Object.defineProperty(exports, "__esModule", {
8
5
  value: true
9
6
  });
10
- exports["default"] = exports.Main = void 0;
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
7
+ exports.default = exports.Main = void 0;
24
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
9
  var _react = _interopRequireDefault(require("react"));
27
-
28
10
  var _reactDom = _interopRequireDefault(require("react-dom"));
29
-
30
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
12
  var _editableHtml = _interopRequireWildcard(require("@pie-lib/editable-html"));
33
-
34
13
  var _configUi = require("@pie-lib/config-ui");
35
-
36
14
  var _mathRendering = require("@pie-lib/math-rendering");
37
-
38
15
  var _renderUi = require("@pie-lib/render-ui");
39
-
40
16
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
41
-
42
17
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
43
-
44
18
  var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
45
-
46
19
  var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
47
-
48
20
  var _reduce = _interopRequireDefault(require("lodash/reduce"));
49
-
50
21
  var _max = _interopRequireDefault(require("lodash/max"));
51
-
52
- var _styles = require("@material-ui/core/styles");
53
-
54
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
55
-
56
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
57
-
58
- var _ExpansionPanel = _interopRequireDefault(require("@material-ui/core/ExpansionPanel"));
59
-
60
- var _ExpansionPanelSummary = _interopRequireDefault(require("@material-ui/core/ExpansionPanelSummary"));
61
-
62
- var _ExpansionPanelDetails = _interopRequireDefault(require("@material-ui/core/ExpansionPanelDetails"));
63
-
64
- var _ExpandMore = _interopRequireDefault(require("@material-ui/icons/ExpandMore"));
65
-
66
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
67
-
22
+ var _styles = require("@mui/material/styles");
23
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
24
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
25
+ var _Accordion = _interopRequireDefault(require("@mui/material/Accordion"));
26
+ var _AccordionSummary = _interopRequireDefault(require("@mui/material/AccordionSummary"));
27
+ var _AccordionDetails = _interopRequireDefault(require("@mui/material/AccordionDetails"));
28
+ var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
29
+ var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
68
30
  var _inlineDropdownToolbar = _interopRequireDefault(require("./inline-dropdown-toolbar"));
69
-
70
31
  var _utils = require("./utils");
71
-
72
32
  var _responseArea = _interopRequireDefault(require("./response-area"));
73
-
74
- 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); }
75
-
76
- 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; }
77
-
78
- 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; }
79
-
80
- 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; }
81
-
82
- 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); }; }
83
-
84
- 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; } }
85
-
86
- var toggle = _configUi.settings.toggle,
87
- Panel = _configUi.settings.Panel,
88
- dropdown = _configUi.settings.dropdown;
89
-
90
- var styles = function styles(theme) {
91
- return {
92
- promptHolder: {
93
- width: '100%',
94
- paddingTop: theme.spacing.unit * 2,
95
- marginBottom: theme.spacing.unit * 2
96
- },
97
- choiceRationaleHolder: {
98
- width: '100%',
99
- paddingTop: theme.spacing.unit / 2,
100
- marginBottom: theme.spacing.unit * 2
101
- },
102
- markup: {
103
- minHeight: '100px',
104
- width: '100%',
105
- '& [data-slate-editor="true"]': {
106
- minHeight: '100px'
107
- }
108
- },
109
- choiceConfiguration: {
110
- paddingTop: theme.spacing.unit * 2,
111
- paddingBottom: theme.spacing.unit * 2
112
- },
113
- text: {
114
- fontSize: theme.typography.fontSize + 2,
115
- marginRight: theme.spacing.unit
116
- },
117
- rationaleLabel: {
118
- display: 'flex',
119
- alignItems: 'center',
120
- whiteSpace: 'break-spaces',
121
- color: _renderUi.color.disabled(),
122
- padding: 0,
123
- fontSize: theme.typography.fontSize - 2,
124
- lineHeight: 1
125
- },
126
- rationaleChoices: {
127
- marginBottom: theme.spacing.unit * 2.5
128
- },
129
- panelDetails: {
130
- display: 'block',
131
- paddingTop: 0,
132
- paddingBottom: 0
133
- },
134
- flexContainer: {
135
- display: 'flex',
136
- alignItems: 'center',
137
- marginBottom: theme.spacing.unit
138
- },
139
- tooltip: {
140
- fontSize: theme.typography.fontSize - 2,
141
- whiteSpace: 'pre',
142
- maxWidth: '500px'
143
- },
144
- errorText: {
145
- fontSize: theme.typography.fontSize - 2,
146
- color: theme.palette.error.main,
147
- paddingTop: theme.spacing.unit
148
- }
149
- };
150
- };
151
-
152
- var createElementFromHTML = function createElementFromHTML(htmlString) {
153
- var div = document.createElement('div');
33
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
34
+ const {
35
+ toggle,
36
+ Panel,
37
+ dropdown
38
+ } = _configUi.settings;
39
+ const PromptHolder = (0, _styles.styled)(_configUi.InputContainer)(({
40
+ theme
41
+ }) => ({
42
+ width: '100%',
43
+ paddingTop: theme.spacing(2),
44
+ marginBottom: theme.spacing(2)
45
+ }));
46
+ const ChoiceRationaleHolder = (0, _styles.styled)(_configUi.InputContainer)(({
47
+ theme
48
+ }) => ({
49
+ width: '100%',
50
+ paddingTop: theme.spacing(0.5),
51
+ marginBottom: theme.spacing(2)
52
+ }));
53
+ const StyledTypography = (0, _styles.styled)(_Typography.default)(({
54
+ theme
55
+ }) => ({
56
+ fontSize: theme.typography.fontSize + 2,
57
+ marginRight: theme.spacing(1)
58
+ }));
59
+ const RationaleLabel = (0, _styles.styled)('span')(({
60
+ theme
61
+ }) => ({
62
+ display: 'flex',
63
+ alignItems: 'center',
64
+ whiteSpace: 'break-spaces',
65
+ color: _renderUi.color.disabled(),
66
+ padding: 0,
67
+ fontSize: theme.typography.fontSize - 2,
68
+ lineHeight: 1
69
+ }));
70
+ const RationaleChoices = (0, _styles.styled)('div')(({
71
+ theme
72
+ }) => ({
73
+ marginBottom: theme.spacing(2.5)
74
+ }));
75
+ const StyledAccordionDetails = (0, _styles.styled)(_AccordionDetails.default)({
76
+ display: 'block',
77
+ paddingTop: 0,
78
+ paddingBottom: 0
79
+ });
80
+ const FlexContainer = (0, _styles.styled)('div')(({
81
+ theme
82
+ }) => ({
83
+ display: 'flex',
84
+ alignItems: 'center',
85
+ marginBottom: theme.spacing(1)
86
+ }));
87
+ const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
88
+ theme
89
+ }) => ({
90
+ '& .MuiTooltip-tooltip': {
91
+ fontSize: theme.typography.fontSize - 2,
92
+ whiteSpace: 'pre',
93
+ maxWidth: '500px'
94
+ }
95
+ }));
96
+ const ErrorText = (0, _styles.styled)('div')(({
97
+ theme
98
+ }) => ({
99
+ fontSize: theme.typography.fontSize - 2,
100
+ color: theme.palette.error.main,
101
+ paddingTop: theme.spacing(1)
102
+ }));
103
+ const createElementFromHTML = htmlString => {
104
+ const div = document.createElement('div');
154
105
  div.innerHTML = (htmlString || '').trim();
155
106
  return div;
156
107
  };
157
-
158
- var Main = /*#__PURE__*/function (_React$Component) {
159
- (0, _inherits2["default"])(Main, _React$Component);
160
-
161
- var _super = _createSuper(Main);
162
-
163
- function Main() {
164
- var _this;
165
-
166
- (0, _classCallCheck2["default"])(this, Main);
167
-
168
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
169
- args[_key] = arguments[_key];
170
- }
171
-
172
- _this = _super.call.apply(_super, [this].concat(args));
173
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
108
+ class Main extends _react.default.Component {
109
+ constructor(...args) {
110
+ super(...args);
111
+ (0, _defineProperty2.default)(this, "state", {
174
112
  warning: {
175
113
  open: false
176
114
  }
177
115
  });
178
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChange", function (newVal) {
179
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), newVal));
180
- });
181
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
182
- _this.onModelChange({
183
- prompt: prompt
116
+ (0, _defineProperty2.default)(this, "onModelChange", newVal => {
117
+ this.props.onModelChanged({
118
+ ...this.props.model,
119
+ ...newVal
184
120
  });
185
121
  });
186
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
187
- _this.onModelChange({
188
- rationale: rationale
122
+ (0, _defineProperty2.default)(this, "onPromptChanged", prompt => {
123
+ this.onModelChange({
124
+ prompt
189
125
  });
190
126
  });
191
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceRationaleChanged", function (index, choice) {
192
- var model = _this.props.model;
193
- var indexOfChoice = model.choices && model.choices[index] && model.choices[index].findIndex(function (elem) {
194
- return elem.label === choice.label && elem.value === choice.value;
127
+ (0, _defineProperty2.default)(this, "onRationaleChanged", rationale => {
128
+ this.onModelChange({
129
+ rationale
195
130
  });
131
+ });
132
+ (0, _defineProperty2.default)(this, "onChoiceRationaleChanged", (index, choice) => {
133
+ const {
134
+ model
135
+ } = this.props;
136
+ const indexOfChoice = model.choices && model.choices[index] && model.choices[index].findIndex(elem => elem.label === choice.label && elem.value === choice.value);
196
137
  model.choices[index] && model.choices[index].splice(indexOfChoice, 1, choice);
197
-
198
- _this.onModelChange(model);
138
+ this.onModelChange(model);
199
139
  });
200
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
201
- _this.onModelChange({
202
- teacherInstructions: teacherInstructions
140
+ (0, _defineProperty2.default)(this, "onTeacherInstructionsChanged", teacherInstructions => {
141
+ this.onModelChange({
142
+ teacherInstructions
203
143
  });
204
144
  });
205
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMarkupChanged", function (slateMarkup) {
206
- _this.onModelChange({
207
- slateMarkup: slateMarkup
145
+ (0, _defineProperty2.default)(this, "onMarkupChanged", slateMarkup => {
146
+ this.onModelChange({
147
+ slateMarkup
208
148
  });
209
149
  });
210
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCheck", function (callback) {
211
- _this.setState({
150
+ (0, _defineProperty2.default)(this, "onCheck", callback => {
151
+ this.setState({
212
152
  warning: {
213
153
  open: true,
214
154
  text: 'Response areas with under 2 options or with no correct answers will be discarded.',
215
- onClose: function onClose() {
216
- _this.setState({
155
+ onClose: () => {
156
+ this.setState({
217
157
  warning: {
218
158
  open: false
219
159
  }
220
160
  });
221
161
  },
222
- onConfirm: function onConfirm() {
223
- _this.setState({
162
+ onConfirm: () => {
163
+ this.setState({
224
164
  warning: {
225
165
  open: false
226
166
  }
@@ -229,29 +169,27 @@ var Main = /*#__PURE__*/function (_React$Component) {
229
169
  }
230
170
  });
231
171
  });
232
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
233
- var respAreaChoices = _this.state.respAreaChoices;
234
- var domMarkup = createElementFromHTML(markup);
235
- var allRespAreas = domMarkup.querySelectorAll('[data-type="inline_dropdown"]');
236
- var allChoices = {};
237
- allRespAreas.forEach(function (el) {
172
+ (0, _defineProperty2.default)(this, "onChange", markup => {
173
+ const {
174
+ respAreaChoices
175
+ } = this.state;
176
+ const domMarkup = createElementFromHTML(markup);
177
+ const allRespAreas = domMarkup.querySelectorAll('[data-type="inline_dropdown"]');
178
+ const allChoices = {};
179
+ allRespAreas.forEach(el => {
238
180
  allChoices[el.dataset.index] = el.dataset.value || '';
239
181
  });
240
- var existingRespAreaChoices = (0, _reduce["default"])(respAreaChoices, function (obj, choices, key) {
241
- if (!(0, _isUndefined["default"])(allChoices[key])) {
182
+ const existingRespAreaChoices = (0, _reduce.default)(respAreaChoices, (obj, choices, key) => {
183
+ if (!(0, _isUndefined.default)(allChoices[key])) {
242
184
  obj[key] = respAreaChoices[key];
243
185
  }
244
-
245
186
  return obj;
246
187
  }, {});
247
- var newRespAreaChoices = {};
248
- var shouldWarn = false;
249
- allRespAreas.forEach(function (el, index) {
250
- var newChoices = existingRespAreaChoices[el.dataset.index] || [];
251
-
252
- if (newChoices.length < 2 || !newChoices.find(function (c) {
253
- return c.correct;
254
- })) {
188
+ const newRespAreaChoices = {};
189
+ let shouldWarn = false;
190
+ allRespAreas.forEach((el, index) => {
191
+ const newChoices = existingRespAreaChoices[el.dataset.index] || [];
192
+ if (newChoices.length < 2 || !newChoices.find(c => c.correct)) {
255
193
  el.remove();
256
194
  shouldWarn = true;
257
195
  } else {
@@ -259,54 +197,52 @@ var Main = /*#__PURE__*/function (_React$Component) {
259
197
  el.dataset.index = index;
260
198
  }
261
199
  });
262
-
263
200
  if (shouldWarn) {
264
- _this.setState({
201
+ this.setState({
265
202
  warning: {
266
203
  open: true,
267
204
  text: 'Response areas with under 2 options or with no correct answers will be discarded.',
268
- onClose: function onClose() {
269
- _this.setState({
205
+ onClose: () => {
206
+ this.setState({
270
207
  warning: {
271
208
  open: false
272
209
  }
273
210
  });
274
211
  },
275
- onConfirm: function onConfirm() {
276
- _this.setState({
212
+ onConfirm: () => {
213
+ this.setState({
277
214
  warning: {
278
215
  open: false
279
216
  }
280
- }, function () {
281
- return _this.onModelChange({
282
- choices: (0, _cloneDeep["default"])(newRespAreaChoices),
283
- slateMarkup: domMarkup.innerHTML
284
- });
285
- });
217
+ }, () => this.onModelChange({
218
+ choices: (0, _cloneDeep.default)(newRespAreaChoices),
219
+ slateMarkup: domMarkup.innerHTML
220
+ }));
286
221
  }
287
222
  }
288
223
  });
289
224
  } else {
290
- _this.onModelChange({
291
- choices: (0, _cloneDeep["default"])(newRespAreaChoices),
225
+ this.onModelChange({
226
+ choices: (0, _cloneDeep.default)(newRespAreaChoices),
292
227
  slateMarkup: domMarkup.innerHTML
293
228
  });
294
229
  }
295
230
  });
296
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function (index, label, choiceIndex) {
297
- var _respAreaChoices$inde;
298
-
299
- var respAreaChoices = _this.state.respAreaChoices;
300
- var maxResponseAreaChoices = _this.props.configuration.maxResponseAreaChoices;
301
-
231
+ (0, _defineProperty2.default)(this, "onAddChoice", (index, label, choiceIndex) => {
232
+ const {
233
+ respAreaChoices
234
+ } = this.state;
235
+ const {
236
+ maxResponseAreaChoices
237
+ } = this.props.configuration;
302
238
  if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {
303
- _this.setState({
239
+ this.setState({
304
240
  warning: {
305
241
  open: true,
306
- text: "There are only ".concat(maxResponseAreaChoices, " answers allowed per choice."),
242
+ text: `There are only ${maxResponseAreaChoices} answers allowed per choice.`,
307
243
  onClose: undefined,
308
- onConfirm: function onConfirm() {
309
- _this.setState({
244
+ onConfirm: () => {
245
+ this.setState({
310
246
  warning: {
311
247
  open: false
312
248
  }
@@ -314,26 +250,22 @@ var Main = /*#__PURE__*/function (_React$Component) {
314
250
  }
315
251
  }
316
252
  });
317
-
318
253
  return;
319
254
  }
320
-
321
255
  if (!respAreaChoices[index]) {
322
256
  respAreaChoices[index] = [];
323
- } // check for duplicate answer, but exclude the one that is currently edited
324
-
257
+ }
325
258
 
326
- if ((respAreaChoices[index] || []).find(function (r, idx) {
327
- return r.label === label && idx !== choiceIndex;
328
- })) {
259
+ // check for duplicate answer, but exclude the one that is currently edited
260
+ if ((respAreaChoices[index] || []).find((r, idx) => r.label === label && idx !== choiceIndex)) {
329
261
  // show warning for duplicated answers
330
- _this.setState({
262
+ this.setState({
331
263
  warning: {
332
264
  open: true,
333
265
  text: 'Duplicate answers are not allowed.',
334
266
  onClose: undefined,
335
- onConfirm: function onConfirm() {
336
- _this.setState({
267
+ onConfirm: () => {
268
+ this.setState({
337
269
  warning: {
338
270
  open: false
339
271
  }
@@ -341,374 +273,287 @@ var Main = /*#__PURE__*/function (_React$Component) {
341
273
  }
342
274
  }
343
275
  });
344
-
345
276
  return;
346
277
  }
347
-
348
- if (choiceIndex >= 0 && (_respAreaChoices$inde = respAreaChoices[index]) !== null && _respAreaChoices$inde !== void 0 && _respAreaChoices$inde[choiceIndex]) {
278
+ if (choiceIndex >= 0 && respAreaChoices[index]?.[choiceIndex]) {
349
279
  // we need to update the choice label with the new value
350
280
  respAreaChoices[index][choiceIndex].label = label;
351
281
  } else {
352
282
  // add a new choice
353
- var value = respAreaChoices[index] && (0, _max["default"])(respAreaChoices[index].map(function (c) {
354
- return parseInt(c.value);
355
- }).filter(function (val) {
356
- return !isNaN(val);
357
- })) || 0;
283
+ const value = respAreaChoices[index] && (0, _max.default)(respAreaChoices[index].map(c => parseInt(c.value)).filter(val => !isNaN(val))) || 0;
358
284
  respAreaChoices[index].push({
359
- label: label,
360
- value: "".concat(value + 1),
285
+ label,
286
+ value: `${value + 1}`,
361
287
  correct: false
362
288
  });
363
289
  }
364
-
365
- _this.onModelChange({
366
- choices: (0, _cloneDeep["default"])(respAreaChoices)
290
+ this.onModelChange({
291
+ choices: (0, _cloneDeep.default)(respAreaChoices)
367
292
  });
368
293
  });
369
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveChoice", function (respIndex, index) {
370
- var respAreaChoices = _this.state.respAreaChoices;
294
+ (0, _defineProperty2.default)(this, "onRemoveChoice", (respIndex, index) => {
295
+ const {
296
+ respAreaChoices
297
+ } = this.state;
371
298
  respAreaChoices[respIndex].splice(index, 1);
372
-
373
- _this.onModelChange({
374
- choices: (0, _cloneDeep["default"])(respAreaChoices)
299
+ this.onModelChange({
300
+ choices: (0, _cloneDeep.default)(respAreaChoices)
375
301
  });
376
302
  });
377
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSelectChoice", function (respIndex, selectedIndex) {
378
- var respAreaChoices = _this.state.respAreaChoices;
379
- respAreaChoices[respIndex] = respAreaChoices[respIndex].map(function (choice, index) {
380
- return _objectSpread(_objectSpread({}, choice), {}, {
381
- correct: index === selectedIndex
382
- });
383
- });
384
-
385
- _this.onModelChange({
386
- choices: (0, _cloneDeep["default"])(respAreaChoices)
303
+ (0, _defineProperty2.default)(this, "onSelectChoice", (respIndex, selectedIndex) => {
304
+ const {
305
+ respAreaChoices
306
+ } = this.state;
307
+ respAreaChoices[respIndex] = respAreaChoices[respIndex].map((choice, index) => ({
308
+ ...choice,
309
+ correct: index === selectedIndex
310
+ }));
311
+ this.onModelChange({
312
+ choices: (0, _cloneDeep.default)(respAreaChoices)
387
313
  });
388
314
  });
389
- return _this;
390
315
  }
391
-
392
- (0, _createClass2["default"])(Main, [{
393
- key: "componentDidMount",
394
- value: function componentDidMount() {
395
- var choices = this.props.model.choices;
396
- this.setState({
397
- respAreaChoices: (0, _cloneDeep["default"])(choices)
398
- });
399
- }
400
- }, {
401
- key: "UNSAFE_componentWillReceiveProps",
402
- value: function UNSAFE_componentWillReceiveProps(nProps) {
403
- var newState = {};
404
-
405
- if (!(0, _isEqual["default"])(nProps.model.choices, this.props.model.choices) || !(0, _isEqual["default"])(nProps.model.choices, this.state.respAreaChoices)) {
406
- newState.respAreaChoices = (0, _cloneDeep["default"])(nProps.model.choices);
407
- }
408
-
409
- if (!(0, _isEmpty["default"])(newState)) {
410
- this.setState(newState);
316
+ componentDidMount() {
317
+ const {
318
+ model: {
319
+ choices
411
320
  }
321
+ } = this.props;
322
+ this.setState({
323
+ respAreaChoices: (0, _cloneDeep.default)(choices)
324
+ });
325
+ }
326
+ UNSAFE_componentWillReceiveProps(nProps) {
327
+ const newState = {};
328
+ if (!(0, _isEqual.default)(nProps.model.choices, this.props.model.choices) || !(0, _isEqual.default)(nProps.model.choices, this.state.respAreaChoices)) {
329
+ newState.respAreaChoices = (0, _cloneDeep.default)(nProps.model.choices);
412
330
  }
413
- }, {
414
- key: "componentDidUpdate",
415
- value: function componentDidUpdate() {
416
- //eslint-disable-next-line
417
- var domNode = _reactDom["default"].findDOMNode(this);
418
-
419
- (0, _mathRendering.renderMath)(domNode);
331
+ if (!(0, _isEmpty.default)(newState)) {
332
+ this.setState(newState);
420
333
  }
421
- }, {
422
- key: "render",
423
- value: function render() {
424
- var _this2 = this;
425
-
426
- var warning = this.state.warning;
427
- var _this$props = this.props,
428
- classes = _this$props.classes,
429
- model = _this$props.model,
430
- configuration = _this$props.configuration,
431
- onConfigurationChanged = _this$props.onConfigurationChanged,
432
- imageSupport = _this$props.imageSupport,
433
- uploadSoundSupport = _this$props.uploadSoundSupport;
434
-
435
- var _ref = configuration || {},
436
- _ref$baseInputConfigu = _ref.baseInputConfiguration,
437
- baseInputConfiguration = _ref$baseInputConfigu === void 0 ? {} : _ref$baseInputConfigu,
438
- _ref$choiceRationale = _ref.choiceRationale,
439
- choiceRationale = _ref$choiceRationale === void 0 ? {} : _ref$choiceRationale,
440
- _ref$contentDimension = _ref.contentDimensions,
441
- contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension,
442
- _ref$lockChoiceOrder = _ref.lockChoiceOrder,
443
- lockChoiceOrder = _ref$lockChoiceOrder === void 0 ? {} : _ref$lockChoiceOrder,
444
- maxResponseAreas = _ref.maxResponseAreas,
445
- _ref$maxImageWidth = _ref.maxImageWidth,
446
- maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
447
- _ref$maxImageHeight = _ref.maxImageHeight,
448
- maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
449
- _ref$partialScoring = _ref.partialScoring,
450
- partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
451
- _ref$prompt = _ref.prompt,
452
- prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
453
- _ref$rationale = _ref.rationale,
454
- rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
455
- settingsPanelDisabled = _ref.settingsPanelDisabled,
456
- _ref$spellCheck = _ref.spellCheck,
457
- spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
458
- _ref$teacherInstructi = _ref.teacherInstructions,
459
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
460
- _ref$template = _ref.template,
461
- template = _ref$template === void 0 ? {} : _ref$template,
462
- _ref$withRubric = _ref.withRubric,
463
- withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric,
464
- _ref$mathMlOptions = _ref.mathMlOptions,
465
- mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions,
466
- _ref$language = _ref.language,
467
- language = _ref$language === void 0 ? {} : _ref$language,
468
- _ref$languageChoices = _ref.languageChoices,
469
- languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices,
470
- _ref$responseAreaInpu = _ref.responseAreaInputConfiguration,
471
- responseAreaInputConfiguration = _ref$responseAreaInpu === void 0 ? {} : _ref$responseAreaInpu;
472
-
473
- var _ref2 = model || {},
474
- choiceRationaleEnabled = _ref2.choiceRationaleEnabled,
475
- choices = _ref2.choices,
476
- errors = _ref2.errors,
477
- extraCSSRules = _ref2.extraCSSRules,
478
- promptEnabled = _ref2.promptEnabled,
479
- rationaleEnabled = _ref2.rationaleEnabled,
480
- spellCheckEnabled = _ref2.spellCheckEnabled,
481
- teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
482
- toolbarEditorPosition = _ref2.toolbarEditorPosition;
483
-
484
- var _ref3 = errors || {},
485
- promptError = _ref3.prompt,
486
- rationaleError = _ref3.rationale,
487
- responseAreasError = _ref3.responseAreasError,
488
- responseAreaChoicesError = _ref3.responseAreaChoicesError,
489
- teacherInstructionsError = _ref3.teacherInstructions;
490
-
491
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
492
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
493
-
494
- var renderChoiceRationale = function renderChoiceRationale() {
495
- return (Object.keys(choices) || []).map(function (key, index) {
496
- return /*#__PURE__*/_react["default"].createElement("div", {
497
- key: key,
498
- className: classes.rationaleChoices
499
- }, /*#__PURE__*/_react["default"].createElement(_ExpansionPanel["default"], null, /*#__PURE__*/_react["default"].createElement(_ExpansionPanelSummary["default"], {
500
- expandIcon: /*#__PURE__*/_react["default"].createElement(_ExpandMore["default"], null)
501
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
502
- className: classes.text
503
- }, "Rationale for response area #".concat(index + 1))), /*#__PURE__*/_react["default"].createElement(_ExpansionPanelDetails["default"], {
504
- className: classes.panelDetails
505
- }, (choices[key] || []).map(function (choice) {
506
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
507
- key: choice.label
508
- }, /*#__PURE__*/_react["default"].createElement("span", {
509
- className: classes.rationaleLabel,
510
- dangerouslySetInnerHTML: {
511
- __html: "".concat(rationale.label, " for ").concat(choice.label, " (").concat(choice.correct ? 'correct' : 'incorrect', ")")
512
- }
513
- }), /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
514
- className: classes.choiceRationaleHolder
515
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
516
- className: classes.prompt,
517
- markup: choice.rationale || '',
334
+ }
335
+ componentDidUpdate() {
336
+ //eslint-disable-next-line
337
+ const domNode = _reactDom.default.findDOMNode(this);
338
+ (0, _mathRendering.renderMath)(domNode);
339
+ }
340
+ render() {
341
+ const {
342
+ warning
343
+ } = this.state;
344
+ const {
345
+ model,
346
+ configuration,
347
+ onConfigurationChanged,
348
+ imageSupport,
349
+ uploadSoundSupport
350
+ } = this.props;
351
+ const {
352
+ baseInputConfiguration = {},
353
+ choiceRationale = {},
354
+ contentDimensions = {},
355
+ lockChoiceOrder = {},
356
+ maxResponseAreas,
357
+ maxImageWidth = {},
358
+ maxImageHeight = {},
359
+ partialScoring = {},
360
+ prompt = {},
361
+ rationale = {},
362
+ settingsPanelDisabled,
363
+ spellCheck = {},
364
+ teacherInstructions = {},
365
+ template = {},
366
+ withRubric = {},
367
+ mathMlOptions = {},
368
+ language = {},
369
+ languageChoices = {},
370
+ responseAreaInputConfiguration = {}
371
+ } = configuration || {};
372
+ const {
373
+ choiceRationaleEnabled,
374
+ choices,
375
+ errors,
376
+ extraCSSRules,
377
+ promptEnabled,
378
+ rationaleEnabled,
379
+ spellCheckEnabled,
380
+ teacherInstructionsEnabled,
381
+ toolbarEditorPosition
382
+ } = model || {};
383
+ const {
384
+ prompt: promptError,
385
+ rationale: rationaleError,
386
+ responseAreasError,
387
+ responseAreaChoicesError,
388
+ teacherInstructions: teacherInstructionsError
389
+ } = errors || {};
390
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
391
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
392
+ const renderChoiceRationale = () => (Object.keys(choices) || []).map((key, index) => /*#__PURE__*/_react.default.createElement(RationaleChoices, {
393
+ key: key
394
+ }, /*#__PURE__*/_react.default.createElement(_Accordion.default, {
395
+ slotProps: {
396
+ transition: {
397
+ timeout: {
398
+ enter: 225,
399
+ exit: 195
400
+ }
401
+ }
402
+ }
403
+ }, /*#__PURE__*/_react.default.createElement(_AccordionSummary.default, {
404
+ expandIcon: /*#__PURE__*/_react.default.createElement(_ExpandMore.default, null)
405
+ }, /*#__PURE__*/_react.default.createElement(StyledTypography, {
406
+ component: 'div'
407
+ }, `Rationale for response area #${index + 1}`)), /*#__PURE__*/_react.default.createElement(StyledAccordionDetails, null, (choices[key] || []).map(choice => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
408
+ key: choice.label
409
+ }, /*#__PURE__*/_react.default.createElement(RationaleLabel, {
410
+ dangerouslySetInnerHTML: {
411
+ __html: `${rationale.label} for ${choice.label} (${choice.correct ? 'correct' : 'incorrect'})`
412
+ }
413
+ }), /*#__PURE__*/_react.default.createElement(ChoiceRationaleHolder, null, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
414
+ markup: choice.rationale || '',
415
+ spellCheck: spellCheckEnabled,
416
+ onChange: c => this.onChoiceRationaleChanged(key, {
417
+ ...choice,
418
+ rationale: c
419
+ }),
420
+ imageSupport: imageSupport,
421
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
422
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
423
+ uploadSoundSupport: uploadSoundSupport,
424
+ mathMlOptions: mathMlOptions
425
+ }))))))));
426
+ const toolbarOpts = {
427
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
428
+ };
429
+ const validationMessage = (0, _utils.generateValidationMessage)(configuration);
430
+ const panelSettings = {
431
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
432
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
433
+ 'language.enabled': language.settings && toggle(language.label, true),
434
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
435
+ };
436
+ const panelProperties = {
437
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
438
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
439
+ choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),
440
+ promptEnabled: prompt.settings && toggle(prompt.label),
441
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
442
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
443
+ };
444
+ const getPluginProps = (props = {}) => ({
445
+ ...baseInputConfiguration,
446
+ ...props
447
+ });
448
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
449
+ extraCSSRules: extraCSSRules,
450
+ dimensions: contentDimensions,
451
+ hideSettings: settingsPanelDisabled,
452
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
453
+ model: model,
454
+ configuration: configuration,
455
+ onChangeModel: model => this.onModelChange(model),
456
+ onChangeConfiguration: configuration => onConfigurationChanged(configuration, true),
457
+ groups: {
458
+ Settings: panelSettings,
459
+ Properties: panelProperties
460
+ }
461
+ })
462
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(PromptHolder, {
463
+ label: teacherInstructions.label
464
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
465
+ markup: model.teacherInstructions || '',
466
+ onChange: this.onTeacherInstructionsChanged,
467
+ imageSupport: imageSupport,
468
+ nonEmpty: false,
469
+ error: teacherInstructionsError,
470
+ toolbarOpts: toolbarOpts,
471
+ pluginProps: getPluginProps(teacherInstructions?.inputConfiguration),
472
+ spellCheck: spellCheckEnabled,
473
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
474
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
475
+ uploadSoundSupport: uploadSoundSupport,
476
+ languageCharactersProps: [{
477
+ language: 'spanish'
478
+ }, {
479
+ language: 'special'
480
+ }],
481
+ mathMlOptions: mathMlOptions
482
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(PromptHolder, {
483
+ label: prompt.label
484
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
485
+ markup: model.prompt,
486
+ onChange: this.onPromptChanged,
487
+ imageSupport: imageSupport,
488
+ nonEmpty: false,
489
+ disableUnderline: true,
490
+ error: promptError,
491
+ toolbarOpts: toolbarOpts,
492
+ pluginProps: getPluginProps(prompt?.inputConfiguration),
493
+ spellCheck: spellCheckEnabled,
494
+ maxImageWidth: defaultImageMaxWidth,
495
+ maxImageHeight: defaultImageMaxHeight,
496
+ uploadSoundSupport: uploadSoundSupport,
497
+ languageCharactersProps: [{
498
+ language: 'spanish'
499
+ }, {
500
+ language: 'special'
501
+ }],
502
+ mathMlOptions: mathMlOptions
503
+ }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError)), /*#__PURE__*/_react.default.createElement(FlexContainer, null, /*#__PURE__*/_react.default.createElement(StyledTypography, {
504
+ component: 'div'
505
+ }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react.default.createElement(StyledTooltip, {
506
+ disableFocusListener: true,
507
+ disableTouchListener: true,
508
+ placement: 'right',
509
+ title: validationMessage
510
+ }, /*#__PURE__*/_react.default.createElement(_Info.default, {
511
+ fontSize: 'small',
512
+ color: 'primary'
513
+ }))), /*#__PURE__*/_react.default.createElement(_responseArea.default, {
514
+ responseAreasError: responseAreasError,
515
+ responseAreaChoicesError: responseAreaChoicesError,
516
+ editableHtmlProps: {
517
+ pluginProps: getPluginProps(template?.inputConfiguration),
518
+ activePlugins: _editableHtml.ALL_PLUGINS,
519
+ toolbarOpts: {
520
+ position: 'top'
521
+ },
522
+ responseAreaProps: {
523
+ type: 'inline-dropdown',
524
+ options: {
525
+ duplicates: true
526
+ },
527
+ maxResponseAreas: maxResponseAreas,
528
+ respAreaToolbar: (node, value, onToolbarDone) => {
529
+ const {
530
+ respAreaChoices
531
+ } = this.state;
532
+ return () => /*#__PURE__*/_react.default.createElement(_inlineDropdownToolbar.default, {
533
+ onAddChoice: this.onAddChoice,
534
+ onCheck: this.onCheck,
535
+ onRemoveChoice: index => this.onRemoveChoice(node.data.get('index'), index),
536
+ onSelectChoice: index => this.onSelectChoice(node.data.get('index'), index),
537
+ node: node,
538
+ value: value,
539
+ onToolbarDone: onToolbarDone,
540
+ choices: respAreaChoices[node.data.get('index')],
518
541
  spellCheck: spellCheckEnabled,
519
- onChange: function onChange(c) {
520
- return _this2.onChoiceRationaleChanged(key, _objectSpread(_objectSpread({}, choice), {}, {
521
- rationale: c
522
- }));
523
- },
524
- imageSupport: imageSupport,
525
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
526
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
527
542
  uploadSoundSupport: uploadSoundSupport,
528
- mathMlOptions: mathMlOptions
529
- })));
530
- }))));
531
- });
532
- };
533
-
534
- var toolbarOpts = {
535
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
536
- };
537
- var validationMessage = (0, _utils.generateValidationMessage)(configuration);
538
- var panelSettings = {
539
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
540
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
541
- 'language.enabled': language.settings && toggle(language.label, true),
542
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
543
- };
544
- var panelProperties = {
545
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
546
- rationaleEnabled: rationale.settings && toggle(rationale.label),
547
- choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),
548
- promptEnabled: prompt.settings && toggle(prompt.label),
549
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
550
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
551
- };
552
-
553
- var getPluginProps = function getPluginProps() {
554
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
555
- return _objectSpread(_objectSpread({}, baseInputConfiguration), props);
556
- };
557
-
558
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
559
- extraCSSRules: extraCSSRules,
560
- dimensions: contentDimensions,
561
- hideSettings: settingsPanelDisabled,
562
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
563
- model: model,
564
- configuration: configuration,
565
- onChangeModel: function onChangeModel(model) {
566
- return _this2.onModelChange(model);
567
- },
568
- onChangeConfiguration: function onChangeConfiguration(configuration) {
569
- return onConfigurationChanged(configuration, true);
570
- },
571
- groups: {
572
- Settings: panelSettings,
573
- Properties: panelProperties
543
+ mathMlOptions: mathMlOptions,
544
+ baseInputConfiguration: baseInputConfiguration,
545
+ responseAreaInputConfiguration: responseAreaInputConfiguration
546
+ });
574
547
  }
575
- })
576
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
577
- label: teacherInstructions.label,
578
- className: classes.promptHolder
579
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
580
- className: classes.prompt,
581
- markup: model.teacherInstructions || '',
582
- onChange: this.onTeacherInstructionsChanged,
583
- imageSupport: imageSupport,
584
- nonEmpty: false,
585
- error: teacherInstructionsError,
586
- toolbarOpts: toolbarOpts,
587
- pluginProps: getPluginProps(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration),
588
- spellCheck: spellCheckEnabled,
589
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
590
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
591
- uploadSoundSupport: uploadSoundSupport,
592
- languageCharactersProps: [{
593
- language: 'spanish'
594
- }, {
595
- language: 'special'
596
- }],
597
- mathMlOptions: mathMlOptions
598
- }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
599
- className: classes.errorText
600
- }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
601
- label: prompt.label,
602
- className: classes.promptHolder
603
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
604
- className: classes.prompt,
605
- markup: model.prompt,
606
- onChange: this.onPromptChanged,
607
- imageSupport: imageSupport,
608
- nonEmpty: false,
609
- disableUnderline: true,
610
- error: promptError,
611
- toolbarOpts: toolbarOpts,
612
- pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
613
- spellCheck: spellCheckEnabled,
614
- maxImageWidth: defaultImageMaxWidth,
615
- maxImageHeight: defaultImageMaxHeight,
616
- uploadSoundSupport: uploadSoundSupport,
617
- languageCharactersProps: [{
618
- language: 'spanish'
619
- }, {
620
- language: 'special'
621
- }],
622
- mathMlOptions: mathMlOptions
623
- }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
624
- className: classes.errorText
625
- }, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
626
- className: classes.flexContainer
627
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
628
- className: classes.text,
629
- component: 'div'
630
- }, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
631
- classes: {
632
- tooltip: classes.tooltip
633
548
  },
634
- disableFocusListener: true,
635
- disableTouchListener: true,
636
- placement: 'right',
637
- title: validationMessage
638
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
639
- fontSize: 'small',
640
- color: 'primary'
641
- }))), /*#__PURE__*/_react["default"].createElement(_responseArea["default"], {
642
- responseAreasError: responseAreasError,
643
- responseAreaChoicesError: responseAreaChoicesError,
644
- editableHtmlProps: {
645
- pluginProps: getPluginProps(template === null || template === void 0 ? void 0 : template.inputConfiguration),
646
- activePlugins: _editableHtml.ALL_PLUGINS,
647
- toolbarOpts: {
648
- position: 'top'
649
- },
650
- responseAreaProps: {
651
- type: 'inline-dropdown',
652
- options: {
653
- duplicates: true
654
- },
655
- maxResponseAreas: maxResponseAreas,
656
- respAreaToolbar: function respAreaToolbar(node, value, onToolbarDone) {
657
- var respAreaChoices = _this2.state.respAreaChoices;
658
- return function () {
659
- return /*#__PURE__*/_react["default"].createElement(_inlineDropdownToolbar["default"], {
660
- onAddChoice: _this2.onAddChoice,
661
- onCheck: _this2.onCheck,
662
- onRemoveChoice: function onRemoveChoice(index) {
663
- return _this2.onRemoveChoice(node.data.get('index'), index);
664
- },
665
- onSelectChoice: function onSelectChoice(index) {
666
- return _this2.onSelectChoice(node.data.get('index'), index);
667
- },
668
- node: node,
669
- value: value,
670
- onToolbarDone: onToolbarDone,
671
- choices: respAreaChoices[node.data.get('index')],
672
- spellCheck: spellCheckEnabled,
673
- uploadSoundSupport: uploadSoundSupport,
674
- mathMlOptions: mathMlOptions,
675
- baseInputConfiguration: baseInputConfiguration,
676
- responseAreaInputConfiguration: responseAreaInputConfiguration
677
- });
678
- };
679
- }
680
- },
681
- spellCheck: spellCheckEnabled,
682
- className: classes.markup,
683
- markup: model.slateMarkup || '',
684
- onChange: this.onChange,
685
- imageSupport: imageSupport,
686
- disableImageAlignmentButtons: true,
687
- disabled: false,
688
- highlightShape: false,
689
- error: responseAreasError,
690
- uploadSoundSupport: uploadSoundSupport,
691
- languageCharactersProps: [{
692
- language: 'spanish'
693
- }, {
694
- language: 'special'
695
- }],
696
- mathMlOptions: mathMlOptions
697
- }
698
- }), choiceRationaleEnabled && renderChoiceRationale(), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
699
- label: rationale.label,
700
- className: classes.promptHolder
701
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
702
- className: classes.prompt,
703
- markup: model.rationale || '',
704
- onChange: this.onRationaleChanged,
705
- imageSupport: imageSupport,
706
- error: rationaleError,
707
- toolbarOpts: toolbarOpts,
708
- pluginProps: getPluginProps(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration),
709
549
  spellCheck: spellCheckEnabled,
710
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
711
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
550
+ markup: model.slateMarkup || '',
551
+ onChange: this.onChange,
552
+ imageSupport: imageSupport,
553
+ disableImageAlignmentButtons: true,
554
+ disabled: false,
555
+ highlightShape: false,
556
+ error: responseAreasError,
712
557
  uploadSoundSupport: uploadSoundSupport,
713
558
  languageCharactersProps: [{
714
559
  language: 'spanish'
@@ -716,38 +561,53 @@ var Main = /*#__PURE__*/function (_React$Component) {
716
561
  language: 'special'
717
562
  }],
718
563
  mathMlOptions: mathMlOptions
719
- }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
720
- className: classes.errorText
721
- }, rationaleError)), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
722
- open: warning.open,
723
- title: "Warning",
724
- text: warning.text,
725
- onClose: warning.onClose,
726
- onConfirm: warning.onConfirm
727
- }));
728
- }
729
- }]);
730
- return Main;
731
- }(_react["default"].Component);
732
-
564
+ }
565
+ }), choiceRationaleEnabled && renderChoiceRationale(), rationaleEnabled && /*#__PURE__*/_react.default.createElement(PromptHolder, {
566
+ label: rationale.label
567
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
568
+ markup: model.rationale || '',
569
+ onChange: this.onRationaleChanged,
570
+ imageSupport: imageSupport,
571
+ error: rationaleError,
572
+ toolbarOpts: toolbarOpts,
573
+ pluginProps: getPluginProps(rationale?.inputConfiguration),
574
+ spellCheck: spellCheckEnabled,
575
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
576
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
577
+ uploadSoundSupport: uploadSoundSupport,
578
+ languageCharactersProps: [{
579
+ language: 'spanish'
580
+ }, {
581
+ language: 'special'
582
+ }],
583
+ mathMlOptions: mathMlOptions
584
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError)), /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
585
+ open: warning.open,
586
+ title: "Warning",
587
+ text: warning.text,
588
+ onClose: warning.onClose,
589
+ onConfirm: warning.onConfirm,
590
+ disableAutoFocus: true,
591
+ disableEnforceFocus: true,
592
+ disableRestoreFocus: true
593
+ }));
594
+ }
595
+ }
733
596
  exports.Main = Main;
734
- (0, _defineProperty2["default"])(Main, "propTypes", {
735
- configuration: _propTypes["default"].object.isRequired,
736
- model: _propTypes["default"].object.isRequired,
737
- disableSidePanel: _propTypes["default"].bool,
738
- onModelChanged: _propTypes["default"].func.isRequired,
739
- onConfigurationChanged: _propTypes["default"].func.isRequired,
740
- classes: _propTypes["default"].object.isRequired,
741
- imageSupport: _propTypes["default"].shape({
742
- add: _propTypes["default"].func.isRequired,
743
- "delete": _propTypes["default"].func.isRequired
597
+ (0, _defineProperty2.default)(Main, "propTypes", {
598
+ configuration: _propTypes.default.object.isRequired,
599
+ model: _propTypes.default.object.isRequired,
600
+ disableSidePanel: _propTypes.default.bool,
601
+ onModelChanged: _propTypes.default.func.isRequired,
602
+ onConfigurationChanged: _propTypes.default.func.isRequired,
603
+ imageSupport: _propTypes.default.shape({
604
+ add: _propTypes.default.func.isRequired,
605
+ delete: _propTypes.default.func.isRequired
744
606
  }),
745
- uploadSoundSupport: _propTypes["default"].shape({
746
- add: _propTypes["default"].func.isRequired,
747
- "delete": _propTypes["default"].func.isRequired
607
+ uploadSoundSupport: _propTypes.default.shape({
608
+ add: _propTypes.default.func.isRequired,
609
+ delete: _propTypes.default.func.isRequired
748
610
  })
749
611
  });
750
- var Styled = (0, _styles.withStyles)(styles)(Main);
751
- var _default = Styled;
752
- exports["default"] = _default;
612
+ var _default = exports.default = Main;
753
613
  //# sourceMappingURL=main.js.map