@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
@@ -0,0 +1,64 @@
1
+ import type { Key } from "../data/keys";
2
+ import type { KeypadConfiguration, KeyHandler, Cursor, ActiveNodesObj, Border } from "../types";
3
+ type DismissKeypadAction = {
4
+ type: "DismissKeypad";
5
+ };
6
+ export declare const dismissKeypad: () => DismissKeypadAction;
7
+ type ActivateKeypadAction = {
8
+ type: "ActivateKeypad";
9
+ };
10
+ export declare const activateKeypad: () => ActivateKeypadAction;
11
+ /**
12
+ * Configure the keypad with the provided configuration parameters.
13
+ */
14
+ type ConfigureKeypadAction = {
15
+ type: "ConfigureKeypad";
16
+ configuration: KeypadConfiguration;
17
+ };
18
+ export declare const configureKeypad: (configuration: KeypadConfiguration) => ConfigureKeypadAction;
19
+ type SetPageSizeAction = {
20
+ type: "SetPageSize";
21
+ pageWidthPx: number;
22
+ pageHeightPx: number;
23
+ };
24
+ export declare const setPageSize: (pageWidthPx: number, pageHeightPx: number) => SetPageSizeAction;
25
+ type RemoveEchoAction = {
26
+ type: "RemoveEcho";
27
+ animationId: string;
28
+ };
29
+ export declare const removeEcho: (animationId: string) => RemoveEchoAction;
30
+ type SetKeyHandlerAction = {
31
+ type: "SetKeyHandler";
32
+ keyHandler: KeyHandler;
33
+ };
34
+ export declare const setKeyHandler: (keyHandler: KeyHandler) => SetKeyHandlerAction;
35
+ type SetCursorAction = {
36
+ type: "SetCursor";
37
+ cursor: Cursor;
38
+ };
39
+ export declare const setCursor: (cursor: Cursor) => SetCursorAction;
40
+ type OnSwipeChangeAction = {
41
+ type: "OnSwipeChange";
42
+ dx: number;
43
+ };
44
+ export declare const onSwipeChange: (dx: number) => OnSwipeChangeAction;
45
+ type OnSwipeEndAction = {
46
+ type: "OnSwipeEnd";
47
+ dx: number;
48
+ };
49
+ export declare const onSwipeEnd: (dx: number) => OnSwipeEndAction;
50
+ type SetActiveNodesAction = {
51
+ type: "SetActiveNodes";
52
+ activeNodes: any;
53
+ };
54
+ export declare const setActiveNodes: (activeNodes: ActiveNodesObj) => SetActiveNodesAction;
55
+ type PressKeyAction = {
56
+ type: "PressKey";
57
+ key: Key;
58
+ borders: Border;
59
+ initialBounds: DOMRect;
60
+ inPopover: boolean;
61
+ };
62
+ export declare const pressKey: (key: Key, borders: ("LEFT" | "BOTTOM" | undefined)[], initialBounds: DOMRect, inPopover: any) => PressKeyAction;
63
+ export type Action = DismissKeypadAction | ActivateKeypadAction | ConfigureKeypadAction | SetPageSizeAction | RemoveEchoAction | SetKeyHandlerAction | SetCursorAction | OnSwipeChangeAction | OnSwipeEndAction | SetActiveNodesAction | PressKeyAction;
64
+ export {};
@@ -0,0 +1,100 @@
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
+ import type {
9
+ KeypadConfiguration,
10
+ KeyHandler,
11
+ Cursor,
12
+ ActiveNodesObj,
13
+ Border,
14
+ } from "../types";
15
+ declare type DismissKeypadAction = {|
16
+ type: "DismissKeypad",
17
+ |};
18
+ declare export var dismissKeypad: () => DismissKeypadAction;
19
+ declare type ActivateKeypadAction = {|
20
+ type: "ActivateKeypad",
21
+ |};
22
+ declare export var activateKeypad: () => ActivateKeypadAction;
23
+ /**
24
+ * Configure the keypad with the provided configuration parameters.
25
+ */
26
+ declare type ConfigureKeypadAction = {|
27
+ type: "ConfigureKeypad",
28
+ configuration: KeypadConfiguration,
29
+ |};
30
+ declare export var configureKeypad: (
31
+ configuration: KeypadConfiguration
32
+ ) => ConfigureKeypadAction;
33
+ declare type SetPageSizeAction = {|
34
+ type: "SetPageSize",
35
+ pageWidthPx: number,
36
+ pageHeightPx: number,
37
+ |};
38
+ declare export var setPageSize: (
39
+ pageWidthPx: number,
40
+ pageHeightPx: number
41
+ ) => SetPageSizeAction;
42
+ declare type RemoveEchoAction = {|
43
+ type: "RemoveEcho",
44
+ animationId: string,
45
+ |};
46
+ declare export var removeEcho: (animationId: string) => RemoveEchoAction;
47
+ declare type SetKeyHandlerAction = {|
48
+ type: "SetKeyHandler",
49
+ keyHandler: KeyHandler,
50
+ |};
51
+ declare export var setKeyHandler: (
52
+ keyHandler: KeyHandler
53
+ ) => SetKeyHandlerAction;
54
+ declare type SetCursorAction = {|
55
+ type: "SetCursor",
56
+ cursor: Cursor,
57
+ |};
58
+ declare export var setCursor: (cursor: Cursor) => SetCursorAction;
59
+ declare type OnSwipeChangeAction = {|
60
+ type: "OnSwipeChange",
61
+ dx: number,
62
+ |};
63
+ declare export var onSwipeChange: (dx: number) => OnSwipeChangeAction;
64
+ declare type OnSwipeEndAction = {|
65
+ type: "OnSwipeEnd",
66
+ dx: number,
67
+ |};
68
+ declare export var onSwipeEnd: (dx: number) => OnSwipeEndAction;
69
+ declare type SetActiveNodesAction = {|
70
+ type: "SetActiveNodes",
71
+ activeNodes: any,
72
+ |};
73
+ declare export var setActiveNodes: (
74
+ activeNodes: ActiveNodesObj
75
+ ) => SetActiveNodesAction;
76
+ declare type PressKeyAction = {|
77
+ type: "PressKey",
78
+ key: Key,
79
+ borders: Border,
80
+ initialBounds: DOMRect,
81
+ inPopover: boolean,
82
+ |};
83
+ declare export var pressKey: (
84
+ key: Key,
85
+ borders: ("LEFT" | "BOTTOM" | void)[],
86
+ initialBounds: DOMRect,
87
+ inPopover: any
88
+ ) => PressKeyAction;
89
+ export type Action =
90
+ | DismissKeypadAction
91
+ | ActivateKeypadAction
92
+ | ConfigureKeypadAction
93
+ | SetPageSizeAction
94
+ | RemoveEchoAction
95
+ | SetKeyHandlerAction
96
+ | SetCursorAction
97
+ | OnSwipeChangeAction
98
+ | OnSwipeEndAction
99
+ | SetActiveNodesAction
100
+ | PressKeyAction;
@@ -0,0 +1,4 @@
1
+ import type { Action } from "./actions";
2
+ import type { EchoState } from "./types";
3
+ declare const echoReducer: (state: EchoState | undefined, action: Action) => EchoState;
4
+ export default echoReducer;
@@ -0,0 +1,10 @@
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 { Action } from "./actions";
8
+ import type { EchoState } from "./types";
9
+ declare var echoReducer: (state: EchoState | void, action: Action) => EchoState;
10
+ declare export default typeof echoReducer;
@@ -1 +1,10 @@
1
- export declare const createStore: () => any;
1
+ import * as Redux from "redux";
2
+ import type { GestureState } from "./types";
3
+ export declare const createStore: () => Redux.Store<Redux.EmptyObject & {
4
+ input: import("./types").InputState;
5
+ keypad: import("./types").KeypadState;
6
+ pager: import("./types").PagerState;
7
+ gestures: GestureState;
8
+ echoes: import("./types").EchoState;
9
+ layout: import("./types").LayoutState;
10
+ }, Redux.AnyAction>;
@@ -4,4 +4,20 @@
4
4
  * Flowgen v1.21.0
5
5
  * @flow
6
6
  */
7
- declare export var createStore: () => any;
7
+ import * as $Flowgen$Import$_2e__2f_types from "./types";
8
+ import * as Redux from "redux";
9
+ import type { GestureState } from "./types";
10
+ declare export var createStore: () => Redux.Store<
11
+ {|
12
+ ...Redux.EmptyObject,
13
+ ...{|
14
+ input: $Flowgen$Import$_2e__2f_types.InputState,
15
+ keypad: $Flowgen$Import$_2e__2f_types.KeypadState,
16
+ pager: $Flowgen$Import$_2e__2f_types.PagerState,
17
+ gestures: GestureState,
18
+ echoes: $Flowgen$Import$_2e__2f_types.EchoState,
19
+ layout: $Flowgen$Import$_2e__2f_types.LayoutState,
20
+ |},
21
+ |},
22
+ Redux.AnyAction
23
+ >;
@@ -0,0 +1,4 @@
1
+ import type { Action } from "./actions";
2
+ import type { InputState } from "./types";
3
+ declare const inputReducer: (state: InputState | undefined, action: Action) => InputState;
4
+ export default inputReducer;
@@ -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 type { Action } from "./actions";
8
+ import type { InputState } from "./types";
9
+ declare var inputReducer: (
10
+ state: InputState | void,
11
+ action: Action
12
+ ) => InputState;
13
+ declare export default typeof inputReducer;
@@ -0,0 +1,4 @@
1
+ import type { Action } from "./actions";
2
+ import type { KeypadState } from "./types";
3
+ declare const keypadReducer: (state: KeypadState | undefined, action: Action) => KeypadState;
4
+ export default keypadReducer;
@@ -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 type { Action } from "./actions";
8
+ import type { KeypadState } from "./types";
9
+ declare var keypadReducer: (
10
+ state: KeypadState | void,
11
+ action: Action
12
+ ) => KeypadState;
13
+ declare export default typeof keypadReducer;
@@ -0,0 +1,4 @@
1
+ import type { Action } from "./actions";
2
+ import type { LayoutState } from "./types";
3
+ declare const layoutReducer: (state: LayoutState | undefined, action: Action) => LayoutState;
4
+ export default layoutReducer;
@@ -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 type { Action } from "./actions";
8
+ import type { LayoutState } from "./types";
9
+ declare var layoutReducer: (
10
+ state: LayoutState | void,
11
+ action: Action
12
+ ) => LayoutState;
13
+ declare export default typeof layoutReducer;
@@ -0,0 +1,4 @@
1
+ import type { Action } from "./actions";
2
+ import type { PagerState } from "./types";
3
+ declare const pagerReducer: (state: PagerState | undefined, action: Action) => PagerState;
4
+ export default pagerReducer;
@@ -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 type { Action } from "./actions";
8
+ import type { PagerState } from "./types";
9
+ declare var pagerReducer: (
10
+ state: PagerState | void,
11
+ action: Action
12
+ ) => PagerState;
13
+ declare export default typeof pagerReducer;
@@ -0,0 +1,6 @@
1
+ declare const defaultKeypadType: "EXPRESSION";
2
+ declare const keypadForType: {
3
+ readonly FRACTION: import("../types").KeypadLayout;
4
+ readonly EXPRESSION: import("../types").KeypadLayout;
5
+ };
6
+ export { keypadForType, defaultKeypadType };
@@ -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 $Flowgen$Import$_2e__2e__2f_types from "../types";
8
+ declare var defaultKeypadType: "EXPRESSION";
9
+ declare var keypadForType: {|
10
+ +FRACTION: $Flowgen$Import$_2e__2e__2f_types.KeypadLayout,
11
+ +EXPRESSION: $Flowgen$Import$_2e__2e__2f_types.KeypadLayout,
12
+ |};
13
+ declare export { keypadForType, defaultKeypadType };
@@ -0,0 +1,58 @@
1
+ import GestureManager from "../components/gesture-manager";
2
+ import VelocityTracker from "../components/velocity-tracker";
3
+ import { LayoutModes } from "../consts";
4
+ import type { KeypadType } from "../consts";
5
+ import type { Key } from "../data/keys";
6
+ import type { Cursor, KeyHandler, Popover, Echo } from "../types";
7
+ export interface InputState {
8
+ keyHandler: KeyHandler | null;
9
+ cursor: Cursor | undefined;
10
+ }
11
+ export interface KeypadState {
12
+ extraKeys: ReadonlyArray<string>;
13
+ keypadType: KeypadType;
14
+ active: boolean;
15
+ }
16
+ export interface PagerState {
17
+ animateToPosition: boolean;
18
+ currentPage: number;
19
+ dx: number;
20
+ numPages: number;
21
+ pageWidthPx: number;
22
+ velocityTracker: VelocityTracker;
23
+ }
24
+ export interface GestureState {
25
+ popover: Popover | null;
26
+ focus: Key | null;
27
+ gestureManager: GestureManager;
28
+ }
29
+ export interface EchoState {
30
+ echoes: ReadonlyArray<Echo>;
31
+ }
32
+ export interface LayoutState {
33
+ gridDimensions: {
34
+ numRows: number;
35
+ numColumns: number;
36
+ numMaxVisibleRows: number;
37
+ numPages: number;
38
+ };
39
+ buttonDimensions: {
40
+ widthPx: number;
41
+ heightPx: number;
42
+ };
43
+ pageDimensions: {
44
+ pageWidthPx: number;
45
+ pageHeightPx: number;
46
+ };
47
+ layoutMode: keyof typeof LayoutModes;
48
+ paginationEnabled: boolean;
49
+ navigationPadEnabled: boolean;
50
+ }
51
+ export interface State {
52
+ input: InputState;
53
+ keypad: KeypadState;
54
+ pager: PagerState;
55
+ gestures: GestureState;
56
+ echoes: EchoState;
57
+ layout: LayoutState;
58
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import GestureManager from "../components/gesture-manager";
8
+ import VelocityTracker from "../components/velocity-tracker";
9
+ import { LayoutModes } from "../consts";
10
+ import type { KeypadType } from "../consts";
11
+ import type { Key } from "../data/keys";
12
+ import type { Cursor, KeyHandler, Popover, Echo } from "../types";
13
+ export interface InputState {
14
+ keyHandler: KeyHandler | null;
15
+ cursor: Cursor | void;
16
+ }
17
+ export interface KeypadState {
18
+ extraKeys: $ReadOnlyArray<string>;
19
+ keypadType: KeypadType;
20
+ active: boolean;
21
+ }
22
+ export interface PagerState {
23
+ animateToPosition: boolean;
24
+ currentPage: number;
25
+ dx: number;
26
+ numPages: number;
27
+ pageWidthPx: number;
28
+ velocityTracker: VelocityTracker;
29
+ }
30
+ export interface GestureState {
31
+ popover: Popover | null;
32
+ focus: Key | null;
33
+ gestureManager: GestureManager;
34
+ }
35
+ export interface EchoState {
36
+ echoes: $ReadOnlyArray<Echo>;
37
+ }
38
+ export interface LayoutState {
39
+ gridDimensions: {|
40
+ numRows: number,
41
+ numColumns: number,
42
+ numMaxVisibleRows: number,
43
+ numPages: number,
44
+ |};
45
+ buttonDimensions: {|
46
+ widthPx: number,
47
+ heightPx: number,
48
+ |};
49
+ pageDimensions: {|
50
+ pageWidthPx: number,
51
+ pageHeightPx: number,
52
+ |};
53
+ layoutMode: $Keys<typeof LayoutModes>;
54
+ paginationEnabled: boolean;
55
+ navigationPadEnabled: boolean;
56
+ }
57
+ export interface State {
58
+ input: InputState;
59
+ keypad: KeypadState;
60
+ pager: PagerState;
61
+ gestures: GestureState;
62
+ echoes: EchoState;
63
+ layout: LayoutState;
64
+ }
@@ -0,0 +1,63 @@
1
+ import { BorderDirections, EchoAnimationTypes, KeyTypes, IconTypes } from "./consts";
2
+ import type { CursorContext } from "./components/input/cursor-contexts";
3
+ import type { KeypadType } from "./consts";
4
+ import type { Key } from "./data/keys";
5
+ export type Border = Partial<Array<keyof typeof BorderDirections>>;
6
+ export type Bound = {
7
+ top: number;
8
+ right: number;
9
+ bottom: number;
10
+ left: number;
11
+ height: number;
12
+ width: number;
13
+ };
14
+ export type Popover = {
15
+ parentId: Key;
16
+ bounds: Partial<Bound>;
17
+ childKeyIds: Array<Key>;
18
+ };
19
+ export type Echo = {
20
+ animationId: string;
21
+ animationType: keyof typeof EchoAnimationTypes;
22
+ borders: Border;
23
+ id: Key;
24
+ initialBounds: DOMRect;
25
+ };
26
+ export type Icon = {
27
+ type: keyof typeof IconTypes;
28
+ data: string;
29
+ };
30
+ export type KeyConfig = {
31
+ ariaLabel: string;
32
+ id: Key;
33
+ type: keyof typeof KeyTypes;
34
+ childKeyIds: Array<Key>;
35
+ icon: Icon;
36
+ };
37
+ export type KeypadConfiguration = {
38
+ keypadType: KeypadType;
39
+ extraKeys?: ReadonlyArray<Key>;
40
+ };
41
+ export type KeyHandler = (key: Key) => Cursor;
42
+ export type Cursor = {
43
+ context: CursorContext;
44
+ };
45
+ export type KeypadLayout = {
46
+ rows: number;
47
+ columns: number;
48
+ numPages: number;
49
+ maxVisibleRows: number;
50
+ };
51
+ type ActiveNodesObjPopover = {
52
+ parentId: string;
53
+ childIds: ReadonlyArray<string>;
54
+ };
55
+ export type ActiveNodesObj = {
56
+ popover: ActiveNodesObjPopover | null;
57
+ focus: string | null;
58
+ };
59
+ export type LayoutProps = {
60
+ initialBounds: DOMRect;
61
+ borders: Border;
62
+ };
63
+ export {};
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Flowtype definitions for data
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+ import {
8
+ BorderDirections,
9
+ EchoAnimationTypes,
10
+ KeyTypes,
11
+ IconTypes,
12
+ } from "./consts";
13
+ import type { CursorContext } from "./components/input/cursor-contexts";
14
+ import type { KeypadType } from "./consts";
15
+ import type { Key } from "./data/keys";
16
+ export type Border = $Rest<Array<$Keys<typeof BorderDirections>>, {}>;
17
+ export type Bound = {|
18
+ top: number,
19
+ right: number,
20
+ bottom: number,
21
+ left: number,
22
+ height: number,
23
+ width: number,
24
+ |};
25
+ export type Popover = {|
26
+ parentId: Key,
27
+ bounds: $Rest<Bound, {}>,
28
+ childKeyIds: Array<Key>,
29
+ |};
30
+ export type Echo = {|
31
+ animationId: string,
32
+ animationType: $Keys<typeof EchoAnimationTypes>,
33
+ borders: Border,
34
+ id: Key,
35
+ initialBounds: DOMRect,
36
+ |};
37
+ export type Icon = {|
38
+ type: $Keys<typeof IconTypes>,
39
+ data: string,
40
+ |};
41
+ export type KeyConfig = {|
42
+ ariaLabel: string,
43
+ id: Key,
44
+ type: $Keys<typeof KeyTypes>,
45
+ childKeyIds: Array<Key>,
46
+ icon: Icon,
47
+ |};
48
+ export type KeypadConfiguration = {|
49
+ keypadType: KeypadType,
50
+ extraKeys?: $ReadOnlyArray<Key>,
51
+ |};
52
+ export type KeyHandler = (key: Key) => Cursor;
53
+ export type Cursor = {|
54
+ context: CursorContext,
55
+ |};
56
+ export type KeypadLayout = {|
57
+ rows: number,
58
+ columns: number,
59
+ numPages: number,
60
+ maxVisibleRows: number,
61
+ |};
62
+ declare type ActiveNodesObjPopover = {|
63
+ parentId: string,
64
+ childIds: $ReadOnlyArray<string>,
65
+ |};
66
+ export type ActiveNodesObj = {|
67
+ popover: ActiveNodesObjPopover | null,
68
+ focus: string | null,
69
+ |};
70
+ export type LayoutProps = {|
71
+ initialBounds: DOMRect,
72
+ borders: Border,
73
+ |};
@@ -121,9 +121,3 @@
121
121
  display: inline-block !important;
122
122
  }
123
123
  }
124
-
125
- // The keypad sets its own color styles for KaTeX elements that are rendered in
126
- // its keys, so prevent any external styling.
127
- .keypad-container .katex {
128
- color: inherit !important;
129
- }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Khan Academy's new expression editor for the mobile web.",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "0.7.2",
6
+ "version": "1.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,5 +1,7 @@
1
1
  import GestureStateMachine from "../gesture-state-machine";
2
2
 
3
+ import type {Handlers} from "../gesture-state-machine";
4
+
3
5
  const swipeThresholdPx = 5;
4
6
  const longPressWaitTimeMs = 5;
5
7
  const holdIntervalMs = 5;
@@ -20,10 +22,11 @@ const eventTrackers = (buffer) => {
20
22
  ];
21
23
  callbackNames.forEach((callbackName) => {
22
24
  handlers[callbackName] = function () {
25
+ // eslint-disable-next-line prefer-rest-params
23
26
  buffer.push([callbackName, ...arguments]);
24
27
  };
25
28
  });
26
- return handlers;
29
+ return handlers as Handlers;
27
30
  };
28
31
 
29
32
  // Arbitrary node IDs (representative of arbitrary keys) to be used in testing.
@@ -48,6 +51,7 @@ describe("GestureStateMachine", () => {
48
51
  longPressWaitTimeMs,
49
52
  holdIntervalMs,
50
53
  },
54
+ // @ts-expect-error TS2322
51
55
  [NodeIds.swipeDisabled],
52
56
  [NodeIds.multiPressable],
53
57
  );
@@ -8,7 +8,6 @@ describe("<TwoPageKeyPage />", () => {
8
8
  // Arrange
9
9
  const wrapper = mount(
10
10
  <TwoPageKeypad
11
- paginationEnabled={true}
12
11
  currentPage={1}
13
12
  leftPage={<p>Left Page</p>}
14
13
  rightPage={<p>Right Page</p>}
@@ -24,7 +23,6 @@ describe("<TwoPageKeyPage />", () => {
24
23
  // Arrange
25
24
  const wrapper = mount(
26
25
  <TwoPageKeypad
27
- paginationEnabled={true}
28
26
  currentPage={0}
29
27
  leftPage={<p>Left Page</p>}
30
28
  rightPage={<p>Right Page</p>}
@@ -3,18 +3,19 @@
3
3
  */
4
4
 
5
5
  import {StyleSheet} from "aphrodite";
6
- import PropTypes from "prop-types";
7
6
  import * as React from "react";
8
7
 
9
8
  import {View} from "../fake-react-native-web/index";
10
9
 
11
10
  import {offBlack} from "./common-style";
12
11
 
13
- class CornerDecal extends React.Component {
14
- static propTypes = {
15
- style: PropTypes.any,
16
- };
12
+ import type {StyleType} from "@khanacademy/wonder-blocks-core";
17
13
 
14
+ type Props = {
15
+ style: StyleType;
16
+ };
17
+
18
+ class CornerDecal extends React.Component<Props> {
18
19
  render() {
19
20
  const {style} = this.props;
20
21