@khanacademy/math-input 20.0.3 → 20.1.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/index.js CHANGED
@@ -44,7 +44,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
44
44
 
45
45
  // This file is processed by a Rollup plugin (replace) to inject the production
46
46
  const libName = "@khanacademy/math-input";
47
- const libVersion = "20.0.3";
47
+ const libVersion = "20.1.1";
48
48
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
49
49
 
50
50
  function _extends() {
@@ -1327,7 +1327,6 @@ const getKeyTranslator = locale => ({
1327
1327
  LEFT_PAREN: buildGenericCallback("(", ActionType.CMD),
1328
1328
  RIGHT_PAREN: buildGenericCallback(")", ActionType.CMD),
1329
1329
  SQRT: buildGenericCallback("sqrt", ActionType.CMD),
1330
- PHI: buildGenericCallback("\\phi", ActionType.CMD),
1331
1330
  PI: buildGenericCallback("pi", ActionType.CMD),
1332
1331
  THETA: buildGenericCallback("theta", ActionType.CMD),
1333
1332
  RADICAL: buildGenericCallback("nthroot", ActionType.CMD),
@@ -1349,13 +1348,6 @@ const getKeyTranslator = locale => ({
1349
1348
  mathQuill.keystroke("Left");
1350
1349
  }
1351
1350
  },
1352
- LOG_B: mathQuill => {
1353
- mathQuill.typedText("log_");
1354
- mathQuill.keystroke("Right");
1355
- mathQuill.typedText("(");
1356
- mathQuill.keystroke("Left");
1357
- mathQuill.keystroke("Left");
1358
- },
1359
1351
  LOG_N: mathQuill => {
1360
1352
  mathQuill.write("log_{ }\\left(\\right)");
1361
1353
  mathQuill.keystroke("Left"); // into parentheses
@@ -1363,26 +1355,9 @@ const getKeyTranslator = locale => ({
1363
1355
  mathQuill.keystroke("Left"); // into index
1364
1356
  },
1365
1357
 
1366
- NTHROOT3: mathQuill => {
1367
- mathQuill.typedText("nthroot3");
1368
- mathQuill.keystroke("Right");
1369
- },
1370
- POW: mathQuill => {
1371
- const contents = mathQuill.latex();
1372
- mathQuill.typedText("^");
1373
-
1374
- // If the input hasn't changed (for example, if we're
1375
- // attempting to add an exponent on an empty input or an empty
1376
- // denominator), insert our own "a^b"
1377
- if (mathQuill.latex() === contents) {
1378
- mathQuill.typedText("a^b");
1379
- }
1380
- },
1381
1358
  // These need to be overwritten by the consumer
1382
1359
  // if they're going to be used
1383
1360
  DISMISS: () => {},
1384
- NOOP: () => {},
1385
- MANY: () => {},
1386
1361
  NUM_0: buildGenericCallback("0"),
1387
1362
  NUM_1: buildGenericCallback("1"),
1388
1363
  NUM_2: buildGenericCallback("2"),
@@ -1457,9 +1432,9 @@ class MathWrapper {
1457
1432
  mathField; // MathQuill MathField input
1458
1433
  callbacks;
1459
1434
  mobileKeyTranslator;
1460
- constructor(element, strings, locale) {
1461
- let callbacks = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1462
- this.mathField = createMathField(element, locale, strings, () => {
1435
+ constructor(mathFieldMount, ariaLabel, strings, locale) {
1436
+ let callbacks = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1437
+ this.mathField = createMathField(mathFieldMount, locale, strings, () => {
1463
1438
  return {
1464
1439
  // use a span instead of a textarea so that we don't bring up the
1465
1440
  // native keyboard on mobile when selecting the input
@@ -1468,6 +1443,7 @@ class MathWrapper {
1468
1443
  }
1469
1444
  };
1470
1445
  });
1446
+ this.mathField?.setAriaLabel(ariaLabel);
1471
1447
  this.callbacks = callbacks;
1472
1448
  this.mobileKeyTranslator = {
1473
1449
  ...getKeyTranslator(locale),
@@ -1689,7 +1665,7 @@ class MathInput extends React__namespace.Component {
1689
1665
  };
1690
1666
  componentDidMount() {
1691
1667
  this._isMounted = true;
1692
- this.mathField = new MathWrapper(this._mathContainer, this.context.strings, this.context.locale, {
1668
+ this.mathField = new MathWrapper(this._mathContainer, this.props.ariaLabel, this.context.strings, this.context.locale, {
1693
1669
  onCursorMove: cursor => {
1694
1670
  // TODO(charlie): It's not great that there is so much coupling
1695
1671
  // between this keypad and the input behavior. We should wrap
@@ -3048,12 +3024,6 @@ const KeyConfigs = strings => ({
3048
3024
  ariaLabel: strings.theta
3049
3025
  })
3050
3026
  },
3051
- NOOP: {
3052
- ...getDefaultOperatorFields({
3053
- key: "NOOP",
3054
- keyType: "EMPTY"
3055
- })
3056
- },
3057
3027
  // Input navigation
3058
3028
  UP: {
3059
3029
  ...getDefaultOperatorFields({
@@ -3140,13 +3110,6 @@ const KeyConfigs = strings => ({
3140
3110
  ariaLabel: strings.dismiss
3141
3111
  })
3142
3112
  },
3143
- // TODO(charlie): Use the numeral color for the 'Many' key.
3144
- MANY: {
3145
- ...getDefaultOperatorFields({
3146
- key: "MANY",
3147
- keyType: "MANY"
3148
- })
3149
- },
3150
3113
  // NUMBERS
3151
3114
  NUM_0: {
3152
3115
  ...getDefaultNumberFields({
@@ -3458,26 +3421,6 @@ const KeyConfigs = strings => ({
3458
3421
  ...getDefaultValueFields({
3459
3422
  key: "z"
3460
3423
  })
3461
- },
3462
- PHI: {
3463
- ...getDefaultValueFields({
3464
- key: "PHI"
3465
- })
3466
- },
3467
- NTHROOT3: {
3468
- ...getDefaultValueFields({
3469
- key: "NTHROOT3"
3470
- })
3471
- },
3472
- POW: {
3473
- ...getDefaultValueFields({
3474
- key: "POW"
3475
- })
3476
- },
3477
- LOG_B: {
3478
- ...getDefaultValueFields({
3479
- key: "LOG_B"
3480
- })
3481
3424
  }
3482
3425
  });
3483
3426
 
@@ -4891,33 +4834,6 @@ function ButtonAsset(_ref) {
4891
4834
  strokeLinejoin: "round",
4892
4835
  d: "M22 18l-6 6 6 6M16 24h16"
4893
4836
  })));
4894
-
4895
- /**
4896
- * ANYTHING BELOW IS NOT YET HANDLED
4897
- */
4898
- case "MANY":
4899
- case "NOOP":
4900
- case "PHI":
4901
- case "NTHROOT3":
4902
- case "POW":
4903
- case "LOG_B":
4904
- // placeholder
4905
- return /*#__PURE__*/React__namespace.createElement("svg", {
4906
- width: "40",
4907
- height: "40",
4908
- viewBox: "0 0 40 40",
4909
- fill: "black",
4910
- xmlns: "http://www.w3.org/2000/svg"
4911
- }, /*#__PURE__*/React__namespace.createElement("text", {
4912
- y: "20",
4913
- textLength: "100%",
4914
- lengthAdjust: "spacingAndGlyphs"
4915
- }, id), /*#__PURE__*/React__namespace.createElement("text", {
4916
- y: "35",
4917
- textLength: "100%",
4918
- lengthAdjust: "spacingAndGlyphs",
4919
- fill: "red"
4920
- }, "placeholder"));
4921
4837
  default:
4922
4838
  // this line forces an exhaustive check of all keys;
4923
4839
  // if a key is not handled, the compiler will complain.
@@ -6182,14 +6098,7 @@ const KeyArray = ["PLUS", "MINUS", "NEGATIVE", "TIMES", "DIVIDE", "DECIMAL", "PE
6182
6098
  // TODO(charlie): Add in additional Greek letters.,
6183
6099
  "TAN", "PI", "THETA", "UP", "RIGHT", "DOWN", "LEFT", "BACKSPACE", "DISMISS", "JUMP_OUT_PARENTHESES", "JUMP_OUT_EXPONENT", "JUMP_OUT_BASE", "JUMP_INTO_NUMERATOR", "JUMP_OUT_NUMERATOR", "JUMP_OUT_DENOMINATOR",
6184
6100
  // Multi-functional keys.
6185
- "NOOP",
6186
- // mobile native only
6187
- "MANY",
6188
- // A custom key that captures an arbitrary number of symbols but has no 'default' symbol or action.
6189
- "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "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", "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",
6190
- // Currently only used by
6191
- // Perseus' Expression MathInput
6192
- "PHI", "NTHROOT3", "POW", "LOG_B"];
6101
+ "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "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", "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"];
6193
6102
 
6194
6103
  /**
6195
6104
  * Constants that are shared between multiple files.