@pie-lib/mask-markup 1.13.47-next.1 → 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
@@ -13,6 +13,8 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
13
13
 
14
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
15
 
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
16
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
19
 
18
20
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -21,6 +23,8 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
21
23
 
22
24
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
25
 
26
+ var _grey = _interopRequireDefault(require("@material-ui/core/colors/grey"));
27
+
24
28
  var _react = _interopRequireDefault(require("react"));
25
29
 
26
30
  var _reactDom = _interopRequireDefault(require("react-dom"));
@@ -60,21 +64,21 @@ var useStyles = (0, _styles.withStyles)(function () {
60
64
  border: "solid 0px ".concat(_renderUi.color.primary()),
61
65
  minWidth: '200px',
62
66
  touchAction: 'none',
63
- overflow: 'hidden'
67
+ overflow: 'hidden',
68
+ whiteSpace: 'nowrap' // Prevent line wrapping
69
+
64
70
  },
65
71
  chip: {
66
72
  backgroundColor: _renderUi.color.background(),
67
- border: "1px solid ".concat(_renderUi.color.text()),
73
+ border: "2px dashed ".concat(_renderUi.color.text()),
68
74
  color: _renderUi.color.text(),
69
- minWidth: '90px',
70
75
  fontSize: 'inherit',
71
- minHeight: '32px',
72
- height: 'auto',
73
76
  maxWidth: '374px',
74
- position: 'relative'
77
+ position: 'relative',
78
+ borderRadius: '3px'
75
79
  },
76
80
  chipLabel: {
77
- whiteSpace: 'pre-wrap',
81
+ whiteSpace: 'normal',
78
82
  // Added for touch devices, for image content.
79
83
  // This will prevent the context menu from appearing and not allowing other interactions with the image.
80
84
  // If interactions with the image in the token will be requested we should handle only the context Menu.
@@ -82,6 +86,16 @@ var useStyles = (0, _styles.withStyles)(function () {
82
86
  '& img': {
83
87
  display: 'block',
84
88
  padding: '2px 0'
89
+ },
90
+ // Remove default <p> margins to ensure consistent spacing across all wrapped content (p, span, div, math)
91
+ // Padding for top and bottom will instead be controlled by the container for consistent layout
92
+ // Ensures consistent behavior with pie-api-browser, where marginTop is already removed by a Bootstrap stylesheet
93
+ '& p': {
94
+ marginTop: '0',
95
+ marginBottom: '0'
96
+ },
97
+ '& mjx-frac': {
98
+ fontSize: '120% !important'
85
99
  }
86
100
  },
87
101
  hidden: {
@@ -102,6 +116,10 @@ var useStyles = (0, _styles.withStyles)(function () {
102
116
  over: {
103
117
  whiteSpace: 'nowrap',
104
118
  overflow: 'hidden'
119
+ },
120
+ parentOver: {
121
+ border: "1px solid ".concat(_grey["default"][500]),
122
+ backgroundColor: "".concat(_grey["default"][300])
105
123
  }
106
124
  };
107
125
  });
@@ -116,17 +134,61 @@ var BlankContent = /*#__PURE__*/function (_React$Component) {
116
134
 
117
135
  (0, _classCallCheck2["default"])(this, BlankContent);
118
136
  _this = _super.call(this);
137
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleImageLoad", function () {
138
+ _this.updateDimensions();
139
+ });
140
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleTouchStart", function (e) {
141
+ e.preventDefault();
142
+ _this.touchStartTimer = setTimeout(function () {
143
+ _this.startDrag();
144
+ }, 300); // Start drag after 300ms (touch and hold duration)
145
+ });
146
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "startDrag", function () {
147
+ var _this$props = _this.props,
148
+ connectDragSource = _this$props.connectDragSource,
149
+ disabled = _this$props.disabled;
150
+
151
+ if (!disabled) {
152
+ connectDragSource(_this.rootRef);
153
+ }
154
+ });
119
155
  _this.state = {
120
- height: 0
156
+ height: 0,
157
+ width: 0
121
158
  };
122
159
  return _this;
123
160
  }
124
161
 
125
162
  (0, _createClass2["default"])(BlankContent, [{
163
+ key: "handleElements",
164
+ value: function handleElements() {
165
+ var _this$spanRef,
166
+ _this2 = this;
167
+
168
+ var imageElement = (_this$spanRef = this.spanRef) === null || _this$spanRef === void 0 ? void 0 : _this$spanRef.querySelector('img');
169
+
170
+ if (imageElement) {
171
+ imageElement.onload = this.handleImageLoad;
172
+ } else {
173
+ setTimeout(function () {
174
+ _this2.updateDimensions();
175
+ }, 300);
176
+ }
177
+ }
178
+ }, {
179
+ key: "componentDidMount",
180
+ value: function componentDidMount() {
181
+ this.handleElements();
182
+
183
+ if (this.rootRef) {
184
+ this.rootRef.addEventListener('touchstart', this.handleTouchStart, {
185
+ passive: false
186
+ });
187
+ }
188
+ }
189
+ }, {
126
190
  key: "componentDidUpdate",
127
191
  value: function componentDidUpdate(prevProps) {
128
- var _this2 = this;
129
-
130
192
  (0, _mathRendering.renderMath)(this.rootRef);
131
193
  var currentChoice = this.props.choice;
132
194
  var prevChoice = prevProps.choice;
@@ -134,16 +196,47 @@ var BlankContent = /*#__PURE__*/function (_React$Component) {
134
196
  if (JSON.stringify(currentChoice) !== JSON.stringify(prevChoice)) {
135
197
  if (!currentChoice) {
136
198
  this.setState({
137
- height: 0
199
+ height: 0,
200
+ width: 0
138
201
  });
139
202
  return;
140
203
  }
141
204
 
142
- setTimeout(function () {
143
- _this2.setState({
144
- height: _this2.spanRef.offsetHeight
145
- });
146
- }, 300);
205
+ this.handleElements();
206
+ }
207
+ }
208
+ }, {
209
+ key: "componentWillUnmount",
210
+ value: function componentWillUnmount() {
211
+ if (this.rootRef) {
212
+ this.rootRef.removeEventListener('touchstart', this.handleTouchStart);
213
+ }
214
+ }
215
+ }, {
216
+ key: "updateDimensions",
217
+ value: function updateDimensions() {
218
+ if (this.spanRef && this.rootRef) {
219
+ // Temporarily set rootRef width to 'auto' for natural measurement
220
+ this.rootRef.style.width = 'auto'; // Get the natural dimensions of the content
221
+
222
+ var width = this.spanRef.offsetWidth || 0;
223
+ var height = this.spanRef.offsetHeight || 0;
224
+ var widthWithPadding = width + 24; // 12px padding on each side
225
+
226
+ var heightWithPadding = height + 24; // 12px padding on top and bottom
227
+
228
+ var responseAreaWidth = parseFloat(this.props.emptyResponseAreaWidth) || 0;
229
+ var responseAreaHeight = parseFloat(this.props.emptyResponseAreaHeight) || 0;
230
+ var adjustedWidth = widthWithPadding <= responseAreaWidth ? responseAreaWidth : widthWithPadding;
231
+ var adjustedHeight = heightWithPadding <= responseAreaHeight ? responseAreaHeight : heightWithPadding;
232
+ this.setState(function (prevState) {
233
+ return {
234
+ width: adjustedWidth > responseAreaWidth ? adjustedWidth : prevState.width,
235
+ height: adjustedHeight > responseAreaHeight ? adjustedHeight : prevState.height
236
+ };
237
+ });
238
+ this.rootRef.style.width = "".concat(adjustedWidth, "px");
239
+ this.rootRef.style.height = "".concat(adjustedHeight, "px");
147
240
  }
148
241
  }
149
242
  }, {
@@ -155,19 +248,37 @@ var BlankContent = /*#__PURE__*/function (_React$Component) {
155
248
  }
156
249
  });
157
250
  }
251
+ }, {
252
+ key: "getRootDimensions",
253
+ value: function getRootDimensions() {
254
+ // Handle potential non-numeric values
255
+ var responseAreaWidth = !isNaN(parseFloat(this.props.emptyResponseAreaWidth)) ? parseFloat(this.props.emptyResponseAreaWidth) : 0;
256
+ var responseAreaHeight = !isNaN(parseFloat(this.props.emptyResponseAreaHeight)) ? parseFloat(this.props.emptyResponseAreaHeight) : 0;
257
+ var rootStyle = {
258
+ height: this.state.height || responseAreaHeight,
259
+ width: this.state.width || responseAreaWidth
260
+ }; // add minWidth, minHeight if width and height are not defined
261
+ // minWidth, minHeight will be also in model in the future
262
+
263
+ return _objectSpread(_objectSpread(_objectSpread({}, rootStyle), responseAreaWidth ? {} : {
264
+ minWidth: 90
265
+ }), responseAreaHeight ? {} : {
266
+ minHeight: 32
267
+ });
268
+ }
158
269
  }, {
159
270
  key: "render",
160
271
  value: function render() {
161
272
  var _this3 = this,
162
273
  _classnames2;
163
274
 
164
- var _this$props = this.props,
165
- disabled = _this$props.disabled,
166
- choice = _this$props.choice,
167
- classes = _this$props.classes,
168
- isOver = _this$props.isOver,
169
- dragItem = _this$props.dragItem,
170
- correct = _this$props.correct;
275
+ var _this$props2 = this.props,
276
+ disabled = _this$props2.disabled,
277
+ choice = _this$props2.choice,
278
+ classes = _this$props2.classes,
279
+ isOver = _this$props2.isOver,
280
+ dragItem = _this$props2.dragItem,
281
+ correct = _this$props2.correct;
171
282
  var draggedLabel = dragItem && isOver && dragItem.choice.value;
172
283
  var label = choice && choice.value;
173
284
  return (
@@ -204,14 +315,9 @@ var BlankContent = /*#__PURE__*/function (_React$Component) {
204
315
  }
205
316
  }
206
317
  }, ' ')),
207
- className: (0, _classnames3["default"])(classes.chip, isOver && classes.over, (_classnames2 = {}, (0, _defineProperty2["default"])(_classnames2, classes.correct, correct !== undefined && correct), (0, _defineProperty2["default"])(_classnames2, classes.incorrect, correct !== undefined && !correct), _classnames2)),
318
+ className: (0, _classnames3["default"])(classes.chip, isOver && classes.over, isOver && classes.parentOver, (_classnames2 = {}, (0, _defineProperty2["default"])(_classnames2, classes.correct, correct !== undefined && correct), (0, _defineProperty2["default"])(_classnames2, classes.incorrect, correct !== undefined && !correct), _classnames2)),
208
319
  variant: disabled ? 'outlined' : undefined,
209
- style: _objectSpread({}, this.state.height ? {
210
- height: this.state.height
211
- } : {}),
212
- classes: {
213
- label: isOver && classes.over
214
- }
320
+ style: _objectSpread({}, this.getRootDimensions())
215
321
  })
216
322
  );
217
323
  }
@@ -220,7 +326,11 @@ var BlankContent = /*#__PURE__*/function (_React$Component) {
220
326
  }(_react["default"].Component);
221
327
 
222
328
  exports.BlankContent = BlankContent;
223
- (0, _defineProperty2["default"])(BlankContent, "propTypes", {
329
+ BlankContent.defaultProps = {
330
+ emptyResponseAreaWidth: 0,
331
+ emptyResponseAreaHeight: 0
332
+ };
333
+ BlankContent.propTypes = {
224
334
  id: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
225
335
  disabled: _propTypes["default"].bool,
226
336
  duplicates: _propTypes["default"].bool,
@@ -229,8 +339,10 @@ exports.BlankContent = BlankContent;
229
339
  isOver: _propTypes["default"].bool,
230
340
  dragItem: _propTypes["default"].object,
231
341
  correct: _propTypes["default"].bool,
232
- onChange: _propTypes["default"].func
233
- });
342
+ onChange: _propTypes["default"].func,
343
+ emptyResponseAreaWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
344
+ emptyResponseAreaHeight: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])
345
+ };
234
346
  var StyledBlankContent = useStyles(BlankContent);
235
347
  var connectedBlankContent = useStyles(function (_ref4) {
236
348
  var connectDragSource = _ref4.connectDragSource,
@@ -283,7 +395,7 @@ var tileSource = {
283
395
  // this will be null if it did not drop
284
396
  var dropResult = monitor.getDropResult();
285
397
 
286
- if (!dropResult || dropResult.dropped && !props.duplicates) {
398
+ if (!dropResult || dropResult.dropped) {
287
399
  var draggedItem = monitor.getItem();
288
400
 
289
401
  if (draggedItem.fromChoice) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/blank.jsx"],"names":["log","DRAG_TYPE","useStyles","content","border","color","primary","minWidth","touchAction","overflow","chip","backgroundColor","background","text","fontSize","minHeight","height","maxWidth","position","chipLabel","whiteSpace","pointerEvents","display","padding","hidden","opacity","dragged","left","correct","incorrect","over","BlankContent","state","prevProps","rootRef","currentChoice","props","choice","prevChoice","JSON","stringify","setState","setTimeout","spanRef","offsetHeight","parent","childNodes","forEach","elem","Element","HTMLDocument","setAttribute","disabled","classes","isOver","dragItem","draggedLabel","value","label","ref","ReactDOM","findDOMNode","innerHTML","addDraggableFalseAttributes","undefined","React","Component","id","PropTypes","oneOfType","string","number","bool","duplicates","object","onChange","func","StyledBlankContent","connectedBlankContent","connectDragSource","connectDropTarget","tileTarget","drop","monitor","draggedItem","getItem","instanceId","dropped","canDrop","DropTile","connect","dropTarget","tileSource","canDrag","beginDrag","fromChoice","endDrag","dropResult","getDropResult","DragDropTile","dragSource","isDragging"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AACA,IAAMA,GAAG,GAAG,uBAAM,2BAAN,CAAZ;AACO,IAAMC,SAAS,GAAG,WAAlB;;AAEP,IAAMC,SAAS,GAAG,wBAAW;AAAA,SAAO;AAClCC,IAAAA,OAAO,EAAE;AACPC,MAAAA,MAAM,sBAAeC,gBAAMC,OAAN,EAAf,CADC;AAEPC,MAAAA,QAAQ,EAAE,OAFH;AAGPC,MAAAA,WAAW,EAAE,MAHN;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KADyB;AAOlCC,IAAAA,IAAI,EAAE;AACJC,MAAAA,eAAe,EAAEN,gBAAMO,UAAN,EADb;AAEJR,MAAAA,MAAM,sBAAeC,gBAAMQ,IAAN,EAAf,CAFF;AAGJR,MAAAA,KAAK,EAAEA,gBAAMQ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lC,EAIbP,qBAJa,CAAjB;AAMA,IAAMc,UAAU,GAAG;AACjBC,EAAAA,OADiB,mBACTzD,KADS,EACF;AACb,WAAO,CAACA,KAAK,CAACgB,QAAP,IAAmB,CAAC,CAAChB,KAAK,CAACC,MAAlC;AACD,GAHgB;AAIjByD,EAAAA,SAJiB,qBAIP1D,KAJO,EAIA;AACf,WAAO;AACL+B,MAAAA,EAAE,EAAE/B,KAAK,CAAC+B,EADL;AAEL9B,MAAAA,MAAM,EAAED,KAAK,CAACC,MAFT;AAGLiD,MAAAA,UAAU,EAAElD,KAAK,CAACkD,UAHb;AAILS,MAAAA,UAAU,EAAE;AAJP,KAAP;AAMD,GAXgB;AAYjBC,EAAAA,OAZiB,mBAYT5D,KAZS,EAYF+C,OAZE,EAYO;AACtB;AACA,QAAMc,UAAU,GAAGd,OAAO,CAACe,aAAR,EAAnB;;AAEA,QAAI,CAACD,UAAD,IAAgBA,UAAU,CAACV,OAAX,IAAsB,CAACnD,KAAK,CAACqC,UAAjD,EAA8D;AAC5D,UAAMW,WAAW,GAAGD,OAAO,CAACE,OAAR,EAApB;;AAEA,UAAID,WAAW,CAACW,UAAhB,EAA4B;AAC1B3D,QAAAA,KAAK,CAACuC,QAAN,CAAevC,KAAK,CAAC+B,EAArB,EAAyBH,SAAzB;AACD;AACF;AACF;AAvBgB,CAAnB;AA0BA,IAAMmC,YAAY,GAAG,sBAAWlG,SAAX,EAAsB2F,UAAtB,EAAkC,UAACF,OAAD,EAAUP,OAAV;AAAA,SAAuB;AAC5EJ,IAAAA,iBAAiB,EAAEW,OAAO,CAACU,UAAR,EADyD;AAE5EC,IAAAA,UAAU,EAAElB,OAAO,CAACkB,UAAR;AAFgE,GAAvB;AAAA,CAAlC,EAGjBZ,QAHiB,CAArB;eAKeU,Y","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\nimport { DragSource, DropTarget } from '@pie-lib/drag';\nimport { withStyles } from '@material-ui/core/styles';\nimport Chip from '@material-ui/core/Chip';\nimport classnames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\nconst log = debug('pie-lib:mask-markup:blank');\nexport const DRAG_TYPE = 'MaskBlank';\n\nconst useStyles = withStyles(() => ({\n content: {\n border: `solid 0px ${color.primary()}`,\n minWidth: '200px',\n touchAction: 'none',\n overflow: 'hidden',\n },\n chip: {\n backgroundColor: color.background(),\n border: `1px solid ${color.text()}`,\n color: color.text(),\n minWidth: '90px',\n fontSize: 'inherit',\n minHeight: '32px',\n height: 'auto',\n maxWidth: '374px',\n position: 'relative',\n },\n chipLabel: {\n whiteSpace: 'pre-wrap',\n // Added for touch devices, for image content.\n // This will prevent the context menu from appearing and not allowing other interactions with the image.\n // If interactions with the image in the token will be requested we should handle only the context Menu.\n pointerEvents: 'none',\n '& img': {\n display: 'block',\n padding: '2px 0',\n },\n },\n hidden: {\n color: 'transparent',\n opacity: 0,\n },\n dragged: {\n position: 'absolute',\n left: 16,\n maxWidth: '60px',\n },\n correct: {\n border: `solid 1px ${color.correct()}`,\n },\n incorrect: {\n border: `solid 1px ${color.incorrect()}`,\n },\n over: {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n },\n}));\n\nexport class BlankContent extends React.Component {\n static propTypes = {\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n disabled: PropTypes.bool,\n duplicates: PropTypes.bool,\n choice: PropTypes.object,\n classes: PropTypes.object,\n isOver: PropTypes.bool,\n dragItem: PropTypes.object,\n correct: PropTypes.bool,\n onChange: PropTypes.func,\n };\n\n constructor() {\n super();\n this.state = {\n height: 0,\n };\n }\n\n componentDidUpdate(prevProps) {\n renderMath(this.rootRef);\n const { choice: currentChoice } = this.props;\n const { choice: prevChoice } = prevProps;\n\n if (JSON.stringify(currentChoice) !== JSON.stringify(prevChoice)) {\n if (!currentChoice) {\n this.setState({\n height: 0,\n });\n return;\n }\n setTimeout(() => {\n this.setState({\n height: this.spanRef.offsetHeight,\n });\n }, 300);\n }\n }\n\n addDraggableFalseAttributes(parent) {\n parent.childNodes.forEach((elem) => {\n if (elem instanceof Element || elem instanceof HTMLDocument) {\n elem.setAttribute('draggable', false);\n }\n });\n }\n\n render() {\n const { disabled, choice, classes, isOver, dragItem, correct } = this.props;\n const draggedLabel = dragItem && isOver && dragItem.choice.value;\n const label = choice && choice.value;\n\n return (\n // TODO the Chip element is causing drag problems on touch devices. Avoid using Chip and consider refactoring the code. Keep in mind that Chip is a span with a button role, which interferes with seamless touch device dragging.\n <Chip\n clickable={false}\n disabled={true}\n ref={(ref) => {\n //eslint-disable-next-line\n this.rootRef = ReactDOM.findDOMNode(ref);\n }}\n component=\"span\"\n label={\n <React.Fragment>\n <span\n className={classnames(classes.chipLabel, isOver && classes.over, {\n [classes.hidden]: draggedLabel,\n })}\n ref={(ref) => {\n if (ref) {\n //eslint-disable-next-line\n this.spanRef = ReactDOM.findDOMNode(ref);\n ref.innerHTML = label || '';\n this.addDraggableFalseAttributes(ref);\n }\n }}\n >\n {' '}\n </span>\n {draggedLabel && (\n <span\n className={classnames(classes.chipLabel, isOver && classes.over, classes.dragged)}\n ref={(ref) => {\n if (ref) {\n //eslint-disable-next-line\n this.spanRef = ReactDOM.findDOMNode(ref);\n ref.innerHTML = draggedLabel || '';\n this.addDraggableFalseAttributes(ref);\n }\n }}\n >\n {' '}\n </span>\n )}\n </React.Fragment>\n }\n className={classnames(classes.chip, isOver && classes.over, {\n [classes.correct]: correct !== undefined && correct,\n [classes.incorrect]: correct !== undefined && !correct,\n })}\n variant={disabled ? 'outlined' : undefined}\n style={{\n ...(this.state.height ? { height: this.state.height } : {}),\n }}\n classes={{\n label: isOver && classes.over,\n }}\n />\n );\n }\n}\n\nconst StyledBlankContent = useStyles(BlankContent);\n\nconst connectedBlankContent = useStyles(({ connectDragSource, connectDropTarget, ...props }) => {\n const { classes, isOver } = props;\n\n return connectDropTarget(\n connectDragSource(\n <span className={classnames(classes.content, isOver && classes.over)}>\n <StyledBlankContent {...props} />\n </span>,\n ),\n );\n});\n\nconst tileTarget = {\n drop(props, monitor) {\n const draggedItem = monitor.getItem();\n\n log('props.instanceId', props.instanceId, 'draggedItem.instanceId:', draggedItem.instanceId);\n\n if (draggedItem.id !== props.id) {\n props.onChange(props.id, draggedItem.choice.id);\n }\n\n return {\n dropped: draggedItem.id !== props.id,\n };\n },\n canDrop(props, monitor) {\n const draggedItem = monitor.getItem();\n\n return draggedItem.instanceId === props.instanceId;\n },\n};\n\nconst DropTile = DropTarget(DRAG_TYPE, tileTarget, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n dragItem: monitor.getItem(),\n}))(connectedBlankContent);\n\nconst tileSource = {\n canDrag(props) {\n return !props.disabled && !!props.choice;\n },\n beginDrag(props) {\n return {\n id: props.id,\n choice: props.choice,\n instanceId: props.instanceId,\n fromChoice: true,\n };\n },\n endDrag(props, monitor) {\n // this will be null if it did not drop\n const dropResult = monitor.getDropResult();\n\n if (!dropResult || (dropResult.dropped && !props.duplicates)) {\n const draggedItem = monitor.getItem();\n\n if (draggedItem.fromChoice) {\n props.onChange(props.id, undefined);\n }\n }\n },\n};\n\nconst DragDropTile = DragSource(DRAG_TYPE, tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging(),\n}))(DropTile);\n\nexport default DragDropTile;\n"],"file":"blank.js"}
1
+ {"version":3,"sources":["../../src/components/blank.jsx"],"names":["log","DRAG_TYPE","useStyles","content","border","color","primary","minWidth","touchAction","overflow","whiteSpace","chip","backgroundColor","background","text","fontSize","maxWidth","position","borderRadius","chipLabel","pointerEvents","display","padding","marginTop","marginBottom","hidden","opacity","dragged","left","correct","incorrect","over","parentOver","grey","BlankContent","updateDimensions","e","preventDefault","touchStartTimer","setTimeout","startDrag","props","connectDragSource","disabled","rootRef","state","height","width","imageElement","spanRef","querySelector","onload","handleImageLoad","handleElements","addEventListener","handleTouchStart","passive","prevProps","currentChoice","choice","prevChoice","JSON","stringify","setState","removeEventListener","style","offsetWidth","offsetHeight","widthWithPadding","heightWithPadding","responseAreaWidth","parseFloat","emptyResponseAreaWidth","responseAreaHeight","emptyResponseAreaHeight","adjustedWidth","adjustedHeight","prevState","parent","childNodes","forEach","elem","Element","HTMLDocument","setAttribute","isNaN","rootStyle","minHeight","classes","isOver","dragItem","draggedLabel","value","label","ref","ReactDOM","findDOMNode","innerHTML","addDraggableFalseAttributes","undefined","getRootDimensions","React","Component","defaultProps","propTypes","id","PropTypes","oneOfType","string","number","bool","duplicates","object","onChange","func","StyledBlankContent","connectedBlankContent","connectDropTarget","tileTarget","drop","monitor","draggedItem","getItem","instanceId","dropped","canDrop","DropTile","connect","dropTarget","tileSource","canDrag","beginDrag","fromChoice","endDrag","dropResult","getDropResult","DragDropTile","dragSource","isDragging"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,2BAAN,CAAZ;AACO,IAAMC,SAAS,GAAG,WAAlB;;AAEP,IAAMC,SAAS,GAAG,wBAAW;AAAA,SAAO;AAClCC,IAAAA,OAAO,EAAE;AACPC,MAAAA,MAAM,sBAAeC,gBAAMC,OAAN,EAAf,CADC;AAEPC,MAAAA,QAAQ,EAAE,OAFH;AAGPC,MAAAA,WAAW,EAAE,MAHN;AAIPC,MAAAA,QAAQ,EAAE,QAJH;AAKPC,MAAAA,UAAU,EAAE,QALL,CAKe;;AALf,KADyB;AAQlCC,IAAAA,IAAI,EAAE;AACJC,MAAAA,eAAe,EAAEP,gBAAMQ,UAAN,EADb;AAEJT,MAAAA,MAAM,uBAAgBC,gBAAMS,IAAN,EAAhB,CAFF;AAGJT,MAAAA,KAAK,EAAEA,gBAAMS,IAAN,EAHH;AAIJC,MAAAA,QAAQ,EAAE,SAJN;AAKJC,MAAAA,QA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,MAAAA,UAAU,EAAE;AAJP,KAAP;AAMD,GAXgB;AAYjBC,EAAAA,OAZiB,mBAYT5F,KAZS,EAYF+E,OAZE,EAYO;AACtB;AACA,QAAMc,UAAU,GAAGd,OAAO,CAACe,aAAR,EAAnB;;AAEA,QAAI,CAACD,UAAD,IAAeA,UAAU,CAACV,OAA9B,EAAuC;AACrC,UAAMH,WAAW,GAAGD,OAAO,CAACE,OAAR,EAApB;;AAEA,UAAID,WAAW,CAACW,UAAhB,EAA4B;AAC1B3F,QAAAA,KAAK,CAACwE,QAAN,CAAexE,KAAK,CAACgE,EAArB,EAAyBN,SAAzB;AACD;AACF;AACF;AAvBgB,CAAnB;AA0BA,IAAMqC,YAAY,GAAG,sBAAWvI,SAAX,EAAsBgI,UAAtB,EAAkC,UAACF,OAAD,EAAUP,OAAV;AAAA,SAAuB;AAC5E9E,IAAAA,iBAAiB,EAAEqF,OAAO,CAACU,UAAR,EADyD;AAE5EC,IAAAA,UAAU,EAAElB,OAAO,CAACkB,UAAR;AAFgE,GAAvB;AAAA,CAAlC,EAGjBZ,QAHiB,CAArB;eAKeU,Y","sourcesContent":["import grey from '@material-ui/core/colors/grey';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\nimport { DragSource, DropTarget } from '@pie-lib/drag';\nimport { withStyles } from '@material-ui/core/styles';\nimport Chip from '@material-ui/core/Chip';\nimport classnames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\n\nconst log = debug('pie-lib:mask-markup:blank');\nexport const DRAG_TYPE = 'MaskBlank';\n\nconst useStyles = withStyles(() => ({\n content: {\n border: `solid 0px ${color.primary()}`,\n minWidth: '200px',\n touchAction: 'none',\n overflow: 'hidden',\n whiteSpace: 'nowrap', // Prevent line wrapping\n },\n chip: {\n backgroundColor: color.background(),\n border: `2px dashed ${color.text()}`,\n color: color.text(),\n fontSize: 'inherit',\n maxWidth: '374px',\n position: 'relative',\n borderRadius: '3px',\n },\n chipLabel: {\n whiteSpace: 'normal',\n // Added for touch devices, for image content.\n // This will prevent the context menu from appearing and not allowing other interactions with the image.\n // If interactions with the image in the token will be requested we should handle only the context Menu.\n pointerEvents: 'none',\n '& img': {\n display: 'block',\n padding: '2px 0',\n },\n // Remove default <p> margins to ensure consistent spacing across all wrapped content (p, span, div, math)\n // Padding for top and bottom will instead be controlled by the container for consistent layout\n // Ensures consistent behavior with pie-api-browser, where marginTop is already removed by a Bootstrap stylesheet\n '& p': {\n marginTop: '0',\n marginBottom: '0',\n },\n '& mjx-frac': {\n fontSize: '120% !important',\n },\n },\n hidden: {\n color: 'transparent',\n opacity: 0,\n },\n dragged: {\n position: 'absolute',\n left: 16,\n maxWidth: '60px',\n },\n correct: {\n border: `solid 1px ${color.correct()}`,\n },\n incorrect: {\n border: `solid 1px ${color.incorrect()}`,\n },\n over: {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n },\n parentOver: {\n border: `1px solid ${grey[500]}`,\n backgroundColor: `${grey[300]}`,\n },\n}));\n\nexport class BlankContent extends React.Component {\n constructor() {\n super();\n this.state = {\n height: 0,\n width: 0,\n };\n }\n\n handleImageLoad = () => {\n this.updateDimensions();\n };\n\n handleElements() {\n const imageElement = this.spanRef?.querySelector('img');\n\n if (imageElement) {\n imageElement.onload = this.handleImageLoad;\n } else {\n setTimeout(() => {\n this.updateDimensions();\n }, 300);\n }\n }\n\n componentDidMount() {\n this.handleElements();\n if (this.rootRef) {\n this.rootRef.addEventListener('touchstart', this.handleTouchStart, { passive: false });\n }\n }\n\n componentDidUpdate(prevProps) {\n renderMath(this.rootRef);\n const { choice: currentChoice } = this.props;\n const { choice: prevChoice } = prevProps;\n\n if (JSON.stringify(currentChoice) !== JSON.stringify(prevChoice)) {\n if (!currentChoice) {\n this.setState({\n height: 0,\n width: 0,\n });\n return;\n }\n this.handleElements();\n }\n }\n\n componentWillUnmount() {\n if (this.rootRef) {\n this.rootRef.removeEventListener('touchstart', this.handleTouchStart);\n }\n }\n\n handleTouchStart = (e) => {\n e.preventDefault();\n this.touchStartTimer = setTimeout(() => {\n this.startDrag();\n }, 300); // Start drag after 300ms (touch and hold duration)\n };\n\n startDrag = () => {\n const { connectDragSource, disabled } = this.props;\n if (!disabled) {\n connectDragSource(this.rootRef);\n }\n };\n\n updateDimensions() {\n if (this.spanRef && this.rootRef) {\n // Temporarily set rootRef width to 'auto' for natural measurement\n this.rootRef.style.width = 'auto';\n\n // Get the natural dimensions of the content\n const width = this.spanRef.offsetWidth || 0;\n const height = this.spanRef.offsetHeight || 0;\n\n const widthWithPadding = width + 24; // 12px padding on each side\n const heightWithPadding = height + 24; // 12px padding on top and bottom\n\n const responseAreaWidth = parseFloat(this.props.emptyResponseAreaWidth) || 0;\n const responseAreaHeight = parseFloat(this.props.emptyResponseAreaHeight) || 0;\n\n const adjustedWidth = widthWithPadding <= responseAreaWidth ? responseAreaWidth : widthWithPadding;\n const adjustedHeight = heightWithPadding <= responseAreaHeight ? responseAreaHeight : heightWithPadding;\n\n this.setState((prevState) => ({\n width: adjustedWidth > responseAreaWidth ? adjustedWidth : prevState.width,\n height: adjustedHeight > responseAreaHeight ? adjustedHeight : prevState.height,\n }));\n\n this.rootRef.style.width = `${adjustedWidth}px`;\n this.rootRef.style.height = `${adjustedHeight}px`;\n }\n }\n\n addDraggableFalseAttributes(parent) {\n parent.childNodes.forEach((elem) => {\n if (elem instanceof Element || elem instanceof HTMLDocument) {\n elem.setAttribute('draggable', false);\n }\n });\n }\n\n getRootDimensions() {\n // Handle potential non-numeric values\n const responseAreaWidth = !isNaN(parseFloat(this.props.emptyResponseAreaWidth))\n ? parseFloat(this.props.emptyResponseAreaWidth)\n : 0;\n const responseAreaHeight = !isNaN(parseFloat(this.props.emptyResponseAreaHeight))\n ? parseFloat(this.props.emptyResponseAreaHeight)\n : 0;\n\n const rootStyle = {\n height: this.state.height || responseAreaHeight,\n width: this.state.width || responseAreaWidth,\n };\n\n // add minWidth, minHeight if width and height are not defined\n // minWidth, minHeight will be also in model in the future\n return {\n ...rootStyle,\n ...(responseAreaWidth ? {} : { minWidth: 90 }),\n ...(responseAreaHeight ? {} : { minHeight: 32 }),\n };\n }\n\n render() {\n const { disabled, choice, classes, isOver, dragItem, correct } = this.props;\n const draggedLabel = dragItem && isOver && dragItem.choice.value;\n const label = choice && choice.value;\n\n return (\n // TODO the Chip element is causing drag problems on touch devices. Avoid using Chip and consider refactoring the code. Keep in mind that Chip is a span with a button role, which interferes with seamless touch device dragging.\n <Chip\n clickable={false}\n disabled={true}\n ref={(ref) => {\n //eslint-disable-next-line\n this.rootRef = ReactDOM.findDOMNode(ref);\n }}\n component=\"span\"\n label={\n <React.Fragment>\n <span\n className={classnames(classes.chipLabel, isOver && classes.over, {\n [classes.hidden]: draggedLabel,\n })}\n ref={(ref) => {\n if (ref) {\n //eslint-disable-next-line\n this.spanRef = ReactDOM.findDOMNode(ref);\n ref.innerHTML = label || '';\n this.addDraggableFalseAttributes(ref);\n }\n }}\n >\n {' '}\n </span>\n {draggedLabel && (\n <span\n className={classnames(classes.chipLabel, isOver && classes.over, classes.dragged)}\n ref={(ref) => {\n if (ref) {\n //eslint-disable-next-line\n this.spanRef = ReactDOM.findDOMNode(ref);\n ref.innerHTML = draggedLabel || '';\n this.addDraggableFalseAttributes(ref);\n }\n }}\n >\n {' '}\n </span>\n )}\n </React.Fragment>\n }\n className={classnames(classes.chip, isOver && classes.over, isOver && classes.parentOver, {\n [classes.correct]: correct !== undefined && correct,\n [classes.incorrect]: correct !== undefined && !correct,\n })}\n variant={disabled ? 'outlined' : undefined}\n style={{\n ...this.getRootDimensions(),\n }}\n />\n );\n }\n}\n\nBlankContent.defaultProps = {\n emptyResponseAreaWidth: 0,\n emptyResponseAreaHeight: 0,\n};\n\nBlankContent.propTypes = {\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n disabled: PropTypes.bool,\n duplicates: PropTypes.bool,\n choice: PropTypes.object,\n classes: PropTypes.object,\n isOver: PropTypes.bool,\n dragItem: PropTypes.object,\n correct: PropTypes.bool,\n onChange: PropTypes.func,\n emptyResponseAreaWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n emptyResponseAreaHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n};\n\nconst StyledBlankContent = useStyles(BlankContent);\n\nconst connectedBlankContent = useStyles(({ connectDragSource, connectDropTarget, ...props }) => {\n const { classes, isOver } = props;\n\n return connectDropTarget(\n connectDragSource(\n <span className={classnames(classes.content, isOver && classes.over)}>\n <StyledBlankContent {...props} />\n </span>,\n ),\n );\n});\n\nconst tileTarget = {\n drop(props, monitor) {\n const draggedItem = monitor.getItem();\n\n log('props.instanceId', props.instanceId, 'draggedItem.instanceId:', draggedItem.instanceId);\n\n if (draggedItem.id !== props.id) {\n props.onChange(props.id, draggedItem.choice.id);\n }\n\n return {\n dropped: draggedItem.id !== props.id,\n };\n },\n canDrop(props, monitor) {\n const draggedItem = monitor.getItem();\n\n return draggedItem.instanceId === props.instanceId;\n },\n};\n\nconst DropTile = DropTarget(DRAG_TYPE, tileTarget, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n dragItem: monitor.getItem(),\n}))(connectedBlankContent);\n\nconst tileSource = {\n canDrag(props) {\n return !props.disabled && !!props.choice;\n },\n beginDrag(props) {\n return {\n id: props.id,\n choice: props.choice,\n instanceId: props.instanceId,\n fromChoice: true,\n };\n },\n endDrag(props, monitor) {\n // this will be null if it did not drop\n const dropResult = monitor.getDropResult();\n\n if (!dropResult || dropResult.dropped) {\n const draggedItem = monitor.getItem();\n\n if (draggedItem.fromChoice) {\n props.onChange(props.id, undefined);\n }\n }\n },\n};\n\nconst DragDropTile = DragSource(DRAG_TYPE, tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging(),\n}))(DropTile);\n\nexport default DragDropTile;\n"],"file":"blank.js"}
@@ -60,7 +60,9 @@ var _default = (0, _styles.withStyles)(function () {
60
60
  correct: correctStyle(_renderUi.color.correct()),
61
61
  incorrect: correctStyle(_renderUi.color.incorrect()),
62
62
  box: {
63
- fontSize: 'inherit'
63
+ fontSize: 'inherit',
64
+ display: 'inline-block',
65
+ verticalAlign: 'middle'
64
66
  },
65
67
  outlinedInput: {
66
68
  padding: '2px',
@@ -87,8 +89,11 @@ var _default = (0, _styles.withStyles)(function () {
87
89
  rest = (0, _objectWithoutProperties2["default"])(props, _excluded);
88
90
  var label = typeof correct === 'boolean' ? correct ? 'correct' : 'incorrect' : undefined;
89
91
  var inputProps = charactersLimit ? {
90
- maxLength: charactersLimit
91
- } : {};
92
+ maxLength: charactersLimit,
93
+ 'aria-label': 'Enter answer'
94
+ } : {
95
+ 'aria-label': 'Enter answer'
96
+ };
92
97
 
93
98
  if (width) {
94
99
  inputProps.style = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/correct-input.jsx"],"names":["correctStyle","color","borderColor","input","text","backgroundColor","background","borderRadius","borderWidth","borderStyle","padding","opacity","cursor","primary","primaryDark","crInput","correct","incorrect","box","fontSize","outlinedInput","border","notchedOutline","props","charactersLimit","classes","disabled","isBox","isConstructedResponse","width","spellCheck","rest","label","undefined","inputProps","maxLength","style","Math","round","disabledInput"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;AAAA,SAAY;AAC/BC,IAAAA,WAAW,YAAKD,KAAL;AADoB,GAAZ;AAAA,CAArB;;eAIe,wBAAW;AAAA,SAAO;AAC/BE,IAAAA,KAAK,EAAE;AACLF,MAAAA,KAAK,EAAEA,gBAAMG,IAAN,EADF;AAELC,MAAAA,eAAe,EAAEJ,gBAAMK,UAAN,EAFZ;AAGLC,MAAAA,YAAY,EAAE,gBAHT;AAILC,MAAAA,WAAW,EAAE,KAJR;AAKLC,MAAAA,WAAW,EAAE,OALR;AAMLC,MAAAA,OAA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IR,KAVJ;AAWA,MAAMS,KAAK,GAAG,OAAOhB,OAAP,KAAmB,SAAnB,GAAgCA,OAAO,GAAG,SAAH,GAAe,WAAtD,GAAqEiB,SAAnF;AACA,MAAMC,UAAU,GAAGV,eAAe,GAAG;AAAEW,IAAAA,SAAS,EAAEX;AAAb,GAAH,GAAoC,EAAtE;;AAEA,MAAIK,KAAJ,EAAW;AACTK,IAAAA,UAAU,CAACE,KAAX,GAAmB;AACjBP,MAAAA,KAAK,YAAKA,KAAK,GAAGQ,IAAI,CAACC,KAAL,CAAWT,KAAK,GAAG,EAAnB,CAAR,GAAiC,CAAtC,OADY,CACiC;;AADjC,KAAnB;AAGD;;AAED,sBACE,gCAAC,yBAAD;AACE,IAAA,SAAS,EAAE,8FACRJ,OAAO,CAACc,aADA,EACgBb,QADhB,iDAERD,OAAO,CAACP,GAFA,EAEMS,KAFN,iDAGRF,OAAO,CAACL,aAHA,EAGgB,IAHhB,gBADb;AAME,IAAA,OAAO,EAAE;AACPjB,MAAAA,KAAK,EAAE,gGACJsB,OAAO,CAACtB,KADJ,EACY,IADZ,kDAEJsB,OAAO,CAACO,KAAD,CAFH,EAEaA,KAFb,kDAGJP,OAAO,CAACV,OAHJ,EAGca,qBAHd;AADA,KANX;AAaE,IAAA,UAAU,EAAEM,UAbd;AAcE,IAAA,UAAU,EAAE,CAdd;AAeE,IAAA,QAAQ,EAAER,QAfZ;AAgBE,IAAA,UAAU,EAAEI;AAhBd,KAiBMC,IAjBN,EADF;AAqBD,CAlFc,C","sourcesContent":["import React from 'react';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport classnames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nconst correctStyle = (color) => ({\n borderColor: `${color} !important`,\n});\n\nexport default withStyles(() => ({\n input: {\n color: color.text(),\n backgroundColor: color.background(),\n borderRadius: '4px !important',\n borderWidth: '1px',\n borderStyle: 'solid',\n padding: '10px 20px 10px 10px',\n '&:disabled': {\n opacity: 0.8,\n cursor: 'not-allowed !important',\n },\n '&:hover': {\n borderColor: color.primary(),\n '&:disabled': {\n borderColor: 'initial',\n },\n },\n '&:focus': {\n borderColor: color.primaryDark(),\n },\n },\n crInput: {\n padding: '8px !important',\n },\n correct: correctStyle(color.correct()),\n incorrect: correctStyle(color.incorrect()),\n box: {\n fontSize: 'inherit',\n },\n outlinedInput: {\n padding: '2px',\n borderRadius: '4px',\n '& fieldset': {\n border: 0,\n },\n },\n notchedOutline: {\n borderColor: color.correct(),\n },\n}))((props) => {\n const {\n correct,\n charactersLimit,\n classes,\n disabled,\n isBox,\n isConstructedResponse,\n width,\n spellCheck,\n ...rest\n } = props;\n const label = typeof correct === 'boolean' ? (correct ? 'correct' : 'incorrect') : undefined;\n const inputProps = charactersLimit ? { maxLength: charactersLimit } : {};\n\n if (width) {\n inputProps.style = {\n width: `${width + Math.round(width / 10) + 1}ch`, // added some extra space for capital letters\n };\n }\n\n return (\n <OutlinedInput\n className={classnames({\n [classes.disabledInput]: disabled,\n [classes.box]: isBox,\n [classes.outlinedInput]: true,\n })}\n classes={{\n input: classnames({\n [classes.input]: true,\n [classes[label]]: label,\n [classes.crInput]: isConstructedResponse,\n }),\n }}\n inputProps={inputProps}\n labelWidth={0}\n disabled={disabled}\n spellCheck={spellCheck}\n {...rest}\n />\n );\n});\n"],"file":"correct-input.js"}
1
+ {"version":3,"sources":["../../src/components/correct-input.jsx"],"names":["correctStyle","color","borderColor","input","text","backgroundColor","background","borderRadius","borderWidth","borderStyle","padding","opacity","cursor","primary","primaryDark","crInput","correct","incorrect","box","fontSize","display","verticalAlign","outlinedInput","border","notchedOutline","props","charactersLimit","classes","disabled","isBox","isConstructedResponse","width","spellCheck","rest","label","undefined","inputProps","maxLength","style","Math","round","disabledInput"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;AAAA,SAAY;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AEM,UAbd;AAcE,IAAA,UAAU,EAAE,CAdd;AAeE,IAAA,QAAQ,EAAER,QAfZ;AAgBE,IAAA,UAAU,EAAEI;AAhBd,KAiBMC,IAjBN,EADF;AAqBD,CAvFc,C","sourcesContent":["import React from 'react';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport classnames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { color } from '@pie-lib/render-ui';\n\nconst correctStyle = (color) => ({\n borderColor: `${color} !important`,\n});\n\nexport default withStyles(() => ({\n input: {\n color: color.text(),\n backgroundColor: color.background(),\n borderRadius: '4px !important',\n borderWidth: '1px',\n borderStyle: 'solid',\n padding: '10px 20px 10px 10px',\n '&:disabled': {\n opacity: 0.8,\n cursor: 'not-allowed !important',\n },\n '&:hover': {\n borderColor: color.primary(),\n '&:disabled': {\n borderColor: 'initial',\n },\n },\n '&:focus': {\n borderColor: color.primaryDark(),\n },\n },\n crInput: {\n padding: '8px !important',\n },\n correct: correctStyle(color.correct()),\n incorrect: correctStyle(color.incorrect()),\n box: {\n fontSize: 'inherit',\n display: 'inline-block',\n verticalAlign: 'middle',\n },\n outlinedInput: {\n padding: '2px',\n borderRadius: '4px',\n '& fieldset': {\n border: 0,\n },\n },\n notchedOutline: {\n borderColor: color.correct(),\n },\n}))((props) => {\n const {\n correct,\n charactersLimit,\n classes,\n disabled,\n isBox,\n isConstructedResponse,\n width,\n spellCheck,\n ...rest\n } = props;\n\n const label = typeof correct === 'boolean' ? (correct ? 'correct' : 'incorrect') : undefined;\n const inputProps = charactersLimit\n ? { maxLength: charactersLimit, 'aria-label': 'Enter answer' }\n : { 'aria-label': 'Enter answer' };\n\n if (width) {\n inputProps.style = {\n width: `${width + Math.round(width / 10) + 1}ch`, // added some extra space for capital letters\n };\n }\n\n return (\n <OutlinedInput\n className={classnames({\n [classes.disabledInput]: disabled,\n [classes.box]: isBox,\n [classes.outlinedInput]: true,\n })}\n classes={{\n input: classnames({\n [classes.input]: true,\n [classes[label]]: label,\n [classes.crInput]: isConstructedResponse,\n }),\n }}\n inputProps={inputProps}\n labelWidth={0}\n disabled={disabled}\n spellCheck={spellCheck}\n {...rest}\n />\n );\n});\n"],"file":"correct-input.js"}