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