@khanacademy/math-input 0.7.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/actions/index.d.ts +31 -0
- package/dist/actions/index.js.flow +40 -0
- package/dist/components/compute-layout-parameters.d.ts +38 -0
- package/dist/components/compute-layout-parameters.js.flow +49 -0
- package/dist/components/corner-decal.d.ts +12 -0
- package/dist/components/corner-decal.js.flow +15 -0
- package/dist/components/echo-manager.d.ts +26 -0
- package/dist/components/echo-manager.js.flow +29 -0
- package/dist/components/empty-keypad-button.d.ts +13 -0
- package/dist/components/empty-keypad-button.js.flow +23 -0
- package/dist/components/expression-keypad.d.ts +22 -0
- package/dist/components/expression-keypad.js.flow +32 -0
- package/dist/components/fraction-keypad.d.ts +21 -0
- package/dist/components/fraction-keypad.js.flow +30 -0
- package/dist/components/gesture-manager.d.ts +74 -0
- package/dist/components/gesture-manager.js.flow +82 -0
- package/dist/components/gesture-state-machine.d.ts +105 -0
- package/dist/components/gesture-state-machine.js.flow +118 -0
- package/dist/components/icon.d.ts +15 -0
- package/dist/components/icon.js.flow +18 -0
- package/dist/components/input/__tests__/test-math-wrapper.d.ts +8 -0
- package/dist/components/input/__tests__/test-math-wrapper.js.flow +14 -0
- package/dist/components/input/cursor-handle.d.ts +1 -1
- package/dist/components/input/cursor-handle.js.flow +1 -1
- package/dist/components/input/drag-listener.d.ts +13 -0
- package/dist/components/input/drag-listener.js.flow +19 -0
- package/dist/components/input/math-input.d.ts +5 -4
- package/dist/components/input/math-input.js.flow +5 -4
- package/dist/components/input/math-wrapper.d.ts +110 -0
- package/dist/components/input/math-wrapper.js.flow +125 -0
- package/dist/components/input/scroll-into-view.d.ts +11 -0
- package/dist/components/input/scroll-into-view.js.flow +20 -0
- package/dist/components/keypad/button-assets.d.ts +4 -3
- package/dist/components/keypad/button-assets.js.flow +3 -3
- package/dist/components/keypad/button.d.ts +1 -2
- package/dist/components/keypad/button.js.flow +1 -2
- package/dist/components/keypad/keypad-page-items.d.ts +15 -10
- package/dist/components/keypad/keypad-page-items.js.flow +20 -10
- package/dist/components/keypad-button.d.ts +52 -0
- package/dist/components/keypad-button.js.flow +79 -0
- package/dist/components/keypad-container.d.ts +40 -0
- package/dist/components/keypad-container.js.flow +58 -0
- package/dist/components/keypad.d.ts +31 -0
- package/dist/components/keypad.js.flow +40 -0
- package/dist/components/many-keypad-button.d.ts +15 -0
- package/dist/components/many-keypad-button.js.flow +17 -0
- package/dist/components/math-icon.d.ts +16 -0
- package/dist/components/math-icon.js.flow +19 -0
- package/dist/components/multi-symbol-grid.d.ts +14 -0
- package/dist/components/multi-symbol-grid.js.flow +16 -0
- package/dist/components/multi-symbol-popover.d.ts +12 -0
- package/dist/components/multi-symbol-popover.js.flow +15 -0
- package/dist/components/navigation-pad.d.ts +14 -0
- package/dist/components/navigation-pad.js.flow +16 -0
- package/dist/components/node-manager.d.ts +53 -0
- package/dist/components/node-manager.js.flow +65 -0
- package/dist/components/popover-manager.d.ts +13 -0
- package/dist/components/popover-manager.js.flow +15 -0
- package/dist/components/popover-state-machine.d.ts +75 -0
- package/dist/components/popover-state-machine.js.flow +83 -0
- package/dist/components/provided-keypad.d.ts +8 -7
- package/dist/components/provided-keypad.js.flow +8 -7
- package/dist/components/styles.d.ts +6 -0
- package/dist/components/styles.js.flow +13 -0
- package/dist/components/svg-icon.d.ts +12 -0
- package/dist/components/svg-icon.js.flow +15 -0
- package/dist/components/tabbar/icons.d.ts +3 -2
- package/dist/components/tabbar/icons.js.flow +3 -2
- package/dist/components/tabbar/item.d.ts +1 -2
- package/dist/components/tabbar/item.js.flow +1 -2
- package/dist/components/tabbar/tabbar.d.ts +3 -3
- package/dist/components/tabbar/tabbar.js.flow +3 -3
- package/dist/components/text-icon.d.ts +13 -0
- package/dist/components/text-icon.js.flow +16 -0
- package/dist/components/touchable-keypad-button.d.ts +30 -0
- package/dist/components/touchable-keypad-button.js.flow +35 -0
- package/dist/components/two-page-keypad.d.ts +20 -0
- package/dist/components/two-page-keypad.js.flow +30 -0
- package/dist/components/velocity-tracker.d.ts +48 -0
- package/dist/components/velocity-tracker.js.flow +54 -0
- package/dist/es/index.js +938 -1059
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/text.d.ts +2 -1
- package/dist/fake-react-native-web/text.js.flow +2 -1
- package/dist/fake-react-native-web/view.d.ts +3 -2
- package/dist/fake-react-native-web/view.js.flow +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +988 -1089
- package/dist/index.js.flow +1 -4
- package/dist/index.js.map +1 -1
- package/dist/store/echo-reducer.d.ts +5 -0
- package/dist/store/echo-reducer.js.flow +14 -0
- package/dist/store/index.d.ts +46 -1
- package/dist/store/index.js.flow +64 -1
- package/dist/store/input-reducer.d.ts +7 -0
- package/dist/store/input-reducer.js.flow +16 -0
- package/dist/store/keypad-reducer.d.ts +9 -0
- package/dist/store/keypad-reducer.js.flow +18 -0
- package/dist/store/layout-reducer.d.ts +21 -0
- package/dist/store/layout-reducer.js.flow +30 -0
- package/dist/store/pager-reducer.d.ts +13 -0
- package/dist/store/pager-reducer.js.flow +22 -0
- package/dist/store/shared.d.ts +6 -0
- package/dist/store/shared.js.flow +13 -0
- package/dist/store/types.d.ts +57 -0
- package/dist/store/types.js.flow +63 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.js.flow +61 -0
- package/package.json +1 -1
- package/src/actions/{index.js → index.ts} +5 -5
- package/src/components/__tests__/{gesture-state-machine_test.js → gesture-state-machine.test.ts} +5 -1
- package/src/components/__tests__/{two-page-keypad_test.js → two-page-keypad.test.tsx} +0 -2
- package/src/components/{corner-decal.js → corner-decal.tsx} +6 -5
- package/src/components/{echo-manager.js → echo-manager.tsx} +29 -24
- package/src/components/{empty-keypad-button.js → empty-keypad-button.tsx} +17 -10
- package/src/components/{expression-keypad.js → expression-keypad.tsx} +27 -25
- package/src/components/{fraction-keypad.js → fraction-keypad.tsx} +21 -16
- package/src/components/{gesture-manager.js → gesture-manager.tsx} +10 -4
- package/src/components/{gesture-state-machine.js → gesture-state-machine.ts} +49 -3
- package/src/components/{icon.js → icon.tsx} +12 -14
- package/src/components/input/cursor-handle.tsx +1 -1
- package/src/components/input/{drag-listener.js → drag-listener.ts} +4 -0
- package/src/components/input/math-input.tsx +10 -9
- package/src/components/input/{math-wrapper.js → math-wrapper.ts} +10 -6
- package/src/components/input/{scroll-into-view.js → scroll-into-view.ts} +5 -15
- package/src/components/keypad/button-assets.tsx +4 -5
- package/src/components/keypad/button.tsx +1 -2
- package/src/components/keypad/index.tsx +1 -1
- package/src/components/keypad/keypad-page-items.tsx +33 -10
- package/src/components/{keypad-button.js → keypad-button.tsx} +42 -37
- package/src/components/{keypad-container.js → keypad-container.tsx} +41 -23
- package/src/components/{keypad.js → keypad.tsx} +31 -23
- package/src/components/{many-keypad-button.js → many-keypad-button.tsx} +8 -6
- package/src/components/{math-icon.js → math-icon.tsx} +7 -6
- package/src/components/{multi-symbol-grid.js → multi-symbol-grid.tsx} +8 -8
- package/src/components/{multi-symbol-popover.js → multi-symbol-popover.tsx} +5 -6
- package/src/components/{navigation-pad.js → navigation-pad.tsx} +7 -6
- package/src/components/{node-manager.js → node-manager.ts} +16 -4
- package/src/components/{popover-manager.js → popover-manager.tsx} +13 -16
- package/src/components/{popover-state-machine.js → popover-state-machine.ts} +21 -2
- package/src/components/prop-types.js +1 -67
- package/src/components/provided-keypad.tsx +14 -12
- package/src/components/{svg-icon.js → svg-icon.tsx} +5 -6
- package/src/components/tabbar/icons.tsx +4 -2
- package/src/components/tabbar/item.tsx +1 -3
- package/src/components/tabbar/{tabbar.stories.js → tabbar.stories.tsx} +10 -1
- package/src/components/tabbar/tabbar.tsx +3 -3
- package/src/components/{text-icon.js → text-icon.tsx} +7 -6
- package/src/components/{touchable-keypad-button.js → touchable-keypad-button.tsx} +19 -16
- package/src/components/{two-page-keypad.js → two-page-keypad.tsx} +13 -9
- package/src/components/{velocity-tracker.js → velocity-tracker.ts} +14 -4
- package/src/fake-react-native-web/text.tsx +2 -1
- package/src/fake-react-native-web/view.tsx +3 -2
- package/src/index.ts +1 -4
- package/src/store/echo-reducer.ts +58 -0
- package/src/store/index.ts +14 -425
- package/src/store/input-reducer.ts +55 -0
- package/src/store/keypad-reducer.ts +62 -0
- package/src/store/layout-reducer.ts +133 -0
- package/src/store/pager-reducer.ts +141 -0
- package/src/store/shared.ts +12 -0
- package/src/store/types.ts +65 -0
- package/src/types.ts +69 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/components/app.js +0 -73
- package/src/demo.js +0 -9
- package/src/native-app.js +0 -85
- /package/src/components/__tests__/{node-manager_test.js → node-manager.test.ts} +0 -0
- /package/src/components/{compute-layout-parameters.js → compute-layout-parameters.ts} +0 -0
- /package/src/components/input/__tests__/{context-tracking_test.js → context-tracking.test.ts} +0 -0
- /package/src/components/input/__tests__/{mathquill_test.js → mathquill.test.ts} +0 -0
- /package/src/components/input/__tests__/{test-math-wrapper.jsx → test-math-wrapper.ts} +0 -0
- /package/src/components/keypad/{button.stories.js → button.stories.tsx} +0 -0
- /package/src/components/{styles.js → styles.ts} +0 -0
- /package/src/components/tabbar/__tests__/{tabbar_test.js → tabbar.test.tsx} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import type { EchoState } from "./types";
|
|
8
|
+
declare var echoReducer: (
|
|
9
|
+
state: {|
|
|
10
|
+
+echoes: [],
|
|
11
|
+
|} | void,
|
|
12
|
+
action: any
|
|
13
|
+
) => EchoState;
|
|
14
|
+
declare export default typeof echoReducer;
|
package/dist/store/index.d.ts
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import * as Redux from "redux";
|
|
2
|
+
import GestureManager from "../components/gesture-manager";
|
|
3
|
+
import type { GestureState } from "./types";
|
|
4
|
+
export declare const createStore: () => Redux.Store<Redux.EmptyObject & {
|
|
5
|
+
input: import("./types").InputState;
|
|
6
|
+
keypad: import("./types").KeypadState | {
|
|
7
|
+
readonly extraKeys: readonly ["x", "y", "THETA", "PI"];
|
|
8
|
+
readonly keypadType: "EXPRESSION";
|
|
9
|
+
readonly active: false;
|
|
10
|
+
};
|
|
11
|
+
pager: import("./types").PagerState | {
|
|
12
|
+
readonly animateToPosition: false;
|
|
13
|
+
readonly currentPage: number;
|
|
14
|
+
readonly dx: 0;
|
|
15
|
+
readonly numPages: number;
|
|
16
|
+
readonly pageWidthPx: 0;
|
|
17
|
+
readonly velocityTracker: import("../components/velocity-tracker").default;
|
|
18
|
+
};
|
|
19
|
+
gestures: GestureState | {
|
|
20
|
+
readonly popover: null;
|
|
21
|
+
readonly focus: null;
|
|
22
|
+
readonly gestureManager: GestureManager;
|
|
23
|
+
};
|
|
24
|
+
echoes: import("./types").EchoState | {
|
|
25
|
+
readonly echoes: readonly [];
|
|
26
|
+
};
|
|
27
|
+
layout: import("./types").LayoutState | {
|
|
28
|
+
readonly gridDimensions: {
|
|
29
|
+
readonly numRows: number;
|
|
30
|
+
readonly numColumns: number;
|
|
31
|
+
readonly numMaxVisibleRows: number;
|
|
32
|
+
readonly numPages: number;
|
|
33
|
+
};
|
|
34
|
+
readonly buttonDimensions: {
|
|
35
|
+
readonly widthPx: 48;
|
|
36
|
+
readonly heightPx: 48;
|
|
37
|
+
};
|
|
38
|
+
readonly pageDimensions: {
|
|
39
|
+
readonly pageWidthPx: 0;
|
|
40
|
+
readonly pageHeightPx: 0;
|
|
41
|
+
};
|
|
42
|
+
readonly layoutMode: "FULLSCREEN";
|
|
43
|
+
readonly paginationEnabled: false;
|
|
44
|
+
readonly navigationPadEnabled: false;
|
|
45
|
+
};
|
|
46
|
+
}, Redux.AnyAction>;
|
package/dist/store/index.js.flow
CHANGED
|
@@ -4,4 +4,67 @@
|
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import * as $Flowgen$Import$_2e__2f_types from "./types";
|
|
8
|
+
import * as $Flowgen$Import$_2e__2e__2f_components_2f_velocity_2d_tracker from "../components/velocity-tracker";
|
|
9
|
+
import * as Redux from "redux";
|
|
10
|
+
import GestureManager from "../components/gesture-manager";
|
|
11
|
+
import type { GestureState } from "./types";
|
|
12
|
+
declare export var createStore: () => Redux.Store<
|
|
13
|
+
{|
|
|
14
|
+
...Redux.EmptyObject,
|
|
15
|
+
...{|
|
|
16
|
+
input: $Flowgen$Import$_2e__2f_types.InputState,
|
|
17
|
+
keypad:
|
|
18
|
+
| $Flowgen$Import$_2e__2f_types.KeypadState
|
|
19
|
+
| {|
|
|
20
|
+
+extraKeys: ["x", "y", "THETA", "PI"],
|
|
21
|
+
+keypadType: "EXPRESSION",
|
|
22
|
+
+active: false,
|
|
23
|
+
|},
|
|
24
|
+
pager:
|
|
25
|
+
| $Flowgen$Import$_2e__2f_types.PagerState
|
|
26
|
+
| {|
|
|
27
|
+
+animateToPosition: false,
|
|
28
|
+
+currentPage: number,
|
|
29
|
+
+dx: 0,
|
|
30
|
+
+numPages: number,
|
|
31
|
+
+pageWidthPx: 0,
|
|
32
|
+
+velocityTracker: $Flowgen$Import$_2e__2e__2f_components_2f_velocity_2d_tracker.default,
|
|
33
|
+
|},
|
|
34
|
+
gestures:
|
|
35
|
+
| GestureState
|
|
36
|
+
| {|
|
|
37
|
+
+popover: null,
|
|
38
|
+
+focus: null,
|
|
39
|
+
+gestureManager: GestureManager,
|
|
40
|
+
|},
|
|
41
|
+
echoes:
|
|
42
|
+
| $Flowgen$Import$_2e__2f_types.EchoState
|
|
43
|
+
| {|
|
|
44
|
+
+echoes: [],
|
|
45
|
+
|},
|
|
46
|
+
layout:
|
|
47
|
+
| $Flowgen$Import$_2e__2f_types.LayoutState
|
|
48
|
+
| {|
|
|
49
|
+
+gridDimensions: {|
|
|
50
|
+
+numRows: number,
|
|
51
|
+
+numColumns: number,
|
|
52
|
+
+numMaxVisibleRows: number,
|
|
53
|
+
+numPages: number,
|
|
54
|
+
|},
|
|
55
|
+
+buttonDimensions: {|
|
|
56
|
+
+widthPx: 48,
|
|
57
|
+
+heightPx: 48,
|
|
58
|
+
|},
|
|
59
|
+
+pageDimensions: {|
|
|
60
|
+
+pageWidthPx: 0,
|
|
61
|
+
+pageHeightPx: 0,
|
|
62
|
+
|},
|
|
63
|
+
+layoutMode: "FULLSCREEN",
|
|
64
|
+
+paginationEnabled: false,
|
|
65
|
+
+navigationPadEnabled: false,
|
|
66
|
+
|},
|
|
67
|
+
|},
|
|
68
|
+
|},
|
|
69
|
+
Redux.AnyAction
|
|
70
|
+
>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { Cursor, KeyHandler } from "../types";
|
|
8
|
+
import type { InputState } from "./types";
|
|
9
|
+
declare var inputReducer: (
|
|
10
|
+
state: {|
|
|
11
|
+
keyHandler: KeyHandler | null,
|
|
12
|
+
cursor: Cursor,
|
|
13
|
+
|} | void,
|
|
14
|
+
action: any
|
|
15
|
+
) => InputState;
|
|
16
|
+
declare export default typeof inputReducer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { KeypadState } from "./types";
|
|
2
|
+
declare const keypadReducer: (state: {
|
|
3
|
+
readonly extraKeys: readonly ["x", "y", "THETA", "PI"];
|
|
4
|
+
readonly keypadType: "EXPRESSION";
|
|
5
|
+
readonly active: false;
|
|
6
|
+
} | undefined, action: {
|
|
7
|
+
type: string;
|
|
8
|
+
}) => KeypadState;
|
|
9
|
+
export default keypadReducer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for data
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.21.0
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
import type { KeypadState } from "./types";
|
|
8
|
+
declare var keypadReducer: (
|
|
9
|
+
state: {|
|
|
10
|
+
+extraKeys: ["x", "y", "THETA", "PI"],
|
|
11
|
+
+keypadType: "EXPRESSION",
|
|
12
|
+
+active: false,
|
|
13
|
+
|} | void,
|
|
14
|
+
action: {|
|
|
15
|
+
type: string,
|
|
16
|
+
|}
|
|
17
|
+
) => KeypadState;
|
|
18
|
+
declare export default typeof keypadReducer;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LayoutState } from "./types";
|
|
2
|
+
declare const layoutReducer: (state: {
|
|
3
|
+
readonly gridDimensions: {
|
|
4
|
+
readonly numRows: number;
|
|
5
|
+
readonly numColumns: number;
|
|
6
|
+
readonly numMaxVisibleRows: number;
|
|
7
|
+
readonly numPages: number;
|
|
8
|
+
};
|
|
9
|
+
readonly buttonDimensions: {
|
|
10
|
+
readonly widthPx: 48;
|
|
11
|
+
readonly heightPx: 48;
|
|
12
|
+
};
|
|
13
|
+
readonly pageDimensions: {
|
|
14
|
+
readonly pageWidthPx: 0;
|
|
15
|
+
readonly pageHeightPx: 0;
|
|
16
|
+
};
|
|
17
|
+
readonly layoutMode: "FULLSCREEN";
|
|
18
|
+
readonly paginationEnabled: false;
|
|
19
|
+
readonly navigationPadEnabled: false;
|
|
20
|
+
} | undefined, action: any) => LayoutState;
|
|
21
|
+
export default layoutReducer;
|
|
@@ -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 type { LayoutState } from "./types";
|
|
8
|
+
declare var layoutReducer: (
|
|
9
|
+
state: {|
|
|
10
|
+
+gridDimensions: {|
|
|
11
|
+
+numRows: number,
|
|
12
|
+
+numColumns: number,
|
|
13
|
+
+numMaxVisibleRows: number,
|
|
14
|
+
+numPages: number,
|
|
15
|
+
|},
|
|
16
|
+
+buttonDimensions: {|
|
|
17
|
+
+widthPx: 48,
|
|
18
|
+
+heightPx: 48,
|
|
19
|
+
|},
|
|
20
|
+
+pageDimensions: {|
|
|
21
|
+
+pageWidthPx: 0,
|
|
22
|
+
+pageHeightPx: 0,
|
|
23
|
+
|},
|
|
24
|
+
+layoutMode: "FULLSCREEN",
|
|
25
|
+
+paginationEnabled: false,
|
|
26
|
+
+navigationPadEnabled: false,
|
|
27
|
+
|} | void,
|
|
28
|
+
action: any
|
|
29
|
+
) => LayoutState;
|
|
30
|
+
declare export default typeof layoutReducer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import VelocityTracker from "../components/velocity-tracker";
|
|
2
|
+
import type { PagerState } from "./types";
|
|
3
|
+
declare const pagerReducer: (state: {
|
|
4
|
+
readonly animateToPosition: false;
|
|
5
|
+
readonly currentPage: number;
|
|
6
|
+
readonly dx: 0;
|
|
7
|
+
readonly numPages: number;
|
|
8
|
+
readonly pageWidthPx: 0;
|
|
9
|
+
readonly velocityTracker: VelocityTracker;
|
|
10
|
+
} | undefined, action: {
|
|
11
|
+
type: string;
|
|
12
|
+
}) => PagerState;
|
|
13
|
+
export default pagerReducer;
|
|
@@ -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 VelocityTracker from "../components/velocity-tracker";
|
|
8
|
+
import type { PagerState } from "./types";
|
|
9
|
+
declare var pagerReducer: (
|
|
10
|
+
state: {|
|
|
11
|
+
+animateToPosition: false,
|
|
12
|
+
+currentPage: number,
|
|
13
|
+
+dx: 0,
|
|
14
|
+
+numPages: number,
|
|
15
|
+
+pageWidthPx: 0,
|
|
16
|
+
+velocityTracker: VelocityTracker,
|
|
17
|
+
|} | void,
|
|
18
|
+
action: {|
|
|
19
|
+
type: string,
|
|
20
|
+
|}
|
|
21
|
+
) => PagerState;
|
|
22
|
+
declare export default typeof 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 * 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,57 @@
|
|
|
1
|
+
import GestureManager from "../components/gesture-manager";
|
|
2
|
+
import VelocityTracker from "../components/velocity-tracker";
|
|
3
|
+
import { LayoutModes } from "../consts";
|
|
4
|
+
import type { Key } from "../data/keys";
|
|
5
|
+
import type { Cursor, KeyHandler, Popover, Echo } from "../types";
|
|
6
|
+
export interface InputState {
|
|
7
|
+
keyHandler: KeyHandler | null;
|
|
8
|
+
cursor: Cursor | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface KeypadState {
|
|
11
|
+
extraKeys: ReadonlyArray<string>;
|
|
12
|
+
keypadType: any;
|
|
13
|
+
active: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface PagerState {
|
|
16
|
+
animateToPosition: boolean;
|
|
17
|
+
currentPage: number;
|
|
18
|
+
dx: number;
|
|
19
|
+
numPages: number;
|
|
20
|
+
pageWidthPx: number;
|
|
21
|
+
velocityTracker: VelocityTracker;
|
|
22
|
+
}
|
|
23
|
+
export interface GestureState {
|
|
24
|
+
popover: Popover | null;
|
|
25
|
+
focus: Key | null;
|
|
26
|
+
gestureManager: GestureManager;
|
|
27
|
+
}
|
|
28
|
+
export interface EchoState {
|
|
29
|
+
echoes: ReadonlyArray<Echo>;
|
|
30
|
+
}
|
|
31
|
+
export interface LayoutState {
|
|
32
|
+
gridDimensions: {
|
|
33
|
+
numRows: number;
|
|
34
|
+
numColumns: number;
|
|
35
|
+
numMaxVisibleRows: number;
|
|
36
|
+
numPages: number;
|
|
37
|
+
};
|
|
38
|
+
buttonDimensions: {
|
|
39
|
+
widthPx: number;
|
|
40
|
+
heightPx: number;
|
|
41
|
+
};
|
|
42
|
+
pageDimensions: {
|
|
43
|
+
pageWidthPx: number;
|
|
44
|
+
pageHeightPx: number;
|
|
45
|
+
};
|
|
46
|
+
layoutMode: keyof typeof LayoutModes;
|
|
47
|
+
paginationEnabled: boolean;
|
|
48
|
+
navigationPadEnabled: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface State {
|
|
51
|
+
input: InputState;
|
|
52
|
+
keypad: KeypadState;
|
|
53
|
+
pager: PagerState;
|
|
54
|
+
gestures: GestureState;
|
|
55
|
+
echoes: EchoState;
|
|
56
|
+
layout: LayoutState;
|
|
57
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { Key } from "../data/keys";
|
|
11
|
+
import type { Cursor, KeyHandler, Popover, Echo } from "../types";
|
|
12
|
+
export interface InputState {
|
|
13
|
+
keyHandler: KeyHandler | null;
|
|
14
|
+
cursor: Cursor | void;
|
|
15
|
+
}
|
|
16
|
+
export interface KeypadState {
|
|
17
|
+
extraKeys: $ReadOnlyArray<string>;
|
|
18
|
+
keypadType: any;
|
|
19
|
+
active: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PagerState {
|
|
22
|
+
animateToPosition: boolean;
|
|
23
|
+
currentPage: number;
|
|
24
|
+
dx: number;
|
|
25
|
+
numPages: number;
|
|
26
|
+
pageWidthPx: number;
|
|
27
|
+
velocityTracker: VelocityTracker;
|
|
28
|
+
}
|
|
29
|
+
export interface GestureState {
|
|
30
|
+
popover: Popover | null;
|
|
31
|
+
focus: Key | null;
|
|
32
|
+
gestureManager: GestureManager;
|
|
33
|
+
}
|
|
34
|
+
export interface EchoState {
|
|
35
|
+
echoes: $ReadOnlyArray<Echo>;
|
|
36
|
+
}
|
|
37
|
+
export interface LayoutState {
|
|
38
|
+
gridDimensions: {|
|
|
39
|
+
numRows: number,
|
|
40
|
+
numColumns: number,
|
|
41
|
+
numMaxVisibleRows: number,
|
|
42
|
+
numPages: number,
|
|
43
|
+
|};
|
|
44
|
+
buttonDimensions: {|
|
|
45
|
+
widthPx: number,
|
|
46
|
+
heightPx: number,
|
|
47
|
+
|};
|
|
48
|
+
pageDimensions: {|
|
|
49
|
+
pageWidthPx: number,
|
|
50
|
+
pageHeightPx: number,
|
|
51
|
+
|};
|
|
52
|
+
layoutMode: $Keys<typeof LayoutModes>;
|
|
53
|
+
paginationEnabled: boolean;
|
|
54
|
+
navigationPadEnabled: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface State {
|
|
57
|
+
input: InputState;
|
|
58
|
+
keypad: KeypadState;
|
|
59
|
+
pager: PagerState;
|
|
60
|
+
gestures: GestureState;
|
|
61
|
+
echoes: EchoState;
|
|
62
|
+
layout: LayoutState;
|
|
63
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
|};
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {KeypadConfiguration, KeyHandler} from "../types";
|
|
2
|
+
|
|
1
3
|
// naming convention: verb + noun
|
|
2
4
|
// the noun should be one of the other properties in the object that's
|
|
3
5
|
// being dispatched
|
|
@@ -16,17 +18,15 @@ export const activateKeypad = () => {
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Configure the keypad with the provided configuration parameters.
|
|
19
|
-
*
|
|
20
|
-
* See: `prop-types.js#keypadConfigurationPropType`.
|
|
21
21
|
*/
|
|
22
|
-
export const configureKeypad = (configuration) => {
|
|
22
|
+
export const configureKeypad = (configuration: KeypadConfiguration) => {
|
|
23
23
|
return {
|
|
24
24
|
type: "ConfigureKeypad",
|
|
25
25
|
configuration,
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const setPageSize = (pageWidthPx, pageHeightPx) => {
|
|
29
|
+
export const setPageSize = (pageWidthPx: number, pageHeightPx: number) => {
|
|
30
30
|
return {
|
|
31
31
|
type: "SetPageSize",
|
|
32
32
|
pageWidthPx,
|
|
@@ -42,7 +42,7 @@ export const removeEcho = (animationId) => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
// Input-related actions.
|
|
45
|
-
export const setKeyHandler = (keyHandler) => {
|
|
45
|
+
export const setKeyHandler = (keyHandler: KeyHandler) => {
|
|
46
46
|
return {
|
|
47
47
|
type: "SetKeyHandler",
|
|
48
48
|
keyHandler,
|
package/src/components/__tests__/{gesture-state-machine_test.js → gesture-state-machine.test.ts}
RENAMED
|
@@ -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
|
-
|
|
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
|
|