@khanacademy/math-input 2.0.0 → 4.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 +55 -0
- package/dist/components/input/__tests__/test-math-wrapper.d.ts +1 -1
- package/dist/components/input/__tests__/test-math-wrapper.js.flow +1 -1
- package/dist/components/input/key-handlers/handle-arrow.d.ts +3 -0
- package/dist/components/input/key-handlers/handle-arrow.js.flow +12 -0
- package/dist/components/input/key-handlers/handle-backspace.d.ts +7 -0
- package/dist/components/input/key-handlers/handle-backspace.js.flow +14 -0
- package/dist/components/input/key-handlers/handle-exponent.d.ts +3 -0
- package/dist/components/input/key-handlers/handle-exponent.js.flow +12 -0
- package/dist/components/input/key-handlers/handle-jump-out.d.ts +7 -0
- package/dist/components/input/key-handlers/handle-jump-out.js.flow +14 -0
- package/dist/components/input/math-input.d.ts +1 -1
- package/dist/components/input/math-input.js.flow +1 -1
- package/dist/components/input/math-wrapper.d.ts +7 -78
- package/dist/components/input/math-wrapper.js.flow +16 -78
- package/dist/components/input/mathquill-helpers.d.ts +46 -0
- package/dist/components/input/mathquill-helpers.js.flow +56 -0
- package/dist/components/input/mathquill-instance.d.ts +3 -0
- package/dist/components/input/mathquill-instance.js.flow +9 -0
- package/dist/components/input/mathquill-types.d.ts +25 -0
- package/dist/components/input/mathquill-types.js.flow +34 -0
- package/dist/components/key-translator.d.ts +4 -0
- package/dist/components/key-translator.js.flow +10 -0
- package/dist/components/keypad/button-assets.d.ts +2 -2
- package/dist/components/keypad/button-assets.js.flow +2 -2
- package/dist/components/keypad/button.d.ts +1 -2
- package/dist/components/keypad/button.js.flow +1 -1
- package/dist/components/keypad/{pre-algebra-page.d.ts → geometry-page/index.d.ts} +1 -1
- package/dist/components/keypad/{pre-algebra-page.js.flow → geometry-page/index.js.flow} +1 -1
- package/dist/components/keypad/index.d.ts +5 -4
- package/dist/components/keypad/index.js.flow +9 -4
- package/dist/components/keypad/keypad-page-items.d.ts +9 -3
- package/dist/components/keypad/keypad-page-items.js.flow +9 -3
- package/dist/components/keypad/{numeric-input-page.d.ts → numbers-page/index.d.ts} +3 -2
- package/dist/components/keypad/numbers-page/index.js.flow +17 -0
- package/dist/components/keypad/numbers-page/types.d.ts +4 -0
- package/dist/components/keypad/numbers-page/types.js.flow +10 -0
- package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +7 -0
- package/dist/components/keypad/{numeric-input-page.js.flow → operators-page/advanced-relations-buttons.js.flow} +3 -4
- package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +7 -0
- package/dist/components/keypad/{trigonometry-page.js.flow → operators-page/basic-relations-buttons.js.flow} +3 -6
- package/dist/components/keypad/operators-page/index.d.ts +9 -0
- package/dist/components/keypad/operators-page/index.js.flow +17 -0
- package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +7 -0
- package/dist/components/keypad/operators-page/logarithms-buttons.js.flow +12 -0
- package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +7 -0
- package/dist/components/keypad/operators-page/pre-algebra-buttons.js.flow +12 -0
- package/dist/components/keypad/operators-page/types.d.ts +6 -0
- package/dist/components/keypad/operators-page/types.js.flow +12 -0
- package/dist/components/{compute-layout-parameters.d.ts → keypad-legacy/compute-layout-parameters.d.ts} +1 -1
- package/dist/components/{compute-layout-parameters.js.flow → keypad-legacy/compute-layout-parameters.js.flow} +1 -1
- package/dist/components/{echo-manager.d.ts → keypad-legacy/echo-manager.d.ts} +2 -11
- package/dist/components/{echo-manager.js.flow → keypad-legacy/echo-manager.js.flow} +2 -11
- package/dist/components/{expression-keypad.d.ts → keypad-legacy/expression-keypad.d.ts} +3 -4
- package/dist/components/{expression-keypad.js.flow → keypad-legacy/expression-keypad.js.flow} +3 -4
- package/dist/components/{fraction-keypad.d.ts → keypad-legacy/fraction-keypad.d.ts} +2 -2
- package/dist/components/{fraction-keypad.js.flow → keypad-legacy/fraction-keypad.js.flow} +2 -2
- package/dist/components/{gesture-manager.d.ts → keypad-legacy/gesture-manager.d.ts} +22 -10
- package/dist/components/{gesture-manager.js.flow → keypad-legacy/gesture-manager.js.flow} +28 -13
- package/dist/components/{gesture-state-machine.d.ts → keypad-legacy/gesture-state-machine.d.ts} +9 -9
- package/dist/components/{gesture-state-machine.js.flow → keypad-legacy/gesture-state-machine.js.flow} +10 -10
- package/dist/components/{icon.d.ts → keypad-legacy/icon.d.ts} +1 -1
- package/dist/components/{icon.js.flow → keypad-legacy/icon.js.flow} +1 -1
- package/dist/components/{keypad-button.d.ts → keypad-legacy/keypad-button.d.ts} +6 -6
- package/dist/components/{keypad-button.js.flow → keypad-legacy/keypad-button.js.flow} +7 -7
- package/dist/components/{keypad-container.d.ts → keypad-legacy/keypad-container.d.ts} +2 -2
- package/dist/components/{keypad-container.js.flow → keypad-legacy/keypad-container.js.flow} +3 -3
- package/dist/components/{keypad.d.ts → keypad-legacy/keypad.d.ts} +3 -3
- package/dist/components/{keypad.js.flow → keypad-legacy/keypad.js.flow} +3 -3
- package/dist/components/{multi-symbol-grid.d.ts → keypad-legacy/multi-symbol-grid.d.ts} +1 -1
- package/dist/components/{multi-symbol-grid.js.flow → keypad-legacy/multi-symbol-grid.js.flow} +1 -1
- package/dist/components/{multi-symbol-popover.d.ts → keypad-legacy/multi-symbol-popover.d.ts} +1 -1
- package/dist/components/{multi-symbol-popover.js.flow → keypad-legacy/multi-symbol-popover.js.flow} +1 -1
- package/dist/components/{node-manager.d.ts → keypad-legacy/node-manager.d.ts} +3 -4
- package/dist/components/{node-manager.js.flow → keypad-legacy/node-manager.js.flow} +3 -5
- package/dist/components/{popover-manager.d.ts → keypad-legacy/popover-manager.d.ts} +1 -1
- package/dist/components/{popover-manager.js.flow → keypad-legacy/popover-manager.js.flow} +1 -1
- package/dist/components/{popover-state-machine.d.ts → keypad-legacy/popover-state-machine.d.ts} +1 -1
- package/dist/components/{popover-state-machine.js.flow → keypad-legacy/popover-state-machine.js.flow} +1 -1
- package/dist/components/{provided-keypad.d.ts → keypad-legacy/provided-keypad.d.ts} +1 -1
- package/dist/components/{provided-keypad.js.flow → keypad-legacy/provided-keypad.js.flow} +1 -1
- package/dist/{store → components/keypad-legacy/store}/actions.d.ts +6 -17
- package/dist/{store → components/keypad-legacy/store}/actions.js.flow +7 -22
- package/dist/{store → components/keypad-legacy/store}/index.d.ts +0 -1
- package/dist/{store → components/keypad-legacy/store}/index.js.flow +0 -1
- package/dist/components/keypad-legacy/store/shared.d.ts +7 -0
- package/dist/components/keypad-legacy/store/shared.js.flow +14 -0
- package/dist/{store → components/keypad-legacy/store}/types.d.ts +5 -15
- package/dist/{store → components/keypad-legacy/store}/types.js.flow +5 -15
- package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +37 -0
- package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +59 -0
- package/dist/components/{two-page-keypad.d.ts → keypad-legacy/two-page-keypad.d.ts} +0 -1
- package/dist/components/{two-page-keypad.js.flow → keypad-legacy/two-page-keypad.js.flow} +0 -1
- package/dist/data/key-configs.d.ts +4 -5
- package/dist/data/key-configs.js.flow +3 -6
- package/dist/data/keys.d.ts +2 -56
- package/dist/data/keys.js.flow +116 -57
- package/dist/enums.d.ts +2 -9
- package/dist/enums.js.flow +2 -11
- package/dist/es/index.js +6393 -5116
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +6868 -5330
- package/dist/index.js.flow +6 -3
- package/dist/index.js.map +1 -1
- package/dist/strings.js +26 -10
- package/dist/types.d.ts +19 -17
- package/dist/types.js.flow +28 -23
- package/package.json +1 -1
- package/src/components/input/__tests__/context-tracking.test.ts +43 -44
- package/src/components/input/__tests__/mathquill.test.ts +133 -135
- package/src/components/input/key-handlers/handle-arrow.ts +70 -0
- package/src/components/input/key-handlers/handle-backspace.ts +275 -0
- package/src/components/input/key-handlers/handle-exponent.ts +52 -0
- package/src/components/input/key-handlers/handle-jump-out.ts +103 -0
- package/src/components/input/math-input.tsx +12 -13
- package/src/components/input/math-wrapper.ts +88 -837
- package/src/components/input/mathquill-helpers.ts +268 -0
- package/src/components/input/mathquill-instance.ts +5 -0
- package/src/components/input/mathquill-types.ts +55 -0
- package/src/components/key-translator.ts +209 -0
- package/src/components/keypad/button-assets.tsx +452 -116
- package/src/components/keypad/button.stories.tsx +61 -13
- package/src/components/keypad/button.tsx +1 -1
- package/src/components/keypad/{trigonometry-page.tsx → geometry-page/index.tsx} +4 -5
- package/src/components/keypad/index.tsx +19 -14
- package/src/components/keypad/keypad-mathquill.stories.tsx +69 -0
- package/src/components/keypad/keypad-page-items.tsx +36 -22
- package/src/components/keypad/keypad-pages.stories.tsx +5 -5
- package/src/components/keypad/keypad.stories.tsx +75 -17
- package/src/components/keypad/{numeric-input-page.tsx → numbers-page/index.tsx} +47 -11
- package/src/components/keypad/numbers-page/types.ts +4 -0
- package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +32 -0
- package/src/components/keypad/operators-page/basic-relations-buttons.tsx +32 -0
- package/src/components/keypad/{pre-algebra-page.tsx → operators-page/index.tsx} +26 -30
- package/src/components/keypad/operators-page/logarithms-buttons.tsx +32 -0
- package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +36 -0
- package/src/components/keypad/operators-page/types.ts +6 -0
- package/src/components/{__tests__ → keypad-legacy/__tests__}/two-page-keypad.test.tsx +0 -2
- package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts} +2 -3
- package/src/components/{corner-decal.tsx → keypad-legacy/corner-decal.tsx} +2 -3
- package/src/components/{echo-manager.tsx → keypad-legacy/echo-manager.tsx} +8 -21
- package/src/components/{empty-keypad-button.tsx → keypad-legacy/empty-keypad-button.tsx} +8 -6
- package/src/components/{expression-keypad.tsx → keypad-legacy/expression-keypad.tsx} +8 -17
- package/src/components/{fraction-keypad.tsx → keypad-legacy/fraction-keypad.tsx} +6 -6
- package/src/components/{gesture-manager.ts → keypad-legacy/gesture-manager.ts} +34 -11
- package/src/components/{gesture-state-machine.ts → keypad-legacy/gesture-state-machine.ts} +14 -14
- package/src/components/{icon.tsx → keypad-legacy/icon.tsx} +3 -3
- package/src/components/{keypad-button.tsx → keypad-legacy/keypad-button.tsx} +26 -26
- package/src/components/{keypad-container.tsx → keypad-legacy/keypad-container.tsx} +6 -6
- package/src/components/{keypad.tsx → keypad-legacy/keypad.tsx} +5 -5
- package/src/components/{many-keypad-button.tsx → keypad-legacy/many-keypad-button.tsx} +13 -6
- package/src/components/{math-icon.tsx → keypad-legacy/math-icon.tsx} +2 -2
- package/src/components/{multi-symbol-grid.tsx → keypad-legacy/multi-symbol-grid.tsx} +4 -4
- package/src/components/{multi-symbol-popover.tsx → keypad-legacy/multi-symbol-popover.tsx} +3 -4
- package/src/components/{navigation-pad.tsx → keypad-legacy/navigation-pad.tsx} +5 -5
- package/src/components/{node-manager.ts → keypad-legacy/node-manager.ts} +2 -10
- package/src/components/{popover-manager.tsx → keypad-legacy/popover-manager.tsx} +2 -2
- package/src/components/{popover-state-machine.ts → keypad-legacy/popover-state-machine.ts} +1 -1
- package/src/components/{provided-keypad.tsx → keypad-legacy/provided-keypad.tsx} +4 -5
- package/src/{store → components/keypad-legacy/store}/actions.ts +7 -36
- package/src/{store → components/keypad-legacy/store}/echo-reducer.ts +3 -7
- package/src/{store → components/keypad-legacy/store}/index.ts +7 -20
- package/src/{store → components/keypad-legacy/store}/input-reducer.ts +4 -5
- package/src/{store → components/keypad-legacy/store}/keypad-reducer.ts +3 -4
- package/src/{store → components/keypad-legacy/store}/layout-reducer.ts +3 -3
- package/src/{store → components/keypad-legacy/store}/shared.ts +3 -3
- package/src/{store → components/keypad-legacy/store}/types.ts +15 -19
- package/src/components/{styles.ts → keypad-legacy/styles.ts} +1 -1
- package/src/components/{text-icon.tsx → keypad-legacy/text-icon.tsx} +2 -2
- package/src/components/{touchable-keypad-button.tsx → keypad-legacy/touchable-keypad-button.tsx} +35 -21
- package/src/components/{two-page-keypad.tsx → keypad-legacy/two-page-keypad.tsx} +5 -6
- package/src/components/tabbar/icons.tsx +0 -2
- package/src/data/key-configs.ts +751 -309
- package/src/data/keys.ts +118 -70
- package/src/enums.ts +10 -9
- package/src/index.ts +6 -3
- package/src/math-input.stories.tsx +3 -3
- package/src/types.ts +21 -16
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/keypad/trigonometry-page.d.ts +0 -8
- package/dist/components/touchable-keypad-button.d.ts +0 -30
- package/dist/components/touchable-keypad-button.js.flow +0 -35
- package/dist/components/velocity-tracker.d.ts +0 -48
- package/dist/components/velocity-tracker.js.flow +0 -54
- package/dist/store/pager-reducer.d.ts +0 -4
- package/dist/store/pager-reducer.js.flow +0 -13
- package/dist/store/shared.d.ts +0 -7
- package/dist/store/shared.js.flow +0 -14
- package/src/components/velocity-tracker.ts +0 -86
- package/src/store/pager-reducer.ts +0 -125
- /package/dist/components/{corner-decal.d.ts → keypad-legacy/corner-decal.d.ts} +0 -0
- /package/dist/components/{corner-decal.js.flow → keypad-legacy/corner-decal.js.flow} +0 -0
- /package/dist/components/{empty-keypad-button.d.ts → keypad-legacy/empty-keypad-button.d.ts} +0 -0
- /package/dist/components/{empty-keypad-button.js.flow → keypad-legacy/empty-keypad-button.js.flow} +0 -0
- /package/dist/components/{many-keypad-button.d.ts → keypad-legacy/many-keypad-button.d.ts} +0 -0
- /package/dist/components/{many-keypad-button.js.flow → keypad-legacy/many-keypad-button.js.flow} +0 -0
- /package/dist/components/{math-icon.d.ts → keypad-legacy/math-icon.d.ts} +0 -0
- /package/dist/components/{math-icon.js.flow → keypad-legacy/math-icon.js.flow} +0 -0
- /package/dist/components/{navigation-pad.d.ts → keypad-legacy/navigation-pad.d.ts} +0 -0
- /package/dist/components/{navigation-pad.js.flow → keypad-legacy/navigation-pad.js.flow} +0 -0
- /package/dist/{store → components/keypad-legacy/store}/echo-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/echo-reducer.js.flow +0 -0
- /package/dist/{store → components/keypad-legacy/store}/input-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/input-reducer.js.flow +0 -0
- /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/keypad-reducer.js.flow +0 -0
- /package/dist/{store → components/keypad-legacy/store}/layout-reducer.d.ts +0 -0
- /package/dist/{store → components/keypad-legacy/store}/layout-reducer.js.flow +0 -0
- /package/dist/components/{styles.d.ts → keypad-legacy/styles.d.ts} +0 -0
- /package/dist/components/{styles.js.flow → keypad-legacy/styles.js.flow} +0 -0
- /package/dist/components/{svg-icon.d.ts → keypad-legacy/svg-icon.d.ts} +0 -0
- /package/dist/components/{svg-icon.js.flow → keypad-legacy/svg-icon.js.flow} +0 -0
- /package/dist/components/{text-icon.d.ts → keypad-legacy/text-icon.d.ts} +0 -0
- /package/dist/components/{text-icon.js.flow → keypad-legacy/text-icon.js.flow} +0 -0
- /package/dist/components/{z-indexes.d.ts → keypad-legacy/z-indexes.d.ts} +0 -0
- /package/dist/components/{z-indexes.js.flow → keypad-legacy/z-indexes.js.flow} +0 -0
- /package/src/components/{__tests__ → keypad-legacy/__tests__}/gesture-state-machine.test.ts +0 -0
- /package/src/components/{__tests__ → keypad-legacy/__tests__}/node-manager.test.ts +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/arrow.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/backspace.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/cdot.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/cos.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/cube-root.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/dismiss.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/divide.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/down.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/equal.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/exp-2.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/exp-3.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/exp.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/frac.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/geq.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/gt.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/index.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-into-numerator.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-base.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-denominator.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-exponent.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-numerator.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/jump-out-parentheses.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/left-paren.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/left.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/leq.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/ln.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/log-n.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/log.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/lt.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/minus.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/neq.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/parens.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/percent.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/period.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/plus.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/radical.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/right-paren.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/right.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/sin.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/sqrt.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/tan.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/times.js +0 -0
- /package/src/components/{iconography → keypad-legacy/iconography}/up.js +0 -0
- /package/src/components/{svg-icon.tsx → keypad-legacy/svg-icon.tsx} +0 -0
- /package/src/components/{z-indexes.ts → keypad-legacy/z-indexes.ts} +0 -0
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import Keys from "
|
|
4
|
-
|
|
3
|
+
import Keys from "../../../data/key-configs";
|
|
5
4
|
import {
|
|
6
5
|
KeypadPageContainer,
|
|
7
6
|
SecondaryKeypadButton,
|
|
8
7
|
KeypadActionButton,
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
} from "../keypad-page-items";
|
|
9
|
+
|
|
10
|
+
import {AdvancedRelations} from "./advanced-relations-buttons";
|
|
11
|
+
import {BasicRelations} from "./basic-relations-buttons";
|
|
12
|
+
import {Logarithms} from "./logarithms-buttons";
|
|
13
|
+
import {PreAlgebra} from "./pre-algebra-buttons";
|
|
14
|
+
import {OperatorsButtonSets} from "./types";
|
|
11
15
|
|
|
12
16
|
type Props = {
|
|
13
17
|
onClickKey: (keyConfig: string) => void;
|
|
14
|
-
};
|
|
18
|
+
} & OperatorsButtonSets;
|
|
15
19
|
|
|
16
|
-
export default class
|
|
20
|
+
export default class OperatorsPage extends React.Component<Props> {
|
|
17
21
|
render(): React.ReactNode {
|
|
18
22
|
const {onClickKey} = this.props;
|
|
19
23
|
return (
|
|
20
24
|
<KeypadPageContainer>
|
|
21
25
|
{/* Row 1 */}
|
|
22
|
-
<
|
|
23
|
-
keyConfig={Keys.EXP_2}
|
|
24
|
-
onClickKey={onClickKey}
|
|
25
|
-
/>
|
|
26
|
-
<SecondaryKeypadButton
|
|
27
|
-
keyConfig={Keys.EXP}
|
|
28
|
-
onClickKey={onClickKey}
|
|
29
|
-
/>
|
|
30
|
-
<SecondaryKeypadButton
|
|
31
|
-
keyConfig={Keys.SQRT}
|
|
32
|
-
onClickKey={onClickKey}
|
|
33
|
-
/>
|
|
34
|
-
<SecondaryKeypadButton
|
|
35
|
-
keyConfig={Keys.RADICAL}
|
|
26
|
+
<PreAlgebra
|
|
36
27
|
onClickKey={onClickKey}
|
|
28
|
+
placeholder={!this.props.preAlgebra}
|
|
37
29
|
/>
|
|
38
30
|
|
|
39
31
|
<SecondaryKeypadButton
|
|
@@ -45,11 +37,12 @@ export default class PreAlgebraPage extends React.Component<Props> {
|
|
|
45
37
|
onClickKey={onClickKey}
|
|
46
38
|
/>
|
|
47
39
|
{/* Row 2 */}
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
<Logarithms
|
|
41
|
+
onClickKey={onClickKey}
|
|
42
|
+
placeholder={!this.props.logarithms}
|
|
43
|
+
/>
|
|
51
44
|
<SecondaryKeypadButton
|
|
52
|
-
keyConfig={Keys.
|
|
45
|
+
keyConfig={Keys.x}
|
|
53
46
|
onClickKey={onClickKey}
|
|
54
47
|
style={{
|
|
55
48
|
gridColumn: 5,
|
|
@@ -63,9 +56,11 @@ export default class PreAlgebraPage extends React.Component<Props> {
|
|
|
63
56
|
}}
|
|
64
57
|
/>
|
|
65
58
|
{/* Row 3 */}
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
59
|
+
{/* TODO: implement relatons buttons */}
|
|
60
|
+
<BasicRelations
|
|
61
|
+
onClickKey={onClickKey}
|
|
62
|
+
placeholder={!this.props.basicRelations}
|
|
63
|
+
/>
|
|
69
64
|
<SecondaryKeypadButton
|
|
70
65
|
keyConfig={Keys.PI}
|
|
71
66
|
onClickKey={onClickKey}
|
|
@@ -81,9 +76,10 @@ export default class PreAlgebraPage extends React.Component<Props> {
|
|
|
81
76
|
onClickKey={onClickKey}
|
|
82
77
|
/>
|
|
83
78
|
{/* Row 4 */}
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
<AdvancedRelations
|
|
80
|
+
onClickKey={onClickKey}
|
|
81
|
+
placeholder={!this.props.advancedRelations}
|
|
82
|
+
/>
|
|
87
83
|
<KeypadActionButton
|
|
88
84
|
keyConfig={Keys.DISMISS}
|
|
89
85
|
style={{
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import Keys from "../../../data/key-configs";
|
|
4
|
+
import {PlaceHolderButtons, SecondaryKeypadButton} from "../keypad-page-items";
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
onClickKey: (keyConfig: string) => void;
|
|
8
|
+
placeholder?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const Logarithms = ({
|
|
12
|
+
onClickKey,
|
|
13
|
+
placeholder,
|
|
14
|
+
}: Props): React.ReactElement =>
|
|
15
|
+
placeholder ? (
|
|
16
|
+
<PlaceHolderButtons count={3} />
|
|
17
|
+
) : (
|
|
18
|
+
<React.Fragment>
|
|
19
|
+
<SecondaryKeypadButton
|
|
20
|
+
keyConfig={Keys.LOG}
|
|
21
|
+
onClickKey={onClickKey}
|
|
22
|
+
/>
|
|
23
|
+
<SecondaryKeypadButton
|
|
24
|
+
keyConfig={Keys.LOG_N}
|
|
25
|
+
onClickKey={onClickKey}
|
|
26
|
+
/>
|
|
27
|
+
<SecondaryKeypadButton
|
|
28
|
+
keyConfig={Keys.LN}
|
|
29
|
+
onClickKey={onClickKey}
|
|
30
|
+
/>
|
|
31
|
+
</React.Fragment>
|
|
32
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import Keys from "../../../data/key-configs";
|
|
4
|
+
import {PlaceHolderButtons, SecondaryKeypadButton} from "../keypad-page-items";
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
onClickKey: (keyConfig: string) => void;
|
|
8
|
+
placeholder?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const PreAlgebra = ({
|
|
12
|
+
onClickKey,
|
|
13
|
+
placeholder,
|
|
14
|
+
}: Props): React.ReactElement =>
|
|
15
|
+
placeholder ? (
|
|
16
|
+
<PlaceHolderButtons count={4} />
|
|
17
|
+
) : (
|
|
18
|
+
<React.Fragment>
|
|
19
|
+
<SecondaryKeypadButton
|
|
20
|
+
keyConfig={Keys.EXP_2}
|
|
21
|
+
onClickKey={onClickKey}
|
|
22
|
+
/>
|
|
23
|
+
<SecondaryKeypadButton
|
|
24
|
+
keyConfig={Keys.EXP}
|
|
25
|
+
onClickKey={onClickKey}
|
|
26
|
+
/>
|
|
27
|
+
<SecondaryKeypadButton
|
|
28
|
+
keyConfig={Keys.SQRT}
|
|
29
|
+
onClickKey={onClickKey}
|
|
30
|
+
/>
|
|
31
|
+
<SecondaryKeypadButton
|
|
32
|
+
keyConfig={Keys.RADICAL}
|
|
33
|
+
onClickKey={onClickKey}
|
|
34
|
+
/>
|
|
35
|
+
</React.Fragment>
|
|
36
|
+
);
|
|
@@ -8,7 +8,6 @@ describe("<TwoPageKeyPage />", () => {
|
|
|
8
8
|
// Arrange
|
|
9
9
|
const wrapper = mount(
|
|
10
10
|
<TwoPageKeypad
|
|
11
|
-
currentPage={1}
|
|
12
11
|
leftPage={<p>Left Page</p>}
|
|
13
12
|
rightPage={<p>Right Page</p>}
|
|
14
13
|
/>,
|
|
@@ -23,7 +22,6 @@ describe("<TwoPageKeyPage />", () => {
|
|
|
23
22
|
// Arrange
|
|
24
23
|
const wrapper = mount(
|
|
25
24
|
<TwoPageKeypad
|
|
26
|
-
currentPage={0}
|
|
27
25
|
leftPage={<p>Left Page</p>}
|
|
28
26
|
rightPage={<p>Right Page</p>}
|
|
29
27
|
/>,
|
package/src/components/{compute-layout-parameters.ts → keypad-legacy/compute-layout-parameters.ts}
RENAMED
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
* might need to be.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import {DeviceType, DeviceOrientation, LayoutMode} from "
|
|
23
|
-
|
|
22
|
+
import {DeviceType, DeviceOrientation, LayoutMode} from "../../enums";
|
|
24
23
|
import {
|
|
25
24
|
pageIndicatorHeightPx,
|
|
26
25
|
toolbarHeightPx,
|
|
27
26
|
navigationPadWidthPx,
|
|
28
27
|
innerBorderWidthPx,
|
|
29
|
-
} from "
|
|
28
|
+
} from "../common-style";
|
|
30
29
|
|
|
31
30
|
const minButtonHeight = 48;
|
|
32
31
|
const maxButtonSize = 64;
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
import {StyleSheet} from "aphrodite";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
|
|
8
|
-
import {View} from "
|
|
9
|
-
|
|
10
|
-
import {offBlack} from "./common-style";
|
|
8
|
+
import {View} from "../../fake-react-native-web/index";
|
|
9
|
+
import {offBlack} from "../common-style";
|
|
11
10
|
|
|
12
11
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
13
12
|
|
|
@@ -5,19 +5,18 @@
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import {TransitionGroup, CSSTransition} from "react-transition-group";
|
|
7
7
|
|
|
8
|
-
import KeyConfigs from "
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
8
|
+
import KeyConfigs from "../../data/key-configs";
|
|
9
|
+
import Key from "../../data/keys";
|
|
10
|
+
import {EchoAnimationType} from "../../enums";
|
|
11
11
|
|
|
12
12
|
import KeypadButton from "./keypad-button";
|
|
13
13
|
import * as zIndexes from "./z-indexes";
|
|
14
14
|
|
|
15
|
-
import type {
|
|
15
|
+
import type {Bound, Echo as EchoType} from "../../types";
|
|
16
16
|
|
|
17
17
|
type EchoProps = {
|
|
18
18
|
animationDurationMs: number;
|
|
19
|
-
|
|
20
|
-
id: Keys;
|
|
19
|
+
id: Key;
|
|
21
20
|
initialBounds: Bound;
|
|
22
21
|
onAnimationFinish: () => void;
|
|
23
22
|
};
|
|
@@ -34,7 +33,7 @@ class Echo extends React.Component<EchoProps> {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
render() {
|
|
37
|
-
const {
|
|
36
|
+
const {id, initialBounds} = this.props;
|
|
38
37
|
const {icon} = KeyConfigs[id];
|
|
39
38
|
|
|
40
39
|
const containerStyle: any = {
|
|
@@ -51,26 +50,14 @@ class Echo extends React.Component<EchoProps> {
|
|
|
51
50
|
// applied via StyleSheet, will override our inlines.
|
|
52
51
|
return (
|
|
53
52
|
<div style={containerStyle}>
|
|
54
|
-
<KeypadButton
|
|
55
|
-
icon={icon}
|
|
56
|
-
type={KeyType.ECHO}
|
|
57
|
-
borders={borders}
|
|
58
|
-
/>
|
|
53
|
+
<KeypadButton icon={icon} type={"ECHO"} />
|
|
59
54
|
</div>
|
|
60
55
|
);
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
type EchoPropType = {
|
|
65
|
-
animationId: string;
|
|
66
|
-
animationType: EchoAnimationType;
|
|
67
|
-
borders: Border;
|
|
68
|
-
id: Keys;
|
|
69
|
-
initialBounds: Bound;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
59
|
type EchoManagerProps = {
|
|
73
|
-
echoes: ReadonlyArray<
|
|
60
|
+
echoes: ReadonlyArray<EchoType>;
|
|
74
61
|
onAnimationFinish?: (animationId: string) => void;
|
|
75
62
|
};
|
|
76
63
|
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import {connect} from "react-redux";
|
|
7
7
|
|
|
8
|
-
import KeyConfigs from "
|
|
8
|
+
import KeyConfigs from "../../data/key-configs";
|
|
9
9
|
|
|
10
10
|
import GestureManager from "./gesture-manager";
|
|
11
11
|
import KeypadButton from "./keypad-button";
|
|
12
12
|
|
|
13
|
-
import type {State} from "
|
|
13
|
+
import type {State} from "./store/types";
|
|
14
14
|
|
|
15
15
|
interface ReduxProps {
|
|
16
16
|
gestureManager: GestureManager;
|
|
@@ -27,14 +27,16 @@ class EmptyKeypadButton extends React.Component<ReduxProps> {
|
|
|
27
27
|
// to focus them or trigger presses.
|
|
28
28
|
return (
|
|
29
29
|
<KeypadButton
|
|
30
|
-
onTouchStart={(evt: TouchEvent) =>
|
|
30
|
+
onTouchStart={(evt: React.TouchEvent<HTMLDivElement>) =>
|
|
31
31
|
gestureManager.onTouchStart(evt)
|
|
32
32
|
}
|
|
33
|
-
onTouchEnd={(evt: TouchEvent) =>
|
|
34
|
-
|
|
33
|
+
onTouchEnd={(evt: React.TouchEvent<HTMLDivElement>) =>
|
|
34
|
+
gestureManager.onTouchEnd(evt)
|
|
35
|
+
}
|
|
36
|
+
onTouchMove={(evt: React.TouchEvent<HTMLDivElement>) =>
|
|
35
37
|
gestureManager.onTouchMove(evt)
|
|
36
38
|
}
|
|
37
|
-
onTouchCancel={(evt: TouchEvent) =>
|
|
39
|
+
onTouchCancel={(evt: React.TouchEvent<HTMLDivElement>) =>
|
|
38
40
|
gestureManager.onTouchCancel(evt)
|
|
39
41
|
}
|
|
40
42
|
{...KeyConfigs.NOOP}
|
|
@@ -6,25 +6,24 @@ import {StyleSheet} from "aphrodite";
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import {connect} from "react-redux";
|
|
8
8
|
|
|
9
|
-
import KeyConfigs from "
|
|
10
|
-
import {BorderStyles} from "
|
|
11
|
-
import {View} from "
|
|
9
|
+
import KeyConfigs from "../../data/key-configs";
|
|
10
|
+
import {BorderStyles} from "../../enums";
|
|
11
|
+
import {View} from "../../fake-react-native-web/index";
|
|
12
|
+
import {valueGrey, controlGrey} from "../common-style";
|
|
13
|
+
import {CursorContext} from "../input/cursor-contexts";
|
|
12
14
|
|
|
13
|
-
import {valueGrey, controlGrey} from "./common-style";
|
|
14
|
-
import {CursorContext} from "./input/cursor-contexts";
|
|
15
15
|
import ManyKeypadButton from "./many-keypad-button";
|
|
16
16
|
import Styles from "./styles";
|
|
17
17
|
import TouchableKeypadButton from "./touchable-keypad-button";
|
|
18
18
|
import TwoPageKeypad from "./two-page-keypad";
|
|
19
19
|
|
|
20
|
-
import type {
|
|
21
|
-
import type {
|
|
20
|
+
import type {KeypadLayout} from "../../types";
|
|
21
|
+
import type {State} from "./store/types";
|
|
22
22
|
|
|
23
23
|
const {row, column, oneColumn, fullWidth, roundedTopLeft, roundedTopRight} =
|
|
24
24
|
Styles;
|
|
25
25
|
|
|
26
26
|
interface ReduxProps {
|
|
27
|
-
currentPage: number;
|
|
28
27
|
cursorContext?: CursorContext;
|
|
29
28
|
dynamicJumpOut: boolean;
|
|
30
29
|
}
|
|
@@ -48,7 +47,6 @@ export const expressionKeypadLayout: KeypadLayout = {
|
|
|
48
47
|
class ExpressionKeypad extends React.Component<Props> {
|
|
49
48
|
render() {
|
|
50
49
|
const {
|
|
51
|
-
currentPage,
|
|
52
50
|
cursorContext,
|
|
53
51
|
dynamicJumpOut,
|
|
54
52
|
extraKeys,
|
|
@@ -286,13 +284,7 @@ class ExpressionKeypad extends React.Component<Props> {
|
|
|
286
284
|
</View>
|
|
287
285
|
);
|
|
288
286
|
|
|
289
|
-
return
|
|
290
|
-
<TwoPageKeypad
|
|
291
|
-
currentPage={currentPage}
|
|
292
|
-
rightPage={rightPage}
|
|
293
|
-
leftPage={leftPage}
|
|
294
|
-
/>
|
|
295
|
-
);
|
|
287
|
+
return <TwoPageKeypad rightPage={rightPage} leftPage={leftPage} />;
|
|
296
288
|
}
|
|
297
289
|
}
|
|
298
290
|
|
|
@@ -313,7 +305,6 @@ const styles = StyleSheet.create({
|
|
|
313
305
|
|
|
314
306
|
const mapStateToProps = (state: State): ReduxProps => {
|
|
315
307
|
return {
|
|
316
|
-
currentPage: state.pager.currentPage,
|
|
317
308
|
cursorContext: state.input.cursor?.context,
|
|
318
309
|
dynamicJumpOut: !state.layout.navigationPadEnabled,
|
|
319
310
|
};
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import {connect} from "react-redux";
|
|
8
8
|
|
|
9
|
-
import KeyConfigs from "
|
|
10
|
-
import {BorderStyles} from "
|
|
11
|
-
import {View} from "
|
|
9
|
+
import KeyConfigs from "../../data/key-configs";
|
|
10
|
+
import {BorderStyles} from "../../enums";
|
|
11
|
+
import {View} from "../../fake-react-native-web/index";
|
|
12
|
+
import {CursorContext} from "../input/cursor-contexts";
|
|
12
13
|
|
|
13
|
-
import {CursorContext} from "./input/cursor-contexts";
|
|
14
14
|
import Keypad from "./keypad";
|
|
15
15
|
import Styles from "./styles";
|
|
16
16
|
import TouchableKeypadButton from "./touchable-keypad-button";
|
|
17
17
|
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
18
|
+
import type {KeypadLayout} from "../../types";
|
|
19
|
+
import type {State} from "./store/types";
|
|
20
20
|
|
|
21
21
|
const {row, roundedTopLeft, roundedTopRight} = Styles;
|
|
22
22
|
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* connects our various bits of logic for managing gestures and interactions,
|
|
4
4
|
* and links them together.
|
|
5
5
|
*/
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
import Key from "../../data/keys";
|
|
9
|
+
import {ActiveNodesObj, LayoutProps} from "../../types";
|
|
6
10
|
|
|
7
11
|
import GestureStateMachine from "./gesture-state-machine";
|
|
8
12
|
import NodeManager from "./node-manager";
|
|
@@ -12,6 +16,17 @@ const coordsForEvent = (evt) => {
|
|
|
12
16
|
return [evt.changedTouches[0].clientX, evt.changedTouches[0].clientY];
|
|
13
17
|
};
|
|
14
18
|
|
|
19
|
+
type Options = {
|
|
20
|
+
swipeEnabled: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type Handlers = {
|
|
24
|
+
onSwipeChange?: (dx: number) => void;
|
|
25
|
+
onSwipeEnd?: (dx: number) => void;
|
|
26
|
+
onActiveNodesChanged: (activeNodes: ActiveNodesObj) => void;
|
|
27
|
+
onClick: (key: Key, layoutProps: LayoutProps, inPopover: boolean) => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
15
30
|
class GestureManager {
|
|
16
31
|
swipeEnabled: boolean;
|
|
17
32
|
trackEvents: boolean;
|
|
@@ -19,7 +34,12 @@ class GestureManager {
|
|
|
19
34
|
popoverStateMachine: PopoverStateMachine;
|
|
20
35
|
gestureStateMachine: GestureStateMachine;
|
|
21
36
|
|
|
22
|
-
constructor(
|
|
37
|
+
constructor(
|
|
38
|
+
options: Options,
|
|
39
|
+
handlers: Handlers,
|
|
40
|
+
disabledSwipeKeys: ReadonlyArray<Key>,
|
|
41
|
+
multiPressableKeys: ReadonlyArray<Key>,
|
|
42
|
+
) {
|
|
23
43
|
const {swipeEnabled} = options;
|
|
24
44
|
|
|
25
45
|
this.swipeEnabled = swipeEnabled;
|
|
@@ -96,11 +116,14 @@ class GestureManager {
|
|
|
96
116
|
* Handle a touch-start event that originated in a node registered with the
|
|
97
117
|
* gesture system.
|
|
98
118
|
*
|
|
99
|
-
* @param {TouchEvent} evt - the raw touch event from the browser
|
|
119
|
+
* @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
|
|
100
120
|
* @param {string} id - the identifier of the DOM node in which the touch
|
|
101
121
|
* occurred
|
|
102
122
|
*/
|
|
103
|
-
onTouchStart(
|
|
123
|
+
onTouchStart(
|
|
124
|
+
evt: React.TouchEvent<HTMLDivElement>,
|
|
125
|
+
id?: string | undefined,
|
|
126
|
+
) {
|
|
104
127
|
if (!this.trackEvents) {
|
|
105
128
|
return;
|
|
106
129
|
}
|
|
@@ -128,9 +151,9 @@ class GestureManager {
|
|
|
128
151
|
* Handle a touch-move event that originated in a node registered with the
|
|
129
152
|
* gesture system.
|
|
130
153
|
*
|
|
131
|
-
* @param {TouchEvent} evt - the raw touch event from the browser
|
|
154
|
+
* @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
|
|
132
155
|
*/
|
|
133
|
-
onTouchMove(evt: TouchEvent) {
|
|
156
|
+
onTouchMove(evt: React.TouchEvent<HTMLDivElement>) {
|
|
134
157
|
if (!this.trackEvents) {
|
|
135
158
|
return;
|
|
136
159
|
}
|
|
@@ -152,9 +175,9 @@ class GestureManager {
|
|
|
152
175
|
* Handle a touch-end event that originated in a node registered with the
|
|
153
176
|
* gesture system.
|
|
154
177
|
*
|
|
155
|
-
* @param {TouchEvent} evt - the raw touch event from the browser
|
|
178
|
+
* @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
|
|
156
179
|
*/
|
|
157
|
-
onTouchEnd(evt: TouchEvent) {
|
|
180
|
+
onTouchEnd(evt: React.TouchEvent<HTMLDivElement>) {
|
|
158
181
|
if (!this.trackEvents) {
|
|
159
182
|
return;
|
|
160
183
|
}
|
|
@@ -173,9 +196,9 @@ class GestureManager {
|
|
|
173
196
|
* Handle a touch-cancel event that originated in a node registered with the
|
|
174
197
|
* gesture system.
|
|
175
198
|
*
|
|
176
|
-
* @param {TouchEvent} evt - the raw touch event from the browser
|
|
199
|
+
* @param {React.TouchEvent<HTMLDivElement>} evt - the raw touch event from the browser
|
|
177
200
|
*/
|
|
178
|
-
onTouchCancel(evt: TouchEvent) {
|
|
201
|
+
onTouchCancel(evt: React.TouchEvent<HTMLDivElement>) {
|
|
179
202
|
if (!this.trackEvents) {
|
|
180
203
|
return;
|
|
181
204
|
}
|
|
@@ -198,8 +221,8 @@ class GestureManager {
|
|
|
198
221
|
* intercepting touch events
|
|
199
222
|
* @param {object} borders - an opaque object describing the node's borders
|
|
200
223
|
*/
|
|
201
|
-
registerDOMNode(id, domNode, childIds
|
|
202
|
-
this.nodeManager.registerDOMNode(id, domNode, childIds
|
|
224
|
+
registerDOMNode(id, domNode, childIds) {
|
|
225
|
+
this.nodeManager.registerDOMNode(id, domNode, childIds);
|
|
203
226
|
this.popoverStateMachine.registerPopover(id, childIds);
|
|
204
227
|
}
|
|
205
228
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Key from "../../data/keys";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The state machine that backs our gesture system. In particular, this state
|
|
@@ -14,8 +14,8 @@ export type Handlers = {
|
|
|
14
14
|
onBlur: () => void;
|
|
15
15
|
onTrigger: (id: string) => void;
|
|
16
16
|
onLongPress: (id: string) => void;
|
|
17
|
-
onSwipeChange
|
|
18
|
-
onSwipeEnd
|
|
17
|
+
onSwipeChange?: (x: number) => void;
|
|
18
|
+
onSwipeEnd?: (x: number) => void;
|
|
19
19
|
onTouchEnd: (id: string) => void;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -26,17 +26,17 @@ type Options = {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
type TouchState = {
|
|
29
|
-
activeNodeId:
|
|
29
|
+
activeNodeId: Key;
|
|
30
30
|
pressAndHoldIntervalId: number | null;
|
|
31
31
|
longPressTimeoutId: number | null;
|
|
32
32
|
swipeLocked: boolean;
|
|
33
33
|
startX: number;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
type TouchStateMap = Record<
|
|
36
|
+
type TouchStateMap = Record<Key, TouchState>;
|
|
37
37
|
|
|
38
38
|
type SwipeState = {
|
|
39
|
-
touchId:
|
|
39
|
+
touchId: Key;
|
|
40
40
|
startX: number;
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -49,16 +49,16 @@ const defaultOptions: Options = {
|
|
|
49
49
|
class GestureStateMachine {
|
|
50
50
|
handlers: Handlers;
|
|
51
51
|
options: Options;
|
|
52
|
-
swipeDisabledNodeIds:
|
|
53
|
-
multiPressableKeys:
|
|
52
|
+
swipeDisabledNodeIds: ReadonlyArray<Key>;
|
|
53
|
+
multiPressableKeys: ReadonlyArray<Key>;
|
|
54
54
|
touchState: Partial<TouchStateMap>;
|
|
55
55
|
swipeState: SwipeState | null;
|
|
56
56
|
|
|
57
57
|
constructor(
|
|
58
58
|
handlers: Handlers,
|
|
59
59
|
options: Partial<Options>,
|
|
60
|
-
swipeDisabledNodeIds?:
|
|
61
|
-
multiPressableKeys?:
|
|
60
|
+
swipeDisabledNodeIds?: ReadonlyArray<Key>,
|
|
61
|
+
multiPressableKeys?: ReadonlyArray<Key>,
|
|
62
62
|
) {
|
|
63
63
|
this.handlers = handlers;
|
|
64
64
|
this.options = {
|
|
@@ -234,7 +234,7 @@ class GestureStateMachine {
|
|
|
234
234
|
// Only respect the finger that started a swipe. Any other lingering
|
|
235
235
|
// gestures are ignored.
|
|
236
236
|
if (this.swipeState.touchId === touchId) {
|
|
237
|
-
this.handlers.onSwipeChange(pageX - this.swipeState.startX);
|
|
237
|
+
this.handlers.onSwipeChange?.(pageX - this.swipeState.startX);
|
|
238
238
|
}
|
|
239
239
|
} else if (this.touchState[touchId]) {
|
|
240
240
|
// It could be touch events started outside the keypad and
|
|
@@ -256,7 +256,7 @@ class GestureStateMachine {
|
|
|
256
256
|
touchId,
|
|
257
257
|
startX,
|
|
258
258
|
};
|
|
259
|
-
this.handlers.onSwipeChange(pageX - this.swipeState.startX);
|
|
259
|
+
this.handlers.onSwipeChange?.(pageX - this.swipeState.startX);
|
|
260
260
|
} else {
|
|
261
261
|
const id = getId();
|
|
262
262
|
if (id !== activeNodeId) {
|
|
@@ -279,7 +279,7 @@ class GestureStateMachine {
|
|
|
279
279
|
// Only respect the finger that started a swipe. Any other lingering
|
|
280
280
|
// gestures are ignored.
|
|
281
281
|
if (this.swipeState.touchId === touchId) {
|
|
282
|
-
this.handlers.onSwipeEnd(pageX - this.swipeState.startX);
|
|
282
|
+
this.handlers.onSwipeEnd?.(pageX - this.swipeState.startX);
|
|
283
283
|
this.swipeState = null;
|
|
284
284
|
}
|
|
285
285
|
} else if (this.touchState[touchId]) {
|
|
@@ -313,7 +313,7 @@ class GestureStateMachine {
|
|
|
313
313
|
// displacement.
|
|
314
314
|
if (this.swipeState) {
|
|
315
315
|
if (this.swipeState.touchId === touchId) {
|
|
316
|
-
this.handlers.onSwipeEnd(0);
|
|
316
|
+
this.handlers.onSwipeEnd?.(0);
|
|
317
317
|
this.swipeState = null;
|
|
318
318
|
}
|
|
319
319
|
} else if (this.touchState[touchId]) {
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import {StyleSheet} from "aphrodite";
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
|
|
8
|
-
import {IconType} from "
|
|
8
|
+
import {IconType} from "../../enums";
|
|
9
|
+
import {offBlack} from "../common-style";
|
|
9
10
|
|
|
10
|
-
import {offBlack} from "./common-style";
|
|
11
11
|
import MathIcon from "./math-icon";
|
|
12
12
|
import SvgIcon from "./svg-icon";
|
|
13
13
|
import TextIcon from "./text-icon";
|
|
14
14
|
|
|
15
|
-
import type {IconConfig} from "
|
|
15
|
+
import type {IconConfig} from "../../types";
|
|
16
16
|
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
17
17
|
|
|
18
18
|
const focusedColor = "#FFF";
|