@khanacademy/math-input 0.0.0-PR442-20230403162612

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 (227) hide show
  1. package/.eslintrc.js +12 -0
  2. package/CHANGELOG.md +117 -0
  3. package/README.md +39 -0
  4. package/dist/components/common-style.d.ts +21 -0
  5. package/dist/components/common-style.js.flow +27 -0
  6. package/dist/components/input/cursor-contexts.d.ts +19 -0
  7. package/dist/components/input/cursor-contexts.js.flow +32 -0
  8. package/dist/components/input/cursor-handle.d.ts +25 -0
  9. package/dist/components/input/cursor-handle.js.flow +28 -0
  10. package/dist/components/input/math-input.d.ts +128 -0
  11. package/dist/components/input/math-input.js.flow +152 -0
  12. package/dist/components/keypad/button-assets.d.ts +6 -0
  13. package/dist/components/keypad/button-assets.js.flow +12 -0
  14. package/dist/components/keypad/button.d.ts +13 -0
  15. package/dist/components/keypad/button.js.flow +18 -0
  16. package/dist/components/keypad/index.d.ts +15 -0
  17. package/dist/components/keypad/index.js.flow +22 -0
  18. package/dist/components/keypad/keypad-page-items.d.ts +23 -0
  19. package/dist/components/keypad/keypad-page-items.js.flow +29 -0
  20. package/dist/components/keypad/numeric-input-page.d.ts +8 -0
  21. package/dist/components/keypad/numeric-input-page.js.flow +13 -0
  22. package/dist/components/keypad/pre-algebra-page.d.ts +8 -0
  23. package/dist/components/keypad/pre-algebra-page.js.flow +13 -0
  24. package/dist/components/keypad/trigonometry-page.d.ts +8 -0
  25. package/dist/components/keypad/trigonometry-page.js.flow +15 -0
  26. package/dist/components/provided-keypad.d.ts +23 -0
  27. package/dist/components/provided-keypad.js.flow +32 -0
  28. package/dist/components/tabbar/icons.d.ts +7 -0
  29. package/dist/components/tabbar/icons.js.flow +13 -0
  30. package/dist/components/tabbar/item.d.ts +14 -0
  31. package/dist/components/tabbar/item.js.flow +20 -0
  32. package/dist/components/tabbar/tabbar.d.ts +14 -0
  33. package/dist/components/tabbar/tabbar.js.flow +20 -0
  34. package/dist/components/tabbar/types.d.ts +1 -0
  35. package/dist/components/tabbar/types.js.flow +7 -0
  36. package/dist/components/z-indexes.d.ts +7 -0
  37. package/dist/components/z-indexes.js.flow +13 -0
  38. package/dist/consts.d.ts +51 -0
  39. package/dist/consts.js.flow +66 -0
  40. package/dist/data/key-configs.d.ts +7 -0
  41. package/dist/data/key-configs.js.flow +13 -0
  42. package/dist/data/keys.d.ts +57 -0
  43. package/dist/data/keys.js.flow +112 -0
  44. package/dist/es/index.css +587 -0
  45. package/dist/es/index.js +7382 -0
  46. package/dist/es/index.js.map +1 -0
  47. package/dist/fake-react-native-web/index.d.ts +10 -0
  48. package/dist/fake-react-native-web/index.js.flow +8 -0
  49. package/dist/fake-react-native-web/text.d.ts +12 -0
  50. package/dist/fake-react-native-web/text.js.flow +18 -0
  51. package/dist/fake-react-native-web/view.d.ts +22 -0
  52. package/dist/fake-react-native-web/view.js.flow +28 -0
  53. package/dist/index.css +587 -0
  54. package/dist/index.d.ts +14 -0
  55. package/dist/index.js +7331 -0
  56. package/dist/index.js.flow +20 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/store/index.d.ts +1 -0
  59. package/dist/store/index.js.flow +7 -0
  60. package/dist/strings.js +71 -0
  61. package/dist/utils.d.ts +1 -0
  62. package/dist/utils.js.flow +7 -0
  63. package/index.html +20 -0
  64. package/less/echo.less +56 -0
  65. package/less/main.less +5 -0
  66. package/less/overrides.less +129 -0
  67. package/less/popover.less +22 -0
  68. package/less/tabbar.less +6 -0
  69. package/package.json +64 -0
  70. package/src/actions/index.js +57 -0
  71. package/src/components/__tests__/gesture-state-machine_test.js +437 -0
  72. package/src/components/__tests__/node-manager_test.js +89 -0
  73. package/src/components/__tests__/two-page-keypad_test.js +42 -0
  74. package/src/components/app.js +73 -0
  75. package/src/components/common-style.ts +46 -0
  76. package/src/components/compute-layout-parameters.js +157 -0
  77. package/src/components/corner-decal.js +56 -0
  78. package/src/components/echo-manager.js +160 -0
  79. package/src/components/empty-keypad-button.js +49 -0
  80. package/src/components/expression-keypad.js +323 -0
  81. package/src/components/fraction-keypad.js +176 -0
  82. package/src/components/gesture-manager.js +226 -0
  83. package/src/components/gesture-state-machine.js +283 -0
  84. package/src/components/icon.js +74 -0
  85. package/src/components/iconography/arrow.js +22 -0
  86. package/src/components/iconography/backspace.js +29 -0
  87. package/src/components/iconography/cdot.js +29 -0
  88. package/src/components/iconography/cos.js +30 -0
  89. package/src/components/iconography/cube-root.js +36 -0
  90. package/src/components/iconography/dismiss.js +25 -0
  91. package/src/components/iconography/divide.js +34 -0
  92. package/src/components/iconography/down.js +16 -0
  93. package/src/components/iconography/equal.js +33 -0
  94. package/src/components/iconography/exp-2.js +29 -0
  95. package/src/components/iconography/exp-3.js +29 -0
  96. package/src/components/iconography/exp.js +29 -0
  97. package/src/components/iconography/frac.js +44 -0
  98. package/src/components/iconography/geq.js +33 -0
  99. package/src/components/iconography/gt.js +33 -0
  100. package/src/components/iconography/index.js +45 -0
  101. package/src/components/iconography/jump-into-numerator.js +41 -0
  102. package/src/components/iconography/jump-out-base.js +30 -0
  103. package/src/components/iconography/jump-out-denominator.js +41 -0
  104. package/src/components/iconography/jump-out-exponent.js +30 -0
  105. package/src/components/iconography/jump-out-numerator.js +41 -0
  106. package/src/components/iconography/jump-out-parentheses.js +33 -0
  107. package/src/components/iconography/left-paren.js +33 -0
  108. package/src/components/iconography/left.js +16 -0
  109. package/src/components/iconography/leq.js +33 -0
  110. package/src/components/iconography/ln.js +29 -0
  111. package/src/components/iconography/log-n.js +29 -0
  112. package/src/components/iconography/log.js +29 -0
  113. package/src/components/iconography/lt.js +33 -0
  114. package/src/components/iconography/minus.js +32 -0
  115. package/src/components/iconography/neq.js +33 -0
  116. package/src/components/iconography/parens.js +33 -0
  117. package/src/components/iconography/percent.js +49 -0
  118. package/src/components/iconography/period.js +26 -0
  119. package/src/components/iconography/plus.js +32 -0
  120. package/src/components/iconography/radical.js +36 -0
  121. package/src/components/iconography/right-paren.js +33 -0
  122. package/src/components/iconography/right.js +16 -0
  123. package/src/components/iconography/sin.js +30 -0
  124. package/src/components/iconography/sqrt.js +32 -0
  125. package/src/components/iconography/tan.js +30 -0
  126. package/src/components/iconography/times.js +33 -0
  127. package/src/components/iconography/up.js +16 -0
  128. package/src/components/input/__tests__/context-tracking_test.js +177 -0
  129. package/src/components/input/__tests__/mathquill_test.js +747 -0
  130. package/src/components/input/__tests__/test-math-wrapper.jsx +33 -0
  131. package/src/components/input/cursor-contexts.ts +44 -0
  132. package/src/components/input/cursor-handle.tsx +137 -0
  133. package/src/components/input/drag-listener.js +75 -0
  134. package/src/components/input/math-input.tsx +993 -0
  135. package/src/components/input/math-wrapper.js +959 -0
  136. package/src/components/input/scroll-into-view.js +72 -0
  137. package/src/components/keypad/button-assets.tsx +493 -0
  138. package/src/components/keypad/button.stories.js +29 -0
  139. package/src/components/keypad/button.tsx +104 -0
  140. package/src/components/keypad/index.tsx +65 -0
  141. package/src/components/keypad/keypad-page-items.tsx +89 -0
  142. package/src/components/keypad/keypad-pages.stories.tsx +30 -0
  143. package/src/components/keypad/keypad.stories.tsx +33 -0
  144. package/src/components/keypad/numeric-input-page.tsx +99 -0
  145. package/src/components/keypad/pre-algebra-page.tsx +97 -0
  146. package/src/components/keypad/trigonometry-page.tsx +89 -0
  147. package/src/components/keypad-button.js +362 -0
  148. package/src/components/keypad-container.js +299 -0
  149. package/src/components/keypad.js +154 -0
  150. package/src/components/many-keypad-button.js +44 -0
  151. package/src/components/math-icon.js +65 -0
  152. package/src/components/multi-symbol-grid.js +182 -0
  153. package/src/components/multi-symbol-popover.js +59 -0
  154. package/src/components/navigation-pad.js +139 -0
  155. package/src/components/node-manager.js +129 -0
  156. package/src/components/popover-manager.js +76 -0
  157. package/src/components/popover-state-machine.js +173 -0
  158. package/src/components/prop-types.js +82 -0
  159. package/src/components/provided-keypad.tsx +105 -0
  160. package/src/components/styles.js +38 -0
  161. package/src/components/svg-icon.js +25 -0
  162. package/src/components/tabbar/__tests__/tabbar_test.js +65 -0
  163. package/src/components/tabbar/icons.tsx +64 -0
  164. package/src/components/tabbar/item.tsx +136 -0
  165. package/src/components/tabbar/tabbar.stories.js +60 -0
  166. package/src/components/tabbar/tabbar.tsx +59 -0
  167. package/src/components/tabbar/types.ts +1 -0
  168. package/src/components/text-icon.js +52 -0
  169. package/src/components/touchable-keypad-button.js +146 -0
  170. package/src/components/two-page-keypad.js +99 -0
  171. package/src/components/velocity-tracker.js +76 -0
  172. package/src/components/z-indexes.ts +8 -0
  173. package/src/consts.ts +91 -0
  174. package/src/data/key-configs.ts +349 -0
  175. package/src/data/keys.ts +124 -0
  176. package/src/demo.js +9 -0
  177. package/src/fake-react-native-web/index.ts +11 -0
  178. package/src/fake-react-native-web/text.tsx +54 -0
  179. package/src/fake-react-native-web/view.tsx +88 -0
  180. package/src/index.ts +22 -0
  181. package/src/native-app.js +85 -0
  182. package/src/store/index.ts +534 -0
  183. package/src/utils.ts +14 -0
  184. package/tools/svg-to-react/convert.py +111 -0
  185. package/tools/svg-to-react/icons/math-keypad-icon-0.svg +32 -0
  186. package/tools/svg-to-react/icons/math-keypad-icon-1.svg +32 -0
  187. package/tools/svg-to-react/icons/math-keypad-icon-2.svg +32 -0
  188. package/tools/svg-to-react/icons/math-keypad-icon-3.svg +32 -0
  189. package/tools/svg-to-react/icons/math-keypad-icon-4.svg +32 -0
  190. package/tools/svg-to-react/icons/math-keypad-icon-5.svg +32 -0
  191. package/tools/svg-to-react/icons/math-keypad-icon-6.svg +32 -0
  192. package/tools/svg-to-react/icons/math-keypad-icon-7.svg +32 -0
  193. package/tools/svg-to-react/icons/math-keypad-icon-8.svg +32 -0
  194. package/tools/svg-to-react/icons/math-keypad-icon-9.svg +32 -0
  195. package/tools/svg-to-react/icons/math-keypad-icon-addition.svg +34 -0
  196. package/tools/svg-to-react/icons/math-keypad-icon-cos.svg +38 -0
  197. package/tools/svg-to-react/icons/math-keypad-icon-delete.svg +36 -0
  198. package/tools/svg-to-react/icons/math-keypad-icon-dismiss.svg +36 -0
  199. package/tools/svg-to-react/icons/math-keypad-icon-division.svg +36 -0
  200. package/tools/svg-to-react/icons/math-keypad-icon-equals-not.svg +50 -0
  201. package/tools/svg-to-react/icons/math-keypad-icon-equals.svg +48 -0
  202. package/tools/svg-to-react/icons/math-keypad-icon-exponent-2.svg +38 -0
  203. package/tools/svg-to-react/icons/math-keypad-icon-exponent-3.svg +38 -0
  204. package/tools/svg-to-react/icons/math-keypad-icon-exponent.svg +38 -0
  205. package/tools/svg-to-react/icons/math-keypad-icon-fraction.svg +42 -0
  206. package/tools/svg-to-react/icons/math-keypad-icon-greater-than.svg +46 -0
  207. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-base.svg +44 -0
  208. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-denominator.svg +48 -0
  209. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-exponent.svg +44 -0
  210. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-parentheses.svg +44 -0
  211. package/tools/svg-to-react/icons/math-keypad-icon-less-than.svg +46 -0
  212. package/tools/svg-to-react/icons/math-keypad-icon-log-10.svg +36 -0
  213. package/tools/svg-to-react/icons/math-keypad-icon-log-e.svg +36 -0
  214. package/tools/svg-to-react/icons/math-keypad-icon-log.svg +38 -0
  215. package/tools/svg-to-react/icons/math-keypad-icon-multiplication-cross.svg +40 -0
  216. package/tools/svg-to-react/icons/math-keypad-icon-multiplication-dot.svg +38 -0
  217. package/tools/svg-to-react/icons/math-keypad-icon-percent.svg +42 -0
  218. package/tools/svg-to-react/icons/math-keypad-icon-radical-2.svg +36 -0
  219. package/tools/svg-to-react/icons/math-keypad-icon-radical-3.svg +38 -0
  220. package/tools/svg-to-react/icons/math-keypad-icon-radical.svg +38 -0
  221. package/tools/svg-to-react/icons/math-keypad-icon-radix-character.svg +32 -0
  222. package/tools/svg-to-react/icons/math-keypad-icon-sin.svg +38 -0
  223. package/tools/svg-to-react/icons/math-keypad-icon-subtraction.svg +32 -0
  224. package/tools/svg-to-react/icons/math-keypad-icon-tan.svg +38 -0
  225. package/tools/svg-to-react/symbol_map.py +41 -0
  226. package/tsconfig.json +9 -0
  227. package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,12 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ /* eslint-disable import/no-commonjs */
3
+ const path = require("path");
4
+
5
+ module.exports = {
6
+ rules: {
7
+ "import/no-extraneous-dependencies": [
8
+ "error",
9
+ {packageDir: [__dirname, path.join(__dirname, "../../")]},
10
+ ],
11
+ },
12
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1,117 @@
1
+ # @khanacademy/math-input
2
+
3
+ ## 0.0.0-PR442-20230403162612
4
+
5
+ ### Patch Changes
6
+
7
+ - 8e8d85cd: Fix imported React types in a couple of files
8
+
9
+ ## 0.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 1f062e98: Bump all package versions since the build settings have been updated
14
+ - 406edf6b: Extract strings to dist/string.js instead of dist/strings.
15
+
16
+ ## 0.7.0
17
+
18
+ ### Minor Changes
19
+
20
+ - 53fd3768: Migrate source code to TypeScript
21
+
22
+ ## 0.6.8
23
+
24
+ ### Patch Changes
25
+
26
+ - 2c843b38: Update to use wonder-blocks deps after migrating wonder-blocks to TS
27
+
28
+ ## 0.6.7
29
+
30
+ ### Patch Changes
31
+
32
+ - a1b4ab3c: Update wonder-blocks and wonder-stuff deps to fix an issue with wonder-stuff's generated flow types
33
+
34
+ ## 0.6.6
35
+
36
+ ### Patch Changes
37
+
38
+ - 6a7f36be: Update wonder-stuff and wonder-blocks dependencies
39
+
40
+ ## 0.6.5
41
+
42
+ ### Patch Changes
43
+
44
+ - c238d540: Wrap all ReactDOM.render() calls in `<RenderStateRoot>` to ensure it propagates properly
45
+
46
+ ## 0.6.4
47
+
48
+ ### Patch Changes
49
+
50
+ - 113953e8: Exports new types to support custom keypads: `CursorContext`, `KeypadType`, `KeyType`, and `Key`
51
+
52
+ ## 0.6.3
53
+
54
+ ### Patch Changes
55
+
56
+ - f567f660: Update the eslint config to look at both the package.json for the package and the one from the root
57
+
58
+ ## 0.6.2
59
+
60
+ ### Patch Changes
61
+
62
+ - bf180fe1: Fix our use of import/no-extraneous-dependencies
63
+
64
+ ## 0.6.1
65
+
66
+ ### Patch Changes
67
+
68
+ - 1a91b6c2: Adds missing wonder-blocks deps, makes wonder-blocks peerDeps
69
+
70
+ ## 0.6.0
71
+
72
+ ### Minor Changes
73
+
74
+ - 8fcd2a28: Inline the import of mathquill.css in math-input's main.less
75
+
76
+ ## 0.5.6
77
+
78
+ ### Patch Changes
79
+
80
+ - 98d283ff: Fix storybook
81
+
82
+ ## 0.5.5
83
+
84
+ ### Patch Changes
85
+
86
+ - 6f8f1ac9: Use wonder-blocks-i18n to determine the decimal separator
87
+
88
+ ## 0.5.4
89
+
90
+ ### Patch Changes
91
+
92
+ - f29b4975: Export the KeyConfigs type
93
+
94
+ ## 0.5.3
95
+
96
+ ### Patch Changes
97
+
98
+ - 96288b87: Export CursorContexts
99
+
100
+ ## 0.5.2
101
+
102
+ ### Patch Changes
103
+
104
+ - a15b0e86: Add 'perseus-build-settings' as a dev dep to packages that were missing it
105
+
106
+ ## 0.5.1
107
+
108
+ ### Patch Changes
109
+
110
+ - 591420a6: Add @flow comment to math-input's index.js and missing props to ProvidedKeypad
111
+
112
+ ## 0.5.0
113
+
114
+ ### Minor Changes
115
+
116
+ - ea57be17: Move math-input into khan/perseus repo (name changes to @khanacademy/math-input)
117
+ - 116df39b: Extract math-input strings from source and save them to packages/math-input/dist
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # math-input
2
+
3
+ Khan Academy's expression editor for the mobile web. Used in the [Perseus](https://github.com/khan/perseus) exercise framework to power math input and expression editing on small screens.
4
+
5
+ Built with [React](https://github.com/facebook/react), [Redux](https://github.com/reactjs/redux), [MathQuill](https://github.com/mathquill/mathquill), [Aphrodite](https://github.com/khan/aphrodite), and more.
6
+
7
+ ![](https://cloud.githubusercontent.com/assets/1309177/15994911/d1acd29e-30c5-11e6-9707-6bef8e69114f.gif)
8
+
9
+ Try it yourself on [Khan Academy](https://www.khanacademy.org/math/algebra-basics/alg-basics-algebraic-expressions/alg-basics-distributive-property/e/distributive-property-with-variables). (Note: you'll need to enable mobile emulation, if you're accessing the site from a desktop browser.)
10
+
11
+ ## Getting started
12
+
13
+ - Clone the project: `git clone git@github.com:Khan/math-input.git`
14
+ - Install dependencies: `yarn install`
15
+ - Start the development server: `yarn start`
16
+
17
+ When you start the project you'll need to be on a device that supports touch or touch emulation to see the keyboard. The easiest way to get started is open the developer tools on Google Chrome.
18
+
19
+ ## Supported Features
20
+
21
+ - Multiple keypad configurations, so as to accommodate a range of input types (i.e., fractions/mixed numbers, algebraic expressions).
22
+ - Multi-page keypads, with swipeable page navigation.
23
+ - Touch-and-drag interactions (as supported by the stock iOS and Android keypads).
24
+ - A draggable cursor with a detached handle, for fine-grained control on touch devices.
25
+ - Custom state transitions for the editing experience, to streamline expression entry.
26
+
27
+ ![](https://cloud.githubusercontent.com/assets/1309177/15994912/d2b60cdc-30c5-11e6-8eb4-9086d76f327c.gif)
28
+
29
+ ## Demo
30
+
31
+ A live demo is available via [GitHub Pages](http://khan.github.io/math-input/). You can configure some of the keypad's behaviors, along with the set of active keys, via the [editor](http://khan.github.io/math-input/custom.html).
32
+
33
+ Note that, as the input and keypad only respond to touch events, you'll need to enable mobile emulation (e.g., as supported by Chrome) in order to use the keypad in a desktop browser.
34
+
35
+ To run the demo locally, clone the repo, `yarn install`, `yarn watch`, and open the `index.html` page. The local behaviors can similarly be customized via the editor @ `custom.html`.
36
+
37
+ ## License
38
+
39
+ [MIT License](http://opensource.org/licenses/MIT)
@@ -0,0 +1,21 @@
1
+ export declare const wonderBlocksBlue: string;
2
+ export declare const offBlack: string;
3
+ export declare const offBlack32: string;
4
+ export declare const offBlack16: string;
5
+ export declare const offBlack8: string;
6
+ export declare const iconSizeHeightPx = 48;
7
+ export declare const iconSizeWidthPx = 48;
8
+ export declare const compactKeypadBorderRadiusPx = 4;
9
+ export declare const cursorHandleRadiusPx = 11;
10
+ export declare const cursorHandleDistanceMultiplier = 1.045;
11
+ export declare const valueGrey = "#FFF";
12
+ export declare const operatorGrey = "#FAFAFA";
13
+ export declare const controlGrey = "#F6F7F7";
14
+ export declare const emptyGrey = "#F0F1F2";
15
+ export declare const innerBorderColor: string;
16
+ export declare const innerBorderStyle = "solid";
17
+ export declare const innerBorderWidthPx = 1;
18
+ export declare const tabletCutoffPx = 600;
19
+ export declare const pageIndicatorHeightPx = 16;
20
+ export declare const navigationPadWidthPx = 192;
21
+ export declare const toolbarHeightPx = 60;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ declare export var wonderBlocksBlue: string;
8
+ declare export var offBlack: string;
9
+ declare export var offBlack32: string;
10
+ declare export var offBlack16: string;
11
+ declare export var offBlack8: string;
12
+ declare export var iconSizeHeightPx: 48;
13
+ declare export var iconSizeWidthPx: 48;
14
+ declare export var compactKeypadBorderRadiusPx: 4;
15
+ declare export var cursorHandleRadiusPx: 11;
16
+ declare export var cursorHandleDistanceMultiplier: 1.045;
17
+ declare export var valueGrey: "#FFF";
18
+ declare export var operatorGrey: "#FAFAFA";
19
+ declare export var controlGrey: "#F6F7F7";
20
+ declare export var emptyGrey: "#F0F1F2";
21
+ declare export var innerBorderColor: string;
22
+ declare export var innerBorderStyle: "solid";
23
+ declare export var innerBorderWidthPx: 1;
24
+ declare export var tabletCutoffPx: 600;
25
+ declare export var pageIndicatorHeightPx: 16;
26
+ declare export var navigationPadWidthPx: 192;
27
+ declare export var toolbarHeightPx: 60;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Constants that define the various contexts in which a cursor can exist. The
3
+ * active context is determined first by looking at the cursor's siblings (e.g.,
4
+ * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
5
+ * cursor could in theory be nested in multiple contexts, we only care about the
6
+ * immediate context.
7
+ *
8
+ * TODO(charlie): Add a context to represent being inside of a radical. Right
9
+ * now, we show the dismiss button rather than allowing the user to jump out of
10
+ * the radical.
11
+ */
12
+ export type CursorContext = "NONE" | "IN_PARENS" | "IN_SUPER_SCRIPT" | "IN_SUB_SCRIPT" | "IN_NUMERATOR" | "IN_DENOMINATOR" | "BEFORE_FRACTION";
13
+ export declare const NONE = "NONE";
14
+ export declare const IN_PARENS = "IN_PARENS";
15
+ export declare const IN_SUPER_SCRIPT = "IN_SUPER_SCRIPT";
16
+ export declare const IN_SUB_SCRIPT = "IN_SUB_SCRIPT";
17
+ export declare const IN_NUMERATOR = "IN_NUMERATOR";
18
+ export declare const IN_DENOMINATOR = "IN_DENOMINATOR";
19
+ export declare const BEFORE_FRACTION = "BEFORE_FRACTION";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * Constants that define the various contexts in which a cursor can exist. The
9
+ * active context is determined first by looking at the cursor's siblings (e.g.,
10
+ * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
11
+ * cursor could in theory be nested in multiple contexts, we only care about the
12
+ * immediate context.
13
+ *
14
+ * TODO(charlie): Add a context to represent being inside of a radical. Right
15
+ * now, we show the dismiss button rather than allowing the user to jump out of
16
+ * the radical.
17
+ */
18
+ export type CursorContext =
19
+ | "NONE"
20
+ | "IN_PARENS"
21
+ | "IN_SUPER_SCRIPT"
22
+ | "IN_SUB_SCRIPT"
23
+ | "IN_NUMERATOR"
24
+ | "IN_DENOMINATOR"
25
+ | "BEFORE_FRACTION";
26
+ declare export var NONE: "NONE";
27
+ declare export var IN_PARENS: "IN_PARENS";
28
+ declare export var IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT";
29
+ declare export var IN_SUB_SCRIPT: "IN_SUB_SCRIPT";
30
+ declare export var IN_NUMERATOR: "IN_NUMERATOR";
31
+ declare export var IN_DENOMINATOR: "IN_DENOMINATOR";
32
+ declare export var BEFORE_FRACTION: "BEFORE_FRACTION";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Renders the green tear-shaped handle under the cursor.
3
+ */
4
+ import * as React from "react";
5
+ type Props = {
6
+ animateIntoPosition: boolean | null | undefined;
7
+ onTouchCancel: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
8
+ onTouchEnd: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
9
+ onTouchMove: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
10
+ onTouchStart: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
11
+ visible: boolean;
12
+ x: number;
13
+ y: number;
14
+ };
15
+ type DefaultProps = {
16
+ animateIntoPosition: Props["animateIntoPosition"];
17
+ visible: Props["visible"];
18
+ x: Props["x"];
19
+ y: Props["y"];
20
+ };
21
+ declare class CursorHandle extends React.Component<Props> {
22
+ static defaultProps: DefaultProps;
23
+ render(): React.ReactNode;
24
+ }
25
+ export default CursorHandle;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ animateIntoPosition: boolean | null | void,
10
+ onTouchCancel: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
11
+ onTouchEnd: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
12
+ onTouchMove: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
13
+ onTouchStart: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
14
+ visible: boolean,
15
+ x: number,
16
+ y: number,
17
+ |};
18
+ declare type DefaultProps = {|
19
+ animateIntoPosition: $PropertyType<Props, "animateIntoPosition">,
20
+ visible: $PropertyType<Props, "visible">,
21
+ x: $PropertyType<Props, "x">,
22
+ y: $PropertyType<Props, "y">,
23
+ |};
24
+ declare class CursorHandle extends React.Component<Props> {
25
+ static defaultProps: DefaultProps;
26
+ render(): React.Node;
27
+ }
28
+ declare export default typeof CursorHandle;
@@ -0,0 +1,128 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ keypadElement: any;
4
+ onBlur: () => void;
5
+ onChange: any;
6
+ onFocus: () => void;
7
+ style: any;
8
+ value: string;
9
+ };
10
+ type DefaultProps = {
11
+ style: Props["style"];
12
+ value: Props["value"];
13
+ };
14
+ type HandleState = {
15
+ animateIntoPosition?: boolean | null | undefined;
16
+ visible: boolean;
17
+ x?: number;
18
+ y?: number;
19
+ };
20
+ type State = {
21
+ focused: boolean;
22
+ handle: HandleState;
23
+ };
24
+ declare class MathInput extends React.Component<Props, State> {
25
+ didTouchOutside: boolean | null | undefined;
26
+ didScroll: boolean | null | undefined;
27
+ mathField: any;
28
+ recordTouchStartOutside: (arg1: any) => void;
29
+ blurOnTouchEndOutside: (arg1: any) => void;
30
+ dragListener: any;
31
+ inputRef: HTMLDivElement | null | undefined;
32
+ _isMounted: boolean | null | undefined;
33
+ _mathContainer: any;
34
+ _container: HTMLDivElement;
35
+ _root: any;
36
+ _containerBounds: ClientRect;
37
+ _keypadBounds: ClientRect | null | undefined;
38
+ static defaultProps: DefaultProps;
39
+ state: State;
40
+ componentDidMount(): void;
41
+ UNSAFE_componentWillReceiveProps(props: Props): void;
42
+ componentDidUpdate(prevProps: Props, prevState: State): void;
43
+ componentWillUnmount(): void;
44
+ _clearKeypadBoundsCache: () => void;
45
+ _cacheKeypadBounds: (arg1: any) => void;
46
+ _updateInputPadding: () => void;
47
+ /** Gets and cache they bounds of the keypadElement */
48
+ _getKeypadBounds: () => any;
49
+ _updateCursorHandle: (arg1?: boolean | null | undefined) => void;
50
+ _hideCursorHandle: () => void;
51
+ _handleScroll: () => void;
52
+ blur: () => void;
53
+ focus: () => void;
54
+ /**
55
+ * Tries to determine which DOM node to place the cursor next to based on
56
+ * where the user drags the cursor handle. If it finds a node it will
57
+ * place the cursor next to it, update the handle to be under the cursor,
58
+ * and return true. If it doesn't find a node, it returns false.
59
+ *
60
+ * It searches for nodes by doing it tests at the following points:
61
+ *
62
+ * (x - dx, y), (x, y), (x + dx, y)
63
+ *
64
+ * If it doesn't find any nodes from the rendered math it will update y
65
+ * by adding dy.
66
+ *
67
+ * The algorithm ends its search when y goes outside the bounds of
68
+ * containerBounds.
69
+ *
70
+ * @param {DOMRect} containerBounds - bounds of the container node
71
+ * @param {number} x - the initial x coordinate in the viewport
72
+ * @param {number} y - the initial y coordinate in the viewport
73
+ * @param {number} dx - horizontal spacing between elementFromPoint calls
74
+ * @param {number} dy - vertical spacing between elementFromPoint calls,
75
+ * sign determines direction.
76
+ * @returns {boolean} - true if a node was hit, false otherwise.
77
+ */
78
+ _findHitNode: (arg1: ClientRect, arg2: number, arg3: number, arg4: number, arg5: number) => boolean;
79
+ /**
80
+ * Inserts the cursor at the DOM node closest to the given coordinates,
81
+ * based on hit-tests conducted using #_findHitNode.
82
+ *
83
+ * @param {number} x - the x coordinate in the viewport
84
+ * @param {number} y - the y coordinate in the viewport
85
+ */
86
+ _insertCursorAtClosestNode: (arg1: number, arg2: number) => void;
87
+ handleTouchStart: (arg1: React.TouchEvent<HTMLDivElement>) => void;
88
+ handleTouchMove: (arg1: React.TouchEvent<HTMLDivElement>) => void;
89
+ handleTouchEnd: (arg1: React.TouchEvent<HTMLDivElement>) => void;
90
+ /**
91
+ * When a touch starts in the cursor handle, we track it so as to avoid
92
+ * handling any touch events ourself.
93
+ *
94
+ * @param {TouchEvent} e - the raw touch event from the browser
95
+ */
96
+ onCursorHandleTouchStart: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
97
+ _constrainToBound: (arg1: number, arg2: number, arg3: number, arg4: number) => number;
98
+ /**
99
+ * When the user moves the cursor handle update the position of the cursor
100
+ * and the handle.
101
+ *
102
+ * @param {TouchEvent} e - the raw touch event from the browser
103
+ */
104
+ onCursorHandleTouchMove: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
105
+ /**
106
+ * When the user releases the cursor handle, animate it back into place.
107
+ *
108
+ * @param {TouchEvent} e - the raw touch event from the browser
109
+ */
110
+ onCursorHandleTouchEnd: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
111
+ /**
112
+ * If the gesture is cancelled mid-drag, simply hide it.
113
+ *
114
+ * @param {TouchEvent} e - the raw touch event from the browser
115
+ */
116
+ onCursorHandleTouchCancel: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
117
+ domKeyToMathQuillKey: (arg1: string) => string | null | undefined;
118
+ handleKeyUp: (arg1: React.KeyboardEvent<HTMLDivElement>) => void;
119
+ getBorderWidthPx: () => number;
120
+ getInputInnerPadding: () => {
121
+ paddingTop: number;
122
+ paddingRight: number;
123
+ paddingBottom: number;
124
+ paddingLeft: number;
125
+ };
126
+ render(): React.ReactNode;
127
+ }
128
+ export default MathInput;
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ keypadElement: any,
10
+ onBlur: () => void,
11
+ onChange: any,
12
+ onFocus: () => void,
13
+ style: any,
14
+ value: string,
15
+ |};
16
+ declare type DefaultProps = {|
17
+ style: $PropertyType<Props, "style">,
18
+ value: $PropertyType<Props, "value">,
19
+ |};
20
+ declare type HandleState = {|
21
+ animateIntoPosition?: boolean | null | void,
22
+ visible: boolean,
23
+ x?: number,
24
+ y?: number,
25
+ |};
26
+ declare type State = {|
27
+ focused: boolean,
28
+ handle: HandleState,
29
+ |};
30
+ declare class MathInput extends React.Component<Props, State> {
31
+ didTouchOutside: boolean | null | void;
32
+ didScroll: boolean | null | void;
33
+ mathField: any;
34
+ recordTouchStartOutside: (arg1: any) => void;
35
+ blurOnTouchEndOutside: (arg1: any) => void;
36
+ dragListener: any;
37
+ inputRef: HTMLDivElement | null | void;
38
+ _isMounted: boolean | null | void;
39
+ _mathContainer: any;
40
+ _container: HTMLDivElement;
41
+ _root: any;
42
+ _containerBounds: ClientRect;
43
+ _keypadBounds: ClientRect | null | void;
44
+ static defaultProps: DefaultProps;
45
+ state: State;
46
+ componentDidMount(): void;
47
+ UNSAFE_componentWillReceiveProps(props: Props): void;
48
+ componentDidUpdate(prevProps: Props, prevState: State): void;
49
+ componentWillUnmount(): void;
50
+ _clearKeypadBoundsCache: () => void;
51
+ _cacheKeypadBounds: (arg1: any) => void;
52
+ _updateInputPadding: () => void;
53
+
54
+ /**
55
+ * Gets and cache they bounds of the keypadElement
56
+ */
57
+ _getKeypadBounds: () => any;
58
+ _updateCursorHandle: (arg1?: boolean | null | void) => void;
59
+ _hideCursorHandle: () => void;
60
+ _handleScroll: () => void;
61
+ blur: () => void;
62
+ focus: () => void;
63
+
64
+ /**
65
+ * Tries to determine which DOM node to place the cursor next to based on
66
+ * where the user drags the cursor handle. If it finds a node it will
67
+ * place the cursor next to it, update the handle to be under the cursor,
68
+ * and return true. If it doesn't find a node, it returns false.
69
+ *
70
+ * It searches for nodes by doing it tests at the following points:
71
+ *
72
+ * (x - dx, y), (x, y), (x + dx, y)
73
+ *
74
+ * If it doesn't find any nodes from the rendered math it will update y
75
+ * by adding dy.
76
+ *
77
+ * The algorithm ends its search when y goes outside the bounds of
78
+ * containerBounds.
79
+ * @param {DOMRect} containerBounds - bounds of the container node
80
+ * @param {number} x - the initial x coordinate in the viewport
81
+ * @param {number} y - the initial y coordinate in the viewport
82
+ * @param {number} dx - horizontal spacing between elementFromPoint calls
83
+ * @param {number} dy - vertical spacing between elementFromPoint calls,
84
+ * sign determines direction.
85
+ * @returns {boolean} - true if a node was hit, false otherwise.
86
+ */
87
+ _findHitNode: (
88
+ arg1: ClientRect,
89
+ arg2: number,
90
+ arg3: number,
91
+ arg4: number,
92
+ arg5: number
93
+ ) => boolean;
94
+
95
+ /**
96
+ * Inserts the cursor at the DOM node closest to the given coordinates,
97
+ * based on hit-tests conducted using #_findHitNode.
98
+ * @param {number} x - the x coordinate in the viewport
99
+ * @param {number} y - the y coordinate in the viewport
100
+ */
101
+ _insertCursorAtClosestNode: (arg1: number, arg2: number) => void;
102
+ handleTouchStart: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void;
103
+ handleTouchMove: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void;
104
+ handleTouchEnd: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void;
105
+
106
+ /**
107
+ * When a touch starts in the cursor handle, we track it so as to avoid
108
+ * handling any touch events ourself.
109
+ * @param {TouchEvent} e - the raw touch event from the browser
110
+ */
111
+ onCursorHandleTouchStart: (
112
+ arg1: SyntheticTouchEvent<HTMLSpanElement>
113
+ ) => void;
114
+ _constrainToBound: (
115
+ arg1: number,
116
+ arg2: number,
117
+ arg3: number,
118
+ arg4: number
119
+ ) => number;
120
+
121
+ /**
122
+ * When the user moves the cursor handle update the position of the cursor
123
+ * and the handle.
124
+ * @param {TouchEvent} e - the raw touch event from the browser
125
+ */
126
+ onCursorHandleTouchMove: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void;
127
+
128
+ /**
129
+ * When the user releases the cursor handle, animate it back into place.
130
+ * @param {TouchEvent} e - the raw touch event from the browser
131
+ */
132
+ onCursorHandleTouchEnd: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void;
133
+
134
+ /**
135
+ * If the gesture is cancelled mid-drag, simply hide it.
136
+ * @param {TouchEvent} e - the raw touch event from the browser
137
+ */
138
+ onCursorHandleTouchCancel: (
139
+ arg1: SyntheticTouchEvent<HTMLSpanElement>
140
+ ) => void;
141
+ domKeyToMathQuillKey: (arg1: string) => string | null | void;
142
+ handleKeyUp: (arg1: SyntheticKeyboardEvent<HTMLDivElement>) => void;
143
+ getBorderWidthPx: () => number;
144
+ getInputInnerPadding: () => {|
145
+ paddingTop: number,
146
+ paddingRight: number,
147
+ paddingBottom: number,
148
+ paddingLeft: number,
149
+ |};
150
+ render(): React.Node;
151
+ }
152
+ declare export default typeof MathInput;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ type KeyId = string;
3
+ declare const buttonAsset: React.FC<{
4
+ id: KeyId;
5
+ }>;
6
+ export default buttonAsset;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type KeyId = string;
9
+ declare var buttonAsset: React.StatelessFunctionalComponent<{|
10
+ id: KeyId,
11
+ |}>;
12
+ declare export default typeof buttonAsset;
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
3
+ type Props = {
4
+ onPress: () => void;
5
+ children: React.ReactNode;
6
+ style?: StyleType;
7
+ tintColor?: string;
8
+ };
9
+ type State = Record<any, any>;
10
+ export default class Button extends React.Component<Props, State> {
11
+ render(): React.ReactNode;
12
+ }
13
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
+ declare type Props = {|
10
+ onPress: () => void,
11
+ children: React.Node,
12
+ style?: StyleType,
13
+ tintColor?: string,
14
+ |};
15
+ declare type State = { [key: any]: any };
16
+ declare export default class Button extends React.Component<Props, State> {
17
+ render(): React.Node;
18
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import type { TabbarItemType } from "../tabbar/types";
3
+ type Props = {
4
+ onClickKey: (keyConfig: string) => void;
5
+ preAlgebra: boolean;
6
+ trigonometry: boolean;
7
+ };
8
+ type State = {
9
+ selectedPage: TabbarItemType;
10
+ };
11
+ export default class PreAlgebraKeypad extends React.Component<Props, State> {
12
+ state: State;
13
+ render(): React.ReactNode;
14
+ }
15
+ export {};