@pie-element/ebsr 10.7.3-next.12 → 10.7.3-next.14

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 (64) hide show
  1. package/module/index.html +1 -1
  2. package/module/manifest.json +1 -1
  3. package/module/print.html +1 -1
  4. package/package.json +3 -3
  5. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.json +0 -1972
  6. package/configure/node_modules/@pie-element/multiple-choice/CHANGELOG.md +0 -4144
  7. package/configure/node_modules/@pie-element/multiple-choice/LICENSE.md +0 -5
  8. package/configure/node_modules/@pie-element/multiple-choice/PRINT.md +0 -35
  9. package/configure/node_modules/@pie-element/multiple-choice/README.md +0 -56
  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 +0 -1387
  12. package/configure/node_modules/@pie-element/multiple-choice/configure/CHANGELOG.md +0 -3316
  13. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js +0 -202
  14. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/defaults.js.map +0 -1
  15. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js +0 -248
  16. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/index.js.map +0 -1
  17. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js +0 -597
  18. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/main.js.map +0 -1
  19. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js +0 -18
  20. package/configure/node_modules/@pie-element/multiple-choice/configure/lib/utils.js.map +0 -1
  21. package/configure/node_modules/@pie-element/multiple-choice/configure/package.json +0 -18
  22. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.json +0 -527
  23. package/configure/node_modules/@pie-element/multiple-choice/controller/CHANGELOG.md +0 -2281
  24. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js +0 -34
  25. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/defaults.js.map +0 -1
  26. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js +0 -346
  27. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/index.js.map +0 -1
  28. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js +0 -28
  29. package/configure/node_modules/@pie-element/multiple-choice/controller/lib/utils.js.map +0 -1
  30. package/configure/node_modules/@pie-element/multiple-choice/controller/package.json +0 -15
  31. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json +0 -2993
  32. package/configure/node_modules/@pie-element/multiple-choice/docs/config-schema.json.md +0 -2217
  33. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/config.js +0 -8
  34. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/generate.js +0 -61
  35. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/index.html +0 -1
  36. package/configure/node_modules/@pie-element/multiple-choice/docs/demo/session.js +0 -7
  37. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json +0 -1332
  38. package/configure/node_modules/@pie-element/multiple-choice/docs/pie-schema.json.md +0 -1015
  39. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js +0 -427
  40. package/configure/node_modules/@pie-element/multiple-choice/lib/choice-input.js.map +0 -1
  41. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js +0 -252
  42. package/configure/node_modules/@pie-element/multiple-choice/lib/choice.js.map +0 -1
  43. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js +0 -174
  44. package/configure/node_modules/@pie-element/multiple-choice/lib/feedback-tick.js.map +0 -1
  45. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js +0 -388
  46. package/configure/node_modules/@pie-element/multiple-choice/lib/index.js.map +0 -1
  47. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js +0 -108
  48. package/configure/node_modules/@pie-element/multiple-choice/lib/main.js.map +0 -1
  49. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js +0 -469
  50. package/configure/node_modules/@pie-element/multiple-choice/lib/multiple-choice.js.map +0 -1
  51. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js +0 -129
  52. package/configure/node_modules/@pie-element/multiple-choice/lib/print.js.map +0 -1
  53. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js +0 -48
  54. package/configure/node_modules/@pie-element/multiple-choice/lib/session-updater.js.map +0 -1
  55. package/configure/node_modules/@pie-element/multiple-choice/module/configure.js +0 -1
  56. package/configure/node_modules/@pie-element/multiple-choice/module/controller.js +0 -3611
  57. package/configure/node_modules/@pie-element/multiple-choice/module/demo.js +0 -86
  58. package/configure/node_modules/@pie-element/multiple-choice/module/element.js +0 -1
  59. package/configure/node_modules/@pie-element/multiple-choice/module/index.html +0 -21
  60. package/configure/node_modules/@pie-element/multiple-choice/module/manifest.json +0 -10
  61. package/configure/node_modules/@pie-element/multiple-choice/module/print-demo.js +0 -124
  62. package/configure/node_modules/@pie-element/multiple-choice/module/print.html +0 -18
  63. package/configure/node_modules/@pie-element/multiple-choice/module/print.js +0 -1
  64. package/configure/node_modules/@pie-element/multiple-choice/package.json +0 -32
@@ -1,427 +0,0 @@
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.StyledRadio = exports.StyledFormControlLabel = exports.StyledCheckbox = exports.ChoiceInput = 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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
23
-
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
- var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
27
-
28
- var _react = _interopRequireDefault(require("react"));
29
-
30
- var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
- var _styles = require("@material-ui/core/styles");
33
-
34
- var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
35
-
36
- var _renderUi = require("@pie-lib/pie-toolbox/render-ui");
37
-
38
- var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));
39
-
40
- var _classnames = _interopRequireDefault(require("classnames"));
41
-
42
- var _feedbackTick = _interopRequireDefault(require("./feedback-tick"));
43
-
44
- 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); }; }
45
-
46
- 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; } }
47
-
48
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
49
-
50
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
51
-
52
- var CLASS_NAME = 'multiple-choice-component';
53
-
54
- var styleSheet = function styleSheet(theme) {
55
- return {
56
- row: {
57
- display: 'flex',
58
- alignItems: 'center',
59
- backgroundColor: _renderUi.color.background()
60
- },
61
- checkboxHolder: {
62
- display: 'flex',
63
- alignItems: 'center',
64
- backgroundColor: _renderUi.color.background(),
65
- flex: 1,
66
- '& label': {
67
- color: _renderUi.color.text(),
68
- '& > span': {
69
- fontSize: 'inherit'
70
- }
71
- }
72
- },
73
- horizontalLayout: (0, _defineProperty2["default"])({}, "& .".concat(CLASS_NAME), {
74
- // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles
75
- // add margin to the top, left and bottom of the checkbox to keep the same spacing as before
76
- padding: theme.spacing.unit,
77
- margin: "".concat(theme.spacing.unit / 2, "px 0 ").concat(theme.spacing.unit / 2, "px ").concat(theme.spacing.unit / 2, "px")
78
- }),
79
- belowLayout: {
80
- '& > label': {
81
- alignItems: 'flex-start'
82
- }
83
- },
84
- belowLayoutCenter: {
85
- justifyContent: 'center',
86
- '& > label': {
87
- alignItems: 'center'
88
- }
89
- },
90
- belowSelectionComponent: {
91
- display: 'flex',
92
- alignItems: 'center',
93
- '& > span': {
94
- // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles
95
- marginLeft: "-".concat(theme.spacing.unit, "px")
96
- }
97
- },
98
- srOnly: {
99
- position: 'absolute',
100
- left: '-10000px',
101
- top: 'auto',
102
- width: '1px',
103
- height: '1px',
104
- overflow: 'hidden'
105
- }
106
- };
107
- };
108
-
109
- var formStyleSheet = {
110
- label: {
111
- color: "".concat(_renderUi.color.text(), " !important"),
112
- //'var(--choice-input-color, black)'
113
- backgroundColor: _renderUi.color.background(),
114
- letterSpacing: 'normal'
115
- },
116
- disabled: {
117
- // apply to all children
118
- '& *': {
119
- cursor: 'not-allowed !important'
120
- }
121
- }
122
- };
123
- var StyledFormControlLabel = (0, _styles.withStyles)(formStyleSheet, {
124
- name: 'FormControlLabel'
125
- })(function (props) {
126
- return /*#__PURE__*/_react["default"].createElement(_FormControlLabel["default"], (0, _extends2["default"])({}, props, {
127
- classes: {
128
- label: props.classes.label,
129
- disabled: props.classes.disabled
130
- }
131
- }));
132
- });
133
- exports.StyledFormControlLabel = StyledFormControlLabel;
134
-
135
- var colorStyle = function colorStyle(varName, fallback) {
136
- return (0, _defineProperty2["default"])({}, "&.".concat(CLASS_NAME), {
137
- color: "var(--choice-input-".concat(varName, ", ").concat(fallback, ") !important")
138
- });
139
- };
140
-
141
- var inputStyles = {
142
- 'correct-root': colorStyle('correct-color', _renderUi.color.text()),
143
- 'correct-checked': colorStyle('correct-selected-color', _renderUi.color.correct()),
144
- //green[500]),
145
- 'correct-disabled': colorStyle('correct-disabled-color', _renderUi.color.disabled()),
146
- //'grey'),
147
- 'incorrect-root': colorStyle('incorrect-color', _renderUi.color.incorrect()),
148
- 'incorrect-checked': colorStyle('incorrect-checked', _renderUi.color.incorrect()),
149
- //orange[500]),
150
- 'incorrect-disabled': colorStyle('incorrect-disabled-color', _renderUi.color.disabled()),
151
- root: _objectSpread(_objectSpread({}, colorStyle('color', _renderUi.color.text())), {}, {
152
- '&:hover': {
153
- color: "".concat(_renderUi.color.primaryLight(), " !important")
154
- }
155
- }),
156
- checked: colorStyle('selected-color', _renderUi.color.primary()),
157
- disabled: _objectSpread(_objectSpread({}, colorStyle('disabled-color', _renderUi.color.text())), {}, {
158
- opacity: 0.6,
159
- cursor: 'not-allowed !important',
160
- pointerEvents: 'initial !important'
161
- }),
162
- focusVisibleUnchecked: {
163
- outline: "2px solid ".concat(_renderUi.color.focusUncheckedBorder()),
164
- backgroundColor: _renderUi.color.focusUnchecked()
165
- },
166
- focusVisibleChecked: {
167
- outline: "2px solid ".concat(_renderUi.color.focusCheckedBorder()),
168
- backgroundColor: _renderUi.color.focusChecked()
169
- }
170
- };
171
- var StyledCheckbox = (0, _styles.withStyles)(inputStyles)(function (props) {
172
- var correctness = props.correctness,
173
- classes = props.classes,
174
- checked = props.checked,
175
- onChange = props.onChange,
176
- disabled = props.disabled,
177
- value = props.value,
178
- id = props.id,
179
- onKeyDown = props.onKeyDown,
180
- inputRef = props.inputRef;
181
-
182
- var key = function key(k) {
183
- return correctness ? "".concat(correctness, "-").concat(k) : k;
184
- };
185
-
186
- var resolved = {
187
- root: classes[key('root')],
188
- checked: classes[key('checked')],
189
- disabled: classes[key('disabled')]
190
- };
191
- var miniProps = {
192
- checked: checked,
193
- onChange: onChange,
194
- disabled: disabled,
195
- value: value
196
- };
197
- return /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], (0, _extends2["default"])({
198
- id: id,
199
- inputRef: inputRef,
200
- "aria-checked": checked,
201
- onKeyDown: onKeyDown,
202
- focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
203
- disableRipple: true
204
- }, miniProps, {
205
- className: CLASS_NAME,
206
- classes: {
207
- root: resolved.root,
208
- checked: resolved.checked,
209
- disabled: "".concat(correctness ? '' : resolved.disabled)
210
- }
211
- }));
212
- });
213
- exports.StyledCheckbox = StyledCheckbox;
214
- var StyledRadio = (0, _styles.withStyles)(inputStyles)(function (props) {
215
- var correctness = props.correctness,
216
- classes = props.classes,
217
- checked = props.checked,
218
- onChange = props.onChange,
219
- disabled = props.disabled,
220
- value = props.value,
221
- id = props.id,
222
- tagName = props.tagName,
223
- inputRef = props.inputRef;
224
-
225
- var key = function key(k) {
226
- return correctness ? "".concat(correctness, "-").concat(k) : k;
227
- };
228
-
229
- var resolved = {
230
- root: classes[key('root')],
231
- checked: classes[key('checked')],
232
- disabled: classes[key('disabled')]
233
- };
234
- var miniProps = {
235
- checked: checked,
236
- onChange: onChange,
237
- disabled: disabled,
238
- value: value
239
- };
240
- return /*#__PURE__*/_react["default"].createElement(_Radio["default"], (0, _extends2["default"])({
241
- id: id,
242
- inputRef: inputRef,
243
- "aria-checked": checked,
244
- focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
245
- disableRipple: true
246
- }, miniProps, {
247
- className: CLASS_NAME,
248
- name: tagName,
249
- classes: {
250
- root: resolved.root,
251
- checked: resolved.checked,
252
- disabled: "".concat(correctness ? '' : resolved.disabled)
253
- }
254
- }));
255
- });
256
- exports.StyledRadio = StyledRadio;
257
-
258
- var ChoiceInput = /*#__PURE__*/function (_React$Component) {
259
- (0, _inherits2["default"])(ChoiceInput, _React$Component);
260
-
261
- var _super = _createSuper(ChoiceInput);
262
-
263
- function ChoiceInput(props) {
264
- var _this;
265
-
266
- (0, _classCallCheck2["default"])(this, ChoiceInput);
267
- _this = _super.call(this, props);
268
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (event) {
269
- var choiceMode = _this.props.choiceMode;
270
- if (choiceMode !== 'checkbox') return;
271
- var isArrowDown = event.key === 'ArrowDown';
272
- var isArrowUp = event.key === 'ArrowUp';
273
- if (!isArrowDown && !isArrowUp) return;
274
- event.preventDefault();
275
- var currentEl = document.getElementById(_this.choiceId);
276
- if (!currentEl) return;
277
- var fieldset = currentEl.closest('fieldset');
278
- if (!fieldset) return;
279
- var groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
280
- var currentIndex = groupCheckboxes.findIndex(function (el) {
281
- return el === currentEl;
282
- });
283
- if (currentIndex === -1) return;
284
- var nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
285
- var nextEl = groupCheckboxes[nextIndex];
286
-
287
- if (nextEl) {
288
- nextEl.focus();
289
- }
290
- });
291
- _this.onToggleChoice = _this.onToggleChoice.bind((0, _assertThisInitialized2["default"])(_this));
292
- _this.choiceId = _this.generateChoiceId();
293
- _this.descId = "".concat(_this.choiceId, "-desc");
294
- return _this;
295
- }
296
-
297
- (0, _createClass2["default"])(ChoiceInput, [{
298
- key: "onToggleChoice",
299
- value: function onToggleChoice(event) {
300
- this.props.onChange(event);
301
- }
302
- }, {
303
- key: "generateChoiceId",
304
- value: function generateChoiceId() {
305
- return 'choice-' + (Math.random() * 10000).toFixed();
306
- }
307
- }, {
308
- key: "render",
309
- value: function render() {
310
- var _classNames;
311
-
312
- var _this$props = this.props,
313
- choiceMode = _this$props.choiceMode,
314
- disabled = _this$props.disabled,
315
- displayKey = _this$props.displayKey,
316
- feedback = _this$props.feedback,
317
- label = _this$props.label,
318
- correctness = _this$props.correctness,
319
- classes = _this$props.classes,
320
- className = _this$props.className,
321
- rationale = _this$props.rationale,
322
- hideTick = _this$props.hideTick,
323
- isEvaluateMode = _this$props.isEvaluateMode,
324
- choicesLayout = _this$props.choicesLayout,
325
- value = _this$props.value,
326
- checked = _this$props.checked,
327
- tagName = _this$props.tagName,
328
- isSelectionButtonBelow = _this$props.isSelectionButtonBelow;
329
- var Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
330
- var classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';
331
- var holderClassNames = (0, _classnames["default"])(classes.checkboxHolder, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, classes.horizontalLayout, choicesLayout === 'horizontal'), (0, _defineProperty2["default"])(_classNames, classes.belowLayout, isSelectionButtonBelow && choicesLayout !== 'grid'), (0, _defineProperty2["default"])(_classNames, classes.belowLayoutCenter, isSelectionButtonBelow && choicesLayout === 'grid'), _classNames));
332
-
333
- var choicelabel = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, displayKey && !isSelectionButtonBelow ? /*#__PURE__*/_react["default"].createElement("span", {
334
- className: classes.row
335
- }, displayKey, ".", "\xA0", /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
336
- className: "label",
337
- prompt: label,
338
- tagName: "span"
339
- })) : /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
340
- className: "label",
341
- prompt: label,
342
- tagName: "span"
343
- }));
344
-
345
- var screenReaderLabel = /*#__PURE__*/_react["default"].createElement("span", {
346
- id: this.descId,
347
- className: classes.srOnly
348
- }, choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below');
349
-
350
- var tagProps = {
351
- disabled: disabled,
352
- checked: checked,
353
- correctness: correctness,
354
- tagName: tagName,
355
- value: value,
356
- id: this.choiceId,
357
- onChange: this.onToggleChoice,
358
- onKeyDown: this.handleKeyDown,
359
- 'aria-describedby': this.descId
360
- };
361
- var hasMathOrImage = typeof label === 'string' && (label.includes('<math') || label.includes('\\(') || label.includes('\\[') || label.includes('<img') || label.includes('data-latex') || label.includes('data-raw') || label.includes('<mjx-container'));
362
- var control = isSelectionButtonBelow ? /*#__PURE__*/_react["default"].createElement("span", {
363
- className: classes.belowSelectionComponent
364
- }, hasMathOrImage && screenReaderLabel, /*#__PURE__*/_react["default"].createElement(Tag, (0, _extends2["default"])({}, tagProps, {
365
- style: {
366
- padding: 0
367
- }
368
- })), displayKey ? "".concat(displayKey, ".") : '') : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, hasMathOrImage && screenReaderLabel, /*#__PURE__*/_react["default"].createElement(Tag, (0, _extends2["default"])({}, tagProps, {
369
- inputRef: this.props.autoFocusRef
370
- })));
371
- return /*#__PURE__*/_react["default"].createElement("div", {
372
- className: (0, _classnames["default"])(className, 'corespring-' + classSuffix, 'choice-input')
373
- }, /*#__PURE__*/_react["default"].createElement("div", {
374
- className: classes.row
375
- }, !hideTick && isEvaluateMode && /*#__PURE__*/_react["default"].createElement(_feedbackTick["default"], {
376
- correctness: correctness
377
- }), /*#__PURE__*/_react["default"].createElement("div", {
378
- className: (0, _classnames["default"])(holderClassNames, 'checkbox-holder')
379
- }, /*#__PURE__*/_react["default"].createElement(StyledFormControlLabel, {
380
- label: choicelabel,
381
- value: value,
382
- htmlFor: this.choiceId,
383
- labelPlacement: isSelectionButtonBelow ? 'top' : undefined,
384
- control: control
385
- }))), rationale && /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
386
- className: "rationale",
387
- defaultClassName: "rationale",
388
- prompt: rationale
389
- }), /*#__PURE__*/_react["default"].createElement(_renderUi.Feedback, {
390
- feedback: feedback,
391
- correctness: correctness
392
- }));
393
- }
394
- }]);
395
- return ChoiceInput;
396
- }(_react["default"].Component);
397
-
398
- exports.ChoiceInput = ChoiceInput;
399
- (0, _defineProperty2["default"])(ChoiceInput, "propTypes", {
400
- choiceMode: _propTypes["default"].oneOf(['radio', 'checkbox']),
401
- displayKey: _propTypes["default"].string,
402
- checked: _propTypes["default"].bool.isRequired,
403
- correctness: _propTypes["default"].string,
404
- disabled: _propTypes["default"].bool.isRequired,
405
- feedback: _propTypes["default"].string,
406
- label: _propTypes["default"].string.isRequired,
407
- rationale: _propTypes["default"].string,
408
- onChange: _propTypes["default"].func.isRequired,
409
- value: _propTypes["default"].string.isRequired,
410
- classes: _propTypes["default"].object,
411
- className: _propTypes["default"].string,
412
- tagName: _propTypes["default"].string,
413
- hideTick: _propTypes["default"].bool,
414
- isEvaluateMode: _propTypes["default"].bool,
415
- choicesLayout: _propTypes["default"].oneOf(['vertical', 'grid', 'horizontal']),
416
- isSelectionButtonBelow: _propTypes["default"].bool
417
- });
418
- (0, _defineProperty2["default"])(ChoiceInput, "defaultProps", {
419
- rationale: null,
420
- checked: false,
421
- isEvaluateMode: false
422
- });
423
-
424
- var _default = (0, _styles.withStyles)(styleSheet)(ChoiceInput);
425
-
426
- exports["default"] = _default;
427
- //# sourceMappingURL=choice-input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/choice-input.jsx"],"names":["CLASS_NAME","styleSheet","theme","row","display","alignItems","backgroundColor","color","background","checkboxHolder","flex","text","fontSize","horizontalLayout","padding","spacing","unit","margin","belowLayout","belowLayoutCenter","justifyContent","belowSelectionComponent","marginLeft","srOnly","position","left","top","width","height","overflow","formStyleSheet","label","letterSpacing","disabled","cursor","StyledFormControlLabel","name","props","classes","colorStyle","varName","fallback","inputStyles","correct","incorrect","root","primaryLight","checked","primary","opacity","pointerEvents","focusVisibleUnchecked","outline","focusUncheckedBorder","focusUnchecked","focusVisibleChecked","focusCheckedBorder","focusChecked","StyledCheckbox","correctness","onChange","value","id","onKeyDown","inputRef","key","k","resolved","miniProps","StyledRadio","tagName","ChoiceInput","event","choiceMode","isArrowDown","isArrowUp","preventDefault","currentEl","document","getElementById","choiceId","fieldset","closest","groupCheckboxes","Array","from","querySelectorAll","currentIndex","findIndex","el","nextIndex","nextEl","focus","onToggleChoice","bind","generateChoiceId","descId","Math","random","toFixed","displayKey","feedback","className","rationale","hideTick","isEvaluateMode","choicesLayout","isSelectionButtonBelow","Tag","classSuffix","holderClassNames","choicelabel","screenReaderLabel","tagProps","handleKeyDown","hasMathOrImage","includes","control","autoFocusRef","undefined","React","Component","PropTypes","oneOf","string","bool","isRequired","func","object"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,2BAAnB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACC,KAAD;AAAA,SAAY;AAC7BC,IAAAA,GAAG,EAAE;AACHC,MAAAA,OAAO,EAAE,MADN;AAEHC,MAAAA,UAAU,EAAE,QAFT;AAGHC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN;AAHd,KADwB;AAM7BC,IAAAA,cAAc,EAAE;AACdL,MAAAA,OAAO,EAAE,MADK;AAEdC,MAAAA,UAAU,EAAE,QAFE;AAGdC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EAHH;AAIdE,MAAAA,IAAI,EAAE,CAJQ;AAKd,iBAAW;AACTH,QAAAA,KAAK,EAAEA,gBAAMI,IAAN,EADE;AAET,oBAAY;AACVC,UAAAA,QAAQ,EAAE;AADA;AA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pB0D,EAAAA,cAAc,EAAE;AAHI,C;;eA4JT,wBAAWxG,UAAX,EAAuBsE,WAAvB,C","sourcesContent":["import FormControlLabel from '@material-ui/core/FormControlLabel';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Checkbox from '@material-ui/core/Checkbox';\nimport { Feedback, color, PreviewPrompt } from '@pie-lib/pie-toolbox/render-ui';\nimport Radio from '@material-ui/core/Radio';\nimport classNames from 'classnames';\n\nimport FeedbackTick from './feedback-tick';\n\nconst CLASS_NAME = 'multiple-choice-component';\n\nconst styleSheet = (theme) => ({\n row: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n },\n checkboxHolder: {\n display: 'flex',\n alignItems: 'center',\n backgroundColor: color.background(),\n flex: 1,\n '& label': {\n color: color.text(),\n '& > span': {\n fontSize: 'inherit',\n },\n },\n },\n horizontalLayout: {\n [`& .${CLASS_NAME}`]: {\n // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles\n // add margin to the top, left and bottom of the checkbox to keep the same spacing as before\n padding: theme.spacing.unit,\n margin: `${theme.spacing.unit / 2}px 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`,\n },\n },\n belowLayout: {\n '& > label': {\n alignItems: 'flex-start',\n },\n },\n belowLayoutCenter: {\n justifyContent: 'center',\n '& > label': {\n alignItems: 'center',\n },\n },\n belowSelectionComponent: {\n display: 'flex',\n alignItems: 'center',\n '& > span': {\n // visually reduce right padding, but maintain accessibility padding for checkbox indicators to be circles\n marginLeft: `-${theme.spacing.unit}px`,\n },\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n});\n\nconst formStyleSheet = {\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)'\n backgroundColor: color.background(),\n letterSpacing: 'normal',\n },\n disabled: {\n // apply to all children\n '& *': {\n cursor: 'not-allowed !important',\n },\n },\n};\n\nexport const StyledFormControlLabel = withStyles(formStyleSheet, {\n name: 'FormControlLabel',\n})((props) => (\n <FormControlLabel {...props} classes={{ label: props.classes.label, disabled: props.classes.disabled }} />\n));\n\nconst colorStyle = (varName, fallback) => ({\n [`&.${CLASS_NAME}`]: {\n color: `var(--choice-input-${varName}, ${fallback}) !important`,\n },\n});\n\nconst inputStyles = {\n 'correct-root': colorStyle('correct-color', color.text()),\n 'correct-checked': colorStyle('correct-selected-color', color.correct()), //green[500]),\n 'correct-disabled': colorStyle('correct-disabled-color', color.disabled()), //'grey'),\n 'incorrect-root': colorStyle('incorrect-color', color.incorrect()),\n 'incorrect-checked': colorStyle('incorrect-checked', color.incorrect()), //orange[500]),\n 'incorrect-disabled': colorStyle('incorrect-disabled-color', color.disabled()),\n root: {\n ...colorStyle('color', color.text()),\n '&:hover': { color: `${color.primaryLight()} !important` },\n },\n checked: colorStyle('selected-color', color.primary()),\n disabled: {\n ...colorStyle('disabled-color', color.text()),\n opacity: 0.6,\n cursor: 'not-allowed !important',\n pointerEvents: 'initial !important',\n },\n focusVisibleUnchecked: {\n outline: `2px solid ${color.focusUncheckedBorder()}`,\n backgroundColor: color.focusUnchecked(),\n },\n focusVisibleChecked: {\n outline: `2px solid ${color.focusCheckedBorder()}`,\n backgroundColor: color.focusChecked(),\n },\n};\n\nexport const StyledCheckbox = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, value, id, onKeyDown, inputRef } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled, value };\n\n return (\n <Checkbox\n id={id}\n inputRef={inputRef}\n aria-checked={checked}\n onKeyDown={onKeyDown}\n focusVisibleClassName={checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked}\n disableRipple\n {...miniProps}\n className={CLASS_NAME}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport const StyledRadio = withStyles(inputStyles)((props) => {\n const { correctness, classes, checked, onChange, disabled, value, id, tagName, inputRef } = props;\n const key = (k) => (correctness ? `${correctness}-${k}` : k);\n\n const resolved = {\n root: classes[key('root')],\n checked: classes[key('checked')],\n disabled: classes[key('disabled')],\n };\n\n const miniProps = { checked, onChange, disabled, value };\n\n return (\n <Radio\n id={id}\n inputRef={inputRef}\n aria-checked={checked}\n focusVisibleClassName={checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked}\n disableRipple\n {...miniProps}\n className={CLASS_NAME}\n name={tagName}\n classes={{\n root: resolved.root,\n checked: resolved.checked,\n disabled: `${correctness ? '' : resolved.disabled}`,\n }}\n />\n );\n});\n\nexport class ChoiceInput extends React.Component {\n static propTypes = {\n choiceMode: PropTypes.oneOf(['radio', 'checkbox']),\n displayKey: PropTypes.string,\n checked: PropTypes.bool.isRequired,\n correctness: PropTypes.string,\n disabled: PropTypes.bool.isRequired,\n feedback: PropTypes.string,\n label: PropTypes.string.isRequired,\n rationale: PropTypes.string,\n onChange: PropTypes.func.isRequired,\n value: PropTypes.string.isRequired,\n classes: PropTypes.object,\n className: PropTypes.string,\n tagName: PropTypes.string,\n hideTick: PropTypes.bool,\n isEvaluateMode: PropTypes.bool,\n choicesLayout: PropTypes.oneOf(['vertical', 'grid', 'horizontal']),\n isSelectionButtonBelow: PropTypes.bool,\n };\n\n static defaultProps = {\n rationale: null,\n checked: false,\n isEvaluateMode: false,\n };\n\n constructor(props) {\n super(props);\n this.onToggleChoice = this.onToggleChoice.bind(this);\n this.choiceId = this.generateChoiceId();\n this.descId = `${this.choiceId}-desc`;\n }\n\n onToggleChoice(event) {\n this.props.onChange(event);\n }\n\n generateChoiceId() {\n return 'choice-' + (Math.random() * 10000).toFixed();\n }\n\n handleKeyDown = (event) => {\n const { choiceMode } = this.props;\n\n if (choiceMode !== 'checkbox') return;\n\n const isArrowDown = event.key === 'ArrowDown';\n const isArrowUp = event.key === 'ArrowUp';\n\n if (!isArrowDown && !isArrowUp) return;\n\n event.preventDefault();\n\n const currentEl = document.getElementById(this.choiceId);\n if (!currentEl) return;\n\n const fieldset = currentEl.closest('fieldset');\n if (!fieldset) return;\n\n const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type=\"checkbox\"]'));\n\n const currentIndex = groupCheckboxes.findIndex((el) => el === currentEl);\n if (currentIndex === -1) return;\n\n const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;\n const nextEl = groupCheckboxes[nextIndex];\n\n if (nextEl) {\n nextEl.focus();\n }\n };\n\n render() {\n const {\n choiceMode,\n disabled,\n displayKey,\n feedback,\n label,\n correctness,\n classes,\n className,\n rationale,\n hideTick,\n isEvaluateMode,\n choicesLayout,\n value,\n checked,\n tagName,\n isSelectionButtonBelow,\n } = this.props;\n\n const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;\n const classSuffix = choiceMode === 'checkbox' ? 'checkbox' : 'radio-button';\n\n const holderClassNames = classNames(classes.checkboxHolder, {\n [classes.horizontalLayout]: choicesLayout === 'horizontal',\n [classes.belowLayout]: isSelectionButtonBelow && choicesLayout !== 'grid',\n [classes.belowLayoutCenter]: isSelectionButtonBelow && choicesLayout === 'grid',\n });\n\n const choicelabel = (\n <>\n {displayKey && !isSelectionButtonBelow ? (\n <span className={classes.row}>\n {displayKey}.{'\\u00A0'}\n <PreviewPrompt className=\"label\" prompt={label} tagName=\"span\" />\n </span>\n ) : (\n <PreviewPrompt className=\"label\" prompt={label} tagName=\"span\" />\n )}\n </>\n );\n\n const screenReaderLabel = (\n <span id={this.descId} className={classes.srOnly}>\n {choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below'}\n </span>\n );\n\n const tagProps = {\n disabled,\n checked,\n correctness,\n tagName,\n value,\n id: this.choiceId,\n onChange: this.onToggleChoice,\n onKeyDown: this.handleKeyDown,\n 'aria-describedby': this.descId,\n };\n\n const hasMathOrImage =\n typeof label === 'string' &&\n (label.includes('<math') ||\n label.includes('\\\\(') ||\n label.includes('\\\\[') ||\n label.includes('<img') ||\n label.includes('data-latex') ||\n label.includes('data-raw') ||\n label.includes('<mjx-container'));\n\n const control = isSelectionButtonBelow ? (\n <span className={classes.belowSelectionComponent}>\n {hasMathOrImage && screenReaderLabel}\n <Tag {...tagProps} style={{ padding: 0 }} />\n {displayKey ? `${displayKey}.` : ''}\n </span>\n ) : (\n <>\n {hasMathOrImage && screenReaderLabel}\n <Tag {...tagProps} inputRef={this.props.autoFocusRef} />\n </>\n );\n\n return (\n <div className={classNames(className, 'corespring-' + classSuffix, 'choice-input')}>\n <div className={classes.row}>\n {!hideTick && isEvaluateMode && <FeedbackTick correctness={correctness} />}\n <div className={classNames(holderClassNames, 'checkbox-holder')}>\n <StyledFormControlLabel\n label={choicelabel}\n value={value}\n htmlFor={this.choiceId}\n labelPlacement={isSelectionButtonBelow ? 'top' : undefined}\n control={control}\n />\n </div>\n </div>\n {rationale && <PreviewPrompt className=\"rationale\" defaultClassName=\"rationale\" prompt={rationale} />}\n <Feedback feedback={feedback} correctness={correctness} />\n </div>\n );\n }\n}\n\nexport default withStyles(styleSheet)(ChoiceInput);\n"],"file":"choice-input.js"}