@khanacademy/math-input 17.2.3 → 17.4.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/dist/components/aphrodite-css-transition-group/types.d.ts +1 -0
- package/dist/components/input/math-input.d.ts +5 -4
- package/dist/es/index.js +29 -10
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/text.d.ts +1 -0
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -47,7 +47,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
47
47
|
|
|
48
48
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
49
49
|
const libName = "@khanacademy/math-input";
|
|
50
|
-
const libVersion = "17.
|
|
50
|
+
const libVersion = "17.4.0";
|
|
51
51
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
52
52
|
|
|
53
53
|
function _extends() {
|
|
@@ -1526,6 +1526,7 @@ class MathInput extends React__namespace.Component {
|
|
|
1526
1526
|
};
|
|
1527
1527
|
state = {
|
|
1528
1528
|
focused: false,
|
|
1529
|
+
showInputFocusStyle: false,
|
|
1529
1530
|
handle: {
|
|
1530
1531
|
animateIntoPosition: false,
|
|
1531
1532
|
visible: false,
|
|
@@ -1608,6 +1609,8 @@ class MathInput extends React__namespace.Component {
|
|
|
1608
1609
|
// multi-touch.
|
|
1609
1610
|
if (this.state.focused && this.didTouchOutside && !this.didScroll) {
|
|
1610
1611
|
this.blur();
|
|
1612
|
+
this.mathField.blur();
|
|
1613
|
+
this.props.onBlur?.();
|
|
1611
1614
|
}
|
|
1612
1615
|
this.didTouchOutside = false;
|
|
1613
1616
|
this.didScroll = false;
|
|
@@ -1632,6 +1635,7 @@ class MathInput extends React__namespace.Component {
|
|
|
1632
1635
|
// in which case we don't want to dismiss the keypad on check.
|
|
1633
1636
|
if (!isWithinKeypadBounds(x, y)) {
|
|
1634
1637
|
this.blur();
|
|
1638
|
+
this.props.onBlur && this.props.onBlur();
|
|
1635
1639
|
}
|
|
1636
1640
|
}
|
|
1637
1641
|
}
|
|
@@ -1726,15 +1730,14 @@ class MathInput extends React__namespace.Component {
|
|
|
1726
1730
|
};
|
|
1727
1731
|
blur = () => {
|
|
1728
1732
|
this.mathField.blur();
|
|
1729
|
-
this.props.onBlur && this.props.onBlur();
|
|
1730
1733
|
this.setState({
|
|
1731
|
-
|
|
1734
|
+
showInputFocusStyle: false,
|
|
1732
1735
|
handle: {
|
|
1733
1736
|
visible: false
|
|
1734
1737
|
}
|
|
1735
1738
|
});
|
|
1736
1739
|
};
|
|
1737
|
-
focus =
|
|
1740
|
+
focus = setKeypadActive => {
|
|
1738
1741
|
// Pass this component's handleKey method to the keypad so it can call
|
|
1739
1742
|
// it whenever it needs to trigger a keypress action.
|
|
1740
1743
|
this.props.keypadElement?.setKeyHandler(key => {
|
|
@@ -1761,8 +1764,10 @@ class MathInput extends React__namespace.Component {
|
|
|
1761
1764
|
});
|
|
1762
1765
|
this.mathField.focus();
|
|
1763
1766
|
this.props?.onFocus();
|
|
1767
|
+
setKeypadActive(true);
|
|
1764
1768
|
this.setState({
|
|
1765
|
-
focused: true
|
|
1769
|
+
focused: true,
|
|
1770
|
+
showInputFocusStyle: true
|
|
1766
1771
|
}, () => {
|
|
1767
1772
|
// NOTE(charlie): We use `setTimeout` to allow for a layout pass to
|
|
1768
1773
|
// occur. Otherwise, the keypad is measured incorrectly. Ideally,
|
|
@@ -1975,7 +1980,7 @@ class MathInput extends React__namespace.Component {
|
|
|
1975
1980
|
|
|
1976
1981
|
// Trigger a focus event, if we're not already focused.
|
|
1977
1982
|
if (!this.state.focused) {
|
|
1978
|
-
this.focus();
|
|
1983
|
+
this.focus(setKeypadActive);
|
|
1979
1984
|
}
|
|
1980
1985
|
|
|
1981
1986
|
// If the user clicked on the input using a mouse or tap gesture,
|
|
@@ -2013,7 +2018,7 @@ class MathInput extends React__namespace.Component {
|
|
|
2013
2018
|
|
|
2014
2019
|
// Trigger a focus event, if we're not already focused.
|
|
2015
2020
|
if (!this.state.focused) {
|
|
2016
|
-
this.focus();
|
|
2021
|
+
this.focus(setKeypadActive);
|
|
2017
2022
|
}
|
|
2018
2023
|
|
|
2019
2024
|
// If the user clicked on the input using a mouse or tap gesture,
|
|
@@ -2218,7 +2223,7 @@ class MathInput extends React__namespace.Component {
|
|
|
2218
2223
|
};
|
|
2219
2224
|
render() {
|
|
2220
2225
|
const {
|
|
2221
|
-
|
|
2226
|
+
showInputFocusStyle,
|
|
2222
2227
|
handle
|
|
2223
2228
|
} = this.state;
|
|
2224
2229
|
const {
|
|
@@ -2227,7 +2232,7 @@ class MathInput extends React__namespace.Component {
|
|
|
2227
2232
|
const innerStyle = {
|
|
2228
2233
|
...inlineStyles.innerContainer,
|
|
2229
2234
|
borderWidth: this.getBorderWidthPx(),
|
|
2230
|
-
...(
|
|
2235
|
+
...(showInputFocusStyle ? {
|
|
2231
2236
|
borderColor: Color__default["default"].blue
|
|
2232
2237
|
} : {}),
|
|
2233
2238
|
...style
|
|
@@ -2266,13 +2271,17 @@ class MathInput extends React__namespace.Component {
|
|
|
2266
2271
|
ref: node => {
|
|
2267
2272
|
this.inputRef = node;
|
|
2268
2273
|
},
|
|
2274
|
+
onFocus: () => {
|
|
2275
|
+
this.focus(setKeypadActive);
|
|
2276
|
+
},
|
|
2277
|
+
onBlur: this.blur,
|
|
2269
2278
|
onKeyUp: this.handleKeyUp
|
|
2270
2279
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
2271
2280
|
ref: node => {
|
|
2272
2281
|
this._mathContainer = ReactDOM__default["default"].findDOMNode(node);
|
|
2273
2282
|
},
|
|
2274
2283
|
style: innerStyle
|
|
2275
|
-
})),
|
|
2284
|
+
})), showInputFocusStyle && handle.visible && /*#__PURE__*/React__namespace.createElement(CursorHandle, _extends({}, handle, {
|
|
2276
2285
|
onTouchStart: this.onCursorHandleTouchStart,
|
|
2277
2286
|
onTouchMove: this.onCursorHandleTouchMove,
|
|
2278
2287
|
onTouchEnd: this.onCursorHandleTouchEnd,
|
|
@@ -4787,6 +4796,13 @@ const KeypadButton = _ref => {
|
|
|
4787
4796
|
testId: keyConfig.id
|
|
4788
4797
|
}, /*#__PURE__*/React__namespace.createElement(Clickable__default["default"], {
|
|
4789
4798
|
onClick: e => onClickKey(keyConfig.id, e),
|
|
4799
|
+
onMouseDown: e =>
|
|
4800
|
+
// Prevent the default behavior of forcing the focus to the
|
|
4801
|
+
// button when it is clicked. This way, the focus can
|
|
4802
|
+
// remain on the input field-- for mouse only. The focus
|
|
4803
|
+
// should still shift for keyboard nav.
|
|
4804
|
+
// (The focus shift happens on mouse down, not on click.)
|
|
4805
|
+
e.preventDefault(),
|
|
4790
4806
|
style: styles$4.clickable,
|
|
4791
4807
|
"aria-label": keyConfig.ariaLabel
|
|
4792
4808
|
}, _ref2 => {
|