@khanacademy/math-input 6.0.1 → 6.0.2
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 +8 -0
- package/dist/es/index.js +26 -1
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +63 -4
- package/src/components/keypad/index.tsx +22 -0
- package/src/components/keypad/keypad-mathquill.stories.tsx +10 -1
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { getDecimalSeparator } from '@khanacademy/wonder-blocks-i18n';
|
|
|
4
4
|
import { entries } from '@khanacademy/wonder-stuff-core';
|
|
5
5
|
import { StyleSheet, css } from 'aphrodite';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
+
import { useEffect } from 'react';
|
|
7
8
|
import ReactDOM from 'react-dom';
|
|
8
9
|
import $ from 'jquery';
|
|
9
10
|
import MathQuill from 'mathquill';
|
|
@@ -8597,6 +8598,7 @@ function allPages(props) {
|
|
|
8597
8598
|
// keypad to learners for entering math expressions.
|
|
8598
8599
|
function Keypad(props) {
|
|
8599
8600
|
const [selectedPage, setSelectedPage] = React.useState("Numbers");
|
|
8601
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
8600
8602
|
const availablePages = allPages(props);
|
|
8601
8603
|
const {
|
|
8602
8604
|
onClickKey,
|
|
@@ -8608,8 +8610,31 @@ function Keypad(props) {
|
|
|
8608
8610
|
logarithms,
|
|
8609
8611
|
basicRelations,
|
|
8610
8612
|
advancedRelations,
|
|
8611
|
-
showDismiss
|
|
8613
|
+
showDismiss,
|
|
8614
|
+
sendEvent
|
|
8612
8615
|
} = props;
|
|
8616
|
+
useEffect(() => {
|
|
8617
|
+
if (!isMounted) {
|
|
8618
|
+
sendEvent({
|
|
8619
|
+
type: "math-input:keypad-opened",
|
|
8620
|
+
payload: {
|
|
8621
|
+
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2"
|
|
8622
|
+
}
|
|
8623
|
+
});
|
|
8624
|
+
setIsMounted(true);
|
|
8625
|
+
}
|
|
8626
|
+
return () => {
|
|
8627
|
+
if (isMounted) {
|
|
8628
|
+
sendEvent({
|
|
8629
|
+
type: "math-input:keypad-closed",
|
|
8630
|
+
payload: {
|
|
8631
|
+
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2"
|
|
8632
|
+
}
|
|
8633
|
+
});
|
|
8634
|
+
setIsMounted(false);
|
|
8635
|
+
}
|
|
8636
|
+
};
|
|
8637
|
+
}, [sendEvent, isMounted]);
|
|
8613
8638
|
return /*#__PURE__*/React.createElement(View$1, null, /*#__PURE__*/React.createElement(Tabbar, {
|
|
8614
8639
|
items: availablePages,
|
|
8615
8640
|
selectedItem: selectedPage,
|