@khanacademy/math-input 17.0.3 → 17.0.5
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/dist/es/index.js +2 -2
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
- package/.eslintrc.js +0 -18
- package/CHANGELOG.md +0 -654
- package/less/main.less +0 -2
- package/less/overrides.less +0 -122
- package/src/components/__tests__/integration.test.tsx +0 -300
- package/src/components/aphrodite-css-transition-group/index.tsx +0 -78
- package/src/components/aphrodite-css-transition-group/transition-child.tsx +0 -192
- package/src/components/aphrodite-css-transition-group/types.ts +0 -20
- package/src/components/aphrodite-css-transition-group/util.ts +0 -97
- package/src/components/input/__tests__/context-tracking.test.ts +0 -176
- package/src/components/input/__tests__/mathquill-helpers.test.ts +0 -105
- package/src/components/input/__tests__/mathquill.test.ts +0 -747
- package/src/components/input/__tests__/test-math-wrapper.ts +0 -29
- package/src/components/input/cursor-contexts.ts +0 -37
- package/src/components/input/cursor-handle.tsx +0 -137
- package/src/components/input/cursor-styles.ts +0 -10
- package/src/components/input/drag-listener.ts +0 -79
- package/src/components/input/math-input.tsx +0 -1036
- package/src/components/input/math-wrapper.ts +0 -189
- package/src/components/input/mathquill-helpers.ts +0 -262
- package/src/components/input/mathquill-instance.ts +0 -106
- package/src/components/input/mathquill-types.ts +0 -32
- package/src/components/input/scroll-into-view.ts +0 -65
- package/src/components/key-handlers/__tests__/handle-jump-out.test.ts +0 -94
- package/src/components/key-handlers/handle-arrow.ts +0 -70
- package/src/components/key-handlers/handle-backspace.ts +0 -277
- package/src/components/key-handlers/handle-exponent.ts +0 -53
- package/src/components/key-handlers/handle-jump-out.ts +0 -107
- package/src/components/key-handlers/key-translator.ts +0 -222
- package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +0 -1913
- package/src/components/keypad/__tests__/__snapshots__/mobile-keypad.test.tsx.snap +0 -600
- package/src/components/keypad/__tests__/keypad-button.test.tsx +0 -84
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +0 -304
- package/src/components/keypad/__tests__/keypad-v2.cypress.ts +0 -16
- package/src/components/keypad/__tests__/keypad.test.tsx +0 -321
- package/src/components/keypad/__tests__/mobile-keypad.test.tsx +0 -115
- package/src/components/keypad/__tests__/test-data-tabs.ts +0 -21
- package/src/components/keypad/button-assets.tsx +0 -1880
- package/src/components/keypad/index.tsx +0 -2
- package/src/components/keypad/keypad-button.stories.tsx +0 -81
- package/src/components/keypad/keypad-button.tsx +0 -124
- package/src/components/keypad/keypad-mathquill.stories.tsx +0 -109
- package/src/components/keypad/keypad-pages/extras-page.tsx +0 -35
- package/src/components/keypad/keypad-pages/fractions-page.tsx +0 -125
- package/src/components/keypad/keypad-pages/geometry-page.tsx +0 -34
- package/src/components/keypad/keypad-pages/keypad-pages.stories.tsx +0 -37
- package/src/components/keypad/keypad-pages/numbers-page.tsx +0 -94
- package/src/components/keypad/keypad-pages/operators-page.tsx +0 -117
- package/src/components/keypad/keypad.tsx +0 -233
- package/src/components/keypad/mobile-keypad-internals.tsx +0 -240
- package/src/components/keypad/mobile-keypad.tsx +0 -24
- package/src/components/keypad/navigation-button.tsx +0 -127
- package/src/components/keypad/navigation-pad.stories.tsx +0 -26
- package/src/components/keypad/navigation-pad.tsx +0 -67
- package/src/components/keypad/shared-keys.tsx +0 -109
- package/src/components/keypad/utils.ts +0 -34
- package/src/components/keypad-context.tsx +0 -70
- package/src/components/prop-types.ts +0 -16
- package/src/components/tabbar/__tests__/tabbar.test.tsx +0 -105
- package/src/components/tabbar/icons.tsx +0 -122
- package/src/components/tabbar/index.ts +0 -1
- package/src/components/tabbar/item.tsx +0 -146
- package/src/components/tabbar/tabbar.stories.tsx +0 -83
- package/src/components/tabbar/tabbar.tsx +0 -65
- package/src/data/key-configs.ts +0 -770
- package/src/data/keys.ts +0 -123
- package/src/enums.ts +0 -27
- package/src/fake-react-native-web/index.ts +0 -11
- package/src/fake-react-native-web/text.tsx +0 -55
- package/src/fake-react-native-web/view.tsx +0 -91
- package/src/full-keypad.stories.tsx +0 -142
- package/src/full-mobile-input.stories.tsx +0 -115
- package/src/index.ts +0 -52
- package/src/types.ts +0 -70
- package/src/utils.test.ts +0 -33
- package/src/utils.ts +0 -61
- package/src/version.ts +0 -10
- package/tsconfig-build.json +0 -11
- package/tsconfig-build.tsbuildinfo +0 -1
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import KeyConfigs from "../../data/key-configs";
|
|
5
|
-
|
|
6
|
-
import {KeypadButton} from "./keypad-button";
|
|
7
|
-
|
|
8
|
-
import type {KeypadButtonProps} from "./keypad-button";
|
|
9
|
-
import type {ComponentStory} from "@storybook/react";
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
title: "math-input/components/Keypad Button",
|
|
13
|
-
args: {
|
|
14
|
-
keyConfig: KeyConfigs["PLUS"],
|
|
15
|
-
tintColor: "#F6F6F7",
|
|
16
|
-
coord: [0, 0],
|
|
17
|
-
},
|
|
18
|
-
argTypes: {
|
|
19
|
-
keyConfig: {
|
|
20
|
-
control: "select",
|
|
21
|
-
options: {...KeyConfigs},
|
|
22
|
-
},
|
|
23
|
-
tintColor: {
|
|
24
|
-
control: "color",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const Template: ComponentStory<typeof KeypadButton> = ({
|
|
30
|
-
...args
|
|
31
|
-
}: KeypadButtonProps): React.ReactElement => (
|
|
32
|
-
<div
|
|
33
|
-
style={{
|
|
34
|
-
width: 200,
|
|
35
|
-
height: 200,
|
|
36
|
-
backgroundColor: "#DBDCDD",
|
|
37
|
-
display: "flex",
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
<div
|
|
41
|
-
style={{
|
|
42
|
-
width: 58,
|
|
43
|
-
margin: "auto",
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
46
|
-
<KeypadButton {...args} onClickKey={action("pressed")} />
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
export const Default = Template.bind({});
|
|
51
|
-
|
|
52
|
-
export const AllButtons: ComponentStory<typeof KeypadButton> = ({
|
|
53
|
-
...args
|
|
54
|
-
}: KeypadButtonProps): React.ReactElement => (
|
|
55
|
-
<div
|
|
56
|
-
style={{
|
|
57
|
-
backgroundColor: "#DBDCDD",
|
|
58
|
-
display: "grid",
|
|
59
|
-
gridTemplateColumns: "repeat(6, 1fr)",
|
|
60
|
-
gap: "25px",
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
{Object.keys(KeyConfigs).map((key) => (
|
|
64
|
-
<div
|
|
65
|
-
key={key}
|
|
66
|
-
style={{
|
|
67
|
-
width: 58,
|
|
68
|
-
margin: "auto",
|
|
69
|
-
overflowWrap: "break-word",
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
{key}
|
|
73
|
-
<KeypadButton
|
|
74
|
-
keyConfig={KeyConfigs[key]}
|
|
75
|
-
onClickKey={action("pressed")}
|
|
76
|
-
coord={[0, 0]}
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
79
|
-
))}
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
@@ -1,124 +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 ButtonAsset from "./button-assets";
|
|
8
|
-
|
|
9
|
-
import type {KeyConfig, ClickKeyCallback} from "../../types";
|
|
10
|
-
import type {StyleType} from "@khanacademy/wonder-blocks-core";
|
|
11
|
-
|
|
12
|
-
export type KeypadButtonProps = {
|
|
13
|
-
// 0 indexed [x, y] position in keypad CSS grid
|
|
14
|
-
coord: readonly [number, number];
|
|
15
|
-
keyConfig: KeyConfig;
|
|
16
|
-
onClickKey: ClickKeyCallback;
|
|
17
|
-
// Apply action button styles
|
|
18
|
-
action?: boolean;
|
|
19
|
-
// Apply secondary button styles
|
|
20
|
-
secondary?: boolean;
|
|
21
|
-
style?: StyleType;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const KeypadButton = ({
|
|
25
|
-
coord,
|
|
26
|
-
keyConfig,
|
|
27
|
-
onClickKey,
|
|
28
|
-
style,
|
|
29
|
-
secondary,
|
|
30
|
-
action,
|
|
31
|
-
}: KeypadButtonProps): React.ReactElement => {
|
|
32
|
-
const tintColor = secondary ? "#F6F6F7" : action ? "#DBDCDD" : undefined;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<View
|
|
36
|
-
style={{
|
|
37
|
-
gridColumn: coord[0] + 1,
|
|
38
|
-
gridRow: coord[1] + 1,
|
|
39
|
-
...style,
|
|
40
|
-
}}
|
|
41
|
-
// Unfortunately the CDOT and TIMES buttons are identical in the DOM
|
|
42
|
-
// apart from the ICON SVG, so we need to use testId.
|
|
43
|
-
testId={keyConfig.id}
|
|
44
|
-
>
|
|
45
|
-
<Clickable
|
|
46
|
-
onClick={(e) => onClickKey(keyConfig.id, e)}
|
|
47
|
-
style={styles.clickable}
|
|
48
|
-
aria-label={keyConfig.ariaLabel}
|
|
49
|
-
>
|
|
50
|
-
{({hovered, focused, pressed}) => {
|
|
51
|
-
return (
|
|
52
|
-
<View style={[styles.outerBoxBase]}>
|
|
53
|
-
<View
|
|
54
|
-
style={[
|
|
55
|
-
styles.base,
|
|
56
|
-
tintColor != null
|
|
57
|
-
? {background: tintColor}
|
|
58
|
-
: undefined,
|
|
59
|
-
hovered && styles.hovered,
|
|
60
|
-
focused && styles.focused,
|
|
61
|
-
pressed && styles.pressed,
|
|
62
|
-
]}
|
|
63
|
-
>
|
|
64
|
-
<ButtonAsset id={keyConfig.id} />
|
|
65
|
-
</View>
|
|
66
|
-
</View>
|
|
67
|
-
);
|
|
68
|
-
}}
|
|
69
|
-
</Clickable>
|
|
70
|
-
</View>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const styles = StyleSheet.create({
|
|
75
|
-
base: {
|
|
76
|
-
display: "flex",
|
|
77
|
-
justifyContent: "center",
|
|
78
|
-
alignItems: "center",
|
|
79
|
-
boxShadow: `0px 1px 0px ${Color.offBlack32}`,
|
|
80
|
-
boxSizing: "border-box",
|
|
81
|
-
background: Color.white,
|
|
82
|
-
borderRadius: 4,
|
|
83
|
-
borderWidth: 2,
|
|
84
|
-
borderStyle: "solid",
|
|
85
|
-
borderColor: "transparent",
|
|
86
|
-
flex: 1,
|
|
87
|
-
minHeight: 42,
|
|
88
|
-
minWidth: 42,
|
|
89
|
-
padding: 1,
|
|
90
|
-
},
|
|
91
|
-
hovered: {
|
|
92
|
-
borderColor: Color.blue,
|
|
93
|
-
padding: 1,
|
|
94
|
-
boxShadow: "none",
|
|
95
|
-
},
|
|
96
|
-
focused: {
|
|
97
|
-
borderColor: Color.blue,
|
|
98
|
-
padding: 0,
|
|
99
|
-
boxShadow: "none",
|
|
100
|
-
},
|
|
101
|
-
pressed: {
|
|
102
|
-
border: "2px solid #1B50B3",
|
|
103
|
-
padding: 0,
|
|
104
|
-
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
|
|
105
|
-
boxShadow: "none",
|
|
106
|
-
},
|
|
107
|
-
outerBoxBase: {
|
|
108
|
-
padding: 1,
|
|
109
|
-
height: "100%",
|
|
110
|
-
width: "100%",
|
|
111
|
-
boxSizing: "border-box",
|
|
112
|
-
borderRadius: 7,
|
|
113
|
-
border: "2px solid transparent",
|
|
114
|
-
},
|
|
115
|
-
clickable: {
|
|
116
|
-
width: "100%",
|
|
117
|
-
height: "100%",
|
|
118
|
-
boxSizing: "border-box",
|
|
119
|
-
|
|
120
|
-
":focus": {
|
|
121
|
-
outline: `none`,
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import Color from "@khanacademy/wonder-blocks-color";
|
|
2
|
-
import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import {CursorContext} from "../input/cursor-contexts";
|
|
6
|
-
import {getCursorContext} from "../input/mathquill-helpers";
|
|
7
|
-
import {createMathField} from "../input/mathquill-instance";
|
|
8
|
-
import keyTranslator from "../key-handlers/key-translator";
|
|
9
|
-
|
|
10
|
-
import type Key from "../../data/keys";
|
|
11
|
-
import type {MathFieldInterface} from "../input/mathquill-types";
|
|
12
|
-
|
|
13
|
-
import Keypad from "./index";
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
title: "math-input/components/v2 Keypad With Mathquill",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function V2KeypadWithMathquill() {
|
|
20
|
-
const mathFieldWrapperRef = React.useRef<HTMLDivElement>(null);
|
|
21
|
-
const [mathField, setMathField] = React.useState<MathFieldInterface>();
|
|
22
|
-
const [keypadOpen, setKeypadOpen] = React.useState<boolean>(true);
|
|
23
|
-
const [cursorContext, setCursorContext] = React.useState<
|
|
24
|
-
typeof CursorContext[keyof typeof CursorContext]
|
|
25
|
-
>(CursorContext.NONE);
|
|
26
|
-
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (!mathField && mathFieldWrapperRef.current) {
|
|
29
|
-
const mathFieldInstance = createMathField(
|
|
30
|
-
mathFieldWrapperRef.current,
|
|
31
|
-
(baseConfig) => ({
|
|
32
|
-
...baseConfig,
|
|
33
|
-
handlers: {
|
|
34
|
-
edit: (_mathField: MathFieldInterface) => {
|
|
35
|
-
setCursorContext(getCursorContext(_mathField));
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}),
|
|
39
|
-
);
|
|
40
|
-
setMathField(mathFieldInstance);
|
|
41
|
-
}
|
|
42
|
-
}, [mathField]);
|
|
43
|
-
|
|
44
|
-
function handleClickKey(key: Key) {
|
|
45
|
-
if (!mathField) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (key === "DISMISS") {
|
|
50
|
-
setKeypadOpen(false);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const mathFieldCallback = keyTranslator[key];
|
|
54
|
-
if (mathFieldCallback) {
|
|
55
|
-
mathFieldCallback(mathField, key);
|
|
56
|
-
setCursorContext(getCursorContext(mathField));
|
|
57
|
-
} else {
|
|
58
|
-
// eslint-disable-next-line no-console
|
|
59
|
-
console.warn(`No translation to Mathquill for: ${key}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div style={{maxWidth: "400px", margin: "2em"}}>
|
|
65
|
-
<Popover
|
|
66
|
-
content={
|
|
67
|
-
<PopoverContentCore
|
|
68
|
-
style={{
|
|
69
|
-
padding: 10,
|
|
70
|
-
maxWidth: "initial",
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
73
|
-
<Keypad
|
|
74
|
-
extraKeys={["x", "y", "PI", "THETA"]}
|
|
75
|
-
onClickKey={handleClickKey}
|
|
76
|
-
cursorContext={cursorContext}
|
|
77
|
-
advancedRelations
|
|
78
|
-
basicRelations
|
|
79
|
-
divisionKey
|
|
80
|
-
logarithms
|
|
81
|
-
convertDotToTimes
|
|
82
|
-
preAlgebra
|
|
83
|
-
trigonometry
|
|
84
|
-
onAnalyticsEvent={async (event) => {
|
|
85
|
-
// eslint-disable-next-line no-console
|
|
86
|
-
console.log("Send Event:", event);
|
|
87
|
-
}}
|
|
88
|
-
showDismiss
|
|
89
|
-
/>
|
|
90
|
-
</PopoverContentCore>
|
|
91
|
-
}
|
|
92
|
-
dismissEnabled
|
|
93
|
-
opened={keypadOpen}
|
|
94
|
-
>
|
|
95
|
-
<div
|
|
96
|
-
style={{
|
|
97
|
-
width: "100%",
|
|
98
|
-
marginBottom: "1em",
|
|
99
|
-
border: `1px solid ${Color.offBlack16}`,
|
|
100
|
-
}}
|
|
101
|
-
ref={mathFieldWrapperRef}
|
|
102
|
-
/>
|
|
103
|
-
</Popover>
|
|
104
|
-
<button onClick={() => setKeypadOpen(!keypadOpen)}>
|
|
105
|
-
{keypadOpen ? "close keypad" : "open keypad"}
|
|
106
|
-
</button>
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {KeypadButton} from "../keypad-button";
|
|
5
|
-
|
|
6
|
-
import type Key from "../../../data/keys";
|
|
7
|
-
import type {ClickKeyCallback} from "../../../types";
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
extraKeys: ReadonlyArray<Key>;
|
|
11
|
-
onClickKey: ClickKeyCallback;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const columns = 3;
|
|
15
|
-
|
|
16
|
-
export default function ExtrasPage(props: Props) {
|
|
17
|
-
const {extraKeys, onClickKey} = props;
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
{extraKeys.map((key, i) => {
|
|
21
|
-
// Map 1D array to Cartesian coordinates
|
|
22
|
-
const coordX = i % columns;
|
|
23
|
-
const coordY = i / columns;
|
|
24
|
-
return (
|
|
25
|
-
<KeypadButton
|
|
26
|
-
key={key}
|
|
27
|
-
keyConfig={Keys[key]}
|
|
28
|
-
onClickKey={onClickKey}
|
|
29
|
-
coord={[coordX, coordY]}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
})}
|
|
33
|
-
</>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {KeypadButton} from "../keypad-button";
|
|
5
|
-
import {getCursorContextConfig} from "../utils";
|
|
6
|
-
|
|
7
|
-
import type {ClickKeyCallback} from "../../../types";
|
|
8
|
-
import type {CursorContext} from "../../input/cursor-contexts";
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
onClickKey: ClickKeyCallback;
|
|
12
|
-
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default function FractionsPage(props: Props) {
|
|
16
|
-
const {onClickKey, cursorContext} = props;
|
|
17
|
-
const cursorKeyConfig = getCursorContextConfig(cursorContext);
|
|
18
|
-
// These keys are arranged sequentially so that tabbing follows numerical order. This
|
|
19
|
-
// allows us to visually mimic a keypad without affecting a11y. The visual order of the
|
|
20
|
-
// keys in the keypad is determined by their coordinates, not their order in the DOM.
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
{/* Row 4 */}
|
|
24
|
-
<KeypadButton
|
|
25
|
-
keyConfig={Keys.NUM_1}
|
|
26
|
-
onClickKey={onClickKey}
|
|
27
|
-
coord={[0, 2]}
|
|
28
|
-
/>
|
|
29
|
-
<KeypadButton
|
|
30
|
-
keyConfig={Keys.NUM_2}
|
|
31
|
-
onClickKey={onClickKey}
|
|
32
|
-
coord={[1, 2]}
|
|
33
|
-
/>
|
|
34
|
-
<KeypadButton
|
|
35
|
-
keyConfig={Keys.NUM_3}
|
|
36
|
-
onClickKey={onClickKey}
|
|
37
|
-
coord={[2, 2]}
|
|
38
|
-
/>
|
|
39
|
-
|
|
40
|
-
{/* Row 3 */}
|
|
41
|
-
<KeypadButton
|
|
42
|
-
keyConfig={Keys.NUM_4}
|
|
43
|
-
onClickKey={onClickKey}
|
|
44
|
-
coord={[0, 1]}
|
|
45
|
-
/>
|
|
46
|
-
<KeypadButton
|
|
47
|
-
keyConfig={Keys.NUM_5}
|
|
48
|
-
onClickKey={onClickKey}
|
|
49
|
-
coord={[1, 1]}
|
|
50
|
-
/>
|
|
51
|
-
<KeypadButton
|
|
52
|
-
keyConfig={Keys.NUM_6}
|
|
53
|
-
onClickKey={onClickKey}
|
|
54
|
-
coord={[2, 1]}
|
|
55
|
-
/>
|
|
56
|
-
|
|
57
|
-
{/* Row 2 */}
|
|
58
|
-
<KeypadButton
|
|
59
|
-
keyConfig={Keys.NUM_7}
|
|
60
|
-
onClickKey={onClickKey}
|
|
61
|
-
coord={[0, 0]}
|
|
62
|
-
/>
|
|
63
|
-
<KeypadButton
|
|
64
|
-
keyConfig={Keys.NUM_8}
|
|
65
|
-
onClickKey={onClickKey}
|
|
66
|
-
coord={[1, 0]}
|
|
67
|
-
/>
|
|
68
|
-
<KeypadButton
|
|
69
|
-
keyConfig={Keys.NUM_9}
|
|
70
|
-
onClickKey={onClickKey}
|
|
71
|
-
coord={[2, 0]}
|
|
72
|
-
/>
|
|
73
|
-
|
|
74
|
-
{/* Row 1 */}
|
|
75
|
-
<KeypadButton
|
|
76
|
-
keyConfig={Keys.NUM_0}
|
|
77
|
-
onClickKey={onClickKey}
|
|
78
|
-
coord={[0, 3]}
|
|
79
|
-
/>
|
|
80
|
-
<KeypadButton
|
|
81
|
-
keyConfig={Keys.DECIMAL}
|
|
82
|
-
onClickKey={onClickKey}
|
|
83
|
-
coord={[1, 3]}
|
|
84
|
-
/>
|
|
85
|
-
<KeypadButton
|
|
86
|
-
keyConfig={Keys.NEGATIVE}
|
|
87
|
-
onClickKey={onClickKey}
|
|
88
|
-
coord={[2, 3]}
|
|
89
|
-
/>
|
|
90
|
-
{/* Side Column */}
|
|
91
|
-
<KeypadButton
|
|
92
|
-
keyConfig={Keys.PERCENT}
|
|
93
|
-
onClickKey={onClickKey}
|
|
94
|
-
coord={[3, 0]}
|
|
95
|
-
secondary
|
|
96
|
-
/>
|
|
97
|
-
<KeypadButton
|
|
98
|
-
keyConfig={Keys.PI}
|
|
99
|
-
onClickKey={onClickKey}
|
|
100
|
-
coord={[3, 1]}
|
|
101
|
-
secondary
|
|
102
|
-
/>
|
|
103
|
-
<KeypadButton
|
|
104
|
-
keyConfig={Keys.FRAC}
|
|
105
|
-
onClickKey={onClickKey}
|
|
106
|
-
coord={[3, 2]}
|
|
107
|
-
secondary
|
|
108
|
-
/>
|
|
109
|
-
{cursorKeyConfig && (
|
|
110
|
-
<KeypadButton
|
|
111
|
-
keyConfig={cursorKeyConfig}
|
|
112
|
-
onClickKey={onClickKey}
|
|
113
|
-
coord={[3, 3]}
|
|
114
|
-
secondary
|
|
115
|
-
/>
|
|
116
|
-
)}
|
|
117
|
-
<KeypadButton
|
|
118
|
-
keyConfig={Keys.BACKSPACE}
|
|
119
|
-
onClickKey={onClickKey}
|
|
120
|
-
coord={[4, 3]}
|
|
121
|
-
action
|
|
122
|
-
/>
|
|
123
|
-
</>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {KeypadButton} from "../keypad-button";
|
|
5
|
-
|
|
6
|
-
import type {ClickKeyCallback} from "../../../types";
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
onClickKey: ClickKeyCallback;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default function GeometryPage(props: Props) {
|
|
13
|
-
const {onClickKey} = props;
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
{/* Row 1 */}
|
|
17
|
-
<KeypadButton
|
|
18
|
-
keyConfig={Keys.SIN}
|
|
19
|
-
onClickKey={onClickKey}
|
|
20
|
-
coord={[0, 0]}
|
|
21
|
-
/>
|
|
22
|
-
<KeypadButton
|
|
23
|
-
keyConfig={Keys.COS}
|
|
24
|
-
onClickKey={onClickKey}
|
|
25
|
-
coord={[1, 0]}
|
|
26
|
-
/>
|
|
27
|
-
<KeypadButton
|
|
28
|
-
keyConfig={Keys.TAN}
|
|
29
|
-
onClickKey={onClickKey}
|
|
30
|
-
coord={[2, 0]}
|
|
31
|
-
/>
|
|
32
|
-
</>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import {withKnobs} from "@storybook/addon-knobs";
|
|
3
|
-
import {INITIAL_VIEWPORTS} from "@storybook/addon-viewport";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
import GeometryInputPage from "./geometry-page";
|
|
7
|
-
import NumbersPage from "./numbers-page";
|
|
8
|
-
import PrealgebraInputPage from "./operators-page";
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: "math-input/components/Keypad pages",
|
|
12
|
-
decorators: [withKnobs],
|
|
13
|
-
parameters: {
|
|
14
|
-
backgrounds: {
|
|
15
|
-
values: [{name: "light background", value: "white", default: true}],
|
|
16
|
-
},
|
|
17
|
-
viewport: {defaultViewport: "iphone6", viewports: INITIAL_VIEWPORTS},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const NumericInput = (): React.ReactElement => (
|
|
22
|
-
<NumbersPage onClickKey={action("onClickKey")} />
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export const PreAlgebraInput = (): React.ReactElement => (
|
|
26
|
-
<PrealgebraInputPage
|
|
27
|
-
onClickKey={action("onClickKey")}
|
|
28
|
-
preAlgebra={true}
|
|
29
|
-
logarithms={true}
|
|
30
|
-
basicRelations={true}
|
|
31
|
-
advancedRelations={true}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export const TrigonometryInput = (): React.ReactElement => (
|
|
36
|
-
<GeometryInputPage onClickKey={action("onClickKey")} />
|
|
37
|
-
);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import Keys from "../../../data/key-configs";
|
|
4
|
-
import {KeypadButton} from "../keypad-button";
|
|
5
|
-
|
|
6
|
-
import type {ClickKeyCallback} from "../../../types";
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
onClickKey: ClickKeyCallback;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default function NumbersPage(props: Props) {
|
|
13
|
-
const {onClickKey} = props;
|
|
14
|
-
// These keys are arranged sequentially so that tabbing follows numerical order. This
|
|
15
|
-
// allows us to visually mimic a keypad without affecting a11y. The visual order of the
|
|
16
|
-
// keys in the keypad is determined by their coordinates, not their order in the DOM.
|
|
17
|
-
return (
|
|
18
|
-
<>
|
|
19
|
-
{/* Row 4 */}
|
|
20
|
-
<KeypadButton
|
|
21
|
-
keyConfig={Keys.NUM_1}
|
|
22
|
-
onClickKey={onClickKey}
|
|
23
|
-
coord={[0, 2]}
|
|
24
|
-
/>
|
|
25
|
-
<KeypadButton
|
|
26
|
-
keyConfig={Keys.NUM_2}
|
|
27
|
-
onClickKey={onClickKey}
|
|
28
|
-
coord={[1, 2]}
|
|
29
|
-
/>
|
|
30
|
-
<KeypadButton
|
|
31
|
-
keyConfig={Keys.NUM_3}
|
|
32
|
-
onClickKey={onClickKey}
|
|
33
|
-
coord={[2, 2]}
|
|
34
|
-
/>
|
|
35
|
-
|
|
36
|
-
{/* Row 3 */}
|
|
37
|
-
<KeypadButton
|
|
38
|
-
keyConfig={Keys.NUM_4}
|
|
39
|
-
onClickKey={onClickKey}
|
|
40
|
-
coord={[0, 1]}
|
|
41
|
-
/>
|
|
42
|
-
<KeypadButton
|
|
43
|
-
keyConfig={Keys.NUM_5}
|
|
44
|
-
onClickKey={onClickKey}
|
|
45
|
-
coord={[1, 1]}
|
|
46
|
-
/>
|
|
47
|
-
<KeypadButton
|
|
48
|
-
keyConfig={Keys.NUM_6}
|
|
49
|
-
onClickKey={onClickKey}
|
|
50
|
-
coord={[2, 1]}
|
|
51
|
-
/>
|
|
52
|
-
|
|
53
|
-
{/* Row 2 */}
|
|
54
|
-
<KeypadButton
|
|
55
|
-
keyConfig={Keys.NUM_7}
|
|
56
|
-
onClickKey={onClickKey}
|
|
57
|
-
coord={[0, 0]}
|
|
58
|
-
/>
|
|
59
|
-
<KeypadButton
|
|
60
|
-
keyConfig={Keys.NUM_8}
|
|
61
|
-
onClickKey={onClickKey}
|
|
62
|
-
coord={[1, 0]}
|
|
63
|
-
/>
|
|
64
|
-
<KeypadButton
|
|
65
|
-
keyConfig={Keys.NUM_9}
|
|
66
|
-
onClickKey={onClickKey}
|
|
67
|
-
coord={[2, 0]}
|
|
68
|
-
/>
|
|
69
|
-
|
|
70
|
-
{/* Row 1 */}
|
|
71
|
-
<KeypadButton
|
|
72
|
-
keyConfig={Keys.NUM_0}
|
|
73
|
-
onClickKey={onClickKey}
|
|
74
|
-
coord={[0, 3]}
|
|
75
|
-
/>
|
|
76
|
-
<KeypadButton
|
|
77
|
-
keyConfig={Keys.DECIMAL}
|
|
78
|
-
onClickKey={onClickKey}
|
|
79
|
-
coord={[1, 3]}
|
|
80
|
-
/>
|
|
81
|
-
<KeypadButton
|
|
82
|
-
keyConfig={Keys.NEGATIVE}
|
|
83
|
-
onClickKey={onClickKey}
|
|
84
|
-
coord={[2, 3]}
|
|
85
|
-
/>
|
|
86
|
-
<KeypadButton
|
|
87
|
-
keyConfig={Keys.PERCENT}
|
|
88
|
-
onClickKey={onClickKey}
|
|
89
|
-
coord={[3, 0]}
|
|
90
|
-
secondary
|
|
91
|
-
/>
|
|
92
|
-
</>
|
|
93
|
-
);
|
|
94
|
-
}
|