@khanacademy/math-input 0.4.1 → 0.5.2

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 (176) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/{build/math-input.css → dist/es/index.css} +0 -150
  4. package/dist/es/index.js +7798 -0
  5. package/dist/es/index.js.map +1 -0
  6. package/dist/index.css +586 -0
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +7768 -0
  9. package/dist/index.js.flow +2 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/strings.js +71 -0
  12. package/index.html +20 -0
  13. package/less/echo.less +56 -0
  14. package/less/main.less +5 -0
  15. package/less/overrides.less +129 -0
  16. package/less/popover.less +22 -0
  17. package/less/tabbar.less +6 -0
  18. package/package.json +60 -89
  19. package/src/actions/index.js +57 -0
  20. package/src/components/__tests__/gesture-state-machine_test.js +437 -0
  21. package/src/components/__tests__/node-manager_test.js +89 -0
  22. package/src/components/__tests__/two-page-keypad_test.js +42 -0
  23. package/src/components/app.js +73 -0
  24. package/src/components/common-style.js +47 -0
  25. package/src/components/compute-layout-parameters.js +157 -0
  26. package/src/components/corner-decal.js +56 -0
  27. package/src/components/echo-manager.js +160 -0
  28. package/src/components/empty-keypad-button.js +49 -0
  29. package/src/components/expression-keypad.js +323 -0
  30. package/src/components/fraction-keypad.js +176 -0
  31. package/src/components/gesture-manager.js +226 -0
  32. package/src/components/gesture-state-machine.js +283 -0
  33. package/src/components/icon.js +74 -0
  34. package/src/components/iconography/arrow.js +22 -0
  35. package/src/components/iconography/backspace.js +29 -0
  36. package/src/components/iconography/cdot.js +29 -0
  37. package/src/components/iconography/cos.js +30 -0
  38. package/src/components/iconography/cube-root.js +36 -0
  39. package/src/components/iconography/dismiss.js +25 -0
  40. package/src/components/iconography/divide.js +34 -0
  41. package/src/components/iconography/down.js +16 -0
  42. package/src/components/iconography/equal.js +33 -0
  43. package/src/components/iconography/exp-2.js +29 -0
  44. package/src/components/iconography/exp-3.js +29 -0
  45. package/src/components/iconography/exp.js +29 -0
  46. package/src/components/iconography/frac.js +44 -0
  47. package/src/components/iconography/geq.js +33 -0
  48. package/src/components/iconography/gt.js +33 -0
  49. package/src/components/iconography/index.js +45 -0
  50. package/src/components/iconography/jump-into-numerator.js +41 -0
  51. package/src/components/iconography/jump-out-base.js +30 -0
  52. package/src/components/iconography/jump-out-denominator.js +41 -0
  53. package/src/components/iconography/jump-out-exponent.js +30 -0
  54. package/src/components/iconography/jump-out-numerator.js +41 -0
  55. package/src/components/iconography/jump-out-parentheses.js +33 -0
  56. package/src/components/iconography/left-paren.js +33 -0
  57. package/src/components/iconography/left.js +16 -0
  58. package/src/components/iconography/leq.js +33 -0
  59. package/src/components/iconography/ln.js +29 -0
  60. package/src/components/iconography/log-n.js +29 -0
  61. package/src/components/iconography/log.js +29 -0
  62. package/src/components/iconography/lt.js +33 -0
  63. package/src/components/iconography/minus.js +32 -0
  64. package/src/components/iconography/neq.js +33 -0
  65. package/src/components/iconography/parens.js +33 -0
  66. package/src/components/iconography/percent.js +49 -0
  67. package/src/components/iconography/period.js +26 -0
  68. package/src/components/iconography/plus.js +32 -0
  69. package/src/components/iconography/radical.js +36 -0
  70. package/src/components/iconography/right-paren.js +33 -0
  71. package/src/components/iconography/right.js +16 -0
  72. package/src/components/iconography/sin.js +30 -0
  73. package/src/components/iconography/sqrt.js +32 -0
  74. package/src/components/iconography/tan.js +30 -0
  75. package/src/components/iconography/times.js +33 -0
  76. package/src/components/iconography/up.js +16 -0
  77. package/src/components/input/__tests__/context-tracking_test.js +177 -0
  78. package/src/components/input/__tests__/math-wrapper.jsx +33 -0
  79. package/src/components/input/__tests__/mathquill_test.js +747 -0
  80. package/src/components/input/cursor-contexts.js +29 -0
  81. package/src/components/input/cursor-handle.js +137 -0
  82. package/src/components/input/drag-listener.js +75 -0
  83. package/src/components/input/math-input.js +924 -0
  84. package/src/components/input/math-wrapper.js +959 -0
  85. package/src/components/input/scroll-into-view.js +72 -0
  86. package/src/components/keypad/button-assets.js +492 -0
  87. package/src/components/keypad/button.js +106 -0
  88. package/src/components/keypad/button.stories.js +29 -0
  89. package/src/components/keypad/index.js +64 -0
  90. package/src/components/keypad/keypad-page-items.js +106 -0
  91. package/src/components/keypad/keypad-pages.stories.js +32 -0
  92. package/src/components/keypad/keypad.stories.js +35 -0
  93. package/src/components/keypad/numeric-input-page.js +100 -0
  94. package/src/components/keypad/pre-algebra-page.js +98 -0
  95. package/src/components/keypad/trigonometry-page.js +90 -0
  96. package/src/components/keypad-button.js +366 -0
  97. package/src/components/keypad-container.js +303 -0
  98. package/src/components/keypad.js +154 -0
  99. package/src/components/many-keypad-button.js +44 -0
  100. package/src/components/math-icon.js +65 -0
  101. package/src/components/multi-symbol-grid.js +182 -0
  102. package/src/components/multi-symbol-popover.js +59 -0
  103. package/src/components/navigation-pad.js +139 -0
  104. package/src/components/node-manager.js +129 -0
  105. package/src/components/popover-manager.js +76 -0
  106. package/src/components/popover-state-machine.js +173 -0
  107. package/src/components/prop-types.js +82 -0
  108. package/src/components/provided-keypad.js +103 -0
  109. package/src/components/styles.js +38 -0
  110. package/src/components/svg-icon.js +25 -0
  111. package/src/components/tabbar/__tests__/tabbar_test.js +65 -0
  112. package/src/components/tabbar/icons.js +69 -0
  113. package/src/components/tabbar/item.js +138 -0
  114. package/src/components/tabbar/tabbar.js +61 -0
  115. package/src/components/tabbar/tabbar.stories.js +60 -0
  116. package/src/components/tabbar/types.js +3 -0
  117. package/src/components/text-icon.js +52 -0
  118. package/src/components/touchable-keypad-button.js +146 -0
  119. package/src/components/two-page-keypad.js +99 -0
  120. package/src/components/velocity-tracker.js +76 -0
  121. package/src/components/z-indexes.js +9 -0
  122. package/src/consts.js +74 -0
  123. package/src/data/key-configs.js +349 -0
  124. package/src/data/keys.js +72 -0
  125. package/src/demo.js +8 -0
  126. package/src/fake-react-native-web/index.js +12 -0
  127. package/src/fake-react-native-web/text.js +56 -0
  128. package/src/fake-react-native-web/view.js +91 -0
  129. package/src/index.js +14 -0
  130. package/src/native-app.js +84 -0
  131. package/src/store/index.js +505 -0
  132. package/src/utils.js +18 -0
  133. package/tools/svg-to-react/convert.py +111 -0
  134. package/tools/svg-to-react/icons/math-keypad-icon-0.svg +32 -0
  135. package/tools/svg-to-react/icons/math-keypad-icon-1.svg +32 -0
  136. package/tools/svg-to-react/icons/math-keypad-icon-2.svg +32 -0
  137. package/tools/svg-to-react/icons/math-keypad-icon-3.svg +32 -0
  138. package/tools/svg-to-react/icons/math-keypad-icon-4.svg +32 -0
  139. package/tools/svg-to-react/icons/math-keypad-icon-5.svg +32 -0
  140. package/tools/svg-to-react/icons/math-keypad-icon-6.svg +32 -0
  141. package/tools/svg-to-react/icons/math-keypad-icon-7.svg +32 -0
  142. package/tools/svg-to-react/icons/math-keypad-icon-8.svg +32 -0
  143. package/tools/svg-to-react/icons/math-keypad-icon-9.svg +32 -0
  144. package/tools/svg-to-react/icons/math-keypad-icon-addition.svg +34 -0
  145. package/tools/svg-to-react/icons/math-keypad-icon-cos.svg +38 -0
  146. package/tools/svg-to-react/icons/math-keypad-icon-delete.svg +36 -0
  147. package/tools/svg-to-react/icons/math-keypad-icon-dismiss.svg +36 -0
  148. package/tools/svg-to-react/icons/math-keypad-icon-division.svg +36 -0
  149. package/tools/svg-to-react/icons/math-keypad-icon-equals-not.svg +50 -0
  150. package/tools/svg-to-react/icons/math-keypad-icon-equals.svg +48 -0
  151. package/tools/svg-to-react/icons/math-keypad-icon-exponent-2.svg +38 -0
  152. package/tools/svg-to-react/icons/math-keypad-icon-exponent-3.svg +38 -0
  153. package/tools/svg-to-react/icons/math-keypad-icon-exponent.svg +38 -0
  154. package/tools/svg-to-react/icons/math-keypad-icon-fraction.svg +42 -0
  155. package/tools/svg-to-react/icons/math-keypad-icon-greater-than.svg +46 -0
  156. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-base.svg +44 -0
  157. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-denominator.svg +48 -0
  158. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-exponent.svg +44 -0
  159. package/tools/svg-to-react/icons/math-keypad-icon-jump-out-parentheses.svg +44 -0
  160. package/tools/svg-to-react/icons/math-keypad-icon-less-than.svg +46 -0
  161. package/tools/svg-to-react/icons/math-keypad-icon-log-10.svg +36 -0
  162. package/tools/svg-to-react/icons/math-keypad-icon-log-e.svg +36 -0
  163. package/tools/svg-to-react/icons/math-keypad-icon-log.svg +38 -0
  164. package/tools/svg-to-react/icons/math-keypad-icon-multiplication-cross.svg +40 -0
  165. package/tools/svg-to-react/icons/math-keypad-icon-multiplication-dot.svg +38 -0
  166. package/tools/svg-to-react/icons/math-keypad-icon-percent.svg +42 -0
  167. package/tools/svg-to-react/icons/math-keypad-icon-radical-2.svg +36 -0
  168. package/tools/svg-to-react/icons/math-keypad-icon-radical-3.svg +38 -0
  169. package/tools/svg-to-react/icons/math-keypad-icon-radical.svg +38 -0
  170. package/tools/svg-to-react/icons/math-keypad-icon-radix-character.svg +32 -0
  171. package/tools/svg-to-react/icons/math-keypad-icon-sin.svg +38 -0
  172. package/tools/svg-to-react/icons/math-keypad-icon-subtraction.svg +32 -0
  173. package/tools/svg-to-react/icons/math-keypad-icon-tan.svg +38 -0
  174. package/tools/svg-to-react/symbol_map.py +41 -0
  175. package/LICENSE.txt +0 -21
  176. package/build/math-input.js +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # @khanacademy/math-input
2
+
3
+ ## 0.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a15b0e86: Add 'perseus-build-settings' as a dev dep to packages that were missing it
8
+
9
+ ## 0.5.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 591420a6: Add @flow comment to math-input's index.js and missing props to ProvidedKeypad
14
+
15
+ ## 0.5.0
16
+
17
+ ### Minor Changes
18
+
19
+ - ea57be17: Move math-input into khan/perseus repo (name changes to @khanacademy/math-input)
20
+ - 116df39b: Extract math-input strings from source and save them to packages/math-input/dist
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # math-input
2
2
 
3
- Khan Academy's new 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.
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
4
 
5
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
6
 
@@ -9,38 +9,6 @@
9
9
  * If the animation durations change, the corresponding values in
10
10
  * echo-manager.js must change as well.
11
11
  */
12
- .echo-slide-and-fade-enter {
13
- opacity: 1 !important;
14
- transform: translate3d(0, 0, 0) !important;
15
- }
16
- .echo-slide-and-fade-enter.echo-slide-and-fade-enter-active {
17
- opacity: 0 !important;
18
- transform: translate3d(0, -33%, 0) !important;
19
- /**
20
- * TODO(charlie): These times are intentionally different, which means
21
- * that the animation really "ends" after 400ms
22
- * cubic-bezier(1, 0, 0.9, 1) (since the opacity goes to 0), even though
23
- * the transform doesn't complete. There's probably a way to achieve the
24
- * same effect by manipulating the transform's Bezier curve and total
25
- * displacement.
26
- */
27
- transition: transform 800ms cubic-bezier(0, 1, 0.25, 1), opacity 400ms cubic-bezier(1, 0, 0.9, 1) !important;
28
- }
29
- .echo-fade-only-enter {
30
- opacity: 1 !important;
31
- }
32
- .echo-fade-only-enter.echo-fade-only-enter-active {
33
- opacity: 0 !important;
34
- transition: opacity 300ms cubic-bezier(0.25, 0, 0.75, 1) !important;
35
- }
36
- .echo-long-fade-only-enter {
37
- opacity: 1 !important;
38
- }
39
- .echo-long-fade-only-enter.echo-long-fade-only-enter-active {
40
- opacity: 0 !important;
41
- transition: opacity 400ms cubic-bezier(0.75, 0, 0.75, 1) !important;
42
- }
43
-
44
12
  /*
45
13
  * MathQuill v0.10.1 http://mathquill.com
46
14
  * by Han, Jeanine, and Mary maintainers@mathquill.com
@@ -476,18 +444,6 @@
476
444
  filter: progid:DXImageTransform.Microsoft.Chroma(color='white');
477
445
  margin-top: -0.1em;
478
446
  }
479
-
480
- /**
481
- * Styles for managing the popover animations.
482
- *
483
- * Ideally, we'd be generating these styles with Aphrodite (along with
484
- * CSSTransitionGroup's support for custom classnames), but the generated
485
- * styles have issues on mobile Safari.
486
- * See: https://github.com/Khan/aphrodite/issues/68.
487
- *
488
- * If the animation durations change, the corresponding values in
489
- * echo-manager.js must change as well.
490
- */
491
447
  .echo-slide-and-fade-enter {
492
448
  opacity: 1 !important;
493
449
  transform: translate3d(0, 0, 0) !important;
@@ -628,109 +584,3 @@
628
584
  .tabbar_item:focus {
629
585
  background-color: green;
630
586
  }
631
-
632
- .keypad-input {
633
- outline: none !important;
634
- }
635
- .keypad-input .mq-editable-field .mq-root-block {
636
- overflow-x: scroll;
637
- }
638
- .keypad-input .mq-editable-field .mq-cursor:not(:only-child),
639
- .keypad-input .mq-editable-field .mq-root-block.mq-hasCursor > .mq-cursor:only-child {
640
- /* HACK(charlie): Magic numbers to properly size and position the vertical
641
- cursor, which is visible whenever the cursor is not alone in its parent,
642
- with the exception that it's also visible when the entire input is
643
- empty. */
644
- height: 20px !important;
645
- width: 2px;
646
- margin-top: -5px !important;
647
- vertical-align: middle !important;
648
- border-radius: 1px !important;
649
- }
650
- .keypad-input .mq-editable-field .mq-cursor {
651
- border-left: 2px solid #1865f2 !important;
652
- margin-left: -1px !important;
653
- margin-right: -1px !important;
654
- opacity: 1 !important;
655
- transition: opacity 500ms ease-out !important;
656
- visibility: visible !important;
657
- }
658
- .keypad-input .mq-editable-field .mq-cursor.mq-blink {
659
- opacity: 0 !important;
660
- transition: opacity 500ms ease-in !important;
661
- visibility: visible !important;
662
- }
663
- .keypad-input .mq-editable-field .mq-non-leaf .mq-cursor:only-child {
664
- border: 2px solid !important;
665
- border-color: #1865f2 !important;
666
- border-radius: 1px;
667
- opacity: 1 !important;
668
- padding: 0 4px 0 4px;
669
- transition: border-color 500ms ease-out !important;
670
- }
671
- .keypad-input .mq-editable-field .mq-non-leaf .mq-cursor:only-child.mq-blink {
672
- border-color: #1865f2 !important;
673
- opacity: 1 !important;
674
- transition: border-color 500ms ease-in !important;
675
- }
676
- .keypad-input .mq-empty {
677
- background: transparent !important;
678
- }
679
- .keypad-input .mq-empty:not(.mq-root-block):after,
680
- .keypad-input .mq-hasCursor:empty:not(.mq-root-block):after {
681
- border: 2px solid rgba(33, 36, 44, 0.16);
682
- border-radius: 1px;
683
- color: transparent;
684
- display: inline-block;
685
- margin-left: -1px;
686
- margin-right: -1px;
687
- padding: 0 4px 0 4px;
688
- visibility: visible !important;
689
- }
690
- .keypad-input .mq-selection .mq-empty:not(.mq-root-block):after {
691
- border-color: white;
692
- }
693
- .keypad-input .mq-hasCursor:empty:not(.mq-root-block):after {
694
- content: 'c';
695
- }
696
- .keypad-input .mq-math-mode .mq-selection .mq-non-leaf,
697
- .keypad-input .mq-editable-field .mq-selection .mq-non-leaf {
698
- background: #1865f2 !important;
699
- border-color: white !important;
700
- color: white !important;
701
- }
702
- .keypad-input .mq-math-mode .mq-selection .mq-scaled,
703
- .keypad-input .mq-editable-field .mq-selection .mq-scaled {
704
- background: transparent !important;
705
- border-color: transparent !important;
706
- color: white !important;
707
- }
708
- .keypad-input .mq-selection {
709
- background: #1865f2 !important;
710
- border-color: white !important;
711
- color: white !important;
712
- display: inline-block !important;
713
- }
714
- .keypad-container .katex {
715
- color: inherit !important;
716
- }
717
-
718
- /**
719
- * Styles for managing the popover animations.
720
- *
721
- * Ideally, we'd be generating these styles with Aphrodite (along with
722
- * CSSTransitionGroup's support for custom classnames), but the generated
723
- * styles have issues on mobile Safari.
724
- * See: https://github.com/Khan/aphrodite/issues/68.
725
- *
726
- * If the animation durations change, the corresponding values in
727
- * popover-manager.js must change as well.
728
- */
729
- .popover-enter {
730
- opacity: 0 !important;
731
- }
732
- .popover-enter.popover-enter-active {
733
- opacity: 1 !important;
734
- transition: opacity 200ms ease-out !important;
735
- }
736
-