@khanacademy/math-input 12.1.1 → 13.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 +22 -0
- package/dist/components/keypad/keypad.d.ts +1 -1
- package/dist/components/keypad/mobile-keypad.d.ts +2 -1
- package/dist/components/keypad/shared-keys.d.ts +1 -1
- package/dist/es/index.js +30 -10
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -10
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/__tests__/integration.test.tsx +287 -0
- package/src/components/keypad/__tests__/__snapshots__/keypad.test.tsx.snap +84 -26
- package/src/components/keypad/__tests__/keypad-v2-mathquill.test.tsx +1 -1
- package/src/components/keypad/__tests__/keypad.test.tsx +30 -0
- package/src/components/keypad/keypad-button.stories.tsx +2 -1
- package/src/components/keypad/keypad-button.tsx +3 -0
- package/src/components/keypad/keypad-mathquill.stories.tsx +2 -2
- package/src/components/keypad/keypad-pages/fractions-page.tsx +1 -1
- package/src/components/keypad/keypad-pages/keypad-pages.stories.tsx +1 -1
- package/src/components/keypad/keypad.tsx +3 -3
- package/src/components/keypad/mobile-keypad.tsx +21 -4
- package/src/components/keypad/navigation-pad.stories.tsx +1 -1
- package/src/components/keypad/shared-keys.tsx +4 -4
- package/src/components/tabbar/tabbar.stories.tsx +4 -1
- package/src/{components/keypad/keypad.stories.tsx → full-keypad.stories.tsx} +6 -6
- package/src/{full-math-input.stories.tsx → full-mobile-input.stories.tsx} +15 -3
- package/src/index.ts +1 -1
- package/src/types.ts +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { default as MobileKeypad } from "./components/keypad-switch";
|
|
|
11
11
|
export { default as DesktopKeypad } from "./components/keypad";
|
|
12
12
|
export { default as KeypadContext } from "./components/keypad-context";
|
|
13
13
|
export { keypadElementPropType } from "./components/prop-types";
|
|
14
|
-
export type { KeypadAPI } from "./types";
|
|
14
|
+
export type { KeypadAPI, KeypadConfiguration } from "./types";
|
|
15
15
|
export type { default as Keys } from "./data/keys";
|
|
16
16
|
export { default as KeyConfigs } from "./data/key-configs";
|
|
17
17
|
export { type KeyType, KeypadType } from "./enums";
|
package/dist/index.js
CHANGED
|
@@ -4665,6 +4665,10 @@ const KeypadButton$2 = _ref => {
|
|
|
4665
4665
|
gridRow: coord[1] + 1,
|
|
4666
4666
|
...style
|
|
4667
4667
|
}
|
|
4668
|
+
// Unfortunately the CDOT and TIMES buttons are identical in the DOM
|
|
4669
|
+
// apart from the ICON SVG, so we need to use testId.
|
|
4670
|
+
,
|
|
4671
|
+
testId: keyConfig.id
|
|
4668
4672
|
}, /*#__PURE__*/React__namespace.createElement(Clickable__default["default"], {
|
|
4669
4673
|
onClick: e => onClickKey(keyConfig.id, e),
|
|
4670
4674
|
style: styles$g.clickable,
|
|
@@ -4853,7 +4857,7 @@ function FractionsPage(props) {
|
|
|
4853
4857
|
coord: [3, 1],
|
|
4854
4858
|
secondary: true
|
|
4855
4859
|
}), /*#__PURE__*/React__namespace.createElement(KeypadButton$2, {
|
|
4856
|
-
keyConfig: KeyConfigs.
|
|
4860
|
+
keyConfig: KeyConfigs.FRAC,
|
|
4857
4861
|
onClickKey: onClickKey,
|
|
4858
4862
|
coord: [3, 2],
|
|
4859
4863
|
secondary: true
|
|
@@ -5168,7 +5172,7 @@ function SharedKeys(props) {
|
|
|
5168
5172
|
onClickKey,
|
|
5169
5173
|
cursorContext,
|
|
5170
5174
|
divisionKey,
|
|
5171
|
-
|
|
5175
|
+
convertDotToTimes,
|
|
5172
5176
|
selectedPage
|
|
5173
5177
|
} = props;
|
|
5174
5178
|
const cursorKeyConfig = getCursorContextConfig(cursorContext);
|
|
@@ -5186,12 +5190,12 @@ function SharedKeys(props) {
|
|
|
5186
5190
|
coord: [5, 0],
|
|
5187
5191
|
secondary: true
|
|
5188
5192
|
}), /*#__PURE__*/React__namespace.createElement(KeypadButton$2, {
|
|
5189
|
-
keyConfig: KeyConfigs.
|
|
5193
|
+
keyConfig: KeyConfigs.FRAC,
|
|
5190
5194
|
onClickKey: onClickKey,
|
|
5191
5195
|
coord: fractionCoord,
|
|
5192
5196
|
secondary: true
|
|
5193
5197
|
}), /*#__PURE__*/React__namespace.createElement(KeypadButton$2, {
|
|
5194
|
-
keyConfig:
|
|
5198
|
+
keyConfig: convertDotToTimes ? KeyConfigs.TIMES : KeyConfigs.CDOT,
|
|
5195
5199
|
onClickKey: onClickKey,
|
|
5196
5200
|
coord: [4, 1],
|
|
5197
5201
|
secondary: true
|
|
@@ -5262,7 +5266,7 @@ function Keypad$2(props) {
|
|
|
5262
5266
|
onClickKey,
|
|
5263
5267
|
cursorContext,
|
|
5264
5268
|
extraKeys,
|
|
5265
|
-
|
|
5269
|
+
convertDotToTimes,
|
|
5266
5270
|
divisionKey,
|
|
5267
5271
|
preAlgebra,
|
|
5268
5272
|
logarithms,
|
|
@@ -5340,7 +5344,7 @@ function Keypad$2(props) {
|
|
|
5340
5344
|
}), !fractionsOnly && /*#__PURE__*/React__namespace.createElement(SharedKeys, {
|
|
5341
5345
|
onClickKey: onClickKey,
|
|
5342
5346
|
cursorContext: cursorContext,
|
|
5343
|
-
|
|
5347
|
+
convertDotToTimes: convertDotToTimes,
|
|
5344
5348
|
divisionKey: divisionKey,
|
|
5345
5349
|
selectedPage: selectedPage
|
|
5346
5350
|
})), expandedView && /*#__PURE__*/React__namespace.createElement(NavigationPad$1, {
|
|
@@ -5400,7 +5404,8 @@ class MobileKeypad extends React__namespace.Component {
|
|
|
5400
5404
|
_defineProperty(this, "hasMounted", false);
|
|
5401
5405
|
_defineProperty(this, "state", {
|
|
5402
5406
|
active: false,
|
|
5403
|
-
containerWidth: 0
|
|
5407
|
+
containerWidth: 0,
|
|
5408
|
+
hasBeenActivated: false
|
|
5404
5409
|
});
|
|
5405
5410
|
_defineProperty(this, "_resize", () => {
|
|
5406
5411
|
var _this$_containerRef$c;
|
|
@@ -5421,7 +5426,8 @@ class MobileKeypad extends React__namespace.Component {
|
|
|
5421
5426
|
});
|
|
5422
5427
|
_defineProperty(this, "activate", () => {
|
|
5423
5428
|
this.setState({
|
|
5424
|
-
active: true
|
|
5429
|
+
active: true,
|
|
5430
|
+
hasBeenActivated: true
|
|
5425
5431
|
});
|
|
5426
5432
|
});
|
|
5427
5433
|
_defineProperty(this, "dismiss", () => {
|
|
@@ -5476,7 +5482,7 @@ class MobileKeypad extends React__namespace.Component {
|
|
|
5476
5482
|
}
|
|
5477
5483
|
}
|
|
5478
5484
|
}
|
|
5479
|
-
|
|
5485
|
+
componentWillUnmount() {
|
|
5480
5486
|
var _this$_containerResiz;
|
|
5481
5487
|
window.removeEventListener("resize", this._throttleResizeHandler);
|
|
5482
5488
|
window.removeEventListener("orientationchange", this._throttleResizeHandler);
|
|
@@ -5499,6 +5505,7 @@ class MobileKeypad extends React__namespace.Component {
|
|
|
5499
5505
|
} = this.props;
|
|
5500
5506
|
const {
|
|
5501
5507
|
active,
|
|
5508
|
+
hasBeenActivated,
|
|
5502
5509
|
containerWidth,
|
|
5503
5510
|
cursor,
|
|
5504
5511
|
keypadConfig
|
|
@@ -5508,9 +5515,22 @@ class MobileKeypad extends React__namespace.Component {
|
|
|
5508
5515
|
styles$c.keypadContainer, active && styles$c.activeKeypadContainer,
|
|
5509
5516
|
// styles passed as props
|
|
5510
5517
|
...(Array.isArray(style) ? style : [style])];
|
|
5518
|
+
|
|
5519
|
+
// If the keypad is yet to have ever been activated, we keep it invisible
|
|
5520
|
+
// so as to avoid, e.g., the keypad flashing at the bottom of the page
|
|
5521
|
+
// during the initial render.
|
|
5522
|
+
// Done inline (dynamicStyle) since stylesheets might not be loaded yet.
|
|
5523
|
+
let dynamicStyle = {};
|
|
5524
|
+
if (!active && !hasBeenActivated) {
|
|
5525
|
+
dynamicStyle = {
|
|
5526
|
+
visibility: "hidden"
|
|
5527
|
+
};
|
|
5528
|
+
}
|
|
5511
5529
|
const isExpression = (keypadConfig === null || keypadConfig === void 0 ? void 0 : keypadConfig.keypadType) === "EXPRESSION";
|
|
5530
|
+
const convertDotToTimes = keypadConfig === null || keypadConfig === void 0 ? void 0 : keypadConfig.times;
|
|
5512
5531
|
return /*#__PURE__*/React__namespace.createElement(View, {
|
|
5513
5532
|
style: containerStyle,
|
|
5533
|
+
dynamicStyle: dynamicStyle,
|
|
5514
5534
|
forwardRef: this._containerRef,
|
|
5515
5535
|
ref: element => {
|
|
5516
5536
|
if (!this.hasMounted && element) {
|
|
@@ -5538,7 +5558,7 @@ class MobileKeypad extends React__namespace.Component {
|
|
|
5538
5558
|
onClickKey: key => this._handleClickKey(key),
|
|
5539
5559
|
cursorContext: cursor === null || cursor === void 0 ? void 0 : cursor.context,
|
|
5540
5560
|
fractionsOnly: !isExpression,
|
|
5541
|
-
|
|
5561
|
+
convertDotToTimes: convertDotToTimes,
|
|
5542
5562
|
divisionKey: isExpression,
|
|
5543
5563
|
trigonometry: isExpression,
|
|
5544
5564
|
preAlgebra: isExpression,
|