@pie-element/explicit-constructed-response 3.13.1 → 3.13.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.
@@ -1,1958 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_lodash, _dll_material_ui__icons, _dll_react_dom, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.15/module/index.js";
2
- import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.5.2/module/index.js";
3
- import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.2.2/module/index.js";
4
- function getDefaultExportFromCjs(x) {
5
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6
- }
7
- var lib$1 = {};
8
- var interopRequireDefault = {
9
- exports: {}
10
- };
11
- (function (module) {
12
- function _interopRequireDefault(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- "default": obj
15
- };
16
- }
17
- (module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports);
18
- })(interopRequireDefault);
19
- getDefaultExportFromCjs(interopRequireDefault.exports);
20
- var classCallCheck = {
21
- exports: {}
22
- };
23
- (function (module) {
24
- function _classCallCheck(instance, Constructor) {
25
- if (!(instance instanceof Constructor)) {
26
- throw new TypeError("Cannot call a class as a function");
27
- }
28
- }
29
- (module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports);
30
- })(classCallCheck);
31
- getDefaultExportFromCjs(classCallCheck.exports);
32
- var createClass = {
33
- exports: {}
34
- };
35
- (function (module) {
36
- function _defineProperties(target, props) {
37
- for (var i = 0; i < props.length; i++) {
38
- var descriptor = props[i];
39
- descriptor.enumerable = descriptor.enumerable || false;
40
- descriptor.configurable = true;
41
- if (("value" in descriptor)) descriptor.writable = true;
42
- Object.defineProperty(target, descriptor.key, descriptor);
43
- }
44
- }
45
- function _createClass(Constructor, protoProps, staticProps) {
46
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
47
- if (staticProps) _defineProperties(Constructor, staticProps);
48
- Object.defineProperty(Constructor, "prototype", {
49
- writable: false
50
- });
51
- return Constructor;
52
- }
53
- (module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports);
54
- })(createClass);
55
- getDefaultExportFromCjs(createClass.exports);
56
- var assertThisInitialized = {
57
- exports: {}
58
- };
59
- (function (module) {
60
- function _assertThisInitialized(self) {
61
- if (self === void 0) {
62
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
63
- }
64
- return self;
65
- }
66
- (module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports);
67
- })(assertThisInitialized);
68
- getDefaultExportFromCjs(assertThisInitialized.exports);
69
- var inherits = {
70
- exports: {}
71
- };
72
- var setPrototypeOf = {
73
- exports: {}
74
- };
75
- (function (module) {
76
- function _setPrototypeOf(o, p) {
77
- (module.exports = _setPrototypeOf = Object.setPrototypeOf || (function _setPrototypeOf(o, p) {
78
- o.__proto__ = p;
79
- return o;
80
- }), module.exports.__esModule = true, module.exports["default"] = module.exports);
81
- return _setPrototypeOf(o, p);
82
- }
83
- (module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports);
84
- })(setPrototypeOf);
85
- getDefaultExportFromCjs(setPrototypeOf.exports);
86
- (function (module) {
87
- var setPrototypeOf$1 = setPrototypeOf.exports;
88
- function _inherits(subClass, superClass) {
89
- if (typeof superClass !== "function" && superClass !== null) {
90
- throw new TypeError("Super expression must either be null or a function");
91
- }
92
- subClass.prototype = Object.create(superClass && superClass.prototype, {
93
- constructor: {
94
- value: subClass,
95
- writable: true,
96
- configurable: true
97
- }
98
- });
99
- Object.defineProperty(subClass, "prototype", {
100
- writable: false
101
- });
102
- if (superClass) setPrototypeOf$1(subClass, superClass);
103
- }
104
- (module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports);
105
- })(inherits);
106
- getDefaultExportFromCjs(inherits.exports);
107
- var possibleConstructorReturn = {
108
- exports: {}
109
- };
110
- var _typeof = {
111
- exports: {}
112
- };
113
- (function (module) {
114
- function _typeof(obj) {
115
- "@babel/helpers - typeof";
116
- return ((module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
117
- return typeof obj;
118
- } : function (obj) {
119
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
120
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj));
121
- }
122
- (module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports);
123
- })(_typeof);
124
- getDefaultExportFromCjs(_typeof.exports);
125
- (function (module) {
126
- var _typeof$1 = _typeof.exports["default"];
127
- var assertThisInitialized$1 = assertThisInitialized.exports;
128
- function _possibleConstructorReturn(self, call) {
129
- if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
130
- return call;
131
- } else if (call !== void 0) {
132
- throw new TypeError("Derived constructors may only return object or undefined");
133
- }
134
- return assertThisInitialized$1(self);
135
- }
136
- (module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports);
137
- })(possibleConstructorReturn);
138
- getDefaultExportFromCjs(possibleConstructorReturn.exports);
139
- var getPrototypeOf = {
140
- exports: {}
141
- };
142
- (function (module) {
143
- function _getPrototypeOf(o) {
144
- (module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
145
- return o.__proto__ || Object.getPrototypeOf(o);
146
- }, module.exports.__esModule = true, module.exports["default"] = module.exports);
147
- return _getPrototypeOf(o);
148
- }
149
- (module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports);
150
- })(getPrototypeOf);
151
- getDefaultExportFromCjs(getPrototypeOf.exports);
152
- var wrapNativeSuper = {
153
- exports: {}
154
- };
155
- var isNativeFunction = {
156
- exports: {}
157
- };
158
- (function (module) {
159
- function _isNativeFunction(fn) {
160
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
161
- }
162
- (module.exports = _isNativeFunction, module.exports.__esModule = true, module.exports["default"] = module.exports);
163
- })(isNativeFunction);
164
- getDefaultExportFromCjs(isNativeFunction.exports);
165
- var construct = {
166
- exports: {}
167
- };
168
- var isNativeReflectConstruct = {
169
- exports: {}
170
- };
171
- (function (module) {
172
- function _isNativeReflectConstruct() {
173
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
174
- if (Reflect.construct.sham) return false;
175
- if (typeof Proxy === "function") return true;
176
- try {
177
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
178
- return true;
179
- } catch (e) {
180
- return false;
181
- }
182
- }
183
- (module.exports = _isNativeReflectConstruct, module.exports.__esModule = true, module.exports["default"] = module.exports);
184
- })(isNativeReflectConstruct);
185
- getDefaultExportFromCjs(isNativeReflectConstruct.exports);
186
- (function (module) {
187
- var setPrototypeOf$1 = setPrototypeOf.exports;
188
- var isNativeReflectConstruct$1 = isNativeReflectConstruct.exports;
189
- function _construct(Parent, args, Class) {
190
- if (isNativeReflectConstruct$1()) {
191
- (module.exports = _construct = Reflect.construct, module.exports.__esModule = true, module.exports["default"] = module.exports);
192
- } else {
193
- (module.exports = _construct = function _construct(Parent, args, Class) {
194
- var a = [null];
195
- a.push.apply(a, args);
196
- var Constructor = Function.bind.apply(Parent, a);
197
- var instance = new Constructor();
198
- if (Class) setPrototypeOf$1(instance, Class.prototype);
199
- return instance;
200
- }, module.exports.__esModule = true, module.exports["default"] = module.exports);
201
- }
202
- return _construct.apply(null, arguments);
203
- }
204
- (module.exports = _construct, module.exports.__esModule = true, module.exports["default"] = module.exports);
205
- })(construct);
206
- getDefaultExportFromCjs(construct.exports);
207
- (function (module) {
208
- var getPrototypeOf$1 = getPrototypeOf.exports;
209
- var setPrototypeOf$1 = setPrototypeOf.exports;
210
- var isNativeFunction$1 = isNativeFunction.exports;
211
- var construct$1 = construct.exports;
212
- function _wrapNativeSuper(Class) {
213
- var _cache = typeof Map === "function" ? new Map() : undefined;
214
- (module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
215
- if (Class === null || !isNativeFunction$1(Class)) return Class;
216
- if (typeof Class !== "function") {
217
- throw new TypeError("Super expression must either be null or a function");
218
- }
219
- if (typeof _cache !== "undefined") {
220
- if (_cache.has(Class)) return _cache.get(Class);
221
- _cache.set(Class, Wrapper);
222
- }
223
- function Wrapper() {
224
- return construct$1(Class, arguments, getPrototypeOf$1(this).constructor);
225
- }
226
- Wrapper.prototype = Object.create(Class.prototype, {
227
- constructor: {
228
- value: Wrapper,
229
- enumerable: false,
230
- writable: true,
231
- configurable: true
232
- }
233
- });
234
- return setPrototypeOf$1(Wrapper, Class);
235
- }, module.exports.__esModule = true, module.exports["default"] = module.exports);
236
- return _wrapNativeSuper(Class);
237
- }
238
- (module.exports = _wrapNativeSuper, module.exports.__esModule = true, module.exports["default"] = module.exports);
239
- })(wrapNativeSuper);
240
- getDefaultExportFromCjs(wrapNativeSuper.exports);
241
- var defineProperty = {
242
- exports: {}
243
- };
244
- (function (module) {
245
- function _defineProperty(obj, key, value) {
246
- if ((key in obj)) {
247
- Object.defineProperty(obj, key, {
248
- value: value,
249
- enumerable: true,
250
- configurable: true,
251
- writable: true
252
- });
253
- } else {
254
- obj[key] = value;
255
- }
256
- return obj;
257
- }
258
- (module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports);
259
- })(defineProperty);
260
- getDefaultExportFromCjs(defineProperty.exports);
261
- var lib = {};
262
- Object.defineProperty(lib, "__esModule", {
263
- value: true
264
- });
265
- class ModelUpdatedEvent extends CustomEvent {
266
- constructor(update, reset = false) {
267
- super(ModelUpdatedEvent.TYPE, {
268
- bubbles: true,
269
- detail: {
270
- update,
271
- reset
272
- }
273
- });
274
- this.update = update;
275
- this.reset = reset;
276
- }
277
- }
278
- ModelUpdatedEvent.TYPE = 'model.updated';
279
- lib.ModelUpdatedEvent = ModelUpdatedEvent;
280
- class DeleteImageEvent extends CustomEvent {
281
- constructor(src, done) {
282
- super(DeleteImageEvent.TYPE, {
283
- bubbles: true,
284
- detail: {
285
- src,
286
- done
287
- }
288
- });
289
- this.src = src;
290
- this.done = done;
291
- }
292
- }
293
- DeleteImageEvent.TYPE = 'delete.image';
294
- lib.DeleteImageEvent = DeleteImageEvent;
295
- class InsertImageEvent extends CustomEvent {
296
- constructor(handler) {
297
- super(InsertImageEvent.TYPE, {
298
- bubbles: true,
299
- detail: handler
300
- });
301
- this.handler = handler;
302
- }
303
- }
304
- InsertImageEvent.TYPE = 'insert.image';
305
- lib.InsertImageEvent = InsertImageEvent;
306
- var main = {};
307
- var toConsumableArray = {
308
- exports: {}
309
- };
310
- var arrayWithoutHoles = {
311
- exports: {}
312
- };
313
- var arrayLikeToArray = {
314
- exports: {}
315
- };
316
- (function (module) {
317
- function _arrayLikeToArray(arr, len) {
318
- if (len == null || len > arr.length) len = arr.length;
319
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
320
- arr2[i] = arr[i];
321
- }
322
- return arr2;
323
- }
324
- (module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports);
325
- })(arrayLikeToArray);
326
- getDefaultExportFromCjs(arrayLikeToArray.exports);
327
- (function (module) {
328
- var arrayLikeToArray$1 = arrayLikeToArray.exports;
329
- function _arrayWithoutHoles(arr) {
330
- if (Array.isArray(arr)) return arrayLikeToArray$1(arr);
331
- }
332
- (module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports);
333
- })(arrayWithoutHoles);
334
- getDefaultExportFromCjs(arrayWithoutHoles.exports);
335
- var iterableToArray = {
336
- exports: {}
337
- };
338
- (function (module) {
339
- function _iterableToArray(iter) {
340
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
341
- }
342
- (module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports);
343
- })(iterableToArray);
344
- getDefaultExportFromCjs(iterableToArray.exports);
345
- var unsupportedIterableToArray = {
346
- exports: {}
347
- };
348
- (function (module) {
349
- var arrayLikeToArray$1 = arrayLikeToArray.exports;
350
- function _unsupportedIterableToArray(o, minLen) {
351
- if (!o) return;
352
- if (typeof o === "string") return arrayLikeToArray$1(o, minLen);
353
- var n = Object.prototype.toString.call(o).slice(8, -1);
354
- if (n === "Object" && o.constructor) n = o.constructor.name;
355
- if (n === "Map" || n === "Set") return Array.from(o);
356
- if (n === "Arguments" || (/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/).test(n)) return arrayLikeToArray$1(o, minLen);
357
- }
358
- (module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports);
359
- })(unsupportedIterableToArray);
360
- getDefaultExportFromCjs(unsupportedIterableToArray.exports);
361
- var nonIterableSpread = {
362
- exports: {}
363
- };
364
- (function (module) {
365
- function _nonIterableSpread() {
366
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
367
- }
368
- (module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports);
369
- })(nonIterableSpread);
370
- getDefaultExportFromCjs(nonIterableSpread.exports);
371
- (function (module) {
372
- var arrayWithoutHoles$1 = arrayWithoutHoles.exports;
373
- var iterableToArray$1 = iterableToArray.exports;
374
- var unsupportedIterableToArray$1 = unsupportedIterableToArray.exports;
375
- var nonIterableSpread$1 = nonIterableSpread.exports;
376
- function _toConsumableArray(arr) {
377
- return arrayWithoutHoles$1(arr) || iterableToArray$1(arr) || unsupportedIterableToArray$1(arr) || nonIterableSpread$1();
378
- }
379
- (module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports);
380
- })(toConsumableArray);
381
- getDefaultExportFromCjs(toConsumableArray.exports);
382
- var ecrToolbar = {};
383
- const require$$8 = _dll_react;
384
- const require$$9$3 = _dll_prop_types;
385
- const require$$10$4 = _dll_material_ui__core_styles;
386
- const {OutlinedInput: require$$11$4} = _dll_material_ui__core;
387
- (function (exports) {
388
- var _interopRequireDefault = interopRequireDefault.exports;
389
- Object.defineProperty(exports, "__esModule", {
390
- value: true
391
- });
392
- exports["default"] = exports.ECRToolbar = void 0;
393
- var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
394
- var _createClass2 = _interopRequireDefault(createClass.exports);
395
- var _assertThisInitialized2 = _interopRequireDefault(assertThisInitialized.exports);
396
- var _inherits2 = _interopRequireDefault(inherits.exports);
397
- var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
398
- var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
399
- var _defineProperty2 = _interopRequireDefault(defineProperty.exports);
400
- var _react = _interopRequireDefault(require$$8);
401
- var _propTypes = _interopRequireDefault(require$$9$3);
402
- var _styles = require$$10$4;
403
- var _OutlinedInput = _interopRequireDefault(require$$11$4);
404
- function ownKeys(object, enumerableOnly) {
405
- var keys = Object.keys(object);
406
- if (Object.getOwnPropertySymbols) {
407
- var symbols = Object.getOwnPropertySymbols(object);
408
- (enumerableOnly && (symbols = symbols.filter(function (sym) {
409
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
410
- })), keys.push.apply(keys, symbols));
411
- }
412
- return keys;
413
- }
414
- function _objectSpread(target) {
415
- for (var i = 1; i < arguments.length; i++) {
416
- var source = null != arguments[i] ? arguments[i] : {};
417
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
418
- (0, _defineProperty2["default"])(target, key, source[key]);
419
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
420
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
421
- });
422
- }
423
- return target;
424
- }
425
- function _createSuper(Derived) {
426
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
427
- return function _createSuperInternal() {
428
- var Super = (0, _getPrototypeOf2["default"])(Derived), result;
429
- if (hasNativeReflectConstruct) {
430
- var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor;
431
- result = Reflect.construct(Super, arguments, NewTarget);
432
- } else {
433
- result = Super.apply(this, arguments);
434
- }
435
- return (0, _possibleConstructorReturn2["default"])(this, result);
436
- };
437
- }
438
- function _isNativeReflectConstruct() {
439
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
440
- if (Reflect.construct.sham) return false;
441
- if (typeof Proxy === "function") return true;
442
- try {
443
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
444
- return true;
445
- } catch (e) {
446
- return false;
447
- }
448
- }
449
- var findSlateNode = function findSlateNode(key) {
450
- return window.document.querySelector('[data-key="' + key + '"]');
451
- };
452
- var ECRToolbar = (function (_React$Component) {
453
- (0, _inherits2["default"])(ECRToolbar, _React$Component);
454
- var _super = _createSuper(ECRToolbar);
455
- function ECRToolbar() {
456
- var _this;
457
- (0, _classCallCheck2["default"])(this, ECRToolbar);
458
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
459
- args[_key] = arguments[_key];
460
- }
461
- _this = _super.call.apply(_super, [this].concat(args));
462
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
463
- markup: ''
464
- });
465
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDone", function () {
466
- var newValue = _this.state.markup;
467
- var _this$props = _this.props, node = _this$props.node, value = _this$props.value, onToolbarDone = _this$props.onToolbarDone, onChangeResponse = _this$props.onChangeResponse;
468
- var update = _objectSpread(_objectSpread({}, node.data.toJSON()), {}, {
469
- value: newValue
470
- });
471
- var change = value.change().setNodeByKey(node.key, {
472
- data: update
473
- });
474
- var nextText = value.document.getNextText(node.key);
475
- change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);
476
- onToolbarDone(change, true);
477
- onChangeResponse(newValue);
478
- });
479
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (e) {
480
- return _this.setState({
481
- markup: e.target.value
482
- });
483
- });
484
- return _this;
485
- }
486
- (0, _createClass2["default"])(ECRToolbar, [{
487
- key: "componentDidMount",
488
- value: function componentDidMount() {
489
- var _this$props2 = this.props, correctChoice = _this$props2.correctChoice, node = _this$props2.node;
490
- var choice = correctChoice || ({});
491
- var domNode = findSlateNode(node.key);
492
- if (domNode) {
493
- var domNodeRect = domNode.getBoundingClientRect();
494
- var editor = domNode.closest('[data-slate-editor]');
495
- var editorRect = editor.getBoundingClientRect();
496
- var top = domNodeRect.top - editorRect.top;
497
- var left = domNodeRect.left - editorRect.left;
498
- this.setState({
499
- markup: choice.label,
500
- toolbarStyle: {
501
- position: 'absolute',
502
- top: ("").concat(top + domNodeRect.height + 20, "px"),
503
- left: ("").concat(left + 20, "px"),
504
- width: domNodeRect.width
505
- }
506
- });
507
- }
508
- }
509
- }, {
510
- key: "render",
511
- value: function render() {
512
- var classes = this.props.classes;
513
- var _this$state = this.state, markup = _this$state.markup, toolbarStyle = _this$state.toolbarStyle;
514
- return _react["default"].createElement("div", {
515
- style: _objectSpread(_objectSpread({}, toolbarStyle), {}, {
516
- backgroundColor: '#E0E1E6'
517
- })
518
- }, _react["default"].createElement(_OutlinedInput["default"], {
519
- style: {
520
- width: '100%'
521
- },
522
- autoFocus: true,
523
- labelWidth: 0,
524
- classes: {
525
- input: classes.input
526
- },
527
- onChange: this.onChange,
528
- onBlur: this.onDone,
529
- value: markup || ''
530
- }));
531
- }
532
- }]);
533
- return ECRToolbar;
534
- })(_react["default"].Component);
535
- exports.ECRToolbar = ECRToolbar;
536
- (0, _defineProperty2["default"])(ECRToolbar, "propTypes", {
537
- correctChoice: _propTypes["default"].object,
538
- classes: _propTypes["default"].object,
539
- node: _propTypes["default"].object,
540
- onDone: _propTypes["default"].func,
541
- onChangeResponse: _propTypes["default"].func.isRequired,
542
- onToolbarDone: _propTypes["default"].func.isRequired,
543
- value: _propTypes["default"].shape({
544
- change: _propTypes["default"].func.isRequired,
545
- document: _propTypes["default"].shape({
546
- getNextText: _propTypes["default"].func.isRequired
547
- })
548
- })
549
- });
550
- var StyledECRToolbar = (0, _styles.withStyles)({
551
- respArea: {
552
- backgroundColor: '#fff'
553
- },
554
- input: {
555
- backgroundColor: '#fff',
556
- padding: '10px 20px 10px 10px'
557
- }
558
- })(ECRToolbar);
559
- var _default = StyledECRToolbar;
560
- exports["default"] = _default;
561
- })(ecrToolbar);
562
- getDefaultExportFromCjs(ecrToolbar);
563
- var alternateResponses = {};
564
- var alternateSection = {};
565
- var markupUtils = {};
566
- const {escape: require$$1} = _dll_lodash;
567
- var _interopRequireDefault = interopRequireDefault.exports;
568
- Object.defineProperty(markupUtils, "__esModule", {
569
- value: true
570
- });
571
- markupUtils.removeUnwantedCharacters = markupUtils.processMarkup = markupUtils.getAdjustedLength = markupUtils.createSlateMarkup = void 0;
572
- var _escape = _interopRequireDefault(require$$1);
573
- var tSymbols = 'imes|riangle|an|heta|herefore';
574
- var nSymbols = 'throot|parallel|cong|approx|eq|e|sim';
575
- var matchTabAndNewLine = new RegExp(("(\\t(?!").concat(tSymbols, "))|(\\n(?!").concat(nSymbols, "))|(\\\\t(?!").concat(tSymbols, "))|(\\\\n(?!").concat(nSymbols, "))"), 'g');
576
- var removeUnwantedCharacters = function removeUnwantedCharacters(markup) {
577
- return markup.replace(matchTabAndNewLine, '').replace(/\\"/g, '"').replace(/\\\//g, '/');
578
- };
579
- markupUtils.removeUnwantedCharacters = removeUnwantedCharacters;
580
- var createElementFromHTML = function createElementFromHTML() {
581
- var htmlString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
582
- var div = document.createElement('div');
583
- div.innerHTML = htmlString.trim();
584
- return div;
585
- };
586
- var processMarkup = function processMarkup(markup) {
587
- var newMarkup = removeUnwantedCharacters(markup || '');
588
- var slateMarkup = createElementFromHTML(newMarkup || '');
589
- var index = 0;
590
- slateMarkup.querySelectorAll('[data-type="explicit_constructed_response"]').forEach(function (s) {
591
- s.replaceWith(("{{").concat(index++, "}}"));
592
- });
593
- return slateMarkup.innerHTML;
594
- };
595
- markupUtils.processMarkup = processMarkup;
596
- var REGEX = /\{\{(\d+)\}\}/g;
597
- var createSlateMarkup = function createSlateMarkup(markup, choices) {
598
- if (!markup) {
599
- return '';
600
- }
601
- var newMarkup = removeUnwantedCharacters(markup);
602
- return newMarkup.replace(REGEX, function (match, g) {
603
- var label = choices[g][0].label || '';
604
- return ("<span data-type=\"explicit_constructed_response\" data-index=\"").concat(g, "\" data-value=\"").concat((0, _escape["default"])(label), "\"></span>");
605
- });
606
- };
607
- markupUtils.createSlateMarkup = createSlateMarkup;
608
- var getAdjustedLength = function getAdjustedLength(length) {
609
- if (length <= 2) {
610
- return length + 2;
611
- }
612
- if (length <= 4) {
613
- return length + 3;
614
- }
615
- if (length <= 6) {
616
- return length + 4;
617
- }
618
- return length + 5;
619
- };
620
- markupUtils.getAdjustedLength = getAdjustedLength;
621
- const require$$9$2 = _dll_react;
622
- const require$$10$3 = _dll_prop_types;
623
- const {debounce: require$$11$3} = _dll_lodash;
624
- const {isEqual: require$$12$3} = _dll_lodash;
625
- const {max: require$$21} = _dll_lodash;
626
- const {OutlinedInput: require$$13$3} = _dll_material_ui__core;
627
- const {Button: require$$14$2} = _dll_material_ui__core;
628
- const {IconButton: require$$16$1} = _dll_material_ui__core;
629
- const {MenuItem: require$$17$1} = _dll_material_ui__core;
630
- const {Select: require$$18$1} = _dll_material_ui__core;
631
- const {TextField: require$$19$1} = _dll_material_ui__core;
632
- const {Delete: require$$15$1} = _dll_material_ui__icons;
633
- const require$$20 = _dll_material_ui__core_styles;
634
- (function (exports) {
635
- var _interopRequireDefault = interopRequireDefault.exports;
636
- Object.defineProperty(exports, "__esModule", {
637
- value: true
638
- });
639
- exports["default"] = exports.Choice = exports.AlternateSection = void 0;
640
- var _toConsumableArray2 = _interopRequireDefault(toConsumableArray.exports);
641
- var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
642
- var _createClass2 = _interopRequireDefault(createClass.exports);
643
- var _assertThisInitialized2 = _interopRequireDefault(assertThisInitialized.exports);
644
- var _inherits2 = _interopRequireDefault(inherits.exports);
645
- var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
646
- var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
647
- var _defineProperty2 = _interopRequireDefault(defineProperty.exports);
648
- var _react = _interopRequireDefault(require$$9$2);
649
- var _propTypes = _interopRequireDefault(require$$10$3);
650
- var _debounce = _interopRequireDefault(require$$11$3);
651
- var _isEqual = _interopRequireDefault(require$$12$3);
652
- var _OutlinedInput = _interopRequireDefault(require$$13$3);
653
- var _Button = _interopRequireDefault(require$$14$2);
654
- var _Delete = _interopRequireDefault(require$$15$1);
655
- var _IconButton = _interopRequireDefault(require$$16$1);
656
- var _MenuItem = _interopRequireDefault(require$$17$1);
657
- var _Select = _interopRequireDefault(require$$18$1);
658
- var _TextField = _interopRequireDefault(require$$19$1);
659
- var _styles = require$$20;
660
- var _max = _interopRequireDefault(require$$21);
661
- var _markupUtils = markupUtils;
662
- function ownKeys(object, enumerableOnly) {
663
- var keys = Object.keys(object);
664
- if (Object.getOwnPropertySymbols) {
665
- var symbols = Object.getOwnPropertySymbols(object);
666
- (enumerableOnly && (symbols = symbols.filter(function (sym) {
667
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
668
- })), keys.push.apply(keys, symbols));
669
- }
670
- return keys;
671
- }
672
- function _objectSpread(target) {
673
- for (var i = 1; i < arguments.length; i++) {
674
- var source = null != arguments[i] ? arguments[i] : {};
675
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
676
- (0, _defineProperty2["default"])(target, key, source[key]);
677
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
678
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
679
- });
680
- }
681
- return target;
682
- }
683
- function _createSuper(Derived) {
684
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
685
- return function _createSuperInternal() {
686
- var Super = (0, _getPrototypeOf2["default"])(Derived), result;
687
- if (hasNativeReflectConstruct) {
688
- var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor;
689
- result = Reflect.construct(Super, arguments, NewTarget);
690
- } else {
691
- result = Super.apply(this, arguments);
692
- }
693
- return (0, _possibleConstructorReturn2["default"])(this, result);
694
- };
695
- }
696
- function _isNativeReflectConstruct() {
697
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
698
- if (Reflect.construct.sham) return false;
699
- if (typeof Proxy === "function") return true;
700
- try {
701
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
702
- return true;
703
- } catch (e) {
704
- return false;
705
- }
706
- }
707
- var styles = function styles() {
708
- return {
709
- altChoices: {
710
- alignItems: 'flex-start',
711
- flexDirection: 'column',
712
- display: 'flex',
713
- padding: '20px 0 0 0',
714
- '& > *': {
715
- marginBottom: '20px',
716
- width: '100%'
717
- }
718
- },
719
- choice: {
720
- flex: '1',
721
- marginRight: '20px'
722
- },
723
- deleteBtn: {
724
- fill: 'gray'
725
- },
726
- selectContainer: {
727
- alignItems: 'flex-end',
728
- display: 'flex',
729
- justifyContent: 'space-between',
730
- width: '100%'
731
- },
732
- rightContainer: {
733
- alignItems: 'center',
734
- display: 'flex'
735
- },
736
- lengthField: {
737
- width: '230px',
738
- marginRight: '20px'
739
- }
740
- };
741
- };
742
- var Choice = (function (_React$Component) {
743
- (0, _inherits2["default"])(Choice, _React$Component);
744
- var _super = _createSuper(Choice);
745
- function Choice() {
746
- var _this;
747
- (0, _classCallCheck2["default"])(this, Choice);
748
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
749
- args[_key] = arguments[_key];
750
- }
751
- _this = _super.call.apply(_super, [this].concat(args));
752
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
753
- value: _this.props.markup
754
- });
755
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateText", (0, _debounce["default"])(_this.props.onChange, 300));
756
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (e) {
757
- var value = e.target.value;
758
- _this.setState({
759
- value: value
760
- });
761
- _this.updateText(value);
762
- });
763
- return _this;
764
- }
765
- (0, _createClass2["default"])(Choice, [{
766
- key: "UNSAFE_componentWillReceiveProps",
767
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
768
- if (nextProps.markup) {
769
- this.setState({
770
- value: nextProps.markup
771
- });
772
- }
773
- }
774
- }, {
775
- key: "render",
776
- value: function render() {
777
- var value = this.state.value;
778
- var _this$props = this.props, classes = _this$props.classes, onDelete = _this$props.onDelete, spellCheck = _this$props.spellCheck;
779
- return _react["default"].createElement("div", {
780
- style: {
781
- alignItems: 'center',
782
- display: 'flex',
783
- justifyContent: 'space-between'
784
- }
785
- }, _react["default"].createElement(_OutlinedInput["default"], {
786
- className: classes.choice,
787
- value: value,
788
- onChange: this.onChange,
789
- labelWidth: 0,
790
- disableUnderline: true,
791
- spellCheck: spellCheck
792
- }), _react["default"].createElement(_IconButton["default"], {
793
- "aria-label": "delete",
794
- className: classes.deleteBtn,
795
- onClick: onDelete
796
- }, _react["default"].createElement(_Delete["default"], null)));
797
- }
798
- }]);
799
- return Choice;
800
- })(_react["default"].Component);
801
- exports.Choice = Choice;
802
- (0, _defineProperty2["default"])(Choice, "propTypes", {
803
- classes: _propTypes["default"].object,
804
- markup: _propTypes["default"].string,
805
- onChange: _propTypes["default"].func.isRequired,
806
- onDelete: _propTypes["default"].func.isRequired,
807
- value: _propTypes["default"].string
808
- });
809
- var AlternateSection = (function (_React$Component2) {
810
- (0, _inherits2["default"])(AlternateSection, _React$Component2);
811
- var _super2 = _createSuper(AlternateSection);
812
- function AlternateSection() {
813
- var _this2;
814
- (0, _classCallCheck2["default"])(this, AlternateSection);
815
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
816
- args[_key2] = arguments[_key2];
817
- }
818
- _this2 = _super2.call.apply(_super2, [this].concat(args));
819
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "state", {});
820
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "updateChoicesIfNeeded", function (props) {
821
- if (!_this2.state.choices || !(0, _isEqual["default"])(props.choices, _this2.state.choices) || !(0, _isEqual["default"])(props.choices, _this2.props.choices)) {
822
- _this2.setState({
823
- choices: props.choices
824
- });
825
- }
826
- });
827
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "handleSelect", function (e) {
828
- var _this2$props = _this2.props, onSelect = _this2$props.onSelect, selectChoices = _this2$props.selectChoices;
829
- var value = e.target.value;
830
- onSelect(selectChoices.find(function (c) {
831
- return c.value === value;
832
- }));
833
- });
834
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "onAddChoice", function () {
835
- var choices = _this2.state.choices;
836
- if (choices.length && choices[choices.length - 1].label !== '') {
837
- var value = (0, _max["default"])(choices.map(function (c) {
838
- return parseInt(c.value);
839
- }).filter(function (id) {
840
- return !isNaN(id);
841
- })) || 0;
842
- _this2.setState({
843
- choices: [].concat((0, _toConsumableArray2["default"])(choices), [{
844
- value: ("").concat(value + 1),
845
- label: ''
846
- }])
847
- });
848
- }
849
- });
850
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "onChoiceChanged", function (choice, value, index) {
851
- var _this2$props2 = _this2.props, choiceChanged = _this2$props2.choiceChanged, lengthChanged = _this2$props2.lengthChanged, maxLength = _this2$props2.maxLength, choices = _this2$props2.choices;
852
- var labelLengthsArr = choices.map(function (choice) {
853
- return (choice.label || '').length;
854
- });
855
- labelLengthsArr[index] = value.length;
856
- var newLength = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
857
- choiceChanged(_objectSpread(_objectSpread({}, choice), {}, {
858
- label: value
859
- }));
860
- if (newLength > maxLength || newLength + 10 <= maxLength) {
861
- lengthChanged((0, _markupUtils.getAdjustedLength)(newLength));
862
- }
863
- });
864
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "onRemoveChoice", function (choice) {
865
- var choiceRemoved = _this2.props.choiceRemoved;
866
- choiceRemoved(choice.value);
867
- });
868
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "getChoicesMaxLength", function () {
869
- var choices = _this2.state.choices;
870
- if (!choices) {
871
- return 1;
872
- }
873
- var labelLengthsArr = choices.map(function (choice) {
874
- return (choice.label || '').length;
875
- });
876
- return Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
877
- });
878
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "changeLength", function (event) {
879
- var lengthChanged = _this2.props.lengthChanged;
880
- var numberValue = parseInt(event.target.value, 10);
881
- var minLength = _this2.getChoicesMaxLength();
882
- if (numberValue && numberValue >= minLength && numberValue <= minLength + 10) {
883
- lengthChanged(numberValue);
884
- }
885
- });
886
- return _this2;
887
- }
888
- (0, _createClass2["default"])(AlternateSection, [{
889
- key: "UNSAFE_componentWillReceiveProps",
890
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
891
- this.updateChoicesIfNeeded(nextProps);
892
- }
893
- }, {
894
- key: "componentDidMount",
895
- value: function componentDidMount() {
896
- this.updateChoicesIfNeeded(this.props);
897
- }
898
- }, {
899
- key: "render",
900
- value: function render() {
901
- var _this3 = this;
902
- var _this$props2 = this.props, classes = _this$props2.classes, selectChoices = _this$props2.selectChoices, maxLength = _this$props2.maxLength, showMaxLength = _this$props2.showMaxLength, value = _this$props2.value, spellCheck = _this$props2.spellCheck;
903
- var choices = this.state.choices;
904
- var minLength = this.getChoicesMaxLength();
905
- return _react["default"].createElement("div", {
906
- className: classes.design
907
- }, _react["default"].createElement("div", {
908
- className: classes.selectContainer
909
- }, _react["default"].createElement(_Select["default"], {
910
- className: classes.select,
911
- displayEmpty: true,
912
- onChange: this.handleSelect,
913
- value: value || '',
914
- readOnly: showMaxLength
915
- }, _react["default"].createElement(_MenuItem["default"], {
916
- value: ""
917
- }, _react["default"].createElement("em", null, value ? 'Remove selection' : 'Select a response')), selectChoices.map(function (c, index) {
918
- return _react["default"].createElement(_MenuItem["default"], {
919
- key: index,
920
- value: c.value
921
- }, c.label);
922
- })), choices && choices.length > 0 && _react["default"].createElement("div", {
923
- className: classes.rightContainer
924
- }, maxLength && showMaxLength && _react["default"].createElement(_TextField["default"], {
925
- className: classes.lengthField,
926
- label: "Maximum length (characters)",
927
- type: "number",
928
- inputProps: {
929
- min: minLength,
930
- max: minLength + 10
931
- },
932
- value: maxLength,
933
- onChange: this.changeLength
934
- }), _react["default"].createElement(_Button["default"], {
935
- className: classes.addButton,
936
- variant: "contained",
937
- color: "primary",
938
- onClick: this.onAddChoice
939
- }, "Add"))), _react["default"].createElement("div", {
940
- className: classes.altChoices
941
- }, choices && choices.map(function (c, index) {
942
- return index > 0 && _react["default"].createElement(Choice, {
943
- key: index,
944
- classes: classes,
945
- markup: c.label,
946
- onChange: function onChange(val) {
947
- return _this3.onChoiceChanged(c, val, index);
948
- },
949
- onDelete: function onDelete() {
950
- return _this3.onRemoveChoice(c);
951
- },
952
- spellCheck: spellCheck
953
- });
954
- })));
955
- }
956
- }]);
957
- return AlternateSection;
958
- })(_react["default"].Component);
959
- exports.AlternateSection = AlternateSection;
960
- (0, _defineProperty2["default"])(AlternateSection, "propTypes", {
961
- choices: _propTypes["default"].array,
962
- selectChoices: _propTypes["default"].array.isRequired,
963
- classes: _propTypes["default"].object.isRequired,
964
- onSelect: _propTypes["default"].func.isRequired,
965
- choiceChanged: _propTypes["default"].func.isRequired,
966
- lengthChanged: _propTypes["default"].func,
967
- choiceRemoved: _propTypes["default"].func.isRequired,
968
- value: _propTypes["default"].string,
969
- maxLength: _propTypes["default"].number,
970
- showMaxLength: _propTypes["default"].bool
971
- });
972
- var Styled = (0, _styles.withStyles)(styles)(AlternateSection);
973
- var _default = Styled;
974
- exports["default"] = _default;
975
- })(alternateSection);
976
- getDefaultExportFromCjs(alternateSection);
977
- const require$$9$1 = _dll_react;
978
- const require$$10$2 = _dll_prop_types;
979
- const {isEqual: require$$11$2} = _dll_lodash;
980
- const {map: require$$12$2} = _dll_lodash;
981
- const {reduce: require$$13$2} = _dll_lodash;
982
- const {cloneDeep: require$$14$1} = _dll_lodash;
983
- (function (exports) {
984
- var _interopRequireDefault = interopRequireDefault.exports;
985
- Object.defineProperty(exports, "__esModule", {
986
- value: true
987
- });
988
- exports["default"] = exports.AlternateResponses = void 0;
989
- var _toConsumableArray2 = _interopRequireDefault(toConsumableArray.exports);
990
- var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
991
- var _createClass2 = _interopRequireDefault(createClass.exports);
992
- var _assertThisInitialized2 = _interopRequireDefault(assertThisInitialized.exports);
993
- var _inherits2 = _interopRequireDefault(inherits.exports);
994
- var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
995
- var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
996
- var _defineProperty2 = _interopRequireDefault(defineProperty.exports);
997
- var _react = _interopRequireDefault(require$$9$1);
998
- var _propTypes = _interopRequireDefault(require$$10$2);
999
- var _isEqual = _interopRequireDefault(require$$11$2);
1000
- var _map = _interopRequireDefault(require$$12$2);
1001
- var _reduce = _interopRequireDefault(require$$13$2);
1002
- var _cloneDeep = _interopRequireDefault(require$$14$1);
1003
- var _alternateSection = _interopRequireDefault(alternateSection);
1004
- function ownKeys(object, enumerableOnly) {
1005
- var keys = Object.keys(object);
1006
- if (Object.getOwnPropertySymbols) {
1007
- var symbols = Object.getOwnPropertySymbols(object);
1008
- (enumerableOnly && (symbols = symbols.filter(function (sym) {
1009
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1010
- })), keys.push.apply(keys, symbols));
1011
- }
1012
- return keys;
1013
- }
1014
- function _objectSpread(target) {
1015
- for (var i = 1; i < arguments.length; i++) {
1016
- var source = null != arguments[i] ? arguments[i] : {};
1017
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1018
- (0, _defineProperty2["default"])(target, key, source[key]);
1019
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1020
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1021
- });
1022
- }
1023
- return target;
1024
- }
1025
- function _createSuper(Derived) {
1026
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
1027
- return function _createSuperInternal() {
1028
- var Super = (0, _getPrototypeOf2["default"])(Derived), result;
1029
- if (hasNativeReflectConstruct) {
1030
- var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor;
1031
- result = Reflect.construct(Super, arguments, NewTarget);
1032
- } else {
1033
- result = Super.apply(this, arguments);
1034
- }
1035
- return (0, _possibleConstructorReturn2["default"])(this, result);
1036
- };
1037
- }
1038
- function _isNativeReflectConstruct() {
1039
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1040
- if (Reflect.construct.sham) return false;
1041
- if (typeof Proxy === "function") return true;
1042
- try {
1043
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1044
- return true;
1045
- } catch (e) {
1046
- return false;
1047
- }
1048
- }
1049
- var AlternateResponses = (function (_React$Component) {
1050
- (0, _inherits2["default"])(AlternateResponses, _React$Component);
1051
- var _super = _createSuper(AlternateResponses);
1052
- function AlternateResponses() {
1053
- var _this;
1054
- (0, _classCallCheck2["default"])(this, AlternateResponses);
1055
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1056
- args[_key] = arguments[_key];
1057
- }
1058
- _this = _super.call.apply(_super, [this].concat(args));
1059
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
1060
- maxLengthPerChoice: (0, _cloneDeep["default"])(_this.props.model.maxLengthPerChoice)
1061
- });
1062
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateChoicesIfNeeded", function (props) {
1063
- if (!_this.state.choices || !(0, _isEqual["default"])(_this.state.choices, props.model.choices) || !(0, _isEqual["default"])(props.model.choices, _this.props.model.choices) || _this.state.values && Object.keys(_this.state.values).length !== Object.keys(_this.props.model.choices).length || props.maxLengthPerChoiceEnabled !== _this.props.maxLengthPerChoiceEnabled) {
1064
- var _props$model = props.model, choices = _props$model.choices, maxLengthPerChoice = _props$model.maxLengthPerChoice;
1065
- var selectedValues = (0, _reduce["default"])(choices, function (obj, c, key) {
1066
- if (c && (props.maxLengthPerChoiceEnabled || c.length > 1)) {
1067
- obj[key] = c[0];
1068
- }
1069
- return obj;
1070
- }, {});
1071
- _this.setState({
1072
- choices: props.model.choices,
1073
- values: selectedValues,
1074
- maxLengthPerChoice: (0, _cloneDeep["default"])(maxLengthPerChoice)
1075
- });
1076
- }
1077
- });
1078
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getRemainingChoices", function (valueKey) {
1079
- var choices = _this.state.choices;
1080
- return (0, _reduce["default"])(choices, function (arr, c, key) {
1081
- if (c && c.length === 1 && !valueKey) {
1082
- arr.push({
1083
- label: c[0].label,
1084
- value: key
1085
- });
1086
- }
1087
- return arr;
1088
- }, []);
1089
- });
1090
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (choice, key) {
1091
- var onChange = _this.props.onChange;
1092
- var choices = _this.state.choices;
1093
- var sectionChoices = choices[key] || [];
1094
- var isNew = !sectionChoices.find(function (c) {
1095
- return c.value === choice.value;
1096
- });
1097
- var newChoices = sectionChoices.reduce(function (arr, c) {
1098
- var newVal = c.value === choice.value ? choice : c;
1099
- arr.push(newVal);
1100
- return arr;
1101
- }, []);
1102
- if (isNew) {
1103
- newChoices.push(choice);
1104
- }
1105
- onChange(_objectSpread(_objectSpread({}, choices), {}, (0, _defineProperty2["default"])({}, key, newChoices)));
1106
- });
1107
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceRemoved", function (value, section) {
1108
- var onChange = _this.props.onChange;
1109
- var choices = _this.state.choices;
1110
- var sectionChoices = choices[section] || [];
1111
- var newChoices = sectionChoices.reduce(function (arr, c) {
1112
- if (c.value === value) {
1113
- return arr;
1114
- }
1115
- arr.push(c);
1116
- return arr;
1117
- }, []);
1118
- onChange(_objectSpread(_objectSpread({}, choices), {}, (0, _defineProperty2["default"])({}, section, newChoices)));
1119
- });
1120
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSectionSelect", function (choice, key) {
1121
- var onChange = _this.props.onChange;
1122
- var _this$state = _this.state, choices = _this$state.choices, values = _this$state.values;
1123
- if (choices[key] && choices[key].length > 1) {
1124
- if (!choice) {
1125
- onChange(_objectSpread(_objectSpread({}, choices), {}, (0, _defineProperty2["default"])({}, key, [choices[key][0]])));
1126
- }
1127
- } else {
1128
- _this.setState({
1129
- choices: _objectSpread(_objectSpread({}, choices), {}, (0, _defineProperty2["default"])({}, key, [].concat((0, _toConsumableArray2["default"])(choices[key]), [{
1130
- label: '',
1131
- value: '1'
1132
- }]))),
1133
- values: _objectSpread(_objectSpread({}, values), {}, (0, _defineProperty2["default"])({}, key, choices[key][0]))
1134
- });
1135
- }
1136
- });
1137
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLengthChanged", function (value, key) {
1138
- var _this$props = _this.props, model = _this$props.model, onLengthChange = _this$props.onLengthChange;
1139
- var maxLengthPerChoice = model.maxLengthPerChoice;
1140
- maxLengthPerChoice[key] = value;
1141
- onLengthChange(maxLengthPerChoice);
1142
- });
1143
- return _this;
1144
- }
1145
- (0, _createClass2["default"])(AlternateResponses, [{
1146
- key: "UNSAFE_componentWillReceiveProps",
1147
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
1148
- this.updateChoicesIfNeeded(nextProps);
1149
- }
1150
- }, {
1151
- key: "componentDidMount",
1152
- value: function componentDidMount() {
1153
- this.updateChoicesIfNeeded(this.props);
1154
- }
1155
- }, {
1156
- key: "render",
1157
- value: function render() {
1158
- var _this2 = this;
1159
- var choices = this.state.choices;
1160
- var _this$props2 = this.props, _this$props2$model = _this$props2.model, maxLengthPerChoice = _this$props2$model.maxLengthPerChoice, maxLengthPerChoiceEnabled = _this$props2$model.maxLengthPerChoiceEnabled, spellCheck = _this$props2.spellCheck;
1161
- return _react["default"].createElement("div", null, (0, _map["default"])(choices, function (c, key) {
1162
- if (c && (maxLengthPerChoiceEnabled || c.length > 1)) {
1163
- var selected = _this2.state.values[key];
1164
- return _react["default"].createElement(_alternateSection["default"], {
1165
- key: key,
1166
- value: selected && selected.value,
1167
- onSelect: function onSelect(choice) {
1168
- return _this2.onSectionSelect(choice, key);
1169
- },
1170
- choiceChanged: function choiceChanged(choice) {
1171
- return _this2.onChoiceChanged(choice, key);
1172
- },
1173
- choiceRemoved: function choiceRemoved(value) {
1174
- return _this2.onChoiceRemoved(value, key);
1175
- },
1176
- lengthChanged: function lengthChanged(value) {
1177
- return _this2.onLengthChanged(value, key);
1178
- },
1179
- selectChoices: [selected],
1180
- choices: c,
1181
- maxLength: maxLengthPerChoice[key],
1182
- showMaxLength: maxLengthPerChoiceEnabled,
1183
- spellCheck: spellCheck
1184
- });
1185
- }
1186
- }), choices && Object.keys(this.state.values).length !== Object.keys(choices).length && _react["default"].createElement(_alternateSection["default"], {
1187
- value: "",
1188
- onSelect: function onSelect(choice) {
1189
- return _this2.onSectionSelect(choice, choice.value);
1190
- },
1191
- choiceChanged: function choiceChanged(choice) {
1192
- return _this2.onChoiceChanged(choice);
1193
- },
1194
- choiceRemoved: function choiceRemoved(value) {
1195
- return _this2.onChoiceRemoved(value);
1196
- },
1197
- selectChoices: this.getRemainingChoices(),
1198
- spellCheck: spellCheck
1199
- }));
1200
- }
1201
- }]);
1202
- return AlternateResponses;
1203
- })(_react["default"].Component);
1204
- exports.AlternateResponses = AlternateResponses;
1205
- (0, _defineProperty2["default"])(AlternateResponses, "propTypes", {
1206
- model: _propTypes["default"].object.isRequired,
1207
- onChange: _propTypes["default"].func.isRequired,
1208
- onLengthChange: _propTypes["default"].func.isRequired,
1209
- maxLengthPerChoiceEnabled: _propTypes["default"].bool.isRequired
1210
- });
1211
- var _default = AlternateResponses;
1212
- exports["default"] = _default;
1213
- })(alternateResponses);
1214
- getDefaultExportFromCjs(alternateResponses);
1215
- const require$$10$1 = _dll_react;
1216
- const require$$11$1 = _dll_prop_types;
1217
- const {cloneDeep: require$$12$1} = _dll_lodash;
1218
- const {isEmpty: require$$13$1} = _dll_lodash;
1219
- const {pick: require$$14} = _dll_lodash;
1220
- const {throttle: require$$15} = _dll_lodash;
1221
- const require$$18 = _dll_material_ui__core_styles;
1222
- const {Typography: require$$19} = _dll_material_ui__core;
1223
- const require$$16 = _dll_pie_lib__editable_html;
1224
- const require$$17 = _dll_pie_lib__config_ui;
1225
- (function (exports) {
1226
- var _interopRequireDefault = interopRequireDefault.exports;
1227
- var _typeof$1 = _typeof.exports;
1228
- Object.defineProperty(exports, "__esModule", {
1229
- value: true
1230
- });
1231
- exports["default"] = exports.Main = void 0;
1232
- var _toConsumableArray2 = _interopRequireDefault(toConsumableArray.exports);
1233
- var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
1234
- var _createClass2 = _interopRequireDefault(createClass.exports);
1235
- var _assertThisInitialized2 = _interopRequireDefault(assertThisInitialized.exports);
1236
- var _inherits2 = _interopRequireDefault(inherits.exports);
1237
- var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
1238
- var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
1239
- var _defineProperty2 = _interopRequireDefault(defineProperty.exports);
1240
- var _react = _interopRequireDefault(require$$10$1);
1241
- var _propTypes = _interopRequireDefault(require$$11$1);
1242
- var _cloneDeep = _interopRequireDefault(require$$12$1);
1243
- var _isEmpty = _interopRequireDefault(require$$13$1);
1244
- var _pick = _interopRequireDefault(require$$14);
1245
- var _throttle = _interopRequireDefault(require$$15);
1246
- var _editableHtml = _interopRequireWildcard(require$$16);
1247
- var _configUi = require$$17;
1248
- var _styles = require$$18;
1249
- var _Typography = _interopRequireDefault(require$$19);
1250
- var _ecrToolbar = _interopRequireDefault(ecrToolbar);
1251
- var _alternateResponses = _interopRequireDefault(alternateResponses);
1252
- var _markupUtils = markupUtils;
1253
- function _getRequireWildcardCache(nodeInterop) {
1254
- if (typeof WeakMap !== "function") return null;
1255
- var cacheBabelInterop = new WeakMap();
1256
- var cacheNodeInterop = new WeakMap();
1257
- return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
1258
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
1259
- })(nodeInterop);
1260
- }
1261
- function _interopRequireWildcard(obj, nodeInterop) {
1262
- if (!nodeInterop && obj && obj.__esModule) {
1263
- return obj;
1264
- }
1265
- if (obj === null || _typeof$1(obj) !== "object" && typeof obj !== "function") {
1266
- return {
1267
- "default": obj
1268
- };
1269
- }
1270
- var cache = _getRequireWildcardCache(nodeInterop);
1271
- if (cache && cache.has(obj)) {
1272
- return cache.get(obj);
1273
- }
1274
- var newObj = {};
1275
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
1276
- for (var key in obj) {
1277
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
1278
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
1279
- if (desc && (desc.get || desc.set)) {
1280
- Object.defineProperty(newObj, key, desc);
1281
- } else {
1282
- newObj[key] = obj[key];
1283
- }
1284
- }
1285
- }
1286
- newObj["default"] = obj;
1287
- if (cache) {
1288
- cache.set(obj, newObj);
1289
- }
1290
- return newObj;
1291
- }
1292
- function ownKeys(object, enumerableOnly) {
1293
- var keys = Object.keys(object);
1294
- if (Object.getOwnPropertySymbols) {
1295
- var symbols = Object.getOwnPropertySymbols(object);
1296
- (enumerableOnly && (symbols = symbols.filter(function (sym) {
1297
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1298
- })), keys.push.apply(keys, symbols));
1299
- }
1300
- return keys;
1301
- }
1302
- function _objectSpread(target) {
1303
- for (var i = 1; i < arguments.length; i++) {
1304
- var source = null != arguments[i] ? arguments[i] : {};
1305
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1306
- (0, _defineProperty2["default"])(target, key, source[key]);
1307
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1308
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1309
- });
1310
- }
1311
- return target;
1312
- }
1313
- function _createSuper(Derived) {
1314
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
1315
- return function _createSuperInternal() {
1316
- var Super = (0, _getPrototypeOf2["default"])(Derived), result;
1317
- if (hasNativeReflectConstruct) {
1318
- var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor;
1319
- result = Reflect.construct(Super, arguments, NewTarget);
1320
- } else {
1321
- result = Super.apply(this, arguments);
1322
- }
1323
- return (0, _possibleConstructorReturn2["default"])(this, result);
1324
- };
1325
- }
1326
- function _isNativeReflectConstruct() {
1327
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1328
- if (Reflect.construct.sham) return false;
1329
- if (typeof Proxy === "function") return true;
1330
- try {
1331
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1332
- return true;
1333
- } catch (e) {
1334
- return false;
1335
- }
1336
- }
1337
- var toggle = _configUi.settings.toggle, Panel = _configUi.settings.Panel;
1338
- var styles = function styles(theme) {
1339
- return {
1340
- promptHolder: {
1341
- width: '100%',
1342
- paddingBottom: theme.spacing.unit * 2,
1343
- marginBottom: theme.spacing.unit * 2
1344
- },
1345
- prompt: {
1346
- paddingTop: theme.spacing.unit * 2,
1347
- width: '100%'
1348
- },
1349
- markup: {
1350
- minHeight: '100px',
1351
- paddingTop: theme.spacing.unit * 2,
1352
- width: '100%',
1353
- '& [data-slate-editor="true"]': {
1354
- minHeight: '100px'
1355
- }
1356
- },
1357
- design: {
1358
- paddingTop: theme.spacing.unit * 3
1359
- },
1360
- choiceConfiguration: {
1361
- paddingTop: theme.spacing.unit * 2,
1362
- paddingBottom: theme.spacing.unit * 2
1363
- },
1364
- switchElement: {
1365
- justifyContent: 'space-between',
1366
- margin: 0
1367
- },
1368
- addButton: {
1369
- "float": 'right'
1370
- },
1371
- text: {
1372
- color: '#495B8F',
1373
- fontFamily: 'Cerebri Sans',
1374
- fontSize: '16px',
1375
- lineHeight: '19px',
1376
- marginTop: theme.spacing.unit * 4
1377
- }
1378
- };
1379
- };
1380
- var createElementFromHTML = function createElementFromHTML(htmlString) {
1381
- var div = document.createElement('div');
1382
- div.innerHTML = htmlString.trim();
1383
- return div;
1384
- };
1385
- var Main = (function (_React$Component) {
1386
- (0, _inherits2["default"])(Main, _React$Component);
1387
- var _super = _createSuper(Main);
1388
- function Main() {
1389
- var _this;
1390
- (0, _classCallCheck2["default"])(this, Main);
1391
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1392
- args[_key] = arguments[_key];
1393
- }
1394
- _this = _super.call.apply(_super, [this].concat(args));
1395
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {});
1396
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChange", function (newVal) {
1397
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), newVal));
1398
- });
1399
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
1400
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
1401
- prompt: prompt
1402
- }));
1403
- });
1404
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
1405
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
1406
- rationale: rationale
1407
- }));
1408
- });
1409
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
1410
- var _this$props = _this.props, model = _this$props.model, onModelChanged = _this$props.onModelChanged;
1411
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
1412
- teacherInstructions: teacherInstructions
1413
- }));
1414
- });
1415
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMarkupChanged", function (slateMarkup) {
1416
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
1417
- slateMarkup: slateMarkup
1418
- }));
1419
- });
1420
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onResponsesChanged", function (choices) {
1421
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
1422
- choices: choices
1423
- }));
1424
- });
1425
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLengthChanged", function (maxLengthPerChoice) {
1426
- var _this$props2 = _this.props, model = _this$props2.model, onModelChanged = _this$props2.onModelChanged;
1427
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
1428
- maxLengthPerChoice: maxLengthPerChoice
1429
- }));
1430
- });
1431
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeResponse", function (index, newVal) {
1432
- var _this$props3 = _this.props, model = _this$props3.model, onModelChanged = _this$props3.onModelChanged;
1433
- var choices = model.choices;
1434
- var maxLengthPerChoice = model.maxLengthPerChoice;
1435
- var newValLength = (newVal || '').length;
1436
- if (!choices[index]) {
1437
- choices[index] = [{
1438
- label: newVal || '',
1439
- value: '0'
1440
- }];
1441
- var nbOfMissingChoices = index > maxLengthPerChoice.length ? index - maxLengthPerChoice.length : 0;
1442
- maxLengthPerChoice = [].concat((0, _toConsumableArray2["default"])(maxLengthPerChoice), (0, _toConsumableArray2["default"])(Array(nbOfMissingChoices).fill(1)));
1443
- maxLengthPerChoice.splice(index, 0, (0, _markupUtils.getAdjustedLength)(newValLength));
1444
- } else {
1445
- choices[index][0].label = newVal || '';
1446
- if (maxLengthPerChoice && (maxLengthPerChoice[index] < newValLength || maxLengthPerChoice[index] > newValLength + 10)) {
1447
- maxLengthPerChoice[index] = (0, _markupUtils.getAdjustedLength)(newValLength);
1448
- }
1449
- }
1450
- onModelChanged(_objectSpread(_objectSpread({}, model), {}, {
1451
- choices: choices,
1452
- maxLengthPerChoice: maxLengthPerChoice
1453
- }));
1454
- });
1455
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
1456
- var _this$props4 = _this.props, _this$props4$model = _this$props4.model, choices = _this$props4$model.choices, maxLengthPerChoice = _this$props4$model.maxLengthPerChoice, onModelChanged = _this$props4.onModelChanged;
1457
- var domMarkup = createElementFromHTML(markup);
1458
- var allRespAreas = domMarkup.querySelectorAll('[data-type="explicit_constructed_response"]');
1459
- var allChoices = {};
1460
- var updatedMaxLengthPerChoice = [];
1461
- allRespAreas.forEach(function (el, index) {
1462
- var newChoices = (0, _cloneDeep["default"])(choices[el.dataset.index]);
1463
- if (newChoices) {
1464
- newChoices[0] = {
1465
- label: el.dataset.value || '',
1466
- value: '0'
1467
- };
1468
- updatedMaxLengthPerChoice[index] = maxLengthPerChoice[el.dataset.index];
1469
- }
1470
- allChoices[index] = newChoices;
1471
- el.dataset.index = index;
1472
- });
1473
- var callback = function callback() {
1474
- return onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
1475
- choices: allChoices,
1476
- slateMarkup: domMarkup.innerHTML,
1477
- maxLengthPerChoice: updatedMaxLengthPerChoice
1478
- }));
1479
- };
1480
- _this.setState({
1481
- cachedChoices: undefined
1482
- }, callback);
1483
- });
1484
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onHandleAreaChange", (0, _throttle["default"])(function (nodes) {
1485
- var _this$props5 = _this.props, choices = _this$props5.model.choices, onModelChanged = _this$props5.onModelChanged;
1486
- var cachedChoices = _this.state.cachedChoices;
1487
- if (!nodes) {
1488
- return;
1489
- }
1490
- var newChoices = choices ? (0, _cloneDeep["default"])(choices) : {};
1491
- var newCachedChoices = cachedChoices ? (0, _cloneDeep["default"])(cachedChoices) : {};
1492
- nodes.forEach(function (node) {
1493
- var keyForNode = node.data.get('index');
1494
- if (!newChoices[keyForNode] && newCachedChoices[keyForNode]) {
1495
- Object.assign(newChoices, (0, _pick["default"])(newCachedChoices, keyForNode));
1496
- if (newCachedChoices.hasOwnProperty(keyForNode)) {
1497
- delete newCachedChoices[keyForNode];
1498
- }
1499
- } else {
1500
- Object.assign(newCachedChoices, (0, _pick["default"])(newChoices, keyForNode));
1501
- if (newChoices.hasOwnProperty(keyForNode)) {
1502
- delete newChoices[keyForNode];
1503
- }
1504
- }
1505
- });
1506
- var callback = function callback() {
1507
- return onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
1508
- choices: newChoices
1509
- }));
1510
- };
1511
- _this.setState({
1512
- cachedChoices: newCachedChoices
1513
- }, callback);
1514
- }, 500, {
1515
- trailing: false,
1516
- leading: true
1517
- }));
1518
- return _this;
1519
- }
1520
- (0, _createClass2["default"])(Main, [{
1521
- key: "componentDidMount",
1522
- value: function componentDidMount() {
1523
- var _this$props6 = this.props, _this$props6$model = _this$props6.model, slateMarkup = _this$props6$model.slateMarkup, choices = _this$props6$model.choices, _this$props6$model$ma = _this$props6$model.maxLengthPerChoice, maxLengthPerChoice = _this$props6$model$ma === void 0 ? [] : _this$props6$model$ma, onModelChanged = _this$props6.onModelChanged;
1524
- var undefinedLengths = !maxLengthPerChoice.length;
1525
- this.setState({
1526
- markup: slateMarkup
1527
- });
1528
- Object.values(choices).forEach(function (choice, index) {
1529
- var labelLengthsArr = (choice || []).map(function (choice) {
1530
- return (choice.label || '').length;
1531
- });
1532
- var length = Math.max.apply(Math, (0, _toConsumableArray2["default"])(labelLengthsArr));
1533
- if (undefinedLengths || !maxLengthPerChoice[index] || maxLengthPerChoice[index] < length || maxLengthPerChoice[index] > length + 10) {
1534
- maxLengthPerChoice[index] = (0, _markupUtils.getAdjustedLength)(length);
1535
- }
1536
- });
1537
- onModelChanged(_objectSpread(_objectSpread({}, this.props.model), {}, {
1538
- maxLengthPerChoice: maxLengthPerChoice
1539
- }));
1540
- }
1541
- }, {
1542
- key: "render",
1543
- value: function render() {
1544
- var _this2 = this;
1545
- var _this$props7 = this.props, classes = _this$props7.classes, model = _this$props7.model, configuration = _this$props7.configuration, onConfigurationChanged = _this$props7.onConfigurationChanged, imageSupport = _this$props7.imageSupport;
1546
- var _ref = configuration || ({}), _ref$prompt = _ref.prompt, prompt = _ref$prompt === void 0 ? {} : _ref$prompt, _ref$partialScoring = _ref.partialScoring, partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring, _ref$rationale = _ref.rationale, rationale = _ref$rationale === void 0 ? {} : _ref$rationale, _ref$teacherInstructi = _ref.teacherInstructions, teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi, _ref$maxLengthPerChoi = _ref.maxLengthPerChoice, maxLengthPerChoice = _ref$maxLengthPerChoi === void 0 ? {} : _ref$maxLengthPerChoi, _ref$spellCheck = _ref.spellCheck, spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck, _ref$playerSpellCheck = _ref.playerSpellCheck, playerSpellCheck = _ref$playerSpellCheck === void 0 ? {} : _ref$playerSpellCheck;
1547
- var _ref2 = model || ({}), teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled, promptEnabled = _ref2.promptEnabled, rationaleEnabled = _ref2.rationaleEnabled, maxLengthPerChoiceEnabled = _ref2.maxLengthPerChoiceEnabled, spellCheckEnabled = _ref2.spellCheckEnabled;
1548
- var toolbarOpts = {};
1549
- switch (model.toolbarEditorPosition) {
1550
- case 'top':
1551
- toolbarOpts.position = 'top';
1552
- break;
1553
- default:
1554
- toolbarOpts.position = 'bottom';
1555
- break;
1556
- }
1557
- return _react["default"].createElement("div", {
1558
- className: classes.design
1559
- }, _react["default"].createElement(_configUi.layout.ConfigLayout, {
1560
- settings: _react["default"].createElement(Panel, {
1561
- model: model,
1562
- configuration: configuration,
1563
- onChangeModel: function onChangeModel(model) {
1564
- return _this2.onModelChange(model);
1565
- },
1566
- onChangeConfiguration: function onChangeConfiguration(configuration) {
1567
- return onConfigurationChanged(configuration, true);
1568
- },
1569
- groups: {
1570
- Settings: {
1571
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
1572
- maxLengthPerChoiceEnabled: maxLengthPerChoice.settings && toggle(maxLengthPerChoice.label)
1573
- },
1574
- Properties: {
1575
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
1576
- rationaleEnabled: rationale.settings && toggle(rationale.label),
1577
- promptEnabled: prompt.settings && toggle(prompt.label),
1578
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
1579
- playerSpellCheckEnabled: playerSpellCheck.settings && toggle(playerSpellCheck.label)
1580
- }
1581
- }
1582
- })
1583
- }, _react["default"].createElement("div", null, teacherInstructionsEnabled && _react["default"].createElement(_configUi.InputContainer, {
1584
- label: teacherInstructions.label,
1585
- className: classes.promptHolder
1586
- }, _react["default"].createElement(_editableHtml["default"], {
1587
- className: classes.prompt,
1588
- markup: model.teacherInstructions || '',
1589
- onChange: this.onTeacherInstructionsChanged,
1590
- imageSupport: imageSupport,
1591
- nonEmpty: false,
1592
- toolbarOpts: toolbarOpts,
1593
- spellCheck: spellCheckEnabled
1594
- })), promptEnabled && _react["default"].createElement(_configUi.InputContainer, {
1595
- label: prompt.label,
1596
- className: classes.promptHolder
1597
- }, _react["default"].createElement(_editableHtml["default"], {
1598
- className: classes.prompt,
1599
- markup: model.prompt,
1600
- onChange: this.onPromptChanged,
1601
- imageSupport: imageSupport,
1602
- nonEmpty: false,
1603
- disableUnderline: true,
1604
- toolbarOpts: toolbarOpts,
1605
- spellCheck: spellCheckEnabled
1606
- })), _react["default"].createElement(_Typography["default"], {
1607
- className: classes.text
1608
- }, "Define Template, Choices, and Correct Responses"), _react["default"].createElement(_editableHtml["default"], {
1609
- activePlugins: _editableHtml.ALL_PLUGINS,
1610
- toolbarOpts: {
1611
- position: 'top'
1612
- },
1613
- spellCheck: spellCheckEnabled,
1614
- responseAreaProps: {
1615
- type: 'explicit-constructed-response',
1616
- options: {
1617
- duplicates: true
1618
- },
1619
- respAreaToolbar: function respAreaToolbar(node, value, onToolbarDone) {
1620
- var model = _this2.props.model;
1621
- var correctChoice = (model.choices[node.data.get('index')] || [])[0];
1622
- return function () {
1623
- return _react["default"].createElement(_ecrToolbar["default"], {
1624
- onChangeResponse: function onChangeResponse(newVal) {
1625
- return _this2.onChangeResponse(node.data.get('index'), newVal);
1626
- },
1627
- node: node,
1628
- value: value,
1629
- onToolbarDone: onToolbarDone,
1630
- correctChoice: correctChoice
1631
- });
1632
- };
1633
- },
1634
- onHandleAreaChange: this.onHandleAreaChange
1635
- },
1636
- className: classes.markup,
1637
- markup: model.slateMarkup,
1638
- onChange: this.onChange,
1639
- imageSupport: imageSupport,
1640
- onBlur: this.onBlur,
1641
- disabled: false,
1642
- highlightShape: false
1643
- }), !(0, _isEmpty["default"])(model.choices) && _react["default"].createElement(_Typography["default"], {
1644
- className: classes.text
1645
- }, ("Define Alternates ").concat(maxLengthPerChoiceEnabled ? 'and Character Limits' : '')), _react["default"].createElement(_alternateResponses["default"], {
1646
- model: model,
1647
- onChange: this.onResponsesChanged,
1648
- onLengthChange: this.onLengthChanged,
1649
- maxLengthPerChoiceEnabled: maxLengthPerChoiceEnabled,
1650
- spellCheck: spellCheckEnabled
1651
- }), rationaleEnabled && _react["default"].createElement(_configUi.InputContainer, {
1652
- label: rationale.label,
1653
- className: classes.promptHolder
1654
- }, _react["default"].createElement(_editableHtml["default"], {
1655
- className: classes.prompt,
1656
- markup: model.rationale || '',
1657
- onChange: this.onRationaleChanged,
1658
- imageSupport: imageSupport,
1659
- toolbarOpts: toolbarOpts,
1660
- spellCheck: spellCheckEnabled
1661
- })))));
1662
- }
1663
- }]);
1664
- return Main;
1665
- })(_react["default"].Component);
1666
- exports.Main = Main;
1667
- (0, _defineProperty2["default"])(Main, "propTypes", {
1668
- configuration: _propTypes["default"].object.isRequired,
1669
- model: _propTypes["default"].object.isRequired,
1670
- disableSidePanel: _propTypes["default"].bool,
1671
- onModelChanged: _propTypes["default"].func.isRequired,
1672
- onConfigurationChanged: _propTypes["default"].func.isRequired,
1673
- classes: _propTypes["default"].object.isRequired,
1674
- imageSupport: _propTypes["default"].shape({
1675
- add: _propTypes["default"].func.isRequired,
1676
- "delete": _propTypes["default"].func.isRequired
1677
- })
1678
- });
1679
- var Styled = (0, _styles.withStyles)(styles)(Main);
1680
- var _default = Styled;
1681
- exports["default"] = _default;
1682
- })(main);
1683
- getDefaultExportFromCjs(main);
1684
- var defaults = {};
1685
- (function (exports) {
1686
- Object.defineProperty(exports, "__esModule", {
1687
- value: true
1688
- });
1689
- exports["default"] = void 0;
1690
- var _default = {
1691
- model: {
1692
- disabled: false,
1693
- mode: 'gather',
1694
- prompt: 'Use the inputs to complete the sentence',
1695
- shuffle: true,
1696
- markup: '<p>The {{0}} jumped {{1}} the {{2}}</p>',
1697
- toolbarEditorPosition: 'bottom',
1698
- displayType: 'block',
1699
- spellCheckEnabled: true,
1700
- playerSpellCheckEnabled: true,
1701
- choices: {
1702
- 0: [{
1703
- label: 'cow',
1704
- value: '0'
1705
- }, {
1706
- label: 'cattle',
1707
- value: '1'
1708
- }, {
1709
- label: 'calf',
1710
- value: '2',
1711
- correct: false
1712
- }],
1713
- 1: [{
1714
- label: 'over',
1715
- value: '0'
1716
- }, {
1717
- label: 'past',
1718
- value: '1'
1719
- }, {
1720
- label: 'beyond',
1721
- value: '2'
1722
- }],
1723
- 2: [{
1724
- label: 'moon',
1725
- value: '0'
1726
- }, {
1727
- label: 'satellite',
1728
- value: '2'
1729
- }, {
1730
- label: 'house ',
1731
- value: '3'
1732
- }]
1733
- },
1734
- maxLengthPerChoiceEnabled: true,
1735
- rationaleEnabled: true,
1736
- promptEnabled: true,
1737
- teacherInstructionsEnabled: true,
1738
- studentInstructionsEnabled: true
1739
- },
1740
- configuration: {
1741
- prompt: {
1742
- settings: true,
1743
- label: 'Prompt'
1744
- },
1745
- partialScoring: {
1746
- settings: false,
1747
- label: 'Allow Partial Scoring'
1748
- },
1749
- rationale: {
1750
- settings: true,
1751
- label: 'Rationale'
1752
- },
1753
- spellCheck: {
1754
- label: 'Spellcheck',
1755
- settings: false,
1756
- enabled: true
1757
- },
1758
- playerSpellCheck: {
1759
- label: 'Student Spellcheck',
1760
- settings: true,
1761
- enabled: true
1762
- },
1763
- teacherInstructions: {
1764
- settings: true,
1765
- label: 'Teacher Instructions'
1766
- },
1767
- maxLengthPerChoice: {
1768
- settings: true,
1769
- label: 'Maximum Length Per Choice'
1770
- }
1771
- }
1772
- };
1773
- exports["default"] = _default;
1774
- })(defaults);
1775
- getDefaultExportFromCjs(defaults);
1776
- const require$$9 = _dll_react;
1777
- const require$$10 = _dll_react_dom;
1778
- const require$$11 = _dll_debug;
1779
- const {defaults: require$$12} = _dll_lodash;
1780
- const {isArray: require$$13} = _dll_lodash;
1781
- (function (exports) {
1782
- var _interopRequireDefault = interopRequireDefault.exports;
1783
- Object.defineProperty(exports, "__esModule", {
1784
- value: true
1785
- });
1786
- exports["default"] = void 0;
1787
- var _classCallCheck2 = _interopRequireDefault(classCallCheck.exports);
1788
- var _createClass2 = _interopRequireDefault(createClass.exports);
1789
- var _assertThisInitialized2 = _interopRequireDefault(assertThisInitialized.exports);
1790
- var _inherits2 = _interopRequireDefault(inherits.exports);
1791
- var _possibleConstructorReturn2 = _interopRequireDefault(possibleConstructorReturn.exports);
1792
- var _getPrototypeOf2 = _interopRequireDefault(getPrototypeOf.exports);
1793
- var _wrapNativeSuper2 = _interopRequireDefault(wrapNativeSuper.exports);
1794
- var _defineProperty2 = _interopRequireDefault(defineProperty.exports);
1795
- var _react = _interopRequireDefault(require$$9);
1796
- var _reactDom = _interopRequireDefault(require$$10);
1797
- var _debug = _interopRequireDefault(require$$11);
1798
- var _defaults = _interopRequireDefault(require$$12);
1799
- var _isArray = _interopRequireDefault(require$$13);
1800
- var _pieConfigureEvents = lib;
1801
- var _main = _interopRequireDefault(main);
1802
- var _defaults2 = _interopRequireDefault(defaults);
1803
- var _markupUtils = markupUtils;
1804
- function ownKeys(object, enumerableOnly) {
1805
- var keys = Object.keys(object);
1806
- if (Object.getOwnPropertySymbols) {
1807
- var symbols = Object.getOwnPropertySymbols(object);
1808
- (enumerableOnly && (symbols = symbols.filter(function (sym) {
1809
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1810
- })), keys.push.apply(keys, symbols));
1811
- }
1812
- return keys;
1813
- }
1814
- function _objectSpread(target) {
1815
- for (var i = 1; i < arguments.length; i++) {
1816
- var source = null != arguments[i] ? arguments[i] : {};
1817
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1818
- (0, _defineProperty2["default"])(target, key, source[key]);
1819
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1820
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1821
- });
1822
- }
1823
- return target;
1824
- }
1825
- function _createSuper(Derived) {
1826
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
1827
- return function _createSuperInternal() {
1828
- var Super = (0, _getPrototypeOf2["default"])(Derived), result;
1829
- if (hasNativeReflectConstruct) {
1830
- var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor;
1831
- result = Reflect.construct(Super, arguments, NewTarget);
1832
- } else {
1833
- result = Super.apply(this, arguments);
1834
- }
1835
- return (0, _possibleConstructorReturn2["default"])(this, result);
1836
- };
1837
- }
1838
- function _isNativeReflectConstruct() {
1839
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1840
- if (Reflect.construct.sham) return false;
1841
- if (typeof Proxy === "function") return true;
1842
- try {
1843
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1844
- return true;
1845
- } catch (e) {
1846
- return false;
1847
- }
1848
- }
1849
- var log = (0, _debug["default"])('explicit-constructed-response:configure');
1850
- var ExplicitConstructedResponse = (function (_HTMLElement) {
1851
- (0, _inherits2["default"])(ExplicitConstructedResponse, _HTMLElement);
1852
- var _super = _createSuper(ExplicitConstructedResponse);
1853
- function ExplicitConstructedResponse() {
1854
- var _this;
1855
- (0, _classCallCheck2["default"])(this, ExplicitConstructedResponse);
1856
- _this = _super.call(this);
1857
- _this._model = ExplicitConstructedResponse.prepareModel();
1858
- _this._configuration = _defaults2["default"].configuration;
1859
- _this.onModelChanged = _this.onModelChanged.bind((0, _assertThisInitialized2["default"])(_this));
1860
- _this.onConfigurationChanged = _this.onConfigurationChanged.bind((0, _assertThisInitialized2["default"])(_this));
1861
- return _this;
1862
- }
1863
- (0, _createClass2["default"])(ExplicitConstructedResponse, [{
1864
- key: "model",
1865
- set: function set(s) {
1866
- this._model = ExplicitConstructedResponse.prepareModel(s);
1867
- this._render();
1868
- }
1869
- }, {
1870
- key: "configuration",
1871
- set: function set(c) {
1872
- this._configuration = (0, _defaults["default"])(c, _defaults2["default"].configuration);
1873
- this._render();
1874
- }
1875
- }, {
1876
- key: "disableSidePanel",
1877
- set: function set(s) {
1878
- this._disableSidePanel = s;
1879
- this._render();
1880
- }
1881
- }, {
1882
- key: "dispatchModelUpdated",
1883
- value: function dispatchModelUpdated(reset) {
1884
- var resetValue = !!reset;
1885
- this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, resetValue));
1886
- }
1887
- }, {
1888
- key: "onModelChanged",
1889
- value: function onModelChanged(m, reset) {
1890
- this._model = ExplicitConstructedResponse.prepareModel(m);
1891
- this._render();
1892
- this.dispatchModelUpdated(reset);
1893
- }
1894
- }, {
1895
- key: "onConfigurationChanged",
1896
- value: function onConfigurationChanged(c) {
1897
- this._configuration = c;
1898
- this._render();
1899
- }
1900
- }, {
1901
- key: "insertImage",
1902
- value: function insertImage(handler) {
1903
- this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
1904
- }
1905
- }, {
1906
- key: "onDeleteImage",
1907
- value: function onDeleteImage(src, done) {
1908
- this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
1909
- }
1910
- }, {
1911
- key: "_render",
1912
- value: function _render() {
1913
- log('_render');
1914
- var element = _react["default"].createElement(_main["default"], {
1915
- model: this._model,
1916
- configuration: this._configuration,
1917
- onModelChanged: this.onModelChanged,
1918
- onConfigurationChanged: this.onConfigurationChanged,
1919
- disableSidePanel: this._disableSidePanel,
1920
- imageSupport: {
1921
- add: this.insertImage.bind(this),
1922
- "delete": this.onDeleteImage.bind(this)
1923
- }
1924
- });
1925
- _reactDom["default"].render(element, this);
1926
- }
1927
- }]);
1928
- return ExplicitConstructedResponse;
1929
- })((0, _wrapNativeSuper2["default"])(HTMLElement));
1930
- exports["default"] = ExplicitConstructedResponse;
1931
- (0, _defineProperty2["default"])(ExplicitConstructedResponse, "prepareModel", function () {
1932
- var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1933
- var joinedObj = _objectSpread(_objectSpread({}, _defaults2["default"].model), model);
1934
- var slateMarkup = joinedObj.slateMarkup || (0, _markupUtils.createSlateMarkup)(joinedObj.markup, joinedObj.choices);
1935
- var processedMarkup = (0, _markupUtils.processMarkup)(slateMarkup);
1936
- if (joinedObj.choices) {
1937
- Object.keys(joinedObj.choices).forEach(function (key) {
1938
- if ((0, _isArray["default"])(joinedObj.choices[key])) {
1939
- joinedObj.choices[key] = (joinedObj.choices[key] || []).map(function (item, index) {
1940
- if (!item.value) {
1941
- log('Choice does not contain "value" property, which is required.', item);
1942
- return _objectSpread({
1943
- value: ("").concat(index)
1944
- }, item);
1945
- }
1946
- return item;
1947
- });
1948
- }
1949
- });
1950
- }
1951
- return _objectSpread(_objectSpread({}, joinedObj), {}, {
1952
- slateMarkup: slateMarkup,
1953
- markup: processedMarkup
1954
- });
1955
- });
1956
- })(lib$1);
1957
- var index = getDefaultExportFromCjs(lib$1);
1958
- export {index as default};