@khanacademy/math-input 2.0.0 → 4.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 (264) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
  3. package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
  4. package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
  5. package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
  6. package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
  7. package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
  8. package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
  9. package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
  10. package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
  11. package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
  12. package/dist/components/input/math-input.d.ts +1 -1
  13. package/dist/components/input/math-input.js.flow +1 -1
  14. package/dist/components/input/math-wrapper.d.ts +7 -78
  15. package/dist/components/input/math-wrapper.js.flow +16 -78
  16. package/dist/components/input/mathquill-helpers.d.ts +46 -0
  17. package/dist/components/input/mathquill-helpers.js.flow +56 -0
  18. package/dist/components/input/mathquill-instance.d.ts +3 -0
  19. package/dist/components/input/mathquill-instance.js.flow +9 -0
  20. package/dist/components/input/mathquill-types.d.ts +25 -0
  21. package/dist/components/input/mathquill-types.js.flow +34 -0
  22. package/dist/components/key-translator.d.ts +4 -0
  23. package/dist/components/key-translator.js.flow +10 -0
  24. package/dist/components/keypad/button-assets.d.ts +2 -2
  25. package/dist/components/keypad/button-assets.js.flow +2 -2
  26. package/dist/components/keypad/button.d.ts +1 -2
  27. package/dist/components/keypad/button.js.flow +1 -1
  28. package/dist/components/keypad/{pre-algebra-page.d.ts → geometry-page/index.d.ts} +1 -1
  29. package/dist/components/keypad/{pre-algebra-page.js.flow → geometry-page/index.js.flow} +1 -1
  30. package/dist/components/keypad/index.d.ts +5 -4
  31. package/dist/components/keypad/index.js.flow +9 -4
  32. package/dist/components/keypad/keypad-page-items.d.ts +9 -3
  33. package/dist/components/keypad/keypad-page-items.js.flow +9 -3
  34. package/dist/components/keypad/{numeric-input-page.d.ts → numbers-page/index.d.ts} +3 -2
  35. package/dist/components/keypad/numbers-page/index.js.flow +17 -0
  36. package/dist/components/keypad/numbers-page/types.d.ts +4 -0
  37. package/dist/components/keypad/numbers-page/types.js.flow +10 -0
  38. package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +7 -0
  39. package/dist/components/keypad/{numeric-input-page.js.flow → operators-page/advanced-relations-buttons.js.flow} +3 -4
  40. package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +7 -0
  41. package/dist/components/keypad/{trigonometry-page.js.flow → operators-page/basic-relations-buttons.js.flow} +3 -6
  42. package/dist/components/keypad/operators-page/index.d.ts +9 -0
  43. package/dist/components/keypad/operators-page/index.js.flow +17 -0
  44. package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +7 -0
  45. package/dist/components/keypad/operators-page/logarithms-buttons.js.flow +12 -0
  46. package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +7 -0
  47. package/dist/components/keypad/operators-page/pre-algebra-buttons.js.flow +12 -0
  48. package/dist/components/keypad/operators-page/types.d.ts +6 -0
  49. package/dist/components/keypad/operators-page/types.js.flow +12 -0
  50. package/dist/components/{compute-layout-parameters.d.ts → keypad-legacy/compute-layout-parameters.d.ts} +1 -1
  51. package/dist/components/{compute-layout-parameters.js.flow → keypad-legacy/compute-layout-parameters.js.flow} +1 -1
  52. package/dist/components/{echo-manager.d.ts → keypad-legacy/echo-manager.d.ts} +2 -11
  53. package/dist/components/{echo-manager.js.flow → keypad-legacy/echo-manager.js.flow} +2 -11
  54. package/dist/components/{expression-keypad.d.ts → keypad-legacy/expression-keypad.d.ts} +3 -4
  55. package/dist/components/{expression-keypad.js.flow → keypad-legacy/expression-keypad.js.flow} +3 -4
  56. package/dist/components/{fraction-keypad.d.ts → keypad-legacy/fraction-keypad.d.ts} +2 -2
  57. package/dist/components/{fraction-keypad.js.flow → keypad-legacy/fraction-keypad.js.flow} +2 -2
  58. package/dist/components/{gesture-manager.d.ts → keypad-legacy/gesture-manager.d.ts} +22 -10
  59. package/dist/components/{gesture-manager.js.flow → keypad-legacy/gesture-manager.js.flow} +28 -13
  60. package/dist/components/{gesture-state-machine.d.ts → keypad-legacy/gesture-state-machine.d.ts} +9 -9
  61. package/dist/components/{gesture-state-machine.js.flow → keypad-legacy/gesture-state-machine.js.flow} +10 -10
  62. package/dist/components/{icon.d.ts → keypad-legacy/icon.d.ts} +1 -1
  63. package/dist/components/{icon.js.flow → keypad-legacy/icon.js.flow} +1 -1
  64. package/dist/components/{keypad-button.d.ts → keypad-legacy/keypad-button.d.ts} +6 -6
  65. package/dist/components/{keypad-button.js.flow → keypad-legacy/keypad-button.js.flow} +7 -7
  66. package/dist/components/{keypad-container.d.ts → keypad-legacy/keypad-container.d.ts} +2 -2
  67. package/dist/components/{keypad-container.js.flow → keypad-legacy/keypad-container.js.flow} +3 -3
  68. package/dist/components/{keypad.d.ts → keypad-legacy/keypad.d.ts} +3 -3
  69. package/dist/components/{keypad.js.flow → keypad-legacy/keypad.js.flow} +3 -3
  70. package/dist/components/{multi-symbol-grid.d.ts → keypad-legacy/multi-symbol-grid.d.ts} +1 -1
  71. package/dist/components/{multi-symbol-grid.js.flow → keypad-legacy/multi-symbol-grid.js.flow} +1 -1
  72. package/dist/components/{multi-symbol-popover.d.ts → keypad-legacy/multi-symbol-popover.d.ts} +1 -1
  73. package/dist/components/{multi-symbol-popover.js.flow → keypad-legacy/multi-symbol-popover.js.flow} +1 -1
  74. package/dist/components/{node-manager.d.ts → keypad-legacy/node-manager.d.ts} +3 -4
  75. package/dist/components/{node-manager.js.flow → keypad-legacy/node-manager.js.flow} +3 -5
  76. package/dist/components/{popover-manager.d.ts → keypad-legacy/popover-manager.d.ts} +1 -1
  77. package/dist/components/{popover-manager.js.flow → keypad-legacy/popover-manager.js.flow} +1 -1
  78. package/dist/components/{popover-state-machine.d.ts → keypad-legacy/popover-state-machine.d.ts} +1 -1
  79. package/dist/components/{popover-state-machine.js.flow → keypad-legacy/popover-state-machine.js.flow} +1 -1
  80. package/dist/components/{provided-keypad.d.ts → keypad-legacy/provided-keypad.d.ts} +1 -1
  81. package/dist/components/{provided-keypad.js.flow → keypad-legacy/provided-keypad.js.flow} +1 -1
  82. package/dist/{store → components/keypad-legacy/store}/actions.d.ts +6 -17
  83. package/dist/{store → components/keypad-legacy/store}/actions.js.flow +7 -22
  84. package/dist/{store → components/keypad-legacy/store}/index.d.ts +0 -1
  85. package/dist/{store → components/keypad-legacy/store}/index.js.flow +0 -1
  86. package/dist/components/keypad-legacy/store/shared.d.ts +7 -0
  87. package/dist/components/keypad-legacy/store/shared.js.flow +14 -0
  88. package/dist/{store → components/keypad-legacy/store}/types.d.ts +5 -15
  89. package/dist/{store → components/keypad-legacy/store}/types.js.flow +5 -15
  90. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +37 -0
  91. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +59 -0
  92. package/dist/components/{two-page-keypad.d.ts → keypad-legacy/two-page-keypad.d.ts} +0 -1
  93. package/dist/components/{two-page-keypad.js.flow → keypad-legacy/two-page-keypad.js.flow} +0 -1
  94. package/dist/data/key-configs.d.ts +4 -5
  95. package/dist/data/key-configs.js.flow +3 -6
  96. package/dist/data/keys.d.ts +2 -56
  97. package/dist/data/keys.js.flow +116 -57
  98. package/dist/enums.d.ts +2 -9
  99. package/dist/enums.js.flow +2 -11
  100. package/dist/es/index.js +6393 -5116
  101. package/dist/es/index.js.map +1 -1
  102. package/dist/index.d.ts +5 -3
  103. package/dist/index.js +6868 -5330
  104. package/dist/index.js.flow +6 -3
  105. package/dist/index.js.map +1 -1
  106. package/dist/strings.js +26 -10
  107. package/dist/types.d.ts +19 -17
  108. package/dist/types.js.flow +28 -23
  109. package/package.json +1 -1
  110. package/src/components/input/__tests__/context-tracking.test.ts +43 -44
  111. package/src/components/input/__tests__/mathquill.test.ts +133 -135
  112. package/src/components/input/key-handlers/handle-arrow.ts +70 -0
  113. package/src/components/input/key-handlers/handle-backspace.ts +275 -0
  114. package/src/components/input/key-handlers/handle-exponent.ts +52 -0
  115. package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
  116. package/src/components/input/math-input.tsx +12 -13
  117. package/src/components/input/math-wrapper.ts +88 -837
  118. package/src/components/input/mathquill-helpers.ts +268 -0
  119. package/src/components/input/mathquill-instance.ts +5 -0
  120. package/src/components/input/mathquill-types.ts +55 -0
  121. package/src/components/key-translator.ts +209 -0
  122. package/src/components/keypad/button-assets.tsx +452 -116
  123. package/src/components/keypad/button.stories.tsx +61 -13
  124. package/src/components/keypad/button.tsx +1 -1
  125. package/src/components/keypad/{trigonometry-page.tsx → geometry-page/index.tsx} +4 -5
  126. package/src/components/keypad/index.tsx +19 -14
  127. package/src/components/keypad/keypad-mathquill.stories.tsx +69 -0
  128. package/src/components/keypad/keypad-page-items.tsx +36 -22
  129. package/src/components/keypad/keypad-pages.stories.tsx +5 -5
  130. package/src/components/keypad/keypad.stories.tsx +75 -17
  131. package/src/components/keypad/{numeric-input-page.tsx → numbers-page/index.tsx} +47 -11
  132. package/src/components/keypad/numbers-page/types.ts +4 -0
  133. package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +32 -0
  134. package/src/components/keypad/operators-page/basic-relations-buttons.tsx +32 -0
  135. package/src/components/keypad/{pre-algebra-page.tsx → operators-page/index.tsx} +26 -30
  136. package/src/components/keypad/operators-page/logarithms-buttons.tsx +32 -0
  137. package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +36 -0
  138. package/src/components/keypad/operators-page/types.ts +6 -0
  139. package/src/components/{__tests__ → keypad-legacy/__tests__}/two-page-keypad.test.tsx +0 -2
  140. package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts} +2 -3
  141. package/src/components/{corner-decal.tsx → keypad-legacy/corner-decal.tsx} +2 -3
  142. package/src/components/{echo-manager.tsx → keypad-legacy/echo-manager.tsx} +8 -21
  143. package/src/components/{empty-keypad-button.tsx → keypad-legacy/empty-keypad-button.tsx} +8 -6
  144. package/src/components/{expression-keypad.tsx → keypad-legacy/expression-keypad.tsx} +8 -17
  145. package/src/components/{fraction-keypad.tsx → keypad-legacy/fraction-keypad.tsx} +6 -6
  146. package/src/components/{gesture-manager.ts → keypad-legacy/gesture-manager.ts} +34 -11
  147. package/src/components/{gesture-state-machine.ts → keypad-legacy/gesture-state-machine.ts} +14 -14
  148. package/src/components/{icon.tsx → keypad-legacy/icon.tsx} +3 -3
  149. package/src/components/{keypad-button.tsx → keypad-legacy/keypad-button.tsx} +26 -26
  150. package/src/components/{keypad-container.tsx → keypad-legacy/keypad-container.tsx} +6 -6
  151. package/src/components/{keypad.tsx → keypad-legacy/keypad.tsx} +5 -5
  152. package/src/components/{many-keypad-button.tsx → keypad-legacy/many-keypad-button.tsx} +13 -6
  153. package/src/components/{math-icon.tsx → keypad-legacy/math-icon.tsx} +2 -2
  154. package/src/components/{multi-symbol-grid.tsx → keypad-legacy/multi-symbol-grid.tsx} +4 -4
  155. package/src/components/{multi-symbol-popover.tsx → keypad-legacy/multi-symbol-popover.tsx} +3 -4
  156. package/src/components/{navigation-pad.tsx → keypad-legacy/navigation-pad.tsx} +5 -5
  157. package/src/components/{node-manager.ts → keypad-legacy/node-manager.ts} +2 -10
  158. package/src/components/{popover-manager.tsx → keypad-legacy/popover-manager.tsx} +2 -2
  159. package/src/components/{popover-state-machine.ts → keypad-legacy/popover-state-machine.ts} +1 -1
  160. package/src/components/{provided-keypad.tsx → keypad-legacy/provided-keypad.tsx} +4 -5
  161. package/src/{store → components/keypad-legacy/store}/actions.ts +7 -36
  162. package/src/{store → components/keypad-legacy/store}/echo-reducer.ts +3 -7
  163. package/src/{store → components/keypad-legacy/store}/index.ts +7 -20
  164. package/src/{store → components/keypad-legacy/store}/input-reducer.ts +4 -5
  165. package/src/{store → components/keypad-legacy/store}/keypad-reducer.ts +3 -4
  166. package/src/{store → components/keypad-legacy/store}/layout-reducer.ts +3 -3
  167. package/src/{store → components/keypad-legacy/store}/shared.ts +3 -3
  168. package/src/{store → components/keypad-legacy/store}/types.ts +15 -19
  169. package/src/components/{styles.ts → keypad-legacy/styles.ts} +1 -1
  170. package/src/components/{text-icon.tsx → keypad-legacy/text-icon.tsx} +2 -2
  171. package/src/components/{touchable-keypad-button.tsx → keypad-legacy/touchable-keypad-button.tsx} +35 -21
  172. package/src/components/{two-page-keypad.tsx → keypad-legacy/two-page-keypad.tsx} +5 -6
  173. package/src/components/tabbar/icons.tsx +0 -2
  174. package/src/data/key-configs.ts +751 -309
  175. package/src/data/keys.ts +118 -70
  176. package/src/enums.ts +10 -9
  177. package/src/index.ts +6 -3
  178. package/src/math-input.stories.tsx +3 -3
  179. package/src/types.ts +21 -16
  180. package/tsconfig-build.tsbuildinfo +1 -1
  181. package/dist/components/keypad/trigonometry-page.d.ts +0 -8
  182. package/dist/components/touchable-keypad-button.d.ts +0 -30
  183. package/dist/components/touchable-keypad-button.js.flow +0 -35
  184. package/dist/components/velocity-tracker.d.ts +0 -48
  185. package/dist/components/velocity-tracker.js.flow +0 -54
  186. package/dist/store/pager-reducer.d.ts +0 -4
  187. package/dist/store/pager-reducer.js.flow +0 -13
  188. package/dist/store/shared.d.ts +0 -7
  189. package/dist/store/shared.js.flow +0 -14
  190. package/src/components/velocity-tracker.ts +0 -86
  191. package/src/store/pager-reducer.ts +0 -125
  192. /package/dist/components/{corner-decal.d.ts → keypad-legacy/corner-decal.d.ts} +0 -0
  193. /package/dist/components/{corner-decal.js.flow → keypad-legacy/corner-decal.js.flow} +0 -0
  194. /package/dist/components/{empty-keypad-button.d.ts → keypad-legacy/empty-keypad-button.d.ts} +0 -0
  195. /package/dist/components/{empty-keypad-button.js.flow → keypad-legacy/empty-keypad-button.js.flow} +0 -0
  196. /package/dist/components/{many-keypad-button.d.ts → keypad-legacy/many-keypad-button.d.ts} +0 -0
  197. /package/dist/components/{many-keypad-button.js.flow → keypad-legacy/many-keypad-button.js.flow} +0 -0
  198. /package/dist/components/{math-icon.d.ts → keypad-legacy/math-icon.d.ts} +0 -0
  199. /package/dist/components/{math-icon.js.flow → keypad-legacy/math-icon.js.flow} +0 -0
  200. /package/dist/components/{navigation-pad.d.ts → keypad-legacy/navigation-pad.d.ts} +0 -0
  201. /package/dist/components/{navigation-pad.js.flow → keypad-legacy/navigation-pad.js.flow} +0 -0
  202. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.d.ts +0 -0
  203. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.js.flow +0 -0
  204. /package/dist/{store → components/keypad-legacy/store}/input-reducer.d.ts +0 -0
  205. /package/dist/{store → components/keypad-legacy/store}/input-reducer.js.flow +0 -0
  206. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.d.ts +0 -0
  207. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.js.flow +0 -0
  208. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.d.ts +0 -0
  209. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.js.flow +0 -0
  210. /package/dist/components/{styles.d.ts → keypad-legacy/styles.d.ts} +0 -0
  211. /package/dist/components/{styles.js.flow → keypad-legacy/styles.js.flow} +0 -0
  212. /package/dist/components/{svg-icon.d.ts → keypad-legacy/svg-icon.d.ts} +0 -0
  213. /package/dist/components/{svg-icon.js.flow → keypad-legacy/svg-icon.js.flow} +0 -0
  214. /package/dist/components/{text-icon.d.ts → keypad-legacy/text-icon.d.ts} +0 -0
  215. /package/dist/components/{text-icon.js.flow → keypad-legacy/text-icon.js.flow} +0 -0
  216. /package/dist/components/{z-indexes.d.ts → keypad-legacy/z-indexes.d.ts} +0 -0
  217. /package/dist/components/{z-indexes.js.flow → keypad-legacy/z-indexes.js.flow} +0 -0
  218. /package/src/components/{__tests__ → keypad-legacy/__tests__}/gesture-state-machine.test.ts +0 -0
  219. /package/src/components/{__tests__ → keypad-legacy/__tests__}/node-manager.test.ts +0 -0
  220. /package/src/components/{iconography → keypad-legacy/iconography}/arrow.js +0 -0
  221. /package/src/components/{iconography → keypad-legacy/iconography}/backspace.js +0 -0
  222. /package/src/components/{iconography → keypad-legacy/iconography}/cdot.js +0 -0
  223. /package/src/components/{iconography → keypad-legacy/iconography}/cos.js +0 -0
  224. /package/src/components/{iconography → keypad-legacy/iconography}/cube-root.js +0 -0
  225. /package/src/components/{iconography → keypad-legacy/iconography}/dismiss.js +0 -0
  226. /package/src/components/{iconography → keypad-legacy/iconography}/divide.js +0 -0
  227. /package/src/components/{iconography → keypad-legacy/iconography}/down.js +0 -0
  228. /package/src/components/{iconography → keypad-legacy/iconography}/equal.js +0 -0
  229. /package/src/components/{iconography → keypad-legacy/iconography}/exp-2.js +0 -0
  230. /package/src/components/{iconography → keypad-legacy/iconography}/exp-3.js +0 -0
  231. /package/src/components/{iconography → keypad-legacy/iconography}/exp.js +0 -0
  232. /package/src/components/{iconography → keypad-legacy/iconography}/frac.js +0 -0
  233. /package/src/components/{iconography → keypad-legacy/iconography}/geq.js +0 -0
  234. /package/src/components/{iconography → keypad-legacy/iconography}/gt.js +0 -0
  235. /package/src/components/{iconography → keypad-legacy/iconography}/index.js +0 -0
  236. /package/src/components/{iconography → keypad-legacy/iconography}/jump-into-numerator.js +0 -0
  237. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-base.js +0 -0
  238. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-denominator.js +0 -0
  239. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-exponent.js +0 -0
  240. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-numerator.js +0 -0
  241. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-parentheses.js +0 -0
  242. /package/src/components/{iconography → keypad-legacy/iconography}/left-paren.js +0 -0
  243. /package/src/components/{iconography → keypad-legacy/iconography}/left.js +0 -0
  244. /package/src/components/{iconography → keypad-legacy/iconography}/leq.js +0 -0
  245. /package/src/components/{iconography → keypad-legacy/iconography}/ln.js +0 -0
  246. /package/src/components/{iconography → keypad-legacy/iconography}/log-n.js +0 -0
  247. /package/src/components/{iconography → keypad-legacy/iconography}/log.js +0 -0
  248. /package/src/components/{iconography → keypad-legacy/iconography}/lt.js +0 -0
  249. /package/src/components/{iconography → keypad-legacy/iconography}/minus.js +0 -0
  250. /package/src/components/{iconography → keypad-legacy/iconography}/neq.js +0 -0
  251. /package/src/components/{iconography → keypad-legacy/iconography}/parens.js +0 -0
  252. /package/src/components/{iconography → keypad-legacy/iconography}/percent.js +0 -0
  253. /package/src/components/{iconography → keypad-legacy/iconography}/period.js +0 -0
  254. /package/src/components/{iconography → keypad-legacy/iconography}/plus.js +0 -0
  255. /package/src/components/{iconography → keypad-legacy/iconography}/radical.js +0 -0
  256. /package/src/components/{iconography → keypad-legacy/iconography}/right-paren.js +0 -0
  257. /package/src/components/{iconography → keypad-legacy/iconography}/right.js +0 -0
  258. /package/src/components/{iconography → keypad-legacy/iconography}/sin.js +0 -0
  259. /package/src/components/{iconography → keypad-legacy/iconography}/sqrt.js +0 -0
  260. /package/src/components/{iconography → keypad-legacy/iconography}/tan.js +0 -0
  261. /package/src/components/{iconography → keypad-legacy/iconography}/times.js +0 -0
  262. /package/src/components/{iconography → keypad-legacy/iconography}/up.js +0 -0
  263. /package/src/components/{svg-icon.tsx → keypad-legacy/svg-icon.tsx} +0 -0
  264. /package/src/components/{z-indexes.ts → keypad-legacy/z-indexes.ts} +0 -0
package/dist/strings.js CHANGED
@@ -5,43 +5,51 @@
5
5
  */
6
6
 
7
7
  module.exports = [
8
+ // I18N: A label for a button that will allow the user to input a
8
9
  i18n._("Cosine", {}),
9
10
  // I18N: A label for a button that will cube (take to the third power)
10
11
  i18n._("Cube", {}),
12
+ // I18N: A label for a button that will allow the user to input a
11
13
  i18n._("Cube root", {}),
12
- // I18N: A label for a button that will allow the user to input a custom
14
+ // I18N: A label for a button that will allow the user to input a
13
15
  i18n._("Custom exponent", {}),
14
- // I18N: A label for a decimal symbol.
16
+ // I18N: A label for a 'decimal' sign (represented as '.' or ',').
15
17
  i18n._("Decimal", {}),
16
- // I18N: A label for a button that will delete some input.
17
18
  i18n._("Delete", {}),
18
19
  // I18N: A label for a button that will dismiss/hide a keypad.
19
20
  i18n._("Dismiss", {}),
20
- // I18N: A label for a division sign.
21
+ // I18N: A label for a 'divide' sign.
21
22
  i18n._("Divide", {}),
22
23
  i18n._("Down arrow", {}),
24
+ // I18N: A label for an 'equals' sign (represented as '=').
23
25
  i18n._("Equals sign", {}),
24
26
  // I18N: A label for a button that creates a new fraction next to the
25
27
  // I18N: A label for a button that creates a new fraction next to the
26
28
  i18n._("Fraction, excluding the current expression", {}),
27
29
  // I18N: A label for a button that creates a new fraction and puts the
28
30
  i18n._("Fraction, with current expression in numerator", {}),
31
+ // I18N: A label for a 'greater than or equal to' sign (represented as '≥').
29
32
  i18n._("Greater than or equal to sign", {}),
30
33
  // I18N: A label for a 'greater than' sign (represented as '>').
31
34
  i18n._("Greater than sign", {}),
32
35
  i18n._("Left arrow", {}),
36
+ // I18N: A label for a button that will allow the user to input a
33
37
  i18n._("Left parenthesis", {}),
38
+ // I18N: A label for a 'less than or equal to' sign (represented as '≤').
34
39
  i18n._("Less than or equal to sign", {}),
35
40
  // I18N: A label for a 'less than' sign (represented as '<').
36
41
  i18n._("Less than sign", {}),
42
+ // I18N: A label for a button that will allow the user to input a
37
43
  i18n._("Logarithm with base 10", {}),
44
+ // I18N: A label for a button that will allow the user to input a
38
45
  i18n._("Logarithm with custom base", {}),
39
46
  i18n._("Math input box", {}),
40
- // I18N: A label for a minus sign.
47
+ // I18N: A label for a 'minus' sign.
41
48
  i18n._("Minus", {}),
42
- // I18N: A label for a multiplication sign (represented with an 'x').
43
- // I18N: A label for a multiplication sign (represented as a dot).
49
+ // I18N: A label for a 'multiply' sign.
50
+ // I18N: A label for a 'centered dot' multiplication sign (represented as '⋅').
44
51
  i18n._("Multiply", {}),
52
+ // I18N: A label for a button that will allow the user to input a
45
53
  i18n._("Natural logarithm", {}),
46
54
  i18n._("Navigate right into the numerator of a fraction", {}),
47
55
  i18n._("Navigate right out of a base", {}),
@@ -49,23 +57,31 @@ module.exports = [
49
57
  i18n._("Navigate right out of an exponent", {}),
50
58
  i18n._("Navigate right out of the denominator of a fraction", {}),
51
59
  i18n._("Navigate right out of the numerator and into the denominator", {}),
52
- // I18N: A label for a minus sign.
60
+ // I18N: A label for a 'negative' sign.
53
61
  i18n._("Negative", {}),
62
+ // I18N: A label for a 'not-equals' sign (represented as '≠').
54
63
  i18n._("Not-equals sign", {}),
55
- // I18N: A label for a percent sign.
64
+ // I18N: A label for a 'percent' sign (represented as '%').
56
65
  i18n._("Percent", {}),
66
+ // I18N: A label for a button that will allow the user to input the
57
67
  i18n._("Pi", {}),
58
- // I18N: A label for a plus sign.
68
+ // I18N: A label for a 'plus' sign.
59
69
  i18n._("Plus", {}),
70
+ // I18N: A label for a button that will allow the user to input a
60
71
  i18n._("Radical with custom root", {}),
61
72
  i18n._("Right arrow", {}),
73
+ // I18N: A label for a button that will allow the user to input a
62
74
  i18n._("Right parenthesis", {}),
75
+ // I18N: A label for a button that will allow the user to input a
63
76
  i18n._("Sine", {}),
64
77
  // I18N: A label for a button that will square (take to the second
65
78
  i18n._("Square", {}),
79
+ // I18N: A label for a button that will allow the user to input a
66
80
  i18n._("Square root", {}),
81
+ // I18N: A label for a button that will allow the user to input a
67
82
  i18n._("Tangent", {}),
68
83
  i18n._("Tap with one or two fingers to open keyboard", {}),
84
+ // I18N: A label for a button that will allow the user to input the
69
85
  i18n._("Theta", {}),
70
86
  i18n._("Up arrow", {}),
71
87
  ];
package/dist/types.d.ts CHANGED
@@ -1,43 +1,46 @@
1
- import Keys from "./data/keys";
1
+ import Key from "./data/keys";
2
2
  import { BorderDirection, EchoAnimationType, IconType, KeyType, KeypadType } from "./enums";
3
3
  import type { CursorContext } from "./components/input/cursor-contexts";
4
4
  export type Border = Partial<ReadonlyArray<BorderDirection>>;
5
- export type Bound = {
5
+ export interface Bound {
6
6
  top: number;
7
7
  right: number;
8
8
  bottom: number;
9
9
  left: number;
10
10
  height: number;
11
11
  width: number;
12
- };
12
+ }
13
13
  export type Popover = {
14
- parentId: Keys;
14
+ parentId: Key;
15
15
  bounds: Partial<Bound>;
16
- childKeyIds: Array<Keys>;
16
+ childKeyIds: Array<Key>;
17
17
  };
18
18
  export type Echo = {
19
19
  animationId: string;
20
20
  animationType: EchoAnimationType;
21
- borders: Border;
22
- id: Keys;
23
- initialBounds: DOMRect;
21
+ id: Key;
22
+ initialBounds: Bound;
24
23
  };
25
24
  export type IconConfig = {
26
25
  type: IconType;
27
26
  data: string;
28
27
  };
29
- export type KeyConfig = {
30
- ariaLabel: string;
31
- id: Keys;
32
- type: KeyType;
33
- childKeyIds: Array<Keys>;
28
+ export type NonManyKeyConfig = {
29
+ id: Key;
30
+ type: Exclude<KeyType, "MANY">;
34
31
  icon: IconConfig;
32
+ ariaLabel: string;
33
+ };
34
+ export type ManyKeyConfig = Omit<NonManyKeyConfig, "type"> & {
35
+ type: Extract<KeyType, "MANY">;
36
+ childKeyIds: ReadonlyArray<string>;
35
37
  };
38
+ export type KeyConfig = NonManyKeyConfig | ManyKeyConfig;
36
39
  export type KeypadConfiguration = {
37
40
  keypadType: KeypadType;
38
- extraKeys?: ReadonlyArray<Keys>;
41
+ extraKeys?: ReadonlyArray<Key>;
39
42
  };
40
- export type KeyHandler = (key: Keys) => Cursor;
43
+ export type KeyHandler = (key: Key) => Cursor;
41
44
  export type Cursor = {
42
45
  context: CursorContext;
43
46
  };
@@ -56,7 +59,6 @@ export type ActiveNodesObj = {
56
59
  focus: string | null;
57
60
  };
58
61
  export type LayoutProps = {
59
- initialBounds: DOMRect;
60
- borders: Border;
62
+ initialBounds: Bound;
61
63
  };
62
64
  export {};
@@ -4,7 +4,7 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- import Keys from "./data/keys";
7
+ import Key from "./data/keys";
8
8
  import {
9
9
  BorderDirection,
10
10
  EchoAnimationType,
@@ -14,42 +14,48 @@ import {
14
14
  } from "./enums";
15
15
  import type { CursorContext } from "./components/input/cursor-contexts";
16
16
  export type Border = $Rest<$ReadOnlyArray<BorderDirection>, {}>;
17
- export type Bound = {|
18
- top: number,
19
- right: number,
20
- bottom: number,
21
- left: number,
22
- height: number,
23
- width: number,
24
- |};
17
+ export interface Bound {
18
+ top: number;
19
+ right: number;
20
+ bottom: number;
21
+ left: number;
22
+ height: number;
23
+ width: number;
24
+ }
25
25
  export type Popover = {|
26
- parentId: Keys,
26
+ parentId: Key,
27
27
  bounds: $Rest<Bound, {}>,
28
- childKeyIds: Array<Keys>,
28
+ childKeyIds: Array<Key>,
29
29
  |};
30
30
  export type Echo = {|
31
31
  animationId: string,
32
32
  animationType: EchoAnimationType,
33
- borders: Border,
34
- id: Keys,
35
- initialBounds: DOMRect,
33
+ id: Key,
34
+ initialBounds: Bound,
36
35
  |};
37
36
  export type IconConfig = {|
38
37
  type: IconType,
39
38
  data: string,
40
39
  |};
41
- export type KeyConfig = {|
42
- ariaLabel: string,
43
- id: Keys,
44
- type: KeyType,
45
- childKeyIds: Array<Keys>,
40
+ export type NonManyKeyConfig = {|
41
+ id: Key,
42
+ type: Exclude<KeyType, "MANY">,
46
43
  icon: IconConfig,
44
+ ariaLabel: string,
45
+ |};
46
+ export type ManyKeyConfig = {|
47
+ ...$Diff<NonManyKeyConfig, { type: any }>,
48
+ ...{|
49
+ type: Extract<KeyType, "MANY">,
50
+ childKeyIds: $ReadOnlyArray<string>,
51
+ |},
47
52
  |};
53
+ export type KeyConfig = NonManyKeyConfig | ManyKeyConfig;
48
54
  export type KeypadConfiguration = {|
49
55
  keypadType: KeypadType,
50
- extraKeys?: $ReadOnlyArray<Keys>,
56
+ extraKeys?: $ReadOnlyArray<Key>,
51
57
  |};
52
- export type KeyHandler = (key: Keys) => Cursor;
58
+ export type KeyHandler = (key: Key) => Cursor;
53
59
  export type Cursor = {|
54
60
  context: CursorContext,
55
61
  |};
@@ -68,6 +74,5 @@ export type ActiveNodesObj = {|
68
74
  focus: string | null,
69
75
  |};
70
76
  export type LayoutProps = {|
71
- initialBounds: DOMRect,
72
- borders: Border,
77
+ initialBounds: Bound,
73
78
  |};
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": "2.0.0",
6
+ "version": "4.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,4 +1,3 @@
1
- import Keys from "../../../data/keys";
2
1
  import {CursorContext} from "../cursor-contexts";
3
2
 
4
3
  import TestMathWrapper from "./test-math-wrapper";
@@ -27,65 +26,65 @@ describe("Cursor context", () => {
27
26
 
28
27
  it("should treat numbers and ternary operators as non-jumpable", () => {
29
28
  mathField.pressKey("NUM_1");
30
- mathField.pressKey(Keys.CDOT);
29
+ mathField.pressKey("CDOT");
31
30
  const cursor = mathField.pressKey("NUM_2");
32
31
  expect(cursor.context).toEqual(CursorContext.NONE);
33
32
  });
34
33
 
35
34
  describe("Before fraction", () => {
36
35
  it("should detect when immediately to the left", () => {
37
- const cursor = mathField.pressKey(Keys.FRAC_EXCLUSIVE);
36
+ const cursor = mathField.pressKey("FRAC_EXCLUSIVE");
38
37
  expect(cursor.context).toEqual(CursorContext.BEFORE_FRACTION);
39
38
  });
40
39
 
41
40
  it("should detect when numbers are between", () => {
42
41
  mathField.pressKey("NUM_1");
43
- mathField.pressKey(Keys.FRAC_EXCLUSIVE);
44
- mathField.pressKey(Keys.LEFT);
45
- const cursor = mathField.pressKey(Keys.LEFT);
42
+ mathField.pressKey("FRAC_EXCLUSIVE");
43
+ mathField.pressKey("LEFT");
44
+ const cursor = mathField.pressKey("LEFT");
46
45
  expect(cursor.context).toEqual(CursorContext.BEFORE_FRACTION);
47
46
  });
48
47
 
49
48
  it("should not detect when operators are between", () => {
50
49
  mathField.pressKey("NUM_1");
51
- mathField.pressKey(Keys.PLUS);
50
+ mathField.pressKey("PLUS");
52
51
  mathField.pressKey("NUM_2");
53
- mathField.pressKey(Keys.FRAC_EXCLUSIVE);
54
- mathField.pressKey(Keys.LEFT);
55
- mathField.pressKey(Keys.LEFT);
56
- mathField.pressKey(Keys.LEFT);
57
- const cursor = mathField.pressKey(Keys.LEFT);
52
+ mathField.pressKey("FRAC_EXCLUSIVE");
53
+ mathField.pressKey("LEFT");
54
+ mathField.pressKey("LEFT");
55
+ mathField.pressKey("LEFT");
56
+ const cursor = mathField.pressKey("LEFT");
58
57
  expect(cursor.context).toEqual(CursorContext.NONE);
59
58
  });
60
59
 
61
60
  it("should not detect when parens are between", () => {
62
61
  mathField.pressKey("NUM_1");
63
- mathField.pressKey(Keys.LEFT_PAREN);
64
- mathField.pressKey(Keys.RIGHT_PAREN);
62
+ mathField.pressKey("LEFT_PAREN");
63
+ mathField.pressKey("RIGHT_PAREN");
65
64
  mathField.pressKey("NUM_2");
66
- mathField.pressKey(Keys.FRAC_EXCLUSIVE);
67
- mathField.pressKey(Keys.LEFT);
68
- mathField.pressKey(Keys.LEFT);
69
- mathField.pressKey(Keys.LEFT);
70
- mathField.pressKey(Keys.LEFT);
71
- const cursor = mathField.pressKey(Keys.LEFT);
65
+ mathField.pressKey("FRAC_EXCLUSIVE");
66
+ mathField.pressKey("LEFT");
67
+ mathField.pressKey("LEFT");
68
+ mathField.pressKey("LEFT");
69
+ mathField.pressKey("LEFT");
70
+ const cursor = mathField.pressKey("LEFT");
72
71
  expect(cursor.context).toEqual(CursorContext.NONE);
73
72
  });
74
73
  });
75
74
 
76
75
  describe("In parens", () => {
77
76
  it("should detect when inside empty parens", () => {
78
- mathField.pressKey(Keys.LEFT_PAREN);
79
- mathField.pressKey(Keys.RIGHT_PAREN);
80
- const cursor = mathField.pressKey(Keys.LEFT);
77
+ mathField.pressKey("LEFT_PAREN");
78
+ mathField.pressKey("RIGHT_PAREN");
79
+ const cursor = mathField.pressKey("LEFT");
81
80
  expect(cursor.context).toEqual(CursorContext.IN_PARENS);
82
81
  });
83
82
 
84
83
  it("should detect when inside non-empty parens", () => {
85
- mathField.pressKey(Keys.LEFT_PAREN);
84
+ mathField.pressKey("LEFT_PAREN");
86
85
  mathField.pressKey("NUM_2");
87
- mathField.pressKey(Keys.RIGHT_PAREN);
88
- const cursor = mathField.pressKey(Keys.LEFT);
86
+ mathField.pressKey("RIGHT_PAREN");
87
+ const cursor = mathField.pressKey("LEFT");
89
88
  expect(cursor.context).toEqual(CursorContext.IN_PARENS);
90
89
  });
91
90
  });
@@ -93,13 +92,13 @@ describe("Cursor context", () => {
93
92
  describe("In superscript", () => {
94
93
  it("should detect when inside empty superscript", () => {
95
94
  mathField.pressKey("NUM_2");
96
- const cursor = mathField.pressKey(Keys.EXP);
95
+ const cursor = mathField.pressKey("EXP");
97
96
  expect(cursor.context).toEqual(CursorContext.IN_SUPER_SCRIPT);
98
97
  });
99
98
 
100
99
  it("should detect when inside non-empty superscript", () => {
101
100
  mathField.pressKey("NUM_2");
102
- mathField.pressKey(Keys.EXP);
101
+ mathField.pressKey("EXP");
103
102
  const cursor = mathField.pressKey("NUM_3");
104
103
  expect(cursor.context).toEqual(CursorContext.IN_SUPER_SCRIPT);
105
104
  });
@@ -107,12 +106,12 @@ describe("Cursor context", () => {
107
106
 
108
107
  describe("In subscript", () => {
109
108
  it("should detect when inside empty superscript", () => {
110
- const cursor = mathField.pressKey(Keys.LOG_N);
109
+ const cursor = mathField.pressKey("LOG_N");
111
110
  expect(cursor.context).toEqual(CursorContext.IN_SUB_SCRIPT);
112
111
  });
113
112
 
114
113
  it("should detect when inside non-empty superscript", () => {
115
- mathField.pressKey(Keys.LOG_N);
114
+ mathField.pressKey("LOG_N");
116
115
  const cursor = mathField.pressKey("NUM_2");
117
116
  expect(cursor.context).toEqual(CursorContext.IN_SUB_SCRIPT);
118
117
  });
@@ -120,12 +119,12 @@ describe("Cursor context", () => {
120
119
 
121
120
  describe("In numerator", () => {
122
121
  it("should detect when inside empty numerator", () => {
123
- const cursor = mathField.pressKey(Keys.FRAC_INCLUSIVE);
122
+ const cursor = mathField.pressKey("FRAC_INCLUSIVE");
124
123
  expect(cursor.context).toEqual(CursorContext.IN_NUMERATOR);
125
124
  });
126
125
 
127
126
  it("should detect when inside non-empty numerator", () => {
128
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
127
+ mathField.pressKey("FRAC_INCLUSIVE");
129
128
  const cursor = mathField.pressKey("NUM_2");
130
129
  expect(cursor.context).toEqual(CursorContext.IN_NUMERATOR);
131
130
  });
@@ -133,14 +132,14 @@ describe("Cursor context", () => {
133
132
 
134
133
  describe("In denominator", () => {
135
134
  it("should detect when inside empty denominator", () => {
136
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
137
- const cursor = mathField.pressKey(Keys.RIGHT);
135
+ mathField.pressKey("FRAC_INCLUSIVE");
136
+ const cursor = mathField.pressKey("RIGHT");
138
137
  expect(cursor.context).toEqual(CursorContext.IN_DENOMINATOR);
139
138
  });
140
139
 
141
140
  it("should detect when inside non-empty denominator", () => {
142
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
143
- mathField.pressKey(Keys.RIGHT);
141
+ mathField.pressKey("FRAC_INCLUSIVE");
142
+ mathField.pressKey("RIGHT");
144
143
  const cursor = mathField.pressKey("NUM_2");
145
144
  expect(cursor.context).toEqual(CursorContext.IN_DENOMINATOR);
146
145
  });
@@ -149,18 +148,18 @@ describe("Cursor context", () => {
149
148
  describe("Nesting", () => {
150
149
  it("should defer to jumping into fraction if possible", () => {
151
150
  // Move inside parens, but include a fraction.
152
- mathField.pressKey(Keys.LEFT_PAREN);
151
+ mathField.pressKey("LEFT_PAREN");
153
152
  mathField.pressKey("NUM_2");
154
- mathField.pressKey(Keys.FRAC_EXCLUSIVE);
155
- const cursor = mathField.pressKey(Keys.LEFT);
153
+ mathField.pressKey("FRAC_EXCLUSIVE");
154
+ const cursor = mathField.pressKey("LEFT");
156
155
  expect(cursor.context).toEqual(CursorContext.BEFORE_FRACTION);
157
156
  });
158
157
 
159
158
  it("should defer to the nearest parent (1)", () => {
160
159
  // Move inside parens, inside a superscript.
161
160
  mathField.pressKey("NUM_2");
162
- mathField.pressKey(Keys.EXP);
163
- mathField.pressKey(Keys.LEFT_PAREN);
161
+ mathField.pressKey("EXP");
162
+ mathField.pressKey("LEFT_PAREN");
164
163
  const cursor = mathField.pressKey("NUM_3");
165
164
  expect(cursor.context).toEqual(CursorContext.IN_PARENS);
166
165
  });
@@ -168,9 +167,9 @@ describe("Cursor context", () => {
168
167
  it("should defer to the nearest parent (2)", () => {
169
168
  // Nest fractions, and put cursor in the denominator of the fraction
170
169
  // in the numerator.
171
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
172
- mathField.pressKey(Keys.FRAC_INCLUSIVE);
173
- const cursor = mathField.pressKey(Keys.RIGHT);
170
+ mathField.pressKey("FRAC_INCLUSIVE");
171
+ mathField.pressKey("FRAC_INCLUSIVE");
172
+ const cursor = mathField.pressKey("RIGHT");
174
173
  expect(cursor.context).toEqual(CursorContext.IN_DENOMINATOR);
175
174
  });
176
175
  });