@khanacademy/math-input 2.0.0 → 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 (225) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/input/math-input.d.ts +1 -1
  3. package/dist/components/input/math-input.js.flow +1 -1
  4. package/dist/components/keypad/button.d.ts +1 -2
  5. package/dist/components/keypad/button.js.flow +1 -1
  6. package/dist/components/keypad/{pre-algebra-page.d.ts → geometry-page/index.d.ts} +1 -1
  7. package/dist/components/keypad/{pre-algebra-page.js.flow → geometry-page/index.js.flow} +1 -1
  8. package/dist/components/keypad/index.d.ts +5 -4
  9. package/dist/components/keypad/index.js.flow +9 -4
  10. package/dist/components/keypad/keypad-page-items.d.ts +8 -2
  11. package/dist/components/keypad/keypad-page-items.js.flow +8 -2
  12. package/dist/components/keypad/{numeric-input-page.d.ts → numbers-page/index.d.ts} +3 -2
  13. package/dist/components/keypad/numbers-page/index.js.flow +17 -0
  14. package/dist/components/keypad/numbers-page/types.d.ts +4 -0
  15. package/dist/components/keypad/numbers-page/types.js.flow +10 -0
  16. package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +7 -0
  17. package/dist/components/keypad/{numeric-input-page.js.flow → operators-page/advanced-relations-buttons.js.flow} +3 -4
  18. package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +7 -0
  19. package/dist/components/keypad/{trigonometry-page.js.flow → operators-page/basic-relations-buttons.js.flow} +3 -6
  20. package/dist/components/keypad/operators-page/index.d.ts +9 -0
  21. package/dist/components/keypad/operators-page/index.js.flow +17 -0
  22. package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +7 -0
  23. package/dist/components/keypad/operators-page/logarithms-buttons.js.flow +12 -0
  24. package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +7 -0
  25. package/dist/components/keypad/operators-page/pre-algebra-buttons.js.flow +12 -0
  26. package/dist/components/keypad/operators-page/types.d.ts +6 -0
  27. package/dist/components/keypad/operators-page/types.js.flow +12 -0
  28. package/dist/components/{compute-layout-parameters.d.ts → keypad-legacy/compute-layout-parameters.d.ts} +1 -1
  29. package/dist/components/{compute-layout-parameters.js.flow → keypad-legacy/compute-layout-parameters.js.flow} +1 -1
  30. package/dist/components/{echo-manager.d.ts → keypad-legacy/echo-manager.d.ts} +2 -11
  31. package/dist/components/{echo-manager.js.flow → keypad-legacy/echo-manager.js.flow} +2 -11
  32. package/dist/components/{expression-keypad.d.ts → keypad-legacy/expression-keypad.d.ts} +3 -4
  33. package/dist/components/{expression-keypad.js.flow → keypad-legacy/expression-keypad.js.flow} +3 -4
  34. package/dist/components/{fraction-keypad.d.ts → keypad-legacy/fraction-keypad.d.ts} +2 -2
  35. package/dist/components/{fraction-keypad.js.flow → keypad-legacy/fraction-keypad.js.flow} +2 -2
  36. package/dist/components/{gesture-manager.d.ts → keypad-legacy/gesture-manager.d.ts} +1 -1
  37. package/dist/components/{gesture-manager.js.flow → keypad-legacy/gesture-manager.js.flow} +1 -1
  38. package/dist/components/{gesture-state-machine.d.ts → keypad-legacy/gesture-state-machine.d.ts} +1 -1
  39. package/dist/components/{gesture-state-machine.js.flow → keypad-legacy/gesture-state-machine.js.flow} +1 -1
  40. package/dist/components/{icon.d.ts → keypad-legacy/icon.d.ts} +1 -1
  41. package/dist/components/{icon.js.flow → keypad-legacy/icon.js.flow} +1 -1
  42. package/dist/components/{keypad-button.d.ts → keypad-legacy/keypad-button.d.ts} +4 -4
  43. package/dist/components/{keypad-button.js.flow → keypad-legacy/keypad-button.js.flow} +4 -4
  44. package/dist/components/{keypad-container.d.ts → keypad-legacy/keypad-container.d.ts} +2 -2
  45. package/dist/components/{keypad-container.js.flow → keypad-legacy/keypad-container.js.flow} +3 -3
  46. package/dist/components/{keypad.d.ts → keypad-legacy/keypad.d.ts} +3 -3
  47. package/dist/components/{keypad.js.flow → keypad-legacy/keypad.js.flow} +3 -3
  48. package/dist/components/{multi-symbol-grid.d.ts → keypad-legacy/multi-symbol-grid.d.ts} +1 -1
  49. package/dist/components/{multi-symbol-grid.js.flow → keypad-legacy/multi-symbol-grid.js.flow} +1 -1
  50. package/dist/components/{multi-symbol-popover.d.ts → keypad-legacy/multi-symbol-popover.d.ts} +1 -1
  51. package/dist/components/{multi-symbol-popover.js.flow → keypad-legacy/multi-symbol-popover.js.flow} +1 -1
  52. package/dist/components/{node-manager.d.ts → keypad-legacy/node-manager.d.ts} +3 -4
  53. package/dist/components/{node-manager.js.flow → keypad-legacy/node-manager.js.flow} +3 -5
  54. package/dist/components/{popover-manager.d.ts → keypad-legacy/popover-manager.d.ts} +1 -1
  55. package/dist/components/{popover-manager.js.flow → keypad-legacy/popover-manager.js.flow} +1 -1
  56. package/dist/components/{popover-state-machine.d.ts → keypad-legacy/popover-state-machine.d.ts} +1 -1
  57. package/dist/components/{popover-state-machine.js.flow → keypad-legacy/popover-state-machine.js.flow} +1 -1
  58. package/dist/components/{provided-keypad.d.ts → keypad-legacy/provided-keypad.d.ts} +1 -1
  59. package/dist/components/{provided-keypad.js.flow → keypad-legacy/provided-keypad.js.flow} +1 -1
  60. package/dist/{store → components/keypad-legacy/store}/actions.d.ts +4 -5
  61. package/dist/{store → components/keypad-legacy/store}/actions.js.flow +5 -8
  62. package/dist/{store → components/keypad-legacy/store}/index.d.ts +0 -1
  63. package/dist/{store → components/keypad-legacy/store}/index.js.flow +0 -1
  64. package/dist/components/keypad-legacy/store/shared.d.ts +7 -0
  65. package/dist/components/keypad-legacy/store/shared.js.flow +14 -0
  66. package/dist/{store → components/keypad-legacy/store}/types.d.ts +4 -14
  67. package/dist/{store → components/keypad-legacy/store}/types.js.flow +4 -14
  68. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +37 -0
  69. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +64 -0
  70. package/dist/components/{two-page-keypad.d.ts → keypad-legacy/two-page-keypad.d.ts} +0 -1
  71. package/dist/components/{two-page-keypad.js.flow → keypad-legacy/two-page-keypad.js.flow} +0 -1
  72. package/dist/data/key-configs.d.ts +3 -1
  73. package/dist/data/key-configs.js.flow +3 -1
  74. package/dist/data/keys.d.ts +1 -3
  75. package/dist/data/keys.js.flow +0 -2
  76. package/dist/es/index.js +4991 -4299
  77. package/dist/es/index.js.map +1 -1
  78. package/dist/index.d.ts +2 -1
  79. package/dist/index.js +4784 -4073
  80. package/dist/index.js.flow +2 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/types.d.ts +13 -9
  83. package/dist/types.js.flow +19 -15
  84. package/package.json +1 -1
  85. package/src/components/input/math-input.tsx +1 -1
  86. package/src/components/keypad/button-assets.tsx +65 -40
  87. package/src/components/keypad/button.stories.tsx +61 -13
  88. package/src/components/keypad/button.tsx +1 -1
  89. package/src/components/keypad/{trigonometry-page.tsx → geometry-page/index.tsx} +3 -4
  90. package/src/components/keypad/index.tsx +19 -14
  91. package/src/components/keypad/keypad-page-items.tsx +34 -21
  92. package/src/components/keypad/keypad-pages.stories.tsx +5 -5
  93. package/src/components/keypad/keypad.stories.tsx +75 -17
  94. package/src/components/keypad/{numeric-input-page.tsx → numbers-page/index.tsx} +47 -11
  95. package/src/components/keypad/numbers-page/types.ts +4 -0
  96. package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +32 -0
  97. package/src/components/keypad/operators-page/basic-relations-buttons.tsx +32 -0
  98. package/src/components/keypad/{pre-algebra-page.tsx → operators-page/index.tsx} +25 -29
  99. package/src/components/keypad/operators-page/logarithms-buttons.tsx +32 -0
  100. package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +36 -0
  101. package/src/components/keypad/operators-page/types.ts +6 -0
  102. package/src/components/{__tests__ → keypad-legacy/__tests__}/two-page-keypad.test.tsx +0 -2
  103. package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts} +2 -3
  104. package/src/components/{corner-decal.tsx → keypad-legacy/corner-decal.tsx} +2 -3
  105. package/src/components/{echo-manager.tsx → keypad-legacy/echo-manager.tsx} +7 -20
  106. package/src/components/{empty-keypad-button.tsx → keypad-legacy/empty-keypad-button.tsx} +2 -2
  107. package/src/components/{expression-keypad.tsx → keypad-legacy/expression-keypad.tsx} +8 -17
  108. package/src/components/{fraction-keypad.tsx → keypad-legacy/fraction-keypad.tsx} +6 -6
  109. package/src/components/{gesture-manager.ts → keypad-legacy/gesture-manager.ts} +2 -2
  110. package/src/components/{gesture-state-machine.ts → keypad-legacy/gesture-state-machine.ts} +1 -1
  111. package/src/components/{icon.tsx → keypad-legacy/icon.tsx} +3 -3
  112. package/src/components/{keypad-button.tsx → keypad-legacy/keypad-button.tsx} +12 -9
  113. package/src/components/{keypad-container.tsx → keypad-legacy/keypad-container.tsx} +6 -6
  114. package/src/components/{keypad.tsx → keypad-legacy/keypad.tsx} +5 -5
  115. package/src/components/{many-keypad-button.tsx → keypad-legacy/many-keypad-button.tsx} +5 -5
  116. package/src/components/{math-icon.tsx → keypad-legacy/math-icon.tsx} +2 -2
  117. package/src/components/{multi-symbol-grid.tsx → keypad-legacy/multi-symbol-grid.tsx} +4 -4
  118. package/src/components/{multi-symbol-popover.tsx → keypad-legacy/multi-symbol-popover.tsx} +3 -4
  119. package/src/components/{navigation-pad.tsx → keypad-legacy/navigation-pad.tsx} +5 -5
  120. package/src/components/{node-manager.ts → keypad-legacy/node-manager.ts} +2 -10
  121. package/src/components/{popover-manager.tsx → keypad-legacy/popover-manager.tsx} +2 -2
  122. package/src/components/{popover-state-machine.ts → keypad-legacy/popover-state-machine.ts} +1 -1
  123. package/src/components/{provided-keypad.tsx → keypad-legacy/provided-keypad.tsx} +4 -5
  124. package/src/{store → components/keypad-legacy/store}/actions.ts +5 -8
  125. package/src/{store → components/keypad-legacy/store}/echo-reducer.ts +2 -3
  126. package/src/{store → components/keypad-legacy/store}/index.ts +4 -11
  127. package/src/{store → components/keypad-legacy/store}/input-reducer.ts +4 -4
  128. package/src/{store → components/keypad-legacy/store}/keypad-reducer.ts +2 -2
  129. package/src/{store → components/keypad-legacy/store}/layout-reducer.ts +3 -3
  130. package/src/{store → components/keypad-legacy/store}/shared.ts +3 -3
  131. package/src/{store → components/keypad-legacy/store}/types.ts +14 -18
  132. package/src/components/{styles.ts → keypad-legacy/styles.ts} +1 -1
  133. package/src/components/{text-icon.tsx → keypad-legacy/text-icon.tsx} +2 -2
  134. package/src/components/{touchable-keypad-button.tsx → keypad-legacy/touchable-keypad-button.tsx} +39 -20
  135. package/src/components/{two-page-keypad.tsx → keypad-legacy/two-page-keypad.tsx} +5 -6
  136. package/src/data/key-configs.ts +10 -15
  137. package/src/data/keys.ts +1 -6
  138. package/src/index.ts +3 -1
  139. package/src/math-input.stories.tsx +2 -2
  140. package/src/types.ts +15 -8
  141. package/tsconfig-build.tsbuildinfo +1 -1
  142. package/dist/components/keypad/trigonometry-page.d.ts +0 -8
  143. package/dist/components/touchable-keypad-button.d.ts +0 -30
  144. package/dist/components/touchable-keypad-button.js.flow +0 -35
  145. package/dist/components/velocity-tracker.d.ts +0 -48
  146. package/dist/components/velocity-tracker.js.flow +0 -54
  147. package/dist/store/pager-reducer.d.ts +0 -4
  148. package/dist/store/pager-reducer.js.flow +0 -13
  149. package/dist/store/shared.d.ts +0 -7
  150. package/dist/store/shared.js.flow +0 -14
  151. package/src/components/velocity-tracker.ts +0 -86
  152. package/src/store/pager-reducer.ts +0 -125
  153. /package/dist/components/{corner-decal.d.ts → keypad-legacy/corner-decal.d.ts} +0 -0
  154. /package/dist/components/{corner-decal.js.flow → keypad-legacy/corner-decal.js.flow} +0 -0
  155. /package/dist/components/{empty-keypad-button.d.ts → keypad-legacy/empty-keypad-button.d.ts} +0 -0
  156. /package/dist/components/{empty-keypad-button.js.flow → keypad-legacy/empty-keypad-button.js.flow} +0 -0
  157. /package/dist/components/{many-keypad-button.d.ts → keypad-legacy/many-keypad-button.d.ts} +0 -0
  158. /package/dist/components/{many-keypad-button.js.flow → keypad-legacy/many-keypad-button.js.flow} +0 -0
  159. /package/dist/components/{math-icon.d.ts → keypad-legacy/math-icon.d.ts} +0 -0
  160. /package/dist/components/{math-icon.js.flow → keypad-legacy/math-icon.js.flow} +0 -0
  161. /package/dist/components/{navigation-pad.d.ts → keypad-legacy/navigation-pad.d.ts} +0 -0
  162. /package/dist/components/{navigation-pad.js.flow → keypad-legacy/navigation-pad.js.flow} +0 -0
  163. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.d.ts +0 -0
  164. /package/dist/{store → components/keypad-legacy/store}/echo-reducer.js.flow +0 -0
  165. /package/dist/{store → components/keypad-legacy/store}/input-reducer.d.ts +0 -0
  166. /package/dist/{store → components/keypad-legacy/store}/input-reducer.js.flow +0 -0
  167. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.d.ts +0 -0
  168. /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.js.flow +0 -0
  169. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.d.ts +0 -0
  170. /package/dist/{store → components/keypad-legacy/store}/layout-reducer.js.flow +0 -0
  171. /package/dist/components/{styles.d.ts → keypad-legacy/styles.d.ts} +0 -0
  172. /package/dist/components/{styles.js.flow → keypad-legacy/styles.js.flow} +0 -0
  173. /package/dist/components/{svg-icon.d.ts → keypad-legacy/svg-icon.d.ts} +0 -0
  174. /package/dist/components/{svg-icon.js.flow → keypad-legacy/svg-icon.js.flow} +0 -0
  175. /package/dist/components/{text-icon.d.ts → keypad-legacy/text-icon.d.ts} +0 -0
  176. /package/dist/components/{text-icon.js.flow → keypad-legacy/text-icon.js.flow} +0 -0
  177. /package/dist/components/{z-indexes.d.ts → keypad-legacy/z-indexes.d.ts} +0 -0
  178. /package/dist/components/{z-indexes.js.flow → keypad-legacy/z-indexes.js.flow} +0 -0
  179. /package/src/components/{__tests__ → keypad-legacy/__tests__}/gesture-state-machine.test.ts +0 -0
  180. /package/src/components/{__tests__ → keypad-legacy/__tests__}/node-manager.test.ts +0 -0
  181. /package/src/components/{iconography → keypad-legacy/iconography}/arrow.js +0 -0
  182. /package/src/components/{iconography → keypad-legacy/iconography}/backspace.js +0 -0
  183. /package/src/components/{iconography → keypad-legacy/iconography}/cdot.js +0 -0
  184. /package/src/components/{iconography → keypad-legacy/iconography}/cos.js +0 -0
  185. /package/src/components/{iconography → keypad-legacy/iconography}/cube-root.js +0 -0
  186. /package/src/components/{iconography → keypad-legacy/iconography}/dismiss.js +0 -0
  187. /package/src/components/{iconography → keypad-legacy/iconography}/divide.js +0 -0
  188. /package/src/components/{iconography → keypad-legacy/iconography}/down.js +0 -0
  189. /package/src/components/{iconography → keypad-legacy/iconography}/equal.js +0 -0
  190. /package/src/components/{iconography → keypad-legacy/iconography}/exp-2.js +0 -0
  191. /package/src/components/{iconography → keypad-legacy/iconography}/exp-3.js +0 -0
  192. /package/src/components/{iconography → keypad-legacy/iconography}/exp.js +0 -0
  193. /package/src/components/{iconography → keypad-legacy/iconography}/frac.js +0 -0
  194. /package/src/components/{iconography → keypad-legacy/iconography}/geq.js +0 -0
  195. /package/src/components/{iconography → keypad-legacy/iconography}/gt.js +0 -0
  196. /package/src/components/{iconography → keypad-legacy/iconography}/index.js +0 -0
  197. /package/src/components/{iconography → keypad-legacy/iconography}/jump-into-numerator.js +0 -0
  198. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-base.js +0 -0
  199. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-denominator.js +0 -0
  200. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-exponent.js +0 -0
  201. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-numerator.js +0 -0
  202. /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-parentheses.js +0 -0
  203. /package/src/components/{iconography → keypad-legacy/iconography}/left-paren.js +0 -0
  204. /package/src/components/{iconography → keypad-legacy/iconography}/left.js +0 -0
  205. /package/src/components/{iconography → keypad-legacy/iconography}/leq.js +0 -0
  206. /package/src/components/{iconography → keypad-legacy/iconography}/ln.js +0 -0
  207. /package/src/components/{iconography → keypad-legacy/iconography}/log-n.js +0 -0
  208. /package/src/components/{iconography → keypad-legacy/iconography}/log.js +0 -0
  209. /package/src/components/{iconography → keypad-legacy/iconography}/lt.js +0 -0
  210. /package/src/components/{iconography → keypad-legacy/iconography}/minus.js +0 -0
  211. /package/src/components/{iconography → keypad-legacy/iconography}/neq.js +0 -0
  212. /package/src/components/{iconography → keypad-legacy/iconography}/parens.js +0 -0
  213. /package/src/components/{iconography → keypad-legacy/iconography}/percent.js +0 -0
  214. /package/src/components/{iconography → keypad-legacy/iconography}/period.js +0 -0
  215. /package/src/components/{iconography → keypad-legacy/iconography}/plus.js +0 -0
  216. /package/src/components/{iconography → keypad-legacy/iconography}/radical.js +0 -0
  217. /package/src/components/{iconography → keypad-legacy/iconography}/right-paren.js +0 -0
  218. /package/src/components/{iconography → keypad-legacy/iconography}/right.js +0 -0
  219. /package/src/components/{iconography → keypad-legacy/iconography}/sin.js +0 -0
  220. /package/src/components/{iconography → keypad-legacy/iconography}/sqrt.js +0 -0
  221. /package/src/components/{iconography → keypad-legacy/iconography}/tan.js +0 -0
  222. /package/src/components/{iconography → keypad-legacy/iconography}/times.js +0 -0
  223. /package/src/components/{iconography → keypad-legacy/iconography}/up.js +0 -0
  224. /package/src/components/{svg-icon.tsx → keypad-legacy/svg-icon.tsx} +0 -0
  225. /package/src/components/{z-indexes.ts → keypad-legacy/z-indexes.ts} +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 KeyConfigs from "../data/key-configs";
13
- import Keys from "../data/keys";
14
- import {KeyType} from "../enums";
12
+ import KeyConfigs from "../../data/key-configs";
13
+ import Keys from "../../data/keys";
14
+ import {KeyType} from "../../enums";
15
15
 
16
16
  import GestureManager from "./gesture-manager";
17
17
  import KeypadButton from "./keypad-button";
18
18
 
19
- import type {Border, IconConfig} 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<Keys>;
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: Keys;
41
+ id: Keys | "MANY";
42
+ focused: boolean;
29
43
  popoverEnabled: boolean;
30
- style: StyleType;
31
- type: KeyType;
44
+ childKeys?: ReadonlyArray<NonManyKeyConfig>;
45
+ ariaLabel?: string;
32
46
  icon: IconConfig;
33
- };
47
+ type: KeyType;
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,18 +116,23 @@ 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).
@@ -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
  }
@@ -14,7 +14,10 @@ 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
23
  type: KeyType.OPERATOR,
@@ -254,22 +257,14 @@ const KeyConfigs: any = {
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: KeyType.MANY,
272
- // childKeyIds will be configured by the client.
267
+ [Keys.PERIOD]: {},
273
268
  };
274
269
 
275
270
  // Add in every numeral.
package/src/data/keys.ts CHANGED
@@ -59,14 +59,9 @@ enum Keys {
59
59
 
60
60
  NOOP = "NOOP", // mobile native only
61
61
 
62
- // Multi-functional keys.
63
62
  // A custom key that captures an arbitrary number of symbols but has no
64
63
  // 'default' symbol or action.
65
- FRAC_MULTI = "FRAC_MULTI", // mobile native only
66
-
67
- // A custom key that captures an arbitrary number of symbols but has no
68
- // 'default' symbol or action.
69
- MANY = "MANY",
64
+ // MANY = "MANY",
70
65
  }
71
66
 
72
67
  export default Keys;
package/src/index.ts CHANGED
@@ -7,7 +7,9 @@ import "../less/main.less";
7
7
  export {CursorContext} from "./components/input/cursor-contexts";
8
8
  export {default as KeypadInput} from "./components/input/math-input";
9
9
  export {keypadElementPropType} from "./components/prop-types";
10
- export {default as Keypad} from "./components/provided-keypad";
10
+ export {default as LegacyKeypad} from "./components/keypad-legacy/provided-keypad";
11
11
  export {default as KeyConfigs} from "./data/key-configs";
12
12
  export {default as Keys} from "./data/keys";
13
13
  export {KeyType, KeypadType} from "./enums";
14
+
15
+ export {default as Keypad} from "./components/keypad/index";
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
 
3
- import {Keypad, KeypadInput, KeypadType} from "./index";
3
+ import {LegacyKeypad, KeypadInput, KeypadType} from "./index";
4
4
 
5
5
  export default {
6
6
  title: "Full MathInput",
@@ -55,7 +55,7 @@ export const Basic = () => {
55
55
  }}
56
56
  />
57
57
 
58
- <Keypad
58
+ <LegacyKeypad
59
59
  onElementMounted={(node) => {
60
60
  if (node && !keypadElement) {
61
61
  setKeypadElement(node);
package/src/types.ts CHANGED
@@ -11,14 +11,14 @@ import type {CursorContext} from "./components/input/cursor-contexts";
11
11
 
12
12
  export type Border = Partial<ReadonlyArray<BorderDirection>>;
13
13
 
14
- export type Bound = {
14
+ export interface Bound {
15
15
  top: number;
16
16
  right: number;
17
17
  bottom: number;
18
18
  left: number;
19
19
  height: number;
20
20
  width: number;
21
- };
21
+ }
22
22
 
23
23
  export type Popover = {
24
24
  parentId: Keys;
@@ -29,9 +29,8 @@ export type Popover = {
29
29
  export type Echo = {
30
30
  animationId: string;
31
31
  animationType: EchoAnimationType;
32
- borders: Border;
33
32
  id: Keys;
34
- initialBounds: DOMRect;
33
+ initialBounds: Bound;
35
34
  };
36
35
 
37
36
  export type IconConfig = {
@@ -39,14 +38,22 @@ export type IconConfig = {
39
38
  data: string;
40
39
  };
41
40
 
42
- export type KeyConfig = {
43
- ariaLabel: string;
41
+ export type NonManyKeyConfig = {
44
42
  id: Keys;
45
43
  type: KeyType;
46
- childKeyIds: Array<Keys>;
47
44
  icon: IconConfig;
45
+ ariaLabel: string;
48
46
  };
49
47
 
48
+ export type ManyKeyConfig = {
49
+ id: "MANY";
50
+ type: KeyType.MANY;
51
+ childKeyIds: ReadonlyArray<string>;
52
+ ariaLabel?: string;
53
+ };
54
+
55
+ export type KeyConfig = NonManyKeyConfig | ManyKeyConfig;
56
+
50
57
  export type KeypadConfiguration = {
51
58
  keypadType: KeypadType;
52
59
  extraKeys?: ReadonlyArray<Keys>;
@@ -78,4 +85,4 @@ export type ActiveNodesObj = {
78
85
  focus: string | null;
79
86
  };
80
87
 
81
- export type LayoutProps = {initialBounds: DOMRect; borders: Border};
88
+ export type LayoutProps = {initialBounds: Bound};