@khanacademy/math-input 1.0.1 → 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.
Files changed (87) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/components/compute-layout-parameters.d.ts +2 -1
  3. package/dist/components/compute-layout-parameters.js.flow +2 -21
  4. package/dist/components/echo-manager.d.ts +4 -4
  5. package/dist/components/echo-manager.js.flow +4 -4
  6. package/dist/components/expression-keypad.d.ts +1 -1
  7. package/dist/components/expression-keypad.js.flow +1 -1
  8. package/dist/components/fraction-keypad.d.ts +1 -1
  9. package/dist/components/fraction-keypad.js.flow +1 -1
  10. package/dist/components/gesture-state-machine.d.ts +7 -7
  11. package/dist/components/gesture-state-machine.js.flow +8 -8
  12. package/dist/components/icon.d.ts +2 -2
  13. package/dist/components/icon.js.flow +2 -2
  14. package/dist/components/input/cursor-contexts.d.ts +10 -9
  15. package/dist/components/input/cursor-contexts.js.flow +11 -16
  16. package/dist/components/input/math-wrapper.d.ts +3 -2
  17. package/dist/components/input/math-wrapper.js.flow +3 -16
  18. package/dist/components/keypad-button.d.ts +8 -8
  19. package/dist/components/keypad-button.js.flow +10 -9
  20. package/dist/components/keypad-container.d.ts +2 -3
  21. package/dist/components/keypad-container.js.flow +2 -3
  22. package/dist/components/keypad.d.ts +1 -1
  23. package/dist/components/keypad.js.flow +1 -1
  24. package/dist/components/multi-symbol-grid.d.ts +2 -2
  25. package/dist/components/multi-symbol-grid.js.flow +2 -2
  26. package/dist/components/styles.d.ts +1 -2
  27. package/dist/components/styles.js.flow +1 -3
  28. package/dist/components/touchable-keypad-button.d.ts +6 -6
  29. package/dist/components/touchable-keypad-button.js.flow +6 -6
  30. package/dist/data/keys.d.ts +51 -52
  31. package/dist/data/keys.js.flow +50 -99
  32. package/dist/enums.d.ts +49 -0
  33. package/dist/enums.js.flow +63 -0
  34. package/dist/es/index.js +362 -391
  35. package/dist/es/index.js.map +1 -1
  36. package/dist/fake-react-native-web/view.d.ts +1 -2
  37. package/dist/fake-react-native-web/view.js.flow +1 -2
  38. package/dist/index.d.ts +3 -6
  39. package/dist/index.js +379 -406
  40. package/dist/index.js.flow +3 -6
  41. package/dist/index.js.map +1 -1
  42. package/dist/store/actions.d.ts +3 -3
  43. package/dist/store/actions.js.flow +5 -4
  44. package/dist/store/shared.d.ts +2 -1
  45. package/dist/store/shared.js.flow +2 -1
  46. package/dist/store/types.d.ts +4 -5
  47. package/dist/store/types.js.flow +4 -5
  48. package/dist/types.d.ts +15 -16
  49. package/dist/types.js.flow +20 -20
  50. package/package.json +1 -1
  51. package/src/components/compute-layout-parameters.ts +6 -6
  52. package/src/components/echo-manager.tsx +10 -10
  53. package/src/components/expression-keypad.tsx +9 -10
  54. package/src/components/fraction-keypad.tsx +11 -12
  55. package/src/components/gesture-state-machine.ts +8 -8
  56. package/src/components/icon.tsx +6 -6
  57. package/src/components/input/__tests__/context-tracking.test.ts +20 -20
  58. package/src/components/input/cursor-contexts.ts +22 -29
  59. package/src/components/input/math-wrapper.ts +75 -67
  60. package/src/components/keypad-button.tsx +20 -21
  61. package/src/components/keypad-container.tsx +8 -9
  62. package/src/components/many-keypad-button.tsx +2 -2
  63. package/src/components/multi-symbol-grid.tsx +4 -5
  64. package/src/components/multi-symbol-popover.tsx +1 -1
  65. package/src/components/navigation-pad.tsx +1 -1
  66. package/src/components/touchable-keypad-button.tsx +7 -7
  67. package/src/data/key-configs.ts +58 -58
  68. package/src/data/keys.ts +53 -105
  69. package/src/enums.ts +74 -0
  70. package/src/index.ts +3 -9
  71. package/src/math-input.stories.tsx +8 -8
  72. package/src/store/actions.ts +4 -3
  73. package/src/store/echo-reducer.ts +5 -5
  74. package/src/store/index.ts +1 -2
  75. package/src/store/input-reducer.ts +4 -4
  76. package/src/store/layout-reducer.ts +9 -9
  77. package/src/store/pager-reducer.ts +3 -3
  78. package/src/store/shared.ts +4 -4
  79. package/src/store/types.ts +4 -5
  80. package/src/types.ts +20 -20
  81. package/src/utils.ts +3 -3
  82. package/tsconfig-build.tsbuildinfo +1 -0
  83. package/dist/consts.d.ts +0 -51
  84. package/dist/consts.js.flow +0 -66
  85. package/src/consts.ts +0 -91
  86. package/tsconfig.tsbuildinfo +0 -1
  87. /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
- 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]; }
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
- const Keys = {
106
- PLUS: "PLUS",
107
- MINUS: "MINUS",
108
- NEGATIVE: "NEGATIVE",
109
- TIMES: "TIMES",
110
- DIVIDE: "DIVIDE",
111
- DECIMAL: "DECIMAL",
112
- PERIOD: "PERIOD",
113
- PERCENT: "PERCENT",
114
- CDOT: "CDOT",
115
- EQUAL: "EQUAL",
116
- NEQ: "NEQ",
117
- GT: "GT",
118
- LT: "LT",
119
- GEQ: "GEQ",
120
- LEQ: "LEQ",
121
- FRAC_INCLUSIVE: "FRAC_INCLUSIVE",
122
- // mobile native only
123
- FRAC_EXCLUSIVE: "FRAC_EXCLUSIVE",
124
- // mobile native only
125
- FRAC: "FRAC",
126
- EXP: "EXP",
127
- EXP_2: "EXP_2",
128
- EXP_3: "EXP_3",
129
- SQRT: "SQRT",
130
- CUBE_ROOT: "CUBE_ROOT",
131
- RADICAL: "RADICAL",
132
- LEFT_PAREN: "LEFT_PAREN",
133
- RIGHT_PAREN: "RIGHT_PAREN",
134
- LN: "LN",
135
- LOG: "LOG",
136
- LOG_N: "LOG_N",
137
- SIN: "SIN",
138
- COS: "COS",
139
- TAN: "TAN",
140
- // TODO(charlie): Add in additional Greek letters.
141
- PI: "PI",
142
- THETA: "THETA",
143
- UP: "UP",
144
- RIGHT: "RIGHT",
145
- DOWN: "DOWN",
146
- LEFT: "LEFT",
147
- BACKSPACE: "BACKSPACE",
148
- DISMISS: "DISMISS",
149
- JUMP_OUT_PARENTHESES: "JUMP_OUT_PARENTHESES",
150
- JUMP_OUT_EXPONENT: "JUMP_OUT_EXPONENT",
151
- JUMP_OUT_BASE: "JUMP_OUT_BASE",
152
- JUMP_INTO_NUMERATOR: "JUMP_INTO_NUMERATOR",
153
- JUMP_OUT_NUMERATOR: "JUMP_OUT_NUMERATOR",
154
- JUMP_OUT_DENOMINATOR: "JUMP_OUT_DENOMINATOR",
155
- NOOP: "NOOP",
156
- // Multi-functional keys.
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
- // TODO: Retire this in favour of KeypadType (above)
455
- const KeypadTypes = {
456
- FRACTION: "FRACTION",
457
- EXPRESSION: "EXPRESSION"
458
- };
459
- const KeyTypes = {
460
- EMPTY: "EMPTY",
461
- // For numerals, variables, and any other characters that themselves
462
- // compose 'values'.
463
- VALUE: "VALUE",
464
- // For buttons that insert or adjust math in an input.
465
- OPERATOR: "OPERATOR",
466
- // For buttons that move the cursor in an input (including via
467
- // deletion).
468
- INPUT_NAVIGATION: "INPUT_NAVIGATION",
469
- // For buttons that modify the broader keypad state (e.g., by changing
470
- // the visible pane).
471
- KEYPAD_NAVIGATION: "KEYPAD_NAVIGATION",
472
- // For buttons that house multiple buttons and have no action
473
- // themselves.
474
- MANY: "MANY",
475
- // For the echo animation that appears on press.
476
- ECHO: "ECHO"
477
- };
478
- const DeviceOrientations = {
479
- LANDSCAPE: "LANDSCAPE",
480
- PORTRAIT: "PORTRAIT"
481
- };
482
- const DeviceTypes = {
483
- PHONE: "PHONE",
484
- TABLET: "TABLET"
485
- };
486
- const LayoutModes = {
487
- FULLSCREEN: "FULLSCREEN",
488
- COMPACT: "COMPACT"
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: ["LEFT"],
496
- BOTTOM: ["BOTTOM"],
497
- ALL: ["LEFT", "BOTTOM"],
505
+ LEFT: [BorderDirection.LEFT],
506
+ BOTTOM: [BorderDirection.BOTTOM],
507
+ ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
498
508
  NONE: []
499
509
  };
500
- const IconTypes = {
501
- MATH: "MATH",
502
- SVG: "SVG",
503
- TEXT: "TEXT"
504
- };
505
- const DecimalSeparators = {
506
- COMMA: "COMMA",
507
- PERIOD: "PERIOD"
508
- };
509
- const EchoAnimationTypes = {
510
- SLIDE_AND_FADE: "SLIDE_AND_FADE",
511
- FADE_ONLY: "FADE_ONLY",
512
- LONG_FADE_ONLY: "LONG_FADE_ONLY"
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() === "," ? DecimalSeparators.COMMA : DecimalSeparators.PERIOD;
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 === DecimalSeparators.COMMA ? "," : ".";
570
- const WRITE = "write";
571
- const CMD = "cmd";
572
- const KEYSTROKE = "keystroke";
573
- const MQ_END = 0;
574
-
575
- // A mapping from keys that can be pressed on a keypad to the way in which
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) {
@@ -3066,231 +3037,231 @@ class GestureManager {
3066
3037
  const KeyConfigs = {
3067
3038
  // Basic math keys.
3068
3039
  [Keys.PLUS]: {
3069
- type: KeyTypes.OPERATOR,
3040
+ type: KeyType.OPERATOR,
3070
3041
  // I18N: A label for a plus sign.
3071
3042
  ariaLabel: i18n__namespace._("Plus")
3072
3043
  },
3073
3044
  [Keys.MINUS]: {
3074
- type: KeyTypes.OPERATOR,
3045
+ type: KeyType.OPERATOR,
3075
3046
  // I18N: A label for a minus sign.
3076
3047
  ariaLabel: i18n__namespace._("Minus")
3077
3048
  },
3078
3049
  [Keys.NEGATIVE]: {
3079
- type: KeyTypes.VALUE,
3050
+ type: KeyType.VALUE,
3080
3051
  // I18N: A label for a minus sign.
3081
3052
  ariaLabel: i18n__namespace._("Negative")
3082
3053
  },
3083
3054
  [Keys.TIMES]: {
3084
- type: KeyTypes.OPERATOR,
3055
+ type: KeyType.OPERATOR,
3085
3056
  // I18N: A label for a multiplication sign (represented with an 'x').
3086
3057
  ariaLabel: i18n__namespace._("Multiply")
3087
3058
  },
3088
3059
  [Keys.DIVIDE]: {
3089
- type: KeyTypes.OPERATOR,
3060
+ type: KeyType.OPERATOR,
3090
3061
  // I18N: A label for a division sign.
3091
3062
  ariaLabel: i18n__namespace._("Divide")
3092
3063
  },
3093
3064
  [Keys.DECIMAL]: {
3094
- type: KeyTypes.VALUE,
3065
+ type: KeyType.VALUE,
3095
3066
  // I18N: A label for a decimal symbol.
3096
3067
  ariaLabel: i18n__namespace._("Decimal"),
3097
- icon: decimalSeparator === DecimalSeparators.COMMA ? {
3068
+ icon: decimalSeparator === DecimalSeparator.COMMA ? {
3098
3069
  // TODO(charlie): Get an SVG icon for the comma, or verify with
3099
3070
  // design that the text-rendered version is acceptable.
3100
- type: IconTypes.TEXT,
3071
+ type: IconType.TEXT,
3101
3072
  data: ","
3102
3073
  } : {
3103
- type: IconTypes.SVG,
3074
+ type: IconType.SVG,
3104
3075
  data: Keys.PERIOD
3105
3076
  }
3106
3077
  },
3107
3078
  [Keys.PERCENT]: {
3108
- type: KeyTypes.OPERATOR,
3079
+ type: KeyType.OPERATOR,
3109
3080
  // I18N: A label for a percent sign.
3110
3081
  ariaLabel: i18n__namespace._("Percent")
3111
3082
  },
3112
3083
  [Keys.CDOT]: {
3113
- type: KeyTypes.OPERATOR,
3084
+ type: KeyType.OPERATOR,
3114
3085
  // I18N: A label for a multiplication sign (represented as a dot).
3115
3086
  ariaLabel: i18n__namespace._("Multiply")
3116
3087
  },
3117
3088
  [Keys.EQUAL]: {
3118
- type: KeyTypes.OPERATOR,
3089
+ type: KeyType.OPERATOR,
3119
3090
  ariaLabel: i18n__namespace._("Equals sign")
3120
3091
  },
3121
3092
  [Keys.NEQ]: {
3122
- type: KeyTypes.OPERATOR,
3093
+ type: KeyType.OPERATOR,
3123
3094
  ariaLabel: i18n__namespace._("Not-equals sign")
3124
3095
  },
3125
3096
  [Keys.GT]: {
3126
- type: KeyTypes.OPERATOR,
3097
+ type: KeyType.OPERATOR,
3127
3098
  // I18N: A label for a 'greater than' sign (represented as '>').
3128
3099
  ariaLabel: i18n__namespace._("Greater than sign")
3129
3100
  },
3130
3101
  [Keys.LT]: {
3131
- type: KeyTypes.OPERATOR,
3102
+ type: KeyType.OPERATOR,
3132
3103
  // I18N: A label for a 'less than' sign (represented as '<').
3133
3104
  ariaLabel: i18n__namespace._("Less than sign")
3134
3105
  },
3135
3106
  [Keys.GEQ]: {
3136
- type: KeyTypes.OPERATOR,
3107
+ type: KeyType.OPERATOR,
3137
3108
  ariaLabel: i18n__namespace._("Greater than or equal to sign")
3138
3109
  },
3139
3110
  [Keys.LEQ]: {
3140
- type: KeyTypes.OPERATOR,
3111
+ type: KeyType.OPERATOR,
3141
3112
  ariaLabel: i18n__namespace._("Less than or equal to sign")
3142
3113
  },
3143
3114
  // mobile native
3144
3115
  [Keys.FRAC_INCLUSIVE]: {
3145
- type: KeyTypes.OPERATOR,
3116
+ type: KeyType.OPERATOR,
3146
3117
  // I18N: A label for a button that creates a new fraction and puts the
3147
3118
  // current expression in the numerator of that fraction.
3148
3119
  ariaLabel: i18n__namespace._("Fraction, with current expression in numerator")
3149
3120
  },
3150
3121
  // mobile native
3151
3122
  [Keys.FRAC_EXCLUSIVE]: {
3152
- type: KeyTypes.OPERATOR,
3123
+ type: KeyType.OPERATOR,
3153
3124
  // I18N: A label for a button that creates a new fraction next to the
3154
3125
  // cursor.
3155
3126
  ariaLabel: i18n__namespace._("Fraction, excluding the current expression")
3156
3127
  },
3157
3128
  // mobile web
3158
3129
  [Keys.FRAC]: {
3159
- type: KeyTypes.OPERATOR,
3130
+ type: KeyType.OPERATOR,
3160
3131
  // I18N: A label for a button that creates a new fraction next to the
3161
3132
  // cursor.
3162
3133
  ariaLabel: i18n__namespace._("Fraction, excluding the current expression")
3163
3134
  },
3164
3135
  [Keys.EXP]: {
3165
- type: KeyTypes.OPERATOR,
3136
+ type: KeyType.OPERATOR,
3166
3137
  // I18N: A label for a button that will allow the user to input a custom
3167
3138
  // exponent.
3168
3139
  ariaLabel: i18n__namespace._("Custom exponent")
3169
3140
  },
3170
3141
  [Keys.EXP_2]: {
3171
- type: KeyTypes.OPERATOR,
3142
+ type: KeyType.OPERATOR,
3172
3143
  // I18N: A label for a button that will square (take to the second
3173
3144
  // power) some math.
3174
3145
  ariaLabel: i18n__namespace._("Square")
3175
3146
  },
3176
3147
  [Keys.EXP_3]: {
3177
- type: KeyTypes.OPERATOR,
3148
+ type: KeyType.OPERATOR,
3178
3149
  // I18N: A label for a button that will cube (take to the third power)
3179
3150
  // some math.
3180
3151
  ariaLabel: i18n__namespace._("Cube")
3181
3152
  },
3182
3153
  [Keys.SQRT]: {
3183
- type: KeyTypes.OPERATOR,
3154
+ type: KeyType.OPERATOR,
3184
3155
  ariaLabel: i18n__namespace._("Square root")
3185
3156
  },
3186
3157
  [Keys.CUBE_ROOT]: {
3187
- type: KeyTypes.OPERATOR,
3158
+ type: KeyType.OPERATOR,
3188
3159
  ariaLabel: i18n__namespace._("Cube root")
3189
3160
  },
3190
3161
  [Keys.RADICAL]: {
3191
- type: KeyTypes.OPERATOR,
3162
+ type: KeyType.OPERATOR,
3192
3163
  ariaLabel: i18n__namespace._("Radical with custom root")
3193
3164
  },
3194
3165
  [Keys.LEFT_PAREN]: {
3195
- type: KeyTypes.OPERATOR,
3166
+ type: KeyType.OPERATOR,
3196
3167
  ariaLabel: i18n__namespace._("Left parenthesis")
3197
3168
  },
3198
3169
  [Keys.RIGHT_PAREN]: {
3199
- type: KeyTypes.OPERATOR,
3170
+ type: KeyType.OPERATOR,
3200
3171
  ariaLabel: i18n__namespace._("Right parenthesis")
3201
3172
  },
3202
3173
  [Keys.LN]: {
3203
- type: KeyTypes.OPERATOR,
3174
+ type: KeyType.OPERATOR,
3204
3175
  ariaLabel: i18n__namespace._("Natural logarithm")
3205
3176
  },
3206
3177
  [Keys.LOG]: {
3207
- type: KeyTypes.OPERATOR,
3178
+ type: KeyType.OPERATOR,
3208
3179
  ariaLabel: i18n__namespace._("Logarithm with base 10")
3209
3180
  },
3210
3181
  [Keys.LOG_N]: {
3211
- type: KeyTypes.OPERATOR,
3182
+ type: KeyType.OPERATOR,
3212
3183
  ariaLabel: i18n__namespace._("Logarithm with custom base")
3213
3184
  },
3214
3185
  [Keys.SIN]: {
3215
- type: KeyTypes.OPERATOR,
3186
+ type: KeyType.OPERATOR,
3216
3187
  ariaLabel: i18n__namespace._("Sine")
3217
3188
  },
3218
3189
  [Keys.COS]: {
3219
- type: KeyTypes.OPERATOR,
3190
+ type: KeyType.OPERATOR,
3220
3191
  ariaLabel: i18n__namespace._("Cosine")
3221
3192
  },
3222
3193
  [Keys.TAN]: {
3223
- type: KeyTypes.OPERATOR,
3194
+ type: KeyType.OPERATOR,
3224
3195
  ariaLabel: i18n__namespace._("Tangent")
3225
3196
  },
3226
3197
  [Keys.PI]: {
3227
- type: KeyTypes.VALUE,
3198
+ type: KeyType.VALUE,
3228
3199
  ariaLabel: i18n__namespace._("Pi"),
3229
3200
  icon: {
3230
- type: IconTypes.MATH,
3201
+ type: IconType.MATH,
3231
3202
  data: "\\pi"
3232
3203
  }
3233
3204
  },
3234
3205
  [Keys.THETA]: {
3235
- type: KeyTypes.VALUE,
3206
+ type: KeyType.VALUE,
3236
3207
  ariaLabel: i18n__namespace._("Theta"),
3237
3208
  icon: {
3238
- type: IconTypes.MATH,
3209
+ type: IconType.MATH,
3239
3210
  data: "\\theta"
3240
3211
  }
3241
3212
  },
3242
3213
  [Keys.NOOP]: {
3243
- type: KeyTypes.EMPTY
3214
+ type: KeyType.EMPTY
3244
3215
  },
3245
3216
  // Input navigation keys.
3246
3217
  [Keys.UP]: {
3247
- type: KeyTypes.INPUT_NAVIGATION,
3218
+ type: KeyType.INPUT_NAVIGATION,
3248
3219
  ariaLabel: i18n__namespace._("Up arrow")
3249
3220
  },
3250
3221
  [Keys.RIGHT]: {
3251
- type: KeyTypes.INPUT_NAVIGATION,
3222
+ type: KeyType.INPUT_NAVIGATION,
3252
3223
  ariaLabel: i18n__namespace._("Right arrow")
3253
3224
  },
3254
3225
  [Keys.DOWN]: {
3255
- type: KeyTypes.INPUT_NAVIGATION,
3226
+ type: KeyType.INPUT_NAVIGATION,
3256
3227
  ariaLabel: i18n__namespace._("Down arrow")
3257
3228
  },
3258
3229
  [Keys.LEFT]: {
3259
- type: KeyTypes.INPUT_NAVIGATION,
3230
+ type: KeyType.INPUT_NAVIGATION,
3260
3231
  ariaLabel: i18n__namespace._("Left arrow")
3261
3232
  },
3262
3233
  [Keys.JUMP_OUT_PARENTHESES]: {
3263
- type: KeyTypes.INPUT_NAVIGATION,
3234
+ type: KeyType.INPUT_NAVIGATION,
3264
3235
  ariaLabel: i18n__namespace._("Navigate right out of a set of parentheses")
3265
3236
  },
3266
3237
  [Keys.JUMP_OUT_EXPONENT]: {
3267
- type: KeyTypes.INPUT_NAVIGATION,
3238
+ type: KeyType.INPUT_NAVIGATION,
3268
3239
  ariaLabel: i18n__namespace._("Navigate right out of an exponent")
3269
3240
  },
3270
3241
  [Keys.JUMP_OUT_BASE]: {
3271
- type: KeyTypes.INPUT_NAVIGATION,
3242
+ type: KeyType.INPUT_NAVIGATION,
3272
3243
  ariaLabel: i18n__namespace._("Navigate right out of a base")
3273
3244
  },
3274
3245
  [Keys.JUMP_INTO_NUMERATOR]: {
3275
- type: KeyTypes.INPUT_NAVIGATION,
3246
+ type: KeyType.INPUT_NAVIGATION,
3276
3247
  ariaLabel: i18n__namespace._("Navigate right into the numerator of a fraction")
3277
3248
  },
3278
3249
  [Keys.JUMP_OUT_NUMERATOR]: {
3279
- type: KeyTypes.INPUT_NAVIGATION,
3250
+ type: KeyType.INPUT_NAVIGATION,
3280
3251
  ariaLabel: i18n__namespace._("Navigate right out of the numerator and into the denominator")
3281
3252
  },
3282
3253
  [Keys.JUMP_OUT_DENOMINATOR]: {
3283
- type: KeyTypes.INPUT_NAVIGATION,
3254
+ type: KeyType.INPUT_NAVIGATION,
3284
3255
  ariaLabel: i18n__namespace._("Navigate right out of the denominator of a fraction")
3285
3256
  },
3286
3257
  [Keys.BACKSPACE]: {
3287
- type: KeyTypes.INPUT_NAVIGATION,
3258
+ type: KeyType.INPUT_NAVIGATION,
3288
3259
  // I18N: A label for a button that will delete some input.
3289
3260
  ariaLabel: i18n__namespace._("Delete")
3290
3261
  },
3291
3262
  // Keypad navigation keys.
3292
3263
  [Keys.DISMISS]: {
3293
- type: KeyTypes.KEYPAD_NAVIGATION,
3264
+ type: KeyType.KEYPAD_NAVIGATION,
3294
3265
  // I18N: A label for a button that will dismiss/hide a keypad.
3295
3266
  ariaLabel: i18n__namespace._("Dismiss")
3296
3267
  }
@@ -3308,7 +3279,7 @@ KeyConfigs[Keys.FRAC_MULTI] = {
3308
3279
 
3309
3280
  // TODO(charlie): Use the numeral color for the 'Many' key.
3310
3281
  KeyConfigs[Keys.MANY] = {
3311
- type: KeyTypes.MANY
3282
+ type: KeyType.MANY
3312
3283
  // childKeyIds will be configured by the client.
3313
3284
  };
3314
3285
 
@@ -3320,10 +3291,10 @@ for (const num of NUMBERS) {
3320
3291
  // would mean that we'd be using text beyond the variable key).
3321
3292
  const textRepresentation = "".concat(num);
3322
3293
  KeyConfigs["NUM_".concat(num)] = {
3323
- type: KeyTypes.VALUE,
3294
+ type: KeyType.VALUE,
3324
3295
  ariaLabel: textRepresentation,
3325
3296
  icon: {
3326
- type: IconTypes.TEXT,
3297
+ type: IconType.TEXT,
3327
3298
  data: textRepresentation
3328
3299
  }
3329
3300
  };
@@ -3336,10 +3307,10 @@ for (const letter of LETTERS) {
3336
3307
  const upperCaseVariable = letter.toUpperCase();
3337
3308
  for (const textRepresentation of [lowerCaseVariable, upperCaseVariable]) {
3338
3309
  KeyConfigs[textRepresentation] = {
3339
- type: KeyTypes.VALUE,
3310
+ type: KeyType.VALUE,
3340
3311
  ariaLabel: textRepresentation,
3341
3312
  icon: {
3342
- type: IconTypes.MATH,
3313
+ type: IconType.MATH,
3343
3314
  data: textRepresentation
3344
3315
  }
3345
3316
  };
@@ -3350,7 +3321,7 @@ for (const key of Object.keys(KeyConfigs)) {
3350
3321
  id: key,
3351
3322
  // Default to an SVG icon indexed by the key name.
3352
3323
  icon: {
3353
- type: IconTypes.SVG,
3324
+ type: IconType.SVG,
3354
3325
  data: key
3355
3326
  },
3356
3327
  ...KeyConfigs[key]
@@ -3372,12 +3343,12 @@ const echoReducer = function () {
3372
3343
 
3373
3344
  // Add in the echo animation if the user performs a math
3374
3345
  // operation.
3375
- if (keyConfig.type === KeyTypes.VALUE || keyConfig.type === KeyTypes.OPERATOR) {
3346
+ if (keyConfig.type === KeyType.VALUE || keyConfig.type === KeyType.OPERATOR) {
3376
3347
  return {
3377
3348
  ...state,
3378
3349
  echoes: [...state.echoes, {
3379
3350
  animationId: "" + _lastAnimationId++,
3380
- animationType: action.inPopover ? EchoAnimationTypes.LONG_FADE_ONLY : EchoAnimationTypes.FADE_ONLY,
3351
+ animationType: action.inPopover ? EchoAnimationType.LONG_FADE_ONLY : EchoAnimationType.FADE_ONLY,
3381
3352
  borders: action.borders,
3382
3353
  id: keyConfig.id,
3383
3354
  initialBounds: action.initialBounds
@@ -3401,7 +3372,7 @@ const echoReducer = function () {
3401
3372
  const initialInputState = {
3402
3373
  keyHandler: null,
3403
3374
  cursor: {
3404
- context: NONE
3375
+ context: CursorContext.NONE
3405
3376
  }
3406
3377
  };
3407
3378
  const inputReducer = function () {
@@ -3415,7 +3386,7 @@ const inputReducer = function () {
3415
3386
  };
3416
3387
  case "PressKey":
3417
3388
  const keyConfig = KeyConfigs[action.key];
3418
- if (keyConfig.type !== KeyTypes.KEYPAD_NAVIGATION) {
3389
+ if (keyConfig.type !== KeyType.KEYPAD_NAVIGATION) {
3419
3390
  var _state$keyHandler;
3420
3391
  // This is probably an anti-pattern but it works for the
3421
3392
  // case where we don't actually control the state but we
@@ -4646,48 +4617,48 @@ const JumpOutDenominator = () => {
4646
4617
  */
4647
4618
 
4648
4619
  var Iconography = /*#__PURE__*/Object.freeze({
4649
- __proto__: null,
4650
- COS: Cos,
4651
- LOG: Log,
4652
- EQUAL: Equal,
4653
- BACKSPACE: Backspace,
4654
- SQRT: Sqrt,
4655
- EXP: Exp,
4656
- NEQ: Neq,
4657
- GEQ: Geq,
4658
- LN: Ln,
4659
- DISMISS: Dismiss,
4660
- SIN: Sin,
4661
- LT: Lt,
4662
- CUBE_ROOT: CubeRoot,
4663
- PLUS: Plus,
4664
- TAN: Tan,
4665
- LEFT: Left,
4666
- UP: Up,
4667
- DOWN: Down,
4668
- LEFT_PAREN: LeftParen,
4669
- RIGHT_PAREN: RightParen,
4670
- GT: Gt,
4671
- DIVIDE: Divide,
4672
- PERIOD: Period,
4673
- PERCENT: Percent,
4674
- TIMES: Times,
4675
- EXP_3: Exp3,
4676
- EXP_2: Exp2,
4677
- RIGHT: Right,
4678
- CDOT: Cdot,
4679
- LOG_N: LogN,
4680
- LEQ: Leq,
4681
- MINUS: Minus,
4682
- NEGATIVE: Minus,
4683
- RADICAL: Radical,
4684
- FRAC: FracInclusive,
4685
- JUMP_OUT_PARENTHESES: JumpOutParentheses,
4686
- JUMP_OUT_EXPONENT: JumpOutExponent,
4687
- JUMP_OUT_BASE: JumpOutBase,
4688
- JUMP_INTO_NUMERATOR: JumpIntoNumerator,
4689
- JUMP_OUT_NUMERATOR: JumpOutNumerator,
4690
- JUMP_OUT_DENOMINATOR: JumpOutDenominator
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
4691
4662
  });
4692
4663
 
4693
4664
  /**
@@ -4752,12 +4723,12 @@ class Icon extends React__namespace.PureComponent {
4752
4723
  } = this.props;
4753
4724
  const styleWithFocus = [focused ? styles$a.focused : styles$a.unfocused, ...(Array.isArray(style) ? style : [style])];
4754
4725
  switch (icon.type) {
4755
- case IconTypes.MATH:
4726
+ case IconType.MATH:
4756
4727
  return /*#__PURE__*/React__namespace.createElement(MathIcon, {
4757
4728
  math: icon.data,
4758
4729
  style: styleWithFocus
4759
4730
  });
4760
- case IconTypes.SVG:
4731
+ case IconType.SVG:
4761
4732
  // TODO(charlie): Support passing style objects to `SvgIcon`.
4762
4733
  // This will require migrating the individual icons to use
4763
4734
  // `currentColor` and accept a `className` prop, rather than
@@ -4766,7 +4737,7 @@ class Icon extends React__namespace.PureComponent {
4766
4737
  name: icon.data,
4767
4738
  color: focused ? focusedColor : unfocusedColor
4768
4739
  });
4769
- case IconTypes.TEXT:
4740
+ case IconType.TEXT:
4770
4741
  return /*#__PURE__*/React__namespace.createElement(TextIcon, {
4771
4742
  character: icon.data,
4772
4743
  style: styleWithFocus
@@ -4808,7 +4779,7 @@ class MultiSymbolGrid extends React__namespace.Component {
4808
4779
  // Supporting other types of icons is possible but would require
4809
4780
  // some styles coercion and doesn't seem worthwhile right now.
4810
4781
  icons.forEach(icon => {
4811
- if (icon.type !== IconTypes.MATH) {
4782
+ if (icon.type !== IconType.MATH) {
4812
4783
  throw new Error("Received invalid icon: type=".concat(icon.type, ", ") + "data=".concat(icon.data));
4813
4784
  }
4814
4785
  });
@@ -4926,7 +4897,7 @@ class KeypadButton extends React__namespace.PureComponent {
4926
4897
  // object. This method must be called whenever a property that
4927
4898
  // influences the possible outcomes of `this._getFocusStyle` and
4928
4899
  // `this._getButtonStyle` changes (such as `this.buttonSizeStyle`).
4929
- for (const type of Object.keys(KeyTypes)) {
4900
+ for (const type of Object.values(KeyType)) {
4930
4901
  aphrodite.css(View.styles.initial, ...this._getFocusStyle(type));
4931
4902
  for (const borders of Object.values(BorderStyles)) {
4932
4903
  aphrodite.css(View.styles.initial, ...this._getButtonStyle(type, borders));
@@ -4935,7 +4906,7 @@ class KeypadButton extends React__namespace.PureComponent {
4935
4906
  });
4936
4907
  _defineProperty(this, "_getFocusStyle", type => {
4937
4908
  let focusBackgroundStyle;
4938
- if (type === KeyTypes.INPUT_NAVIGATION || type === KeyTypes.KEYPAD_NAVIGATION) {
4909
+ if (type === KeyType.INPUT_NAVIGATION || type === KeyType.KEYPAD_NAVIGATION) {
4939
4910
  focusBackgroundStyle = styles$8.light;
4940
4911
  } else {
4941
4912
  focusBackgroundStyle = styles$8.bright;
@@ -4946,34 +4917,34 @@ class KeypadButton extends React__namespace.PureComponent {
4946
4917
  // Select the appropriate style for the button.
4947
4918
  let backgroundStyle;
4948
4919
  switch (type) {
4949
- case KeyTypes.EMPTY:
4920
+ case KeyType.EMPTY:
4950
4921
  backgroundStyle = styles$8.empty;
4951
4922
  break;
4952
- case KeyTypes.MANY:
4953
- case KeyTypes.VALUE:
4923
+ case KeyType.MANY:
4924
+ case KeyType.VALUE:
4954
4925
  backgroundStyle = styles$8.value;
4955
4926
  break;
4956
- case KeyTypes.OPERATOR:
4927
+ case KeyType.OPERATOR:
4957
4928
  backgroundStyle = styles$8.operator;
4958
4929
  break;
4959
- case KeyTypes.INPUT_NAVIGATION:
4960
- case KeyTypes.KEYPAD_NAVIGATION:
4930
+ case KeyType.INPUT_NAVIGATION:
4931
+ case KeyType.KEYPAD_NAVIGATION:
4961
4932
  backgroundStyle = styles$8.control;
4962
4933
  break;
4963
- case KeyTypes.ECHO:
4934
+ case KeyType.ECHO:
4964
4935
  backgroundStyle = null;
4965
4936
  break;
4966
4937
  }
4967
4938
  const borderStyle = [];
4968
- if (borders.includes(BorderDirections.LEFT)) {
4939
+ if (borders.includes(BorderDirection.LEFT)) {
4969
4940
  // @ts-expect-error TS2345
4970
4941
  borderStyle.push(styles$8.leftBorder);
4971
4942
  }
4972
- if (borders.includes(BorderDirections.BOTTOM)) {
4943
+ if (borders.includes(BorderDirection.BOTTOM)) {
4973
4944
  // @ts-expect-error TS2345
4974
4945
  borderStyle.push(styles$8.bottomBorder);
4975
4946
  }
4976
- return [styles$8.buttonBase, backgroundStyle, ...borderStyle, type === KeyTypes.ECHO && styles$8.echo, this.buttonSizeStyle,
4947
+ return [styles$8.buttonBase, backgroundStyle, ...borderStyle, type === KeyType.ECHO && styles$8.echo, this.buttonSizeStyle,
4977
4948
  // React Native allows you to set the 'style' props on user defined
4978
4949
  // components.
4979
4950
  // See: https://facebook.github.io/react-native/docs/style.html
@@ -5015,7 +4986,7 @@ class KeypadButton extends React__namespace.PureComponent {
5015
4986
 
5016
4987
  // We render in the focus state if the key is focused, or if it's an
5017
4988
  // echo.
5018
- const renderFocused = !disabled && focused || popoverEnabled || type === KeyTypes.ECHO;
4989
+ const renderFocused = !disabled && focused || popoverEnabled || type === KeyType.ECHO;
5019
4990
  const buttonStyle = this._getButtonStyle(type, borders, style);
5020
4991
  const focusStyle = this._getFocusStyle(type);
5021
4992
  const iconWrapperStyle = [styles$8.iconWrapper, disabled ? styles$8.disabled : undefined];
@@ -5031,11 +5002,11 @@ class KeypadButton extends React__namespace.PureComponent {
5031
5002
  const maybeCornerDecal = !renderFocused && !disabled && childKeys && childKeys.length > 0 && /*#__PURE__*/React__namespace.createElement(CornerDecal, {
5032
5003
  style: styles$8.decalInset
5033
5004
  });
5034
- if (type === KeyTypes.EMPTY) {
5005
+ if (type === KeyType.EMPTY) {
5035
5006
  return /*#__PURE__*/React__namespace.createElement(View, _extends({
5036
5007
  style: buttonStyle
5037
5008
  }, eventHandlers));
5038
- } else if (type === KeyTypes.MANY) {
5009
+ } else if (type === KeyType.MANY) {
5039
5010
  // TODO(charlie): Make the long-press interaction accessible. See
5040
5011
  // the TODO in key-configs.js for more.
5041
5012
  const manyButtonA11yMarkup = {
@@ -5269,7 +5240,7 @@ const mapStateToProps$5 = (state, ownProps) => {
5269
5240
 
5270
5241
  // Override with the default child props, if the key is a multi-symbol key
5271
5242
  // (but not a many-symbol key, which operates under different rules).
5272
- const useFirstChildProps = type !== KeyTypes.MANY && childKeys && childKeys.length > 0;
5243
+ const useFirstChildProps = type !== KeyType.MANY && childKeys && childKeys.length > 0;
5273
5244
  return {
5274
5245
  ...rest,
5275
5246
  childKeyIds: childKeyIds,
@@ -5314,7 +5285,7 @@ class ManyKeypadButton extends React__namespace.Component {
5314
5285
  } else {
5315
5286
  const keyConfig = {
5316
5287
  id: Keys.MANY,
5317
- type: KeyTypes.MANY,
5288
+ type: KeyType.MANY,
5318
5289
  childKeyIds: keys
5319
5290
  };
5320
5291
  return /*#__PURE__*/React__namespace.createElement(TouchableKeypadButton$1, _extends({
@@ -5374,7 +5345,7 @@ class Echo extends React__namespace.Component {
5374
5345
  style: containerStyle
5375
5346
  }, /*#__PURE__*/React__namespace.createElement(KeypadButton$1, {
5376
5347
  icon: icon,
5377
- type: KeyTypes.ECHO,
5348
+ type: KeyType.ECHO,
5378
5349
  borders: borders
5379
5350
  }));
5380
5351
  }
@@ -5388,15 +5359,15 @@ class EchoManager extends React__namespace.Component {
5388
5359
  let animationDurationMs;
5389
5360
  let animationTransitionName;
5390
5361
  switch (animationType) {
5391
- case EchoAnimationTypes.SLIDE_AND_FADE:
5362
+ case EchoAnimationType.SLIDE_AND_FADE:
5392
5363
  animationDurationMs = 400;
5393
5364
  animationTransitionName = "echo-slide-and-fade";
5394
5365
  break;
5395
- case EchoAnimationTypes.FADE_ONLY:
5366
+ case EchoAnimationType.FADE_ONLY:
5396
5367
  animationDurationMs = 300;
5397
5368
  animationTransitionName = "echo-fade-only";
5398
5369
  break;
5399
- case EchoAnimationTypes.LONG_FADE_ONLY:
5370
+ case EchoAnimationType.LONG_FADE_ONLY:
5400
5371
  animationDurationMs = 400;
5401
5372
  animationTransitionName = "echo-long-fade-only";
5402
5373
  break;
@@ -5414,7 +5385,7 @@ class EchoManager extends React__namespace.Component {
5414
5385
  echoes,
5415
5386
  onAnimationFinish
5416
5387
  } = this.props;
5417
- return /*#__PURE__*/React__namespace.createElement("span", null, Object.keys(EchoAnimationTypes).map(animationType => {
5388
+ return /*#__PURE__*/React__namespace.createElement("span", null, Object.keys(EchoAnimationType).map(animationType => {
5418
5389
  // Collect the relevant parameters for the animation type, and
5419
5390
  // filter for the appropriate echoes.
5420
5391
  const {
@@ -5945,25 +5916,25 @@ class ExpressionKeypad extends React__namespace.Component {
5945
5916
  let dismissOrJumpOutKey;
5946
5917
  if (dynamicJumpOut) {
5947
5918
  switch (cursorContext) {
5948
- case IN_PARENS:
5919
+ case CursorContext.IN_PARENS:
5949
5920
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
5950
5921
  break;
5951
- case IN_SUPER_SCRIPT:
5922
+ case CursorContext.IN_SUPER_SCRIPT:
5952
5923
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
5953
5924
  break;
5954
- case IN_SUB_SCRIPT:
5925
+ case CursorContext.IN_SUB_SCRIPT:
5955
5926
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
5956
5927
  break;
5957
- case BEFORE_FRACTION:
5928
+ case CursorContext.BEFORE_FRACTION:
5958
5929
  dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
5959
5930
  break;
5960
- case IN_NUMERATOR:
5931
+ case CursorContext.IN_NUMERATOR:
5961
5932
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
5962
5933
  break;
5963
- case IN_DENOMINATOR:
5934
+ case CursorContext.IN_DENOMINATOR:
5964
5935
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
5965
5936
  break;
5966
- case NONE:
5937
+ case CursorContext.NONE:
5967
5938
  default:
5968
5939
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
5969
5940
  break;
@@ -6178,25 +6149,25 @@ class FractionKeypad extends React__namespace.Component {
6178
6149
  let dismissOrJumpOutKey;
6179
6150
  if (dynamicJumpOut) {
6180
6151
  switch (cursorContext) {
6181
- case IN_PARENS:
6152
+ case CursorContext.IN_PARENS:
6182
6153
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
6183
6154
  break;
6184
- case IN_SUPER_SCRIPT:
6155
+ case CursorContext.IN_SUPER_SCRIPT:
6185
6156
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
6186
6157
  break;
6187
- case IN_SUB_SCRIPT:
6158
+ case CursorContext.IN_SUB_SCRIPT:
6188
6159
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
6189
6160
  break;
6190
- case BEFORE_FRACTION:
6161
+ case CursorContext.BEFORE_FRACTION:
6191
6162
  dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
6192
6163
  break;
6193
- case IN_NUMERATOR:
6164
+ case CursorContext.IN_NUMERATOR:
6194
6165
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
6195
6166
  break;
6196
- case IN_DENOMINATOR:
6167
+ case CursorContext.IN_DENOMINATOR:
6197
6168
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
6198
6169
  break;
6199
- case NONE:
6170
+ case CursorContext.NONE:
6200
6171
  default:
6201
6172
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
6202
6173
  break;
@@ -6225,7 +6196,7 @@ class FractionKeypad extends React__namespace.Component {
6225
6196
  // then when the cursor was inside a parenthetical
6226
6197
  // expression in a numerator or denominator, this check
6227
6198
  // would fail.
6228
- cursorContext === IN_NUMERATOR || cursorContext === IN_DENOMINATOR,
6199
+ cursorContext === CursorContext.IN_NUMERATOR || cursorContext === CursorContext.IN_DENOMINATOR,
6229
6200
  style: roundTopRight && roundedTopRight
6230
6201
  })), /*#__PURE__*/React__namespace.createElement(View, {
6231
6202
  style: row$2
@@ -6282,10 +6253,10 @@ var FractionKeypad$1 = reactRedux.connect(mapStateToProps$1, null, null, {
6282
6253
  forwardRef: true
6283
6254
  })(FractionKeypad);
6284
6255
 
6285
- const defaultKeypadType = KeypadTypes.EXPRESSION;
6256
+ const defaultKeypadType = KeypadType.EXPRESSION;
6286
6257
  const keypadForType = {
6287
- [KeypadTypes.FRACTION]: fractionKeypadLayout,
6288
- [KeypadTypes.EXPRESSION]: expressionKeypadLayout
6258
+ [KeypadType.FRACTION]: fractionKeypadLayout,
6259
+ [KeypadType.EXPRESSION]: expressionKeypadLayout
6289
6260
  };
6290
6261
 
6291
6262
  const initialKeypadState = {
@@ -6403,8 +6374,8 @@ const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
6403
6374
 
6404
6375
  // Then, compute the button dimensions based on the provided parameters.
6405
6376
  let buttonDimensions;
6406
- if (deviceType === DeviceTypes.PHONE) {
6407
- const isLandscape = deviceOrientation === DeviceOrientations.LANDSCAPE;
6377
+ if (deviceType === DeviceType.PHONE) {
6378
+ const isLandscape = deviceOrientation === DeviceOrientation.LANDSCAPE;
6408
6379
 
6409
6380
  // In many cases, the browser chrome will already have been factored
6410
6381
  // into `pageHeightPx`. But we have no way of knowing if that's
@@ -6447,7 +6418,7 @@ const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
6447
6418
  widthPx: buttonWidthPx,
6448
6419
  heightPx: buttonHeightPx
6449
6420
  };
6450
- } else if (deviceType === DeviceTypes.TABLET) {
6421
+ } else if (deviceType === DeviceType.TABLET) {
6451
6422
  buttonDimensions = {
6452
6423
  widthPx: maxButtonSize,
6453
6424
  heightPx: maxButtonSize
@@ -6462,7 +6433,7 @@ const computeLayoutParameters = (_ref, _ref2, _ref3, _ref4) => {
6462
6433
  const keypadWidth = effectiveNumColumns * buttonDimensions.widthPx + (navigationPadEnabled ? navigationPadWidthPx : 0) + numSeparators * innerBorderWidthPx;
6463
6434
  return {
6464
6435
  buttonDimensions,
6465
- layoutMode: keypadWidth >= pageWidthPx ? LayoutModes.FULLSCREEN : LayoutModes.COMPACT
6436
+ layoutMode: keypadWidth >= pageWidthPx ? LayoutMode.FULLSCREEN : LayoutMode.COMPACT
6466
6437
  };
6467
6438
  };
6468
6439
 
@@ -6481,7 +6452,7 @@ const initialLayoutState = {
6481
6452
  pageWidthPx: 0,
6482
6453
  pageHeightPx: 0
6483
6454
  },
6484
- layoutMode: LayoutModes.FULLSCREEN,
6455
+ layoutMode: LayoutMode.FULLSCREEN,
6485
6456
  paginationEnabled: false,
6486
6457
  navigationPadEnabled: false
6487
6458
  };
@@ -6497,13 +6468,13 @@ const layoutParametersForDimensions = (pageDimensions, gridDimensions) => {
6497
6468
  } = pageDimensions;
6498
6469
 
6499
6470
  // Determine the device type and orientation.
6500
- const deviceOrientation = pageWidthPx > pageHeightPx ? DeviceOrientations.LANDSCAPE : DeviceOrientations.PORTRAIT;
6501
- const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ? DeviceTypes.TABLET : DeviceTypes.PHONE;
6471
+ const deviceOrientation = pageWidthPx > pageHeightPx ? DeviceOrientation.LANDSCAPE : DeviceOrientation.PORTRAIT;
6472
+ const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ? DeviceType.TABLET : DeviceType.PHONE;
6502
6473
 
6503
6474
  // Using that information, make some decisions (or assumptions)
6504
6475
  // about the resulting layout.
6505
- const navigationPadEnabled = deviceType === DeviceTypes.TABLET;
6506
- const paginationEnabled = deviceType === DeviceTypes.PHONE && deviceOrientation === DeviceOrientations.PORTRAIT;
6476
+ const navigationPadEnabled = deviceType === DeviceType.TABLET;
6477
+ const paginationEnabled = deviceType === DeviceType.PHONE && deviceOrientation === DeviceOrientation.PORTRAIT;
6507
6478
  const deviceInfo = {
6508
6479
  deviceOrientation,
6509
6480
  deviceType
@@ -6674,7 +6645,7 @@ const pagerReducer = function () {
6674
6645
  const keyConfig = KeyConfigs[action.key];
6675
6646
 
6676
6647
  // Reset the keypad page if the user performs a math operation.
6677
- if (keyConfig.type === KeyTypes.VALUE || keyConfig.type === KeyTypes.OPERATOR) {
6648
+ if (keyConfig.type === KeyType.VALUE || keyConfig.type === KeyType.OPERATOR) {
6678
6649
  return {
6679
6650
  ...state,
6680
6651
  animateToPosition: true,
@@ -6967,8 +6938,8 @@ class KeypadContainer extends React__namespace.Component {
6967
6938
  // compact keypad, we need to instruct some of our child views to
6968
6939
  // crop themselves. At least we're colocating all the layout
6969
6940
  // information in this component, though.
6970
- roundTopLeft: layoutMode === LayoutModes.COMPACT && !navigationPadEnabled,
6971
- roundTopRight: layoutMode === LayoutModes.COMPACT
6941
+ roundTopLeft: layoutMode === LayoutMode.COMPACT && !navigationPadEnabled,
6942
+ roundTopRight: layoutMode === LayoutMode.COMPACT
6972
6943
  };
6973
6944
 
6974
6945
  // Select the appropriate keyboard given the type.
@@ -6979,9 +6950,9 @@ class KeypadContainer extends React__namespace.Component {
6979
6950
  // clear what that format would look like exactly. Plus, there aren't
6980
6951
  // very many of them. So to keep us moving, we'll just hardcode.
6981
6952
  switch (keypadType) {
6982
- case KeypadTypes.FRACTION:
6953
+ case KeypadType.FRACTION:
6983
6954
  return /*#__PURE__*/React__namespace.createElement(FractionKeypad$1, keypadProps);
6984
- case KeypadTypes.EXPRESSION:
6955
+ case KeypadType.EXPRESSION:
6985
6956
  return /*#__PURE__*/React__namespace.createElement(ExpressionKeypad$1, keypadProps);
6986
6957
  default:
6987
6958
  throw new Error("Invalid keypad type: " + keypadType);
@@ -7044,7 +7015,7 @@ class KeypadContainer extends React__namespace.Component {
7044
7015
  };
7045
7016
  }
7046
7017
  const keypadContainerStyle = [row, centered, fullWidth, styles.keypadContainer, ...(Array.isArray(style) ? style : [style])];
7047
- const keypadStyle = [row, styles.keypadBorder, layoutMode === LayoutModes.FULLSCREEN ? styles.fullscreen : styles.compact];
7018
+ const keypadStyle = [row, styles.keypadBorder, layoutMode === LayoutMode.FULLSCREEN ? styles.fullscreen : styles.compact];
7048
7019
 
7049
7020
  // TODO(charlie): When the keypad is shorter than the width of the
7050
7021
  // screen, add a border on its left and right edges, and round out the
@@ -7062,7 +7033,7 @@ class KeypadContainer extends React__namespace.Component {
7062
7033
  }
7063
7034
  }
7064
7035
  }, navigationPadEnabled && /*#__PURE__*/React__namespace.createElement(NavigationPad, {
7065
- roundTopLeft: layoutMode === LayoutModes.COMPACT,
7036
+ roundTopLeft: layoutMode === LayoutMode.COMPACT,
7066
7037
  style: styles.navigationPadContainer
7067
7038
  }), /*#__PURE__*/React__namespace.createElement(View, {
7068
7039
  style: styles.keypadLayout
@@ -7209,10 +7180,12 @@ class ProvidedKeypad extends React__namespace.Component {
7209
7180
  }
7210
7181
  }
7211
7182
 
7212
- exports.CursorContexts = cursorContexts;
7183
+ exports.CursorContext = CursorContext;
7213
7184
  exports.KeyConfigs = KeyConfigs;
7185
+ exports.KeyType = KeyType;
7214
7186
  exports.Keypad = ProvidedKeypad;
7215
7187
  exports.KeypadInput = MathInput;
7216
- exports.KeypadTypes = KeypadTypes;
7188
+ exports.KeypadType = KeypadType;
7189
+ exports.Keys = Keys;
7217
7190
  exports.keypadElementPropType = keypadElementPropType;
7218
7191
  //# sourceMappingURL=index.js.map