@khanacademy/math-input 9.0.0 → 10.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 +16 -0
- package/dist/components/keypad/keypad.d.ts +2 -2
- package/dist/components/keypad-legacy/keypad-container.d.ts +1 -0
- package/dist/es/index.js +13 -6
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +14 -10
- package/src/components/keypad/__tests__/keypad.test.tsx +7 -5
- package/src/components/keypad/keypad-mathquill.stories.tsx +1 -1
- package/src/components/keypad/keypad.tsx +6 -6
- package/src/components/keypad/mobile-keypad.tsx +1 -1
- package/src/components/keypad-legacy/keypad-container.tsx +10 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 10.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dd800c22: Rename analytics prop from onEvent to onAnalyticsEvent
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 5352d512: Handle keypad resize better when it's positioned absolutely
|
|
12
|
+
- 673f61b3: Introduce `dependencies` on Keypad.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [dd800c22]
|
|
17
|
+
- @khanacademy/perseus-core@0.2.0
|
|
18
|
+
|
|
3
19
|
## 9.0.0
|
|
4
20
|
|
|
5
21
|
### Major Changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type Key from "../../data/keys";
|
|
3
3
|
import type { ClickKeyCallback } from "../../types";
|
|
4
4
|
import type { CursorContext } from "../input/cursor-contexts";
|
|
5
|
-
import type {
|
|
5
|
+
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
6
6
|
export type Props = {
|
|
7
7
|
extraKeys: ReadonlyArray<Key>;
|
|
8
8
|
cursorContext?: typeof CursorContext[keyof typeof CursorContext];
|
|
@@ -16,7 +16,7 @@ export type Props = {
|
|
|
16
16
|
advancedRelations?: boolean;
|
|
17
17
|
fractionsOnly?: boolean;
|
|
18
18
|
onClickKey: ClickKeyCallback;
|
|
19
|
-
|
|
19
|
+
onAnalyticsEvent: AnalyticsEventHandlerFn;
|
|
20
20
|
};
|
|
21
21
|
declare function Keypad(props: Props): JSX.Element;
|
|
22
22
|
declare namespace Keypad {
|
|
@@ -20,6 +20,7 @@ type State = {
|
|
|
20
20
|
};
|
|
21
21
|
declare class KeypadContainer extends React.Component<Props, State> {
|
|
22
22
|
_containerRef: React.RefObject<HTMLDivElement>;
|
|
23
|
+
_containerResizeObserver: ResizeObserver | null;
|
|
23
24
|
_resizeTimeout: number | null | undefined;
|
|
24
25
|
hasMounted: boolean | undefined;
|
|
25
26
|
state: {
|
package/dist/es/index.js
CHANGED
|
@@ -4738,8 +4738,8 @@ function Keypad$2(props) {
|
|
|
4738
4738
|
basicRelations,
|
|
4739
4739
|
advancedRelations,
|
|
4740
4740
|
showDismiss,
|
|
4741
|
-
|
|
4742
|
-
|
|
4741
|
+
onAnalyticsEvent,
|
|
4742
|
+
fractionsOnly
|
|
4743
4743
|
} = props;
|
|
4744
4744
|
|
|
4745
4745
|
// Use a different grid for our fraction keypad
|
|
@@ -4751,7 +4751,7 @@ function Keypad$2(props) {
|
|
|
4751
4751
|
}, [fractionsOnly, defaultSelectedPage]);
|
|
4752
4752
|
useEffect(() => {
|
|
4753
4753
|
if (!isMounted) {
|
|
4754
|
-
|
|
4754
|
+
onAnalyticsEvent({
|
|
4755
4755
|
type: "math-input:keypad-opened",
|
|
4756
4756
|
payload: {
|
|
4757
4757
|
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2"
|
|
@@ -4761,7 +4761,7 @@ function Keypad$2(props) {
|
|
|
4761
4761
|
}
|
|
4762
4762
|
return () => {
|
|
4763
4763
|
if (isMounted) {
|
|
4764
|
-
|
|
4764
|
+
onAnalyticsEvent({
|
|
4765
4765
|
type: "math-input:keypad-closed",
|
|
4766
4766
|
payload: {
|
|
4767
4767
|
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V2"
|
|
@@ -4770,7 +4770,7 @@ function Keypad$2(props) {
|
|
|
4770
4770
|
setIsMounted(false);
|
|
4771
4771
|
}
|
|
4772
4772
|
};
|
|
4773
|
-
}, [
|
|
4773
|
+
}, [onAnalyticsEvent, isMounted]);
|
|
4774
4774
|
return /*#__PURE__*/React.createElement(View$1, null, /*#__PURE__*/React.createElement(Tabbar, {
|
|
4775
4775
|
items: availableTabs,
|
|
4776
4776
|
selectedItem: selectedPage,
|
|
@@ -4937,7 +4937,7 @@ class MobileKeypad extends React.Component {
|
|
|
4937
4937
|
}, /*#__PURE__*/React.createElement(Keypad$2
|
|
4938
4938
|
// TODO(jeremy)
|
|
4939
4939
|
, {
|
|
4940
|
-
|
|
4940
|
+
onAnalyticsEvent: async function () {},
|
|
4941
4941
|
extraKeys: keypadConfig == null ? void 0 : keypadConfig.extraKeys,
|
|
4942
4942
|
onClickKey: key => this._handleClickKey(key),
|
|
4943
4943
|
cursorContext: cursor == null ? void 0 : cursor.context,
|
|
@@ -7973,6 +7973,7 @@ class KeypadContainer extends React.Component {
|
|
|
7973
7973
|
constructor(...args) {
|
|
7974
7974
|
super(...args);
|
|
7975
7975
|
this._containerRef = /*#__PURE__*/React.createRef();
|
|
7976
|
+
this._containerResizeObserver = null;
|
|
7976
7977
|
this._resizeTimeout = void 0;
|
|
7977
7978
|
this.hasMounted = void 0;
|
|
7978
7979
|
this.state = {
|
|
@@ -8048,6 +8049,10 @@ class KeypadContainer extends React.Component {
|
|
|
8048
8049
|
// And update it on resize.
|
|
8049
8050
|
window.addEventListener("resize", this._throttleResizeHandler);
|
|
8050
8051
|
window.addEventListener("orientationchange", this._throttleResizeHandler);
|
|
8052
|
+
this._containerResizeObserver = new ResizeObserver(this._throttleResizeHandler);
|
|
8053
|
+
if (this._containerRef.current) {
|
|
8054
|
+
this._containerResizeObserver.observe(this._containerRef.current);
|
|
8055
|
+
}
|
|
8051
8056
|
}
|
|
8052
8057
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
8053
8058
|
if (!this.state.hasBeenActivated && nextProps.active) {
|
|
@@ -8062,8 +8067,10 @@ class KeypadContainer extends React.Component {
|
|
|
8062
8067
|
}
|
|
8063
8068
|
}
|
|
8064
8069
|
componentWillUnmount() {
|
|
8070
|
+
var _this$_containerResiz;
|
|
8065
8071
|
window.removeEventListener("resize", this._throttleResizeHandler);
|
|
8066
8072
|
window.removeEventListener("orientationchange", this._throttleResizeHandler);
|
|
8073
|
+
(_this$_containerResiz = this._containerResizeObserver) == null ? void 0 : _this$_containerResiz.disconnect();
|
|
8067
8074
|
}
|
|
8068
8075
|
render() {
|
|
8069
8076
|
const {
|