@khanacademy/math-input 1.0.1 → 3.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 (246) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/components/input/cursor-contexts.d.ts +10 -9
  3. package/dist/components/input/cursor-contexts.js.flow +11 -16
  4. package/dist/components/input/math-input.d.ts +1 -1
  5. package/dist/components/input/math-input.js.flow +1 -1
  6. package/dist/components/input/math-wrapper.d.ts +3 -2
  7. package/dist/components/input/math-wrapper.js.flow +3 -16
  8. package/dist/components/keypad/button.d.ts +1 -2
  9. package/dist/components/keypad/button.js.flow +1 -1
  10. package/dist/components/keypad/{pre-algebra-page.d.ts → geometry-page/index.d.ts} +1 -1
  11. package/dist/components/keypad/{pre-algebra-page.js.flow → geometry-page/index.js.flow} +1 -1
  12. package/dist/components/keypad/index.d.ts +5 -4
  13. package/dist/components/keypad/index.js.flow +9 -4
  14. package/dist/components/keypad/keypad-page-items.d.ts +8 -2
  15. package/dist/components/keypad/keypad-page-items.js.flow +8 -2
  16. package/dist/components/keypad/{numeric-input-page.d.ts → numbers-page/index.d.ts} +3 -2
  17. package/dist/components/keypad/numbers-page/index.js.flow +17 -0
  18. package/dist/components/keypad/numbers-page/types.d.ts +4 -0
  19. package/dist/components/keypad/numbers-page/types.js.flow +10 -0
  20. package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +7 -0
  21. package/dist/components/keypad/{numeric-input-page.js.flow → operators-page/advanced-relations-buttons.js.flow} +3 -4
  22. package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +7 -0
  23. package/dist/components/keypad/{trigonometry-page.js.flow → operators-page/basic-relations-buttons.js.flow} +3 -6
  24. package/dist/components/keypad/operators-page/index.d.ts +9 -0
  25. package/dist/components/keypad/operators-page/index.js.flow +17 -0
  26. package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +7 -0
  27. package/dist/components/keypad/operators-page/logarithms-buttons.js.flow +12 -0
  28. package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +7 -0
  29. package/dist/components/keypad/operators-page/pre-algebra-buttons.js.flow +12 -0
  30. package/dist/components/keypad/operators-page/types.d.ts +6 -0
  31. package/dist/components/keypad/operators-page/types.js.flow +12 -0
  32. package/dist/components/{compute-layout-parameters.d.ts → keypad-legacy/compute-layout-parameters.d.ts} +2 -1
  33. package/dist/components/keypad-legacy/compute-layout-parameters.js.flow +30 -0
  34. package/dist/components/{echo-manager.d.ts → keypad-legacy/echo-manager.d.ts} +2 -11
  35. package/dist/components/{echo-manager.js.flow → keypad-legacy/echo-manager.js.flow} +2 -11
  36. package/dist/components/{expression-keypad.d.ts → keypad-legacy/expression-keypad.d.ts} +3 -4
  37. package/dist/components/{expression-keypad.js.flow → keypad-legacy/expression-keypad.js.flow} +3 -4
  38. package/dist/components/{fraction-keypad.d.ts → keypad-legacy/fraction-keypad.d.ts} +2 -2
  39. package/dist/components/{fraction-keypad.js.flow → keypad-legacy/fraction-keypad.js.flow} +2 -2
  40. package/dist/components/{gesture-manager.d.ts → keypad-legacy/gesture-manager.d.ts} +1 -1
  41. package/dist/components/{gesture-manager.js.flow → keypad-legacy/gesture-manager.js.flow} +1 -1
  42. package/dist/components/{gesture-state-machine.d.ts → keypad-legacy/gesture-state-machine.d.ts} +7 -7
  43. package/dist/components/{gesture-state-machine.js.flow → keypad-legacy/gesture-state-machine.js.flow} +8 -8
  44. package/dist/components/{icon.d.ts → keypad-legacy/icon.d.ts} +2 -2
  45. package/dist/components/{icon.js.flow → keypad-legacy/icon.js.flow} +2 -2
  46. package/dist/components/{keypad-button.d.ts → keypad-legacy/keypad-button.d.ts} +10 -10
  47. package/dist/components/{keypad-button.js.flow → keypad-legacy/keypad-button.js.flow} +12 -11
  48. package/dist/components/{keypad-container.d.ts → keypad-legacy/keypad-container.d.ts} +3 -4
  49. package/dist/components/{keypad-container.js.flow → keypad-legacy/keypad-container.js.flow} +4 -5
  50. package/dist/components/{keypad.d.ts → keypad-legacy/keypad.d.ts} +3 -3
  51. package/dist/components/{keypad.js.flow → keypad-legacy/keypad.js.flow} +3 -3
  52. package/dist/components/{multi-symbol-grid.d.ts → keypad-legacy/multi-symbol-grid.d.ts} +2 -2
  53. package/dist/components/{multi-symbol-grid.js.flow → keypad-legacy/multi-symbol-grid.js.flow} +2 -2
  54. package/dist/components/{multi-symbol-popover.d.ts → keypad-legacy/multi-symbol-popover.d.ts} +1 -1
  55. package/dist/components/{multi-symbol-popover.js.flow → keypad-legacy/multi-symbol-popover.js.flow} +1 -1
  56. package/dist/components/{node-manager.d.ts → keypad-legacy/node-manager.d.ts} +3 -4
  57. package/dist/components/{node-manager.js.flow → keypad-legacy/node-manager.js.flow} +3 -5
  58. package/dist/components/{popover-manager.d.ts → keypad-legacy/popover-manager.d.ts} +1 -1
  59. package/dist/components/{popover-manager.js.flow → keypad-legacy/popover-manager.js.flow} +1 -1
  60. package/dist/components/{popover-state-machine.d.ts → keypad-legacy/popover-state-machine.d.ts} +1 -1
  61. package/dist/components/{popover-state-machine.js.flow → keypad-legacy/popover-state-machine.js.flow} +1 -1
  62. package/dist/components/{provided-keypad.d.ts → keypad-legacy/provided-keypad.d.ts} +1 -1
  63. package/dist/components/{provided-keypad.js.flow → keypad-legacy/provided-keypad.js.flow} +1 -1
  64. package/dist/{store → components/keypad-legacy/store}/actions.d.ts +5 -6
  65. package/dist/{store → components/keypad-legacy/store}/actions.js.flow +7 -9
  66. package/dist/{store → components/keypad-legacy/store}/index.d.ts +0 -1
  67. package/dist/{store → components/keypad-legacy/store}/index.js.flow +0 -1
  68. package/dist/components/keypad-legacy/store/shared.d.ts +7 -0
  69. package/dist/components/keypad-legacy/store/shared.js.flow +14 -0
  70. package/dist/{store → components/keypad-legacy/store}/types.d.ts +6 -17
  71. package/dist/{store → components/keypad-legacy/store}/types.js.flow +6 -17
  72. package/dist/components/keypad-legacy/styles.d.ts +5 -0
  73. package/dist/components/{styles.js.flow → keypad-legacy/styles.js.flow} +1 -3
  74. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +37 -0
  75. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +64 -0
  76. package/dist/components/{two-page-keypad.d.ts → keypad-legacy/two-page-keypad.d.ts} +0 -1
  77. package/dist/components/{two-page-keypad.js.flow → keypad-legacy/two-page-keypad.js.flow} +0 -1
  78. package/dist/data/key-configs.d.ts +3 -1
  79. package/dist/data/key-configs.js.flow +3 -1
  80. package/dist/data/keys.d.ts +49 -52
  81. package/dist/data/keys.js.flow +48 -99
  82. package/dist/enums.d.ts +49 -0
  83. package/dist/enums.js.flow +63 -0
  84. package/dist/es/index.js +5033 -4370
  85. package/dist/es/index.js.map +1 -1
  86. package/dist/fake-react-native-web/view.d.ts +1 -2
  87. package/dist/fake-react-native-web/view.js.flow +1 -2
  88. package/dist/index.d.ts +5 -7
  89. package/dist/index.js +5398 -4714
  90. package/dist/index.js.flow +5 -7
  91. package/dist/index.js.map +1 -1
  92. package/dist/types.d.ts +26 -23
  93. package/dist/types.js.flow +37 -33
  94. package/package.json +1 -1
  95. package/src/components/input/__tests__/context-tracking.test.ts +20 -20
  96. package/src/components/input/cursor-contexts.ts +22 -29
  97. package/src/components/input/math-input.tsx +1 -1
  98. package/src/components/input/math-wrapper.ts +75 -67
  99. package/src/components/keypad/button-assets.tsx +65 -40
  100. package/src/components/keypad/button.stories.tsx +61 -13
  101. package/src/components/keypad/button.tsx +1 -1
  102. package/src/components/keypad/{trigonometry-page.tsx → geometry-page/index.tsx} +3 -4
  103. package/src/components/keypad/index.tsx +19 -14
  104. package/src/components/keypad/keypad-page-items.tsx +34 -21
  105. package/src/components/keypad/keypad-pages.stories.tsx +5 -5
  106. package/src/components/keypad/keypad.stories.tsx +75 -17
  107. package/src/components/keypad/{numeric-input-page.tsx → numbers-page/index.tsx} +47 -11
  108. package/src/components/keypad/numbers-page/types.ts +4 -0
  109. package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +32 -0
  110. package/src/components/keypad/operators-page/basic-relations-buttons.tsx +32 -0
  111. package/src/components/keypad/{pre-algebra-page.tsx → operators-page/index.tsx} +25 -29
  112. package/src/components/keypad/operators-page/logarithms-buttons.tsx +32 -0
  113. package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +36 -0
  114. package/src/components/keypad/operators-page/types.ts +6 -0
  115. package/src/components/{__tests__ → keypad-legacy/__tests__}/two-page-keypad.test.tsx +0 -2
  116. package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts} +7 -8
  117. package/src/components/{corner-decal.tsx → keypad-legacy/corner-decal.tsx} +2 -3
  118. package/src/components/{echo-manager.tsx → keypad-legacy/echo-manager.tsx} +12 -25
  119. package/src/components/{empty-keypad-button.tsx → keypad-legacy/empty-keypad-button.tsx} +2 -2
  120. package/src/components/{expression-keypad.tsx → keypad-legacy/expression-keypad.tsx} +15 -25
  121. package/src/components/{fraction-keypad.tsx → keypad-legacy/fraction-keypad.tsx} +15 -16
  122. package/src/components/{gesture-manager.ts → keypad-legacy/gesture-manager.ts} +2 -2
  123. package/src/components/{gesture-state-machine.ts → keypad-legacy/gesture-state-machine.ts} +8 -8
  124. package/src/components/{icon.tsx → keypad-legacy/icon.tsx} +7 -7
  125. package/src/components/{keypad-button.tsx → keypad-legacy/keypad-button.tsx} +30 -28
  126. package/src/components/{keypad-container.tsx → keypad-legacy/keypad-container.tsx} +13 -14
  127. package/src/components/{keypad.tsx → keypad-legacy/keypad.tsx} +5 -5
  128. package/src/components/{many-keypad-button.tsx → keypad-legacy/many-keypad-button.tsx} +6 -6
  129. package/src/components/{math-icon.tsx → keypad-legacy/math-icon.tsx} +2 -2
  130. package/src/components/{multi-symbol-grid.tsx → keypad-legacy/multi-symbol-grid.tsx} +6 -7
  131. package/src/components/{multi-symbol-popover.tsx → keypad-legacy/multi-symbol-popover.tsx} +3 -4
  132. package/src/components/{navigation-pad.tsx → keypad-legacy/navigation-pad.tsx} +5 -5
  133. package/src/components/{node-manager.ts → keypad-legacy/node-manager.ts} +2 -10
  134. package/src/components/{popover-manager.tsx → keypad-legacy/popover-manager.tsx} +2 -2
  135. package/src/components/{popover-state-machine.ts → keypad-legacy/popover-state-machine.ts} +1 -1
  136. package/src/components/{provided-keypad.tsx → keypad-legacy/provided-keypad.tsx} +4 -5
  137. package/src/{store → components/keypad-legacy/store}/actions.ts +8 -10
  138. package/src/{store → components/keypad-legacy/store}/echo-reducer.ts +6 -7
  139. package/src/{store → components/keypad-legacy/store}/index.ts +5 -13
  140. package/src/{store → components/keypad-legacy/store}/input-reducer.ts +6 -6
  141. package/src/{store → components/keypad-legacy/store}/keypad-reducer.ts +2 -2
  142. package/src/{store → components/keypad-legacy/store}/layout-reducer.ts +11 -11
  143. package/src/components/keypad-legacy/store/shared.ts +12 -0
  144. package/src/{store → components/keypad-legacy/store}/types.ts +16 -21
  145. package/src/components/{styles.ts → keypad-legacy/styles.ts} +1 -1
  146. package/src/components/{text-icon.tsx → keypad-legacy/text-icon.tsx} +2 -2
  147. package/src/components/{touchable-keypad-button.tsx → keypad-legacy/touchable-keypad-button.tsx} +40 -21
  148. package/src/components/{two-page-keypad.tsx → keypad-legacy/two-page-keypad.tsx} +5 -6
  149. package/src/data/key-configs.ts +67 -72
  150. package/src/data/keys.ts +50 -107
  151. package/src/enums.ts +74 -0
  152. package/src/index.ts +5 -9
  153. package/src/math-input.stories.tsx +9 -9
  154. package/src/types.ts +33 -26
  155. package/src/utils.ts +3 -3
  156. package/tsconfig-build.tsbuildinfo +1 -0
  157. package/dist/components/compute-layout-parameters.js.flow +0 -49
  158. package/dist/components/keypad/trigonometry-page.d.ts +0 -8
  159. package/dist/components/styles.d.ts +0 -6
  160. package/dist/components/touchable-keypad-button.d.ts +0 -30
  161. package/dist/components/touchable-keypad-button.js.flow +0 -35
  162. package/dist/components/velocity-tracker.d.ts +0 -48
  163. package/dist/components/velocity-tracker.js.flow +0 -54
  164. package/dist/consts.d.ts +0 -51
  165. package/dist/consts.js.flow +0 -66
  166. package/dist/store/pager-reducer.d.ts +0 -4
  167. package/dist/store/pager-reducer.js.flow +0 -13
  168. package/dist/store/shared.d.ts +0 -6
  169. package/dist/store/shared.js.flow +0 -13
  170. package/src/components/velocity-tracker.ts +0 -86
  171. package/src/consts.ts +0 -91
  172. package/src/store/pager-reducer.ts +0 -125
  173. package/src/store/shared.ts +0 -12
  174. package/tsconfig.tsbuildinfo +0 -1
  175. /package/dist/components/{corner-decal.d.ts → keypad-legacy/corner-decal.d.ts} +0 -0
  176. /package/dist/components/{corner-decal.js.flow → keypad-legacy/corner-decal.js.flow} +0 -0
  177. /package/dist/components/{empty-keypad-button.d.ts → keypad-legacy/empty-keypad-button.d.ts} +0 -0
  178. /package/dist/components/{empty-keypad-button.js.flow → keypad-legacy/empty-keypad-button.js.flow} +0 -0
  179. /package/dist/components/{many-keypad-button.d.ts → keypad-legacy/many-keypad-button.d.ts} +0 -0
  180. /package/dist/components/{many-keypad-button.js.flow → keypad-legacy/many-keypad-button.js.flow} +0 -0
  181. /package/dist/components/{math-icon.d.ts → keypad-legacy/math-icon.d.ts} +0 -0
  182. /package/dist/components/{math-icon.js.flow → keypad-legacy/math-icon.js.flow} +0 -0
  183. /package/dist/components/{navigation-pad.d.ts → keypad-legacy/navigation-pad.d.ts} +0 -0
  184. /package/dist/components/{navigation-pad.js.flow → keypad-legacy/navigation-pad.js.flow} +0 -0
  185. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.d.ts +0 -0
  186. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.js.flow +0 -0
  187. /package/dist/{store → components/keypad-legacy/store}/input-reducer.d.ts +0 -0
  188. /package/dist/{store → components/keypad-legacy/store}/input-reducer.js.flow +0 -0
  189. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.d.ts +0 -0
  190. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.js.flow +0 -0
  191. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.d.ts +0 -0
  192. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.js.flow +0 -0
  193. /package/dist/components/{svg-icon.d.ts → keypad-legacy/svg-icon.d.ts} +0 -0
  194. /package/dist/components/{svg-icon.js.flow → keypad-legacy/svg-icon.js.flow} +0 -0
  195. /package/dist/components/{text-icon.d.ts → keypad-legacy/text-icon.d.ts} +0 -0
  196. /package/dist/components/{text-icon.js.flow → keypad-legacy/text-icon.js.flow} +0 -0
  197. /package/dist/components/{z-indexes.d.ts → keypad-legacy/z-indexes.d.ts} +0 -0
  198. /package/dist/components/{z-indexes.js.flow → keypad-legacy/z-indexes.js.flow} +0 -0
  199. /package/src/components/{__tests__ → keypad-legacy/__tests__}/gesture-state-machine.test.ts +0 -0
  200. /package/src/components/{__tests__ → keypad-legacy/__tests__}/node-manager.test.ts +0 -0
  201. /package/src/components/{iconography → keypad-legacy/iconography}/arrow.js +0 -0
  202. /package/src/components/{iconography → keypad-legacy/iconography}/backspace.js +0 -0
  203. /package/src/components/{iconography → keypad-legacy/iconography}/cdot.js +0 -0
  204. /package/src/components/{iconography → keypad-legacy/iconography}/cos.js +0 -0
  205. /package/src/components/{iconography → keypad-legacy/iconography}/cube-root.js +0 -0
  206. /package/src/components/{iconography → keypad-legacy/iconography}/dismiss.js +0 -0
  207. /package/src/components/{iconography → keypad-legacy/iconography}/divide.js +0 -0
  208. /package/src/components/{iconography → keypad-legacy/iconography}/down.js +0 -0
  209. /package/src/components/{iconography → keypad-legacy/iconography}/equal.js +0 -0
  210. /package/src/components/{iconography → keypad-legacy/iconography}/exp-2.js +0 -0
  211. /package/src/components/{iconography → keypad-legacy/iconography}/exp-3.js +0 -0
  212. /package/src/components/{iconography → keypad-legacy/iconography}/exp.js +0 -0
  213. /package/src/components/{iconography → keypad-legacy/iconography}/frac.js +0 -0
  214. /package/src/components/{iconography → keypad-legacy/iconography}/geq.js +0 -0
  215. /package/src/components/{iconography → keypad-legacy/iconography}/gt.js +0 -0
  216. /package/src/components/{iconography → keypad-legacy/iconography}/index.js +0 -0
  217. /package/src/components/{iconography → keypad-legacy/iconography}/jump-into-numerator.js +0 -0
  218. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-base.js +0 -0
  219. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-denominator.js +0 -0
  220. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-exponent.js +0 -0
  221. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-numerator.js +0 -0
  222. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-parentheses.js +0 -0
  223. /package/src/components/{iconography → keypad-legacy/iconography}/left-paren.js +0 -0
  224. /package/src/components/{iconography → keypad-legacy/iconography}/left.js +0 -0
  225. /package/src/components/{iconography → keypad-legacy/iconography}/leq.js +0 -0
  226. /package/src/components/{iconography → keypad-legacy/iconography}/ln.js +0 -0
  227. /package/src/components/{iconography → keypad-legacy/iconography}/log-n.js +0 -0
  228. /package/src/components/{iconography → keypad-legacy/iconography}/log.js +0 -0
  229. /package/src/components/{iconography → keypad-legacy/iconography}/lt.js +0 -0
  230. /package/src/components/{iconography → keypad-legacy/iconography}/minus.js +0 -0
  231. /package/src/components/{iconography → keypad-legacy/iconography}/neq.js +0 -0
  232. /package/src/components/{iconography → keypad-legacy/iconography}/parens.js +0 -0
  233. /package/src/components/{iconography → keypad-legacy/iconography}/percent.js +0 -0
  234. /package/src/components/{iconography → keypad-legacy/iconography}/period.js +0 -0
  235. /package/src/components/{iconography → keypad-legacy/iconography}/plus.js +0 -0
  236. /package/src/components/{iconography → keypad-legacy/iconography}/radical.js +0 -0
  237. /package/src/components/{iconography → keypad-legacy/iconography}/right-paren.js +0 -0
  238. /package/src/components/{iconography → keypad-legacy/iconography}/right.js +0 -0
  239. /package/src/components/{iconography → keypad-legacy/iconography}/sin.js +0 -0
  240. /package/src/components/{iconography → keypad-legacy/iconography}/sqrt.js +0 -0
  241. /package/src/components/{iconography → keypad-legacy/iconography}/tan.js +0 -0
  242. /package/src/components/{iconography → keypad-legacy/iconography}/times.js +0 -0
  243. /package/src/components/{iconography → keypad-legacy/iconography}/up.js +0 -0
  244. /package/src/components/{svg-icon.tsx → keypad-legacy/svg-icon.tsx} +0 -0
  245. /package/src/components/{z-indexes.ts → keypad-legacy/z-indexes.ts} +0 -0
  246. /package/{tsconfig.json → tsconfig-build.json} +0 -0
@@ -9,31 +9,46 @@ import * as React from "react";
9
9
  import ReactDOM from "react-dom";
10
10
  import {connect} from "react-redux";
11
11
 
12
- import {KeyType, KeyTypes} from "../consts";
13
- import KeyConfigs from "../data/key-configs";
12
+ import KeyConfigs from "../../data/key-configs";
13
+ import Keys from "../../data/keys";
14
+ import {KeyType} from "../../enums";
14
15
 
15
16
  import GestureManager from "./gesture-manager";
16
17
  import KeypadButton from "./keypad-button";
17
18
 
18
- import type {Key} from "../data/keys";
19
- import type {Border, Icon} from "../types";
19
+ import type {
20
+ Border,
21
+ IconConfig,
22
+ KeyConfig,
23
+ NonManyKeyConfig,
24
+ } from "../../types";
25
+ import type {State} from "./store/types";
20
26
  import type {StyleType} from "@khanacademy/wonder-blocks-core";
21
27
 
22
- type Props = {
23
- borders: Border;
24
- childKeyIds: ReadonlyArray<Key>;
25
- disabled: boolean;
26
- focused: boolean;
28
+ interface SharedProps {
29
+ borders?: Border;
30
+ disabled?: boolean;
31
+ style?: StyleType;
32
+ }
33
+
34
+ interface OwnProps extends SharedProps {
35
+ keyConfig: KeyConfig;
36
+ }
37
+
38
+ interface Props extends SharedProps {
39
+ childKeyIds?: ReadonlyArray<string>;
27
40
  gestureManager: GestureManager;
28
- id: Key;
41
+ id: Keys | "MANY";
42
+ focused: boolean;
29
43
  popoverEnabled: boolean;
30
- style: StyleType;
44
+ childKeys?: ReadonlyArray<NonManyKeyConfig>;
45
+ ariaLabel?: string;
46
+ icon: IconConfig;
31
47
  type: KeyType;
32
- icon: Icon;
33
- };
48
+ }
34
49
 
35
50
  class TouchableKeypadButton extends React.Component<Props> {
36
- shouldComponentUpdate(newProps) {
51
+ shouldComponentUpdate(newProps: Props) {
37
52
  // We take advantage of a few different properties of our key
38
53
  // configuration system. Namely, we know that the other props flow
39
54
  // directly from the ID, and thus don't need to be checked. If a key has
@@ -89,7 +104,6 @@ class TouchableKeypadButton extends React.Component<Props> {
89
104
  id,
90
105
  ReactDOM.findDOMNode(node),
91
106
  childKeyIds,
92
- borders,
93
107
  )
94
108
  }
95
109
  borders={borders}
@@ -102,23 +116,28 @@ class TouchableKeypadButton extends React.Component<Props> {
102
116
  }
103
117
  }
104
118
 
105
- const extractProps = (keyConfig) => {
119
+ const extractProps = (keyConfig: NonManyKeyConfig) => {
106
120
  const {ariaLabel, icon, type} = keyConfig;
107
121
  return {ariaLabel, icon, type};
108
122
  };
109
123
 
110
- const mapStateToProps = (state, ownProps) => {
124
+ const mapStateToProps = (state: State, ownProps: OwnProps): Props => {
111
125
  const {gestures} = state;
112
126
 
113
127
  const {keyConfig, ...rest} = ownProps;
114
- const {id, childKeyIds, type} = keyConfig;
128
+ const {id, type} = keyConfig;
129
+
130
+ const childKeyIds =
131
+ "childKeyIds" in keyConfig ? keyConfig.childKeyIds : undefined;
115
132
 
116
- const childKeys = childKeyIds && childKeyIds.map((id) => KeyConfigs[id]);
133
+ const childKeys = childKeyIds
134
+ ? childKeyIds.map((id) => KeyConfigs[id])
135
+ : undefined;
117
136
 
118
137
  // Override with the default child props, if the key is a multi-symbol key
119
138
  // (but not a many-symbol key, which operates under different rules).
120
139
  const useFirstChildProps =
121
- type !== KeyTypes.MANY && childKeys && childKeys.length > 0;
140
+ type !== KeyType.MANY && childKeys && childKeys.length > 0;
122
141
 
123
142
  return {
124
143
  ...rest,
@@ -128,7 +147,7 @@ const mapStateToProps = (state, ownProps) => {
128
147
 
129
148
  // Add in some gesture state.
130
149
  focused: gestures.focus === id,
131
- popoverEnabled: gestures.popover && gestures.popover.parentId === id,
150
+ popoverEnabled: gestures.popover?.parentId === id,
132
151
 
133
152
  // Pass down the child keys and any extracted props.
134
153
  childKeys,
@@ -6,19 +6,19 @@ import {StyleSheet} from "aphrodite";
6
6
  import * as React from "react";
7
7
  import {connect} from "react-redux";
8
8
 
9
- import {View} from "../fake-react-native-web/index";
10
-
9
+ import {View} from "../../fake-react-native-web/index";
11
10
  import {
12
11
  innerBorderColor,
13
12
  innerBorderStyle,
14
13
  innerBorderWidthPx,
15
14
  offBlack16,
16
- } from "./common-style";
15
+ } from "../common-style";
16
+ import Tabbar from "../tabbar/tabbar";
17
+
17
18
  import Keypad from "./keypad";
18
19
  import Styles from "./styles";
19
- import Tabbar from "./tabbar/tabbar";
20
20
 
21
- import type {State} from "../store/types";
21
+ import type {State} from "./store/types";
22
22
 
23
23
  const {column, row, fullWidth} = Styles;
24
24
 
@@ -27,7 +27,6 @@ interface ReduxProps {
27
27
  }
28
28
 
29
29
  interface Props extends ReduxProps {
30
- currentPage: number;
31
30
  leftPage: React.ReactNode;
32
31
  rightPage: React.ReactNode;
33
32
  }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
5
5
 
6
- import {DecimalSeparators, IconTypes, KeyTypes} from "../consts";
6
+ import {DecimalSeparator, IconType, KeyType} from "../enums";
7
7
  import {decimalSeparator} from "../utils";
8
8
 
9
9
  import Keys from "./keys";
@@ -14,262 +14,257 @@ export type KeyConfig = {
14
14
  ariaLabel: string;
15
15
  };
16
16
 
17
- const KeyConfigs: any = {
17
+ // I tried to make the below {[key in Keys]: KeyConfig}
18
+ // but we are doing all kinds of sneaky magic that makes it hard to
19
+ // type this safely. Leaving it for now as a generic index signature.
20
+ const KeyConfigs: {[key: string]: any} = {
18
21
  // Basic math keys.
19
22
  [Keys.PLUS]: {
20
- type: KeyTypes.OPERATOR,
23
+ type: KeyType.OPERATOR,
21
24
  // I18N: A label for a plus sign.
22
25
  ariaLabel: i18n._("Plus"),
23
26
  },
24
27
  [Keys.MINUS]: {
25
- type: KeyTypes.OPERATOR,
28
+ type: KeyType.OPERATOR,
26
29
  // I18N: A label for a minus sign.
27
30
  ariaLabel: i18n._("Minus"),
28
31
  },
29
32
  [Keys.NEGATIVE]: {
30
- type: KeyTypes.VALUE,
33
+ type: KeyType.VALUE,
31
34
  // I18N: A label for a minus sign.
32
35
  ariaLabel: i18n._("Negative"),
33
36
  },
34
37
  [Keys.TIMES]: {
35
- type: KeyTypes.OPERATOR,
38
+ type: KeyType.OPERATOR,
36
39
  // I18N: A label for a multiplication sign (represented with an 'x').
37
40
  ariaLabel: i18n._("Multiply"),
38
41
  },
39
42
  [Keys.DIVIDE]: {
40
- type: KeyTypes.OPERATOR,
43
+ type: KeyType.OPERATOR,
41
44
  // I18N: A label for a division sign.
42
45
  ariaLabel: i18n._("Divide"),
43
46
  },
44
47
  [Keys.DECIMAL]: {
45
- type: KeyTypes.VALUE,
48
+ type: KeyType.VALUE,
46
49
  // I18N: A label for a decimal symbol.
47
50
  ariaLabel: i18n._("Decimal"),
48
51
  icon:
49
- decimalSeparator === DecimalSeparators.COMMA
52
+ decimalSeparator === DecimalSeparator.COMMA
50
53
  ? {
51
54
  // TODO(charlie): Get an SVG icon for the comma, or verify with
52
55
  // design that the text-rendered version is acceptable.
53
- type: IconTypes.TEXT,
56
+ type: IconType.TEXT,
54
57
  data: ",",
55
58
  }
56
59
  : {
57
- type: IconTypes.SVG,
60
+ type: IconType.SVG,
58
61
  data: Keys.PERIOD,
59
62
  },
60
63
  },
61
64
  [Keys.PERCENT]: {
62
- type: KeyTypes.OPERATOR,
65
+ type: KeyType.OPERATOR,
63
66
  // I18N: A label for a percent sign.
64
67
  ariaLabel: i18n._("Percent"),
65
68
  },
66
69
  [Keys.CDOT]: {
67
- type: KeyTypes.OPERATOR,
70
+ type: KeyType.OPERATOR,
68
71
  // I18N: A label for a multiplication sign (represented as a dot).
69
72
  ariaLabel: i18n._("Multiply"),
70
73
  },
71
74
  [Keys.EQUAL]: {
72
- type: KeyTypes.OPERATOR,
75
+ type: KeyType.OPERATOR,
73
76
  ariaLabel: i18n._("Equals sign"),
74
77
  },
75
78
  [Keys.NEQ]: {
76
- type: KeyTypes.OPERATOR,
79
+ type: KeyType.OPERATOR,
77
80
  ariaLabel: i18n._("Not-equals sign"),
78
81
  },
79
82
  [Keys.GT]: {
80
- type: KeyTypes.OPERATOR,
83
+ type: KeyType.OPERATOR,
81
84
  // I18N: A label for a 'greater than' sign (represented as '>').
82
85
  ariaLabel: i18n._("Greater than sign"),
83
86
  },
84
87
  [Keys.LT]: {
85
- type: KeyTypes.OPERATOR,
88
+ type: KeyType.OPERATOR,
86
89
  // I18N: A label for a 'less than' sign (represented as '<').
87
90
  ariaLabel: i18n._("Less than sign"),
88
91
  },
89
92
  [Keys.GEQ]: {
90
- type: KeyTypes.OPERATOR,
93
+ type: KeyType.OPERATOR,
91
94
  ariaLabel: i18n._("Greater than or equal to sign"),
92
95
  },
93
96
  [Keys.LEQ]: {
94
- type: KeyTypes.OPERATOR,
97
+ type: KeyType.OPERATOR,
95
98
  ariaLabel: i18n._("Less than or equal to sign"),
96
99
  },
97
100
  // mobile native
98
101
  [Keys.FRAC_INCLUSIVE]: {
99
- type: KeyTypes.OPERATOR,
102
+ type: KeyType.OPERATOR,
100
103
  // I18N: A label for a button that creates a new fraction and puts the
101
104
  // current expression in the numerator of that fraction.
102
105
  ariaLabel: i18n._("Fraction, with current expression in numerator"),
103
106
  },
104
107
  // mobile native
105
108
  [Keys.FRAC_EXCLUSIVE]: {
106
- type: KeyTypes.OPERATOR,
109
+ type: KeyType.OPERATOR,
107
110
  // I18N: A label for a button that creates a new fraction next to the
108
111
  // cursor.
109
112
  ariaLabel: i18n._("Fraction, excluding the current expression"),
110
113
  },
111
114
  // mobile web
112
115
  [Keys.FRAC]: {
113
- type: KeyTypes.OPERATOR,
116
+ type: KeyType.OPERATOR,
114
117
  // I18N: A label for a button that creates a new fraction next to the
115
118
  // cursor.
116
119
  ariaLabel: i18n._("Fraction, excluding the current expression"),
117
120
  },
118
121
  [Keys.EXP]: {
119
- type: KeyTypes.OPERATOR,
122
+ type: KeyType.OPERATOR,
120
123
  // I18N: A label for a button that will allow the user to input a custom
121
124
  // exponent.
122
125
  ariaLabel: i18n._("Custom exponent"),
123
126
  },
124
127
  [Keys.EXP_2]: {
125
- type: KeyTypes.OPERATOR,
128
+ type: KeyType.OPERATOR,
126
129
  // I18N: A label for a button that will square (take to the second
127
130
  // power) some math.
128
131
  ariaLabel: i18n._("Square"),
129
132
  },
130
133
  [Keys.EXP_3]: {
131
- type: KeyTypes.OPERATOR,
134
+ type: KeyType.OPERATOR,
132
135
  // I18N: A label for a button that will cube (take to the third power)
133
136
  // some math.
134
137
  ariaLabel: i18n._("Cube"),
135
138
  },
136
139
  [Keys.SQRT]: {
137
- type: KeyTypes.OPERATOR,
140
+ type: KeyType.OPERATOR,
138
141
  ariaLabel: i18n._("Square root"),
139
142
  },
140
143
  [Keys.CUBE_ROOT]: {
141
- type: KeyTypes.OPERATOR,
144
+ type: KeyType.OPERATOR,
142
145
  ariaLabel: i18n._("Cube root"),
143
146
  },
144
147
  [Keys.RADICAL]: {
145
- type: KeyTypes.OPERATOR,
148
+ type: KeyType.OPERATOR,
146
149
  ariaLabel: i18n._("Radical with custom root"),
147
150
  },
148
151
  [Keys.LEFT_PAREN]: {
149
- type: KeyTypes.OPERATOR,
152
+ type: KeyType.OPERATOR,
150
153
  ariaLabel: i18n._("Left parenthesis"),
151
154
  },
152
155
  [Keys.RIGHT_PAREN]: {
153
- type: KeyTypes.OPERATOR,
156
+ type: KeyType.OPERATOR,
154
157
  ariaLabel: i18n._("Right parenthesis"),
155
158
  },
156
159
  [Keys.LN]: {
157
- type: KeyTypes.OPERATOR,
160
+ type: KeyType.OPERATOR,
158
161
  ariaLabel: i18n._("Natural logarithm"),
159
162
  },
160
163
  [Keys.LOG]: {
161
- type: KeyTypes.OPERATOR,
164
+ type: KeyType.OPERATOR,
162
165
  ariaLabel: i18n._("Logarithm with base 10"),
163
166
  },
164
167
  [Keys.LOG_N]: {
165
- type: KeyTypes.OPERATOR,
168
+ type: KeyType.OPERATOR,
166
169
  ariaLabel: i18n._("Logarithm with custom base"),
167
170
  },
168
171
  [Keys.SIN]: {
169
- type: KeyTypes.OPERATOR,
172
+ type: KeyType.OPERATOR,
170
173
  ariaLabel: i18n._("Sine"),
171
174
  },
172
175
  [Keys.COS]: {
173
- type: KeyTypes.OPERATOR,
176
+ type: KeyType.OPERATOR,
174
177
  ariaLabel: i18n._("Cosine"),
175
178
  },
176
179
  [Keys.TAN]: {
177
- type: KeyTypes.OPERATOR,
180
+ type: KeyType.OPERATOR,
178
181
  ariaLabel: i18n._("Tangent"),
179
182
  },
180
183
  [Keys.PI]: {
181
- type: KeyTypes.VALUE,
184
+ type: KeyType.VALUE,
182
185
  ariaLabel: i18n._("Pi"),
183
186
  icon: {
184
- type: IconTypes.MATH,
187
+ type: IconType.MATH,
185
188
  data: "\\pi",
186
189
  },
187
190
  },
188
191
  [Keys.THETA]: {
189
- type: KeyTypes.VALUE,
192
+ type: KeyType.VALUE,
190
193
  ariaLabel: i18n._("Theta"),
191
194
  icon: {
192
- type: IconTypes.MATH,
195
+ type: IconType.MATH,
193
196
  data: "\\theta",
194
197
  },
195
198
  },
196
199
  [Keys.NOOP]: {
197
- type: KeyTypes.EMPTY,
200
+ type: KeyType.EMPTY,
198
201
  },
199
202
 
200
203
  // Input navigation keys.
201
204
  [Keys.UP]: {
202
- type: KeyTypes.INPUT_NAVIGATION,
205
+ type: KeyType.INPUT_NAVIGATION,
203
206
  ariaLabel: i18n._("Up arrow"),
204
207
  },
205
208
  [Keys.RIGHT]: {
206
- type: KeyTypes.INPUT_NAVIGATION,
209
+ type: KeyType.INPUT_NAVIGATION,
207
210
  ariaLabel: i18n._("Right arrow"),
208
211
  },
209
212
  [Keys.DOWN]: {
210
- type: KeyTypes.INPUT_NAVIGATION,
213
+ type: KeyType.INPUT_NAVIGATION,
211
214
  ariaLabel: i18n._("Down arrow"),
212
215
  },
213
216
  [Keys.LEFT]: {
214
- type: KeyTypes.INPUT_NAVIGATION,
217
+ type: KeyType.INPUT_NAVIGATION,
215
218
  ariaLabel: i18n._("Left arrow"),
216
219
  },
217
220
  [Keys.JUMP_OUT_PARENTHESES]: {
218
- type: KeyTypes.INPUT_NAVIGATION,
221
+ type: KeyType.INPUT_NAVIGATION,
219
222
  ariaLabel: i18n._("Navigate right out of a set of parentheses"),
220
223
  },
221
224
  [Keys.JUMP_OUT_EXPONENT]: {
222
- type: KeyTypes.INPUT_NAVIGATION,
225
+ type: KeyType.INPUT_NAVIGATION,
223
226
  ariaLabel: i18n._("Navigate right out of an exponent"),
224
227
  },
225
228
  [Keys.JUMP_OUT_BASE]: {
226
- type: KeyTypes.INPUT_NAVIGATION,
229
+ type: KeyType.INPUT_NAVIGATION,
227
230
  ariaLabel: i18n._("Navigate right out of a base"),
228
231
  },
229
232
  [Keys.JUMP_INTO_NUMERATOR]: {
230
- type: KeyTypes.INPUT_NAVIGATION,
233
+ type: KeyType.INPUT_NAVIGATION,
231
234
  ariaLabel: i18n._("Navigate right into the numerator of a fraction"),
232
235
  },
233
236
  [Keys.JUMP_OUT_NUMERATOR]: {
234
- type: KeyTypes.INPUT_NAVIGATION,
237
+ type: KeyType.INPUT_NAVIGATION,
235
238
  ariaLabel: i18n._(
236
239
  "Navigate right out of the numerator and into the denominator",
237
240
  ),
238
241
  },
239
242
  [Keys.JUMP_OUT_DENOMINATOR]: {
240
- type: KeyTypes.INPUT_NAVIGATION,
243
+ type: KeyType.INPUT_NAVIGATION,
241
244
  ariaLabel: i18n._(
242
245
  "Navigate right out of the denominator of a fraction",
243
246
  ),
244
247
  },
245
248
  [Keys.BACKSPACE]: {
246
- type: KeyTypes.INPUT_NAVIGATION,
249
+ type: KeyType.INPUT_NAVIGATION,
247
250
  // I18N: A label for a button that will delete some input.
248
251
  ariaLabel: i18n._("Delete"),
249
252
  },
250
253
 
251
254
  // Keypad navigation keys.
252
255
  [Keys.DISMISS]: {
253
- type: KeyTypes.KEYPAD_NAVIGATION,
256
+ type: KeyType.KEYPAD_NAVIGATION,
254
257
  // I18N: A label for a button that will dismiss/hide a keypad.
255
258
  ariaLabel: i18n._("Dismiss"),
256
259
  },
257
- };
258
260
 
259
- // Add in any multi-function buttons. By default, these keys will mix in any
260
- // configuration settings from their default child key (i.e., the first key in
261
- // the `childKeyIds` array).
262
- // TODO(charlie): Make the multi-function button's long-press interaction
263
- // accessible.
264
- // NOTE(kevinb): This is only used in the mobile native app.
265
- KeyConfigs[Keys.FRAC_MULTI] = {
266
- childKeyIds: [Keys.FRAC_INCLUSIVE, Keys.FRAC_EXCLUSIVE],
267
- };
261
+ // TODO(charlie): Use the numeral color for the 'Many' key.
262
+ // MANY: {
263
+ // type: KeyType.MANY,
264
+ // // childKeyIds will be configured by the client.
265
+ // },
268
266
 
269
- // TODO(charlie): Use the numeral color for the 'Many' key.
270
- KeyConfigs[Keys.MANY] = {
271
- type: KeyTypes.MANY,
272
- // childKeyIds will be configured by the client.
267
+ [Keys.PERIOD]: {},
273
268
  };
274
269
 
275
270
  // Add in every numeral.
@@ -280,10 +275,10 @@ for (const num of NUMBERS) {
280
275
  // would mean that we'd be using text beyond the variable key).
281
276
  const textRepresentation = `${num}`;
282
277
  KeyConfigs[`NUM_${num}`] = {
283
- type: KeyTypes.VALUE,
278
+ type: KeyType.VALUE,
284
279
  ariaLabel: textRepresentation,
285
280
  icon: {
286
- type: IconTypes.TEXT,
281
+ type: IconType.TEXT,
287
282
  data: textRepresentation,
288
283
  },
289
284
  };
@@ -324,10 +319,10 @@ for (const letter of LETTERS) {
324
319
 
325
320
  for (const textRepresentation of [lowerCaseVariable, upperCaseVariable]) {
326
321
  KeyConfigs[textRepresentation] = {
327
- type: KeyTypes.VALUE,
322
+ type: KeyType.VALUE,
328
323
  ariaLabel: textRepresentation,
329
324
  icon: {
330
- type: IconTypes.MATH,
325
+ type: IconType.MATH,
331
326
  data: textRepresentation,
332
327
  },
333
328
  };
@@ -339,7 +334,7 @@ for (const key of Object.keys(KeyConfigs)) {
339
334
  id: key,
340
335
  // Default to an SVG icon indexed by the key name.
341
336
  icon: {
342
- type: IconTypes.SVG,
337
+ type: IconType.SVG,
343
338
  data: key,
344
339
  },
345
340
  ...KeyConfigs[key],