@khanacademy/math-input 21.1.0 → 21.1.2

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.
@@ -6,5 +6,4 @@
6
6
  * Inspired by https://github.com/necolas/react-native-web. We use aphrodite
7
7
  * StyleSheets instead.
8
8
  */
9
- export { default as Text } from "./text";
10
9
  export { default as View } from "./view";
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
45
45
 
46
46
  // This file is processed by a Rollup plugin (replace) to inject the production
47
47
  const libName = "@khanacademy/math-input";
48
- const libVersion = "21.1.0";
48
+ const libVersion = "21.1.2";
49
49
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
50
50
 
51
51
  function _extends() {
@@ -63,25 +63,6 @@ function _extends() {
63
63
  return _extends.apply(this, arguments);
64
64
  }
65
65
 
66
- // https://github.com/necolas/react-native-web/blob/master/src/components/Text/index.js
67
- aphrodite.StyleSheet.create({
68
- initial: {
69
- color: "inherit",
70
- display: "inline",
71
- font: "inherit",
72
- margin: 0,
73
- padding: 0,
74
- textDecorationLine: "none",
75
- wordWrap: "break-word"
76
- },
77
- singleLineStyle: {
78
- maxWidth: "100%",
79
- overflow: "hidden",
80
- textOverflow: "ellipsis",
81
- whiteSpace: "nowrap"
82
- }
83
- });
84
-
85
66
  class View extends React__namespace.Component {
86
67
  static styles = aphrodite.StyleSheet.create({
87
68
  // From: https://github.com/necolas/react-native-web/blob/master/src/components/View/index.js
@@ -438,6 +419,14 @@ class DragListener {
438
419
  }
439
420
  }
440
421
 
422
+ let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
423
+ MathFieldActionType["WRITE"] = "write";
424
+ MathFieldActionType["CMD"] = "cmd";
425
+ MathFieldActionType["KEYSTROKE"] = "keystroke";
426
+ MathFieldActionType[MathFieldActionType["MQ_END"] = 0] = "MQ_END";
427
+ return MathFieldActionType;
428
+ }({});
429
+
441
430
  /**
442
431
  * Enum that defines the various contexts in which a cursor can exist. The
443
432
  * active context is determined first by looking at the cursor's siblings (e.g.,
@@ -609,29 +598,6 @@ function createMathField(container, locale, strings, configCallback) {
609
598
  return mathField;
610
599
  }
611
600
 
612
- /**
613
- * Editable math fields have all of the above methods in addition to
614
- * the ones listed here.
615
- * https://docs.mathquill.com/en/latest/Api_Methods/
616
- */
617
-
618
- let MathFieldActionType = /*#__PURE__*/function (MathFieldActionType) {
619
- MathFieldActionType["WRITE"] = "write";
620
- MathFieldActionType["CMD"] = "cmd";
621
- MathFieldActionType["KEYSTROKE"] = "keystroke";
622
- MathFieldActionType[MathFieldActionType["MQ_END"] = 0] = "MQ_END";
623
- return MathFieldActionType;
624
- }({});
625
-
626
- /**
627
- * The MathQuill API (see mathuill.d.ts) does not include types
628
- * for cursor() and controller(), and adding these types there
629
- * in the MathQuill repo causes unexpected conflicts with other types.
630
- *
631
- * We don't want to use the cursor and controller default type `any`
632
- * so we declare the types here.
633
- */
634
-
635
601
  const Numerals = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
636
602
  const GreekLetters = ["\\theta", "\\pi"];
637
603
  const Letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
@@ -1214,28 +1180,21 @@ function handleJumpOut(mathField, key) {
1214
1180
  }
1215
1181
  }
1216
1182
 
1217
- var ActionType = /*#__PURE__*/function (ActionType) {
1218
- ActionType["WRITE"] = "write";
1219
- ActionType["CMD"] = "cmd";
1220
- ActionType["KEYSTROKE"] = "keystroke";
1221
- ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
1222
- return ActionType;
1223
- }(ActionType || {});
1224
1183
  function buildGenericCallback(str) {
1225
- let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ActionType.WRITE;
1184
+ let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MathFieldActionType.WRITE;
1226
1185
  return function (mathQuill) {
1227
1186
  switch (type) {
1228
- case ActionType.WRITE:
1187
+ case MathFieldActionType.WRITE:
1229
1188
  {
1230
1189
  mathQuill.write(str);
1231
1190
  return;
1232
1191
  }
1233
- case ActionType.CMD:
1192
+ case MathFieldActionType.CMD:
1234
1193
  {
1235
1194
  mathQuill.cmd(str);
1236
1195
  return;
1237
1196
  }
1238
- case ActionType.KEYSTROKE:
1197
+ case MathFieldActionType.KEYSTROKE:
1239
1198
  {
1240
1199
  mathQuill.keystroke(str);
1241
1200
  return;
@@ -1301,17 +1260,17 @@ const getKeyTranslator = (locale, strings) => ({
1301
1260
  TIMES: buildGenericCallback("\\times"),
1302
1261
  // The `FRAC_EXCLUSIVE` variant is handled manually, since we may need to do
1303
1262
  // some additional navigation depending on the cursor position.
1304
- FRAC_INCLUSIVE: buildGenericCallback("/", ActionType.CMD),
1305
- FRAC: buildGenericCallback("\\frac", ActionType.CMD),
1306
- LEFT_PAREN: buildGenericCallback("(", ActionType.CMD),
1307
- RIGHT_PAREN: buildGenericCallback(")", ActionType.CMD),
1308
- SQRT: buildGenericCallback("sqrt", ActionType.CMD),
1309
- PI: buildGenericCallback("pi", ActionType.CMD),
1310
- THETA: buildGenericCallback("theta", ActionType.CMD),
1311
- RADICAL: buildGenericCallback("nthroot", ActionType.CMD),
1312
- BACKSPACE: buildGenericCallback("Backspace", ActionType.KEYSTROKE),
1313
- UP: buildGenericCallback("Up", ActionType.KEYSTROKE),
1314
- DOWN: buildGenericCallback("Down", ActionType.KEYSTROKE),
1263
+ FRAC_INCLUSIVE: buildGenericCallback("/", MathFieldActionType.CMD),
1264
+ FRAC: buildGenericCallback("\\frac", MathFieldActionType.CMD),
1265
+ LEFT_PAREN: buildGenericCallback("(", MathFieldActionType.CMD),
1266
+ RIGHT_PAREN: buildGenericCallback(")", MathFieldActionType.CMD),
1267
+ SQRT: buildGenericCallback("sqrt", MathFieldActionType.CMD),
1268
+ PI: buildGenericCallback("pi", MathFieldActionType.CMD),
1269
+ THETA: buildGenericCallback("theta", MathFieldActionType.CMD),
1270
+ RADICAL: buildGenericCallback("nthroot", MathFieldActionType.CMD),
1271
+ BACKSPACE: buildGenericCallback("Backspace", MathFieldActionType.KEYSTROKE),
1272
+ UP: buildGenericCallback("Up", MathFieldActionType.KEYSTROKE),
1273
+ DOWN: buildGenericCallback("Down", MathFieldActionType.KEYSTROKE),
1315
1274
  CUBE_ROOT: mathQuill => {
1316
1275
  mathQuill.write("\\sqrt[3]{}");
1317
1276
  mathQuill.keystroke("Left"); // under the root
@@ -1321,7 +1280,7 @@ const getKeyTranslator = (locale, strings) => ({
1321
1280
  const cursor = mathQuill.cursor();
1322
1281
  // If there's nothing to the left of the cursor, then we want to
1323
1282
  // leave the cursor to the left of the fraction after creating it.
1324
- const shouldNavigateLeft = cursor[mathQuillInstance.L] === ActionType.MQ_END;
1283
+ const shouldNavigateLeft = cursor[mathQuillInstance.L] === MathFieldActionType.MQ_END;
1325
1284
  mathQuill.cmd("\\frac");
1326
1285
  if (shouldNavigateLeft) {
1327
1286
  mathQuill.keystroke("Left");
@@ -5409,9 +5368,6 @@ function SharedKeys(props) {
5409
5368
  }));
5410
5369
  }
5411
5370
 
5412
- const defaultProps = {
5413
- extraKeys: []
5414
- };
5415
5371
  function getAvailableTabs(props) {
5416
5372
  // We don't want to show any available tabs on the fractions keypad
5417
5373
  if (props.fractionsOnly) {
@@ -5434,7 +5390,11 @@ function getAvailableTabs(props) {
5434
5390
 
5435
5391
  // The main (v2) Keypad. Use this component to present an accessible, onscreen
5436
5392
  // keypad to learners for entering math expressions.
5437
- function Keypad(props) {
5393
+ function Keypad(_ref) {
5394
+ let {
5395
+ extraKeys = [],
5396
+ ...props
5397
+ } = _ref;
5438
5398
  // If we're using the Fractions keypad, we want to default select that page
5439
5399
  // Otherwise, we want to default to the Numbers page
5440
5400
  const defaultSelectedPage = props.fractionsOnly ? "Fractions" : "Numbers";
@@ -5442,11 +5402,13 @@ function Keypad(props) {
5442
5402
  const [isMounted, setIsMounted] = React__namespace.useState(false);
5443
5403
 
5444
5404
  // We don't want any tabs available on mobile fractions keypad
5445
- const availableTabs = getAvailableTabs(props);
5405
+ const availableTabs = getAvailableTabs({
5406
+ ...props,
5407
+ extraKeys
5408
+ });
5446
5409
  const {
5447
5410
  onClickKey,
5448
5411
  cursorContext,
5449
- extraKeys,
5450
5412
  convertDotToTimes,
5451
5413
  divisionKey,
5452
5414
  preAlgebra,
@@ -5530,7 +5492,6 @@ function Keypad(props) {
5530
5492
  onClickKey: onClickKey
5531
5493
  }))));
5532
5494
  }
5533
- Keypad.defaultProps = defaultProps;
5534
5495
  const styles$1 = aphrodite.StyleSheet.create({
5535
5496
  keypadOuterContainer: {
5536
5497
  display: "flex",