@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
@@ -4,47 +4,113 @@
4
4
  import * as i18n from "@khanacademy/wonder-blocks-i18n";
5
5
 
6
6
  import {DecimalSeparator, IconType, KeyType} from "../enums";
7
+ import {KeyConfig} from "../types";
7
8
  import {decimalSeparator} from "../utils";
8
9
 
9
- import Keys from "./keys";
10
+ import Key from "./keys";
10
11
 
11
- export type KeyConfig = {
12
- id: string;
13
- type: string;
14
- ariaLabel: string;
15
- };
12
+ type KeyConfigMapper = (args: {
13
+ key: Key;
14
+ keyType?: KeyType;
15
+ iconType?: IconType;
16
+ ariaLabel?: string;
17
+ data?: string;
18
+ }) => KeyConfig;
19
+
20
+ const getDefaultOperatorFields: KeyConfigMapper = ({
21
+ key,
22
+ keyType = "OPERATOR",
23
+ iconType = IconType.SVG,
24
+ ariaLabel = key,
25
+ data = key,
26
+ }) => ({
27
+ id: key,
28
+ type: keyType,
29
+ ariaLabel,
30
+ icon: {
31
+ type: iconType,
32
+ data,
33
+ },
34
+ });
35
+
36
+ const getDefaultValueFields: KeyConfigMapper = ({
37
+ key,
38
+ keyType = "VALUE",
39
+ iconType = IconType.MATH,
40
+ ariaLabel = key,
41
+ data = key,
42
+ }) => ({
43
+ id: key,
44
+ type: keyType,
45
+ ariaLabel,
46
+ icon: {
47
+ type: iconType,
48
+ data,
49
+ },
50
+ });
16
51
 
17
- const KeyConfigs: any = {
18
- // Basic math keys.
19
- [Keys.PLUS]: {
20
- type: KeyType.OPERATOR,
21
- // I18N: A label for a plus sign.
22
- ariaLabel: i18n._("Plus"),
23
- },
24
- [Keys.MINUS]: {
25
- type: KeyType.OPERATOR,
26
- // I18N: A label for a minus sign.
27
- ariaLabel: i18n._("Minus"),
28
- },
29
- [Keys.NEGATIVE]: {
30
- type: KeyType.VALUE,
31
- // I18N: A label for a minus sign.
32
- ariaLabel: i18n._("Negative"),
33
- },
34
- [Keys.TIMES]: {
35
- type: KeyType.OPERATOR,
36
- // I18N: A label for a multiplication sign (represented with an 'x').
37
- ariaLabel: i18n._("Multiply"),
38
- },
39
- [Keys.DIVIDE]: {
40
- type: KeyType.OPERATOR,
41
- // I18N: A label for a division sign.
42
- ariaLabel: i18n._("Divide"),
43
- },
44
- [Keys.DECIMAL]: {
45
- type: KeyType.VALUE,
46
- // I18N: A label for a decimal symbol.
47
- ariaLabel: i18n._("Decimal"),
52
+ const getDefaultNumberFields: KeyConfigMapper = ({
53
+ key,
54
+ data = key.replace("NUM_", ""),
55
+ keyType = "VALUE",
56
+ iconType = IconType.TEXT,
57
+ ariaLabel = data,
58
+ }) => ({
59
+ id: key,
60
+ type: keyType,
61
+ ariaLabel,
62
+ icon: {
63
+ type: iconType,
64
+ data,
65
+ },
66
+ });
67
+
68
+ const KeyConfigs: {
69
+ [key in Key]: KeyConfig;
70
+ } = {
71
+ // Basic math
72
+ PLUS: {
73
+ ...getDefaultOperatorFields({
74
+ key: "PLUS",
75
+ // I18N: A label for a 'plus' sign.
76
+ ariaLabel: i18n._("Plus"),
77
+ }),
78
+ },
79
+ MINUS: {
80
+ ...getDefaultOperatorFields({
81
+ key: "MINUS",
82
+ // I18N: A label for a 'minus' sign.
83
+ ariaLabel: i18n._("Minus"),
84
+ }),
85
+ },
86
+ NEGATIVE: {
87
+ ...getDefaultOperatorFields({
88
+ key: "NEGATIVE",
89
+ // I18N: A label for a 'negative' sign.
90
+ ariaLabel: i18n._("Negative"),
91
+ }),
92
+ },
93
+ TIMES: {
94
+ ...getDefaultOperatorFields({
95
+ key: "TIMES",
96
+ // I18N: A label for a 'multiply' sign.
97
+ ariaLabel: i18n._("Multiply"),
98
+ }),
99
+ },
100
+ DIVIDE: {
101
+ ...getDefaultOperatorFields({
102
+ key: "DIVIDE",
103
+ // I18N: A label for a 'divide' sign.
104
+ ariaLabel: i18n._("Divide"),
105
+ }),
106
+ },
107
+ DECIMAL: {
108
+ ...getDefaultOperatorFields({
109
+ key: "DECIMAL",
110
+ keyType: "VALUE",
111
+ // I18N: A label for a 'decimal' sign (represented as '.' or ',').
112
+ ariaLabel: i18n._("Decimal"),
113
+ }),
48
114
  icon:
49
115
  decimalSeparator === DecimalSeparator.COMMA
50
116
  ? {
@@ -55,295 +121,671 @@ const KeyConfigs: any = {
55
121
  }
56
122
  : {
57
123
  type: IconType.SVG,
58
- data: Keys.PERIOD,
124
+ data: "PERIOD",
59
125
  },
60
126
  },
61
- [Keys.PERCENT]: {
62
- type: KeyType.OPERATOR,
63
- // I18N: A label for a percent sign.
64
- ariaLabel: i18n._("Percent"),
65
- },
66
- [Keys.CDOT]: {
67
- type: KeyType.OPERATOR,
68
- // I18N: A label for a multiplication sign (represented as a dot).
69
- ariaLabel: i18n._("Multiply"),
70
- },
71
- [Keys.EQUAL]: {
72
- type: KeyType.OPERATOR,
73
- ariaLabel: i18n._("Equals sign"),
74
- },
75
- [Keys.NEQ]: {
76
- type: KeyType.OPERATOR,
77
- ariaLabel: i18n._("Not-equals sign"),
78
- },
79
- [Keys.GT]: {
80
- type: KeyType.OPERATOR,
81
- // I18N: A label for a 'greater than' sign (represented as '>').
82
- ariaLabel: i18n._("Greater than sign"),
83
- },
84
- [Keys.LT]: {
85
- type: KeyType.OPERATOR,
86
- // I18N: A label for a 'less than' sign (represented as '<').
87
- ariaLabel: i18n._("Less than sign"),
88
- },
89
- [Keys.GEQ]: {
90
- type: KeyType.OPERATOR,
91
- ariaLabel: i18n._("Greater than or equal to sign"),
92
- },
93
- [Keys.LEQ]: {
94
- type: KeyType.OPERATOR,
95
- ariaLabel: i18n._("Less than or equal to sign"),
127
+ PERIOD: {
128
+ ...getDefaultOperatorFields({
129
+ key: "PERIOD",
130
+ keyType: "VALUE",
131
+ ariaLabel: ".",
132
+ }),
133
+ },
134
+ PERCENT: {
135
+ ...getDefaultOperatorFields({
136
+ key: "PERCENT",
137
+ // I18N: A label for a 'percent' sign (represented as '%').
138
+ ariaLabel: i18n._("Percent"),
139
+ }),
140
+ },
141
+ CDOT: {
142
+ ...getDefaultOperatorFields({
143
+ key: "CDOT",
144
+ // I18N: A label for a 'centered dot' multiplication sign (represented as '⋅').
145
+ ariaLabel: i18n._("Multiply"),
146
+ }),
147
+ },
148
+ EQUAL: {
149
+ ...getDefaultOperatorFields({
150
+ key: "EQUAL",
151
+ // I18N: A label for an 'equals' sign (represented as '=').
152
+ ariaLabel: i18n._("Equals sign"),
153
+ }),
154
+ },
155
+ NEQ: {
156
+ ...getDefaultOperatorFields({
157
+ key: "NEQ",
158
+ // I18N: A label for a 'not-equals' sign (represented as '≠').
159
+ ariaLabel: i18n._("Not-equals sign"),
160
+ }),
161
+ },
162
+ GT: {
163
+ ...getDefaultOperatorFields({
164
+ key: "GT",
165
+ // I18N: A label for a 'greater than' sign (represented as '>').
166
+ ariaLabel: i18n._("Greater than sign"),
167
+ }),
168
+ },
169
+ LT: {
170
+ ...getDefaultOperatorFields({
171
+ key: "LT",
172
+ // I18N: A label for a 'less than' sign (represented as '<').
173
+ ariaLabel: i18n._("Less than sign"),
174
+ }),
175
+ },
176
+ GEQ: {
177
+ ...getDefaultOperatorFields({
178
+ key: "GEQ",
179
+ // I18N: A label for a 'greater than or equal to' sign (represented as '≥').
180
+ ariaLabel: i18n._("Greater than or equal to sign"),
181
+ }),
182
+ },
183
+ LEQ: {
184
+ ...getDefaultOperatorFields({
185
+ key: "LEQ",
186
+ // I18N: A label for a 'less than or equal to' sign (represented as '≤').
187
+ ariaLabel: i18n._("Less than or equal to sign"),
188
+ }),
96
189
  },
97
190
  // mobile native
98
- [Keys.FRAC_INCLUSIVE]: {
99
- type: KeyType.OPERATOR,
100
- // I18N: A label for a button that creates a new fraction and puts the
101
- // current expression in the numerator of that fraction.
102
- ariaLabel: i18n._("Fraction, with current expression in numerator"),
191
+ FRAC_INCLUSIVE: {
192
+ ...getDefaultOperatorFields({
193
+ key: "FRAC_INCLUSIVE",
194
+ // I18N: A label for a button that creates a new fraction and puts the
195
+ // current expression in the numerator of that fraction.
196
+ ariaLabel: i18n._("Fraction, with current expression in numerator"),
197
+ }),
103
198
  },
104
199
  // mobile native
105
- [Keys.FRAC_EXCLUSIVE]: {
106
- type: KeyType.OPERATOR,
107
- // I18N: A label for a button that creates a new fraction next to the
108
- // cursor.
109
- ariaLabel: i18n._("Fraction, excluding the current expression"),
200
+ FRAC_EXCLUSIVE: {
201
+ ...getDefaultOperatorFields({
202
+ key: "FRAC_EXCLUSIVE",
203
+ // I18N: A label for a button that creates a new fraction next to the
204
+ // cursor.
205
+ ariaLabel: i18n._("Fraction, excluding the current expression"),
206
+ }),
110
207
  },
111
208
  // mobile web
112
- [Keys.FRAC]: {
113
- type: KeyType.OPERATOR,
114
- // I18N: A label for a button that creates a new fraction next to the
115
- // cursor.
116
- ariaLabel: i18n._("Fraction, excluding the current expression"),
117
- },
118
- [Keys.EXP]: {
119
- type: KeyType.OPERATOR,
120
- // I18N: A label for a button that will allow the user to input a custom
121
- // exponent.
122
- ariaLabel: i18n._("Custom exponent"),
123
- },
124
- [Keys.EXP_2]: {
125
- type: KeyType.OPERATOR,
126
- // I18N: A label for a button that will square (take to the second
127
- // power) some math.
128
- ariaLabel: i18n._("Square"),
129
- },
130
- [Keys.EXP_3]: {
131
- type: KeyType.OPERATOR,
132
- // I18N: A label for a button that will cube (take to the third power)
133
- // some math.
134
- ariaLabel: i18n._("Cube"),
135
- },
136
- [Keys.SQRT]: {
137
- type: KeyType.OPERATOR,
138
- ariaLabel: i18n._("Square root"),
139
- },
140
- [Keys.CUBE_ROOT]: {
141
- type: KeyType.OPERATOR,
142
- ariaLabel: i18n._("Cube root"),
143
- },
144
- [Keys.RADICAL]: {
145
- type: KeyType.OPERATOR,
146
- ariaLabel: i18n._("Radical with custom root"),
147
- },
148
- [Keys.LEFT_PAREN]: {
149
- type: KeyType.OPERATOR,
150
- ariaLabel: i18n._("Left parenthesis"),
151
- },
152
- [Keys.RIGHT_PAREN]: {
153
- type: KeyType.OPERATOR,
154
- ariaLabel: i18n._("Right parenthesis"),
155
- },
156
- [Keys.LN]: {
157
- type: KeyType.OPERATOR,
158
- ariaLabel: i18n._("Natural logarithm"),
159
- },
160
- [Keys.LOG]: {
161
- type: KeyType.OPERATOR,
162
- ariaLabel: i18n._("Logarithm with base 10"),
163
- },
164
- [Keys.LOG_N]: {
165
- type: KeyType.OPERATOR,
166
- ariaLabel: i18n._("Logarithm with custom base"),
167
- },
168
- [Keys.SIN]: {
169
- type: KeyType.OPERATOR,
170
- ariaLabel: i18n._("Sine"),
171
- },
172
- [Keys.COS]: {
173
- type: KeyType.OPERATOR,
174
- ariaLabel: i18n._("Cosine"),
175
- },
176
- [Keys.TAN]: {
177
- type: KeyType.OPERATOR,
178
- ariaLabel: i18n._("Tangent"),
179
- },
180
- [Keys.PI]: {
181
- type: KeyType.VALUE,
182
- ariaLabel: i18n._("Pi"),
183
- icon: {
184
- type: IconType.MATH,
209
+ FRAC: {
210
+ ...getDefaultOperatorFields({
211
+ key: "FRAC",
212
+ // I18N: A label for a button that creates a new fraction next to the
213
+ // cursor.
214
+ ariaLabel: i18n._("Fraction, excluding the current expression"),
215
+ }),
216
+ },
217
+ EXP: {
218
+ ...getDefaultOperatorFields({
219
+ key: "EXP",
220
+ // I18N: A label for a button that will allow the user to input a
221
+ // custom exponent.
222
+ ariaLabel: i18n._("Custom exponent"),
223
+ }),
224
+ },
225
+ EXP_2: {
226
+ ...getDefaultOperatorFields({
227
+ key: "EXP_2",
228
+ // I18N: A label for a button that will square (take to the second
229
+ // power) some math.
230
+ ariaLabel: i18n._("Square"),
231
+ }),
232
+ },
233
+ EXP_3: {
234
+ ...getDefaultOperatorFields({
235
+ key: "EXP_3",
236
+ // I18N: A label for a button that will cube (take to the third power)
237
+ // some math.
238
+ ariaLabel: i18n._("Cube"),
239
+ }),
240
+ },
241
+ SQRT: {
242
+ ...getDefaultOperatorFields({
243
+ key: "SQRT",
244
+ // I18N: A label for a button that will allow the user to input a
245
+ // square root.
246
+ ariaLabel: i18n._("Square root"),
247
+ }),
248
+ },
249
+ CUBE_ROOT: {
250
+ ...getDefaultOperatorFields({
251
+ key: "CUBE_ROOT",
252
+ // I18N: A label for a button that will allow the user to input a
253
+ // cube root.
254
+ ariaLabel: i18n._("Cube root"),
255
+ }),
256
+ },
257
+ RADICAL: {
258
+ ...getDefaultOperatorFields({
259
+ key: "RADICAL",
260
+ // I18N: A label for a button that will allow the user to input a
261
+ // radical with a custom root.
262
+ ariaLabel: i18n._("Radical with custom root"),
263
+ }),
264
+ },
265
+ LEFT_PAREN: {
266
+ ...getDefaultOperatorFields({
267
+ key: "LEFT_PAREN",
268
+ // I18N: A label for a button that will allow the user to input a
269
+ // left parenthesis (i.e. '(')
270
+ ariaLabel: i18n._("Left parenthesis"),
271
+ }),
272
+ },
273
+ RIGHT_PAREN: {
274
+ ...getDefaultOperatorFields({
275
+ key: "RIGHT_PAREN",
276
+ // I18N: A label for a button that will allow the user to input a
277
+ // right parenthesis (i.e. ')')
278
+ ariaLabel: i18n._("Right parenthesis"),
279
+ }),
280
+ },
281
+ LN: {
282
+ ...getDefaultOperatorFields({
283
+ key: "LN",
284
+ // I18N: A label for a button that will allow the user to input a
285
+ // natural logarithm.
286
+ ariaLabel: i18n._("Natural logarithm"),
287
+ }),
288
+ },
289
+ LOG: {
290
+ ...getDefaultOperatorFields({
291
+ key: "LOG",
292
+ // I18N: A label for a button that will allow the user to input a
293
+ // logarithm with base 10.
294
+ ariaLabel: i18n._("Logarithm with base 10"),
295
+ }),
296
+ },
297
+ LOG_N: {
298
+ ...getDefaultOperatorFields({
299
+ key: "LOG_N",
300
+ // I18N: A label for a button that will allow the user to input a
301
+ // logarithm with a custom base.
302
+ ariaLabel: i18n._("Logarithm with custom base"),
303
+ }),
304
+ },
305
+ SIN: {
306
+ ...getDefaultOperatorFields({
307
+ key: "SIN",
308
+ // I18N: A label for a button that will allow the user to input a
309
+ // sine function.
310
+ ariaLabel: i18n._("Sine"),
311
+ }),
312
+ },
313
+ COS: {
314
+ ...getDefaultOperatorFields({
315
+ key: "COS",
316
+ // I18N: A label for a button that will allow the user to input a
317
+ // cosine function.
318
+ ariaLabel: i18n._("Cosine"),
319
+ }),
320
+ },
321
+ TAN: {
322
+ ...getDefaultOperatorFields({
323
+ key: "TAN",
324
+ // I18N: A label for a button that will allow the user to input a
325
+ // tangent function.
326
+ ariaLabel: i18n._("Tangent"),
327
+ }),
328
+ },
329
+ PI: {
330
+ ...getDefaultValueFields({
331
+ key: "PI",
185
332
  data: "\\pi",
186
- },
187
- },
188
- [Keys.THETA]: {
189
- type: KeyType.VALUE,
190
- ariaLabel: i18n._("Theta"),
191
- icon: {
192
- type: IconType.MATH,
333
+ // I18N: A label for a button that will allow the user to input the
334
+ // mathematical constant pi (i.e., π)
335
+ ariaLabel: i18n._("Pi"),
336
+ }),
337
+ },
338
+ THETA: {
339
+ ...getDefaultValueFields({
340
+ key: "THETA",
193
341
  data: "\\theta",
194
- },
195
- },
196
- [Keys.NOOP]: {
197
- type: KeyType.EMPTY,
342
+ // I18N: A label for a button that will allow the user to input the
343
+ // mathematical constant theta (i.e., θ)
344
+ ariaLabel: i18n._("Theta"),
345
+ }),
346
+ },
347
+ NOOP: {
348
+ ...getDefaultOperatorFields({
349
+ key: "NOOP",
350
+ keyType: "EMPTY",
351
+ }),
352
+ },
353
+ // Input navigation
354
+ UP: {
355
+ ...getDefaultOperatorFields({
356
+ key: "UP",
357
+ keyType: "INPUT_NAVIGATION",
358
+ ariaLabel: i18n._("Up arrow"),
359
+ }),
360
+ },
361
+ RIGHT: {
362
+ ...getDefaultOperatorFields({
363
+ key: "RIGHT",
364
+ keyType: "INPUT_NAVIGATION",
365
+ ariaLabel: i18n._("Right arrow"),
366
+ }),
367
+ },
368
+ DOWN: {
369
+ ...getDefaultOperatorFields({
370
+ key: "DOWN",
371
+ keyType: "INPUT_NAVIGATION",
372
+ ariaLabel: i18n._("Down arrow"),
373
+ }),
374
+ },
375
+ LEFT: {
376
+ ...getDefaultOperatorFields({
377
+ key: "LEFT",
378
+ keyType: "INPUT_NAVIGATION",
379
+ ariaLabel: i18n._("Left arrow"),
380
+ }),
381
+ },
382
+ JUMP_OUT_PARENTHESES: {
383
+ ...getDefaultOperatorFields({
384
+ key: "JUMP_OUT_PARENTHESES",
385
+ keyType: "INPUT_NAVIGATION",
386
+ ariaLabel: i18n._("Navigate right out of a set of parentheses"),
387
+ }),
388
+ },
389
+ JUMP_OUT_EXPONENT: {
390
+ ...getDefaultOperatorFields({
391
+ key: "JUMP_OUT_EXPONENT",
392
+ keyType: "INPUT_NAVIGATION",
393
+ ariaLabel: i18n._("Navigate right out of an exponent"),
394
+ }),
395
+ },
396
+ JUMP_OUT_BASE: {
397
+ ...getDefaultOperatorFields({
398
+ key: "JUMP_OUT_BASE",
399
+ keyType: "INPUT_NAVIGATION",
400
+ ariaLabel: i18n._("Navigate right out of a base"),
401
+ }),
402
+ },
403
+ JUMP_INTO_NUMERATOR: {
404
+ ...getDefaultOperatorFields({
405
+ key: "JUMP_INTO_NUMERATOR",
406
+ keyType: "INPUT_NAVIGATION",
407
+ ariaLabel: i18n._(
408
+ "Navigate right into the numerator of a fraction",
409
+ ),
410
+ }),
411
+ },
412
+ JUMP_OUT_NUMERATOR: {
413
+ ...getDefaultOperatorFields({
414
+ key: "JUMP_OUT_NUMERATOR",
415
+ keyType: "INPUT_NAVIGATION",
416
+ ariaLabel: i18n._(
417
+ "Navigate right out of the numerator and into the denominator",
418
+ ),
419
+ }),
420
+ },
421
+ JUMP_OUT_DENOMINATOR: {
422
+ ...getDefaultOperatorFields({
423
+ key: "JUMP_OUT_DENOMINATOR",
424
+ keyType: "INPUT_NAVIGATION",
425
+ ariaLabel: i18n._(
426
+ "Navigate right out of the denominator of a fraction",
427
+ ),
428
+ }),
429
+ },
430
+ BACKSPACE: {
431
+ ...getDefaultOperatorFields({
432
+ key: "BACKSPACE",
433
+ keyType: "INPUT_NAVIGATION",
434
+ ariaLabel: i18n._("Delete"),
435
+ }),
198
436
  },
199
437
 
200
- // Input navigation keys.
201
- [Keys.UP]: {
202
- type: KeyType.INPUT_NAVIGATION,
203
- ariaLabel: i18n._("Up arrow"),
204
- },
205
- [Keys.RIGHT]: {
206
- type: KeyType.INPUT_NAVIGATION,
207
- ariaLabel: i18n._("Right arrow"),
208
- },
209
- [Keys.DOWN]: {
210
- type: KeyType.INPUT_NAVIGATION,
211
- ariaLabel: i18n._("Down arrow"),
212
- },
213
- [Keys.LEFT]: {
214
- type: KeyType.INPUT_NAVIGATION,
215
- ariaLabel: i18n._("Left arrow"),
216
- },
217
- [Keys.JUMP_OUT_PARENTHESES]: {
218
- type: KeyType.INPUT_NAVIGATION,
219
- ariaLabel: i18n._("Navigate right out of a set of parentheses"),
220
- },
221
- [Keys.JUMP_OUT_EXPONENT]: {
222
- type: KeyType.INPUT_NAVIGATION,
223
- ariaLabel: i18n._("Navigate right out of an exponent"),
224
- },
225
- [Keys.JUMP_OUT_BASE]: {
226
- type: KeyType.INPUT_NAVIGATION,
227
- ariaLabel: i18n._("Navigate right out of a base"),
228
- },
229
- [Keys.JUMP_INTO_NUMERATOR]: {
230
- type: KeyType.INPUT_NAVIGATION,
231
- ariaLabel: i18n._("Navigate right into the numerator of a fraction"),
232
- },
233
- [Keys.JUMP_OUT_NUMERATOR]: {
234
- type: KeyType.INPUT_NAVIGATION,
235
- ariaLabel: i18n._(
236
- "Navigate right out of the numerator and into the denominator",
237
- ),
238
- },
239
- [Keys.JUMP_OUT_DENOMINATOR]: {
240
- type: KeyType.INPUT_NAVIGATION,
241
- ariaLabel: i18n._(
242
- "Navigate right out of the denominator of a fraction",
243
- ),
244
- },
245
- [Keys.BACKSPACE]: {
246
- type: KeyType.INPUT_NAVIGATION,
247
- // I18N: A label for a button that will delete some input.
248
- ariaLabel: i18n._("Delete"),
438
+ // Keypad navigation
439
+ DISMISS: {
440
+ ...getDefaultOperatorFields({
441
+ key: "DISMISS",
442
+ keyType: "KEYPAD_NAVIGATION",
443
+ // I18N: A label for a button that will dismiss/hide a keypad.
444
+ ariaLabel: i18n._("Dismiss"),
445
+ }),
249
446
  },
250
447
 
251
- // Keypad navigation keys.
252
- [Keys.DISMISS]: {
253
- type: KeyType.KEYPAD_NAVIGATION,
254
- // I18N: A label for a button that will dismiss/hide a keypad.
255
- ariaLabel: i18n._("Dismiss"),
448
+ // TODO(charlie): Use the numeral color for the 'Many' key.
449
+ MANY: {
450
+ ...getDefaultOperatorFields({
451
+ key: "MANY",
452
+ keyType: "MANY",
453
+ }),
256
454
  },
257
- };
258
455
 
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
- };
456
+ // NUMBERS
457
+ NUM_0: {
458
+ ...getDefaultNumberFields({
459
+ key: "NUM_0",
460
+ }),
461
+ },
462
+ NUM_1: {
463
+ ...getDefaultNumberFields({
464
+ key: "NUM_1",
465
+ }),
466
+ },
467
+ NUM_2: {
468
+ ...getDefaultNumberFields({
469
+ key: "NUM_2",
470
+ }),
471
+ },
472
+ NUM_3: {
473
+ ...getDefaultNumberFields({
474
+ key: "NUM_3",
475
+ }),
476
+ },
477
+ NUM_4: {
478
+ ...getDefaultNumberFields({
479
+ key: "NUM_4",
480
+ }),
481
+ },
482
+ NUM_5: {
483
+ ...getDefaultNumberFields({
484
+ key: "NUM_5",
485
+ }),
486
+ },
487
+ NUM_6: {
488
+ ...getDefaultNumberFields({
489
+ key: "NUM_6",
490
+ }),
491
+ },
492
+ NUM_7: {
493
+ ...getDefaultNumberFields({
494
+ key: "NUM_7",
495
+ }),
496
+ },
497
+ NUM_8: {
498
+ ...getDefaultNumberFields({
499
+ key: "NUM_8",
500
+ }),
501
+ },
502
+ NUM_9: {
503
+ ...getDefaultNumberFields({
504
+ key: "NUM_9",
505
+ }),
506
+ },
268
507
 
269
- // TODO(charlie): Use the numeral color for the 'Many' key.
270
- KeyConfigs[Keys.MANY] = {
271
- type: KeyType.MANY,
272
- // childKeyIds will be configured by the client.
508
+ // LETTERS
509
+ A: {
510
+ ...getDefaultValueFields({
511
+ key: "A",
512
+ }),
513
+ },
514
+ B: {
515
+ ...getDefaultValueFields({
516
+ key: "B",
517
+ }),
518
+ },
519
+ C: {
520
+ ...getDefaultValueFields({
521
+ key: "C",
522
+ }),
523
+ },
524
+ D: {
525
+ ...getDefaultValueFields({
526
+ key: "D",
527
+ }),
528
+ },
529
+ E: {
530
+ ...getDefaultValueFields({
531
+ key: "E",
532
+ }),
533
+ },
534
+ F: {
535
+ ...getDefaultValueFields({
536
+ key: "F",
537
+ }),
538
+ },
539
+ G: {
540
+ ...getDefaultValueFields({
541
+ key: "G",
542
+ }),
543
+ },
544
+ H: {
545
+ ...getDefaultValueFields({
546
+ key: "H",
547
+ }),
548
+ },
549
+ I: {
550
+ ...getDefaultValueFields({
551
+ key: "I",
552
+ }),
553
+ },
554
+ J: {
555
+ ...getDefaultValueFields({
556
+ key: "J",
557
+ }),
558
+ },
559
+ K: {
560
+ ...getDefaultValueFields({
561
+ key: "K",
562
+ }),
563
+ },
564
+ L: {
565
+ ...getDefaultValueFields({
566
+ key: "L",
567
+ }),
568
+ },
569
+ M: {
570
+ ...getDefaultValueFields({
571
+ key: "M",
572
+ }),
573
+ },
574
+ N: {
575
+ ...getDefaultValueFields({
576
+ key: "N",
577
+ }),
578
+ },
579
+ O: {
580
+ ...getDefaultValueFields({
581
+ key: "O",
582
+ }),
583
+ },
584
+ P: {
585
+ ...getDefaultValueFields({
586
+ key: "P",
587
+ }),
588
+ },
589
+ Q: {
590
+ ...getDefaultValueFields({
591
+ key: "Q",
592
+ }),
593
+ },
594
+ R: {
595
+ ...getDefaultValueFields({
596
+ key: "R",
597
+ }),
598
+ },
599
+ S: {
600
+ ...getDefaultValueFields({
601
+ key: "S",
602
+ }),
603
+ },
604
+ T: {
605
+ ...getDefaultValueFields({
606
+ key: "T",
607
+ }),
608
+ },
609
+ U: {
610
+ ...getDefaultValueFields({
611
+ key: "U",
612
+ }),
613
+ },
614
+ V: {
615
+ ...getDefaultValueFields({
616
+ key: "V",
617
+ }),
618
+ },
619
+ W: {
620
+ ...getDefaultValueFields({
621
+ key: "W",
622
+ }),
623
+ },
624
+ X: {
625
+ ...getDefaultValueFields({
626
+ key: "X",
627
+ }),
628
+ },
629
+ Y: {
630
+ ...getDefaultValueFields({
631
+ key: "Y",
632
+ }),
633
+ },
634
+ Z: {
635
+ ...getDefaultValueFields({
636
+ key: "Z",
637
+ }),
638
+ },
639
+ a: {
640
+ ...getDefaultValueFields({
641
+ key: "a",
642
+ }),
643
+ },
644
+ b: {
645
+ ...getDefaultValueFields({
646
+ key: "b",
647
+ }),
648
+ },
649
+ c: {
650
+ ...getDefaultValueFields({
651
+ key: "c",
652
+ }),
653
+ },
654
+ d: {
655
+ ...getDefaultValueFields({
656
+ key: "d",
657
+ }),
658
+ },
659
+ e: {
660
+ ...getDefaultValueFields({
661
+ key: "e",
662
+ }),
663
+ },
664
+ f: {
665
+ ...getDefaultValueFields({
666
+ key: "f",
667
+ }),
668
+ },
669
+ g: {
670
+ ...getDefaultValueFields({
671
+ key: "g",
672
+ }),
673
+ },
674
+ h: {
675
+ ...getDefaultValueFields({
676
+ key: "h",
677
+ }),
678
+ },
679
+ i: {
680
+ ...getDefaultValueFields({
681
+ key: "i",
682
+ }),
683
+ },
684
+ j: {
685
+ ...getDefaultValueFields({
686
+ key: "j",
687
+ }),
688
+ },
689
+ k: {
690
+ ...getDefaultValueFields({
691
+ key: "k",
692
+ }),
693
+ },
694
+ l: {
695
+ ...getDefaultValueFields({
696
+ key: "l",
697
+ }),
698
+ },
699
+ m: {
700
+ ...getDefaultValueFields({
701
+ key: "m",
702
+ }),
703
+ },
704
+ n: {
705
+ ...getDefaultValueFields({
706
+ key: "n",
707
+ }),
708
+ },
709
+ o: {
710
+ ...getDefaultValueFields({
711
+ key: "o",
712
+ }),
713
+ },
714
+ p: {
715
+ ...getDefaultValueFields({
716
+ key: "p",
717
+ }),
718
+ },
719
+ q: {
720
+ ...getDefaultValueFields({
721
+ key: "q",
722
+ }),
723
+ },
724
+ r: {
725
+ ...getDefaultValueFields({
726
+ key: "r",
727
+ }),
728
+ },
729
+ s: {
730
+ ...getDefaultValueFields({
731
+ key: "s",
732
+ }),
733
+ },
734
+ t: {
735
+ ...getDefaultValueFields({
736
+ key: "t",
737
+ }),
738
+ },
739
+ u: {
740
+ ...getDefaultValueFields({
741
+ key: "u",
742
+ }),
743
+ },
744
+ v: {
745
+ ...getDefaultValueFields({
746
+ key: "v",
747
+ }),
748
+ },
749
+ w: {
750
+ ...getDefaultValueFields({
751
+ key: "w",
752
+ }),
753
+ },
754
+ x: {
755
+ ...getDefaultValueFields({
756
+ key: "x",
757
+ }),
758
+ },
759
+ y: {
760
+ ...getDefaultValueFields({
761
+ key: "y",
762
+ }),
763
+ },
764
+ z: {
765
+ ...getDefaultValueFields({
766
+ key: "z",
767
+ }),
768
+ },
769
+ PHI: {
770
+ ...getDefaultValueFields({
771
+ key: "PHI",
772
+ }),
773
+ },
774
+ NTHROOT3: {
775
+ ...getDefaultValueFields({
776
+ key: "NTHROOT3",
777
+ }),
778
+ },
779
+ POW: {
780
+ ...getDefaultValueFields({
781
+ key: "POW",
782
+ }),
783
+ },
784
+ LOG_B: {
785
+ ...getDefaultValueFields({
786
+ key: "LOG_B",
787
+ }),
788
+ },
273
789
  };
274
790
 
275
- // Add in every numeral.
276
- const NUMBERS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
277
- for (const num of NUMBERS) {
278
- // TODO(charlie): Consider removing the SVG icons that we have for the
279
- // numeral keys. They can be rendered just as easily with text (though that
280
- // would mean that we'd be using text beyond the variable key).
281
- const textRepresentation = `${num}`;
282
- KeyConfigs[`NUM_${num}`] = {
283
- type: KeyType.VALUE,
284
- ariaLabel: textRepresentation,
285
- icon: {
286
- type: IconType.TEXT,
287
- data: textRepresentation,
288
- },
289
- };
290
- }
291
-
292
- // Add in every variable.
293
- const LETTERS = [
294
- "A",
295
- "B",
296
- "C",
297
- "D",
298
- "E",
299
- "F",
300
- "G",
301
- "H",
302
- "I",
303
- "J",
304
- "K",
305
- "L",
306
- "M",
307
- "N",
308
- "O",
309
- "P",
310
- "Q",
311
- "R",
312
- "S",
313
- "T",
314
- "U",
315
- "V",
316
- "W",
317
- "X",
318
- "Y",
319
- "Z",
320
- ];
321
- for (const letter of LETTERS) {
322
- const lowerCaseVariable = letter.toLowerCase();
323
- const upperCaseVariable = letter.toUpperCase();
324
-
325
- for (const textRepresentation of [lowerCaseVariable, upperCaseVariable]) {
326
- KeyConfigs[textRepresentation] = {
327
- type: KeyType.VALUE,
328
- ariaLabel: textRepresentation,
329
- icon: {
330
- type: IconType.MATH,
331
- data: textRepresentation,
332
- },
333
- };
334
- }
335
- }
336
-
337
- for (const key of Object.keys(KeyConfigs)) {
338
- KeyConfigs[key] = {
339
- id: key,
340
- // Default to an SVG icon indexed by the key name.
341
- icon: {
342
- type: IconType.SVG,
343
- data: key,
344
- },
345
- ...KeyConfigs[key],
346
- };
347
- }
348
-
349
791
  export default KeyConfigs;