@pie-lib/math-toolbar 1.8.8 → 1.9.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,37 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.9.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.9.0...@pie-lib/math-toolbar@1.9.1) (2022-05-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **math-toolbar:** add sanity checks ([e012294](https://github.com/pie-framework/pie-lib/commit/e012294184b6f0c1472e6306be01e76e650c8fa5))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.9.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.8.9...@pie-lib/math-toolbar@1.9.0) (2022-05-03)
18
+
19
+
20
+ ### Features
21
+
22
+ * **math-toolbar:** add validation ui/ux for math-inline inputs PD-1705 ([cbc7205](https://github.com/pie-framework/pie-lib/commit/cbc72051deaefd76765cd60a387e47eebd0abc2f))
23
+ * **math-toolbar:** PD-1705 disable logic for add button in editor if maxResponseAreas is defined ([d68034c](https://github.com/pie-framework/pie-lib/commit/d68034cb4a2d24224f2c778fa4cf425ff157177a))
24
+
25
+
26
+
27
+
28
+
29
+ ## [1.8.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.8.8...@pie-lib/math-toolbar@1.8.9) (2022-04-12)
30
+
31
+ **Note:** Version bump only for package @pie-lib/math-toolbar
32
+
33
+
34
+
35
+
36
+
6
37
  ## [1.8.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/math-toolbar@1.8.7...@pie-lib/math-toolbar@1.8.8) (2022-02-04)
7
38
 
8
39
  **Note:** Version bump only for package @pie-lib/math-toolbar
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DoneButton = exports.RawDoneButton = void 0;
6
+ exports.RawDoneButton = exports.DoneButton = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -20,7 +20,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
20
20
  var RawDoneButton = function RawDoneButton(_ref) {
21
21
  var classes = _ref.classes,
22
22
  onClick = _ref.onClick;
23
- return _react["default"].createElement(_IconButton["default"], {
23
+ return /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
24
24
  "aria-label": "Done",
25
25
  className: classes.iconRoot,
26
26
  onClick: onClick,
@@ -28,7 +28,7 @@ var RawDoneButton = function RawDoneButton(_ref) {
28
28
  label: classes.label,
29
29
  root: classes.iconRoot
30
30
  }
31
- }, _react["default"].createElement(_Check["default"], null));
31
+ }, /*#__PURE__*/_react["default"].createElement(_Check["default"], null));
32
32
  };
33
33
 
34
34
  exports.RawDoneButton = RawDoneButton;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/done-button.jsx"],"names":["RawDoneButton","classes","onClick","iconRoot","label","root","propTypes","PropTypes","object","isRequired","func","styles","verticalAlign","width","height","color","position","top","DoneButton"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAAGC,OAAH,QAAGA,OAAH;AAAA,MAAYC,OAAZ,QAAYA,OAAZ;AAAA,SAC3B,gCAAC,sBAAD;AACE,kBAAW,MADb;AAEE,IAAA,SAAS,EAAED,OAAO,CAACE,QAFrB;AAGE,IAAA,OAAO,EAAED,OAHX;AAIE,IAAA,OAAO,EAAE;AACPE,MAAAA,KAAK,EAAEH,OAAO,CAACG,KADR;AAEPC,MAAAA,IAAI,EAAEJ,OAAO,CAACE;AAFP;AAJX,KASE,gCAAC,iBAAD,OATF,CAD2B;AAAA,CAAtB;;;AAcPH,aAAa,CAACM,SAAd,GAA0B;AACxBL,EAAAA,OAAO,EAAEM,sBAAUC,MAAV,CAAiBC,UADF;AAExBP,EAAAA,OAAO,EAAEK,sBAAUG;AAFK,CAA1B;AAKA,IAAMC,MAAM,GAAG;AACbR,EAAAA,QAAQ,EAAE;AACRS,IAAAA,aAAa,EAAE,KADP;AAERC,IAAAA,KAAK,EAAE,MAFC;AAGRC,IAAAA,MAAM,EAAE,MAHA;AAIRC,IAAAA,KAAK,EAAE;AAJC,GADG;AAObX,EAAAA,KAAK,EAAE;AACLY,IAAAA,QAAQ,EAAE,UADL;AAELC,IAAAA,GAAG,EAAE;AAFA;AAPM,CAAf;AAYO,IAAMC,UAAU,GAAG,wBAAWP,MAAX,EAAmBX,aAAnB,CAAnB","sourcesContent":["import React from 'react';\n\nimport IconButton from '@material-ui/core/IconButton';\nimport Check from '@material-ui/icons/Check';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\n\nexport const RawDoneButton = ({ classes, onClick }) => (\n <IconButton\n aria-label=\"Done\"\n className={classes.iconRoot}\n onClick={onClick}\n classes={{\n label: classes.label,\n root: classes.iconRoot\n }}\n >\n <Check />\n </IconButton>\n);\n\nRawDoneButton.propTypes = {\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func\n};\n\nconst styles = {\n iconRoot: {\n verticalAlign: 'top',\n width: '28px',\n height: '28px',\n color: '#00bb00'\n },\n label: {\n position: 'absolute',\n top: '2px'\n }\n};\nexport const DoneButton = withStyles(styles)(RawDoneButton);\n"],"file":"done-button.js"}
1
+ {"version":3,"sources":["../src/done-button.jsx"],"names":["RawDoneButton","classes","onClick","iconRoot","label","root","propTypes","PropTypes","object","isRequired","func","styles","verticalAlign","width","height","color","position","top","DoneButton"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAAGC,OAAH,QAAGA,OAAH;AAAA,MAAYC,OAAZ,QAAYA,OAAZ;AAAA,sBAC3B,gCAAC,sBAAD;AACE,kBAAW,MADb;AAEE,IAAA,SAAS,EAAED,OAAO,CAACE,QAFrB;AAGE,IAAA,OAAO,EAAED,OAHX;AAIE,IAAA,OAAO,EAAE;AACPE,MAAAA,KAAK,EAAEH,OAAO,CAACG,KADR;AAEPC,MAAAA,IAAI,EAAEJ,OAAO,CAACE;AAFP;AAJX,kBASE,gCAAC,iBAAD,OATF,CAD2B;AAAA,CAAtB;;;AAcPH,aAAa,CAACM,SAAd,GAA0B;AACxBL,EAAAA,OAAO,EAAEM,sBAAUC,MAAV,CAAiBC,UADF;AAExBP,EAAAA,OAAO,EAAEK,sBAAUG;AAFK,CAA1B;AAKA,IAAMC,MAAM,GAAG;AACbR,EAAAA,QAAQ,EAAE;AACRS,IAAAA,aAAa,EAAE,KADP;AAERC,IAAAA,KAAK,EAAE,MAFC;AAGRC,IAAAA,MAAM,EAAE,MAHA;AAIRC,IAAAA,KAAK,EAAE;AAJC,GADG;AAObX,EAAAA,KAAK,EAAE;AACLY,IAAAA,QAAQ,EAAE,UADL;AAELC,IAAAA,GAAG,EAAE;AAFA;AAPM,CAAf;AAYO,IAAMC,UAAU,GAAG,wBAAWP,MAAX,EAAmBX,aAAnB,CAAnB","sourcesContent":["import React from 'react';\n\nimport IconButton from '@material-ui/core/IconButton';\nimport Check from '@material-ui/icons/Check';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\n\nexport const RawDoneButton = ({ classes, onClick }) => (\n <IconButton\n aria-label=\"Done\"\n className={classes.iconRoot}\n onClick={onClick}\n classes={{\n label: classes.label,\n root: classes.iconRoot\n }}\n >\n <Check />\n </IconButton>\n);\n\nRawDoneButton.propTypes = {\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func\n};\n\nconst styles = {\n iconRoot: {\n verticalAlign: 'top',\n width: '28px',\n height: '28px',\n color: '#00bb00'\n },\n label: {\n position: 'absolute',\n top: '2px'\n }\n};\nexport const DoneButton = withStyles(styles)(RawDoneButton);\n"],"file":"done-button.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
  });
@@ -27,27 +29,29 @@ var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
27
29
 
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
31
 
30
- 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); }
31
-
32
32
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
33
 
34
34
  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); } }
35
35
 
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
36
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
37
 
38
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
38
+ 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); }
39
39
 
40
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
+
42
+ 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); }; }
43
+
44
+ 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); }
41
45
 
42
46
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
47
 
44
- 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
48
+ 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; } }
45
49
 
46
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
50
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
51
 
48
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
52
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
49
53
 
50
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
54
+ 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; }
51
55
 
52
56
  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; }
53
57
 
@@ -80,17 +84,17 @@ var toNodeData = function toNodeData(data) {
80
84
  }
81
85
  };
82
86
 
83
- var EditorAndPad =
84
- /*#__PURE__*/
85
- function (_React$Component) {
87
+ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
86
88
  _inherits(EditorAndPad, _React$Component);
87
89
 
90
+ var _super = _createSuper(EditorAndPad);
91
+
88
92
  function EditorAndPad(props) {
89
93
  var _this;
90
94
 
91
95
  _classCallCheck(this, EditorAndPad);
92
96
 
93
- _this = _possibleConstructorReturn(this, _getPrototypeOf(EditorAndPad).call(this, props));
97
+ _this = _super.call(this, props);
94
98
 
95
99
  _defineProperty(_assertThisInitialized(_this), "onClick", function (data) {
96
100
  var noDecimal = _this.props.noDecimal;
@@ -116,19 +120,36 @@ function (_React$Component) {
116
120
  }
117
121
  });
118
122
 
123
+ _defineProperty(_assertThisInitialized(_this), "updateDisable", function (isEdit) {
124
+ var maxResponseAreas = _this.props.maxResponseAreas;
125
+
126
+ if (maxResponseAreas) {
127
+ var shouldDisable = _this.checkResponseAreasNumber(maxResponseAreas, isEdit);
128
+
129
+ _this.setState({
130
+ addDisabled: shouldDisable
131
+ });
132
+ }
133
+ });
134
+
119
135
  _defineProperty(_assertThisInitialized(_this), "onAnswerBlockClick", function () {
120
136
  _this.props.onAnswerBlockAdd();
121
137
 
122
138
  _this.onClick({
123
139
  type: 'answer'
124
140
  });
141
+
142
+ _this.updateDisable(true);
125
143
  });
126
144
 
127
145
  _defineProperty(_assertThisInitialized(_this), "onEditorChange", function (latex) {
128
146
  var _this$props = _this.props,
129
147
  onChange = _this$props.onChange,
130
148
  noDecimal = _this$props.noDecimal;
131
- (0, _mathInput.updateSpans)(); // if no decimals are allowed and the last change is a decimal dot, discard the change
149
+ (0, _mathInput.updateSpans)();
150
+
151
+ _this.updateDisable(true); // if no decimals are allowed and the last change is a decimal dot, discard the change
152
+
132
153
 
133
154
  if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && _this.input) {
134
155
  _this.input.clear();
@@ -147,8 +168,21 @@ function (_React$Component) {
147
168
  });
148
169
  });
149
170
 
171
+ _defineProperty(_assertThisInitialized(_this), "checkResponseAreasNumber", function (maxResponseAreas, isEdit) {
172
+ var _ref = _this.input && _this.input.props || {},
173
+ latex = _ref.latex;
174
+
175
+ if (latex) {
176
+ var count = (latex.match(/answerBlock/g) || []).length;
177
+ return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
178
+ }
179
+
180
+ return false;
181
+ });
182
+
150
183
  _this.state = {
151
- equationEditor: 'item-authoring'
184
+ equationEditor: 'item-authoring',
185
+ addDisabled: false
152
186
  };
153
187
  return _this;
154
188
  }
@@ -162,10 +196,10 @@ function (_React$Component) {
162
196
  }
163
197
  }, {
164
198
  key: "shouldComponentUpdate",
165
-
199
+ value:
166
200
  /** Only render if the mathquill instance's latex is different
167
201
  * or the keypad state changed from one state to the other (shown / hidden) */
168
- value: function shouldComponentUpdate(nextProps, nextState) {
202
+ function shouldComponentUpdate(nextProps, nextState) {
169
203
  var inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
170
204
  log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
171
205
 
@@ -202,65 +236,78 @@ function (_React$Component) {
202
236
  showKeypad = _this$props2.showKeypad,
203
237
  noDecimal = _this$props2.noDecimal,
204
238
  latex = _this$props2.latex,
205
- onFocus = _this$props2.onFocus,
206
- onBlur = _this$props2.onBlur,
207
- classes = _this$props2.classes;
239
+ _onFocus = _this$props2.onFocus,
240
+ _onBlur = _this$props2.onBlur,
241
+ classes = _this$props2.classes,
242
+ error = _this$props2.error;
208
243
  var shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
244
+ var addDisabled = this.state.addDisabled;
209
245
  log('[render]', latex);
210
- return _react["default"].createElement("div", {
246
+ return /*#__PURE__*/_react["default"].createElement("div", {
211
247
  className: (0, _classnames["default"])(classes.mathToolbar, classNames.mathToolbar)
212
- }, _react["default"].createElement("div", {
248
+ }, /*#__PURE__*/_react["default"].createElement("div", {
213
249
  className: classes.inputAndTypeContainer
214
- }, controlledKeypadMode && _react["default"].createElement(_renderUi.InputContainer, {
250
+ }, controlledKeypadMode && /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
215
251
  label: "Equation Editor",
216
252
  className: classes.selectContainer
217
- }, _react["default"].createElement(_Select["default"], {
253
+ }, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
218
254
  className: classes.select,
219
255
  onChange: this.onEditorTypeChange,
220
256
  value: this.state.equationEditor
221
- }, _react["default"].createElement(_MenuItem["default"], {
257
+ }, /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
222
258
  value: "non-negative-integers"
223
- }, "Numeric - Non-Negative Integers"), _react["default"].createElement(_MenuItem["default"], {
259
+ }, "Numeric - Non-Negative Integers"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
224
260
  value: "integers"
225
- }, "Numeric - Integers"), _react["default"].createElement(_MenuItem["default"], {
261
+ }, "Numeric - Integers"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
226
262
  value: "decimals"
227
- }, "Numeric - Decimals"), _react["default"].createElement(_MenuItem["default"], {
263
+ }, "Numeric - Decimals"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
228
264
  value: "fractions"
229
- }, "Numeric - Fractions"), _react["default"].createElement(_MenuItem["default"], {
265
+ }, "Numeric - Fractions"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
230
266
  value: 1
231
- }, "Grade 1 - 2"), _react["default"].createElement(_MenuItem["default"], {
267
+ }, "Grade 1 - 2"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
232
268
  value: 3
233
- }, "Grade 3 - 5"), _react["default"].createElement(_MenuItem["default"], {
269
+ }, "Grade 3 - 5"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
234
270
  value: 6
235
- }, "Grade 6 - 7"), _react["default"].createElement(_MenuItem["default"], {
271
+ }, "Grade 6 - 7"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
236
272
  value: 8
237
- }, "Grade 8 - HS"), _react["default"].createElement(_MenuItem["default"], {
273
+ }, "Grade 8 - HS"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
238
274
  value: 'geometry'
239
- }, "Geometry"), _react["default"].createElement(_MenuItem["default"], {
275
+ }, "Geometry"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
240
276
  value: 'advanced-algebra'
241
- }, "Advanced Algebra"), _react["default"].createElement(_MenuItem["default"], {
277
+ }, "Advanced Algebra"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
242
278
  value: 'statistics'
243
- }, "Statistics"), _react["default"].createElement(_MenuItem["default"], {
279
+ }, "Statistics"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
244
280
  value: 'item-authoring'
245
- }, "Item Authoring"))), _react["default"].createElement(_mathInput.mq.Input, {
246
- onFocus: onFocus,
247
- onBlur: onBlur,
281
+ }, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement("div", {
282
+ className: (0, _classnames["default"])(classes.inputContainer, error ? classes.error : '')
283
+ }, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Input, {
284
+ onFocus: function onFocus() {
285
+ _onFocus && _onFocus();
286
+
287
+ _this2.updateDisable(false);
288
+ },
289
+ onBlur: function onBlur() {
290
+ _this2.updateDisable(false);
291
+
292
+ _onBlur && _onBlur();
293
+ },
248
294
  className: (0, _classnames["default"])(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
249
295
  innerRef: function innerRef(r) {
250
296
  return _this2.input = r;
251
297
  },
252
298
  latex: latex,
253
299
  onChange: this.onEditorChange
254
- })), allowAnswerBlock && _react["default"].createElement(_Button["default"], {
300
+ }))), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
255
301
  className: classes.addAnswerBlockButton,
256
302
  type: "primary",
257
303
  style: {
258
304
  bottom: shouldShowKeypad ? '320px' : '20px'
259
305
  },
260
- onClick: this.onAnswerBlockClick
261
- }, "+ Response Area"), _react["default"].createElement("hr", {
306
+ onClick: this.onAnswerBlockClick,
307
+ disabled: addDisabled
308
+ }, "+ Response Area"), /*#__PURE__*/_react["default"].createElement("hr", {
262
309
  className: classes.hr
263
- }), shouldShowKeypad && _react["default"].createElement(_mathInput.HorizontalKeypad, {
310
+ }), shouldShowKeypad && /*#__PURE__*/_react["default"].createElement(_mathInput.HorizontalKeypad, {
264
311
  additionalKeys: additionalKeys,
265
312
  mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
266
313
  onClick: this.onClick,
@@ -337,9 +384,7 @@ var styles = function styles(theme) {
337
384
  maxWidth: '400px',
338
385
  color: _renderUi.color.text(),
339
386
  backgroundColor: _renderUi.color.background(),
340
- padding: theme.spacing.unit,
341
- marginTop: theme.spacing.unit,
342
- marginBottom: theme.spacing.unit
387
+ padding: theme.spacing.unit
343
388
  },
344
389
  longMathEditor: {
345
390
  maxWidth: '500px'
@@ -390,6 +435,18 @@ var styles = function styles(theme) {
390
435
  '& .mq-parallelogram': {
391
436
  lineHeight: 0.85
392
437
  }
438
+ },
439
+ inputContainer: {
440
+ minWidth: '500px',
441
+ maxWidth: '900px',
442
+ minHeight: '40px',
443
+ width: '100%',
444
+ display: 'flex',
445
+ marginTop: theme.spacing.unit,
446
+ marginBottom: theme.spacing.unit
447
+ },
448
+ error: {
449
+ border: '2px solid red'
393
450
  }
394
451
  };
395
452
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/editor-and-pad.jsx"],"names":["log","decimalRegex","toNodeData","data","type","value","EditorAndPad","props","noDecimal","c","input","clear","command","keystroke","write","onAnswerBlockAdd","onClick","latex","onChange","indexOf","replace","evt","setState","equationEditor","target","state","autoFocus","focus","nextProps","nextState","inputIsDifferent","mathField","keypadMode","controlledKeypad","showKeypad","classNames","allowAnswerBlock","additionalKeys","controlledKeypadMode","onFocus","onBlur","classes","shouldShowKeypad","mathToolbar","inputAndTypeContainer","selectContainer","select","onEditorTypeChange","mathEditor","editor","longMathEditor","r","onEditorChange","addAnswerBlockButton","bottom","onAnswerBlockClick","hr","React","Component","PropTypes","object","oneOfType","string","number","bool","array","isRequired","func","styles","theme","display","alignItems","fontFamily","minWidth","lineHeight","top","left","right","flex","width","marginLeft","marginTop","marginBottom","marginRight","maxWidth","color","text","backgroundColor","background","padding","spacing","unit","position","border","margin","height","borderBottom","palette","primary","main","zIndex","textAlign","outline","boxShadow","borderRadius","paddingTop","borderTop"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAHA,IAAMA,GAAG,GAAG,uBAAM,sCAAN,CAAZ;AAMA,IAAMC,YAAY,GAAG,OAArB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,IAAI,EAAI;AACzB,MAAI,CAACA,IAAL,EAAW;AACT;AACD;;AAHwB,MAKjBC,IALiB,GAKDD,IALC,CAKjBC,IALiB;AAAA,MAKXC,KALW,GAKDF,IALC,CAKXE,KALW;;AAOzB,MAAID,IAAI,KAAK,SAAT,IAAsBA,IAAI,KAAK,QAAnC,EAA6C;AAC3C,WAAOD,IAAP;AACD,GAFD,MAEO,IAAIC,IAAI,KAAK,QAAb,EAAuB;AAC5B;AAASA,MAAAA,IAAI,EAAE;AAAf,OAA4BD,IAA5B;AACD,GAFM,MAEA,IAAIE,KAAK,KAAK,OAAd,EAAuB;AAC5B,WAAO;AAAED,MAAAA,IAAI,EAAE;AAAR,KAAP;AACD,GAFM,MAEA;AACL,WAAO;AAAEA,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,KAAK,EAALA;AAAjB,KAAP;AACD;AACF,CAhBD;;IAkBaC,Y;;;;;AAmBX,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,sFAAMA,KAAN;;AADiB,8DAYT,UAAAJ,IAAI,EAAI;AAAA,UACRK,SADQ,GACM,MAAKD,KADX,CACRC,SADQ;AAEhB,UAAMC,CAA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X,EAAmB9D,YAAnB,C","sourcesContent":["import { HorizontalKeypad, mq } from '@pie-lib/math-input';\nimport React from 'react';\nimport debug from 'debug';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Button from '@material-ui/core/Button';\nimport { withStyles } from '@material-ui/core/styles';\nconst log = debug('@pie-lib:math-toolbar:editor-and-pad');\nimport { color, InputContainer } from '@pie-lib/render-ui';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { updateSpans } from '@pie-lib/math-input';\n\nconst decimalRegex = /\\.|,/g;\n\nconst toNodeData = data => {\n if (!data) {\n return;\n }\n\n const { type, value } = data;\n\n if (type === 'command' || type === 'cursor') {\n return data;\n } else if (type === 'answer') {\n return { type: 'answer', ...data };\n } else if (value === 'clear') {\n return { type: 'clear' };\n } else {\n return { type: 'write', value };\n }\n};\n\nexport class EditorAndPad extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n showKeypad: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object\n };\n\n constructor(props) {\n super(props);\n\n this.state = { equationEditor: 'item-authoring' };\n }\n\n componentDidMount() {\n if (this.input && this.props.autoFocus) {\n this.input.focus();\n }\n }\n\n onClick = data => {\n const { noDecimal } = this.props;\n const c = toNodeData(data);\n log('mathChange: ', c);\n\n // if decimals are not allowed for this response, we discard the input\n if (noDecimal && (c.value === '.' || c.value === ',')) {\n return;\n }\n\n if (c.type === 'clear') {\n log('call clear...');\n this.input.clear();\n } else if (c.type === 'command') {\n this.input.command(c.value);\n } else if (c.type === 'cursor') {\n this.input.keystroke(c.value);\n } else if (c.type === 'answer') {\n this.input.write('%response%');\n } else {\n this.input.write(c.value);\n }\n };\n\n onAnswerBlockClick = () => {\n this.props.onAnswerBlockAdd();\n this.onClick({\n type: 'answer'\n });\n };\n\n onEditorChange = latex => {\n const { onChange, noDecimal } = this.props;\n\n updateSpans();\n\n // if no decimals are allowed and the last change is a decimal dot, discard the change\n if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {\n this.input.clear();\n this.input.write(latex.replace(decimalRegex, ''));\n return;\n }\n\n onChange(latex);\n };\n\n /** Only render if the mathquill instance's latex is different\n * or the keypad state changed from one state to the other (shown / hidden) */\n shouldComponentUpdate(nextProps, nextState) {\n const inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;\n log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);\n\n if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {\n return true;\n }\n\n if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.controlledKeypad) {\n return this.props.showKeypad !== nextProps.showKeypad;\n }\n\n return inputIsDifferent;\n }\n\n onEditorTypeChange = evt => {\n this.setState({ equationEditor: evt.target.value });\n };\n\n render() {\n const {\n classNames,\n keypadMode,\n allowAnswerBlock,\n additionalKeys,\n controlledKeypad,\n controlledKeypadMode,\n showKeypad,\n noDecimal,\n latex,\n onFocus,\n onBlur,\n classes\n } = this.props;\n const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);\n\n log('[render]', latex);\n\n return (\n <div className={cx(classes.mathToolbar, classNames.mathToolbar)}>\n <div className={classes.inputAndTypeContainer}>\n {controlledKeypadMode && (\n <InputContainer label=\"Equation Editor\" className={classes.selectContainer}>\n <Select\n className={classes.select}\n onChange={this.onEditorTypeChange}\n value={this.state.equationEditor}\n >\n <MenuItem value=\"non-negative-integers\">Numeric - Non-Negative Integers</MenuItem>\n <MenuItem value=\"integers\">Numeric - Integers</MenuItem>\n <MenuItem value=\"decimals\">Numeric - Decimals</MenuItem>\n <MenuItem value=\"fractions\">Numeric - Fractions</MenuItem>\n <MenuItem value={1}>Grade 1 - 2</MenuItem>\n <MenuItem value={3}>Grade 3 - 5</MenuItem>\n <MenuItem value={6}>Grade 6 - 7</MenuItem>\n <MenuItem value={8}>Grade 8 - HS</MenuItem>\n <MenuItem value={'geometry'}>Geometry</MenuItem>\n <MenuItem value={'advanced-algebra'}>Advanced Algebra</MenuItem>\n <MenuItem value={'statistics'}>Statistics</MenuItem>\n <MenuItem value={'item-authoring'}>Item Authoring</MenuItem>\n </Select>\n </InputContainer>\n )}\n <mq.Input\n onFocus={onFocus}\n onBlur={onBlur}\n className={cx(\n classes.mathEditor,\n classNames.editor,\n !controlledKeypadMode ? classes.longMathEditor : ''\n )}\n innerRef={r => (this.input = r)}\n latex={latex}\n onChange={this.onEditorChange}\n />\n </div>\n {allowAnswerBlock && (\n <Button\n className={classes.addAnswerBlockButton}\n type=\"primary\"\n style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}\n onClick={this.onAnswerBlockClick}\n >\n + Response Area\n </Button>\n )}\n <hr className={classes.hr} />\n {shouldShowKeypad && (\n <HorizontalKeypad\n additionalKeys={additionalKeys}\n mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}\n onClick={this.onClick}\n noDecimal={noDecimal}\n />\n )}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n inputAndTypeContainer: {\n display: 'flex',\n alignItems: 'center',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important'\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px'\n },\n '&:after': {\n top: '-2.36em',\n right: '-1px'\n },\n '&.mq-empty:after': {\n top: '-0.45em'\n }\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px'\n }\n }\n },\n selectContainer: {\n flex: 'initial',\n width: '25%',\n minWidth: '100px',\n marginLeft: '15px',\n marginTop: '5px',\n marginBottom: '5px',\n marginRight: '5px'\n },\n mathEditor: {\n maxWidth: '400px',\n color: color.text(),\n backgroundColor: color.background(),\n padding: theme.spacing.unit,\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit\n },\n longMathEditor: {\n maxWidth: '500px'\n },\n addAnswerBlockButton: {\n position: 'absolute',\n right: '12px',\n border: '1px solid lightgrey'\n },\n hr: {\n padding: 0,\n margin: 0,\n height: '1px',\n border: 'none',\n borderBottom: `solid 1px ${theme.palette.primary.main}`\n },\n mathToolbar: {\n zIndex: 9,\n position: 'relative',\n textAlign: 'center',\n width: 'auto',\n '& > .mq-math-mode': {\n border: 'solid 1px lightgrey'\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: `dotted 1px ${theme.palette.primary.main}`,\n borderRadius: '0px'\n },\n '& .mq-overarrow-inner': {\n border: 'none !important',\n paddingTop: '0 !important'\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important'\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important'\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em'\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85\n }\n }\n});\n\nexport default withStyles(styles)(EditorAndPad);\n"],"file":"editor-and-pad.js"}
1
+ {"version":3,"sources":["../src/editor-and-pad.jsx"],"names":["log","decimalRegex","toNodeData","data","type","value","EditorAndPad","props","noDecimal","c","input","clear","command","keystroke","write","isEdit","maxResponseAreas","shouldDisable","checkResponseAreasNumber","setState","addDisabled","onAnswerBlockAdd","onClick","updateDisable","latex","onChange","indexOf","replace","evt","equationEditor","target","count","match","length","state","autoFocus","focus","nextProps","nextState","inputIsDifferent","mathField","keypadMode","controlledKeypad","showKeypad","classNames","allowAnswerBlock","additionalKeys","controlledKeypadMode","onFocus","onBlur","classes","error","shouldShowKeypad","mathToolbar","inputAndTypeContainer","selectContainer","select","onEditorTypeChange","inputContainer","mathEditor","editor","longMathEditor","r","onEditorChange","addAnswerBlockButton","bottom","onAnswerBlockClick","hr","React","Component","PropTypes","object","oneOfType","string","number","bool","array","isRequired","func","styles","theme","display","alignItems","fontFamily","minWidth","lineHeight","top","left","right","flex","width","marginLeft","marginTop","marginBottom","marginRight","maxWidth","color","text","backgroundColor","background","padding","spacing","unit","position","border","margin","height","borderBottom","palette","primary","main","zIndex","textAlign","outline","boxShadow","borderRadius","paddingTop","borderTop","minHeight"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAHA,IAAMA,GAAG,GAAG,uBAAM,sCAAN,CAAZ;AAMA,IAAMC,YAAY,GAAG,OAArB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,IAAI,EAAI;AACzB,MAAI,CAACA,IAAL,EAAW;AACT;AACD;;AAED,MAAQC,IAAR,GAAwBD,IAAxB,CAAQC,IAAR;AAAA,MAAcC,KAAd,GAAwBF,IAAxB,CAAcE,KAAd;;AAEA,MAAID,IAAI,KAAK,SAAT,IAAsBA,IAAI,KAAK,QAAnC,EAA6C;AAC3C,WAAOD,IAAP;AACD,GAFD,MAEO,IAAIC,IAAI,KAAK,QAAb,EAAuB;AAC5B;AAASA,MAAAA,IAAI,EAAE;AAAf,OAA4BD,IAA5B;AACD,GAFM,MAEA,IAAIE,KAAK,KAAK,OAAd,EAAuB;AAC5B,WAAO;AAAED,MAAAA,IAAI,EAAE;AAAR,KAAP;AACD,GAFM,MAEA;AACL,WAAO;AAAEA,MAAAA,IAAI,EAAE,OAAR;AAAiBC,MAAAA,KA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AAE;AAFS,OAxBZ;AA4BX,uCAAiC;AAC/BhC,QAAAA,QAAQ,EAAE;AADqB,OA5BtB;AA+BX,6BAAuB;AACrBC,QAAAA,UAAU,EAAE;AADS;AA/BZ,KA7DU;AAgGvB3B,IAAAA,cAAc,EAAE;AACd0B,MAAAA,QAAQ,EAAE,OADI;AAEdW,MAAAA,QAAQ,EAAE,OAFI;AAGduB,MAAAA,SAAS,EAAE,MAHG;AAId5B,MAAAA,KAAK,EAAE,MAJO;AAKdT,MAAAA,OAAO,EAAE,MALK;AAMdW,MAAAA,SAAS,EAAEZ,KAAK,CAACqB,OAAN,CAAcC,IANX;AAOdT,MAAAA,YAAY,EAAEb,KAAK,CAACqB,OAAN,CAAcC;AAPd,KAhGO;AAyGvBnD,IAAAA,KAAK,EAAE;AACLqD,MAAAA,MAAM,EAAE;AADH;AAzGgB,GAAL;AAAA,CAApB;;eA8Ge,wBAAWzB,MAAX,EAAmBzE,YAAnB,C","sourcesContent":["import { HorizontalKeypad, mq } from '@pie-lib/math-input';\nimport React from 'react';\nimport debug from 'debug';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport Button from '@material-ui/core/Button';\nimport { withStyles } from '@material-ui/core/styles';\nconst log = debug('@pie-lib:math-toolbar:editor-and-pad');\nimport { color, InputContainer } from '@pie-lib/render-ui';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport Select from '@material-ui/core/Select';\nimport { updateSpans } from '@pie-lib/math-input';\n\nconst decimalRegex = /\\.|,/g;\n\nconst toNodeData = data => {\n if (!data) {\n return;\n }\n\n const { type, value } = data;\n\n if (type === 'command' || type === 'cursor') {\n return data;\n } else if (type === 'answer') {\n return { type: 'answer', ...data };\n } else if (value === 'clear') {\n return { type: 'clear' };\n } else {\n return { type: 'write', value };\n }\n};\n\nexport class EditorAndPad extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n showKeypad: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object\n };\n\n constructor(props) {\n super(props);\n\n this.state = { equationEditor: 'item-authoring', addDisabled: false };\n }\n\n componentDidMount() {\n if (this.input && this.props.autoFocus) {\n this.input.focus();\n }\n }\n\n onClick = data => {\n const { noDecimal } = this.props;\n const c = toNodeData(data);\n log('mathChange: ', c);\n\n // if decimals are not allowed for this response, we discard the input\n if (noDecimal && (c.value === '.' || c.value === ',')) {\n return;\n }\n\n if (c.type === 'clear') {\n log('call clear...');\n this.input.clear();\n } else if (c.type === 'command') {\n this.input.command(c.value);\n } else if (c.type === 'cursor') {\n this.input.keystroke(c.value);\n } else if (c.type === 'answer') {\n this.input.write('%response%');\n } else {\n this.input.write(c.value);\n }\n };\n\n updateDisable = isEdit => {\n const { maxResponseAreas } = this.props;\n\n if (maxResponseAreas) {\n const shouldDisable = this.checkResponseAreasNumber(maxResponseAreas, isEdit);\n\n this.setState({ addDisabled: shouldDisable });\n }\n };\n\n onAnswerBlockClick = () => {\n this.props.onAnswerBlockAdd();\n this.onClick({\n type: 'answer'\n });\n\n this.updateDisable(true);\n };\n\n onEditorChange = latex => {\n const { onChange, noDecimal } = this.props;\n\n updateSpans();\n\n this.updateDisable(true);\n\n // if no decimals are allowed and the last change is a decimal dot, discard the change\n if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {\n this.input.clear();\n this.input.write(latex.replace(decimalRegex, ''));\n return;\n }\n\n onChange(latex);\n };\n\n /** Only render if the mathquill instance's latex is different\n * or the keypad state changed from one state to the other (shown / hidden) */\n shouldComponentUpdate(nextProps, nextState) {\n const inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;\n log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);\n\n if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {\n return true;\n }\n\n if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {\n return true;\n }\n\n if (!inputIsDifferent && this.props.controlledKeypad) {\n return this.props.showKeypad !== nextProps.showKeypad;\n }\n\n return inputIsDifferent;\n }\n\n onEditorTypeChange = evt => {\n this.setState({ equationEditor: evt.target.value });\n };\n\n checkResponseAreasNumber = (maxResponseAreas, isEdit) => {\n const { latex } = (this.input && this.input.props) || {};\n\n if (latex) {\n const count = (latex.match(/answerBlock/g) || []).length;\n\n return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;\n }\n\n return false;\n };\n\n render() {\n const {\n classNames,\n keypadMode,\n allowAnswerBlock,\n additionalKeys,\n controlledKeypad,\n controlledKeypadMode,\n showKeypad,\n noDecimal,\n latex,\n onFocus,\n onBlur,\n classes,\n error\n } = this.props;\n const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);\n const { addDisabled } = this.state;\n\n log('[render]', latex);\n\n return (\n <div className={cx(classes.mathToolbar, classNames.mathToolbar)}>\n <div className={classes.inputAndTypeContainer}>\n {controlledKeypadMode && (\n <InputContainer label=\"Equation Editor\" className={classes.selectContainer}>\n <Select\n className={classes.select}\n onChange={this.onEditorTypeChange}\n value={this.state.equationEditor}\n >\n <MenuItem value=\"non-negative-integers\">Numeric - Non-Negative Integers</MenuItem>\n <MenuItem value=\"integers\">Numeric - Integers</MenuItem>\n <MenuItem value=\"decimals\">Numeric - Decimals</MenuItem>\n <MenuItem value=\"fractions\">Numeric - Fractions</MenuItem>\n <MenuItem value={1}>Grade 1 - 2</MenuItem>\n <MenuItem value={3}>Grade 3 - 5</MenuItem>\n <MenuItem value={6}>Grade 6 - 7</MenuItem>\n <MenuItem value={8}>Grade 8 - HS</MenuItem>\n <MenuItem value={'geometry'}>Geometry</MenuItem>\n <MenuItem value={'advanced-algebra'}>Advanced Algebra</MenuItem>\n <MenuItem value={'statistics'}>Statistics</MenuItem>\n <MenuItem value={'item-authoring'}>Item Authoring</MenuItem>\n </Select>\n </InputContainer>\n )}\n <div className={cx(classes.inputContainer, error ? classes.error : '')}>\n <mq.Input\n onFocus={() => {\n onFocus && onFocus();\n this.updateDisable(false);\n }}\n onBlur={() => {\n this.updateDisable(false);\n onBlur && onBlur();\n }}\n className={cx(\n classes.mathEditor,\n classNames.editor,\n !controlledKeypadMode ? classes.longMathEditor : ''\n )}\n innerRef={r => (this.input = r)}\n latex={latex}\n onChange={this.onEditorChange}\n />\n </div>\n </div>\n {allowAnswerBlock && (\n <Button\n className={classes.addAnswerBlockButton}\n type=\"primary\"\n style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}\n onClick={this.onAnswerBlockClick}\n disabled={addDisabled}\n >\n + Response Area\n </Button>\n )}\n <hr className={classes.hr} />\n {shouldShowKeypad && (\n <HorizontalKeypad\n additionalKeys={additionalKeys}\n mode={controlledKeypadMode ? this.state.equationEditor : keypadMode}\n onClick={this.onClick}\n noDecimal={noDecimal}\n />\n )}\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n inputAndTypeContainer: {\n display: 'flex',\n alignItems: 'center',\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important'\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px'\n },\n '&:after': {\n top: '-2.36em',\n right: '-1px'\n },\n '&.mq-empty:after': {\n top: '-0.45em'\n }\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px'\n }\n }\n },\n selectContainer: {\n flex: 'initial',\n width: '25%',\n minWidth: '100px',\n marginLeft: '15px',\n marginTop: '5px',\n marginBottom: '5px',\n marginRight: '5px'\n },\n mathEditor: {\n maxWidth: '400px',\n color: color.text(),\n backgroundColor: color.background(),\n padding: theme.spacing.unit\n },\n longMathEditor: {\n maxWidth: '500px'\n },\n addAnswerBlockButton: {\n position: 'absolute',\n right: '12px',\n border: '1px solid lightgrey'\n },\n hr: {\n padding: 0,\n margin: 0,\n height: '1px',\n border: 'none',\n borderBottom: `solid 1px ${theme.palette.primary.main}`\n },\n mathToolbar: {\n zIndex: 9,\n position: 'relative',\n textAlign: 'center',\n width: 'auto',\n '& > .mq-math-mode': {\n border: 'solid 1px lightgrey'\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: `dotted 1px ${theme.palette.primary.main}`,\n borderRadius: '0px'\n },\n '& .mq-overarrow-inner': {\n border: 'none !important',\n paddingTop: '0 !important'\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important'\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important'\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em'\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85\n }\n },\n inputContainer: {\n minWidth: '500px',\n maxWidth: '900px',\n minHeight: '40px',\n width: '100%',\n display: 'flex',\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit\n },\n error: {\n border: '2px solid red'\n }\n});\n\nexport default withStyles(styles)(EditorAndPad);\n"],"file":"editor-and-pad.js"}
package/lib/index.js CHANGED
@@ -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
  });
@@ -9,7 +11,7 @@ Object.defineProperty(exports, "MathPreview", {
9
11
  return _mathPreview["default"];
10
12
  }
11
13
  });
12
- exports.PureToolbar = exports.RawPureToolbar = exports.MathToolbar = void 0;
14
+ exports.RawPureToolbar = exports.PureToolbar = exports.MathToolbar = void 0;
13
15
 
14
16
  var _react = _interopRequireDefault(require("react"));
15
17
 
@@ -27,37 +29,39 @@ var _mathPreview = _interopRequireDefault(require("./math-preview"));
27
29
 
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
29
31
 
30
- 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); }
31
-
32
32
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
33
 
34
34
  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); } }
35
35
 
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
36
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
37
 
38
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
38
+ 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); }
39
39
 
40
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
+
42
+ 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); }; }
43
+
44
+ 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); }
41
45
 
42
46
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
47
 
44
- 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
48
+ 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; } }
45
49
 
46
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
50
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
51
 
48
52
  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; }
49
53
 
50
- var MathToolbar =
51
- /*#__PURE__*/
52
- function (_React$Component) {
54
+ var MathToolbar = /*#__PURE__*/function (_React$Component) {
53
55
  _inherits(MathToolbar, _React$Component);
54
56
 
57
+ var _super = _createSuper(MathToolbar);
58
+
55
59
  function MathToolbar(props) {
56
60
  var _this;
57
61
 
58
62
  _classCallCheck(this, MathToolbar);
59
63
 
60
- _this = _possibleConstructorReturn(this, _getPrototypeOf(MathToolbar).call(this, props));
64
+ _this = _super.call(this, props);
61
65
 
62
66
  _defineProperty(_assertThisInitialized(_this), "done", function () {
63
67
  _this.props.onDone(_this.state.latex);
@@ -101,8 +105,10 @@ function (_React$Component) {
101
105
  showKeypad = _this$props.showKeypad,
102
106
  onFocus = _this$props.onFocus,
103
107
  onBlur = _this$props.onBlur,
104
- hideDoneButton = _this$props.hideDoneButton;
105
- return _react["default"].createElement(PureToolbar, {
108
+ hideDoneButton = _this$props.hideDoneButton,
109
+ error = _this$props.error,
110
+ maxResponseAreas = _this$props.maxResponseAreas;
111
+ return /*#__PURE__*/_react["default"].createElement(PureToolbar, {
106
112
  autoFocus: autoFocus,
107
113
  classNames: classNames,
108
114
  onAnswerBlockAdd: onAnswerBlockAdd,
@@ -118,7 +124,9 @@ function (_React$Component) {
118
124
  showKeypad: showKeypad,
119
125
  controlledKeypad: controlledKeypad,
120
126
  controlledKeypadMode: controlledKeypadMode,
121
- hideDoneButton: hideDoneButton
127
+ hideDoneButton: hideDoneButton,
128
+ error: error,
129
+ maxResponseAreas: maxResponseAreas
122
130
  });
123
131
  }
124
132
  }]);
@@ -163,15 +171,15 @@ _defineProperty(MathToolbar, "defaultProps", {
163
171
  hideDoneButton: false
164
172
  });
165
173
 
166
- var RawPureToolbar =
167
- /*#__PURE__*/
168
- function (_React$Component2) {
174
+ var RawPureToolbar = /*#__PURE__*/function (_React$Component2) {
169
175
  _inherits(RawPureToolbar, _React$Component2);
170
176
 
177
+ var _super2 = _createSuper(RawPureToolbar);
178
+
171
179
  function RawPureToolbar() {
172
180
  _classCallCheck(this, RawPureToolbar);
173
181
 
174
- return _possibleConstructorReturn(this, _getPrototypeOf(RawPureToolbar).apply(this, arguments));
182
+ return _super2.apply(this, arguments);
175
183
  }
176
184
 
177
185
  _createClass(RawPureToolbar, [{
@@ -194,10 +202,12 @@ function (_React$Component2) {
194
202
  onFocus = _this$props2.onFocus,
195
203
  onBlur = _this$props2.onBlur,
196
204
  hideDoneButton = _this$props2.hideDoneButton,
197
- classes = _this$props2.classes;
198
- return _react["default"].createElement("div", {
205
+ classes = _this$props2.classes,
206
+ error = _this$props2.error,
207
+ maxResponseAreas = _this$props2.maxResponseAreas;
208
+ return /*#__PURE__*/_react["default"].createElement("div", {
199
209
  className: (0, _classnames["default"])(classes.pureToolbar, (classNames || {}).toolbar)
200
- }, _react["default"].createElement("div", null), _react["default"].createElement(_editorAndPad["default"], {
210
+ }, /*#__PURE__*/_react["default"].createElement("div", null), /*#__PURE__*/_react["default"].createElement(_editorAndPad["default"], {
201
211
  autoFocus: autoFocus,
202
212
  keypadMode: keypadMode,
203
213
  classNames: classNames || {},
@@ -211,8 +221,10 @@ function (_React$Component2) {
211
221
  latex: latex,
212
222
  onChange: onChange,
213
223
  onFocus: onFocus,
214
- onBlur: onBlur
215
- }), (!controlledKeypad || controlledKeypad && showKeypad) && !hideDoneButton && _react["default"].createElement(_doneButton.DoneButton, {
224
+ onBlur: onBlur,
225
+ error: error,
226
+ maxResponseAreas: maxResponseAreas
227
+ }), (!controlledKeypad || controlledKeypad && showKeypad) && !hideDoneButton && /*#__PURE__*/_react["default"].createElement(_doneButton.DoneButton, {
216
228
  onClick: onDone
217
229
  }));
218
230
  }
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.jsx"],"names":["MathToolbar","props","onDone","state","latex","setState","onChange","nextProps","classNames","autoFocus","allowAnswerBlock","onAnswerBlockAdd","controlledKeypad","controlledKeypadMode","keypadMode","noDecimal","additionalKeys","showKeypad","onFocus","onBlur","hideDoneButton","done","React","Component","PropTypes","bool","oneOfType","string","number","object","array","isRequired","func","RawPureToolbar","classes","pureToolbar","toolbar","styles","display","width","zIndex","alignItems","PureToolbar"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;IAIaA,W;;;;;AAoCX,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,qFAAMA,KAAN;;AADiB,2DAOZ,YAAM;AACX,YAAKA,KAAL,CAAWC,MAAX,CAAkB,MAAKC,KAAL,CAAWC,KAA7B;AACD,KATkB;;AAAA,+DAeR,UAAAA,KAAK,EAAI;AAClB,YAAKC,QAAL,CAAc;AAAED,QAAAA,KAAK,EAALA;AAAF,OAAd;;AACA,YAAKH,KAAL,CAAWK,QAAX,CAAoBF,KAApB;AACD,KAlBkB;;AAEjB,UAAKD,KAAL,GAAa;AACXC,MAAAA,KAAK,EAAEH,KAAK,CAACG;AADF,KAAb;AAFiB;AAKlB;;;;qDAMgCG,S,EAAW;AAC1C,WAAKF,QAAL,CAAc;AAAED,QAAAA,KAAK,EAAEG,SAAS,CAACH;AAAnB,OAAd;AACD;;;6BAOQ;AAAA,UACCA,KADD,GACW,KAAKD,KADhB,CACCC,KADD;AAAA,wBAgBH,KAAKH,KAhBF;AAAA,UAGLO,UAHK,eAGLA,UAHK;AAAA,UAILC,SAJK,eAILA,SAJK;AAAA,UAKLC,gBALK,eAKLA,gBALK;AAAA,UAMLC,gBANK,eAMLA,gBANK;AAAA,UAOLC,gBAPK,eAOLA,gBAPK;AAAA,UAQLC,oBARK,eAQLA,oBARK;AAAA,UASLC,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,UAFP;AAGjBjB,EAAAA,UAAU,EAAEU,sBAAUE,SAAV,CAAoB,CAACF,sBAAUG,MAAX,EAAmBH,sBAAUI,MAA7B,CAApB,CAHK;AAIjBtB,EAAAA,QAAQ,EAAEkB,sBAAUQ,IAAV,CAAeD,UAJR;AAKjB7B,EAAAA,MAAM,EAAEsB,sBAAUQ,IAAV,CAAeD,UALN;AAMjBZ,EAAAA,MAAM,EAAEK,sBAAUQ,IAND;AAOjBrB,EAAAA,gBAAgB,EAAEa,sBAAUQ,IAPX;AAQjBhB,EAAAA,cAAc,EAAEQ,sBAAUM,KART;AASjBZ,EAAAA,OAAO,EAAEM,sBAAUQ,IATF;AAUjBE,EAAAA,OAAO,EAAEV,sBAAUK,MAAV,CAAiBE,UAVT;AAWjBtB,EAAAA,SAAS,EAAEe,sBAAUC,IAXJ;AAYjBV,EAAAA,SAAS,EAAES,sBAAUC,IAZJ;AAajBf,EAAAA,gBAAgB,EAAEc,sBAAUC,IAbX;AAcjBb,EAAAA,gBAAgB,EAAEY,sBAAUC,IAdX;AAejBZ,EAAAA,oBAAoB,EAAEW,sBAAUC,IAff;AAgBjBR,EAAAA,UAAU,EAAEO,sBAAUC,IAhBL;AAiBjBL,EAAAA,cAAc,EAAEI,sBAAUC;AAjBT,C;;AAmErB,IAAMY,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO;AACpBF,IAAAA,WAAW,EAAE;AACXG,MAAAA,OAAO,EAAE,MADE;AAEXC,MAAAA,KAAK,EAAE,MAFI;AAGXC,MAAAA,MAAM,EAAE,CAHG;AAIXC,MAAAA,UAAU,EAAE;AAJD;AADO,GAAP;AAAA,CAAf;;AASO,IAAMC,WAAW,GAAG,wBAAWL,MAAX,EAAmBJ,cAAnB,CAApB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport EditorAndPad from './editor-and-pad';\nimport { DoneButton } from './done-button';\nimport { withStyles } from '@material-ui/core/styles';\nimport MathPreview from './math-preview';\n\nexport { MathPreview };\n\nexport class MathToolbar extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classNames: PropTypes.object,\n showKeypad: PropTypes.bool,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onChange: PropTypes.func,\n onDone: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n hideDoneButton: PropTypes.bool\n };\n\n static defaultProps = {\n classNames: {},\n keypadMode: 'item-authoring',\n autoFocus: false,\n allowAnswerBlock: false,\n controlledKeypad: false,\n controlledKeypadMode: false,\n noDecimal: false,\n showKeypad: true,\n additionalKeys: [],\n onChange: () => {},\n onAnswerBlockAdd: () => {},\n onFocus: () => {},\n hideDoneButton: false\n };\n\n constructor(props) {\n super(props);\n this.state = {\n latex: props.latex\n };\n }\n\n done = () => {\n this.props.onDone(this.state.latex);\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({ latex: nextProps.latex });\n }\n\n onChange = latex => {\n this.setState({ latex });\n this.props.onChange(latex);\n };\n\n render() {\n const { latex } = this.state;\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n keypadMode,\n noDecimal,\n additionalKeys,\n showKeypad,\n onFocus,\n onBlur,\n hideDoneButton\n } = this.props;\n\n return (\n <PureToolbar\n autoFocus={autoFocus}\n classNames={classNames}\n onAnswerBlockAdd={onAnswerBlockAdd}\n allowAnswerBlock={allowAnswerBlock}\n latex={latex}\n additionalKeys={additionalKeys}\n noDecimal={noDecimal}\n keypadMode={keypadMode}\n onChange={this.onChange}\n onDone={this.done}\n onFocus={onFocus}\n onBlur={onBlur}\n showKeypad={showKeypad}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n hideDoneButton={hideDoneButton}\n />\n );\n }\n}\n\nexport class RawPureToolbar extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n latex: PropTypes.string.isRequired,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n onChange: PropTypes.func.isRequired,\n onDone: PropTypes.func.isRequired,\n onBlur: PropTypes.func,\n onAnswerBlockAdd: PropTypes.func,\n additionalKeys: PropTypes.array,\n onFocus: PropTypes.func,\n classes: PropTypes.object.isRequired,\n autoFocus: PropTypes.bool,\n noDecimal: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n showKeypad: PropTypes.bool,\n hideDoneButton: PropTypes.bool\n };\n\n render() {\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n additionalKeys,\n showKeypad,\n keypadMode,\n noDecimal,\n latex,\n onChange,\n onDone,\n onFocus,\n onBlur,\n hideDoneButton,\n classes\n } = this.props;\n\n return (\n <div className={cx(classes.pureToolbar, (classNames || {}).toolbar)}>\n <div />\n <EditorAndPad\n autoFocus={autoFocus}\n keypadMode={keypadMode}\n classNames={classNames || {}}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n noDecimal={noDecimal}\n showKeypad={showKeypad}\n additionalKeys={additionalKeys}\n allowAnswerBlock={allowAnswerBlock}\n onAnswerBlockAdd={onAnswerBlockAdd}\n latex={latex}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n />\n {(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (\n <DoneButton onClick={onDone} />\n )}\n </div>\n );\n }\n}\nconst styles = () => ({\n pureToolbar: {\n display: 'flex',\n width: '100%',\n zIndex: 8,\n alignItems: 'center'\n }\n});\n\nexport const PureToolbar = withStyles(styles)(RawPureToolbar);\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.jsx"],"names":["MathToolbar","props","onDone","state","latex","setState","onChange","nextProps","classNames","autoFocus","allowAnswerBlock","onAnswerBlockAdd","controlledKeypad","controlledKeypadMode","keypadMode","noDecimal","additionalKeys","showKeypad","onFocus","onBlur","hideDoneButton","error","maxResponseAreas","done","React","Component","PropTypes","bool","oneOfType","string","number","object","array","isRequired","func","RawPureToolbar","classes","pureToolbar","toolbar","styles","display","width","zIndex","alignItems","PureToolbar"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;IAIaA,W;;;;;AAoCX,uBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,2DAOZ,YAAM;AACX,YAAKA,KAAL,CAAWC,MAAX,CAAkB,MAAKC,KAAL,CAAWC,KAA7B;AACD,KATkB;;AAAA,+DAeR,UAAAA,KAAK,EAAI;AAClB,YAAKC,QAAL,CAAc;AAAED,QAAAA,KAAK,EAALA;AAAF,OAAd;;AACA,YAAKH,KAAL,CAAWK,QAAX,CAAoBF,KAApB;AACD,KAlBkB;;AAEjB,UAAKD,KAAL,GAAa;AACXC,MAAAA,KAAK,EAAEH,KAAK,CAACG;AADF,KAAb;AAFiB;AAKlB;;;;WAMD,0CAAiCG,SAAjC,EAA4C;AAC1C,WAAKF,QAAL,CAAc;AAAED,QAAAA,KAAK,EAAEG,SAAS,CAACH;AAAnB,OAAd;AACD;;;WAOD,kBAAS;AACP,UAAQA,KAAR,GAAkB,KAAKD,KAAvB,CAAQC,KAAR;AACA,wBAgBI,KAAKH,KAhBT;AAAA,UACEO,UADF,eACEA,UADF;AAAA,UAEEC,SAFF,eAEEA,SAFF;AAAA,UAGEC,gBAHF,eAGEA,gBAHF;AAAA,UAIEC,gBAJF,eAIEA,gBAJF;AAAA,UAKEC,gBALF,eAKEA,gBALF;AAAA,UAMEC,oB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AAAA,KAAK,EAAE,MAFI;AAGXC,MAAAA,MAAM,EAAE,CAHG;AAIXC,MAAAA,UAAU,EAAE;AAJD;AADO,GAAP;AAAA,CAAf;;AASO,IAAMC,WAAW,GAAG,wBAAWL,MAAX,EAAmBJ,cAAnB,CAApB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport cx from 'classnames';\nimport EditorAndPad from './editor-and-pad';\nimport { DoneButton } from './done-button';\nimport { withStyles } from '@material-ui/core/styles';\nimport MathPreview from './math-preview';\n\nexport { MathPreview };\n\nexport class MathToolbar extends React.Component {\n static propTypes = {\n autoFocus: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n classNames: PropTypes.object,\n showKeypad: PropTypes.bool,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n latex: PropTypes.string.isRequired,\n onAnswerBlockAdd: PropTypes.func,\n onChange: PropTypes.func,\n onDone: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n hideDoneButton: PropTypes.bool\n };\n\n static defaultProps = {\n classNames: {},\n keypadMode: 'item-authoring',\n autoFocus: false,\n allowAnswerBlock: false,\n controlledKeypad: false,\n controlledKeypadMode: false,\n noDecimal: false,\n showKeypad: true,\n additionalKeys: [],\n onChange: () => {},\n onAnswerBlockAdd: () => {},\n onFocus: () => {},\n hideDoneButton: false\n };\n\n constructor(props) {\n super(props);\n this.state = {\n latex: props.latex\n };\n }\n\n done = () => {\n this.props.onDone(this.state.latex);\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({ latex: nextProps.latex });\n }\n\n onChange = latex => {\n this.setState({ latex });\n this.props.onChange(latex);\n };\n\n render() {\n const { latex } = this.state;\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n keypadMode,\n noDecimal,\n additionalKeys,\n showKeypad,\n onFocus,\n onBlur,\n hideDoneButton,\n error,\n maxResponseAreas\n } = this.props;\n\n return (\n <PureToolbar\n autoFocus={autoFocus}\n classNames={classNames}\n onAnswerBlockAdd={onAnswerBlockAdd}\n allowAnswerBlock={allowAnswerBlock}\n latex={latex}\n additionalKeys={additionalKeys}\n noDecimal={noDecimal}\n keypadMode={keypadMode}\n onChange={this.onChange}\n onDone={this.done}\n onFocus={onFocus}\n onBlur={onBlur}\n showKeypad={showKeypad}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n hideDoneButton={hideDoneButton}\n error={error}\n maxResponseAreas={maxResponseAreas}\n />\n );\n }\n}\n\nexport class RawPureToolbar extends React.Component {\n static propTypes = {\n classNames: PropTypes.object,\n latex: PropTypes.string.isRequired,\n keypadMode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n onChange: PropTypes.func.isRequired,\n onDone: PropTypes.func.isRequired,\n onBlur: PropTypes.func,\n onAnswerBlockAdd: PropTypes.func,\n additionalKeys: PropTypes.array,\n onFocus: PropTypes.func,\n classes: PropTypes.object.isRequired,\n autoFocus: PropTypes.bool,\n noDecimal: PropTypes.bool,\n allowAnswerBlock: PropTypes.bool,\n controlledKeypad: PropTypes.bool,\n controlledKeypadMode: PropTypes.bool,\n showKeypad: PropTypes.bool,\n hideDoneButton: PropTypes.bool\n };\n\n render() {\n const {\n classNames,\n autoFocus,\n allowAnswerBlock,\n onAnswerBlockAdd,\n controlledKeypad,\n controlledKeypadMode,\n additionalKeys,\n showKeypad,\n keypadMode,\n noDecimal,\n latex,\n onChange,\n onDone,\n onFocus,\n onBlur,\n hideDoneButton,\n classes,\n error,\n maxResponseAreas\n } = this.props;\n\n return (\n <div className={cx(classes.pureToolbar, (classNames || {}).toolbar)}>\n <div />\n <EditorAndPad\n autoFocus={autoFocus}\n keypadMode={keypadMode}\n classNames={classNames || {}}\n controlledKeypad={controlledKeypad}\n controlledKeypadMode={controlledKeypadMode}\n noDecimal={noDecimal}\n showKeypad={showKeypad}\n additionalKeys={additionalKeys}\n allowAnswerBlock={allowAnswerBlock}\n onAnswerBlockAdd={onAnswerBlockAdd}\n latex={latex}\n onChange={onChange}\n onFocus={onFocus}\n onBlur={onBlur}\n error={error}\n maxResponseAreas={maxResponseAreas}\n />\n {(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (\n <DoneButton onClick={onDone} />\n )}\n </div>\n );\n }\n}\nconst styles = () => ({\n pureToolbar: {\n display: 'flex',\n width: '100%',\n zIndex: 8,\n alignItems: 'center'\n }\n});\n\nexport const PureToolbar = withStyles(styles)(RawPureToolbar);\n"],"file":"index.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
  });
@@ -19,37 +21,39 @@ var _mathInput = require("@pie-lib/math-input");
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
23
 
22
- 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); }
23
-
24
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
25
 
26
26
  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); } }
27
27
 
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
29
 
30
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
30
+ 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); }
31
31
 
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
33
 
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
+ 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); }; }
35
35
 
36
- 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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
36
+ 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); }
37
37
 
38
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
38
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
+
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
43
 
40
44
  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; }
41
45
 
42
46
  var log = (0, _debug["default"])('@pie-lib:math-toolbar:math-preview');
43
47
 
44
- var RawMathPreview =
45
- /*#__PURE__*/
46
- function (_React$Component) {
48
+ var RawMathPreview = /*#__PURE__*/function (_React$Component) {
47
49
  _inherits(RawMathPreview, _React$Component);
48
50
 
51
+ var _super = _createSuper(RawMathPreview);
52
+
49
53
  function RawMathPreview() {
50
54
  _classCallCheck(this, RawMathPreview);
51
55
 
52
- return _possibleConstructorReturn(this, _getPrototypeOf(RawMathPreview).apply(this, arguments));
56
+ return _super.apply(this, arguments);
53
57
  }
54
58
 
55
59
  _createClass(RawMathPreview, [{
@@ -62,11 +66,11 @@ function (_React$Component) {
62
66
  isSelected = _this$props.isSelected,
63
67
  onFocus = _this$props.onFocus,
64
68
  onBlur = _this$props.onBlur;
65
- return _react["default"].createElement("div", {
69
+ return /*#__PURE__*/_react["default"].createElement("div", {
66
70
  className: (0, _classnames["default"])(classes.root, isSelected && classes.selected)
67
- }, ' ', _react["default"].createElement("span", {
71
+ }, ' ', /*#__PURE__*/_react["default"].createElement("span", {
68
72
  className: classes.insideOverlay
69
- }), _react["default"].createElement(_mathInput.mq.Static, {
73
+ }), /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
70
74
  latex: latex,
71
75
  onFocus: onFocus,
72
76
  onBlur: onBlur
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/math-preview.jsx"],"names":["log","RawMathPreview","props","node","data","latex","get","classes","isSelected","onFocus","onBlur","root","selected","insideOverlay","React","Component","PropTypes","string","object","bool","func","mp","theme","display","alignItems","position","border","outline","boxShadow","borderRadius","fontFamily","paddingTop","minWidth","lineHeight","top","left","right","borderTop","palette","primary","main","bottom"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,oCAAN,CAAZ;;IAEaC,c;;;;;;;;;;;;;6BAUF;AACPD,MAAAA,GAAG,CAAC,iBAAD,EAAoB,KAAKE,KAAL,CAAWC,IAAX,CAAgBC,IAApC,CAAH;AACA,UAAMC,KAAK,GAAG,KAAKH,KAAL,CAAWC,IAAX,CAAgBC,IAAhB,CAAqBE,GAArB,CAAyB,OAAzB,CAAd;AAFO,wBAG0C,KAAKJ,KAH/C;AAAA,UAGCK,OAHD,eAGCA,OAHD;AAAA,UAGUC,UAHV,eAGUA,UAHV;AAAA,UAGsBC,OAHtB,eAGsBA,OAHtB;AAAA,UAG+BC,MAH/B,eAG+BA,MAH/B;AAIP,aACE;AAAK,QAAA,SAAS,EAAE,4BAAWH,OAAO,CAACI,IAAnB,EAAyBH,UAAU,IAAID,OAAO,CAACK,QAA/C;AAAhB,SACG,GADH,EAEE;AAAM,QA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AACTD,UAAAA,GAAG,EAAE,SADI;AAETE,UAAAA,KAAK,EAAE;AAFE,SAToB;AAa/B,4BAAoB;AAClBF,UAAAA,GAAG,EAAE;AADa;AAbW,OApB7B;AAqCJ,wCAAkC;AAChC,oBAAY;AACVA,UAAAA,GAAG,EAAE,QADK;AAEVE,UAAAA,KAAK,EAAE;AAFG;AADoB,OArC9B;AA2CJ,qCAA+B;AAC7Bb,QAAAA,OAAO,EAAE;AADoB,OA3C3B;AA8CJ,oCAA8B;AAC5BA,QAAAA,OAAO,EAAE;AADmB,OA9C1B;AAiDJ,6BAAuB;AACrBc,QAAAA,SAAS,EAAE,sBADU;AAErBN,QAAAA,UAAU,EAAE;AAFS,OAjDnB;AAqDJ,6BAAuB;AACrBE,QAAAA,UAAU,EAAE;AADS;AArDnB,KADa;AA0DnBrB,IAAAA,QAAQ,EAAE;AACRc,MAAAA,MAAM,sBAAeJ,KAAK,CAACgB,OAAN,CAAcC,OAAd,CAAsBC,IAArC,CADE;AAER,2BAAqB;AACnBd,QAAAA,MAAM,EAAE;AADW;AAFb,KA1DS;AAgEnBb,IAAAA,aAAa,EAAE;AACbY,MAAAA,QAAQ,EAAE,UADG;AAEbgB,MAAAA,MAAM,EAAE,CAFK;AAGbN,MAAAA,IAAI,EAAE,CAHO;AAIbC,MAAAA,KAAK,EAAE,CAJM;AAKbF,MAAAA,GAAG,EAAE;AALQ;AAhEI,GAAL;AAAA,CAAhB;;eAyEe,wBAAWb,EAAX,EAAepB,cAAf,C","sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport { mq } from '@pie-lib/math-input';\n\nconst log = debug('@pie-lib:math-toolbar:math-preview');\n\nexport class RawMathPreview extends React.Component {\n static propTypes = {\n latex: PropTypes.string,\n node: PropTypes.object,\n classes: PropTypes.object,\n isSelected: PropTypes.bool,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func\n };\n\n render() {\n log('[render] data: ', this.props.node.data);\n const latex = this.props.node.data.get('latex');\n const { classes, isSelected, onFocus, onBlur } = this.props;\n return (\n <div className={classNames(classes.root, isSelected && classes.selected)}>\n {' '}\n <span className={classes.insideOverlay} />\n <mq.Static latex={latex} onFocus={onFocus} onBlur={onBlur} />\n </div>\n );\n }\n}\n\nconst mp = theme => ({\n root: {\n display: 'inline-flex',\n alignItems: 'center',\n position: 'relative',\n '& > .mq-math-mode': {\n border: 'solid 1px lightgrey'\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: 'solid 1px black',\n borderRadius: '0px'\n },\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'\n },\n '& .mq-overarrow-inner': {\n paddingTop: '0 !important',\n border: 'none !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important'\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px'\n },\n '&:after': {\n top: '-2.36em',\n right: '-1px'\n },\n '&.mq-empty:after': {\n top: '-0.45em'\n }\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px'\n }\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important'\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important'\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important'\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85\n }\n },\n selected: {\n border: `solid 1px ${theme.palette.primary.main}`,\n '& > .mq-math-mode': {\n border: 'solid 0px lightgrey'\n }\n },\n insideOverlay: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n top: 0\n }\n});\n\nexport default withStyles(mp)(RawMathPreview);\n"],"file":"math-preview.js"}
1
+ {"version":3,"sources":["../src/math-preview.jsx"],"names":["log","RawMathPreview","props","node","data","latex","get","classes","isSelected","onFocus","onBlur","root","selected","insideOverlay","React","Component","PropTypes","string","object","bool","func","mp","theme","display","alignItems","position","border","outline","boxShadow","borderRadius","fontFamily","paddingTop","minWidth","lineHeight","top","left","right","borderTop","palette","primary","main","bottom"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,oCAAN,CAAZ;;IAEaC,c;;;;;;;;;;;;;WAUX,kBAAS;AACPD,MAAAA,GAAG,CAAC,iBAAD,EAAoB,KAAKE,KAAL,CAAWC,IAAX,CAAgBC,IAApC,CAAH;AACA,UAAMC,KAAK,GAAG,KAAKH,KAAL,CAAWC,IAAX,CAAgBC,IAAhB,CAAqBE,GAArB,CAAyB,OAAzB,CAAd;AACA,wBAAiD,KAAKJ,KAAtD;AAAA,UAAQK,OAAR,eAAQA,OAAR;AAAA,UAAiBC,UAAjB,eAAiBA,UAAjB;AAAA,UAA6BC,OAA7B,eAA6BA,OAA7B;AAAA,UAAsCC,MAAtC,eAAsCA,MAAtC;AACA,0BACE;AAAK,QAAA,SAAS,EAAE,4BAAWH,OAAO,CAACI,IAAnB,EAAyBH,UAAU,IAAID,OAAO,CAACK,QAA/C;AAAhB,SACG,GADH,eAEE;AAAM,QAAA,SAAS,EAAEL,OAAO,CAACM;AAAzB,QAFF,eAGE,gCAAC,aAAD,CAAI,MAAJ;AAAW,QAAA,KAAK,EAAER,KAAlB;AAAyB,QAAA,OAAO,EAAEI,OAAlC;AAA2C,QAAA,MAAM,EAAEC;AAAnD,QAHF,CADF;AAOD;;;;EArBiCI,kBAAMC,S;;;;gBAA7Bd,c,eACQ;AACjBI,EAAAA,KAAK,EAAEW,sBAAUC,MADA;AAEjBd,EAAAA,IAAI,EAAEa,sBAAUE,MAFC;AAGjBX,EAAAA,OAAO,EAAES,sBAAUE,MAHF;AAIjBV,EAAAA,UAAU,EAAEQ,sBAAUG,IAJL;AAKjBV,EAAAA,OAAO,EAAEO,sBAAUI,IALF;AAMjBV,EAAAA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BE,QAAAA,UAAU,EAAE;AADS;AArDnB,KADa;AA0DnBrB,IAAAA,QAAQ,EAAE;AACRc,MAAAA,MAAM,sBAAeJ,KAAK,CAACgB,OAAN,CAAcC,OAAd,CAAsBC,IAArC,CADE;AAER,2BAAqB;AACnBd,QAAAA,MAAM,EAAE;AADW;AAFb,KA1DS;AAgEnBb,IAAAA,aAAa,EAAE;AACbY,MAAAA,QAAQ,EAAE,UADG;AAEbgB,MAAAA,MAAM,EAAE,CAFK;AAGbN,MAAAA,IAAI,EAAE,CAHO;AAIbC,MAAAA,KAAK,EAAE,CAJM;AAKbF,MAAAA,GAAG,EAAE;AALQ;AAhEI,GAAL;AAAA,CAAhB;;eAyEe,wBAAWb,EAAX,EAAepB,cAAf,C","sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport debug from 'debug';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport { mq } from '@pie-lib/math-input';\n\nconst log = debug('@pie-lib:math-toolbar:math-preview');\n\nexport class RawMathPreview extends React.Component {\n static propTypes = {\n latex: PropTypes.string,\n node: PropTypes.object,\n classes: PropTypes.object,\n isSelected: PropTypes.bool,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func\n };\n\n render() {\n log('[render] data: ', this.props.node.data);\n const latex = this.props.node.data.get('latex');\n const { classes, isSelected, onFocus, onBlur } = this.props;\n return (\n <div className={classNames(classes.root, isSelected && classes.selected)}>\n {' '}\n <span className={classes.insideOverlay} />\n <mq.Static latex={latex} onFocus={onFocus} onBlur={onBlur} />\n </div>\n );\n }\n}\n\nconst mp = theme => ({\n root: {\n display: 'inline-flex',\n alignItems: 'center',\n position: 'relative',\n '& > .mq-math-mode': {\n border: 'solid 1px lightgrey'\n },\n '& > .mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: 'solid 1px black',\n borderRadius: '0px'\n },\n '& *': {\n fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'\n },\n '& .mq-overarrow-inner': {\n paddingTop: '0 !important',\n border: 'none !important'\n },\n '& .mq-overarrow.mq-arrow-both': {\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important'\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px'\n },\n '&:after': {\n top: '-2.36em',\n right: '-1px'\n },\n '&.mq-empty:after': {\n top: '-0.45em'\n }\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px'\n }\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important'\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important'\n },\n '& .mq-longdiv-inner': {\n borderTop: '1px solid !important',\n paddingTop: '1.5px !important'\n },\n '& .mq-parallelogram': {\n lineHeight: 0.85\n }\n },\n selected: {\n border: `solid 1px ${theme.palette.primary.main}`,\n '& > .mq-math-mode': {\n border: 'solid 0px lightgrey'\n }\n },\n insideOverlay: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n top: 0\n }\n});\n\nexport default withStyles(mp)(RawMathPreview);\n"],"file":"math-preview.js"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.8",
6
+ "version": "1.9.1",
7
7
  "description": "Math toolbar for editing math equations",
8
8
  "keywords": [
9
9
  "math",
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@material-ui/core": "^3.8.3",
21
21
  "@material-ui/icons": "^3.0.2",
22
- "@pie-lib/math-input": "^6.6.8",
22
+ "@pie-lib/math-input": "^6.6.9",
23
23
  "classnames": "^2.2.6",
24
24
  "debug": "^4.1.1",
25
25
  "keycode": "^2.2.0"
@@ -32,5 +32,5 @@
32
32
  "@pie-lib/test-utils": "^0.2.19"
33
33
  },
34
34
  "scripts": {},
35
- "gitHead": "8c254f4c516c9f4e67109accdb2ad415e1f6cea4"
35
+ "gitHead": "7af4bd333e7b4ae5720a863ee443377274cc6181"
36
36
  }
@@ -53,7 +53,7 @@ export class EditorAndPad extends React.Component {
53
53
  constructor(props) {
54
54
  super(props);
55
55
 
56
- this.state = { equationEditor: 'item-authoring' };
56
+ this.state = { equationEditor: 'item-authoring', addDisabled: false };
57
57
  }
58
58
 
59
59
  componentDidMount() {
@@ -86,11 +86,23 @@ export class EditorAndPad extends React.Component {
86
86
  }
87
87
  };
88
88
 
89
+ updateDisable = isEdit => {
90
+ const { maxResponseAreas } = this.props;
91
+
92
+ if (maxResponseAreas) {
93
+ const shouldDisable = this.checkResponseAreasNumber(maxResponseAreas, isEdit);
94
+
95
+ this.setState({ addDisabled: shouldDisable });
96
+ }
97
+ };
98
+
89
99
  onAnswerBlockClick = () => {
90
100
  this.props.onAnswerBlockAdd();
91
101
  this.onClick({
92
102
  type: 'answer'
93
103
  });
104
+
105
+ this.updateDisable(true);
94
106
  };
95
107
 
96
108
  onEditorChange = latex => {
@@ -98,6 +110,8 @@ export class EditorAndPad extends React.Component {
98
110
 
99
111
  updateSpans();
100
112
 
113
+ this.updateDisable(true);
114
+
101
115
  // if no decimals are allowed and the last change is a decimal dot, discard the change
102
116
  if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {
103
117
  this.input.clear();
@@ -137,6 +151,18 @@ export class EditorAndPad extends React.Component {
137
151
  this.setState({ equationEditor: evt.target.value });
138
152
  };
139
153
 
154
+ checkResponseAreasNumber = (maxResponseAreas, isEdit) => {
155
+ const { latex } = (this.input && this.input.props) || {};
156
+
157
+ if (latex) {
158
+ const count = (latex.match(/answerBlock/g) || []).length;
159
+
160
+ return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
161
+ }
162
+
163
+ return false;
164
+ };
165
+
140
166
  render() {
141
167
  const {
142
168
  classNames,
@@ -150,9 +176,11 @@ export class EditorAndPad extends React.Component {
150
176
  latex,
151
177
  onFocus,
152
178
  onBlur,
153
- classes
179
+ classes,
180
+ error
154
181
  } = this.props;
155
182
  const shouldShowKeypad = !controlledKeypad || (controlledKeypad && showKeypad);
183
+ const { addDisabled } = this.state;
156
184
 
157
185
  log('[render]', latex);
158
186
 
@@ -181,18 +209,26 @@ export class EditorAndPad extends React.Component {
181
209
  </Select>
182
210
  </InputContainer>
183
211
  )}
184
- <mq.Input
185
- onFocus={onFocus}
186
- onBlur={onBlur}
187
- className={cx(
188
- classes.mathEditor,
189
- classNames.editor,
190
- !controlledKeypadMode ? classes.longMathEditor : ''
191
- )}
192
- innerRef={r => (this.input = r)}
193
- latex={latex}
194
- onChange={this.onEditorChange}
195
- />
212
+ <div className={cx(classes.inputContainer, error ? classes.error : '')}>
213
+ <mq.Input
214
+ onFocus={() => {
215
+ onFocus && onFocus();
216
+ this.updateDisable(false);
217
+ }}
218
+ onBlur={() => {
219
+ this.updateDisable(false);
220
+ onBlur && onBlur();
221
+ }}
222
+ className={cx(
223
+ classes.mathEditor,
224
+ classNames.editor,
225
+ !controlledKeypadMode ? classes.longMathEditor : ''
226
+ )}
227
+ innerRef={r => (this.input = r)}
228
+ latex={latex}
229
+ onChange={this.onEditorChange}
230
+ />
231
+ </div>
196
232
  </div>
197
233
  {allowAnswerBlock && (
198
234
  <Button
@@ -200,6 +236,7 @@ export class EditorAndPad extends React.Component {
200
236
  type="primary"
201
237
  style={{ bottom: shouldShowKeypad ? '320px' : '20px' }}
202
238
  onClick={this.onAnswerBlockClick}
239
+ disabled={addDisabled}
203
240
  >
204
241
  + Response Area
205
242
  </Button>
@@ -262,9 +299,7 @@ const styles = theme => ({
262
299
  maxWidth: '400px',
263
300
  color: color.text(),
264
301
  backgroundColor: color.background(),
265
- padding: theme.spacing.unit,
266
- marginTop: theme.spacing.unit,
267
- marginBottom: theme.spacing.unit
302
+ padding: theme.spacing.unit
268
303
  },
269
304
  longMathEditor: {
270
305
  maxWidth: '500px'
@@ -315,6 +350,18 @@ const styles = theme => ({
315
350
  '& .mq-parallelogram': {
316
351
  lineHeight: 0.85
317
352
  }
353
+ },
354
+ inputContainer: {
355
+ minWidth: '500px',
356
+ maxWidth: '900px',
357
+ minHeight: '40px',
358
+ width: '100%',
359
+ display: 'flex',
360
+ marginTop: theme.spacing.unit,
361
+ marginBottom: theme.spacing.unit
362
+ },
363
+ error: {
364
+ border: '2px solid red'
318
365
  }
319
366
  });
320
367
 
package/src/index.jsx CHANGED
@@ -79,7 +79,9 @@ export class MathToolbar extends React.Component {
79
79
  showKeypad,
80
80
  onFocus,
81
81
  onBlur,
82
- hideDoneButton
82
+ hideDoneButton,
83
+ error,
84
+ maxResponseAreas
83
85
  } = this.props;
84
86
 
85
87
  return (
@@ -100,6 +102,8 @@ export class MathToolbar extends React.Component {
100
102
  controlledKeypad={controlledKeypad}
101
103
  controlledKeypadMode={controlledKeypadMode}
102
104
  hideDoneButton={hideDoneButton}
105
+ error={error}
106
+ maxResponseAreas={maxResponseAreas}
103
107
  />
104
108
  );
105
109
  }
@@ -144,7 +148,9 @@ export class RawPureToolbar extends React.Component {
144
148
  onFocus,
145
149
  onBlur,
146
150
  hideDoneButton,
147
- classes
151
+ classes,
152
+ error,
153
+ maxResponseAreas
148
154
  } = this.props;
149
155
 
150
156
  return (
@@ -165,6 +171,8 @@ export class RawPureToolbar extends React.Component {
165
171
  onChange={onChange}
166
172
  onFocus={onFocus}
167
173
  onBlur={onBlur}
174
+ error={error}
175
+ maxResponseAreas={maxResponseAreas}
168
176
  />
169
177
  {(!controlledKeypad || (controlledKeypad && showKeypad)) && !hideDoneButton && (
170
178
  <DoneButton onClick={onDone} />