@pie-element/ebsr 7.0.22 → 7.0.24-next.2

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.
Files changed (144) hide show
  1. package/CHANGELOG.md +0 -16
  2. package/configure/CHANGELOG.md +0 -16
  3. package/configure/lib/main.js +6 -4
  4. package/configure/lib/main.js.map +1 -1
  5. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +1972 -0
  6. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +1793 -0
  7. package/{LICENSE.md → configure/node_modules/@pie-element/multiple-choice/LICENSE.md} +0 -0
  8. package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +35 -0
  9. package/configure/node_modules/@pie-element/multiple-choice/README.md +56 -0
  10. package/configure/node_modules/@pie-element/multiple-choice/choice.png +0 -0
  11. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.json +1387 -0
  12. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +1334 -0
  13. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +104 -0
  14. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +1 -0
  15. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +198 -0
  16. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +1 -0
  17. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +599 -0
  18. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +1 -0
  19. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +18 -0
  20. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +1 -0
  21. package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +20 -0
  22. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +527 -0
  23. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +768 -0
  24. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +18 -0
  25. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +1 -0
  26. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +305 -0
  27. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +1 -0
  28. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +36 -0
  29. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +1 -0
  30. package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +15 -0
  31. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +353 -0
  32. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +277 -0
  33. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +8 -0
  34. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +52 -0
  35. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +1 -0
  36. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +7 -0
  37. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +338 -0
  38. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +274 -0
  39. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +298 -0
  40. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +1 -0
  41. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +157 -0
  42. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +1 -0
  43. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +174 -0
  44. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +1 -0
  45. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +151 -0
  46. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +1 -0
  47. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +97 -0
  48. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +1 -0
  49. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +254 -0
  50. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +1 -0
  51. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +129 -0
  52. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +1 -0
  53. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +35 -0
  54. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +1 -0
  55. package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +843 -0
  56. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/controller.js +17304 -17374
  57. package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +77 -0
  58. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/element.js +42 -171
  59. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/index.html +1 -1
  60. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/manifest.json +4 -4
  61. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print-demo.js +46 -46
  62. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.html +1 -1
  63. package/{module → configure/node_modules/@pie-element/multiple-choice/module}/print.js +70 -259
  64. package/configure/node_modules/@pie-element/multiple-choice/package.json +34 -0
  65. package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.json +672 -0
  66. package/configure/node_modules/@pie-lib/math-rendering/CHANGELOG.md +427 -0
  67. package/configure/node_modules/@pie-lib/math-rendering/LICENSE.md +5 -0
  68. package/configure/node_modules/@pie-lib/math-rendering/lib/index.js +30 -0
  69. package/configure/node_modules/@pie-lib/math-rendering/lib/index.js.map +1 -0
  70. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js +316 -0
  71. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/chtml.js.map +1 -0
  72. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js +23 -0
  73. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/index.js.map +1 -0
  74. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js +123 -0
  75. package/configure/node_modules/@pie-lib/math-rendering/lib/mstack/mml.js.map +1 -0
  76. package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js +103 -0
  77. package/configure/node_modules/@pie-lib/math-rendering/lib/normalization.js.map +1 -0
  78. package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js +275 -0
  79. package/configure/node_modules/@pie-lib/math-rendering/lib/render-math.js.map +1 -0
  80. package/configure/node_modules/@pie-lib/math-rendering/package.json +19 -0
  81. package/configure/node_modules/@pie-lib/math-rendering/playground/demo.html +872 -0
  82. package/configure/node_modules/@pie-lib/math-rendering/playground/demo.js +108 -0
  83. package/configure/node_modules/@pie-lib/math-rendering/playground/main.html +156 -0
  84. package/configure/node_modules/@pie-lib/math-rendering/playground/main.js +16 -0
  85. package/configure/node_modules/@pie-lib/math-rendering/playground/webpack.config.js +29 -0
  86. package/configure/node_modules/@pie-lib/math-rendering/src/index.js +4 -0
  87. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/chtml.js +215 -0
  88. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/index.js +13 -0
  89. package/configure/node_modules/@pie-lib/math-rendering/src/mstack/mml.js +24 -0
  90. package/configure/node_modules/@pie-lib/math-rendering/src/normalization.js +69 -0
  91. package/configure/node_modules/@pie-lib/math-rendering/src/render-math.js +234 -0
  92. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.json +937 -0
  93. package/configure/node_modules/@pie-lib/render-ui/CHANGELOG.md +602 -0
  94. package/configure/node_modules/@pie-lib/render-ui/LICENSE.md +5 -0
  95. package/configure/node_modules/@pie-lib/render-ui/README.md +33 -0
  96. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js +146 -0
  97. package/configure/node_modules/@pie-lib/render-ui/lib/collapsible/index.js.map +1 -0
  98. package/configure/node_modules/@pie-lib/render-ui/lib/color.js +134 -0
  99. package/configure/node_modules/@pie-lib/render-ui/lib/color.js.map +1 -0
  100. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js +160 -0
  101. package/configure/node_modules/@pie-lib/render-ui/lib/feedback.js.map +1 -0
  102. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js +24 -0
  103. package/configure/node_modules/@pie-lib/render-ui/lib/has-text.js.map +1 -0
  104. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js +102 -0
  105. package/configure/node_modules/@pie-lib/render-ui/lib/html-and-math.js.map +1 -0
  106. package/configure/node_modules/@pie-lib/render-ui/lib/index.js +104 -0
  107. package/configure/node_modules/@pie-lib/render-ui/lib/index.js.map +1 -0
  108. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js +60 -0
  109. package/configure/node_modules/@pie-lib/render-ui/lib/input-container.js.map +1 -0
  110. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js +133 -0
  111. package/configure/node_modules/@pie-lib/render-ui/lib/preview-layout.js.map +1 -0
  112. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js +162 -0
  113. package/configure/node_modules/@pie-lib/render-ui/lib/preview-prompt.js.map +1 -0
  114. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js +28 -0
  115. package/configure/node_modules/@pie-lib/render-ui/lib/purpose.js.map +1 -0
  116. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js +28 -0
  117. package/configure/node_modules/@pie-lib/render-ui/lib/readable.js.map +1 -0
  118. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js +160 -0
  119. package/configure/node_modules/@pie-lib/render-ui/lib/response-indicators.js.map +1 -0
  120. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js +206 -0
  121. package/configure/node_modules/@pie-lib/render-ui/lib/withUndoReset.js.map +1 -0
  122. package/configure/node_modules/@pie-lib/render-ui/package.json +30 -0
  123. package/configure/node_modules/@pie-lib/render-ui/src/collapsible/index.jsx +68 -0
  124. package/configure/node_modules/@pie-lib/render-ui/src/color.js +48 -0
  125. package/configure/node_modules/@pie-lib/render-ui/src/feedback.jsx +100 -0
  126. package/configure/node_modules/@pie-lib/render-ui/src/has-text.js +14 -0
  127. package/configure/node_modules/@pie-lib/render-ui/src/html-and-math.js +40 -0
  128. package/configure/node_modules/@pie-lib/render-ui/src/index.js +27 -0
  129. package/configure/node_modules/@pie-lib/render-ui/src/input-container.jsx +41 -0
  130. package/configure/node_modules/@pie-lib/render-ui/src/preview-layout.jsx +77 -0
  131. package/configure/node_modules/@pie-lib/render-ui/src/preview-prompt.jsx +90 -0
  132. package/configure/node_modules/@pie-lib/render-ui/src/purpose.jsx +19 -0
  133. package/configure/node_modules/@pie-lib/render-ui/src/readable.jsx +19 -0
  134. package/configure/node_modules/@pie-lib/render-ui/src/response-indicators.jsx +89 -0
  135. package/configure/node_modules/@pie-lib/render-ui/src/withUndoReset.jsx +118 -0
  136. package/configure/package.json +3 -3
  137. package/configure/src/__tests__/index.test.js +4 -2
  138. package/configure/src/main.jsx +8 -3
  139. package/controller/lib/index.js +79 -3
  140. package/controller/lib/index.js.map +1 -1
  141. package/controller/src/index.js +55 -0
  142. package/package.json +3 -3
  143. package/module/configure.js +0 -472
  144. package/module/demo.js +0 -77
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.MultipleChoice = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _react = _interopRequireDefault(require("react"));
25
+
26
+ var _propTypes = _interopRequireDefault(require("prop-types"));
27
+
28
+ var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
29
+
30
+ var _classnames = _interopRequireDefault(require("classnames"));
31
+
32
+ var _styles = require("@material-ui/core/styles");
33
+
34
+ var _renderUi = require("@pie-lib/render-ui");
35
+
36
+ var _choice = _interopRequireDefault(require("./choice"));
37
+
38
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
39
+
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
+
42
+ // MultipleChoice
43
+ var styles = {
44
+ corespringChoice: {
45
+ backgroundColor: _renderUi.color.background(),
46
+ padding: '5px',
47
+ '& *': {
48
+ '-webkit-font-smoothing': 'antialiased'
49
+ }
50
+ },
51
+ horizontalLayout: {
52
+ display: 'flex',
53
+ flexDirection: 'row',
54
+ flexWrap: 'wrap'
55
+ },
56
+ gridLayout: {
57
+ display: 'grid'
58
+ },
59
+ getColumns: function getColumns(columns) {
60
+ return columns > 1 ? {
61
+ gridTemplateColumns: "repeat(".concat(columns, ", 1fr)")
62
+ } : undefined;
63
+ }
64
+ };
65
+
66
+ var MultipleChoice = /*#__PURE__*/function (_React$Component) {
67
+ (0, _inherits2["default"])(MultipleChoice, _React$Component);
68
+
69
+ var _super = _createSuper(MultipleChoice);
70
+
71
+ function MultipleChoice(props) {
72
+ var _this;
73
+
74
+ (0, _classCallCheck2["default"])(this, MultipleChoice);
75
+ _this = _super.call(this, props);
76
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getCorrectness", function () {
77
+ var choice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
78
+ var isCorrect = choice.correct;
79
+
80
+ var isChecked = _this.isSelected(choice.value);
81
+
82
+ if (_this.state.showCorrect) {
83
+ return isCorrect ? 'correct' : undefined;
84
+ }
85
+
86
+ if (isCorrect) {
87
+ if (isChecked) {
88
+ // A correct answer is selected: marked with a green checkmark
89
+ return 'correct';
90
+ } else {
91
+ // A correct answer is NOT selected: marked with an orange X
92
+ return 'incorrect';
93
+ }
94
+ } else {
95
+ if (isChecked) {
96
+ // An incorrect answer is selected: marked with an orange X
97
+ return 'incorrect';
98
+ } else {
99
+ // An incorrect answer is NOT selected: not marked
100
+ return undefined;
101
+ }
102
+ }
103
+ });
104
+ _this.state = {
105
+ showCorrect: _this.props.alwaysShowCorrect || false
106
+ };
107
+ _this.onToggle = _this.onToggle.bind((0, _assertThisInitialized2["default"])(_this));
108
+ return _this;
109
+ }
110
+
111
+ (0, _createClass2["default"])(MultipleChoice, [{
112
+ key: "onToggle",
113
+ value: function onToggle() {
114
+ if (this.props.mode === 'evaluate') {
115
+ this.setState({
116
+ showCorrect: !this.state.showCorrect
117
+ });
118
+ }
119
+ }
120
+ }, {
121
+ key: "UNSAFE_componentWillReceiveProps",
122
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
123
+ if (!nextProps.correctResponse) {
124
+ this.setState({
125
+ showCorrect: false
126
+ });
127
+ }
128
+
129
+ if (nextProps.alwaysShowCorrect) {
130
+ this.setState({
131
+ showCorrect: true
132
+ });
133
+ }
134
+ }
135
+ }, {
136
+ key: "isSelected",
137
+ value: function isSelected(value) {
138
+ var sessionValue = this.props.session && this.props.session.value;
139
+ return sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0;
140
+ }
141
+ }, {
142
+ key: "indexToSymbol",
143
+ value: function indexToSymbol(index) {
144
+ if (this.props.keyMode === 'numbers') {
145
+ return "".concat(index + 1);
146
+ }
147
+
148
+ if (this.props.keyMode === 'letters') {
149
+ return String.fromCharCode(97 + index).toUpperCase();
150
+ }
151
+
152
+ return '';
153
+ }
154
+ }, {
155
+ key: "render",
156
+ value: function render() {
157
+ var _this2 = this;
158
+
159
+ var _this$props = this.props,
160
+ mode = _this$props.mode,
161
+ disabled = _this$props.disabled,
162
+ _this$props$choices = _this$props.choices,
163
+ choices = _this$props$choices === void 0 ? [] : _this$props$choices,
164
+ choiceMode = _this$props.choiceMode,
165
+ prompt = _this$props.prompt,
166
+ onChoiceChanged = _this$props.onChoiceChanged,
167
+ responseCorrect = _this$props.responseCorrect,
168
+ teacherInstructions = _this$props.teacherInstructions,
169
+ classes = _this$props.classes,
170
+ alwaysShowCorrect = _this$props.alwaysShowCorrect,
171
+ animationsDisabled = _this$props.animationsDisabled;
172
+ var showCorrect = this.state.showCorrect;
173
+ var isEvaluateMode = mode === 'evaluate';
174
+ var showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
175
+ return /*#__PURE__*/_react["default"].createElement("div", {
176
+ className: (0, _classnames["default"])(classes.corespringChoice, 'multiple-choice')
177
+ }, teacherInstructions && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !animationsDisabled ? /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
178
+ labels: {
179
+ hidden: 'Show Teacher Instructions',
180
+ visible: 'Hide Teacher Instructions'
181
+ }
182
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
183
+ tagName: "div",
184
+ className: "prompt",
185
+ prompt: teacherInstructions
186
+ })) : /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
187
+ tagName: "div",
188
+ className: "prompt",
189
+ defaultClassName: "teacher-instructions",
190
+ prompt: teacherInstructions
191
+ }), /*#__PURE__*/_react["default"].createElement("br", null)), !alwaysShowCorrect && /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
192
+ show: showCorrectAnswerToggle,
193
+ toggled: showCorrect,
194
+ onToggle: this.onToggle.bind(this)
195
+ }), showCorrectAnswerToggle && /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
196
+ className: "prompt",
197
+ defaultClassName: "prompt",
198
+ prompt: prompt
199
+ }), /*#__PURE__*/_react["default"].createElement("div", {
200
+ className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.gridLayout, this.props.choicesLayout === 'grid'), (0, _defineProperty2["default"])({}, classes.horizontalLayout, this.props.choicesLayout === 'horizontal')),
201
+ style: styles.getColumns(this.props.gridColumns)
202
+ }, choices.map(function (choice, index) {
203
+ return /*#__PURE__*/_react["default"].createElement(_choice["default"], {
204
+ choicesLayout: _this2.props.choicesLayout,
205
+ gridColumns: _this2.props.gridColumns,
206
+ key: "choice-".concat(index),
207
+ choice: choice,
208
+ index: index,
209
+ choicesLength: choices.length,
210
+ showCorrect: showCorrect,
211
+ isEvaluateMode: isEvaluateMode,
212
+ choiceMode: choiceMode,
213
+ disabled: disabled,
214
+ onChoiceChanged: onChoiceChanged,
215
+ hideTick: choice.hideTick,
216
+ checked: showCorrect ? choice.correct || false : _this2.isSelected(choice.value),
217
+ correctness: isEvaluateMode ? _this2.getCorrectness(choice) : undefined,
218
+ displayKey: _this2.indexToSymbol(index)
219
+ });
220
+ })));
221
+ }
222
+ }]);
223
+ return MultipleChoice;
224
+ }(_react["default"].Component);
225
+
226
+ exports.MultipleChoice = MultipleChoice;
227
+ (0, _defineProperty2["default"])(MultipleChoice, "propTypes", {
228
+ mode: _propTypes["default"].oneOf(['gather', 'view', 'evaluate']),
229
+ choiceMode: _propTypes["default"].oneOf(['radio', 'checkbox']),
230
+ keyMode: _propTypes["default"].oneOf(['numbers', 'letters', 'none']),
231
+ choices: _propTypes["default"].array,
232
+ prompt: _propTypes["default"].string,
233
+ teacherInstructions: _propTypes["default"].string,
234
+ session: _propTypes["default"].object,
235
+ disabled: _propTypes["default"].bool,
236
+ onChoiceChanged: _propTypes["default"].func,
237
+ responseCorrect: _propTypes["default"].bool,
238
+ classes: _propTypes["default"].object.isRequired,
239
+ correctResponse: _propTypes["default"].array,
240
+ choicesLayout: _propTypes["default"].oneOf(['vertical', 'grid', 'horizontal']),
241
+ gridColumns: _propTypes["default"].string,
242
+ alwaysShowCorrect: _propTypes["default"].bool,
243
+ animationsDisabled: _propTypes["default"].bool
244
+ });
245
+ MultipleChoice.defaultProps = {
246
+ session: {
247
+ value: []
248
+ }
249
+ };
250
+
251
+ var _default = (0, _styles.withStyles)(styles)(MultipleChoice);
252
+
253
+ exports["default"] = _default;
254
+ //# sourceMappingURL=multiple-choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/multiple-choice.jsx"],"names":["styles","corespringChoice","backgroundColor","color","background","padding","horizontalLayout","display","flexDirection","flexWrap","gridLayout","getColumns","columns","gridTemplateColumns","undefined","MultipleChoice","props","choice","isCorrect","correct","isChecked","isSelected","value","state","showCorrect","alwaysShowCorrect","onToggle","bind","mode","setState","nextProps","correctResponse","sessionValue","session","indexOf","index","keyMode","String","fromCharCode","toUpperCase","disabled","choices","choiceMode","prompt","onChoiceChanged","responseCorrect","teacherInstructions","classes","animationsDisabled","isEvaluateMode","showCorrectAnswerToggle","hidden","visible","choicesLayout","gridColumns","map","length","hideTick","getCorrectness","indexToSymbol","React","Component","PropTypes","oneOf","array","string","object","bool","func","isRequired","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA;AAEA,IAAMA,MAAM,GAAG;AACbC,EAAAA,gBAAgB,EAAE;AAChBC,IAAAA,eAAe,EAAEC,gBAAMC,UAAN,EAD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gB,CAAC,QAAD,EAAW,MAAX,EAAmB,UAAnB,CAAhB,CADW;AAEjBrB,EAAAA,UAAU,EAAEoB,sBAAUC,KAAV,CAAgB,CAAC,OAAD,EAAU,UAAV,CAAhB,CAFK;AAGjB3B,EAAAA,OAAO,EAAE0B,sBAAUC,KAAV,CAAgB,CAAC,SAAD,EAAY,SAAZ,EAAuB,MAAvB,CAAhB,CAHQ;AAIjBtB,EAAAA,OAAO,EAAEqB,sBAAUE,KAJF;AAKjBrB,EAAAA,MAAM,EAAEmB,sBAAUG,MALD;AAMjBnB,EAAAA,mBAAmB,EAAEgB,sBAAUG,MANd;AAOjBhC,EAAAA,OAAO,EAAE6B,sBAAUI,MAPF;AAQjB1B,EAAAA,QAAQ,EAAEsB,sBAAUK,IARH;AASjBvB,EAAAA,eAAe,EAAEkB,sBAAUM,IATV;AAUjBvB,EAAAA,eAAe,EAAEiB,sBAAUK,IAVV;AAWjBpB,EAAAA,OAAO,EAAEe,sBAAUI,MAAV,CAAiBG,UAXT;AAYjBtC,EAAAA,eAAe,EAAE+B,sBAAUE,KAZV;AAajBX,EAAAA,aAAa,EAAES,sBAAUC,KAAV,CAAgB,CAAC,UAAD,EAAa,MAAb,EAAqB,YAArB,CAAhB,CAbE;AAcjBT,EAAAA,WAAW,EAAEQ,sBAAUG,MAdN;AAejBxC,EAAAA,iBAAiB,EAAEqC,sBAAUK,IAfZ;AAgBjBnB,EAAAA,kBAAkB,EAAEc,sBAAUK;AAhBb,C;AA0LrBpD,cAAc,CAACuD,YAAf,GAA8B;AAC5BrC,EAAAA,OAAO,EAAE;AACPX,IAAAA,KAAK,EAAE;AADA;AADmB,CAA9B;;eAMe,wBAAWtB,MAAX,EAAmBe,cAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color, Collapsible, PreviewPrompt } from '@pie-lib/render-ui';\nimport StyledChoice from './choice';\n\n// MultipleChoice\n\nconst styles = {\n corespringChoice: {\n backgroundColor: color.background(),\n padding: '5px',\n '& *': {\n '-webkit-font-smoothing': 'antialiased',\n },\n },\n horizontalLayout: {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\n gridLayout: {\n display: 'grid',\n },\n getColumns: function (columns) {\n return columns > 1\n ? { gridTemplateColumns: `repeat(${columns}, 1fr)` }\n : undefined;\n },\n};\n\nexport class MultipleChoice extends React.Component {\n static propTypes = {\n mode: PropTypes.oneOf(['gather', 'view', 'evaluate']),\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n keyMode: PropTypes.oneOf(['numbers', 'letters', 'none']),\n choices: PropTypes.array,\n prompt: PropTypes.string,\n teacherInstructions: PropTypes.string,\n session: PropTypes.object,\n disabled: PropTypes.bool,\n onChoiceChanged: PropTypes.func,\n responseCorrect: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n correctResponse: PropTypes.array,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n gridColumns: PropTypes.string,\n alwaysShowCorrect: PropTypes.bool,\n animationsDisabled: PropTypes.bool,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCorrect: this.props.alwaysShowCorrect || false,\n };\n\n this.onToggle = this.onToggle.bind(this);\n }\n\n onToggle() {\n if (this.props.mode === 'evaluate') {\n this.setState({ showCorrect: !this.state.showCorrect });\n }\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!nextProps.correctResponse) {\n this.setState({ showCorrect: false });\n }\n\n if (nextProps.alwaysShowCorrect) {\n this.setState({ showCorrect: true });\n }\n }\n\n isSelected(value) {\n const sessionValue = this.props.session && this.props.session.value;\n\n return (\n sessionValue && sessionValue.indexOf && sessionValue.indexOf(value) >= 0\n );\n }\n\n indexToSymbol(index) {\n if (this.props.keyMode === 'numbers') {\n return `${index + 1}`;\n }\n\n if (this.props.keyMode === 'letters') {\n return String.fromCharCode(97 + index).toUpperCase();\n }\n\n return '';\n }\n\n getCorrectness = (choice = {}) => {\n const isCorrect = choice.correct;\n const isChecked = this.isSelected(choice.value);\n\n if (this.state.showCorrect) {\n return isCorrect ? 'correct' : undefined;\n }\n\n if (isCorrect) {\n if (isChecked) {\n // A correct answer is selected: marked with a green checkmark\n return 'correct';\n } else {\n // A correct answer is NOT selected: marked with an orange X\n return 'incorrect';\n }\n } else {\n if (isChecked) {\n // An incorrect answer is selected: marked with an orange X\n return 'incorrect';\n } else {\n // An incorrect answer is NOT selected: not marked\n return undefined;\n }\n }\n };\n\n render() {\n const {\n mode,\n disabled,\n choices = [],\n choiceMode,\n prompt,\n onChoiceChanged,\n responseCorrect,\n teacherInstructions,\n classes,\n alwaysShowCorrect,\n animationsDisabled\n } = this.props;\n const { showCorrect } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;\n\n return (\n <div className={classNames(classes.corespringChoice, 'multiple-choice')}>\n {teacherInstructions && (\n <React.Fragment>\n {!animationsDisabled ?\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n prompt={teacherInstructions}\n />\n </Collapsible> :\n <PreviewPrompt\n tagName=\"div\"\n className=\"prompt\"\n defaultClassName=\"teacher-instructions\"\n prompt={teacherInstructions}\n />}\n <br />\n </React.Fragment>\n )}\n {!alwaysShowCorrect && (\n <CorrectAnswerToggle\n show={showCorrectAnswerToggle}\n toggled={showCorrect}\n onToggle={this.onToggle.bind(this)}\n />\n )}\n {showCorrectAnswerToggle && <br />}\n <PreviewPrompt className=\"prompt\" defaultClassName=\"prompt\" prompt={prompt} />\n <div\n className={classNames(\n { [classes.gridLayout]: this.props.choicesLayout === 'grid' },\n {\n [classes.horizontalLayout]:\n this.props.choicesLayout === 'horizontal',\n }\n )}\n style={styles.getColumns(this.props.gridColumns)}\n >\n {choices.map((choice, index) => (\n <StyledChoice\n choicesLayout={this.props.choicesLayout}\n gridColumns={this.props.gridColumns}\n key={`choice-${index}`}\n choice={choice}\n index={index}\n choicesLength={choices.length}\n showCorrect={showCorrect}\n isEvaluateMode={isEvaluateMode}\n choiceMode={choiceMode}\n disabled={disabled}\n onChoiceChanged={onChoiceChanged}\n hideTick={choice.hideTick}\n checked={\n showCorrect\n ? choice.correct || false\n : this.isSelected(choice.value)\n }\n correctness={\n isEvaluateMode ? this.getCorrectness(choice) : undefined\n }\n displayKey={this.indexToSymbol(index)}\n />\n ))}\n </div>\n </div>\n );\n }\n}\n\nMultipleChoice.defaultProps = {\n session: {\n value: [],\n },\n};\n\nexport default withStyles(styles)(MultipleChoice);\n"],"file":"multiple-choice.js"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
23
+
24
+ var _react = _interopRequireDefault(require("react"));
25
+
26
+ var _reactDom = _interopRequireDefault(require("react-dom"));
27
+
28
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
29
+
30
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
31
+
32
+ var _main = _interopRequireDefault(require("./main"));
33
+
34
+ var _mathRendering = require("@pie-lib/math-rendering");
35
+
36
+ var _debug = _interopRequireDefault(require("debug"));
37
+
38
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
39
+
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
+
42
+ var log = (0, _debug["default"])('pie-element:multiple-choice:print');
43
+ /**
44
+ * Live in same package as main element - so we can access some of the shared comps!
45
+ *
46
+ * - update pslb to build print if src/print.js is there
47
+ * - update demo el
48
+ * - get configure/controller building
49
+ */
50
+
51
+ var preparePrintModel = function preparePrintModel(model, opts) {
52
+ var instr = opts.role === 'instructor';
53
+ model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
54
+ model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
55
+ model.showTeacherInstructions = instr;
56
+ model.alwaysShowCorrect = instr;
57
+ model.mode = instr ? 'evaluate' : model.mode;
58
+ model.disabled = true;
59
+ model.animationsDisabled = true;
60
+ model.lockChoiceOrder = true;
61
+ model.choicesLayout = model.choicesLayout || 'vertical';
62
+ var choices = (0, _cloneDeep["default"])(model.choices);
63
+ model.choices = choices.map(function (c) {
64
+ c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;
65
+ c.hideTick = instr;
66
+ c.feedback = undefined;
67
+ return c;
68
+ });
69
+ model.keyMode = model.choicePrefix || 'letters';
70
+ return model;
71
+ };
72
+
73
+ var MultipleChoicePrint = /*#__PURE__*/function (_HTMLElement) {
74
+ (0, _inherits2["default"])(MultipleChoicePrint, _HTMLElement);
75
+
76
+ var _super = _createSuper(MultipleChoicePrint);
77
+
78
+ function MultipleChoicePrint() {
79
+ var _this;
80
+
81
+ (0, _classCallCheck2["default"])(this, MultipleChoicePrint);
82
+ _this = _super.call(this);
83
+ _this._options = null;
84
+ _this._model = null;
85
+ _this._session = [];
86
+ _this._rerender = (0, _debounce["default"])(function () {
87
+ if (_this._model && _this._session) {
88
+ var printModel = preparePrintModel(_this._model, _this._options);
89
+
90
+ var element = _this._options && /*#__PURE__*/_react["default"].createElement(_main["default"], {
91
+ model: printModel,
92
+ session: {}
93
+ });
94
+
95
+ _reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
96
+ log('render complete - render math');
97
+ (0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
98
+ });
99
+ } else {
100
+ log('skip');
101
+ }
102
+ }, 50, {
103
+ leading: false,
104
+ trailing: true
105
+ });
106
+ return _this;
107
+ }
108
+
109
+ (0, _createClass2["default"])(MultipleChoicePrint, [{
110
+ key: "options",
111
+ set: function set(o) {
112
+ this._options = o;
113
+ }
114
+ }, {
115
+ key: "model",
116
+ set: function set(s) {
117
+ this._model = s;
118
+
119
+ this._rerender();
120
+ }
121
+ }, {
122
+ key: "connectedCallback",
123
+ value: function connectedCallback() {}
124
+ }]);
125
+ return MultipleChoicePrint;
126
+ }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
127
+
128
+ exports["default"] = MultipleChoicePrint;
129
+ //# sourceMappingURL=print.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","alwaysShowCorrect","mode","disabled","animationsDisabled","lockChoiceOrder","choicesLayout","choices","map","c","rationale","rationaleEnabled","hideTick","feedback","keyMode","choicePrefix","MultipleChoicePrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","session","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mCAAN,CAAZ;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GAA4BL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SAA9G;AACAN,EAAAA,KAAK,CAACS,uBAAN,GAAgCP,KAAhC;AACAF,EAAAA,KAAK,CAACU,iBAAN,GAA0BR,KAA1B;AACAF,EAAAA,KAAK,CAACW,IAAN,GAAaT,KAAK,GAAG,UAAH,GAAgBF,KAAK,CAACW,IAAxC;AAEAX,EAAAA,KAAK,CAACY,QAAN,GAAiB,IAAjB;AACAZ,EAAAA,KAAK,CAACa,kBAAN,GAA2B,IAA3B;AACAb,EAAAA,KAAK,CAACc,eAAN,GAAwB,IAAxB;AACAd,EAAAA,KAAK,CAACe,aAAN,GAAsBf,KAAK,CAACe,aAAN,IAAuB,UAA7C;AAEA,MAAMC,OAAO,GAAG,2BAAUhB,KAAK,CAACgB,OAAhB,CAAhB;AAEAhB,EAAAA,KAAK,CAACgB,OAAN,GAAgBA,OAAO,CAACC,GAAR,CAAY,UAACC,CAAD,EAAO;AACjCA,IAAAA,CAAC,CAACC,S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AAcc,CAAd;;AACA,WAAKZ,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAvCyBa,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport cloneDeep from 'lodash/cloneDeep';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\n\nconst log = debug('pie-element:multiple-choice:print');\n\n/**\n * Live in same package as main element - so we can access some of the shared comps!\n *\n * - update pslb to build print if src/print.js is there\n * - update demo el\n * - get configure/controller building\n */\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.alwaysShowCorrect = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n model.disabled = true;\n model.animationsDisabled = true;\n model.lockChoiceOrder = true;\n model.choicesLayout = model.choicesLayout || 'vertical';\n\n const choices = cloneDeep(model.choices);\n\n model.choices = choices.map((c) => {\n c.rationale = instr && model.rationaleEnabled !== false ? c.rationale : undefined;\n c.hideTick = instr;\n c.feedback = undefined;\n return c;\n });\n\n model.keyMode = model.choicePrefix || 'letters';\n\n return model;\n};\n\nexport default class MultipleChoicePrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n });\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true }\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.updateSessionValue = updateSessionValue;
9
+
10
+ var _concat = _interopRequireDefault(require("lodash/concat"));
11
+
12
+ var _uniq = _interopRequireDefault(require("lodash/uniq"));
13
+
14
+ var _without = _interopRequireDefault(require("lodash/without"));
15
+
16
+ function updateSessionValue(session, choiceMode, data) {
17
+ session.value = session.value || [];
18
+
19
+ if (choiceMode === 'checkbox') {
20
+ if (data.selected) {
21
+ session.value = (0, _uniq["default"])((0, _concat["default"])(session.value, [data.value]));
22
+ } else {
23
+ session.value = (0, _without["default"])(session.value, data.value);
24
+ }
25
+ }
26
+
27
+ if (choiceMode === 'radio') {
28
+ if (data.selected) {
29
+ session.value = [data.value];
30
+ } else {
31
+ session.value = [];
32
+ }
33
+ }
34
+ }
35
+ //# sourceMappingURL=session-updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/session-updater.js"],"names":["updateSessionValue","session","choiceMode","data","value","selected"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,SAASA,kBAAT,CAA4BC,OAA5B,EAAqCC,UAArC,EAAiDC,IAAjD,EAAuD;AAC5DF,EAAAA,OAAO,CAACG,KAAR,GAAgBH,OAAO,CAACG,KAAR,IAAiB,EAAjC;;AACA,MAAIF,UAAU,KAAK,UAAnB,EAA+B;AAC7B,QAAIC,IAAI,CAACE,QAAT,EAAmB;AACjBJ,MAAAA,OAAO,CAACG,KAAR,GAAgB,sBAAK,wBAAOH,OAAO,CAACG,KAAf,EAAsB,CAACD,IAAI,CAACC,KAAN,CAAtB,CAAL,CAAhB;AACD,KAFD,MAEO;AACLH,MAAAA,OAAO,CAACG,KAAR,GAAgB,yBAAQH,OAAO,CAACG,KAAhB,EAAuBD,IAAI,CAACC,KAA5B,CAAhB;AACD;AACF;;AAGD,MAAIF,UAAU,KAAK,OAAnB,EAA4B;AAC1B,QAAIC,IAAI,CAACE,QAAT,EAAmB;AACjBJ,MAAAA,OAAO,CAACG,KAAR,GAAgB,CAACD,IAAI,CAACC,KAAN,CAAhB;AACD,KAFD,MAEO;AACLH,MAAAA,OAAO,CAACG,KAAR,GAAgB,EAAhB;AACD;AACF;AACF","sourcesContent":["import concat from 'lodash/concat';\nimport uniq from 'lodash/uniq';\nimport without from 'lodash/without';\n\nexport function updateSessionValue(session, choiceMode, data) {\n session.value = session.value || [];\n if (choiceMode === 'checkbox') {\n if (data.selected) {\n session.value = uniq(concat(session.value, [data.value]));\n } else {\n session.value = without(session.value, data.value);\n }\n }\n\n\n if (choiceMode === 'radio') {\n if (data.selected) {\n session.value = [data.value]\n } else {\n session.value = [];\n }\n }\n}\n"],"file":"session-updater.js"}