@khanacademy/math-input 0.7.2 → 1.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 (176) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/actions/index.d.ts +31 -0
  3. package/dist/actions/index.js.flow +40 -0
  4. package/dist/components/compute-layout-parameters.d.ts +38 -0
  5. package/dist/components/compute-layout-parameters.js.flow +49 -0
  6. package/dist/components/corner-decal.d.ts +12 -0
  7. package/dist/components/corner-decal.js.flow +15 -0
  8. package/dist/components/echo-manager.d.ts +26 -0
  9. package/dist/components/echo-manager.js.flow +29 -0
  10. package/dist/components/empty-keypad-button.d.ts +13 -0
  11. package/dist/components/empty-keypad-button.js.flow +23 -0
  12. package/dist/components/expression-keypad.d.ts +22 -0
  13. package/dist/components/expression-keypad.js.flow +32 -0
  14. package/dist/components/fraction-keypad.d.ts +21 -0
  15. package/dist/components/fraction-keypad.js.flow +30 -0
  16. package/dist/components/gesture-manager.d.ts +74 -0
  17. package/dist/components/gesture-manager.js.flow +82 -0
  18. package/dist/components/gesture-state-machine.d.ts +105 -0
  19. package/dist/components/gesture-state-machine.js.flow +118 -0
  20. package/dist/components/icon.d.ts +15 -0
  21. package/dist/components/icon.js.flow +18 -0
  22. package/dist/components/input/__tests__/test-math-wrapper.d.ts +8 -0
  23. package/dist/components/input/__tests__/test-math-wrapper.js.flow +14 -0
  24. package/dist/components/input/cursor-handle.d.ts +1 -1
  25. package/dist/components/input/cursor-handle.js.flow +1 -1
  26. package/dist/components/input/drag-listener.d.ts +13 -0
  27. package/dist/components/input/drag-listener.js.flow +19 -0
  28. package/dist/components/input/math-input.d.ts +5 -4
  29. package/dist/components/input/math-input.js.flow +5 -4
  30. package/dist/components/input/math-wrapper.d.ts +110 -0
  31. package/dist/components/input/math-wrapper.js.flow +125 -0
  32. package/dist/components/input/scroll-into-view.d.ts +11 -0
  33. package/dist/components/input/scroll-into-view.js.flow +20 -0
  34. package/dist/components/keypad/button-assets.d.ts +4 -3
  35. package/dist/components/keypad/button-assets.js.flow +3 -3
  36. package/dist/components/keypad/button.d.ts +1 -2
  37. package/dist/components/keypad/button.js.flow +1 -2
  38. package/dist/components/keypad/keypad-page-items.d.ts +15 -10
  39. package/dist/components/keypad/keypad-page-items.js.flow +20 -10
  40. package/dist/components/keypad-button.d.ts +52 -0
  41. package/dist/components/keypad-button.js.flow +79 -0
  42. package/dist/components/keypad-container.d.ts +40 -0
  43. package/dist/components/keypad-container.js.flow +58 -0
  44. package/dist/components/keypad.d.ts +31 -0
  45. package/dist/components/keypad.js.flow +40 -0
  46. package/dist/components/many-keypad-button.d.ts +15 -0
  47. package/dist/components/many-keypad-button.js.flow +17 -0
  48. package/dist/components/math-icon.d.ts +16 -0
  49. package/dist/components/math-icon.js.flow +19 -0
  50. package/dist/components/multi-symbol-grid.d.ts +14 -0
  51. package/dist/components/multi-symbol-grid.js.flow +16 -0
  52. package/dist/components/multi-symbol-popover.d.ts +12 -0
  53. package/dist/components/multi-symbol-popover.js.flow +15 -0
  54. package/dist/components/navigation-pad.d.ts +14 -0
  55. package/dist/components/navigation-pad.js.flow +16 -0
  56. package/dist/components/node-manager.d.ts +53 -0
  57. package/dist/components/node-manager.js.flow +65 -0
  58. package/dist/components/popover-manager.d.ts +13 -0
  59. package/dist/components/popover-manager.js.flow +15 -0
  60. package/dist/components/popover-state-machine.d.ts +75 -0
  61. package/dist/components/popover-state-machine.js.flow +83 -0
  62. package/dist/components/provided-keypad.d.ts +8 -7
  63. package/dist/components/provided-keypad.js.flow +8 -7
  64. package/dist/components/styles.d.ts +6 -0
  65. package/dist/components/styles.js.flow +13 -0
  66. package/dist/components/svg-icon.d.ts +12 -0
  67. package/dist/components/svg-icon.js.flow +15 -0
  68. package/dist/components/tabbar/icons.d.ts +3 -2
  69. package/dist/components/tabbar/icons.js.flow +3 -2
  70. package/dist/components/tabbar/item.d.ts +1 -2
  71. package/dist/components/tabbar/item.js.flow +1 -2
  72. package/dist/components/tabbar/tabbar.d.ts +3 -3
  73. package/dist/components/tabbar/tabbar.js.flow +3 -3
  74. package/dist/components/text-icon.d.ts +13 -0
  75. package/dist/components/text-icon.js.flow +16 -0
  76. package/dist/components/touchable-keypad-button.d.ts +30 -0
  77. package/dist/components/touchable-keypad-button.js.flow +35 -0
  78. package/dist/components/two-page-keypad.d.ts +20 -0
  79. package/dist/components/two-page-keypad.js.flow +30 -0
  80. package/dist/components/velocity-tracker.d.ts +48 -0
  81. package/dist/components/velocity-tracker.js.flow +54 -0
  82. package/dist/es/index.js +938 -1059
  83. package/dist/es/index.js.map +1 -1
  84. package/dist/fake-react-native-web/text.d.ts +2 -1
  85. package/dist/fake-react-native-web/text.js.flow +2 -1
  86. package/dist/fake-react-native-web/view.d.ts +3 -2
  87. package/dist/fake-react-native-web/view.js.flow +3 -2
  88. package/dist/index.d.ts +1 -1
  89. package/dist/index.js +988 -1089
  90. package/dist/index.js.flow +1 -4
  91. package/dist/index.js.map +1 -1
  92. package/dist/store/echo-reducer.d.ts +5 -0
  93. package/dist/store/echo-reducer.js.flow +14 -0
  94. package/dist/store/index.d.ts +46 -1
  95. package/dist/store/index.js.flow +64 -1
  96. package/dist/store/input-reducer.d.ts +7 -0
  97. package/dist/store/input-reducer.js.flow +16 -0
  98. package/dist/store/keypad-reducer.d.ts +9 -0
  99. package/dist/store/keypad-reducer.js.flow +18 -0
  100. package/dist/store/layout-reducer.d.ts +21 -0
  101. package/dist/store/layout-reducer.js.flow +30 -0
  102. package/dist/store/pager-reducer.d.ts +13 -0
  103. package/dist/store/pager-reducer.js.flow +22 -0
  104. package/dist/store/shared.d.ts +6 -0
  105. package/dist/store/shared.js.flow +13 -0
  106. package/dist/store/types.d.ts +57 -0
  107. package/dist/store/types.js.flow +63 -0
  108. package/dist/types.d.ts +50 -0
  109. package/dist/types.js.flow +61 -0
  110. package/package.json +1 -1
  111. package/src/actions/{index.js → index.ts} +5 -5
  112. package/src/components/__tests__/{gesture-state-machine_test.js → gesture-state-machine.test.ts} +5 -1
  113. package/src/components/__tests__/{two-page-keypad_test.js → two-page-keypad.test.tsx} +0 -2
  114. package/src/components/{corner-decal.js → corner-decal.tsx} +6 -5
  115. package/src/components/{echo-manager.js → echo-manager.tsx} +29 -24
  116. package/src/components/{empty-keypad-button.js → empty-keypad-button.tsx} +17 -10
  117. package/src/components/{expression-keypad.js → expression-keypad.tsx} +27 -25
  118. package/src/components/{fraction-keypad.js → fraction-keypad.tsx} +21 -16
  119. package/src/components/{gesture-manager.js → gesture-manager.tsx} +10 -4
  120. package/src/components/{gesture-state-machine.js → gesture-state-machine.ts} +49 -3
  121. package/src/components/{icon.js → icon.tsx} +12 -14
  122. package/src/components/input/cursor-handle.tsx +1 -1
  123. package/src/components/input/{drag-listener.js → drag-listener.ts} +4 -0
  124. package/src/components/input/math-input.tsx +10 -9
  125. package/src/components/input/{math-wrapper.js → math-wrapper.ts} +10 -6
  126. package/src/components/input/{scroll-into-view.js → scroll-into-view.ts} +5 -15
  127. package/src/components/keypad/button-assets.tsx +4 -5
  128. package/src/components/keypad/button.tsx +1 -2
  129. package/src/components/keypad/index.tsx +1 -1
  130. package/src/components/keypad/keypad-page-items.tsx +33 -10
  131. package/src/components/{keypad-button.js → keypad-button.tsx} +42 -37
  132. package/src/components/{keypad-container.js → keypad-container.tsx} +41 -23
  133. package/src/components/{keypad.js → keypad.tsx} +31 -23
  134. package/src/components/{many-keypad-button.js → many-keypad-button.tsx} +8 -6
  135. package/src/components/{math-icon.js → math-icon.tsx} +7 -6
  136. package/src/components/{multi-symbol-grid.js → multi-symbol-grid.tsx} +8 -8
  137. package/src/components/{multi-symbol-popover.js → multi-symbol-popover.tsx} +5 -6
  138. package/src/components/{navigation-pad.js → navigation-pad.tsx} +7 -6
  139. package/src/components/{node-manager.js → node-manager.ts} +16 -4
  140. package/src/components/{popover-manager.js → popover-manager.tsx} +13 -16
  141. package/src/components/{popover-state-machine.js → popover-state-machine.ts} +21 -2
  142. package/src/components/prop-types.js +1 -67
  143. package/src/components/provided-keypad.tsx +14 -12
  144. package/src/components/{svg-icon.js → svg-icon.tsx} +5 -6
  145. package/src/components/tabbar/icons.tsx +4 -2
  146. package/src/components/tabbar/item.tsx +1 -3
  147. package/src/components/tabbar/{tabbar.stories.js → tabbar.stories.tsx} +10 -1
  148. package/src/components/tabbar/tabbar.tsx +3 -3
  149. package/src/components/{text-icon.js → text-icon.tsx} +7 -6
  150. package/src/components/{touchable-keypad-button.js → touchable-keypad-button.tsx} +19 -16
  151. package/src/components/{two-page-keypad.js → two-page-keypad.tsx} +13 -9
  152. package/src/components/{velocity-tracker.js → velocity-tracker.ts} +14 -4
  153. package/src/fake-react-native-web/text.tsx +2 -1
  154. package/src/fake-react-native-web/view.tsx +3 -2
  155. package/src/index.ts +1 -4
  156. package/src/store/echo-reducer.ts +58 -0
  157. package/src/store/index.ts +14 -425
  158. package/src/store/input-reducer.ts +55 -0
  159. package/src/store/keypad-reducer.ts +62 -0
  160. package/src/store/layout-reducer.ts +133 -0
  161. package/src/store/pager-reducer.ts +141 -0
  162. package/src/store/shared.ts +12 -0
  163. package/src/store/types.ts +65 -0
  164. package/src/types.ts +69 -0
  165. package/tsconfig.tsbuildinfo +1 -1
  166. package/src/components/app.js +0 -73
  167. package/src/demo.js +0 -9
  168. package/src/native-app.js +0 -85
  169. /package/src/components/__tests__/{node-manager_test.js → node-manager.test.ts} +0 -0
  170. /package/src/components/{compute-layout-parameters.js → compute-layout-parameters.ts} +0 -0
  171. /package/src/components/input/__tests__/{context-tracking_test.js → context-tracking.test.ts} +0 -0
  172. /package/src/components/input/__tests__/{mathquill_test.js → mathquill.test.ts} +0 -0
  173. /package/src/components/input/__tests__/{test-math-wrapper.jsx → test-math-wrapper.ts} +0 -0
  174. /package/src/components/keypad/{button.stories.js → button.stories.tsx} +0 -0
  175. /package/src/components/{styles.js → styles.ts} +0 -0
  176. /package/src/components/tabbar/__tests__/{tabbar_test.js → tabbar.test.tsx} +0 -0
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import type { Key } from "../data/keys";
8
+
9
+ /**
10
+ * The state machine that backs our gesture system. In particular, this state
11
+ * machine manages the interplay between focuses, touch ups, and swiping.
12
+ * It is entirely ignorant of the existence of popovers and the positions of
13
+ * DOM nodes, operating solely on IDs. The state machine does accommodate for
14
+ * multi-touch interactions, tracking gesture state on a per-touch basis.
15
+ */
16
+ export type Handlers = {|
17
+ onFocus: (id: string) => void,
18
+ onBlur: () => void,
19
+ onTrigger: (id: string) => void,
20
+ onLongPress: (id: string) => void,
21
+ onSwipeChange: (x: number) => void,
22
+ onSwipeEnd: (x: number) => void,
23
+ onTouchEnd: (id: string) => void,
24
+ |};
25
+ declare type Options = {|
26
+ longPressWaitTimeMs: number,
27
+ swipeThresholdPx: number,
28
+ holdIntervalMs: number,
29
+ |};
30
+ declare type TouchState = {|
31
+ activeNodeId: Key,
32
+ pressAndHoldIntervalId: number | null,
33
+ longPressTimeoutId: number | null,
34
+ swipeLocked: boolean,
35
+ startX: number,
36
+ |};
37
+ declare type TouchStateMap = { [key: Key]: TouchState };
38
+ declare type SwipeState = {|
39
+ touchId: Key,
40
+ startX: number,
41
+ |};
42
+ declare class GestureStateMachine {
43
+ handlers: Handlers;
44
+ options: Options;
45
+ swipeDisabledNodeIds: $Rest<[Key], {}>;
46
+ multiPressableKeys: $Rest<[Key], {}>;
47
+ touchState: $Rest<TouchStateMap, {}>;
48
+ swipeState: SwipeState | null;
49
+ constructor(
50
+ handlers: Handlers,
51
+ options: $Rest<Options, {}>,
52
+ swipeDisabledNodeIds?: [Key],
53
+ multiPressableKeys?: [Key]
54
+ ): this;
55
+ _maybeCancelLongPressForTouch(touchId: any): void;
56
+ _maybeCancelPressAndHoldForTouch(touchId: any): void;
57
+ _cleanupTouchEvent(touchId: any): void;
58
+
59
+ /**
60
+ * Handle a focus event on the node with the given identifier, which may be
61
+ * `null` to indicate that the user has dragged their finger off of any
62
+ * registered nodes, but is still in the middle of a gesture.
63
+ * @param {string | null} id - the identifier of the newly focused node, or
64
+ * `null` if no node is focused
65
+ * @param {number} touchId - a unique identifier associated with the touch
66
+ */
67
+ _onFocus(id: any, touchId: any): void;
68
+
69
+ /**
70
+ * Clear out all active gesture information.
71
+ */
72
+ _onSwipeStart(): void;
73
+
74
+ /**
75
+ * A function that returns the identifier of the node over which the touch
76
+ * event occurred. This is provided as a piece of lazy computation, as
77
+ * computing the DOM node for a given point is expensive, and the state
78
+ * machine won't always need that information. For example, if the user is
79
+ * swiping, then `onTouchMove` needs to be performant and doesn't care about
80
+ * the node over which the touch occurred.
81
+ * @typedef idComputation
82
+ * @returns {DOMNode} - the identifier of the node over which the touch
83
+ * occurred
84
+ */
85
+ /**
86
+ * Handle a touch-start event on the node with the given identifer.
87
+ * @param {idComputation} getId - a function that returns identifier of the
88
+ * node over which the start event occurred
89
+ * @param {number} touchId - a unique identifier associated with the touch
90
+ */
91
+ onTouchStart(getId: any, touchId: any, pageX: any): void;
92
+
93
+ /**
94
+ * Handle a touch-move event on the node with the given identifer.
95
+ * @param {idComputation} getId - a function that returns identifier of the
96
+ * node over which the move event occurred
97
+ * @param {number} touchId - a unique identifier associated with the touch
98
+ * @param {number} pageX - the x coordinate of the touch
99
+ * @param {boolean} swipeEnabled - whether the system should allow for
100
+ * transitions into a swiping state
101
+ */
102
+ onTouchMove(getId: any, touchId: any, pageX: any, swipeEnabled: any): void;
103
+
104
+ /**
105
+ * Handle a touch-end event on the node with the given identifer.
106
+ * @param {idComputation} getId - a function that returns identifier of the
107
+ * node over which the end event occurred
108
+ * @param {number} touchId - a unique identifier associated with the touch
109
+ * @param {number} pageX - the x coordinate of the touch
110
+ */
111
+ onTouchEnd(getId: any, touchId: any, pageX: any): void;
112
+
113
+ /**
114
+ * Handle a touch-cancel event.
115
+ */
116
+ onTouchCancel(touchId: any): void;
117
+ }
118
+ declare export default typeof GestureStateMachine;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A component that renders an icon for a symbol with the given name.
3
+ */
4
+ import * as React from "react";
5
+ import type { Icon as IconPropType } from "../types";
6
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
7
+ type Props = {
8
+ focused: boolean;
9
+ icon: IconPropType;
10
+ style?: StyleType;
11
+ };
12
+ declare class Icon extends React.PureComponent<Props> {
13
+ render(): JSX.Element;
14
+ }
15
+ export default Icon;
@@ -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 { Icon as IconPropType } from "../types";
9
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
10
+ declare type Props = {|
11
+ focused: boolean,
12
+ icon: IconPropType,
13
+ style?: StyleType,
14
+ |};
15
+ declare class Icon extends React.PureComponent<Props> {
16
+ render(): React$Node;
17
+ }
18
+ declare export default typeof Icon;
@@ -0,0 +1,8 @@
1
+ import MathWrapper from "../math-wrapper";
2
+ export default class TestMathWrapper extends MathWrapper {
3
+ getContent(): any;
4
+ selectAll(): void;
5
+ clearSelection(): void;
6
+ moveToStart(): void;
7
+ isSelected(): boolean;
8
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import MathWrapper from "../math-wrapper";
8
+ declare export default class TestMathWrapper extends MathWrapper {
9
+ getContent(): any;
10
+ selectAll(): void;
11
+ clearSelection(): void;
12
+ moveToStart(): void;
13
+ isSelected(): boolean;
14
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as React from "react";
5
5
  type Props = {
6
- animateIntoPosition: boolean | null | undefined;
6
+ animateIntoPosition: boolean;
7
7
  onTouchCancel: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
8
8
  onTouchEnd: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
9
9
  onTouchMove: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  declare type Props = {|
9
- animateIntoPosition: boolean | null | void,
9
+ animateIntoPosition: boolean,
10
10
  onTouchCancel: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
11
11
  onTouchEnd: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
12
12
  onTouchMove: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A gesture recognizer that detects 'drags', crudely defined as either scrolls
3
+ * or touches that move a sufficient distance.
4
+ */
5
+ declare class DragListener {
6
+ _scrollListener: () => void;
7
+ _moveListener: (evt: TouchEvent) => void;
8
+ _endAndCancelListener: (evt: TouchEvent) => void;
9
+ constructor(onDrag: any, initialEvent: any);
10
+ attach(): void;
11
+ detach(): void;
12
+ }
13
+ export default DragListener;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * A gesture recognizer that detects 'drags', crudely defined as either scrolls
9
+ * or touches that move a sufficient distance.
10
+ */
11
+ declare class DragListener {
12
+ _scrollListener: () => void;
13
+ _moveListener: (evt: TouchEvent) => void;
14
+ _endAndCancelListener: (evt: TouchEvent) => void;
15
+ constructor(onDrag: any, initialEvent: any): this;
16
+ attach(): void;
17
+ detach(): void;
18
+ }
19
+ declare export default typeof DragListener;
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
+ import ProvidedKeypad from "../provided-keypad";
2
3
  type Props = {
3
- keypadElement: any;
4
+ keypadElement: ProvidedKeypad;
4
5
  onBlur: () => void;
5
- onChange: any;
6
+ onChange: (value: string, callback: any) => void;
6
7
  onFocus: () => void;
7
8
  style: any;
8
9
  value: string;
@@ -12,7 +13,7 @@ type DefaultProps = {
12
13
  value: Props["value"];
13
14
  };
14
15
  type HandleState = {
15
- animateIntoPosition?: boolean | null | undefined;
16
+ animateIntoPosition?: boolean;
16
17
  visible: boolean;
17
18
  x?: number;
18
19
  y?: number;
@@ -46,7 +47,7 @@ declare class MathInput extends React.Component<Props, State> {
46
47
  _updateInputPadding: () => void;
47
48
  /** Gets and cache they bounds of the keypadElement */
48
49
  _getKeypadBounds: () => any;
49
- _updateCursorHandle: (arg1?: boolean | null | undefined) => void;
50
+ _updateCursorHandle: (arg1?: boolean) => void;
50
51
  _hideCursorHandle: () => void;
51
52
  _handleScroll: () => void;
52
53
  blur: () => void;
@@ -5,10 +5,11 @@
5
5
  * @flow
6
6
  */
7
7
  import * as React from "react";
8
+ import ProvidedKeypad from "../provided-keypad";
8
9
  declare type Props = {|
9
- keypadElement: any,
10
+ keypadElement: ProvidedKeypad,
10
11
  onBlur: () => void,
11
- onChange: any,
12
+ onChange: (value: string, callback: any) => void,
12
13
  onFocus: () => void,
13
14
  style: any,
14
15
  value: string,
@@ -18,7 +19,7 @@ declare type DefaultProps = {|
18
19
  value: $PropertyType<Props, "value">,
19
20
  |};
20
21
  declare type HandleState = {|
21
- animateIntoPosition?: boolean | null | void,
22
+ animateIntoPosition?: boolean,
22
23
  visible: boolean,
23
24
  x?: number,
24
25
  y?: number,
@@ -55,7 +56,7 @@ declare class MathInput extends React.Component<Props, State> {
55
56
  * Gets and cache they bounds of the keypadElement
56
57
  */
57
58
  _getKeypadBounds: () => any;
58
- _updateCursorHandle: (arg1?: boolean | null | void) => void;
59
+ _updateCursorHandle: (arg1?: boolean) => void;
59
60
  _hideCursorHandle: () => void;
60
61
  _handleScroll: () => void;
61
62
  blur: () => void;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * This file contains a wrapper around MathQuill so that we can provide a
3
+ * more regular interface for the functionality we need while insulating us
4
+ * from MathQuill changes.
5
+ */
6
+ declare class MathWrapper {
7
+ MQ: any;
8
+ mathField: any;
9
+ callbacks: any;
10
+ constructor(element: any, options?: {}, callbacks?: {});
11
+ focus(): void;
12
+ blur(): void;
13
+ _writeNormalFunction(name: string): void;
14
+ /**
15
+ * Handle a key press and return the resulting cursor state.
16
+ *
17
+ * @param {Key} key - an enum representing the key that was pressed
18
+ * @returns {object} a cursor object, consisting of a cursor context
19
+ */
20
+ pressKey(key: string): {
21
+ context: string;
22
+ };
23
+ /**
24
+ * Place the cursor beside the node located at the given coordinates.
25
+ *
26
+ * @param {number} x - the x coordinate in the viewport
27
+ * @param {number} y - the y coordinate in the viewport
28
+ * @param {Node} hitNode - the node next to which the cursor should be
29
+ * placed; if provided, the coordinates will be used
30
+ * to determine on which side of the node the cursor
31
+ * should be placed
32
+ */
33
+ setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
34
+ getCursor(): any;
35
+ getSelection(): any;
36
+ getContent(): any;
37
+ setContent(latex: string): void;
38
+ isEmpty(): boolean;
39
+ _handleBackspaceInNthRoot(cursor: any): void;
40
+ /**
41
+ * Advances the cursor to the next logical position.
42
+ *
43
+ * @param {cursor} cursor
44
+ * @private
45
+ */
46
+ _handleJumpOut(cursor: any, key: any): void;
47
+ /**
48
+ * Selects and deletes part of the expression based on the cursor location.
49
+ * See inline comments for precise behavior of different cases.
50
+ *
51
+ * @param {cursor} cursor
52
+ * @private
53
+ */
54
+ _handleBackspace(cursor: any): void;
55
+ _handleLeftArrow(cursor: any): void;
56
+ _handleRightArrow(cursor: any): void;
57
+ _handleExponent(cursor: any, key: any): void;
58
+ /**
59
+ * Return the start node, end node, and full name of the command of which
60
+ * the initial node is a part, or `null` if the node is not part of a
61
+ * command.
62
+ *
63
+ * @param {node} initialNode - the node to included as part of the command
64
+ * @returns {null|object} - `null` or an object containing the start node
65
+ * (`startNode`), end node (`endNode`), and full
66
+ * name (`name`) of the command
67
+ * @private
68
+ */
69
+ _maybeFindCommand(initialNode: any): {
70
+ name: string;
71
+ startNode: any;
72
+ endNode: any;
73
+ } | null;
74
+ /**
75
+ * Return the start node, end node, and full name of the command to the left
76
+ * of `\\left(`, or `null` if there is no command.
77
+ *
78
+ * @param {node} leftParenNode - node where .ctrlSeq == `\\left(`
79
+ * @returns {null|object} - `null` or an object containing the start node
80
+ * (`startNode`), end node (`endNode`), and full
81
+ * name (`name`) of the command
82
+ * @private
83
+ */
84
+ _maybeFindCommandBeforeParens(leftParenNode: any): {
85
+ name: string;
86
+ startNode: any;
87
+ endNode: any;
88
+ } | null;
89
+ _selectNode(node: any, cursor: any): void;
90
+ _isFraction(node: any): any;
91
+ _isNumerator(node: any): any;
92
+ _isDenominator(node: any): any;
93
+ _isSubScript(node: any): any;
94
+ _isSuperScript(node: any): any;
95
+ _isParens(node: any): any;
96
+ _isLeaf(node: any): any;
97
+ _isSquareRoot(node: any): any;
98
+ _isNthRoot(node: any): any;
99
+ _isNthRootIndex(node: any): any;
100
+ _isInsideLogIndex(cursor: any): boolean;
101
+ _isInsideEmptyNode(cursor: any): boolean;
102
+ _handleBackspaceInRootIndex(cursor: any): void;
103
+ _handleBackspaceInLogIndex(cursor: any): void;
104
+ _handleBackspaceOutsideParens(cursor: any): void;
105
+ _handleBackspaceInsideParens(cursor: any): void;
106
+ _handleBackspaceAfterLigaturedSymbol(cursor: any): void;
107
+ contextForCursor(cursor: any): "NONE" | "IN_PARENS" | "IN_SUPER_SCRIPT" | "IN_SUB_SCRIPT" | "IN_NUMERATOR" | "IN_DENOMINATOR" | "BEFORE_FRACTION";
108
+ _isAtTopLevel(cursor: any): boolean;
109
+ }
110
+ export default MathWrapper;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * This file contains a wrapper around MathQuill so that we can provide a
9
+ * more regular interface for the functionality we need while insulating us
10
+ * from MathQuill changes.
11
+ */
12
+ declare class MathWrapper {
13
+ MQ: any;
14
+ mathField: any;
15
+ callbacks: any;
16
+ constructor(element: any, options?: {||}, callbacks?: {||}): this;
17
+ focus(): void;
18
+ blur(): void;
19
+ _writeNormalFunction(name: string): void;
20
+
21
+ /**
22
+ * Handle a key press and return the resulting cursor state.
23
+ * @param {Key} key - an enum representing the key that was pressed
24
+ * @returns {{...}} a cursor object, consisting of a cursor context
25
+ */
26
+ pressKey(key: string): {|
27
+ context: string,
28
+ |};
29
+
30
+ /**
31
+ * Place the cursor beside the node located at the given coordinates.
32
+ * @param {number} x - the x coordinate in the viewport
33
+ * @param {number} y - the y coordinate in the viewport
34
+ * @param {Node} hitNode - the node next to which the cursor should be
35
+ * placed; if provided, the coordinates will be used
36
+ * to determine on which side of the node the cursor
37
+ * should be placed
38
+ */
39
+ setCursorPosition(x: number, y: number, hitNode: HTMLElement): void;
40
+ getCursor(): any;
41
+ getSelection(): any;
42
+ getContent(): any;
43
+ setContent(latex: string): void;
44
+ isEmpty(): boolean;
45
+ _handleBackspaceInNthRoot(cursor: any): void;
46
+
47
+ /**
48
+ * Advances the cursor to the next logical position.
49
+ * @param {cursor} cursor
50
+ * @private
51
+ */
52
+ _handleJumpOut(cursor: any, key: any): void;
53
+
54
+ /**
55
+ * Selects and deletes part of the expression based on the cursor location.
56
+ * See inline comments for precise behavior of different cases.
57
+ * @param {cursor} cursor
58
+ * @private
59
+ */
60
+ _handleBackspace(cursor: any): void;
61
+ _handleLeftArrow(cursor: any): void;
62
+ _handleRightArrow(cursor: any): void;
63
+ _handleExponent(cursor: any, key: any): void;
64
+
65
+ /**
66
+ * Return the start node, end node, and full name of the command of which
67
+ * the initial node is a part, or `null` if the node is not part of a
68
+ * command.
69
+ * @param {node} initialNode - the node to included as part of the command
70
+ * @returns {null | {...}} - `null` or an object containing the start node
71
+ * (`startNode`), end node (`endNode`), and full
72
+ * name (`name`) of the command
73
+ * @private
74
+ */
75
+ _maybeFindCommand(initialNode: any): {|
76
+ name: string,
77
+ startNode: any,
78
+ endNode: any,
79
+ |} | null;
80
+
81
+ /**
82
+ * Return the start node, end node, and full name of the command to the left
83
+ * of `\\left(`, or `null` if there is no command.
84
+ * @param {node} leftParenNode - node where .ctrlSeq == `\\left(`
85
+ * @returns {null | {...}} - `null` or an object containing the start node
86
+ * (`startNode`), end node (`endNode`), and full
87
+ * name (`name`) of the command
88
+ * @private
89
+ */
90
+ _maybeFindCommandBeforeParens(leftParenNode: any): {|
91
+ name: string,
92
+ startNode: any,
93
+ endNode: any,
94
+ |} | null;
95
+ _selectNode(node: any, cursor: any): void;
96
+ _isFraction(node: any): any;
97
+ _isNumerator(node: any): any;
98
+ _isDenominator(node: any): any;
99
+ _isSubScript(node: any): any;
100
+ _isSuperScript(node: any): any;
101
+ _isParens(node: any): any;
102
+ _isLeaf(node: any): any;
103
+ _isSquareRoot(node: any): any;
104
+ _isNthRoot(node: any): any;
105
+ _isNthRootIndex(node: any): any;
106
+ _isInsideLogIndex(cursor: any): boolean;
107
+ _isInsideEmptyNode(cursor: any): boolean;
108
+ _handleBackspaceInRootIndex(cursor: any): void;
109
+ _handleBackspaceInLogIndex(cursor: any): void;
110
+ _handleBackspaceOutsideParens(cursor: any): void;
111
+ _handleBackspaceInsideParens(cursor: any): void;
112
+ _handleBackspaceAfterLigaturedSymbol(cursor: any): void;
113
+ contextForCursor(
114
+ cursor: any
115
+ ):
116
+ | "NONE"
117
+ | "IN_PARENS"
118
+ | "IN_SUPER_SCRIPT"
119
+ | "IN_SUB_SCRIPT"
120
+ | "IN_NUMERATOR"
121
+ | "IN_DENOMINATOR"
122
+ | "BEFORE_FRACTION";
123
+ _isAtTopLevel(cursor: any): boolean;
124
+ }
125
+ declare export default typeof MathWrapper;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A single function used to scroll a DOM node into view, optionally taking into
3
+ * account that it may be obscured by the custom keypad. The logic makes the
4
+ * strong assumption that the keypad will be anchored to the bottom of the page
5
+ * in calculating its height, as this method may be called before the keypad has
6
+ * animated into view.
7
+ *
8
+ * TODO(charlie): Move this scroll logic out of our components and into a higher
9
+ * level in the component tree--perhaps even into webapp, beyond Perseus.
10
+ */
11
+ export declare const scrollIntoView: (containerNode: any, keypadNode: any) => void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * A single function used to scroll a DOM node into view, optionally taking into
9
+ * account that it may be obscured by the custom keypad. The logic makes the
10
+ * strong assumption that the keypad will be anchored to the bottom of the page
11
+ * in calculating its height, as this method may be called before the keypad has
12
+ * animated into view.
13
+ *
14
+ * TODO(charlie): Move this scroll logic out of our components and into a higher
15
+ * level in the component tree--perhaps even into webapp, beyond Perseus.
16
+ */
17
+ declare export var scrollIntoView: (
18
+ containerNode: any,
19
+ keypadNode: any
20
+ ) => void;
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  type KeyId = string;
3
- declare const buttonAsset: React.FC<{
3
+ type Props = {
4
4
  id: KeyId;
5
- }>;
6
- export default buttonAsset;
5
+ };
6
+ export default function ButtonAsset({ id }: Props): React.ReactElement;
7
+ export {};
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import * as React from "react";
8
8
  declare type KeyId = string;
9
- declare var buttonAsset: React.StatelessFunctionalComponent<{|
9
+ declare type Props = {|
10
10
  id: KeyId,
11
- |}>;
12
- declare export default typeof buttonAsset;
11
+ |};
12
+ declare export default function ButtonAsset(x: Props): React.Element<any>;
@@ -6,8 +6,7 @@ type Props = {
6
6
  style?: StyleType;
7
7
  tintColor?: string;
8
8
  };
9
- type State = Record<any, any>;
10
- export default class Button extends React.Component<Props, State> {
9
+ export default class Button extends React.Component<Props> {
11
10
  render(): React.ReactNode;
12
11
  }
13
12
  export {};
@@ -12,7 +12,6 @@ declare type Props = {|
12
12
  style?: StyleType,
13
13
  tintColor?: string,
14
14
  |};
15
- declare type State = { [key: any]: any };
16
- declare export default class Button extends React.Component<Props, State> {
15
+ declare export default class Button extends React.Component<Props> {
17
16
  render(): React.Node;
18
17
  }
@@ -1,23 +1,28 @@
1
1
  import * as React from "react";
2
2
  import type { KeyConfig } from "../../data/key-configs";
3
3
  import type { StyleType } from "@khanacademy/wonder-blocks-core";
4
- export declare const KeypadPageContainer: React.FC<{
4
+ type KeypadPageContainerProps = {
5
5
  children: React.ReactNode;
6
- }>;
7
- export declare const KeypadButton: React.FC<{
6
+ };
7
+ export declare const KeypadPageContainer: ({ children, }: KeypadPageContainerProps) => React.ReactElement;
8
+ type KeypadButtonProps = {
8
9
  keyConfig: KeyConfig;
9
10
  tintColor?: string;
10
11
  style?: StyleType;
11
12
  onClickKey: (keyConfig: string) => void;
12
- }>;
13
- export declare const SecondaryKeypadButton: React.FC<{
13
+ };
14
+ export declare const KeypadButton: ({ keyConfig, onClickKey, tintColor, style, }: KeypadButtonProps) => React.ReactElement;
15
+ type SecondaryKeypadButtonProps = {
14
16
  keyConfig: KeyConfig;
15
- style?: any;
17
+ style?: StyleType;
16
18
  onClickKey: (keyConfig: string) => void;
17
- }>;
18
- export declare const KeypadActionButton: React.FC<{
19
+ };
20
+ export declare const SecondaryKeypadButton: ({ keyConfig, onClickKey, style, }: SecondaryKeypadButtonProps) => React.ReactElement;
21
+ type KeypadActionButtonProps = {
19
22
  keyConfig: KeyConfig;
20
- style?: any;
23
+ style?: StyleType;
21
24
  onClickKey: (keyConfig: string) => void;
22
- }>;
25
+ };
26
+ export declare const KeypadActionButton: ({ keyConfig, onClickKey, style, }: KeypadActionButtonProps) => React.ReactElement;
23
27
  export declare const PlaceHolderButton: () => React.ReactElement;
28
+ export {};