@pie-lib/math-input 6.31.2-next.0 → 6.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.
- package/CHANGELOG.md +7 -11
- package/lib/horizontal-keypad.js +16 -44
- package/lib/horizontal-keypad.js.map +1 -1
- package/lib/index.js +3 -25
- package/lib/index.js.map +1 -1
- package/lib/keypad/index.js +233 -314
- package/lib/keypad/index.js.map +1 -1
- package/lib/keypad/keys-layout.js +2 -12
- package/lib/keypad/keys-layout.js.map +1 -1
- package/lib/keys/basic-operators.js +5 -13
- package/lib/keys/basic-operators.js.map +1 -1
- package/lib/keys/chars.js +5 -10
- package/lib/keys/chars.js.map +1 -1
- package/lib/keys/comparison.js +6 -16
- package/lib/keys/comparison.js.map +1 -1
- package/lib/keys/constants.js +4 -10
- package/lib/keys/constants.js.map +1 -1
- package/lib/keys/digits.js +1 -7
- package/lib/keys/digits.js.map +1 -1
- package/lib/keys/edit.js +1 -4
- package/lib/keys/edit.js.map +1 -1
- package/lib/keys/exponent.js +4 -10
- package/lib/keys/exponent.js.map +1 -1
- package/lib/keys/fractions.js +3 -8
- package/lib/keys/fractions.js.map +1 -1
- package/lib/keys/geometry.js +25 -54
- package/lib/keys/geometry.js.map +1 -1
- package/lib/keys/grades.js +10 -46
- package/lib/keys/grades.js.map +1 -1
- package/lib/keys/index.js +13 -32
- package/lib/keys/index.js.map +1 -1
- package/lib/keys/log.js +3 -8
- package/lib/keys/log.js.map +1 -1
- package/lib/keys/logic.js +2 -6
- package/lib/keys/logic.js.map +1 -1
- package/lib/keys/matrices.js +2 -6
- package/lib/keys/matrices.js.map +1 -1
- package/lib/keys/misc.js +10 -22
- package/lib/keys/misc.js.map +1 -1
- package/lib/keys/navigation.js +2 -7
- package/lib/keys/navigation.js.map +1 -1
- package/lib/keys/operators.js +1 -4
- package/lib/keys/operators.js.map +1 -1
- package/lib/keys/statistics.js +5 -12
- package/lib/keys/statistics.js.map +1 -1
- package/lib/keys/sub-sup.js +2 -6
- package/lib/keys/sub-sup.js.map +1 -1
- package/lib/keys/trigonometry.js +6 -14
- package/lib/keys/trigonometry.js.map +1 -1
- package/lib/keys/utils.js +7 -40
- package/lib/keys/utils.js.map +1 -1
- package/lib/keys/vars.js +3 -8
- package/lib/keys/vars.js.map +1 -1
- package/lib/math-input.js +52 -103
- package/lib/math-input.js.map +1 -1
- package/lib/mq/common-mq-styles.js +7 -18
- package/lib/mq/common-mq-styles.js.map +1 -1
- package/lib/mq/custom-elements.js +1 -4
- package/lib/mq/custom-elements.js.map +1 -1
- package/lib/mq/index.js +0 -4
- package/lib/mq/index.js.map +1 -1
- package/lib/mq/input.js +22 -75
- package/lib/mq/input.js.map +1 -1
- package/lib/mq/static.js +31 -92
- package/lib/mq/static.js.map +1 -1
- package/lib/shared/constants.js +3 -6
- package/lib/updateSpans.js +1 -5
- package/lib/updateSpans.js.map +1 -1
- package/package.json +9 -7
- package/src/keypad/index.jsx +151 -151
- package/src/math-input.jsx +35 -44
- package/src/mq/input.jsx +9 -9
package/lib/keypad/index.js
CHANGED
|
@@ -1,193 +1,162 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = exports.KeyPad = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
-
|
|
18
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
-
|
|
20
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
21
|
-
|
|
22
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
-
|
|
24
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
-
|
|
26
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
-
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
28
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
-
|
|
30
17
|
var _react = _interopRequireDefault(require("react"));
|
|
31
|
-
|
|
32
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
|
|
37
|
-
|
|
38
|
-
var _styles = require("@material-ui/core/styles");
|
|
39
|
-
|
|
19
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
20
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
21
|
+
var _styles = require("@mui/material/styles");
|
|
40
22
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
41
|
-
|
|
42
|
-
var _colorManipulator = require("@material-ui/core/styles/colorManipulator");
|
|
43
|
-
|
|
44
|
-
var _green = _interopRequireDefault(require("@material-ui/core/colors/green"));
|
|
45
|
-
|
|
46
23
|
var _debug = _interopRequireDefault(require("debug"));
|
|
47
|
-
|
|
48
24
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
49
|
-
|
|
50
25
|
var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));
|
|
51
|
-
|
|
52
26
|
var mq = _interopRequireWildcard(require("../mq"));
|
|
53
|
-
|
|
54
27
|
var _keys = require("../keys");
|
|
55
|
-
|
|
56
28
|
var _constants = _interopRequireDefault(require("./../shared/constants"));
|
|
57
|
-
|
|
58
29
|
var _commonMqStyles = require("../mq/common-mq-styles");
|
|
59
|
-
|
|
60
30
|
var _keysLayout = require("./keys-layout");
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
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; }
|
|
69
|
-
|
|
70
|
-
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); }; }
|
|
71
|
-
|
|
72
|
-
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; } }
|
|
73
|
-
|
|
31
|
+
var _colors = require("@mui/material/colors");
|
|
32
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
33
|
+
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)); }
|
|
34
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
35
|
+
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; }
|
|
36
|
+
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; }
|
|
74
37
|
var log = (0, _debug["default"])('pie-lib:math-inline:keypad');
|
|
75
|
-
var
|
|
38
|
+
var StyledLatexButton = (0, _styles.styled)(_Button["default"])(function (_ref) {
|
|
39
|
+
var theme = _ref.theme;
|
|
76
40
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
41
|
+
textTransform: 'none',
|
|
42
|
+
padding: 0,
|
|
43
|
+
margin: 0,
|
|
44
|
+
fontSize: '110% !important'
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
var LatexButtonContent = (0, _styles.styled)(mq.Static)(function (_ref2) {
|
|
48
|
+
var theme = _ref2.theme,
|
|
49
|
+
latex = _ref2.latex;
|
|
50
|
+
var baseStyles = {
|
|
51
|
+
pointerEvents: 'none',
|
|
52
|
+
textTransform: 'none !important',
|
|
53
|
+
'& .mq-scaled.mq-sqrt-prefix': {
|
|
54
|
+
transform: 'scale(1, 0.9) !important'
|
|
82
55
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
borderTop: '2px solid black',
|
|
106
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
107
|
-
'&.mq-arrow-both': {
|
|
108
|
-
top: '0px !important',
|
|
109
|
-
'& *': {
|
|
110
|
-
lineHeight: '1 !important',
|
|
111
|
-
borderTop: 'none !important' // fixing PD-4873 - in OT, it has border-top 1px and adds extra line,
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
'&:before': {
|
|
115
|
-
fontSize: '80%',
|
|
116
|
-
left: 'calc(-13%) !important',
|
|
117
|
-
top: '-0.31em !important'
|
|
118
|
-
},
|
|
119
|
-
'&:after': {
|
|
120
|
-
fontSize: '80% !important',
|
|
121
|
-
right: 'calc(-13%) !important',
|
|
122
|
-
top: '-1.5em'
|
|
123
|
-
},
|
|
124
|
-
'&.mq-empty:before': {
|
|
125
|
-
fontSize: '80%',
|
|
126
|
-
left: 'calc(-13%)',
|
|
127
|
-
top: '-0.26em'
|
|
128
|
-
},
|
|
129
|
-
'&.mq-empty:after': {
|
|
130
|
-
fontSize: '80%',
|
|
131
|
-
right: 'calc(-13%)',
|
|
132
|
-
top: '-0.26em'
|
|
133
|
-
},
|
|
134
|
-
'&.mq-empty': {
|
|
135
|
-
minHeight: '1.4em'
|
|
136
|
-
}
|
|
56
|
+
'& .mq-sup-only .mq-sup': {
|
|
57
|
+
marginBottom: '0.9px !important'
|
|
58
|
+
},
|
|
59
|
+
'& .mq-empty': {
|
|
60
|
+
backgroundColor: "".concat((0, _styles.alpha)(theme.palette.secondary.main, 0.4), " !important")
|
|
61
|
+
},
|
|
62
|
+
'& .mq-overline .mq-overline-inner': {
|
|
63
|
+
borderTop: '2px solid black'
|
|
64
|
+
},
|
|
65
|
+
'& .mq-non-leaf.mq-overline': {
|
|
66
|
+
borderTop: 'none !important'
|
|
67
|
+
},
|
|
68
|
+
'& .mq-overarrow': {
|
|
69
|
+
width: '30px',
|
|
70
|
+
marginTop: '0 !important',
|
|
71
|
+
borderTop: '2px solid black',
|
|
72
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
73
|
+
'&.mq-arrow-both': {
|
|
74
|
+
top: '0px !important',
|
|
75
|
+
'& *': {
|
|
76
|
+
lineHeight: '1 !important',
|
|
77
|
+
borderTop: 'none !important'
|
|
137
78
|
},
|
|
138
|
-
'
|
|
79
|
+
'&:before': {
|
|
139
80
|
fontSize: '80%',
|
|
81
|
+
left: 'calc(-13%) !important',
|
|
82
|
+
top: '-0.31em !important'
|
|
83
|
+
},
|
|
84
|
+
'&:after': {
|
|
85
|
+
fontSize: '80% !important',
|
|
140
86
|
right: 'calc(-13%) !important',
|
|
141
|
-
top: '-
|
|
87
|
+
top: '-1.5em'
|
|
88
|
+
},
|
|
89
|
+
'&.mq-empty:before': {
|
|
90
|
+
fontSize: '80%',
|
|
91
|
+
left: 'calc(-13%)',
|
|
92
|
+
top: '-0.26em'
|
|
142
93
|
},
|
|
143
|
-
'
|
|
144
|
-
|
|
94
|
+
'&.mq-empty:after': {
|
|
95
|
+
fontSize: '80%',
|
|
96
|
+
right: 'calc(-13%)',
|
|
97
|
+
top: '-0.26em'
|
|
145
98
|
},
|
|
146
|
-
'
|
|
147
|
-
|
|
99
|
+
'&.mq-empty': {
|
|
100
|
+
minHeight: '1.4em'
|
|
148
101
|
}
|
|
149
102
|
},
|
|
150
|
-
'
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
right: '-6px',
|
|
155
|
-
fontSize: '80% !important',
|
|
156
|
-
top: '-3px'
|
|
157
|
-
},
|
|
158
|
-
'& .mq-overarrow.mq-arrow-right.mq-empty:before': {
|
|
159
|
-
right: '-5px',
|
|
160
|
-
fontSize: '80% !important',
|
|
161
|
-
top: '-3px'
|
|
103
|
+
'&.mq-arrow-right:before': {
|
|
104
|
+
fontSize: '80%',
|
|
105
|
+
right: 'calc(-13%) !important',
|
|
106
|
+
top: '-0.26em !important'
|
|
162
107
|
},
|
|
163
|
-
'& .mq-overarrow
|
|
164
|
-
|
|
165
|
-
fontSize: '80% !important',
|
|
166
|
-
top: '-3px'
|
|
108
|
+
'& .mq-overarrow-inner': {
|
|
109
|
+
border: 'none !important'
|
|
167
110
|
},
|
|
168
|
-
'& .mq-
|
|
169
|
-
|
|
170
|
-
paddingTop: '1.5px !important'
|
|
171
|
-
},
|
|
172
|
-
'& .mq-parallelogram': {
|
|
173
|
-
lineHeight: 0.85
|
|
174
|
-
},
|
|
175
|
-
'& .mq-overarc': {
|
|
176
|
-
borderTop: '2px solid black !important',
|
|
177
|
-
'& .mq-overline': {
|
|
178
|
-
borderTop: 'none !important' // fixing PD-4873 - in OT, it has border-top 1px and adds extra line
|
|
179
|
-
|
|
180
|
-
},
|
|
181
|
-
'& .mq-overline-inner': {
|
|
182
|
-
borderTop: 'none !important',
|
|
183
|
-
paddingTop: '0 !important'
|
|
184
|
-
}
|
|
111
|
+
'& .mq-overarrow-inner .mq-overarrow-inner-right': {
|
|
112
|
+
display: 'none !important'
|
|
185
113
|
}
|
|
186
114
|
},
|
|
187
|
-
|
|
188
|
-
|
|
115
|
+
'& .mq-root-block': {
|
|
116
|
+
padding: '5px !important'
|
|
117
|
+
},
|
|
118
|
+
'& .mq-overarrow.mq-arrow-both.mq-empty:after': {
|
|
119
|
+
right: '-6px',
|
|
120
|
+
fontSize: '80% !important',
|
|
121
|
+
top: '-3px'
|
|
122
|
+
},
|
|
123
|
+
'& .mq-overarrow.mq-arrow-right.mq-empty:before': {
|
|
124
|
+
right: '-5px',
|
|
125
|
+
fontSize: '80% !important',
|
|
126
|
+
top: '-3px'
|
|
127
|
+
},
|
|
128
|
+
'& .mq-overarrow.mq-arrow-both.mq-empty:before': {
|
|
129
|
+
left: '-6px',
|
|
130
|
+
fontSize: '80% !important',
|
|
131
|
+
top: '-3px'
|
|
132
|
+
},
|
|
133
|
+
'& .mq-longdiv-inner': {
|
|
134
|
+
borderTop: '1px solid !important',
|
|
135
|
+
paddingTop: '1.5px !important'
|
|
136
|
+
},
|
|
137
|
+
'& .mq-parallelogram': {
|
|
138
|
+
lineHeight: 0.85
|
|
189
139
|
},
|
|
190
|
-
|
|
140
|
+
'& .mq-overarc': {
|
|
141
|
+
borderTop: '2px solid black !important',
|
|
142
|
+
'& .mq-overline': {
|
|
143
|
+
borderTop: 'none !important'
|
|
144
|
+
},
|
|
145
|
+
'& .mq-overline-inner': {
|
|
146
|
+
borderTop: 'none !important',
|
|
147
|
+
paddingTop: '0 !important'
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Add specific styles based on latex content
|
|
153
|
+
if (latex === '\\parallel') {
|
|
154
|
+
return _objectSpread(_objectSpread({}, baseStyles), {}, {
|
|
155
|
+
fontStyle: 'italic !important'
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (latex === '\\overleftrightarrow{\\overline{}}') {
|
|
159
|
+
return _objectSpread(_objectSpread({}, baseStyles), {}, {
|
|
191
160
|
'& .mq-overarrow.mq-arrow-both': {
|
|
192
161
|
'& .mq-overline-inner': {
|
|
193
162
|
borderTop: 'none !important',
|
|
@@ -198,22 +167,13 @@ var LatexButton = (0, _styles.withStyles)(function (theme) {
|
|
|
198
167
|
top: '0px !important'
|
|
199
168
|
}
|
|
200
169
|
}
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
})(function (props) {
|
|
204
|
-
var buttonClass;
|
|
205
|
-
|
|
206
|
-
if (props.latex === '\\parallel') {
|
|
207
|
-
buttonClass = (0, _classnames["default"])(props.classes.latexButton, props.mqClassName, props.classes.parallelButton);
|
|
208
|
-
} else if (props.latex === '\\overleftrightarrow{\\overline{}}') {
|
|
209
|
-
buttonClass = (0, _classnames["default"])(props.classes.latexButton, props.mqClassName, props.classes.leftRightArrowButton);
|
|
210
|
-
} else {
|
|
211
|
-
buttonClass = (0, _classnames["default"])(props.classes.latexButton, props.mqClassName);
|
|
170
|
+
});
|
|
212
171
|
}
|
|
213
|
-
|
|
172
|
+
return baseStyles;
|
|
173
|
+
});
|
|
174
|
+
var LatexButton = function LatexButton(props) {
|
|
214
175
|
try {
|
|
215
176
|
var MQ = _mathquill["default"].getInterface(2);
|
|
216
|
-
|
|
217
177
|
var span = document.createElement('span');
|
|
218
178
|
span.innerHTML = '';
|
|
219
179
|
var mathField = MQ.StaticMath(span);
|
|
@@ -223,17 +183,14 @@ var LatexButton = (0, _styles.withStyles)(function (theme) {
|
|
|
223
183
|
// received latex has errors - do not create button
|
|
224
184
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
|
|
225
185
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
className: (0, _classnames["default"])(props.classes.root, props.className),
|
|
186
|
+
return /*#__PURE__*/_react["default"].createElement(StyledLatexButton, {
|
|
187
|
+
className: props.className,
|
|
229
188
|
onClick: props.onClick,
|
|
230
189
|
"aria-label": props.ariaLabel
|
|
231
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
232
|
-
className: buttonClass,
|
|
190
|
+
}, /*#__PURE__*/_react["default"].createElement(LatexButtonContent, {
|
|
233
191
|
latex: props.latex
|
|
234
192
|
}));
|
|
235
|
-
}
|
|
236
|
-
|
|
193
|
+
};
|
|
237
194
|
var createCustomLayout = function createCustomLayout(layoutObj) {
|
|
238
195
|
if (layoutObj) {
|
|
239
196
|
return {
|
|
@@ -242,72 +199,130 @@ var createCustomLayout = function createCustomLayout(layoutObj) {
|
|
|
242
199
|
gridAutoFlow: 'initial'
|
|
243
200
|
};
|
|
244
201
|
}
|
|
245
|
-
|
|
246
202
|
return {};
|
|
247
203
|
};
|
|
248
|
-
|
|
249
|
-
var
|
|
250
|
-
(
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
204
|
+
var KeyPadContainer = (0, _styles.styled)('div')(function (_ref3) {
|
|
205
|
+
var theme = _ref3.theme;
|
|
206
|
+
return _objectSpread(_objectSpread({}, _commonMqStyles.commonMqKeyboardStyles), {}, {
|
|
207
|
+
width: '100%',
|
|
208
|
+
display: 'grid',
|
|
209
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
210
|
+
gridRowGap: '0px',
|
|
211
|
+
gridColumnGap: '0px',
|
|
212
|
+
gridAutoFlow: 'column',
|
|
213
|
+
'&.character': {
|
|
214
|
+
textTransform: 'initial !important',
|
|
215
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important'
|
|
216
|
+
},
|
|
217
|
+
'&.language': {
|
|
218
|
+
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
219
|
+
'& *': {
|
|
220
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
var StyledButton = (0, _styles.styled)(_Button["default"])(function (_ref4) {
|
|
226
|
+
var theme = _ref4.theme,
|
|
227
|
+
category = _ref4.category,
|
|
228
|
+
isDelete = _ref4.isDelete,
|
|
229
|
+
isComma = _ref4.isComma,
|
|
230
|
+
isDot = _ref4.isDot;
|
|
231
|
+
return _objectSpread({
|
|
232
|
+
minWidth: 'auto',
|
|
233
|
+
fontSize: isComma || isDot ? '200% !important' : '140% !important',
|
|
234
|
+
lineHeight: isComma || isDot ? '100%' : 'normal',
|
|
235
|
+
backgroundColor: category === 'operators' ? (0, _styles.lighten)(theme.palette.secondary.light, 0.5) : category === 'comparison' ? (0, _styles.lighten)(_colors.green[500], 0.5) : (0, _styles.lighten)(theme.palette.primary.light, 0.5),
|
|
236
|
+
'&:hover': {
|
|
237
|
+
backgroundColor: category === 'operators' ? (0, _styles.lighten)(theme.palette.secondary.light, 0.7) : category === 'comparison' ? (0, _styles.lighten)(_colors.green[500], 0.7) : (0, _styles.lighten)(theme.palette.primary.light, 0.7)
|
|
238
|
+
},
|
|
239
|
+
borderRadius: 0
|
|
240
|
+
}, isDelete && {
|
|
241
|
+
'& > span': {
|
|
242
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
var StyledLatexButtonWrapper = (0, _styles.styled)(_Button["default"])(function (_ref5) {
|
|
247
|
+
var theme = _ref5.theme,
|
|
248
|
+
category = _ref5.category;
|
|
249
|
+
return {
|
|
250
|
+
minWidth: 'auto',
|
|
251
|
+
borderRadius: 0,
|
|
252
|
+
backgroundColor: category === 'operators' ? (0, _styles.lighten)(theme.palette.secondary.light, 0.5) : category === 'comparison' ? (0, _styles.lighten)(_colors.green[500], 0.5) : (0, _styles.lighten)(theme.palette.primary.light, 0.5),
|
|
253
|
+
'&:hover': {
|
|
254
|
+
backgroundColor: category === 'operators' ? (0, _styles.lighten)(theme.palette.secondary.light, 0.7) : category === 'comparison' ? (0, _styles.lighten)(_colors.green[500], 0.7) : (0, _styles.lighten)(theme.palette.primary.light, 0.7)
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
});
|
|
258
|
+
var StyledIconButton = (0, _styles.styled)(_IconButton["default"])(function (_ref6) {
|
|
259
|
+
var theme = _ref6.theme,
|
|
260
|
+
category = _ref6.category;
|
|
261
|
+
return {
|
|
262
|
+
minWidth: 'auto',
|
|
263
|
+
backgroundColor: category === 'operators' ? (0, _styles.lighten)(theme.palette.secondary.light, 0.5) : category === 'comparison' ? (0, _styles.lighten)(_colors.green[500], 0.5) : (0, _styles.lighten)(theme.palette.primary.light, 0.5),
|
|
264
|
+
'&:hover': {
|
|
265
|
+
backgroundColor: category === 'operators' ? (0, _styles.lighten)(theme.palette.secondary.light, 0.7) : category === 'comparison' ? (0, _styles.lighten)(_colors.green[500], 0.7) : (0, _styles.lighten)(theme.palette.primary.light, 0.7)
|
|
266
|
+
},
|
|
267
|
+
borderRadius: 0,
|
|
268
|
+
'& .icon': {
|
|
269
|
+
height: '30px'
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
var KeyPad = exports.KeyPad = /*#__PURE__*/function (_React$Component) {
|
|
254
274
|
function KeyPad(props) {
|
|
255
275
|
var _this;
|
|
256
|
-
|
|
257
276
|
(0, _classCallCheck2["default"])(this, KeyPad);
|
|
258
|
-
_this =
|
|
259
|
-
(0, _defineProperty2["default"])(
|
|
277
|
+
_this = _callSuper(this, KeyPad, [props]);
|
|
278
|
+
(0, _defineProperty2["default"])(_this, "handleKeypadInteraction", function () {
|
|
260
279
|
// Check if the setKeypadInteraction prop is available, which is used for both
|
|
261
280
|
// the language keypad and the special characters keypad
|
|
262
281
|
if (_this.props.setKeypadInteraction) {
|
|
263
282
|
_this.props.setKeypadInteraction(true);
|
|
264
283
|
}
|
|
265
284
|
});
|
|
266
|
-
(0, _defineProperty2["default"])(
|
|
285
|
+
(0, _defineProperty2["default"])(_this, "buttonClick", function (key) {
|
|
267
286
|
log('[buttonClick]', key);
|
|
268
287
|
var onPress = _this.props.onPress;
|
|
269
288
|
onPress(key);
|
|
270
289
|
});
|
|
271
|
-
(0, _defineProperty2["default"])(
|
|
290
|
+
(0, _defineProperty2["default"])(_this, "flowKeys", function (base, extras) {
|
|
272
291
|
var transposed = [].concat((0, _toConsumableArray2["default"])((0, _keysLayout.sortKeys)(base)), (0, _toConsumableArray2["default"])((0, _keysLayout.sortKeys)(extras)));
|
|
273
292
|
return _lodash["default"].flatten(transposed);
|
|
274
293
|
});
|
|
275
|
-
(0, _defineProperty2["default"])(
|
|
294
|
+
(0, _defineProperty2["default"])(_this, "keyIsNotAllowed", function (key) {
|
|
276
295
|
var noDecimal = _this.props.noDecimal;
|
|
277
|
-
|
|
278
296
|
if ((key.write === '.' && key.label === '.' || key.write === ',' && key.label === ',') && noDecimal) {
|
|
279
297
|
return true;
|
|
280
298
|
}
|
|
281
|
-
|
|
282
299
|
return false;
|
|
283
300
|
});
|
|
284
301
|
_this.keypadRef = /*#__PURE__*/_react["default"].createRef();
|
|
285
302
|
return _this;
|
|
286
303
|
}
|
|
287
|
-
|
|
288
|
-
(0, _createClass2["default"])(KeyPad, [{
|
|
304
|
+
(0, _inherits2["default"])(KeyPad, _React$Component);
|
|
305
|
+
return (0, _createClass2["default"])(KeyPad, [{
|
|
289
306
|
key: "componentDidMount",
|
|
290
307
|
value: function componentDidMount() {
|
|
291
308
|
var _this$keypadRef;
|
|
292
|
-
|
|
293
309
|
var keyPadElement = (_this$keypadRef = this.keypadRef) === null || _this$keypadRef === void 0 ? void 0 : _this$keypadRef.current;
|
|
294
310
|
var mainContainer = keyPadElement === null || keyPadElement === void 0 ? void 0 : keyPadElement.closest(".".concat(_constants["default"].MAIN_CONTAINER_CLASS));
|
|
295
|
-
var currentToolbar = keyPadElement === null || keyPadElement === void 0 ? void 0 : keyPadElement.closest('.pie-toolbar');
|
|
311
|
+
var currentToolbar = keyPadElement === null || keyPadElement === void 0 ? void 0 : keyPadElement.closest('.pie-toolbar');
|
|
296
312
|
|
|
313
|
+
// need only for math keyboard so we need also controlledKeypadMode
|
|
297
314
|
if (this.props.controlledKeypadMode && mainContainer && currentToolbar) {
|
|
298
315
|
var mainContainerPosition = mainContainer.getBoundingClientRect();
|
|
299
316
|
var currentToolbarPosition = currentToolbar.getBoundingClientRect();
|
|
300
317
|
var difference = mainContainerPosition.top + mainContainerPosition.height - (currentToolbarPosition.top + currentToolbarPosition.height);
|
|
301
|
-
|
|
302
318
|
if (difference < 0) {
|
|
303
|
-
var totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;
|
|
304
|
-
|
|
319
|
+
var totalHeight = mainContainerPosition.height + mainContainerPosition.top - difference;
|
|
320
|
+
// increase the height of the main container if keyboard needs it
|
|
305
321
|
if (mainContainer) {
|
|
306
322
|
mainContainer.style.height = "".concat(totalHeight, "px");
|
|
307
323
|
}
|
|
308
324
|
}
|
|
309
325
|
}
|
|
310
|
-
|
|
311
326
|
if (keyPadElement) {
|
|
312
327
|
keyPadElement.addEventListener('touchstart', this.handleKeypadInteraction, true);
|
|
313
328
|
keyPadElement.addEventListener('mousedown', this.handleKeypadInteraction, true);
|
|
@@ -317,17 +332,14 @@ var KeyPad = /*#__PURE__*/function (_React$Component) {
|
|
|
317
332
|
key: "componentWillUnmount",
|
|
318
333
|
value: function componentWillUnmount() {
|
|
319
334
|
var _this$keypadRef2;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
335
|
+
var keyPadElement = (_this$keypadRef2 = this.keypadRef) === null || _this$keypadRef2 === void 0 ? void 0 : _this$keypadRef2.current;
|
|
336
|
+
// need only for math keyboard
|
|
323
337
|
if (this.props.controlledKeypadMode && keyPadElement) {
|
|
324
338
|
var mainContainer = keyPadElement.closest(".".concat(_constants["default"].MAIN_CONTAINER_CLASS));
|
|
325
|
-
|
|
326
339
|
if (mainContainer) {
|
|
327
340
|
mainContainer.style.height = 'unset';
|
|
328
341
|
}
|
|
329
342
|
}
|
|
330
|
-
|
|
331
343
|
if (keyPadElement) {
|
|
332
344
|
keyPadElement.removeEventListener('touchstart', this.handleKeypadInteraction, true);
|
|
333
345
|
keyPadElement.removeEventListener('mousedown', this.handleKeypadInteraction, true);
|
|
@@ -337,82 +349,69 @@ var KeyPad = /*#__PURE__*/function (_React$Component) {
|
|
|
337
349
|
key: "render",
|
|
338
350
|
value: function render() {
|
|
339
351
|
var _this2 = this;
|
|
340
|
-
|
|
341
352
|
var _this$props = this.props,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
mode = _this$props.mode;
|
|
353
|
+
className = _this$props.className,
|
|
354
|
+
baseSet = _this$props.baseSet,
|
|
355
|
+
additionalKeys = _this$props.additionalKeys,
|
|
356
|
+
layoutForKeyPad = _this$props.layoutForKeyPad,
|
|
357
|
+
onFocus = _this$props.onFocus,
|
|
358
|
+
mode = _this$props.mode;
|
|
349
359
|
var noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];
|
|
350
360
|
var keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
351
|
-
var allKeys = keysWithoutBaseSet ? this.flowKeys([], additionalKeys || []) : this.flowKeys(baseSet, additionalKeys || []);
|
|
352
|
-
|
|
361
|
+
var allKeys = keysWithoutBaseSet ? this.flowKeys([], additionalKeys || []) : this.flowKeys(baseSet, additionalKeys || []);
|
|
353
362
|
var shift = allKeys.length % 5 ? 1 : 0;
|
|
354
|
-
|
|
355
363
|
var style = _objectSpread({
|
|
356
364
|
gridTemplateColumns: "repeat(".concat(Math.floor(allKeys.length / 5) + shift, ", minmax(min-content, 150px))")
|
|
357
365
|
}, createCustomLayout(layoutForKeyPad));
|
|
358
|
-
|
|
359
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
366
|
+
return /*#__PURE__*/_react["default"].createElement(KeyPadContainer, {
|
|
360
367
|
ref: this.keypadRef,
|
|
361
|
-
className: (0, _classnames["default"])(
|
|
368
|
+
className: (0, _classnames["default"])(className, mode),
|
|
362
369
|
style: style,
|
|
363
370
|
onFocus: onFocus
|
|
364
371
|
}, allKeys.map(function (k, index) {
|
|
365
372
|
var onClick = _this2.buttonClick.bind(_this2, k);
|
|
366
|
-
|
|
367
373
|
if (!k) {
|
|
368
374
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
369
375
|
key: "empty-".concat(index)
|
|
370
376
|
});
|
|
371
377
|
}
|
|
372
|
-
|
|
373
378
|
var common = _objectSpread(_objectSpread({
|
|
374
379
|
onClick: onClick,
|
|
375
|
-
className: (0, _classnames["default"])(classes.labelButton, !keysWithoutBaseSet && classes[k.category], classes[k.extraClass], k.label === ',' && classes.comma, k.label === '.' && classes.dot),
|
|
376
380
|
disabled: _this2.keyIsNotAllowed(k),
|
|
377
381
|
key: "".concat(k.label || k.latex || k.command, "-").concat(index)
|
|
378
382
|
}, k.actions || {}), k.extraProps || {});
|
|
379
|
-
|
|
380
383
|
if (k.latex) {
|
|
381
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
},
|
|
385
|
-
|
|
386
|
-
ariaLabel: k.ariaLabel ? k.ariaLabel : k.name || k.label
|
|
384
|
+
return /*#__PURE__*/_react["default"].createElement(StyledLatexButtonWrapper, (0, _extends2["default"])({}, common, {
|
|
385
|
+
category: !keysWithoutBaseSet ? k.category : undefined,
|
|
386
|
+
"aria-label": k.ariaLabel ? k.ariaLabel : k.name || k.label
|
|
387
|
+
}), /*#__PURE__*/_react["default"].createElement(LatexButtonContent, {
|
|
388
|
+
latex: k.latex
|
|
387
389
|
}));
|
|
388
390
|
}
|
|
389
|
-
|
|
390
391
|
if (k.label) {
|
|
391
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
return /*#__PURE__*/_react["default"].createElement(StyledButton, (0, _extends2["default"])({}, common, {
|
|
393
|
+
category: !keysWithoutBaseSet ? k.category : undefined,
|
|
394
|
+
isDelete: k.label === '⌫',
|
|
395
|
+
isComma: k.label === ',',
|
|
396
|
+
isDot: k.label === '.',
|
|
395
397
|
"aria-label": k.ariaLabel ? k.ariaLabel : k.name || k.label
|
|
396
398
|
}), k.label);
|
|
397
399
|
} else {
|
|
398
400
|
var Icon = k.icon ? k.icon : 'div';
|
|
399
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
401
|
+
return /*#__PURE__*/_react["default"].createElement(StyledIconButton, (0, _extends2["default"])({
|
|
400
402
|
tabIndex: '-1'
|
|
401
403
|
}, common, {
|
|
402
|
-
|
|
404
|
+
category: !keysWithoutBaseSet ? k.category : undefined,
|
|
405
|
+
size: "large"
|
|
403
406
|
}), /*#__PURE__*/_react["default"].createElement(Icon, {
|
|
404
|
-
className:
|
|
407
|
+
className: "icon"
|
|
405
408
|
}));
|
|
406
409
|
}
|
|
407
410
|
}));
|
|
408
411
|
}
|
|
409
412
|
}]);
|
|
410
|
-
return KeyPad;
|
|
411
413
|
}(_react["default"].Component);
|
|
412
|
-
|
|
413
|
-
exports.KeyPad = KeyPad;
|
|
414
414
|
(0, _defineProperty2["default"])(KeyPad, "propTypes", {
|
|
415
|
-
classes: _propTypes["default"].object.isRequired,
|
|
416
415
|
className: _propTypes["default"].string,
|
|
417
416
|
controlledKeypadMode: _propTypes["default"].bool,
|
|
418
417
|
baseSet: _propTypes["default"].array,
|
|
@@ -428,85 +427,5 @@ exports.KeyPad = KeyPad;
|
|
|
428
427
|
baseSet: _keys.baseSet,
|
|
429
428
|
noDecimal: false
|
|
430
429
|
});
|
|
431
|
-
|
|
432
|
-
var styles = function styles(theme) {
|
|
433
|
-
return {
|
|
434
|
-
keys: _objectSpread(_objectSpread({}, _commonMqStyles.commonMqKeyboardStyles), {}, {
|
|
435
|
-
width: '100%',
|
|
436
|
-
display: 'grid',
|
|
437
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
438
|
-
gridRowGap: '0px',
|
|
439
|
-
gridColumnGap: '0px',
|
|
440
|
-
gridAutoFlow: 'column'
|
|
441
|
-
}),
|
|
442
|
-
character: {
|
|
443
|
-
textTransform: 'initial !important',
|
|
444
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important'
|
|
445
|
-
},
|
|
446
|
-
language: {
|
|
447
|
-
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
448
|
-
'& *': {
|
|
449
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
holder: {
|
|
453
|
-
position: 'relative',
|
|
454
|
-
width: '100%',
|
|
455
|
-
height: '100%',
|
|
456
|
-
backgroundColor: '#cef',
|
|
457
|
-
borderRadius: 0,
|
|
458
|
-
padding: "".concat(theme.spacing.unit, "px 0 ").concat(theme.spacing.unit, "px 0")
|
|
459
|
-
},
|
|
460
|
-
labelButton: {
|
|
461
|
-
minWidth: 'auto',
|
|
462
|
-
fontSize: '140% !important',
|
|
463
|
-
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.primary.light, 0.5),
|
|
464
|
-
'&:hover': {
|
|
465
|
-
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.primary.light, 0.7)
|
|
466
|
-
},
|
|
467
|
-
borderRadius: 0
|
|
468
|
-
},
|
|
469
|
-
latexButton: {
|
|
470
|
-
minWidth: 'auto',
|
|
471
|
-
borderRadius: 0,
|
|
472
|
-
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.primary.light, 0.5),
|
|
473
|
-
'&:hover': {
|
|
474
|
-
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.primary.light, 0.7)
|
|
475
|
-
}
|
|
476
|
-
},
|
|
477
|
-
deleteButton: {
|
|
478
|
-
'& > span': {
|
|
479
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
base: {},
|
|
483
|
-
operators: {
|
|
484
|
-
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.secondary.light, 0.5),
|
|
485
|
-
'&:hover': {
|
|
486
|
-
backgroundColor: (0, _colorManipulator.lighten)(theme.palette.secondary.light, 0.7)
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
comparison: {
|
|
490
|
-
backgroundColor: (0, _colorManipulator.lighten)(_green["default"][500], 0.5),
|
|
491
|
-
'&:hover': {
|
|
492
|
-
backgroundColor: (0, _colorManipulator.lighten)(_green["default"][500], 0.7)
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
comma: {
|
|
496
|
-
fontSize: '200% !important',
|
|
497
|
-
lineHeight: '100%'
|
|
498
|
-
},
|
|
499
|
-
dot: {
|
|
500
|
-
fontSize: '200% !important',
|
|
501
|
-
lineHeight: '100%'
|
|
502
|
-
},
|
|
503
|
-
icon: {
|
|
504
|
-
height: '30px'
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
var _default = (0, _styles.withStyles)(styles)(KeyPad);
|
|
510
|
-
|
|
511
|
-
exports["default"] = _default;
|
|
430
|
+
var _default = exports["default"] = KeyPad;
|
|
512
431
|
//# sourceMappingURL=index.js.map
|