@pie-element/ebsr 7.0.13 → 7.0.17

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,2175 @@
1
+ import {_dll_prop_types, _dll_react_dom, _dll_react, _dll_material_ui__core_styles, _dll_pie_lib__render_ui, _dll_material_ui__core, _dll_classnames, _dll_pie_lib__correct_answer_toggle, _dll_lodash, _dll_debug} from "../../../@pie-lib/shared-module@^1.4.1/module/index.js";
2
+ import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.0.26/module/index.js";
3
+ function getDefaultExportFromCjs(x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+ function getAugmentedNamespace(n) {
7
+ if (n.__esModule) return n;
8
+ var a = Object.defineProperty({}, '__esModule', {
9
+ value: true
10
+ });
11
+ Object.keys(n).forEach(function (k) {
12
+ var d = Object.getOwnPropertyDescriptor(n, k);
13
+ Object.defineProperty(a, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: function () {
16
+ return n[k];
17
+ }
18
+ });
19
+ });
20
+ return a;
21
+ }
22
+ var CSSTransition = {
23
+ exports: {}
24
+ };
25
+ var addClass = {
26
+ exports: {}
27
+ };
28
+ var interopRequireDefault = {
29
+ exports: {}
30
+ };
31
+ (function (module) {
32
+ function _interopRequireDefault(obj) {
33
+ return obj && obj.__esModule ? obj : {
34
+ "default": obj
35
+ };
36
+ }
37
+ module.exports = _interopRequireDefault;
38
+ (module.exports["default"] = module.exports, module.exports.__esModule = true);
39
+ })(interopRequireDefault);
40
+ getDefaultExportFromCjs(interopRequireDefault.exports);
41
+ var hasClass = {
42
+ exports: {}
43
+ };
44
+ (function (module, exports) {
45
+ exports.__esModule = true;
46
+ exports.default = hasClass;
47
+ function hasClass(element, className) {
48
+ if (element.classList) return !!className && element.classList.contains(className); else return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
49
+ }
50
+ module.exports = exports["default"];
51
+ })(hasClass, hasClass.exports);
52
+ getDefaultExportFromCjs(hasClass.exports);
53
+ (function (module, exports) {
54
+ var _interopRequireDefault = interopRequireDefault.exports;
55
+ exports.__esModule = true;
56
+ exports.default = addClass;
57
+ var _hasClass = _interopRequireDefault(hasClass.exports);
58
+ function addClass(element, className) {
59
+ if (element.classList) element.classList.add(className); else if (!(0, _hasClass.default)(element, className)) if (typeof element.className === 'string') element.className = element.className + ' ' + className; else element.setAttribute('class', (element.className && element.className.baseVal || '') + ' ' + className);
60
+ }
61
+ module.exports = exports["default"];
62
+ })(addClass, addClass.exports);
63
+ getDefaultExportFromCjs(addClass.exports);
64
+ function replaceClassName(origClass, classToRemove) {
65
+ return origClass.replace(new RegExp('(^|\\s)' + classToRemove + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
66
+ }
67
+ var removeClass = function removeClass(element, className) {
68
+ if (element.classList) element.classList.remove(className); else if (typeof element.className === 'string') element.className = replaceClassName(element.className, className); else element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
69
+ };
70
+ var Transition$1 = {};
71
+ function componentWillMount() {
72
+ var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
73
+ if (state !== null && state !== undefined) {
74
+ this.setState(state);
75
+ }
76
+ }
77
+ function componentWillReceiveProps(nextProps) {
78
+ function updater(prevState) {
79
+ var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
80
+ return state !== null && state !== undefined ? state : null;
81
+ }
82
+ this.setState(updater.bind(this));
83
+ }
84
+ function componentWillUpdate(nextProps, nextState) {
85
+ try {
86
+ var prevProps = this.props;
87
+ var prevState = this.state;
88
+ this.props = nextProps;
89
+ this.state = nextState;
90
+ this.__reactInternalSnapshotFlag = true;
91
+ this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(prevProps, prevState);
92
+ } finally {
93
+ this.props = prevProps;
94
+ this.state = prevState;
95
+ }
96
+ }
97
+ componentWillMount.__suppressDeprecationWarning = true;
98
+ componentWillReceiveProps.__suppressDeprecationWarning = true;
99
+ componentWillUpdate.__suppressDeprecationWarning = true;
100
+ function polyfill(Component) {
101
+ var prototype = Component.prototype;
102
+ if (!prototype || !prototype.isReactComponent) {
103
+ throw new Error('Can only polyfill class components');
104
+ }
105
+ if (typeof Component.getDerivedStateFromProps !== 'function' && typeof prototype.getSnapshotBeforeUpdate !== 'function') {
106
+ return Component;
107
+ }
108
+ var foundWillMountName = null;
109
+ var foundWillReceivePropsName = null;
110
+ var foundWillUpdateName = null;
111
+ if (typeof prototype.componentWillMount === 'function') {
112
+ foundWillMountName = 'componentWillMount';
113
+ } else if (typeof prototype.UNSAFE_componentWillMount === 'function') {
114
+ foundWillMountName = 'UNSAFE_componentWillMount';
115
+ }
116
+ if (typeof prototype.componentWillReceiveProps === 'function') {
117
+ foundWillReceivePropsName = 'componentWillReceiveProps';
118
+ } else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {
119
+ foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
120
+ }
121
+ if (typeof prototype.componentWillUpdate === 'function') {
122
+ foundWillUpdateName = 'componentWillUpdate';
123
+ } else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {
124
+ foundWillUpdateName = 'UNSAFE_componentWillUpdate';
125
+ }
126
+ if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
127
+ var componentName = Component.displayName || Component.name;
128
+ var newApiName = typeof Component.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()';
129
+ throw Error('Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + componentName + ' uses ' + newApiName + ' but also contains the following legacy lifecycles:' + (foundWillMountName !== null ? '\n ' + foundWillMountName : '') + (foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '') + (foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') + '\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks');
130
+ }
131
+ if (typeof Component.getDerivedStateFromProps === 'function') {
132
+ prototype.componentWillMount = componentWillMount;
133
+ prototype.componentWillReceiveProps = componentWillReceiveProps;
134
+ }
135
+ if (typeof prototype.getSnapshotBeforeUpdate === 'function') {
136
+ if (typeof prototype.componentDidUpdate !== 'function') {
137
+ throw new Error('Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype');
138
+ }
139
+ prototype.componentWillUpdate = componentWillUpdate;
140
+ var componentDidUpdate = prototype.componentDidUpdate;
141
+ prototype.componentDidUpdate = function componentDidUpdatePolyfill(prevProps, prevState, maybeSnapshot) {
142
+ var snapshot = this.__reactInternalSnapshotFlag ? this.__reactInternalSnapshot : maybeSnapshot;
143
+ componentDidUpdate.call(this, prevProps, prevState, snapshot);
144
+ };
145
+ }
146
+ return Component;
147
+ }
148
+ var reactLifecyclesCompat_es = Object.freeze({
149
+ __proto__: null,
150
+ polyfill: polyfill
151
+ });
152
+ var require$$2$2 = getAugmentedNamespace(reactLifecyclesCompat_es);
153
+ var PropTypes$6 = {};
154
+ const require$$0$5 = _dll_prop_types;
155
+ PropTypes$6.__esModule = true;
156
+ PropTypes$6.classNamesShape = PropTypes$6.timeoutsShape = void 0;
157
+ var _propTypes = _interopRequireDefault$2(require$$0$5);
158
+ function _interopRequireDefault$2(obj) {
159
+ return obj && obj.__esModule ? obj : {
160
+ default: obj
161
+ };
162
+ }
163
+ var timeoutsShape = _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
164
+ enter: _propTypes.default.number,
165
+ exit: _propTypes.default.number,
166
+ appear: _propTypes.default.number
167
+ }).isRequired]);
168
+ PropTypes$6.timeoutsShape = timeoutsShape;
169
+ var classNamesShape = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({
170
+ enter: _propTypes.default.string,
171
+ exit: _propTypes.default.string,
172
+ active: _propTypes.default.string
173
+ }), _propTypes.default.shape({
174
+ enter: _propTypes.default.string,
175
+ enterDone: _propTypes.default.string,
176
+ enterActive: _propTypes.default.string,
177
+ exit: _propTypes.default.string,
178
+ exitDone: _propTypes.default.string,
179
+ exitActive: _propTypes.default.string
180
+ })]);
181
+ PropTypes$6.classNamesShape = classNamesShape;
182
+ const require$$0$4 = _dll_prop_types;
183
+ const require$$1$2 = _dll_react;
184
+ const require$$2$1 = _dll_react_dom;
185
+ Transition$1.__esModule = true;
186
+ Transition$1.default = Transition$1.EXITING = Transition$1.ENTERED = Transition$1.ENTERING = Transition$1.EXITED = Transition$1.UNMOUNTED = void 0;
187
+ var PropTypes$5 = _interopRequireWildcard(require$$0$4);
188
+ var _react$1 = _interopRequireDefault$1(require$$1$2);
189
+ var _reactDom = _interopRequireDefault$1(require$$2$1);
190
+ var _reactLifecyclesCompat = require$$2$2;
191
+ var _PropTypes = PropTypes$6;
192
+ function _interopRequireDefault$1(obj) {
193
+ return obj && obj.__esModule ? obj : {
194
+ default: obj
195
+ };
196
+ }
197
+ function _interopRequireWildcard(obj) {
198
+ if (obj && obj.__esModule) {
199
+ return obj;
200
+ } else {
201
+ var newObj = {};
202
+ if (obj != null) {
203
+ for (var key in obj) {
204
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
205
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
206
+ if (desc.get || desc.set) {
207
+ Object.defineProperty(newObj, key, desc);
208
+ } else {
209
+ newObj[key] = obj[key];
210
+ }
211
+ }
212
+ }
213
+ }
214
+ newObj.default = obj;
215
+ return newObj;
216
+ }
217
+ }
218
+ function _objectWithoutPropertiesLoose(source, excluded) {
219
+ if (source == null) return {};
220
+ var target = {};
221
+ var sourceKeys = Object.keys(source);
222
+ var key, i;
223
+ for (i = 0; i < sourceKeys.length; i++) {
224
+ key = sourceKeys[i];
225
+ if (excluded.indexOf(key) >= 0) continue;
226
+ target[key] = source[key];
227
+ }
228
+ return target;
229
+ }
230
+ function _inheritsLoose(subClass, superClass) {
231
+ subClass.prototype = Object.create(superClass.prototype);
232
+ subClass.prototype.constructor = subClass;
233
+ subClass.__proto__ = superClass;
234
+ }
235
+ var UNMOUNTED = 'unmounted';
236
+ Transition$1.UNMOUNTED = UNMOUNTED;
237
+ var EXITED = 'exited';
238
+ Transition$1.EXITED = EXITED;
239
+ var ENTERING = 'entering';
240
+ Transition$1.ENTERING = ENTERING;
241
+ var ENTERED = 'entered';
242
+ Transition$1.ENTERED = ENTERED;
243
+ var EXITING = 'exiting';
244
+ Transition$1.EXITING = EXITING;
245
+ var Transition = (function (_React$Component) {
246
+ _inheritsLoose(Transition, _React$Component);
247
+ function Transition(props, context) {
248
+ var _this;
249
+ _this = _React$Component.call(this, props, context) || this;
250
+ var parentGroup = context.transitionGroup;
251
+ var appear = parentGroup && !parentGroup.isMounting ? props.enter : props.appear;
252
+ var initialStatus;
253
+ _this.appearStatus = null;
254
+ if (props.in) {
255
+ if (appear) {
256
+ initialStatus = EXITED;
257
+ _this.appearStatus = ENTERING;
258
+ } else {
259
+ initialStatus = ENTERED;
260
+ }
261
+ } else {
262
+ if (props.unmountOnExit || props.mountOnEnter) {
263
+ initialStatus = UNMOUNTED;
264
+ } else {
265
+ initialStatus = EXITED;
266
+ }
267
+ }
268
+ _this.state = {
269
+ status: initialStatus
270
+ };
271
+ _this.nextCallback = null;
272
+ return _this;
273
+ }
274
+ var _proto = Transition.prototype;
275
+ _proto.getChildContext = function getChildContext() {
276
+ return {
277
+ transitionGroup: null
278
+ };
279
+ };
280
+ Transition.getDerivedStateFromProps = function getDerivedStateFromProps(_ref, prevState) {
281
+ var nextIn = _ref.in;
282
+ if (nextIn && prevState.status === UNMOUNTED) {
283
+ return {
284
+ status: EXITED
285
+ };
286
+ }
287
+ return null;
288
+ };
289
+ _proto.componentDidMount = function componentDidMount() {
290
+ this.updateStatus(true, this.appearStatus);
291
+ };
292
+ _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
293
+ var nextStatus = null;
294
+ if (prevProps !== this.props) {
295
+ var status = this.state.status;
296
+ if (this.props.in) {
297
+ if (status !== ENTERING && status !== ENTERED) {
298
+ nextStatus = ENTERING;
299
+ }
300
+ } else {
301
+ if (status === ENTERING || status === ENTERED) {
302
+ nextStatus = EXITING;
303
+ }
304
+ }
305
+ }
306
+ this.updateStatus(false, nextStatus);
307
+ };
308
+ _proto.componentWillUnmount = function componentWillUnmount() {
309
+ this.cancelNextCallback();
310
+ };
311
+ _proto.getTimeouts = function getTimeouts() {
312
+ var timeout = this.props.timeout;
313
+ var exit, enter, appear;
314
+ exit = enter = appear = timeout;
315
+ if (timeout != null && typeof timeout !== 'number') {
316
+ exit = timeout.exit;
317
+ enter = timeout.enter;
318
+ appear = timeout.appear !== undefined ? timeout.appear : enter;
319
+ }
320
+ return {
321
+ exit: exit,
322
+ enter: enter,
323
+ appear: appear
324
+ };
325
+ };
326
+ _proto.updateStatus = function updateStatus(mounting, nextStatus) {
327
+ if (mounting === void 0) {
328
+ mounting = false;
329
+ }
330
+ if (nextStatus !== null) {
331
+ this.cancelNextCallback();
332
+ var node = _reactDom.default.findDOMNode(this);
333
+ if (nextStatus === ENTERING) {
334
+ this.performEnter(node, mounting);
335
+ } else {
336
+ this.performExit(node);
337
+ }
338
+ } else if (this.props.unmountOnExit && this.state.status === EXITED) {
339
+ this.setState({
340
+ status: UNMOUNTED
341
+ });
342
+ }
343
+ };
344
+ _proto.performEnter = function performEnter(node, mounting) {
345
+ var _this2 = this;
346
+ var enter = this.props.enter;
347
+ var appearing = this.context.transitionGroup ? this.context.transitionGroup.isMounting : mounting;
348
+ var timeouts = this.getTimeouts();
349
+ var enterTimeout = appearing ? timeouts.appear : timeouts.enter;
350
+ if (!mounting && !enter) {
351
+ this.safeSetState({
352
+ status: ENTERED
353
+ }, function () {
354
+ _this2.props.onEntered(node);
355
+ });
356
+ return;
357
+ }
358
+ this.props.onEnter(node, appearing);
359
+ this.safeSetState({
360
+ status: ENTERING
361
+ }, function () {
362
+ _this2.props.onEntering(node, appearing);
363
+ _this2.onTransitionEnd(node, enterTimeout, function () {
364
+ _this2.safeSetState({
365
+ status: ENTERED
366
+ }, function () {
367
+ _this2.props.onEntered(node, appearing);
368
+ });
369
+ });
370
+ });
371
+ };
372
+ _proto.performExit = function performExit(node) {
373
+ var _this3 = this;
374
+ var exit = this.props.exit;
375
+ var timeouts = this.getTimeouts();
376
+ if (!exit) {
377
+ this.safeSetState({
378
+ status: EXITED
379
+ }, function () {
380
+ _this3.props.onExited(node);
381
+ });
382
+ return;
383
+ }
384
+ this.props.onExit(node);
385
+ this.safeSetState({
386
+ status: EXITING
387
+ }, function () {
388
+ _this3.props.onExiting(node);
389
+ _this3.onTransitionEnd(node, timeouts.exit, function () {
390
+ _this3.safeSetState({
391
+ status: EXITED
392
+ }, function () {
393
+ _this3.props.onExited(node);
394
+ });
395
+ });
396
+ });
397
+ };
398
+ _proto.cancelNextCallback = function cancelNextCallback() {
399
+ if (this.nextCallback !== null) {
400
+ this.nextCallback.cancel();
401
+ this.nextCallback = null;
402
+ }
403
+ };
404
+ _proto.safeSetState = function safeSetState(nextState, callback) {
405
+ callback = this.setNextCallback(callback);
406
+ this.setState(nextState, callback);
407
+ };
408
+ _proto.setNextCallback = function setNextCallback(callback) {
409
+ var _this4 = this;
410
+ var active = true;
411
+ this.nextCallback = function (event) {
412
+ if (active) {
413
+ active = false;
414
+ _this4.nextCallback = null;
415
+ callback(event);
416
+ }
417
+ };
418
+ this.nextCallback.cancel = function () {
419
+ active = false;
420
+ };
421
+ return this.nextCallback;
422
+ };
423
+ _proto.onTransitionEnd = function onTransitionEnd(node, timeout, handler) {
424
+ this.setNextCallback(handler);
425
+ var doesNotHaveTimeoutOrListener = timeout == null && !this.props.addEndListener;
426
+ if (!node || doesNotHaveTimeoutOrListener) {
427
+ setTimeout(this.nextCallback, 0);
428
+ return;
429
+ }
430
+ if (this.props.addEndListener) {
431
+ this.props.addEndListener(node, this.nextCallback);
432
+ }
433
+ if (timeout != null) {
434
+ setTimeout(this.nextCallback, timeout);
435
+ }
436
+ };
437
+ _proto.render = function render() {
438
+ var status = this.state.status;
439
+ if (status === UNMOUNTED) {
440
+ return null;
441
+ }
442
+ var _this$props = this.props, children = _this$props.children, childProps = _objectWithoutPropertiesLoose(_this$props, ["children"]);
443
+ delete childProps.in;
444
+ delete childProps.mountOnEnter;
445
+ delete childProps.unmountOnExit;
446
+ delete childProps.appear;
447
+ delete childProps.enter;
448
+ delete childProps.exit;
449
+ delete childProps.timeout;
450
+ delete childProps.addEndListener;
451
+ delete childProps.onEnter;
452
+ delete childProps.onEntering;
453
+ delete childProps.onEntered;
454
+ delete childProps.onExit;
455
+ delete childProps.onExiting;
456
+ delete childProps.onExited;
457
+ if (typeof children === 'function') {
458
+ return children(status, childProps);
459
+ }
460
+ var child = _react$1.default.Children.only(children);
461
+ return _react$1.default.cloneElement(child, childProps);
462
+ };
463
+ return Transition;
464
+ })(_react$1.default.Component);
465
+ Transition.contextTypes = {
466
+ transitionGroup: PropTypes$5.object
467
+ };
468
+ Transition.childContextTypes = {
469
+ transitionGroup: function transitionGroup() {}
470
+ };
471
+ Transition.propTypes = {
472
+ children: PropTypes$5.oneOfType([PropTypes$5.func.isRequired, PropTypes$5.element.isRequired]).isRequired,
473
+ in: PropTypes$5.bool,
474
+ mountOnEnter: PropTypes$5.bool,
475
+ unmountOnExit: PropTypes$5.bool,
476
+ appear: PropTypes$5.bool,
477
+ enter: PropTypes$5.bool,
478
+ exit: PropTypes$5.bool,
479
+ timeout: function timeout(props) {
480
+ var pt = _PropTypes.timeoutsShape;
481
+ if (!props.addEndListener) pt = pt.isRequired;
482
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
483
+ args[_key - 1] = arguments[_key];
484
+ }
485
+ return pt.apply(void 0, [props].concat(args));
486
+ },
487
+ addEndListener: PropTypes$5.func,
488
+ onEnter: PropTypes$5.func,
489
+ onEntering: PropTypes$5.func,
490
+ onEntered: PropTypes$5.func,
491
+ onExit: PropTypes$5.func,
492
+ onExiting: PropTypes$5.func,
493
+ onExited: PropTypes$5.func
494
+ };
495
+ function noop() {}
496
+ Transition.defaultProps = {
497
+ in: false,
498
+ mountOnEnter: false,
499
+ unmountOnExit: false,
500
+ appear: false,
501
+ enter: true,
502
+ exit: true,
503
+ onEnter: noop,
504
+ onEntering: noop,
505
+ onEntered: noop,
506
+ onExit: noop,
507
+ onExiting: noop,
508
+ onExited: noop
509
+ };
510
+ Transition.UNMOUNTED = 0;
511
+ Transition.EXITED = 1;
512
+ Transition.ENTERING = 2;
513
+ Transition.ENTERED = 3;
514
+ Transition.EXITING = 4;
515
+ var _default = (0, _reactLifecyclesCompat.polyfill)(Transition);
516
+ Transition$1.default = _default;
517
+ const require$$0$3 = _dll_prop_types;
518
+ const require$$3 = _dll_react;
519
+ (function (module, exports) {
520
+ exports.__esModule = true;
521
+ exports.default = void 0;
522
+ var PropTypes = _interopRequireWildcard(require$$0$3);
523
+ var _addClass = _interopRequireDefault(addClass.exports);
524
+ var _removeClass = _interopRequireDefault(removeClass);
525
+ var _react = _interopRequireDefault(require$$3);
526
+ var _Transition = _interopRequireDefault(Transition$1);
527
+ var _PropTypes = PropTypes$6;
528
+ function _interopRequireDefault(obj) {
529
+ return obj && obj.__esModule ? obj : {
530
+ default: obj
531
+ };
532
+ }
533
+ function _interopRequireWildcard(obj) {
534
+ if (obj && obj.__esModule) {
535
+ return obj;
536
+ } else {
537
+ var newObj = {};
538
+ if (obj != null) {
539
+ for (var key in obj) {
540
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
541
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
542
+ if (desc.get || desc.set) {
543
+ Object.defineProperty(newObj, key, desc);
544
+ } else {
545
+ newObj[key] = obj[key];
546
+ }
547
+ }
548
+ }
549
+ }
550
+ newObj.default = obj;
551
+ return newObj;
552
+ }
553
+ }
554
+ function _extends() {
555
+ _extends = Object.assign || (function (target) {
556
+ for (var i = 1; i < arguments.length; i++) {
557
+ var source = arguments[i];
558
+ for (var key in source) {
559
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
560
+ target[key] = source[key];
561
+ }
562
+ }
563
+ }
564
+ return target;
565
+ });
566
+ return _extends.apply(this, arguments);
567
+ }
568
+ function _inheritsLoose(subClass, superClass) {
569
+ subClass.prototype = Object.create(superClass.prototype);
570
+ subClass.prototype.constructor = subClass;
571
+ subClass.__proto__ = superClass;
572
+ }
573
+ var addClass$1 = function addClass(node, classes) {
574
+ return node && classes && classes.split(' ').forEach(function (c) {
575
+ return (0, _addClass.default)(node, c);
576
+ });
577
+ };
578
+ var removeClass$1 = function removeClass(node, classes) {
579
+ return node && classes && classes.split(' ').forEach(function (c) {
580
+ return (0, _removeClass.default)(node, c);
581
+ });
582
+ };
583
+ var CSSTransition = (function (_React$Component) {
584
+ _inheritsLoose(CSSTransition, _React$Component);
585
+ function CSSTransition() {
586
+ var _this;
587
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
588
+ args[_key] = arguments[_key];
589
+ }
590
+ _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
591
+ _this.onEnter = function (node, appearing) {
592
+ var _this$getClassNames = _this.getClassNames(appearing ? 'appear' : 'enter'), className = _this$getClassNames.className;
593
+ _this.removeClasses(node, 'exit');
594
+ addClass$1(node, className);
595
+ if (_this.props.onEnter) {
596
+ _this.props.onEnter(node, appearing);
597
+ }
598
+ };
599
+ _this.onEntering = function (node, appearing) {
600
+ var _this$getClassNames2 = _this.getClassNames(appearing ? 'appear' : 'enter'), activeClassName = _this$getClassNames2.activeClassName;
601
+ _this.reflowAndAddClass(node, activeClassName);
602
+ if (_this.props.onEntering) {
603
+ _this.props.onEntering(node, appearing);
604
+ }
605
+ };
606
+ _this.onEntered = function (node, appearing) {
607
+ var appearClassName = _this.getClassNames('appear').doneClassName;
608
+ var enterClassName = _this.getClassNames('enter').doneClassName;
609
+ var doneClassName = appearing ? appearClassName + " " + enterClassName : enterClassName;
610
+ _this.removeClasses(node, appearing ? 'appear' : 'enter');
611
+ addClass$1(node, doneClassName);
612
+ if (_this.props.onEntered) {
613
+ _this.props.onEntered(node, appearing);
614
+ }
615
+ };
616
+ _this.onExit = function (node) {
617
+ var _this$getClassNames3 = _this.getClassNames('exit'), className = _this$getClassNames3.className;
618
+ _this.removeClasses(node, 'appear');
619
+ _this.removeClasses(node, 'enter');
620
+ addClass$1(node, className);
621
+ if (_this.props.onExit) {
622
+ _this.props.onExit(node);
623
+ }
624
+ };
625
+ _this.onExiting = function (node) {
626
+ var _this$getClassNames4 = _this.getClassNames('exit'), activeClassName = _this$getClassNames4.activeClassName;
627
+ _this.reflowAndAddClass(node, activeClassName);
628
+ if (_this.props.onExiting) {
629
+ _this.props.onExiting(node);
630
+ }
631
+ };
632
+ _this.onExited = function (node) {
633
+ var _this$getClassNames5 = _this.getClassNames('exit'), doneClassName = _this$getClassNames5.doneClassName;
634
+ _this.removeClasses(node, 'exit');
635
+ addClass$1(node, doneClassName);
636
+ if (_this.props.onExited) {
637
+ _this.props.onExited(node);
638
+ }
639
+ };
640
+ _this.getClassNames = function (type) {
641
+ var classNames = _this.props.classNames;
642
+ var isStringClassNames = typeof classNames === 'string';
643
+ var prefix = isStringClassNames && classNames ? classNames + '-' : '';
644
+ var className = isStringClassNames ? prefix + type : classNames[type];
645
+ var activeClassName = isStringClassNames ? className + '-active' : classNames[type + 'Active'];
646
+ var doneClassName = isStringClassNames ? className + '-done' : classNames[type + 'Done'];
647
+ return {
648
+ className: className,
649
+ activeClassName: activeClassName,
650
+ doneClassName: doneClassName
651
+ };
652
+ };
653
+ return _this;
654
+ }
655
+ var _proto = CSSTransition.prototype;
656
+ _proto.removeClasses = function removeClasses(node, type) {
657
+ var _this$getClassNames6 = this.getClassNames(type), className = _this$getClassNames6.className, activeClassName = _this$getClassNames6.activeClassName, doneClassName = _this$getClassNames6.doneClassName;
658
+ className && removeClass$1(node, className);
659
+ activeClassName && removeClass$1(node, activeClassName);
660
+ doneClassName && removeClass$1(node, doneClassName);
661
+ };
662
+ _proto.reflowAndAddClass = function reflowAndAddClass(node, className) {
663
+ if (className) {
664
+ node && node.scrollTop;
665
+ addClass$1(node, className);
666
+ }
667
+ };
668
+ _proto.render = function render() {
669
+ var props = _extends({}, this.props);
670
+ delete props.classNames;
671
+ return _react.default.createElement(_Transition.default, _extends({}, props, {
672
+ onEnter: this.onEnter,
673
+ onEntered: this.onEntered,
674
+ onEntering: this.onEntering,
675
+ onExit: this.onExit,
676
+ onExiting: this.onExiting,
677
+ onExited: this.onExited
678
+ }));
679
+ };
680
+ return CSSTransition;
681
+ })(_react.default.Component);
682
+ CSSTransition.defaultProps = {
683
+ classNames: ''
684
+ };
685
+ CSSTransition.propTypes = _extends({}, _Transition.default.propTypes, {
686
+ classNames: _PropTypes.classNamesShape,
687
+ onEnter: PropTypes.func,
688
+ onEntering: PropTypes.func,
689
+ onEntered: PropTypes.func,
690
+ onExit: PropTypes.func,
691
+ onExiting: PropTypes.func,
692
+ onExited: PropTypes.func
693
+ });
694
+ var _default = CSSTransition;
695
+ exports.default = _default;
696
+ module.exports = exports["default"];
697
+ })(CSSTransition, CSSTransition.exports);
698
+ getDefaultExportFromCjs(CSSTransition.exports);
699
+ var ReplaceTransition = {
700
+ exports: {}
701
+ };
702
+ var TransitionGroup = {
703
+ exports: {}
704
+ };
705
+ var ChildMapping = {};
706
+ const require$$0$2 = _dll_react;
707
+ ChildMapping.__esModule = true;
708
+ ChildMapping.getChildMapping = getChildMapping;
709
+ ChildMapping.mergeChildMappings = mergeChildMappings;
710
+ ChildMapping.getInitialChildMapping = getInitialChildMapping;
711
+ ChildMapping.getNextChildMapping = getNextChildMapping;
712
+ var _react = require$$0$2;
713
+ function getChildMapping(children, mapFn) {
714
+ var mapper = function mapper(child) {
715
+ return mapFn && (0, _react.isValidElement)(child) ? mapFn(child) : child;
716
+ };
717
+ var result = Object.create(null);
718
+ if (children) _react.Children.map(children, function (c) {
719
+ return c;
720
+ }).forEach(function (child) {
721
+ result[child.key] = mapper(child);
722
+ });
723
+ return result;
724
+ }
725
+ function mergeChildMappings(prev, next) {
726
+ prev = prev || ({});
727
+ next = next || ({});
728
+ function getValueForKey(key) {
729
+ return (key in next) ? next[key] : prev[key];
730
+ }
731
+ var nextKeysPending = Object.create(null);
732
+ var pendingKeys = [];
733
+ for (var prevKey in prev) {
734
+ if ((prevKey in next)) {
735
+ if (pendingKeys.length) {
736
+ nextKeysPending[prevKey] = pendingKeys;
737
+ pendingKeys = [];
738
+ }
739
+ } else {
740
+ pendingKeys.push(prevKey);
741
+ }
742
+ }
743
+ var i;
744
+ var childMapping = {};
745
+ for (var nextKey in next) {
746
+ if (nextKeysPending[nextKey]) {
747
+ for (i = 0; i < nextKeysPending[nextKey].length; i++) {
748
+ var pendingNextKey = nextKeysPending[nextKey][i];
749
+ childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
750
+ }
751
+ }
752
+ childMapping[nextKey] = getValueForKey(nextKey);
753
+ }
754
+ for (i = 0; i < pendingKeys.length; i++) {
755
+ childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
756
+ }
757
+ return childMapping;
758
+ }
759
+ function getProp(child, prop, props) {
760
+ return props[prop] != null ? props[prop] : child.props[prop];
761
+ }
762
+ function getInitialChildMapping(props, onExited) {
763
+ return getChildMapping(props.children, function (child) {
764
+ return (0, _react.cloneElement)(child, {
765
+ onExited: onExited.bind(null, child),
766
+ in: true,
767
+ appear: getProp(child, 'appear', props),
768
+ enter: getProp(child, 'enter', props),
769
+ exit: getProp(child, 'exit', props)
770
+ });
771
+ });
772
+ }
773
+ function getNextChildMapping(nextProps, prevChildMapping, onExited) {
774
+ var nextChildMapping = getChildMapping(nextProps.children);
775
+ var children = mergeChildMappings(prevChildMapping, nextChildMapping);
776
+ Object.keys(children).forEach(function (key) {
777
+ var child = children[key];
778
+ if (!(0, _react.isValidElement)(child)) return;
779
+ var hasPrev = (key in prevChildMapping);
780
+ var hasNext = (key in nextChildMapping);
781
+ var prevChild = prevChildMapping[key];
782
+ var isLeaving = (0, _react.isValidElement)(prevChild) && !prevChild.props.in;
783
+ if (hasNext && (!hasPrev || isLeaving)) {
784
+ children[key] = (0, _react.cloneElement)(child, {
785
+ onExited: onExited.bind(null, child),
786
+ in: true,
787
+ exit: getProp(child, 'exit', nextProps),
788
+ enter: getProp(child, 'enter', nextProps)
789
+ });
790
+ } else if (!hasNext && hasPrev && !isLeaving) {
791
+ children[key] = (0, _react.cloneElement)(child, {
792
+ in: false
793
+ });
794
+ } else if (hasNext && hasPrev && (0, _react.isValidElement)(prevChild)) {
795
+ children[key] = (0, _react.cloneElement)(child, {
796
+ onExited: onExited.bind(null, child),
797
+ in: prevChild.props.in,
798
+ exit: getProp(child, 'exit', nextProps),
799
+ enter: getProp(child, 'enter', nextProps)
800
+ });
801
+ }
802
+ });
803
+ return children;
804
+ }
805
+ const require$$0$1 = _dll_prop_types;
806
+ const require$$1$1 = _dll_react;
807
+ (function (module, exports) {
808
+ exports.__esModule = true;
809
+ exports.default = void 0;
810
+ var _propTypes = _interopRequireDefault(require$$0$1);
811
+ var _react = _interopRequireDefault(require$$1$1);
812
+ var _reactLifecyclesCompat = require$$2$2;
813
+ var _ChildMapping = ChildMapping;
814
+ function _interopRequireDefault(obj) {
815
+ return obj && obj.__esModule ? obj : {
816
+ default: obj
817
+ };
818
+ }
819
+ function _objectWithoutPropertiesLoose(source, excluded) {
820
+ if (source == null) return {};
821
+ var target = {};
822
+ var sourceKeys = Object.keys(source);
823
+ var key, i;
824
+ for (i = 0; i < sourceKeys.length; i++) {
825
+ key = sourceKeys[i];
826
+ if (excluded.indexOf(key) >= 0) continue;
827
+ target[key] = source[key];
828
+ }
829
+ return target;
830
+ }
831
+ function _extends() {
832
+ _extends = Object.assign || (function (target) {
833
+ for (var i = 1; i < arguments.length; i++) {
834
+ var source = arguments[i];
835
+ for (var key in source) {
836
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
837
+ target[key] = source[key];
838
+ }
839
+ }
840
+ }
841
+ return target;
842
+ });
843
+ return _extends.apply(this, arguments);
844
+ }
845
+ function _inheritsLoose(subClass, superClass) {
846
+ subClass.prototype = Object.create(superClass.prototype);
847
+ subClass.prototype.constructor = subClass;
848
+ subClass.__proto__ = superClass;
849
+ }
850
+ function _assertThisInitialized(self) {
851
+ if (self === void 0) {
852
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
853
+ }
854
+ return self;
855
+ }
856
+ var values = Object.values || (function (obj) {
857
+ return Object.keys(obj).map(function (k) {
858
+ return obj[k];
859
+ });
860
+ });
861
+ var defaultProps = {
862
+ component: 'div',
863
+ childFactory: function childFactory(child) {
864
+ return child;
865
+ }
866
+ };
867
+ var TransitionGroup = (function (_React$Component) {
868
+ _inheritsLoose(TransitionGroup, _React$Component);
869
+ function TransitionGroup(props, context) {
870
+ var _this;
871
+ _this = _React$Component.call(this, props, context) || this;
872
+ var handleExited = _this.handleExited.bind(_assertThisInitialized(_assertThisInitialized(_this)));
873
+ _this.state = {
874
+ handleExited: handleExited,
875
+ firstRender: true
876
+ };
877
+ return _this;
878
+ }
879
+ var _proto = TransitionGroup.prototype;
880
+ _proto.getChildContext = function getChildContext() {
881
+ return {
882
+ transitionGroup: {
883
+ isMounting: !this.appeared
884
+ }
885
+ };
886
+ };
887
+ _proto.componentDidMount = function componentDidMount() {
888
+ this.appeared = true;
889
+ this.mounted = true;
890
+ };
891
+ _proto.componentWillUnmount = function componentWillUnmount() {
892
+ this.mounted = false;
893
+ };
894
+ TransitionGroup.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, _ref) {
895
+ var prevChildMapping = _ref.children, handleExited = _ref.handleExited, firstRender = _ref.firstRender;
896
+ return {
897
+ children: firstRender ? (0, _ChildMapping.getInitialChildMapping)(nextProps, handleExited) : (0, _ChildMapping.getNextChildMapping)(nextProps, prevChildMapping, handleExited),
898
+ firstRender: false
899
+ };
900
+ };
901
+ _proto.handleExited = function handleExited(child, node) {
902
+ var currentChildMapping = (0, _ChildMapping.getChildMapping)(this.props.children);
903
+ if ((child.key in currentChildMapping)) return;
904
+ if (child.props.onExited) {
905
+ child.props.onExited(node);
906
+ }
907
+ if (this.mounted) {
908
+ this.setState(function (state) {
909
+ var children = _extends({}, state.children);
910
+ delete children[child.key];
911
+ return {
912
+ children: children
913
+ };
914
+ });
915
+ }
916
+ };
917
+ _proto.render = function render() {
918
+ var _this$props = this.props, Component = _this$props.component, childFactory = _this$props.childFactory, props = _objectWithoutPropertiesLoose(_this$props, ["component", "childFactory"]);
919
+ var children = values(this.state.children).map(childFactory);
920
+ delete props.appear;
921
+ delete props.enter;
922
+ delete props.exit;
923
+ if (Component === null) {
924
+ return children;
925
+ }
926
+ return _react.default.createElement(Component, props, children);
927
+ };
928
+ return TransitionGroup;
929
+ })(_react.default.Component);
930
+ TransitionGroup.childContextTypes = {
931
+ transitionGroup: _propTypes.default.object.isRequired
932
+ };
933
+ TransitionGroup.propTypes = {
934
+ component: _propTypes.default.any,
935
+ children: _propTypes.default.node,
936
+ appear: _propTypes.default.bool,
937
+ enter: _propTypes.default.bool,
938
+ exit: _propTypes.default.bool,
939
+ childFactory: _propTypes.default.func
940
+ };
941
+ TransitionGroup.defaultProps = defaultProps;
942
+ var _default = (0, _reactLifecyclesCompat.polyfill)(TransitionGroup);
943
+ exports.default = _default;
944
+ module.exports = exports["default"];
945
+ })(TransitionGroup, TransitionGroup.exports);
946
+ getDefaultExportFromCjs(TransitionGroup.exports);
947
+ const require$$0 = _dll_prop_types;
948
+ const require$$1 = _dll_react;
949
+ const require$$2 = _dll_react_dom;
950
+ (function (module, exports) {
951
+ exports.__esModule = true;
952
+ exports.default = void 0;
953
+ var _propTypes = _interopRequireDefault(require$$0);
954
+ var _react = _interopRequireDefault(require$$1);
955
+ var _reactDom = require$$2;
956
+ var _TransitionGroup = _interopRequireDefault(TransitionGroup.exports);
957
+ function _interopRequireDefault(obj) {
958
+ return obj && obj.__esModule ? obj : {
959
+ default: obj
960
+ };
961
+ }
962
+ function _objectWithoutPropertiesLoose(source, excluded) {
963
+ if (source == null) return {};
964
+ var target = {};
965
+ var sourceKeys = Object.keys(source);
966
+ var key, i;
967
+ for (i = 0; i < sourceKeys.length; i++) {
968
+ key = sourceKeys[i];
969
+ if (excluded.indexOf(key) >= 0) continue;
970
+ target[key] = source[key];
971
+ }
972
+ return target;
973
+ }
974
+ function _inheritsLoose(subClass, superClass) {
975
+ subClass.prototype = Object.create(superClass.prototype);
976
+ subClass.prototype.constructor = subClass;
977
+ subClass.__proto__ = superClass;
978
+ }
979
+ var ReplaceTransition = (function (_React$Component) {
980
+ _inheritsLoose(ReplaceTransition, _React$Component);
981
+ function ReplaceTransition() {
982
+ var _this;
983
+ for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
984
+ _args[_key] = arguments[_key];
985
+ }
986
+ _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
987
+ _this.handleEnter = function () {
988
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
989
+ args[_key2] = arguments[_key2];
990
+ }
991
+ return _this.handleLifecycle('onEnter', 0, args);
992
+ };
993
+ _this.handleEntering = function () {
994
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
995
+ args[_key3] = arguments[_key3];
996
+ }
997
+ return _this.handleLifecycle('onEntering', 0, args);
998
+ };
999
+ _this.handleEntered = function () {
1000
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1001
+ args[_key4] = arguments[_key4];
1002
+ }
1003
+ return _this.handleLifecycle('onEntered', 0, args);
1004
+ };
1005
+ _this.handleExit = function () {
1006
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1007
+ args[_key5] = arguments[_key5];
1008
+ }
1009
+ return _this.handleLifecycle('onExit', 1, args);
1010
+ };
1011
+ _this.handleExiting = function () {
1012
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
1013
+ args[_key6] = arguments[_key6];
1014
+ }
1015
+ return _this.handleLifecycle('onExiting', 1, args);
1016
+ };
1017
+ _this.handleExited = function () {
1018
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
1019
+ args[_key7] = arguments[_key7];
1020
+ }
1021
+ return _this.handleLifecycle('onExited', 1, args);
1022
+ };
1023
+ return _this;
1024
+ }
1025
+ var _proto = ReplaceTransition.prototype;
1026
+ _proto.handleLifecycle = function handleLifecycle(handler, idx, originalArgs) {
1027
+ var _child$props;
1028
+ var children = this.props.children;
1029
+ var child = _react.default.Children.toArray(children)[idx];
1030
+ if (child.props[handler]) (_child$props = child.props)[handler].apply(_child$props, originalArgs);
1031
+ if (this.props[handler]) this.props[handler]((0, _reactDom.findDOMNode)(this));
1032
+ };
1033
+ _proto.render = function render() {
1034
+ var _this$props = this.props, children = _this$props.children, inProp = _this$props.in, props = _objectWithoutPropertiesLoose(_this$props, ["children", "in"]);
1035
+ var _React$Children$toArr = _react.default.Children.toArray(children), first = _React$Children$toArr[0], second = _React$Children$toArr[1];
1036
+ delete props.onEnter;
1037
+ delete props.onEntering;
1038
+ delete props.onEntered;
1039
+ delete props.onExit;
1040
+ delete props.onExiting;
1041
+ delete props.onExited;
1042
+ return _react.default.createElement(_TransitionGroup.default, props, inProp ? _react.default.cloneElement(first, {
1043
+ key: 'first',
1044
+ onEnter: this.handleEnter,
1045
+ onEntering: this.handleEntering,
1046
+ onEntered: this.handleEntered
1047
+ }) : _react.default.cloneElement(second, {
1048
+ key: 'second',
1049
+ onEnter: this.handleExit,
1050
+ onEntering: this.handleExiting,
1051
+ onEntered: this.handleExited
1052
+ }));
1053
+ };
1054
+ return ReplaceTransition;
1055
+ })(_react.default.Component);
1056
+ ReplaceTransition.propTypes = {
1057
+ in: _propTypes.default.bool.isRequired,
1058
+ children: function children(props, propName) {
1059
+ if (_react.default.Children.count(props[propName]) !== 2) return new Error("\"" + propName + "\" must be exactly two transition components.");
1060
+ return null;
1061
+ }
1062
+ };
1063
+ var _default = ReplaceTransition;
1064
+ exports.default = _default;
1065
+ module.exports = exports["default"];
1066
+ })(ReplaceTransition, ReplaceTransition.exports);
1067
+ getDefaultExportFromCjs(ReplaceTransition.exports);
1068
+ var _CSSTransition = _interopRequireDefault(CSSTransition.exports);
1069
+ var _ReplaceTransition = _interopRequireDefault(ReplaceTransition.exports);
1070
+ var _TransitionGroup = _interopRequireDefault(TransitionGroup.exports);
1071
+ var _Transition = _interopRequireDefault(Transition$1);
1072
+ function _interopRequireDefault(obj) {
1073
+ return obj && obj.__esModule ? obj : {
1074
+ default: obj
1075
+ };
1076
+ }
1077
+ var reactTransitionGroup = {
1078
+ Transition: _Transition.default,
1079
+ TransitionGroup: _TransitionGroup.default,
1080
+ ReplaceTransition: _ReplaceTransition.default,
1081
+ CSSTransition: _CSSTransition.default
1082
+ };
1083
+ const React$5 = _dll_react;
1084
+ const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
1085
+ const PropTypes$4 = _dll_prop_types;
1086
+ const {color: color$2} = _dll_pie_lib__render_ui;
1087
+ const _jsxFileName$4 = "/home/circleci/repo/packages/multiple-choice/src/feedback-tick.jsx";
1088
+ const stylesheet = {
1089
+ incorrect: {
1090
+ fill: `var(--feedback-incorrect-bg-color, ${color$2.incorrect()})`
1091
+ },
1092
+ correct: {
1093
+ fill: `var(--feedback-correct-bg-color, ${color$2.correct()})`
1094
+ },
1095
+ feedbackTick: {
1096
+ width: '33px',
1097
+ height: '33px',
1098
+ '& svg': {
1099
+ position: 'absolute',
1100
+ display: 'inline-block',
1101
+ width: '33px',
1102
+ height: '33px',
1103
+ verticalAlign: 'middle',
1104
+ '& hide': {
1105
+ display: 'none'
1106
+ }
1107
+ }
1108
+ },
1109
+ feedbackTickEnter: {
1110
+ opacity: '0',
1111
+ left: '-50px'
1112
+ },
1113
+ feedbackTickEnterActive: {
1114
+ opacity: '1',
1115
+ left: '0px',
1116
+ transition: 'left 500ms ease-in 200ms, opacity 500ms linear 200ms'
1117
+ },
1118
+ feedbackTickLeave: {
1119
+ opacity: '1',
1120
+ left: '0px'
1121
+ },
1122
+ feedbackTickLeaveActive: {
1123
+ opacity: '0',
1124
+ left: '-50px',
1125
+ transition: 'left 300ms ease-in, opacity 300ms'
1126
+ }
1127
+ };
1128
+ class FeedbackTick extends React$5.Component {
1129
+ static __initStatic() {
1130
+ this.propTypes = {
1131
+ classes: PropTypes$4.object.isRequired,
1132
+ correctness: PropTypes$4.string
1133
+ };
1134
+ }
1135
+ constructor(props) {
1136
+ super(props);
1137
+ this.incorrectIcon = React$5.createElement('svg', {
1138
+ key: "1",
1139
+ preserveAspectRatio: "xMinYMin meet",
1140
+ x: "0px",
1141
+ y: "0px",
1142
+ viewBox: "0 0 44 40",
1143
+ style: {
1144
+ enableBackground: 'new 0 0 44 40'
1145
+ },
1146
+ __self: this,
1147
+ __source: {
1148
+ fileName: _jsxFileName$4,
1149
+ lineNumber: 56
1150
+ }
1151
+ }, React$5.createElement('g', {
1152
+ __self: this,
1153
+ __source: {
1154
+ fileName: _jsxFileName$4,
1155
+ lineNumber: 64
1156
+ }
1157
+ }, React$5.createElement('rect', {
1158
+ x: "11",
1159
+ y: "17.3",
1160
+ transform: "matrix(0.7071 -0.7071 0.7071 0.7071 -7.852 19.2507)",
1161
+ className: this.props.classes.incorrect,
1162
+ width: "16.6",
1163
+ height: "3.7",
1164
+ __self: this,
1165
+ __source: {
1166
+ fileName: _jsxFileName$4,
1167
+ lineNumber: 65
1168
+ }
1169
+ }), React$5.createElement('rect', {
1170
+ x: "17.4",
1171
+ y: "10.7",
1172
+ transform: "matrix(0.7071 -0.7071 0.7071 0.7071 -7.8175 19.209)",
1173
+ className: this.props.classes.incorrect,
1174
+ width: "3.7",
1175
+ height: "16.6",
1176
+ __self: this,
1177
+ __source: {
1178
+ fileName: _jsxFileName$4,
1179
+ lineNumber: 73
1180
+ }
1181
+ })));
1182
+ this.correctIcon = React$5.createElement('svg', {
1183
+ key: "2",
1184
+ preserveAspectRatio: "xMinYMin meet",
1185
+ version: "1.1",
1186
+ x: "0px",
1187
+ y: "0px",
1188
+ viewBox: "0 0 44 40",
1189
+ style: {
1190
+ enableBackground: 'new 0 0 44 40'
1191
+ },
1192
+ __self: this,
1193
+ __source: {
1194
+ fileName: _jsxFileName$4,
1195
+ lineNumber: 86
1196
+ }
1197
+ }, React$5.createElement('polygon', {
1198
+ className: this.props.classes.correct,
1199
+ points: "19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4",
1200
+ __self: this,
1201
+ __source: {
1202
+ fileName: _jsxFileName$4,
1203
+ lineNumber: 95
1204
+ }
1205
+ }));
1206
+ }
1207
+ render() {
1208
+ const {correctness, classes} = this.props;
1209
+ const icon = (() => {
1210
+ if (correctness === 'incorrect') {
1211
+ return this.incorrectIcon;
1212
+ } else if (correctness === 'correct') {
1213
+ return this.correctIcon;
1214
+ }
1215
+ })();
1216
+ return React$5.createElement('div', {
1217
+ className: classes.feedbackTick,
1218
+ __self: this,
1219
+ __source: {
1220
+ fileName: _jsxFileName$4,
1221
+ lineNumber: 115
1222
+ }
1223
+ }, React$5.createElement(reactTransitionGroup.TransitionGroup, {
1224
+ __self: this,
1225
+ __source: {
1226
+ fileName: _jsxFileName$4,
1227
+ lineNumber: 116
1228
+ }
1229
+ }, correctness && React$5.createElement(reactTransitionGroup.CSSTransition, {
1230
+ classNames: {
1231
+ enter: classes.feedbackTickEnter,
1232
+ enterActive: classes.feedbackTickEnterActive,
1233
+ exit: classes.feedbackTickLeave,
1234
+ exitActive: classes.feedbackTickLeaveActive
1235
+ },
1236
+ timeout: {
1237
+ enter: 700,
1238
+ exit: 300
1239
+ },
1240
+ __self: this,
1241
+ __source: {
1242
+ fileName: _jsxFileName$4,
1243
+ lineNumber: 118
1244
+ }
1245
+ }, icon)));
1246
+ }
1247
+ }
1248
+ FeedbackTick.__initStatic();
1249
+ var FeedbackTick$1 = withStyles$4(stylesheet, {
1250
+ name: 'FeedbackTick'
1251
+ })(FeedbackTick);
1252
+ const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
1253
+ const {Checkbox: Checkbox} = _dll_material_ui__core;
1254
+ const {Radio: Radio} = _dll_material_ui__core;
1255
+ const React$4 = _dll_react;
1256
+ const PropTypes$3 = _dll_prop_types;
1257
+ const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
1258
+ const {Feedback: Feedback} = _dll_pie_lib__render_ui;
1259
+ const {color: color$1} = _dll_pie_lib__render_ui;
1260
+ const {PreviewPrompt: PreviewPrompt$1} = _dll_pie_lib__render_ui;
1261
+ const classNames$3 = _dll_classnames;
1262
+ const _jsxFileName$3 = "/home/circleci/repo/packages/multiple-choice/src/choice-input.jsx";
1263
+ const styleSheet = () => ({
1264
+ row: {
1265
+ display: 'flex',
1266
+ alignItems: 'center',
1267
+ backgroundColor: color$1.background()
1268
+ },
1269
+ checkboxHolder: {
1270
+ display: 'flex',
1271
+ alignItems: 'center',
1272
+ backgroundColor: color$1.background(),
1273
+ flex: 1,
1274
+ '& label': {
1275
+ color: color$1.text()
1276
+ }
1277
+ }
1278
+ });
1279
+ const formStyleSheet = {
1280
+ label: {
1281
+ color: `${color$1.text()} !important`,
1282
+ backgroundColor: color$1.background()
1283
+ }
1284
+ };
1285
+ const StyledFormControlLabel = withStyles$3(formStyleSheet, {
1286
+ name: 'FormControlLabel'
1287
+ })(props => React$4.createElement(FormControlLabel, {
1288
+ ...props,
1289
+ classes: {
1290
+ label: props.classes.label
1291
+ },
1292
+ __self: undefined,
1293
+ __source: {
1294
+ fileName: _jsxFileName$3,
1295
+ lineNumber: 39
1296
+ }
1297
+ }));
1298
+ const CLASS_NAME = 'multiple-choice-component';
1299
+ const colorStyle = (varName, fallback) => ({
1300
+ [`&.${CLASS_NAME}`]: {
1301
+ color: `var(--choice-input-${varName}, ${fallback}) !important`
1302
+ }
1303
+ });
1304
+ const inputStyles = {
1305
+ 'correct-root': colorStyle('correct-color', color$1.text()),
1306
+ 'correct-checked': colorStyle('correct-selected-color', color$1.correct()),
1307
+ 'correct-disabled': colorStyle('correct-disabled-color', color$1.disabled()),
1308
+ 'incorrect-root': colorStyle('incorrect-color', color$1.incorrect()),
1309
+ 'incorrect-checked': colorStyle('incorrect-checked', color$1.incorrect()),
1310
+ 'incorrect-disabled': colorStyle('incorrect-disabled-color', color$1.disabled()),
1311
+ root: {
1312
+ ...colorStyle('color', color$1.text()),
1313
+ '&:hover': {
1314
+ color: `${color$1.primaryLight()} !important`
1315
+ }
1316
+ },
1317
+ checked: colorStyle('selected-color', color$1.primary()),
1318
+ disabled: {
1319
+ ...colorStyle('disabled-color', color$1.text()),
1320
+ opacity: 0.6,
1321
+ cursor: 'not-allowed !important',
1322
+ pointerEvents: 'initial !important'
1323
+ }
1324
+ };
1325
+ const StyledCheckbox = withStyles$3(inputStyles)(props => {
1326
+ const {correctness, classes, checked, onChange, disabled, accessibility} = props;
1327
+ const key = k => correctness ? `${correctness}-${k}` : k;
1328
+ const resolved = {
1329
+ root: classes[key('root')],
1330
+ checked: classes[key('checked')],
1331
+ disabled: classes[key('disabled')]
1332
+ };
1333
+ const miniProps = {
1334
+ checked,
1335
+ onChange,
1336
+ disabled
1337
+ };
1338
+ return React$4.createElement(Checkbox, {
1339
+ 'aria-label': accessibility,
1340
+ ...miniProps,
1341
+ className: CLASS_NAME,
1342
+ classes: {
1343
+ root: resolved.root,
1344
+ checked: resolved.checked,
1345
+ disabled: `${correctness ? '' : resolved.disabled}`
1346
+ },
1347
+ __self: undefined,
1348
+ __source: {
1349
+ fileName: _jsxFileName$3,
1350
+ lineNumber: 92
1351
+ }
1352
+ });
1353
+ });
1354
+ const StyledRadio = withStyles$3(inputStyles)(props => {
1355
+ const {correctness, classes, checked, onChange, disabled, accessibility} = props;
1356
+ const key = k => correctness ? `${correctness}-${k}` : k;
1357
+ const resolved = {
1358
+ root: classes[key('root')],
1359
+ checked: classes[key('checked')],
1360
+ disabled: classes[key('disabled')]
1361
+ };
1362
+ const miniProps = {
1363
+ checked,
1364
+ onChange,
1365
+ disabled
1366
+ };
1367
+ return React$4.createElement(Radio, {
1368
+ 'aria-label': accessibility,
1369
+ ...miniProps,
1370
+ className: CLASS_NAME,
1371
+ classes: {
1372
+ root: resolved.root,
1373
+ checked: resolved.checked,
1374
+ disabled: `${correctness ? '' : resolved.disabled}`
1375
+ },
1376
+ __self: undefined,
1377
+ __source: {
1378
+ fileName: _jsxFileName$3,
1379
+ lineNumber: 125
1380
+ }
1381
+ });
1382
+ });
1383
+ class ChoiceInput extends React$4.Component {
1384
+ static __initStatic() {
1385
+ this.propTypes = {
1386
+ choiceMode: PropTypes$3.oneOf(['radio', 'checkbox']),
1387
+ displayKey: PropTypes$3.string.isRequired,
1388
+ checked: PropTypes$3.bool.isRequired,
1389
+ correctness: PropTypes$3.string,
1390
+ disabled: PropTypes$3.bool.isRequired,
1391
+ feedback: PropTypes$3.string,
1392
+ label: PropTypes$3.string.isRequired,
1393
+ rationale: PropTypes$3.string,
1394
+ accessibility: PropTypes$3.string,
1395
+ onChange: PropTypes$3.func.isRequired,
1396
+ value: PropTypes$3.string.isRequired,
1397
+ classes: PropTypes$3.object,
1398
+ className: PropTypes$3.string,
1399
+ hideTick: PropTypes$3.bool,
1400
+ isEvaluateMode: PropTypes$3.bool
1401
+ };
1402
+ }
1403
+ static __initStatic2() {
1404
+ this.defaultProps = {
1405
+ rationale: null,
1406
+ accessibility: null,
1407
+ checked: false,
1408
+ isEvaluateMode: false
1409
+ };
1410
+ }
1411
+ constructor(props) {
1412
+ super(props);
1413
+ this.onToggleChoice = this.onToggleChoice.bind(this);
1414
+ }
1415
+ onToggleChoice() {
1416
+ this.props.onChange({
1417
+ value: this.props.value,
1418
+ selected: !this.props.checked
1419
+ });
1420
+ }
1421
+ render() {
1422
+ const {choiceMode, disabled, displayKey, feedback, label, checked, correctness, classes, className, rationale, accessibility, hideTick, isEvaluateMode} = this.props;
1423
+ const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
1424
+ const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';
1425
+ return React$4.createElement('div', {
1426
+ className: classNames$3(className, 'corespring-' + classSuffix, 'choice-input'),
1427
+ __self: this,
1428
+ __source: {
1429
+ fileName: _jsxFileName$3,
1430
+ lineNumber: 197
1431
+ }
1432
+ }, React$4.createElement('div', {
1433
+ className: classes.row,
1434
+ __self: this,
1435
+ __source: {
1436
+ fileName: _jsxFileName$3,
1437
+ lineNumber: 198
1438
+ }
1439
+ }, !hideTick && isEvaluateMode && React$4.createElement(FeedbackTick$1, {
1440
+ correctness: correctness,
1441
+ __self: this,
1442
+ __source: {
1443
+ fileName: _jsxFileName$3,
1444
+ lineNumber: 199
1445
+ }
1446
+ }), React$4.createElement('div', {
1447
+ className: classNames$3(classes.checkboxHolder, 'checkbox-holder'),
1448
+ __self: this,
1449
+ __source: {
1450
+ fileName: _jsxFileName$3,
1451
+ lineNumber: 200
1452
+ }
1453
+ }, React$4.createElement(StyledFormControlLabel, {
1454
+ disabled: disabled,
1455
+ label: displayKey ? displayKey + '. ' : '',
1456
+ control: React$4.createElement(Tag, {
1457
+ accessibility: accessibility,
1458
+ checked: checked,
1459
+ correctness: correctness,
1460
+ onChange: this.onToggleChoice,
1461
+ __self: this,
1462
+ __source: {
1463
+ fileName: _jsxFileName$3,
1464
+ lineNumber: 205
1465
+ }
1466
+ }),
1467
+ __self: this,
1468
+ __source: {
1469
+ fileName: _jsxFileName$3,
1470
+ lineNumber: 201
1471
+ }
1472
+ }), React$4.createElement(PreviewPrompt$1, {
1473
+ className: "label",
1474
+ onClick: this.onToggleChoice,
1475
+ prompt: label,
1476
+ tagName: "span",
1477
+ __self: this,
1478
+ __source: {
1479
+ fileName: _jsxFileName$3,
1480
+ lineNumber: 213
1481
+ }
1482
+ }))), rationale && React$4.createElement(PreviewPrompt$1, {
1483
+ className: "rationale",
1484
+ defaultClassName: "rationale",
1485
+ prompt: rationale,
1486
+ __self: this,
1487
+ __source: {
1488
+ fileName: _jsxFileName$3,
1489
+ lineNumber: 222
1490
+ }
1491
+ }), React$4.createElement(Feedback, {
1492
+ feedback: feedback,
1493
+ correctness: correctness,
1494
+ __self: this,
1495
+ __source: {
1496
+ fileName: _jsxFileName$3,
1497
+ lineNumber: 224
1498
+ }
1499
+ }));
1500
+ }
1501
+ }
1502
+ ChoiceInput.__initStatic();
1503
+ ChoiceInput.__initStatic2();
1504
+ var ChoiceInput$1 = withStyles$3(styleSheet)(ChoiceInput);
1505
+ const React$3 = _dll_react;
1506
+ const PropTypes$2 = _dll_prop_types;
1507
+ const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
1508
+ const classNames$2 = _dll_classnames;
1509
+ const _jsxFileName$2 = "/home/circleci/repo/packages/multiple-choice/src/choice.jsx";
1510
+ class Choice extends React$3.Component {
1511
+ constructor(...args) {
1512
+ super(...args);
1513
+ Choice.prototype.__init.call(this);
1514
+ }
1515
+ __init() {
1516
+ this.onChange = choice => {
1517
+ const {disabled, onChoiceChanged} = this.props;
1518
+ if (!disabled) {
1519
+ onChoiceChanged(choice);
1520
+ }
1521
+ };
1522
+ }
1523
+ render() {
1524
+ const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns} = this.props;
1525
+ const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
1526
+ const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
1527
+ const choiceProps = {
1528
+ ...choice,
1529
+ checked,
1530
+ choiceMode,
1531
+ disabled,
1532
+ feedback,
1533
+ correctness,
1534
+ displayKey,
1535
+ choicesLayout,
1536
+ gridColumns,
1537
+ onChange: this.onChange,
1538
+ isEvaluateMode
1539
+ };
1540
+ const names = classNames$2(classes.choice, {
1541
+ [classes.noBorder]: index === choicesLength - 1 || choicesLayout !== 'vertical'
1542
+ });
1543
+ return React$3.createElement('div', {
1544
+ className: choiceClass,
1545
+ key: index,
1546
+ __self: this,
1547
+ __source: {
1548
+ fileName: _jsxFileName$2,
1549
+ lineNumber: 56
1550
+ }
1551
+ }, React$3.createElement(ChoiceInput$1, {
1552
+ ...choiceProps,
1553
+ className: names,
1554
+ __self: this,
1555
+ __source: {
1556
+ fileName: _jsxFileName$2,
1557
+ lineNumber: 57
1558
+ }
1559
+ }));
1560
+ }
1561
+ }
1562
+ Choice.propTypes = {
1563
+ choiceMode: PropTypes$2.oneOf(['radio', 'checkbox']),
1564
+ choice: PropTypes$2.object,
1565
+ disabled: PropTypes$2.bool.isRequired,
1566
+ onChoiceChanged: PropTypes$2.func,
1567
+ classes: PropTypes$2.object.isRequired,
1568
+ index: PropTypes$2.number,
1569
+ choicesLength: PropTypes$2.number,
1570
+ showCorrect: PropTypes$2.bool,
1571
+ isEvaluateMode: PropTypes$2.bool,
1572
+ checked: PropTypes$2.bool,
1573
+ correctness: PropTypes$2.string,
1574
+ displayKey: PropTypes$2.string,
1575
+ choicesLayout: PropTypes$2.oneOf(['vertical', 'grid', 'horizontal']),
1576
+ gridColumns: PropTypes$2.string
1577
+ };
1578
+ var StyledChoice = withStyles$2({
1579
+ choice: {
1580
+ paddingTop: '20px',
1581
+ paddingBottom: '10px',
1582
+ borderBottom: '1px solid #E0DEE0'
1583
+ },
1584
+ noBorder: {
1585
+ borderBottom: 'none'
1586
+ }
1587
+ })(Choice);
1588
+ const React$2 = _dll_react;
1589
+ const PropTypes$1 = _dll_prop_types;
1590
+ const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
1591
+ const classNames$1 = _dll_classnames;
1592
+ const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
1593
+ const {color: color} = _dll_pie_lib__render_ui;
1594
+ const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
1595
+ const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
1596
+ const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
1597
+ const styles = {
1598
+ corespringChoice: {
1599
+ backgroundColor: color.background(),
1600
+ padding: '5px',
1601
+ '& *': {
1602
+ '-webkit-font-smoothing': 'antialiased'
1603
+ }
1604
+ },
1605
+ horizontalLayout: {
1606
+ display: 'flex',
1607
+ flexDirection: 'row',
1608
+ flexWrap: 'wrap'
1609
+ },
1610
+ gridLayout: {
1611
+ display: 'grid'
1612
+ },
1613
+ getColumns: function (columns) {
1614
+ return columns > 1 ? {
1615
+ gridTemplateColumns: `repeat(${columns}, 1fr)`
1616
+ } : undefined;
1617
+ }
1618
+ };
1619
+ class MultipleChoice$1 extends React$2.Component {
1620
+ static __initStatic() {
1621
+ this.propTypes = {
1622
+ mode: PropTypes$1.oneOf(['gather', 'view', 'evaluate']),
1623
+ choiceMode: PropTypes$1.oneOf(['radio', 'checkbox']),
1624
+ keyMode: PropTypes$1.oneOf(['numbers', 'letters', 'none']),
1625
+ choices: PropTypes$1.array,
1626
+ prompt: PropTypes$1.string,
1627
+ teacherInstructions: PropTypes$1.string,
1628
+ session: PropTypes$1.object,
1629
+ disabled: PropTypes$1.bool,
1630
+ onChoiceChanged: PropTypes$1.func,
1631
+ responseCorrect: PropTypes$1.bool,
1632
+ classes: PropTypes$1.object.isRequired,
1633
+ correctResponse: PropTypes$1.array,
1634
+ choicesLayout: PropTypes$1.oneOf(['vertical', 'grid', 'horizontal']),
1635
+ gridColumns: PropTypes$1.string,
1636
+ alwaysShowCorrect: PropTypes$1.bool,
1637
+ animationsDisabled: PropTypes$1.bool
1638
+ };
1639
+ }
1640
+ constructor(props) {
1641
+ super(props);
1642
+ MultipleChoice$1.prototype.__init.call(this);
1643
+ this.state = {
1644
+ showCorrect: this.props.alwaysShowCorrect || false
1645
+ };
1646
+ this.onToggle = this.onToggle.bind(this);
1647
+ }
1648
+ onToggle() {
1649
+ if (this.props.mode === 'evaluate') {
1650
+ this.setState({
1651
+ showCorrect: !this.state.showCorrect
1652
+ });
1653
+ }
1654
+ }
1655
+ UNSAFE_componentWillReceiveProps(nextProps) {
1656
+ if (!nextProps.correctResponse) {
1657
+ this.setState({
1658
+ showCorrect: false
1659
+ });
1660
+ }
1661
+ if (nextProps.alwaysShowCorrect) {
1662
+ this.setState({
1663
+ showCorrect: true
1664
+ });
1665
+ }
1666
+ }
1667
+ isSelected(value) {
1668
+ const sessionValue = this.props.session && this.props.session.value;
1669
+ return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;
1670
+ }
1671
+ indexToSymbol(index) {
1672
+ if (this.props.keyMode === 'numbers') {
1673
+ return `${index + 1}`;
1674
+ }
1675
+ if (this.props.keyMode === 'letters') {
1676
+ return String.fromCharCode(97 + index).toUpperCase();
1677
+ }
1678
+ return '';
1679
+ }
1680
+ __init() {
1681
+ this.getCorrectness = (choice = {}) => {
1682
+ const isCorrect = choice.correct;
1683
+ const isChecked = this.isSelected(choice.value);
1684
+ if (this.state.showCorrect) {
1685
+ return isCorrect ? 'correct' : undefined;
1686
+ }
1687
+ if (isCorrect) {
1688
+ if (isChecked) {
1689
+ return 'correct';
1690
+ } else {
1691
+ return 'incorrect';
1692
+ }
1693
+ } else {
1694
+ if (isChecked) {
1695
+ return 'incorrect';
1696
+ } else {
1697
+ return undefined;
1698
+ }
1699
+ }
1700
+ };
1701
+ }
1702
+ render() {
1703
+ const {mode, disabled, choices = [], choiceMode, prompt, onChoiceChanged, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled} = this.props;
1704
+ const {showCorrect} = this.state;
1705
+ const isEvaluateMode = mode === 'evaluate';
1706
+ const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
1707
+ return React$2.createElement('div', {
1708
+ className: classNames$1(classes.corespringChoice, 'multiple-choice'),
1709
+ __self: this,
1710
+ __source: {
1711
+ fileName: _jsxFileName$1,
1712
+ lineNumber: 146
1713
+ }
1714
+ }, teacherInstructions && React$2.createElement(React$2.Fragment, {
1715
+ __self: this,
1716
+ __source: {
1717
+ fileName: _jsxFileName$1,
1718
+ lineNumber: 148
1719
+ }
1720
+ }, !animationsDisabled ? React$2.createElement(Collapsible, {
1721
+ labels: {
1722
+ hidden: 'Show Teacher Instructions',
1723
+ visible: 'Hide Teacher Instructions'
1724
+ },
1725
+ __self: this,
1726
+ __source: {
1727
+ fileName: _jsxFileName$1,
1728
+ lineNumber: 150
1729
+ }
1730
+ }, React$2.createElement(PreviewPrompt, {
1731
+ tagName: "div",
1732
+ className: "prompt",
1733
+ prompt: teacherInstructions,
1734
+ __self: this,
1735
+ __source: {
1736
+ fileName: _jsxFileName$1,
1737
+ lineNumber: 156
1738
+ }
1739
+ })) : React$2.createElement(PreviewPrompt, {
1740
+ tagName: "div",
1741
+ className: "prompt",
1742
+ defaultClassName: "teacher-instructions",
1743
+ prompt: teacherInstructions,
1744
+ __self: this,
1745
+ __source: {
1746
+ fileName: _jsxFileName$1,
1747
+ lineNumber: 162
1748
+ }
1749
+ }), React$2.createElement('br', {
1750
+ __self: this,
1751
+ __source: {
1752
+ fileName: _jsxFileName$1,
1753
+ lineNumber: 168
1754
+ }
1755
+ })), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
1756
+ show: showCorrectAnswerToggle,
1757
+ toggled: showCorrect,
1758
+ onToggle: this.onToggle.bind(this),
1759
+ __self: this,
1760
+ __source: {
1761
+ fileName: _jsxFileName$1,
1762
+ lineNumber: 172
1763
+ }
1764
+ }), showCorrectAnswerToggle && React$2.createElement('br', {
1765
+ __self: this,
1766
+ __source: {
1767
+ fileName: _jsxFileName$1,
1768
+ lineNumber: 178
1769
+ }
1770
+ }), React$2.createElement(PreviewPrompt, {
1771
+ className: "prompt",
1772
+ defaultClassName: "prompt",
1773
+ prompt: prompt,
1774
+ __self: this,
1775
+ __source: {
1776
+ fileName: _jsxFileName$1,
1777
+ lineNumber: 179
1778
+ }
1779
+ }), React$2.createElement('div', {
1780
+ className: classNames$1({
1781
+ [classes.gridLayout]: this.props.choicesLayout === 'grid'
1782
+ }, {
1783
+ [classes.horizontalLayout]: this.props.choicesLayout === 'horizontal'
1784
+ }),
1785
+ style: styles.getColumns(this.props.gridColumns),
1786
+ __self: this,
1787
+ __source: {
1788
+ fileName: _jsxFileName$1,
1789
+ lineNumber: 180
1790
+ }
1791
+ }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
1792
+ choicesLayout: this.props.choicesLayout,
1793
+ gridColumns: this.props.gridColumns,
1794
+ key: `choice-${index}`,
1795
+ choice: choice,
1796
+ index: index,
1797
+ choicesLength: choices.length,
1798
+ showCorrect: showCorrect,
1799
+ isEvaluateMode: isEvaluateMode,
1800
+ choiceMode: choiceMode,
1801
+ disabled: disabled,
1802
+ onChoiceChanged: onChoiceChanged,
1803
+ hideTick: choice.hideTick,
1804
+ checked: showCorrect ? choice.correct || false : this.isSelected(choice.value),
1805
+ correctness: isEvaluateMode ? this.getCorrectness(choice) : undefined,
1806
+ displayKey: this.indexToSymbol(index),
1807
+ __self: this,
1808
+ __source: {
1809
+ fileName: _jsxFileName$1,
1810
+ lineNumber: 191
1811
+ }
1812
+ }))));
1813
+ }
1814
+ }
1815
+ MultipleChoice$1.__initStatic();
1816
+ MultipleChoice$1.defaultProps = {
1817
+ session: {
1818
+ value: []
1819
+ }
1820
+ };
1821
+ var MultipleChoice$2 = withStyles$1(styles)(MultipleChoice$1);
1822
+ const React$1 = _dll_react;
1823
+ const PropTypes = _dll_prop_types;
1824
+ const {withStyles: withStyles} = _dll_material_ui__core_styles;
1825
+ const {createMuiTheme: createMuiTheme} = _dll_material_ui__core_styles;
1826
+ const {MuiThemeProvider: MuiThemeProvider} = _dll_material_ui__core_styles;
1827
+ const classNames = _dll_classnames;
1828
+ const {PreviewLayout: PreviewLayout} = _dll_pie_lib__render_ui;
1829
+ const _jsxFileName = "/home/circleci/repo/packages/multiple-choice/src/main.jsx";
1830
+ class Main extends React$1.Component {
1831
+ static __initStatic() {
1832
+ this.propTypes = {
1833
+ model: PropTypes.object,
1834
+ session: PropTypes.object,
1835
+ onChoiceChanged: PropTypes.func,
1836
+ classes: PropTypes.object.isRequired
1837
+ };
1838
+ }
1839
+ static __initStatic2() {
1840
+ this.defaultProps = {
1841
+ model: {},
1842
+ session: {}
1843
+ };
1844
+ }
1845
+ constructor(props) {
1846
+ super(props);
1847
+ }
1848
+ render() {
1849
+ const {model, onChoiceChanged, session, classes} = this.props;
1850
+ return React$1.createElement(PreviewLayout, {
1851
+ __self: this,
1852
+ __source: {
1853
+ fileName: _jsxFileName,
1854
+ lineNumber: 30
1855
+ }
1856
+ }, model.partLabel && React$1.createElement('p', {
1857
+ __self: this,
1858
+ __source: {
1859
+ fileName: _jsxFileName,
1860
+ lineNumber: 31
1861
+ }
1862
+ }, model.partLabel), React$1.createElement('div', {
1863
+ className: classNames(classes.root, classes[model.className]),
1864
+ __self: this,
1865
+ __source: {
1866
+ fileName: _jsxFileName,
1867
+ lineNumber: 32
1868
+ }
1869
+ }, React$1.createElement(MultipleChoice$2, {
1870
+ ...model,
1871
+ session: session,
1872
+ onChoiceChanged: onChoiceChanged,
1873
+ __self: this,
1874
+ __source: {
1875
+ fileName: _jsxFileName,
1876
+ lineNumber: 33
1877
+ }
1878
+ })));
1879
+ }
1880
+ }
1881
+ Main.__initStatic();
1882
+ Main.__initStatic2();
1883
+ const Styled = withStyles({}, {
1884
+ name: 'Main'
1885
+ })(Main);
1886
+ const theme = createMuiTheme({
1887
+ typography: {
1888
+ useNextVariants: true
1889
+ }
1890
+ });
1891
+ const Root = props => React$1.createElement(MuiThemeProvider, {
1892
+ theme: theme,
1893
+ __self: undefined,
1894
+ __source: {
1895
+ fileName: _jsxFileName,
1896
+ lineNumber: 53
1897
+ }
1898
+ }, React$1.createElement(Styled, {
1899
+ ...props,
1900
+ __self: undefined,
1901
+ __source: {
1902
+ fileName: _jsxFileName,
1903
+ lineNumber: 54
1904
+ }
1905
+ }));
1906
+ const {concat: concat} = _dll_lodash;
1907
+ const {uniq: uniq} = _dll_lodash;
1908
+ const {without: without} = _dll_lodash;
1909
+ function updateSessionValue(session, choiceMode, data) {
1910
+ session.value = session.value || [];
1911
+ if (choiceMode === 'checkbox') {
1912
+ if (data.selected) {
1913
+ session.value = uniq(concat(session.value, [data.value]));
1914
+ } else {
1915
+ session.value = without(session.value, data.value);
1916
+ }
1917
+ }
1918
+ if (choiceMode === 'radio') {
1919
+ if (data.selected) {
1920
+ session.value = [data.value];
1921
+ } else {
1922
+ session.value = [];
1923
+ }
1924
+ }
1925
+ }
1926
+ const React = _dll_react;
1927
+ const ReactDOM = _dll_react_dom;
1928
+ const {debounce: debounce} = _dll_lodash;
1929
+ const debug$1 = _dll_debug;
1930
+ const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
1931
+ const log$1 = debug$1('pie-ui:multiple-choice');
1932
+ const isComplete = session => !!(session && session.value && session.value.length);
1933
+ class MultipleChoice extends HTMLElement {
1934
+ constructor() {
1935
+ super();
1936
+ this._model = null;
1937
+ this._session = null;
1938
+ this._rerender = debounce(() => {
1939
+ if (this._model && this._session) {
1940
+ var element = React.createElement(Root, {
1941
+ model: this._model,
1942
+ session: this._session,
1943
+ onChoiceChanged: this._onChange.bind(this)
1944
+ });
1945
+ ReactDOM.render(element, this, () => {
1946
+ log$1('render complete - render math');
1947
+ renderMath(this);
1948
+ });
1949
+ } else {
1950
+ log$1('skip');
1951
+ }
1952
+ }, 50, {
1953
+ leading: false,
1954
+ trailing: true
1955
+ });
1956
+ this._dispatchResponseChanged = debounce(() => {
1957
+ var event = new CustomEvent('session-changed', {
1958
+ bubbles: true,
1959
+ composed: true,
1960
+ detail: {
1961
+ complete: isComplete(this._session),
1962
+ component: this.tagName.toLowerCase()
1963
+ }
1964
+ });
1965
+ this.dispatchEvent(event);
1966
+ });
1967
+ this._dispatchModelSet = debounce(() => {
1968
+ this.dispatchEvent(new CustomEvent('model-set', {
1969
+ bubbles: true,
1970
+ composed: true,
1971
+ detail: {
1972
+ complete: isComplete(this._session),
1973
+ component: this.tagName.toLowerCase(),
1974
+ hasModel: this._model !== undefined
1975
+ }
1976
+ }));
1977
+ }, 50, {
1978
+ leading: false,
1979
+ trailing: true
1980
+ });
1981
+ }
1982
+ set model(s) {
1983
+ this._model = s;
1984
+ this._rerender();
1985
+ this._dispatchModelSet();
1986
+ }
1987
+ get session() {
1988
+ return this._session;
1989
+ }
1990
+ set session(s) {
1991
+ this._session = s;
1992
+ this._rerender();
1993
+ this._dispatchResponseChanged();
1994
+ }
1995
+ _onChange(data) {
1996
+ updateSessionValue(this._session, this._model.choiceMode, data);
1997
+ this._dispatchResponseChanged();
1998
+ this._rerender();
1999
+ }
2000
+ connectedCallback() {
2001
+ this._rerender();
2002
+ }
2003
+ }
2004
+ var lib = {};
2005
+ Object.defineProperty(lib, "__esModule", {
2006
+ value: true
2007
+ });
2008
+ class ModelSetEvent extends CustomEvent {
2009
+ constructor(component, complete, hasModel) {
2010
+ super(ModelSetEvent.TYPE, {
2011
+ bubbles: true,
2012
+ composed: true,
2013
+ detail: {
2014
+ complete,
2015
+ component,
2016
+ hasModel
2017
+ }
2018
+ });
2019
+ this.component = component;
2020
+ this.complete = complete;
2021
+ }
2022
+ }
2023
+ ModelSetEvent.TYPE = 'model-set';
2024
+ lib.ModelSetEvent = ModelSetEvent;
2025
+ class SessionChangedEvent extends CustomEvent {
2026
+ constructor(component, complete) {
2027
+ super(SessionChangedEvent.TYPE, {
2028
+ bubbles: true,
2029
+ composed: true,
2030
+ detail: {
2031
+ complete,
2032
+ component
2033
+ }
2034
+ });
2035
+ this.component = component;
2036
+ this.complete = complete;
2037
+ }
2038
+ }
2039
+ SessionChangedEvent.TYPE = 'session-changed';
2040
+ var SessionChangedEvent_1 = lib.SessionChangedEvent = SessionChangedEvent;
2041
+ const {cloneDeep: cloneDeep} = _dll_lodash;
2042
+ const {get: get} = _dll_lodash;
2043
+ const debug = _dll_debug;
2044
+ const MC_TAG_NAME = 'ebsr-multiple-choice';
2045
+ const SESSION_CHANGED = SessionChangedEvent_1.TYPE;
2046
+ const log = debug('pie-element:ebsr:print');
2047
+ const preparePrintModel = (model, opts) => {
2048
+ const instr = opts.role === 'instructor';
2049
+ model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
2050
+ model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
2051
+ model.showTeacherInstructions = instr;
2052
+ model.alwaysShowCorrect = instr;
2053
+ model.mode = instr ? 'evaluate' : model.mode;
2054
+ model.disabled = true;
2055
+ model.animationsDisabled = true;
2056
+ model.lockChoiceOrder = true;
2057
+ model.choicesLayout = model.choicesLayout || 'vertical';
2058
+ const choices = cloneDeep(model.choices);
2059
+ model.choices = choices.map(c => {
2060
+ c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
2061
+ c.hideTick = instr;
2062
+ c.feedback = undefined;
2063
+ return c;
2064
+ });
2065
+ model.keyMode = model.choicePrefix || 'letters';
2066
+ return model;
2067
+ };
2068
+ class EbsrMC extends MultipleChoice {}
2069
+ const defineMultipleChoice = () => {
2070
+ if (!customElements.get(MC_TAG_NAME)) {
2071
+ customElements.define(MC_TAG_NAME, EbsrMC);
2072
+ }
2073
+ };
2074
+ defineMultipleChoice();
2075
+ const isNonEmptyArray = a => Array.isArray(a) && a.length > 0;
2076
+ const isSessionComplete = session => {
2077
+ const a = get(session, 'value.partA.value');
2078
+ const b = get(session, 'value.partB.value');
2079
+ return isNonEmptyArray(a) && isNonEmptyArray(b);
2080
+ };
2081
+ class Ebsr extends HTMLElement {
2082
+ constructor() {
2083
+ super();
2084
+ Ebsr.prototype.__init.call(this);
2085
+ this._model = {};
2086
+ this._session = {};
2087
+ this._options = null;
2088
+ }
2089
+ __init() {
2090
+ this.onSessionUpdated = e => {
2091
+ if (e.target === this) {
2092
+ return;
2093
+ }
2094
+ e.preventDefault();
2095
+ e.stopImmediatePropagation();
2096
+ const id = e.target.getAttribute('id');
2097
+ if (id) {
2098
+ const key = `part${id.toUpperCase()}`;
2099
+ if (e.update) {
2100
+ this._model[key] = e.update;
2101
+ }
2102
+ this.dispatchSessionChanged(e.srcElement._session, key);
2103
+ }
2104
+ };
2105
+ }
2106
+ set model(m) {
2107
+ this._model = m;
2108
+ customElements.whenDefined(MC_TAG_NAME).then(() => {
2109
+ this.setPartModel(this.partA, 'partA');
2110
+ this.setPartModel(this.partB, 'partB');
2111
+ });
2112
+ }
2113
+ set session(s) {
2114
+ this._session = s;
2115
+ customElements.whenDefined(MC_TAG_NAME).then(() => {
2116
+ this.setPartSession(this.partA, 'partA');
2117
+ this.setPartSession(this.partB, 'partB');
2118
+ });
2119
+ }
2120
+ setPartModel(part, key) {
2121
+ if (this._model && this._model[key]) {
2122
+ const {mode} = this._model;
2123
+ part.model = {
2124
+ ...preparePrintModel(this._model[key], this._options),
2125
+ mode,
2126
+ keyMode: this._model[key].choicePrefix
2127
+ };
2128
+ if (!part._session) {
2129
+ part.session = {};
2130
+ }
2131
+ }
2132
+ }
2133
+ set options(o) {
2134
+ this._options = o;
2135
+ }
2136
+ setPartSession(part, key) {
2137
+ if (this._session && this._model) {
2138
+ const {value} = this._session;
2139
+ part.session = value && value[key] ? value[key] : {
2140
+ id: key
2141
+ };
2142
+ }
2143
+ }
2144
+ dispatchSessionChanged(partSession, key) {
2145
+ this._session.value = {
2146
+ ...this._session.value,
2147
+ [key]: partSession
2148
+ };
2149
+ log('[onSessionChanged] session: ', this._session);
2150
+ const complete = isSessionComplete(this._session);
2151
+ this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), complete));
2152
+ }
2153
+ get partA() {
2154
+ return this.querySelector(`${MC_TAG_NAME}#a`);
2155
+ }
2156
+ get partB() {
2157
+ return this.querySelector(`${MC_TAG_NAME}#b`);
2158
+ }
2159
+ connectedCallback() {
2160
+ this._render();
2161
+ this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);
2162
+ }
2163
+ disconnectedCallback() {
2164
+ this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);
2165
+ }
2166
+ _render() {
2167
+ this.innerHTML = `
2168
+ <div>
2169
+ <${MC_TAG_NAME} id="a"></${MC_TAG_NAME}>
2170
+ <${MC_TAG_NAME} id="b"></${MC_TAG_NAME}>
2171
+ </div>
2172
+ `;
2173
+ }
2174
+ }
2175
+ export {Ebsr as default, isSessionComplete};