@khanacademy/math-input 1.0.0 → 2.0.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 +10 -0
- package/dist/components/compute-layout-parameters.d.ts +2 -1
- package/dist/components/compute-layout-parameters.js.flow +2 -21
- package/dist/components/echo-manager.d.ts +4 -4
- package/dist/components/echo-manager.js.flow +4 -4
- package/dist/components/expression-keypad.d.ts +1 -1
- package/dist/components/expression-keypad.js.flow +1 -1
- package/dist/components/fraction-keypad.d.ts +1 -1
- package/dist/components/fraction-keypad.js.flow +1 -1
- package/dist/components/gesture-state-machine.d.ts +7 -7
- package/dist/components/gesture-state-machine.js.flow +8 -8
- package/dist/components/icon.d.ts +2 -2
- package/dist/components/icon.js.flow +2 -2
- package/dist/components/input/cursor-contexts.d.ts +10 -9
- package/dist/components/input/cursor-contexts.js.flow +11 -16
- package/dist/components/input/math-wrapper.d.ts +3 -2
- package/dist/components/input/math-wrapper.js.flow +3 -16
- package/dist/components/keypad/index.d.ts +1 -1
- package/dist/components/keypad/index.js.flow +1 -3
- package/dist/components/keypad-button.d.ts +8 -8
- package/dist/components/keypad-button.js.flow +10 -9
- package/dist/components/keypad-container.d.ts +2 -3
- package/dist/components/keypad-container.js.flow +2 -3
- package/dist/components/keypad.d.ts +1 -1
- package/dist/components/keypad.js.flow +1 -1
- package/dist/components/multi-symbol-grid.d.ts +2 -2
- package/dist/components/multi-symbol-grid.js.flow +2 -2
- package/dist/components/node-manager.d.ts +2 -5
- package/dist/components/node-manager.js.flow +2 -5
- package/dist/components/popover-state-machine.d.ts +1 -8
- package/dist/components/popover-state-machine.js.flow +2 -8
- package/dist/components/provided-keypad.d.ts +1 -4
- package/dist/components/provided-keypad.js.flow +1 -4
- package/dist/components/styles.d.ts +1 -2
- package/dist/components/styles.js.flow +1 -3
- package/dist/components/touchable-keypad-button.d.ts +6 -6
- package/dist/components/touchable-keypad-button.js.flow +6 -6
- package/dist/data/keys.d.ts +51 -52
- package/dist/data/keys.js.flow +50 -99
- package/dist/enums.d.ts +49 -0
- package/dist/enums.js.flow +63 -0
- package/dist/es/index.css +0 -3
- package/dist/es/index.js +415 -455
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/view.d.ts +1 -2
- package/dist/fake-react-native-web/view.js.flow +1 -2
- package/dist/index.css +0 -3
- package/dist/index.d.ts +3 -6
- package/dist/index.js +438 -477
- package/dist/index.js.flow +3 -6
- package/dist/index.js.map +1 -1
- package/dist/store/actions.d.ts +64 -0
- package/dist/store/actions.js.flow +101 -0
- package/dist/store/echo-reducer.d.ts +2 -3
- package/dist/store/echo-reducer.js.flow +2 -6
- package/dist/store/index.d.ts +5 -41
- package/dist/store/index.js.flow +5 -52
- package/dist/store/input-reducer.d.ts +2 -5
- package/dist/store/input-reducer.js.flow +3 -6
- package/dist/store/keypad-reducer.d.ts +2 -7
- package/dist/store/keypad-reducer.js.flow +3 -8
- package/dist/store/layout-reducer.d.ts +2 -19
- package/dist/store/layout-reducer.js.flow +3 -20
- package/dist/store/pager-reducer.d.ts +2 -11
- package/dist/store/pager-reducer.js.flow +3 -12
- package/dist/store/shared.d.ts +2 -1
- package/dist/store/shared.js.flow +2 -1
- package/dist/store/types.d.ts +5 -5
- package/dist/store/types.js.flow +5 -5
- package/dist/types.d.ts +28 -16
- package/dist/types.js.flow +32 -20
- package/less/overrides.less +0 -6
- package/package.json +1 -1
- package/src/components/compute-layout-parameters.ts +6 -6
- package/src/components/echo-manager.tsx +10 -10
- package/src/components/expression-keypad.tsx +9 -10
- package/src/components/fraction-keypad.tsx +11 -12
- package/src/components/gesture-state-machine.ts +8 -8
- package/src/components/icon.tsx +6 -6
- package/src/components/input/__tests__/context-tracking.test.ts +20 -20
- package/src/components/input/cursor-contexts.ts +22 -29
- package/src/components/input/math-wrapper.ts +75 -67
- package/src/components/keypad/index.tsx +1 -1
- package/src/components/keypad-button.tsx +20 -21
- package/src/components/keypad-container.tsx +9 -10
- package/src/components/keypad.tsx +1 -1
- package/src/components/many-keypad-button.tsx +2 -2
- package/src/components/multi-symbol-grid.tsx +4 -5
- package/src/components/multi-symbol-popover.tsx +1 -1
- package/src/components/navigation-pad.tsx +1 -1
- package/src/components/node-manager.ts +2 -2
- package/src/components/popover-state-machine.ts +2 -10
- package/src/components/provided-keypad.tsx +3 -12
- package/src/components/touchable-keypad-button.tsx +7 -7
- package/src/data/key-configs.ts +58 -58
- package/src/data/keys.ts +53 -105
- package/src/enums.ts +74 -0
- package/src/index.ts +3 -9
- package/src/math-input.stories.tsx +67 -0
- package/src/store/actions.ts +179 -0
- package/src/store/echo-reducer.ts +10 -7
- package/src/store/index.ts +24 -24
- package/src/store/input-reducer.ts +7 -6
- package/src/store/keypad-reducer.ts +3 -6
- package/src/store/layout-reducer.ts +12 -11
- package/src/store/pager-reducer.ts +30 -46
- package/src/store/shared.ts +4 -4
- package/src/store/types.ts +21 -5
- package/src/types.ts +32 -20
- package/src/utils.ts +3 -3
- package/tsconfig-build.tsbuildinfo +1 -0
- package/dist/actions/index.d.ts +0 -31
- package/dist/actions/index.js.flow +0 -40
- package/dist/consts.d.ts +0 -51
- package/dist/consts.js.flow +0 -66
- package/src/actions/index.ts +0 -57
- package/src/consts.ts +0 -91
- package/tsconfig.tsbuildinfo +0 -1
- /package/src/components/{gesture-manager.tsx → gesture-manager.ts} +0 -0
- /package/{tsconfig.json → tsconfig-build.json} +0 -0
package/dist/index.js
CHANGED
|
@@ -22,21 +22,21 @@ var now = require('performance-now');
|
|
|
22
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
23
|
|
|
24
24
|
function _interopNamespace(e) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
if (e && e.__esModule) return e;
|
|
26
|
+
var n = Object.create(null);
|
|
27
|
+
if (e) {
|
|
28
|
+
Object.keys(e).forEach(function (k) {
|
|
29
|
+
if (k !== 'default') {
|
|
30
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return e[k]; }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
34
36
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
n["default"] = e;
|
|
39
|
-
return Object.freeze(n);
|
|
37
|
+
}
|
|
38
|
+
n["default"] = e;
|
|
39
|
+
return Object.freeze(n);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
@@ -51,6 +51,29 @@ var katex__default = /*#__PURE__*/_interopDefaultLegacy(katex);
|
|
|
51
51
|
var Clickable__default = /*#__PURE__*/_interopDefaultLegacy(Clickable);
|
|
52
52
|
var now__default = /*#__PURE__*/_interopDefaultLegacy(now);
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Enum that defines the various contexts in which a cursor can exist. The
|
|
56
|
+
* active context is determined first by looking at the cursor's siblings (e.g.,
|
|
57
|
+
* for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
|
|
58
|
+
* cursor could in theory be nested in multiple contexts, we only care about the
|
|
59
|
+
* immediate context.
|
|
60
|
+
*
|
|
61
|
+
* TODO(charlie): Add a context to represent being inside of a radical. Right
|
|
62
|
+
* now, we show the dismiss button rather than allowing the user to jump out of
|
|
63
|
+
* the radical.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
let CursorContext = /*#__PURE__*/function (CursorContext) {
|
|
67
|
+
CursorContext["NONE"] = "NONE";
|
|
68
|
+
CursorContext["IN_PARENS"] = "IN_PARENS";
|
|
69
|
+
CursorContext["IN_SUPER_SCRIPT"] = "IN_SUPER_SCRIPT";
|
|
70
|
+
CursorContext["IN_SUB_SCRIPT"] = "IN_SUB_SCRIPT";
|
|
71
|
+
CursorContext["IN_NUMERATOR"] = "IN_NUMERATOR";
|
|
72
|
+
CursorContext["IN_DENOMINATOR"] = "IN_DENOMINATOR";
|
|
73
|
+
CursorContext["BEFORE_FRACTION"] = "BEFORE_FRACTION";
|
|
74
|
+
return CursorContext;
|
|
75
|
+
}({});
|
|
76
|
+
|
|
54
77
|
function _defineProperty(obj, key, value) {
|
|
55
78
|
key = _toPropertyKey(key);
|
|
56
79
|
if (key in obj) {
|
|
@@ -98,69 +121,61 @@ function _toPropertyKey(arg) {
|
|
|
98
121
|
* This file contains constants for keypad buttons that aren't single
|
|
99
122
|
* alphanumeric characters.
|
|
100
123
|
*/
|
|
101
|
-
|
|
102
124
|
// TODO(charlie): There's duplication between this file and key-configs.js.
|
|
103
125
|
// We should clean it up by removing this file and requiring clients to use the
|
|
104
126
|
// `id` field on the key configurations.
|
|
105
|
-
|
|
106
|
-
PLUS
|
|
107
|
-
MINUS
|
|
108
|
-
NEGATIVE
|
|
109
|
-
TIMES
|
|
110
|
-
DIVIDE
|
|
111
|
-
DECIMAL
|
|
112
|
-
PERIOD
|
|
113
|
-
PERCENT
|
|
114
|
-
CDOT
|
|
115
|
-
EQUAL
|
|
116
|
-
NEQ
|
|
117
|
-
GT
|
|
118
|
-
LT
|
|
119
|
-
GEQ
|
|
120
|
-
LEQ
|
|
121
|
-
FRAC_INCLUSIVE
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
FRAC_MULTI: "FRAC_MULTI",
|
|
158
|
-
// mobile native only
|
|
159
|
-
|
|
160
|
-
// A custom key that captures an arbitrary number of symbols but has no
|
|
161
|
-
// 'default' symbol or action.
|
|
162
|
-
MANY: "MANY"
|
|
163
|
-
};
|
|
127
|
+
var Keys = /*#__PURE__*/function (Keys) {
|
|
128
|
+
Keys["PLUS"] = "PLUS";
|
|
129
|
+
Keys["MINUS"] = "MINUS";
|
|
130
|
+
Keys["NEGATIVE"] = "NEGATIVE";
|
|
131
|
+
Keys["TIMES"] = "TIMES";
|
|
132
|
+
Keys["DIVIDE"] = "DIVIDE";
|
|
133
|
+
Keys["DECIMAL"] = "DECIMAL";
|
|
134
|
+
Keys["PERIOD"] = "PERIOD";
|
|
135
|
+
Keys["PERCENT"] = "PERCENT";
|
|
136
|
+
Keys["CDOT"] = "CDOT";
|
|
137
|
+
Keys["EQUAL"] = "EQUAL";
|
|
138
|
+
Keys["NEQ"] = "NEQ";
|
|
139
|
+
Keys["GT"] = "GT";
|
|
140
|
+
Keys["LT"] = "LT";
|
|
141
|
+
Keys["GEQ"] = "GEQ";
|
|
142
|
+
Keys["LEQ"] = "LEQ";
|
|
143
|
+
Keys["FRAC_INCLUSIVE"] = "FRAC_INCLUSIVE";
|
|
144
|
+
Keys["FRAC_EXCLUSIVE"] = "FRAC_EXCLUSIVE";
|
|
145
|
+
Keys["FRAC"] = "FRAC";
|
|
146
|
+
Keys["EXP"] = "EXP";
|
|
147
|
+
Keys["EXP_2"] = "EXP_2";
|
|
148
|
+
Keys["EXP_3"] = "EXP_3";
|
|
149
|
+
Keys["SQRT"] = "SQRT";
|
|
150
|
+
Keys["CUBE_ROOT"] = "CUBE_ROOT";
|
|
151
|
+
Keys["RADICAL"] = "RADICAL";
|
|
152
|
+
Keys["LEFT_PAREN"] = "LEFT_PAREN";
|
|
153
|
+
Keys["RIGHT_PAREN"] = "RIGHT_PAREN";
|
|
154
|
+
Keys["LN"] = "LN";
|
|
155
|
+
Keys["LOG"] = "LOG";
|
|
156
|
+
Keys["LOG_N"] = "LOG_N";
|
|
157
|
+
Keys["SIN"] = "SIN";
|
|
158
|
+
Keys["COS"] = "COS";
|
|
159
|
+
Keys["TAN"] = "TAN";
|
|
160
|
+
Keys["PI"] = "PI";
|
|
161
|
+
Keys["THETA"] = "THETA";
|
|
162
|
+
Keys["UP"] = "UP";
|
|
163
|
+
Keys["RIGHT"] = "RIGHT";
|
|
164
|
+
Keys["DOWN"] = "DOWN";
|
|
165
|
+
Keys["LEFT"] = "LEFT";
|
|
166
|
+
Keys["BACKSPACE"] = "BACKSPACE";
|
|
167
|
+
Keys["DISMISS"] = "DISMISS";
|
|
168
|
+
Keys["JUMP_OUT_PARENTHESES"] = "JUMP_OUT_PARENTHESES";
|
|
169
|
+
Keys["JUMP_OUT_EXPONENT"] = "JUMP_OUT_EXPONENT";
|
|
170
|
+
Keys["JUMP_OUT_BASE"] = "JUMP_OUT_BASE";
|
|
171
|
+
Keys["JUMP_INTO_NUMERATOR"] = "JUMP_INTO_NUMERATOR";
|
|
172
|
+
Keys["JUMP_OUT_NUMERATOR"] = "JUMP_OUT_NUMERATOR";
|
|
173
|
+
Keys["JUMP_OUT_DENOMINATOR"] = "JUMP_OUT_DENOMINATOR";
|
|
174
|
+
Keys["NOOP"] = "NOOP";
|
|
175
|
+
Keys["FRAC_MULTI"] = "FRAC_MULTI";
|
|
176
|
+
Keys["MANY"] = "MANY";
|
|
177
|
+
return Keys;
|
|
178
|
+
}(Keys || {});
|
|
164
179
|
|
|
165
180
|
class Text extends React__namespace.Component {
|
|
166
181
|
render() {
|
|
@@ -451,66 +466,64 @@ class DragListener {
|
|
|
451
466
|
* Constants that are shared between multiple files.
|
|
452
467
|
*/
|
|
453
468
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
EMPTY
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
};
|
|
490
|
-
const BorderDirections = {
|
|
491
|
-
LEFT: "LEFT",
|
|
492
|
-
BOTTOM: "BOTTOM"
|
|
493
|
-
};
|
|
469
|
+
let KeypadType = /*#__PURE__*/function (KeypadType) {
|
|
470
|
+
KeypadType["FRACTION"] = "FRACTION";
|
|
471
|
+
KeypadType["EXPRESSION"] = "EXPRESSION";
|
|
472
|
+
return KeypadType;
|
|
473
|
+
}({});
|
|
474
|
+
let KeyType = /*#__PURE__*/function (KeyType) {
|
|
475
|
+
KeyType["EMPTY"] = "EMPTY";
|
|
476
|
+
KeyType["VALUE"] = "VALUE";
|
|
477
|
+
KeyType["OPERATOR"] = "OPERATOR";
|
|
478
|
+
KeyType["INPUT_NAVIGATION"] = "INPUT_NAVIGATION";
|
|
479
|
+
KeyType["KEYPAD_NAVIGATION"] = "KEYPAD_NAVIGATION";
|
|
480
|
+
KeyType["MANY"] = "MANY";
|
|
481
|
+
KeyType["ECHO"] = "ECHO";
|
|
482
|
+
return KeyType;
|
|
483
|
+
}({});
|
|
484
|
+
let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
|
|
485
|
+
DeviceOrientation["LANDSCAPE"] = "LANDSCAPE";
|
|
486
|
+
DeviceOrientation["PORTRAIT"] = "PORTRAIT";
|
|
487
|
+
return DeviceOrientation;
|
|
488
|
+
}({});
|
|
489
|
+
let DeviceType = /*#__PURE__*/function (DeviceType) {
|
|
490
|
+
DeviceType["PHONE"] = "PHONE";
|
|
491
|
+
DeviceType["TABLET"] = "TABLET";
|
|
492
|
+
return DeviceType;
|
|
493
|
+
}({});
|
|
494
|
+
let LayoutMode = /*#__PURE__*/function (LayoutMode) {
|
|
495
|
+
LayoutMode["FULLSCREEN"] = "FULLSCREEN";
|
|
496
|
+
LayoutMode["COMPACT"] = "COMPACT";
|
|
497
|
+
return LayoutMode;
|
|
498
|
+
}({});
|
|
499
|
+
let BorderDirection = /*#__PURE__*/function (BorderDirection) {
|
|
500
|
+
BorderDirection["LEFT"] = "LEFT";
|
|
501
|
+
BorderDirection["BOTTOM"] = "BOTTOM";
|
|
502
|
+
return BorderDirection;
|
|
503
|
+
}({});
|
|
494
504
|
const BorderStyles = {
|
|
495
|
-
LEFT: [
|
|
496
|
-
BOTTOM: [
|
|
497
|
-
ALL: [
|
|
505
|
+
LEFT: [BorderDirection.LEFT],
|
|
506
|
+
BOTTOM: [BorderDirection.BOTTOM],
|
|
507
|
+
ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
|
|
498
508
|
NONE: []
|
|
499
509
|
};
|
|
500
|
-
|
|
501
|
-
MATH
|
|
502
|
-
SVG
|
|
503
|
-
TEXT
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
510
|
+
let IconType = /*#__PURE__*/function (IconType) {
|
|
511
|
+
IconType["MATH"] = "MATH";
|
|
512
|
+
IconType["SVG"] = "SVG";
|
|
513
|
+
IconType["TEXT"] = "TEXT";
|
|
514
|
+
return IconType;
|
|
515
|
+
}({});
|
|
516
|
+
let DecimalSeparator = /*#__PURE__*/function (DecimalSeparator) {
|
|
517
|
+
DecimalSeparator["COMMA"] = "COMMA";
|
|
518
|
+
DecimalSeparator["PERIOD"] = "PERIOD";
|
|
519
|
+
return DecimalSeparator;
|
|
520
|
+
}({});
|
|
521
|
+
let EchoAnimationType = /*#__PURE__*/function (EchoAnimationType) {
|
|
522
|
+
EchoAnimationType["SLIDE_AND_FADE"] = "SLIDE_AND_FADE";
|
|
523
|
+
EchoAnimationType["FADE_ONLY"] = "FADE_ONLY";
|
|
524
|
+
EchoAnimationType["LONG_FADE_ONLY"] = "LONG_FADE_ONLY";
|
|
525
|
+
return EchoAnimationType;
|
|
526
|
+
}({});
|
|
514
527
|
|
|
515
528
|
// NOTES(kevinb):
|
|
516
529
|
// - In order to get the correct decimal separator for the current locale,
|
|
@@ -518,158 +531,116 @@ const EchoAnimationTypes = {
|
|
|
518
531
|
// imported from wonder-blocks-i18n.
|
|
519
532
|
// - Some languages/locales use different decimal separators than the ones
|
|
520
533
|
// listed here. Much of the Arab world uses U+066C.
|
|
521
|
-
const decimalSeparator = i18n.getDecimalSeparator() === "," ?
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Constants that define the various contexts in which a cursor can exist. The
|
|
525
|
-
* active context is determined first by looking at the cursor's siblings (e.g.,
|
|
526
|
-
* for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
|
|
527
|
-
* cursor could in theory be nested in multiple contexts, we only care about the
|
|
528
|
-
* immediate context.
|
|
529
|
-
*
|
|
530
|
-
* TODO(charlie): Add a context to represent being inside of a radical. Right
|
|
531
|
-
* now, we show the dismiss button rather than allowing the user to jump out of
|
|
532
|
-
* the radical.
|
|
533
|
-
*/
|
|
534
|
-
|
|
535
|
-
// TODO: Get rid of these constants in favour of CursorContext type.
|
|
536
|
-
|
|
537
|
-
// The cursor is not in any of the other viable contexts.
|
|
538
|
-
const NONE = "NONE";
|
|
539
|
-
// The cursor is within a set of parentheses.
|
|
540
|
-
const IN_PARENS = "IN_PARENS";
|
|
541
|
-
// The cursor is within a superscript (e.g., an exponent).
|
|
542
|
-
const IN_SUPER_SCRIPT = "IN_SUPER_SCRIPT";
|
|
543
|
-
// The cursor is within a subscript (e.g., the base of a custom logarithm).
|
|
544
|
-
const IN_SUB_SCRIPT = "IN_SUB_SCRIPT";
|
|
545
|
-
// The cursor is in the numerator of a fraction.
|
|
546
|
-
const IN_NUMERATOR = "IN_NUMERATOR";
|
|
547
|
-
// The cursor is in the denominator of a fraction.
|
|
548
|
-
const IN_DENOMINATOR = "IN_DENOMINATOR";
|
|
549
|
-
// The cursor is sitting before a fraction; that is, the cursor is within
|
|
550
|
-
// what looks to be a mixed number preceding a fraction. This will only be
|
|
551
|
-
// the case when the only math between the cursor and the fraction to its
|
|
552
|
-
// write is non-leaf math (numbers and variables).
|
|
553
|
-
const BEFORE_FRACTION = "BEFORE_FRACTION";
|
|
554
|
-
|
|
555
|
-
var cursorContexts = /*#__PURE__*/Object.freeze({
|
|
556
|
-
__proto__: null,
|
|
557
|
-
NONE: NONE,
|
|
558
|
-
IN_PARENS: IN_PARENS,
|
|
559
|
-
IN_SUPER_SCRIPT: IN_SUPER_SCRIPT,
|
|
560
|
-
IN_SUB_SCRIPT: IN_SUB_SCRIPT,
|
|
561
|
-
IN_NUMERATOR: IN_NUMERATOR,
|
|
562
|
-
IN_DENOMINATOR: IN_DENOMINATOR,
|
|
563
|
-
BEFORE_FRACTION: BEFORE_FRACTION
|
|
564
|
-
});
|
|
534
|
+
const decimalSeparator = i18n.getDecimalSeparator() === "," ? DecimalSeparator.COMMA : DecimalSeparator.PERIOD;
|
|
565
535
|
|
|
566
536
|
// Keeping `window` in place for test suite and GitHub Pages.
|
|
567
537
|
// If it does not exist, fall back to CommonJS require. - jsatk
|
|
568
538
|
|
|
569
|
-
const decimalSymbol = decimalSeparator ===
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
539
|
+
const decimalSymbol = decimalSeparator === DecimalSeparator.COMMA ? "," : ".";
|
|
540
|
+
var ActionType = /*#__PURE__*/function (ActionType) {
|
|
541
|
+
ActionType["WRITE"] = "write";
|
|
542
|
+
ActionType["CMD"] = "cmd";
|
|
543
|
+
ActionType["KEYSTROKE"] = "keystroke";
|
|
544
|
+
ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
|
|
545
|
+
return ActionType;
|
|
546
|
+
}(ActionType || {}); // A mapping from keys that can be pressed on a keypad to the way in which
|
|
576
547
|
// MathQuill should modify its input in response to that key-press. Any keys
|
|
577
548
|
// that do not provide explicit actions (like the numeral keys) will merely
|
|
578
549
|
// write their contents to MathQuill.
|
|
579
550
|
const KeyActions = {
|
|
580
551
|
[Keys.PLUS]: {
|
|
581
552
|
str: "+",
|
|
582
|
-
fn: WRITE
|
|
553
|
+
fn: ActionType.WRITE
|
|
583
554
|
},
|
|
584
555
|
[Keys.MINUS]: {
|
|
585
556
|
str: "-",
|
|
586
|
-
fn: WRITE
|
|
557
|
+
fn: ActionType.WRITE
|
|
587
558
|
},
|
|
588
559
|
[Keys.NEGATIVE]: {
|
|
589
560
|
str: "-",
|
|
590
|
-
fn: WRITE
|
|
561
|
+
fn: ActionType.WRITE
|
|
591
562
|
},
|
|
592
563
|
[Keys.TIMES]: {
|
|
593
564
|
str: "\\times",
|
|
594
|
-
fn: WRITE
|
|
565
|
+
fn: ActionType.WRITE
|
|
595
566
|
},
|
|
596
567
|
[Keys.DIVIDE]: {
|
|
597
568
|
str: "\\div",
|
|
598
|
-
fn: WRITE
|
|
569
|
+
fn: ActionType.WRITE
|
|
599
570
|
},
|
|
600
571
|
[Keys.DECIMAL]: {
|
|
601
572
|
str: decimalSymbol,
|
|
602
|
-
fn: WRITE
|
|
573
|
+
fn: ActionType.WRITE
|
|
603
574
|
},
|
|
604
575
|
[Keys.EQUAL]: {
|
|
605
576
|
str: "=",
|
|
606
|
-
fn: WRITE
|
|
577
|
+
fn: ActionType.WRITE
|
|
607
578
|
},
|
|
608
579
|
[Keys.NEQ]: {
|
|
609
580
|
str: "\\neq",
|
|
610
|
-
fn: WRITE
|
|
581
|
+
fn: ActionType.WRITE
|
|
611
582
|
},
|
|
612
583
|
[Keys.CDOT]: {
|
|
613
584
|
str: "\\cdot",
|
|
614
|
-
fn: WRITE
|
|
585
|
+
fn: ActionType.WRITE
|
|
615
586
|
},
|
|
616
587
|
[Keys.PERCENT]: {
|
|
617
588
|
str: "%",
|
|
618
|
-
fn: WRITE
|
|
589
|
+
fn: ActionType.WRITE
|
|
619
590
|
},
|
|
620
591
|
[Keys.LEFT_PAREN]: {
|
|
621
592
|
str: "(",
|
|
622
|
-
fn: CMD
|
|
593
|
+
fn: ActionType.CMD
|
|
623
594
|
},
|
|
624
595
|
[Keys.RIGHT_PAREN]: {
|
|
625
596
|
str: ")",
|
|
626
|
-
fn: CMD
|
|
597
|
+
fn: ActionType.CMD
|
|
627
598
|
},
|
|
628
599
|
[Keys.SQRT]: {
|
|
629
600
|
str: "sqrt",
|
|
630
|
-
fn: CMD
|
|
601
|
+
fn: ActionType.CMD
|
|
631
602
|
},
|
|
632
603
|
[Keys.PI]: {
|
|
633
604
|
str: "pi",
|
|
634
|
-
fn: CMD
|
|
605
|
+
fn: ActionType.CMD
|
|
635
606
|
},
|
|
636
607
|
[Keys.THETA]: {
|
|
637
608
|
str: "theta",
|
|
638
|
-
fn: CMD
|
|
609
|
+
fn: ActionType.CMD
|
|
639
610
|
},
|
|
640
611
|
[Keys.RADICAL]: {
|
|
641
612
|
str: "nthroot",
|
|
642
|
-
fn: CMD
|
|
613
|
+
fn: ActionType.CMD
|
|
643
614
|
},
|
|
644
615
|
[Keys.LT]: {
|
|
645
616
|
str: "<",
|
|
646
|
-
fn: WRITE
|
|
617
|
+
fn: ActionType.WRITE
|
|
647
618
|
},
|
|
648
619
|
[Keys.LEQ]: {
|
|
649
620
|
str: "\\leq",
|
|
650
|
-
fn: WRITE
|
|
621
|
+
fn: ActionType.WRITE
|
|
651
622
|
},
|
|
652
623
|
[Keys.GT]: {
|
|
653
624
|
str: ">",
|
|
654
|
-
fn: WRITE
|
|
625
|
+
fn: ActionType.WRITE
|
|
655
626
|
},
|
|
656
627
|
[Keys.GEQ]: {
|
|
657
628
|
str: "\\geq",
|
|
658
|
-
fn: WRITE
|
|
629
|
+
fn: ActionType.WRITE
|
|
659
630
|
},
|
|
660
631
|
[Keys.UP]: {
|
|
661
632
|
str: "Up",
|
|
662
|
-
fn: KEYSTROKE
|
|
633
|
+
fn: ActionType.KEYSTROKE
|
|
663
634
|
},
|
|
664
635
|
[Keys.DOWN]: {
|
|
665
636
|
str: "Down",
|
|
666
|
-
fn: KEYSTROKE
|
|
637
|
+
fn: ActionType.KEYSTROKE
|
|
667
638
|
},
|
|
668
639
|
// The `FRAC_EXCLUSIVE` variant is handled manually, since we may need to do
|
|
669
640
|
// some additional navigation depending on the cursor position.
|
|
670
641
|
[Keys.FRAC_INCLUSIVE]: {
|
|
671
642
|
str: "/",
|
|
672
|
-
fn: CMD
|
|
643
|
+
fn: ActionType.CMD
|
|
673
644
|
}
|
|
674
645
|
};
|
|
675
646
|
const NormalCommands = {
|
|
@@ -689,12 +660,12 @@ const Letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"
|
|
|
689
660
|
// leaf nodes.
|
|
690
661
|
const ValidLeaves = [...Numerals, ...GreekLetters, ...Letters.map(letter => letter.toLowerCase()), ...Letters.map(letter => letter.toUpperCase())];
|
|
691
662
|
const KeysForJumpContext = {
|
|
692
|
-
[IN_PARENS]: Keys.JUMP_OUT_PARENTHESES,
|
|
693
|
-
[IN_SUPER_SCRIPT]: Keys.JUMP_OUT_EXPONENT,
|
|
694
|
-
[IN_SUB_SCRIPT]: Keys.JUMP_OUT_BASE,
|
|
695
|
-
[BEFORE_FRACTION]: Keys.JUMP_INTO_NUMERATOR,
|
|
696
|
-
[IN_NUMERATOR]: Keys.JUMP_OUT_NUMERATOR,
|
|
697
|
-
[IN_DENOMINATOR]: Keys.JUMP_OUT_DENOMINATOR
|
|
663
|
+
[CursorContext.IN_PARENS]: Keys.JUMP_OUT_PARENTHESES,
|
|
664
|
+
[CursorContext.IN_SUPER_SCRIPT]: Keys.JUMP_OUT_EXPONENT,
|
|
665
|
+
[CursorContext.IN_SUB_SCRIPT]: Keys.JUMP_OUT_BASE,
|
|
666
|
+
[CursorContext.BEFORE_FRACTION]: Keys.JUMP_INTO_NUMERATOR,
|
|
667
|
+
[CursorContext.IN_NUMERATOR]: Keys.JUMP_OUT_NUMERATOR,
|
|
668
|
+
[CursorContext.IN_DENOMINATOR]: Keys.JUMP_OUT_DENOMINATOR
|
|
698
669
|
};
|
|
699
670
|
class MathWrapper {
|
|
700
671
|
// MathQuill interface
|
|
@@ -758,14 +729,14 @@ class MathWrapper {
|
|
|
758
729
|
} else if (key === Keys.FRAC_EXCLUSIVE) {
|
|
759
730
|
// If there's nothing to the left of the cursor, then we want to
|
|
760
731
|
// leave the cursor to the left of the fraction after creating it.
|
|
761
|
-
const shouldNavigateLeft = cursor[this.MQ.L] === MQ_END;
|
|
732
|
+
const shouldNavigateLeft = cursor[this.MQ.L] === ActionType.MQ_END;
|
|
762
733
|
this.mathField.cmd("\\frac");
|
|
763
734
|
if (shouldNavigateLeft) {
|
|
764
735
|
this.mathField.keystroke("Left");
|
|
765
736
|
}
|
|
766
737
|
} else if (key === Keys.FRAC) {
|
|
767
738
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
768
|
-
cursor[this.MQ.L] === MQ_END;
|
|
739
|
+
cursor[this.MQ.L] === ActionType.MQ_END;
|
|
769
740
|
this.mathField.cmd("\\frac");
|
|
770
741
|
} else if (key === Keys.LOG_N) {
|
|
771
742
|
this.mathField.write("log_{ }\\left(\\right)");
|
|
@@ -786,9 +757,9 @@ class MathWrapper {
|
|
|
786
757
|
} else if (key === Keys.RIGHT) {
|
|
787
758
|
this._handleRightArrow(cursor);
|
|
788
759
|
} else if (/^[a-zA-Z]$/.test(key)) {
|
|
789
|
-
this.mathField[WRITE](key);
|
|
760
|
+
this.mathField[ActionType.WRITE](key);
|
|
790
761
|
} else if (/^NUM_\d/.test(key)) {
|
|
791
|
-
this.mathField[WRITE](key[4]);
|
|
762
|
+
this.mathField[ActionType.WRITE](key[4]);
|
|
792
763
|
}
|
|
793
764
|
if (!cursor.selection) {
|
|
794
765
|
// don't show the cursor for selections
|
|
@@ -882,7 +853,7 @@ class MathWrapper {
|
|
|
882
853
|
// when upgrading MathQuill.
|
|
883
854
|
|
|
884
855
|
_handleBackspaceInNthRoot(cursor) {
|
|
885
|
-
const isAtLeftEnd = cursor[this.MQ.L] === MQ_END;
|
|
856
|
+
const isAtLeftEnd = cursor[this.MQ.L] === ActionType.MQ_END;
|
|
886
857
|
const isRootEmpty = this._isInsideEmptyNode(cursor.parent.parent.blocks[0].ends);
|
|
887
858
|
if (isAtLeftEnd) {
|
|
888
859
|
this._selectNode(cursor.parent.parent, cursor);
|
|
@@ -913,16 +884,16 @@ class MathWrapper {
|
|
|
913
884
|
return;
|
|
914
885
|
}
|
|
915
886
|
switch (context) {
|
|
916
|
-
case IN_PARENS:
|
|
887
|
+
case CursorContext.IN_PARENS:
|
|
917
888
|
// Insert at the end of the parentheses, and then navigate right
|
|
918
889
|
// once more to get 'beyond' the parentheses.
|
|
919
890
|
cursor.insRightOf(cursor.parent.parent);
|
|
920
891
|
break;
|
|
921
|
-
case BEFORE_FRACTION:
|
|
892
|
+
case CursorContext.BEFORE_FRACTION:
|
|
922
893
|
// Find the nearest fraction to the right of the cursor.
|
|
923
894
|
let fractionNode;
|
|
924
895
|
let visitor = cursor;
|
|
925
|
-
while (visitor[this.MQ.R] !== MQ_END) {
|
|
896
|
+
while (visitor[this.MQ.R] !== ActionType.MQ_END) {
|
|
926
897
|
if (this._isFraction(visitor[this.MQ.R])) {
|
|
927
898
|
fractionNode = visitor[this.MQ.R];
|
|
928
899
|
}
|
|
@@ -933,7 +904,7 @@ class MathWrapper {
|
|
|
933
904
|
cursor.insLeftOf(fractionNode);
|
|
934
905
|
this.mathField.keystroke("Right");
|
|
935
906
|
break;
|
|
936
|
-
case IN_NUMERATOR:
|
|
907
|
+
case CursorContext.IN_NUMERATOR:
|
|
937
908
|
// HACK(charlie): I can't find a better way to do this. The goal
|
|
938
909
|
// is to place the cursor at the start of the matching
|
|
939
910
|
// denominator. So, we identify the appropriate node, and
|
|
@@ -945,10 +916,10 @@ class MathWrapper {
|
|
|
945
916
|
this.mathField.keystroke("Right");
|
|
946
917
|
}
|
|
947
918
|
break;
|
|
948
|
-
case IN_DENOMINATOR:
|
|
919
|
+
case CursorContext.IN_DENOMINATOR:
|
|
949
920
|
cursor.insRightOf(cursor.parent.parent);
|
|
950
921
|
break;
|
|
951
|
-
case IN_SUB_SCRIPT:
|
|
922
|
+
case CursorContext.IN_SUB_SCRIPT:
|
|
952
923
|
// Insert just beyond the superscript.
|
|
953
924
|
cursor.insRightOf(cursor.parent.parent);
|
|
954
925
|
|
|
@@ -959,7 +930,7 @@ class MathWrapper {
|
|
|
959
930
|
this.mathField.keystroke("Right");
|
|
960
931
|
}
|
|
961
932
|
break;
|
|
962
|
-
case IN_SUPER_SCRIPT:
|
|
933
|
+
case CursorContext.IN_SUPER_SCRIPT:
|
|
963
934
|
// Insert just beyond the superscript.
|
|
964
935
|
cursor.insRightOf(cursor.parent.parent);
|
|
965
936
|
break;
|
|
@@ -996,7 +967,7 @@ class MathWrapper {
|
|
|
996
967
|
this._handleBackspaceInLogIndex(cursor);
|
|
997
968
|
} else if (leftNode.ctrlSeq === "\\ge " || leftNode.ctrlSeq === "\\le ") {
|
|
998
969
|
this._handleBackspaceAfterLigaturedSymbol(cursor);
|
|
999
|
-
} else if (this._isNthRoot(grandparent) && leftNode === MQ_END) {
|
|
970
|
+
} else if (this._isNthRoot(grandparent) && leftNode === ActionType.MQ_END) {
|
|
1000
971
|
this._handleBackspaceInNthRoot(cursor);
|
|
1001
972
|
} else {
|
|
1002
973
|
this.mathField.keystroke("Backspace");
|
|
@@ -1013,10 +984,10 @@ class MathWrapper {
|
|
|
1013
984
|
// the entire expression, rather than between the `s` and the left
|
|
1014
985
|
// parenthesis.
|
|
1015
986
|
// From the cursor's perspective, this requires that our left node is
|
|
1016
|
-
// the MQ_END node, that our grandparent is the left parenthesis, and
|
|
987
|
+
// the ActionType.MQ_END node, that our grandparent is the left parenthesis, and
|
|
1017
988
|
// the nodes to the left of our grandparent comprise a valid function
|
|
1018
989
|
// name.
|
|
1019
|
-
if (cursor[this.MQ.L] === MQ_END) {
|
|
990
|
+
if (cursor[this.MQ.L] === ActionType.MQ_END) {
|
|
1020
991
|
const parent = cursor.parent;
|
|
1021
992
|
const grandparent = parent.parent;
|
|
1022
993
|
if (grandparent.ctrlSeq === "\\left(") {
|
|
@@ -1051,7 +1022,7 @@ class MathWrapper {
|
|
|
1051
1022
|
// parentheses and apply the exponent to that.
|
|
1052
1023
|
const invalidPrefixes = [...ArithmeticOperators, ...EqualityOperators];
|
|
1053
1024
|
const precedingNode = cursor[this.MQ.L];
|
|
1054
|
-
const shouldPrefixWithParens = precedingNode === MQ_END || invalidPrefixes.includes(precedingNode.ctrlSeq.trim());
|
|
1025
|
+
const shouldPrefixWithParens = precedingNode === ActionType.MQ_END || invalidPrefixes.includes(precedingNode.ctrlSeq.trim());
|
|
1055
1026
|
if (shouldPrefixWithParens) {
|
|
1056
1027
|
this.mathField.write("\\left(\\right)");
|
|
1057
1028
|
}
|
|
@@ -1236,7 +1207,7 @@ class MathWrapper {
|
|
|
1236
1207
|
return false;
|
|
1237
1208
|
}
|
|
1238
1209
|
_isInsideEmptyNode(cursor) {
|
|
1239
|
-
return cursor[this.MQ.L] === MQ_END && cursor[this.MQ.R] === MQ_END;
|
|
1210
|
+
return cursor[this.MQ.L] === ActionType.MQ_END && cursor[this.MQ.R] === ActionType.MQ_END;
|
|
1240
1211
|
}
|
|
1241
1212
|
_handleBackspaceInRootIndex(cursor) {
|
|
1242
1213
|
if (this._isInsideEmptyNode(cursor)) {
|
|
@@ -1264,14 +1235,14 @@ class MathWrapper {
|
|
|
1264
1235
|
this.mathField.write(latex.replace(/^\\sqrt\[\]/, "\\sqrt"));
|
|
1265
1236
|
|
|
1266
1237
|
// Adjust the cursor to be to the left the sqrt.
|
|
1267
|
-
if (reinsertionPoint === MQ_END) {
|
|
1238
|
+
if (reinsertionPoint === ActionType.MQ_END) {
|
|
1268
1239
|
this.mathField.moveToDirEnd(this.MQ.L);
|
|
1269
1240
|
} else {
|
|
1270
1241
|
cursor.insRightOf(reinsertionPoint);
|
|
1271
1242
|
}
|
|
1272
1243
|
}
|
|
1273
1244
|
} else {
|
|
1274
|
-
if (cursor[this.MQ.L] !== MQ_END) {
|
|
1245
|
+
if (cursor[this.MQ.L] !== ActionType.MQ_END) {
|
|
1275
1246
|
// If the cursor is not at the leftmost position inside the
|
|
1276
1247
|
// root's index, delete a character.
|
|
1277
1248
|
this.mathField.keystroke("Backspace");
|
|
@@ -1284,7 +1255,7 @@ class MathWrapper {
|
|
|
1284
1255
|
const command = this._maybeFindCommandBeforeParens(grandparent);
|
|
1285
1256
|
cursor.insLeftOf(command === null || command === void 0 ? void 0 : command.startNode);
|
|
1286
1257
|
cursor.startSelection();
|
|
1287
|
-
if (grandparent[this.MQ.R] !== MQ_END) {
|
|
1258
|
+
if (grandparent[this.MQ.R] !== ActionType.MQ_END) {
|
|
1288
1259
|
cursor.insRightOf(grandparent[this.MQ.R]);
|
|
1289
1260
|
} else {
|
|
1290
1261
|
cursor.insRightOf(grandparent);
|
|
@@ -1318,7 +1289,7 @@ class MathWrapper {
|
|
|
1318
1289
|
// the parens.
|
|
1319
1290
|
cursor.insLeftOf(command.startNode);
|
|
1320
1291
|
cursor.startSelection();
|
|
1321
|
-
if (rightNode === MQ_END) {
|
|
1292
|
+
if (rightNode === ActionType.MQ_END) {
|
|
1322
1293
|
cursor.insAtRightEnd(cursor.parent);
|
|
1323
1294
|
} else {
|
|
1324
1295
|
cursor.insLeftOf(rightNode);
|
|
@@ -1357,7 +1328,7 @@ class MathWrapper {
|
|
|
1357
1328
|
// - \log(|x+1) => |\log(x+1)|
|
|
1358
1329
|
// - \log(|) => |
|
|
1359
1330
|
|
|
1360
|
-
if (cursor[this.MQ.L] !== MQ_END) {
|
|
1331
|
+
if (cursor[this.MQ.L] !== ActionType.MQ_END) {
|
|
1361
1332
|
// This command contains math and there's some math to
|
|
1362
1333
|
// the left of the cursor that we should delete normally
|
|
1363
1334
|
// before doing anything special.
|
|
@@ -1406,9 +1377,9 @@ class MathWrapper {
|
|
|
1406
1377
|
contextForCursor(cursor) {
|
|
1407
1378
|
// First, try to find any fraction to the right, unimpeded.
|
|
1408
1379
|
let visitor = cursor;
|
|
1409
|
-
while (visitor[this.MQ.R] !== MQ_END) {
|
|
1380
|
+
while (visitor[this.MQ.R] !== ActionType.MQ_END) {
|
|
1410
1381
|
if (this._isFraction(visitor[this.MQ.R])) {
|
|
1411
|
-
return BEFORE_FRACTION;
|
|
1382
|
+
return CursorContext.BEFORE_FRACTION;
|
|
1412
1383
|
} else if (!this._isLeaf(visitor[this.MQ.R])) {
|
|
1413
1384
|
break;
|
|
1414
1385
|
}
|
|
@@ -1418,17 +1389,17 @@ class MathWrapper {
|
|
|
1418
1389
|
// If that didn't work, check if the parent or grandparent is a special
|
|
1419
1390
|
// context, so that we can jump outwards.
|
|
1420
1391
|
if (this._isParens(cursor.parent && cursor.parent.parent)) {
|
|
1421
|
-
return IN_PARENS;
|
|
1392
|
+
return CursorContext.IN_PARENS;
|
|
1422
1393
|
} else if (this._isNumerator(cursor.parent)) {
|
|
1423
|
-
return IN_NUMERATOR;
|
|
1394
|
+
return CursorContext.IN_NUMERATOR;
|
|
1424
1395
|
} else if (this._isDenominator(cursor.parent)) {
|
|
1425
|
-
return IN_DENOMINATOR;
|
|
1396
|
+
return CursorContext.IN_DENOMINATOR;
|
|
1426
1397
|
} else if (this._isSubScript(cursor.parent)) {
|
|
1427
|
-
return IN_SUB_SCRIPT;
|
|
1398
|
+
return CursorContext.IN_SUB_SCRIPT;
|
|
1428
1399
|
} else if (this._isSuperScript(cursor.parent)) {
|
|
1429
|
-
return IN_SUPER_SCRIPT;
|
|
1400
|
+
return CursorContext.IN_SUPER_SCRIPT;
|
|
1430
1401
|
} else {
|
|
1431
|
-
return NONE;
|
|
1402
|
+
return CursorContext.NONE;
|
|
1432
1403
|
}
|
|
1433
1404
|
}
|
|
1434
1405
|
_isAtTopLevel(cursor) {
|
|
@@ -2224,6 +2195,7 @@ const activateKeypad = () => {
|
|
|
2224
2195
|
/**
|
|
2225
2196
|
* Configure the keypad with the provided configuration parameters.
|
|
2226
2197
|
*/
|
|
2198
|
+
|
|
2227
2199
|
const configureKeypad = configuration => {
|
|
2228
2200
|
return {
|
|
2229
2201
|
type: "ConfigureKeypad",
|
|
@@ -2245,6 +2217,7 @@ const removeEcho = animationId => {
|
|
|
2245
2217
|
};
|
|
2246
2218
|
|
|
2247
2219
|
// Input-related actions.
|
|
2220
|
+
|
|
2248
2221
|
const setKeyHandler = keyHandler => {
|
|
2249
2222
|
return {
|
|
2250
2223
|
type: "SetKeyHandler",
|
|
@@ -2258,6 +2231,36 @@ const setCursor = cursor => {
|
|
|
2258
2231
|
};
|
|
2259
2232
|
};
|
|
2260
2233
|
|
|
2234
|
+
// Gesture actions
|
|
2235
|
+
|
|
2236
|
+
const onSwipeChange = dx => {
|
|
2237
|
+
return {
|
|
2238
|
+
type: "OnSwipeChange",
|
|
2239
|
+
dx
|
|
2240
|
+
};
|
|
2241
|
+
};
|
|
2242
|
+
const onSwipeEnd = dx => {
|
|
2243
|
+
return {
|
|
2244
|
+
type: "OnSwipeEnd",
|
|
2245
|
+
dx
|
|
2246
|
+
};
|
|
2247
|
+
};
|
|
2248
|
+
const setActiveNodes = activeNodes => {
|
|
2249
|
+
return {
|
|
2250
|
+
type: "SetActiveNodes",
|
|
2251
|
+
activeNodes
|
|
2252
|
+
};
|
|
2253
|
+
};
|
|
2254
|
+
const pressKey = (key, borders, initialBounds, inPopover) => {
|
|
2255
|
+
return {
|
|
2256
|
+
type: "PressKey",
|
|
2257
|
+
key,
|
|
2258
|
+
borders,
|
|
2259
|
+
initialBounds,
|
|
2260
|
+
inPopover
|
|
2261
|
+
};
|
|
2262
|
+
};
|
|
2263
|
+
|
|
2261
2264
|
/**
|
|
2262
2265
|
* The state machine that backs our gesture system. In particular, this state
|
|
2263
2266
|
* machine manages the interplay between focuses, touch ups, and swiping.
|
|
@@ -3034,231 +3037,231 @@ class GestureManager {
|
|
|
3034
3037
|
const KeyConfigs = {
|
|
3035
3038
|
// Basic math keys.
|
|
3036
3039
|
[Keys.PLUS]: {
|
|
3037
|
-
type:
|
|
3040
|
+
type: KeyType.OPERATOR,
|
|
3038
3041
|
// I18N: A label for a plus sign.
|
|
3039
3042
|
ariaLabel: i18n__namespace._("Plus")
|
|
3040
3043
|
},
|
|
3041
3044
|
[Keys.MINUS]: {
|
|
3042
|
-
type:
|
|
3045
|
+
type: KeyType.OPERATOR,
|
|
3043
3046
|
// I18N: A label for a minus sign.
|
|
3044
3047
|
ariaLabel: i18n__namespace._("Minus")
|
|
3045
3048
|
},
|
|
3046
3049
|
[Keys.NEGATIVE]: {
|
|
3047
|
-
type:
|
|
3050
|
+
type: KeyType.VALUE,
|
|
3048
3051
|
// I18N: A label for a minus sign.
|
|
3049
3052
|
ariaLabel: i18n__namespace._("Negative")
|
|
3050
3053
|
},
|
|
3051
3054
|
[Keys.TIMES]: {
|
|
3052
|
-
type:
|
|
3055
|
+
type: KeyType.OPERATOR,
|
|
3053
3056
|
// I18N: A label for a multiplication sign (represented with an 'x').
|
|
3054
3057
|
ariaLabel: i18n__namespace._("Multiply")
|
|
3055
3058
|
},
|
|
3056
3059
|
[Keys.DIVIDE]: {
|
|
3057
|
-
type:
|
|
3060
|
+
type: KeyType.OPERATOR,
|
|
3058
3061
|
// I18N: A label for a division sign.
|
|
3059
3062
|
ariaLabel: i18n__namespace._("Divide")
|
|
3060
3063
|
},
|
|
3061
3064
|
[Keys.DECIMAL]: {
|
|
3062
|
-
type:
|
|
3065
|
+
type: KeyType.VALUE,
|
|
3063
3066
|
// I18N: A label for a decimal symbol.
|
|
3064
3067
|
ariaLabel: i18n__namespace._("Decimal"),
|
|
3065
|
-
icon: decimalSeparator ===
|
|
3068
|
+
icon: decimalSeparator === DecimalSeparator.COMMA ? {
|
|
3066
3069
|
// TODO(charlie): Get an SVG icon for the comma, or verify with
|
|
3067
3070
|
// design that the text-rendered version is acceptable.
|
|
3068
|
-
type:
|
|
3071
|
+
type: IconType.TEXT,
|
|
3069
3072
|
data: ","
|
|
3070
3073
|
} : {
|
|
3071
|
-
type:
|
|
3074
|
+
type: IconType.SVG,
|
|
3072
3075
|
data: Keys.PERIOD
|
|
3073
3076
|
}
|
|
3074
3077
|
},
|
|
3075
3078
|
[Keys.PERCENT]: {
|
|
3076
|
-
type:
|
|
3079
|
+
type: KeyType.OPERATOR,
|
|
3077
3080
|
// I18N: A label for a percent sign.
|
|
3078
3081
|
ariaLabel: i18n__namespace._("Percent")
|
|
3079
3082
|
},
|
|
3080
3083
|
[Keys.CDOT]: {
|
|
3081
|
-
type:
|
|
3084
|
+
type: KeyType.OPERATOR,
|
|
3082
3085
|
// I18N: A label for a multiplication sign (represented as a dot).
|
|
3083
3086
|
ariaLabel: i18n__namespace._("Multiply")
|
|
3084
3087
|
},
|
|
3085
3088
|
[Keys.EQUAL]: {
|
|
3086
|
-
type:
|
|
3089
|
+
type: KeyType.OPERATOR,
|
|
3087
3090
|
ariaLabel: i18n__namespace._("Equals sign")
|
|
3088
3091
|
},
|
|
3089
3092
|
[Keys.NEQ]: {
|
|
3090
|
-
type:
|
|
3093
|
+
type: KeyType.OPERATOR,
|
|
3091
3094
|
ariaLabel: i18n__namespace._("Not-equals sign")
|
|
3092
3095
|
},
|
|
3093
3096
|
[Keys.GT]: {
|
|
3094
|
-
type:
|
|
3097
|
+
type: KeyType.OPERATOR,
|
|
3095
3098
|
// I18N: A label for a 'greater than' sign (represented as '>').
|
|
3096
3099
|
ariaLabel: i18n__namespace._("Greater than sign")
|
|
3097
3100
|
},
|
|
3098
3101
|
[Keys.LT]: {
|
|
3099
|
-
type:
|
|
3102
|
+
type: KeyType.OPERATOR,
|
|
3100
3103
|
// I18N: A label for a 'less than' sign (represented as '<').
|
|
3101
3104
|
ariaLabel: i18n__namespace._("Less than sign")
|
|
3102
3105
|
},
|
|
3103
3106
|
[Keys.GEQ]: {
|
|
3104
|
-
type:
|
|
3107
|
+
type: KeyType.OPERATOR,
|
|
3105
3108
|
ariaLabel: i18n__namespace._("Greater than or equal to sign")
|
|
3106
3109
|
},
|
|
3107
3110
|
[Keys.LEQ]: {
|
|
3108
|
-
type:
|
|
3111
|
+
type: KeyType.OPERATOR,
|
|
3109
3112
|
ariaLabel: i18n__namespace._("Less than or equal to sign")
|
|
3110
3113
|
},
|
|
3111
3114
|
// mobile native
|
|
3112
3115
|
[Keys.FRAC_INCLUSIVE]: {
|
|
3113
|
-
type:
|
|
3116
|
+
type: KeyType.OPERATOR,
|
|
3114
3117
|
// I18N: A label for a button that creates a new fraction and puts the
|
|
3115
3118
|
// current expression in the numerator of that fraction.
|
|
3116
3119
|
ariaLabel: i18n__namespace._("Fraction, with current expression in numerator")
|
|
3117
3120
|
},
|
|
3118
3121
|
// mobile native
|
|
3119
3122
|
[Keys.FRAC_EXCLUSIVE]: {
|
|
3120
|
-
type:
|
|
3123
|
+
type: KeyType.OPERATOR,
|
|
3121
3124
|
// I18N: A label for a button that creates a new fraction next to the
|
|
3122
3125
|
// cursor.
|
|
3123
3126
|
ariaLabel: i18n__namespace._("Fraction, excluding the current expression")
|
|
3124
3127
|
},
|
|
3125
3128
|
// mobile web
|
|
3126
3129
|
[Keys.FRAC]: {
|
|
3127
|
-
type:
|
|
3130
|
+
type: KeyType.OPERATOR,
|
|
3128
3131
|
// I18N: A label for a button that creates a new fraction next to the
|
|
3129
3132
|
// cursor.
|
|
3130
3133
|
ariaLabel: i18n__namespace._("Fraction, excluding the current expression")
|
|
3131
3134
|
},
|
|
3132
3135
|
[Keys.EXP]: {
|
|
3133
|
-
type:
|
|
3136
|
+
type: KeyType.OPERATOR,
|
|
3134
3137
|
// I18N: A label for a button that will allow the user to input a custom
|
|
3135
3138
|
// exponent.
|
|
3136
3139
|
ariaLabel: i18n__namespace._("Custom exponent")
|
|
3137
3140
|
},
|
|
3138
3141
|
[Keys.EXP_2]: {
|
|
3139
|
-
type:
|
|
3142
|
+
type: KeyType.OPERATOR,
|
|
3140
3143
|
// I18N: A label for a button that will square (take to the second
|
|
3141
3144
|
// power) some math.
|
|
3142
3145
|
ariaLabel: i18n__namespace._("Square")
|
|
3143
3146
|
},
|
|
3144
3147
|
[Keys.EXP_3]: {
|
|
3145
|
-
type:
|
|
3148
|
+
type: KeyType.OPERATOR,
|
|
3146
3149
|
// I18N: A label for a button that will cube (take to the third power)
|
|
3147
3150
|
// some math.
|
|
3148
3151
|
ariaLabel: i18n__namespace._("Cube")
|
|
3149
3152
|
},
|
|
3150
3153
|
[Keys.SQRT]: {
|
|
3151
|
-
type:
|
|
3154
|
+
type: KeyType.OPERATOR,
|
|
3152
3155
|
ariaLabel: i18n__namespace._("Square root")
|
|
3153
3156
|
},
|
|
3154
3157
|
[Keys.CUBE_ROOT]: {
|
|
3155
|
-
type:
|
|
3158
|
+
type: KeyType.OPERATOR,
|
|
3156
3159
|
ariaLabel: i18n__namespace._("Cube root")
|
|
3157
3160
|
},
|
|
3158
3161
|
[Keys.RADICAL]: {
|
|
3159
|
-
type:
|
|
3162
|
+
type: KeyType.OPERATOR,
|
|
3160
3163
|
ariaLabel: i18n__namespace._("Radical with custom root")
|
|
3161
3164
|
},
|
|
3162
3165
|
[Keys.LEFT_PAREN]: {
|
|
3163
|
-
type:
|
|
3166
|
+
type: KeyType.OPERATOR,
|
|
3164
3167
|
ariaLabel: i18n__namespace._("Left parenthesis")
|
|
3165
3168
|
},
|
|
3166
3169
|
[Keys.RIGHT_PAREN]: {
|
|
3167
|
-
type:
|
|
3170
|
+
type: KeyType.OPERATOR,
|
|
3168
3171
|
ariaLabel: i18n__namespace._("Right parenthesis")
|
|
3169
3172
|
},
|
|
3170
3173
|
[Keys.LN]: {
|
|
3171
|
-
type:
|
|
3174
|
+
type: KeyType.OPERATOR,
|
|
3172
3175
|
ariaLabel: i18n__namespace._("Natural logarithm")
|
|
3173
3176
|
},
|
|
3174
3177
|
[Keys.LOG]: {
|
|
3175
|
-
type:
|
|
3178
|
+
type: KeyType.OPERATOR,
|
|
3176
3179
|
ariaLabel: i18n__namespace._("Logarithm with base 10")
|
|
3177
3180
|
},
|
|
3178
3181
|
[Keys.LOG_N]: {
|
|
3179
|
-
type:
|
|
3182
|
+
type: KeyType.OPERATOR,
|
|
3180
3183
|
ariaLabel: i18n__namespace._("Logarithm with custom base")
|
|
3181
3184
|
},
|
|
3182
3185
|
[Keys.SIN]: {
|
|
3183
|
-
type:
|
|
3186
|
+
type: KeyType.OPERATOR,
|
|
3184
3187
|
ariaLabel: i18n__namespace._("Sine")
|
|
3185
3188
|
},
|
|
3186
3189
|
[Keys.COS]: {
|
|
3187
|
-
type:
|
|
3190
|
+
type: KeyType.OPERATOR,
|
|
3188
3191
|
ariaLabel: i18n__namespace._("Cosine")
|
|
3189
3192
|
},
|
|
3190
3193
|
[Keys.TAN]: {
|
|
3191
|
-
type:
|
|
3194
|
+
type: KeyType.OPERATOR,
|
|
3192
3195
|
ariaLabel: i18n__namespace._("Tangent")
|
|
3193
3196
|
},
|
|
3194
3197
|
[Keys.PI]: {
|
|
3195
|
-
type:
|
|
3198
|
+
type: KeyType.VALUE,
|
|
3196
3199
|
ariaLabel: i18n__namespace._("Pi"),
|
|
3197
3200
|
icon: {
|
|
3198
|
-
type:
|
|
3201
|
+
type: IconType.MATH,
|
|
3199
3202
|
data: "\\pi"
|
|
3200
3203
|
}
|
|
3201
3204
|
},
|
|
3202
3205
|
[Keys.THETA]: {
|
|
3203
|
-
type:
|
|
3206
|
+
type: KeyType.VALUE,
|
|
3204
3207
|
ariaLabel: i18n__namespace._("Theta"),
|
|
3205
3208
|
icon: {
|
|
3206
|
-
type:
|
|
3209
|
+
type: IconType.MATH,
|
|
3207
3210
|
data: "\\theta"
|
|
3208
3211
|
}
|
|
3209
3212
|
},
|
|
3210
3213
|
[Keys.NOOP]: {
|
|
3211
|
-
type:
|
|
3214
|
+
type: KeyType.EMPTY
|
|
3212
3215
|
},
|
|
3213
3216
|
// Input navigation keys.
|
|
3214
3217
|
[Keys.UP]: {
|
|
3215
|
-
type:
|
|
3218
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3216
3219
|
ariaLabel: i18n__namespace._("Up arrow")
|
|
3217
3220
|
},
|
|
3218
3221
|
[Keys.RIGHT]: {
|
|
3219
|
-
type:
|
|
3222
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3220
3223
|
ariaLabel: i18n__namespace._("Right arrow")
|
|
3221
3224
|
},
|
|
3222
3225
|
[Keys.DOWN]: {
|
|
3223
|
-
type:
|
|
3226
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3224
3227
|
ariaLabel: i18n__namespace._("Down arrow")
|
|
3225
3228
|
},
|
|
3226
3229
|
[Keys.LEFT]: {
|
|
3227
|
-
type:
|
|
3230
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3228
3231
|
ariaLabel: i18n__namespace._("Left arrow")
|
|
3229
3232
|
},
|
|
3230
3233
|
[Keys.JUMP_OUT_PARENTHESES]: {
|
|
3231
|
-
type:
|
|
3234
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3232
3235
|
ariaLabel: i18n__namespace._("Navigate right out of a set of parentheses")
|
|
3233
3236
|
},
|
|
3234
3237
|
[Keys.JUMP_OUT_EXPONENT]: {
|
|
3235
|
-
type:
|
|
3238
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3236
3239
|
ariaLabel: i18n__namespace._("Navigate right out of an exponent")
|
|
3237
3240
|
},
|
|
3238
3241
|
[Keys.JUMP_OUT_BASE]: {
|
|
3239
|
-
type:
|
|
3242
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3240
3243
|
ariaLabel: i18n__namespace._("Navigate right out of a base")
|
|
3241
3244
|
},
|
|
3242
3245
|
[Keys.JUMP_INTO_NUMERATOR]: {
|
|
3243
|
-
type:
|
|
3246
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3244
3247
|
ariaLabel: i18n__namespace._("Navigate right into the numerator of a fraction")
|
|
3245
3248
|
},
|
|
3246
3249
|
[Keys.JUMP_OUT_NUMERATOR]: {
|
|
3247
|
-
type:
|
|
3250
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3248
3251
|
ariaLabel: i18n__namespace._("Navigate right out of the numerator and into the denominator")
|
|
3249
3252
|
},
|
|
3250
3253
|
[Keys.JUMP_OUT_DENOMINATOR]: {
|
|
3251
|
-
type:
|
|
3254
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3252
3255
|
ariaLabel: i18n__namespace._("Navigate right out of the denominator of a fraction")
|
|
3253
3256
|
},
|
|
3254
3257
|
[Keys.BACKSPACE]: {
|
|
3255
|
-
type:
|
|
3258
|
+
type: KeyType.INPUT_NAVIGATION,
|
|
3256
3259
|
// I18N: A label for a button that will delete some input.
|
|
3257
3260
|
ariaLabel: i18n__namespace._("Delete")
|
|
3258
3261
|
},
|
|
3259
3262
|
// Keypad navigation keys.
|
|
3260
3263
|
[Keys.DISMISS]: {
|
|
3261
|
-
type:
|
|
3264
|
+
type: KeyType.KEYPAD_NAVIGATION,
|
|
3262
3265
|
// I18N: A label for a button that will dismiss/hide a keypad.
|
|
3263
3266
|
ariaLabel: i18n__namespace._("Dismiss")
|
|
3264
3267
|
}
|
|
@@ -3276,7 +3279,7 @@ KeyConfigs[Keys.FRAC_MULTI] = {
|
|
|
3276
3279
|
|
|
3277
3280
|
// TODO(charlie): Use the numeral color for the 'Many' key.
|
|
3278
3281
|
KeyConfigs[Keys.MANY] = {
|
|
3279
|
-
type:
|
|
3282
|
+
type: KeyType.MANY
|
|
3280
3283
|
// childKeyIds will be configured by the client.
|
|
3281
3284
|
};
|
|
3282
3285
|
|
|
@@ -3288,10 +3291,10 @@ for (const num of NUMBERS) {
|
|
|
3288
3291
|
// would mean that we'd be using text beyond the variable key).
|
|
3289
3292
|
const textRepresentation = "".concat(num);
|
|
3290
3293
|
KeyConfigs["NUM_".concat(num)] = {
|
|
3291
|
-
type:
|
|
3294
|
+
type: KeyType.VALUE,
|
|
3292
3295
|
ariaLabel: textRepresentation,
|
|
3293
3296
|
icon: {
|
|
3294
|
-
type:
|
|
3297
|
+
type: IconType.TEXT,
|
|
3295
3298
|
data: textRepresentation
|
|
3296
3299
|
}
|
|
3297
3300
|
};
|
|
@@ -3304,10 +3307,10 @@ for (const letter of LETTERS) {
|
|
|
3304
3307
|
const upperCaseVariable = letter.toUpperCase();
|
|
3305
3308
|
for (const textRepresentation of [lowerCaseVariable, upperCaseVariable]) {
|
|
3306
3309
|
KeyConfigs[textRepresentation] = {
|
|
3307
|
-
type:
|
|
3310
|
+
type: KeyType.VALUE,
|
|
3308
3311
|
ariaLabel: textRepresentation,
|
|
3309
3312
|
icon: {
|
|
3310
|
-
type:
|
|
3313
|
+
type: IconType.MATH,
|
|
3311
3314
|
data: textRepresentation
|
|
3312
3315
|
}
|
|
3313
3316
|
};
|
|
@@ -3318,7 +3321,7 @@ for (const key of Object.keys(KeyConfigs)) {
|
|
|
3318
3321
|
id: key,
|
|
3319
3322
|
// Default to an SVG icon indexed by the key name.
|
|
3320
3323
|
icon: {
|
|
3321
|
-
type:
|
|
3324
|
+
type: IconType.SVG,
|
|
3322
3325
|
data: key
|
|
3323
3326
|
},
|
|
3324
3327
|
...KeyConfigs[key]
|
|
@@ -3340,12 +3343,12 @@ const echoReducer = function () {
|
|
|
3340
3343
|
|
|
3341
3344
|
// Add in the echo animation if the user performs a math
|
|
3342
3345
|
// operation.
|
|
3343
|
-
if (keyConfig.type ===
|
|
3346
|
+
if (keyConfig.type === KeyType.VALUE || keyConfig.type === KeyType.OPERATOR) {
|
|
3344
3347
|
return {
|
|
3345
3348
|
...state,
|
|
3346
3349
|
echoes: [...state.echoes, {
|
|
3347
3350
|
animationId: "" + _lastAnimationId++,
|
|
3348
|
-
animationType: action.inPopover ?
|
|
3351
|
+
animationType: action.inPopover ? EchoAnimationType.LONG_FADE_ONLY : EchoAnimationType.FADE_ONLY,
|
|
3349
3352
|
borders: action.borders,
|
|
3350
3353
|
id: keyConfig.id,
|
|
3351
3354
|
initialBounds: action.initialBounds
|
|
@@ -3355,7 +3358,6 @@ const echoReducer = function () {
|
|
|
3355
3358
|
return state;
|
|
3356
3359
|
case "RemoveEcho":
|
|
3357
3360
|
const remainingEchoes = state.echoes.filter(echo => {
|
|
3358
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'animationId' does not exist on type 'never'.
|
|
3359
3361
|
return echo.animationId !== action.animationId;
|
|
3360
3362
|
});
|
|
3361
3363
|
return {
|
|
@@ -3370,7 +3372,7 @@ const echoReducer = function () {
|
|
|
3370
3372
|
const initialInputState = {
|
|
3371
3373
|
keyHandler: null,
|
|
3372
3374
|
cursor: {
|
|
3373
|
-
context: NONE
|
|
3375
|
+
context: CursorContext.NONE
|
|
3374
3376
|
}
|
|
3375
3377
|
};
|
|
3376
3378
|
const inputReducer = function () {
|
|
@@ -3384,7 +3386,7 @@ const inputReducer = function () {
|
|
|
3384
3386
|
};
|
|
3385
3387
|
case "PressKey":
|
|
3386
3388
|
const keyConfig = KeyConfigs[action.key];
|
|
3387
|
-
if (keyConfig.type !==
|
|
3389
|
+
if (keyConfig.type !== KeyType.KEYPAD_NAVIGATION) {
|
|
3388
3390
|
var _state$keyHandler;
|
|
3389
3391
|
// This is probably an anti-pattern but it works for the
|
|
3390
3392
|
// case where we don't actually control the state but we
|
|
@@ -4615,48 +4617,48 @@ const JumpOutDenominator = () => {
|
|
|
4615
4617
|
*/
|
|
4616
4618
|
|
|
4617
4619
|
var Iconography = /*#__PURE__*/Object.freeze({
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4620
|
+
__proto__: null,
|
|
4621
|
+
COS: Cos,
|
|
4622
|
+
LOG: Log,
|
|
4623
|
+
EQUAL: Equal,
|
|
4624
|
+
BACKSPACE: Backspace,
|
|
4625
|
+
SQRT: Sqrt,
|
|
4626
|
+
EXP: Exp,
|
|
4627
|
+
NEQ: Neq,
|
|
4628
|
+
GEQ: Geq,
|
|
4629
|
+
LN: Ln,
|
|
4630
|
+
DISMISS: Dismiss,
|
|
4631
|
+
SIN: Sin,
|
|
4632
|
+
LT: Lt,
|
|
4633
|
+
CUBE_ROOT: CubeRoot,
|
|
4634
|
+
PLUS: Plus,
|
|
4635
|
+
TAN: Tan,
|
|
4636
|
+
LEFT: Left,
|
|
4637
|
+
UP: Up,
|
|
4638
|
+
DOWN: Down,
|
|
4639
|
+
LEFT_PAREN: LeftParen,
|
|
4640
|
+
RIGHT_PAREN: RightParen,
|
|
4641
|
+
GT: Gt,
|
|
4642
|
+
DIVIDE: Divide,
|
|
4643
|
+
PERIOD: Period,
|
|
4644
|
+
PERCENT: Percent,
|
|
4645
|
+
TIMES: Times,
|
|
4646
|
+
EXP_3: Exp3,
|
|
4647
|
+
EXP_2: Exp2,
|
|
4648
|
+
RIGHT: Right,
|
|
4649
|
+
CDOT: Cdot,
|
|
4650
|
+
LOG_N: LogN,
|
|
4651
|
+
LEQ: Leq,
|
|
4652
|
+
MINUS: Minus,
|
|
4653
|
+
NEGATIVE: Minus,
|
|
4654
|
+
RADICAL: Radical,
|
|
4655
|
+
FRAC: FracInclusive,
|
|
4656
|
+
JUMP_OUT_PARENTHESES: JumpOutParentheses,
|
|
4657
|
+
JUMP_OUT_EXPONENT: JumpOutExponent,
|
|
4658
|
+
JUMP_OUT_BASE: JumpOutBase,
|
|
4659
|
+
JUMP_INTO_NUMERATOR: JumpIntoNumerator,
|
|
4660
|
+
JUMP_OUT_NUMERATOR: JumpOutNumerator,
|
|
4661
|
+
JUMP_OUT_DENOMINATOR: JumpOutDenominator
|
|
4660
4662
|
});
|
|
4661
4663
|
|
|
4662
4664
|
/**
|
|
@@ -4721,12 +4723,12 @@ class Icon extends React__namespace.PureComponent {
|
|
|
4721
4723
|
} = this.props;
|
|
4722
4724
|
const styleWithFocus = [focused ? styles$a.focused : styles$a.unfocused, ...(Array.isArray(style) ? style : [style])];
|
|
4723
4725
|
switch (icon.type) {
|
|
4724
|
-
case
|
|
4726
|
+
case IconType.MATH:
|
|
4725
4727
|
return /*#__PURE__*/React__namespace.createElement(MathIcon, {
|
|
4726
4728
|
math: icon.data,
|
|
4727
4729
|
style: styleWithFocus
|
|
4728
4730
|
});
|
|
4729
|
-
case
|
|
4731
|
+
case IconType.SVG:
|
|
4730
4732
|
// TODO(charlie): Support passing style objects to `SvgIcon`.
|
|
4731
4733
|
// This will require migrating the individual icons to use
|
|
4732
4734
|
// `currentColor` and accept a `className` prop, rather than
|
|
@@ -4735,7 +4737,7 @@ class Icon extends React__namespace.PureComponent {
|
|
|
4735
4737
|
name: icon.data,
|
|
4736
4738
|
color: focused ? focusedColor : unfocusedColor
|
|
4737
4739
|
});
|
|
4738
|
-
case
|
|
4740
|
+
case IconType.TEXT:
|
|
4739
4741
|
return /*#__PURE__*/React__namespace.createElement(TextIcon, {
|
|
4740
4742
|
character: icon.data,
|
|
4741
4743
|
style: styleWithFocus
|
|
@@ -4777,7 +4779,7 @@ class MultiSymbolGrid extends React__namespace.Component {
|
|
|
4777
4779
|
// Supporting other types of icons is possible but would require
|
|
4778
4780
|
// some styles coercion and doesn't seem worthwhile right now.
|
|
4779
4781
|
icons.forEach(icon => {
|
|
4780
|
-
if (icon.type !==
|
|
4782
|
+
if (icon.type !== IconType.MATH) {
|
|
4781
4783
|
throw new Error("Received invalid icon: type=".concat(icon.type, ", ") + "data=".concat(icon.data));
|
|
4782
4784
|
}
|
|
4783
4785
|
});
|
|
@@ -4895,7 +4897,7 @@ class KeypadButton extends React__namespace.PureComponent {
|
|
|
4895
4897
|
// object. This method must be called whenever a property that
|
|
4896
4898
|
// influences the possible outcomes of `this._getFocusStyle` and
|
|
4897
4899
|
// `this._getButtonStyle` changes (such as `this.buttonSizeStyle`).
|
|
4898
|
-
for (const type of Object.
|
|
4900
|
+
for (const type of Object.values(KeyType)) {
|
|
4899
4901
|
aphrodite.css(View.styles.initial, ...this._getFocusStyle(type));
|
|
4900
4902
|
for (const borders of Object.values(BorderStyles)) {
|
|
4901
4903
|
aphrodite.css(View.styles.initial, ...this._getButtonStyle(type, borders));
|
|
@@ -4904,7 +4906,7 @@ class KeypadButton extends React__namespace.PureComponent {
|
|
|
4904
4906
|
});
|
|
4905
4907
|
_defineProperty(this, "_getFocusStyle", type => {
|
|
4906
4908
|
let focusBackgroundStyle;
|
|
4907
|
-
if (type ===
|
|
4909
|
+
if (type === KeyType.INPUT_NAVIGATION || type === KeyType.KEYPAD_NAVIGATION) {
|
|
4908
4910
|
focusBackgroundStyle = styles$8.light;
|
|
4909
4911
|
} else {
|
|
4910
4912
|
focusBackgroundStyle = styles$8.bright;
|
|
@@ -4915,34 +4917,34 @@ class KeypadButton extends React__namespace.PureComponent {
|
|
|
4915
4917
|
// Select the appropriate style for the button.
|
|
4916
4918
|
let backgroundStyle;
|
|
4917
4919
|
switch (type) {
|
|
4918
|
-
case
|
|
4920
|
+
case KeyType.EMPTY:
|
|
4919
4921
|
backgroundStyle = styles$8.empty;
|
|
4920
4922
|
break;
|
|
4921
|
-
case
|
|
4922
|
-
case
|
|
4923
|
+
case KeyType.MANY:
|
|
4924
|
+
case KeyType.VALUE:
|
|
4923
4925
|
backgroundStyle = styles$8.value;
|
|
4924
4926
|
break;
|
|
4925
|
-
case
|
|
4927
|
+
case KeyType.OPERATOR:
|
|
4926
4928
|
backgroundStyle = styles$8.operator;
|
|
4927
4929
|
break;
|
|
4928
|
-
case
|
|
4929
|
-
case
|
|
4930
|
+
case KeyType.INPUT_NAVIGATION:
|
|
4931
|
+
case KeyType.KEYPAD_NAVIGATION:
|
|
4930
4932
|
backgroundStyle = styles$8.control;
|
|
4931
4933
|
break;
|
|
4932
|
-
case
|
|
4934
|
+
case KeyType.ECHO:
|
|
4933
4935
|
backgroundStyle = null;
|
|
4934
4936
|
break;
|
|
4935
4937
|
}
|
|
4936
4938
|
const borderStyle = [];
|
|
4937
|
-
if (borders.includes(
|
|
4939
|
+
if (borders.includes(BorderDirection.LEFT)) {
|
|
4938
4940
|
// @ts-expect-error TS2345
|
|
4939
4941
|
borderStyle.push(styles$8.leftBorder);
|
|
4940
4942
|
}
|
|
4941
|
-
if (borders.includes(
|
|
4943
|
+
if (borders.includes(BorderDirection.BOTTOM)) {
|
|
4942
4944
|
// @ts-expect-error TS2345
|
|
4943
4945
|
borderStyle.push(styles$8.bottomBorder);
|
|
4944
4946
|
}
|
|
4945
|
-
return [styles$8.buttonBase, backgroundStyle, ...borderStyle, type ===
|
|
4947
|
+
return [styles$8.buttonBase, backgroundStyle, ...borderStyle, type === KeyType.ECHO && styles$8.echo, this.buttonSizeStyle,
|
|
4946
4948
|
// React Native allows you to set the 'style' props on user defined
|
|
4947
4949
|
// components.
|
|
4948
4950
|
// See: https://facebook.github.io/react-native/docs/style.html
|
|
@@ -4984,7 +4986,7 @@ class KeypadButton extends React__namespace.PureComponent {
|
|
|
4984
4986
|
|
|
4985
4987
|
// We render in the focus state if the key is focused, or if it's an
|
|
4986
4988
|
// echo.
|
|
4987
|
-
const renderFocused = !disabled && focused || popoverEnabled || type ===
|
|
4989
|
+
const renderFocused = !disabled && focused || popoverEnabled || type === KeyType.ECHO;
|
|
4988
4990
|
const buttonStyle = this._getButtonStyle(type, borders, style);
|
|
4989
4991
|
const focusStyle = this._getFocusStyle(type);
|
|
4990
4992
|
const iconWrapperStyle = [styles$8.iconWrapper, disabled ? styles$8.disabled : undefined];
|
|
@@ -5000,11 +5002,11 @@ class KeypadButton extends React__namespace.PureComponent {
|
|
|
5000
5002
|
const maybeCornerDecal = !renderFocused && !disabled && childKeys && childKeys.length > 0 && /*#__PURE__*/React__namespace.createElement(CornerDecal, {
|
|
5001
5003
|
style: styles$8.decalInset
|
|
5002
5004
|
});
|
|
5003
|
-
if (type ===
|
|
5005
|
+
if (type === KeyType.EMPTY) {
|
|
5004
5006
|
return /*#__PURE__*/React__namespace.createElement(View, _extends({
|
|
5005
5007
|
style: buttonStyle
|
|
5006
5008
|
}, eventHandlers));
|
|
5007
|
-
} else if (type ===
|
|
5009
|
+
} else if (type === KeyType.MANY) {
|
|
5008
5010
|
// TODO(charlie): Make the long-press interaction accessible. See
|
|
5009
5011
|
// the TODO in key-configs.js for more.
|
|
5010
5012
|
const manyButtonA11yMarkup = {
|
|
@@ -5238,7 +5240,7 @@ const mapStateToProps$5 = (state, ownProps) => {
|
|
|
5238
5240
|
|
|
5239
5241
|
// Override with the default child props, if the key is a multi-symbol key
|
|
5240
5242
|
// (but not a many-symbol key, which operates under different rules).
|
|
5241
|
-
const useFirstChildProps = type !==
|
|
5243
|
+
const useFirstChildProps = type !== KeyType.MANY && childKeys && childKeys.length > 0;
|
|
5242
5244
|
return {
|
|
5243
5245
|
...rest,
|
|
5244
5246
|
childKeyIds: childKeyIds,
|
|
@@ -5283,7 +5285,7 @@ class ManyKeypadButton extends React__namespace.Component {
|
|
|
5283
5285
|
} else {
|
|
5284
5286
|
const keyConfig = {
|
|
5285
5287
|
id: Keys.MANY,
|
|
5286
|
-
type:
|
|
5288
|
+
type: KeyType.MANY,
|
|
5287
5289
|
childKeyIds: keys
|
|
5288
5290
|
};
|
|
5289
5291
|
return /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, _extends({
|
|
@@ -5343,7 +5345,7 @@ class Echo extends React__namespace.Component {
|
|
|
5343
5345
|
style: containerStyle
|
|
5344
5346
|
}, /*#__PURE__*/React__namespace.createElement(KeypadButton$1, {
|
|
5345
5347
|
icon: icon,
|
|
5346
|
-
type:
|
|
5348
|
+
type: KeyType.ECHO,
|
|
5347
5349
|
borders: borders
|
|
5348
5350
|
}));
|
|
5349
5351
|
}
|
|
@@ -5357,15 +5359,15 @@ class EchoManager extends React__namespace.Component {
|
|
|
5357
5359
|
let animationDurationMs;
|
|
5358
5360
|
let animationTransitionName;
|
|
5359
5361
|
switch (animationType) {
|
|
5360
|
-
case
|
|
5362
|
+
case EchoAnimationType.SLIDE_AND_FADE:
|
|
5361
5363
|
animationDurationMs = 400;
|
|
5362
5364
|
animationTransitionName = "echo-slide-and-fade";
|
|
5363
5365
|
break;
|
|
5364
|
-
case
|
|
5366
|
+
case EchoAnimationType.FADE_ONLY:
|
|
5365
5367
|
animationDurationMs = 300;
|
|
5366
5368
|
animationTransitionName = "echo-fade-only";
|
|
5367
5369
|
break;
|
|
5368
|
-
case
|
|
5370
|
+
case EchoAnimationType.LONG_FADE_ONLY:
|
|
5369
5371
|
animationDurationMs = 400;
|
|
5370
5372
|
animationTransitionName = "echo-long-fade-only";
|
|
5371
5373
|
break;
|
|
@@ -5383,7 +5385,7 @@ class EchoManager extends React__namespace.Component {
|
|
|
5383
5385
|
echoes,
|
|
5384
5386
|
onAnimationFinish
|
|
5385
5387
|
} = this.props;
|
|
5386
|
-
return /*#__PURE__*/React__namespace.createElement("span", null, Object.keys(
|
|
5388
|
+
return /*#__PURE__*/React__namespace.createElement("span", null, Object.keys(EchoAnimationType).map(animationType => {
|
|
5387
5389
|
// Collect the relevant parameters for the animation type, and
|
|
5388
5390
|
// filter for the appropriate echoes.
|
|
5389
5391
|
const {
|
|
@@ -5914,25 +5916,25 @@ class ExpressionKeypad extends React__namespace.Component {
|
|
|
5914
5916
|
let dismissOrJumpOutKey;
|
|
5915
5917
|
if (dynamicJumpOut) {
|
|
5916
5918
|
switch (cursorContext) {
|
|
5917
|
-
case IN_PARENS:
|
|
5919
|
+
case CursorContext.IN_PARENS:
|
|
5918
5920
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
|
|
5919
5921
|
break;
|
|
5920
|
-
case IN_SUPER_SCRIPT:
|
|
5922
|
+
case CursorContext.IN_SUPER_SCRIPT:
|
|
5921
5923
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
|
|
5922
5924
|
break;
|
|
5923
|
-
case IN_SUB_SCRIPT:
|
|
5925
|
+
case CursorContext.IN_SUB_SCRIPT:
|
|
5924
5926
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
|
|
5925
5927
|
break;
|
|
5926
|
-
case BEFORE_FRACTION:
|
|
5928
|
+
case CursorContext.BEFORE_FRACTION:
|
|
5927
5929
|
dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
|
|
5928
5930
|
break;
|
|
5929
|
-
case IN_NUMERATOR:
|
|
5931
|
+
case CursorContext.IN_NUMERATOR:
|
|
5930
5932
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
|
|
5931
5933
|
break;
|
|
5932
|
-
case IN_DENOMINATOR:
|
|
5934
|
+
case CursorContext.IN_DENOMINATOR:
|
|
5933
5935
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
|
|
5934
5936
|
break;
|
|
5935
|
-
case NONE:
|
|
5937
|
+
case CursorContext.NONE:
|
|
5936
5938
|
default:
|
|
5937
5939
|
dismissOrJumpOutKey = KeyConfigs.DISMISS;
|
|
5938
5940
|
break;
|
|
@@ -6147,25 +6149,25 @@ class FractionKeypad extends React__namespace.Component {
|
|
|
6147
6149
|
let dismissOrJumpOutKey;
|
|
6148
6150
|
if (dynamicJumpOut) {
|
|
6149
6151
|
switch (cursorContext) {
|
|
6150
|
-
case IN_PARENS:
|
|
6152
|
+
case CursorContext.IN_PARENS:
|
|
6151
6153
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
|
|
6152
6154
|
break;
|
|
6153
|
-
case IN_SUPER_SCRIPT:
|
|
6155
|
+
case CursorContext.IN_SUPER_SCRIPT:
|
|
6154
6156
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
|
|
6155
6157
|
break;
|
|
6156
|
-
case IN_SUB_SCRIPT:
|
|
6158
|
+
case CursorContext.IN_SUB_SCRIPT:
|
|
6157
6159
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
|
|
6158
6160
|
break;
|
|
6159
|
-
case BEFORE_FRACTION:
|
|
6161
|
+
case CursorContext.BEFORE_FRACTION:
|
|
6160
6162
|
dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
|
|
6161
6163
|
break;
|
|
6162
|
-
case IN_NUMERATOR:
|
|
6164
|
+
case CursorContext.IN_NUMERATOR:
|
|
6163
6165
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
|
|
6164
6166
|
break;
|
|
6165
|
-
case IN_DENOMINATOR:
|
|
6167
|
+
case CursorContext.IN_DENOMINATOR:
|
|
6166
6168
|
dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
|
|
6167
6169
|
break;
|
|
6168
|
-
case NONE:
|
|
6170
|
+
case CursorContext.NONE:
|
|
6169
6171
|
default:
|
|
6170
6172
|
dismissOrJumpOutKey = KeyConfigs.DISMISS;
|
|
6171
6173
|
break;
|
|
@@ -6194,7 +6196,7 @@ class FractionKeypad extends React__namespace.Component {
|
|
|
6194
6196
|
// then when the cursor was inside a parenthetical
|
|
6195
6197
|
// expression in a numerator or denominator, this check
|
|
6196
6198
|
// would fail.
|
|
6197
|
-
cursorContext === IN_NUMERATOR || cursorContext === IN_DENOMINATOR,
|
|
6199
|
+
cursorContext === CursorContext.IN_NUMERATOR || cursorContext === CursorContext.IN_DENOMINATOR,
|
|
6198
6200
|
style: roundTopRight && roundedTopRight
|
|
6199
6201
|
})), /*#__PURE__*/React__namespace.createElement(View, {
|
|
6200
6202
|
style: row$2
|
|
@@ -6251,10 +6253,10 @@ var FractionKeypad$1 = reactRedux.connect(mapStateToProps$1, null, null, {
|
|
|
6251
6253
|
forwardRef: true
|
|
6252
6254
|
})(FractionKeypad);
|
|
6253
6255
|
|
|
6254
|
-
const defaultKeypadType =
|
|
6256
|
+
const defaultKeypadType = KeypadType.EXPRESSION;
|
|
6255
6257
|
const keypadForType = {
|
|
6256
|
-
[
|
|
6257
|
-
[
|
|
6258
|
+
[KeypadType.FRACTION]: fractionKeypadLayout,
|
|
6259
|
+
[KeypadType.EXPRESSION]: expressionKeypadLayout
|
|
6258
6260
|
};
|
|
6259
6261
|
|
|
6260
6262
|
const initialKeypadState = {
|
|
@@ -6281,11 +6283,9 @@ const keypadReducer = function () {
|
|
|
6281
6283
|
...state,
|
|
6282
6284
|
// Default `extraKeys` to the empty array.
|
|
6283
6285
|
extraKeys: [],
|
|
6284
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'configuration' does not exist on type '{ type: string; }'.
|
|
6285
6286
|
...action.configuration
|
|
6286
6287
|
};
|
|
6287
6288
|
case "PressKey":
|
|
6288
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'key' does not exist on type '{ type: string; }'.
|
|
6289
6289
|
const keyConfig = KeyConfigs[action.key];
|
|
6290
6290
|
// NOTE(charlie): Our keypad system operates by triggering key
|
|
6291
6291
|
// presses with key IDs in a dumb manner, such that the keys
|
|
@@ -6374,8 +6374,8 @@ const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
|
|
|
6374
6374
|
|
|
6375
6375
|
// Then, compute the button dimensions based on the provided parameters.
|
|
6376
6376
|
let buttonDimensions;
|
|
6377
|
-
if (deviceType ===
|
|
6378
|
-
const isLandscape = deviceOrientation ===
|
|
6377
|
+
if (deviceType === DeviceType.PHONE) {
|
|
6378
|
+
const isLandscape = deviceOrientation === DeviceOrientation.LANDSCAPE;
|
|
6379
6379
|
|
|
6380
6380
|
// In many cases, the browser chrome will already have been factored
|
|
6381
6381
|
// into `pageHeightPx`. But we have no way of knowing if that's
|
|
@@ -6418,7 +6418,7 @@ const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
|
|
|
6418
6418
|
widthPx: buttonWidthPx,
|
|
6419
6419
|
heightPx: buttonHeightPx
|
|
6420
6420
|
};
|
|
6421
|
-
} else if (deviceType ===
|
|
6421
|
+
} else if (deviceType === DeviceType.TABLET) {
|
|
6422
6422
|
buttonDimensions = {
|
|
6423
6423
|
widthPx: maxButtonSize,
|
|
6424
6424
|
heightPx: maxButtonSize
|
|
@@ -6433,7 +6433,7 @@ const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
|
|
|
6433
6433
|
const keypadWidth = effectiveNumColumns * buttonDimensions.widthPx + (navigationPadEnabled ? navigationPadWidthPx : 0) + numSeparators * innerBorderWidthPx;
|
|
6434
6434
|
return {
|
|
6435
6435
|
buttonDimensions,
|
|
6436
|
-
layoutMode: keypadWidth >= pageWidthPx ?
|
|
6436
|
+
layoutMode: keypadWidth >= pageWidthPx ? LayoutMode.FULLSCREEN : LayoutMode.COMPACT
|
|
6437
6437
|
};
|
|
6438
6438
|
};
|
|
6439
6439
|
|
|
@@ -6452,7 +6452,7 @@ const initialLayoutState = {
|
|
|
6452
6452
|
pageWidthPx: 0,
|
|
6453
6453
|
pageHeightPx: 0
|
|
6454
6454
|
},
|
|
6455
|
-
layoutMode:
|
|
6455
|
+
layoutMode: LayoutMode.FULLSCREEN,
|
|
6456
6456
|
paginationEnabled: false,
|
|
6457
6457
|
navigationPadEnabled: false
|
|
6458
6458
|
};
|
|
@@ -6468,13 +6468,13 @@ const layoutParametersForDimensions = (pageDimensions, gridDimensions) => {
|
|
|
6468
6468
|
} = pageDimensions;
|
|
6469
6469
|
|
|
6470
6470
|
// Determine the device type and orientation.
|
|
6471
|
-
const deviceOrientation = pageWidthPx > pageHeightPx ?
|
|
6472
|
-
const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ?
|
|
6471
|
+
const deviceOrientation = pageWidthPx > pageHeightPx ? DeviceOrientation.LANDSCAPE : DeviceOrientation.PORTRAIT;
|
|
6472
|
+
const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ? DeviceType.TABLET : DeviceType.PHONE;
|
|
6473
6473
|
|
|
6474
6474
|
// Using that information, make some decisions (or assumptions)
|
|
6475
6475
|
// about the resulting layout.
|
|
6476
|
-
const navigationPadEnabled = deviceType ===
|
|
6477
|
-
const paginationEnabled = deviceType ===
|
|
6476
|
+
const navigationPadEnabled = deviceType === DeviceType.TABLET;
|
|
6477
|
+
const paginationEnabled = deviceType === DeviceType.PHONE && deviceOrientation === DeviceOrientation.PORTRAIT;
|
|
6478
6478
|
const deviceInfo = {
|
|
6479
6479
|
deviceOrientation,
|
|
6480
6480
|
deviceType
|
|
@@ -6623,7 +6623,6 @@ const pagerReducer = function () {
|
|
|
6623
6623
|
let action = arguments.length > 1 ? arguments[1] : undefined;
|
|
6624
6624
|
switch (action.type) {
|
|
6625
6625
|
case "ConfigureKeypad":
|
|
6626
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'configuration' does not exist on type '{ type: string; }'.
|
|
6627
6626
|
const {
|
|
6628
6627
|
keypadType
|
|
6629
6628
|
} = action.configuration;
|
|
@@ -6640,51 +6639,27 @@ const pagerReducer = function () {
|
|
|
6640
6639
|
case "SetPageSize":
|
|
6641
6640
|
return {
|
|
6642
6641
|
...state,
|
|
6643
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'pageWidthPx' does not exist on type '{ type: string; }'.
|
|
6644
6642
|
pageWidthPx: action.pageWidthPx
|
|
6645
6643
|
};
|
|
6646
6644
|
case "PressKey":
|
|
6647
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'key' does not exist on type '{ type: string; }'.
|
|
6648
6645
|
const keyConfig = KeyConfigs[action.key];
|
|
6649
6646
|
|
|
6650
6647
|
// Reset the keypad page if the user performs a math operation.
|
|
6651
|
-
if (keyConfig.type ===
|
|
6652
|
-
return
|
|
6653
|
-
|
|
6654
|
-
|
|
6648
|
+
if (keyConfig.type === KeyType.VALUE || keyConfig.type === KeyType.OPERATOR) {
|
|
6649
|
+
return {
|
|
6650
|
+
...state,
|
|
6651
|
+
animateToPosition: true,
|
|
6652
|
+
// We start at the right-most page.
|
|
6653
|
+
currentPage: getDefaultPage(state.numPages),
|
|
6654
|
+
dx: 0
|
|
6655
|
+
};
|
|
6655
6656
|
}
|
|
6656
6657
|
return state;
|
|
6657
|
-
case "ResetKeypadPage":
|
|
6658
|
-
return {
|
|
6659
|
-
...state,
|
|
6660
|
-
animateToPosition: true,
|
|
6661
|
-
// We start at the right-most page.
|
|
6662
|
-
currentPage: getDefaultPage(state.numPages),
|
|
6663
|
-
dx: 0
|
|
6664
|
-
};
|
|
6665
|
-
case "PageKeypadRight":
|
|
6666
|
-
const nextPage = Math.min(state.currentPage + 1, state.numPages - 1);
|
|
6667
|
-
return {
|
|
6668
|
-
...state,
|
|
6669
|
-
animateToPosition: true,
|
|
6670
|
-
currentPage: nextPage,
|
|
6671
|
-
dx: 0
|
|
6672
|
-
};
|
|
6673
|
-
case "PageKeypadLeft":
|
|
6674
|
-
const prevPage = Math.max(state.currentPage - 1, 0);
|
|
6675
|
-
return {
|
|
6676
|
-
...state,
|
|
6677
|
-
animateToPosition: true,
|
|
6678
|
-
currentPage: prevPage,
|
|
6679
|
-
dx: 0
|
|
6680
|
-
};
|
|
6681
6658
|
case "OnSwipeChange":
|
|
6682
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'dx' does not exist on type '{ type: string; }'.
|
|
6683
6659
|
state.velocityTracker.push(action.dx);
|
|
6684
6660
|
return {
|
|
6685
6661
|
...state,
|
|
6686
6662
|
animateToPosition: false,
|
|
6687
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'dx' does not exist on type '{ type: string; }'.
|
|
6688
6663
|
dx: action.dx
|
|
6689
6664
|
};
|
|
6690
6665
|
case "OnSwipeEnd":
|
|
@@ -6692,7 +6667,6 @@ const pagerReducer = function () {
|
|
|
6692
6667
|
pageWidthPx,
|
|
6693
6668
|
velocityTracker
|
|
6694
6669
|
} = state;
|
|
6695
|
-
// @ts-expect-error [FEI-5003] - TS2339 - Property 'dx' does not exist on type '{ type: string; }'.
|
|
6696
6670
|
const {
|
|
6697
6671
|
dx
|
|
6698
6672
|
} = action;
|
|
@@ -6705,13 +6679,21 @@ const pagerReducer = function () {
|
|
|
6705
6679
|
const shouldPageRight = dx < -pageWidthPx / 2 || velocity < -minFlingVelocity && dx < -minFlingDistance;
|
|
6706
6680
|
const shouldPageLeft = dx > pageWidthPx / 2 || velocity > minFlingVelocity && dx > minFlingDistance;
|
|
6707
6681
|
if (shouldPageRight) {
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6682
|
+
const nextPage = Math.min(state.currentPage + 1, state.numPages - 1);
|
|
6683
|
+
return {
|
|
6684
|
+
...state,
|
|
6685
|
+
animateToPosition: true,
|
|
6686
|
+
currentPage: nextPage,
|
|
6687
|
+
dx: 0
|
|
6688
|
+
};
|
|
6711
6689
|
} else if (shouldPageLeft) {
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6690
|
+
const prevPage = Math.max(state.currentPage - 1, 0);
|
|
6691
|
+
return {
|
|
6692
|
+
...state,
|
|
6693
|
+
animateToPosition: true,
|
|
6694
|
+
currentPage: prevPage,
|
|
6695
|
+
dx: 0
|
|
6696
|
+
};
|
|
6715
6697
|
}
|
|
6716
6698
|
return {
|
|
6717
6699
|
...state,
|
|
@@ -6731,30 +6713,16 @@ const createStore = () => {
|
|
|
6731
6713
|
swipeEnabled
|
|
6732
6714
|
}, {
|
|
6733
6715
|
onSwipeChange: dx => {
|
|
6734
|
-
store.dispatch(
|
|
6735
|
-
type: "OnSwipeChange",
|
|
6736
|
-
dx
|
|
6737
|
-
});
|
|
6716
|
+
store.dispatch(onSwipeChange(dx));
|
|
6738
6717
|
},
|
|
6739
6718
|
onSwipeEnd: dx => {
|
|
6740
|
-
store.dispatch(
|
|
6741
|
-
type: "OnSwipeEnd",
|
|
6742
|
-
dx
|
|
6743
|
-
});
|
|
6719
|
+
store.dispatch(onSwipeEnd(dx));
|
|
6744
6720
|
},
|
|
6745
6721
|
onActiveNodesChanged: activeNodes => {
|
|
6746
|
-
store.dispatch(
|
|
6747
|
-
type: "SetActiveNodes",
|
|
6748
|
-
activeNodes
|
|
6749
|
-
});
|
|
6722
|
+
store.dispatch(setActiveNodes(activeNodes));
|
|
6750
6723
|
},
|
|
6751
6724
|
onClick: (key, layoutProps, inPopover) => {
|
|
6752
|
-
store.dispatch(
|
|
6753
|
-
type: "PressKey",
|
|
6754
|
-
key,
|
|
6755
|
-
...layoutProps,
|
|
6756
|
-
inPopover
|
|
6757
|
-
});
|
|
6725
|
+
store.dispatch(pressKey(key, layoutProps.borders, layoutProps.initialBounds, inPopover));
|
|
6758
6726
|
}
|
|
6759
6727
|
}, [], [Keys.BACKSPACE, Keys.UP, Keys.RIGHT, Keys.DOWN, Keys.LEFT]);
|
|
6760
6728
|
};
|
|
@@ -6970,8 +6938,8 @@ class KeypadContainer extends React__namespace.Component {
|
|
|
6970
6938
|
// compact keypad, we need to instruct some of our child views to
|
|
6971
6939
|
// crop themselves. At least we're colocating all the layout
|
|
6972
6940
|
// information in this component, though.
|
|
6973
|
-
roundTopLeft: layoutMode ===
|
|
6974
|
-
roundTopRight: layoutMode ===
|
|
6941
|
+
roundTopLeft: layoutMode === LayoutMode.COMPACT && !navigationPadEnabled,
|
|
6942
|
+
roundTopRight: layoutMode === LayoutMode.COMPACT
|
|
6975
6943
|
};
|
|
6976
6944
|
|
|
6977
6945
|
// Select the appropriate keyboard given the type.
|
|
@@ -6982,9 +6950,9 @@ class KeypadContainer extends React__namespace.Component {
|
|
|
6982
6950
|
// clear what that format would look like exactly. Plus, there aren't
|
|
6983
6951
|
// very many of them. So to keep us moving, we'll just hardcode.
|
|
6984
6952
|
switch (keypadType) {
|
|
6985
|
-
case
|
|
6953
|
+
case KeypadType.FRACTION:
|
|
6986
6954
|
return /*#__PURE__*/React__namespace.createElement(FractionKeypad$1, keypadProps);
|
|
6987
|
-
case
|
|
6955
|
+
case KeypadType.EXPRESSION:
|
|
6988
6956
|
return /*#__PURE__*/React__namespace.createElement(ExpressionKeypad$1, keypadProps);
|
|
6989
6957
|
default:
|
|
6990
6958
|
throw new Error("Invalid keypad type: " + keypadType);
|
|
@@ -7047,7 +7015,7 @@ class KeypadContainer extends React__namespace.Component {
|
|
|
7047
7015
|
};
|
|
7048
7016
|
}
|
|
7049
7017
|
const keypadContainerStyle = [row, centered, fullWidth, styles.keypadContainer, ...(Array.isArray(style) ? style : [style])];
|
|
7050
|
-
const keypadStyle = [row, styles.keypadBorder, layoutMode ===
|
|
7018
|
+
const keypadStyle = [row, styles.keypadBorder, layoutMode === LayoutMode.FULLSCREEN ? styles.fullscreen : styles.compact];
|
|
7051
7019
|
|
|
7052
7020
|
// TODO(charlie): When the keypad is shorter than the width of the
|
|
7053
7021
|
// screen, add a border on its left and right edges, and round out the
|
|
@@ -7065,7 +7033,7 @@ class KeypadContainer extends React__namespace.Component {
|
|
|
7065
7033
|
}
|
|
7066
7034
|
}
|
|
7067
7035
|
}, navigationPadEnabled && /*#__PURE__*/React__namespace.createElement(NavigationPad, {
|
|
7068
|
-
roundTopLeft: layoutMode ===
|
|
7036
|
+
roundTopLeft: layoutMode === LayoutMode.COMPACT,
|
|
7069
7037
|
style: styles.navigationPadContainer
|
|
7070
7038
|
}), /*#__PURE__*/React__namespace.createElement(View, {
|
|
7071
7039
|
style: styles.keypadLayout
|
|
@@ -7151,9 +7119,8 @@ var KeypadContainer$1 = reactRedux.connect(mapStateToProps, mapDispatchToProps,
|
|
|
7151
7119
|
})(KeypadContainer);
|
|
7152
7120
|
|
|
7153
7121
|
class ProvidedKeypad extends React__namespace.Component {
|
|
7154
|
-
constructor() {
|
|
7155
|
-
super(
|
|
7156
|
-
_defineProperty(this, "mounted", void 0);
|
|
7122
|
+
constructor(props) {
|
|
7123
|
+
super(props);
|
|
7157
7124
|
_defineProperty(this, "store", void 0);
|
|
7158
7125
|
_defineProperty(this, "activate", () => {
|
|
7159
7126
|
this.store.dispatch(activateKeypad());
|
|
@@ -7182,16 +7149,8 @@ class ProvidedKeypad extends React__namespace.Component {
|
|
|
7182
7149
|
_defineProperty(this, "getDOMNode", () => {
|
|
7183
7150
|
return ReactDOM__default["default"].findDOMNode(this);
|
|
7184
7151
|
});
|
|
7185
|
-
}
|
|
7186
|
-
UNSAFE_componentWillMount() {
|
|
7187
7152
|
this.store = createStore();
|
|
7188
7153
|
}
|
|
7189
|
-
componentDidMount() {
|
|
7190
|
-
this.mounted = true;
|
|
7191
|
-
}
|
|
7192
|
-
componentWillUnmount() {
|
|
7193
|
-
this.mounted = false;
|
|
7194
|
-
}
|
|
7195
7154
|
render() {
|
|
7196
7155
|
const {
|
|
7197
7156
|
onElementMounted,
|
|
@@ -7221,10 +7180,12 @@ class ProvidedKeypad extends React__namespace.Component {
|
|
|
7221
7180
|
}
|
|
7222
7181
|
}
|
|
7223
7182
|
|
|
7224
|
-
exports.
|
|
7183
|
+
exports.CursorContext = CursorContext;
|
|
7225
7184
|
exports.KeyConfigs = KeyConfigs;
|
|
7185
|
+
exports.KeyType = KeyType;
|
|
7226
7186
|
exports.Keypad = ProvidedKeypad;
|
|
7227
7187
|
exports.KeypadInput = MathInput;
|
|
7228
|
-
exports.
|
|
7188
|
+
exports.KeypadType = KeypadType;
|
|
7189
|
+
exports.Keys = Keys;
|
|
7229
7190
|
exports.keypadElementPropType = keypadElementPropType;
|
|
7230
7191
|
//# sourceMappingURL=index.js.map
|