@khanacademy/math-input 15.0.1 → 16.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 +17 -0
- package/dist/components/aphrodite-css-transition-group/transition-child.d.ts +11 -8
- package/dist/components/keypad/index.d.ts +1 -1
- package/dist/components/keypad/mobile-keypad-internals.d.ts +49 -0
- package/dist/components/keypad/mobile-keypad.d.ts +4 -48
- package/dist/es/index.js +168 -4740
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +166 -4722
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
- package/src/components/__tests__/integration.test.tsx +2 -3
- package/src/components/keypad/__tests__/mobile-keypad.test.tsx +8 -8
- package/src/components/keypad/index.tsx +1 -1
- package/src/components/keypad/mobile-keypad-internals.tsx +240 -0
- package/src/components/keypad/mobile-keypad.tsx +21 -234
- package/src/full-mobile-input.stories.tsx +0 -1
- package/src/index.ts +1 -1
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/keypad-legacy/compute-layout-parameters.d.ts +0 -28
- package/dist/components/keypad-legacy/corner-decal.d.ts +0 -12
- package/dist/components/keypad-legacy/echo-manager.d.ts +0 -17
- package/dist/components/keypad-legacy/empty-keypad-button.d.ts +0 -13
- package/dist/components/keypad-legacy/expression-keypad.d.ts +0 -21
- package/dist/components/keypad-legacy/fraction-keypad.d.ts +0 -21
- package/dist/components/keypad-legacy/gesture-manager.d.ts +0 -86
- package/dist/components/keypad-legacy/gesture-state-machine.d.ts +0 -105
- package/dist/components/keypad-legacy/icon.d.ts +0 -15
- package/dist/components/keypad-legacy/index.d.ts +0 -1
- package/dist/components/keypad-legacy/keypad-button.d.ts +0 -53
- package/dist/components/keypad-legacy/keypad-container.d.ts +0 -41
- package/dist/components/keypad-legacy/keypad.d.ts +0 -31
- package/dist/components/keypad-legacy/many-keypad-button.d.ts +0 -15
- package/dist/components/keypad-legacy/math-icon.d.ts +0 -16
- package/dist/components/keypad-legacy/multi-symbol-grid.d.ts +0 -14
- package/dist/components/keypad-legacy/multi-symbol-popover.d.ts +0 -12
- package/dist/components/keypad-legacy/navigation-pad.d.ts +0 -14
- package/dist/components/keypad-legacy/node-manager.d.ts +0 -49
- package/dist/components/keypad-legacy/popover-manager.d.ts +0 -13
- package/dist/components/keypad-legacy/popover-state-machine.d.ts +0 -68
- package/dist/components/keypad-legacy/provided-keypad.d.ts +0 -28
- package/dist/components/keypad-legacy/store/actions.d.ts +0 -55
- package/dist/components/keypad-legacy/store/echo-reducer.d.ts +0 -4
- package/dist/components/keypad-legacy/store/index.d.ts +0 -9
- package/dist/components/keypad-legacy/store/input-reducer.d.ts +0 -4
- package/dist/components/keypad-legacy/store/keypad-reducer.d.ts +0 -4
- package/dist/components/keypad-legacy/store/layout-reducer.d.ts +0 -4
- package/dist/components/keypad-legacy/store/shared.d.ts +0 -7
- package/dist/components/keypad-legacy/store/types.d.ts +0 -47
- package/dist/components/keypad-legacy/styles.d.ts +0 -5
- package/dist/components/keypad-legacy/svg-icon.d.ts +0 -12
- package/dist/components/keypad-legacy/text-icon.d.ts +0 -13
- package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +0 -37
- package/dist/components/keypad-legacy/two-page-keypad.d.ts +0 -21
- package/dist/components/keypad-legacy/z-indexes.d.ts +0 -7
- package/dist/components/keypad-switch.d.ts +0 -12
- package/src/components/keypad-legacy/__tests__/gesture-state-machine.test.ts +0 -441
- package/src/components/keypad-legacy/__tests__/node-manager.test.ts +0 -89
- package/src/components/keypad-legacy/__tests__/two-page-keypad.test.tsx +0 -38
- package/src/components/keypad-legacy/compute-layout-parameters.ts +0 -205
- package/src/components/keypad-legacy/corner-decal.tsx +0 -56
- package/src/components/keypad-legacy/echo-manager.tsx +0 -152
- package/src/components/keypad-legacy/empty-keypad-button.tsx +0 -58
- package/src/components/keypad-legacy/expression-keypad.tsx +0 -315
- package/src/components/keypad-legacy/fraction-keypad.tsx +0 -180
- package/src/components/keypad-legacy/gesture-manager.ts +0 -255
- package/src/components/keypad-legacy/gesture-state-machine.ts +0 -329
- package/src/components/keypad-legacy/icon.tsx +0 -72
- package/src/components/keypad-legacy/iconography/arrow.js +0 -22
- package/src/components/keypad-legacy/iconography/backspace.js +0 -29
- package/src/components/keypad-legacy/iconography/cdot.js +0 -29
- package/src/components/keypad-legacy/iconography/cos.js +0 -30
- package/src/components/keypad-legacy/iconography/cube-root.js +0 -36
- package/src/components/keypad-legacy/iconography/dismiss.js +0 -25
- package/src/components/keypad-legacy/iconography/divide.js +0 -34
- package/src/components/keypad-legacy/iconography/down.js +0 -16
- package/src/components/keypad-legacy/iconography/equal.js +0 -33
- package/src/components/keypad-legacy/iconography/exp-2.js +0 -29
- package/src/components/keypad-legacy/iconography/exp-3.js +0 -29
- package/src/components/keypad-legacy/iconography/exp.js +0 -29
- package/src/components/keypad-legacy/iconography/frac.js +0 -44
- package/src/components/keypad-legacy/iconography/geq.js +0 -33
- package/src/components/keypad-legacy/iconography/gt.js +0 -33
- package/src/components/keypad-legacy/iconography/index.js +0 -45
- package/src/components/keypad-legacy/iconography/jump-into-numerator.js +0 -41
- package/src/components/keypad-legacy/iconography/jump-out-base.js +0 -30
- package/src/components/keypad-legacy/iconography/jump-out-denominator.js +0 -41
- package/src/components/keypad-legacy/iconography/jump-out-exponent.js +0 -30
- package/src/components/keypad-legacy/iconography/jump-out-numerator.js +0 -41
- package/src/components/keypad-legacy/iconography/jump-out-parentheses.js +0 -33
- package/src/components/keypad-legacy/iconography/left-paren.js +0 -33
- package/src/components/keypad-legacy/iconography/left.js +0 -16
- package/src/components/keypad-legacy/iconography/leq.js +0 -33
- package/src/components/keypad-legacy/iconography/ln.js +0 -29
- package/src/components/keypad-legacy/iconography/log-n.js +0 -29
- package/src/components/keypad-legacy/iconography/log.js +0 -29
- package/src/components/keypad-legacy/iconography/lt.js +0 -33
- package/src/components/keypad-legacy/iconography/minus.js +0 -32
- package/src/components/keypad-legacy/iconography/neq.js +0 -33
- package/src/components/keypad-legacy/iconography/parens.js +0 -33
- package/src/components/keypad-legacy/iconography/percent.js +0 -49
- package/src/components/keypad-legacy/iconography/period.js +0 -26
- package/src/components/keypad-legacy/iconography/plus.js +0 -32
- package/src/components/keypad-legacy/iconography/radical.js +0 -36
- package/src/components/keypad-legacy/iconography/right-paren.js +0 -33
- package/src/components/keypad-legacy/iconography/right.js +0 -16
- package/src/components/keypad-legacy/iconography/sin.js +0 -30
- package/src/components/keypad-legacy/iconography/sqrt.js +0 -32
- package/src/components/keypad-legacy/iconography/tan.js +0 -30
- package/src/components/keypad-legacy/iconography/times.js +0 -33
- package/src/components/keypad-legacy/iconography/up.js +0 -16
- package/src/components/keypad-legacy/index.ts +0 -1
- package/src/components/keypad-legacy/keypad-button.tsx +0 -368
- package/src/components/keypad-legacy/keypad-container.tsx +0 -358
- package/src/components/keypad-legacy/keypad.tsx +0 -162
- package/src/components/keypad-legacy/many-keypad-button.tsx +0 -54
- package/src/components/keypad-legacy/math-icon.tsx +0 -66
- package/src/components/keypad-legacy/multi-symbol-grid.tsx +0 -182
- package/src/components/keypad-legacy/multi-symbol-popover.tsx +0 -58
- package/src/components/keypad-legacy/navigation-pad.tsx +0 -140
- package/src/components/keypad-legacy/node-manager.ts +0 -133
- package/src/components/keypad-legacy/popover-manager.tsx +0 -73
- package/src/components/keypad-legacy/popover-state-machine.ts +0 -184
- package/src/components/keypad-legacy/provided-keypad.tsx +0 -136
- package/src/components/keypad-legacy/store/actions.ts +0 -155
- package/src/components/keypad-legacy/store/echo-reducer.ts +0 -57
- package/src/components/keypad-legacy/store/index.ts +0 -110
- package/src/components/keypad-legacy/store/input-reducer.ts +0 -55
- package/src/components/keypad-legacy/store/keypad-reducer.ts +0 -58
- package/src/components/keypad-legacy/store/layout-reducer.test.ts +0 -171
- package/src/components/keypad-legacy/store/layout-reducer.ts +0 -129
- package/src/components/keypad-legacy/store/shared.ts +0 -12
- package/src/components/keypad-legacy/store/types.ts +0 -78
- package/src/components/keypad-legacy/styles.ts +0 -38
- package/src/components/keypad-legacy/svg-icon.tsx +0 -24
- package/src/components/keypad-legacy/text-icon.tsx +0 -53
- package/src/components/keypad-legacy/touchable-keypad-button.tsx +0 -163
- package/src/components/keypad-legacy/two-page-keypad.tsx +0 -115
- package/src/components/keypad-legacy/z-indexes.ts +0 -8
- package/src/components/keypad-switch.tsx +0 -42
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import KeyConfigs from "../../../data/key-configs";
|
|
2
|
-
|
|
3
|
-
import {defaultKeypadType} from "./shared";
|
|
4
|
-
|
|
5
|
-
import type {Action} from "./actions";
|
|
6
|
-
import type {KeypadState} from "./types";
|
|
7
|
-
|
|
8
|
-
const initialKeypadState = {
|
|
9
|
-
extraKeys: ["x", "y", "THETA", "PI"] as const,
|
|
10
|
-
keypadType: defaultKeypadType,
|
|
11
|
-
active: false,
|
|
12
|
-
} as const;
|
|
13
|
-
|
|
14
|
-
const keypadReducer = function (
|
|
15
|
-
state: KeypadState = initialKeypadState,
|
|
16
|
-
action: Action,
|
|
17
|
-
): KeypadState {
|
|
18
|
-
switch (action.type) {
|
|
19
|
-
case "DismissKeypad":
|
|
20
|
-
return {
|
|
21
|
-
...state,
|
|
22
|
-
active: false,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
case "ActivateKeypad":
|
|
26
|
-
return {
|
|
27
|
-
...state,
|
|
28
|
-
active: true,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
case "ConfigureKeypad":
|
|
32
|
-
return {
|
|
33
|
-
...state,
|
|
34
|
-
// Default `extraKeys` to the empty array.
|
|
35
|
-
extraKeys: [],
|
|
36
|
-
...action.configuration,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
case "PressKey":
|
|
40
|
-
const keyConfig = KeyConfigs[action.key];
|
|
41
|
-
// NOTE(charlie): Our keypad system operates by triggering key
|
|
42
|
-
// presses with key IDs in a dumb manner, such that the keys
|
|
43
|
-
// don't know what they can do--instead, the store is
|
|
44
|
-
// responsible for interpreting key presses and triggering the
|
|
45
|
-
// right actions when they occur. Hence, we figure off a
|
|
46
|
-
// dismissal here rather than dispatching a dismiss action in
|
|
47
|
-
// the first place.
|
|
48
|
-
if (keyConfig.id === "DISMISS") {
|
|
49
|
-
return keypadReducer(state, {type: "DismissKeypad"});
|
|
50
|
-
}
|
|
51
|
-
return state;
|
|
52
|
-
|
|
53
|
-
default:
|
|
54
|
-
return state;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default keypadReducer;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import {KeypadType} from "../../../enums";
|
|
2
|
-
|
|
3
|
-
import {configureKeypad, setPageSize} from "./actions";
|
|
4
|
-
import layoutReducer from "./layout-reducer";
|
|
5
|
-
|
|
6
|
-
function initState() {
|
|
7
|
-
// This is just simulating the Redux action that initializes state
|
|
8
|
-
// @ts-expect-error TS2345
|
|
9
|
-
let state = layoutReducer(undefined, {type: "@redux-init"});
|
|
10
|
-
state = layoutReducer(
|
|
11
|
-
state,
|
|
12
|
-
configureKeypad({keypadType: KeypadType.EXPRESSION}),
|
|
13
|
-
);
|
|
14
|
-
return state;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe("layout reducer", () => {
|
|
18
|
-
it("enables pagination on small screens portrait (iPhone)", () => {
|
|
19
|
-
// Arrange
|
|
20
|
-
let state = initState();
|
|
21
|
-
|
|
22
|
-
// Act
|
|
23
|
-
state = layoutReducer(state, setPageSize(375, 812, 375, 812));
|
|
24
|
-
|
|
25
|
-
// Assert
|
|
26
|
-
expect(state.paginationEnabled).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("does not enable navigation pad on small screens portrait (iPhone)", () => {
|
|
30
|
-
// Arrange
|
|
31
|
-
let state = initState();
|
|
32
|
-
|
|
33
|
-
// Act
|
|
34
|
-
state = layoutReducer(state, setPageSize(375, 812, 375, 812));
|
|
35
|
-
|
|
36
|
-
// Assert
|
|
37
|
-
expect(state.navigationPadEnabled).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("does not enable pagination on medium screens portrait (iPad Mini)", () => {
|
|
41
|
-
// Arrange
|
|
42
|
-
let state = initState();
|
|
43
|
-
|
|
44
|
-
// Act
|
|
45
|
-
state = layoutReducer(state, setPageSize(768, 1024, 768, 1024));
|
|
46
|
-
|
|
47
|
-
// Assert
|
|
48
|
-
expect(state.paginationEnabled).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("does not enable navigation pad on medium screens portrait (iPad Mini)", () => {
|
|
52
|
-
// Arrange
|
|
53
|
-
let state = initState();
|
|
54
|
-
|
|
55
|
-
// Act
|
|
56
|
-
state = layoutReducer(state, setPageSize(768, 1024, 768, 1024));
|
|
57
|
-
|
|
58
|
-
// Assert
|
|
59
|
-
expect(state.navigationPadEnabled).toBe(false);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("does not enable pagination on large screens portrait (iPad)", () => {
|
|
63
|
-
// Arrange
|
|
64
|
-
let state = initState();
|
|
65
|
-
|
|
66
|
-
// Act
|
|
67
|
-
state = layoutReducer(state, setPageSize(810, 1080, 810, 1080));
|
|
68
|
-
|
|
69
|
-
// Assert
|
|
70
|
-
expect(state.paginationEnabled).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("does enable navigation pad on large screens portrait (iPad)", () => {
|
|
74
|
-
// Arrange
|
|
75
|
-
let state = initState();
|
|
76
|
-
|
|
77
|
-
// Act
|
|
78
|
-
state = layoutReducer(state, setPageSize(810, 1080, 810, 1080));
|
|
79
|
-
|
|
80
|
-
// Assert
|
|
81
|
-
expect(state.navigationPadEnabled).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("does not enable pagination on small screens landscape (iPhone)", () => {
|
|
85
|
-
// Arrange
|
|
86
|
-
let state = initState();
|
|
87
|
-
|
|
88
|
-
// Act
|
|
89
|
-
state = layoutReducer(state, setPageSize(812, 375, 812, 375));
|
|
90
|
-
|
|
91
|
-
// Assert
|
|
92
|
-
expect(state.paginationEnabled).toBe(false);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("does enable navigation pad on small screens landscape (iPhone)", () => {
|
|
96
|
-
// Arrange
|
|
97
|
-
let state = initState();
|
|
98
|
-
|
|
99
|
-
// Act
|
|
100
|
-
state = layoutReducer(state, setPageSize(812, 375, 812, 375));
|
|
101
|
-
|
|
102
|
-
// Assert
|
|
103
|
-
expect(state.navigationPadEnabled).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("does not enable pagination on medium screens landscape (iPad Mini)", () => {
|
|
107
|
-
// Arrange
|
|
108
|
-
let state = initState();
|
|
109
|
-
|
|
110
|
-
// Act
|
|
111
|
-
state = layoutReducer(state, setPageSize(1024, 768, 1024, 768));
|
|
112
|
-
|
|
113
|
-
// Assert
|
|
114
|
-
expect(state.paginationEnabled).toBe(false);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("does enable navigation pad on medium screens landscape (iPad Mini)", () => {
|
|
118
|
-
// Arrange
|
|
119
|
-
let state = initState();
|
|
120
|
-
|
|
121
|
-
// Act
|
|
122
|
-
state = layoutReducer(state, setPageSize(1024, 768, 1024, 768));
|
|
123
|
-
|
|
124
|
-
// Assert
|
|
125
|
-
expect(state.navigationPadEnabled).toBe(true);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("does not enable pagination on large screens landscape (iPad)", () => {
|
|
129
|
-
// Arrange
|
|
130
|
-
let state = initState();
|
|
131
|
-
|
|
132
|
-
// Act
|
|
133
|
-
state = layoutReducer(state, setPageSize(1080, 810, 1080, 810));
|
|
134
|
-
|
|
135
|
-
// Assert
|
|
136
|
-
expect(state.paginationEnabled).toBe(false);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("does enable navigation pad on large screens landscape (iPad)", () => {
|
|
140
|
-
// Arrange
|
|
141
|
-
let state = initState();
|
|
142
|
-
|
|
143
|
-
// Act
|
|
144
|
-
state = layoutReducer(state, setPageSize(1080, 810, 1080, 810));
|
|
145
|
-
|
|
146
|
-
// Assert
|
|
147
|
-
expect(state.navigationPadEnabled).toBe(true);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("does enable pagination in small containers on big screens", () => {
|
|
151
|
-
// Arrange
|
|
152
|
-
let state = initState();
|
|
153
|
-
|
|
154
|
-
// Act
|
|
155
|
-
state = layoutReducer(state, setPageSize(2000, 2000, 300, 300));
|
|
156
|
-
|
|
157
|
-
// Assert
|
|
158
|
-
expect(state.paginationEnabled).toBe(true);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("does not enable navigation in small containers on big screens", () => {
|
|
162
|
-
// Arrange
|
|
163
|
-
let state = initState();
|
|
164
|
-
|
|
165
|
-
// Act
|
|
166
|
-
state = layoutReducer(state, setPageSize(2000, 2000, 300, 300));
|
|
167
|
-
|
|
168
|
-
// Assert
|
|
169
|
-
expect(state.navigationPadEnabled).toBe(false);
|
|
170
|
-
});
|
|
171
|
-
});
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {DeviceOrientation, LayoutMode} from "../../../enums";
|
|
2
|
-
import {computeLayoutParameters} from "../compute-layout-parameters";
|
|
3
|
-
|
|
4
|
-
import {defaultKeypadType, keypadForType} from "./shared";
|
|
5
|
-
|
|
6
|
-
import type {Action} from "./actions";
|
|
7
|
-
import type {GridDimensions, LayoutState, WidthHeight} from "./types";
|
|
8
|
-
|
|
9
|
-
const expandedViewThreshold = 682;
|
|
10
|
-
const navigationViewThreshold = 800;
|
|
11
|
-
|
|
12
|
-
const initialLayoutState: LayoutState = {
|
|
13
|
-
gridDimensions: {
|
|
14
|
-
numRows: keypadForType[defaultKeypadType].rows,
|
|
15
|
-
numColumns: keypadForType[defaultKeypadType].columns,
|
|
16
|
-
numMaxVisibleRows: keypadForType[defaultKeypadType].maxVisibleRows,
|
|
17
|
-
numPages: keypadForType[defaultKeypadType].numPages,
|
|
18
|
-
},
|
|
19
|
-
buttonDimensions: {
|
|
20
|
-
width: 48,
|
|
21
|
-
height: 48,
|
|
22
|
-
},
|
|
23
|
-
pageDimensions: {
|
|
24
|
-
width: 0,
|
|
25
|
-
height: 0,
|
|
26
|
-
},
|
|
27
|
-
containerDimensions: {
|
|
28
|
-
width: 0,
|
|
29
|
-
height: 0,
|
|
30
|
-
},
|
|
31
|
-
layoutMode: LayoutMode.FULLSCREEN,
|
|
32
|
-
paginationEnabled: false,
|
|
33
|
-
navigationPadEnabled: false,
|
|
34
|
-
} as const;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Compute the additional layout state based on the provided page and grid
|
|
38
|
-
* dimensions.
|
|
39
|
-
*/
|
|
40
|
-
const layoutParametersForDimensions = (
|
|
41
|
-
pageDimensions: WidthHeight,
|
|
42
|
-
containerDimensions: WidthHeight,
|
|
43
|
-
gridDimensions: GridDimensions,
|
|
44
|
-
) => {
|
|
45
|
-
// Determine the device type and orientation.
|
|
46
|
-
const deviceOrientation =
|
|
47
|
-
containerDimensions.width > containerDimensions.height
|
|
48
|
-
? DeviceOrientation.LANDSCAPE
|
|
49
|
-
: DeviceOrientation.PORTRAIT;
|
|
50
|
-
|
|
51
|
-
// Using that information, make some decisions (or assumptions)
|
|
52
|
-
// about the resulting layout.
|
|
53
|
-
const navigationPadEnabled =
|
|
54
|
-
containerDimensions.width > navigationViewThreshold;
|
|
55
|
-
const paginationEnabled = containerDimensions.width < expandedViewThreshold;
|
|
56
|
-
const toolbarEnabled = true;
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
...computeLayoutParameters(
|
|
60
|
-
gridDimensions,
|
|
61
|
-
pageDimensions,
|
|
62
|
-
containerDimensions,
|
|
63
|
-
deviceOrientation,
|
|
64
|
-
navigationPadEnabled,
|
|
65
|
-
paginationEnabled,
|
|
66
|
-
toolbarEnabled,
|
|
67
|
-
),
|
|
68
|
-
// Pass along some of the layout information, so that other
|
|
69
|
-
// components in the heirarchy can adapt appropriately.
|
|
70
|
-
navigationPadEnabled,
|
|
71
|
-
paginationEnabled,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const layoutReducer = function (
|
|
76
|
-
state: LayoutState = initialLayoutState,
|
|
77
|
-
action: Action,
|
|
78
|
-
): LayoutState {
|
|
79
|
-
switch (action.type) {
|
|
80
|
-
case "ConfigureKeypad":
|
|
81
|
-
const {keypadType} = action.configuration;
|
|
82
|
-
const gridDimensions = {
|
|
83
|
-
numRows: keypadForType[keypadType].rows,
|
|
84
|
-
numColumns: keypadForType[keypadType].columns,
|
|
85
|
-
numMaxVisibleRows: keypadForType[keypadType].maxVisibleRows,
|
|
86
|
-
numPages: keypadForType[keypadType].numPages,
|
|
87
|
-
} as const;
|
|
88
|
-
|
|
89
|
-
const layoutParams = layoutParametersForDimensions(
|
|
90
|
-
state.pageDimensions,
|
|
91
|
-
state.containerDimensions,
|
|
92
|
-
gridDimensions,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
...state,
|
|
97
|
-
...layoutParams,
|
|
98
|
-
gridDimensions,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
case "SetPageSize":
|
|
102
|
-
const {pageWidth, pageHeight, containerWidth, containerHeight} =
|
|
103
|
-
action;
|
|
104
|
-
const pageDimensions = {
|
|
105
|
-
width: pageWidth,
|
|
106
|
-
height: pageHeight,
|
|
107
|
-
} as const;
|
|
108
|
-
const containerDimensions = {
|
|
109
|
-
width: containerWidth,
|
|
110
|
-
height: containerHeight,
|
|
111
|
-
} as const;
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
...state,
|
|
115
|
-
...layoutParametersForDimensions(
|
|
116
|
-
pageDimensions,
|
|
117
|
-
containerDimensions,
|
|
118
|
-
state.gridDimensions,
|
|
119
|
-
),
|
|
120
|
-
pageDimensions,
|
|
121
|
-
containerDimensions,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
default:
|
|
125
|
-
return state;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export default layoutReducer;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {KeypadType} from "../../../enums";
|
|
2
|
-
import {expressionKeypadLayout} from "../expression-keypad";
|
|
3
|
-
import {fractionKeypadLayout} from "../fraction-keypad";
|
|
4
|
-
|
|
5
|
-
const defaultKeypadType = KeypadType.EXPRESSION;
|
|
6
|
-
|
|
7
|
-
const keypadForType = {
|
|
8
|
-
[KeypadType.FRACTION]: fractionKeypadLayout,
|
|
9
|
-
[KeypadType.EXPRESSION]: expressionKeypadLayout,
|
|
10
|
-
} as const;
|
|
11
|
-
|
|
12
|
-
export {keypadForType, defaultKeypadType};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type Key from "../../../data/keys";
|
|
2
|
-
import type {LayoutMode, KeypadType} from "../../../enums";
|
|
3
|
-
import type {Cursor, KeyHandler, Popover, Echo} from "../../../types";
|
|
4
|
-
import type GestureManager from "../gesture-manager";
|
|
5
|
-
|
|
6
|
-
// Interaction between keypad and input
|
|
7
|
-
export interface InputState {
|
|
8
|
-
// This is the callback to tell the input
|
|
9
|
-
// that a key was pressed. It returns information
|
|
10
|
-
// about where the cursor is
|
|
11
|
-
keyHandler: KeyHandler | null;
|
|
12
|
-
// Information about where the cursor is, which we use to
|
|
13
|
-
// conditionally render buttons to help navigate
|
|
14
|
-
// where the cursor should go next
|
|
15
|
-
cursor: Cursor | undefined;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Managing high-level keypad state
|
|
19
|
-
export interface KeypadState {
|
|
20
|
-
// Additional symbols that get grouped in a
|
|
21
|
-
// ManyKeypadButton; for variables and
|
|
22
|
-
// special symbols (pi)
|
|
23
|
-
extraKeys: ReadonlyArray<string>;
|
|
24
|
-
// Keypad variations (Fraction vs Expression)
|
|
25
|
-
keypadType: KeypadType;
|
|
26
|
-
// Whether or not to show the keypad
|
|
27
|
-
active: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Handles things like:
|
|
31
|
-
// long-press: to open multikey popover
|
|
32
|
-
// swipe: for pagination
|
|
33
|
-
// press: regular pushing of a button
|
|
34
|
-
export interface GestureState {
|
|
35
|
-
// The current multikey popover?
|
|
36
|
-
popover: Popover | null;
|
|
37
|
-
// ?? Maybe which key is currently focused?
|
|
38
|
-
focus: Key | null;
|
|
39
|
-
// Complex object that interprets touches as actions
|
|
40
|
-
gestureManager: GestureManager;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Manages the animations for pressing keys
|
|
44
|
-
export interface EchoState {
|
|
45
|
-
// Which echoes are in the process of animating
|
|
46
|
-
echoes: ReadonlyArray<Echo>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type GridDimensions = {
|
|
50
|
-
numRows: number;
|
|
51
|
-
numColumns: number;
|
|
52
|
-
numMaxVisibleRows: number;
|
|
53
|
-
numPages: number;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export type WidthHeight = {
|
|
57
|
-
width: number;
|
|
58
|
-
height: number;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// Layout (size, where to put buttons, etc)
|
|
62
|
-
export interface LayoutState {
|
|
63
|
-
gridDimensions: GridDimensions;
|
|
64
|
-
buttonDimensions: WidthHeight;
|
|
65
|
-
containerDimensions: WidthHeight;
|
|
66
|
-
pageDimensions: WidthHeight;
|
|
67
|
-
layoutMode: LayoutMode;
|
|
68
|
-
paginationEnabled: boolean;
|
|
69
|
-
navigationPadEnabled: boolean;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface State {
|
|
73
|
-
input: InputState;
|
|
74
|
-
keypad: KeypadState;
|
|
75
|
-
gestures: GestureState;
|
|
76
|
-
echoes: EchoState;
|
|
77
|
-
layout: LayoutState;
|
|
78
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common styles shared across components.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {StyleSheet} from "aphrodite";
|
|
6
|
-
|
|
7
|
-
import {compactKeypadBorderRadiusPx} from "../common-style";
|
|
8
|
-
|
|
9
|
-
export default StyleSheet.create({
|
|
10
|
-
row: {
|
|
11
|
-
flexDirection: "row",
|
|
12
|
-
},
|
|
13
|
-
column: {
|
|
14
|
-
flexDirection: "column",
|
|
15
|
-
},
|
|
16
|
-
oneColumn: {
|
|
17
|
-
flexGrow: 1,
|
|
18
|
-
},
|
|
19
|
-
fullWidth: {
|
|
20
|
-
width: "100%",
|
|
21
|
-
},
|
|
22
|
-
stretch: {
|
|
23
|
-
alignItems: "stretch",
|
|
24
|
-
},
|
|
25
|
-
centered: {
|
|
26
|
-
justifyContent: "center",
|
|
27
|
-
alignItems: "center",
|
|
28
|
-
},
|
|
29
|
-
centeredText: {
|
|
30
|
-
textAlign: "center",
|
|
31
|
-
},
|
|
32
|
-
roundedTopLeft: {
|
|
33
|
-
borderTopLeftRadius: compactKeypadBorderRadiusPx,
|
|
34
|
-
},
|
|
35
|
-
roundedTopRight: {
|
|
36
|
-
borderTopRightRadius: compactKeypadBorderRadiusPx,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A component that renders a single SVG icon.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
|
|
7
|
-
import * as Iconography from "./iconography/index";
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
color: string;
|
|
11
|
-
name: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
class SvgIcon extends React.Component<Props> {
|
|
15
|
-
render() {
|
|
16
|
-
const {color, name} = this.props;
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line import/namespace
|
|
19
|
-
const SvgForName = Iconography[name];
|
|
20
|
-
return <SvgForName color={color} />;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default SvgIcon;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A component that renders a text-based icon.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {StyleSheet} from "aphrodite";
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
|
|
8
|
-
import {View, Text} from "../../fake-react-native-web/index";
|
|
9
|
-
import {iconSizeHeightPx, iconSizeWidthPx} from "../common-style";
|
|
10
|
-
|
|
11
|
-
import Styles from "./styles";
|
|
12
|
-
|
|
13
|
-
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
14
|
-
|
|
15
|
-
const {row, centered} = Styles;
|
|
16
|
-
|
|
17
|
-
type Props = {
|
|
18
|
-
character: string;
|
|
19
|
-
style?: StyleType;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
class TextIcon extends React.Component<Props> {
|
|
23
|
-
render() {
|
|
24
|
-
const {character, style} = this.props;
|
|
25
|
-
|
|
26
|
-
const containerStyle = [
|
|
27
|
-
row,
|
|
28
|
-
centered,
|
|
29
|
-
styles.size,
|
|
30
|
-
styles.base,
|
|
31
|
-
...(Array.isArray(style) ? style : [style]),
|
|
32
|
-
];
|
|
33
|
-
return (
|
|
34
|
-
<View style={containerStyle}>
|
|
35
|
-
<Text>{character}</Text>
|
|
36
|
-
</View>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const styles = StyleSheet.create({
|
|
42
|
-
size: {
|
|
43
|
-
height: iconSizeHeightPx,
|
|
44
|
-
width: iconSizeWidthPx,
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
base: {
|
|
48
|
-
fontFamily: "'Lato', sans-serif",
|
|
49
|
-
fontSize: 25,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export default TextIcon;
|