@khanacademy/math-input 4.1.1 → 4.3.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/input/math-wrapper.d.ts +1 -1
- package/dist/components/input/math-wrapper.js.flow +1 -1
- package/dist/components/input/mathquill-instance.d.ts +14 -3
- package/dist/components/input/mathquill-instance.js.flow +18 -3
- package/dist/components/input/mathquill-types.d.ts +30 -6
- package/dist/components/input/mathquill-types.js.flow +33 -7
- package/dist/components/key-handlers/handle-arrow.d.ts +3 -0
- package/dist/components/{input/key-handlers → key-handlers}/handle-arrow.js.flow +2 -2
- package/dist/components/{input/key-handlers → key-handlers}/handle-backspace.d.ts +1 -1
- package/dist/components/{input/key-handlers → key-handlers}/handle-backspace.js.flow +1 -1
- package/dist/components/key-handlers/handle-exponent.d.ts +3 -0
- package/dist/components/{input/key-handlers → key-handlers}/handle-exponent.js.flow +2 -2
- package/dist/components/{input/key-handlers → key-handlers}/handle-jump-out.d.ts +2 -2
- package/dist/components/{input/key-handlers → key-handlers}/handle-jump-out.js.flow +2 -2
- package/dist/components/key-handlers/key-translator.d.ts +4 -0
- package/dist/components/{key-translator.js.flow → key-handlers/key-translator.js.flow} +3 -3
- package/dist/components/keypad/index.d.ts +8 -16
- package/dist/components/keypad/index.js.flow +10 -22
- package/dist/components/keypad/keypad-button.d.ts +12 -0
- package/dist/components/keypad/keypad-button.js.flow +18 -0
- package/dist/components/keypad/keypad-pages/extras-page.d.ts +9 -0
- package/dist/components/keypad/{operators-page/basic-relations-buttons.js.flow → keypad-pages/extras-page.js.flow} +3 -3
- package/dist/components/keypad/keypad-pages/geometry-page.d.ts +7 -0
- package/dist/components/keypad/{operators-page/logarithms-buttons.js.flow → keypad-pages/geometry-page.js.flow} +1 -3
- package/dist/components/keypad/keypad-pages/numbers-page.d.ts +7 -0
- package/dist/components/keypad/{operators-page/pre-algebra-buttons.js.flow → keypad-pages/numbers-page.js.flow} +1 -3
- package/dist/components/keypad/keypad-pages/operators-page.d.ts +11 -0
- package/dist/components/keypad/{geometry-page/index.js.flow → keypad-pages/operators-page.js.flow} +5 -4
- package/dist/components/keypad/shared-keys.d.ts +9 -0
- package/dist/components/keypad/{numbers-page/types.js.flow → shared-keys.js.flow} +4 -1
- package/dist/es/index.js +763 -878
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +740 -878
- package/dist/index.js.flow +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/src/components/input/__tests__/test-math-wrapper.ts +2 -5
- package/src/components/input/math-input.tsx +10 -14
- package/src/components/input/math-wrapper.ts +23 -49
- package/src/components/input/mathquill-helpers.ts +11 -11
- package/src/components/input/mathquill-instance.ts +57 -2
- package/src/components/input/mathquill-types.ts +43 -7
- package/src/components/{input/key-handlers → key-handlers}/handle-arrow.ts +6 -6
- package/src/components/{input/key-handlers → key-handlers}/handle-backspace.ts +19 -17
- package/src/components/{input/key-handlers → key-handlers}/handle-exponent.ts +8 -5
- package/src/components/{input/key-handlers → key-handlers}/handle-jump-out.ts +15 -10
- package/src/components/{key-translator.ts → key-handlers/key-translator.ts} +43 -28
- package/src/components/keypad/__tests__/{KeypadButton.test.tsx → keypad-button.test.tsx} +7 -5
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +231 -0
- package/src/components/keypad/__tests__/keypad-v2.cypress.ts +19 -6
- package/src/components/keypad/index.tsx +73 -49
- package/src/components/keypad/{button.stories.tsx → keypad-button.stories.tsx} +2 -1
- package/src/components/keypad/keypad-button.tsx +128 -0
- package/src/components/keypad/keypad-mathquill.stories.tsx +24 -26
- package/src/components/keypad/keypad-pages/extras-page.tsx +34 -0
- package/src/components/keypad/keypad-pages/geometry-page.tsx +33 -0
- package/src/components/keypad/keypad-pages/numbers-page.tsx +84 -0
- package/src/components/keypad/keypad-pages/operators-page.tsx +116 -0
- package/src/components/keypad/shared-keys.tsx +78 -0
- package/src/index.ts +6 -1
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/input/key-handlers/handle-arrow.d.ts +0 -3
- package/dist/components/input/key-handlers/handle-exponent.d.ts +0 -3
- package/dist/components/key-translator.d.ts +0 -4
- package/dist/components/keypad/button.d.ts +0 -12
- package/dist/components/keypad/button.js.flow +0 -18
- package/dist/components/keypad/extras-page/index.d.ts +0 -10
- package/dist/components/keypad/extras-page/index.js.flow +0 -15
- package/dist/components/keypad/geometry-page/index.d.ts +0 -9
- package/dist/components/keypad/keypad-page-items.d.ts +0 -26
- package/dist/components/keypad/keypad-page-items.js.flow +0 -40
- package/dist/components/keypad/numbers-page/index.d.ts +0 -10
- package/dist/components/keypad/numbers-page/index.js.flow +0 -18
- package/dist/components/keypad/numbers-page/types.d.ts +0 -4
- package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/advanced-relations-buttons.js.flow +0 -13
- package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/index.d.ts +0 -10
- package/dist/components/keypad/operators-page/index.js.flow +0 -18
- package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +0 -8
- package/dist/components/keypad/operators-page/types.d.ts +0 -6
- package/dist/components/keypad/operators-page/types.js.flow +0 -12
- package/src/components/keypad/__tests__/Button.test.tsx +0 -51
- package/src/components/keypad/button.tsx +0 -108
- package/src/components/keypad/extras-page/index.tsx +0 -27
- package/src/components/keypad/geometry-page/index.tsx +0 -89
- package/src/components/keypad/keypad-page-items.tsx +0 -118
- package/src/components/keypad/numbers-page/index.tsx +0 -136
- package/src/components/keypad/numbers-page/types.ts +0 -4
- package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +0 -33
- package/src/components/keypad/operators-page/basic-relations-buttons.tsx +0 -33
- package/src/components/keypad/operators-page/index.tsx +0 -94
- package/src/components/keypad/operators-page/logarithms-buttons.tsx +0 -33
- package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +0 -37
- package/src/components/keypad/operators-page/types.ts +0 -6
- /package/src/components/keypad/{keypad-pages.stories.tsx → keypad-pages/keypad-pages.stories.tsx} +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { ClickKeyCallback } from "../../../types";
|
|
9
|
-
import { NumbersPageOptions } from "./types";
|
|
10
|
-
declare type Props = {|
|
|
11
|
-
...{|
|
|
12
|
-
onClickKey: ClickKeyCallback,
|
|
13
|
-
|},
|
|
14
|
-
...NumbersPageOptions,
|
|
15
|
-
|};
|
|
16
|
-
declare export default class NumbersPage extends React.Component<Props> {
|
|
17
|
-
render(): React.Node;
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const AdvancedRelations: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import React from "react";
|
|
8
|
-
import { ClickKeyCallback } from "../../../types";
|
|
9
|
-
declare type Props = {|
|
|
10
|
-
onClickKey: ClickKeyCallback,
|
|
11
|
-
placeholder?: boolean,
|
|
12
|
-
|};
|
|
13
|
-
declare export var AdvancedRelations: (x: Props) => React.ReactElement;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const BasicRelations: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
import { OperatorsButtonSets } from "./types";
|
|
4
|
-
type Props = {
|
|
5
|
-
onClickKey: ClickKeyCallback;
|
|
6
|
-
} & OperatorsButtonSets;
|
|
7
|
-
export default class OperatorsPage extends React.Component<Props> {
|
|
8
|
-
render(): React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
import * as React from "react";
|
|
8
|
-
import { ClickKeyCallback } from "../../../types";
|
|
9
|
-
import { OperatorsButtonSets } from "./types";
|
|
10
|
-
declare type Props = {|
|
|
11
|
-
...{|
|
|
12
|
-
onClickKey: ClickKeyCallback,
|
|
13
|
-
|},
|
|
14
|
-
...OperatorsButtonSets,
|
|
15
|
-
|};
|
|
16
|
-
declare export default class OperatorsPage extends React.Component<Props> {
|
|
17
|
-
render(): React.Node;
|
|
18
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const Logarithms: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ClickKeyCallback } from "../../../types";
|
|
3
|
-
type Props = {
|
|
4
|
-
onClickKey: ClickKeyCallback;
|
|
5
|
-
placeholder?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare const PreAlgebra: ({ onClickKey, placeholder, }: Props) => React.ReactElement;
|
|
8
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flowtype definitions for data
|
|
3
|
-
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.21.0
|
|
5
|
-
* @flow
|
|
6
|
-
*/
|
|
7
|
-
export type OperatorsButtonSets = {|
|
|
8
|
-
preAlgebra?: boolean,
|
|
9
|
-
logarithms?: boolean,
|
|
10
|
-
basicRelations?: boolean,
|
|
11
|
-
advancedRelations?: boolean,
|
|
12
|
-
|};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {render, screen} from "@testing-library/react";
|
|
2
|
-
import userEvent from "@testing-library/user-event";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import "@testing-library/jest-dom";
|
|
5
|
-
|
|
6
|
-
import Button from "../button";
|
|
7
|
-
|
|
8
|
-
describe("<Button />", () => {
|
|
9
|
-
it("uses the aria label", () => {
|
|
10
|
-
// Arrange
|
|
11
|
-
render(
|
|
12
|
-
<Button onPress={() => {}} ariaLabel="Oranges">
|
|
13
|
-
<p />
|
|
14
|
-
</Button>,
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
// Assert
|
|
18
|
-
expect(
|
|
19
|
-
screen.getByRole("button", {name: "Oranges"}),
|
|
20
|
-
).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("handles callback on press", () => {
|
|
24
|
-
// Arrange
|
|
25
|
-
const mockPressCallback = jest.fn();
|
|
26
|
-
render(
|
|
27
|
-
<Button onPress={mockPressCallback} ariaLabel="Oranges">
|
|
28
|
-
<p />
|
|
29
|
-
</Button>,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Act
|
|
33
|
-
userEvent.click(screen.getByRole("button", {name: "Oranges"}));
|
|
34
|
-
|
|
35
|
-
// Assert
|
|
36
|
-
expect(mockPressCallback).toHaveBeenCalled();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("renders child", () => {
|
|
40
|
-
// Arrange
|
|
41
|
-
render(
|
|
42
|
-
<Button onPress={() => {}} ariaLabel="Test">
|
|
43
|
-
<img aria-label="child1" />
|
|
44
|
-
</Button>,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// Assert
|
|
48
|
-
expect(screen.getByRole("button", {name: "Test"})).toBeInTheDocument();
|
|
49
|
-
expect(screen.getByRole("img", {name: "child1"})).toBeInTheDocument();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import Clickable from "@khanacademy/wonder-blocks-clickable";
|
|
2
|
-
import Color from "@khanacademy/wonder-blocks-color";
|
|
3
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
4
|
-
import {StyleSheet} from "aphrodite";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
|
|
7
|
-
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
8
|
-
|
|
9
|
-
const styles = StyleSheet.create({
|
|
10
|
-
base: {
|
|
11
|
-
display: "flex",
|
|
12
|
-
justifyContent: "center",
|
|
13
|
-
alignItems: "center",
|
|
14
|
-
boxShadow: "0px 1px 0px rgba(33, 36, 44, 0.32)",
|
|
15
|
-
boxSizing: "border-box",
|
|
16
|
-
background: Color.white,
|
|
17
|
-
borderRadius: 4,
|
|
18
|
-
border: `1px solid transparent`,
|
|
19
|
-
flex: 1,
|
|
20
|
-
minHeight: 42,
|
|
21
|
-
minWidth: 42,
|
|
22
|
-
padding: 1,
|
|
23
|
-
},
|
|
24
|
-
hovered: {
|
|
25
|
-
border: `1px solid ${Color.blue}`,
|
|
26
|
-
padding: 1,
|
|
27
|
-
boxShadow: "none",
|
|
28
|
-
},
|
|
29
|
-
focused: {
|
|
30
|
-
border: `2px solid ${Color.blue}`,
|
|
31
|
-
padding: 0,
|
|
32
|
-
boxShadow: "none",
|
|
33
|
-
},
|
|
34
|
-
pressed: {
|
|
35
|
-
border: "2px solid #1B50B3",
|
|
36
|
-
padding: 0,
|
|
37
|
-
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
|
|
38
|
-
boxShadow: "none",
|
|
39
|
-
},
|
|
40
|
-
outerBoxBase: {
|
|
41
|
-
padding: 1,
|
|
42
|
-
height: "100%",
|
|
43
|
-
width: "100%",
|
|
44
|
-
boxSizing: "border-box",
|
|
45
|
-
borderRadius: 7,
|
|
46
|
-
border: "2px solid transparent",
|
|
47
|
-
},
|
|
48
|
-
outerBoxHover: {
|
|
49
|
-
border: `2px solid ${Color.blue}`,
|
|
50
|
-
},
|
|
51
|
-
outerBoxPressed: {
|
|
52
|
-
border: "2px solid #1B50B3",
|
|
53
|
-
},
|
|
54
|
-
clickable: {
|
|
55
|
-
width: "100%",
|
|
56
|
-
height: "100%",
|
|
57
|
-
boxSizing: "border-box",
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export type Props = {
|
|
62
|
-
onPress: () => void;
|
|
63
|
-
children: React.ReactNode;
|
|
64
|
-
ariaLabel: string;
|
|
65
|
-
style?: StyleType;
|
|
66
|
-
tintColor?: string;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export default class Button extends React.Component<Props> {
|
|
70
|
-
render(): React.ReactNode {
|
|
71
|
-
const {onPress, ariaLabel, children, style, tintColor} = this.props;
|
|
72
|
-
return (
|
|
73
|
-
<View style={style}>
|
|
74
|
-
<Clickable
|
|
75
|
-
onClick={onPress}
|
|
76
|
-
style={styles.clickable}
|
|
77
|
-
aria-label={ariaLabel}
|
|
78
|
-
>
|
|
79
|
-
{({hovered, focused, pressed}) => {
|
|
80
|
-
return (
|
|
81
|
-
<View
|
|
82
|
-
style={[
|
|
83
|
-
styles.outerBoxBase,
|
|
84
|
-
hovered && styles.outerBoxHover,
|
|
85
|
-
pressed && styles.outerBoxPressed,
|
|
86
|
-
]}
|
|
87
|
-
>
|
|
88
|
-
<View
|
|
89
|
-
style={[
|
|
90
|
-
styles.base,
|
|
91
|
-
tintColor != null
|
|
92
|
-
? {background: tintColor}
|
|
93
|
-
: undefined,
|
|
94
|
-
hovered && styles.hovered,
|
|
95
|
-
focused && styles.focused,
|
|
96
|
-
pressed && styles.pressed,
|
|
97
|
-
]}
|
|
98
|
-
>
|
|
99
|
-
{children}
|
|
100
|
-
</View>
|
|
101
|
-
</View>
|
|
102
|
-
);
|
|
103
|
-
}}
|
|
104
|
-
</Clickable>
|
|
105
|
-
</View>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import Key from "../../../data/keys";
|
|
5
|
-
import {KeypadPageContainer, KeypadButton} from "../keypad-page-items";
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
extraKeys: ReadonlyArray<Key>;
|
|
9
|
-
onClickKey: (keyConfig: string) => void;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class ExtrasPage extends React.Component<Props> {
|
|
13
|
-
render(): React.ReactNode {
|
|
14
|
-
const {extraKeys, onClickKey} = this.props;
|
|
15
|
-
return (
|
|
16
|
-
<KeypadPageContainer>
|
|
17
|
-
{extraKeys.map((key) => (
|
|
18
|
-
<KeypadButton
|
|
19
|
-
key={key}
|
|
20
|
-
keyConfig={Keys[key]}
|
|
21
|
-
onClickKey={onClickKey}
|
|
22
|
-
/>
|
|
23
|
-
))}
|
|
24
|
-
</KeypadPageContainer>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {ClickKeyCallback} from "../../../types";
|
|
5
|
-
import {
|
|
6
|
-
KeypadPageContainer,
|
|
7
|
-
SecondaryKeypadButton,
|
|
8
|
-
KeypadActionButton,
|
|
9
|
-
} from "../keypad-page-items";
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
onClickKey: ClickKeyCallback;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default class GeometryPage extends React.Component<Props> {
|
|
16
|
-
render(): React.ReactNode {
|
|
17
|
-
const {onClickKey} = this.props;
|
|
18
|
-
return (
|
|
19
|
-
<KeypadPageContainer>
|
|
20
|
-
{/* Row 1 */}
|
|
21
|
-
<SecondaryKeypadButton
|
|
22
|
-
keyConfig={Keys.SIN}
|
|
23
|
-
onClickKey={onClickKey}
|
|
24
|
-
/>
|
|
25
|
-
<SecondaryKeypadButton
|
|
26
|
-
keyConfig={Keys.COS}
|
|
27
|
-
onClickKey={onClickKey}
|
|
28
|
-
/>
|
|
29
|
-
<SecondaryKeypadButton
|
|
30
|
-
keyConfig={Keys.TAN}
|
|
31
|
-
onClickKey={onClickKey}
|
|
32
|
-
/>
|
|
33
|
-
|
|
34
|
-
<SecondaryKeypadButton
|
|
35
|
-
keyConfig={Keys.LEFT_PAREN}
|
|
36
|
-
onClickKey={onClickKey}
|
|
37
|
-
style={{
|
|
38
|
-
gridColumn: 5,
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
41
|
-
<SecondaryKeypadButton
|
|
42
|
-
keyConfig={Keys.RIGHT_PAREN}
|
|
43
|
-
onClickKey={onClickKey}
|
|
44
|
-
style={{
|
|
45
|
-
gridColumn: 6,
|
|
46
|
-
}}
|
|
47
|
-
/>
|
|
48
|
-
{/* Row 2 */}
|
|
49
|
-
<SecondaryKeypadButton
|
|
50
|
-
keyConfig={Keys.x}
|
|
51
|
-
onClickKey={onClickKey}
|
|
52
|
-
style={{
|
|
53
|
-
gridColumn: 5,
|
|
54
|
-
}}
|
|
55
|
-
/>
|
|
56
|
-
<SecondaryKeypadButton
|
|
57
|
-
keyConfig={Keys.FRAC_INCLUSIVE}
|
|
58
|
-
onClickKey={onClickKey}
|
|
59
|
-
style={{
|
|
60
|
-
gridColumn: 6,
|
|
61
|
-
}}
|
|
62
|
-
/>
|
|
63
|
-
{/* Row 3 */}
|
|
64
|
-
<SecondaryKeypadButton
|
|
65
|
-
keyConfig={Keys.PI}
|
|
66
|
-
onClickKey={onClickKey}
|
|
67
|
-
style={{
|
|
68
|
-
gridColumn: 5,
|
|
69
|
-
}}
|
|
70
|
-
/>
|
|
71
|
-
<KeypadActionButton
|
|
72
|
-
keyConfig={Keys.BACKSPACE}
|
|
73
|
-
style={{
|
|
74
|
-
gridColumn: "6",
|
|
75
|
-
}}
|
|
76
|
-
onClickKey={onClickKey}
|
|
77
|
-
/>
|
|
78
|
-
{/* Row 4 */}
|
|
79
|
-
<KeypadActionButton
|
|
80
|
-
keyConfig={Keys.DISMISS}
|
|
81
|
-
style={{
|
|
82
|
-
gridColumn: "6",
|
|
83
|
-
}}
|
|
84
|
-
onClickKey={onClickKey}
|
|
85
|
-
/>
|
|
86
|
-
</KeypadPageContainer>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import {KeyConfig, ClickKeyCallback} from "../../types";
|
|
5
|
-
|
|
6
|
-
import Button from "./button";
|
|
7
|
-
import ButtonAsset from "./button-assets";
|
|
8
|
-
|
|
9
|
-
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
10
|
-
|
|
11
|
-
type KeypadPageContainerProps = {
|
|
12
|
-
children: React.ReactNode;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const KeypadPageContainer = ({
|
|
16
|
-
children,
|
|
17
|
-
}: KeypadPageContainerProps): React.ReactElement => (
|
|
18
|
-
<View
|
|
19
|
-
style={{
|
|
20
|
-
backgroundColor: "#DBDCDD",
|
|
21
|
-
width: "100%",
|
|
22
|
-
height: 192,
|
|
23
|
-
|
|
24
|
-
display: "grid",
|
|
25
|
-
gridTemplateColumns: "repeat(6, 1fr)",
|
|
26
|
-
gridTemplateRows: "repeat(4, 1fr)",
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
{children}
|
|
30
|
-
</View>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
type SharedButtonProps = {
|
|
34
|
-
keyConfig: KeyConfig;
|
|
35
|
-
style?: StyleType;
|
|
36
|
-
onClickKey: ClickKeyCallback;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type KeypadButtonProps = SharedButtonProps & {
|
|
40
|
-
tintColor?: string;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const KeypadButton = ({
|
|
44
|
-
keyConfig,
|
|
45
|
-
onClickKey,
|
|
46
|
-
tintColor,
|
|
47
|
-
style,
|
|
48
|
-
}: KeypadButtonProps): React.ReactElement => (
|
|
49
|
-
<Button
|
|
50
|
-
onPress={() => onClickKey(keyConfig.id)}
|
|
51
|
-
tintColor={tintColor}
|
|
52
|
-
style={style}
|
|
53
|
-
ariaLabel={keyConfig.id}
|
|
54
|
-
>
|
|
55
|
-
<ButtonAsset id={keyConfig.id} />
|
|
56
|
-
</Button>
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
export const SecondaryKeypadButton = ({
|
|
60
|
-
keyConfig,
|
|
61
|
-
onClickKey,
|
|
62
|
-
style,
|
|
63
|
-
}: SharedButtonProps): React.ReactElement => (
|
|
64
|
-
<KeypadButton
|
|
65
|
-
keyConfig={keyConfig}
|
|
66
|
-
onClickKey={onClickKey}
|
|
67
|
-
style={style}
|
|
68
|
-
tintColor={"#F6F6F7"}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
export const KeypadActionButton = ({
|
|
73
|
-
keyConfig,
|
|
74
|
-
onClickKey,
|
|
75
|
-
style,
|
|
76
|
-
}: SharedButtonProps): React.ReactElement => (
|
|
77
|
-
<KeypadButton
|
|
78
|
-
keyConfig={keyConfig}
|
|
79
|
-
onClickKey={onClickKey}
|
|
80
|
-
style={style}
|
|
81
|
-
tintColor={"#DBDCDD"}
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* A placeholder button for the keypad. Optional count prop to render multiple
|
|
87
|
-
* buttons. Defaults to 1.
|
|
88
|
-
*/
|
|
89
|
-
export const PlaceHolderButtons = ({
|
|
90
|
-
count = 1,
|
|
91
|
-
}: {
|
|
92
|
-
count?: number;
|
|
93
|
-
}): React.ReactElement => (
|
|
94
|
-
<React.Fragment>
|
|
95
|
-
{Array.from({length: count}).map((_, index) => (
|
|
96
|
-
<View
|
|
97
|
-
key={index}
|
|
98
|
-
style={{
|
|
99
|
-
height: "100%",
|
|
100
|
-
width: "100%",
|
|
101
|
-
boxSizing: "border-box",
|
|
102
|
-
borderRadius: 7,
|
|
103
|
-
border: "4px solid transparent",
|
|
104
|
-
}}
|
|
105
|
-
>
|
|
106
|
-
<View
|
|
107
|
-
style={{
|
|
108
|
-
background: "rgba(33, 36, 44, 0.04)",
|
|
109
|
-
width: "100%",
|
|
110
|
-
height: "100%",
|
|
111
|
-
borderRadius: 4,
|
|
112
|
-
border: `1px solid transparent`,
|
|
113
|
-
}}
|
|
114
|
-
/>
|
|
115
|
-
</View>
|
|
116
|
-
))}
|
|
117
|
-
</React.Fragment>
|
|
118
|
-
);
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {ClickKeyCallback} from "../../../types";
|
|
5
|
-
import {
|
|
6
|
-
KeypadPageContainer,
|
|
7
|
-
KeypadButton,
|
|
8
|
-
SecondaryKeypadButton,
|
|
9
|
-
KeypadActionButton,
|
|
10
|
-
} from "../keypad-page-items";
|
|
11
|
-
|
|
12
|
-
import {NumbersPageOptions} from "./types";
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
onClickKey: ClickKeyCallback;
|
|
16
|
-
} & NumbersPageOptions;
|
|
17
|
-
|
|
18
|
-
export default class NumbersPage extends React.Component<Props> {
|
|
19
|
-
render(): React.ReactNode {
|
|
20
|
-
const {onClickKey} = this.props;
|
|
21
|
-
return (
|
|
22
|
-
<KeypadPageContainer>
|
|
23
|
-
{/* Row 1 */}
|
|
24
|
-
<KeypadButton keyConfig={Keys.NUM_7} onClickKey={onClickKey} />
|
|
25
|
-
<KeypadButton keyConfig={Keys.NUM_8} onClickKey={onClickKey} />
|
|
26
|
-
<KeypadButton keyConfig={Keys.NUM_9} onClickKey={onClickKey} />
|
|
27
|
-
<SecondaryKeypadButton
|
|
28
|
-
keyConfig={Keys.DIVIDE}
|
|
29
|
-
style={
|
|
30
|
-
this.props.divisionKey
|
|
31
|
-
? {
|
|
32
|
-
gridColumn: "4",
|
|
33
|
-
gridRow: "1",
|
|
34
|
-
}
|
|
35
|
-
: {
|
|
36
|
-
display: "none",
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
onClickKey={onClickKey}
|
|
40
|
-
/>
|
|
41
|
-
<SecondaryKeypadButton
|
|
42
|
-
keyConfig={
|
|
43
|
-
this.props.multiplicationDot ? Keys.CDOT : Keys.TIMES
|
|
44
|
-
}
|
|
45
|
-
style={
|
|
46
|
-
this.props.divisionKey && {
|
|
47
|
-
gridColumn: "4",
|
|
48
|
-
gridRow: "2",
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
onClickKey={onClickKey}
|
|
52
|
-
/>
|
|
53
|
-
<SecondaryKeypadButton
|
|
54
|
-
keyConfig={Keys.LEFT_PAREN}
|
|
55
|
-
onClickKey={onClickKey}
|
|
56
|
-
/>
|
|
57
|
-
<SecondaryKeypadButton
|
|
58
|
-
keyConfig={Keys.RIGHT_PAREN}
|
|
59
|
-
onClickKey={onClickKey}
|
|
60
|
-
/>
|
|
61
|
-
|
|
62
|
-
{/* Row 2 */}
|
|
63
|
-
<KeypadButton keyConfig={Keys.NUM_4} onClickKey={onClickKey} />
|
|
64
|
-
<KeypadButton keyConfig={Keys.NUM_5} onClickKey={onClickKey} />
|
|
65
|
-
<KeypadButton keyConfig={Keys.NUM_6} onClickKey={onClickKey} />
|
|
66
|
-
|
|
67
|
-
<SecondaryKeypadButton
|
|
68
|
-
keyConfig={Keys.MINUS}
|
|
69
|
-
style={
|
|
70
|
-
this.props.divisionKey && {
|
|
71
|
-
gridColumn: "4",
|
|
72
|
-
gridRow: "3",
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
onClickKey={onClickKey}
|
|
76
|
-
/>
|
|
77
|
-
|
|
78
|
-
<SecondaryKeypadButton
|
|
79
|
-
keyConfig={Keys.FRAC_INCLUSIVE}
|
|
80
|
-
onClickKey={onClickKey}
|
|
81
|
-
style={{
|
|
82
|
-
gridColumn: "5 / 7",
|
|
83
|
-
}}
|
|
84
|
-
/>
|
|
85
|
-
{/* Row 3 */}
|
|
86
|
-
<KeypadButton keyConfig={Keys.NUM_1} onClickKey={onClickKey} />
|
|
87
|
-
<KeypadButton keyConfig={Keys.NUM_2} onClickKey={onClickKey} />
|
|
88
|
-
<KeypadButton keyConfig={Keys.NUM_3} onClickKey={onClickKey} />
|
|
89
|
-
|
|
90
|
-
<SecondaryKeypadButton
|
|
91
|
-
keyConfig={Keys.PLUS}
|
|
92
|
-
style={
|
|
93
|
-
this.props.divisionKey
|
|
94
|
-
? {
|
|
95
|
-
gridColumn: "4",
|
|
96
|
-
gridRow: "4",
|
|
97
|
-
}
|
|
98
|
-
: {
|
|
99
|
-
gridColumn: "4",
|
|
100
|
-
gridRowStart: "3",
|
|
101
|
-
gridRowEnd: "5",
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
onClickKey={onClickKey}
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
<KeypadActionButton
|
|
108
|
-
keyConfig={Keys.BACKSPACE}
|
|
109
|
-
style={{
|
|
110
|
-
gridColumn: "6",
|
|
111
|
-
}}
|
|
112
|
-
onClickKey={onClickKey}
|
|
113
|
-
/>
|
|
114
|
-
|
|
115
|
-
{/* Row 4 */}
|
|
116
|
-
<KeypadButton keyConfig={Keys.NUM_0} onClickKey={onClickKey} />
|
|
117
|
-
<KeypadButton
|
|
118
|
-
keyConfig={Keys.DECIMAL}
|
|
119
|
-
onClickKey={onClickKey}
|
|
120
|
-
/>
|
|
121
|
-
<KeypadButton
|
|
122
|
-
keyConfig={Keys.NEGATIVE}
|
|
123
|
-
onClickKey={onClickKey}
|
|
124
|
-
/>
|
|
125
|
-
|
|
126
|
-
<KeypadActionButton
|
|
127
|
-
keyConfig={Keys.DISMISS}
|
|
128
|
-
style={{
|
|
129
|
-
gridColumn: "6",
|
|
130
|
-
}}
|
|
131
|
-
onClickKey={onClickKey}
|
|
132
|
-
/>
|
|
133
|
-
</KeypadPageContainer>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
}
|