@khanacademy/math-input 17.3.0 → 17.4.1
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 +48 -36
- package/dist/es/index.js.map +1 -1
- package/dist/fake-react-native-web/text.d.ts +1 -0
- package/dist/index.js +45 -37
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var perseusCore = require('@khanacademy/perseus-core');
|
|
6
|
-
var Color = require('@khanacademy/wonder-blocks-color');
|
|
7
6
|
var i18n = require('@khanacademy/wonder-blocks-i18n');
|
|
7
|
+
var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
|
|
8
8
|
var wonderStuffCore = require('@khanacademy/wonder-stuff-core');
|
|
9
9
|
var aphrodite = require('aphrodite');
|
|
10
10
|
var React = require('react');
|
|
@@ -37,7 +37,6 @@ function _interopNamespace(e) {
|
|
|
37
37
|
return Object.freeze(n);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
41
40
|
var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n);
|
|
42
41
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
43
42
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
@@ -47,7 +46,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
47
46
|
|
|
48
47
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
49
48
|
const libName = "@khanacademy/math-input";
|
|
50
|
-
const libVersion = "17.
|
|
49
|
+
const libVersion = "17.4.1";
|
|
51
50
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
52
51
|
|
|
53
52
|
function _extends() {
|
|
@@ -1526,6 +1525,7 @@ class MathInput extends React__namespace.Component {
|
|
|
1526
1525
|
};
|
|
1527
1526
|
state = {
|
|
1528
1527
|
focused: false,
|
|
1528
|
+
showInputFocusStyle: false,
|
|
1529
1529
|
handle: {
|
|
1530
1530
|
animateIntoPosition: false,
|
|
1531
1531
|
visible: false,
|
|
@@ -1608,6 +1608,8 @@ class MathInput extends React__namespace.Component {
|
|
|
1608
1608
|
// multi-touch.
|
|
1609
1609
|
if (this.state.focused && this.didTouchOutside && !this.didScroll) {
|
|
1610
1610
|
this.blur();
|
|
1611
|
+
this.mathField.blur();
|
|
1612
|
+
this.props.onBlur?.();
|
|
1611
1613
|
}
|
|
1612
1614
|
this.didTouchOutside = false;
|
|
1613
1615
|
this.didScroll = false;
|
|
@@ -1632,6 +1634,7 @@ class MathInput extends React__namespace.Component {
|
|
|
1632
1634
|
// in which case we don't want to dismiss the keypad on check.
|
|
1633
1635
|
if (!isWithinKeypadBounds(x, y)) {
|
|
1634
1636
|
this.blur();
|
|
1637
|
+
this.props.onBlur && this.props.onBlur();
|
|
1635
1638
|
}
|
|
1636
1639
|
}
|
|
1637
1640
|
}
|
|
@@ -1726,15 +1729,14 @@ class MathInput extends React__namespace.Component {
|
|
|
1726
1729
|
};
|
|
1727
1730
|
blur = () => {
|
|
1728
1731
|
this.mathField.blur();
|
|
1729
|
-
this.props.onBlur && this.props.onBlur();
|
|
1730
1732
|
this.setState({
|
|
1731
|
-
|
|
1733
|
+
showInputFocusStyle: false,
|
|
1732
1734
|
handle: {
|
|
1733
1735
|
visible: false
|
|
1734
1736
|
}
|
|
1735
1737
|
});
|
|
1736
1738
|
};
|
|
1737
|
-
focus =
|
|
1739
|
+
focus = setKeypadActive => {
|
|
1738
1740
|
// Pass this component's handleKey method to the keypad so it can call
|
|
1739
1741
|
// it whenever it needs to trigger a keypress action.
|
|
1740
1742
|
this.props.keypadElement?.setKeyHandler(key => {
|
|
@@ -1761,8 +1763,10 @@ class MathInput extends React__namespace.Component {
|
|
|
1761
1763
|
});
|
|
1762
1764
|
this.mathField.focus();
|
|
1763
1765
|
this.props?.onFocus();
|
|
1766
|
+
setKeypadActive(true);
|
|
1764
1767
|
this.setState({
|
|
1765
|
-
focused: true
|
|
1768
|
+
focused: true,
|
|
1769
|
+
showInputFocusStyle: true
|
|
1766
1770
|
}, () => {
|
|
1767
1771
|
// NOTE(charlie): We use `setTimeout` to allow for a layout pass to
|
|
1768
1772
|
// occur. Otherwise, the keypad is measured incorrectly. Ideally,
|
|
@@ -1975,7 +1979,7 @@ class MathInput extends React__namespace.Component {
|
|
|
1975
1979
|
|
|
1976
1980
|
// Trigger a focus event, if we're not already focused.
|
|
1977
1981
|
if (!this.state.focused) {
|
|
1978
|
-
this.focus();
|
|
1982
|
+
this.focus(setKeypadActive);
|
|
1979
1983
|
}
|
|
1980
1984
|
|
|
1981
1985
|
// If the user clicked on the input using a mouse or tap gesture,
|
|
@@ -2013,7 +2017,7 @@ class MathInput extends React__namespace.Component {
|
|
|
2013
2017
|
|
|
2014
2018
|
// Trigger a focus event, if we're not already focused.
|
|
2015
2019
|
if (!this.state.focused) {
|
|
2016
|
-
this.focus();
|
|
2020
|
+
this.focus(setKeypadActive);
|
|
2017
2021
|
}
|
|
2018
2022
|
|
|
2019
2023
|
// If the user clicked on the input using a mouse or tap gesture,
|
|
@@ -2218,7 +2222,7 @@ class MathInput extends React__namespace.Component {
|
|
|
2218
2222
|
};
|
|
2219
2223
|
render() {
|
|
2220
2224
|
const {
|
|
2221
|
-
|
|
2225
|
+
showInputFocusStyle,
|
|
2222
2226
|
handle
|
|
2223
2227
|
} = this.state;
|
|
2224
2228
|
const {
|
|
@@ -2227,8 +2231,8 @@ class MathInput extends React__namespace.Component {
|
|
|
2227
2231
|
const innerStyle = {
|
|
2228
2232
|
...inlineStyles.innerContainer,
|
|
2229
2233
|
borderWidth: this.getBorderWidthPx(),
|
|
2230
|
-
...(
|
|
2231
|
-
borderColor:
|
|
2234
|
+
...(showInputFocusStyle ? {
|
|
2235
|
+
borderColor: wonderBlocksTokens.color.blue
|
|
2232
2236
|
} : {}),
|
|
2233
2237
|
...style
|
|
2234
2238
|
};
|
|
@@ -2266,13 +2270,17 @@ class MathInput extends React__namespace.Component {
|
|
|
2266
2270
|
ref: node => {
|
|
2267
2271
|
this.inputRef = node;
|
|
2268
2272
|
},
|
|
2273
|
+
onFocus: () => {
|
|
2274
|
+
this.focus(setKeypadActive);
|
|
2275
|
+
},
|
|
2276
|
+
onBlur: this.blur,
|
|
2269
2277
|
onKeyUp: this.handleKeyUp
|
|
2270
2278
|
}, /*#__PURE__*/React__namespace.createElement("div", {
|
|
2271
2279
|
ref: node => {
|
|
2272
2280
|
this._mathContainer = ReactDOM__default["default"].findDOMNode(node);
|
|
2273
2281
|
},
|
|
2274
2282
|
style: innerStyle
|
|
2275
|
-
})),
|
|
2283
|
+
})), showInputFocusStyle && handle.visible && /*#__PURE__*/React__namespace.createElement(CursorHandle, _extends({}, handle, {
|
|
2276
2284
|
onTouchStart: this.onCursorHandleTouchStart,
|
|
2277
2285
|
onTouchMove: this.onCursorHandleTouchMove,
|
|
2278
2286
|
onTouchEnd: this.onCursorHandleTouchEnd,
|
|
@@ -2320,9 +2328,9 @@ const inlineStyles = {
|
|
|
2320
2328
|
boxSizing: "border-box",
|
|
2321
2329
|
position: "relative",
|
|
2322
2330
|
borderStyle: "solid",
|
|
2323
|
-
borderColor:
|
|
2331
|
+
borderColor: wonderBlocksTokens.color.offBlack50,
|
|
2324
2332
|
borderRadius: 4,
|
|
2325
|
-
color:
|
|
2333
|
+
color: wonderBlocksTokens.color.offBlack
|
|
2326
2334
|
}
|
|
2327
2335
|
};
|
|
2328
2336
|
|
|
@@ -2448,7 +2456,7 @@ const styles$6 = aphrodite.StyleSheet.create({
|
|
|
2448
2456
|
marginLeft: 1
|
|
2449
2457
|
},
|
|
2450
2458
|
hovered: {
|
|
2451
|
-
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${
|
|
2459
|
+
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${wonderBlocksTokens.color.white}`,
|
|
2452
2460
|
border: "1px solid #1865F2"
|
|
2453
2461
|
},
|
|
2454
2462
|
pressed: {
|
|
@@ -2456,7 +2464,7 @@ const styles$6 = aphrodite.StyleSheet.create({
|
|
|
2456
2464
|
},
|
|
2457
2465
|
focused: {
|
|
2458
2466
|
outline: "none",
|
|
2459
|
-
border: `2px solid ${
|
|
2467
|
+
border: `2px solid ${wonderBlocksTokens.color.blue}`
|
|
2460
2468
|
},
|
|
2461
2469
|
innerBox: {
|
|
2462
2470
|
boxSizing: "border-box",
|
|
@@ -2468,7 +2476,7 @@ const styles$6 = aphrodite.StyleSheet.create({
|
|
|
2468
2476
|
alignItems: "center"
|
|
2469
2477
|
},
|
|
2470
2478
|
innerBoxPressed: {
|
|
2471
|
-
border: `1px solid ${
|
|
2479
|
+
border: `1px solid ${wonderBlocksTokens.color.white}`
|
|
2472
2480
|
},
|
|
2473
2481
|
activeIndicator: {
|
|
2474
2482
|
position: "absolute",
|
|
@@ -2486,15 +2494,15 @@ const styles$6 = aphrodite.StyleSheet.create({
|
|
|
2486
2494
|
});
|
|
2487
2495
|
function imageTintColor(itemState, hovered, focused, pressed) {
|
|
2488
2496
|
if (itemState === "disabled") {
|
|
2489
|
-
return
|
|
2497
|
+
return wonderBlocksTokens.color.offBlack64;
|
|
2490
2498
|
} else if (pressed) {
|
|
2491
|
-
return
|
|
2499
|
+
return wonderBlocksTokens.color.white;
|
|
2492
2500
|
} else if (itemState === "active") {
|
|
2493
|
-
return
|
|
2501
|
+
return wonderBlocksTokens.color.blue;
|
|
2494
2502
|
} else if (hovered) {
|
|
2495
|
-
return
|
|
2503
|
+
return wonderBlocksTokens.color.blue;
|
|
2496
2504
|
}
|
|
2497
|
-
return
|
|
2505
|
+
return wonderBlocksTokens.color.offBlack64;
|
|
2498
2506
|
}
|
|
2499
2507
|
class TabbarItem extends React__namespace.Component {
|
|
2500
2508
|
render() {
|
|
@@ -4818,9 +4826,9 @@ const styles$4 = aphrodite.StyleSheet.create({
|
|
|
4818
4826
|
display: "flex",
|
|
4819
4827
|
justifyContent: "center",
|
|
4820
4828
|
alignItems: "center",
|
|
4821
|
-
boxShadow: `0px 1px 0px ${
|
|
4829
|
+
boxShadow: `0px 1px 0px ${wonderBlocksTokens.color.offBlack32}`,
|
|
4822
4830
|
boxSizing: "border-box",
|
|
4823
|
-
background:
|
|
4831
|
+
background: wonderBlocksTokens.color.white,
|
|
4824
4832
|
borderRadius: 4,
|
|
4825
4833
|
borderWidth: 2,
|
|
4826
4834
|
borderStyle: "solid",
|
|
@@ -4831,19 +4839,19 @@ const styles$4 = aphrodite.StyleSheet.create({
|
|
|
4831
4839
|
padding: 1
|
|
4832
4840
|
},
|
|
4833
4841
|
hovered: {
|
|
4834
|
-
borderColor:
|
|
4842
|
+
borderColor: wonderBlocksTokens.color.blue,
|
|
4835
4843
|
padding: 1,
|
|
4836
4844
|
boxShadow: "none"
|
|
4837
4845
|
},
|
|
4838
4846
|
focused: {
|
|
4839
|
-
borderColor:
|
|
4847
|
+
borderColor: wonderBlocksTokens.color.blue,
|
|
4840
4848
|
padding: 0,
|
|
4841
4849
|
boxShadow: "none"
|
|
4842
4850
|
},
|
|
4843
4851
|
pressed: {
|
|
4844
4852
|
border: "2px solid #1B50B3",
|
|
4845
4853
|
padding: 0,
|
|
4846
|
-
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${
|
|
4854
|
+
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${wonderBlocksTokens.color.white}`,
|
|
4847
4855
|
boxShadow: "none"
|
|
4848
4856
|
},
|
|
4849
4857
|
outerBoxBase: {
|
|
@@ -5202,13 +5210,13 @@ const styles$3 = aphrodite.StyleSheet.create({
|
|
|
5202
5210
|
width: "100%"
|
|
5203
5211
|
},
|
|
5204
5212
|
base: {
|
|
5205
|
-
boxShadow: `0px 1px 0px ${
|
|
5213
|
+
boxShadow: `0px 1px 0px ${wonderBlocksTokens.color.offBlack32}`,
|
|
5206
5214
|
display: "flex",
|
|
5207
5215
|
justifyContent: "center",
|
|
5208
5216
|
alignItems: "center",
|
|
5209
|
-
background:
|
|
5217
|
+
background: wonderBlocksTokens.color.white,
|
|
5210
5218
|
borderWidth: 2,
|
|
5211
|
-
borderColor:
|
|
5219
|
+
borderColor: wonderBlocksTokens.color.white
|
|
5212
5220
|
},
|
|
5213
5221
|
up: {
|
|
5214
5222
|
borderTopLeftRadius: borderRadiusPx,
|
|
@@ -5227,16 +5235,16 @@ const styles$3 = aphrodite.StyleSheet.create({
|
|
|
5227
5235
|
borderBottomLeftRadius: borderRadiusPx
|
|
5228
5236
|
},
|
|
5229
5237
|
hovered: {
|
|
5230
|
-
borderColor:
|
|
5238
|
+
borderColor: wonderBlocksTokens.color.blue,
|
|
5231
5239
|
boxShadow: "none"
|
|
5232
5240
|
},
|
|
5233
5241
|
focused: {
|
|
5234
|
-
borderColor:
|
|
5242
|
+
borderColor: wonderBlocksTokens.color.blue,
|
|
5235
5243
|
boxShadow: "none"
|
|
5236
5244
|
},
|
|
5237
5245
|
pressed: {
|
|
5238
5246
|
border: "2px solid #1B50B3",
|
|
5239
|
-
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${
|
|
5247
|
+
background: `linear-gradient(0deg, rgba(24, 101, 242, 0.32), rgba(24, 101, 242, 0.32)), ${wonderBlocksTokens.color.white}`,
|
|
5240
5248
|
boxShadow: "none"
|
|
5241
5249
|
}
|
|
5242
5250
|
});
|
|
@@ -5286,7 +5294,7 @@ const styles$2 = aphrodite.StyleSheet.create({
|
|
|
5286
5294
|
spacer: {
|
|
5287
5295
|
gridColumn: 2,
|
|
5288
5296
|
gridRow: 2,
|
|
5289
|
-
background:
|
|
5297
|
+
background: wonderBlocksTokens.color.white
|
|
5290
5298
|
}
|
|
5291
5299
|
});
|
|
5292
5300
|
|
|
@@ -5479,11 +5487,11 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
5479
5487
|
alignItems: "center"
|
|
5480
5488
|
},
|
|
5481
5489
|
wrapper: {
|
|
5482
|
-
background:
|
|
5490
|
+
background: wonderBlocksTokens.color.white
|
|
5483
5491
|
},
|
|
5484
5492
|
expandedWrapper: {
|
|
5485
5493
|
borderWidth: "1px 1px 0 1px",
|
|
5486
|
-
borderColor:
|
|
5494
|
+
borderColor: wonderBlocksTokens.color.offBlack32,
|
|
5487
5495
|
maxWidth: expandedViewThreshold,
|
|
5488
5496
|
borderRadius: "3px 3px 0 0"
|
|
5489
5497
|
},
|