@pie-lib/math-toolbar 1.31.1 → 1.32.0-mui-update.0

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.
@@ -1,74 +1,242 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = exports.EditorAndPad = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
10
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
11
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
22
13
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
14
  var _react = _interopRequireDefault(require("react"));
25
-
26
15
  var _debug = _interopRequireDefault(require("debug"));
27
-
28
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
17
  var _classnames = _interopRequireDefault(require("classnames"));
31
-
32
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
33
-
34
- var _styles = require("@material-ui/core/styles");
35
-
36
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
37
-
38
- var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
39
-
18
+ var _Button = _interopRequireDefault(require("@mui/material/Button"));
19
+ var _styles = require("@mui/material/styles");
20
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
21
+ var _Select = _interopRequireDefault(require("@mui/material/Select"));
40
22
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
41
-
42
23
  var _mathInput = require("@pie-lib/math-input");
43
-
44
24
  var _renderUi = require("@pie-lib/render-ui");
45
-
46
25
  var _utils = require("./utils");
47
-
48
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
49
-
50
- 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; } }
51
-
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; }
53
-
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) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
55
-
26
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
27
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
28
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
29
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
56
30
  var _mq$CommonMqStyles = _mathInput.mq.CommonMqStyles,
57
- commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
58
- commonMqKeyboardStyles = _mq$CommonMqStyles.commonMqKeyboardStyles,
59
- longdivStyles = _mq$CommonMqStyles.longdivStyles,
60
- supsubStyles = _mq$CommonMqStyles.supsubStyles;
31
+ commonMqFontStyles = _mq$CommonMqStyles.commonMqFontStyles,
32
+ commonMqKeyboardStyles = _mq$CommonMqStyles.commonMqKeyboardStyles,
33
+ longdivStyles = _mq$CommonMqStyles.longdivStyles,
34
+ supsubStyles = _mq$CommonMqStyles.supsubStyles;
61
35
  var log = (0, _debug["default"])('@pie-lib:math-toolbar:editor-and-pad');
62
36
  var decimalRegex = /\.|,/g;
63
-
37
+ var MathToolbarContainer = (0, _styles.styled)('div')(function (_ref) {
38
+ var theme = _ref.theme;
39
+ return {
40
+ zIndex: 9,
41
+ position: 'relative',
42
+ textAlign: 'center',
43
+ width: 'auto',
44
+ '& > .mq-math-mode': {
45
+ border: 'solid 1px lightgrey'
46
+ },
47
+ '& > .mq-focused': {
48
+ outline: 'none',
49
+ boxShadow: 'none',
50
+ border: "dotted 1px ".concat(theme.palette.primary.main),
51
+ borderRadius: '0px'
52
+ },
53
+ '& .mq-overarrow-inner': {
54
+ border: 'none !important',
55
+ paddingTop: '0 !important'
56
+ },
57
+ '& .mq-overarrow-inner-right': {
58
+ display: 'none !important'
59
+ },
60
+ '& .mq-overarrow-inner-left': {
61
+ display: 'none !important'
62
+ },
63
+ '& .mq-longdiv-inner': {
64
+ borderTop: '1px solid !important',
65
+ paddingTop: '1.5px !important'
66
+ },
67
+ '& .mq-overarrow.mq-arrow-both': {
68
+ top: '7.8px',
69
+ marginTop: '0px',
70
+ minWidth: '1.23em'
71
+ },
72
+ '& .mq-parallelogram': {
73
+ lineHeight: 0.85
74
+ }
75
+ };
76
+ });
77
+ var InputAndTypeContainer = (0, _styles.styled)('div')(function (_ref2) {
78
+ var theme = _ref2.theme,
79
+ hide = _ref2.hide;
80
+ return {
81
+ display: hide ? 'none' : 'flex',
82
+ alignItems: 'center',
83
+ '& .mq-editable-field .mq-cursor': {
84
+ top: '-4px'
85
+ },
86
+ '& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
87
+ paddingTop: '18px'
88
+ },
89
+ '& .mq-math-mode .mq-overarrow': {
90
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
91
+ },
92
+ '& .mq-math-mode .mq-overline .mq-overline-inner': {
93
+ paddingTop: '0.4em !important'
94
+ },
95
+ '& .mq-overarrow.mq-arrow-both': {
96
+ minWidth: '1.23em',
97
+ '& *': {
98
+ lineHeight: '1 !important'
99
+ },
100
+ '&:before': {
101
+ top: '-0.45em',
102
+ left: '-1px'
103
+ },
104
+ '&:after': {
105
+ position: 'absolute !important',
106
+ top: '0px !important',
107
+ right: '-2px'
108
+ },
109
+ '&.mq-empty:after': {
110
+ top: '-0.45em'
111
+ }
112
+ },
113
+ '& .mq-overarrow.mq-arrow-right': {
114
+ '&:before': {
115
+ top: '-0.4em',
116
+ right: '-1px'
117
+ }
118
+ },
119
+ '& *': _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), supsubStyles), longdivStyles), {}, {
120
+ '& .mq-math-mode .mq-sqrt-prefix': {
121
+ verticalAlign: 'baseline !important',
122
+ top: '1px !important',
123
+ left: '-0.1em !important'
124
+ },
125
+ '& .mq-math-mode .mq-overarc ': {
126
+ paddingTop: '0.45em !important'
127
+ },
128
+ '& .mq-math-mode .mq-empty': {
129
+ padding: '9px 1px !important'
130
+ },
131
+ '& .mq-math-mode .mq-root-block': {
132
+ paddingTop: '10px'
133
+ },
134
+ '& .mq-scaled .mq-sqrt-prefix': {
135
+ top: '0 !important'
136
+ },
137
+ '& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
138
+ marginLeft: '4px !important',
139
+ paddingTop: '6px !important',
140
+ paddingLeft: '6px !important'
141
+ },
142
+ '& .mq-math-mode .mq-paren': {
143
+ verticalAlign: 'top !important',
144
+ padding: '1px 0.1em !important'
145
+ },
146
+ '& .mq-math-mode .mq-sqrt-stem': {
147
+ borderTop: '0.07em solid',
148
+ marginLeft: '-1.5px',
149
+ marginTop: '-2px !important',
150
+ paddingTop: '5px !important'
151
+ },
152
+ '& .mq-math-mode .mq-denominator': {
153
+ marginTop: '-5px !important',
154
+ padding: '0.5em 0.1em 0.1em !important'
155
+ },
156
+ '& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
157
+ padding: '0 0.1em !important',
158
+ paddingBottom: '0 !important',
159
+ marginBottom: '-2px'
160
+ }
161
+ }),
162
+ '& span[data-prime="true"]': {
163
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
164
+ }
165
+ };
166
+ });
167
+ var SelectContainer = (0, _styles.styled)(_renderUi.InputContainer)({
168
+ flex: 'initial',
169
+ width: '25%',
170
+ minWidth: '100px',
171
+ marginLeft: '15px',
172
+ marginTop: '5px',
173
+ marginBottom: '5px',
174
+ marginRight: '5px',
175
+ '& label': {
176
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
177
+ },
178
+ '& div': {
179
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
180
+ }
181
+ });
182
+ var StyledSelect = (0, _styles.styled)(_Select["default"])({});
183
+ var InputContainerDiv = (0, _styles.styled)('div')(function (_ref3) {
184
+ var theme = _ref3.theme,
185
+ error = _ref3.error;
186
+ return _objectSpread(_objectSpread({
187
+ minWidth: '500px',
188
+ maxWidth: '900px',
189
+ minHeight: '30px',
190
+ width: '100%',
191
+ display: 'flex',
192
+ marginTop: theme.spacing(1),
193
+ marginBottom: theme.spacing(1)
194
+ }, error && {
195
+ border: '2px solid red'
196
+ }), {}, {
197
+ '& .mq-sqrt-prefix .mq-scaled': {
198
+ verticalAlign: 'middle !important'
199
+ }
200
+ });
201
+ });
202
+ var MathEditor = (0, _styles.styled)(_mathInput.mq.Input)(function (_ref4) {
203
+ var controlledKeypadMode = _ref4.controlledKeypadMode;
204
+ return {
205
+ maxWidth: controlledKeypadMode ? '400px' : '500px',
206
+ color: _renderUi.color.text(),
207
+ backgroundColor: _renderUi.color.background(),
208
+ padding: '2px'
209
+ };
210
+ });
211
+ var AddAnswerBlockButton = (0, _styles.styled)(_Button["default"])({
212
+ position: 'absolute',
213
+ right: '12px',
214
+ border: '1px solid lightgrey'
215
+ });
216
+ var StyledHr = (0, _styles.styled)('hr')(function (_ref5) {
217
+ var theme = _ref5.theme;
218
+ return {
219
+ padding: 0,
220
+ margin: 0,
221
+ height: '1px',
222
+ border: 'none',
223
+ borderBottom: "solid 1px ".concat(theme.palette.primary.main)
224
+ };
225
+ });
226
+ var KeyboardContainer = (0, _styles.styled)(_mathInput.HorizontalKeypad)(function (_ref6) {
227
+ var mode = _ref6.mode;
228
+ return _objectSpread(_objectSpread({}, commonMqKeyboardStyles), mode === 'language' && {
229
+ '& *': {
230
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
231
+ }
232
+ });
233
+ });
64
234
  var toNodeData = function toNodeData(data) {
65
235
  if (!data) {
66
236
  return;
67
237
  }
68
-
69
238
  var type = data.type,
70
- value = data.value;
71
-
239
+ value = data.value;
72
240
  if (type === 'command' || type === 'cursor') {
73
241
  return data;
74
242
  } else if (type === 'answer') {
@@ -86,42 +254,32 @@ var toNodeData = function toNodeData(data) {
86
254
  };
87
255
  }
88
256
  };
89
-
90
- var EditorAndPad = /*#__PURE__*/function (_React$Component) {
91
- (0, _inherits2["default"])(EditorAndPad, _React$Component);
92
-
93
- var _super = _createSuper(EditorAndPad);
94
-
257
+ var EditorAndPad = exports.EditorAndPad = /*#__PURE__*/function (_React$Component) {
95
258
  function EditorAndPad(props) {
96
259
  var _this;
97
-
98
260
  (0, _classCallCheck2["default"])(this, EditorAndPad);
99
- _this = _super.call(this, props);
100
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onClick", function (data) {
261
+ _this = _callSuper(this, EditorAndPad, [props]);
262
+ (0, _defineProperty2["default"])(_this, "onClick", function (data) {
101
263
  var _this$props = _this.props,
102
- noDecimal = _this$props.noDecimal,
103
- noLatexHandling = _this$props.noLatexHandling,
104
- onChange = _this$props.onChange;
264
+ noDecimal = _this$props.noDecimal,
265
+ noLatexHandling = _this$props.noLatexHandling,
266
+ onChange = _this$props.onChange;
105
267
  var c = toNodeData(data);
106
268
  log('mathChange: ', c);
107
-
108
269
  if (noLatexHandling) {
109
270
  onChange(c.value);
110
271
  return;
111
- } // if decimals are not allowed for this response, we discard the input
112
-
272
+ }
113
273
 
274
+ // if decimals are not allowed for this response, we discard the input
114
275
  if (noDecimal && (c.value === '.' || c.value === ',')) {
115
276
  return;
116
277
  }
117
-
118
278
  if (!c) {
119
279
  return;
120
280
  }
121
-
122
281
  if (c.type === 'clear') {
123
282
  log('call clear...');
124
-
125
283
  _this.input.clear();
126
284
  } else if (c.type === 'command') {
127
285
  _this.input.command(c.value);
@@ -133,51 +291,42 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
133
291
  _this.input.write(c.value);
134
292
  }
135
293
  });
136
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateDisable", function (isEdit) {
294
+ (0, _defineProperty2["default"])(_this, "updateDisable", function (isEdit) {
137
295
  var maxResponseAreas = _this.props.maxResponseAreas;
138
-
139
296
  if (maxResponseAreas) {
140
297
  var shouldDisable = _this.checkResponseAreasNumber(maxResponseAreas, isEdit);
141
-
142
298
  _this.setState({
143
299
  addDisabled: shouldDisable
144
300
  });
145
301
  }
146
302
  });
147
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAnswerBlockClick", function () {
303
+ (0, _defineProperty2["default"])(_this, "onAnswerBlockClick", function () {
148
304
  _this.props.onAnswerBlockAdd();
149
-
150
305
  _this.onClick({
151
306
  type: 'answer'
152
307
  });
153
-
154
308
  _this.updateDisable(true);
155
309
  });
156
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditorChange", function (latex) {
310
+ (0, _defineProperty2["default"])(_this, "onEditorChange", function (latex) {
157
311
  var _this$props2 = _this.props,
158
- onChange = _this$props2.onChange,
159
- noDecimal = _this$props2.noDecimal;
312
+ onChange = _this$props2.onChange,
313
+ noDecimal = _this$props2.noDecimal;
160
314
  (0, _mathInput.updateSpans)();
161
315
  (0, _utils.markFractionBaseSuperscripts)();
316
+ _this.updateDisable(true);
162
317
 
163
- _this.updateDisable(true); // if no decimals are allowed and the last change is a decimal dot, discard the change
164
-
165
-
318
+ // if no decimals are allowed and the last change is a decimal dot, discard the change
166
319
  if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && _this.input) {
167
320
  _this.input.clear();
168
-
169
321
  _this.input.write(latex.replace(decimalRegex, ''));
170
-
171
322
  return;
172
- } // eslint-disable-next-line no-useless-escape
173
-
323
+ }
174
324
 
325
+ // eslint-disable-next-line no-useless-escape
175
326
  var regexMatch = latex.match(/[0-9]\\ \\frac\{[^\{]*\}\{ \}/);
176
-
177
327
  if (_this.input && regexMatch && regexMatch !== null && regexMatch !== void 0 && regexMatch.length) {
178
328
  try {
179
329
  _this.input.mathField.__controller.cursor.insLeftOf(_this.input.mathField.__controller.cursor.parent[-1].parent);
180
-
181
330
  _this.input.mathField.el().dispatchEvent(new KeyboardEvent('keydown', {
182
331
  keyCode: 8
183
332
  }));
@@ -185,26 +334,22 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
185
334
  // eslint-disable-next-line no-console
186
335
  console.error(e.toString());
187
336
  }
188
-
189
337
  return;
190
338
  }
191
-
192
339
  onChange(latex);
193
340
  });
194
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onEditorTypeChange", function (evt) {
341
+ (0, _defineProperty2["default"])(_this, "onEditorTypeChange", function (evt) {
195
342
  _this.setState({
196
343
  equationEditor: evt.target.value
197
344
  });
198
345
  });
199
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "checkResponseAreasNumber", function (maxResponseAreas, isEdit) {
200
- var _ref = _this.input && _this.input.props || {},
201
- latex = _ref.latex;
202
-
346
+ (0, _defineProperty2["default"])(_this, "checkResponseAreasNumber", function (maxResponseAreas, isEdit) {
347
+ var _ref7 = _this.input && _this.input.props || {},
348
+ latex = _ref7.latex;
203
349
  if (latex) {
204
350
  var count = (latex.match(/answerBlock/g) || []).length;
205
351
  return isEdit ? count === maxResponseAreas - 1 : count === maxResponseAreas;
206
352
  }
207
-
208
353
  return false;
209
354
  });
210
355
  _this.state = {
@@ -213,8 +358,8 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
213
358
  };
214
359
  return _this;
215
360
  }
216
-
217
- (0, _createClass2["default"])(EditorAndPad, [{
361
+ (0, _inherits2["default"])(EditorAndPad, _React$Component);
362
+ return (0, _createClass2["default"])(EditorAndPad, [{
218
363
  key: "componentDidMount",
219
364
  value: function componentDidMount() {
220
365
  if (this.input && this.props.autoFocus) {
@@ -229,63 +374,53 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
229
374
  function shouldComponentUpdate(nextProps, nextState) {
230
375
  var inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
231
376
  log('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
232
-
233
377
  if (!(0, _isEqual["default"])(this.props.error, nextProps.error)) {
234
378
  return true;
235
379
  }
236
-
237
380
  if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
238
381
  return true;
239
382
  }
240
-
241
383
  if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {
242
384
  return true;
243
385
  }
244
-
245
386
  if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {
246
387
  return true;
247
388
  }
248
-
249
389
  if (!inputIsDifferent && this.props.controlledKeypad) {
250
390
  return this.props.showKeypad !== nextProps.showKeypad;
251
391
  }
252
-
253
392
  return inputIsDifferent;
254
393
  }
255
394
  }, {
256
395
  key: "render",
257
396
  value: function render() {
258
397
  var _this2 = this;
259
-
260
398
  var _this$props3 = this.props,
261
- classNames = _this$props3.classNames,
262
- keypadMode = _this$props3.keypadMode,
263
- allowAnswerBlock = _this$props3.allowAnswerBlock,
264
- additionalKeys = _this$props3.additionalKeys,
265
- controlledKeypad = _this$props3.controlledKeypad,
266
- controlledKeypadMode = _this$props3.controlledKeypadMode,
267
- showKeypad = _this$props3.showKeypad,
268
- setKeypadInteraction = _this$props3.setKeypadInteraction,
269
- noDecimal = _this$props3.noDecimal,
270
- hideInput = _this$props3.hideInput,
271
- layoutForKeyPad = _this$props3.layoutForKeyPad,
272
- latex = _this$props3.latex,
273
- _onFocus = _this$props3.onFocus,
274
- _onBlur = _this$props3.onBlur,
275
- classes = _this$props3.classes,
276
- error = _this$props3.error;
399
+ classNames = _this$props3.classNames,
400
+ keypadMode = _this$props3.keypadMode,
401
+ allowAnswerBlock = _this$props3.allowAnswerBlock,
402
+ additionalKeys = _this$props3.additionalKeys,
403
+ controlledKeypad = _this$props3.controlledKeypad,
404
+ controlledKeypadMode = _this$props3.controlledKeypadMode,
405
+ showKeypad = _this$props3.showKeypad,
406
+ setKeypadInteraction = _this$props3.setKeypadInteraction,
407
+ noDecimal = _this$props3.noDecimal,
408
+ hideInput = _this$props3.hideInput,
409
+ layoutForKeyPad = _this$props3.layoutForKeyPad,
410
+ latex = _this$props3.latex,
411
+ _onFocus = _this$props3.onFocus,
412
+ _onBlur = _this$props3.onBlur,
413
+ error = _this$props3.error;
277
414
  var shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
278
415
  var addDisabled = this.state.addDisabled;
279
416
  log('[render]', latex);
280
- return /*#__PURE__*/_react["default"].createElement("div", {
281
- className: (0, _classnames["default"])(classes.mathToolbar, classNames.mathToolbar)
282
- }, /*#__PURE__*/_react["default"].createElement("div", {
283
- className: (0, _classnames["default"])(classes.inputAndTypeContainer, (0, _defineProperty2["default"])({}, classes.hide, hideInput))
284
- }, controlledKeypadMode && /*#__PURE__*/_react["default"].createElement(_renderUi.InputContainer, {
285
- label: "Equation Editor",
286
- className: classes.selectContainer
287
- }, /*#__PURE__*/_react["default"].createElement(_Select["default"], {
288
- className: classes.select,
417
+ return /*#__PURE__*/_react["default"].createElement(MathToolbarContainer, {
418
+ className: (0, _classnames["default"])(classNames.mathToolbar)
419
+ }, /*#__PURE__*/_react["default"].createElement(InputAndTypeContainer, {
420
+ hide: hideInput
421
+ }, controlledKeypadMode && /*#__PURE__*/_react["default"].createElement(SelectContainer, {
422
+ label: "Equation Editor"
423
+ }, /*#__PURE__*/_react["default"].createElement(StyledSelect, {
289
424
  onChange: this.onEditorTypeChange,
290
425
  value: this.state.equationEditor
291
426
  }, /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
@@ -312,51 +447,43 @@ var EditorAndPad = /*#__PURE__*/function (_React$Component) {
312
447
  value: 'statistics'
313
448
  }, "Statistics"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
314
449
  value: 'item-authoring'
315
- }, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement("div", {
316
- className: (0, _classnames["default"])(classes.inputContainer, error ? classes.error : '')
317
- }, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Input, {
450
+ }, "Item Authoring"))), /*#__PURE__*/_react["default"].createElement(InputContainerDiv, {
451
+ error: error
452
+ }, /*#__PURE__*/_react["default"].createElement(MathEditor, {
318
453
  onFocus: function onFocus() {
319
454
  _onFocus && _onFocus();
320
-
321
455
  _this2.updateDisable(false);
322
456
  },
323
457
  onBlur: function onBlur(event) {
324
458
  _this2.updateDisable(false);
325
-
326
459
  _onBlur && _onBlur(event);
327
460
  },
328
- className: (0, _classnames["default"])(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
461
+ className: (0, _classnames["default"])(classNames.editor),
462
+ controlledKeypadMode: controlledKeypadMode,
329
463
  innerRef: function innerRef(r) {
330
464
  return _this2.input = r;
331
465
  },
332
466
  latex: latex,
333
467
  onChange: this.onEditorChange
334
- }))), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
335
- className: classes.addAnswerBlockButton,
468
+ }))), allowAnswerBlock && /*#__PURE__*/_react["default"].createElement(AddAnswerBlockButton, {
336
469
  type: "primary",
337
470
  style: {
338
471
  bottom: shouldShowKeypad ? '320px' : '20px'
339
472
  },
340
473
  onClick: this.onAnswerBlockClick,
341
474
  disabled: addDisabled
342
- }, "+ Response Area"), /*#__PURE__*/_react["default"].createElement("hr", {
343
- className: classes.hr
344
- }), shouldShowKeypad && /*#__PURE__*/_react["default"].createElement(_mathInput.HorizontalKeypad, {
345
- className: (0, _classnames["default"])(classes[keypadMode], classes.keyboard),
475
+ }, "+ Response Area"), /*#__PURE__*/_react["default"].createElement(StyledHr, null), shouldShowKeypad && /*#__PURE__*/_react["default"].createElement(KeyboardContainer, {
476
+ mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
346
477
  controlledKeypadMode: controlledKeypadMode,
347
478
  layoutForKeyPad: layoutForKeyPad,
348
479
  additionalKeys: additionalKeys,
349
- mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
350
480
  onClick: this.onClick,
351
481
  noDecimal: noDecimal,
352
482
  setKeypadInteraction: setKeypadInteraction
353
483
  }));
354
484
  }
355
485
  }]);
356
- return EditorAndPad;
357
486
  }(_react["default"].Component);
358
-
359
- exports.EditorAndPad = EditorAndPad;
360
487
  (0, _defineProperty2["default"])(EditorAndPad, "propTypes", {
361
488
  classNames: _propTypes["default"].object,
362
489
  keypadMode: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
@@ -377,199 +504,7 @@ exports.EditorAndPad = EditorAndPad;
377
504
  onFocus: _propTypes["default"].func,
378
505
  onBlur: _propTypes["default"].func,
379
506
  onChange: _propTypes["default"].func.isRequired,
380
- classes: _propTypes["default"].object,
381
507
  setKeypadInteraction: _propTypes["default"].func
382
508
  });
383
-
384
- var styles = function styles(theme) {
385
- return {
386
- inputAndTypeContainer: {
387
- display: 'flex',
388
- alignItems: 'center',
389
- '& .mq-editable-field .mq-cursor': {
390
- top: '-4px'
391
- },
392
- '& .mq-math-mode .mq-selection, .mq-editable-field .mq-selection': {
393
- paddingTop: '18px'
394
- },
395
- '& .mq-math-mode .mq-overarrow': {
396
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
397
- },
398
- '& .mq-math-mode .mq-overline .mq-overline-inner': {
399
- paddingTop: '0.4em !important'
400
- },
401
- '& .mq-overarrow.mq-arrow-both': {
402
- minWidth: '1.23em',
403
- '& *': {
404
- lineHeight: '1 !important'
405
- },
406
- '&:before': {
407
- top: '-0.45em',
408
- left: '-1px'
409
- },
410
- '&:after': {
411
- position: 'absolute !important',
412
- top: '0px !important',
413
- right: '-2px'
414
- },
415
- '&.mq-empty:after': {
416
- top: '-0.45em'
417
- }
418
- },
419
- '& .mq-overarrow.mq-arrow-right': {
420
- '&:before': {
421
- top: '-0.4em',
422
- right: '-1px'
423
- }
424
- },
425
- '& *': _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, commonMqFontStyles), supsubStyles), longdivStyles), {}, {
426
- '& .mq-math-mode .mq-sqrt-prefix': {
427
- verticalAlign: 'baseline !important',
428
- top: '1px !important',
429
- left: '-0.1em !important'
430
- },
431
- '& .mq-math-mode .mq-overarc ': {
432
- paddingTop: '0.45em !important'
433
- },
434
- '& .mq-math-mode .mq-empty': {
435
- padding: '9px 1px !important'
436
- },
437
- '& .mq-math-mode .mq-root-block': {
438
- paddingTop: '10px'
439
- },
440
- '& .mq-scaled .mq-sqrt-prefix': {
441
- top: '0 !important'
442
- },
443
- '& .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
444
- marginLeft: '4px !important',
445
- paddingTop: '6px !important',
446
- paddingLeft: '6px !important'
447
- },
448
- '& .mq-math-mode .mq-paren': {
449
- verticalAlign: 'top !important',
450
- padding: '1px 0.1em !important'
451
- },
452
- '& .mq-math-mode .mq-sqrt-stem': {
453
- borderTop: '0.07em solid',
454
- marginLeft: '-1.5px',
455
- marginTop: '-2px !important',
456
- paddingTop: '5px !important'
457
- },
458
- '& .mq-math-mode .mq-denominator': {
459
- marginTop: '-5px !important',
460
- padding: '0.5em 0.1em 0.1em !important'
461
- },
462
- '& .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
463
- padding: '0 0.1em !important',
464
- paddingBottom: '0 !important',
465
- marginBottom: '-2px'
466
- }
467
- }),
468
- '& span[data-prime="true"]': {
469
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
470
- }
471
- },
472
- hide: {
473
- display: 'none'
474
- },
475
- selectContainer: {
476
- flex: 'initial',
477
- width: '25%',
478
- minWidth: '100px',
479
- marginLeft: '15px',
480
- marginTop: '5px',
481
- marginBottom: '5px',
482
- marginRight: '5px',
483
- '& label': {
484
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
485
- },
486
- '& div': {
487
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
488
- }
489
- },
490
- mathEditor: {
491
- maxWidth: '400px',
492
- color: _renderUi.color.text(),
493
- backgroundColor: _renderUi.color.background(),
494
- padding: '2px'
495
- },
496
- longMathEditor: {
497
- maxWidth: '500px'
498
- },
499
- addAnswerBlockButton: {
500
- position: 'absolute',
501
- right: '12px',
502
- border: '1px solid lightgrey'
503
- },
504
- hr: {
505
- padding: 0,
506
- margin: 0,
507
- height: '1px',
508
- border: 'none',
509
- borderBottom: "solid 1px ".concat(theme.palette.primary.main)
510
- },
511
- mathToolbar: {
512
- zIndex: 9,
513
- position: 'relative',
514
- textAlign: 'center',
515
- width: 'auto',
516
- '& > .mq-math-mode': {
517
- border: 'solid 1px lightgrey'
518
- },
519
- '& > .mq-focused': {
520
- outline: 'none',
521
- boxShadow: 'none',
522
- border: "dotted 1px ".concat(theme.palette.primary.main),
523
- borderRadius: '0px'
524
- },
525
- '& .mq-overarrow-inner': {
526
- border: 'none !important',
527
- paddingTop: '0 !important'
528
- },
529
- '& .mq-overarrow-inner-right': {
530
- display: 'none !important'
531
- },
532
- '& .mq-overarrow-inner-left': {
533
- display: 'none !important'
534
- },
535
- '& .mq-longdiv-inner': {
536
- borderTop: '1px solid !important',
537
- paddingTop: '1.5px !important'
538
- },
539
- '& .mq-overarrow.mq-arrow-both': {
540
- top: '7.8px',
541
- marginTop: '0px',
542
- minWidth: '1.23em'
543
- },
544
- '& .mq-parallelogram': {
545
- lineHeight: 0.85
546
- }
547
- },
548
- inputContainer: {
549
- minWidth: '500px',
550
- maxWidth: '900px',
551
- minHeight: '30px',
552
- width: '100%',
553
- display: 'flex',
554
- marginTop: theme.spacing.unit,
555
- marginBottom: theme.spacing.unit,
556
- '& .mq-sqrt-prefix .mq-scaled': {
557
- verticalAlign: 'middle !important'
558
- }
559
- },
560
- error: {
561
- border: '2px solid red'
562
- },
563
- keyboard: commonMqKeyboardStyles,
564
- language: {
565
- '& *': {
566
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
567
- }
568
- }
569
- };
570
- };
571
-
572
- var _default = (0, _styles.withStyles)(styles)(EditorAndPad);
573
-
574
- exports["default"] = _default;
509
+ var _default = exports["default"] = EditorAndPad;
575
510
  //# sourceMappingURL=editor-and-pad.js.map