@pie-lib/math-input 6.31.0-mui-update.0 → 6.31.1-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -6
- package/lib/__tests__/math-input-test.js +109 -0
- package/lib/horizontal-keypad.js +45 -17
- package/lib/index.js +26 -4
- package/lib/keypad/__tests__/index.test.js +41 -0
- package/lib/keypad/__tests__/keys-layout.test.js +15 -0
- package/lib/keypad/index.js +316 -237
- package/lib/keypad/keys-layout.js +13 -3
- package/lib/keys/__tests__/utils.test.js +60 -0
- package/lib/keys/basic-operators.js +14 -6
- package/lib/keys/chars.js +11 -6
- package/lib/keys/comparison.js +17 -7
- package/lib/keys/constants.js +11 -5
- package/lib/keys/digits.js +8 -2
- package/lib/keys/edit.js +5 -2
- package/lib/keys/exponent.js +11 -5
- package/lib/keys/fractions.js +9 -4
- package/lib/keys/geometry.js +55 -26
- package/lib/keys/grades.js +47 -11
- package/lib/keys/index.js +33 -14
- package/lib/keys/log.js +9 -4
- package/lib/keys/logic.js +7 -3
- package/lib/keys/matrices.js +7 -3
- package/lib/keys/misc.js +23 -11
- package/lib/keys/navigation.js +8 -3
- package/lib/keys/operators.js +5 -2
- package/lib/keys/statistics.js +13 -6
- package/lib/keys/sub-sup.js +7 -3
- package/lib/keys/trigonometry.js +15 -7
- package/lib/keys/utils.js +41 -8
- package/lib/keys/vars.js +9 -4
- package/lib/math-input.js +104 -53
- package/lib/mq/__tests__/input.test.js +119 -0
- package/lib/mq/__tests__/static.test.js +74 -0
- package/lib/mq/common-mq-styles.js +19 -8
- package/lib/mq/custom-elements.js +5 -2
- package/lib/mq/index.js +5 -1
- package/lib/mq/input.js +76 -23
- package/lib/mq/static.js +93 -32
- package/lib/updateSpans.js +6 -2
- package/package.json +7 -9
- package/src/keypad/index.jsx +153 -154
- package/src/math-input.jsx +44 -35
- package/src/mq/input.jsx +9 -9
- package/LICENSE.md +0 -5
- package/NEXT.CHANGELOG.json +0 -1
- package/lib/horizontal-keypad.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/keypad/index.js.map +0 -1
- package/lib/keypad/keys-layout.js.map +0 -1
- package/lib/keys/basic-operators.js.map +0 -1
- package/lib/keys/chars.js.map +0 -1
- package/lib/keys/comparison.js.map +0 -1
- package/lib/keys/constants.js.map +0 -1
- package/lib/keys/digits.js.map +0 -1
- package/lib/keys/edit.js.map +0 -1
- package/lib/keys/exponent.js.map +0 -1
- package/lib/keys/fractions.js.map +0 -1
- package/lib/keys/geometry.js.map +0 -1
- package/lib/keys/grades.js.map +0 -1
- package/lib/keys/index.js.map +0 -1
- package/lib/keys/log.js.map +0 -1
- package/lib/keys/logic.js.map +0 -1
- package/lib/keys/matrices.js.map +0 -1
- package/lib/keys/misc.js.map +0 -1
- package/lib/keys/navigation.js.map +0 -1
- package/lib/keys/operators.js.map +0 -1
- package/lib/keys/statistics.js.map +0 -1
- package/lib/keys/sub-sup.js.map +0 -1
- package/lib/keys/trigonometry.js.map +0 -1
- package/lib/keys/utils.js.map +0 -1
- package/lib/keys/vars.js.map +0 -1
- package/lib/math-input.js.map +0 -1
- package/lib/mq/common-mq-styles.js.map +0 -1
- package/lib/mq/custom-elements.js.map +0 -1
- package/lib/mq/index.js.map +0 -1
- package/lib/mq/input.js.map +0 -1
- package/lib/mq/static.js.map +0 -1
- package/lib/shared/constants.js +0 -13
- package/lib/updateSpans.js.map +0 -1
package/package.json
CHANGED
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.31.
|
|
6
|
+
"version": "6.31.1-beta-1",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"module": "src/index.jsx",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"@
|
|
12
|
-
"@mui/icons-material": "^7.3.4",
|
|
13
|
-
"@mui/material": "^7.3.4",
|
|
10
|
+
"@material-ui/core": "^3.8.3",
|
|
11
|
+
"@material-ui/icons": "^3.0.2",
|
|
14
12
|
"@pie-framework/mathquill": "^1.1.3",
|
|
15
13
|
"classnames": "^2.2.6",
|
|
16
14
|
"debug": "^4.1.1",
|
|
@@ -19,12 +17,12 @@
|
|
|
19
17
|
"react-portal": "^4.2.0"
|
|
20
18
|
},
|
|
21
19
|
"peerDependencies": {
|
|
22
|
-
"react": "
|
|
20
|
+
"react": "18.2.0"
|
|
23
21
|
},
|
|
24
22
|
"devDependencies": {
|
|
25
|
-
"react": "
|
|
26
|
-
"react-dom": "
|
|
23
|
+
"react": "18.2.0",
|
|
24
|
+
"react-dom": "18.2.0"
|
|
27
25
|
},
|
|
28
26
|
"scripts": {},
|
|
29
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "ff5ec2ebe11110b7652812a10c6dc230f08e12cb"
|
|
30
28
|
}
|
package/src/keypad/index.jsx
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Button from '@
|
|
4
|
-
import IconButton from '@
|
|
5
|
-
import {
|
|
3
|
+
import Button from '@material-ui/core/Button';
|
|
4
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
5
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
+
import { lighten, fade } from '@material-ui/core/styles/colorManipulator';
|
|
8
|
+
import green from '@material-ui/core/colors/green';
|
|
7
9
|
import debug from 'debug';
|
|
8
10
|
import _ from 'lodash';
|
|
9
11
|
import MathQuill from '@pie-framework/mathquill';
|
|
10
|
-
import * as mq from '../mq';
|
|
11
12
|
|
|
13
|
+
import * as mq from '../mq';
|
|
12
14
|
import { baseSet } from '../keys';
|
|
13
|
-
import editableHtmlConstants from '../../../editable-html/src/constants';
|
|
14
15
|
import { commonMqKeyboardStyles } from '../mq/common-mq-styles';
|
|
15
16
|
import { sortKeys } from './keys-layout';
|
|
16
|
-
import { green } from '@mui/material/colors';
|
|
17
17
|
|
|
18
18
|
const log = debug('pie-lib:math-inline:keypad');
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const baseStyles = {
|
|
20
|
+
const LatexButton = withStyles((theme) => ({
|
|
21
|
+
root: {
|
|
22
|
+
textTransform: 'none',
|
|
23
|
+
padding: 0,
|
|
24
|
+
margin: 0,
|
|
25
|
+
fontSize: '110% !important',
|
|
26
|
+
},
|
|
27
|
+
latexButton: {
|
|
29
28
|
pointerEvents: 'none',
|
|
30
29
|
textTransform: 'none !important',
|
|
31
30
|
'& .mq-scaled.mq-sqrt-prefix': {
|
|
@@ -35,24 +34,25 @@ const LatexButtonContent = styled(mq.Static)(({ theme, latex }) => {
|
|
|
35
34
|
marginBottom: '0.9px !important',
|
|
36
35
|
},
|
|
37
36
|
'& .mq-empty': {
|
|
38
|
-
backgroundColor: `${
|
|
37
|
+
backgroundColor: `${fade(theme.palette.secondary.main, 0.4)} !important`,
|
|
39
38
|
},
|
|
40
39
|
'& .mq-overline .mq-overline-inner': {
|
|
41
40
|
borderTop: '2px solid black',
|
|
42
41
|
},
|
|
43
42
|
'& .mq-non-leaf.mq-overline': {
|
|
44
|
-
borderTop: 'none !important',
|
|
43
|
+
borderTop: 'none !important', // fixing PD-4873 - in OT, it has border-top 1px and adds extra line
|
|
45
44
|
},
|
|
46
45
|
'& .mq-overarrow': {
|
|
47
46
|
width: '30px',
|
|
48
47
|
marginTop: '0 !important',
|
|
49
48
|
borderTop: '2px solid black',
|
|
50
49
|
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
50
|
+
|
|
51
51
|
'&.mq-arrow-both': {
|
|
52
52
|
top: '0px !important',
|
|
53
53
|
'& *': {
|
|
54
54
|
lineHeight: '1 !important',
|
|
55
|
-
borderTop: 'none !important',
|
|
55
|
+
borderTop: 'none !important', // fixing PD-4873 - in OT, it has border-top 1px and adds extra line,
|
|
56
56
|
},
|
|
57
57
|
'&:before': {
|
|
58
58
|
fontSize: '80%',
|
|
@@ -118,43 +118,40 @@ const LatexButtonContent = styled(mq.Static)(({ theme, latex }) => {
|
|
|
118
118
|
'& .mq-overarc': {
|
|
119
119
|
borderTop: '2px solid black !important',
|
|
120
120
|
'& .mq-overline': {
|
|
121
|
-
borderTop: 'none !important',
|
|
121
|
+
borderTop: 'none !important', // fixing PD-4873 - in OT, it has border-top 1px and adds extra line
|
|
122
122
|
},
|
|
123
123
|
'& .mq-overline-inner': {
|
|
124
124
|
borderTop: 'none !important',
|
|
125
125
|
paddingTop: '0 !important',
|
|
126
126
|
},
|
|
127
127
|
},
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (latex === '\\overleftrightarrow{\\overline{}}') {
|
|
139
|
-
return {
|
|
140
|
-
...baseStyles,
|
|
141
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
142
|
-
'& .mq-overline-inner': {
|
|
143
|
-
borderTop: 'none !important',
|
|
144
|
-
paddingTop: '0 !important',
|
|
145
|
-
},
|
|
146
|
-
'&:after': {
|
|
147
|
-
position: 'absolute !important',
|
|
148
|
-
top: '0px !important',
|
|
149
|
-
},
|
|
128
|
+
},
|
|
129
|
+
parallelButton: {
|
|
130
|
+
fontStyle: 'italic !important',
|
|
131
|
+
},
|
|
132
|
+
leftRightArrowButton: {
|
|
133
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
134
|
+
'& .mq-overline-inner': {
|
|
135
|
+
borderTop: 'none !important',
|
|
136
|
+
paddingTop: '0 !important',
|
|
150
137
|
},
|
|
151
|
-
|
|
138
|
+
'&:after': {
|
|
139
|
+
position: 'absolute !important',
|
|
140
|
+
top: '0px !important',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}))((props) => {
|
|
145
|
+
let buttonClass;
|
|
146
|
+
|
|
147
|
+
if (props.latex === '\\parallel') {
|
|
148
|
+
buttonClass = classNames(props.classes.latexButton, props.mqClassName, props.classes.parallelButton);
|
|
149
|
+
} else if (props.latex === '\\overleftrightarrow{\\overline{}}') {
|
|
150
|
+
buttonClass = classNames(props.classes.latexButton, props.mqClassName, props.classes.leftRightArrowButton);
|
|
151
|
+
} else {
|
|
152
|
+
buttonClass = classNames(props.classes.latexButton, props.mqClassName);
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
return baseStyles;
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const LatexButton = (props) => {
|
|
158
155
|
try {
|
|
159
156
|
const MQ = MathQuill.getInterface(2);
|
|
160
157
|
const span = document.createElement('span');
|
|
@@ -169,15 +166,15 @@ const LatexButton = (props) => {
|
|
|
169
166
|
}
|
|
170
167
|
|
|
171
168
|
return (
|
|
172
|
-
<
|
|
173
|
-
className={props.className}
|
|
169
|
+
<Button
|
|
170
|
+
className={classNames(props.classes.root, props.className)}
|
|
174
171
|
onClick={props.onClick}
|
|
175
172
|
aria-label={props.ariaLabel}
|
|
176
173
|
>
|
|
177
|
-
<
|
|
178
|
-
</
|
|
174
|
+
<mq.Static className={buttonClass} latex={props.latex} />
|
|
175
|
+
</Button>
|
|
179
176
|
);
|
|
180
|
-
};
|
|
177
|
+
});
|
|
181
178
|
|
|
182
179
|
const createCustomLayout = (layoutObj) => {
|
|
183
180
|
if (layoutObj) {
|
|
@@ -191,83 +188,9 @@ const createCustomLayout = (layoutObj) => {
|
|
|
191
188
|
return {};
|
|
192
189
|
};
|
|
193
190
|
|
|
194
|
-
const KeyPadContainer = styled('div')(({ theme }) => ({
|
|
195
|
-
...commonMqKeyboardStyles,
|
|
196
|
-
width: '100%',
|
|
197
|
-
display: 'grid',
|
|
198
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
199
|
-
gridRowGap: '0px',
|
|
200
|
-
gridColumnGap: '0px',
|
|
201
|
-
gridAutoFlow: 'column',
|
|
202
|
-
'&.character': {
|
|
203
|
-
textTransform: 'initial !important',
|
|
204
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',
|
|
205
|
-
},
|
|
206
|
-
'&.language': {
|
|
207
|
-
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
208
|
-
'& *': {
|
|
209
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
}));
|
|
213
|
-
|
|
214
|
-
const StyledButton = styled(Button)(({ theme, category, isDelete, isComma, isDot }) => ({
|
|
215
|
-
minWidth: 'auto',
|
|
216
|
-
fontSize: isComma || isDot ? '200% !important' : '140% !important',
|
|
217
|
-
lineHeight: isComma || isDot ? '100%' : 'normal',
|
|
218
|
-
backgroundColor:
|
|
219
|
-
category === 'operators' ? lighten(theme.palette.secondary.light, 0.5) :
|
|
220
|
-
category === 'comparison' ? lighten(green[500], 0.5) :
|
|
221
|
-
lighten(theme.palette.primary.light, 0.5),
|
|
222
|
-
'&:hover': {
|
|
223
|
-
backgroundColor:
|
|
224
|
-
category === 'operators' ? lighten(theme.palette.secondary.light, 0.7) :
|
|
225
|
-
category === 'comparison' ? lighten(green[500], 0.7) :
|
|
226
|
-
lighten(theme.palette.primary.light, 0.7),
|
|
227
|
-
},
|
|
228
|
-
borderRadius: 0,
|
|
229
|
-
...(isDelete && {
|
|
230
|
-
'& > span': {
|
|
231
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
232
|
-
},
|
|
233
|
-
}),
|
|
234
|
-
}));
|
|
235
|
-
|
|
236
|
-
const StyledLatexButtonWrapper = styled(Button)(({ theme, category }) => ({
|
|
237
|
-
minWidth: 'auto',
|
|
238
|
-
borderRadius: 0,
|
|
239
|
-
backgroundColor:
|
|
240
|
-
category === 'operators' ? lighten(theme.palette.secondary.light, 0.5) :
|
|
241
|
-
category === 'comparison' ? lighten(green[500], 0.5) :
|
|
242
|
-
lighten(theme.palette.primary.light, 0.5),
|
|
243
|
-
'&:hover': {
|
|
244
|
-
backgroundColor:
|
|
245
|
-
category === 'operators' ? lighten(theme.palette.secondary.light, 0.7) :
|
|
246
|
-
category === 'comparison' ? lighten(green[500], 0.7) :
|
|
247
|
-
lighten(theme.palette.primary.light, 0.7),
|
|
248
|
-
},
|
|
249
|
-
}));
|
|
250
|
-
|
|
251
|
-
const StyledIconButton = styled(IconButton)(({ theme, category }) => ({
|
|
252
|
-
minWidth: 'auto',
|
|
253
|
-
backgroundColor:
|
|
254
|
-
category === 'operators' ? lighten(theme.palette.secondary.light, 0.5) :
|
|
255
|
-
category === 'comparison' ? lighten(green[500], 0.5) :
|
|
256
|
-
lighten(theme.palette.primary.light, 0.5),
|
|
257
|
-
'&:hover': {
|
|
258
|
-
backgroundColor:
|
|
259
|
-
category === 'operators' ? lighten(theme.palette.secondary.light, 0.7) :
|
|
260
|
-
category === 'comparison' ? lighten(green[500], 0.7) :
|
|
261
|
-
lighten(theme.palette.primary.light, 0.7),
|
|
262
|
-
},
|
|
263
|
-
borderRadius: 0,
|
|
264
|
-
'& .icon': {
|
|
265
|
-
height: '30px',
|
|
266
|
-
},
|
|
267
|
-
}));
|
|
268
|
-
|
|
269
191
|
export class KeyPad extends React.Component {
|
|
270
192
|
static propTypes = {
|
|
193
|
+
classes: PropTypes.object.isRequired,
|
|
271
194
|
className: PropTypes.string,
|
|
272
195
|
controlledKeypadMode: PropTypes.bool,
|
|
273
196
|
baseSet: PropTypes.array,
|
|
@@ -291,7 +214,7 @@ export class KeyPad extends React.Component {
|
|
|
291
214
|
|
|
292
215
|
componentDidMount() {
|
|
293
216
|
const keyPadElement = this.keypadRef?.current;
|
|
294
|
-
const mainContainer = keyPadElement?.closest(
|
|
217
|
+
const mainContainer = keyPadElement?.closest('.main-container');
|
|
295
218
|
const currentToolbar = keyPadElement?.closest('.pie-toolbar');
|
|
296
219
|
|
|
297
220
|
// need only for math keyboard so we need also controlledKeypadMode
|
|
@@ -321,7 +244,7 @@ export class KeyPad extends React.Component {
|
|
|
321
244
|
const keyPadElement = this.keypadRef?.current;
|
|
322
245
|
// need only for math keyboard
|
|
323
246
|
if (this.props.controlledKeypadMode && keyPadElement) {
|
|
324
|
-
const mainContainer = keyPadElement.closest(
|
|
247
|
+
const mainContainer = keyPadElement.closest('.main-container');
|
|
325
248
|
|
|
326
249
|
if (mainContainer) {
|
|
327
250
|
mainContainer.style.height = 'unset';
|
|
@@ -365,14 +288,14 @@ export class KeyPad extends React.Component {
|
|
|
365
288
|
};
|
|
366
289
|
|
|
367
290
|
render() {
|
|
368
|
-
const { className, baseSet, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;
|
|
291
|
+
const { classes, className, baseSet, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;
|
|
369
292
|
|
|
370
293
|
const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];
|
|
371
294
|
|
|
372
295
|
const keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
373
296
|
const allKeys = keysWithoutBaseSet
|
|
374
297
|
? this.flowKeys([], additionalKeys || [])
|
|
375
|
-
: this.flowKeys(baseSet, additionalKeys || []);
|
|
298
|
+
: this.flowKeys(baseSet, additionalKeys || []); //, ...sortKeys(additionalKeys)];
|
|
376
299
|
|
|
377
300
|
const shift = allKeys.length % 5 ? 1 : 0;
|
|
378
301
|
const style = {
|
|
@@ -381,9 +304,9 @@ export class KeyPad extends React.Component {
|
|
|
381
304
|
};
|
|
382
305
|
|
|
383
306
|
return (
|
|
384
|
-
<
|
|
307
|
+
<div
|
|
385
308
|
ref={this.keypadRef}
|
|
386
|
-
className={classNames(className, mode)}
|
|
309
|
+
className={classNames(classes.keys, className, classes[mode])}
|
|
387
310
|
style={style}
|
|
388
311
|
onFocus={onFocus}
|
|
389
312
|
>
|
|
@@ -396,6 +319,13 @@ export class KeyPad extends React.Component {
|
|
|
396
319
|
|
|
397
320
|
const common = {
|
|
398
321
|
onClick,
|
|
322
|
+
className: classNames(
|
|
323
|
+
classes.labelButton,
|
|
324
|
+
!keysWithoutBaseSet && classes[k.category],
|
|
325
|
+
classes[k.extraClass],
|
|
326
|
+
k.label === ',' && classes.comma,
|
|
327
|
+
k.label === '.' && classes.dot,
|
|
328
|
+
),
|
|
399
329
|
disabled: this.keyIsNotAllowed(k),
|
|
400
330
|
key: `${k.label || k.latex || k.command}-${index}`,
|
|
401
331
|
...(k.actions || {}),
|
|
@@ -404,47 +334,116 @@ export class KeyPad extends React.Component {
|
|
|
404
334
|
|
|
405
335
|
if (k.latex) {
|
|
406
336
|
return (
|
|
407
|
-
<
|
|
337
|
+
<LatexButton
|
|
338
|
+
latex={k.latex}
|
|
339
|
+
key={index}
|
|
408
340
|
{...common}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
<LatexButtonContent latex={k.latex} />
|
|
413
|
-
</StyledLatexButtonWrapper>
|
|
341
|
+
className={classes.latexButton}
|
|
342
|
+
ariaLabel={k.ariaLabel ? k.ariaLabel : k.name || k.label}
|
|
343
|
+
/>
|
|
414
344
|
);
|
|
415
345
|
}
|
|
416
346
|
|
|
417
347
|
if (k.label) {
|
|
418
348
|
return (
|
|
419
|
-
<
|
|
349
|
+
<Button
|
|
350
|
+
key={index}
|
|
420
351
|
{...common}
|
|
421
|
-
|
|
422
|
-
isDelete={k.label === '⌫'}
|
|
423
|
-
isComma={k.label === ','}
|
|
424
|
-
isDot={k.label === '.'}
|
|
352
|
+
className={classNames(common.className, { [classes.deleteButton]: k.label === '⌫' })}
|
|
425
353
|
aria-label={k.ariaLabel ? k.ariaLabel : k.name || k.label}
|
|
426
354
|
>
|
|
427
355
|
{k.label}
|
|
428
|
-
</
|
|
356
|
+
</Button>
|
|
429
357
|
);
|
|
430
358
|
} else {
|
|
431
359
|
const Icon = k.icon ? k.icon : 'div';
|
|
432
360
|
|
|
433
361
|
return (
|
|
434
|
-
<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
438
|
-
size="large"
|
|
439
|
-
>
|
|
440
|
-
<Icon className="icon" />
|
|
441
|
-
</StyledIconButton>
|
|
362
|
+
<IconButton tabIndex={'-1'} {...common} key={index}>
|
|
363
|
+
<Icon className={classes.icon} />
|
|
364
|
+
</IconButton>
|
|
442
365
|
);
|
|
443
366
|
}
|
|
444
367
|
})}
|
|
445
|
-
</
|
|
368
|
+
</div>
|
|
446
369
|
);
|
|
447
370
|
}
|
|
448
371
|
}
|
|
449
372
|
|
|
450
|
-
|
|
373
|
+
const styles = (theme) => ({
|
|
374
|
+
keys: {
|
|
375
|
+
...commonMqKeyboardStyles,
|
|
376
|
+
width: '100%',
|
|
377
|
+
display: 'grid',
|
|
378
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
379
|
+
gridRowGap: '0px',
|
|
380
|
+
gridColumnGap: '0px',
|
|
381
|
+
gridAutoFlow: 'column',
|
|
382
|
+
},
|
|
383
|
+
character: {
|
|
384
|
+
textTransform: 'initial !important',
|
|
385
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',
|
|
386
|
+
},
|
|
387
|
+
language: {
|
|
388
|
+
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
389
|
+
'& *': {
|
|
390
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
holder: {
|
|
394
|
+
position: 'relative',
|
|
395
|
+
width: '100%',
|
|
396
|
+
height: '100%',
|
|
397
|
+
backgroundColor: '#cef',
|
|
398
|
+
borderRadius: 0,
|
|
399
|
+
padding: `${theme.spacing.unit}px 0 ${theme.spacing.unit}px 0`,
|
|
400
|
+
},
|
|
401
|
+
labelButton: {
|
|
402
|
+
minWidth: 'auto',
|
|
403
|
+
fontSize: '140% !important',
|
|
404
|
+
backgroundColor: lighten(theme.palette.primary.light, 0.5),
|
|
405
|
+
'&:hover': {
|
|
406
|
+
backgroundColor: lighten(theme.palette.primary.light, 0.7),
|
|
407
|
+
},
|
|
408
|
+
borderRadius: 0,
|
|
409
|
+
},
|
|
410
|
+
latexButton: {
|
|
411
|
+
minWidth: 'auto',
|
|
412
|
+
borderRadius: 0,
|
|
413
|
+
backgroundColor: lighten(theme.palette.primary.light, 0.5),
|
|
414
|
+
'&:hover': {
|
|
415
|
+
backgroundColor: lighten(theme.palette.primary.light, 0.7),
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
deleteButton: {
|
|
419
|
+
'& > span': {
|
|
420
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
base: {},
|
|
424
|
+
operators: {
|
|
425
|
+
backgroundColor: lighten(theme.palette.secondary.light, 0.5),
|
|
426
|
+
'&:hover': {
|
|
427
|
+
backgroundColor: lighten(theme.palette.secondary.light, 0.7),
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
comparison: {
|
|
431
|
+
backgroundColor: lighten(green[500], 0.5),
|
|
432
|
+
'&:hover': {
|
|
433
|
+
backgroundColor: lighten(green[500], 0.7),
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
comma: {
|
|
437
|
+
fontSize: '200% !important',
|
|
438
|
+
lineHeight: '100%',
|
|
439
|
+
},
|
|
440
|
+
dot: {
|
|
441
|
+
fontSize: '200% !important',
|
|
442
|
+
lineHeight: '100%',
|
|
443
|
+
},
|
|
444
|
+
icon: {
|
|
445
|
+
height: '30px',
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
export default withStyles(styles)(KeyPad);
|
package/src/math-input.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
import * as mq from './mq';
|
|
5
6
|
import { baseSet } from './keys';
|
|
6
7
|
import KeyPad from './keypad';
|
|
@@ -8,35 +9,9 @@ import debug from 'debug';
|
|
|
8
9
|
|
|
9
10
|
const log = debug('pie-lib:math-input');
|
|
10
11
|
|
|
11
|
-
const grey = 'rgba(0, 0, 0, 0.23)';
|
|
12
|
-
|
|
13
|
-
const MathInputContainer = styled('div')(({ theme, focused }) => ({
|
|
14
|
-
borderRadius: '4px',
|
|
15
|
-
border: `solid 1px ${focused ? theme.palette.primary.main : grey}`,
|
|
16
|
-
marginTop: theme.spacing(1),
|
|
17
|
-
marginBottom: theme.spacing(1),
|
|
18
|
-
transition: 'border 200ms linear',
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const PadContainer = styled('div')({
|
|
22
|
-
width: '100%',
|
|
23
|
-
display: 'flex',
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const StyledMqInput = styled(mq.Input)(({ theme }) => ({
|
|
27
|
-
width: '100%',
|
|
28
|
-
border: `solid 0px ${theme.palette.primary.light}`,
|
|
29
|
-
transition: 'border 200ms linear',
|
|
30
|
-
padding: theme.spacing(1),
|
|
31
|
-
'&.mq-focused': {
|
|
32
|
-
outline: 'none',
|
|
33
|
-
boxShadow: 'none',
|
|
34
|
-
border: `solid 0px ${theme.palette.primary.dark}`,
|
|
35
|
-
},
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
12
|
export class MathInput extends React.Component {
|
|
39
13
|
static propTypes = {
|
|
14
|
+
classes: PropTypes.object.isRequired,
|
|
40
15
|
className: PropTypes.string,
|
|
41
16
|
keyset: PropTypes.array,
|
|
42
17
|
displayMode: PropTypes.oneOf(['block', 'block-on-focus']),
|
|
@@ -92,14 +67,15 @@ export class MathInput extends React.Component {
|
|
|
92
67
|
};
|
|
93
68
|
|
|
94
69
|
render() {
|
|
95
|
-
const { className, keyset, latex } = this.props;
|
|
70
|
+
const { classes, className, keyset, latex } = this.props;
|
|
96
71
|
const { focused } = this.state;
|
|
97
72
|
|
|
98
73
|
const showKeypad = true; // TODO: add support for different displayModes - displayMode === 'block' || focused;
|
|
99
74
|
|
|
100
75
|
return (
|
|
101
|
-
<
|
|
102
|
-
<
|
|
76
|
+
<div className={classNames(classes.mathInput, className, focused && classes.focused)}>
|
|
77
|
+
<mq.Input
|
|
78
|
+
className={classes.mqInput}
|
|
103
79
|
innerRef={(r) => (this.input = r)}
|
|
104
80
|
onFocus={this.inputFocus}
|
|
105
81
|
onBlur={this.inputBlur}
|
|
@@ -107,13 +83,46 @@ export class MathInput extends React.Component {
|
|
|
107
83
|
onChange={this.changeLatex}
|
|
108
84
|
/>
|
|
109
85
|
{showKeypad && (
|
|
110
|
-
<
|
|
86
|
+
<div className={classes.pad}>
|
|
111
87
|
<KeyPad baseSet={baseSet} additionalKeys={keyset} onPress={this.keypadPress} />
|
|
112
|
-
</
|
|
88
|
+
</div>
|
|
113
89
|
)}
|
|
114
|
-
</
|
|
90
|
+
</div>
|
|
115
91
|
);
|
|
116
92
|
}
|
|
117
93
|
}
|
|
118
94
|
|
|
119
|
-
|
|
95
|
+
const grey = 'rgba(0, 0, 0, 0.23)';
|
|
96
|
+
const styles = (theme) => ({
|
|
97
|
+
formGroup: {
|
|
98
|
+
display: 'flex',
|
|
99
|
+
textAlign: 'right',
|
|
100
|
+
float: 'right',
|
|
101
|
+
},
|
|
102
|
+
pad: {
|
|
103
|
+
width: '100%',
|
|
104
|
+
display: 'flex',
|
|
105
|
+
},
|
|
106
|
+
mathInput: {
|
|
107
|
+
borderRadius: '4px',
|
|
108
|
+
border: `solid 1px ${grey}`,
|
|
109
|
+
marginTop: theme.spacing.unit,
|
|
110
|
+
marginBottom: theme.spacing.unit,
|
|
111
|
+
transition: 'border 200ms linear',
|
|
112
|
+
},
|
|
113
|
+
focused: {
|
|
114
|
+
border: `solid 1px ${theme.palette.primary.main}`,
|
|
115
|
+
},
|
|
116
|
+
mqInput: {
|
|
117
|
+
width: '100%',
|
|
118
|
+
border: `solid 0px ${theme.palette.primary.light}`,
|
|
119
|
+
transition: 'border 200ms linear',
|
|
120
|
+
padding: theme.spacing.unit,
|
|
121
|
+
'&.mq-focused': {
|
|
122
|
+
outline: 'none',
|
|
123
|
+
boxShadow: 'none',
|
|
124
|
+
border: `solid 0px ${theme.palette.primary.dark}`,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
export default withStyles(styles)(MathInput);
|
package/src/mq/input.jsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
4
|
import debug from 'debug';
|
|
5
|
+
import classNames from 'classnames';
|
|
5
6
|
import { registerLineBreak } from './custom-elements';
|
|
6
7
|
import MathQuill from '@pie-framework/mathquill';
|
|
7
8
|
|
|
@@ -16,16 +17,13 @@ if (typeof window !== 'undefined') {
|
|
|
16
17
|
|
|
17
18
|
const log = debug('math-input:mq:input');
|
|
18
19
|
|
|
19
|
-
const StyledSpan = styled('span')({
|
|
20
|
-
// No specific styles needed, but component is available for future styling
|
|
21
|
-
});
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* Wrapper for MathQuill MQ.MathField.
|
|
25
22
|
*/
|
|
26
23
|
export class Input extends React.Component {
|
|
27
24
|
static propTypes = {
|
|
28
25
|
className: PropTypes.string,
|
|
26
|
+
classes: PropTypes.object.isRequired,
|
|
29
27
|
onClick: PropTypes.func,
|
|
30
28
|
onChange: PropTypes.func,
|
|
31
29
|
latex: PropTypes.string,
|
|
@@ -158,11 +156,11 @@ export class Input extends React.Component {
|
|
|
158
156
|
}
|
|
159
157
|
|
|
160
158
|
render() {
|
|
161
|
-
const { onFocus, onBlur, className } = this.props;
|
|
159
|
+
const { onFocus, onBlur, classes, className } = this.props;
|
|
162
160
|
|
|
163
161
|
return (
|
|
164
|
-
<
|
|
165
|
-
className={className}
|
|
162
|
+
<span
|
|
163
|
+
className={classNames(classes.input, className)}
|
|
166
164
|
onKeyDown={this.onKeyPress}
|
|
167
165
|
onClick={this.onClick}
|
|
168
166
|
onFocus={onFocus}
|
|
@@ -173,4 +171,6 @@ export class Input extends React.Component {
|
|
|
173
171
|
}
|
|
174
172
|
}
|
|
175
173
|
|
|
176
|
-
|
|
174
|
+
const styles = () => ({});
|
|
175
|
+
|
|
176
|
+
export default withStyles(styles)(Input);
|
package/LICENSE.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
Copyright 2019 CoreSpring Inc
|
|
2
|
-
|
|
3
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
4
|
-
|
|
5
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/NEXT.CHANGELOG.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"horizontal-keypad.js","names":["_react","_interopRequireDefault","require","_propTypes","_grades","_utils","_keypad","_callSuper","t","o","e","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","toOldModel","d","command","value","type","write","keystroke","HorizontalKeypad","exports","_React$Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","concat","_defineProperty2","data","onClick","props","_inherits2","_createClass2","key","render","_this$props","mode","onFocus","controlledKeypadMode","noDecimal","className","additionalKeys","layoutForKeyPad","setKeypadInteraction","normalizedKeys","normalizeAdditionalKeys","createElement","extendKeySet","keysForGrade","onPress","keypadPress","React","Component","PropTypes","string","bool","oneOfType","number","object","func","isRequired","array"],"sources":["../src/horizontal-keypad.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { keysForGrade, normalizeAdditionalKeys } from './keys/grades';\nimport { extendKeySet } from './keys/utils';\nimport Keypad from './keypad';\n\nconst toOldModel = (d) => {\n if (d.command) {\n return { value: d.command, type: 'command' };\n } else if (d.write) {\n return { value: d.write };\n } else if (d.keystroke) {\n return { type: 'cursor', value: d.keystroke };\n }\n};\n\nexport default class HorizontalKeypad extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n controlledKeypadMode: PropTypes.bool,\n mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n layoutForKeyPad: PropTypes.object,\n onClick: PropTypes.func.isRequired,\n onFocus: PropTypes.func,\n noDecimal: PropTypes.bool,\n additionalKeys: PropTypes.array,\n setKeypadInteraction: PropTypes.func,\n };\n\n static defaultProps = {\n mode: 'scientific',\n noDecimal: false,\n additionalKeys: [],\n };\n\n keypadPress = (data) => {\n const { onClick } = this.props;\n\n onClick(toOldModel(data));\n };\n\n render() {\n const {\n mode,\n onFocus,\n controlledKeypadMode,\n noDecimal,\n className,\n additionalKeys,\n layoutForKeyPad,\n setKeypadInteraction,\n } = this.props;\n const normalizedKeys = normalizeAdditionalKeys(additionalKeys);\n\n return (\n <Keypad\n className={className}\n controlledKeypadMode={controlledKeypadMode}\n onFocus={onFocus}\n noDecimal={noDecimal}\n layoutForKeyPad={layoutForKeyPad}\n additionalKeys={extendKeySet(keysForGrade(mode), normalizedKeys)}\n onPress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