@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
@@ -1,4 +1,4 @@
1
- import type { Key } from "../data/keys";
1
+ import Keys from "../data/keys";
2
2
  import type { KeypadConfiguration, KeyHandler, Cursor, ActiveNodesObj, Border } from "../types";
3
3
  type DismissKeypadAction = {
4
4
  type: "DismissKeypad";
@@ -54,11 +54,11 @@ type SetActiveNodesAction = {
54
54
  export declare const setActiveNodes: (activeNodes: ActiveNodesObj) => SetActiveNodesAction;
55
55
  type PressKeyAction = {
56
56
  type: "PressKey";
57
- key: Key;
57
+ key: Keys;
58
58
  borders: Border;
59
59
  initialBounds: DOMRect;
60
60
  inPopover: boolean;
61
61
  };
62
- export declare const pressKey: (key: Key, borders: ("LEFT" | "BOTTOM" | undefined)[], initialBounds: DOMRect, inPopover: any) => PressKeyAction;
62
+ export declare const pressKey: (key: Keys, borders: readonly (import("../enums").BorderDirection | undefined)[], initialBounds: DOMRect, inPopover: any) => PressKeyAction;
63
63
  export type Action = DismissKeypadAction | ActivateKeypadAction | ConfigureKeypadAction | SetPageSizeAction | RemoveEchoAction | SetKeyHandlerAction | SetCursorAction | OnSwipeChangeAction | OnSwipeEndAction | SetActiveNodesAction | PressKeyAction;
64
64
  export {};
@@ -4,7 +4,8 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import type { Key } from "../data/keys";
7
+ import * as $Flowgen$Import$_2e__2e__2f_enums from "../enums";
8
+ import Keys from "../data/keys";
8
9
  import type {
9
10
  KeypadConfiguration,
10
11
  KeyHandler,
@@ -75,14 +76,14 @@ declare export var setActiveNodes: (
75
76
  ) => SetActiveNodesAction;
76
77
  declare type PressKeyAction = {|
77
78
  type: "PressKey",
78
- key: Key,
79
+ key: Keys,
79
80
  borders: Border,
80
81
  initialBounds: DOMRect,
81
82
  inPopover: boolean,
82
83
  |};
83
84
  declare export var pressKey: (
84
- key: Key,
85
- borders: ("LEFT" | "BOTTOM" | void)[],
85
+ key: Keys,
86
+ borders: $ReadOnlyArray<$Flowgen$Import$_2e__2e__2f_enums.BorderDirection | void>,
86
87
  initialBounds: DOMRect,
87
88
  inPopover: any
88
89
  ) => PressKeyAction;
@@ -1,4 +1,5 @@
1
- declare const defaultKeypadType: "EXPRESSION";
1
+ import { KeypadType } from "../enums";
2
+ declare const defaultKeypadType = KeypadType.EXPRESSION;
2
3
  declare const keypadForType: {
3
4
  readonly FRACTION: import("../types").KeypadLayout;
4
5
  readonly EXPRESSION: import("../types").KeypadLayout;
@@ -5,7 +5,8 @@
5
5
  * @flow
6
6
  */
7
7
  import * as $Flowgen$Import$_2e__2e__2f_types from "../types";
8
- declare var defaultKeypadType: "EXPRESSION";
8
+ import { KeypadType } from "../enums";
9
+ declare var defaultKeypadType: KeypadType.EXPRESSION;
9
10
  declare var keypadForType: {|
10
11
  +FRACTION: $Flowgen$Import$_2e__2e__2f_types.KeypadLayout,
11
12
  +EXPRESSION: $Flowgen$Import$_2e__2e__2f_types.KeypadLayout,
@@ -1,8 +1,7 @@
1
1
  import GestureManager from "../components/gesture-manager";
2
2
  import VelocityTracker from "../components/velocity-tracker";
3
- import { LayoutModes } from "../consts";
4
- import type { KeypadType } from "../consts";
5
- import type { Key } from "../data/keys";
3
+ import Keys from "../data/keys";
4
+ import { LayoutMode, KeypadType } from "../enums";
6
5
  import type { Cursor, KeyHandler, Popover, Echo } from "../types";
7
6
  export interface InputState {
8
7
  keyHandler: KeyHandler | null;
@@ -23,7 +22,7 @@ export interface PagerState {
23
22
  }
24
23
  export interface GestureState {
25
24
  popover: Popover | null;
26
- focus: Key | null;
25
+ focus: Keys | null;
27
26
  gestureManager: GestureManager;
28
27
  }
29
28
  export interface EchoState {
@@ -44,7 +43,7 @@ export interface LayoutState {
44
43
  pageWidthPx: number;
45
44
  pageHeightPx: number;
46
45
  };
47
- layoutMode: keyof typeof LayoutModes;
46
+ layoutMode: LayoutMode;
48
47
  paginationEnabled: boolean;
49
48
  navigationPadEnabled: boolean;
50
49
  }
@@ -6,9 +6,8 @@
6
6
  */
7
7
  import GestureManager from "../components/gesture-manager";
8
8
  import VelocityTracker from "../components/velocity-tracker";
9
- import { LayoutModes } from "../consts";
10
- import type { KeypadType } from "../consts";
11
- import type { Key } from "../data/keys";
9
+ import Keys from "../data/keys";
10
+ import { LayoutMode, KeypadType } from "../enums";
12
11
  import type { Cursor, KeyHandler, Popover, Echo } from "../types";
13
12
  export interface InputState {
14
13
  keyHandler: KeyHandler | null;
@@ -29,7 +28,7 @@ export interface PagerState {
29
28
  }
30
29
  export interface GestureState {
31
30
  popover: Popover | null;
32
- focus: Key | null;
31
+ focus: Keys | null;
33
32
  gestureManager: GestureManager;
34
33
  }
35
34
  export interface EchoState {
@@ -50,7 +49,7 @@ export interface LayoutState {
50
49
  pageWidthPx: number,
51
50
  pageHeightPx: number,
52
51
  |};
53
- layoutMode: $Keys<typeof LayoutModes>;
52
+ layoutMode: LayoutMode;
54
53
  paginationEnabled: boolean;
55
54
  navigationPadEnabled: boolean;
56
55
  }
package/dist/types.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { BorderDirections, EchoAnimationTypes, KeyTypes, IconTypes } from "./consts";
1
+ import Keys from "./data/keys";
2
+ import { BorderDirection, EchoAnimationType, IconType, KeyType, KeypadType } from "./enums";
2
3
  import type { CursorContext } from "./components/input/cursor-contexts";
3
- import type { KeypadType } from "./consts";
4
- import type { Key } from "./data/keys";
5
- export type Border = Partial<Array<keyof typeof BorderDirections>>;
4
+ export type Border = Partial<ReadonlyArray<BorderDirection>>;
6
5
  export type Bound = {
7
6
  top: number;
8
7
  right: number;
@@ -12,33 +11,33 @@ export type Bound = {
12
11
  width: number;
13
12
  };
14
13
  export type Popover = {
15
- parentId: Key;
14
+ parentId: Keys;
16
15
  bounds: Partial<Bound>;
17
- childKeyIds: Array<Key>;
16
+ childKeyIds: Array<Keys>;
18
17
  };
19
18
  export type Echo = {
20
19
  animationId: string;
21
- animationType: keyof typeof EchoAnimationTypes;
20
+ animationType: EchoAnimationType;
22
21
  borders: Border;
23
- id: Key;
22
+ id: Keys;
24
23
  initialBounds: DOMRect;
25
24
  };
26
- export type Icon = {
27
- type: keyof typeof IconTypes;
25
+ export type IconConfig = {
26
+ type: IconType;
28
27
  data: string;
29
28
  };
30
29
  export type KeyConfig = {
31
30
  ariaLabel: string;
32
- id: Key;
33
- type: keyof typeof KeyTypes;
34
- childKeyIds: Array<Key>;
35
- icon: Icon;
31
+ id: Keys;
32
+ type: KeyType;
33
+ childKeyIds: Array<Keys>;
34
+ icon: IconConfig;
36
35
  };
37
36
  export type KeypadConfiguration = {
38
37
  keypadType: KeypadType;
39
- extraKeys?: ReadonlyArray<Key>;
38
+ extraKeys?: ReadonlyArray<Keys>;
40
39
  };
41
- export type KeyHandler = (key: Key) => Cursor;
40
+ export type KeyHandler = (key: Keys) => Cursor;
42
41
  export type Cursor = {
43
42
  context: CursorContext;
44
43
  };
@@ -4,16 +4,16 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
+ import Keys from "./data/keys";
7
8
  import {
8
- BorderDirections,
9
- EchoAnimationTypes,
10
- KeyTypes,
11
- IconTypes,
12
- } from "./consts";
9
+ BorderDirection,
10
+ EchoAnimationType,
11
+ IconType,
12
+ KeyType,
13
+ KeypadType,
14
+ } from "./enums";
13
15
  import type { CursorContext } from "./components/input/cursor-contexts";
14
- import type { KeypadType } from "./consts";
15
- import type { Key } from "./data/keys";
16
- export type Border = $Rest<Array<$Keys<typeof BorderDirections>>, {}>;
16
+ export type Border = $Rest<$ReadOnlyArray<BorderDirection>, {}>;
17
17
  export type Bound = {|
18
18
  top: number,
19
19
  right: number,
@@ -23,33 +23,33 @@ export type Bound = {|
23
23
  width: number,
24
24
  |};
25
25
  export type Popover = {|
26
- parentId: Key,
26
+ parentId: Keys,
27
27
  bounds: $Rest<Bound, {}>,
28
- childKeyIds: Array<Key>,
28
+ childKeyIds: Array<Keys>,
29
29
  |};
30
30
  export type Echo = {|
31
31
  animationId: string,
32
- animationType: $Keys<typeof EchoAnimationTypes>,
32
+ animationType: EchoAnimationType,
33
33
  borders: Border,
34
- id: Key,
34
+ id: Keys,
35
35
  initialBounds: DOMRect,
36
36
  |};
37
- export type Icon = {|
38
- type: $Keys<typeof IconTypes>,
37
+ export type IconConfig = {|
38
+ type: IconType,
39
39
  data: string,
40
40
  |};
41
41
  export type KeyConfig = {|
42
42
  ariaLabel: string,
43
- id: Key,
44
- type: $Keys<typeof KeyTypes>,
45
- childKeyIds: Array<Key>,
46
- icon: Icon,
43
+ id: Keys,
44
+ type: KeyType,
45
+ childKeyIds: Array<Keys>,
46
+ icon: IconConfig,
47
47
  |};
48
48
  export type KeypadConfiguration = {|
49
49
  keypadType: KeypadType,
50
- extraKeys?: $ReadOnlyArray<Key>,
50
+ extraKeys?: $ReadOnlyArray<Keys>,
51
51
  |};
52
- export type KeyHandler = (key: Key) => Cursor;
52
+ export type KeyHandler = (key: Keys) => Cursor;
53
53
  export type Cursor = {|
54
54
  context: CursorContext,
55
55
  |};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Khan Academy's new expression editor for the mobile web.",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "1.0.1",
6
+ "version": "2.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -19,7 +19,7 @@
19
19
  * might need to be.
20
20
  */
21
21
 
22
- import {DeviceTypes, DeviceOrientations, LayoutModes} from "../consts";
22
+ import {DeviceType, DeviceOrientation, LayoutMode} from "../enums";
23
23
 
24
24
  import {
25
25
  pageIndicatorHeightPx,
@@ -68,8 +68,8 @@ export const computeLayoutParameters = (
68
68
 
69
69
  // Then, compute the button dimensions based on the provided parameters.
70
70
  let buttonDimensions;
71
- if (deviceType === DeviceTypes.PHONE) {
72
- const isLandscape = deviceOrientation === DeviceOrientations.LANDSCAPE;
71
+ if (deviceType === DeviceType.PHONE) {
72
+ const isLandscape = deviceOrientation === DeviceOrientation.LANDSCAPE;
73
73
 
74
74
  // In many cases, the browser chrome will already have been factored
75
75
  // into `pageHeightPx`. But we have no way of knowing if that's
@@ -129,7 +129,7 @@ export const computeLayoutParameters = (
129
129
  widthPx: buttonWidthPx,
130
130
  heightPx: buttonHeightPx,
131
131
  };
132
- } else if (deviceType === DeviceTypes.TABLET) {
132
+ } else if (deviceType === DeviceType.TABLET) {
133
133
  buttonDimensions = {
134
134
  widthPx: maxButtonSize,
135
135
  heightPx: maxButtonSize,
@@ -151,7 +151,7 @@ export const computeLayoutParameters = (
151
151
  buttonDimensions,
152
152
  layoutMode:
153
153
  keypadWidth >= pageWidthPx
154
- ? LayoutModes.FULLSCREEN
155
- : LayoutModes.COMPACT,
154
+ ? LayoutMode.FULLSCREEN
155
+ : LayoutMode.COMPACT,
156
156
  };
157
157
  };
@@ -5,19 +5,19 @@
5
5
  import * as React from "react";
6
6
  import {TransitionGroup, CSSTransition} from "react-transition-group";
7
7
 
8
- import {KeyTypes, EchoAnimationTypes} from "../consts";
9
8
  import KeyConfigs from "../data/key-configs";
9
+ import Keys from "../data/keys";
10
+ import {KeyType, EchoAnimationType} from "../enums";
10
11
 
11
12
  import KeypadButton from "./keypad-button";
12
13
  import * as zIndexes from "./z-indexes";
13
14
 
14
- import type {Key} from "../data/keys";
15
15
  import type {Border, Bound} from "../types";
16
16
 
17
17
  type EchoProps = {
18
18
  animationDurationMs: number;
19
19
  borders: Border;
20
- id: Key;
20
+ id: Keys;
21
21
  initialBounds: Bound;
22
22
  onAnimationFinish: () => void;
23
23
  };
@@ -53,7 +53,7 @@ class Echo extends React.Component<EchoProps> {
53
53
  <div style={containerStyle}>
54
54
  <KeypadButton
55
55
  icon={icon}
56
- type={KeyTypes.ECHO}
56
+ type={KeyType.ECHO}
57
57
  borders={borders}
58
58
  />
59
59
  </div>
@@ -63,9 +63,9 @@ class Echo extends React.Component<EchoProps> {
63
63
 
64
64
  type EchoPropType = {
65
65
  animationId: string;
66
- animationType: keyof typeof EchoAnimationTypes;
66
+ animationType: EchoAnimationType;
67
67
  borders: Border;
68
- id: Key;
68
+ id: Keys;
69
69
  initialBounds: Bound;
70
70
  };
71
71
 
@@ -82,17 +82,17 @@ class EchoManager extends React.Component<EchoManagerProps> {
82
82
  let animationTransitionName;
83
83
 
84
84
  switch (animationType) {
85
- case EchoAnimationTypes.SLIDE_AND_FADE:
85
+ case EchoAnimationType.SLIDE_AND_FADE:
86
86
  animationDurationMs = 400;
87
87
  animationTransitionName = "echo-slide-and-fade";
88
88
  break;
89
89
 
90
- case EchoAnimationTypes.FADE_ONLY:
90
+ case EchoAnimationType.FADE_ONLY:
91
91
  animationDurationMs = 300;
92
92
  animationTransitionName = "echo-fade-only";
93
93
  break;
94
94
 
95
- case EchoAnimationTypes.LONG_FADE_ONLY:
95
+ case EchoAnimationType.LONG_FADE_ONLY:
96
96
  animationDurationMs = 400;
97
97
  animationTransitionName = "echo-long-fade-only";
98
98
  break;
@@ -114,7 +114,7 @@ class EchoManager extends React.Component<EchoManagerProps> {
114
114
 
115
115
  return (
116
116
  <span>
117
- {Object.keys(EchoAnimationTypes).map((animationType) => {
117
+ {Object.keys(EchoAnimationType).map((animationType) => {
118
118
  // Collect the relevant parameters for the animation type, and
119
119
  // filter for the appropriate echoes.
120
120
  const {animationDurationMs, animationTransitionName} =
@@ -6,12 +6,12 @@ import {StyleSheet} from "aphrodite";
6
6
  import * as React from "react";
7
7
  import {connect} from "react-redux";
8
8
 
9
- import {BorderStyles} from "../consts";
10
9
  import KeyConfigs from "../data/key-configs";
10
+ import {BorderStyles} from "../enums";
11
11
  import {View} from "../fake-react-native-web/index";
12
12
 
13
13
  import {valueGrey, controlGrey} from "./common-style";
14
- import * as CursorContexts from "./input/cursor-contexts";
14
+ import {CursorContext} from "./input/cursor-contexts";
15
15
  import ManyKeypadButton from "./many-keypad-button";
16
16
  import Styles from "./styles";
17
17
  import TouchableKeypadButton from "./touchable-keypad-button";
@@ -19,7 +19,6 @@ import TwoPageKeypad from "./two-page-keypad";
19
19
 
20
20
  import type {State} from "../store/types";
21
21
  import type {KeypadLayout} from "../types";
22
- import type {CursorContext} from "./input/cursor-contexts";
23
22
 
24
23
  const {row, column, oneColumn, fullWidth, roundedTopLeft, roundedTopRight} =
25
24
  Styles;
@@ -60,31 +59,31 @@ class ExpressionKeypad extends React.Component<Props> {
60
59
  let dismissOrJumpOutKey;
61
60
  if (dynamicJumpOut) {
62
61
  switch (cursorContext) {
63
- case CursorContexts.IN_PARENS:
62
+ case CursorContext.IN_PARENS:
64
63
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
65
64
  break;
66
65
 
67
- case CursorContexts.IN_SUPER_SCRIPT:
66
+ case CursorContext.IN_SUPER_SCRIPT:
68
67
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
69
68
  break;
70
69
 
71
- case CursorContexts.IN_SUB_SCRIPT:
70
+ case CursorContext.IN_SUB_SCRIPT:
72
71
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
73
72
  break;
74
73
 
75
- case CursorContexts.BEFORE_FRACTION:
74
+ case CursorContext.BEFORE_FRACTION:
76
75
  dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
77
76
  break;
78
77
 
79
- case CursorContexts.IN_NUMERATOR:
78
+ case CursorContext.IN_NUMERATOR:
80
79
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
81
80
  break;
82
81
 
83
- case CursorContexts.IN_DENOMINATOR:
82
+ case CursorContext.IN_DENOMINATOR:
84
83
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
85
84
  break;
86
85
 
87
- case CursorContexts.NONE:
86
+ case CursorContext.NONE:
88
87
  default:
89
88
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
90
89
  break;
@@ -6,18 +6,17 @@
6
6
  import * as React from "react";
7
7
  import {connect} from "react-redux";
8
8
 
9
- import {BorderStyles} from "../consts";
10
9
  import KeyConfigs from "../data/key-configs";
10
+ import {BorderStyles} from "../enums";
11
11
  import {View} from "../fake-react-native-web/index";
12
12
 
13
- import * as CursorContexts from "./input/cursor-contexts";
13
+ import {CursorContext} from "./input/cursor-contexts";
14
14
  import Keypad from "./keypad";
15
15
  import Styles from "./styles";
16
16
  import TouchableKeypadButton from "./touchable-keypad-button";
17
17
 
18
18
  import type {State} from "../store/types";
19
19
  import type {KeypadLayout} from "../types";
20
- import type {CursorContext} from "./input/cursor-contexts";
21
20
 
22
21
  const {row, roundedTopLeft, roundedTopRight} = Styles;
23
22
 
@@ -49,31 +48,31 @@ class FractionKeypad extends React.Component<Props> {
49
48
  let dismissOrJumpOutKey;
50
49
  if (dynamicJumpOut) {
51
50
  switch (cursorContext) {
52
- case CursorContexts.IN_PARENS:
51
+ case CursorContext.IN_PARENS:
53
52
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_PARENTHESES;
54
53
  break;
55
54
 
56
- case CursorContexts.IN_SUPER_SCRIPT:
55
+ case CursorContext.IN_SUPER_SCRIPT:
57
56
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_EXPONENT;
58
57
  break;
59
58
 
60
- case CursorContexts.IN_SUB_SCRIPT:
59
+ case CursorContext.IN_SUB_SCRIPT:
61
60
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_BASE;
62
61
  break;
63
62
 
64
- case CursorContexts.BEFORE_FRACTION:
63
+ case CursorContext.BEFORE_FRACTION:
65
64
  dismissOrJumpOutKey = KeyConfigs.JUMP_INTO_NUMERATOR;
66
65
  break;
67
66
 
68
- case CursorContexts.IN_NUMERATOR:
67
+ case CursorContext.IN_NUMERATOR:
69
68
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_NUMERATOR;
70
69
  break;
71
70
 
72
- case CursorContexts.IN_DENOMINATOR:
71
+ case CursorContext.IN_DENOMINATOR:
73
72
  dismissOrJumpOutKey = KeyConfigs.JUMP_OUT_DENOMINATOR;
74
73
  break;
75
74
 
76
- case CursorContexts.NONE:
75
+ case CursorContext.NONE:
77
76
  default:
78
77
  dismissOrJumpOutKey = KeyConfigs.DISMISS;
79
78
  break;
@@ -107,8 +106,8 @@ class FractionKeypad extends React.Component<Props> {
107
106
  // then when the cursor was inside a parenthetical
108
107
  // expression in a numerator or denominator, this check
109
108
  // would fail.
110
- cursorContext === CursorContexts.IN_NUMERATOR ||
111
- cursorContext === CursorContexts.IN_DENOMINATOR
109
+ cursorContext === CursorContext.IN_NUMERATOR ||
110
+ cursorContext === CursorContext.IN_DENOMINATOR
112
111
  }
113
112
  style={roundTopRight && roundedTopRight}
114
113
  />
@@ -1,4 +1,4 @@
1
- import type {Key} from "../data/keys";
1
+ import Keys from "../data/keys";
2
2
 
3
3
  /**
4
4
  * The state machine that backs our gesture system. In particular, this state
@@ -26,17 +26,17 @@ type Options = {
26
26
  };
27
27
 
28
28
  type TouchState = {
29
- activeNodeId: Key;
29
+ activeNodeId: Keys;
30
30
  pressAndHoldIntervalId: number | null;
31
31
  longPressTimeoutId: number | null;
32
32
  swipeLocked: boolean;
33
33
  startX: number;
34
34
  };
35
35
 
36
- type TouchStateMap = Record<Key, TouchState>;
36
+ type TouchStateMap = Record<Keys, TouchState>;
37
37
 
38
38
  type SwipeState = {
39
- touchId: Key;
39
+ touchId: Keys;
40
40
  startX: number;
41
41
  };
42
42
 
@@ -49,16 +49,16 @@ const defaultOptions: Options = {
49
49
  class GestureStateMachine {
50
50
  handlers: Handlers;
51
51
  options: Options;
52
- swipeDisabledNodeIds: Partial<[Key]>;
53
- multiPressableKeys: Partial<[Key]>;
52
+ swipeDisabledNodeIds: Partial<[Keys]>;
53
+ multiPressableKeys: Partial<[Keys]>;
54
54
  touchState: Partial<TouchStateMap>;
55
55
  swipeState: SwipeState | null;
56
56
 
57
57
  constructor(
58
58
  handlers: Handlers,
59
59
  options: Partial<Options>,
60
- swipeDisabledNodeIds?: [Key],
61
- multiPressableKeys?: [Key],
60
+ swipeDisabledNodeIds?: [Keys],
61
+ multiPressableKeys?: [Keys],
62
62
  ) {
63
63
  this.handlers = handlers;
64
64
  this.options = {
@@ -5,14 +5,14 @@
5
5
  import {StyleSheet} from "aphrodite";
6
6
  import * as React from "react";
7
7
 
8
- import {IconTypes} from "../consts";
8
+ import {IconType} from "../enums";
9
9
 
10
10
  import {offBlack} from "./common-style";
11
11
  import MathIcon from "./math-icon";
12
12
  import SvgIcon from "./svg-icon";
13
13
  import TextIcon from "./text-icon";
14
14
 
15
- import type {Icon as IconPropType} from "../types";
15
+ import type {IconConfig} from "../types";
16
16
  import type {StyleType} from "@khanacademy/wonder-blocks-core";
17
17
 
18
18
  const focusedColor = "#FFF";
@@ -20,7 +20,7 @@ const unfocusedColor = offBlack;
20
20
 
21
21
  type Props = {
22
22
  focused: boolean;
23
- icon: IconPropType;
23
+ icon: IconConfig;
24
24
  style?: StyleType;
25
25
  };
26
26
 
@@ -34,10 +34,10 @@ class Icon extends React.PureComponent<Props> {
34
34
  ];
35
35
 
36
36
  switch (icon.type) {
37
- case IconTypes.MATH:
37
+ case IconType.MATH:
38
38
  return <MathIcon math={icon.data} style={styleWithFocus} />;
39
39
 
40
- case IconTypes.SVG:
40
+ case IconType.SVG:
41
41
  // TODO(charlie): Support passing style objects to `SvgIcon`.
42
42
  // This will require migrating the individual icons to use
43
43
  // `currentColor` and accept a `className` prop, rather than
@@ -49,7 +49,7 @@ class Icon extends React.PureComponent<Props> {
49
49
  />
50
50
  );
51
51
 
52
- case IconTypes.TEXT:
52
+ case IconType.TEXT:
53
53
  return (
54
54
  <TextIcon character={icon.data} style={styleWithFocus} />
55
55
  );