@khanacademy/math-input 0.0.0-PR443-20230328215601

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 (174) hide show
  1. package/.eslintrc.js +12 -0
  2. package/CHANGELOG.md +104 -0
  3. package/README.md +39 -0
  4. package/dist/es/index.css +587 -0
  5. package/dist/es/index.js +7291 -0
  6. package/dist/es/index.js.map +1 -0
  7. package/dist/index.css +587 -0
  8. package/dist/index.js +7333 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/strings +71 -0
  11. package/index.html +20 -0
  12. package/less/echo.less +56 -0
  13. package/less/main.less +5 -0
  14. package/less/overrides.less +129 -0
  15. package/less/popover.less +22 -0
  16. package/less/tabbar.less +6 -0
  17. package/package.json +64 -0
  18. package/src/actions/index.js +57 -0
  19. package/src/components/__tests__/gesture-state-machine_test.js +437 -0
  20. package/src/components/__tests__/node-manager_test.js +89 -0
  21. package/src/components/__tests__/two-page-keypad_test.js +42 -0
  22. package/src/components/app.js +73 -0
  23. package/src/components/common-style.ts +46 -0
  24. package/src/components/compute-layout-parameters.js +157 -0
  25. package/src/components/corner-decal.js +56 -0
  26. package/src/components/echo-manager.js +160 -0
  27. package/src/components/empty-keypad-button.js +49 -0
  28. package/src/components/expression-keypad.js +323 -0
  29. package/src/components/fraction-keypad.js +176 -0
  30. package/src/components/gesture-manager.js +226 -0
  31. package/src/components/gesture-state-machine.js +283 -0
  32. package/src/components/icon.js +74 -0
  33. package/src/components/iconography/arrow.js +22 -0
  34. package/src/components/iconography/backspace.js +29 -0
  35. package/src/components/iconography/cdot.js +29 -0
  36. package/src/components/iconography/cos.js +30 -0
  37. package/src/components/iconography/cube-root.js +36 -0
  38. package/src/components/iconography/dismiss.js +25 -0
  39. package/src/components/iconography/divide.js +34 -0
  40. package/src/components/iconography/down.js +16 -0
  41. package/src/components/iconography/equal.js +33 -0
  42. package/src/components/iconography/exp-2.js +29 -0
  43. package/src/components/iconography/exp-3.js +29 -0
  44. package/src/components/iconography/exp.js +29 -0
  45. package/src/components/iconography/frac.js +44 -0
  46. package/src/components/iconography/geq.js +33 -0
  47. package/src/components/iconography/gt.js +33 -0
  48. package/src/components/iconography/index.js +45 -0
  49. package/src/components/iconography/jump-into-numerator.js +41 -0
  50. package/src/components/iconography/jump-out-base.js +30 -0
  51. package/src/components/iconography/jump-out-denominator.js +41 -0
  52. package/src/components/iconography/jump-out-exponent.js +30 -0
  53. package/src/components/iconography/jump-out-numerator.js +41 -0
  54. package/src/components/iconography/jump-out-parentheses.js +33 -0
  55. package/src/components/iconography/left-paren.js +33 -0
  56. package/src/components/iconography/left.js +16 -0
  57. package/src/components/iconography/leq.js +33 -0
  58. package/src/components/iconography/ln.js +29 -0
  59. package/src/components/iconography/log-n.js +29 -0
  60. package/src/components/iconography/log.js +29 -0
  61. package/src/components/iconography/lt.js +33 -0
  62. package/src/components/iconography/minus.js +32 -0
  63. package/src/components/iconography/neq.js +33 -0
  64. package/src/components/iconography/parens.js +33 -0
  65. package/src/components/iconography/percent.js +49 -0
  66. package/src/components/iconography/period.js +26 -0
  67. package/src/components/iconography/plus.js +32 -0
  68. package/src/components/iconography/radical.js +36 -0
  69. package/src/components/iconography/right-paren.js +33 -0
  70. package/src/components/iconography/right.js +16 -0
  71. package/src/components/iconography/sin.js +30 -0
  72. package/src/components/iconography/sqrt.js +32 -0
  73. package/src/components/iconography/tan.js +30 -0
  74. package/src/components/iconography/times.js +33 -0
  75. package/src/components/iconography/up.js +16 -0
  76. package/src/components/input/__tests__/context-tracking_test.js +177 -0
  77. package/src/components/input/__tests__/mathquill_test.js +747 -0
  78. package/src/components/input/__tests__/test-math-wrapper.jsx +33 -0
  79. package/src/components/input/cursor-contexts.ts +44 -0
  80. package/src/components/input/cursor-handle.tsx +137 -0
  81. package/src/components/input/drag-listener.js +75 -0
  82. package/src/components/input/math-input.tsx +993 -0
  83. package/src/components/input/math-wrapper.js +959 -0
  84. package/src/components/input/scroll-into-view.js +72 -0
  85. package/src/components/keypad/button-assets.tsx +493 -0
  86. package/src/components/keypad/button.stories.js +29 -0
  87. package/src/components/keypad/button.tsx +106 -0
  88. package/src/components/keypad/index.tsx +65 -0
  89. package/src/components/keypad/keypad-page-items.tsx +91 -0
  90. package/src/components/keypad/keypad-pages.stories.tsx +30 -0
  91. package/src/components/keypad/keypad.stories.tsx +33 -0
  92. package/src/components/keypad/numeric-input-page.tsx +99 -0
  93. package/src/components/keypad/pre-algebra-page.tsx +97 -0
  94. package/src/components/keypad/trigonometry-page.tsx +89 -0
  95. package/src/components/keypad-button.js +362 -0
  96. package/src/components/keypad-container.js +299 -0
  97. package/src/components/keypad.js +154 -0
  98. package/src/components/many-keypad-button.js +44 -0
  99. package/src/components/math-icon.js +65 -0
  100. package/src/components/multi-symbol-grid.js +182 -0
  101. package/src/components/multi-symbol-popover.js +59 -0
  102. package/src/components/navigation-pad.js +139 -0
  103. package/src/components/node-manager.js +129 -0
  104. package/src/components/popover-manager.js +76 -0
  105. package/src/components/popover-state-machine.js +173 -0
  106. package/src/components/prop-types.js +82 -0
  107. package/src/components/provided-keypad.tsx +105 -0
  108. package/src/components/styles.js +38 -0
  109. package/src/components/svg-icon.js +25 -0
  110. package/src/components/tabbar/__tests__/tabbar_test.js +65 -0
  111. package/src/components/tabbar/icons.tsx +64 -0
  112. package/src/components/tabbar/item.tsx +136 -0
  113. package/src/components/tabbar/tabbar.stories.js +60 -0
  114. package/src/components/tabbar/tabbar.tsx +59 -0
  115. package/src/components/tabbar/types.ts +1 -0
  116. package/src/components/text-icon.js +52 -0
  117. package/src/components/touchable-keypad-button.js +146 -0
  118. package/src/components/two-page-keypad.js +99 -0
  119. package/src/components/velocity-tracker.js +76 -0
  120. package/src/components/z-indexes.ts +8 -0
  121. package/src/consts.ts +91 -0
  122. package/src/data/key-configs.ts +349 -0
  123. package/src/data/keys.ts +124 -0
  124. package/src/demo.js +9 -0
  125. package/src/fake-react-native-web/index.ts +11 -0
  126. package/src/fake-react-native-web/text.tsx +54 -0
  127. package/src/fake-react-native-web/view.tsx +89 -0
  128. package/src/index.ts +22 -0
  129. package/src/native-app.js +85 -0
  130. package/src/store/index.ts +534 -0
  131. package/src/utils.ts +14 -0
  132. package/tools/svg-to-react/convert.py +111 -0
  133. package/tools/svg-to-react/icons/math-keypad-icon-0.svg +32 -0
  134. package/tools/svg-to-react/icons/math-keypad-icon-1.svg +32 -0
  135. package/tools/svg-to-react/icons/math-keypad-icon-2.svg +32 -0
  136. package/tools/svg-to-react/icons/math-keypad-icon-3.svg +32 -0
  137. package/tools/svg-to-react/icons/math-keypad-icon-4.svg +32 -0
  138. package/tools/svg-to-react/icons/math-keypad-icon-5.svg +32 -0
  139. package/tools/svg-to-react/icons/math-keypad-icon-6.svg +32 -0
  140. package/tools/svg-to-react/icons/math-keypad-icon-7.svg +32 -0
  141. package/tools/svg-to-react/icons/math-keypad-icon-8.svg +32 -0
  142. package/tools/svg-to-react/icons/math-keypad-icon-9.svg +32 -0
  143. package/tools/svg-to-react/icons/math-keypad-icon-addition.svg +34 -0
  144. package/tools/svg-to-react/icons/math-keypad-icon-cos.svg +38 -0
  145. package/tools/svg-to-react/icons/math-keypad-icon-delete.svg +36 -0
  146. package/tools/svg-to-react/icons/math-keypad-icon-dismiss.svg +36 -0
  147. package/tools/svg-to-react/icons/math-keypad-icon-division.svg +36 -0
  148. package/tools/svg-to-react/icons/math-keypad-icon-equals-not.svg +50 -0
  149. package/tools/svg-to-react/icons/math-keypad-icon-equals.svg +48 -0
  150. package/tools/svg-to-react/icons/math-keypad-icon-exponent-2.svg +38 -0
  151. package/tools/svg-to-react/icons/math-keypad-icon-exponent-3.svg +38 -0
  152. package/tools/svg-to-react/icons/math-keypad-icon-exponent.svg +38 -0
  153. package/tools/svg-to-react/icons/math-keypad-icon-fraction.svg +42 -0
  154. package/tools/svg-to-react/icons/math-keypad-icon-greater-than.svg +46 -0
  155. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-base.svg +44 -0
  156. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-denominator.svg +48 -0
  157. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-exponent.svg +44 -0
  158. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-parentheses.svg +44 -0
  159. package/tools/svg-to-react/icons/math-keypad-icon-less-than.svg +46 -0
  160. package/tools/svg-to-react/icons/math-keypad-icon-log-10.svg +36 -0
  161. package/tools/svg-to-react/icons/math-keypad-icon-log-e.svg +36 -0
  162. package/tools/svg-to-react/icons/math-keypad-icon-log.svg +38 -0
  163. package/tools/svg-to-react/icons/math-keypad-icon-multiplication-cross.svg +40 -0
  164. package/tools/svg-to-react/icons/math-keypad-icon-multiplication-dot.svg +38 -0
  165. package/tools/svg-to-react/icons/math-keypad-icon-percent.svg +42 -0
  166. package/tools/svg-to-react/icons/math-keypad-icon-radical-2.svg +36 -0
  167. package/tools/svg-to-react/icons/math-keypad-icon-radical-3.svg +38 -0
  168. package/tools/svg-to-react/icons/math-keypad-icon-radical.svg +38 -0
  169. package/tools/svg-to-react/icons/math-keypad-icon-radix-character.svg +32 -0
  170. package/tools/svg-to-react/icons/math-keypad-icon-sin.svg +38 -0
  171. package/tools/svg-to-react/icons/math-keypad-icon-subtraction.svg +32 -0
  172. package/tools/svg-to-react/icons/math-keypad-icon-tan.svg +38 -0
  173. package/tools/svg-to-react/symbol_map.py +41 -0
  174. package/tsconfig.json +9 -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,104 @@
1
+ # @khanacademy/math-input
2
+
3
+ ## 0.0.0-PR443-20230328215601
4
+
5
+ ### Minor Changes
6
+
7
+ - 4ef5607d: Migrate source code to TypeScript
8
+
9
+ ## 0.6.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 2c843b38: Update to use wonder-blocks deps after migrating wonder-blocks to TS
14
+
15
+ ## 0.6.7
16
+
17
+ ### Patch Changes
18
+
19
+ - a1b4ab3c: Update wonder-blocks and wonder-stuff deps to fix an issue with wonder-stuff's generated flow types
20
+
21
+ ## 0.6.6
22
+
23
+ ### Patch Changes
24
+
25
+ - 6a7f36be: Update wonder-stuff and wonder-blocks dependencies
26
+
27
+ ## 0.6.5
28
+
29
+ ### Patch Changes
30
+
31
+ - c238d540: Wrap all ReactDOM.render() calls in `<RenderStateRoot>` to ensure it propagates properly
32
+
33
+ ## 0.6.4
34
+
35
+ ### Patch Changes
36
+
37
+ - 113953e8: Exports new types to support custom keypads: `CursorContext`, `KeypadType`, `KeyType`, and `Key`
38
+
39
+ ## 0.6.3
40
+
41
+ ### Patch Changes
42
+
43
+ - f567f660: Update the eslint config to look at both the package.json for the package and the one from the root
44
+
45
+ ## 0.6.2
46
+
47
+ ### Patch Changes
48
+
49
+ - bf180fe1: Fix our use of import/no-extraneous-dependencies
50
+
51
+ ## 0.6.1
52
+
53
+ ### Patch Changes
54
+
55
+ - 1a91b6c2: Adds missing wonder-blocks deps, makes wonder-blocks peerDeps
56
+
57
+ ## 0.6.0
58
+
59
+ ### Minor Changes
60
+
61
+ - 8fcd2a28: Inline the import of mathquill.css in math-input's main.less
62
+
63
+ ## 0.5.6
64
+
65
+ ### Patch Changes
66
+
67
+ - 98d283ff: Fix storybook
68
+
69
+ ## 0.5.5
70
+
71
+ ### Patch Changes
72
+
73
+ - 6f8f1ac9: Use wonder-blocks-i18n to determine the decimal separator
74
+
75
+ ## 0.5.4
76
+
77
+ ### Patch Changes
78
+
79
+ - f29b4975: Export the KeyConfigs type
80
+
81
+ ## 0.5.3
82
+
83
+ ### Patch Changes
84
+
85
+ - 96288b87: Export CursorContexts
86
+
87
+ ## 0.5.2
88
+
89
+ ### Patch Changes
90
+
91
+ - a15b0e86: Add 'perseus-build-settings' as a dev dep to packages that were missing it
92
+
93
+ ## 0.5.1
94
+
95
+ ### Patch Changes
96
+
97
+ - 591420a6: Add @flow comment to math-input's index.js and missing props to ProvidedKeypad
98
+
99
+ ## 0.5.0
100
+
101
+ ### Minor Changes
102
+
103
+ - ea57be17: Move math-input into khan/perseus repo (name changes to @khanacademy/math-input)
104
+ - 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)