@khanacademy/math-input 11.0.0 → 12.1.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 +27 -0
- package/dist/components/keypad/mobile-keypad.d.ts +2 -0
- package/dist/components/keypad-legacy/provided-keypad.d.ts +2 -0
- package/dist/components/keypad-switch.d.ts +2 -0
- package/dist/es/index.js +39 -12
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +39 -12
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/keypad/mobile-keypad.tsx +15 -8
- package/src/components/keypad-legacy/keypad-container.tsx +11 -5
- package/src/components/keypad-legacy/provided-keypad.tsx +21 -3
- package/src/components/keypad-switch.tsx +5 -0
- package/src/full-math-input.stories.tsx +2 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @khanacademy/math-input
|
|
2
2
|
|
|
3
|
+
## 12.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a5a60852: revert focus changes to math input
|
|
8
|
+
|
|
9
|
+
## 12.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a383823d: Bump @khanacademy/wonder-stuff-core to v1.5.1 (which adds needed support for `isTruthy` helper function)
|
|
14
|
+
|
|
15
|
+
## 12.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- fa5f463b: Added onAnalyticsEvent prop to the LegacyKeypad (aka ProvidedKeypad). You must now pass in this prop, which is a function, to handle analytics events originating from the legacy keypad.
|
|
20
|
+
- 6d8ede65: Added `onAnalyticsEvent` prop to MobileKeypad to pipe out Perseus analytics
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- fa1bb6b4: Implemented some focus management fixes and improved the full-math-input story.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 3afc0da2: Check for ResizeObserver before using it
|
|
29
|
+
|
|
3
30
|
## 11.0.0
|
|
4
31
|
|
|
5
32
|
### Major Changes
|
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import type Key from "../../data/keys";
|
|
4
4
|
import type { Cursor, KeypadConfiguration, KeyHandler, KeypadAPI } from "../../types";
|
|
5
|
+
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
5
6
|
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
6
7
|
/**
|
|
7
8
|
* This is the v2 equivalent of v1's ProvidedKeypad. It follows the same
|
|
@@ -17,6 +18,7 @@ type Props = {
|
|
|
17
18
|
onElementMounted?: (arg1: any) => void;
|
|
18
19
|
onDismiss?: () => void;
|
|
19
20
|
style?: StyleType;
|
|
21
|
+
onAnalyticsEvent: AnalyticsEventHandlerFn;
|
|
20
22
|
};
|
|
21
23
|
type State = {
|
|
22
24
|
active: boolean;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
import type { Cursor, KeypadConfiguration, KeyHandler, KeypadAPI } from "../../types";
|
|
4
|
+
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
4
5
|
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
5
6
|
type Props = {
|
|
6
7
|
onElementMounted?: (arg1: any) => void;
|
|
7
8
|
onDismiss?: () => void;
|
|
8
9
|
style?: StyleType;
|
|
10
|
+
onAnalyticsEvent: AnalyticsEventHandlerFn;
|
|
9
11
|
};
|
|
10
12
|
declare class ProvidedKeypad extends React.Component<Props> implements KeypadAPI {
|
|
11
13
|
store: any;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
|
|
2
3
|
import type { StyleType } from "@khanacademy/wonder-blocks-core";
|
|
3
4
|
type Props = {
|
|
4
5
|
onElementMounted?: (arg1: any) => void;
|
|
5
6
|
onDismiss?: () => void;
|
|
6
7
|
style?: StyleType;
|
|
7
8
|
useV2Keypad?: boolean;
|
|
9
|
+
onAnalyticsEvent: AnalyticsEventHandlerFn;
|
|
8
10
|
};
|
|
9
11
|
declare function KeypadSwitch(props: Props): JSX.Element;
|
|
10
12
|
export default KeypadSwitch;
|
package/dist/es/index.js
CHANGED
|
@@ -5167,9 +5167,14 @@ class MobileKeypad extends React.Component {
|
|
|
5167
5167
|
this._resize();
|
|
5168
5168
|
window.addEventListener("resize", this._throttleResizeHandler);
|
|
5169
5169
|
window.addEventListener("orientationchange", this._throttleResizeHandler);
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5170
|
+
|
|
5171
|
+
// LC-1213: some common older browsers (as of 2023-09-07)
|
|
5172
|
+
// don't support ResizeObserver
|
|
5173
|
+
if ("ResizeObserver" in window) {
|
|
5174
|
+
this._containerResizeObserver = new window.ResizeObserver(this._throttleResizeHandler);
|
|
5175
|
+
if (this._containerRef.current) {
|
|
5176
|
+
this._containerResizeObserver.observe(this._containerRef.current);
|
|
5177
|
+
}
|
|
5173
5178
|
}
|
|
5174
5179
|
}
|
|
5175
5180
|
componentWillUnMount() {
|
|
@@ -5227,10 +5232,8 @@ class MobileKeypad extends React.Component {
|
|
|
5227
5232
|
(_this$props$onElement = (_this$props2 = this.props).onElementMounted) == null ? void 0 : _this$props$onElement.call(_this$props2, elementWithDispatchMethods);
|
|
5228
5233
|
}
|
|
5229
5234
|
}
|
|
5230
|
-
}, /*#__PURE__*/React.createElement(Keypad$2
|
|
5231
|
-
|
|
5232
|
-
, {
|
|
5233
|
-
onAnalyticsEvent: async function () {},
|
|
5235
|
+
}, /*#__PURE__*/React.createElement(Keypad$2, {
|
|
5236
|
+
onAnalyticsEvent: this.props.onAnalyticsEvent,
|
|
5234
5237
|
extraKeys: keypadConfig == null ? void 0 : keypadConfig.extraKeys,
|
|
5235
5238
|
onClickKey: key => this._handleClickKey(key),
|
|
5236
5239
|
cursorContext: cursor == null ? void 0 : cursor.context,
|
|
@@ -8345,9 +8348,14 @@ class KeypadContainer extends React.Component {
|
|
|
8345
8348
|
// And update it on resize.
|
|
8346
8349
|
window.addEventListener("resize", this._throttleResizeHandler);
|
|
8347
8350
|
window.addEventListener("orientationchange", this._throttleResizeHandler);
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
+
|
|
8352
|
+
// LC-1213: some common older browsers (as of 2023-09-07)
|
|
8353
|
+
// don't support ResizeObserver
|
|
8354
|
+
if ("ResizeObserver" in window) {
|
|
8355
|
+
this._containerResizeObserver = new window.ResizeObserver(this._throttleResizeHandler);
|
|
8356
|
+
if (this._containerRef.current) {
|
|
8357
|
+
this._containerResizeObserver.observe(this._containerRef.current);
|
|
8358
|
+
}
|
|
8351
8359
|
}
|
|
8352
8360
|
}
|
|
8353
8361
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
@@ -9695,6 +9703,13 @@ class ProvidedKeypad extends React.Component {
|
|
|
9695
9703
|
store: this.store
|
|
9696
9704
|
}, /*#__PURE__*/React.createElement(KeypadContainer$1, {
|
|
9697
9705
|
onElementMounted: element => {
|
|
9706
|
+
this.props.onAnalyticsEvent({
|
|
9707
|
+
type: "math-input:keypad-opened",
|
|
9708
|
+
payload: {
|
|
9709
|
+
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1"
|
|
9710
|
+
}
|
|
9711
|
+
});
|
|
9712
|
+
|
|
9698
9713
|
// Append the dispatch methods that we want to expose
|
|
9699
9714
|
// externally to the returned React element.
|
|
9700
9715
|
const elementWithDispatchMethods = _extends({}, element, {
|
|
@@ -9705,9 +9720,17 @@ class ProvidedKeypad extends React.Component {
|
|
|
9705
9720
|
setKeyHandler: this.setKeyHandler,
|
|
9706
9721
|
getDOMNode: this.getDOMNode
|
|
9707
9722
|
});
|
|
9708
|
-
onElementMounted
|
|
9723
|
+
onElementMounted == null ? void 0 : onElementMounted(elementWithDispatchMethods);
|
|
9724
|
+
},
|
|
9725
|
+
onDismiss: () => {
|
|
9726
|
+
this.props.onAnalyticsEvent({
|
|
9727
|
+
type: "math-input:keypad-closed",
|
|
9728
|
+
payload: {
|
|
9729
|
+
virtualKeypadVersion: "MATH_INPUT_KEYPAD_V1"
|
|
9730
|
+
}
|
|
9731
|
+
});
|
|
9732
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
9709
9733
|
},
|
|
9710
|
-
onDismiss: onDismiss,
|
|
9711
9734
|
style: style
|
|
9712
9735
|
}));
|
|
9713
9736
|
}
|
|
@@ -9720,6 +9743,10 @@ function KeypadSwitch(props) {
|
|
|
9720
9743
|
} = props,
|
|
9721
9744
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
9722
9745
|
const KeypadComponent = useV2Keypad ? MobileKeypad : ProvidedKeypad;
|
|
9746
|
+
|
|
9747
|
+
// Note: Although we pass the "onAnalyticsEvent" to both keypad components,
|
|
9748
|
+
// only the current one uses it. There's no point in instrumenting the
|
|
9749
|
+
// legacy keypad given that it's on its way out the door.
|
|
9723
9750
|
return /*#__PURE__*/React.createElement(KeypadComponent, rest);
|
|
9724
9751
|
}
|
|
9725
9752
|
|