@pie-lib/math-input 6.31.2-next.11 → 6.31.2-next.164
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 +6 -64
- 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 +254 -332
- 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 +34 -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 +10 -10
- package/src/__tests__/math-input-test.jsx +31 -71
- package/src/keypad/__tests__/index.test.jsx +18 -17
- package/src/keypad/index.jsx +172 -169
- package/src/math-input.jsx +35 -44
- package/src/mq/__tests__/input.test.jsx +26 -78
- package/src/mq/__tests__/static.test.jsx +14 -38
- package/src/mq/input.jsx +9 -9
- package/src/mq/static.jsx +3 -0
- package/esm/index.css +0 -847
- package/esm/index.js +0 -44393
- package/esm/index.js.map +0 -1
- package/src/__tests__/__snapshots__/math-input-test.jsx.snap +0 -152
- package/src/keypad/__tests__/__snapshots__/index.test.jsx.snap +0 -193
- package/src/mq/__tests__/__snapshots__/input.test.jsx.snap +0 -9
package/src/keypad/index.jsx
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Button from '@material
|
|
4
|
-
import IconButton from '@material
|
|
5
|
-
import {
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
import { lighten, fade } from '@material-ui/core/styles/colorManipulator';
|
|
8
|
-
import green from '@material-ui/core/colors/green';
|
|
3
|
+
import Button from '@mui/material/Button';
|
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
|
5
|
+
import { lighten, alpha, styled } from '@mui/material/styles';
|
|
9
6
|
import debug from 'debug';
|
|
10
7
|
import _ from 'lodash';
|
|
11
8
|
import MathQuill from '@pie-framework/mathquill';
|
|
12
|
-
|
|
13
9
|
import * as mq from '../mq';
|
|
10
|
+
|
|
14
11
|
import { baseSet } from '../keys';
|
|
15
12
|
import editableHtmlConstants from '../../../editable-html/src/constants';
|
|
16
13
|
import { commonMqKeyboardStyles } from '../mq/common-mq-styles';
|
|
17
14
|
import { sortKeys } from './keys-layout';
|
|
15
|
+
import { indigo, pink } from '@mui/material/colors';
|
|
16
|
+
import { color } from '@pie-lib/render-ui';
|
|
18
17
|
|
|
19
18
|
const log = debug('pie-lib:math-inline:keypad');
|
|
20
19
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const StyledLatexButton = styled(Button)(() => ({
|
|
21
|
+
textTransform: 'none',
|
|
22
|
+
padding: 0,
|
|
23
|
+
margin: 0,
|
|
24
|
+
fontSize: '110% !important',
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const LatexButtonContent = styled(mq.Static)(({ latex }) => {
|
|
28
|
+
const baseStyles = {
|
|
29
29
|
pointerEvents: 'none',
|
|
30
30
|
textTransform: 'none !important',
|
|
31
|
+
color: color.text(),
|
|
31
32
|
'& .mq-scaled.mq-sqrt-prefix': {
|
|
32
33
|
transform: 'scale(1, 0.9) !important',
|
|
33
34
|
},
|
|
@@ -35,25 +36,24 @@ const LatexButton = withStyles((theme) => ({
|
|
|
35
36
|
marginBottom: '0.9px !important',
|
|
36
37
|
},
|
|
37
38
|
'& .mq-empty': {
|
|
38
|
-
backgroundColor: `${
|
|
39
|
+
backgroundColor: `${alpha(pink[300], 0.4)} !important`,
|
|
39
40
|
},
|
|
40
41
|
'& .mq-overline .mq-overline-inner': {
|
|
41
42
|
borderTop: '2px solid black',
|
|
42
43
|
},
|
|
43
44
|
'& .mq-non-leaf.mq-overline': {
|
|
44
|
-
borderTop: 'none !important',
|
|
45
|
+
borderTop: 'none !important',
|
|
45
46
|
},
|
|
46
47
|
'& .mq-overarrow': {
|
|
47
48
|
width: '30px',
|
|
48
49
|
marginTop: '0 !important',
|
|
49
50
|
borderTop: '2px solid black',
|
|
50
51
|
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
51
|
-
|
|
52
52
|
'&.mq-arrow-both': {
|
|
53
53
|
top: '0px !important',
|
|
54
54
|
'& *': {
|
|
55
55
|
lineHeight: '1 !important',
|
|
56
|
-
borderTop: 'none !important',
|
|
56
|
+
borderTop: 'none !important',
|
|
57
57
|
},
|
|
58
58
|
'&:before': {
|
|
59
59
|
fontSize: '80%',
|
|
@@ -119,64 +119,48 @@ const LatexButton = withStyles((theme) => ({
|
|
|
119
119
|
'& .mq-overarc': {
|
|
120
120
|
borderTop: '2px solid black !important',
|
|
121
121
|
'& .mq-overline': {
|
|
122
|
-
borderTop: 'none !important', // fixing PD-4873 - in OT, it has border-top 1px and adds extra line
|
|
123
|
-
},
|
|
124
|
-
'& .mq-overline-inner': {
|
|
125
122
|
borderTop: 'none !important',
|
|
126
|
-
paddingTop: '0 !important',
|
|
127
123
|
},
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
parallelButton: {
|
|
131
|
-
fontStyle: 'italic !important',
|
|
132
|
-
},
|
|
133
|
-
leftRightArrowButton: {
|
|
134
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
135
124
|
'& .mq-overline-inner': {
|
|
136
125
|
borderTop: 'none !important',
|
|
137
126
|
paddingTop: '0 !important',
|
|
138
127
|
},
|
|
139
|
-
'&:after': {
|
|
140
|
-
position: 'absolute !important',
|
|
141
|
-
top: '0px !important',
|
|
142
|
-
},
|
|
143
128
|
},
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} else {
|
|
153
|
-
buttonClass = classNames(props.classes.latexButton, props.mqClassName);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Add specific styles based on latex content
|
|
132
|
+
if (latex === '\\parallel') {
|
|
133
|
+
return {
|
|
134
|
+
...baseStyles,
|
|
135
|
+
fontStyle: 'italic !important',
|
|
136
|
+
};
|
|
154
137
|
}
|
|
155
138
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
139
|
+
if (latex === '\\overleftrightarrow{\\overline{}}') {
|
|
140
|
+
return {
|
|
141
|
+
...baseStyles,
|
|
142
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
143
|
+
'& .mq-overline-inner': {
|
|
144
|
+
borderTop: 'none !important',
|
|
145
|
+
paddingTop: '0 !important',
|
|
146
|
+
},
|
|
147
|
+
'&:after': {
|
|
148
|
+
position: 'absolute !important',
|
|
149
|
+
top: '0px !important',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
167
153
|
}
|
|
168
154
|
|
|
169
|
-
return
|
|
170
|
-
<Button
|
|
171
|
-
className={classNames(props.classes.root, props.className)}
|
|
172
|
-
onClick={props.onClick}
|
|
173
|
-
aria-label={props.ariaLabel}
|
|
174
|
-
>
|
|
175
|
-
<mq.Static className={buttonClass} latex={props.latex} />
|
|
176
|
-
</Button>
|
|
177
|
-
);
|
|
155
|
+
return baseStyles;
|
|
178
156
|
});
|
|
179
157
|
|
|
158
|
+
LatexButtonContent.propTypes = {
|
|
159
|
+
latex: PropTypes.string.isRequired,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// LatexButton component removed - LatexButtonContent is used directly instead
|
|
163
|
+
|
|
180
164
|
const createCustomLayout = (layoutObj) => {
|
|
181
165
|
if (layoutObj) {
|
|
182
166
|
return {
|
|
@@ -189,9 +173,92 @@ const createCustomLayout = (layoutObj) => {
|
|
|
189
173
|
return {};
|
|
190
174
|
};
|
|
191
175
|
|
|
176
|
+
const KeyPadContainer = styled('div')(() => ({
|
|
177
|
+
...commonMqKeyboardStyles,
|
|
178
|
+
width: '100%',
|
|
179
|
+
display: 'grid',
|
|
180
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
181
|
+
gridRowGap: '0px',
|
|
182
|
+
gridColumnGap: '0px',
|
|
183
|
+
gridAutoFlow: 'column',
|
|
184
|
+
'&.character': {
|
|
185
|
+
textTransform: 'initial !important',
|
|
186
|
+
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',
|
|
187
|
+
},
|
|
188
|
+
'&.language': {
|
|
189
|
+
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
190
|
+
'& *': {
|
|
191
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
const StyledButton = styled(Button)(({ category, isDelete, isComma, isDot }) => ({
|
|
197
|
+
minWidth: 'auto',
|
|
198
|
+
fontSize: isComma || isDot ? '200% !important' : '140% !important',
|
|
199
|
+
lineHeight: isComma || isDot ? '100%' : 'normal',
|
|
200
|
+
color: color.text(),
|
|
201
|
+
|
|
202
|
+
backgroundColor:
|
|
203
|
+
category === 'operators'
|
|
204
|
+
? lighten(pink[300], 0.5)
|
|
205
|
+
: // this code with green seems to not be applied to current implementation, so I commented it out, but left it here just in case
|
|
206
|
+
// category === 'comparison' ? lighten(green[500], 0.5) :
|
|
207
|
+
lighten(indigo[300], 0.5),
|
|
208
|
+
'&:hover': {
|
|
209
|
+
backgroundColor:
|
|
210
|
+
category === 'operators'
|
|
211
|
+
? lighten(pink[300], 0.7)
|
|
212
|
+
: // category === 'comparison' ? lighten(green[500], 0.7) :
|
|
213
|
+
lighten(indigo[300], 0.7),
|
|
214
|
+
},
|
|
215
|
+
borderRadius: 0,
|
|
216
|
+
...(isDelete && {
|
|
217
|
+
'& > span': {
|
|
218
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
}));
|
|
222
|
+
|
|
223
|
+
const StyledLatexButtonWrapper = styled(Button)(({ category }) => ({
|
|
224
|
+
minWidth: 'auto',
|
|
225
|
+
borderRadius: 0,
|
|
226
|
+
backgroundColor:
|
|
227
|
+
category === 'operators'
|
|
228
|
+
? lighten(pink[300], 0.5)
|
|
229
|
+
: // category === 'comparison' ? lighten(green[500], 0.5) :
|
|
230
|
+
lighten(indigo[300], 0.5),
|
|
231
|
+
'&:hover': {
|
|
232
|
+
backgroundColor:
|
|
233
|
+
category === 'operators'
|
|
234
|
+
? lighten(pink[300], 0.7)
|
|
235
|
+
: // category === 'comparison' ? lighten(green[500], 0.7) :
|
|
236
|
+
lighten(indigo[300], 0.7),
|
|
237
|
+
},
|
|
238
|
+
}));
|
|
239
|
+
|
|
240
|
+
const StyledIconButton = styled(IconButton)(({ category }) => ({
|
|
241
|
+
minWidth: 'auto',
|
|
242
|
+
backgroundColor:
|
|
243
|
+
category === 'operators'
|
|
244
|
+
? lighten(pink[300], 0.5)
|
|
245
|
+
: // category === 'comparison' ? lighten(green[500], 0.5) :
|
|
246
|
+
lighten(indigo[300], 0.5),
|
|
247
|
+
'&:hover': {
|
|
248
|
+
backgroundColor:
|
|
249
|
+
category === 'operators'
|
|
250
|
+
? lighten(pink[300], 0.7)
|
|
251
|
+
: // category === 'comparison' ? lighten(green[500], 0.7) :
|
|
252
|
+
lighten(indigo[300], 0.7),
|
|
253
|
+
},
|
|
254
|
+
borderRadius: 0,
|
|
255
|
+
'& .icon': {
|
|
256
|
+
height: '30px',
|
|
257
|
+
},
|
|
258
|
+
}));
|
|
259
|
+
|
|
192
260
|
export class KeyPad extends React.Component {
|
|
193
261
|
static propTypes = {
|
|
194
|
-
classes: PropTypes.object.isRequired,
|
|
195
262
|
className: PropTypes.string,
|
|
196
263
|
controlledKeypadMode: PropTypes.bool,
|
|
197
264
|
baseSet: PropTypes.array,
|
|
@@ -289,14 +356,14 @@ export class KeyPad extends React.Component {
|
|
|
289
356
|
};
|
|
290
357
|
|
|
291
358
|
render() {
|
|
292
|
-
const {
|
|
359
|
+
const { className, baseSet, additionalKeys, layoutForKeyPad, onFocus, mode } = this.props;
|
|
293
360
|
|
|
294
361
|
const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring', 'language'];
|
|
295
362
|
|
|
296
363
|
const keysWithoutBaseSet = noBaseSet.includes(mode);
|
|
297
364
|
const allKeys = keysWithoutBaseSet
|
|
298
365
|
? this.flowKeys([], additionalKeys || [])
|
|
299
|
-
: this.flowKeys(baseSet, additionalKeys || []);
|
|
366
|
+
: this.flowKeys(baseSet, additionalKeys || []);
|
|
300
367
|
|
|
301
368
|
const shift = allKeys.length % 5 ? 1 : 0;
|
|
302
369
|
const style = {
|
|
@@ -305,9 +372,9 @@ export class KeyPad extends React.Component {
|
|
|
305
372
|
};
|
|
306
373
|
|
|
307
374
|
return (
|
|
308
|
-
<
|
|
375
|
+
<KeyPadContainer
|
|
309
376
|
ref={this.keypadRef}
|
|
310
|
-
className={
|
|
377
|
+
className={[className, mode].filter(Boolean).join(' ')}
|
|
311
378
|
style={style}
|
|
312
379
|
onFocus={onFocus}
|
|
313
380
|
>
|
|
@@ -320,13 +387,6 @@ export class KeyPad extends React.Component {
|
|
|
320
387
|
|
|
321
388
|
const common = {
|
|
322
389
|
onClick,
|
|
323
|
-
className: classNames(
|
|
324
|
-
classes.labelButton,
|
|
325
|
-
!keysWithoutBaseSet && classes[k.category],
|
|
326
|
-
classes[k.extraClass],
|
|
327
|
-
k.label === ',' && classes.comma,
|
|
328
|
-
k.label === '.' && classes.dot,
|
|
329
|
-
),
|
|
330
390
|
disabled: this.keyIsNotAllowed(k),
|
|
331
391
|
key: `${k.label || k.latex || k.command}-${index}`,
|
|
332
392
|
...(k.actions || {}),
|
|
@@ -335,116 +395,59 @@ export class KeyPad extends React.Component {
|
|
|
335
395
|
|
|
336
396
|
if (k.latex) {
|
|
337
397
|
return (
|
|
338
|
-
<
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
{
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
398
|
+
<StyledLatexButtonWrapper
|
|
399
|
+
key={common.key}
|
|
400
|
+
onClick={common.onClick}
|
|
401
|
+
disabled={common.disabled}
|
|
402
|
+
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
403
|
+
aria-label={k.ariaLabel ? k.ariaLabel : k.name || k.label}
|
|
404
|
+
{...(k.actions || {})}
|
|
405
|
+
{...(k.extraProps || {})}
|
|
406
|
+
>
|
|
407
|
+
<LatexButtonContent latex={k.latex} />
|
|
408
|
+
</StyledLatexButtonWrapper>
|
|
345
409
|
);
|
|
346
410
|
}
|
|
347
411
|
|
|
348
412
|
if (k.label) {
|
|
349
413
|
return (
|
|
350
|
-
<
|
|
351
|
-
key={
|
|
352
|
-
{
|
|
353
|
-
|
|
414
|
+
<StyledButton
|
|
415
|
+
key={common.key}
|
|
416
|
+
onClick={common.onClick}
|
|
417
|
+
disabled={common.disabled}
|
|
418
|
+
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
419
|
+
isDelete={k.label === '⌫'}
|
|
420
|
+
isComma={k.label === ','}
|
|
421
|
+
isDot={k.label === '.'}
|
|
354
422
|
aria-label={k.ariaLabel ? k.ariaLabel : k.name || k.label}
|
|
423
|
+
{...(k.actions || {})}
|
|
424
|
+
{...(k.extraProps || {})}
|
|
355
425
|
>
|
|
356
426
|
{k.label}
|
|
357
|
-
</
|
|
427
|
+
</StyledButton>
|
|
358
428
|
);
|
|
359
429
|
} else {
|
|
360
430
|
const Icon = k.icon ? k.icon : 'div';
|
|
361
431
|
|
|
362
432
|
return (
|
|
363
|
-
<
|
|
364
|
-
|
|
365
|
-
|
|
433
|
+
<StyledIconButton
|
|
434
|
+
key={common.key}
|
|
435
|
+
tabIndex={'-1'}
|
|
436
|
+
onClick={common.onClick}
|
|
437
|
+
disabled={common.disabled}
|
|
438
|
+
category={!keysWithoutBaseSet ? k.category : undefined}
|
|
439
|
+
size="large"
|
|
440
|
+
{...(k.actions || {})}
|
|
441
|
+
{...(k.extraProps || {})}
|
|
442
|
+
>
|
|
443
|
+
<Icon className="icon" />
|
|
444
|
+
</StyledIconButton>
|
|
366
445
|
);
|
|
367
446
|
}
|
|
368
447
|
})}
|
|
369
|
-
</
|
|
448
|
+
</KeyPadContainer>
|
|
370
449
|
);
|
|
371
450
|
}
|
|
372
451
|
}
|
|
373
452
|
|
|
374
|
-
|
|
375
|
-
keys: {
|
|
376
|
-
...commonMqKeyboardStyles,
|
|
377
|
-
width: '100%',
|
|
378
|
-
display: 'grid',
|
|
379
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
|
|
380
|
-
gridRowGap: '0px',
|
|
381
|
-
gridColumnGap: '0px',
|
|
382
|
-
gridAutoFlow: 'column',
|
|
383
|
-
},
|
|
384
|
-
character: {
|
|
385
|
-
textTransform: 'initial !important',
|
|
386
|
-
gridTemplateRows: 'repeat(5, minmax(40px, 50px)) !important',
|
|
387
|
-
},
|
|
388
|
-
language: {
|
|
389
|
-
gridTemplateRows: 'repeat(4, minmax(40px, 50px)) !important',
|
|
390
|
-
'& *': {
|
|
391
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
holder: {
|
|
395
|
-
position: 'relative',
|
|
396
|
-
width: '100%',
|
|
397
|
-
height: '100%',
|
|
398
|
-
backgroundColor: '#cef',
|
|
399
|
-
borderRadius: 0,
|
|
400
|
-
padding: `${theme.spacing.unit}px 0 ${theme.spacing.unit}px 0`,
|
|
401
|
-
},
|
|
402
|
-
labelButton: {
|
|
403
|
-
minWidth: 'auto',
|
|
404
|
-
fontSize: '140% !important',
|
|
405
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.5),
|
|
406
|
-
'&:hover': {
|
|
407
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.7),
|
|
408
|
-
},
|
|
409
|
-
borderRadius: 0,
|
|
410
|
-
},
|
|
411
|
-
latexButton: {
|
|
412
|
-
minWidth: 'auto',
|
|
413
|
-
borderRadius: 0,
|
|
414
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.5),
|
|
415
|
-
'&:hover': {
|
|
416
|
-
backgroundColor: lighten(theme.palette.primary.light, 0.7),
|
|
417
|
-
},
|
|
418
|
-
},
|
|
419
|
-
deleteButton: {
|
|
420
|
-
'& > span': {
|
|
421
|
-
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
422
|
-
},
|
|
423
|
-
},
|
|
424
|
-
base: {},
|
|
425
|
-
operators: {
|
|
426
|
-
backgroundColor: lighten(theme.palette.secondary.light, 0.5),
|
|
427
|
-
'&:hover': {
|
|
428
|
-
backgroundColor: lighten(theme.palette.secondary.light, 0.7),
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
comparison: {
|
|
432
|
-
backgroundColor: lighten(green[500], 0.5),
|
|
433
|
-
'&:hover': {
|
|
434
|
-
backgroundColor: lighten(green[500], 0.7),
|
|
435
|
-
},
|
|
436
|
-
},
|
|
437
|
-
comma: {
|
|
438
|
-
fontSize: '200% !important',
|
|
439
|
-
lineHeight: '100%',
|
|
440
|
-
},
|
|
441
|
-
dot: {
|
|
442
|
-
fontSize: '200% !important',
|
|
443
|
-
lineHeight: '100%',
|
|
444
|
-
},
|
|
445
|
-
icon: {
|
|
446
|
-
height: '30px',
|
|
447
|
-
},
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
export default withStyles(styles)(KeyPad);
|
|
453
|
+
export default KeyPad;
|
package/src/math-input.jsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
-
import classNames from 'classnames';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
5
4
|
import * as mq from './mq';
|
|
6
5
|
import { baseSet } from './keys';
|
|
7
6
|
import KeyPad from './keypad';
|
|
@@ -9,9 +8,35 @@ import debug from 'debug';
|
|
|
9
8
|
|
|
10
9
|
const log = debug('pie-lib:math-input');
|
|
11
10
|
|
|
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
|
+
|
|
12
38
|
export class MathInput extends React.Component {
|
|
13
39
|
static propTypes = {
|
|
14
|
-
classes: PropTypes.object.isRequired,
|
|
15
40
|
className: PropTypes.string,
|
|
16
41
|
keyset: PropTypes.array,
|
|
17
42
|
displayMode: PropTypes.oneOf(['block', 'block-on-focus']),
|
|
@@ -67,15 +92,14 @@ export class MathInput extends React.Component {
|
|
|
67
92
|
};
|
|
68
93
|
|
|
69
94
|
render() {
|
|
70
|
-
const {
|
|
95
|
+
const { className, keyset, latex } = this.props;
|
|
71
96
|
const { focused } = this.state;
|
|
72
97
|
|
|
73
98
|
const showKeypad = true; // TODO: add support for different displayModes - displayMode === 'block' || focused;
|
|
74
99
|
|
|
75
100
|
return (
|
|
76
|
-
<
|
|
77
|
-
<
|
|
78
|
-
className={classes.mqInput}
|
|
101
|
+
<MathInputContainer className={className} focused={focused}>
|
|
102
|
+
<StyledMqInput
|
|
79
103
|
innerRef={(r) => (this.input = r)}
|
|
80
104
|
onFocus={this.inputFocus}
|
|
81
105
|
onBlur={this.inputBlur}
|
|
@@ -83,46 +107,13 @@ export class MathInput extends React.Component {
|
|
|
83
107
|
onChange={this.changeLatex}
|
|
84
108
|
/>
|
|
85
109
|
{showKeypad && (
|
|
86
|
-
<
|
|
110
|
+
<PadContainer>
|
|
87
111
|
<KeyPad baseSet={baseSet} additionalKeys={keyset} onPress={this.keypadPress} />
|
|
88
|
-
</
|
|
112
|
+
</PadContainer>
|
|
89
113
|
)}
|
|
90
|
-
</
|
|
114
|
+
</MathInputContainer>
|
|
91
115
|
);
|
|
92
116
|
}
|
|
93
117
|
}
|
|
94
118
|
|
|
95
|
-
|
|
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);
|
|
119
|
+
export default MathInput;
|