@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.
Files changed (99) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/components/input/math-wrapper.d.ts +1 -1
  3. package/dist/components/input/math-wrapper.js.flow +1 -1
  4. package/dist/components/input/mathquill-instance.d.ts +14 -3
  5. package/dist/components/input/mathquill-instance.js.flow +18 -3
  6. package/dist/components/input/mathquill-types.d.ts +30 -6
  7. package/dist/components/input/mathquill-types.js.flow +33 -7
  8. package/dist/components/key-handlers/handle-arrow.d.ts +3 -0
  9. package/dist/components/{input/key-handlers → key-handlers}/handle-arrow.js.flow +2 -2
  10. package/dist/components/{input/key-handlers → key-handlers}/handle-backspace.d.ts +1 -1
  11. package/dist/components/{input/key-handlers → key-handlers}/handle-backspace.js.flow +1 -1
  12. package/dist/components/key-handlers/handle-exponent.d.ts +3 -0
  13. package/dist/components/{input/key-handlers → key-handlers}/handle-exponent.js.flow +2 -2
  14. package/dist/components/{input/key-handlers → key-handlers}/handle-jump-out.d.ts +2 -2
  15. package/dist/components/{input/key-handlers → key-handlers}/handle-jump-out.js.flow +2 -2
  16. package/dist/components/key-handlers/key-translator.d.ts +4 -0
  17. package/dist/components/{key-translator.js.flow → key-handlers/key-translator.js.flow} +3 -3
  18. package/dist/components/keypad/index.d.ts +8 -16
  19. package/dist/components/keypad/index.js.flow +10 -22
  20. package/dist/components/keypad/keypad-button.d.ts +12 -0
  21. package/dist/components/keypad/keypad-button.js.flow +18 -0
  22. package/dist/components/keypad/keypad-pages/extras-page.d.ts +9 -0
  23. package/dist/components/keypad/{operators-page/basic-relations-buttons.js.flow → keypad-pages/extras-page.js.flow} +3 -3
  24. package/dist/components/keypad/keypad-pages/geometry-page.d.ts +7 -0
  25. package/dist/components/keypad/{operators-page/logarithms-buttons.js.flow → keypad-pages/geometry-page.js.flow} +1 -3
  26. package/dist/components/keypad/keypad-pages/numbers-page.d.ts +7 -0
  27. package/dist/components/keypad/{operators-page/pre-algebra-buttons.js.flow → keypad-pages/numbers-page.js.flow} +1 -3
  28. package/dist/components/keypad/keypad-pages/operators-page.d.ts +11 -0
  29. package/dist/components/keypad/{geometry-page/index.js.flow → keypad-pages/operators-page.js.flow} +5 -4
  30. package/dist/components/keypad/shared-keys.d.ts +9 -0
  31. package/dist/components/keypad/{numbers-page/types.js.flow → shared-keys.js.flow} +4 -1
  32. package/dist/es/index.js +763 -878
  33. package/dist/es/index.js.map +1 -1
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.js +740 -878
  36. package/dist/index.js.flow +6 -1
  37. package/dist/index.js.map +1 -1
  38. package/package.json +2 -3
  39. package/src/components/input/__tests__/test-math-wrapper.ts +2 -5
  40. package/src/components/input/math-input.tsx +10 -14
  41. package/src/components/input/math-wrapper.ts +23 -49
  42. package/src/components/input/mathquill-helpers.ts +11 -11
  43. package/src/components/input/mathquill-instance.ts +57 -2
  44. package/src/components/input/mathquill-types.ts +43 -7
  45. package/src/components/{input/key-handlers → key-handlers}/handle-arrow.ts +6 -6
  46. package/src/components/{input/key-handlers → key-handlers}/handle-backspace.ts +19 -17
  47. package/src/components/{input/key-handlers → key-handlers}/handle-exponent.ts +8 -5
  48. package/src/components/{input/key-handlers → key-handlers}/handle-jump-out.ts +15 -10
  49. package/src/components/{key-translator.ts → key-handlers/key-translator.ts} +43 -28
  50. package/src/components/keypad/__tests__/{KeypadButton.test.tsx → keypad-button.test.tsx} +7 -5
  51. package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +231 -0
  52. package/src/components/keypad/__tests__/keypad-v2.cypress.ts +19 -6
  53. package/src/components/keypad/index.tsx +73 -49
  54. package/src/components/keypad/{button.stories.tsx → keypad-button.stories.tsx} +2 -1
  55. package/src/components/keypad/keypad-button.tsx +128 -0
  56. package/src/components/keypad/keypad-mathquill.stories.tsx +24 -26
  57. package/src/components/keypad/keypad-pages/extras-page.tsx +34 -0
  58. package/src/components/keypad/keypad-pages/geometry-page.tsx +33 -0
  59. package/src/components/keypad/keypad-pages/numbers-page.tsx +84 -0
  60. package/src/components/keypad/keypad-pages/operators-page.tsx +116 -0
  61. package/src/components/keypad/shared-keys.tsx +78 -0
  62. package/src/index.ts +6 -1
  63. package/tsconfig-build.tsbuildinfo +1 -1
  64. package/dist/components/input/key-handlers/handle-arrow.d.ts +0 -3
  65. package/dist/components/input/key-handlers/handle-exponent.d.ts +0 -3
  66. package/dist/components/key-translator.d.ts +0 -4
  67. package/dist/components/keypad/button.d.ts +0 -12
  68. package/dist/components/keypad/button.js.flow +0 -18
  69. package/dist/components/keypad/extras-page/index.d.ts +0 -10
  70. package/dist/components/keypad/extras-page/index.js.flow +0 -15
  71. package/dist/components/keypad/geometry-page/index.d.ts +0 -9
  72. package/dist/components/keypad/keypad-page-items.d.ts +0 -26
  73. package/dist/components/keypad/keypad-page-items.js.flow +0 -40
  74. package/dist/components/keypad/numbers-page/index.d.ts +0 -10
  75. package/dist/components/keypad/numbers-page/index.js.flow +0 -18
  76. package/dist/components/keypad/numbers-page/types.d.ts +0 -4
  77. package/dist/components/keypad/operators-page/advanced-relations-buttons.d.ts +0 -8
  78. package/dist/components/keypad/operators-page/advanced-relations-buttons.js.flow +0 -13
  79. package/dist/components/keypad/operators-page/basic-relations-buttons.d.ts +0 -8
  80. package/dist/components/keypad/operators-page/index.d.ts +0 -10
  81. package/dist/components/keypad/operators-page/index.js.flow +0 -18
  82. package/dist/components/keypad/operators-page/logarithms-buttons.d.ts +0 -8
  83. package/dist/components/keypad/operators-page/pre-algebra-buttons.d.ts +0 -8
  84. package/dist/components/keypad/operators-page/types.d.ts +0 -6
  85. package/dist/components/keypad/operators-page/types.js.flow +0 -12
  86. package/src/components/keypad/__tests__/Button.test.tsx +0 -51
  87. package/src/components/keypad/button.tsx +0 -108
  88. package/src/components/keypad/extras-page/index.tsx +0 -27
  89. package/src/components/keypad/geometry-page/index.tsx +0 -89
  90. package/src/components/keypad/keypad-page-items.tsx +0 -118
  91. package/src/components/keypad/numbers-page/index.tsx +0 -136
  92. package/src/components/keypad/numbers-page/types.ts +0 -4
  93. package/src/components/keypad/operators-page/advanced-relations-buttons.tsx +0 -33
  94. package/src/components/keypad/operators-page/basic-relations-buttons.tsx +0 -33
  95. package/src/components/keypad/operators-page/index.tsx +0 -94
  96. package/src/components/keypad/operators-page/logarithms-buttons.tsx +0 -33
  97. package/src/components/keypad/operators-page/pre-algebra-buttons.tsx +0 -37
  98. package/src/components/keypad/operators-page/types.ts +0 -6
  99. /package/src/components/keypad/{keypad-pages.stories.tsx → keypad-pages/keypad-pages.stories.tsx} +0 -0
@@ -0,0 +1,128 @@
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 {KeyConfig, ClickKeyCallback} from "../../types";
8
+
9
+ import ButtonAsset from "./button-assets";
10
+
11
+ import type {StyleType} from "@khanacademy/wonder-blocks-core";
12
+
13
+ export type KeypadButtonProps = {
14
+ // 0 indexed [x, y] position in keypad CSS grid
15
+ coord: readonly [number, number];
16
+ keyConfig: KeyConfig;
17
+ onClickKey: ClickKeyCallback;
18
+ // Apply action button styles
19
+ action?: boolean;
20
+ // Apply secondary button styles
21
+ secondary?: boolean;
22
+ style?: StyleType;
23
+ };
24
+
25
+ export const KeypadButton = ({
26
+ coord,
27
+ keyConfig,
28
+ onClickKey,
29
+ style,
30
+ secondary,
31
+ action,
32
+ }: KeypadButtonProps): React.ReactElement => {
33
+ const tintColor = secondary ? "#F6F6F7" : action ? "#DBDCDD" : undefined;
34
+
35
+ return (
36
+ <View
37
+ style={{
38
+ gridColumn: coord[0] + 1,
39
+ gridRow: coord[1] + 1,
40
+ ...style,
41
+ }}
42
+ >
43
+ <Clickable
44
+ onClick={() => onClickKey(keyConfig.id)}
45
+ style={styles.clickable}
46
+ aria-label={keyConfig.ariaLabel}
47
+ >
48
+ {({hovered, focused, pressed}) => {
49
+ return (
50
+ <View
51
+ style={[
52
+ styles.outerBoxBase,
53
+ hovered && styles.outerBoxHover,
54
+ pressed && styles.outerBoxPressed,
55
+ ]}
56
+ >
57
+ <View
58
+ style={[
59
+ styles.base,
60
+ tintColor != null
61
+ ? {background: tintColor}
62
+ : undefined,
63
+ hovered && styles.hovered,
64
+ focused && styles.focused,
65
+ pressed && styles.pressed,
66
+ ]}
67
+ >
68
+ <ButtonAsset id={keyConfig.id} />
69
+ </View>
70
+ </View>
71
+ );
72
+ }}
73
+ </Clickable>
74
+ </View>
75
+ );
76
+ };
77
+
78
+ const styles = StyleSheet.create({
79
+ base: {
80
+ display: "flex",
81
+ justifyContent: "center",
82
+ alignItems: "center",
83
+ boxShadow: "0px 1px 0px rgba(33, 36, 44, 0.32)",
84
+ boxSizing: "border-box",
85
+ background: Color.white,
86
+ borderRadius: 4,
87
+ border: `1px solid transparent`,
88
+ flex: 1,
89
+ minHeight: 42,
90
+ minWidth: 42,
91
+ padding: 1,
92
+ },
93
+ hovered: {
94
+ border: `1px solid ${Color.blue}`,
95
+ padding: 1,
96
+ boxShadow: "none",
97
+ },
98
+ focused: {
99
+ border: `2px solid ${Color.blue}`,
100
+ padding: 0,
101
+ boxShadow: "none",
102
+ },
103
+ pressed: {
104
+ border: "2px solid #1B50B3",
105
+ padding: 0,
106
+ background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${Color.white}`,
107
+ boxShadow: "none",
108
+ },
109
+ outerBoxBase: {
110
+ padding: 1,
111
+ height: "100%",
112
+ width: "100%",
113
+ boxSizing: "border-box",
114
+ borderRadius: 7,
115
+ border: "2px solid transparent",
116
+ },
117
+ outerBoxHover: {
118
+ border: `2px solid ${Color.blue}`,
119
+ },
120
+ outerBoxPressed: {
121
+ border: "2px solid #1B50B3",
122
+ },
123
+ clickable: {
124
+ width: "100%",
125
+ height: "100%",
126
+ boxSizing: "border-box",
127
+ },
128
+ });
@@ -1,10 +1,11 @@
1
1
  import Color from "@khanacademy/wonder-blocks-color";
2
- import {Popover} from "@khanacademy/wonder-blocks-popover";
3
- import MathQuill from "mathquill";
2
+ import {Popover, PopoverContentCore} from "@khanacademy/wonder-blocks-popover";
4
3
  import * as React from "react";
5
4
 
6
5
  import Key from "../../data/keys";
7
- import keyTranslator from "../key-translator";
6
+ import {createMathField} from "../input/mathquill-instance";
7
+ import {MathFieldInterface} from "../input/mathquill-types";
8
+ import keyTranslator from "../key-handlers/key-translator";
8
9
 
9
10
  import Keypad from "./index";
10
11
 
@@ -12,36 +13,27 @@ export default {
12
13
  title: "v2 Keypad With Mathquill",
13
14
  };
14
15
 
15
- const mathQuillConfig = {
16
- autoCommands: "pi theta phi sqrt nthroot",
17
- charsThatBreakOutOfSupSub: "+-*/=<>≠≤≥",
18
- supSubsRequireOperand: true,
19
- spaceBehavesLikeTab: true,
20
- };
21
-
22
16
  export function V2KeypadWithMathquill() {
23
- const mathquillWrapperRef = React.useRef<HTMLDivElement>(null);
24
- const [mathQuill, setMathQuill] = React.useState<MathQuill>();
17
+ const mathFieldWrapperRef = React.useRef<HTMLDivElement>(null);
18
+ const [mathField, setMathField] = React.useState<MathFieldInterface>();
25
19
 
26
20
  React.useEffect(() => {
27
- if (!mathQuill && mathquillWrapperRef.current) {
28
- const MQ = MathQuill.getInterface(2);
29
- const mathQuillInstance = MQ.MathField(
30
- mathquillWrapperRef.current,
31
- mathQuillConfig,
21
+ if (!mathField && mathFieldWrapperRef.current) {
22
+ const mathFieldInstance = createMathField(
23
+ mathFieldWrapperRef.current,
32
24
  );
33
- setMathQuill(mathQuillInstance);
25
+ setMathField(mathFieldInstance);
34
26
  }
35
- }, [mathQuill]);
27
+ }, [mathField]);
36
28
 
37
29
  function handleClickKey(key: Key) {
38
- if (!mathQuill) {
30
+ if (!mathField) {
39
31
  return;
40
32
  }
41
33
 
42
- const mathQuillCallback = keyTranslator[key];
43
- if (mathQuillCallback) {
44
- mathQuillCallback(mathQuill, key);
34
+ const mathFieldCallback = keyTranslator[key];
35
+ if (mathFieldCallback) {
36
+ mathFieldCallback(mathField, key);
45
37
  } else {
46
38
  // eslint-disable-next-line no-console
47
39
  console.warn(`No translation to Mathquill for: ${key}`);
@@ -52,7 +44,12 @@ export function V2KeypadWithMathquill() {
52
44
  <div style={{maxWidth: "400px", margin: "2em"}}>
53
45
  <Popover
54
46
  content={
55
- <div>
47
+ <PopoverContentCore
48
+ style={{
49
+ padding: 10,
50
+ maxWidth: "initial",
51
+ }}
52
+ >
56
53
  <Keypad
57
54
  extraKeys={["a", "b", "c"]}
58
55
  onClickKey={handleClickKey}
@@ -64,9 +61,10 @@ export function V2KeypadWithMathquill() {
64
61
  preAlgebra
65
62
  trigonometry
66
63
  />
67
- </div>
64
+ </PopoverContentCore>
68
65
  }
69
66
  dismissEnabled
67
+ opened
70
68
  >
71
69
  <div
72
70
  style={{
@@ -74,7 +72,7 @@ export function V2KeypadWithMathquill() {
74
72
  marginBottom: "1em",
75
73
  border: `1px solid ${Color.offBlack16}`,
76
74
  }}
77
- ref={mathquillWrapperRef}
75
+ ref={mathFieldWrapperRef}
78
76
  />
79
77
  </Popover>
80
78
  </div>
@@ -0,0 +1,34 @@
1
+ import * as React from "react";
2
+
3
+ import Keys from "../../../data/key-configs";
4
+ import Key from "../../../data/keys";
5
+ import {ClickKeyCallback} from "../../../types";
6
+ import {KeypadButton} from "../keypad-button";
7
+
8
+ type Props = {
9
+ extraKeys: ReadonlyArray<Key>;
10
+ onClickKey: ClickKeyCallback;
11
+ };
12
+
13
+ const columns = 4;
14
+
15
+ export default function ExtrasPage(props: Props) {
16
+ const {extraKeys, onClickKey} = props;
17
+ return (
18
+ <>
19
+ {extraKeys.map((key, i) => {
20
+ // Map 1D array to Cartesian coordinates
21
+ const coordX = i % columns;
22
+ const coordY = i / columns;
23
+ return (
24
+ <KeypadButton
25
+ key={key}
26
+ keyConfig={Keys[key]}
27
+ onClickKey={onClickKey}
28
+ coord={[coordX, coordY]}
29
+ />
30
+ );
31
+ })}
32
+ </>
33
+ );
34
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from "react";
2
+
3
+ import Keys from "../../../data/key-configs";
4
+ import {ClickKeyCallback} from "../../../types";
5
+ import {KeypadButton} from "../keypad-button";
6
+
7
+ type Props = {
8
+ onClickKey: ClickKeyCallback;
9
+ };
10
+
11
+ export default function GeometryPage(props: Props) {
12
+ const {onClickKey} = props;
13
+ return (
14
+ <>
15
+ {/* Row 1 */}
16
+ <KeypadButton
17
+ keyConfig={Keys.SIN}
18
+ onClickKey={onClickKey}
19
+ coord={[0, 0]}
20
+ />
21
+ <KeypadButton
22
+ keyConfig={Keys.COS}
23
+ onClickKey={onClickKey}
24
+ coord={[1, 0]}
25
+ />
26
+ <KeypadButton
27
+ keyConfig={Keys.TAN}
28
+ onClickKey={onClickKey}
29
+ coord={[2, 0]}
30
+ />
31
+ </>
32
+ );
33
+ }
@@ -0,0 +1,84 @@
1
+ import * as React from "react";
2
+
3
+ import Keys from "../../../data/key-configs";
4
+ import {ClickKeyCallback} from "../../../types";
5
+ import {KeypadButton} from "../keypad-button";
6
+
7
+ type Props = {
8
+ onClickKey: ClickKeyCallback;
9
+ };
10
+
11
+ export default function NumbersPage(props: Props) {
12
+ const {onClickKey} = props;
13
+ return (
14
+ <>
15
+ {/* Row 1 */}
16
+ <KeypadButton
17
+ keyConfig={Keys.NUM_7}
18
+ onClickKey={onClickKey}
19
+ coord={[0, 0]}
20
+ />
21
+ <KeypadButton
22
+ keyConfig={Keys.NUM_8}
23
+ onClickKey={onClickKey}
24
+ coord={[1, 0]}
25
+ />
26
+ <KeypadButton
27
+ keyConfig={Keys.NUM_9}
28
+ onClickKey={onClickKey}
29
+ coord={[2, 0]}
30
+ />
31
+
32
+ {/* Row 2 */}
33
+ <KeypadButton
34
+ keyConfig={Keys.NUM_4}
35
+ onClickKey={onClickKey}
36
+ coord={[0, 1]}
37
+ />
38
+ <KeypadButton
39
+ keyConfig={Keys.NUM_5}
40
+ onClickKey={onClickKey}
41
+ coord={[1, 1]}
42
+ />
43
+ <KeypadButton
44
+ keyConfig={Keys.NUM_6}
45
+ onClickKey={onClickKey}
46
+ coord={[2, 1]}
47
+ />
48
+
49
+ {/* Row 3 */}
50
+ <KeypadButton
51
+ keyConfig={Keys.NUM_1}
52
+ onClickKey={onClickKey}
53
+ coord={[0, 2]}
54
+ />
55
+ <KeypadButton
56
+ keyConfig={Keys.NUM_2}
57
+ onClickKey={onClickKey}
58
+ coord={[1, 2]}
59
+ />
60
+ <KeypadButton
61
+ keyConfig={Keys.NUM_3}
62
+ onClickKey={onClickKey}
63
+ coord={[2, 2]}
64
+ />
65
+
66
+ {/* Row 4 */}
67
+ <KeypadButton
68
+ keyConfig={Keys.NUM_0}
69
+ onClickKey={onClickKey}
70
+ coord={[0, 3]}
71
+ />
72
+ <KeypadButton
73
+ keyConfig={Keys.DECIMAL}
74
+ onClickKey={onClickKey}
75
+ coord={[1, 3]}
76
+ />
77
+ <KeypadButton
78
+ keyConfig={Keys.NEGATIVE}
79
+ onClickKey={onClickKey}
80
+ coord={[2, 3]}
81
+ />
82
+ </>
83
+ );
84
+ }
@@ -0,0 +1,116 @@
1
+ import * as React from "react";
2
+
3
+ import Keys from "../../../data/key-configs";
4
+ import {ClickKeyCallback} from "../../../types";
5
+ import {KeypadButton} from "../keypad-button";
6
+
7
+ type Props = {
8
+ onClickKey: ClickKeyCallback;
9
+ preAlgebra?: boolean;
10
+ logarithms?: boolean;
11
+ basicRelations?: boolean;
12
+ advancedRelations?: boolean;
13
+ };
14
+
15
+ export default function OperatorsPage(props: Props) {
16
+ const {
17
+ onClickKey,
18
+ preAlgebra,
19
+ logarithms,
20
+ basicRelations,
21
+ advancedRelations,
22
+ } = props;
23
+
24
+ return (
25
+ <>
26
+ {/* Row 1 */}
27
+ {preAlgebra && (
28
+ <>
29
+ <KeypadButton
30
+ keyConfig={Keys.EXP_2}
31
+ onClickKey={onClickKey}
32
+ coord={[0, 0]}
33
+ />
34
+ <KeypadButton
35
+ keyConfig={Keys.EXP}
36
+ onClickKey={onClickKey}
37
+ coord={[1, 0]}
38
+ />
39
+ <KeypadButton
40
+ keyConfig={Keys.SQRT}
41
+ onClickKey={onClickKey}
42
+ coord={[2, 0]}
43
+ />
44
+ <KeypadButton
45
+ keyConfig={Keys.RADICAL}
46
+ onClickKey={onClickKey}
47
+ coord={[3, 0]}
48
+ />
49
+ </>
50
+ )}
51
+
52
+ {/* Row 2 */}
53
+ {logarithms && (
54
+ <>
55
+ <KeypadButton
56
+ keyConfig={Keys.LOG}
57
+ onClickKey={onClickKey}
58
+ coord={[0, 1]}
59
+ />
60
+ <KeypadButton
61
+ keyConfig={Keys.LOG_N}
62
+ onClickKey={onClickKey}
63
+ coord={[1, 1]}
64
+ />
65
+ <KeypadButton
66
+ keyConfig={Keys.LN}
67
+ onClickKey={onClickKey}
68
+ coord={[2, 1]}
69
+ />
70
+ </>
71
+ )}
72
+
73
+ {/* Row 3 */}
74
+ {basicRelations && (
75
+ <>
76
+ <KeypadButton
77
+ keyConfig={Keys.EQUAL}
78
+ onClickKey={onClickKey}
79
+ coord={[0, 2]}
80
+ />
81
+ <KeypadButton
82
+ keyConfig={Keys.LT}
83
+ onClickKey={onClickKey}
84
+ coord={[1, 2]}
85
+ />
86
+ <KeypadButton
87
+ keyConfig={Keys.GT}
88
+ onClickKey={onClickKey}
89
+ coord={[2, 2]}
90
+ />
91
+ </>
92
+ )}
93
+
94
+ {/* Row 4 */}
95
+ {advancedRelations && (
96
+ <>
97
+ <KeypadButton
98
+ keyConfig={Keys.NEQ}
99
+ onClickKey={onClickKey}
100
+ coord={[0, 3]}
101
+ />
102
+ <KeypadButton
103
+ keyConfig={Keys.LEQ}
104
+ onClickKey={onClickKey}
105
+ coord={[1, 3]}
106
+ />
107
+ <KeypadButton
108
+ keyConfig={Keys.GEQ}
109
+ onClickKey={onClickKey}
110
+ coord={[2, 3]}
111
+ />
112
+ </>
113
+ )}
114
+ </>
115
+ );
116
+ }
@@ -0,0 +1,78 @@
1
+ import * as React from "react";
2
+
3
+ import Keys from "../../data/key-configs";
4
+ import {ClickKeyCallback} from "../../types";
5
+
6
+ import {KeypadButton} from "./keypad-button";
7
+
8
+ type Props = {
9
+ onClickKey: ClickKeyCallback;
10
+ multiplicationDot?: boolean;
11
+ divisionKey?: boolean;
12
+ };
13
+
14
+ export default function SharedKeys(props: Props) {
15
+ const {onClickKey, divisionKey, multiplicationDot} = props;
16
+
17
+ return (
18
+ <>
19
+ {/* Row 1 */}
20
+ <KeypadButton
21
+ keyConfig={Keys.PLUS}
22
+ onClickKey={onClickKey}
23
+ coord={[4, 0]}
24
+ secondary
25
+ />
26
+ <KeypadButton
27
+ keyConfig={Keys.MINUS}
28
+ onClickKey={onClickKey}
29
+ coord={[5, 0]}
30
+ secondary
31
+ />
32
+
33
+ {/* Row 2 */}
34
+ <KeypadButton
35
+ keyConfig={multiplicationDot ? Keys.CDOT : Keys.TIMES}
36
+ onClickKey={onClickKey}
37
+ coord={[4, 1]}
38
+ secondary
39
+ />
40
+ {divisionKey && (
41
+ <KeypadButton
42
+ keyConfig={Keys.DIVIDE}
43
+ onClickKey={onClickKey}
44
+ coord={[5, 1]}
45
+ secondary
46
+ />
47
+ )}
48
+
49
+ {/* Row 3 */}
50
+ <KeypadButton
51
+ keyConfig={Keys.LEFT_PAREN}
52
+ onClickKey={onClickKey}
53
+ coord={[4, 2]}
54
+ secondary
55
+ />
56
+ <KeypadButton
57
+ keyConfig={Keys.RIGHT_PAREN}
58
+ onClickKey={onClickKey}
59
+ coord={[5, 2]}
60
+ secondary
61
+ />
62
+
63
+ {/* Row 4 */}
64
+ <KeypadButton
65
+ keyConfig={Keys.FRAC_INCLUSIVE}
66
+ onClickKey={onClickKey}
67
+ coord={[4, 3]}
68
+ secondary
69
+ />
70
+ <KeypadButton
71
+ keyConfig={Keys.BACKSPACE}
72
+ onClickKey={onClickKey}
73
+ coord={[5, 3]}
74
+ action
75
+ />
76
+ </>
77
+ );
78
+ }
package/src/index.ts CHANGED
@@ -13,4 +13,9 @@ export type {default as Keys} from "./data/keys";
13
13
  export {type KeyType, KeypadType} from "./enums";
14
14
 
15
15
  export {default as Keypad} from "./components/keypad/index";
16
- export {default as keyTranslator} from "./components/key-translator";
16
+ export {default as keyTranslator} from "./components/key-handlers/key-translator";
17
+ export {
18
+ createMathField,
19
+ mathQuillInstance,
20
+ } from "./components/input/mathquill-instance";
21
+ export {type MathFieldInterface} from "./components/input/mathquill-types";