@pie-lib/mask-markup 1.10.20 → 1.10.21-next.185
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.
- package/CHANGELOG.json +45 -0
- package/CHANGELOG.md +13 -102
- package/lib/choices/choice.js +25 -17
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +17 -15
- package/lib/choices/index.js.map +1 -1
- package/lib/components/blank.js +33 -22
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +27 -4
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +27 -17
- package/lib/components/dropdown.js.map +1 -1
- package/lib/components/input.js +8 -2
- package/lib/components/input.js.map +1 -1
- package/lib/constructed-response.js +10 -4
- package/lib/constructed-response.js.map +1 -1
- package/lib/drag-in-the-blank.js +19 -17
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +12 -12
- package/lib/inline-dropdown.js +1 -1
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +47 -26
- package/lib/mask.js.map +1 -1
- package/lib/serialization.js +13 -4
- package/lib/serialization.js.map +1 -1
- package/lib/with-mask.js +19 -15
- package/lib/with-mask.js.map +1 -1
- package/package.json +2 -2
- package/src/choices/choice.jsx +5 -1
- package/src/components/blank.jsx +6 -1
- package/src/components/correct-input.jsx +29 -2
- package/src/components/dropdown.jsx +11 -1
- package/src/components/input.jsx +15 -1
- package/src/constructed-response.jsx +5 -1
- package/src/mask.jsx +14 -1
- package/src/serialization.js +8 -1
package/lib/components/blank.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports["default"] = exports.
|
|
8
|
+
exports["default"] = exports.DRAG_TYPE = exports.BlankContent = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
@@ -25,33 +27,37 @@ var _classnames3 = _interopRequireDefault(require("classnames"));
|
|
|
25
27
|
|
|
26
28
|
var _renderUi = require("@pie-lib/render-ui");
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
var _excluded = ["connectDragSource", "connectDropTarget"];
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
33
|
|
|
32
34
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
33
35
|
|
|
34
36
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
35
37
|
|
|
36
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
38
|
+
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; }
|
|
37
39
|
|
|
38
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
40
|
+
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) { _defineProperty(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; }
|
|
39
41
|
|
|
40
42
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
43
|
|
|
42
44
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
45
|
|
|
44
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
46
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
45
47
|
|
|
46
|
-
function
|
|
48
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
49
|
|
|
48
|
-
function
|
|
50
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
51
|
|
|
50
|
-
function
|
|
52
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
53
|
|
|
52
|
-
function
|
|
54
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
53
55
|
|
|
54
|
-
function
|
|
56
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
57
|
+
|
|
58
|
+
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; } }
|
|
59
|
+
|
|
60
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
61
|
|
|
56
62
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
63
|
|
|
@@ -68,11 +74,16 @@ var useStyles = (0, _styles.withStyles)(function () {
|
|
|
68
74
|
minWidth: '90px',
|
|
69
75
|
fontSize: 'inherit',
|
|
70
76
|
minHeight: '32px',
|
|
77
|
+
height: 'auto',
|
|
71
78
|
maxWidth: '374px',
|
|
72
79
|
position: 'relative'
|
|
73
80
|
},
|
|
74
81
|
chipLabel: {
|
|
75
|
-
whiteSpace: 'pre-wrap'
|
|
82
|
+
whiteSpace: 'pre-wrap',
|
|
83
|
+
'& img': {
|
|
84
|
+
display: 'block',
|
|
85
|
+
padding: '2px 0'
|
|
86
|
+
}
|
|
76
87
|
},
|
|
77
88
|
hidden: {
|
|
78
89
|
color: 'transparent',
|
|
@@ -96,17 +107,17 @@ var useStyles = (0, _styles.withStyles)(function () {
|
|
|
96
107
|
};
|
|
97
108
|
});
|
|
98
109
|
|
|
99
|
-
var BlankContent =
|
|
100
|
-
/*#__PURE__*/
|
|
101
|
-
function (_React$Component) {
|
|
110
|
+
var BlankContent = /*#__PURE__*/function (_React$Component) {
|
|
102
111
|
_inherits(BlankContent, _React$Component);
|
|
103
112
|
|
|
113
|
+
var _super = _createSuper(BlankContent);
|
|
114
|
+
|
|
104
115
|
function BlankContent() {
|
|
105
116
|
var _this;
|
|
106
117
|
|
|
107
118
|
_classCallCheck(this, BlankContent);
|
|
108
119
|
|
|
109
|
-
_this =
|
|
120
|
+
_this = _super.call(this);
|
|
110
121
|
_this.state = {
|
|
111
122
|
height: 0
|
|
112
123
|
};
|
|
@@ -161,13 +172,13 @@ function (_React$Component) {
|
|
|
161
172
|
correct = _this$props.correct;
|
|
162
173
|
var draggedLabel = dragItem && isOver && dragItem.choice.value;
|
|
163
174
|
var label = choice && choice.value;
|
|
164
|
-
return _react["default"].createElement(_Chip["default"], {
|
|
175
|
+
return /*#__PURE__*/_react["default"].createElement(_Chip["default"], {
|
|
165
176
|
ref: function ref(_ref3) {
|
|
166
177
|
//eslint-disable-next-line
|
|
167
178
|
_this3.rootRef = _reactDom["default"].findDOMNode(_ref3);
|
|
168
179
|
},
|
|
169
180
|
component: "span",
|
|
170
|
-
label: _react["default"].createElement(_react["default"].Fragment, null, _react["default"].createElement("span", {
|
|
181
|
+
label: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
171
182
|
className: (0, _classnames3["default"])(classes.chipLabel, isOver && classes.over, _defineProperty({}, classes.hidden, draggedLabel)),
|
|
172
183
|
ref: function ref(_ref) {
|
|
173
184
|
if (_ref) {
|
|
@@ -178,7 +189,7 @@ function (_React$Component) {
|
|
|
178
189
|
_this3.addDraggableFalseAttributes(_ref);
|
|
179
190
|
}
|
|
180
191
|
}
|
|
181
|
-
}, ' '), draggedLabel && _react["default"].createElement("span", {
|
|
192
|
+
}, ' '), draggedLabel && /*#__PURE__*/_react["default"].createElement("span", {
|
|
182
193
|
className: (0, _classnames3["default"])(classes.chipLabel, isOver && classes.over, classes.dragged),
|
|
183
194
|
ref: function ref(_ref2) {
|
|
184
195
|
if (_ref2) {
|
|
@@ -223,13 +234,13 @@ var StyledBlankContent = useStyles(BlankContent);
|
|
|
223
234
|
var connectedBlankContent = useStyles(function (_ref4) {
|
|
224
235
|
var connectDragSource = _ref4.connectDragSource,
|
|
225
236
|
connectDropTarget = _ref4.connectDropTarget,
|
|
226
|
-
props = _objectWithoutProperties(_ref4,
|
|
237
|
+
props = _objectWithoutProperties(_ref4, _excluded);
|
|
227
238
|
|
|
228
239
|
var classes = props.classes,
|
|
229
240
|
isOver = props.isOver;
|
|
230
|
-
return connectDropTarget(connectDragSource(_react["default"].createElement("span", {
|
|
241
|
+
return connectDropTarget(connectDragSource( /*#__PURE__*/_react["default"].createElement("span", {
|
|
231
242
|
className: (0, _classnames3["default"])(classes.content, isOver && classes.over)
|
|
232
|
-
}, _react["default"].createElement(StyledBlankContent, props))));
|
|
243
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledBlankContent, props))));
|
|
233
244
|
});
|
|
234
245
|
var tileTarget = {
|
|
235
246
|
drop: function drop(props, monitor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/blank.jsx"],"names":["log","DRAG_TYPE","useStyles","content","border","color","primary","minWidth","chip","fontSize","minHeight","maxWidth","position","chipLabel","whiteSpace","hidden","opacity","dragged","left","correct","incorrect","over","overflow","BlankContent","state","height","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;AAFH,KADyB;AAKlCC,IAAAA,IAAI,EAAE;AACJD,MAAAA,QAAQ,EAAE,MADN;AAEJE,MAAAA,QAAQ,EAAE,SAFN;AAGJC,MAAAA,SAAS,EAAE,MAHP;AAIJC,MAAAA,QAAQ,EAAE,OAJN;AAKJC,MAAAA,QAAQ,EAAE;AALN,KAL4B;AAYlCC,IAAAA,SAAS,EAAE;AACTC,MAAAA,UAAU,EAAE;AADH,KAZuB;AAelCC,IAAAA,MAAM,EAAE;AACNV,MAAAA,KAAK,EAAE,aADD;AAENW,MAAAA,OAAO,EAAE;AAFH,KAf0B;AAmBlCC,IAAAA,OAAO,EAAE;AACPL,MAAAA,QAAQ,EAAE,UADH;AAEPM,MAAAA,IAAI,EAAE,EAFC;AAGPP,MAAAA,QAAQ,EAA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evC,KAAK,CAAC+B,EAArB,EAAyBH,SAAzB;AACD;AACF;AACF;AAvBgB,CAAnB;AA0BA,IAAMmC,YAAY,GAAG,sBAAW3F,SAAX,EAAsBoF,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 },\n chip: {\n minWidth: '90px',\n fontSize: 'inherit',\n minHeight: '32px',\n maxWidth: '374px',\n position: 'relative'\n },\n chipLabel: {\n whiteSpace: 'pre-wrap'\n },\n hidden: {\n color: 'transparent',\n opacity: 0\n },\n dragged: {\n position: 'absolute',\n left: 14,\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 <Chip\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","chip","fontSize","minHeight","height","maxWidth","position","chipLabel","whiteSpace","display","padding","hidden","opacity","dragged","left","correct","incorrect","over","overflow","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;AAFH,KADyB;AAKlCC,IAAAA,IAAI,EAAE;AACJD,MAAAA,QAAQ,EAAE,MADN;AAEJE,MAAAA,QAAQ,EAAE,SAFN;AAGJC,MAAAA,SAAS,EAAE,MAHP;AAIJC,MAAAA,MAAM,EAAE,MAJJ;AAKJC,MAAAA,QAAQ,EAAE,OALN;AAMJC,MAAAA,QAAQ,EAAE;AANN,KAL4B;AAalCC,IAAAA,SAAS,EAAE;AACTC,MAAAA,UAAU,EAAE,UADH;AAET,eAAS;AACPC,QAAAA,OAAO,EAAE,OADF;AAEPC,QAAAA,OAAO,EAAE;AAFF;AAFA,KAbuB;AAoBlCC,IAAAA,MAAM,EAAE;AACNb,MAAAA,KAAK,EAAE,aADD;AAENc,MAAAA,OAAO,EAAE;AAFH,KApB0B;AAwBlCC,IAAAA,OAAO,EAAE;AACPP,MAAAA,QAAQ,EAAE,UADH;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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,sBAAW7F,SAAX,EAAsBsF,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 },\n chip: {\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 '& 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: 14,\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 <Chip\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"}
|
|
@@ -15,6 +15,8 @@ var _styles = require("@material-ui/core/styles");
|
|
|
15
15
|
|
|
16
16
|
var _renderUi = require("@pie-lib/render-ui");
|
|
17
17
|
|
|
18
|
+
var _excluded = ["correct", "charactersLimit", "classes", "disabled", "isBox", "isConstructedResponse", "width"];
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
22
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -36,6 +38,7 @@ var _default = (0, _styles.withStyles)(function () {
|
|
|
36
38
|
input: {
|
|
37
39
|
color: _renderUi.color.text(),
|
|
38
40
|
backgroundColor: _renderUi.color.background(),
|
|
41
|
+
borderRadius: '4px !important',
|
|
39
42
|
borderWidth: '1px',
|
|
40
43
|
borderStyle: 'solid',
|
|
41
44
|
padding: '10px 20px 10px 10px',
|
|
@@ -53,12 +56,17 @@ var _default = (0, _styles.withStyles)(function () {
|
|
|
53
56
|
borderColor: _renderUi.color.primaryDark()
|
|
54
57
|
}
|
|
55
58
|
},
|
|
59
|
+
crInput: {
|
|
60
|
+
padding: '8px !important'
|
|
61
|
+
},
|
|
56
62
|
correct: correctStyle(_renderUi.color.correct()),
|
|
57
63
|
incorrect: correctStyle(_renderUi.color.incorrect()),
|
|
58
64
|
box: {
|
|
59
65
|
fontSize: 'inherit'
|
|
60
66
|
},
|
|
61
67
|
outlinedInput: {
|
|
68
|
+
padding: '2px',
|
|
69
|
+
borderRadius: '4px',
|
|
62
70
|
'& fieldset': {
|
|
63
71
|
border: 0
|
|
64
72
|
}
|
|
@@ -71,17 +79,32 @@ var _default = (0, _styles.withStyles)(function () {
|
|
|
71
79
|
var _classnames, _classnames2;
|
|
72
80
|
|
|
73
81
|
var correct = props.correct,
|
|
74
|
-
|
|
82
|
+
charactersLimit = props.charactersLimit,
|
|
75
83
|
classes = props.classes,
|
|
76
84
|
disabled = props.disabled,
|
|
77
|
-
|
|
85
|
+
isBox = props.isBox,
|
|
86
|
+
isConstructedResponse = props.isConstructedResponse,
|
|
87
|
+
width = props.width,
|
|
88
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
78
89
|
|
|
79
90
|
var label = typeof correct === 'boolean' ? correct ? 'correct' : 'incorrect' : undefined;
|
|
80
|
-
|
|
91
|
+
var inputProps = charactersLimit ? {
|
|
92
|
+
maxLength: charactersLimit
|
|
93
|
+
} : {};
|
|
94
|
+
|
|
95
|
+
if (width) {
|
|
96
|
+
inputProps.style = {
|
|
97
|
+
width: "".concat(width + Math.round(width / 10) + 1, "ch") // added some extra space for capital letters
|
|
98
|
+
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return /*#__PURE__*/_react["default"].createElement(_OutlinedInput["default"], _extends({
|
|
81
103
|
className: (0, _classnames3["default"])((_classnames = {}, _defineProperty(_classnames, classes.disabledInput, disabled), _defineProperty(_classnames, classes.box, isBox), _defineProperty(_classnames, classes.outlinedInput, true), _classnames)),
|
|
82
104
|
classes: {
|
|
83
|
-
input: (0, _classnames3["default"])((_classnames2 = {}, _defineProperty(_classnames2, classes.input, true), _defineProperty(_classnames2, classes[label], label), _classnames2))
|
|
105
|
+
input: (0, _classnames3["default"])((_classnames2 = {}, _defineProperty(_classnames2, classes.input, true), _defineProperty(_classnames2, classes[label], label), _defineProperty(_classnames2, classes.crInput, isConstructedResponse), _classnames2))
|
|
84
106
|
},
|
|
107
|
+
inputProps: inputProps,
|
|
85
108
|
labelWidth: 0,
|
|
86
109
|
disabled: disabled
|
|
87
110
|
}, rest));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/correct-input.jsx"],"names":["correctStyle","color","borderColor","input","text","backgroundColor","background","borderWidth","borderStyle","padding","opacity","cursor","primary","primaryDark","correct","incorrect","box","fontSize","outlinedInput","border","notchedOutline","props","
|
|
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","rest","label","undefined","inputProps","maxLength","style","Math","round","disabledInput"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAAAC,KAAK;AAAA,SAAK;AAC7BC,IAAAA,WAAW,YAAKD,KAAL;AADkB,GAAL;AAAA,CAA1B;;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,OAAO,EAAE,qBANJ;AAOL,oBAAc;AACZC,QAAAA,OAAO,EAAE,GADG;AAEZC,QAAAA,MAAM,EAAE;AAFI,OAPT;AAWL,iBAAW;AACTV,QAAAA,WAAW,EAAED,gBAAMY,OAAN,EADJ;AAET,sBAAc;AACZX,UAAAA,WAAW,EAAE;AADD;AAFL,OAXN;AAiBL,iBAAW;AACTA,QAAAA,WAAW,EAAED,gBAAMa,WAAN;AADJ;AAjBN,KADwB;AAsB/BC,IAAAA,OAAO,EAAE;AACPL,MAAAA,OAAO,EAAE;AADF,KAtBsB;AAyB/BM,IAAAA,OAAO,EAAEhB,YAAY,CAACC,gBAAMe,OAAN,EAAD,CAzBU;AA0B/BC,IAAAA,SAAS,EAAEjB,YAAY,CAACC,gBAAMgB,SAAN,EAAD,CA1BQ;AA2B/BC,IAAAA,GAAG,EAAE;AACHC,MAAAA,QAAQ,EAAE;AADP,KA3B0B;AA8B/BC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,EAAE,+EACJsB,OAAO,CAACtB,KADJ,EACY,IADZ,iCAEJsB,OAAO,CAACM,KAAD,CAFH,EAEaA,KAFb,iCAGJN,OAAO,CAACV,OAHJ,EAGca,qBAHd;AADA,KANX;AAaE,IAAA,UAAU,EAAEK,UAbd;AAcE,IAAA,UAAU,EAAE,CAdd;AAeE,IAAA,QAAQ,EAAEP;AAfZ,KAgBMI,IAhBN,EADF;AAoBD,CAhFc,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 ...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 {...rest}\n />\n );\n});\n"],"file":"correct-input.js"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -21,37 +23,39 @@ var _renderUi = require("@pie-lib/render-ui");
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
25
|
-
|
|
26
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
27
|
|
|
28
28
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
29
|
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
39
|
|
|
36
40
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
41
|
|
|
38
|
-
function
|
|
42
|
+
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; } }
|
|
39
43
|
|
|
40
|
-
function
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
45
|
|
|
42
46
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
47
|
|
|
44
|
-
var Dropdown =
|
|
45
|
-
/*#__PURE__*/
|
|
46
|
-
function (_React$Component) {
|
|
48
|
+
var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
47
49
|
_inherits(Dropdown, _React$Component);
|
|
48
50
|
|
|
51
|
+
var _super = _createSuper(Dropdown);
|
|
52
|
+
|
|
49
53
|
function Dropdown(props) {
|
|
50
54
|
var _this;
|
|
51
55
|
|
|
52
56
|
_classCallCheck(this, Dropdown);
|
|
53
57
|
|
|
54
|
-
_this =
|
|
58
|
+
_this = _super.call(this, props);
|
|
55
59
|
|
|
56
60
|
_defineProperty(_assertThisInitialized(_this), "showCheckmarkAndOpen", function () {
|
|
57
61
|
_this.setState({
|
|
@@ -89,18 +93,19 @@ function (_React$Component) {
|
|
|
89
93
|
var _this$state = this.state,
|
|
90
94
|
showCheckmark = _this$state.showCheckmark,
|
|
91
95
|
open = _this$state.open;
|
|
92
|
-
return _react["default"].createElement(_Select["default"], {
|
|
96
|
+
return /*#__PURE__*/_react["default"].createElement(_Select["default"], {
|
|
93
97
|
classes: {
|
|
94
98
|
root: classes.root,
|
|
95
99
|
icon: classes.icon,
|
|
96
|
-
selectMenu: classes.selectMenu
|
|
100
|
+
selectMenu: classes.selectMenu,
|
|
101
|
+
select: classes.select
|
|
97
102
|
},
|
|
98
103
|
disabled: disabled,
|
|
99
104
|
value: value || '',
|
|
100
105
|
onOpen: this.showCheckmarkAndOpen,
|
|
101
106
|
onClose: this.hideCheckmarkAndClose,
|
|
102
107
|
open: open,
|
|
103
|
-
input: _react["default"].createElement(_correctInput["default"], {
|
|
108
|
+
input: /*#__PURE__*/_react["default"].createElement(_correctInput["default"], {
|
|
104
109
|
correct: showCorrectAnswer || correct
|
|
105
110
|
}),
|
|
106
111
|
MenuProps: {
|
|
@@ -111,19 +116,19 @@ function (_React$Component) {
|
|
|
111
116
|
_onChange(id, e.target.value);
|
|
112
117
|
}
|
|
113
118
|
}, (choices || []).map(function (c, index) {
|
|
114
|
-
return _react["default"].createElement(_MenuItem["default"], {
|
|
119
|
+
return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
115
120
|
classes: {
|
|
116
121
|
root: classes.menuRoot,
|
|
117
122
|
selected: classes.selected
|
|
118
123
|
},
|
|
119
124
|
key: "".concat(c.label, "-").concat(index),
|
|
120
125
|
value: c.value
|
|
121
|
-
}, _react["default"].createElement("span", {
|
|
126
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
122
127
|
className: classes.label,
|
|
123
128
|
dangerouslySetInnerHTML: {
|
|
124
129
|
__html: c.label
|
|
125
130
|
}
|
|
126
|
-
}), showCheckmark && _react["default"].createElement("span", {
|
|
131
|
+
}), showCheckmark && /*#__PURE__*/_react["default"].createElement("span", {
|
|
127
132
|
className: classes.label,
|
|
128
133
|
dangerouslySetInnerHTML: {
|
|
129
134
|
__html: c.value === value ? ' ✓' : ''
|
|
@@ -165,6 +170,11 @@ var styles = function styles() {
|
|
|
165
170
|
backgroundColor: _renderUi.color.background()
|
|
166
171
|
}
|
|
167
172
|
},
|
|
173
|
+
select: {
|
|
174
|
+
'&:focus': {
|
|
175
|
+
borderRadius: '4px'
|
|
176
|
+
}
|
|
177
|
+
},
|
|
168
178
|
selectMenu: {
|
|
169
179
|
backgroundColor: _renderUi.color.background(),
|
|
170
180
|
'&:hover': {
|
|
@@ -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","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":"
|
|
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;;;;;AAcJ,oBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,2EASI,YAAM;AAC3B,YAAKC,QAAL,CAAc;AACZC,QAAAA,aAAa,EAAE,IADH;AAEZC,QAAAA,IAAI,EAAE;AAFM,OAAd;AAID,KAdkB;;AAAA,4EAgBK,YAAM;AAC5B,YAAKF,QAAL,CAAc;AACZC,QAAAA,aAAa,EAAE,KADH;AAEZC,QAAAA,IAAI,EAAE;AAFM,OAAd;AAID,KArBkB;;AAGjB,UAAKC,KAAL,GAAa;AACXF,MAAAA,aAAa,EAAE,KADJ;AAEXC,MAAAA,IAAI,EAAE;AAFK,KAAb;AAHiB;AAOlB;;;;WAgBD,kBAAS;AACP,wBASI,KAAKH,KATT;AAAA,UACEK,OADF,eACEA,OADF;AAAA,UAEEC,EAFF,eAEEA,EAFF;AAAA,UAGEC,OAHF,eAGEA,OAHF;AAAA,UAIEC,QAJF,eAIEA,QAJF;AAAA,UAKEC,KALF,eAKEA,KALF;AAAA,UAMEC,SANF,eAMEA,QANF;AAA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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(\n PropTypes.shape({ value: PropTypes.string, label: PropTypes.string })\n ),\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 {\n classes,\n id,\n correct,\n disabled,\n value,\n onChange,\n choices,\n showCorrectAnswer\n } = 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 ? ' ✓' : '' }}\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"}
|
package/lib/components/input.js
CHANGED
|
@@ -16,16 +16,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
16
16
|
var Input = function Input(_ref) {
|
|
17
17
|
var disabled = _ref.disabled,
|
|
18
18
|
correct = _ref.correct,
|
|
19
|
+
charactersLimit = _ref.charactersLimit,
|
|
19
20
|
id = _ref.id,
|
|
21
|
+
isConstructedResponse = _ref.isConstructedResponse,
|
|
20
22
|
value = _ref.value,
|
|
21
23
|
_onChange = _ref.onChange,
|
|
22
|
-
showCorrectAnswer = _ref.showCorrectAnswer
|
|
23
|
-
|
|
24
|
+
showCorrectAnswer = _ref.showCorrectAnswer,
|
|
25
|
+
width = _ref.width;
|
|
26
|
+
return /*#__PURE__*/_react["default"].createElement(_correctInput["default"], {
|
|
24
27
|
disabled: disabled,
|
|
25
28
|
correct: showCorrectAnswer || correct,
|
|
29
|
+
charactersLimit: charactersLimit,
|
|
26
30
|
variant: "outlined",
|
|
27
31
|
value: value,
|
|
32
|
+
isConstructedResponse: isConstructedResponse,
|
|
28
33
|
isBox: true,
|
|
34
|
+
width: width,
|
|
29
35
|
onChange: function onChange(e) {
|
|
30
36
|
_onChange(id, e.target.value);
|
|
31
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/input.jsx"],"names":["Input","disabled","correct","id","value","onChange","showCorrectAnswer","e","target","propTypes","PropTypes","string","func","bool"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/components/input.jsx"],"names":["Input","disabled","correct","charactersLimit","id","isConstructedResponse","value","onChange","showCorrectAnswer","width","e","target","propTypes","PropTypes","string","func","bool"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,OAUR;AAAA,MATJC,QASI,QATJA,QASI;AAAA,MARJC,OAQI,QARJA,OAQI;AAAA,MAPJC,eAOI,QAPJA,eAOI;AAAA,MANJC,EAMI,QANJA,EAMI;AAAA,MALJC,qBAKI,QALJA,qBAKI;AAAA,MAJJC,KAII,QAJJA,KAII;AAAA,MAHJC,SAGI,QAHJA,QAGI;AAAA,MAFJC,iBAEI,QAFJA,iBAEI;AAAA,MADJC,KACI,QADJA,KACI;AACJ,sBACE,gCAAC,wBAAD;AACE,IAAA,QAAQ,EAAER,QADZ;AAEE,IAAA,OAAO,EAAEO,iBAAiB,IAAIN,OAFhC;AAGE,IAAA,eAAe,EAAEC,eAHnB;AAIE,IAAA,OAAO,EAAC,UAJV;AAKE,IAAA,KAAK,EAAEG,KALT;AAME,IAAA,qBAAqB,EAAED,qBANzB;AAOE,IAAA,KAAK,EAAE,IAPT;AAQE,IAAA,KAAK,EAAEI,KART;AASE,IAAA,QAAQ,EAAE,kBAAAC,CAAC,EAAI;AACbH,MAAAA,SAAQ,CAACH,EAAD,EAAKM,CAAC,CAACC,MAAF,CAASL,KAAd,CAAR;AACD;AAXH,IADF;AAeD,CA1BD;;AA4BAN,KAAK,CAACY,SAAN,GAAkB;AAChBR,EAAAA,EAAE,EAAES,sBAAUC,MADE;AAEhBR,EAAAA,KAAK,EAAEO,sBAAUC,MAFD;AAGhBP,EAAAA,QAAQ,EAAEM,sBAAUE,IAHJ;AAIhBd,EAAAA,QAAQ,EAAEY,sBAAUG,IAJJ;AAKhBd,EAAAA,OAAO,EAAEW,sBAAUG,IALH;AAMhBR,EAAAA,iBAAiB,EAAEK,sBAAUG;AANb,CAAlB;eASehB,K","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectInput from './correct-input';\n\nconst Input = ({\n disabled,\n correct,\n charactersLimit,\n id,\n isConstructedResponse,\n value,\n onChange,\n showCorrectAnswer,\n width\n}) => {\n return (\n <CorrectInput\n disabled={disabled}\n correct={showCorrectAnswer || correct}\n charactersLimit={charactersLimit}\n variant=\"outlined\"\n value={value}\n isConstructedResponse={isConstructedResponse}\n isBox={true}\n width={width}\n onChange={e => {\n onChange(id, e.target.value);\n }}\n />\n );\n};\n\nInput.propTypes = {\n id: PropTypes.string,\n value: PropTypes.string,\n onChange: PropTypes.func,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n showCorrectAnswer: PropTypes.bool\n};\n\nexport default Input;\n"],"file":"input.js"}
|
|
@@ -18,20 +18,26 @@ var _default = (0, _withMask.withMask)('input', function (props) {
|
|
|
18
18
|
var dataset = node.data ? node.data.dataset || {} : {};
|
|
19
19
|
|
|
20
20
|
if (dataset.component === 'input') {
|
|
21
|
-
var
|
|
21
|
+
var adjustedLimit = props.adjustedLimit,
|
|
22
|
+
disabled = props.disabled,
|
|
22
23
|
feedback = props.feedback,
|
|
23
|
-
showCorrectAnswer = props.showCorrectAnswer
|
|
24
|
+
showCorrectAnswer = props.showCorrectAnswer,
|
|
25
|
+
maxLength = props.maxLength; // the first answer is the correct one
|
|
24
26
|
|
|
25
27
|
var correctAnswer = (props.choices && dataset && props.choices[dataset.id] || [])[0];
|
|
26
28
|
var finalValue = showCorrectAnswer ? correctAnswer && correctAnswer.label : data[dataset.id] || '';
|
|
27
|
-
|
|
29
|
+
var width = maxLength && maxLength[dataset.id];
|
|
30
|
+
return /*#__PURE__*/_react["default"].createElement(_input["default"], {
|
|
28
31
|
key: "".concat(node.type, "-input-").concat(dataset.id),
|
|
29
32
|
correct: feedback && feedback[dataset.id] && feedback[dataset.id] === 'correct',
|
|
30
33
|
disabled: showCorrectAnswer || disabled,
|
|
31
34
|
value: finalValue,
|
|
32
35
|
id: dataset.id,
|
|
33
36
|
onChange: onChange,
|
|
34
|
-
showCorrectAnswer: showCorrectAnswer
|
|
37
|
+
showCorrectAnswer: showCorrectAnswer,
|
|
38
|
+
width: width,
|
|
39
|
+
charactersLimit: adjustedLimit ? width : 25,
|
|
40
|
+
isConstructedResponse: true
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constructed-response.jsx"],"names":["props","node","data","onChange","dataset","component","disabled","feedback","showCorrectAnswer","correctAnswer","choices","id","finalValue","label","type"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;eAEe,wBAAS,OAAT,EAAkB,UAAAA,KAAK;AAAA,SAAI,UAACC,IAAD,EAAOC,IAAP,EAAaC,QAAb,EAA0B;AAClE,QAAMC,OAAO,GAAGH,IAAI,CAACC,IAAL,GAAYD,IAAI,CAACC,IAAL,CAAUE,OAAV,IAAqB,EAAjC,GAAsC,EAAtD;;AACA,QAAIA,OAAO,CAACC,SAAR,KAAsB,OAA1B,EAAmC;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/constructed-response.jsx"],"names":["props","node","data","onChange","dataset","component","adjustedLimit","disabled","feedback","showCorrectAnswer","maxLength","correctAnswer","choices","id","finalValue","label","width","type"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;eAEe,wBAAS,OAAT,EAAkB,UAAAA,KAAK;AAAA,SAAI,UAACC,IAAD,EAAOC,IAAP,EAAaC,QAAb,EAA0B;AAClE,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,UAAQC,aAAR,GAA4EN,KAA5E,CAAQM,aAAR;AAAA,UAAuBC,QAAvB,GAA4EP,KAA5E,CAAuBO,QAAvB;AAAA,UAAiCC,QAAjC,GAA4ER,KAA5E,CAAiCQ,QAAjC;AAAA,UAA2CC,iBAA3C,GAA4ET,KAA5E,CAA2CS,iBAA3C;AAAA,UAA8DC,SAA9D,GAA4EV,KAA5E,CAA8DU,SAA9D,CADiC,CAEjC;;AACA,UAAMC,aAAa,GAAG,CAAEX,KAAK,CAACY,OAAN,IAAiBR,OAAjB,IAA4BJ,KAAK,CAACY,OAAN,CAAcR,OAAO,CAACS,EAAtB,CAA7B,IAA2D,EAA5D,EAAgE,CAAhE,CAAtB;AACA,UAAMC,UAAU,GAAGL,iBAAiB,GAChCE,aAAa,IAAIA,aAAa,CAACI,KADC,GAEhCb,IAAI,CAACE,OAAO,CAACS,EAAT,CAAJ,IAAoB,EAFxB;AAGA,UAAMG,KAAK,GAAGN,SAAS,IAAIA,SAAS,CAACN,OAAO,CAACS,EAAT,CAApC;AAEA,0BACE,gCAAC,iBAAD;AACE,QAAA,GAAG,YAAKZ,IAAI,CAACgB,IAAV,oBAAwBb,OAAO,CAACS,EAAhC,CADL;AAEE,QAAA,OAAO,EAAEL,QAAQ,IAAIA,QAAQ,CAACJ,OAAO,CAACS,EAAT,CAApB,IAAoCL,QAAQ,CAACJ,OAAO,CAACS,EAAT,CAAR,KAAyB,SAFxE;AAGE,QAAA,QAAQ,EAAEJ,iBAAiB,IAAIF,QAHjC;AAIE,QAAA,KAAK,EAAEO,UAJT;AAKE,QAAA,EAAE,EAAEV,OAAO,CAACS,EALd;AAME,QAAA,QAAQ,EAAEV,QANZ;AAOE,QAAA,iBAAiB,EAAEM,iBAPrB;AAQE,QAAA,KAAK,EAAEO,KART;AASE,QAAA,eAAe,EAAEV,aAAa,GAAGU,KAAH,GAAW,EAT3C;AAUE,QAAA,qBAAqB,EAAE;AAVzB,QADF;AAcD;AACF,GA1BqC;AAAA,CAAvB,C","sourcesContent":["import React from 'react';\nimport Input from './components/input';\nimport { withMask } from './with-mask';\n\nexport default withMask('input', props => (node, data, onChange) => {\n const dataset = node.data ? node.data.dataset || {} : {};\n if (dataset.component === 'input') {\n const { adjustedLimit, disabled, feedback, showCorrectAnswer, maxLength } = props;\n // the first answer is the correct one\n const correctAnswer = ((props.choices && dataset && props.choices[dataset.id]) || [])[0];\n const finalValue = showCorrectAnswer\n ? correctAnswer && correctAnswer.label\n : 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 />\n );\n }\n});\n"],"file":"constructed-response.js"}
|