@pie-lib/mask-markup 1.13.46 → 1.14.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +15 -56
  2. package/NEXT.CHANGELOG.json +1 -0
  3. package/lib/choices/choice.js +80 -17
  4. package/lib/choices/choice.js.map +1 -1
  5. package/lib/choices/index.js +11 -3
  6. package/lib/choices/index.js.map +1 -1
  7. package/lib/components/blank.js +146 -34
  8. package/lib/components/blank.js.map +1 -1
  9. package/lib/components/correct-input.js +8 -3
  10. package/lib/components/correct-input.js.map +1 -1
  11. package/lib/components/dropdown.js +182 -49
  12. package/lib/components/dropdown.js.map +1 -1
  13. package/lib/constructed-response.js +87 -23
  14. package/lib/constructed-response.js.map +1 -1
  15. package/lib/customizable.js +48 -0
  16. package/lib/customizable.js.map +1 -0
  17. package/lib/drag-in-the-blank.js +34 -8
  18. package/lib/drag-in-the-blank.js.map +1 -1
  19. package/lib/index.js +8 -0
  20. package/lib/index.js.map +1 -1
  21. package/lib/inline-dropdown.js +3 -1
  22. package/lib/inline-dropdown.js.map +1 -1
  23. package/lib/mask.js +45 -6
  24. package/lib/mask.js.map +1 -1
  25. package/lib/with-mask.js +34 -2
  26. package/lib/with-mask.js.map +1 -1
  27. package/package.json +9 -5
  28. package/src/__tests__/__snapshots__/drag-in-the-blank.test.js.snap +316 -0
  29. package/src/__tests__/__snapshots__/mask.test.js.snap +55 -0
  30. package/src/__tests__/__snapshots__/with-mask.test.js.snap +62 -0
  31. package/src/__tests__/drag-in-the-blank.test.js +71 -0
  32. package/src/__tests__/index.test.js +39 -0
  33. package/src/__tests__/mask.test.js +152 -0
  34. package/src/__tests__/serialization.test.js +54 -0
  35. package/src/__tests__/utils.js +1 -0
  36. package/src/__tests__/with-mask.test.js +51 -0
  37. package/src/choices/__tests__/__snapshots__/index.test.js.snap +209 -0
  38. package/src/choices/__tests__/index.test.js +62 -0
  39. package/src/choices/choice.jsx +60 -6
  40. package/src/choices/index.jsx +2 -2
  41. package/src/components/__tests__/__snapshots__/blank.test.js.snap +111 -0
  42. package/src/components/__tests__/__snapshots__/correct-input.test.js.snap +64 -0
  43. package/src/components/__tests__/__snapshots__/dropdown.test.js.snap +133 -0
  44. package/src/components/__tests__/__snapshots__/input.test.js.snap +34 -0
  45. package/src/components/__tests__/blank.test.js +202 -0
  46. package/src/components/__tests__/correct-input.test.js +49 -0
  47. package/src/components/__tests__/dropdown.test.js +51 -0
  48. package/src/components/__tests__/input.test.js +50 -0
  49. package/src/components/blank.jsx +139 -28
  50. package/src/components/correct-input.jsx +6 -1
  51. package/src/components/dropdown.jsx +192 -71
  52. package/src/constructed-response.jsx +76 -18
  53. package/src/customizable.jsx +35 -0
  54. package/src/drag-in-the-blank.jsx +26 -3
  55. package/src/index.js +10 -1
  56. package/src/inline-dropdown.jsx +2 -0
  57. package/src/mask.jsx +30 -5
  58. package/src/with-mask.jsx +39 -2
  59. package/README.md +0 -14
@@ -25,16 +25,28 @@ var _react = _interopRequireDefault(require("react"));
25
25
 
26
26
  var _propTypes = _interopRequireDefault(require("prop-types"));
27
27
 
28
- var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
28
+ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
29
+
30
+ var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));
31
+
32
+ var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
29
33
 
30
34
  var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
31
35
 
32
- var _correctInput = _interopRequireDefault(require("./correct-input"));
36
+ var _ArrowDropDown = _interopRequireDefault(require("@material-ui/icons/ArrowDropDown"));
37
+
38
+ var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
39
+
40
+ var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
33
41
 
34
42
  var _styles = require("@material-ui/core/styles");
35
43
 
44
+ var _classnames = _interopRequireDefault(require("classnames"));
45
+
36
46
  var _renderUi = require("@pie-lib/render-ui");
37
47
 
48
+ var _mathRendering = require("@pie-lib/math-rendering");
49
+
38
50
  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
51
 
40
52
  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; } }
@@ -49,82 +61,164 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
49
61
 
50
62
  (0, _classCallCheck2["default"])(this, Dropdown);
51
63
  _this = _super.call(this, props);
52
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showCheckmarkAndOpen", function () {
53
- _this.setState({
54
- showCheckmark: true,
55
- open: true
64
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClick", function (event) {
65
+ return _this.setState({
66
+ anchorEl: event.currentTarget
67
+ });
68
+ });
69
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClose", function () {
70
+ return _this.setState({
71
+ anchorEl: null
56
72
  });
57
73
  });
58
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideCheckmarkAndClose", function () {
74
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleHighlight", function (index) {
75
+ var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
76
+
59
77
  _this.setState({
60
- showCheckmark: false,
61
- open: false
78
+ highlightedOptionId: highlightedOptionId
62
79
  });
63
80
  });
81
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleSelect", function (value, index) {
82
+ _this.props.onChange(_this.props.id, value);
83
+
84
+ _this.handleHighlight(index);
85
+
86
+ _this.handleClose();
87
+ });
64
88
  _this.state = {
65
- showCheckmark: false,
66
- open: false
89
+ anchorEl: null,
90
+ highlightedOptionId: null
67
91
  };
92
+ _this.elementRefs = [];
68
93
  return _this;
69
94
  }
70
95
 
71
96
  (0, _createClass2["default"])(Dropdown, [{
97
+ key: "componentDidUpdate",
98
+ value: function componentDidUpdate() {
99
+ this.elementRefs.forEach(function (ref) {
100
+ if (ref) {
101
+ (0, _mathRendering.renderMath)(ref);
102
+ }
103
+ });
104
+ }
105
+ }, {
106
+ key: "getLabel",
107
+ value: function getLabel(choices, value) {
108
+ var found = (choices || []).find(function (choice) {
109
+ return choice.value === value;
110
+ });
111
+ return found ? found.label.trim() : undefined;
112
+ }
113
+ }, {
72
114
  key: "render",
73
115
  value: function render() {
116
+ var _this2 = this;
117
+
74
118
  var _this$props = this.props,
75
119
  classes = _this$props.classes,
76
120
  id = _this$props.id,
77
121
  correct = _this$props.correct,
78
122
  disabled = _this$props.disabled,
79
123
  value = _this$props.value,
80
- _onChange = _this$props.onChange,
81
124
  choices = _this$props.choices,
82
- showCorrectAnswer = _this$props.showCorrectAnswer;
83
- var _this$state = this.state,
84
- showCheckmark = _this$state.showCheckmark,
85
- open = _this$state.open;
86
- return /*#__PURE__*/_react["default"].createElement(_Select["default"], {
125
+ showCorrectAnswer = _this$props.showCorrectAnswer,
126
+ singleQuery = _this$props.singleQuery,
127
+ correctValue = _this$props.correctValue;
128
+ var anchorEl = this.state.anchorEl;
129
+ var open = Boolean(anchorEl);
130
+ var buttonId = "dropdown-button-".concat(id);
131
+ var menuId = "dropdown-menu-".concat(id);
132
+ var valueDisplayId = "dropdown-value-".concat(id); // Determine the class for disabled state, view mode and evaluate mode
133
+
134
+ var disabledClass; // Reset elementRefs before each render to avoid stale references
135
+
136
+ this.elementRefs = [];
137
+
138
+ if (disabled && correct !== undefined) {
139
+ disabledClass = correct || showCorrectAnswer ? classes.disabledCorrect : classes.disabledIncorrect;
140
+ } // Create distinct, visually hidden labels for each dropdown
141
+
142
+
143
+ var incrementedId = parseInt(id, 10) + 1;
144
+ var labelId = singleQuery ? 'Query-label' : "Query-label-".concat(incrementedId);
145
+ var labelText = singleQuery ? 'Query' : "Query ".concat(incrementedId); // Changed from Select to Button for dropdown to enhance accessibility. This modification offers explicit control over aria attributes and focuses management, ensuring the dropdown is compliant with accessibility standards. The use of Button and Menu components allows for better handling of keyboard interactions and provides accessible labels and menus, aligning with WCAG guidelines and improving usability for assistive technology users.
146
+
147
+ var correctnessIcon = null;
148
+
149
+ if (disabled && correct !== undefined) {
150
+ correctnessIcon = correct || showCorrectAnswer ? /*#__PURE__*/_react["default"].createElement(_Check["default"], {
151
+ className: (0, _classnames["default"])(classes.correctnessIndicatorIcon, classes.correctIcon)
152
+ }) : /*#__PURE__*/_react["default"].createElement(_Close["default"], {
153
+ className: (0, _classnames["default"])(classes.correctnessIndicatorIcon, classes.incorrectIcon)
154
+ });
155
+ }
156
+
157
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_InputLabel["default"], {
158
+ className: classes.srOnly,
159
+ id: labelId
160
+ }, labelText), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
161
+ "aria-controls": open ? menuId : undefined,
162
+ "aria-haspopup": "listbox",
163
+ "aria-expanded": open ? 'true' : undefined,
164
+ "aria-activedescendant": this.state.highlightedOptionId,
165
+ onClick: this.handleClick,
87
166
  classes: {
88
167
  root: classes.root,
89
- icon: classes.icon,
90
- selectMenu: classes.selectMenu,
91
- select: classes.select
168
+ disabled: disabledClass
92
169
  },
93
170
  disabled: disabled,
94
- value: value || '',
95
- onOpen: this.showCheckmarkAndOpen,
96
- onClose: this.hideCheckmarkAndClose,
171
+ id: buttonId,
172
+ role: "combobox",
173
+ "aria-label": "Select answer",
174
+ "aria-labelledby": valueDisplayId
175
+ }, correctnessIcon, /*#__PURE__*/_react["default"].createElement("span", {
176
+ id: valueDisplayId,
177
+ className: classes.label,
178
+ dangerouslySetInnerHTML: {
179
+ __html: correctValue ? correctValue : this.getLabel(choices, value) ? this.getLabel(choices, value) : ''
180
+ }
181
+ }), /*#__PURE__*/_react["default"].createElement(_ArrowDropDown["default"], null)), /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
182
+ id: menuId,
183
+ anchorEl: anchorEl,
184
+ className: classes.selectMenu,
185
+ keepMounted: true,
97
186
  open: open,
98
- input: /*#__PURE__*/_react["default"].createElement(_correctInput["default"], {
99
- correct: showCorrectAnswer || correct
100
- }),
101
- MenuProps: {
102
- keepMounted: true,
103
- disablePortal: true
104
- },
105
- onChange: function onChange(e) {
106
- _onChange(id, e.target.value);
187
+ onClose: this.handleClose,
188
+ MenuListProps: {
189
+ 'aria-labelledby': buttonId,
190
+ role: 'listbox'
107
191
  }
108
192
  }, (choices || []).map(function (c, index) {
193
+ var optionId = "dropdown-option-".concat(id, "-").concat(index);
109
194
  return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
195
+ id: optionId,
110
196
  classes: {
111
197
  root: classes.menuRoot,
112
198
  selected: classes.selected
113
199
  },
114
200
  key: "".concat(c.label, "-").concat(index),
115
- value: c.value
201
+ value: c.value,
202
+ onClick: function onClick() {
203
+ return _this2.handleSelect(c.value, index);
204
+ },
205
+ role: "option",
206
+ "aria-selected": _this2.state.highlightedOptionId === optionId ? 'true' : undefined
116
207
  }, /*#__PURE__*/_react["default"].createElement("span", {
208
+ ref: function ref(_ref) {
209
+ return _this2.elementRefs[index] = _ref;
210
+ },
117
211
  className: classes.label,
118
212
  dangerouslySetInnerHTML: {
119
213
  __html: c.label
120
214
  }
121
- }), showCheckmark && /*#__PURE__*/_react["default"].createElement("span", {
215
+ }), /*#__PURE__*/_react["default"].createElement("span", {
122
216
  className: classes.label,
123
217
  dangerouslySetInnerHTML: {
124
218
  __html: c.value === value ? ' ✓' : ''
125
219
  }
126
220
  }));
127
- }));
221
+ })));
128
222
  }
129
223
  }]);
130
224
  return Dropdown;
@@ -148,34 +242,49 @@ var styles = function styles() {
148
242
  return {
149
243
  root: {
150
244
  color: _renderUi.color.text(),
245
+ border: "1px solid ".concat(_renderUi.color.text()),
246
+ borderRadius: '4px',
247
+ justifyContent: 'space-between',
151
248
  backgroundColor: _renderUi.color.background(),
152
- borderColor: _renderUi.color.secondaryLight(),
153
- '& ul': {
154
- paddingTop: 0,
155
- paddingBottom: 0,
156
- border: "1px solid ".concat(_renderUi.color.text()),
157
- borderRadius: '5px',
249
+ position: 'relative',
250
+ height: '45px',
251
+ width: 'fit-content',
252
+ margin: '2px',
253
+ textTransform: 'none',
254
+ '& span': {
255
+ paddingRight: '5px'
256
+ },
257
+ '& svg': {
258
+ position: 'absolute',
259
+ right: 0,
260
+ top: 'calc(50% - 12px)',
261
+ pointerEvents: 'none',
158
262
  color: _renderUi.color.text(),
159
- backgroundColor: _renderUi.color.background()
263
+ marginLeft: '5px'
160
264
  }
161
265
  },
162
- select: {
163
- '&:focus': {
164
- borderRadius: '4px'
165
- }
266
+ disabledCorrect: {
267
+ borderWidth: '2px',
268
+ borderColor: _renderUi.color.correct(),
269
+ color: "".concat(_renderUi.color.text(), " !important")
270
+ },
271
+ disabledIncorrect: {
272
+ borderWidth: '2px',
273
+ borderColor: _renderUi.color.incorrectWithIcon(),
274
+ color: "".concat(_renderUi.color.text(), " !important")
166
275
  },
167
276
  selectMenu: {
168
277
  backgroundColor: _renderUi.color.background(),
278
+ border: "1px solid ".concat(_renderUi.color.correct(), " !important"),
169
279
  '&:hover': {
280
+ border: "1px solid ".concat(_renderUi.color.text(), " "),
170
281
  borderColor: 'initial'
171
282
  },
172
283
  '&:focus': {
284
+ border: "1px solid ".concat(_renderUi.color.text()),
173
285
  borderColor: 'initial'
174
286
  }
175
287
  },
176
- icon: {
177
- color: _renderUi.color.text()
178
- },
179
288
  selected: {
180
289
  color: "".concat(_renderUi.color.text(), " !important"),
181
290
  backgroundColor: "".concat(_renderUi.color.background(), " !important"),
@@ -206,6 +315,30 @@ var styles = function styles() {
206
315
  },
207
316
  label: {
208
317
  fontSize: 'max(1rem, 14px)'
318
+ },
319
+ srOnly: {
320
+ position: 'absolute',
321
+ left: '-10000px',
322
+ top: 'auto',
323
+ width: '1px',
324
+ height: '1px',
325
+ overflow: 'hidden'
326
+ },
327
+ correctnessIndicatorIcon: {
328
+ color: "".concat(_renderUi.color.white(), " !important"),
329
+ position: 'absolute',
330
+ top: '-8px !important',
331
+ left: '-8px',
332
+ marginLeft: '0 !important',
333
+ borderRadius: '50%',
334
+ fontSize: '16px',
335
+ padding: '2px'
336
+ },
337
+ correctIcon: {
338
+ backgroundColor: _renderUi.color.correct()
339
+ },
340
+ incorrectIcon: {
341
+ backgroundColor: _renderUi.color.incorrectWithIcon()
209
342
  }
210
343
  };
211
344
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/dropdown.jsx"],"names":["Dropdown","props","setState","showCheckmark","open","state","classes","id","correct","disabled","value","onChange","choices","showCorrectAnswer","root","icon","selectMenu","select","showCheckmarkAndOpen","hideCheckmarkAndClose","keepMounted","disablePortal","e","target","map","c","index","menuRoot","selected","label","__html","React","Component","PropTypes","string","bool","func","object","arrayOf","shape","styles","color","text","backgroundColor","background","borderColor","secondaryLight","paddingTop","paddingBottom","border","borderRadius","boxSizing","padding","fontSize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEMA,Q;;;;;AAYJ,oBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,6GASI,YAAM;AAC3B,YAAKC,QAAL,CAAc;AACZC,QAAAA,aAAa,EAAE,IADH;AAEZC,QAAAA,IAAI,EAAE;AAFM,OAAd;AAID,KAdkB;AAAA,8GAgBK,YAAM;AAC5B,YAAKF,QAAL,CAAc;AACZC,QAAAA,aAAa,EAAE,KAD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;AAHH,KA/BU;AAuCpBnB,IAAAA,QAAQ,EAAE;AACRc,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADC;AAERC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFT;AAGR,iBAAW;AACTH,QAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADE;AAETC,QAAAA,eAAe,EAAEF,gBAAMG,UAAN;AAFR,OAHH;AAOR,iBAAW;AACTH,QAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADE;AAETC,QAAAA,eAAe,EAAEF,gBAAMK,cAAN;AAFR,OAPH;AAWRK,MAAAA,SAAS,EAAE,YAXH;AAYRC,MAAAA,OAAO,EAAE,MAZD;AAaR,yBAAmB;AACjBF,QAAAA,YAAY,EAAE;AADG,OAbX;AAgBR,wBAAkB;AAChBA,QAAAA,YAAY,EAAE;AADE;AAhBV,KAvCU;AA2DpBrB,IAAAA,KAAK,EAAE;AACLwB,MAAAA,QAAQ,EAAE;AADL;AA3Da,GAAP;AAAA,CAAf;;eAgEe,wBAAWb,MAAX,EAAmBxC,QAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Select from '@material-ui/core/Select';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport CorrectInput from './correct-input';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nclass Dropdown extends React.Component {\n static propTypes = {\n id: PropTypes.string,\n value: PropTypes.string,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n classes: PropTypes.object,\n correct: PropTypes.bool,\n choices: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string, label: PropTypes.string })),\n showCorrectAnswer: PropTypes.bool,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showCheckmark: false,\n open: false,\n };\n }\n\n showCheckmarkAndOpen = () => {\n this.setState({\n showCheckmark: true,\n open: true,\n });\n };\n\n hideCheckmarkAndClose = () => {\n this.setState({\n showCheckmark: false,\n open: false,\n });\n };\n\n render() {\n const { classes, id, correct, disabled, value, onChange, choices, showCorrectAnswer } = this.props;\n\n const { showCheckmark, open } = this.state;\n\n return (\n <Select\n classes={{\n root: classes.root,\n icon: classes.icon,\n selectMenu: classes.selectMenu,\n select: classes.select,\n }}\n disabled={disabled}\n value={value || ''}\n onOpen={this.showCheckmarkAndOpen}\n onClose={this.hideCheckmarkAndClose}\n open={open}\n input={<CorrectInput correct={showCorrectAnswer || correct} />}\n MenuProps={{\n keepMounted: true,\n disablePortal: true,\n }}\n onChange={(e) => {\n onChange(id, e.target.value);\n }}\n >\n {(choices || []).map((c, index) => (\n <MenuItem\n classes={{ root: classes.menuRoot, selected: classes.selected }}\n key={`${c.label}-${index}`}\n value={c.value}\n >\n <span\n className={classes.label}\n dangerouslySetInnerHTML={{\n __html: c.label,\n }}\n />\n {showCheckmark && (\n <span\n className={classes.label}\n dangerouslySetInnerHTML={{ __html: c.value === value ? ' &check;' : '' }}\n />\n )}\n </MenuItem>\n ))}\n </Select>\n );\n }\n}\n\nconst styles = () => ({\n root: {\n color: color.text(),\n backgroundColor: color.background(),\n borderColor: color.secondaryLight(),\n '& ul': {\n paddingTop: 0,\n paddingBottom: 0,\n border: `1px solid ${color.text()}`,\n borderRadius: '5px',\n color: color.text(),\n backgroundColor: color.background(),\n },\n },\n select: {\n '&:focus': {\n borderRadius: '4px',\n },\n },\n selectMenu: {\n backgroundColor: color.background(),\n '&:hover': {\n borderColor: 'initial',\n },\n '&:focus': {\n borderColor: 'initial',\n },\n },\n icon: {\n color: color.text(),\n },\n selected: {\n color: `${color.text()} !important`,\n backgroundColor: `${color.background()} !important`,\n '&:hover': {\n color: color.text(),\n backgroundColor: `${color.secondaryLight()} !important`,\n },\n },\n menuRoot: {\n color: color.text(),\n backgroundColor: color.background(),\n '&:focus': {\n color: color.text(),\n backgroundColor: color.background(),\n },\n '&:hover': {\n color: color.text(),\n backgroundColor: color.secondaryLight(),\n },\n boxSizing: 'border-box',\n padding: '25px',\n '&:first-of-type': {\n borderRadius: '3px 3px 0 0',\n },\n '&:last-of-type': {\n borderRadius: '0 0 3px 3px',\n },\n },\n label: {\n fontSize: 'max(1rem, 14px)',\n },\n});\n\nexport default withStyles(styles)(Dropdown);\n"],"file":"dropdown.js"}
1
+ {"version":3,"sources":["../../src/components/dropdown.jsx"],"names":["Dropdown","props","event","setState","anchorEl","currentTarget","index","highlightedOptionId","id","value","onChange","handleHighlight","handleClose","state","elementRefs","forEach","ref","choices","found","find","choice","label","trim","undefined","classes","correct","disabled","showCorrectAnswer","singleQuery","correctValue","open","Boolean","buttonId","menuId","valueDisplayId","disabledClass","disabledCorrect","disabledIncorrect","incrementedId","parseInt","labelId","labelText","correctnessIcon","correctnessIndicatorIcon","correctIcon","incorrectIcon","srOnly","handleClick","root","__html","getLabel","selectMenu","role","map","c","optionId","menuRoot","selected","handleSelect","React","Component","PropTypes","string","bool","func","object","arrayOf","shape","styles","color","text","border","borderRadius","justifyContent","backgroundColor","background","position","height","width","margin","textTransform","paddingRight","right","top","pointerEvents","marginLeft","borderWidth","borderColor","incorrectWithIcon","secondaryLight","boxSizing","padding","fontSize","left","overflow","white"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;IAEMA,Q;;;;;AAYJ,oBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,oGAmBL,UAACC,KAAD;AAAA,aAAW,MAAKC,QAAL,CAAc;AAAEC,QAAAA,QAAQ,EAAEF,KAAK,CAACG;AAAlB,OAAd,CAAX;AAAA,KAnBK;AAAA,oGAqBL;AAAA,aAAM,MAAKF,QAAL,CAAc;AAAEC,QAAAA,QAAQ,EAAE;AAAZ,OAAd,CAAN;AAAA,KArBK;AAAA,wGAuBD,UAACE,KAAD,EAAW;AAC3B,UAAMC,mBAAmB,6BAAsB,MAAKN,KAAL,CAAWO,EAAjC,cAAu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AWRC,MAAAA,SAAS,EAAE,YAXH;AAYRC,MAAAA,OAAO,EAAE,MAZD;AAaR,yBAAmB;AACjBnB,QAAAA,YAAY,EAAE;AADG,OAbX;AAgBR,wBAAkB;AAChBA,QAAAA,YAAY,EAAE;AADE;AAhBV,KAtDU;AA0EpBnD,IAAAA,KAAK,EAAE;AACLuE,MAAAA,QAAQ,EAAE;AADL,KA1Ea;AA6EpB9C,IAAAA,MAAM,EAAE;AACN8B,MAAAA,QAAQ,EAAE,UADJ;AAENiB,MAAAA,IAAI,EAAE,UAFA;AAGNV,MAAAA,GAAG,EAAE,MAHC;AAINL,MAAAA,KAAK,EAAE,KAJD;AAKND,MAAAA,MAAM,EAAE,KALF;AAMNiB,MAAAA,QAAQ,EAAE;AANJ,KA7EY;AAqFpBnD,IAAAA,wBAAwB,EAAE;AACxB0B,MAAAA,KAAK,YAAKA,gBAAM0B,KAAN,EAAL,gBADmB;AAExBnB,MAAAA,QAAQ,EAAE,UAFc;AAGxBO,MAAAA,GAAG,EAAE,iBAHmB;AAIxBU,MAAAA,IAAI,EAAE,MAJkB;AAKxBR,MAAAA,UAAU,EAAE,cALY;AAMxBb,MAAAA,YAAY,EAAE,KANU;AAOxBoB,MAAAA,QAAQ,EAAE,MAPc;AAQxBD,MAAAA,OAAO,EAAE;AARe,KArFN;AA+FpB/C,IAAAA,WAAW,EAAE;AACX8B,MAAAA,eAAe,EAAEL,gBAAM5C,OAAN;AADN,KA/FO;AAkGpBoB,IAAAA,aAAa,EAAE;AACb6B,MAAAA,eAAe,EAAEL,gBAAMmB,iBAAN;AADJ;AAlGK,GAAP;AAAA,CAAf;;eAuGe,wBAAWpB,MAAX,EAAmBpE,QAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@material-ui/core/Button';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';\nimport Close from '@material-ui/icons/Close';\nimport Check from '@material-ui/icons/Check';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\n\nimport { color } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nclass Dropdown extends React.Component {\n static propTypes = {\n id: PropTypes.string,\n value: PropTypes.string,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n classes: PropTypes.object,\n correct: PropTypes.bool,\n choices: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string, label: PropTypes.string })),\n showCorrectAnswer: PropTypes.bool,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n anchorEl: null,\n highlightedOptionId: null,\n };\n\n this.elementRefs = [];\n }\n\n componentDidUpdate() {\n this.elementRefs.forEach((ref) => {\n if (ref) {\n renderMath(ref);\n }\n });\n }\n\n handleClick = (event) => this.setState({ anchorEl: event.currentTarget });\n\n handleClose = () => this.setState({ anchorEl: null });\n\n handleHighlight = (index) => {\n const highlightedOptionId = `dropdown-option-${this.props.id}-${index}`;\n\n this.setState({ highlightedOptionId });\n };\n\n handleSelect = (value, index) => {\n this.props.onChange(this.props.id, value);\n this.handleHighlight(index);\n this.handleClose();\n };\n\n getLabel(choices, value) {\n const found = (choices || []).find((choice) => choice.value === value);\n\n return found ? found.label.trim() : undefined;\n }\n\n render() {\n const { classes, id, correct, disabled, value, choices, showCorrectAnswer, singleQuery, correctValue } = this.props;\n\n const { anchorEl } = this.state;\n const open = Boolean(anchorEl);\n const buttonId = `dropdown-button-${id}`;\n const menuId = `dropdown-menu-${id}`;\n const valueDisplayId = `dropdown-value-${id}`;\n\n // Determine the class for disabled state, view mode and evaluate mode\n let disabledClass;\n // Reset elementRefs before each render to avoid stale references\n this.elementRefs = [];\n\n if (disabled && correct !== undefined) {\n disabledClass = correct || showCorrectAnswer ? classes.disabledCorrect : classes.disabledIncorrect;\n }\n\n // Create distinct, visually hidden labels for each dropdown\n const incrementedId = parseInt(id, 10) + 1;\n const labelId = singleQuery ? 'Query-label' : `Query-label-${incrementedId}`;\n const labelText = singleQuery ? 'Query' : `Query ${incrementedId}`;\n\n // Changed from Select to Button for dropdown to enhance accessibility. This modification offers explicit control over aria attributes and focuses management, ensuring the dropdown is compliant with accessibility standards. The use of Button and Menu components allows for better handling of keyboard interactions and provides accessible labels and menus, aligning with WCAG guidelines and improving usability for assistive technology users.\n\n let correctnessIcon = null;\n if (disabled && correct !== undefined) {\n correctnessIcon =\n correct || showCorrectAnswer ? (\n <Check className={classNames(classes.correctnessIndicatorIcon, classes.correctIcon)} />\n ) : (\n <Close className={classNames(classes.correctnessIndicatorIcon, classes.incorrectIcon)} />\n );\n }\n\n return (\n <>\n <InputLabel className={classes.srOnly} id={labelId}>\n {labelText}\n </InputLabel>\n <Button\n aria-controls={open ? menuId : undefined}\n aria-haspopup=\"listbox\"\n aria-expanded={open ? 'true' : undefined}\n aria-activedescendant={this.state.highlightedOptionId}\n onClick={this.handleClick}\n classes={{\n root: classes.root,\n disabled: disabledClass,\n }}\n disabled={disabled}\n id={buttonId}\n role=\"combobox\"\n aria-label=\"Select answer\"\n aria-labelledby={valueDisplayId}\n >\n {correctnessIcon}\n <span\n id={valueDisplayId}\n className={classes.label}\n dangerouslySetInnerHTML={{\n __html: correctValue ? correctValue : this.getLabel(choices, value) ? this.getLabel(choices, value) : '',\n }}\n />\n <ArrowDropDownIcon />\n </Button>\n <Menu\n id={menuId}\n anchorEl={anchorEl}\n className={classes.selectMenu}\n keepMounted\n open={open}\n onClose={this.handleClose}\n MenuListProps={{\n 'aria-labelledby': buttonId,\n role: 'listbox',\n }}\n >\n {(choices || []).map((c, index) => {\n const optionId = `dropdown-option-${id}-${index}`;\n\n return (\n <MenuItem\n id={optionId}\n classes={{ root: classes.menuRoot, selected: classes.selected }}\n key={`${c.label}-${index}`}\n value={c.value}\n onClick={() => this.handleSelect(c.value, index)}\n role=\"option\"\n aria-selected={this.state.highlightedOptionId === optionId ? 'true' : undefined}\n >\n <span\n ref={(ref) => (this.elementRefs[index] = ref)}\n className={classes.label}\n dangerouslySetInnerHTML={{ __html: c.label }}\n />\n <span\n className={classes.label}\n dangerouslySetInnerHTML={{ __html: c.value === value ? ' &check;' : '' }}\n />\n </MenuItem>\n );\n })}\n </Menu>\n </>\n );\n }\n}\n\nconst styles = () => ({\n root: {\n color: color.text(),\n border: `1px solid ${color.text()}`,\n borderRadius: '4px',\n justifyContent: 'space-between',\n backgroundColor: color.background(),\n position: 'relative',\n height: '45px',\n width: 'fit-content',\n margin: '2px',\n textTransform: 'none',\n '& span': {\n paddingRight: '5px',\n },\n '& svg': {\n position: 'absolute',\n right: 0,\n top: 'calc(50% - 12px)',\n pointerEvents: 'none',\n color: color.text(),\n marginLeft: '5px',\n },\n },\n disabledCorrect: {\n borderWidth: '2px',\n borderColor: color.correct(),\n color: `${color.text()} !important`,\n },\n disabledIncorrect: {\n borderWidth: '2px',\n borderColor: color.incorrectWithIcon(),\n color: `${color.text()} !important`,\n },\n selectMenu: {\n backgroundColor: color.background(),\n border: `1px solid ${color.correct()} !important`,\n '&:hover': {\n border: `1px solid ${color.text()} `,\n borderColor: 'initial',\n },\n '&:focus': {\n border: `1px solid ${color.text()}`,\n borderColor: 'initial',\n },\n },\n selected: {\n color: `${color.text()} !important`,\n backgroundColor: `${color.background()} !important`,\n '&:hover': {\n color: color.text(),\n backgroundColor: `${color.secondaryLight()} !important`,\n },\n },\n menuRoot: {\n color: color.text(),\n backgroundColor: color.background(),\n '&:focus': {\n color: color.text(),\n backgroundColor: color.background(),\n },\n '&:hover': {\n color: color.text(),\n backgroundColor: color.secondaryLight(),\n },\n boxSizing: 'border-box',\n padding: '25px',\n '&:first-of-type': {\n borderRadius: '3px 3px 0 0',\n },\n '&:last-of-type': {\n borderRadius: '0 0 3px 3px',\n },\n },\n label: {\n fontSize: 'max(1rem, 14px)',\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n correctnessIndicatorIcon: {\n color: `${color.white()} !important`,\n position: 'absolute',\n top: '-8px !important',\n left: '-8px',\n marginLeft: '0 !important',\n borderRadius: '50%',\n fontSize: '16px',\n padding: '2px',\n },\n correctIcon: {\n backgroundColor: color.correct(),\n },\n incorrectIcon: {\n backgroundColor: color.incorrectWithIcon(),\n },\n});\n\nexport default withStyles(styles)(Dropdown);\n"],"file":"dropdown.js"}
@@ -7,46 +7,110 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
10
12
  var _react = _interopRequireDefault(require("react"));
11
13
 
12
- var _input = _interopRequireDefault(require("./components/input"));
14
+ var _styles = require("@material-ui/core/styles");
15
+
16
+ var _classnames2 = _interopRequireDefault(require("classnames"));
17
+
18
+ var _renderUi = require("@pie-lib/render-ui");
19
+
20
+ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
13
21
 
14
22
  var _withMask = require("./with-mask");
15
23
 
16
- // eslint-disable-next-line react/display-name
17
- var _default = (0, _withMask.withMask)('input', function (props) {
18
- return function (node, data, onChange) {
19
- var dataset = node.data ? node.data.dataset || {} : {};
24
+ 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; }
25
+
26
+ 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; }
27
+
28
+ var styles = function styles() {
29
+ return {
30
+ editableHtmlCustom: {
31
+ display: 'inline-block',
32
+ verticalAlign: 'middle',
33
+ margin: '4px',
34
+ borderRadius: '4px',
35
+ border: "1px solid ".concat(_renderUi.color.black())
36
+ },
37
+ correct: {
38
+ border: "1px solid ".concat(_renderUi.color.correct())
39
+ },
40
+ incorrect: {
41
+ border: "1px solid ".concat(_renderUi.color.incorrect())
42
+ }
43
+ };
44
+ };
45
+
46
+ var MaskedInput = function MaskedInput(props) {
47
+ return function (node, data) {
48
+ var _node$data;
49
+
50
+ var adjustedLimit = props.adjustedLimit,
51
+ disabled = props.disabled,
52
+ feedback = props.feedback,
53
+ showCorrectAnswer = props.showCorrectAnswer,
54
+ maxLength = props.maxLength,
55
+ spellCheck = props.spellCheck,
56
+ classes = props.classes,
57
+ pluginProps = props.pluginProps,
58
+ onChange = props.onChange;
59
+ var dataset = ((_node$data = node.data) === null || _node$data === void 0 ? void 0 : _node$data.dataset) || {};
20
60
 
21
61
  if (dataset.component === 'input') {
22
- // eslint-disable-next-line react/prop-types
23
- var adjustedLimit = props.adjustedLimit,
24
- disabled = props.disabled,
25
- feedback = props.feedback,
26
- showCorrectAnswer = props.showCorrectAnswer,
27
- maxLength = props.maxLength,
28
- spellCheck = props.spellCheck; // the first answer is the correct one
29
- // eslint-disable-next-line react/prop-types
62
+ var _pluginProps$characte, _classnames;
30
63
 
31
64
  var correctAnswer = (props.choices && dataset && props.choices[dataset.id] || [])[0];
32
65
  var finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';
33
66
  var width = maxLength && maxLength[dataset.id];
34
- return /*#__PURE__*/_react["default"].createElement(_input["default"], {
67
+ var feedbackStatus = feedback && feedback[dataset.id];
68
+ var isCorrect = showCorrectAnswer || feedbackStatus === 'correct';
69
+ var isIncorrect = !showCorrectAnswer && feedbackStatus === 'incorrect';
70
+
71
+ var handleInputChange = function handleInputChange(newValue) {
72
+ var updatedValue = _objectSpread(_objectSpread({}, data), {}, (0, _defineProperty2["default"])({}, dataset.id, newValue));
73
+
74
+ onChange(updatedValue);
75
+ };
76
+
77
+ var handleKeyDown = function handleKeyDown(event) {
78
+ // the keyCode value for the Enter/Return key is 13
79
+ if (event.key === 'Enter' || event.keyCode === 13) {
80
+ return false;
81
+ }
82
+ };
83
+
84
+ return /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
85
+ id: dataset.id,
35
86
  key: "".concat(node.type, "-input-").concat(dataset.id),
36
- correct: feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct',
37
87
  disabled: showCorrectAnswer || disabled,
38
- value: finalValue,
39
- id: dataset.id,
40
- onChange: onChange,
41
- showCorrectAnswer: showCorrectAnswer,
42
- width: width,
88
+ disableUnderline: true,
89
+ onChange: handleInputChange,
90
+ markup: finalValue || '',
43
91
  charactersLimit: adjustedLimit ? width : 25,
44
- isConstructedResponse: true,
45
- spellCheck: spellCheck
92
+ activePlugins: ['languageCharacters'],
93
+ pluginProps: pluginProps,
94
+ languageCharactersProps: [{
95
+ language: 'spanish'
96
+ }],
97
+ spellCheck: spellCheck,
98
+ width: "calc(".concat(width, "em + 42px)") // added 42px for left and right padding of editable-html
99
+ ,
100
+ onKeyDown: handleKeyDown,
101
+ autoWidthToolbar: true,
102
+ toolbarOpts: {
103
+ minWidth: 'auto',
104
+ noBorder: true,
105
+ isHidden: !!(pluginProps !== null && pluginProps !== void 0 && (_pluginProps$characte = pluginProps.characters) !== null && _pluginProps$characte !== void 0 && _pluginProps$characte.disabled)
106
+ },
107
+ className: (0, _classnames2["default"])(classes.editableHtmlCustom, (_classnames = {}, (0, _defineProperty2["default"])(_classnames, classes.correct, isCorrect), (0, _defineProperty2["default"])(_classnames, classes.incorrect, isIncorrect), _classnames))
46
108
  });
47
109
  }
48
110
  };
49
- });
111
+ };
112
+
113
+ var _default = (0, _styles.withStyles)(styles)((0, _withMask.withMask)('input', MaskedInput));
50
114
 
51
115
  exports["default"] = _default;
52
116
  //# sourceMappingURL=constructed-response.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/constructed-response.jsx"],"names":["props","node","data","onChange","dataset","component","adjustedLimit","disabled","feedback","showCorrectAnswer","maxLength","spellCheck","correctAnswer","choices","id","finalValue","label","width","type"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;eACe,wBAAS,OAAT,EAAkB,UAACA,KAAD;AAAA,SAAW,UAACC,IAAD,EAAOC,IAAP,EAAaC,QAAb,EAA0B;AACpE,QAAMC,OAAO,GAAGH,IAAI,CAACC,IAAL,GAAYD,IAAI,CAACC,IAAL,CAAUE,OAAV,IAAqB,EAAjC,GAAsC,EAAtD;;AACA,QAAIA,OAAO,CAACC,SAAR,KAAsB,OAA1B,EAAmC;AACjC;AACA,UAAQC,aAAR,GAAwFN,KAAxF,CAAQM,aAAR;AAAA,UAAuBC,QAAvB,GAAwFP,KAAxF,CAAuBO,QAAvB;AAAA,UAAiCC,QAAjC,GAAwFR,KAAxF,CAAiCQ,QAAjC;AAAA,UAA2CC,iBAA3C,GAAwFT,KAAxF,CAA2CS,iBAA3C;AAAA,UAA8DC,SAA9D,GAAwFV,KAAxF,CAA8DU,SAA9D;AAAA,UAAyEC,UAAzE,GAAwFX,KAAxF,CAAyEW,UAAzE,CAFiC,CAIjC;AACA;;AACA,UAAMC,aAAa,GAAG,CAAEZ,KAAK,CAACa,OAAN,IAAiBT,OAAjB,IAA4BJ,KAAK,CAACa,OAAN,CAAcT,OAAO,CAACU,EAAtB,CAA7B,IAA2D,EAA5D,EAAgE,CAAhE,CAAtB;AACA,UAAMC,UAAU,GAAGN,iBAAiB,GAAGG,aAAa,IAAIA,aAAa,CAACI,KAAlC,GAA0Cd,IAAI,CAACE,OAAO,CAACU,EAAT,CAAJ,IAAoB,EAAlG;AACA,UAAMG,KAAK,GAAGP,SAAS,IAAIA,SAAS,CAACN,OAAO,CAACU,EAAT,CAApC;AAEA,0BACE,gCAAC,iBAAD;AACE,QAAA,GAAG,YAAKb,IAAI,CAACiB,IAAV,oBAAwBd,OAAO,CAACU,EAAhC,CADL;AAEE,QAAA,OAAO,EAAEN,QAAQ,IAAIA,QAAQ,CAACJ,OAAO,CAACU,EAAT,CAApB,IAAoCN,QAAQ,CAACJ,OAAO,CAACU,EAAT,CAAR,KAAyB,SAFxE;AAGE,QAAA,QAAQ,EAAEL,iBAAiB,IAAIF,QAHjC;AAIE,QAAA,KAAK,EAAEQ,UAJT;AAKE,QAAA,EAAE,EAAEX,OAAO,CAACU,EALd;AAME,QAAA,QAAQ,EAAEX,QANZ;AAOE,QAAA,iBAAiB,EAAEM,iBAPrB;AAQE,QAAA,KAAK,EAAEQ,KART;AASE,QAAA,eAAe,EAAEX,aAAa,GAAGW,KAAH,GAAW,EAT3C;AAUE,QAAA,qBAAqB,EAAE,IAVzB;AAWE,QAAA,UAAU,EAAEN;AAXd,QADF;AAeD;AACF,GA5BgC;AAAA,CAAlB,C","sourcesContent":["import React from 'react';\nimport Input from './components/input';\nimport { withMask } from './with-mask';\n\n// eslint-disable-next-line react/display-name\nexport default withMask('input', (props) => (node, data, onChange) => {\n const dataset = node.data ? node.data.dataset || {} : {};\n if (dataset.component === 'input') {\n // eslint-disable-next-line react/prop-types\n const { adjustedLimit, disabled, feedback, showCorrectAnswer, maxLength, spellCheck } = props;\n\n // the first answer is the correct one\n // eslint-disable-next-line react/prop-types\n const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];\n const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';\n const width = maxLength && maxLength[dataset.id];\n\n return (\n <Input\n key={`${node.type}-input-${dataset.id}`}\n correct={feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct'}\n disabled={showCorrectAnswer || disabled}\n value={finalValue}\n id={dataset.id}\n onChange={onChange}\n showCorrectAnswer={showCorrectAnswer}\n width={width}\n charactersLimit={adjustedLimit ? width : 25}\n isConstructedResponse={true}\n spellCheck={spellCheck}\n />\n );\n }\n});\n"],"file":"constructed-response.js"}
1
+ {"version":3,"sources":["../src/constructed-response.jsx"],"names":["styles","editableHtmlCustom","display","verticalAlign","margin","borderRadius","border","color","black","correct","incorrect","MaskedInput","props","node","data","adjustedLimit","disabled","feedback","showCorrectAnswer","maxLength","spellCheck","classes","pluginProps","onChange","dataset","component","correctAnswer","choices","id","finalValue","label","width","feedbackStatus","isCorrect","isIncorrect","handleInputChange","newValue","updatedValue","handleKeyDown","event","key","keyCode","type","language","minWidth","noBorder","isHidden","characters"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBC,IAAAA,kBAAkB,EAAE;AAClBC,MAAAA,OAAO,EAAE,cADS;AAElBC,MAAAA,aAAa,EAAE,QAFG;AAGlBC,MAAAA,MAAM,EAAE,KAHU;AAIlBC,MAAAA,YAAY,EAAE,KAJI;AAKlBC,MAAAA,MAAM,sBAAeC,gBAAMC,KAAN,EAAf;AALY,KADA;AAQpBC,IAAAA,OAAO,EAAE;AACPH,MAAAA,MAAM,sBAAeC,gBAAME,OAAN,EAAf;AADC,KARW;AAWpBC,IAAAA,SAAS,EAAE;AACTJ,MAAAA,MAAM,sBAAeC,gBAAMG,SAAN,EAAf;AADG;AAXS,GAAP;AAAA,CAAf;;AAgBA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD;AAAA,SAAW,UAACC,IAAD,EAAOC,IAAP,EAAgB;AAAA;;AAC7C,QACEC,aADF,GAUIH,KAVJ,CACEG,aADF;AAAA,QAEEC,QAFF,GAUIJ,KAVJ,CAEEI,QAFF;AAAA,QAGEC,QAHF,GAUIL,KAVJ,CAGEK,QAHF;AAAA,QAIEC,iBAJF,GAUIN,KAVJ,CAIEM,iBAJF;AAAA,QAKEC,SALF,GAUIP,KAVJ,CAKEO,SALF;AAAA,QAMEC,UANF,GAUIR,KAVJ,CAMEQ,UANF;AAAA,QAOEC,OA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E,gCAAC,wBAAD;AACE,QAAA,EAAE,EAAEjB,OAAO,CAACI,EADd;AAEE,QAAA,GAAG,YAAKf,IAAI,CAAC6B,IAAV,oBAAwBlB,OAAO,CAACI,EAAhC,CAFL;AAGE,QAAA,QAAQ,EAAEV,iBAAiB,IAAIF,QAHjC;AAIE,QAAA,gBAAgB,MAJlB;AAKE,QAAA,QAAQ,EAAEmB,iBALZ;AAME,QAAA,MAAM,EAAEN,UAAU,IAAI,EANxB;AAOE,QAAA,eAAe,EAAEd,aAAa,GAAGgB,KAAH,GAAW,EAP3C;AAQE,QAAA,aAAa,EAAE,CAAC,oBAAD,CARjB;AASE,QAAA,WAAW,EAAET,WATf;AAUE,QAAA,uBAAuB,EAAE,CAAC;AAAEqB,UAAAA,QAAQ,EAAE;AAAZ,SAAD,CAV3B;AAWE,QAAA,UAAU,EAAEvB,UAXd;AAYE,QAAA,KAAK,iBAAUW,KAAV,eAZP,CAYoC;AAZpC;AAaE,QAAA,SAAS,EAAEO,aAbb;AAcE,QAAA,gBAAgB,MAdlB;AAeE,QAAA,WAAW,EAAE;AACXM,UAAAA,QAAQ,EAAE,MADC;AAEXC,UAAAA,QAAQ,EAAE,IAFC;AAGXC,UAAAA,QAAQ,EAAE,CAAC,EAACxB,WAAD,aAACA,WAAD,wCAACA,WAAW,CAAEyB,UAAd,kDAAC,sBAAyB/B,QAA1B;AAHA,SAff;AAoBE,QAAA,SAAS,EAAE,6BAAWK,OAAO,CAACpB,kBAAnB,mEACRoB,OAAO,CAACZ,OADA,EACUwB,SADV,iDAERZ,OAAO,CAACX,SAFA,EAEYwB,WAFZ;AApBb,QADF;AA2BD;AACF,GAjEmB;AAAA,CAApB;;eAmEe,wBAAWlC,MAAX,EAAmB,wBAAS,OAAT,EAAkBW,WAAlB,CAAnB,C","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport classnames from 'classnames';\n\nimport { color } from '@pie-lib/render-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { withMask } from './with-mask';\n\nconst styles = () => ({\n editableHtmlCustom: {\n display: 'inline-block',\n verticalAlign: 'middle',\n margin: '4px',\n borderRadius: '4px',\n border: `1px solid ${color.black()}`,\n },\n correct: {\n border: `1px solid ${color.correct()}`,\n },\n incorrect: {\n border: `1px solid ${color.incorrect()}`,\n },\n});\n\nconst MaskedInput = (props) => (node, data) => {\n const {\n adjustedLimit,\n disabled,\n feedback,\n showCorrectAnswer,\n maxLength,\n spellCheck,\n classes,\n pluginProps,\n onChange,\n } = props;\n const dataset = node.data?.dataset || {};\n\n if (dataset.component === 'input') {\n const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];\n const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';\n const width = maxLength && maxLength[dataset.id];\n const feedbackStatus = feedback && feedback[dataset.id];\n const isCorrect = showCorrectAnswer || feedbackStatus === 'correct';\n const isIncorrect = !showCorrectAnswer && feedbackStatus === 'incorrect';\n\n const handleInputChange = (newValue) => {\n const updatedValue = {\n ...data,\n [dataset.id]: newValue,\n };\n onChange(updatedValue);\n };\n\n const handleKeyDown = (event) => {\n // the keyCode value for the Enter/Return key is 13\n if (event.key === 'Enter' || event.keyCode === 13) {\n return false;\n }\n };\n\n return (\n <EditableHtml\n id={dataset.id}\n key={`${node.type}-input-${dataset.id}`}\n disabled={showCorrectAnswer || disabled}\n disableUnderline\n onChange={handleInputChange}\n markup={finalValue || ''}\n charactersLimit={adjustedLimit ? width : 25}\n activePlugins={['languageCharacters']}\n pluginProps={pluginProps}\n languageCharactersProps={[{ language: 'spanish' }]}\n spellCheck={spellCheck}\n width={`calc(${width}em + 42px)`} // added 42px for left and right padding of editable-html\n onKeyDown={handleKeyDown}\n autoWidthToolbar\n toolbarOpts={{\n minWidth: 'auto',\n noBorder: true,\n isHidden: !!pluginProps?.characters?.disabled,\n }}\n className={classnames(classes.editableHtmlCustom, {\n [classes.correct]: isCorrect,\n [classes.incorrect]: isIncorrect,\n })}\n />\n );\n }\n};\n\nexport default withStyles(styles)(withMask('input', MaskedInput));\n"],"file":"constructed-response.js"}
@@ -0,0 +1,48 @@
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 _react = _interopRequireDefault(require("react"));
11
+
12
+ var _withMask = require("./with-mask");
13
+
14
+ // import Input from './components/input';
15
+ // eslint-disable-next-line react/display-name
16
+ var _default = (0, _withMask.withMask)('input', function (props) {
17
+ return function (node, data, onChange) {
18
+ var dataset = node.data ? node.data.dataset || {} : {};
19
+
20
+ if (dataset.component === 'input') {
21
+ // eslint-disable-next-line react/prop-types
22
+ // const { adjustedLimit, disabled, feedback, showCorrectAnswer, maxLength, spellCheck } = props;
23
+ // the first answer is the correct one
24
+ // eslint-disable-next-line react/prop-types
25
+ // const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];
26
+ // const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';
27
+ // const width = maxLength && maxLength[dataset.id];
28
+ return props.customMarkMarkupComponent(dataset.id); // return (
29
+ // <Input
30
+ // key={`${node.type}-input-${dataset.id}`}
31
+ // correct={feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct'}
32
+ // disabled={showCorrectAnswer || disabled}
33
+ // value={finalValue}
34
+ // id={dataset.id}
35
+ // onChange={onChange}
36
+ // showCorrectAnswer={showCorrectAnswer}
37
+ // width={width}
38
+ // charactersLimit={adjustedLimit ? width : 25}
39
+ // isConstructedResponse={true}
40
+ // spellCheck={spellCheck}
41
+ // />
42
+ // );
43
+ }
44
+ };
45
+ });
46
+
47
+ exports["default"] = _default;
48
+ //# sourceMappingURL=customizable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/customizable.jsx"],"names":["props","node","data","onChange","dataset","component","customMarkMarkupComponent","id"],"mappings":";;;;;;;;;AAAA;;AAEA;;AADA;AAGA;eACe,wBAAS,OAAT,EAAkB,UAACA,KAAD;AAAA,SAAW,UAACC,IAAD,EAAOC,IAAP,EAAaC,QAAb,EAA0B;AACpE,QAAMC,OAAO,GAAGH,IAAI,CAACC,IAAL,GAAYD,IAAI,CAACC,IAAL,CAAUE,OAAV,IAAqB,EAAjC,GAAsC,EAAtD;;AACA,QAAIA,OAAO,CAACC,SAAR,KAAsB,OAA1B,EAAmC;AACjC;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA,aAAOL,KAAK,CAACM,yBAAN,CAAgCF,OAAO,CAACG,EAAxC,CAAP,CAViC,CAWjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACD;AACF,GA7BgC;AAAA,CAAlB,C","sourcesContent":["import React from 'react';\n// import Input from './components/input';\nimport { withMask } from './with-mask';\n\n// eslint-disable-next-line react/display-name\nexport default withMask('input', (props) => (node, data, onChange) => {\n const dataset = node.data ? node.data.dataset || {} : {};\n if (dataset.component === 'input') {\n // eslint-disable-next-line react/prop-types\n // const { adjustedLimit, disabled, feedback, showCorrectAnswer, maxLength, spellCheck } = props;\n\n // the first answer is the correct one\n // eslint-disable-next-line react/prop-types\n // const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];\n // const finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';\n // const width = maxLength && maxLength[dataset.id];\n\n return props.customMarkMarkupComponent(dataset.id);\n // return (\n // <Input\n // key={`${node.type}-input-${dataset.id}`}\n // correct={feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct'}\n // disabled={showCorrectAnswer || disabled}\n // value={finalValue}\n // id={dataset.id}\n // onChange={onChange}\n // showCorrectAnswer={showCorrectAnswer}\n // width={width}\n // charactersLimit={adjustedLimit ? width : 25}\n // isConstructedResponse={true}\n // spellCheck={spellCheck}\n // />\n // );\n }\n});\n"],"file":"customizable.js"}