@pie-element/math-inline 5.8.10 → 5.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1463 @@
1
+ import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_classnames, _dll_lodash, _dll_debug, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.2.19/module/index.js";
2
+ import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.20/module/index.js";
3
+ import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.0.20/module/index.js";
4
+ import {_dll_pie_lib__math_toolbar, _dll_pie_framework__mathquill} from "../../../@pie-lib/math-edit-module@^1.1.18/module/index.js";
5
+ const React$3 = _dll_react;
6
+ const PropTypes$2 = _dll_prop_types;
7
+ const {Card: Card} = _dll_material_ui__core;
8
+ const {CardContent: CardContent} = _dll_material_ui__core;
9
+ const {Button: Button} = _dll_material_ui__core;
10
+ const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
11
+ const {Typography: Typography} = _dll_material_ui__core;
12
+ const {InputLabel: InputLabel$1} = _dll_material_ui__core;
13
+ const {Checkbox: Checkbox} = _dll_material_ui__core;
14
+ const {Select: Select$1} = _dll_material_ui__core;
15
+ const {MenuItem: MenuItem$1} = _dll_material_ui__core;
16
+ const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
17
+ const {InputContainer: InputContainer$2} = _dll_pie_lib__config_ui;
18
+ const {MathToolbar: MathToolbar$1} = _dll_pie_lib__math_toolbar;
19
+ const _jsxFileName$2 = "/home/circleci/repo/packages/math-inline/configure/src/response.jsx";
20
+ const styles$2 = theme => ({
21
+ responseContainer: {
22
+ marginTop: theme.spacing.unit * 2,
23
+ width: '100%',
24
+ border: '1px solid darkgray',
25
+ display: 'flex',
26
+ flexDirection: 'column',
27
+ justifyContent: 'space-between'
28
+ },
29
+ cardContent: {
30
+ paddingBottom: `${theme.spacing.unit}px !important`
31
+ },
32
+ title: {
33
+ fontWeight: 700,
34
+ fontSize: '1.2rem',
35
+ flex: 3
36
+ },
37
+ selectContainer: {
38
+ flex: 2
39
+ },
40
+ inputContainer: {
41
+ marginTop: theme.spacing.unit
42
+ },
43
+ titleBar: {
44
+ display: 'flex',
45
+ alignItems: 'center',
46
+ justifyContent: 'space-between'
47
+ },
48
+ responseEditor: {
49
+ display: 'flex',
50
+ alignItems: 'center',
51
+ justifyContent: 'center',
52
+ width: '100%',
53
+ minWidth: '500px',
54
+ maxWidth: '900px',
55
+ height: 'auto',
56
+ minHeight: '40px'
57
+ },
58
+ mathToolbar: {
59
+ width: '100%'
60
+ },
61
+ configPanel: {
62
+ display: 'flex',
63
+ justifyContent: 'space-between',
64
+ alignItems: 'center'
65
+ },
66
+ alternateButton: {
67
+ border: '1px solid lightgrey'
68
+ },
69
+ removeAlternateButton: {
70
+ marginLeft: theme.spacing.unit * 2,
71
+ border: '1px solid lightgrey',
72
+ color: 'gray',
73
+ fontSize: '0.8rem'
74
+ },
75
+ checkboxContainer: {
76
+ marginTop: theme.spacing.unit * 2,
77
+ display: 'flex',
78
+ flexDirection: 'column',
79
+ alignItems: 'center'
80
+ },
81
+ configLabel: {
82
+ marginRight: 'auto'
83
+ }
84
+ });
85
+ class Response extends React$3.Component {
86
+ static __initStatic() {
87
+ this.propTypes = {
88
+ classes: PropTypes$2.object.isRequired,
89
+ defaultResponse: PropTypes$2.bool,
90
+ mode: PropTypes$2.oneOfType([PropTypes$2.string, PropTypes$2.number]),
91
+ index: PropTypes$2.number,
92
+ onResponseChange: PropTypes$2.func.isRequired,
93
+ response: PropTypes$2.object.isRequired,
94
+ cIgnoreOrder: PropTypes$2.object.isRequired,
95
+ cAllowTrailingZeros: PropTypes$2.object.isRequired
96
+ };
97
+ }
98
+ static __initStatic2() {
99
+ this.defaultProps = {
100
+ defaultResponse: false,
101
+ mode: 'miscellaneous'
102
+ };
103
+ }
104
+ constructor(props) {
105
+ super(props);
106
+ Response.prototype.__init.call(this);
107
+ Response.prototype.__init2.call(this);
108
+ Response.prototype.__init3.call(this);
109
+ Response.prototype.__init4.call(this);
110
+ Response.prototype.__init5.call(this);
111
+ Response.prototype.__init6.call(this);
112
+ Response.prototype.__init7.call(this);
113
+ Response.prototype.__init8.call(this);
114
+ Response.prototype.__init9.call(this);
115
+ Response.prototype.__init10.call(this);
116
+ Response.prototype.__init11.call(this);
117
+ const {response: {alternates} = {}} = props || ({});
118
+ const alternatesLength = Object.keys(alternates || ({})).length;
119
+ this.state = {
120
+ alternateIdCounter: alternatesLength + 1,
121
+ showKeypad: {
122
+ openCount: 0,
123
+ main: false
124
+ }
125
+ };
126
+ }
127
+ __init() {
128
+ this.onChange = name => evt => {
129
+ const {response, onResponseChange, index} = this.props;
130
+ const newResponse = {
131
+ ...response
132
+ };
133
+ newResponse[name] = evt.target.value;
134
+ onResponseChange(newResponse, index);
135
+ };
136
+ }
137
+ __init2() {
138
+ this.onConfigChanged = name => evt => {
139
+ const {response, onResponseChange, index} = this.props;
140
+ const newResponse = {
141
+ ...response
142
+ };
143
+ newResponse[name] = evt.target.checked;
144
+ onResponseChange(newResponse, index);
145
+ };
146
+ }
147
+ __init3() {
148
+ this.onLiteralOptionsChange = name => evt => {
149
+ const {response, onResponseChange, index} = this.props;
150
+ const newResponse = {
151
+ ...response
152
+ };
153
+ newResponse[name] = !response[name];
154
+ onResponseChange(newResponse, index);
155
+ };
156
+ }
157
+ __init4() {
158
+ this.onAnswerChange = answer => {
159
+ const {response, onResponseChange, index} = this.props;
160
+ const newResponse = {
161
+ ...response
162
+ };
163
+ newResponse.answer = answer;
164
+ onResponseChange(newResponse, index);
165
+ };
166
+ }
167
+ __init5() {
168
+ this.onAlternateAnswerChange = alternateId => answer => {
169
+ const {response, onResponseChange, index} = this.props;
170
+ const newResponse = {
171
+ ...response
172
+ };
173
+ newResponse.alternates[alternateId] = answer;
174
+ onResponseChange(newResponse, index);
175
+ };
176
+ }
177
+ __init6() {
178
+ this.onAddAlternate = () => {
179
+ const {response, onResponseChange, index} = this.props;
180
+ const {alternateIdCounter} = this.state;
181
+ const newResponse = {
182
+ ...response
183
+ };
184
+ if (!newResponse.alternates) {
185
+ newResponse.alternates = {};
186
+ }
187
+ newResponse.alternates[alternateIdCounter] = '';
188
+ onResponseChange(newResponse, index);
189
+ this.setState({
190
+ alternateIdCounter: alternateIdCounter + 1
191
+ });
192
+ };
193
+ }
194
+ __init7() {
195
+ this.onRemoveAlternate = alternateId => () => {
196
+ const {response, onResponseChange, index} = this.props;
197
+ const newResponse = {
198
+ ...response
199
+ };
200
+ delete newResponse.alternates[alternateId];
201
+ onResponseChange(newResponse, index);
202
+ this.setState(state => ({
203
+ showKeypad: {
204
+ ...state.showKeypad,
205
+ openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount : state.showKeypad.openCount - 1
206
+ }
207
+ }));
208
+ };
209
+ }
210
+ __init8() {
211
+ this.onDone = () => {
212
+ this.setState(state => ({
213
+ showKeypad: {
214
+ ...state.showKeypad,
215
+ openCount: state.showKeypad.openCount - 1,
216
+ main: false
217
+ }
218
+ }));
219
+ };
220
+ }
221
+ __init9() {
222
+ this.onFocus = () => {
223
+ this.setState(state => ({
224
+ showKeypad: {
225
+ ...state.showKeypad,
226
+ openCount: !state.showKeypad.main ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
227
+ main: true
228
+ }
229
+ }));
230
+ };
231
+ }
232
+ __init10() {
233
+ this.onAlternateFocus = alternateId => () => {
234
+ this.setState(state => ({
235
+ showKeypad: {
236
+ ...state.showKeypad,
237
+ openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
238
+ [alternateId]: true
239
+ }
240
+ }));
241
+ };
242
+ }
243
+ __init11() {
244
+ this.onAlternateDone = alternateId => () => {
245
+ this.setState(state => ({
246
+ showKeypad: {
247
+ ...state.showKeypad,
248
+ openCount: state.showKeypad.openCount - 1,
249
+ [alternateId]: false
250
+ }
251
+ }));
252
+ };
253
+ }
254
+ render() {
255
+ const {classes, mode, defaultResponse, index, response, cAllowTrailingZeros, cIgnoreOrder} = this.props;
256
+ const {showKeypad} = this.state;
257
+ const {validation, answer, alternates, ignoreOrder, allowTrailingZeros} = response;
258
+ const hasAlternates = Object.keys(alternates || ({})).length > 0;
259
+ const classNames = {
260
+ editor: classes.responseEditor,
261
+ mathToolbar: classes.mathToolbar
262
+ };
263
+ const styles = {
264
+ minHeight: `${showKeypad.openCount > 0 ? 430 : 230}px`
265
+ };
266
+ return React$3.createElement(Card, {
267
+ className: classes.responseContainer,
268
+ style: styles,
269
+ __self: this,
270
+ __source: {
271
+ fileName: _jsxFileName$2,
272
+ lineNumber: 271
273
+ }
274
+ }, React$3.createElement(CardContent, {
275
+ className: classes.cardContent,
276
+ __self: this,
277
+ __source: {
278
+ fileName: _jsxFileName$2,
279
+ lineNumber: 272
280
+ }
281
+ }, React$3.createElement('div', {
282
+ className: classes.titleBar,
283
+ __self: this,
284
+ __source: {
285
+ fileName: _jsxFileName$2,
286
+ lineNumber: 273
287
+ }
288
+ }, React$3.createElement(Typography, {
289
+ className: classes.title,
290
+ component: "h2",
291
+ __self: this,
292
+ __source: {
293
+ fileName: _jsxFileName$2,
294
+ lineNumber: 274
295
+ }
296
+ }, "Response", ' ', ''), React$3.createElement(InputContainer$2, {
297
+ label: "Validation",
298
+ className: classes.selectContainer,
299
+ __self: this,
300
+ __source: {
301
+ fileName: _jsxFileName$2,
302
+ lineNumber: 282
303
+ }
304
+ }, React$3.createElement(Select$1, {
305
+ className: classes.select,
306
+ onChange: this.onChange('validation'),
307
+ value: validation || 'literal',
308
+ __self: this,
309
+ __source: {
310
+ fileName: _jsxFileName$2,
311
+ lineNumber: 286
312
+ }
313
+ }, React$3.createElement(MenuItem$1, {
314
+ value: "literal",
315
+ __self: this,
316
+ __source: {
317
+ fileName: _jsxFileName$2,
318
+ lineNumber: 291
319
+ }
320
+ }, "Literal Validation"), React$3.createElement(MenuItem$1, {
321
+ value: "symbolic",
322
+ __self: this,
323
+ __source: {
324
+ fileName: _jsxFileName$2,
325
+ lineNumber: 292
326
+ }
327
+ }, "Symbolic Validation")))), validation === 'literal' && React$3.createElement('div', {
328
+ className: classes.flexContainer,
329
+ __self: this,
330
+ __source: {
331
+ fileName: _jsxFileName$2,
332
+ lineNumber: 297
333
+ }
334
+ }, cAllowTrailingZeros.enabled && React$3.createElement(FormControlLabel, {
335
+ label: cAllowTrailingZeros.label,
336
+ control: React$3.createElement(Checkbox, {
337
+ checked: allowTrailingZeros,
338
+ onChange: this.onLiteralOptionsChange('allowTrailingZeros'),
339
+ __self: this,
340
+ __source: {
341
+ fileName: _jsxFileName$2,
342
+ lineNumber: 302
343
+ }
344
+ }),
345
+ __self: this,
346
+ __source: {
347
+ fileName: _jsxFileName$2,
348
+ lineNumber: 299
349
+ }
350
+ }), cIgnoreOrder.enabled && React$3.createElement(FormControlLabel, {
351
+ label: cIgnoreOrder.label,
352
+ control: React$3.createElement(Checkbox, {
353
+ checked: ignoreOrder,
354
+ onChange: this.onLiteralOptionsChange('ignoreOrder'),
355
+ __self: this,
356
+ __source: {
357
+ fileName: _jsxFileName$2,
358
+ lineNumber: 316
359
+ }
360
+ }),
361
+ __self: this,
362
+ __source: {
363
+ fileName: _jsxFileName$2,
364
+ lineNumber: 313
365
+ }
366
+ })), React$3.createElement('div', {
367
+ className: classes.inputContainer,
368
+ __self: this,
369
+ __source: {
370
+ fileName: _jsxFileName$2,
371
+ lineNumber: 325
372
+ }
373
+ }, React$3.createElement(InputLabel$1, {
374
+ __self: this,
375
+ __source: {
376
+ fileName: _jsxFileName$2,
377
+ lineNumber: 326
378
+ }
379
+ }, "Correct Answer"), React$3.createElement(MathToolbar$1, {
380
+ keypadMode: mode,
381
+ classNames: classNames,
382
+ controlledKeypad: true,
383
+ showKeypad: showKeypad.main,
384
+ latex: answer || '',
385
+ onChange: this.onAnswerChange,
386
+ onFocus: this.onFocus,
387
+ onDone: this.onDone,
388
+ __self: this,
389
+ __source: {
390
+ fileName: _jsxFileName$2,
391
+ lineNumber: 327
392
+ }
393
+ })), hasAlternates && Object.keys(alternates).map((alternateId, altIdx) => React$3.createElement('div', {
394
+ className: classes.inputContainer,
395
+ key: alternateId,
396
+ __self: this,
397
+ __source: {
398
+ fileName: _jsxFileName$2,
399
+ lineNumber: 340
400
+ }
401
+ }, React$3.createElement('div', {
402
+ className: classes.alternateBar,
403
+ __self: this,
404
+ __source: {
405
+ fileName: _jsxFileName$2,
406
+ lineNumber: 341
407
+ }
408
+ }, React$3.createElement(InputLabel$1, {
409
+ __self: this,
410
+ __source: {
411
+ fileName: _jsxFileName$2,
412
+ lineNumber: 342
413
+ }
414
+ }, "Alternate", Object.keys(alternates).length > 1 ? ` ${altIdx + 1}` : ''), React$3.createElement(Button, {
415
+ className: classes.removeAlternateButton,
416
+ type: "secondary",
417
+ onClick: this.onRemoveAlternate(alternateId),
418
+ __self: this,
419
+ __source: {
420
+ fileName: _jsxFileName$2,
421
+ lineNumber: 346
422
+ }
423
+ }, "Remove")), React$3.createElement(MathToolbar$1, {
424
+ classNames: classNames,
425
+ controlledKeypad: true,
426
+ keypadMode: mode,
427
+ showKeypad: showKeypad[alternateId] || false,
428
+ latex: alternates[alternateId] || '',
429
+ onChange: this.onAlternateAnswerChange(alternateId),
430
+ onFocus: this.onAlternateFocus(alternateId),
431
+ onDone: this.onAlternateDone(alternateId),
432
+ __self: this,
433
+ __source: {
434
+ fileName: _jsxFileName$2,
435
+ lineNumber: 354
436
+ }
437
+ }))), React$3.createElement('div', {
438
+ className: classes.configPanel,
439
+ __self: this,
440
+ __source: {
441
+ fileName: _jsxFileName$2,
442
+ lineNumber: 366
443
+ }
444
+ }, React$3.createElement(Button, {
445
+ className: classes.alternateButton,
446
+ type: "primary",
447
+ onClick: this.onAddAlternate,
448
+ __self: this,
449
+ __source: {
450
+ fileName: _jsxFileName$2,
451
+ lineNumber: 367
452
+ }
453
+ }, "ADD ALTERNATE"), React$3.createElement('div', {
454
+ className: classes.checkboxContainer,
455
+ __self: this,
456
+ __source: {
457
+ fileName: _jsxFileName$2,
458
+ lineNumber: 374
459
+ }
460
+ }))));
461
+ }
462
+ }
463
+ Response.__initStatic();
464
+ Response.__initStatic2();
465
+ var Response$1 = withStyles$2(styles$2)(Response);
466
+ const ResponseTypes = {
467
+ advanced: 'Advanced Multi',
468
+ simple: 'Simple'
469
+ };
470
+ const React$2 = _dll_react;
471
+ const PropTypes$1 = _dll_prop_types;
472
+ const cx = _dll_classnames;
473
+ const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
474
+ const {InputLabel: InputLabel} = _dll_material_ui__core;
475
+ const {Select: Select} = _dll_material_ui__core;
476
+ const {MenuItem: MenuItem} = _dll_material_ui__core;
477
+ const {isEqual: isEqual} = _dll_lodash;
478
+ const EditableHtml$1 = _dll_pie_lib__editable_html;
479
+ const {InputContainer: InputContainer$1} = _dll_pie_lib__config_ui;
480
+ const {MathToolbar: MathToolbar} = _dll_pie_lib__math_toolbar;
481
+ const MathQuill = _dll_pie_framework__mathquill;
482
+ const _jsxFileName$1 = "/home/circleci/repo/packages/math-inline/configure/src/general-config-block.jsx";
483
+ let registered = false;
484
+ const styles$1 = theme => ({
485
+ container: {
486
+ marginTop: theme.spacing.unit * 2,
487
+ marginBottom: theme.spacing.unit * 2,
488
+ display: 'flex',
489
+ flexDirection: 'column'
490
+ },
491
+ templateTitle: {
492
+ fontSize: '0.85rem'
493
+ },
494
+ addResponseButton: {
495
+ border: '1px solid lightgrey',
496
+ float: 'right',
497
+ width: '150px'
498
+ },
499
+ flexContainer: {
500
+ display: 'flex',
501
+ alignItems: 'center',
502
+ justifyContent: 'space-between'
503
+ },
504
+ selectContainer: {
505
+ flex: 'initial',
506
+ width: '40%',
507
+ marginTop: theme.spacing.unit * 2,
508
+ marginBottom: theme.spacing.unit * 2
509
+ },
510
+ inputContainer: {
511
+ marginBottom: theme.spacing.unit * 4,
512
+ display: 'flex',
513
+ flexDirection: 'column',
514
+ width: '90%'
515
+ },
516
+ responseEditor: {
517
+ display: 'flex',
518
+ justifyContent: 'center',
519
+ width: '100%',
520
+ minWidth: '500px',
521
+ maxWidth: 'inherit',
522
+ height: 'auto',
523
+ minHeight: '130px',
524
+ textAlign: 'left',
525
+ padding: theme.spacing.unit
526
+ },
527
+ promptHolder: {
528
+ width: '100%',
529
+ paddingBottom: theme.spacing.unit * 2,
530
+ marginBottom: theme.spacing.unit * 2
531
+ },
532
+ prompt: {
533
+ paddingTop: theme.spacing.unit * 2,
534
+ width: '100%',
535
+ maxWidth: '600px'
536
+ },
537
+ blockContainer: {
538
+ margin: theme.spacing.unit,
539
+ display: 'inline-flex',
540
+ border: '2px solid grey'
541
+ },
542
+ blockContainerGeneric: {
543
+ margin: theme.spacing.unit / 2
544
+ },
545
+ blockResponse: {
546
+ flex: 2,
547
+ color: 'grey',
548
+ background: 'lightgrey',
549
+ fontSize: '0.8rem',
550
+ padding: theme.spacing.unit / 2,
551
+ display: 'flex',
552
+ alignItems: 'center',
553
+ justifyContent: 'center',
554
+ borderRight: '2px solid grey'
555
+ },
556
+ blockResponseGeneric: {
557
+ borderRight: 0
558
+ },
559
+ blockMath: {
560
+ color: '#bdbdbd',
561
+ padding: theme.spacing.unit / 2,
562
+ display: 'flex',
563
+ alignItems: 'center',
564
+ justifyContent: 'center',
565
+ flex: 8,
566
+ '& > .mq-math-mode': {
567
+ '& > .mq-hasCursor': {
568
+ '& > .mq-cursor': {
569
+ display: 'none'
570
+ }
571
+ }
572
+ }
573
+ }
574
+ });
575
+ const REGEX = /{{response}}/gm;
576
+ const TEMPORARY_RESPONSE_FIELD = /\\%response\\%/gm;
577
+ const ANSWER_BLOCK_REGEX = /\\embed\{answerBlock\}\[r\d*\]/g;
578
+ const NEWLINE_BLOCK = /\\embed\{newLine\}\[\]/g;
579
+ const NEWLINE_LATEX = /\\newline/g;
580
+ function prepareForStatic(expression) {
581
+ if (expression) {
582
+ let answerBlocks = 1;
583
+ return expression.replace(REGEX, () => `\\embed{answerBlock}[r${answerBlocks++}]`).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
584
+ }
585
+ }
586
+ function prepareForModel(expression) {
587
+ if (expression) {
588
+ return expression.replace(ANSWER_BLOCK_REGEX, () => '{{response}}').replace(TEMPORARY_RESPONSE_FIELD, () => '{{response}}').replace(NEWLINE_BLOCK, () => '\\newline');
589
+ }
590
+ }
591
+ class GeneralConfigBlock extends React$2.Component {
592
+ static __initStatic() {
593
+ this.propTypes = {
594
+ classes: PropTypes$1.object.isRequired,
595
+ model: PropTypes$1.object.isRequired,
596
+ imageSupport: PropTypes$1.object,
597
+ configuration: PropTypes$1.object,
598
+ onChange: PropTypes$1.func.isRequired,
599
+ promptEnabled: PropTypes$1.bool,
600
+ rationaleEnabled: PropTypes$1.bool,
601
+ toolbarOpts: PropTypes$1.object
602
+ };
603
+ }
604
+ constructor(props) {
605
+ super(props);
606
+ GeneralConfigBlock.prototype.__init.call(this);
607
+ GeneralConfigBlock.prototype.__init2.call(this);
608
+ GeneralConfigBlock.prototype.__init3.call(this);
609
+ GeneralConfigBlock.prototype.__init4.call(this);
610
+ GeneralConfigBlock.prototype.__init5.call(this);
611
+ GeneralConfigBlock.prototype.__init6.call(this);
612
+ GeneralConfigBlock.prototype.__init7.call(this);
613
+ const responseAreas = {};
614
+ if (props.model && props.model.expression) {
615
+ let answerBlocks = 1;
616
+ props.model.expression.replace(REGEX, () => {
617
+ responseAreas[`r${answerBlocks++}`] = {
618
+ value: ''
619
+ };
620
+ });
621
+ }
622
+ this.state = {
623
+ showKeypad: false,
624
+ responseAreas,
625
+ responseIdCounter: Object.keys(responseAreas).length
626
+ };
627
+ }
628
+ __init() {
629
+ this.onChange = name => evtOrValue => {
630
+ const {model, onChange} = this.props;
631
+ const newModel = {
632
+ ...model
633
+ };
634
+ if (typeof evtOrValue === 'object') {
635
+ newModel[name] = evtOrValue.target.value;
636
+ } else {
637
+ newModel[name] = evtOrValue;
638
+ }
639
+ if (name === 'expression') {
640
+ newModel[name] = prepareForModel(evtOrValue);
641
+ }
642
+ onChange(newModel);
643
+ };
644
+ }
645
+ __init2() {
646
+ this.onDone = () => {
647
+ this.setState({
648
+ showKeypad: false
649
+ });
650
+ };
651
+ }
652
+ __init3() {
653
+ this.onFocus = () => {
654
+ this.setState({
655
+ showKeypad: true
656
+ });
657
+ };
658
+ }
659
+ __init4() {
660
+ this.onPromptFocus = () => {
661
+ this.setState({
662
+ showKeypad: false
663
+ });
664
+ };
665
+ }
666
+ UNSAFE_componentWillMount() {
667
+ const {classes} = this.props;
668
+ if (typeof window !== 'undefined') {
669
+ let MQ = MathQuill.getInterface(2);
670
+ if (!registered) {
671
+ MQ.registerEmbed('answerBlock', data => {
672
+ const genericAnswerBlock = `<div class="${cx(classes.blockContainer, classes.blockContainerGeneric)}">
673
+ <div class="${cx(classes.blockResponse, classes.blockResponseGeneric)}" id="${data}Index">Response</div>
674
+ </div>`;
675
+ return {
676
+ htmlString: genericAnswerBlock,
677
+ text: () => 'text',
678
+ latex: () => `\\embed{answerBlock}[${data}]`
679
+ };
680
+ });
681
+ registered = true;
682
+ }
683
+ }
684
+ }
685
+ componentDidMount() {
686
+ this.handleAnswerBlockDomUpdate();
687
+ }
688
+ componentDidUpdate() {
689
+ this.handleAnswerBlockDomUpdate();
690
+ }
691
+ __init5() {
692
+ this.handleAnswerBlockDomUpdate = () => {
693
+ const {model} = this.props;
694
+ const responseAreas = {};
695
+ if (model && model.expression) {
696
+ let answerBlocks = 1;
697
+ model.expression.replace(REGEX, () => {
698
+ responseAreas[`r${answerBlocks++}`] = {
699
+ value: ''
700
+ };
701
+ });
702
+ }
703
+ if (!isEqual(responseAreas, this.state.responseAreas)) {
704
+ this.setState({
705
+ responseAreas
706
+ }, () => {
707
+ if (this.root && Object.keys(responseAreas).length) {
708
+ Object.keys(responseAreas).forEach((responseId, idx) => {
709
+ const el = this.root.querySelector(`#${responseId}`);
710
+ const indexEl = this.root.querySelector(`#${responseId}Index`);
711
+ if (el) {
712
+ let MQ = MathQuill.getInterface(2);
713
+ MQ.StaticMath(el);
714
+ indexEl.textContent = `R${idx + 1}`;
715
+ }
716
+ });
717
+ }
718
+ });
719
+ }
720
+ };
721
+ }
722
+ __init6() {
723
+ this.onAddResponse = () => {
724
+ const {model, onChange} = this.props;
725
+ const {responseIdCounter} = this.state;
726
+ const newModel = {
727
+ ...model
728
+ };
729
+ let newCounter = responseIdCounter;
730
+ while (model.responses.find(response => response.id === newCounter)) {
731
+ newCounter++;
732
+ }
733
+ const response = {
734
+ id: newCounter,
735
+ validation: 'literal',
736
+ answer: '',
737
+ alternates: {}
738
+ };
739
+ newModel.responses = newModel.responses.concat(response);
740
+ onChange(newModel);
741
+ this.setState({
742
+ responseIdCounter: response.id
743
+ });
744
+ };
745
+ }
746
+ __init7() {
747
+ this.onResponseChange = (response, index) => {
748
+ const {model, onChange} = this.props;
749
+ const newModel = {
750
+ ...model
751
+ };
752
+ newModel.responses[index] = response;
753
+ onChange(newModel);
754
+ };
755
+ }
756
+ render() {
757
+ const {classes, model, imageSupport, configuration, promptEnabled, rationaleEnabled, toolbarOpts} = this.props;
758
+ const {showKeypad} = this.state;
759
+ const {prompt, expression, equationEditor, promptEquationEditor = '8', responses, responseType, rationale} = model;
760
+ const {rationale: cRationale = {}, prompt: cPrompt = {}, ignoreOrder: cIgnoreOrder = {}, allowTrailingZeros: cAllowTrailingZeros = {}} = configuration || ({});
761
+ const classNames = {
762
+ editor: classes.responseEditor,
763
+ mathToolbar: classes.mathToolbar
764
+ };
765
+ const responsesToUse = responseType === ResponseTypes.advanced ? responses : responses.slice(0, 1);
766
+ return React$2.createElement('div', {
767
+ ref: r => this.root = r || this.root,
768
+ className: classes.container,
769
+ __self: this,
770
+ __source: {
771
+ fileName: _jsxFileName$1,
772
+ lineNumber: 356
773
+ }
774
+ }, promptEnabled && React$2.createElement(InputContainer$1, {
775
+ label: cPrompt.label,
776
+ className: classes.promptHolder,
777
+ __self: this,
778
+ __source: {
779
+ fileName: _jsxFileName$1,
780
+ lineNumber: 361
781
+ }
782
+ }, React$2.createElement(EditableHtml$1, {
783
+ onFocus: this.onPromptFocus,
784
+ className: classes.prompt,
785
+ markup: prompt || '',
786
+ onChange: this.onChange('prompt'),
787
+ imageSupport: imageSupport,
788
+ nonEmpty: false,
789
+ toolbarOpts: toolbarOpts,
790
+ __self: this,
791
+ __source: {
792
+ fileName: _jsxFileName$1,
793
+ lineNumber: 362
794
+ }
795
+ })), rationaleEnabled && React$2.createElement(InputContainer$1, {
796
+ label: cRationale.label,
797
+ className: classes.promptHolder,
798
+ __self: this,
799
+ __source: {
800
+ fileName: _jsxFileName$1,
801
+ lineNumber: 374
802
+ }
803
+ }, React$2.createElement(EditableHtml$1, {
804
+ className: classes.prompt,
805
+ markup: rationale || '',
806
+ pluginProps: {
807
+ math: {
808
+ controlledKeypadMode: false
809
+ }
810
+ },
811
+ onChange: this.onChange('rationale'),
812
+ imageSupport: imageSupport,
813
+ nonEmpty: false,
814
+ toolbarOpts: toolbarOpts,
815
+ __self: this,
816
+ __source: {
817
+ fileName: _jsxFileName$1,
818
+ lineNumber: 378
819
+ }
820
+ })), responseType === ResponseTypes.advanced && [React$2.createElement(InputContainer$1, {
821
+ key: "templateEditorType",
822
+ label: "Response Template Equation Editor",
823
+ className: classes.selectContainer,
824
+ __self: this,
825
+ __source: {
826
+ fileName: _jsxFileName$1,
827
+ lineNumber: 394
828
+ }
829
+ }, React$2.createElement(Select, {
830
+ className: classes.select,
831
+ onChange: this.onChange('promptEquationEditor'),
832
+ value: promptEquationEditor,
833
+ __self: this,
834
+ __source: {
835
+ fileName: _jsxFileName$1,
836
+ lineNumber: 399
837
+ }
838
+ }, React$2.createElement(MenuItem, {
839
+ value: "non-negative-integers",
840
+ __self: this,
841
+ __source: {
842
+ fileName: _jsxFileName$1,
843
+ lineNumber: 404
844
+ }
845
+ }, "Numeric - Non-Negative Integers"), React$2.createElement(MenuItem, {
846
+ value: "integers",
847
+ __self: this,
848
+ __source: {
849
+ fileName: _jsxFileName$1,
850
+ lineNumber: 405
851
+ }
852
+ }, "Numeric - Integers"), React$2.createElement(MenuItem, {
853
+ value: "decimals",
854
+ __self: this,
855
+ __source: {
856
+ fileName: _jsxFileName$1,
857
+ lineNumber: 406
858
+ }
859
+ }, "Numeric - Decimals"), React$2.createElement(MenuItem, {
860
+ value: "fractions",
861
+ __self: this,
862
+ __source: {
863
+ fileName: _jsxFileName$1,
864
+ lineNumber: 407
865
+ }
866
+ }, "Numeric - Fractions"), React$2.createElement(MenuItem, {
867
+ value: 1,
868
+ __self: this,
869
+ __source: {
870
+ fileName: _jsxFileName$1,
871
+ lineNumber: 408
872
+ }
873
+ }, "Grade 1 - 2"), React$2.createElement(MenuItem, {
874
+ value: 3,
875
+ __self: this,
876
+ __source: {
877
+ fileName: _jsxFileName$1,
878
+ lineNumber: 409
879
+ }
880
+ }, "Grade 3 - 5"), React$2.createElement(MenuItem, {
881
+ value: 6,
882
+ __self: this,
883
+ __source: {
884
+ fileName: _jsxFileName$1,
885
+ lineNumber: 410
886
+ }
887
+ }, "Grade 6 - 7"), React$2.createElement(MenuItem, {
888
+ value: 8,
889
+ __self: this,
890
+ __source: {
891
+ fileName: _jsxFileName$1,
892
+ lineNumber: 411
893
+ }
894
+ }, "Grade 8 - HS"), React$2.createElement(MenuItem, {
895
+ value: 'geometry',
896
+ __self: this,
897
+ __source: {
898
+ fileName: _jsxFileName$1,
899
+ lineNumber: 412
900
+ }
901
+ }, "Geometry"), React$2.createElement(MenuItem, {
902
+ value: 'advanced-algebra',
903
+ __self: this,
904
+ __source: {
905
+ fileName: _jsxFileName$1,
906
+ lineNumber: 413
907
+ }
908
+ }, "Advanced Algebra"), React$2.createElement(MenuItem, {
909
+ value: 'statistics',
910
+ __self: this,
911
+ __source: {
912
+ fileName: _jsxFileName$1,
913
+ lineNumber: 414
914
+ }
915
+ }, "Statistics"), React$2.createElement(MenuItem, {
916
+ value: 'item-authoring',
917
+ __self: this,
918
+ __source: {
919
+ fileName: _jsxFileName$1,
920
+ lineNumber: 415
921
+ }
922
+ }, "Item Authoring"))), React$2.createElement('div', {
923
+ className: classes.inputContainer,
924
+ key: "templateHolder",
925
+ __self: this,
926
+ __source: {
927
+ fileName: _jsxFileName$1,
928
+ lineNumber: 418
929
+ }
930
+ }, React$2.createElement(InputLabel, {
931
+ className: classes.templateTitle,
932
+ __self: this,
933
+ __source: {
934
+ fileName: _jsxFileName$1,
935
+ lineNumber: 419
936
+ }
937
+ }, "RESPONSE TEMPLATE"), React$2.createElement(MathToolbar, {
938
+ classNames: classNames,
939
+ allowAnswerBlock: true,
940
+ keypadMode: promptEquationEditor,
941
+ controlledKeypad: true,
942
+ showKeypad: showKeypad,
943
+ latex: prepareForStatic(expression) || '',
944
+ onChange: this.onChange('expression'),
945
+ onFocus: this.onFocus,
946
+ onDone: this.onDone,
947
+ __self: this,
948
+ __source: {
949
+ fileName: _jsxFileName$1,
950
+ lineNumber: 422
951
+ }
952
+ }))], React$2.createElement('h3', {
953
+ __self: this,
954
+ __source: {
955
+ fileName: _jsxFileName$1,
956
+ lineNumber: 435
957
+ }
958
+ }, "Define Correct Response"), React$2.createElement('div', {
959
+ className: classes.flexContainer,
960
+ __self: this,
961
+ __source: {
962
+ fileName: _jsxFileName$1,
963
+ lineNumber: 436
964
+ }
965
+ }, React$2.createElement(InputContainer$1, {
966
+ label: "Equation Editor",
967
+ className: classes.selectContainer,
968
+ __self: this,
969
+ __source: {
970
+ fileName: _jsxFileName$1,
971
+ lineNumber: 437
972
+ }
973
+ }, React$2.createElement(Select, {
974
+ className: classes.select,
975
+ onChange: this.onChange('equationEditor'),
976
+ value: equationEditor,
977
+ __self: this,
978
+ __source: {
979
+ fileName: _jsxFileName$1,
980
+ lineNumber: 441
981
+ }
982
+ }, React$2.createElement(MenuItem, {
983
+ value: "non-negative-integers",
984
+ __self: this,
985
+ __source: {
986
+ fileName: _jsxFileName$1,
987
+ lineNumber: 446
988
+ }
989
+ }, "Numeric - Non-Negative Integers"), React$2.createElement(MenuItem, {
990
+ value: "integers",
991
+ __self: this,
992
+ __source: {
993
+ fileName: _jsxFileName$1,
994
+ lineNumber: 447
995
+ }
996
+ }, "Numeric - Integers"), React$2.createElement(MenuItem, {
997
+ value: "decimals",
998
+ __self: this,
999
+ __source: {
1000
+ fileName: _jsxFileName$1,
1001
+ lineNumber: 448
1002
+ }
1003
+ }, "Numeric - Decimals"), React$2.createElement(MenuItem, {
1004
+ value: "fractions",
1005
+ __self: this,
1006
+ __source: {
1007
+ fileName: _jsxFileName$1,
1008
+ lineNumber: 449
1009
+ }
1010
+ }, "Numeric - Fractions"), React$2.createElement(MenuItem, {
1011
+ value: 1,
1012
+ __self: this,
1013
+ __source: {
1014
+ fileName: _jsxFileName$1,
1015
+ lineNumber: 450
1016
+ }
1017
+ }, "Grade 1 - 2"), React$2.createElement(MenuItem, {
1018
+ value: 3,
1019
+ __self: this,
1020
+ __source: {
1021
+ fileName: _jsxFileName$1,
1022
+ lineNumber: 451
1023
+ }
1024
+ }, "Grade 3 - 5"), React$2.createElement(MenuItem, {
1025
+ value: 6,
1026
+ __self: this,
1027
+ __source: {
1028
+ fileName: _jsxFileName$1,
1029
+ lineNumber: 452
1030
+ }
1031
+ }, "Grade 6 - 7"), React$2.createElement(MenuItem, {
1032
+ value: 8,
1033
+ __self: this,
1034
+ __source: {
1035
+ fileName: _jsxFileName$1,
1036
+ lineNumber: 453
1037
+ }
1038
+ }, "Grade 8 - HS"), React$2.createElement(MenuItem, {
1039
+ value: 'geometry',
1040
+ __self: this,
1041
+ __source: {
1042
+ fileName: _jsxFileName$1,
1043
+ lineNumber: 454
1044
+ }
1045
+ }, "Geometry"), React$2.createElement(MenuItem, {
1046
+ value: 'advanced-algebra',
1047
+ __self: this,
1048
+ __source: {
1049
+ fileName: _jsxFileName$1,
1050
+ lineNumber: 455
1051
+ }
1052
+ }, "Advanced Algebra"), React$2.createElement(MenuItem, {
1053
+ value: 'statistics',
1054
+ __self: this,
1055
+ __source: {
1056
+ fileName: _jsxFileName$1,
1057
+ lineNumber: 456
1058
+ }
1059
+ }, "Statistics"), React$2.createElement(MenuItem, {
1060
+ value: 'item-authoring',
1061
+ __self: this,
1062
+ __source: {
1063
+ fileName: _jsxFileName$1,
1064
+ lineNumber: 457
1065
+ }
1066
+ }, "Item Authoring")))), responsesToUse.map((response, idx) => React$2.createElement(Response$1, {
1067
+ key: response.id,
1068
+ mode: equationEditor,
1069
+ response: response,
1070
+ defaultResponse: responseType === ResponseTypes.simple,
1071
+ onResponseChange: this.onResponseChange,
1072
+ index: idx,
1073
+ cIgnoreOrder: cIgnoreOrder,
1074
+ cAllowTrailingZeros: cAllowTrailingZeros,
1075
+ __self: this,
1076
+ __source: {
1077
+ fileName: _jsxFileName$1,
1078
+ lineNumber: 462
1079
+ }
1080
+ })));
1081
+ }
1082
+ }
1083
+ GeneralConfigBlock.__initStatic();
1084
+ var GeneralConfigBlock$1 = withStyles$1(styles$1)(GeneralConfigBlock);
1085
+ const React$1 = _dll_react;
1086
+ const {withStyles: withStyles} = _dll_material_ui__core_styles;
1087
+ const PropTypes = _dll_prop_types;
1088
+ const debug$1 = _dll_debug;
1089
+ const {FeedbackConfig: FeedbackConfig} = _dll_pie_lib__config_ui;
1090
+ const {settings: settings} = _dll_pie_lib__config_ui;
1091
+ const {layout: layout} = _dll_pie_lib__config_ui;
1092
+ const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
1093
+ const EditableHtml = _dll_pie_lib__editable_html;
1094
+ const _jsxFileName = "/home/circleci/repo/packages/math-inline/configure/src/configure.jsx";
1095
+ const log$1 = debug$1('@pie-element:math-inline:configure');
1096
+ const {Panel, toggle, radio} = settings;
1097
+ const styles = theme => ({
1098
+ title: {
1099
+ fontSize: '1.1rem',
1100
+ display: 'block',
1101
+ marginTop: theme.spacing.unit * 2,
1102
+ marginBottom: theme.spacing.unit
1103
+ },
1104
+ content: {
1105
+ marginTop: theme.spacing.unit * 2
1106
+ },
1107
+ promptHolder: {
1108
+ width: '100%',
1109
+ paddingTop: theme.spacing.unit * 2
1110
+ },
1111
+ prompt: {
1112
+ paddingTop: theme.spacing.unit * 2,
1113
+ width: '100%'
1114
+ }
1115
+ });
1116
+ class Configure extends React$1.Component {
1117
+ constructor(...args) {
1118
+ super(...args);
1119
+ Configure.prototype.__init.call(this);
1120
+ Configure.prototype.__init2.call(this);
1121
+ Configure.prototype.__init3.call(this);
1122
+ }
1123
+ static __initStatic() {
1124
+ this.propTypes = {
1125
+ onModelChanged: PropTypes.func,
1126
+ onConfigurationChanged: PropTypes.func,
1127
+ classes: PropTypes.object,
1128
+ model: PropTypes.object.isRequired,
1129
+ configuration: PropTypes.object.isRequired,
1130
+ imageSupport: PropTypes.object
1131
+ };
1132
+ }
1133
+ __init() {
1134
+ this.onChange = model => {
1135
+ this.props.onModelChanged(model);
1136
+ };
1137
+ }
1138
+ __init2() {
1139
+ this.changeTeacherInstructions = teacherInstructions => {
1140
+ this.props.onModelChanged({
1141
+ ...this.props.model,
1142
+ teacherInstructions
1143
+ });
1144
+ };
1145
+ }
1146
+ __init3() {
1147
+ this.onFeedbackChange = feedback => {
1148
+ const {model, onModelChanged} = this.props;
1149
+ model.feedback = feedback;
1150
+ onModelChanged(model);
1151
+ };
1152
+ }
1153
+ render() {
1154
+ const {classes, model, imageSupport, onModelChanged, configuration, onConfigurationChanged} = this.props;
1155
+ const {feedback = {}, responseType = {}, teacherInstructions = {}, studentInstructions = {}, rationale = {}, prompt = {}, scoringType = {}, ignoreOrder = {}, allowTrailingZeros = {}} = configuration || ({});
1156
+ log$1('[render] model', model);
1157
+ const {rationaleEnabled, promptEnabled, teacherInstructionsEnabled, feedbackEnabled} = model || ({});
1158
+ const toolbarOpts = {};
1159
+ switch (model.toolbarEditorPosition) {
1160
+ case 'top':
1161
+ toolbarOpts.position = 'top';
1162
+ break;
1163
+ default:
1164
+ toolbarOpts.position = 'bottom';
1165
+ break;
1166
+ }
1167
+ return React$1.createElement('div', {
1168
+ __self: this,
1169
+ __source: {
1170
+ fileName: _jsxFileName,
1171
+ lineNumber: 92
1172
+ }
1173
+ }, React$1.createElement(layout.ConfigLayout, {
1174
+ settings: React$1.createElement(Panel, {
1175
+ model: model,
1176
+ configuration: configuration,
1177
+ onChangeModel: model => onModelChanged(model),
1178
+ onChangeConfiguration: config => onConfigurationChanged(config),
1179
+ groups: {
1180
+ 'Settings': {
1181
+ responseType: responseType.settings && radio(responseType.label, [ResponseTypes.simple, ResponseTypes.advanced]),
1182
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
1183
+ 'promptEnabled': prompt.settings && toggle(prompt.label)
1184
+ },
1185
+ 'Properties': {
1186
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
1187
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
1188
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
1189
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
1190
+ 'ignoreOrder.enabled': ignoreOrder.settings && toggle(ignoreOrder.label),
1191
+ 'allowTrailingZeros.enabled': allowTrailingZeros.settings && toggle(allowTrailingZeros.label)
1192
+ }
1193
+ },
1194
+ __self: this,
1195
+ __source: {
1196
+ fileName: _jsxFileName,
1197
+ lineNumber: 95
1198
+ }
1199
+ }),
1200
+ __self: this,
1201
+ __source: {
1202
+ fileName: _jsxFileName,
1203
+ lineNumber: 93
1204
+ }
1205
+ }, React$1.createElement('div', {
1206
+ __self: this,
1207
+ __source: {
1208
+ fileName: _jsxFileName,
1209
+ lineNumber: 126
1210
+ }
1211
+ }, React$1.createElement('div', {
1212
+ className: classes.content,
1213
+ __self: this,
1214
+ __source: {
1215
+ fileName: _jsxFileName,
1216
+ lineNumber: 127
1217
+ }
1218
+ }, teacherInstructionsEnabled && React$1.createElement(InputContainer, {
1219
+ label: teacherInstructions.label,
1220
+ className: classes.promptHolder,
1221
+ __self: this,
1222
+ __source: {
1223
+ fileName: _jsxFileName,
1224
+ lineNumber: 129
1225
+ }
1226
+ }, React$1.createElement(EditableHtml, {
1227
+ className: classes.prompt,
1228
+ markup: model.teacherInstructions || '',
1229
+ onChange: this.changeTeacherInstructions,
1230
+ imageSupport: imageSupport,
1231
+ nonEmpty: false,
1232
+ toolbarOpts: toolbarOpts,
1233
+ __self: this,
1234
+ __source: {
1235
+ fileName: _jsxFileName,
1236
+ lineNumber: 130
1237
+ }
1238
+ })), React$1.createElement(GeneralConfigBlock$1, {
1239
+ imageSupport: imageSupport,
1240
+ model: model,
1241
+ configuration: configuration,
1242
+ onChange: this.onChange,
1243
+ rationaleEnabled: rationaleEnabled,
1244
+ promptEnabled: promptEnabled,
1245
+ toolbarOpts: toolbarOpts,
1246
+ __self: this,
1247
+ __source: {
1248
+ fileName: _jsxFileName,
1249
+ lineNumber: 141
1250
+ }
1251
+ }), feedbackEnabled && React$1.createElement(FeedbackConfig, {
1252
+ feedback: model.feedback,
1253
+ onChange: this.onFeedbackChange,
1254
+ toolbarOpts: toolbarOpts,
1255
+ __self: this,
1256
+ __source: {
1257
+ fileName: _jsxFileName,
1258
+ lineNumber: 152
1259
+ }
1260
+ })))));
1261
+ }
1262
+ }
1263
+ Configure.__initStatic();
1264
+ var Configure$1 = withStyles(styles)(Configure);
1265
+ var lib = {};
1266
+ Object.defineProperty(lib, "__esModule", {
1267
+ value: true
1268
+ });
1269
+ class ModelUpdatedEvent extends CustomEvent {
1270
+ constructor(update, reset = false) {
1271
+ super(ModelUpdatedEvent.TYPE, {
1272
+ bubbles: true,
1273
+ detail: {
1274
+ update,
1275
+ reset
1276
+ }
1277
+ });
1278
+ this.update = update;
1279
+ this.reset = reset;
1280
+ }
1281
+ }
1282
+ ModelUpdatedEvent.TYPE = 'model.updated';
1283
+ var ModelUpdatedEvent_1 = lib.ModelUpdatedEvent = ModelUpdatedEvent;
1284
+ class DeleteImageEvent extends CustomEvent {
1285
+ constructor(src, done) {
1286
+ super(DeleteImageEvent.TYPE, {
1287
+ bubbles: true,
1288
+ detail: {
1289
+ src,
1290
+ done
1291
+ }
1292
+ });
1293
+ this.src = src;
1294
+ this.done = done;
1295
+ }
1296
+ }
1297
+ DeleteImageEvent.TYPE = 'delete.image';
1298
+ var DeleteImageEvent_1 = lib.DeleteImageEvent = DeleteImageEvent;
1299
+ class InsertImageEvent extends CustomEvent {
1300
+ constructor(handler) {
1301
+ super(InsertImageEvent.TYPE, {
1302
+ bubbles: true,
1303
+ detail: handler
1304
+ });
1305
+ this.handler = handler;
1306
+ }
1307
+ }
1308
+ InsertImageEvent.TYPE = 'insert.image';
1309
+ var InsertImageEvent_1 = lib.InsertImageEvent = InsertImageEvent;
1310
+ var defaults = {
1311
+ model: {
1312
+ partialScoring: true,
1313
+ responseType: ResponseTypes.advanced,
1314
+ element: 'math-inline',
1315
+ feedback: {
1316
+ correct: {
1317
+ default: 'Correct',
1318
+ type: 'none'
1319
+ },
1320
+ incorrect: {
1321
+ default: 'Incorrect',
1322
+ type: 'none'
1323
+ },
1324
+ partial: {
1325
+ default: 'Nearly',
1326
+ type: 'none'
1327
+ }
1328
+ },
1329
+ equationEditor: '8',
1330
+ expression: '',
1331
+ rationale: 'Rationale goes here.',
1332
+ note: 'The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.',
1333
+ prompt: '',
1334
+ responses: [],
1335
+ customKeys: [],
1336
+ scoringType: 'auto',
1337
+ feedbackEnabled: true,
1338
+ promptEnabled: true,
1339
+ rationaleEnabled: true,
1340
+ teacherInstructionsEnabled: true,
1341
+ studentInstructionsEnabled: true,
1342
+ toolbarEditorPosition: 'bottom',
1343
+ validationDefault: 'literal',
1344
+ ignoreOrderDefault: false,
1345
+ allowTrailingZerosDefault: false
1346
+ },
1347
+ configuration: {
1348
+ prompt: {
1349
+ settings: true,
1350
+ label: 'Prompt'
1351
+ },
1352
+ feedback: {
1353
+ settings: true,
1354
+ label: 'Feedback'
1355
+ },
1356
+ responseType: {
1357
+ settings: true,
1358
+ label: 'Response type'
1359
+ },
1360
+ rationale: {
1361
+ settings: true,
1362
+ label: 'Rationale'
1363
+ },
1364
+ scoringType: {
1365
+ settings: false,
1366
+ label: 'Scoring Type'
1367
+ },
1368
+ studentInstructions: {
1369
+ settings: false,
1370
+ label: 'Student Instructions'
1371
+ },
1372
+ teacherInstructions: {
1373
+ settings: true,
1374
+ label: 'Teacher Instructions'
1375
+ },
1376
+ partialScoring: {
1377
+ settings: false,
1378
+ label: 'Allow Partial Scoring'
1379
+ },
1380
+ ignoreOrder: {
1381
+ settings: false,
1382
+ label: 'Ignore Order',
1383
+ enabled: true
1384
+ },
1385
+ allowTrailingZeros: {
1386
+ settings: false,
1387
+ label: 'Allow Trailing Zeros',
1388
+ enabled: true
1389
+ }
1390
+ }
1391
+ };
1392
+ const React = _dll_react;
1393
+ const ReactDOM = _dll_react_dom;
1394
+ const {isEmpty: isEmpty} = _dll_lodash;
1395
+ const debug = _dll_debug;
1396
+ const log = debug('pie-elements:math-inline:configure');
1397
+ class MathInlineConfigure extends HTMLElement {
1398
+ static __initStatic() {
1399
+ this.createDefaultModel = (model = {}) => {
1400
+ if (!isEmpty(model.responses)) {
1401
+ model.responses = model.responses.map(correctResponse => ({
1402
+ ...correctResponse,
1403
+ validation: correctResponse.validation || defaults.model.validationDefault,
1404
+ allowTrailingZeros: correctResponse.allowTrailingZeros || defaults.model.allowTrailingZerosDefault,
1405
+ ignoreOrder: correctResponse.ignoreOrder || defaults.model.ignoreOrderDefault || false
1406
+ }));
1407
+ }
1408
+ return {
1409
+ ...defaults.model,
1410
+ ...model
1411
+ };
1412
+ };
1413
+ }
1414
+ constructor() {
1415
+ super();
1416
+ this._model = MathInlineConfigure.createDefaultModel();
1417
+ this._configuration = defaults.configuration;
1418
+ }
1419
+ set model(m) {
1420
+ this._model = MathInlineConfigure.createDefaultModel(m);
1421
+ this._render();
1422
+ }
1423
+ set configuration(c) {
1424
+ this._configuration = c;
1425
+ this._render();
1426
+ }
1427
+ onModelChanged(model) {
1428
+ this._model = model;
1429
+ log('[onModelChanged]: ', this._model);
1430
+ this._render();
1431
+ this.dispatchEvent(new ModelUpdatedEvent_1(this._model));
1432
+ }
1433
+ onConfigurationChanged(c) {
1434
+ this._configuration = c;
1435
+ if (this._model) {
1436
+ this.onModelChanged(this._model);
1437
+ }
1438
+ this._render();
1439
+ }
1440
+ insertImage(handler) {
1441
+ this.dispatchEvent(new InsertImageEvent_1(handler));
1442
+ }
1443
+ onDeleteImage(src, done) {
1444
+ this.dispatchEvent(new DeleteImageEvent_1(src, done));
1445
+ }
1446
+ _render() {
1447
+ if (this._model) {
1448
+ const el = React.createElement(Configure$1, {
1449
+ onModelChanged: this.onModelChanged.bind(this),
1450
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
1451
+ model: this._model,
1452
+ configuration: this._configuration,
1453
+ imageSupport: {
1454
+ add: this.insertImage.bind(this),
1455
+ delete: this.onDeleteImage.bind(this)
1456
+ }
1457
+ });
1458
+ ReactDOM.render(el, this);
1459
+ }
1460
+ }
1461
+ }
1462
+ MathInlineConfigure.__initStatic();
1463
+ export {MathInlineConfigure as default};