@pie-lib/math-input 6.6.6 → 6.6.9
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 +27 -0
- package/lib/horizontal-keypad.js +18 -15
- package/lib/horizontal-keypad.js.map +1 -1
- package/lib/index.js +11 -6
- package/lib/index.js.map +1 -1
- package/lib/keypad/index.js +54 -30
- package/lib/keypad/index.js.map +1 -1
- package/lib/keypad/keys-layout.js +5 -1
- package/lib/keypad/keys-layout.js.map +1 -1
- package/lib/keys/basic-operators.js +1 -1
- package/lib/keys/chars.js +1 -1
- package/lib/keys/comparison.js +4 -4
- package/lib/keys/comparison.js.map +1 -1
- package/lib/keys/constants.js +17 -1
- package/lib/keys/constants.js.map +1 -1
- package/lib/keys/exponent.js +1 -1
- package/lib/keys/fractions.js +1 -1
- package/lib/keys/geometry.js +28 -4
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/grades.js +123 -26
- package/lib/keys/grades.js.map +1 -1
- package/lib/keys/index.js +6 -2
- package/lib/keys/index.js.map +1 -1
- package/lib/keys/log.js +1 -1
- package/lib/keys/logic.js +1 -1
- package/lib/keys/matrices.js +1 -1
- package/lib/keys/misc.js +1 -1
- package/lib/keys/statistics.js +8 -1
- package/lib/keys/statistics.js.map +1 -1
- package/lib/keys/sub-sup.js +1 -1
- package/lib/keys/trigonometry.js +1 -1
- package/lib/keys/utils.js +13 -9
- package/lib/keys/utils.js.map +1 -1
- package/lib/keys/vars.js +1 -1
- package/lib/math-input.js +22 -16
- package/lib/math-input.js.map +1 -1
- package/lib/mq/input.js +16 -14
- package/lib/mq/input.js.map +1 -1
- package/lib/mq/static.js +16 -14
- package/lib/mq/static.js.map +1 -1
- package/package.json +2 -2
- package/src/horizontal-keypad.jsx +1 -0
- package/src/keypad/index.jsx +30 -4
- package/src/keys/constants.js +16 -0
- package/src/keys/geometry.js +24 -0
- package/src/keys/grades.js +197 -83
- package/src/keys/statistics.js +7 -0
package/lib/keys/utils.js
CHANGED
|
@@ -3,29 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.transformToKeySetStructure = exports.toKey = exports.toArray = exports.mkSet = exports.extendKeySet = void 0;
|
|
7
7
|
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
|
|
12
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
13
|
|
|
14
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
21
|
|
|
22
|
-
function
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _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; }
|
|
23
27
|
|
|
24
28
|
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; }
|
|
25
29
|
|
|
26
30
|
var mkSet = function mkSet(category) {
|
|
27
31
|
return function (o) {
|
|
28
|
-
return _objectSpread({}, o, {
|
|
32
|
+
return _objectSpread(_objectSpread({}, o), {}, {
|
|
29
33
|
category: category
|
|
30
34
|
});
|
|
31
35
|
};
|
|
@@ -51,7 +55,7 @@ var toKey = function toKey(category) {
|
|
|
51
55
|
write: v
|
|
52
56
|
};
|
|
53
57
|
} else {
|
|
54
|
-
return _objectSpread({}, v, {
|
|
58
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
55
59
|
category: category
|
|
56
60
|
});
|
|
57
61
|
}
|
package/lib/keys/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/keys/utils.js"],"names":["mkSet","category","o","toArray","Object","keys","map","k","toKey","v","name","label","write","transformToKeySetStructure","data","structure","_","times","push","ln","length","i","j","latexAndNameDontExist","base","flattened","flatten","latexExists","some","b","latex","nameExists","extendKeySet","keySetData","filter","final","extra"],"mappings":";;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../src/keys/utils.js"],"names":["mkSet","category","o","toArray","Object","keys","map","k","toKey","v","name","label","write","transformToKeySetStructure","data","structure","_","times","push","ln","length","i","j","latexAndNameDontExist","base","flattened","flatten","latexExists","some","b","latex","nameExists","extendKeySet","keySetData","filter","final","extra"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,KAAK,GAAG,SAARA,KAAQ,CAAAC,QAAQ;AAAA,SAAI,UAAAC,CAAC;AAAA,2CAAUA,CAAV;AAAaD,MAAAA,QAAQ,EAARA;AAAb;AAAA,GAAL;AAAA,CAAtB;;;;AAEA,IAAME,OAAO,GAAG,SAAVA,OAAU,CAAAD,CAAC;AAAA,SAAIE,MAAM,CAACC,IAAP,CAAYH,CAAZ,EAAeI,GAAf,CAAmB,UAAAC,CAAC;AAAA,WAAIL,CAAC,CAACK,CAAD,CAAL;AAAA,GAApB,CAAJ;AAAA,CAAjB;;;;AAEA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAAAP,QAAQ;AAAA,SAAI,UAAAQ,CAAC,EAAI;AACpC,QAAI,OAAOA,CAAP,KAAa,QAAjB,EAA2B;AACzB,aAAO;AACLC,QAAAA,IAAI,EAAED,CADD;AAELE,QAAAA,KAAK,EAAEF,CAFF;AAGLR,QAAAA,QAAQ,EAARA,QAHK;AAILW,QAAAA,KAAK,EAAEH;AAJF,OAAP;AAMD,KAPD,MAOO;AACL,6CACKA,CADL;AAEER,QAAAA,QAAQ,EAARA;AAFF;AAID;AACF,GAd4B;AAAA,CAAtB;;;;AAgBA,IAAMY,0BAA0B,GAAG,SAA7BA,0BAA6B,GAAe;AAAA,MAAdC,IAAc,uEAAP,EAAO;AACvD,MAAMC,SAAS,GAAG,EAAlB;;AA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,IAAIO,IAAI,CAACJ,MAAjB,EAAyB,YAAM;AAC7BI,IAAAA,IAAI,CAACN,IAAL,CAAU,EAAV;AACD,GAFD;;AAGAF,qBAAEC,KAAF,CAAQ,CAAR,EAAW,YAAM;AACfkB,IAAAA,MAAK,CAACjB,IAAN,CAAW,EAAX;AACD,GAFD;;AAIA,MAAMkB,KAAK,GAAGvB,0BAA0B,CAACoB,UAAD,CAAxC;;AAEA,OAAK,IAAIZ,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,CAApB,EAAuBA,CAAC,EAAxB,EAA4B;AAC1Bc,IAAAA,MAAK,CAACd,CAAD,CAAL,gCAAeG,IAAI,CAACH,CAAD,CAAnB,sBAA2Be,KAAK,CAACf,CAAD,CAAhC;AACD;;AAED,SAAOc,MAAP;AACD,CAnBM","sourcesContent":["import _ from 'lodash';\n\nexport const mkSet = category => o => ({ ...o, category });\n\nexport const toArray = o => Object.keys(o).map(k => o[k]);\n\nexport const toKey = category => v => {\n if (typeof v === 'string') {\n return {\n name: v,\n label: v,\n category,\n write: v\n };\n } else {\n return {\n ...v,\n category\n };\n }\n};\n\nexport const transformToKeySetStructure = (data = []) => {\n const structure = [];\n\n _.times(5, () => {\n structure.push([]);\n });\n\n let ln = data.length;\n let i = 0;\n let j = 0;\n\n while (j < ln) {\n structure[i++].push(data[j++]);\n\n if (i === 5) {\n i = 0;\n }\n }\n\n return structure;\n};\n\nconst latexAndNameDontExist = base => k => {\n const flattened = _.flatten(base);\n const latexExists = flattened.some(b => b.latex === k.latex);\n const nameExists = flattened.some(b => b.name === k.name);\n return !latexExists && !nameExists;\n};\n\nexport const extendKeySet = (base = [], keySetData = []) => {\n keySetData = keySetData.filter(latexAndNameDontExist(base));\n\n const final = [];\n\n _.times(5 - base.length, () => {\n base.push([]);\n });\n _.times(5, () => {\n final.push([]);\n });\n\n const extra = transformToKeySetStructure(keySetData);\n\n for (let i = 0; i < 5; i++) {\n final[i] = [...base[i], ...extra[i]];\n }\n\n return final;\n};\n"],"file":"utils.js"}
|
package/lib/keys/vars.js
CHANGED
package/lib/math-input.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
|
});
|
|
@@ -21,43 +23,47 @@ var _keypad = _interopRequireDefault(require("./keypad"));
|
|
|
21
23
|
|
|
22
24
|
var _debug = _interopRequireDefault(require("debug"));
|
|
23
25
|
|
|
24
|
-
function
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
31
|
|
|
30
32
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
33
|
|
|
32
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); } }
|
|
33
35
|
|
|
34
|
-
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; }
|
|
35
37
|
|
|
36
|
-
function
|
|
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); }
|
|
37
39
|
|
|
38
|
-
function
|
|
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); }
|
|
39
45
|
|
|
40
46
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
47
|
|
|
42
|
-
function
|
|
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; } }
|
|
43
49
|
|
|
44
|
-
function
|
|
50
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
45
51
|
|
|
46
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; }
|
|
47
53
|
|
|
48
54
|
var log = (0, _debug["default"])('pie-lib:math-input');
|
|
49
55
|
|
|
50
|
-
var MathInput =
|
|
51
|
-
/*#__PURE__*/
|
|
52
|
-
function (_React$Component) {
|
|
56
|
+
var MathInput = /*#__PURE__*/function (_React$Component) {
|
|
53
57
|
_inherits(MathInput, _React$Component);
|
|
54
58
|
|
|
59
|
+
var _super = _createSuper(MathInput);
|
|
60
|
+
|
|
55
61
|
function MathInput(props) {
|
|
56
62
|
var _this;
|
|
57
63
|
|
|
58
64
|
_classCallCheck(this, MathInput);
|
|
59
65
|
|
|
60
|
-
_this =
|
|
66
|
+
_this = _super.call(this, props);
|
|
61
67
|
|
|
62
68
|
_defineProperty(_assertThisInitialized(_this), "keypadPress", function (key) {
|
|
63
69
|
log('[keypadPress] key:', key);
|
|
@@ -117,9 +123,9 @@ function (_React$Component) {
|
|
|
117
123
|
var focused = this.state.focused;
|
|
118
124
|
var showKeypad = true; // TODO: add support for different displayModes - displayMode === 'block' || focused;
|
|
119
125
|
|
|
120
|
-
return _react["default"].createElement("div", {
|
|
126
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
121
127
|
className: (0, _classnames["default"])(classes.mathInput, className, focused && classes.focused)
|
|
122
|
-
}, _react["default"].createElement(mq.Input, {
|
|
128
|
+
}, /*#__PURE__*/_react["default"].createElement(mq.Input, {
|
|
123
129
|
className: classes.mqInput,
|
|
124
130
|
innerRef: function innerRef(r) {
|
|
125
131
|
return _this2.input = r;
|
|
@@ -128,9 +134,9 @@ function (_React$Component) {
|
|
|
128
134
|
onBlur: this.inputBlur,
|
|
129
135
|
latex: latex,
|
|
130
136
|
onChange: this.changeLatex
|
|
131
|
-
}), showKeypad && _react["default"].createElement("div", {
|
|
137
|
+
}), showKeypad && /*#__PURE__*/_react["default"].createElement("div", {
|
|
132
138
|
className: classes.pad
|
|
133
|
-
}, _react["default"].createElement(_keypad["default"], {
|
|
139
|
+
}, /*#__PURE__*/_react["default"].createElement(_keypad["default"], {
|
|
134
140
|
baseSet: _keys.baseSet,
|
|
135
141
|
additionalKeys: keyset,
|
|
136
142
|
onPress: this.keypadPress
|
package/lib/math-input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math-input.jsx"],"names":["log","MathInput","props","key","input","latex","command","write","keystroke","setState","focused","l","onChange","state","classes","className","keyset","showKeypad","mathInput","mqInput","r","inputFocus","inputBlur","changeLatex","pad","baseSet","keypadPress","React","Component","PropTypes","object","isRequired","string","array","displayMode","oneOf","func","grey","styles","theme","formGroup","display","textAlign","width","borderRadius","border","marginTop","spacing","unit","marginBottom","transition","palette","primary","main","light","padding","outline","boxShadow","dark"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/math-input.jsx"],"names":["log","MathInput","props","key","input","latex","command","write","keystroke","setState","focused","l","onChange","state","classes","className","keyset","showKeypad","mathInput","mqInput","r","inputFocus","inputBlur","changeLatex","pad","baseSet","keypadPress","React","Component","PropTypes","object","isRequired","string","array","displayMode","oneOf","func","grey","styles","theme","formGroup","display","textAlign","width","borderRadius","border","marginTop","spacing","unit","marginBottom","transition","palette","primary","main","light","padding","outline","boxShadow","dark"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,oBAAN,CAAZ;;IAEaC,S;;;;;AAeX,qBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,kEAOL,UAAAC,GAAG,EAAI;AACnBH,MAAAA,GAAG,CAAC,oBAAD,EAAuBG,GAAvB,CAAH;;AAEA,UAAI,CAAC,MAAKC,KAAV,EAAiB;AACf;AACD;;AAED,UAAID,GAAG,CAACE,KAAJ,IAAa,CAACF,GAAG,CAACG,OAAtB,EAA+B;AAC7B,cAAKF,KAAL,CAAWG,KAAX,CAAiBJ,GAAG,CAACE,KAArB;AACD,OAFD,MAEO,IAAIF,GAAG,CAACI,KAAR,EAAe;AACpB,cAAKH,KAAL,CAAWG,KAAX,CAAiBJ,GAAG,CAACI,KAArB;AACD,OAFM,MAEA,IAAIJ,GAAG,CAACG,OAAR,EAAiB;AACtB,cAAKF,KAAL,CAAWE,OAAX,CAAmBH,GAAG,CAACG,OAAvB;AACD,OAFM,MAEA,IAAIH,GAAG,CAACK,SAAR,EAAmB;AACxB,cAAKJ,KAAL,CAAWI,SAAX,CAAqBL,GAAG,CAACK,SAAzB;AACD;AACF,KAvBkB;;AAAA,iEAyBN,YAAM;AACjB,YAAKC,QAAL,CAAc;AAAEC,QAAAA,OAAO,EAAE;AAAX,OAAd;AACD,KA3BkB;;AAAA,gEA6BP,YAAM;AAChB,YAAKD,QAAL,CAAc;AAAEC,QAAAA,OAAO,EAAE;AAAX,OAAd;AACD,KA/BkB;;AAAA,kEAiCL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C;AADC,KAjBc;AAoBvBlC,IAAAA,OAAO,EAAE;AACPwB,MAAAA,KAAK,EAAE,MADA;AAEPE,MAAAA,MAAM,sBAAeN,KAAK,CAACY,OAAN,CAAcC,OAAd,CAAsBE,KAArC,CAFC;AAGPJ,MAAAA,UAAU,EAAE,qBAHL;AAIPK,MAAAA,OAAO,EAAEhB,KAAK,CAACQ,OAAN,CAAcC,IAJhB;AAKP,sBAAgB;AACdQ,QAAAA,OAAO,EAAE,MADK;AAEdC,QAAAA,SAAS,EAAE,MAFG;AAGdZ,QAAAA,MAAM,sBAAeN,KAAK,CAACY,OAAN,CAAcC,OAAd,CAAsBM,IAArC;AAHQ;AALT;AApBc,GAAL;AAAA,CAApB;;eAgCe,wBAAWpB,MAAX,EAAmBrC,SAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport * as mq from './mq';\nimport { baseSet } from './keys';\nimport KeyPad from './keypad';\nimport debug from 'debug';\n\nconst log = debug('pie-lib:math-input');\n\nexport class MathInput extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n keyset: PropTypes.array,\n displayMode: PropTypes.oneOf(['block', 'block-on-focus']),\n latex: PropTypes.string,\n onChange: PropTypes.func\n };\n\n static defaultProps = {\n keyset: [],\n displayMode: 'block'\n };\n\n constructor(props) {\n super(props);\n this.state = {\n focused: false\n };\n }\n\n keypadPress = key => {\n log('[keypadPress] key:', key);\n\n if (!this.input) {\n return;\n }\n\n if (key.latex && !key.command) {\n this.input.write(key.latex);\n } else if (key.write) {\n this.input.write(key.write);\n } else if (key.command) {\n this.input.command(key.command);\n } else if (key.keystroke) {\n this.input.keystroke(key.keystroke);\n }\n };\n\n inputFocus = () => {\n this.setState({ focused: true });\n };\n\n inputBlur = () => {\n this.setState({ focused: false });\n };\n\n changeLatex = l => {\n const { onChange } = this.props;\n\n if (onChange && l !== this.props.latex) {\n log('[changeLatex]', l, this.props.latex);\n onChange(l);\n }\n };\n\n render() {\n const { classes, className, keyset, latex } = this.props;\n const { focused } = this.state;\n\n const showKeypad = true; // TODO: add support for different displayModes - displayMode === 'block' || focused;\n\n return (\n <div className={classNames(classes.mathInput, className, focused && classes.focused)}>\n <mq.Input\n className={classes.mqInput}\n innerRef={r => (this.input = r)}\n onFocus={this.inputFocus}\n onBlur={this.inputBlur}\n latex={latex}\n onChange={this.changeLatex}\n />\n {showKeypad && (\n <div className={classes.pad}>\n <KeyPad baseSet={baseSet} additionalKeys={keyset} onPress={this.keypadPress} />\n </div>\n )}\n </div>\n );\n }\n}\n\nconst grey = 'rgba(0, 0, 0, 0.23)';\nconst styles = theme => ({\n formGroup: {\n display: 'flex',\n textAlign: 'right',\n float: 'right'\n },\n pad: {\n width: '100%',\n display: 'flex'\n },\n mathInput: {\n borderRadius: '4px',\n border: `solid 1px ${grey}`,\n marginTop: theme.spacing.unit,\n marginBottom: theme.spacing.unit,\n transition: 'border 200ms linear'\n },\n focused: {\n border: `solid 1px ${theme.palette.primary.main}`\n },\n mqInput: {\n width: '100%',\n border: `solid 0px ${theme.palette.primary.light}`,\n transition: 'border 200ms linear',\n padding: theme.spacing.unit,\n '&.mq-focused': {\n outline: 'none',\n boxShadow: 'none',\n border: `solid 0px ${theme.palette.primary.dark}`\n }\n }\n});\nexport default withStyles(styles)(MathInput);\n"],"file":"math-input.js"}
|
package/lib/mq/input.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
|
});
|
|
@@ -21,23 +23,25 @@ var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
25
|
-
|
|
26
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
27
|
|
|
28
28
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
29
|
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
39
|
|
|
36
40
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
41
|
|
|
38
|
-
function
|
|
42
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
43
|
|
|
40
|
-
function
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
45
|
|
|
42
46
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
47
|
|
|
@@ -56,14 +60,12 @@ var log = (0, _debug["default"])('math-input:mq:input');
|
|
|
56
60
|
* Wrapper for MathQuill MQ.MathField.
|
|
57
61
|
*/
|
|
58
62
|
|
|
59
|
-
var Input =
|
|
60
|
-
/*#__PURE__*/
|
|
61
|
-
function (_React$Component) {
|
|
63
|
+
var Input = /*#__PURE__*/function (_React$Component) {
|
|
62
64
|
_inherits(Input, _React$Component);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
var _getPrototypeOf2;
|
|
66
|
+
var _super = _createSuper(Input);
|
|
66
67
|
|
|
68
|
+
function Input() {
|
|
67
69
|
var _this;
|
|
68
70
|
|
|
69
71
|
_classCallCheck(this, Input);
|
|
@@ -72,7 +74,7 @@ function (_React$Component) {
|
|
|
72
74
|
args[_key] = arguments[_key];
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
_this =
|
|
77
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
76
78
|
|
|
77
79
|
_defineProperty(_assertThisInitialized(_this), "onInputEdit", function () {
|
|
78
80
|
log('[onInputEdit] ...');
|
|
@@ -217,7 +219,7 @@ function (_React$Component) {
|
|
|
217
219
|
onBlur = _this$props.onBlur,
|
|
218
220
|
classes = _this$props.classes,
|
|
219
221
|
className = _this$props.className;
|
|
220
|
-
return _react["default"].createElement("span", {
|
|
222
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
221
223
|
className: (0, _classnames["default"])(classes.input, className),
|
|
222
224
|
onKeyPress: this.onKeyPress,
|
|
223
225
|
onClick: onClick,
|
package/lib/mq/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mq/input.jsx"],"names":["MQ","window","MathQuill","getInterface","registerEmbed","log","Input","onChange","props","mathField","latex","blur","focus","event","keys","Object","__controller","options","indexOf","refresh","charCode","write","onInputEdit","Error","MathField","input","handlers","edit","bind","updateLatex","v","Array","isArray","forEach","vv","cmd","keystroke","nextProps","onClick","onFocus","onBlur","classes","className","onKeyPress","r","React","Component","PropTypes","string","object","isRequired","func","styles"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/mq/input.jsx"],"names":["MQ","window","MathQuill","getInterface","registerEmbed","log","Input","onChange","props","mathField","latex","blur","focus","event","keys","Object","__controller","options","indexOf","refresh","charCode","write","onInputEdit","Error","MathField","input","handlers","edit","bind","updateLatex","v","Array","isArray","forEach","vv","cmd","keystroke","nextProps","onClick","onFocus","onBlur","classes","className","onKeyPress","r","React","Component","PropTypes","string","object","isRequired","func","styles"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;;AAEA,MAAIH,EAAE,IAAIA,EAAE,CAACI,aAAb,EAA4B;AAC1B,2CAAkBJ,EAAlB;AACD;AACF;;AAED,IAAMK,GAAG,GAAG,uBAAM,qBAAN,CAAZ;AAEA;AACA;AACA;;IACaC,K;;;;;;;;;;;;;;;;kEAgFG,YAAM;AAClBD,MAAAA,GAAG,CAAC,mBAAD,CAAH;AACA,UAAQE,QAAR,GAAqB,MAAKC,KAA1B,CAAQD,QAAR;;AACA,UAAI,CAAC,MAAKE,SAAV,EAAqB;AACnB;AACD;;AAED,UAAIF,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAAC,MAAKE,SAAL,CAAeC,KAAf,EAAD,CAAR;AACD;AACF,K;;8DAES,YAAM;AACd,YAAKC,IAAL;;AACA,YAAKC,KAAL;AACD,K;;iEAEY,UAAAC,KAAK,EAAI;AACpB,UAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAY,MAAKL,SAAL,CAAeO,YAAf,CAA4BC,OAAxC,CAAb;;AAEA,UAAIH,IAAI,CAACI,OAAL,CAAa,qBAAb,IAAsC,CAA1C,EAA6C;AAC3C;AACA;AACA;AACA,cAAKC,OAAL;AACD;;AAED,UAAIN,KAAK,CAACO,QAAN,KAAmB,EAAvB,EAA2B;AACzB;AACA;AACA;AACA,cAAKC,KAAL,CAAW,oBAAX;;AACA,cAAKC,WAAL;AACD;AACF,K;;;;;;;WAvGD,6BAAoB;AAClB,UAAI,CAACtB,EAAL,EAAS;AACP,cAAM,IAAIuB,KAA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AAA,OAAO,EAAEM,sBAAUE,MAAV,CAAiBC,UAFT;AAGjBZ,EAAAA,OAAO,EAAES,sBAAUI,IAHF;AAIjB5C,EAAAA,QAAQ,EAAEwC,sBAAUI,IAJH;AAKjBzC,EAAAA,KAAK,EAAEqC,sBAAUC,MALA;AAMjBT,EAAAA,OAAO,EAAEQ,sBAAUI,IANF;AAOjBX,EAAAA,MAAM,EAAEO,sBAAUI;AAPD,C;;AAyIrB,IAAMC,MAAM,GAAG,SAATA,MAAS;AAAA,SAAO,EAAP;AAAA,CAAf;;eAEe,wBAAWA,MAAX,EAAmB9C,KAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport debug from 'debug';\nimport classNames from 'classnames';\nimport { registerLineBreak } from './custom-elements';\nimport MathQuill from '@pie-framework/mathquill';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n\n if (MQ && MQ.registerEmbed) {\n registerLineBreak(MQ);\n }\n}\n\nconst log = debug('math-input:mq:input');\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport class Input extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n onChange: PropTypes.func,\n latex: PropTypes.string,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func\n };\n\n componentDidMount() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n\n this.mathField = MQ.MathField(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this)\n }\n });\n\n this.updateLatex();\n }\n\n componentDidUpdate() {\n this.updateLatex();\n }\n\n updateLatex() {\n if (!this.mathField) {\n return;\n }\n const { latex } = this.props;\n if (latex) {\n this.mathField.latex(latex);\n }\n }\n\n clear() {\n this.mathField.latex('');\n return '';\n }\n\n blur() {\n log('blur mathfield');\n this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField.focus();\n }\n\n command(v) {\n log('command: ', v);\n if (Array.isArray(v)) {\n v.forEach(vv => {\n this.mathField.cmd(vv);\n });\n } else {\n this.mathField.cmd(v);\n }\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n keystroke(v) {\n this.mathField.keystroke(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n write(v) {\n log('write: ', v);\n this.mathField.write(v);\n this.mathField.focus();\n return this.mathField.latex();\n }\n\n onInputEdit = () => {\n log('[onInputEdit] ...');\n const { onChange } = this.props;\n if (!this.mathField) {\n return;\n }\n\n if (onChange) {\n onChange(this.mathField.latex());\n }\n };\n\n refresh = () => {\n this.blur();\n this.focus();\n };\n\n onKeyPress = event => {\n const keys = Object.keys(this.mathField.__controller.options);\n\n if (keys.indexOf('ignoreNextMousedown') < 0) {\n // It seems like the controller has the above handler as an option\n // when all the right events are set and everything works fine\n // this seems to work in all cases\n this.refresh();\n }\n\n if (event.charCode === 13) {\n // if enter's pressed, we're going for a custom embedded element that'll\n // have a block display (empty div) - for a hacked line break using ccs\n // all because mathquill doesn't support a line break\n this.write('\\\\embed{newLine}[]');\n this.onInputEdit();\n }\n };\n\n shouldComponentUpdate(nextProps) {\n log('next: ', nextProps.latex);\n log('current: ', this.mathField.latex());\n return nextProps.latex !== this.mathField.latex();\n }\n\n render() {\n const { onClick, onFocus, onBlur, classes, className } = this.props;\n\n return (\n <span\n className={classNames(classes.input, className)}\n onKeyPress={this.onKeyPress}\n onClick={onClick}\n onFocus={onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n\nconst styles = () => ({});\n\nexport default withStyles(styles)(Input);\n"],"file":"input.js"}
|
package/lib/mq/static.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
|
});
|
|
@@ -17,23 +19,25 @@ var _index = require("../index");
|
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
|
-
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); }
|
|
21
|
-
|
|
22
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
23
|
|
|
24
24
|
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); } }
|
|
25
25
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
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); }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
+
|
|
32
|
+
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); }; }
|
|
33
|
+
|
|
34
|
+
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); }
|
|
31
35
|
|
|
32
36
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
37
|
|
|
34
|
-
function
|
|
38
|
+
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; } }
|
|
35
39
|
|
|
36
|
-
function
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
41
|
|
|
38
42
|
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; }
|
|
39
43
|
|
|
@@ -56,14 +60,12 @@ function stripSpaces() {
|
|
|
56
60
|
*/
|
|
57
61
|
|
|
58
62
|
|
|
59
|
-
var Static =
|
|
60
|
-
/*#__PURE__*/
|
|
61
|
-
function (_React$Component) {
|
|
63
|
+
var Static = /*#__PURE__*/function (_React$Component) {
|
|
62
64
|
_inherits(Static, _React$Component);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
var _getPrototypeOf2;
|
|
66
|
+
var _super = _createSuper(Static);
|
|
66
67
|
|
|
68
|
+
function Static() {
|
|
67
69
|
var _this;
|
|
68
70
|
|
|
69
71
|
_classCallCheck(this, Static);
|
|
@@ -72,7 +74,7 @@ function (_React$Component) {
|
|
|
72
74
|
args[_key] = arguments[_key];
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
_this =
|
|
77
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
76
78
|
|
|
77
79
|
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
78
80
|
try {
|
|
@@ -193,7 +195,7 @@ function (_React$Component) {
|
|
|
193
195
|
var _this$props = this.props,
|
|
194
196
|
onBlur = _this$props.onBlur,
|
|
195
197
|
className = _this$props.className;
|
|
196
|
-
return _react["default"].createElement("span", {
|
|
198
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
197
199
|
className: className,
|
|
198
200
|
onFocus: this.onFocus,
|
|
199
201
|
onBlur: onBlur,
|
package/lib/mq/static.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mq/static.jsx"],"names":["MQ","window","MathQuill","getInterface","log","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","Static","e","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","mathField","innerFields","find","f","name","props","getFieldName","setInput","onSubFieldFocus","err","console","error","message","update","field","onSubFieldChange","latex","Error","StaticMath","input","handlers","edit","onInputEdit","bind","parseLatex","blur","focus","nextProps","parsedLatex","stripped","newFieldCount","match","length","out","trim","Object","keys","warn","onBlur","className","onFocus","r","React","Component","PropTypes","isRequired","func"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/mq/static.jsx"],"names":["MQ","window","MathQuill","getInterface","log","REGEX","WHITESPACE_REGEX","stripSpaces","string","replace","Static","e","rootBlock","target","parentElement","nextSibling","id","parseInt","getAttribute","innerField","mathField","innerFields","find","f","name","props","getFieldName","setInput","onSubFieldFocus","err","console","error","message","update","field","onSubFieldChange","latex","Error","StaticMath","input","handlers","edit","onInputEdit","bind","parseLatex","blur","focus","nextProps","parsedLatex","stripped","newFieldCount","match","length","out","trim","Object","keys","warn","onBlur","className","onFocus","r","React","Component","PropTypes","isRequired","func"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAIA,EAAJ;;AACA,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;AACjCD,EAAAA,EAAE,GAAGE,sBAAUC,YAAV,CAAuB,CAAvB,CAAL;AACD;;AAED,IAAMC,GAAG,GAAG,uBAAM,8BAAN,CAAZ;AACA,IAAMC,KAAK,GAAG,wCAAd;AACA,IAAMC,gBAAgB,GAAG,IAAzB;;AAEA,SAASC,WAAT,GAAkC;AAAA,MAAbC,MAAa,uEAAJ,EAAI;AAChC,SAAOA,MAAM,CAACC,OAAP,CAAeH,gBAAf,EAAiC,EAAjC,CAAP;AACD;AAED;AACA;AACA;;;IACqBI,M;;;;;;;;;;;;;;;;8DAqFT,UAAAC,CAAC,EAAI;AACb,UAAI;AACF,YAAIC,SAAS,GAAGD,CAAC,CAACE,MAAF,CAASC,aAAT,CAAuBC,WAAvC;AACA,YAAIC,EAAE,GAAGC,QAAQ,CAACL,SAAS,CAACM,YAAV,CAAuB,oBAAvB,CAAD,EAA+C,EAA/C,CAAjB;;AAEA,YAAI,CAACF,EAAL,EAAS;AACPJ,UAAAA,SAAS,GAAGA,SAAS,CAACE,aAAtB;AACAE,UAAAA,EAAE,GAAGC,QAAQ,CAACL,SAAS,CAACM,YAAV,CAAuB,oBAAvB,CAAD,EAA+C,EAA/C,CAAb;AACD;;AAED,YAAMC,UAAU,GAAG,MAAKC,SAAL,CAAeC,WAAf,CAA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U,CAGV;;AACAF,QAAAA,OAAO,CAAC2B,IAAR,CAAa9C,CAAb;AACA,eAAO,KAAP;AACD;AACF;;;WA2BD,kBAAS;AAAA;;AACP,wBAA8B,KAAKc,KAAnC;AAAA,UAAQiC,MAAR,eAAQA,MAAR;AAAA,UAAgBC,SAAhB,eAAgBA,SAAhB;AAEA,0BACE;AACE,QAAA,SAAS,EAAEA,SADb;AAEE,QAAA,OAAO,EAAE,KAAKC,OAFhB;AAGE,QAAA,MAAM,EAAEF,MAHV;AAIE,QAAA,GAAG,EAAE,aAAAG,CAAC;AAAA,iBAAK,MAAI,CAACtB,KAAL,GAAasB,CAAlB;AAAA;AAJR,QADF;AAQD;;;;EAzHiCC,kBAAMC,S;;;;gBAArBrD,M,eACA;AACjB0B,EAAAA,KAAK,EAAE4B,sBAAUxD,MAAV,CAAiByD,UADP;AAEjBL,EAAAA,OAAO,EAAEI,sBAAUE,IAFF;AAGjBR,EAAAA,MAAM,EAAEM,sBAAUE,IAHD;AAIjBP,EAAAA,SAAS,EAAEK,sBAAUxD,MAJJ;AAKjBkB,EAAAA,YAAY,EAAEsC,sBAAUE,IALP;AAMjB/B,EAAAA,gBAAgB,EAAE6B,sBAAUE,IANX;AAOjBtC,EAAAA,eAAe,EAAEoC,sBAAUE,IAPV;AAQjBvC,EAAAA,QAAQ,EAAEqC,sBAAUE;AARH,C","sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport MathQuill from '@pie-framework/mathquill';\nimport { updateSpans } from '../index';\n\nlet MQ;\nif (typeof window !== 'undefined') {\n MQ = MathQuill.getInterface(2);\n}\n\nconst log = debug('pie-lib:math-input:mq:static');\nconst REGEX = /\\\\MathQuillMathField\\[r\\d*\\]\\{(.*?)\\}/g;\nconst WHITESPACE_REGEX = / /g;\n\nfunction stripSpaces(string = '') {\n return string.replace(WHITESPACE_REGEX, '');\n}\n\n/**\n * Wrapper for MathQuill MQ.MathField.\n */\nexport default class Static extends React.Component {\n static propTypes = {\n latex: PropTypes.string.isRequired,\n onFocus: PropTypes.func,\n onBlur: PropTypes.func,\n className: PropTypes.string,\n getFieldName: PropTypes.func,\n onSubFieldChange: PropTypes.func,\n onSubFieldFocus: PropTypes.func,\n setInput: PropTypes.func\n };\n\n componentDidMount() {\n this.update();\n updateSpans();\n }\n\n componentDidUpdate() {\n this.update();\n updateSpans();\n }\n\n onInputEdit(field) {\n if (!this.mathField) {\n return;\n }\n const name = this.props.getFieldName(field, this.mathField.innerFields);\n if (this.props.onSubFieldChange) {\n this.props.onSubFieldChange(name, field.latex());\n }\n }\n\n update() {\n if (!MQ) {\n throw new Error('MQ is not defined - but component has mounted?');\n }\n // this.input.innerHTML = this.props.latex;\n if (!this.mathField) {\n this.mathField = MQ.StaticMath(this.input, {\n handlers: {\n edit: this.onInputEdit.bind(this)\n }\n });\n }\n\n try {\n this.mathField.parseLatex(this.props.latex);\n this.mathField.latex(this.props.latex);\n } catch (e) {\n // default latex if received has errors\n this.mathField.latex('\\\\MathQuillMathField[r1]{}');\n }\n }\n\n blur() {\n log('blur mathfield');\n this.mathField.blur();\n }\n\n focus() {\n log('focus mathfield...');\n this.mathField.focus();\n }\n\n shouldComponentUpdate(nextProps) {\n try {\n const parsedLatex = this.mathField.parseLatex(nextProps.latex);\n const stripped = stripSpaces(parsedLatex);\n const newFieldCount = (nextProps.latex.match(REGEX) || []).length;\n\n const out =\n stripped !== stripSpaces(this.mathField.latex().trim()) ||\n newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;\n\n log('[shouldComponentUpdate] ', out);\n return out;\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn('Error parsing latex:', e.message, 'skip update');\n // eslint-disable-next-line no-console\n console.warn(e);\n return false;\n }\n }\n\n onFocus = e => {\n try {\n let rootBlock = e.target.parentElement.nextSibling;\n let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n\n if (!id) {\n rootBlock = rootBlock.parentElement;\n id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);\n }\n\n const innerField = this.mathField.innerFields.find(f => f.id === id);\n\n if (innerField) {\n const name = this.props.getFieldName(innerField, this.mathField.innerFields);\n if (this.props.setInput) {\n this.props.setInput(innerField);\n }\n this.props.onSubFieldFocus(name, innerField);\n }\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('error finding root block', err.message);\n }\n };\n\n render() {\n const { onBlur, className } = this.props;\n\n return (\n <span\n className={className}\n onFocus={this.onFocus}\n onBlur={onBlur}\n ref={r => (this.input = r)}\n />\n );\n }\n}\n"],"file":"static.js"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.6.
|
|
6
|
+
"version": "6.6.9",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"module": "src/index.jsx",
|
|
9
9
|
"dependencies": {
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"react-dom": "^16.9.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "c37429328de4f87b6a7095de6e671c2cc53dd7f5"
|
|
26
26
|
}
|
package/src/keypad/index.jsx
CHANGED
|
@@ -145,6 +145,20 @@ const LatexButton = withStyles(theme => ({
|
|
|
145
145
|
} else {
|
|
146
146
|
buttonClass = classNames(props.classes.latexButton, props.mqClassName);
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const MQ = MathQuill.getInterface(2);
|
|
151
|
+
const span = document.createElement('span');
|
|
152
|
+
span.innerHTML = '';
|
|
153
|
+
const mathField = MQ.StaticMath(span);
|
|
154
|
+
|
|
155
|
+
mathField.parseLatex(props.latex);
|
|
156
|
+
mathField.latex(props.latex);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
// received latex has errors - do not create button
|
|
159
|
+
return <></>;
|
|
160
|
+
}
|
|
161
|
+
|
|
148
162
|
return (
|
|
149
163
|
<Button className={classNames(props.classes.root, props.className)} onClick={props.onClick}>
|
|
150
164
|
<mq.Static className={buttonClass} latex={props.latex} />
|
|
@@ -160,7 +174,8 @@ export class KeyPad extends React.Component {
|
|
|
160
174
|
additionalKeys: PropTypes.array,
|
|
161
175
|
onPress: PropTypes.func.isRequired,
|
|
162
176
|
onFocus: PropTypes.func,
|
|
163
|
-
noDecimal: PropTypes.bool
|
|
177
|
+
noDecimal: PropTypes.bool,
|
|
178
|
+
mode: PropTypes.string
|
|
164
179
|
};
|
|
165
180
|
static defaultProps = {
|
|
166
181
|
baseSet: baseSet,
|
|
@@ -192,9 +207,20 @@ export class KeyPad extends React.Component {
|
|
|
192
207
|
};
|
|
193
208
|
|
|
194
209
|
render() {
|
|
195
|
-
const { classes, className, baseSet, additionalKeys, onFocus } = this.props;
|
|
210
|
+
const { classes, className, baseSet, additionalKeys, onFocus, mode } = this.props;
|
|
211
|
+
|
|
212
|
+
const noBaseSet = [
|
|
213
|
+
'non-negative-integers',
|
|
214
|
+
'integers',
|
|
215
|
+
'decimals',
|
|
216
|
+
'fractions',
|
|
217
|
+
'item-authoring'
|
|
218
|
+
];
|
|
196
219
|
|
|
197
|
-
const
|
|
220
|
+
const keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
221
|
+
const allKeys = keysWithoutBaseSet
|
|
222
|
+
? this.flowKeys([], additionalKeys || [])
|
|
223
|
+
: this.flowKeys(baseSet, additionalKeys || []); //, ...sortKeys(additionalKeys)];
|
|
198
224
|
|
|
199
225
|
const shift = allKeys.length % 5 ? 1 : 0;
|
|
200
226
|
const style = {
|
|
@@ -214,7 +240,7 @@ export class KeyPad extends React.Component {
|
|
|
214
240
|
onClick,
|
|
215
241
|
className: classNames(
|
|
216
242
|
classes.labelButton,
|
|
217
|
-
classes[k.category],
|
|
243
|
+
!keysWithoutBaseSet && classes[k.category],
|
|
218
244
|
k.label === ',' && classes.comma,
|
|
219
245
|
k.label === '.' && classes.dot
|
|
220
246
|
),
|
package/src/keys/constants.js
CHANGED
|
@@ -17,3 +17,19 @@ export const eulers = set({
|
|
|
17
17
|
command: 'e',
|
|
18
18
|
category: 'constants'
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
export const infinity = set({
|
|
22
|
+
name: 'Infinity',
|
|
23
|
+
label: '\\infty',
|
|
24
|
+
latex: '\\infty',
|
|
25
|
+
command: '\\infty',
|
|
26
|
+
category: 'constants'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const halfInfinity = set({
|
|
30
|
+
name: 'Half Infinity',
|
|
31
|
+
label: '\\propto',
|
|
32
|
+
latex: '\\propto',
|
|
33
|
+
command: '\\propto',
|
|
34
|
+
category: 'constants'
|
|
35
|
+
});
|