@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.
Files changed (120) hide show
  1. package/CHANGELOG.md +10 -0
  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/index.d.ts +1 -1
  19. package/dist/components/keypad/index.js.flow +1 -3
  20. package/dist/components/keypad-button.d.ts +8 -8
  21. package/dist/components/keypad-button.js.flow +10 -9
  22. package/dist/components/keypad-container.d.ts +2 -3
  23. package/dist/components/keypad-container.js.flow +2 -3
  24. package/dist/components/keypad.d.ts +1 -1
  25. package/dist/components/keypad.js.flow +1 -1
  26. package/dist/components/multi-symbol-grid.d.ts +2 -2
  27. package/dist/components/multi-symbol-grid.js.flow +2 -2
  28. package/dist/components/node-manager.d.ts +2 -5
  29. package/dist/components/node-manager.js.flow +2 -5
  30. package/dist/components/popover-state-machine.d.ts +1 -8
  31. package/dist/components/popover-state-machine.js.flow +2 -8
  32. package/dist/components/provided-keypad.d.ts +1 -4
  33. package/dist/components/provided-keypad.js.flow +1 -4
  34. package/dist/components/styles.d.ts +1 -2
  35. package/dist/components/styles.js.flow +1 -3
  36. package/dist/components/touchable-keypad-button.d.ts +6 -6
  37. package/dist/components/touchable-keypad-button.js.flow +6 -6
  38. package/dist/data/keys.d.ts +51 -52
  39. package/dist/data/keys.js.flow +50 -99
  40. package/dist/enums.d.ts +49 -0
  41. package/dist/enums.js.flow +63 -0
  42. package/dist/es/index.css +0 -3
  43. package/dist/es/index.js +415 -455
  44. package/dist/es/index.js.map +1 -1
  45. package/dist/fake-react-native-web/view.d.ts +1 -2
  46. package/dist/fake-react-native-web/view.js.flow +1 -2
  47. package/dist/index.css +0 -3
  48. package/dist/index.d.ts +3 -6
  49. package/dist/index.js +438 -477
  50. package/dist/index.js.flow +3 -6
  51. package/dist/index.js.map +1 -1
  52. package/dist/store/actions.d.ts +64 -0
  53. package/dist/store/actions.js.flow +101 -0
  54. package/dist/store/echo-reducer.d.ts +2 -3
  55. package/dist/store/echo-reducer.js.flow +2 -6
  56. package/dist/store/index.d.ts +5 -41
  57. package/dist/store/index.js.flow +5 -52
  58. package/dist/store/input-reducer.d.ts +2 -5
  59. package/dist/store/input-reducer.js.flow +3 -6
  60. package/dist/store/keypad-reducer.d.ts +2 -7
  61. package/dist/store/keypad-reducer.js.flow +3 -8
  62. package/dist/store/layout-reducer.d.ts +2 -19
  63. package/dist/store/layout-reducer.js.flow +3 -20
  64. package/dist/store/pager-reducer.d.ts +2 -11
  65. package/dist/store/pager-reducer.js.flow +3 -12
  66. package/dist/store/shared.d.ts +2 -1
  67. package/dist/store/shared.js.flow +2 -1
  68. package/dist/store/types.d.ts +5 -5
  69. package/dist/store/types.js.flow +5 -5
  70. package/dist/types.d.ts +28 -16
  71. package/dist/types.js.flow +32 -20
  72. package/less/overrides.less +0 -6
  73. package/package.json +1 -1
  74. package/src/components/compute-layout-parameters.ts +6 -6
  75. package/src/components/echo-manager.tsx +10 -10
  76. package/src/components/expression-keypad.tsx +9 -10
  77. package/src/components/fraction-keypad.tsx +11 -12
  78. package/src/components/gesture-state-machine.ts +8 -8
  79. package/src/components/icon.tsx +6 -6
  80. package/src/components/input/__tests__/context-tracking.test.ts +20 -20
  81. package/src/components/input/cursor-contexts.ts +22 -29
  82. package/src/components/input/math-wrapper.ts +75 -67
  83. package/src/components/keypad/index.tsx +1 -1
  84. package/src/components/keypad-button.tsx +20 -21
  85. package/src/components/keypad-container.tsx +9 -10
  86. package/src/components/keypad.tsx +1 -1
  87. package/src/components/many-keypad-button.tsx +2 -2
  88. package/src/components/multi-symbol-grid.tsx +4 -5
  89. package/src/components/multi-symbol-popover.tsx +1 -1
  90. package/src/components/navigation-pad.tsx +1 -1
  91. package/src/components/node-manager.ts +2 -2
  92. package/src/components/popover-state-machine.ts +2 -10
  93. package/src/components/provided-keypad.tsx +3 -12
  94. package/src/components/touchable-keypad-button.tsx +7 -7
  95. package/src/data/key-configs.ts +58 -58
  96. package/src/data/keys.ts +53 -105
  97. package/src/enums.ts +74 -0
  98. package/src/index.ts +3 -9
  99. package/src/math-input.stories.tsx +67 -0
  100. package/src/store/actions.ts +179 -0
  101. package/src/store/echo-reducer.ts +10 -7
  102. package/src/store/index.ts +24 -24
  103. package/src/store/input-reducer.ts +7 -6
  104. package/src/store/keypad-reducer.ts +3 -6
  105. package/src/store/layout-reducer.ts +12 -11
  106. package/src/store/pager-reducer.ts +30 -46
  107. package/src/store/shared.ts +4 -4
  108. package/src/store/types.ts +21 -5
  109. package/src/types.ts +32 -20
  110. package/src/utils.ts +3 -3
  111. package/tsconfig-build.tsbuildinfo +1 -0
  112. package/dist/actions/index.d.ts +0 -31
  113. package/dist/actions/index.js.flow +0 -40
  114. package/dist/consts.d.ts +0 -51
  115. package/dist/consts.js.flow +0 -66
  116. package/src/actions/index.ts +0 -57
  117. package/src/consts.ts +0 -91
  118. package/tsconfig.tsbuildinfo +0 -1
  119. /package/src/components/{gesture-manager.tsx → gesture-manager.ts} +0 -0
  120. /package/{tsconfig.json → tsconfig-build.json} +0 -0
package/dist/es/index.js CHANGED
@@ -16,6 +16,29 @@ import { View as View$1 } from '@khanacademy/wonder-blocks-core';
16
16
  import Clickable from '@khanacademy/wonder-blocks-clickable';
17
17
  import now from 'performance-now';
18
18
 
19
+ /**
20
+ * Enum that defines the various contexts in which a cursor can exist. The
21
+ * active context is determined first by looking at the cursor's siblings (e.g.,
22
+ * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
23
+ * cursor could in theory be nested in multiple contexts, we only care about the
24
+ * immediate context.
25
+ *
26
+ * TODO(charlie): Add a context to represent being inside of a radical. Right
27
+ * now, we show the dismiss button rather than allowing the user to jump out of
28
+ * the radical.
29
+ */
30
+
31
+ let CursorContext = /*#__PURE__*/function (CursorContext) {
32
+ CursorContext["NONE"] = "NONE";
33
+ CursorContext["IN_PARENS"] = "IN_PARENS";
34
+ CursorContext["IN_SUPER_SCRIPT"] = "IN_SUPER_SCRIPT";
35
+ CursorContext["IN_SUB_SCRIPT"] = "IN_SUB_SCRIPT";
36
+ CursorContext["IN_NUMERATOR"] = "IN_NUMERATOR";
37
+ CursorContext["IN_DENOMINATOR"] = "IN_DENOMINATOR";
38
+ CursorContext["BEFORE_FRACTION"] = "BEFORE_FRACTION";
39
+ return CursorContext;
40
+ }({});
41
+
19
42
  function _extends() {
20
43
  _extends = Object.assign || function (target) {
21
44
  for (var i = 1; i < arguments.length; i++) {
@@ -38,69 +61,61 @@ function _extends() {
38
61
  * This file contains constants for keypad buttons that aren't single
39
62
  * alphanumeric characters.
40
63
  */
41
-
42
64
  // TODO(charlie): There's duplication between this file and key-configs.js.
43
65
  // We should clean it up by removing this file and requiring clients to use the
44
66
  // `id` field on the key configurations.
45
- const Keys = {
46
- PLUS: "PLUS",
47
- MINUS: "MINUS",
48
- NEGATIVE: "NEGATIVE",
49
- TIMES: "TIMES",
50
- DIVIDE: "DIVIDE",
51
- DECIMAL: "DECIMAL",
52
- PERIOD: "PERIOD",
53
- PERCENT: "PERCENT",
54
- CDOT: "CDOT",
55
- EQUAL: "EQUAL",
56
- NEQ: "NEQ",
57
- GT: "GT",
58
- LT: "LT",
59
- GEQ: "GEQ",
60
- LEQ: "LEQ",
61
- FRAC_INCLUSIVE: "FRAC_INCLUSIVE",
62
- // mobile native only
63
- FRAC_EXCLUSIVE: "FRAC_EXCLUSIVE",
64
- // mobile native only
65
- FRAC: "FRAC",
66
- EXP: "EXP",
67
- EXP_2: "EXP_2",
68
- EXP_3: "EXP_3",
69
- SQRT: "SQRT",
70
- CUBE_ROOT: "CUBE_ROOT",
71
- RADICAL: "RADICAL",
72
- LEFT_PAREN: "LEFT_PAREN",
73
- RIGHT_PAREN: "RIGHT_PAREN",
74
- LN: "LN",
75
- LOG: "LOG",
76
- LOG_N: "LOG_N",
77
- SIN: "SIN",
78
- COS: "COS",
79
- TAN: "TAN",
80
- // TODO(charlie): Add in additional Greek letters.
81
- PI: "PI",
82
- THETA: "THETA",
83
- UP: "UP",
84
- RIGHT: "RIGHT",
85
- DOWN: "DOWN",
86
- LEFT: "LEFT",
87
- BACKSPACE: "BACKSPACE",
88
- DISMISS: "DISMISS",
89
- JUMP_OUT_PARENTHESES: "JUMP_OUT_PARENTHESES",
90
- JUMP_OUT_EXPONENT: "JUMP_OUT_EXPONENT",
91
- JUMP_OUT_BASE: "JUMP_OUT_BASE",
92
- JUMP_INTO_NUMERATOR: "JUMP_INTO_NUMERATOR",
93
- JUMP_OUT_NUMERATOR: "JUMP_OUT_NUMERATOR",
94
- JUMP_OUT_DENOMINATOR: "JUMP_OUT_DENOMINATOR",
95
- NOOP: "NOOP",
96
- // Multi-functional keys.
97
- FRAC_MULTI: "FRAC_MULTI",
98
- // mobile native only
99
-
100
- // A custom key that captures an arbitrary number of symbols but has no
101
- // 'default' symbol or action.
102
- MANY: "MANY"
103
- };
67
+ var Keys = /*#__PURE__*/function (Keys) {
68
+ Keys["PLUS"] = "PLUS";
69
+ Keys["MINUS"] = "MINUS";
70
+ Keys["NEGATIVE"] = "NEGATIVE";
71
+ Keys["TIMES"] = "TIMES";
72
+ Keys["DIVIDE"] = "DIVIDE";
73
+ Keys["DECIMAL"] = "DECIMAL";
74
+ Keys["PERIOD"] = "PERIOD";
75
+ Keys["PERCENT"] = "PERCENT";
76
+ Keys["CDOT"] = "CDOT";
77
+ Keys["EQUAL"] = "EQUAL";
78
+ Keys["NEQ"] = "NEQ";
79
+ Keys["GT"] = "GT";
80
+ Keys["LT"] = "LT";
81
+ Keys["GEQ"] = "GEQ";
82
+ Keys["LEQ"] = "LEQ";
83
+ Keys["FRAC_INCLUSIVE"] = "FRAC_INCLUSIVE";
84
+ Keys["FRAC_EXCLUSIVE"] = "FRAC_EXCLUSIVE";
85
+ Keys["FRAC"] = "FRAC";
86
+ Keys["EXP"] = "EXP";
87
+ Keys["EXP_2"] = "EXP_2";
88
+ Keys["EXP_3"] = "EXP_3";
89
+ Keys["SQRT"] = "SQRT";
90
+ Keys["CUBE_ROOT"] = "CUBE_ROOT";
91
+ Keys["RADICAL"] = "RADICAL";
92
+ Keys["LEFT_PAREN"] = "LEFT_PAREN";
93
+ Keys["RIGHT_PAREN"] = "RIGHT_PAREN";
94
+ Keys["LN"] = "LN";
95
+ Keys["LOG"] = "LOG";
96
+ Keys["LOG_N"] = "LOG_N";
97
+ Keys["SIN"] = "SIN";
98
+ Keys["COS"] = "COS";
99
+ Keys["TAN"] = "TAN";
100
+ Keys["PI"] = "PI";
101
+ Keys["THETA"] = "THETA";
102
+ Keys["UP"] = "UP";
103
+ Keys["RIGHT"] = "RIGHT";
104
+ Keys["DOWN"] = "DOWN";
105
+ Keys["LEFT"] = "LEFT";
106
+ Keys["BACKSPACE"] = "BACKSPACE";
107
+ Keys["DISMISS"] = "DISMISS";
108
+ Keys["JUMP_OUT_PARENTHESES"] = "JUMP_OUT_PARENTHESES";
109
+ Keys["JUMP_OUT_EXPONENT"] = "JUMP_OUT_EXPONENT";
110
+ Keys["JUMP_OUT_BASE"] = "JUMP_OUT_BASE";
111
+ Keys["JUMP_INTO_NUMERATOR"] = "JUMP_INTO_NUMERATOR";
112
+ Keys["JUMP_OUT_NUMERATOR"] = "JUMP_OUT_NUMERATOR";
113
+ Keys["JUMP_OUT_DENOMINATOR"] = "JUMP_OUT_DENOMINATOR";
114
+ Keys["NOOP"] = "NOOP";
115
+ Keys["FRAC_MULTI"] = "FRAC_MULTI";
116
+ Keys["MANY"] = "MANY";
117
+ return Keys;
118
+ }(Keys || {});
104
119
 
105
120
  class Text extends React.Component {
106
121
  render() {
@@ -390,66 +405,64 @@ class DragListener {
390
405
  * Constants that are shared between multiple files.
391
406
  */
392
407
 
393
- // TODO: Retire this in favour of KeypadType (above)
394
- const KeypadTypes = {
395
- FRACTION: "FRACTION",
396
- EXPRESSION: "EXPRESSION"
397
- };
398
- const KeyTypes = {
399
- EMPTY: "EMPTY",
400
- // For numerals, variables, and any other characters that themselves
401
- // compose 'values'.
402
- VALUE: "VALUE",
403
- // For buttons that insert or adjust math in an input.
404
- OPERATOR: "OPERATOR",
405
- // For buttons that move the cursor in an input (including via
406
- // deletion).
407
- INPUT_NAVIGATION: "INPUT_NAVIGATION",
408
- // For buttons that modify the broader keypad state (e.g., by changing
409
- // the visible pane).
410
- KEYPAD_NAVIGATION: "KEYPAD_NAVIGATION",
411
- // For buttons that house multiple buttons and have no action
412
- // themselves.
413
- MANY: "MANY",
414
- // For the echo animation that appears on press.
415
- ECHO: "ECHO"
416
- };
417
- const DeviceOrientations = {
418
- LANDSCAPE: "LANDSCAPE",
419
- PORTRAIT: "PORTRAIT"
420
- };
421
- const DeviceTypes = {
422
- PHONE: "PHONE",
423
- TABLET: "TABLET"
424
- };
425
- const LayoutModes = {
426
- FULLSCREEN: "FULLSCREEN",
427
- COMPACT: "COMPACT"
428
- };
429
- const BorderDirections = {
430
- LEFT: "LEFT",
431
- BOTTOM: "BOTTOM"
432
- };
408
+ let KeypadType = /*#__PURE__*/function (KeypadType) {
409
+ KeypadType["FRACTION"] = "FRACTION";
410
+ KeypadType["EXPRESSION"] = "EXPRESSION";
411
+ return KeypadType;
412
+ }({});
413
+ let KeyType = /*#__PURE__*/function (KeyType) {
414
+ KeyType["EMPTY"] = "EMPTY";
415
+ KeyType["VALUE"] = "VALUE";
416
+ KeyType["OPERATOR"] = "OPERATOR";
417
+ KeyType["INPUT_NAVIGATION"] = "INPUT_NAVIGATION";
418
+ KeyType["KEYPAD_NAVIGATION"] = "KEYPAD_NAVIGATION";
419
+ KeyType["MANY"] = "MANY";
420
+ KeyType["ECHO"] = "ECHO";
421
+ return KeyType;
422
+ }({});
423
+ let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
424
+ DeviceOrientation["LANDSCAPE"] = "LANDSCAPE";
425
+ DeviceOrientation["PORTRAIT"] = "PORTRAIT";
426
+ return DeviceOrientation;
427
+ }({});
428
+ let DeviceType = /*#__PURE__*/function (DeviceType) {
429
+ DeviceType["PHONE"] = "PHONE";
430
+ DeviceType["TABLET"] = "TABLET";
431
+ return DeviceType;
432
+ }({});
433
+ let LayoutMode = /*#__PURE__*/function (LayoutMode) {
434
+ LayoutMode["FULLSCREEN"] = "FULLSCREEN";
435
+ LayoutMode["COMPACT"] = "COMPACT";
436
+ return LayoutMode;
437
+ }({});
438
+ let BorderDirection = /*#__PURE__*/function (BorderDirection) {
439
+ BorderDirection["LEFT"] = "LEFT";
440
+ BorderDirection["BOTTOM"] = "BOTTOM";
441
+ return BorderDirection;
442
+ }({});
433
443
  const BorderStyles = {
434
- LEFT: ["LEFT"],
435
- BOTTOM: ["BOTTOM"],
436
- ALL: ["LEFT", "BOTTOM"],
444
+ LEFT: [BorderDirection.LEFT],
445
+ BOTTOM: [BorderDirection.BOTTOM],
446
+ ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
437
447
  NONE: []
438
448
  };
439
- const IconTypes = {
440
- MATH: "MATH",
441
- SVG: "SVG",
442
- TEXT: "TEXT"
443
- };
444
- const DecimalSeparators = {
445
- COMMA: "COMMA",
446
- PERIOD: "PERIOD"
447
- };
448
- const EchoAnimationTypes = {
449
- SLIDE_AND_FADE: "SLIDE_AND_FADE",
450
- FADE_ONLY: "FADE_ONLY",
451
- LONG_FADE_ONLY: "LONG_FADE_ONLY"
452
- };
449
+ let IconType = /*#__PURE__*/function (IconType) {
450
+ IconType["MATH"] = "MATH";
451
+ IconType["SVG"] = "SVG";
452
+ IconType["TEXT"] = "TEXT";
453
+ return IconType;
454
+ }({});
455
+ let DecimalSeparator = /*#__PURE__*/function (DecimalSeparator) {
456
+ DecimalSeparator["COMMA"] = "COMMA";
457
+ DecimalSeparator["PERIOD"] = "PERIOD";
458
+ return DecimalSeparator;
459
+ }({});
460
+ let EchoAnimationType = /*#__PURE__*/function (EchoAnimationType) {
461
+ EchoAnimationType["SLIDE_AND_FADE"] = "SLIDE_AND_FADE";
462
+ EchoAnimationType["FADE_ONLY"] = "FADE_ONLY";
463
+ EchoAnimationType["LONG_FADE_ONLY"] = "LONG_FADE_ONLY";
464
+ return EchoAnimationType;
465
+ }({});
453
466
 
454
467
  // NOTES(kevinb):
455
468
  // - In order to get the correct decimal separator for the current locale,
@@ -457,50 +470,7 @@ const EchoAnimationTypes = {
457
470
  // imported from wonder-blocks-i18n.
458
471
  // - Some languages/locales use different decimal separators than the ones
459
472
  // listed here. Much of the Arab world uses U+066C.
460
- const decimalSeparator = getDecimalSeparator() === "," ? DecimalSeparators.COMMA : DecimalSeparators.PERIOD;
461
-
462
- /**
463
- * Constants that define the various contexts in which a cursor can exist. The
464
- * active context is determined first by looking at the cursor's siblings (e.g.,
465
- * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
466
- * cursor could in theory be nested in multiple contexts, we only care about the
467
- * immediate context.
468
- *
469
- * TODO(charlie): Add a context to represent being inside of a radical. Right
470
- * now, we show the dismiss button rather than allowing the user to jump out of
471
- * the radical.
472
- */
473
-
474
- // TODO: Get rid of these constants in favour of CursorContext type.
475
-
476
- // The cursor is not in any of the other viable contexts.
477
- const NONE = "NONE";
478
- // The cursor is within a set of parentheses.
479
- const IN_PARENS = "IN_PARENS";
480
- // The cursor is within a superscript (e.g., an exponent).
481
- const IN_SUPER_SCRIPT = "IN_SUPER_SCRIPT";
482
- // The cursor is within a subscript (e.g., the base of a custom logarithm).
483
- const IN_SUB_SCRIPT = "IN_SUB_SCRIPT";
484
- // The cursor is in the numerator of a fraction.
485
- const IN_NUMERATOR = "IN_NUMERATOR";
486
- // The cursor is in the denominator of a fraction.
487
- const IN_DENOMINATOR = "IN_DENOMINATOR";
488
- // The cursor is sitting before a fraction; that is, the cursor is within
489
- // what looks to be a mixed number preceding a fraction. This will only be
490
- // the case when the only math between the cursor and the fraction to its
491
- // write is non-leaf math (numbers and variables).
492
- const BEFORE_FRACTION = "BEFORE_FRACTION";
493
-
494
- var cursorContexts = /*#__PURE__*/Object.freeze({
495
- __proto__: null,
496
- NONE: NONE,
497
- IN_PARENS: IN_PARENS,
498
- IN_SUPER_SCRIPT: IN_SUPER_SCRIPT,
499
- IN_SUB_SCRIPT: IN_SUB_SCRIPT,
500
- IN_NUMERATOR: IN_NUMERATOR,
501
- IN_DENOMINATOR: IN_DENOMINATOR,
502
- BEFORE_FRACTION: BEFORE_FRACTION
503
- });
473
+ const decimalSeparator = getDecimalSeparator() === "," ? DecimalSeparator.COMMA : DecimalSeparator.PERIOD;
504
474
 
505
475
  /**
506
476
  * This file contains a wrapper around MathQuill so that we can provide a
@@ -511,110 +481,111 @@ var cursorContexts = /*#__PURE__*/Object.freeze({
511
481
  // Keeping `window` in place for test suite and GitHub Pages.
512
482
  // If it does not exist, fall back to CommonJS require. - jsatk
513
483
 
514
- const decimalSymbol = decimalSeparator === DecimalSeparators.COMMA ? "," : ".";
515
- const WRITE = "write";
516
- const CMD = "cmd";
517
- const KEYSTROKE = "keystroke";
518
- const MQ_END = 0;
519
-
520
- // A mapping from keys that can be pressed on a keypad to the way in which
484
+ const decimalSymbol = decimalSeparator === DecimalSeparator.COMMA ? "," : ".";
485
+ var ActionType = /*#__PURE__*/function (ActionType) {
486
+ ActionType["WRITE"] = "write";
487
+ ActionType["CMD"] = "cmd";
488
+ ActionType["KEYSTROKE"] = "keystroke";
489
+ ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
490
+ return ActionType;
491
+ }(ActionType || {}); // A mapping from keys that can be pressed on a keypad to the way in which
521
492
  // MathQuill should modify its input in response to that key-press. Any keys
522
493
  // that do not provide explicit actions (like the numeral keys) will merely
523
494
  // write their contents to MathQuill.
524
495
  const KeyActions = {
525
496
  [Keys.PLUS]: {
526
497
  str: "+",
527
- fn: WRITE
498
+ fn: ActionType.WRITE
528
499
  },
529
500
  [Keys.MINUS]: {
530
501
  str: "-",
531
- fn: WRITE
502
+ fn: ActionType.WRITE
532
503
  },
533
504
  [Keys.NEGATIVE]: {
534
505
  str: "-",
535
- fn: WRITE
506
+ fn: ActionType.WRITE
536
507
  },
537
508
  [Keys.TIMES]: {
538
509
  str: "\\times",
539
- fn: WRITE
510
+ fn: ActionType.WRITE
540
511
  },
541
512
  [Keys.DIVIDE]: {
542
513
  str: "\\div",
543
- fn: WRITE
514
+ fn: ActionType.WRITE
544
515
  },
545
516
  [Keys.DECIMAL]: {
546
517
  str: decimalSymbol,
547
- fn: WRITE
518
+ fn: ActionType.WRITE
548
519
  },
549
520
  [Keys.EQUAL]: {
550
521
  str: "=",
551
- fn: WRITE
522
+ fn: ActionType.WRITE
552
523
  },
553
524
  [Keys.NEQ]: {
554
525
  str: "\\neq",
555
- fn: WRITE
526
+ fn: ActionType.WRITE
556
527
  },
557
528
  [Keys.CDOT]: {
558
529
  str: "\\cdot",
559
- fn: WRITE
530
+ fn: ActionType.WRITE
560
531
  },
561
532
  [Keys.PERCENT]: {
562
533
  str: "%",
563
- fn: WRITE
534
+ fn: ActionType.WRITE
564
535
  },
565
536
  [Keys.LEFT_PAREN]: {
566
537
  str: "(",
567
- fn: CMD
538
+ fn: ActionType.CMD
568
539
  },
569
540
  [Keys.RIGHT_PAREN]: {
570
541
  str: ")",
571
- fn: CMD
542
+ fn: ActionType.CMD
572
543
  },
573
544
  [Keys.SQRT]: {
574
545
  str: "sqrt",
575
- fn: CMD
546
+ fn: ActionType.CMD
576
547
  },
577
548
  [Keys.PI]: {
578
549
  str: "pi",
579
- fn: CMD
550
+ fn: ActionType.CMD
580
551
  },
581
552
  [Keys.THETA]: {
582
553
  str: "theta",
583
- fn: CMD
554
+ fn: ActionType.CMD
584
555
  },
585
556
  [Keys.RADICAL]: {
586
557
  str: "nthroot",
587
- fn: CMD
558
+ fn: ActionType.CMD
588
559
  },
589
560
  [Keys.LT]: {
590
561
  str: "<",
591
- fn: WRITE
562
+ fn: ActionType.WRITE
592
563
  },
593
564
  [Keys.LEQ]: {
594
565
  str: "\\leq",
595
- fn: WRITE
566
+ fn: ActionType.WRITE
596
567
  },
597
568
  [Keys.GT]: {
598
569
  str: ">",
599
- fn: WRITE
570
+ fn: ActionType.WRITE
600
571
  },
601
572
  [Keys.GEQ]: {
602
573
  str: "\\geq",
603
- fn: WRITE
574
+ fn: ActionType.WRITE
604
575
  },
605
576
  [Keys.UP]: {
606
577
  str: "Up",
607
- fn: KEYSTROKE
578
+ fn: ActionType.KEYSTROKE
608
579
  },
609
580
  [Keys.DOWN]: {
610
581
  str: "Down",
611
- fn: KEYSTROKE
582
+ fn: ActionType.KEYSTROKE
612
583
  },
613
584
  // The `FRAC_EXCLUSIVE` variant is handled manually, since we may need to do
614
585
  // some additional navigation depending on the cursor position.
615
586
  [Keys.FRAC_INCLUSIVE]: {
616
587
  str: "/",
617
- fn: CMD
588
+ fn: ActionType.CMD
618
589
  }
619
590
  };
620
591
  const NormalCommands = {
@@ -634,12 +605,12 @@ const Letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"
634
605
  // leaf nodes.
635
606
  const ValidLeaves = [...Numerals, ...GreekLetters, ...Letters.map(letter => letter.toLowerCase()), ...Letters.map(letter => letter.toUpperCase())];
636
607
  const KeysForJumpContext = {
637
- [IN_PARENS]: Keys.JUMP_OUT_PARENTHESES,
638
- [IN_SUPER_SCRIPT]: Keys.JUMP_OUT_EXPONENT,
639
- [IN_SUB_SCRIPT]: Keys.JUMP_OUT_BASE,
640
- [BEFORE_FRACTION]: Keys.JUMP_INTO_NUMERATOR,
641
- [IN_NUMERATOR]: Keys.JUMP_OUT_NUMERATOR,
642
- [IN_DENOMINATOR]: Keys.JUMP_OUT_DENOMINATOR
608
+ [CursorContext.IN_PARENS]: Keys.JUMP_OUT_PARENTHESES,
609
+ [CursorContext.IN_SUPER_SCRIPT]: Keys.JUMP_OUT_EXPONENT,
610
+ [CursorContext.IN_SUB_SCRIPT]: Keys.JUMP_OUT_BASE,
611
+ [CursorContext.BEFORE_FRACTION]: Keys.JUMP_INTO_NUMERATOR,
612
+ [CursorContext.IN_NUMERATOR]: Keys.JUMP_OUT_NUMERATOR,
613
+ [CursorContext.IN_DENOMINATOR]: Keys.JUMP_OUT_DENOMINATOR
643
614
  };
644
615
  class MathWrapper {
645
616
  // MathQuill interface
@@ -702,14 +673,14 @@ class MathWrapper {
702
673
  } else if (key === Keys.FRAC_EXCLUSIVE) {
703
674
  // If there's nothing to the left of the cursor, then we want to
704
675
  // leave the cursor to the left of the fraction after creating it.
705
- const shouldNavigateLeft = cursor[this.MQ.L] === MQ_END;
676
+ const shouldNavigateLeft = cursor[this.MQ.L] === ActionType.MQ_END;
706
677
  this.mathField.cmd("\\frac");
707
678
  if (shouldNavigateLeft) {
708
679
  this.mathField.keystroke("Left");
709
680
  }
710
681
  } else if (key === Keys.FRAC) {
711
682
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
712
- cursor[this.MQ.L] === MQ_END;
683
+ cursor[this.MQ.L] === ActionType.MQ_END;
713
684
  this.mathField.cmd("\\frac");
714
685
  } else if (key === Keys.LOG_N) {
715
686
  this.mathField.write("log_{ }\\left(\\right)");
@@ -730,9 +701,9 @@ class MathWrapper {
730
701
  } else if (key === Keys.RIGHT) {
731
702
  this._handleRightArrow(cursor);
732
703
  } else if (/^[a-zA-Z]$/.test(key)) {
733
- this.mathField[WRITE](key);
704
+ this.mathField[ActionType.WRITE](key);
734
705
  } else if (/^NUM_\d/.test(key)) {
735
- this.mathField[WRITE](key[4]);
706
+ this.mathField[ActionType.WRITE](key[4]);
736
707
  }
737
708
  if (!cursor.selection) {
738
709
  // don't show the cursor for selections
@@ -826,7 +797,7 @@ class MathWrapper {
826
797
  // when upgrading MathQuill.
827
798
 
828
799
  _handleBackspaceInNthRoot(cursor) {
829
- const isAtLeftEnd = cursor[this.MQ.L] === MQ_END;
800
+ const isAtLeftEnd = cursor[this.MQ.L] === ActionType.MQ_END;
830
801
  const isRootEmpty = this._isInsideEmptyNode(cursor.parent.parent.blocks[0].ends);
831
802
  if (isAtLeftEnd) {
832
803
  this._selectNode(cursor.parent.parent, cursor);
@@ -857,16 +828,16 @@ class MathWrapper {
857
828
  return;
858
829
  }
859
830
  switch (context) {
860
- case IN_PARENS:
831
+ case CursorContext.IN_PARENS:
861
832
  // Insert at the end of the parentheses, and then navigate right
862
833
  // once more to get 'beyond' the parentheses.
863
834
  cursor.insRightOf(cursor.parent.parent);
864
835
  break;
865
- case BEFORE_FRACTION:
836
+ case CursorContext.BEFORE_FRACTION:
866
837
  // Find the nearest fraction to the right of the cursor.
867
838
  let fractionNode;
868
839
  let visitor = cursor;
869
- while (visitor[this.MQ.R] !== MQ_END) {
840
+ while (visitor[this.MQ.R] !== ActionType.MQ_END) {
870
841
  if (this._isFraction(visitor[this.MQ.R])) {
871
842
  fractionNode = visitor[this.MQ.R];
872
843
  }
@@ -877,7 +848,7 @@ class MathWrapper {
877
848
  cursor.insLeftOf(fractionNode);
878
849
  this.mathField.keystroke("Right");
879
850
  break;
880
- case IN_NUMERATOR:
851
+ case CursorContext.IN_NUMERATOR:
881
852
  // HACK(charlie): I can't find a better way to do this. The goal
882
853
  // is to place the cursor at the start of the matching
883
854
  // denominator. So, we identify the appropriate node, and
@@ -889,10 +860,10 @@ class MathWrapper {
889
860
  this.mathField.keystroke("Right");
890
861
  }
891
862
  break;
892
- case IN_DENOMINATOR:
863
+ case CursorContext.IN_DENOMINATOR:
893
864
  cursor.insRightOf(cursor.parent.parent);
894
865
  break;
895
- case IN_SUB_SCRIPT:
866
+ case CursorContext.IN_SUB_SCRIPT:
896
867
  // Insert just beyond the superscript.
897
868
  cursor.insRightOf(cursor.parent.parent);
898
869
 
@@ -903,7 +874,7 @@ class MathWrapper {
903
874
  this.mathField.keystroke("Right");
904
875
  }
905
876
  break;
906
- case IN_SUPER_SCRIPT:
877
+ case CursorContext.IN_SUPER_SCRIPT:
907
878
  // Insert just beyond the superscript.
908
879
  cursor.insRightOf(cursor.parent.parent);
909
880
  break;
@@ -940,7 +911,7 @@ class MathWrapper {
940
911
  this._handleBackspaceInLogIndex(cursor);
941
912
  } else if (leftNode.ctrlSeq === "\\ge " || leftNode.ctrlSeq === "\\le ") {
942
913
  this._handleBackspaceAfterLigaturedSymbol(cursor);
943
- } else if (this._isNthRoot(grandparent) && leftNode === MQ_END) {
914
+ } else if (this._isNthRoot(grandparent) && leftNode === ActionType.MQ_END) {
944
915
  this._handleBackspaceInNthRoot(cursor);
945
916
  } else {
946
917
  this.mathField.keystroke("Backspace");
@@ -957,10 +928,10 @@ class MathWrapper {
957
928
  // the entire expression, rather than between the `s` and the left
958
929
  // parenthesis.
959
930
  // From the cursor's perspective, this requires that our left node is
960
- // the MQ_END node, that our grandparent is the left parenthesis, and
931
+ // the ActionType.MQ_END node, that our grandparent is the left parenthesis, and
961
932
  // the nodes to the left of our grandparent comprise a valid function
962
933
  // name.
963
- if (cursor[this.MQ.L] === MQ_END) {
934
+ if (cursor[this.MQ.L] === ActionType.MQ_END) {
964
935
  const parent = cursor.parent;
965
936
  const grandparent = parent.parent;
966
937
  if (grandparent.ctrlSeq === "\\left(") {
@@ -995,7 +966,7 @@ class MathWrapper {
995
966
  // parentheses and apply the exponent to that.
996
967
  const invalidPrefixes = [...ArithmeticOperators, ...EqualityOperators];
997
968
  const precedingNode = cursor[this.MQ.L];
998
- const shouldPrefixWithParens = precedingNode === MQ_END || invalidPrefixes.includes(precedingNode.ctrlSeq.trim());
969
+ const shouldPrefixWithParens = precedingNode === ActionType.MQ_END || invalidPrefixes.includes(precedingNode.ctrlSeq.trim());
999
970
  if (shouldPrefixWithParens) {
1000
971
  this.mathField.write("\\left(\\right)");
1001
972
  }
@@ -1180,7 +1151,7 @@ class MathWrapper {
1180
1151
  return false;
1181
1152
  }
1182
1153
  _isInsideEmptyNode(cursor) {
1183
- return cursor[this.MQ.L] === MQ_END && cursor[this.MQ.R] === MQ_END;
1154
+ return cursor[this.MQ.L] === ActionType.MQ_END && cursor[this.MQ.R] === ActionType.MQ_END;
1184
1155
  }
1185
1156
  _handleBackspaceInRootIndex(cursor) {
1186
1157
  if (this._isInsideEmptyNode(cursor)) {
@@ -1208,14 +1179,14 @@ class MathWrapper {
1208
1179
  this.mathField.write(latex.replace(/^\\sqrt\[\]/, "\\sqrt"));
1209
1180
 
1210
1181
  // Adjust the cursor to be to the left the sqrt.
1211
- if (reinsertionPoint === MQ_END) {
1182
+ if (reinsertionPoint === ActionType.MQ_END) {
1212
1183
  this.mathField.moveToDirEnd(this.MQ.L);
1213
1184
  } else {
1214
1185
  cursor.insRightOf(reinsertionPoint);
1215
1186
  }
1216
1187
  }
1217
1188
  } else {
1218
- if (cursor[this.MQ.L] !== MQ_END) {
1189
+ if (cursor[this.MQ.L] !== ActionType.MQ_END) {
1219
1190
  // If the cursor is not at the leftmost position inside the
1220
1191
  // root's index, delete a character.
1221
1192
  this.mathField.keystroke("Backspace");
@@ -1228,7 +1199,7 @@ class MathWrapper {
1228
1199
  const command = this._maybeFindCommandBeforeParens(grandparent);
1229
1200
  cursor.insLeftOf(command == null ? void 0 : command.startNode);
1230
1201
  cursor.startSelection();
1231
- if (grandparent[this.MQ.R] !== MQ_END) {
1202
+ if (grandparent[this.MQ.R] !== ActionType.MQ_END) {
1232
1203
  cursor.insRightOf(grandparent[this.MQ.R]);
1233
1204
  } else {
1234
1205
  cursor.insRightOf(grandparent);
@@ -1262,7 +1233,7 @@ class MathWrapper {
1262
1233
  // the parens.
1263
1234
  cursor.insLeftOf(command.startNode);
1264
1235
  cursor.startSelection();
1265
- if (rightNode === MQ_END) {
1236
+ if (rightNode === ActionType.MQ_END) {
1266
1237
  cursor.insAtRightEnd(cursor.parent);
1267
1238
  } else {
1268
1239
  cursor.insLeftOf(rightNode);
@@ -1301,7 +1272,7 @@ class MathWrapper {
1301
1272
  // - \log(|x+1) => |\log(x+1)|
1302
1273
  // - \log(|) => |
1303
1274
 
1304
- if (cursor[this.MQ.L] !== MQ_END) {
1275
+ if (cursor[this.MQ.L] !== ActionType.MQ_END) {
1305
1276
  // This command contains math and there's some math to
1306
1277
  // the left of the cursor that we should delete normally
1307
1278
  // before doing anything special.
@@ -1350,9 +1321,9 @@ class MathWrapper {
1350
1321
  contextForCursor(cursor) {
1351
1322
  // First, try to find any fraction to the right, unimpeded.
1352
1323
  let visitor = cursor;
1353
- while (visitor[this.MQ.R] !== MQ_END) {
1324
+ while (visitor[this.MQ.R] !== ActionType.MQ_END) {
1354
1325
  if (this._isFraction(visitor[this.MQ.R])) {
1355
- return BEFORE_FRACTION;
1326
+ return CursorContext.BEFORE_FRACTION;
1356
1327
  } else if (!this._isLeaf(visitor[this.MQ.R])) {
1357
1328
  break;
1358
1329
  }
@@ -1362,17 +1333,17 @@ class MathWrapper {
1362
1333
  // If that didn't work, check if the parent or grandparent is a special
1363
1334
  // context, so that we can jump outwards.
1364
1335
  if (this._isParens(cursor.parent && cursor.parent.parent)) {
1365
- return IN_PARENS;
1336
+ return CursorContext.IN_PARENS;
1366
1337
  } else if (this._isNumerator(cursor.parent)) {
1367
- return IN_NUMERATOR;
1338
+ return CursorContext.IN_NUMERATOR;
1368
1339
  } else if (this._isDenominator(cursor.parent)) {
1369
- return IN_DENOMINATOR;
1340
+ return CursorContext.IN_DENOMINATOR;
1370
1341
  } else if (this._isSubScript(cursor.parent)) {
1371
- return IN_SUB_SCRIPT;
1342
+ return CursorContext.IN_SUB_SCRIPT;
1372
1343
  } else if (this._isSuperScript(cursor.parent)) {
1373
- return IN_SUPER_SCRIPT;
1344
+ return CursorContext.IN_SUPER_SCRIPT;
1374
1345
  } else {
1375
- return NONE;
1346
+ return CursorContext.NONE;
1376
1347
  }
1377
1348
  }
1378
1349
  _isAtTopLevel(cursor) {
@@ -2165,6 +2136,7 @@ const activateKeypad = () => {
2165
2136
  /**
2166
2137
  * Configure the keypad with the provided configuration parameters.
2167
2138
  */
2139
+
2168
2140
  const configureKeypad = configuration => {
2169
2141
  return {
2170
2142
  type: "ConfigureKeypad",
@@ -2186,6 +2158,7 @@ const removeEcho = animationId => {
2186
2158
  };
2187
2159
 
2188
2160
  // Input-related actions.
2161
+
2189
2162
  const setKeyHandler = keyHandler => {
2190
2163
  return {
2191
2164
  type: "SetKeyHandler",
@@ -2199,6 +2172,36 @@ const setCursor = cursor => {
2199
2172
  };
2200
2173
  };
2201
2174
 
2175
+ // Gesture actions
2176
+
2177
+ const onSwipeChange = dx => {
2178
+ return {
2179
+ type: "OnSwipeChange",
2180
+ dx
2181
+ };
2182
+ };
2183
+ const onSwipeEnd = dx => {
2184
+ return {
2185
+ type: "OnSwipeEnd",
2186
+ dx
2187
+ };
2188
+ };
2189
+ const setActiveNodes = activeNodes => {
2190
+ return {
2191
+ type: "SetActiveNodes",
2192
+ activeNodes
2193
+ };
2194
+ };
2195
+ const pressKey = (key, borders, initialBounds, inPopover) => {
2196
+ return {
2197
+ type: "PressKey",
2198
+ key,
2199
+ borders,
2200
+ initialBounds,
2201
+ inPopover
2202
+ };
2203
+ };
2204
+
2202
2205
  function _objectWithoutPropertiesLoose(source, excluded) {
2203
2206
  if (source == null) return {};
2204
2207
  var target = {};
@@ -2978,231 +2981,231 @@ class GestureManager {
2978
2981
  const KeyConfigs = {
2979
2982
  // Basic math keys.
2980
2983
  [Keys.PLUS]: {
2981
- type: KeyTypes.OPERATOR,
2984
+ type: KeyType.OPERATOR,
2982
2985
  // I18N: A label for a plus sign.
2983
2986
  ariaLabel: i18n._("Plus")
2984
2987
  },
2985
2988
  [Keys.MINUS]: {
2986
- type: KeyTypes.OPERATOR,
2989
+ type: KeyType.OPERATOR,
2987
2990
  // I18N: A label for a minus sign.
2988
2991
  ariaLabel: i18n._("Minus")
2989
2992
  },
2990
2993
  [Keys.NEGATIVE]: {
2991
- type: KeyTypes.VALUE,
2994
+ type: KeyType.VALUE,
2992
2995
  // I18N: A label for a minus sign.
2993
2996
  ariaLabel: i18n._("Negative")
2994
2997
  },
2995
2998
  [Keys.TIMES]: {
2996
- type: KeyTypes.OPERATOR,
2999
+ type: KeyType.OPERATOR,
2997
3000
  // I18N: A label for a multiplication sign (represented with an 'x').
2998
3001
  ariaLabel: i18n._("Multiply")
2999
3002
  },
3000
3003
  [Keys.DIVIDE]: {
3001
- type: KeyTypes.OPERATOR,
3004
+ type: KeyType.OPERATOR,
3002
3005
  // I18N: A label for a division sign.
3003
3006
  ariaLabel: i18n._("Divide")
3004
3007
  },
3005
3008
  [Keys.DECIMAL]: {
3006
- type: KeyTypes.VALUE,
3009
+ type: KeyType.VALUE,
3007
3010
  // I18N: A label for a decimal symbol.
3008
3011
  ariaLabel: i18n._("Decimal"),
3009
- icon: decimalSeparator === DecimalSeparators.COMMA ? {
3012
+ icon: decimalSeparator === DecimalSeparator.COMMA ? {
3010
3013
  // TODO(charlie): Get an SVG icon for the comma, or verify with
3011
3014
  // design that the text-rendered version is acceptable.
3012
- type: IconTypes.TEXT,
3015
+ type: IconType.TEXT,
3013
3016
  data: ","
3014
3017
  } : {
3015
- type: IconTypes.SVG,
3018
+ type: IconType.SVG,
3016
3019
  data: Keys.PERIOD
3017
3020
  }
3018
3021
  },
3019
3022
  [Keys.PERCENT]: {
3020
- type: KeyTypes.OPERATOR,
3023
+ type: KeyType.OPERATOR,
3021
3024
  // I18N: A label for a percent sign.
3022
3025
  ariaLabel: i18n._("Percent")
3023
3026
  },
3024
3027
  [Keys.CDOT]: {
3025
- type: KeyTypes.OPERATOR,
3028
+ type: KeyType.OPERATOR,
3026
3029
  // I18N: A label for a multiplication sign (represented as a dot).
3027
3030
  ariaLabel: i18n._("Multiply")
3028
3031
  },
3029
3032
  [Keys.EQUAL]: {
3030
- type: KeyTypes.OPERATOR,
3033
+ type: KeyType.OPERATOR,
3031
3034
  ariaLabel: i18n._("Equals sign")
3032
3035
  },
3033
3036
  [Keys.NEQ]: {
3034
- type: KeyTypes.OPERATOR,
3037
+ type: KeyType.OPERATOR,
3035
3038
  ariaLabel: i18n._("Not-equals sign")
3036
3039
  },
3037
3040
  [Keys.GT]: {
3038
- type: KeyTypes.OPERATOR,
3041
+ type: KeyType.OPERATOR,
3039
3042
  // I18N: A label for a 'greater than' sign (represented as '>').
3040
3043
  ariaLabel: i18n._("Greater than sign")
3041
3044
  },
3042
3045
  [Keys.LT]: {
3043
- type: KeyTypes.OPERATOR,
3046
+ type: KeyType.OPERATOR,
3044
3047
  // I18N: A label for a 'less than' sign (represented as '<').
3045
3048
  ariaLabel: i18n._("Less than sign")
3046
3049
  },
3047
3050
  [Keys.GEQ]: {
3048
- type: KeyTypes.OPERATOR,
3051
+ type: KeyType.OPERATOR,
3049
3052
  ariaLabel: i18n._("Greater than or equal to sign")
3050
3053
  },
3051
3054
  [Keys.LEQ]: {
3052
- type: KeyTypes.OPERATOR,
3055
+ type: KeyType.OPERATOR,
3053
3056
  ariaLabel: i18n._("Less than or equal to sign")
3054
3057
  },
3055
3058
  // mobile native
3056
3059
  [Keys.FRAC_INCLUSIVE]: {
3057
- type: KeyTypes.OPERATOR,
3060
+ type: KeyType.OPERATOR,
3058
3061
  // I18N: A label for a button that creates a new fraction and puts the
3059
3062
  // current expression in the numerator of that fraction.
3060
3063
  ariaLabel: i18n._("Fraction, with current expression in numerator")
3061
3064
  },
3062
3065
  // mobile native
3063
3066
  [Keys.FRAC_EXCLUSIVE]: {
3064
- type: KeyTypes.OPERATOR,
3067
+ type: KeyType.OPERATOR,
3065
3068
  // I18N: A label for a button that creates a new fraction next to the
3066
3069
  // cursor.
3067
3070
  ariaLabel: i18n._("Fraction, excluding the current expression")
3068
3071
  },
3069
3072
  // mobile web
3070
3073
  [Keys.FRAC]: {
3071
- type: KeyTypes.OPERATOR,
3074
+ type: KeyType.OPERATOR,
3072
3075
  // I18N: A label for a button that creates a new fraction next to the
3073
3076
  // cursor.
3074
3077
  ariaLabel: i18n._("Fraction, excluding the current expression")
3075
3078
  },
3076
3079
  [Keys.EXP]: {
3077
- type: KeyTypes.OPERATOR,
3080
+ type: KeyType.OPERATOR,
3078
3081
  // I18N: A label for a button that will allow the user to input a custom
3079
3082
  // exponent.
3080
3083
  ariaLabel: i18n._("Custom exponent")
3081
3084
  },
3082
3085
  [Keys.EXP_2]: {
3083
- type: KeyTypes.OPERATOR,
3086
+ type: KeyType.OPERATOR,
3084
3087
  // I18N: A label for a button that will square (take to the second
3085
3088
  // power) some math.
3086
3089
  ariaLabel: i18n._("Square")
3087
3090
  },
3088
3091
  [Keys.EXP_3]: {
3089
- type: KeyTypes.OPERATOR,
3092
+ type: KeyType.OPERATOR,
3090
3093
  // I18N: A label for a button that will cube (take to the third power)
3091
3094
  // some math.
3092
3095
  ariaLabel: i18n._("Cube")
3093
3096
  },
3094
3097
  [Keys.SQRT]: {
3095
- type: KeyTypes.OPERATOR,
3098
+ type: KeyType.OPERATOR,
3096
3099
  ariaLabel: i18n._("Square root")
3097
3100
  },
3098
3101
  [Keys.CUBE_ROOT]: {
3099
- type: KeyTypes.OPERATOR,
3102
+ type: KeyType.OPERATOR,
3100
3103
  ariaLabel: i18n._("Cube root")
3101
3104
  },
3102
3105
  [Keys.RADICAL]: {
3103
- type: KeyTypes.OPERATOR,
3106
+ type: KeyType.OPERATOR,
3104
3107
  ariaLabel: i18n._("Radical with custom root")
3105
3108
  },
3106
3109
  [Keys.LEFT_PAREN]: {
3107
- type: KeyTypes.OPERATOR,
3110
+ type: KeyType.OPERATOR,
3108
3111
  ariaLabel: i18n._("Left parenthesis")
3109
3112
  },
3110
3113
  [Keys.RIGHT_PAREN]: {
3111
- type: KeyTypes.OPERATOR,
3114
+ type: KeyType.OPERATOR,
3112
3115
  ariaLabel: i18n._("Right parenthesis")
3113
3116
  },
3114
3117
  [Keys.LN]: {
3115
- type: KeyTypes.OPERATOR,
3118
+ type: KeyType.OPERATOR,
3116
3119
  ariaLabel: i18n._("Natural logarithm")
3117
3120
  },
3118
3121
  [Keys.LOG]: {
3119
- type: KeyTypes.OPERATOR,
3122
+ type: KeyType.OPERATOR,
3120
3123
  ariaLabel: i18n._("Logarithm with base 10")
3121
3124
  },
3122
3125
  [Keys.LOG_N]: {
3123
- type: KeyTypes.OPERATOR,
3126
+ type: KeyType.OPERATOR,
3124
3127
  ariaLabel: i18n._("Logarithm with custom base")
3125
3128
  },
3126
3129
  [Keys.SIN]: {
3127
- type: KeyTypes.OPERATOR,
3130
+ type: KeyType.OPERATOR,
3128
3131
  ariaLabel: i18n._("Sine")
3129
3132
  },
3130
3133
  [Keys.COS]: {
3131
- type: KeyTypes.OPERATOR,
3134
+ type: KeyType.OPERATOR,
3132
3135
  ariaLabel: i18n._("Cosine")
3133
3136
  },
3134
3137
  [Keys.TAN]: {
3135
- type: KeyTypes.OPERATOR,
3138
+ type: KeyType.OPERATOR,
3136
3139
  ariaLabel: i18n._("Tangent")
3137
3140
  },
3138
3141
  [Keys.PI]: {
3139
- type: KeyTypes.VALUE,
3142
+ type: KeyType.VALUE,
3140
3143
  ariaLabel: i18n._("Pi"),
3141
3144
  icon: {
3142
- type: IconTypes.MATH,
3145
+ type: IconType.MATH,
3143
3146
  data: "\\pi"
3144
3147
  }
3145
3148
  },
3146
3149
  [Keys.THETA]: {
3147
- type: KeyTypes.VALUE,
3150
+ type: KeyType.VALUE,
3148
3151
  ariaLabel: i18n._("Theta"),
3149
3152
  icon: {
3150
- type: IconTypes.MATH,
3153
+ type: IconType.MATH,
3151
3154
  data: "\\theta"
3152
3155
  }
3153
3156
  },
3154
3157
  [Keys.NOOP]: {
3155
- type: KeyTypes.EMPTY
3158
+ type: KeyType.EMPTY
3156
3159
  },
3157
3160
  // Input navigation keys.
3158
3161
  [Keys.UP]: {
3159
- type: KeyTypes.INPUT_NAVIGATION,
3162
+ type: KeyType.INPUT_NAVIGATION,
3160
3163
  ariaLabel: i18n._("Up arrow")
3161
3164
  },
3162
3165
  [Keys.RIGHT]: {
3163
- type: KeyTypes.INPUT_NAVIGATION,
3166
+ type: KeyType.INPUT_NAVIGATION,
3164
3167
  ariaLabel: i18n._("Right arrow")
3165
3168
  },
3166
3169
  [Keys.DOWN]: {
3167
- type: KeyTypes.INPUT_NAVIGATION,
3170
+ type: KeyType.INPUT_NAVIGATION,
3168
3171
  ariaLabel: i18n._("Down arrow")
3169
3172
  },
3170
3173
  [Keys.LEFT]: {
3171
- type: KeyTypes.INPUT_NAVIGATION,
3174
+ type: KeyType.INPUT_NAVIGATION,
3172
3175
  ariaLabel: i18n._("Left arrow")
3173
3176
  },
3174
3177
  [Keys.JUMP_OUT_PARENTHESES]: {
3175
- type: KeyTypes.INPUT_NAVIGATION,
3178
+ type: KeyType.INPUT_NAVIGATION,
3176
3179
  ariaLabel: i18n._("Navigate right out of a set of parentheses")
3177
3180
  },
3178
3181
  [Keys.JUMP_OUT_EXPONENT]: {
3179
- type: KeyTypes.INPUT_NAVIGATION,
3182
+ type: KeyType.INPUT_NAVIGATION,
3180
3183
  ariaLabel: i18n._("Navigate right out of an exponent")
3181
3184
  },
3182
3185
  [Keys.JUMP_OUT_BASE]: {
3183
- type: KeyTypes.INPUT_NAVIGATION,
3186
+ type: KeyType.INPUT_NAVIGATION,
3184
3187
  ariaLabel: i18n._("Navigate right out of a base")
3185
3188
  },
3186
3189
  [Keys.JUMP_INTO_NUMERATOR]: {
3187
- type: KeyTypes.INPUT_NAVIGATION,
3190
+ type: KeyType.INPUT_NAVIGATION,
3188
3191
  ariaLabel: i18n._("Navigate right into the numerator of a fraction")
3189
3192
  },
3190
3193
  [Keys.JUMP_OUT_NUMERATOR]: {
3191
- type: KeyTypes.INPUT_NAVIGATION,
3194
+ type: KeyType.INPUT_NAVIGATION,
3192
3195
  ariaLabel: i18n._("Navigate right out of the numerator and into the denominator")
3193
3196
  },
3194
3197
  [Keys.JUMP_OUT_DENOMINATOR]: {
3195
- type: KeyTypes.INPUT_NAVIGATION,
3198
+ type: KeyType.INPUT_NAVIGATION,
3196
3199
  ariaLabel: i18n._("Navigate right out of the denominator of a fraction")
3197
3200
  },
3198
3201
  [Keys.BACKSPACE]: {
3199
- type: KeyTypes.INPUT_NAVIGATION,
3202
+ type: KeyType.INPUT_NAVIGATION,
3200
3203
  // I18N: A label for a button that will delete some input.
3201
3204
  ariaLabel: i18n._("Delete")
3202
3205
  },
3203
3206
  // Keypad navigation keys.
3204
3207
  [Keys.DISMISS]: {
3205
- type: KeyTypes.KEYPAD_NAVIGATION,
3208
+ type: KeyType.KEYPAD_NAVIGATION,
3206
3209
  // I18N: A label for a button that will dismiss/hide a keypad.
3207
3210
  ariaLabel: i18n._("Dismiss")
3208
3211
  }
@@ -3220,7 +3223,7 @@ KeyConfigs[Keys.FRAC_MULTI] = {
3220
3223
 
3221
3224
  // TODO(charlie): Use the numeral color for the 'Many' key.
3222
3225
  KeyConfigs[Keys.MANY] = {
3223
- type: KeyTypes.MANY
3226
+ type: KeyType.MANY
3224
3227
  // childKeyIds will be configured by the client.
3225
3228
  };
3226
3229
 
@@ -3232,10 +3235,10 @@ for (const num of NUMBERS) {
3232
3235
  // would mean that we'd be using text beyond the variable key).
3233
3236
  const textRepresentation = `${num}`;
3234
3237
  KeyConfigs[`NUM_${num}`] = {
3235
- type: KeyTypes.VALUE,
3238
+ type: KeyType.VALUE,
3236
3239
  ariaLabel: textRepresentation,
3237
3240
  icon: {
3238
- type: IconTypes.TEXT,
3241
+ type: IconType.TEXT,
3239
3242
  data: textRepresentation
3240
3243
  }
3241
3244
  };
@@ -3248,10 +3251,10 @@ for (const letter of LETTERS) {
3248
3251
  const upperCaseVariable = letter.toUpperCase();
3249
3252
  for (const textRepresentation of [lowerCaseVariable, upperCaseVariable]) {
3250
3253
  KeyConfigs[textRepresentation] = {
3251
- type: KeyTypes.VALUE,
3254
+ type: KeyType.VALUE,
3252
3255
  ariaLabel: textRepresentation,
3253
3256
  icon: {
3254
- type: IconTypes.MATH,
3257
+ type: IconType.MATH,
3255
3258
  data: textRepresentation
3256
3259
  }
3257
3260
  };
@@ -3262,7 +3265,7 @@ for (const key of Object.keys(KeyConfigs)) {
3262
3265
  id: key,
3263
3266
  // Default to an SVG icon indexed by the key name.
3264
3267
  icon: {
3265
- type: IconTypes.SVG,
3268
+ type: IconType.SVG,
3266
3269
  data: key
3267
3270
  }
3268
3271
  }, KeyConfigs[key]);
@@ -3281,11 +3284,11 @@ const echoReducer = function echoReducer(state = initialEchoState, action) {
3281
3284
 
3282
3285
  // Add in the echo animation if the user performs a math
3283
3286
  // operation.
3284
- if (keyConfig.type === KeyTypes.VALUE || keyConfig.type === KeyTypes.OPERATOR) {
3287
+ if (keyConfig.type === KeyType.VALUE || keyConfig.type === KeyType.OPERATOR) {
3285
3288
  return _extends({}, state, {
3286
3289
  echoes: [...state.echoes, {
3287
3290
  animationId: "" + _lastAnimationId++,
3288
- animationType: action.inPopover ? EchoAnimationTypes.LONG_FADE_ONLY : EchoAnimationTypes.FADE_ONLY,
3291
+ animationType: action.inPopover ? EchoAnimationType.LONG_FADE_ONLY : EchoAnimationType.FADE_ONLY,
3289
3292
  borders: action.borders,
3290
3293
  id: keyConfig.id,
3291
3294
  initialBounds: action.initialBounds
@@ -3295,7 +3298,6 @@ const echoReducer = function echoReducer(state = initialEchoState, action) {
3295
3298
  return state;
3296
3299
  case "RemoveEcho":
3297
3300
  const remainingEchoes = state.echoes.filter(echo => {
3298
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'animationId' does not exist on type 'never'.
3299
3301
  return echo.animationId !== action.animationId;
3300
3302
  });
3301
3303
  return _extends({}, state, {
@@ -3309,7 +3311,7 @@ const echoReducer = function echoReducer(state = initialEchoState, action) {
3309
3311
  const initialInputState = {
3310
3312
  keyHandler: null,
3311
3313
  cursor: {
3312
- context: NONE
3314
+ context: CursorContext.NONE
3313
3315
  }
3314
3316
  };
3315
3317
  const inputReducer = function inputReducer(state = initialInputState, action) {
@@ -3320,7 +3322,7 @@ const inputReducer = function inputReducer(state = initialInputState, action) {
3320
3322
  });
3321
3323
  case "PressKey":
3322
3324
  const keyConfig = KeyConfigs[action.key];
3323
- if (keyConfig.type !== KeyTypes.KEYPAD_NAVIGATION) {
3325
+ if (keyConfig.type !== KeyType.KEYPAD_NAVIGATION) {
3324
3326
  // This is probably an anti-pattern but it works for the
3325
3327
  // case where we don't actually control the state but we
3326
3328
  // still want to communicate with the other object
@@ -4691,48 +4693,48 @@ const JumpOutDenominator = () => {
4691
4693
  */
4692
4694
 
4693
4695
  var Iconography = /*#__PURE__*/Object.freeze({
4694
- __proto__: null,
4695
- COS: Cos,
4696
- LOG: Log,
4697
- EQUAL: Equal,
4698
- BACKSPACE: Backspace,
4699
- SQRT: Sqrt,
4700
- EXP: Exp,
4701
- NEQ: Neq,
4702
- GEQ: Geq,
4703
- LN: Ln,
4704
- DISMISS: Dismiss,
4705
- SIN: Sin,
4706
- LT: Lt,
4707
- CUBE_ROOT: CubeRoot,
4708
- PLUS: Plus,
4709
- TAN: Tan,
4710
- LEFT: Left,
4711
- UP: Up,
4712
- DOWN: Down,
4713
- LEFT_PAREN: LeftParen,
4714
- RIGHT_PAREN: RightParen,
4715
- GT: Gt,
4716
- DIVIDE: Divide,
4717
- PERIOD: Period,
4718
- PERCENT: Percent,
4719
- TIMES: Times,
4720
- EXP_3: Exp3,
4721
- EXP_2: Exp2,
4722
- RIGHT: Right,
4723
- CDOT: Cdot,
4724
- LOG_N: LogN,
4725
- LEQ: Leq,
4726
- MINUS: Minus,
4727
- NEGATIVE: Minus,
4728
- RADICAL: Radical,
4729
- FRAC: FracInclusive,
4730
- JUMP_OUT_PARENTHESES: JumpOutParentheses,
4731
- JUMP_OUT_EXPONENT: JumpOutExponent,
4732
- JUMP_OUT_BASE: JumpOutBase,
4733
- JUMP_INTO_NUMERATOR: JumpIntoNumerator,
4734
- JUMP_OUT_NUMERATOR: JumpOutNumerator,
4735
- JUMP_OUT_DENOMINATOR: JumpOutDenominator
4696
+ __proto__: null,
4697
+ COS: Cos,
4698
+ LOG: Log,
4699
+ EQUAL: Equal,
4700
+ BACKSPACE: Backspace,
4701
+ SQRT: Sqrt,
4702
+ EXP: Exp,
4703
+ NEQ: Neq,
4704
+ GEQ: Geq,
4705
+ LN: Ln,
4706
+ DISMISS: Dismiss,
4707
+ SIN: Sin,
4708
+ LT: Lt,
4709
+ CUBE_ROOT: CubeRoot,
4710
+ PLUS: Plus,
4711
+ TAN: Tan,
4712
+ LEFT: Left,
4713
+ UP: Up,
4714
+ DOWN: Down,
4715
+ LEFT_PAREN: LeftParen,
4716
+ RIGHT_PAREN: RightParen,
4717
+ GT: Gt,
4718
+ DIVIDE: Divide,
4719
+ PERIOD: Period,
4720
+ PERCENT: Percent,
4721
+ TIMES: Times,
4722
+ EXP_3: Exp3,
4723
+ EXP_2: Exp2,
4724
+ RIGHT: Right,
4725
+ CDOT: Cdot,
4726
+ LOG_N: LogN,
4727
+ LEQ: Leq,
4728
+ MINUS: Minus,
4729
+ NEGATIVE: Minus,
4730
+ RADICAL: Radical,
4731
+ FRAC: FracInclusive,
4732
+ JUMP_OUT_PARENTHESES: JumpOutParentheses,
4733
+ JUMP_OUT_EXPONENT: JumpOutExponent,
4734
+ JUMP_OUT_BASE: JumpOutBase,
4735
+ JUMP_INTO_NUMERATOR: JumpIntoNumerator,
4736
+ JUMP_OUT_NUMERATOR: JumpOutNumerator,
4737
+ JUMP_OUT_DENOMINATOR: JumpOutDenominator
4736
4738
  });
4737
4739
 
4738
4740
  /**
@@ -4797,12 +4799,12 @@ class Icon extends React.PureComponent {
4797
4799
  } = this.props;
4798
4800
  const styleWithFocus = [focused ? styles$a.focused : styles$a.unfocused, ...(Array.isArray(style) ? style : [style])];
4799
4801
  switch (icon.type) {
4800
- case IconTypes.MATH:
4802
+ case IconType.MATH:
4801
4803
  return /*#__PURE__*/React.createElement(MathIcon, {
4802
4804
  math: icon.data,
4803
4805
  style: styleWithFocus
4804
4806
  });
4805
- case IconTypes.SVG:
4807
+ case IconType.SVG:
4806
4808
  // TODO(charlie): Support passing style objects to `SvgIcon`.
4807
4809
  // This will require migrating the individual icons to use
4808
4810
  // `currentColor` and accept a `className` prop, rather than
@@ -4811,7 +4813,7 @@ class Icon extends React.PureComponent {
4811
4813
  name: icon.data,
4812
4814
  color: focused ? focusedColor : unfocusedColor
4813
4815
  });
4814
- case IconTypes.TEXT:
4816
+ case IconType.TEXT:
4815
4817
  return /*#__PURE__*/React.createElement(TextIcon, {
4816
4818
  character: icon.data,
4817
4819
  style: styleWithFocus
@@ -4853,7 +4855,7 @@ class MultiSymbolGrid extends React.Component {
4853
4855
  // Supporting other types of icons is possible but would require
4854
4856
  // some styles coercion and doesn't seem worthwhile right now.
4855
4857
  icons.forEach(icon => {
4856
- if (icon.type !== IconTypes.MATH) {
4858
+ if (icon.type !== IconType.MATH) {
4857
4859
  throw new Error(`Received invalid icon: type=${icon.type}, ` + `data=${icon.data}`);
4858
4860
  }
4859
4861
  });
@@ -4971,7 +4973,7 @@ class KeypadButton extends React.PureComponent {
4971
4973
  // object. This method must be called whenever a property that
4972
4974
  // influences the possible outcomes of `this._getFocusStyle` and
4973
4975
  // `this._getButtonStyle` changes (such as `this.buttonSizeStyle`).
4974
- for (const type of Object.keys(KeyTypes)) {
4976
+ for (const type of Object.values(KeyType)) {
4975
4977
  css(View.styles.initial, ...this._getFocusStyle(type));
4976
4978
  for (const borders of Object.values(BorderStyles)) {
4977
4979
  css(View.styles.initial, ...this._getButtonStyle(type, borders));
@@ -4980,7 +4982,7 @@ class KeypadButton extends React.PureComponent {
4980
4982
  };
4981
4983
  this._getFocusStyle = type => {
4982
4984
  let focusBackgroundStyle;
4983
- if (type === KeyTypes.INPUT_NAVIGATION || type === KeyTypes.KEYPAD_NAVIGATION) {
4985
+ if (type === KeyType.INPUT_NAVIGATION || type === KeyType.KEYPAD_NAVIGATION) {
4984
4986
  focusBackgroundStyle = styles$8.light;
4985
4987
  } else {
4986
4988
  focusBackgroundStyle = styles$8.bright;
@@ -4991,34 +4993,34 @@ class KeypadButton extends React.PureComponent {
4991
4993
  // Select the appropriate style for the button.
4992
4994
  let backgroundStyle;
4993
4995
  switch (type) {
4994
- case KeyTypes.EMPTY:
4996
+ case KeyType.EMPTY:
4995
4997
  backgroundStyle = styles$8.empty;
4996
4998
  break;
4997
- case KeyTypes.MANY:
4998
- case KeyTypes.VALUE:
4999
+ case KeyType.MANY:
5000
+ case KeyType.VALUE:
4999
5001
  backgroundStyle = styles$8.value;
5000
5002
  break;
5001
- case KeyTypes.OPERATOR:
5003
+ case KeyType.OPERATOR:
5002
5004
  backgroundStyle = styles$8.operator;
5003
5005
  break;
5004
- case KeyTypes.INPUT_NAVIGATION:
5005
- case KeyTypes.KEYPAD_NAVIGATION:
5006
+ case KeyType.INPUT_NAVIGATION:
5007
+ case KeyType.KEYPAD_NAVIGATION:
5006
5008
  backgroundStyle = styles$8.control;
5007
5009
  break;
5008
- case KeyTypes.ECHO:
5010
+ case KeyType.ECHO:
5009
5011
  backgroundStyle = null;
5010
5012
  break;
5011
5013
  }
5012
5014
  const borderStyle = [];
5013
- if (borders.includes(BorderDirections.LEFT)) {
5015
+ if (borders.includes(BorderDirection.LEFT)) {
5014
5016
  // @ts-expect-error TS2345
5015
5017
  borderStyle.push(styles$8.leftBorder);
5016
5018
  }
5017
- if (borders.includes(BorderDirections.BOTTOM)) {
5019
+ if (borders.includes(BorderDirection.BOTTOM)) {
5018
5020
  // @ts-expect-error TS2345
5019
5021
  borderStyle.push(styles$8.bottomBorder);
5020
5022
  }
5021
- return [styles$8.buttonBase, backgroundStyle, ...borderStyle, type === KeyTypes.ECHO && styles$8.echo, this.buttonSizeStyle,
5023
+ return [styles$8.buttonBase, backgroundStyle, ...borderStyle, type === KeyType.ECHO && styles$8.echo, this.buttonSizeStyle,
5022
5024
  // React Native allows you to set the 'style' props on user defined
5023
5025
  // components.
5024
5026
  // See: https://facebook.github.io/react-native/docs/style.html
@@ -5060,7 +5062,7 @@ class KeypadButton extends React.PureComponent {
5060
5062
 
5061
5063
  // We render in the focus state if the key is focused, or if it's an
5062
5064
  // echo.
5063
- const renderFocused = !disabled && focused || popoverEnabled || type === KeyTypes.ECHO;
5065
+ const renderFocused = !disabled && focused || popoverEnabled || type === KeyType.ECHO;
5064
5066
  const buttonStyle = this._getButtonStyle(type, borders, style);
5065
5067
  const focusStyle = this._getFocusStyle(type);
5066
5068
  const iconWrapperStyle = [styles$8.iconWrapper, disabled ? styles$8.disabled : undefined];
@@ -5076,11 +5078,11 @@ class KeypadButton extends React.PureComponent {
5076
5078
  const maybeCornerDecal = !renderFocused && !disabled && childKeys && childKeys.length > 0 && /*#__PURE__*/React.createElement(CornerDecal, {
5077
5079
  style: styles$8.decalInset
5078
5080
  });
5079
- if (type === KeyTypes.EMPTY) {
5081
+ if (type === KeyType.EMPTY) {
5080
5082
  return /*#__PURE__*/React.createElement(View, _extends({
5081
5083
  style: buttonStyle
5082
5084
  }, eventHandlers));
5083
- } else if (type === KeyTypes.MANY) {
5085
+ } else if (type === KeyType.MANY) {
5084
5086
  // TODO(charlie): Make the long-press interaction accessible. See
5085
5087
  // the TODO in key-configs.js for more.
5086
5088
  const manyButtonA11yMarkup = {
@@ -5319,7 +5321,7 @@ const mapStateToProps$5 = (state, ownProps) => {
5319
5321
 
5320
5322
  // Override with the default child props, if the key is a multi-symbol key
5321
5323
  // (but not a many-symbol key, which operates under different rules).
5322
- const useFirstChildProps = type !== KeyTypes.MANY && childKeys && childKeys.length > 0;
5324
+ const useFirstChildProps = type !== KeyType.MANY && childKeys && childKeys.length > 0;
5323
5325
  return _extends({}, rest, {
5324
5326
  childKeyIds: childKeyIds,
5325
5327
  gestureManager: gestures.gestureManager,
@@ -5364,7 +5366,7 @@ class ManyKeypadButton extends React.Component {
5364
5366
  } else {
5365
5367
  const keyConfig = {
5366
5368
  id: Keys.MANY,
5367
- type: KeyTypes.MANY,
5369
+ type: KeyType.MANY,
5368
5370
  childKeyIds: keys
5369
5371
  };
5370
5372
  return /*#__PURE__*/React.createElement(TouchableKeypadButton$1, _extends({
@@ -5423,7 +5425,7 @@ class Echo extends React.Component {
5423
5425
  style: containerStyle
5424
5426
  }, /*#__PURE__*/React.createElement(KeypadButton$1, {
5425
5427
  icon: icon,
5426
- type: KeyTypes.ECHO,
5428
+ type: KeyType.ECHO,
5427
5429
  borders: borders
5428
5430
  }));
5429
5431
  }
@@ -5437,15 +5439,15 @@ class EchoManager extends React.Component {
5437
5439
  let animationDurationMs;
5438
5440
  let animationTransitionName;
5439
5441
  switch (animationType) {
5440
- case EchoAnimationTypes.SLIDE_AND_FADE:
5442
+ case EchoAnimationType.SLIDE_AND_FADE:
5441
5443
  animationDurationMs = 400;
5442
5444
  animationTransitionName = "echo-slide-and-fade";
5443
5445
  break;
5444
- case EchoAnimationTypes.FADE_ONLY:
5446
+ case EchoAnimationType.FADE_ONLY:
5445
5447
  animationDurationMs = 300;
5446
5448
  animationTransitionName = "echo-fade-only";
5447
5449
  break;
5448
- case EchoAnimationTypes.LONG_FADE_ONLY:
5450
+ case EchoAnimationType.LONG_FADE_ONLY:
5449
5451
  animationDurationMs = 400;
5450
5452
  animationTransitionName = "echo-long-fade-only";
5451
5453
  break;
@@ -5463,7 +5465,7 @@ class EchoManager extends React.Component {
5463
5465
  echoes,
5464
5466
  onAnimationFinish
5465
5467
  } = this.props;
5466
- return /*#__PURE__*/React.createElement("span", null, Object.keys(EchoAnimationTypes).map(animationType => {
5468
+ return /*#__PURE__*/React.createElement("span", null, Object.keys(EchoAnimationType).map(animationType => {
5467
5469
  // Collect the relevant parameters for the animation type, and
5468
5470
  // filter for the appropriate echoes.
5469
5471
  const {
@@ -5989,25 +5991,25 @@ class ExpressionKeypad extends React.Component {
5989
5991
  let dismissOrJumpOutKey;
5990
5992
  if (dynamicJumpOut) {
5991
5993
  switch (cursorContext) {
5992
- case IN_PARENS:
5994
+ case CursorContext.IN_PARENS:
5993
5995
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
5994
5996
  break;
5995
- case IN_SUPER_SCRIPT:
5997
+ case CursorContext.IN_SUPER_SCRIPT:
5996
5998
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
5997
5999
  break;
5998
- case IN_SUB_SCRIPT:
6000
+ case CursorContext.IN_SUB_SCRIPT:
5999
6001
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
6000
6002
  break;
6001
- case BEFORE_FRACTION:
6003
+ case CursorContext.BEFORE_FRACTION:
6002
6004
  dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
6003
6005
  break;
6004
- case IN_NUMERATOR:
6006
+ case CursorContext.IN_NUMERATOR:
6005
6007
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
6006
6008
  break;
6007
- case IN_DENOMINATOR:
6009
+ case CursorContext.IN_DENOMINATOR:
6008
6010
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
6009
6011
  break;
6010
- case NONE:
6012
+ case CursorContext.NONE:
6011
6013
  default:
6012
6014
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
6013
6015
  break;
@@ -6222,25 +6224,25 @@ class FractionKeypad extends React.Component {
6222
6224
  let dismissOrJumpOutKey;
6223
6225
  if (dynamicJumpOut) {
6224
6226
  switch (cursorContext) {
6225
- case IN_PARENS:
6227
+ case CursorContext.IN_PARENS:
6226
6228
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
6227
6229
  break;
6228
- case IN_SUPER_SCRIPT:
6230
+ case CursorContext.IN_SUPER_SCRIPT:
6229
6231
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
6230
6232
  break;
6231
- case IN_SUB_SCRIPT:
6233
+ case CursorContext.IN_SUB_SCRIPT:
6232
6234
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
6233
6235
  break;
6234
- case BEFORE_FRACTION:
6236
+ case CursorContext.BEFORE_FRACTION:
6235
6237
  dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
6236
6238
  break;
6237
- case IN_NUMERATOR:
6239
+ case CursorContext.IN_NUMERATOR:
6238
6240
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
6239
6241
  break;
6240
- case IN_DENOMINATOR:
6242
+ case CursorContext.IN_DENOMINATOR:
6241
6243
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
6242
6244
  break;
6243
- case NONE:
6245
+ case CursorContext.NONE:
6244
6246
  default:
6245
6247
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
6246
6248
  break;
@@ -6269,7 +6271,7 @@ class FractionKeypad extends React.Component {
6269
6271
  // then when the cursor was inside a parenthetical
6270
6272
  // expression in a numerator or denominator, this check
6271
6273
  // would fail.
6272
- cursorContext === IN_NUMERATOR || cursorContext === IN_DENOMINATOR,
6274
+ cursorContext === CursorContext.IN_NUMERATOR || cursorContext === CursorContext.IN_DENOMINATOR,
6273
6275
  style: roundTopRight && roundedTopRight
6274
6276
  })), /*#__PURE__*/React.createElement(View, {
6275
6277
  style: row$2
@@ -6326,10 +6328,10 @@ var FractionKeypad$1 = connect(mapStateToProps$1, null, null, {
6326
6328
  forwardRef: true
6327
6329
  })(FractionKeypad);
6328
6330
 
6329
- const defaultKeypadType = KeypadTypes.EXPRESSION;
6331
+ const defaultKeypadType = KeypadType.EXPRESSION;
6330
6332
  const keypadForType = {
6331
- [KeypadTypes.FRACTION]: fractionKeypadLayout,
6332
- [KeypadTypes.EXPRESSION]: expressionKeypadLayout
6333
+ [KeypadType.FRACTION]: fractionKeypadLayout,
6334
+ [KeypadType.EXPRESSION]: expressionKeypadLayout
6333
6335
  };
6334
6336
 
6335
6337
  const initialKeypadState = {
@@ -6353,7 +6355,6 @@ const keypadReducer = function keypadReducer(state = initialKeypadState, action)
6353
6355
  extraKeys: []
6354
6356
  }, action.configuration);
6355
6357
  case "PressKey":
6356
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'key' does not exist on type '{ type: string; }'.
6357
6358
  const keyConfig = KeyConfigs[action.key];
6358
6359
  // NOTE(charlie): Our keypad system operates by triggering key
6359
6360
  // presses with key IDs in a dumb manner, such that the keys
@@ -6438,8 +6439,8 @@ const computeLayoutParameters = ({
6438
6439
 
6439
6440
  // Then, compute the button dimensions based on the provided parameters.
6440
6441
  let buttonDimensions;
6441
- if (deviceType === DeviceTypes.PHONE) {
6442
- const isLandscape = deviceOrientation === DeviceOrientations.LANDSCAPE;
6442
+ if (deviceType === DeviceType.PHONE) {
6443
+ const isLandscape = deviceOrientation === DeviceOrientation.LANDSCAPE;
6443
6444
 
6444
6445
  // In many cases, the browser chrome will already have been factored
6445
6446
  // into `pageHeightPx`. But we have no way of knowing if that's
@@ -6482,7 +6483,7 @@ const computeLayoutParameters = ({
6482
6483
  widthPx: buttonWidthPx,
6483
6484
  heightPx: buttonHeightPx
6484
6485
  };
6485
- } else if (deviceType === DeviceTypes.TABLET) {
6486
+ } else if (deviceType === DeviceType.TABLET) {
6486
6487
  buttonDimensions = {
6487
6488
  widthPx: maxButtonSize,
6488
6489
  heightPx: maxButtonSize
@@ -6497,7 +6498,7 @@ const computeLayoutParameters = ({
6497
6498
  const keypadWidth = effectiveNumColumns * buttonDimensions.widthPx + (navigationPadEnabled ? navigationPadWidthPx : 0) + numSeparators * innerBorderWidthPx;
6498
6499
  return {
6499
6500
  buttonDimensions,
6500
- layoutMode: keypadWidth >= pageWidthPx ? LayoutModes.FULLSCREEN : LayoutModes.COMPACT
6501
+ layoutMode: keypadWidth >= pageWidthPx ? LayoutMode.FULLSCREEN : LayoutMode.COMPACT
6501
6502
  };
6502
6503
  };
6503
6504
 
@@ -6516,7 +6517,7 @@ const initialLayoutState = {
6516
6517
  pageWidthPx: 0,
6517
6518
  pageHeightPx: 0
6518
6519
  },
6519
- layoutMode: LayoutModes.FULLSCREEN,
6520
+ layoutMode: LayoutMode.FULLSCREEN,
6520
6521
  paginationEnabled: false,
6521
6522
  navigationPadEnabled: false
6522
6523
  };
@@ -6532,13 +6533,13 @@ const layoutParametersForDimensions = (pageDimensions, gridDimensions) => {
6532
6533
  } = pageDimensions;
6533
6534
 
6534
6535
  // Determine the device type and orientation.
6535
- const deviceOrientation = pageWidthPx > pageHeightPx ? DeviceOrientations.LANDSCAPE : DeviceOrientations.PORTRAIT;
6536
- const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ? DeviceTypes.TABLET : DeviceTypes.PHONE;
6536
+ const deviceOrientation = pageWidthPx > pageHeightPx ? DeviceOrientation.LANDSCAPE : DeviceOrientation.PORTRAIT;
6537
+ const deviceType = Math.min(pageWidthPx, pageHeightPx) > tabletCutoffPx ? DeviceType.TABLET : DeviceType.PHONE;
6537
6538
 
6538
6539
  // Using that information, make some decisions (or assumptions)
6539
6540
  // about the resulting layout.
6540
- const navigationPadEnabled = deviceType === DeviceTypes.TABLET;
6541
- const paginationEnabled = deviceType === DeviceTypes.PHONE && deviceOrientation === DeviceOrientations.PORTRAIT;
6541
+ const navigationPadEnabled = deviceType === DeviceType.TABLET;
6542
+ const paginationEnabled = deviceType === DeviceType.PHONE && deviceOrientation === DeviceOrientation.PORTRAIT;
6542
6543
  const deviceInfo = {
6543
6544
  deviceOrientation,
6544
6545
  deviceType
@@ -6677,7 +6678,6 @@ const initialPagerState = {
6677
6678
  const pagerReducer = function pagerReducer(state = initialPagerState, action) {
6678
6679
  switch (action.type) {
6679
6680
  case "ConfigureKeypad":
6680
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'configuration' does not exist on type '{ type: string; }'.
6681
6681
  const {
6682
6682
  keypadType
6683
6683
  } = action.configuration;
@@ -6692,47 +6692,25 @@ const pagerReducer = function pagerReducer(state = initialPagerState, action) {
6692
6692
  });
6693
6693
  case "SetPageSize":
6694
6694
  return _extends({}, state, {
6695
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'pageWidthPx' does not exist on type '{ type: string; }'.
6696
6695
  pageWidthPx: action.pageWidthPx
6697
6696
  });
6698
6697
  case "PressKey":
6699
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'key' does not exist on type '{ type: string; }'.
6700
6698
  const keyConfig = KeyConfigs[action.key];
6701
6699
 
6702
6700
  // Reset the keypad page if the user performs a math operation.
6703
- if (keyConfig.type === KeyTypes.VALUE || keyConfig.type === KeyTypes.OPERATOR) {
6704
- return pagerReducer(state, {
6705
- type: "ResetKeypadPage"
6701
+ if (keyConfig.type === KeyType.VALUE || keyConfig.type === KeyType.OPERATOR) {
6702
+ return _extends({}, state, {
6703
+ animateToPosition: true,
6704
+ // We start at the right-most page.
6705
+ currentPage: getDefaultPage(state.numPages),
6706
+ dx: 0
6706
6707
  });
6707
6708
  }
6708
6709
  return state;
6709
- case "ResetKeypadPage":
6710
- return _extends({}, state, {
6711
- animateToPosition: true,
6712
- // We start at the right-most page.
6713
- currentPage: getDefaultPage(state.numPages),
6714
- dx: 0
6715
- });
6716
- case "PageKeypadRight":
6717
- const nextPage = Math.min(state.currentPage + 1, state.numPages - 1);
6718
- return _extends({}, state, {
6719
- animateToPosition: true,
6720
- currentPage: nextPage,
6721
- dx: 0
6722
- });
6723
- case "PageKeypadLeft":
6724
- const prevPage = Math.max(state.currentPage - 1, 0);
6725
- return _extends({}, state, {
6726
- animateToPosition: true,
6727
- currentPage: prevPage,
6728
- dx: 0
6729
- });
6730
6710
  case "OnSwipeChange":
6731
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'dx' does not exist on type '{ type: string; }'.
6732
6711
  state.velocityTracker.push(action.dx);
6733
6712
  return _extends({}, state, {
6734
6713
  animateToPosition: false,
6735
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'dx' does not exist on type '{ type: string; }'.
6736
6714
  dx: action.dx
6737
6715
  });
6738
6716
  case "OnSwipeEnd":
@@ -6740,7 +6718,6 @@ const pagerReducer = function pagerReducer(state = initialPagerState, action) {
6740
6718
  pageWidthPx,
6741
6719
  velocityTracker
6742
6720
  } = state;
6743
- // @ts-expect-error [FEI-5003] - TS2339 - Property 'dx' does not exist on type '{ type: string; }'.
6744
6721
  const {
6745
6722
  dx
6746
6723
  } = action;
@@ -6753,12 +6730,18 @@ const pagerReducer = function pagerReducer(state = initialPagerState, action) {
6753
6730
  const shouldPageRight = dx < -pageWidthPx / 2 || velocity < -minFlingVelocity && dx < -minFlingDistance;
6754
6731
  const shouldPageLeft = dx > pageWidthPx / 2 || velocity > minFlingVelocity && dx > minFlingDistance;
6755
6732
  if (shouldPageRight) {
6756
- return pagerReducer(state, {
6757
- type: "PageKeypadRight"
6733
+ const nextPage = Math.min(state.currentPage + 1, state.numPages - 1);
6734
+ return _extends({}, state, {
6735
+ animateToPosition: true,
6736
+ currentPage: nextPage,
6737
+ dx: 0
6758
6738
  });
6759
6739
  } else if (shouldPageLeft) {
6760
- return pagerReducer(state, {
6761
- type: "PageKeypadLeft"
6740
+ const prevPage = Math.max(state.currentPage - 1, 0);
6741
+ return _extends({}, state, {
6742
+ animateToPosition: true,
6743
+ currentPage: prevPage,
6744
+ dx: 0
6762
6745
  });
6763
6746
  }
6764
6747
  return _extends({}, state, {
@@ -6778,30 +6761,16 @@ const createStore = () => {
6778
6761
  swipeEnabled
6779
6762
  }, {
6780
6763
  onSwipeChange: dx => {
6781
- store.dispatch({
6782
- type: "OnSwipeChange",
6783
- dx
6784
- });
6764
+ store.dispatch(onSwipeChange(dx));
6785
6765
  },
6786
6766
  onSwipeEnd: dx => {
6787
- store.dispatch({
6788
- type: "OnSwipeEnd",
6789
- dx
6790
- });
6767
+ store.dispatch(onSwipeEnd(dx));
6791
6768
  },
6792
6769
  onActiveNodesChanged: activeNodes => {
6793
- store.dispatch({
6794
- type: "SetActiveNodes",
6795
- activeNodes
6796
- });
6770
+ store.dispatch(setActiveNodes(activeNodes));
6797
6771
  },
6798
6772
  onClick: (key, layoutProps, inPopover) => {
6799
- store.dispatch(_extends({
6800
- type: "PressKey",
6801
- key
6802
- }, layoutProps, {
6803
- inPopover
6804
- }));
6773
+ store.dispatch(pressKey(key, layoutProps.borders, layoutProps.initialBounds, inPopover));
6805
6774
  }
6806
6775
  }, [], [Keys.BACKSPACE, Keys.UP, Keys.RIGHT, Keys.DOWN, Keys.LEFT]);
6807
6776
  };
@@ -7012,8 +6981,8 @@ class KeypadContainer extends React.Component {
7012
6981
  // compact keypad, we need to instruct some of our child views to
7013
6982
  // crop themselves. At least we're colocating all the layout
7014
6983
  // information in this component, though.
7015
- roundTopLeft: layoutMode === LayoutModes.COMPACT && !navigationPadEnabled,
7016
- roundTopRight: layoutMode === LayoutModes.COMPACT
6984
+ roundTopLeft: layoutMode === LayoutMode.COMPACT && !navigationPadEnabled,
6985
+ roundTopRight: layoutMode === LayoutMode.COMPACT
7017
6986
  };
7018
6987
 
7019
6988
  // Select the appropriate keyboard given the type.
@@ -7024,9 +6993,9 @@ class KeypadContainer extends React.Component {
7024
6993
  // clear what that format would look like exactly. Plus, there aren't
7025
6994
  // very many of them. So to keep us moving, we'll just hardcode.
7026
6995
  switch (keypadType) {
7027
- case KeypadTypes.FRACTION:
6996
+ case KeypadType.FRACTION:
7028
6997
  return /*#__PURE__*/React.createElement(FractionKeypad$1, keypadProps);
7029
- case KeypadTypes.EXPRESSION:
6998
+ case KeypadType.EXPRESSION:
7030
6999
  return /*#__PURE__*/React.createElement(ExpressionKeypad$1, keypadProps);
7031
7000
  default:
7032
7001
  throw new Error("Invalid keypad type: " + keypadType);
@@ -7084,7 +7053,7 @@ class KeypadContainer extends React.Component {
7084
7053
  dynamicStyle = _extends({}, dynamicStyle, inlineStyles.invisible);
7085
7054
  }
7086
7055
  const keypadContainerStyle = [row, centered, fullWidth, styles.keypadContainer, ...(Array.isArray(style) ? style : [style])];
7087
- const keypadStyle = [row, styles.keypadBorder, layoutMode === LayoutModes.FULLSCREEN ? styles.fullscreen : styles.compact];
7056
+ const keypadStyle = [row, styles.keypadBorder, layoutMode === LayoutMode.FULLSCREEN ? styles.fullscreen : styles.compact];
7088
7057
 
7089
7058
  // TODO(charlie): When the keypad is shorter than the width of the
7090
7059
  // screen, add a border on its left and right edges, and round out the
@@ -7102,7 +7071,7 @@ class KeypadContainer extends React.Component {
7102
7071
  }
7103
7072
  }
7104
7073
  }, navigationPadEnabled && /*#__PURE__*/React.createElement(NavigationPad, {
7105
- roundTopLeft: layoutMode === LayoutModes.COMPACT,
7074
+ roundTopLeft: layoutMode === LayoutMode.COMPACT,
7106
7075
  style: styles.navigationPadContainer
7107
7076
  }), /*#__PURE__*/React.createElement(View, {
7108
7077
  style: styles.keypadLayout
@@ -7188,9 +7157,8 @@ var KeypadContainer$1 = connect(mapStateToProps, mapDispatchToProps, null, {
7188
7157
  })(KeypadContainer);
7189
7158
 
7190
7159
  class ProvidedKeypad extends React.Component {
7191
- constructor(...args) {
7192
- super(...args);
7193
- this.mounted = void 0;
7160
+ constructor(props) {
7161
+ super(props);
7194
7162
  this.store = void 0;
7195
7163
  this.activate = () => {
7196
7164
  this.store.dispatch(activateKeypad());
@@ -7219,16 +7187,8 @@ class ProvidedKeypad extends React.Component {
7219
7187
  this.getDOMNode = () => {
7220
7188
  return ReactDOM.findDOMNode(this);
7221
7189
  };
7222
- }
7223
- UNSAFE_componentWillMount() {
7224
7190
  this.store = createStore();
7225
7191
  }
7226
- componentDidMount() {
7227
- this.mounted = true;
7228
- }
7229
- componentWillUnmount() {
7230
- this.mounted = false;
7231
- }
7232
7192
  render() {
7233
7193
  const {
7234
7194
  onElementMounted,
@@ -7257,5 +7217,5 @@ class ProvidedKeypad extends React.Component {
7257
7217
  }
7258
7218
  }
7259
7219
 
7260
- export { cursorContexts as CursorContexts, KeyConfigs, ProvidedKeypad as Keypad, MathInput as KeypadInput, KeypadTypes, keypadElementPropType };
7220
+ export { CursorContext, KeyConfigs, KeyType, ProvidedKeypad as Keypad, MathInput as KeypadInput, KeypadType, Keys, keypadElementPropType };
7261
7221
  //# sourceMappingURL=index.js.map