@khanacademy/math-input 6.0.2 → 7.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 +21 -0
- package/dist/components/input/math-input.d.ts +2 -2
- package/dist/components/input/math-input.js.flow +2 -2
- package/dist/components/keypad/index.d.ts +2 -26
- package/dist/components/keypad/index.js.flow +2 -31
- package/dist/components/keypad/keypad.d.ts +26 -0
- package/dist/components/keypad/keypad.js.flow +37 -0
- package/dist/components/keypad/mobile-keypad.d.ts +39 -0
- package/dist/components/keypad/mobile-keypad.js.flow +57 -0
- package/dist/components/keypad/shared-keys.d.ts +1 -1
- package/dist/components/keypad/shared-keys.js.flow +1 -1
- package/dist/components/keypad-legacy/index.d.ts +1 -0
- package/dist/components/keypad-legacy/index.js.flow +7 -0
- package/dist/components/keypad-legacy/provided-keypad.d.ts +2 -2
- package/dist/components/keypad-legacy/provided-keypad.js.flow +10 -2
- package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +1 -1
- package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +1 -1
- package/dist/components/keypad-legacy/two-page-keypad.d.ts +1 -1
- package/dist/components/keypad-legacy/two-page-keypad.js.flow +1 -1
- package/dist/components/tabbar/index.d.ts +2 -0
- package/dist/components/tabbar/index.js.flow +8 -0
- package/dist/es/index.js +306 -173
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +322 -187
- package/dist/index.js.flow +9 -9
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.js.flow +12 -0
- package/package.json +2 -2
- package/src/components/input/math-input.tsx +4 -5
- package/src/components/keypad/index.tsx +2 -173
- package/src/components/keypad/keypad.stories.tsx +2 -1
- package/src/components/keypad/keypad.tsx +171 -0
- package/src/components/keypad/mobile-keypad.tsx +165 -0
- package/src/components/keypad/shared-keys.tsx +1 -1
- package/src/components/keypad-legacy/index.ts +1 -0
- package/src/components/keypad-legacy/provided-keypad.tsx +7 -2
- package/src/components/keypad-legacy/two-page-keypad.tsx +3 -2
- package/src/components/prop-types.js +0 -1
- package/src/components/tabbar/index.ts +2 -0
- package/src/full-math-input.stories.tsx +78 -0
- package/src/index.ts +28 -9
- package/src/types.ts +11 -0
- package/tsconfig-build.tsbuildinfo +1 -1
- package/src/math-input.stories.tsx +0 -67
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
import {LegacyKeypad, KeypadInput, KeypadType} from "./index";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "Full MathInput",
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Basic = () => {
|
|
10
|
-
const [value, setValue] = React.useState("");
|
|
11
|
-
const [keypadElement, setKeypadElement] = React.useState<any>(null);
|
|
12
|
-
const [keypadType, setKeypadType] = React.useState<KeypadType>(
|
|
13
|
-
KeypadType.EXPRESSION,
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
keypadElement?.configure({
|
|
18
|
-
keypadType: keypadType,
|
|
19
|
-
extraKeys: ["x", "y", "PI", "THETA"],
|
|
20
|
-
});
|
|
21
|
-
}, [keypadElement, keypadType]);
|
|
22
|
-
|
|
23
|
-
function handleChangeKeypadType() {
|
|
24
|
-
setKeypadType(
|
|
25
|
-
keypadType === KeypadType.FRACTION
|
|
26
|
-
? KeypadType.EXPRESSION
|
|
27
|
-
: KeypadType.FRACTION,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div>
|
|
33
|
-
<div style={{padding: "1rem 0"}}>
|
|
34
|
-
<button onClick={handleChangeKeypadType}>
|
|
35
|
-
{`Use ${
|
|
36
|
-
keypadType === KeypadType.FRACTION
|
|
37
|
-
? "Expression"
|
|
38
|
-
: "Fraction"
|
|
39
|
-
} Keypad`}
|
|
40
|
-
</button>
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<KeypadInput
|
|
44
|
-
value={value}
|
|
45
|
-
keypadElement={keypadElement}
|
|
46
|
-
onChange={(newValue, callback) => {
|
|
47
|
-
setValue(newValue);
|
|
48
|
-
callback();
|
|
49
|
-
}}
|
|
50
|
-
onFocus={() => {
|
|
51
|
-
keypadElement?.activate();
|
|
52
|
-
}}
|
|
53
|
-
onBlur={() => {
|
|
54
|
-
keypadElement?.dismiss();
|
|
55
|
-
}}
|
|
56
|
-
/>
|
|
57
|
-
|
|
58
|
-
<LegacyKeypad
|
|
59
|
-
onElementMounted={(node) => {
|
|
60
|
-
if (node && !keypadElement) {
|
|
61
|
-
setKeypadElement(node);
|
|
62
|
-
}
|
|
63
|
-
}}
|
|
64
|
-
/>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
};
|