@khanacademy/math-input 0.6.8 → 0.7.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 (131) hide show
  1. package/.eslintrc.js +1 -0
  2. package/CHANGELOG.md +12 -0
  3. package/dist/components/common-style.d.ts +21 -0
  4. package/dist/components/common-style.js.flow +27 -0
  5. package/dist/components/input/cursor-contexts.d.ts +19 -0
  6. package/dist/components/input/cursor-contexts.js.flow +32 -0
  7. package/dist/components/input/cursor-handle.d.ts +25 -0
  8. package/dist/components/input/cursor-handle.js.flow +28 -0
  9. package/dist/components/input/math-input.d.ts +128 -0
  10. package/dist/components/input/math-input.js.flow +152 -0
  11. package/dist/components/keypad/button-assets.d.ts +6 -0
  12. package/dist/components/keypad/button-assets.js.flow +12 -0
  13. package/dist/components/keypad/button.d.ts +14 -0
  14. package/dist/components/keypad/button.js.flow +19 -0
  15. package/dist/components/keypad/index.d.ts +15 -0
  16. package/dist/components/keypad/index.js.flow +22 -0
  17. package/dist/components/keypad/keypad-page-items.d.ts +24 -0
  18. package/dist/components/keypad/keypad-page-items.js.flow +30 -0
  19. package/dist/components/keypad/numeric-input-page.d.ts +8 -0
  20. package/dist/components/keypad/numeric-input-page.js.flow +13 -0
  21. package/dist/components/keypad/pre-algebra-page.d.ts +8 -0
  22. package/dist/components/keypad/pre-algebra-page.js.flow +13 -0
  23. package/dist/components/keypad/trigonometry-page.d.ts +8 -0
  24. package/dist/components/keypad/trigonometry-page.js.flow +15 -0
  25. package/dist/components/provided-keypad.d.ts +23 -0
  26. package/dist/components/provided-keypad.js.flow +32 -0
  27. package/dist/components/tabbar/icons.d.ts +7 -0
  28. package/dist/components/tabbar/icons.js.flow +13 -0
  29. package/dist/components/tabbar/item.d.ts +14 -0
  30. package/dist/components/tabbar/item.js.flow +20 -0
  31. package/dist/components/tabbar/tabbar.d.ts +14 -0
  32. package/dist/components/tabbar/tabbar.js.flow +20 -0
  33. package/{src/components/tabbar/types.js → dist/components/tabbar/types.d.ts} +0 -2
  34. package/dist/components/tabbar/types.js.flow +7 -0
  35. package/dist/components/z-indexes.d.ts +7 -0
  36. package/dist/components/z-indexes.js.flow +13 -0
  37. package/dist/consts.d.ts +51 -0
  38. package/dist/consts.js.flow +66 -0
  39. package/dist/data/key-configs.d.ts +7 -0
  40. package/dist/data/key-configs.js.flow +13 -0
  41. package/dist/data/keys.d.ts +57 -0
  42. package/dist/data/keys.js.flow +112 -0
  43. package/dist/es/index.js +1431 -1836
  44. package/dist/es/index.js.map +1 -1
  45. package/dist/fake-react-native-web/index.d.ts +10 -0
  46. package/dist/fake-react-native-web/index.js.flow +8 -0
  47. package/dist/fake-react-native-web/text.d.ts +12 -0
  48. package/dist/fake-react-native-web/text.js.flow +18 -0
  49. package/dist/fake-react-native-web/view.d.ts +22 -0
  50. package/dist/fake-react-native-web/view.js.flow +28 -0
  51. package/dist/index.d.ts +14 -2
  52. package/dist/index.js +524 -951
  53. package/dist/index.js.flow +20 -2
  54. package/dist/index.js.map +1 -1
  55. package/dist/store/index.d.ts +1 -0
  56. package/dist/store/index.js.flow +7 -0
  57. package/dist/utils.d.ts +1 -0
  58. package/dist/utils.js.flow +7 -0
  59. package/package.json +3 -3
  60. package/src/components/__tests__/gesture-state-machine_test.js +1 -1
  61. package/src/components/__tests__/node-manager_test.js +1 -1
  62. package/src/components/__tests__/two-page-keypad_test.js +1 -1
  63. package/src/components/app.js +2 -2
  64. package/src/components/{common-style.js → common-style.ts} +0 -1
  65. package/src/components/compute-layout-parameters.js +2 -2
  66. package/src/components/corner-decal.js +2 -2
  67. package/src/components/echo-manager.js +5 -5
  68. package/src/components/empty-keypad-button.js +3 -3
  69. package/src/components/expression-keypad.js +10 -10
  70. package/src/components/fraction-keypad.js +9 -9
  71. package/src/components/gesture-manager.js +3 -3
  72. package/src/components/icon.js +6 -6
  73. package/src/components/iconography/down.js +1 -1
  74. package/src/components/iconography/index.js +41 -41
  75. package/src/components/iconography/left.js +1 -1
  76. package/src/components/iconography/right.js +1 -1
  77. package/src/components/iconography/up.js +1 -1
  78. package/src/components/input/__tests__/context-tracking_test.js +3 -3
  79. package/src/components/input/__tests__/mathquill_test.js +2 -2
  80. package/src/components/input/__tests__/test-math-wrapper.jsx +1 -1
  81. package/src/components/input/{cursor-contexts.js → cursor-contexts.ts} +7 -14
  82. package/src/components/input/{cursor-handle.js → cursor-handle.tsx} +19 -20
  83. package/src/components/input/{math-input.js → math-input.tsx} +170 -151
  84. package/src/components/input/math-wrapper.js +5 -5
  85. package/src/components/input/scroll-into-view.js +1 -1
  86. package/src/components/keypad/{button-assets.js → button-assets.tsx} +5 -4
  87. package/src/components/keypad/button.stories.js +1 -1
  88. package/src/components/keypad/{button.js → button.tsx} +9 -9
  89. package/src/components/keypad/{index.js → index.tsx} +16 -15
  90. package/src/components/keypad/{keypad-page-items.js → keypad-page-items.tsx} +24 -39
  91. package/src/components/keypad/{keypad-pages.stories.js → keypad-pages.stories.tsx} +6 -8
  92. package/src/components/keypad/{keypad.stories.js → keypad.stories.tsx} +3 -5
  93. package/src/components/keypad/{numeric-input-page.js → numeric-input-page.tsx} +6 -7
  94. package/src/components/keypad/{pre-algebra-page.js → pre-algebra-page.tsx} +6 -7
  95. package/src/components/keypad/{trigonometry-page.js → trigonometry-page.tsx} +6 -7
  96. package/src/components/keypad-button.js +7 -11
  97. package/src/components/keypad-container.js +10 -10
  98. package/src/components/keypad.js +5 -5
  99. package/src/components/many-keypad-button.js +6 -6
  100. package/src/components/math-icon.js +3 -3
  101. package/src/components/multi-symbol-grid.js +6 -6
  102. package/src/components/multi-symbol-popover.js +5 -5
  103. package/src/components/navigation-pad.js +6 -6
  104. package/src/components/popover-manager.js +3 -3
  105. package/src/components/prop-types.js +3 -3
  106. package/src/components/{provided-keypad.js → provided-keypad.tsx} +16 -14
  107. package/src/components/styles.js +1 -1
  108. package/src/components/svg-icon.js +1 -1
  109. package/src/components/tabbar/__tests__/tabbar_test.js +1 -1
  110. package/src/components/tabbar/{icons.js → icons.tsx} +7 -12
  111. package/src/components/tabbar/{item.js → item.tsx} +6 -8
  112. package/src/components/tabbar/tabbar.stories.js +2 -2
  113. package/src/components/tabbar/{tabbar.js → tabbar.tsx} +6 -8
  114. package/src/components/tabbar/types.ts +1 -0
  115. package/src/components/text-icon.js +3 -3
  116. package/src/components/touchable-keypad-button.js +5 -5
  117. package/src/components/two-page-keypad.js +5 -5
  118. package/src/components/{z-indexes.js → z-indexes.ts} +0 -1
  119. package/src/{consts.js → consts.ts} +22 -27
  120. package/src/data/{key-configs.js → key-configs.ts} +7 -8
  121. package/src/data/{keys.js → keys.ts} +7 -13
  122. package/src/demo.js +1 -1
  123. package/src/fake-react-native-web/{index.js → index.ts} +2 -3
  124. package/src/fake-react-native-web/{text.js → text.tsx} +7 -9
  125. package/src/fake-react-native-web/{view.js → view.tsx} +15 -17
  126. package/src/{index.js → index.ts} +9 -10
  127. package/src/native-app.js +3 -3
  128. package/src/store/{index.js → index.ts} +63 -34
  129. package/src/{utils.js → utils.ts} +1 -2
  130. package/tsconfig.json +9 -0
  131. package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
1
2
  /* eslint-disable import/no-commonjs */
2
3
  const path = require("path");
3
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @khanacademy/math-input
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 406edf6b: Extract strings to dist/string.js instead of dist/strings.
8
+
9
+ ## 0.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 53fd3768: Migrate source code to TypeScript
14
+
3
15
  ## 0.6.8
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,21 @@
1
+ export declare const wonderBlocksBlue: string;
2
+ export declare const offBlack: string;
3
+ export declare const offBlack32: string;
4
+ export declare const offBlack16: string;
5
+ export declare const offBlack8: string;
6
+ export declare const iconSizeHeightPx = 48;
7
+ export declare const iconSizeWidthPx = 48;
8
+ export declare const compactKeypadBorderRadiusPx = 4;
9
+ export declare const cursorHandleRadiusPx = 11;
10
+ export declare const cursorHandleDistanceMultiplier = 1.045;
11
+ export declare const valueGrey = "#FFF";
12
+ export declare const operatorGrey = "#FAFAFA";
13
+ export declare const controlGrey = "#F6F7F7";
14
+ export declare const emptyGrey = "#F0F1F2";
15
+ export declare const innerBorderColor: string;
16
+ export declare const innerBorderStyle = "solid";
17
+ export declare const innerBorderWidthPx = 1;
18
+ export declare const tabletCutoffPx = 600;
19
+ export declare const pageIndicatorHeightPx = 16;
20
+ export declare const navigationPadWidthPx = 192;
21
+ export declare const toolbarHeightPx = 60;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ declare export var wonderBlocksBlue: string;
8
+ declare export var offBlack: string;
9
+ declare export var offBlack32: string;
10
+ declare export var offBlack16: string;
11
+ declare export var offBlack8: string;
12
+ declare export var iconSizeHeightPx: 48;
13
+ declare export var iconSizeWidthPx: 48;
14
+ declare export var compactKeypadBorderRadiusPx: 4;
15
+ declare export var cursorHandleRadiusPx: 11;
16
+ declare export var cursorHandleDistanceMultiplier: 1.045;
17
+ declare export var valueGrey: "#FFF";
18
+ declare export var operatorGrey: "#FAFAFA";
19
+ declare export var controlGrey: "#F6F7F7";
20
+ declare export var emptyGrey: "#F0F1F2";
21
+ declare export var innerBorderColor: string;
22
+ declare export var innerBorderStyle: "solid";
23
+ declare export var innerBorderWidthPx: 1;
24
+ declare export var tabletCutoffPx: 600;
25
+ declare export var pageIndicatorHeightPx: 16;
26
+ declare export var navigationPadWidthPx: 192;
27
+ declare export var toolbarHeightPx: 60;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Constants that define the various contexts in which a cursor can exist. The
3
+ * active context is determined first by looking at the cursor's siblings (e.g.,
4
+ * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
5
+ * cursor could in theory be nested in multiple contexts, we only care about the
6
+ * immediate context.
7
+ *
8
+ * TODO(charlie): Add a context to represent being inside of a radical. Right
9
+ * now, we show the dismiss button rather than allowing the user to jump out of
10
+ * the radical.
11
+ */
12
+ export type CursorContext = "NONE" | "IN_PARENS" | "IN_SUPER_SCRIPT" | "IN_SUB_SCRIPT" | "IN_NUMERATOR" | "IN_DENOMINATOR" | "BEFORE_FRACTION";
13
+ export declare const NONE = "NONE";
14
+ export declare const IN_PARENS = "IN_PARENS";
15
+ export declare const IN_SUPER_SCRIPT = "IN_SUPER_SCRIPT";
16
+ export declare const IN_SUB_SCRIPT = "IN_SUB_SCRIPT";
17
+ export declare const IN_NUMERATOR = "IN_NUMERATOR";
18
+ export declare const IN_DENOMINATOR = "IN_DENOMINATOR";
19
+ export declare const BEFORE_FRACTION = "BEFORE_FRACTION";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * Constants that define the various contexts in which a cursor can exist. The
9
+ * active context is determined first by looking at the cursor's siblings (e.g.,
10
+ * for the `BEFORE_FRACTION` context), and then at its direct parent. Though a
11
+ * cursor could in theory be nested in multiple contexts, we only care about the
12
+ * immediate context.
13
+ *
14
+ * TODO(charlie): Add a context to represent being inside of a radical. Right
15
+ * now, we show the dismiss button rather than allowing the user to jump out of
16
+ * the radical.
17
+ */
18
+ export type CursorContext =
19
+ | "NONE"
20
+ | "IN_PARENS"
21
+ | "IN_SUPER_SCRIPT"
22
+ | "IN_SUB_SCRIPT"
23
+ | "IN_NUMERATOR"
24
+ | "IN_DENOMINATOR"
25
+ | "BEFORE_FRACTION";
26
+ declare export var NONE: "NONE";
27
+ declare export var IN_PARENS: "IN_PARENS";
28
+ declare export var IN_SUPER_SCRIPT: "IN_SUPER_SCRIPT";
29
+ declare export var IN_SUB_SCRIPT: "IN_SUB_SCRIPT";
30
+ declare export var IN_NUMERATOR: "IN_NUMERATOR";
31
+ declare export var IN_DENOMINATOR: "IN_DENOMINATOR";
32
+ declare export var BEFORE_FRACTION: "BEFORE_FRACTION";
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Renders the green tear-shaped handle under the cursor.
3
+ */
4
+ import * as React from "react";
5
+ type Props = {
6
+ animateIntoPosition: boolean | null | undefined;
7
+ onTouchCancel: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
8
+ onTouchEnd: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
9
+ onTouchMove: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
10
+ onTouchStart: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
11
+ visible: boolean;
12
+ x: number;
13
+ y: number;
14
+ };
15
+ type DefaultProps = {
16
+ animateIntoPosition: Props["animateIntoPosition"];
17
+ visible: Props["visible"];
18
+ x: Props["x"];
19
+ y: Props["y"];
20
+ };
21
+ declare class CursorHandle extends React.Component<Props> {
22
+ static defaultProps: DefaultProps;
23
+ render(): React.ReactNode;
24
+ }
25
+ export default CursorHandle;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ animateIntoPosition: boolean | null | void,
10
+ onTouchCancel: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
11
+ onTouchEnd: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
12
+ onTouchMove: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
13
+ onTouchStart: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void,
14
+ visible: boolean,
15
+ x: number,
16
+ y: number,
17
+ |};
18
+ declare type DefaultProps = {|
19
+ animateIntoPosition: $PropertyType<Props, "animateIntoPosition">,
20
+ visible: $PropertyType<Props, "visible">,
21
+ x: $PropertyType<Props, "x">,
22
+ y: $PropertyType<Props, "y">,
23
+ |};
24
+ declare class CursorHandle extends React.Component<Props> {
25
+ static defaultProps: DefaultProps;
26
+ render(): React.Node;
27
+ }
28
+ declare export default typeof CursorHandle;
@@ -0,0 +1,128 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ keypadElement: any;
4
+ onBlur: () => void;
5
+ onChange: any;
6
+ onFocus: () => void;
7
+ style: any;
8
+ value: string;
9
+ };
10
+ type DefaultProps = {
11
+ style: Props["style"];
12
+ value: Props["value"];
13
+ };
14
+ type HandleState = {
15
+ animateIntoPosition?: boolean | null | undefined;
16
+ visible: boolean;
17
+ x?: number;
18
+ y?: number;
19
+ };
20
+ type State = {
21
+ focused: boolean;
22
+ handle: HandleState;
23
+ };
24
+ declare class MathInput extends React.Component<Props, State> {
25
+ didTouchOutside: boolean | null | undefined;
26
+ didScroll: boolean | null | undefined;
27
+ mathField: any;
28
+ recordTouchStartOutside: (arg1: any) => void;
29
+ blurOnTouchEndOutside: (arg1: any) => void;
30
+ dragListener: any;
31
+ inputRef: HTMLDivElement | null | undefined;
32
+ _isMounted: boolean | null | undefined;
33
+ _mathContainer: any;
34
+ _container: HTMLDivElement;
35
+ _root: any;
36
+ _containerBounds: ClientRect;
37
+ _keypadBounds: ClientRect | null | undefined;
38
+ static defaultProps: DefaultProps;
39
+ state: State;
40
+ componentDidMount(): void;
41
+ UNSAFE_componentWillReceiveProps(props: Props): void;
42
+ componentDidUpdate(prevProps: Props, prevState: State): void;
43
+ componentWillUnmount(): void;
44
+ _clearKeypadBoundsCache: () => void;
45
+ _cacheKeypadBounds: (arg1: any) => void;
46
+ _updateInputPadding: () => void;
47
+ /** Gets and cache they bounds of the keypadElement */
48
+ _getKeypadBounds: () => any;
49
+ _updateCursorHandle: (arg1?: boolean | null | undefined) => void;
50
+ _hideCursorHandle: () => void;
51
+ _handleScroll: () => void;
52
+ blur: () => void;
53
+ focus: () => void;
54
+ /**
55
+ * Tries to determine which DOM node to place the cursor next to based on
56
+ * where the user drags the cursor handle. If it finds a node it will
57
+ * place the cursor next to it, update the handle to be under the cursor,
58
+ * and return true. If it doesn't find a node, it returns false.
59
+ *
60
+ * It searches for nodes by doing it tests at the following points:
61
+ *
62
+ * (x - dx, y), (x, y), (x + dx, y)
63
+ *
64
+ * If it doesn't find any nodes from the rendered math it will update y
65
+ * by adding dy.
66
+ *
67
+ * The algorithm ends its search when y goes outside the bounds of
68
+ * containerBounds.
69
+ *
70
+ * @param {DOMRect} containerBounds - bounds of the container node
71
+ * @param {number} x - the initial x coordinate in the viewport
72
+ * @param {number} y - the initial y coordinate in the viewport
73
+ * @param {number} dx - horizontal spacing between elementFromPoint calls
74
+ * @param {number} dy - vertical spacing between elementFromPoint calls,
75
+ * sign determines direction.
76
+ * @returns {boolean} - true if a node was hit, false otherwise.
77
+ */
78
+ _findHitNode: (arg1: ClientRect, arg2: number, arg3: number, arg4: number, arg5: number) => boolean;
79
+ /**
80
+ * Inserts the cursor at the DOM node closest to the given coordinates,
81
+ * based on hit-tests conducted using #_findHitNode.
82
+ *
83
+ * @param {number} x - the x coordinate in the viewport
84
+ * @param {number} y - the y coordinate in the viewport
85
+ */
86
+ _insertCursorAtClosestNode: (arg1: number, arg2: number) => void;
87
+ handleTouchStart: (arg1: React.TouchEvent<HTMLDivElement>) => void;
88
+ handleTouchMove: (arg1: React.TouchEvent<HTMLDivElement>) => void;
89
+ handleTouchEnd: (arg1: React.TouchEvent<HTMLDivElement>) => void;
90
+ /**
91
+ * When a touch starts in the cursor handle, we track it so as to avoid
92
+ * handling any touch events ourself.
93
+ *
94
+ * @param {TouchEvent} e - the raw touch event from the browser
95
+ */
96
+ onCursorHandleTouchStart: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
97
+ _constrainToBound: (arg1: number, arg2: number, arg3: number, arg4: number) => number;
98
+ /**
99
+ * When the user moves the cursor handle update the position of the cursor
100
+ * and the handle.
101
+ *
102
+ * @param {TouchEvent} e - the raw touch event from the browser
103
+ */
104
+ onCursorHandleTouchMove: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
105
+ /**
106
+ * When the user releases the cursor handle, animate it back into place.
107
+ *
108
+ * @param {TouchEvent} e - the raw touch event from the browser
109
+ */
110
+ onCursorHandleTouchEnd: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
111
+ /**
112
+ * If the gesture is cancelled mid-drag, simply hide it.
113
+ *
114
+ * @param {TouchEvent} e - the raw touch event from the browser
115
+ */
116
+ onCursorHandleTouchCancel: (arg1: React.TouchEvent<HTMLSpanElement>) => void;
117
+ domKeyToMathQuillKey: (arg1: string) => string | null | undefined;
118
+ handleKeyUp: (arg1: React.KeyboardEvent<HTMLDivElement>) => void;
119
+ getBorderWidthPx: () => number;
120
+ getInputInnerPadding: () => {
121
+ paddingTop: number;
122
+ paddingRight: number;
123
+ paddingBottom: number;
124
+ paddingLeft: number;
125
+ };
126
+ render(): React.ReactNode;
127
+ }
128
+ export default MathInput;
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ keypadElement: any,
10
+ onBlur: () => void,
11
+ onChange: any,
12
+ onFocus: () => void,
13
+ style: any,
14
+ value: string,
15
+ |};
16
+ declare type DefaultProps = {|
17
+ style: $PropertyType<Props, "style">,
18
+ value: $PropertyType<Props, "value">,
19
+ |};
20
+ declare type HandleState = {|
21
+ animateIntoPosition?: boolean | null | void,
22
+ visible: boolean,
23
+ x?: number,
24
+ y?: number,
25
+ |};
26
+ declare type State = {|
27
+ focused: boolean,
28
+ handle: HandleState,
29
+ |};
30
+ declare class MathInput extends React.Component<Props, State> {
31
+ didTouchOutside: boolean | null | void;
32
+ didScroll: boolean | null | void;
33
+ mathField: any;
34
+ recordTouchStartOutside: (arg1: any) => void;
35
+ blurOnTouchEndOutside: (arg1: any) => void;
36
+ dragListener: any;
37
+ inputRef: HTMLDivElement | null | void;
38
+ _isMounted: boolean | null | void;
39
+ _mathContainer: any;
40
+ _container: HTMLDivElement;
41
+ _root: any;
42
+ _containerBounds: ClientRect;
43
+ _keypadBounds: ClientRect | null | void;
44
+ static defaultProps: DefaultProps;
45
+ state: State;
46
+ componentDidMount(): void;
47
+ UNSAFE_componentWillReceiveProps(props: Props): void;
48
+ componentDidUpdate(prevProps: Props, prevState: State): void;
49
+ componentWillUnmount(): void;
50
+ _clearKeypadBoundsCache: () => void;
51
+ _cacheKeypadBounds: (arg1: any) => void;
52
+ _updateInputPadding: () => void;
53
+
54
+ /**
55
+ * Gets and cache they bounds of the keypadElement
56
+ */
57
+ _getKeypadBounds: () => any;
58
+ _updateCursorHandle: (arg1?: boolean | null | void) => void;
59
+ _hideCursorHandle: () => void;
60
+ _handleScroll: () => void;
61
+ blur: () => void;
62
+ focus: () => void;
63
+
64
+ /**
65
+ * Tries to determine which DOM node to place the cursor next to based on
66
+ * where the user drags the cursor handle. If it finds a node it will
67
+ * place the cursor next to it, update the handle to be under the cursor,
68
+ * and return true. If it doesn't find a node, it returns false.
69
+ *
70
+ * It searches for nodes by doing it tests at the following points:
71
+ *
72
+ * (x - dx, y), (x, y), (x + dx, y)
73
+ *
74
+ * If it doesn't find any nodes from the rendered math it will update y
75
+ * by adding dy.
76
+ *
77
+ * The algorithm ends its search when y goes outside the bounds of
78
+ * containerBounds.
79
+ * @param {DOMRect} containerBounds - bounds of the container node
80
+ * @param {number} x - the initial x coordinate in the viewport
81
+ * @param {number} y - the initial y coordinate in the viewport
82
+ * @param {number} dx - horizontal spacing between elementFromPoint calls
83
+ * @param {number} dy - vertical spacing between elementFromPoint calls,
84
+ * sign determines direction.
85
+ * @returns {boolean} - true if a node was hit, false otherwise.
86
+ */
87
+ _findHitNode: (
88
+ arg1: ClientRect,
89
+ arg2: number,
90
+ arg3: number,
91
+ arg4: number,
92
+ arg5: number
93
+ ) => boolean;
94
+
95
+ /**
96
+ * Inserts the cursor at the DOM node closest to the given coordinates,
97
+ * based on hit-tests conducted using #_findHitNode.
98
+ * @param {number} x - the x coordinate in the viewport
99
+ * @param {number} y - the y coordinate in the viewport
100
+ */
101
+ _insertCursorAtClosestNode: (arg1: number, arg2: number) => void;
102
+ handleTouchStart: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void;
103
+ handleTouchMove: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void;
104
+ handleTouchEnd: (arg1: SyntheticTouchEvent<HTMLDivElement>) => void;
105
+
106
+ /**
107
+ * When a touch starts in the cursor handle, we track it so as to avoid
108
+ * handling any touch events ourself.
109
+ * @param {TouchEvent} e - the raw touch event from the browser
110
+ */
111
+ onCursorHandleTouchStart: (
112
+ arg1: SyntheticTouchEvent<HTMLSpanElement>
113
+ ) => void;
114
+ _constrainToBound: (
115
+ arg1: number,
116
+ arg2: number,
117
+ arg3: number,
118
+ arg4: number
119
+ ) => number;
120
+
121
+ /**
122
+ * When the user moves the cursor handle update the position of the cursor
123
+ * and the handle.
124
+ * @param {TouchEvent} e - the raw touch event from the browser
125
+ */
126
+ onCursorHandleTouchMove: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void;
127
+
128
+ /**
129
+ * When the user releases the cursor handle, animate it back into place.
130
+ * @param {TouchEvent} e - the raw touch event from the browser
131
+ */
132
+ onCursorHandleTouchEnd: (arg1: SyntheticTouchEvent<HTMLSpanElement>) => void;
133
+
134
+ /**
135
+ * If the gesture is cancelled mid-drag, simply hide it.
136
+ * @param {TouchEvent} e - the raw touch event from the browser
137
+ */
138
+ onCursorHandleTouchCancel: (
139
+ arg1: SyntheticTouchEvent<HTMLSpanElement>
140
+ ) => void;
141
+ domKeyToMathQuillKey: (arg1: string) => string | null | void;
142
+ handleKeyUp: (arg1: SyntheticKeyboardEvent<HTMLDivElement>) => void;
143
+ getBorderWidthPx: () => number;
144
+ getInputInnerPadding: () => {|
145
+ paddingTop: number,
146
+ paddingRight: number,
147
+ paddingBottom: number,
148
+ paddingLeft: number,
149
+ |};
150
+ render(): React.Node;
151
+ }
152
+ declare export default typeof MathInput;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ type KeyId = string;
3
+ declare const buttonAsset: React.FC<{
4
+ id: KeyId;
5
+ }>;
6
+ export default buttonAsset;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type KeyId = string;
9
+ declare var buttonAsset: React.StatelessFunctionalComponent<{|
10
+ id: KeyId,
11
+ |}>;
12
+ declare export default typeof buttonAsset;
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
3
+ import type { Node } from "React";
4
+ type Props = {
5
+ onPress: () => void;
6
+ children: Node;
7
+ style?: StyleType;
8
+ tintColor?: string;
9
+ };
10
+ type State = Record<any, any>;
11
+ export default class Button extends React.Component<Props, State> {
12
+ render(): React.ReactNode;
13
+ }
14
+ export {};
@@ -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
+ import * as React from "react";
8
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
9
+ import type { Node } from "React";
10
+ declare type Props = {|
11
+ onPress: () => void,
12
+ children: Node,
13
+ style?: StyleType,
14
+ tintColor?: string,
15
+ |};
16
+ declare type State = { [key: any]: any };
17
+ declare export default class Button extends React.Component<Props, State> {
18
+ render(): React.Node;
19
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from "react";
2
+ import type { TabbarItemType } from "../tabbar/types";
3
+ type Props = {
4
+ onClickKey: (keyConfig: string) => void;
5
+ preAlgebra: boolean;
6
+ trigonometry: boolean;
7
+ };
8
+ type State = {
9
+ selectedPage: TabbarItemType;
10
+ };
11
+ export default class PreAlgebraKeypad extends React.Component<Props, State> {
12
+ state: State;
13
+ render(): React.ReactNode;
14
+ }
15
+ export {};
@@ -0,0 +1,22 @@
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 { TabbarItemType } from "../tabbar/types";
9
+ declare type Props = {|
10
+ onClickKey: (keyConfig: string) => void,
11
+ preAlgebra: boolean,
12
+ trigonometry: boolean,
13
+ |};
14
+ declare type State = {|
15
+ selectedPage: TabbarItemType,
16
+ |};
17
+ declare export default class PreAlgebraKeypad
18
+ extends React.Component<Props, State>
19
+ {
20
+ state: State;
21
+ render(): React.Node;
22
+ }
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import type { KeyConfig } from "../../data/key-configs";
3
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
4
+ import type { Node } from "React";
5
+ export declare const KeypadPageContainer: React.FC<{
6
+ children: Node;
7
+ }>;
8
+ export declare const KeypadButton: React.FC<{
9
+ keyConfig: KeyConfig;
10
+ tintColor?: string;
11
+ style?: StyleType;
12
+ onClickKey: (keyConfig: string) => void;
13
+ }>;
14
+ export declare const SecondaryKeypadButton: React.FC<{
15
+ keyConfig: KeyConfig;
16
+ style?: any;
17
+ onClickKey: (keyConfig: string) => void;
18
+ }>;
19
+ export declare const KeypadActionButton: React.FC<{
20
+ keyConfig: KeyConfig;
21
+ style?: any;
22
+ onClickKey: (keyConfig: string) => void;
23
+ }>;
24
+ export declare const PlaceHolderButton: () => React.ReactElement;
@@ -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 React from "react";
8
+ import type { KeyConfig } from "../../data/key-configs";
9
+ import type { StyleType } from "@khanacademy/wonder-blocks-core";
10
+ import type { Node } from "React";
11
+ declare export var KeypadPageContainer: React.StatelessFunctionalComponent<{|
12
+ children: Node,
13
+ |}>;
14
+ declare export var KeypadButton: React.StatelessFunctionalComponent<{|
15
+ keyConfig: KeyConfig,
16
+ tintColor?: string,
17
+ style?: StyleType,
18
+ onClickKey: (keyConfig: string) => void,
19
+ |}>;
20
+ declare export var SecondaryKeypadButton: React.StatelessFunctionalComponent<{|
21
+ keyConfig: KeyConfig,
22
+ style?: any,
23
+ onClickKey: (keyConfig: string) => void,
24
+ |}>;
25
+ declare export var KeypadActionButton: React.StatelessFunctionalComponent<{|
26
+ keyConfig: KeyConfig,
27
+ style?: any,
28
+ onClickKey: (keyConfig: string) => void,
29
+ |}>;
30
+ declare export var PlaceHolderButton: () => React.Element<any>;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ onClickKey: (keyConfig: string) => void;
4
+ };
5
+ export default class NumericInputPage extends React.Component<Props> {
6
+ render(): React.ReactNode;
7
+ }
8
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ onClickKey: (keyConfig: string) => void,
10
+ |};
11
+ declare export default class NumericInputPage extends React.Component<Props> {
12
+ render(): React.Node;
13
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ onClickKey: (keyConfig: string) => void;
4
+ };
5
+ export default class PreAlgebraPage extends React.Component<Props> {
6
+ render(): React.ReactNode;
7
+ }
8
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import * as React from "react";
8
+ declare type Props = {|
9
+ onClickKey: (keyConfig: string) => void,
10
+ |};
11
+ declare export default class PreAlgebraPage extends React.Component<Props> {
12
+ render(): React.Node;
13
+ }
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ onClickKey: (keyConfig: string) => void;
4
+ };
5
+ export default class TrigonometryInputPage extends React.Component<Props> {
6
+ render(): React.ReactNode;
7
+ }
8
+ export {};