@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.
Files changed (46) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/components/input/math-input.d.ts +2 -2
  3. package/dist/components/input/math-input.js.flow +2 -2
  4. package/dist/components/keypad/index.d.ts +2 -26
  5. package/dist/components/keypad/index.js.flow +2 -31
  6. package/dist/components/keypad/keypad.d.ts +26 -0
  7. package/dist/components/keypad/keypad.js.flow +37 -0
  8. package/dist/components/keypad/mobile-keypad.d.ts +39 -0
  9. package/dist/components/keypad/mobile-keypad.js.flow +57 -0
  10. package/dist/components/keypad/shared-keys.d.ts +1 -1
  11. package/dist/components/keypad/shared-keys.js.flow +1 -1
  12. package/dist/components/keypad-legacy/index.d.ts +1 -0
  13. package/dist/components/keypad-legacy/index.js.flow +7 -0
  14. package/dist/components/keypad-legacy/provided-keypad.d.ts +2 -2
  15. package/dist/components/keypad-legacy/provided-keypad.js.flow +10 -2
  16. package/dist/components/keypad-legacy/touchable-keypad-button.d.ts +1 -1
  17. package/dist/components/keypad-legacy/touchable-keypad-button.js.flow +1 -1
  18. package/dist/components/keypad-legacy/two-page-keypad.d.ts +1 -1
  19. package/dist/components/keypad-legacy/two-page-keypad.js.flow +1 -1
  20. package/dist/components/tabbar/index.d.ts +2 -0
  21. package/dist/components/tabbar/index.js.flow +8 -0
  22. package/dist/es/index.js +306 -173
  23. package/dist/es/index.js.map +1 -1
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +322 -187
  26. package/dist/index.js.flow +9 -9
  27. package/dist/index.js.map +1 -1
  28. package/dist/types.d.ts +9 -0
  29. package/dist/types.js.flow +12 -0
  30. package/package.json +2 -2
  31. package/src/components/input/math-input.tsx +4 -5
  32. package/src/components/keypad/index.tsx +2 -173
  33. package/src/components/keypad/keypad.stories.tsx +2 -1
  34. package/src/components/keypad/keypad.tsx +171 -0
  35. package/src/components/keypad/mobile-keypad.tsx +165 -0
  36. package/src/components/keypad/shared-keys.tsx +1 -1
  37. package/src/components/keypad-legacy/index.ts +1 -0
  38. package/src/components/keypad-legacy/provided-keypad.tsx +7 -2
  39. package/src/components/keypad-legacy/two-page-keypad.tsx +3 -2
  40. package/src/components/prop-types.js +0 -1
  41. package/src/components/tabbar/index.ts +2 -0
  42. package/src/full-math-input.stories.tsx +78 -0
  43. package/src/index.ts +28 -9
  44. package/src/types.ts +11 -0
  45. package/tsconfig-build.tsbuildinfo +1 -1
  46. 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
- };