@khanacademy/math-input 0.7.2 → 1.0.1

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 (183) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/components/compute-layout-parameters.d.ts +38 -0
  3. package/dist/components/compute-layout-parameters.js.flow +49 -0
  4. package/dist/components/corner-decal.d.ts +12 -0
  5. package/dist/components/corner-decal.js.flow +15 -0
  6. package/dist/components/echo-manager.d.ts +26 -0
  7. package/dist/components/echo-manager.js.flow +29 -0
  8. package/dist/components/empty-keypad-button.d.ts +13 -0
  9. package/dist/components/empty-keypad-button.js.flow +23 -0
  10. package/dist/components/expression-keypad.d.ts +22 -0
  11. package/dist/components/expression-keypad.js.flow +32 -0
  12. package/dist/components/fraction-keypad.d.ts +21 -0
  13. package/dist/components/fraction-keypad.js.flow +30 -0
  14. package/dist/components/gesture-manager.d.ts +74 -0
  15. package/dist/components/gesture-manager.js.flow +82 -0
  16. package/dist/components/gesture-state-machine.d.ts +105 -0
  17. package/dist/components/gesture-state-machine.js.flow +118 -0
  18. package/dist/components/icon.d.ts +15 -0
  19. package/dist/components/icon.js.flow +18 -0
  20. package/dist/components/input/__tests__/test-math-wrapper.d.ts +8 -0
  21. package/dist/components/input/__tests__/test-math-wrapper.js.flow +14 -0
  22. package/dist/components/input/cursor-handle.d.ts +1 -1
  23. package/dist/components/input/cursor-handle.js.flow +1 -1
  24. package/dist/components/input/drag-listener.d.ts +13 -0
  25. package/dist/components/input/drag-listener.js.flow +19 -0
  26. package/dist/components/input/math-input.d.ts +5 -4
  27. package/dist/components/input/math-input.js.flow +5 -4
  28. package/dist/components/input/math-wrapper.d.ts +110 -0
  29. package/dist/components/input/math-wrapper.js.flow +125 -0
  30. package/dist/components/input/scroll-into-view.d.ts +11 -0
  31. package/dist/components/input/scroll-into-view.js.flow +20 -0
  32. package/dist/components/keypad/button-assets.d.ts +4 -3
  33. package/dist/components/keypad/button-assets.js.flow +3 -3
  34. package/dist/components/keypad/button.d.ts +1 -2
  35. package/dist/components/keypad/button.js.flow +1 -2
  36. package/dist/components/keypad/index.d.ts +1 -1
  37. package/dist/components/keypad/index.js.flow +1 -3
  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 +50 -0
  57. package/dist/components/node-manager.js.flow +62 -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 +68 -0
  61. package/dist/components/popover-state-machine.js.flow +77 -0
  62. package/dist/components/provided-keypad.d.ts +8 -10
  63. package/dist/components/provided-keypad.js.flow +8 -10
  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.css +0 -3
  83. package/dist/es/index.js +933 -1065
  84. package/dist/es/index.js.map +1 -1
  85. package/dist/fake-react-native-web/text.d.ts +2 -1
  86. package/dist/fake-react-native-web/text.js.flow +2 -1
  87. package/dist/fake-react-native-web/view.d.ts +3 -2
  88. package/dist/fake-react-native-web/view.js.flow +3 -2
  89. package/dist/index.css +0 -3
  90. package/dist/index.d.ts +1 -1
  91. package/dist/index.js +977 -1090
  92. package/dist/index.js.flow +1 -4
  93. package/dist/index.js.map +1 -1
  94. package/dist/store/actions.d.ts +64 -0
  95. package/dist/store/actions.js.flow +100 -0
  96. package/dist/store/echo-reducer.d.ts +4 -0
  97. package/dist/store/echo-reducer.js.flow +10 -0
  98. package/dist/store/index.d.ts +10 -1
  99. package/dist/store/index.js.flow +17 -1
  100. package/dist/store/input-reducer.d.ts +4 -0
  101. package/dist/store/input-reducer.js.flow +13 -0
  102. package/dist/store/keypad-reducer.d.ts +4 -0
  103. package/dist/store/keypad-reducer.js.flow +13 -0
  104. package/dist/store/layout-reducer.d.ts +4 -0
  105. package/dist/store/layout-reducer.js.flow +13 -0
  106. package/dist/store/pager-reducer.d.ts +4 -0
  107. package/dist/store/pager-reducer.js.flow +13 -0
  108. package/dist/store/shared.d.ts +6 -0
  109. package/dist/store/shared.js.flow +13 -0
  110. package/dist/store/types.d.ts +58 -0
  111. package/dist/store/types.js.flow +64 -0
  112. package/dist/types.d.ts +63 -0
  113. package/dist/types.js.flow +73 -0
  114. package/less/overrides.less +0 -6
  115. package/package.json +1 -1
  116. package/src/components/__tests__/{gesture-state-machine_test.js → gesture-state-machine.test.ts} +5 -1
  117. package/src/components/__tests__/{two-page-keypad_test.js → two-page-keypad.test.tsx} +0 -2
  118. package/src/components/{corner-decal.js → corner-decal.tsx} +6 -5
  119. package/src/components/{echo-manager.js → echo-manager.tsx} +29 -24
  120. package/src/components/{empty-keypad-button.js → empty-keypad-button.tsx} +17 -10
  121. package/src/components/{expression-keypad.js → expression-keypad.tsx} +27 -25
  122. package/src/components/{fraction-keypad.js → fraction-keypad.tsx} +21 -16
  123. package/src/components/{gesture-manager.js → gesture-manager.ts} +10 -4
  124. package/src/components/{gesture-state-machine.js → gesture-state-machine.ts} +49 -3
  125. package/src/components/{icon.js → icon.tsx} +12 -14
  126. package/src/components/input/cursor-handle.tsx +1 -1
  127. package/src/components/input/{drag-listener.js → drag-listener.ts} +4 -0
  128. package/src/components/input/math-input.tsx +10 -9
  129. package/src/components/input/{math-wrapper.js → math-wrapper.ts} +10 -6
  130. package/src/components/input/{scroll-into-view.js → scroll-into-view.ts} +5 -15
  131. package/src/components/keypad/button-assets.tsx +4 -5
  132. package/src/components/keypad/button.tsx +1 -2
  133. package/src/components/keypad/index.tsx +2 -2
  134. package/src/components/keypad/keypad-page-items.tsx +33 -10
  135. package/src/components/{keypad-button.js → keypad-button.tsx} +42 -37
  136. package/src/components/{keypad-container.js → keypad-container.tsx} +42 -24
  137. package/src/components/{keypad.js → keypad.tsx} +32 -24
  138. package/src/components/{many-keypad-button.js → many-keypad-button.tsx} +8 -6
  139. package/src/components/{math-icon.js → math-icon.tsx} +7 -6
  140. package/src/components/{multi-symbol-grid.js → multi-symbol-grid.tsx} +8 -8
  141. package/src/components/{multi-symbol-popover.js → multi-symbol-popover.tsx} +5 -6
  142. package/src/components/{navigation-pad.js → navigation-pad.tsx} +7 -6
  143. package/src/components/{node-manager.js → node-manager.ts} +16 -4
  144. package/src/components/{popover-manager.js → popover-manager.tsx} +13 -16
  145. package/src/components/{popover-state-machine.js → popover-state-machine.ts} +13 -2
  146. package/src/components/prop-types.js +1 -67
  147. package/src/components/provided-keypad.tsx +16 -23
  148. package/src/components/{svg-icon.js → svg-icon.tsx} +5 -6
  149. package/src/components/tabbar/icons.tsx +4 -2
  150. package/src/components/tabbar/item.tsx +1 -3
  151. package/src/components/tabbar/{tabbar.stories.js → tabbar.stories.tsx} +10 -1
  152. package/src/components/tabbar/tabbar.tsx +3 -3
  153. package/src/components/{text-icon.js → text-icon.tsx} +7 -6
  154. package/src/components/{touchable-keypad-button.js → touchable-keypad-button.tsx} +19 -16
  155. package/src/components/{two-page-keypad.js → two-page-keypad.tsx} +13 -9
  156. package/src/components/{velocity-tracker.js → velocity-tracker.ts} +14 -4
  157. package/src/fake-react-native-web/text.tsx +2 -1
  158. package/src/fake-react-native-web/view.tsx +3 -2
  159. package/src/index.ts +1 -4
  160. package/src/math-input.stories.tsx +67 -0
  161. package/src/store/actions.ts +178 -0
  162. package/src/store/echo-reducer.ts +61 -0
  163. package/src/store/index.ts +39 -449
  164. package/src/store/input-reducer.ts +56 -0
  165. package/src/store/keypad-reducer.ts +59 -0
  166. package/src/store/layout-reducer.ts +134 -0
  167. package/src/store/pager-reducer.ts +125 -0
  168. package/src/store/shared.ts +12 -0
  169. package/src/store/types.ts +82 -0
  170. package/src/types.ts +81 -0
  171. package/tsconfig.tsbuildinfo +1 -1
  172. package/src/actions/index.js +0 -57
  173. package/src/components/app.js +0 -73
  174. package/src/demo.js +0 -9
  175. package/src/native-app.js +0 -85
  176. /package/src/components/__tests__/{node-manager_test.js → node-manager.test.ts} +0 -0
  177. /package/src/components/{compute-layout-parameters.js → compute-layout-parameters.ts} +0 -0
  178. /package/src/components/input/__tests__/{context-tracking_test.js → context-tracking.test.ts} +0 -0
  179. /package/src/components/input/__tests__/{mathquill_test.js → mathquill.test.ts} +0 -0
  180. /package/src/components/input/__tests__/{test-math-wrapper.jsx → test-math-wrapper.ts} +0 -0
  181. /package/src/components/keypad/{button.stories.js → button.stories.tsx} +0 -0
  182. /package/src/components/{styles.js → styles.ts} +0 -0
  183. /package/src/components/tabbar/__tests__/{tabbar_test.js → tabbar.test.tsx} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @khanacademy/math-input
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c1cf562: Removal of an unused keypad style
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 4c03a43d: Convert math-input to TS, changing the API in the process
14
+
15
+ ### Patch Changes
16
+
17
+ - 22c5d564: Remove the use of React.FC<> and use types named Props/State in more components
18
+
3
19
  ## 0.7.2
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,38 @@
1
+ /**
2
+ * An algorithm for computing the appropriate layout parameters for the keypad,
3
+ * including the size of the buttons and whether or not to render fullscreen,
4
+ * taking into account a number of factors including the size of the screen, the
5
+ * orientation of the screen, the presence of browser chrome, the presence of
6
+ * other exercise-related chrome, the size of the input box, the parameters that
7
+ * define the keypad (i.e., the number of rows, columns, and pages), and so
8
+ * forth.
9
+ *
10
+ * The computations herein make some strong assumptions about the sizes of
11
+ * various other elements and the situations under which they will be visible
12
+ * (e.g., browser chrome). However, this is just a heuristic--it's not crucial
13
+ * that our buttons are sized in a pixel-perfect manner, but rather, that we
14
+ * make a balanced use of space.
15
+ *
16
+ * Note that one goal of the algorithm is to avoid resizing the keypad in the
17
+ * face of dynamic browser chrome. In order to avoid that awkwardness, we tend
18
+ * to be conservative in our measurements and make things smaller than they
19
+ * might need to be.
20
+ */
21
+ export declare const computeLayoutParameters: ({ numColumns, numMaxVisibleRows, numPages }: {
22
+ numColumns: any;
23
+ numMaxVisibleRows: any;
24
+ numPages: any;
25
+ }, { pageWidthPx, pageHeightPx }: {
26
+ pageWidthPx: any;
27
+ pageHeightPx: any;
28
+ }, { deviceOrientation, deviceType }: {
29
+ deviceOrientation: any;
30
+ deviceType: any;
31
+ }, { navigationPadEnabled, paginationEnabled, toolbarEnabled }: {
32
+ navigationPadEnabled: any;
33
+ paginationEnabled: any;
34
+ toolbarEnabled: any;
35
+ }) => {
36
+ buttonDimensions: any;
37
+ layoutMode: "FULLSCREEN" | "COMPACT";
38
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * An algorithm for computing the appropriate layout parameters for the keypad,
9
+ * including the size of the buttons and whether or not to render fullscreen,
10
+ * taking into account a number of factors including the size of the screen, the
11
+ * orientation of the screen, the presence of browser chrome, the presence of
12
+ * other exercise-related chrome, the size of the input box, the parameters that
13
+ * define the keypad (i.e., the number of rows, columns, and pages), and so
14
+ * forth.
15
+ *
16
+ * The computations herein make some strong assumptions about the sizes of
17
+ * various other elements and the situations under which they will be visible
18
+ * (e.g., browser chrome). However, this is just a heuristic--it's not crucial
19
+ * that our buttons are sized in a pixel-perfect manner, but rather, that we
20
+ * make a balanced use of space.
21
+ *
22
+ * Note that one goal of the algorithm is to avoid resizing the keypad in the
23
+ * face of dynamic browser chrome. In order to avoid that awkwardness, we tend
24
+ * to be conservative in our measurements and make things smaller than they
25
+ * might need to be.
26
+ */
27
+ declare export var computeLayoutParameters: (
28
+ x: {|
29
+ numColumns: any,
30
+ numMaxVisibleRows: any,
31
+ numPages: any,
32
+ |},
33
+ x: {|
34
+ pageWidthPx: any,
35
+ pageHeightPx: any,
36
+ |},
37
+ x: {|
38
+ deviceOrientation: any,
39
+ deviceType: any,
40
+ |},
41
+ x: {|
42
+ navigationPadEnabled: any,
43
+ paginationEnabled: any,
44
+ toolbarEnabled: any,
45
+ |}
46
+ ) => {|
47
+ buttonDimensions: any,
48
+ layoutMode: "FULLSCREEN" | "COMPACT",
49
+ |};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A small triangular decal to sit in the corner of a parent component.
3
+ */
4
+ import * as React from "react";
5
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
6
+ type Props = {
7
+ style: StyleType;
8
+ };
9
+ declare class CornerDecal extends React.Component<Props> {
10
+ render(): JSX.Element;
11
+ }
12
+ export default CornerDecal;
@@ -0,0 +1,15 @@
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
+ style: StyleType,
11
+ |};
12
+ declare class CornerDecal extends React.Component<Props> {
13
+ render(): React$Node;
14
+ }
15
+ declare export default typeof CornerDecal;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A component that renders and animates the selection state effect effect.
3
+ */
4
+ import * as React from "react";
5
+ import { EchoAnimationTypes } from "../consts";
6
+ import type { Key } from "../data/keys";
7
+ import type { Border, Bound } from "../types";
8
+ type EchoPropType = {
9
+ animationId: string;
10
+ animationType: keyof typeof EchoAnimationTypes;
11
+ borders: Border;
12
+ id: Key;
13
+ initialBounds: Bound;
14
+ };
15
+ type EchoManagerProps = {
16
+ echoes: ReadonlyArray<EchoPropType>;
17
+ onAnimationFinish?: (animationId: string) => void;
18
+ };
19
+ declare class EchoManager extends React.Component<EchoManagerProps> {
20
+ _animationConfigForType: (animationType: any) => {
21
+ animationDurationMs: any;
22
+ animationTransitionName: any;
23
+ };
24
+ render(): JSX.Element;
25
+ }
26
+ export default EchoManager;
@@ -0,0 +1,29 @@
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 { EchoAnimationTypes } from "../consts";
9
+ import type { Key } from "../data/keys";
10
+ import type { Border, Bound } from "../types";
11
+ declare type EchoPropType = {|
12
+ animationId: string,
13
+ animationType: $Keys<typeof EchoAnimationTypes>,
14
+ borders: Border,
15
+ id: Key,
16
+ initialBounds: Bound,
17
+ |};
18
+ declare type EchoManagerProps = {|
19
+ echoes: $ReadOnlyArray<EchoPropType>,
20
+ onAnimationFinish?: (animationId: string) => void,
21
+ |};
22
+ declare class EchoManager extends React.Component<EchoManagerProps> {
23
+ _animationConfigForType: (animationType: any) => {|
24
+ animationDurationMs: any,
25
+ animationTransitionName: any,
26
+ |};
27
+ render(): React$Node;
28
+ }
29
+ declare export default typeof EchoManager;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A keypad button containing no symbols and triggering no actions on click.
3
+ */
4
+ import * as React from "react";
5
+ import GestureManager from "./gesture-manager";
6
+ interface ReduxProps {
7
+ gestureManager: GestureManager;
8
+ }
9
+ declare class EmptyKeypadButton extends React.Component<ReduxProps> {
10
+ render(): JSX.Element;
11
+ }
12
+ declare const _default: import("react-redux").ConnectedComponent<typeof EmptyKeypadButton, import("react-redux").Omit<React.ClassAttributes<EmptyKeypadButton> & ReduxProps, "gestureManager">>;
13
+ export default _default;
@@ -0,0 +1,23 @@
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 $Flowgen$Import$react_2d_redux from "react-redux";
8
+ import * as React from "react";
9
+ import GestureManager from "./gesture-manager";
10
+ declare interface ReduxProps {
11
+ gestureManager: GestureManager;
12
+ }
13
+ declare class EmptyKeypadButton extends React.Component<ReduxProps> {
14
+ render(): React$Node;
15
+ }
16
+ declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
17
+ typeof EmptyKeypadButton,
18
+ $Flowgen$Import$react_2d_redux.Omit<
19
+ {| ...React.ClassAttributes<EmptyKeypadButton>, ...ReduxProps |},
20
+ "gestureManager"
21
+ >
22
+ >;
23
+ declare export default typeof _default;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A keypad that includes all of the expression symbols.
3
+ */
4
+ import * as React from "react";
5
+ import type { KeypadLayout } from "../types";
6
+ import type { CursorContext } from "./input/cursor-contexts";
7
+ interface ReduxProps {
8
+ currentPage: number;
9
+ cursorContext?: CursorContext;
10
+ dynamicJumpOut: boolean;
11
+ }
12
+ interface Props extends ReduxProps {
13
+ extraKeys?: ReadonlyArray<string>;
14
+ roundTopLeft: boolean;
15
+ roundTopRight: boolean;
16
+ }
17
+ export declare const expressionKeypadLayout: KeypadLayout;
18
+ declare class ExpressionKeypad extends React.Component<Props> {
19
+ render(): JSX.Element;
20
+ }
21
+ declare const _default: import("react-redux").ConnectedComponent<typeof ExpressionKeypad, import("react-redux").Omit<React.ClassAttributes<ExpressionKeypad> & Props, "currentPage" | "cursorContext" | "dynamicJumpOut">>;
22
+ export default _default;
@@ -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
+ import * as $Flowgen$Import$react_2d_redux from "react-redux";
8
+ import * as React from "react";
9
+ import type { KeypadLayout } from "../types";
10
+ import type { CursorContext } from "./input/cursor-contexts";
11
+ declare interface ReduxProps {
12
+ currentPage: number;
13
+ cursorContext?: CursorContext;
14
+ dynamicJumpOut: boolean;
15
+ }
16
+ declare type Props = {
17
+ extraKeys?: $ReadOnlyArray<string>,
18
+ roundTopLeft: boolean,
19
+ roundTopRight: boolean,
20
+ } & ReduxProps;
21
+ declare export var expressionKeypadLayout: KeypadLayout;
22
+ declare class ExpressionKeypad extends React.Component<Props> {
23
+ render(): React$Node;
24
+ }
25
+ declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
26
+ typeof ExpressionKeypad,
27
+ $Flowgen$Import$react_2d_redux.Omit<
28
+ {| ...React.ClassAttributes<ExpressionKeypad>, ...Props |},
29
+ "currentPage" | "cursorContext" | "dynamicJumpOut"
30
+ >
31
+ >;
32
+ declare export default typeof _default;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A keypad that includes the digits, as well as the symbols required to deal
3
+ * with fractions, decimals, and percents.
4
+ */
5
+ import * as React from "react";
6
+ import type { KeypadLayout } from "../types";
7
+ import type { CursorContext } from "./input/cursor-contexts";
8
+ interface ReduxProps {
9
+ cursorContext?: CursorContext;
10
+ dynamicJumpOut: boolean;
11
+ }
12
+ interface Props extends ReduxProps {
13
+ roundTopLeft: boolean;
14
+ roundTopRight: boolean;
15
+ }
16
+ export declare const fractionKeypadLayout: KeypadLayout;
17
+ declare class FractionKeypad extends React.Component<Props> {
18
+ render(): JSX.Element;
19
+ }
20
+ declare const _default: import("react-redux").ConnectedComponent<typeof FractionKeypad, import("react-redux").Omit<React.ClassAttributes<FractionKeypad> & Props, "cursorContext" | "dynamicJumpOut">>;
21
+ export default _default;
@@ -0,0 +1,30 @@
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 $Flowgen$Import$react_2d_redux from "react-redux";
8
+ import * as React from "react";
9
+ import type { KeypadLayout } from "../types";
10
+ import type { CursorContext } from "./input/cursor-contexts";
11
+ declare interface ReduxProps {
12
+ cursorContext?: CursorContext;
13
+ dynamicJumpOut: boolean;
14
+ }
15
+ declare type Props = {
16
+ roundTopLeft: boolean,
17
+ roundTopRight: boolean,
18
+ } & ReduxProps;
19
+ declare export var fractionKeypadLayout: KeypadLayout;
20
+ declare class FractionKeypad extends React.Component<Props> {
21
+ render(): React$Node;
22
+ }
23
+ declare var _default: $Flowgen$Import$react_2d_redux.ConnectedComponent<
24
+ typeof FractionKeypad,
25
+ $Flowgen$Import$react_2d_redux.Omit<
26
+ {| ...React.ClassAttributes<FractionKeypad>, ...Props |},
27
+ "cursorContext" | "dynamicJumpOut"
28
+ >
29
+ >;
30
+ declare export default typeof _default;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A high-level manager for our gesture system. In particular, this class
3
+ * connects our various bits of logic for managing gestures and interactions,
4
+ * and links them together.
5
+ */
6
+ import GestureStateMachine from "./gesture-state-machine";
7
+ import NodeManager from "./node-manager";
8
+ import PopoverStateMachine from "./popover-state-machine";
9
+ declare class GestureManager {
10
+ swipeEnabled: boolean;
11
+ trackEvents: boolean;
12
+ nodeManager: NodeManager;
13
+ popoverStateMachine: PopoverStateMachine;
14
+ gestureStateMachine: GestureStateMachine;
15
+ constructor(options: any, handlers: any, disabledSwipeKeys: any, multiPressableKeys: any);
16
+ /**
17
+ * Handle a touch-start event that originated in a node registered with the
18
+ * gesture system.
19
+ *
20
+ * @param {TouchEvent} evt - the raw touch event from the browser
21
+ * @param {string} id - the identifier of the DOM node in which the touch
22
+ * occurred
23
+ */
24
+ onTouchStart(evt: TouchEvent, id?: any): void;
25
+ /**
26
+ * Handle a touch-move event that originated in a node registered with the
27
+ * gesture system.
28
+ *
29
+ * @param {TouchEvent} evt - the raw touch event from the browser
30
+ */
31
+ onTouchMove(evt: TouchEvent): void;
32
+ /**
33
+ * Handle a touch-end event that originated in a node registered with the
34
+ * gesture system.
35
+ *
36
+ * @param {TouchEvent} evt - the raw touch event from the browser
37
+ */
38
+ onTouchEnd(evt: TouchEvent): void;
39
+ /**
40
+ * Handle a touch-cancel event that originated in a node registered with the
41
+ * gesture system.
42
+ *
43
+ * @param {TouchEvent} evt - the raw touch event from the browser
44
+ */
45
+ onTouchCancel(evt: TouchEvent): void;
46
+ /**
47
+ * Register a DOM node with a given identifier.
48
+ *
49
+ * @param {string} id - the identifier of the given node
50
+ * @param {node} domNode - the DOM node linked to the identifier
51
+ * @param {string[]} childIds - the identifiers of any DOM nodes that
52
+ * should be considered children of this node,
53
+ * in that they should take priority when
54
+ * intercepting touch events
55
+ * @param {object} borders - an opaque object describing the node's borders
56
+ */
57
+ registerDOMNode(id: any, domNode: any, childIds: any, borders: any): void;
58
+ /**
59
+ * Unregister the DOM node with the given identifier.
60
+ *
61
+ * @param {string} id - the identifier of the node to unregister
62
+ */
63
+ unregisterDOMNode(id: any): void;
64
+ /**
65
+ * Enable event tracking for the gesture manager.
66
+ */
67
+ enableEventTracking(): void;
68
+ /**
69
+ * Disable event tracking for the gesture manager. When called, the gesture
70
+ * manager will drop any events received by managed nodes.
71
+ */
72
+ disableEventTracking(): void;
73
+ }
74
+ export default GestureManager;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import GestureStateMachine from "./gesture-state-machine";
8
+ import NodeManager from "./node-manager";
9
+ import PopoverStateMachine from "./popover-state-machine";
10
+ declare class GestureManager {
11
+ swipeEnabled: boolean;
12
+ trackEvents: boolean;
13
+ nodeManager: NodeManager;
14
+ popoverStateMachine: PopoverStateMachine;
15
+ gestureStateMachine: GestureStateMachine;
16
+ constructor(
17
+ options: any,
18
+ handlers: any,
19
+ disabledSwipeKeys: any,
20
+ multiPressableKeys: any
21
+ ): this;
22
+
23
+ /**
24
+ * Handle a touch-start event that originated in a node registered with the
25
+ * gesture system.
26
+ * @param {TouchEvent} evt - the raw touch event from the browser
27
+ * @param {string} id - the identifier of the DOM node in which the touch
28
+ * occurred
29
+ */
30
+ onTouchStart(evt: TouchEvent, id?: any): void;
31
+
32
+ /**
33
+ * Handle a touch-move event that originated in a node registered with the
34
+ * gesture system.
35
+ * @param {TouchEvent} evt - the raw touch event from the browser
36
+ */
37
+ onTouchMove(evt: TouchEvent): void;
38
+
39
+ /**
40
+ * Handle a touch-end event that originated in a node registered with the
41
+ * gesture system.
42
+ * @param {TouchEvent} evt - the raw touch event from the browser
43
+ */
44
+ onTouchEnd(evt: TouchEvent): void;
45
+
46
+ /**
47
+ * Handle a touch-cancel event that originated in a node registered with the
48
+ * gesture system.
49
+ * @param {TouchEvent} evt - the raw touch event from the browser
50
+ */
51
+ onTouchCancel(evt: TouchEvent): void;
52
+
53
+ /**
54
+ * Register a DOM node with a given identifier.
55
+ * @param {string} id - the identifier of the given node
56
+ * @param {node} domNode - the DOM node linked to the identifier
57
+ * @param {string[]} childIds - the identifiers of any DOM nodes that
58
+ * should be considered children of this node,
59
+ * in that they should take priority when
60
+ * intercepting touch events
61
+ * @param {{...}} borders - an opaque object describing the node's borders
62
+ */
63
+ registerDOMNode(id: any, domNode: any, childIds: any, borders: any): void;
64
+
65
+ /**
66
+ * Unregister the DOM node with the given identifier.
67
+ * @param {string} id - the identifier of the node to unregister
68
+ */
69
+ unregisterDOMNode(id: any): void;
70
+
71
+ /**
72
+ * Enable event tracking for the gesture manager.
73
+ */
74
+ enableEventTracking(): void;
75
+
76
+ /**
77
+ * Disable event tracking for the gesture manager. When called, the gesture
78
+ * manager will drop any events received by managed nodes.
79
+ */
80
+ disableEventTracking(): void;
81
+ }
82
+ declare export default typeof GestureManager;
@@ -0,0 +1,105 @@
1
+ import type { Key } from "../data/keys";
2
+ /**
3
+ * The state machine that backs our gesture system. In particular, this state
4
+ * machine manages the interplay between focuses, touch ups, and swiping.
5
+ * It is entirely ignorant of the existence of popovers and the positions of
6
+ * DOM nodes, operating solely on IDs. The state machine does accommodate for
7
+ * multi-touch interactions, tracking gesture state on a per-touch basis.
8
+ */
9
+ export type Handlers = {
10
+ onFocus: (id: string) => void;
11
+ onBlur: () => void;
12
+ onTrigger: (id: string) => void;
13
+ onLongPress: (id: string) => void;
14
+ onSwipeChange: (x: number) => void;
15
+ onSwipeEnd: (x: number) => void;
16
+ onTouchEnd: (id: string) => void;
17
+ };
18
+ type Options = {
19
+ longPressWaitTimeMs: number;
20
+ swipeThresholdPx: number;
21
+ holdIntervalMs: number;
22
+ };
23
+ type TouchState = {
24
+ activeNodeId: Key;
25
+ pressAndHoldIntervalId: number | null;
26
+ longPressTimeoutId: number | null;
27
+ swipeLocked: boolean;
28
+ startX: number;
29
+ };
30
+ type TouchStateMap = Record<Key, TouchState>;
31
+ type SwipeState = {
32
+ touchId: Key;
33
+ startX: number;
34
+ };
35
+ declare class GestureStateMachine {
36
+ handlers: Handlers;
37
+ options: Options;
38
+ swipeDisabledNodeIds: Partial<[Key]>;
39
+ multiPressableKeys: Partial<[Key]>;
40
+ touchState: Partial<TouchStateMap>;
41
+ swipeState: SwipeState | null;
42
+ constructor(handlers: Handlers, options: Partial<Options>, swipeDisabledNodeIds?: [Key], multiPressableKeys?: [Key]);
43
+ _maybeCancelLongPressForTouch(touchId: any): void;
44
+ _maybeCancelPressAndHoldForTouch(touchId: any): void;
45
+ _cleanupTouchEvent(touchId: any): void;
46
+ /**
47
+ * Handle a focus event on the node with the given identifier, which may be
48
+ * `null` to indicate that the user has dragged their finger off of any
49
+ * registered nodes, but is still in the middle of a gesture.
50
+ *
51
+ * @param {string|null} id - the identifier of the newly focused node, or
52
+ * `null` if no node is focused
53
+ * @param {number} touchId - a unique identifier associated with the touch
54
+ */
55
+ _onFocus(id: any, touchId: any): void;
56
+ /**
57
+ * Clear out all active gesture information.
58
+ */
59
+ _onSwipeStart(): void;
60
+ /**
61
+ * A function that returns the identifier of the node over which the touch
62
+ * event occurred. This is provided as a piece of lazy computation, as
63
+ * computing the DOM node for a given point is expensive, and the state
64
+ * machine won't always need that information. For example, if the user is
65
+ * swiping, then `onTouchMove` needs to be performant and doesn't care about
66
+ * the node over which the touch occurred.
67
+ *
68
+ * @typedef idComputation
69
+ * @returns {DOMNode} - the identifier of the node over which the touch
70
+ * occurred
71
+ */
72
+ /**
73
+ * Handle a touch-start event on the node with the given identifer.
74
+ *
75
+ * @param {idComputation} getId - a function that returns identifier of the
76
+ * node over which the start event occurred
77
+ * @param {number} touchId - a unique identifier associated with the touch
78
+ */
79
+ onTouchStart(getId: any, touchId: any, pageX: any): void;
80
+ /**
81
+ * Handle a touch-move event on the node with the given identifer.
82
+ *
83
+ * @param {idComputation} getId - a function that returns identifier of the
84
+ * node over which the move event occurred
85
+ * @param {number} touchId - a unique identifier associated with the touch
86
+ * @param {number} pageX - the x coordinate of the touch
87
+ * @param {boolean} swipeEnabled - whether the system should allow for
88
+ * transitions into a swiping state
89
+ */
90
+ onTouchMove(getId: any, touchId: any, pageX: any, swipeEnabled: any): void;
91
+ /**
92
+ * Handle a touch-end event on the node with the given identifer.
93
+ *
94
+ * @param {idComputation} getId - a function that returns identifier of the
95
+ * node over which the end event occurred
96
+ * @param {number} touchId - a unique identifier associated with the touch
97
+ * @param {number} pageX - the x coordinate of the touch
98
+ */
99
+ onTouchEnd(getId: any, touchId: any, pageX: any): void;
100
+ /**
101
+ * Handle a touch-cancel event.
102
+ */
103
+ onTouchCancel(touchId: any): void;
104
+ }
105
+ export default GestureStateMachine;