@khanacademy/math-input 15.0.0 → 15.0.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
@@ -53,7 +53,7 @@ var Redux__namespace = /*#__PURE__*/_interopNamespace(Redux);
53
53
 
54
54
  // This file is processed by a Rollup plugin (replace) to inject the production
55
55
  const libName = "@khanacademy/math-input";
56
- const libVersion = "15.0.0";
56
+ const libVersion = "15.0.1";
57
57
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
58
58
 
59
59
  function _extends() {
@@ -857,70 +857,10 @@ function handleBackspace(mathField) {
857
857
  }
858
858
  }
859
859
 
860
- /**
861
- * Constants that are shared between multiple files.
862
- */
863
-
864
- let KeypadType = /*#__PURE__*/function (KeypadType) {
865
- KeypadType["FRACTION"] = "FRACTION";
866
- KeypadType["EXPRESSION"] = "EXPRESSION";
867
- return KeypadType;
868
- }({});
869
- const KeyTypes = ["EMPTY",
870
- // For numerals, variables, and any other characters that themselves
871
- // compose 'values'.
872
- "VALUE",
873
- // For buttons that insert or adjust math in an input.
874
- "OPERATOR",
875
- // For buttons that move the cursor in an input (including via
876
- // deletion).
877
- "INPUT_NAVIGATION",
878
- // For buttons that modify the broader keypad state (e.g., by changing
879
- // the visible pane).
880
- "KEYPAD_NAVIGATION",
881
- // For buttons that house multiple buttons and have no action
882
- // themselves.
883
- "MANY",
884
- // For the echo animation that appears on press.
885
- "ECHO"];
886
- let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
887
- DeviceOrientation["LANDSCAPE"] = "LANDSCAPE";
888
- DeviceOrientation["PORTRAIT"] = "PORTRAIT";
889
- return DeviceOrientation;
890
- }({});
891
- let LayoutMode = /*#__PURE__*/function (LayoutMode) {
892
- LayoutMode["FULLSCREEN"] = "FULLSCREEN";
893
- LayoutMode["COMPACT"] = "COMPACT";
894
- return LayoutMode;
895
- }({});
896
- let BorderDirection = /*#__PURE__*/function (BorderDirection) {
897
- BorderDirection["LEFT"] = "LEFT";
898
- BorderDirection["BOTTOM"] = "BOTTOM";
899
- return BorderDirection;
900
- }({});
901
- const BorderStyles = {
902
- LEFT: [BorderDirection.LEFT],
903
- BOTTOM: [BorderDirection.BOTTOM],
904
- ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
905
- NONE: []
860
+ const DecimalSeparator = {
861
+ COMMA: ",",
862
+ PERIOD: "."
906
863
  };
907
- let IconType = /*#__PURE__*/function (IconType) {
908
- IconType["MATH"] = "MATH";
909
- IconType["SVG"] = "SVG";
910
- IconType["TEXT"] = "TEXT";
911
- return IconType;
912
- }({});
913
- let DecimalSeparator = /*#__PURE__*/function (DecimalSeparator) {
914
- DecimalSeparator["COMMA"] = "COMMA";
915
- DecimalSeparator["PERIOD"] = "PERIOD";
916
- return DecimalSeparator;
917
- }({});
918
- let EchoAnimationType = /*#__PURE__*/function (EchoAnimationType) {
919
- EchoAnimationType["SLIDE_AND_FADE"] = "SLIDE_AND_FADE";
920
- EchoAnimationType["FADE_ONLY"] = "FADE_ONLY";
921
- EchoAnimationType["LONG_FADE_ONLY"] = "LONG_FADE_ONLY";
922
- return EchoAnimationType;
923
- }({});
924
864
 
925
865
  // NOTES(kevinb):
926
866
  // - In order to get the correct decimal separator for the current locale,
@@ -1107,7 +1047,6 @@ var ActionType = /*#__PURE__*/function (ActionType) {
1107
1047
  ActionType[ActionType["MQ_END"] = 0] = "MQ_END";
1108
1048
  return ActionType;
1109
1049
  }(ActionType || {});
1110
- const decimalSymbol = decimalSeparator === DecimalSeparator.COMMA ? "," : ".";
1111
1050
  function buildGenericCallback(str) {
1112
1051
  let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ActionType.WRITE;
1113
1052
  return function (mathQuill) {
@@ -1154,7 +1093,7 @@ const keyToMathquillMap = {
1154
1093
  COS: buildNormalFunctionCallback("cos"),
1155
1094
  TAN: buildNormalFunctionCallback("tan"),
1156
1095
  CDOT: buildGenericCallback("\\cdot"),
1157
- DECIMAL: buildGenericCallback(decimalSymbol),
1096
+ DECIMAL: buildGenericCallback(decimalSeparator),
1158
1097
  DIVIDE: buildGenericCallback("\\div"),
1159
1098
  EQUAL: buildGenericCallback("="),
1160
1099
  GEQ: buildGenericCallback("\\geq"),
@@ -2491,6 +2430,66 @@ function Tabbar(props) {
2491
2430
  })));
2492
2431
  }
2493
2432
 
2433
+ /**
2434
+ * Constants that are shared between multiple files.
2435
+ */
2436
+
2437
+ let KeypadType = /*#__PURE__*/function (KeypadType) {
2438
+ KeypadType["FRACTION"] = "FRACTION";
2439
+ KeypadType["EXPRESSION"] = "EXPRESSION";
2440
+ return KeypadType;
2441
+ }({});
2442
+ const KeyTypes = ["EMPTY",
2443
+ // For numerals, variables, and any other characters that themselves
2444
+ // compose 'values'.
2445
+ "VALUE",
2446
+ // For buttons that insert or adjust math in an input.
2447
+ "OPERATOR",
2448
+ // For buttons that move the cursor in an input (including via
2449
+ // deletion).
2450
+ "INPUT_NAVIGATION",
2451
+ // For buttons that modify the broader keypad state (e.g., by changing
2452
+ // the visible pane).
2453
+ "KEYPAD_NAVIGATION",
2454
+ // For buttons that house multiple buttons and have no action
2455
+ // themselves.
2456
+ "MANY",
2457
+ // For the echo animation that appears on press.
2458
+ "ECHO"];
2459
+ let DeviceOrientation = /*#__PURE__*/function (DeviceOrientation) {
2460
+ DeviceOrientation["LANDSCAPE"] = "LANDSCAPE";
2461
+ DeviceOrientation["PORTRAIT"] = "PORTRAIT";
2462
+ return DeviceOrientation;
2463
+ }({});
2464
+ let LayoutMode = /*#__PURE__*/function (LayoutMode) {
2465
+ LayoutMode["FULLSCREEN"] = "FULLSCREEN";
2466
+ LayoutMode["COMPACT"] = "COMPACT";
2467
+ return LayoutMode;
2468
+ }({});
2469
+ let BorderDirection = /*#__PURE__*/function (BorderDirection) {
2470
+ BorderDirection["LEFT"] = "LEFT";
2471
+ BorderDirection["BOTTOM"] = "BOTTOM";
2472
+ return BorderDirection;
2473
+ }({});
2474
+ const BorderStyles = {
2475
+ LEFT: [BorderDirection.LEFT],
2476
+ BOTTOM: [BorderDirection.BOTTOM],
2477
+ ALL: [BorderDirection.LEFT, BorderDirection.BOTTOM],
2478
+ NONE: []
2479
+ };
2480
+ let IconType = /*#__PURE__*/function (IconType) {
2481
+ IconType["MATH"] = "MATH";
2482
+ IconType["SVG"] = "SVG";
2483
+ IconType["TEXT"] = "TEXT";
2484
+ return IconType;
2485
+ }({});
2486
+ let EchoAnimationType = /*#__PURE__*/function (EchoAnimationType) {
2487
+ EchoAnimationType["SLIDE_AND_FADE"] = "SLIDE_AND_FADE";
2488
+ EchoAnimationType["FADE_ONLY"] = "FADE_ONLY";
2489
+ EchoAnimationType["LONG_FADE_ONLY"] = "LONG_FADE_ONLY";
2490
+ return EchoAnimationType;
2491
+ }({});
2492
+
2494
2493
  /**
2495
2494
  * This file contains configuration settings for the buttons in the keypad.
2496
2495
  */
@@ -2591,16 +2590,7 @@ const KeyConfigs = {
2591
2590
  keyType: "VALUE",
2592
2591
  // I18N: A label for a 'decimal' sign (represented as '.' or ',').
2593
2592
  ariaLabel: i18n__namespace._("Decimal")
2594
- }),
2595
- icon: decimalSeparator === DecimalSeparator.COMMA ? {
2596
- // TODO(charlie): Get an SVG icon for the comma, or verify with
2597
- // design that the text-rendered version is acceptable.
2598
- type: IconType.TEXT,
2599
- data: ","
2600
- } : {
2601
- type: IconType.SVG,
2602
- data: "PERIOD"
2603
- }
2593
+ })
2604
2594
  },
2605
2595
  PERIOD: {
2606
2596
  ...getDefaultOperatorFields({
@@ -3383,16 +3373,32 @@ function ButtonAsset(_ref) {
3383
3373
  d: "M16.735 16.8558c0 1.024.272 1.812.816 2.364.552.544 1.32.816 2.304.816.528 0 .992-.084 1.392-.252.408-.168.752-.392 1.032-.672.28-.288.492-.62.636-.996.144-.384.216-.792.216-1.224 0-.504-.08-.952-.24-1.344-.152-.4-.372-.74-.66-1.02-.28-.28-.616-.492-1.008-.636-.392-.152-.82-.228-1.284-.228-.488 0-.928.08-1.32.24-.392.16-.728.384-1.008.672-.28.28-.496.616-.648 1.008-.152.384-.228.808-.228 1.272zm4.428 5.364c.16-.2.308-.388.444-.564.136-.184.264-.368.384-.552-.416.296-.88.524-1.392.684-.512.152-1.056.228-1.632.228-.624 0-1.224-.104-1.8-.312-.576-.216-1.088-.532-1.536-.948-.448-.424-.808-.944-1.08-1.56-.264-.624-.396-1.34-.396-2.148 0-.76.14-1.476.42-2.148.288-.672.688-1.256 1.2-1.752.512-.504 1.124-.9 1.836-1.188.712-.288 1.5-.432 2.364-.432.856 0 1.632.14 2.328.42.696.272 1.288.66 1.776 1.164.488.496.864 1.092 1.128 1.788.264.688.396 1.448.396 2.28 0 .52-.048 1.012-.144 1.476-.088.464-.22.916-.396 1.356-.168.432-.376.86-.624 1.284-.24.416-.512.84-.816 1.272l-4.068 5.832c-.12.176-.3.32-.54.432-.232.112-.496.168-.792.168h-2.364l5.304-6.78z",
3384
3374
  fill: "#21242C"
3385
3375
  }));
3386
- // TODO(ned): Per the notes in `KeyConfigs`, shouldn't this be a comma
3387
- // that we replace with the period icon for i18n? Duplicating for now.
3388
3376
  case "DECIMAL":
3389
3377
  case "PERIOD":
3378
+ // Different locales use different symbols for the decimal separator
3379
+ // (, vs .)
3380
+ if (id === "DECIMAL" && decimalSeparator === DecimalSeparator.COMMA) {
3381
+ // comma decimal separator
3382
+ return /*#__PURE__*/React__namespace.createElement("svg", {
3383
+ width: "40",
3384
+ height: "40",
3385
+ viewBox: "0 0 32 32",
3386
+ fill: "none",
3387
+ xmlns: "http://www.w3.org/2000/svg",
3388
+ "data-test-id": "comma-decimal"
3389
+ }, /*#__PURE__*/React__namespace.createElement("path", {
3390
+ d: "M11.5559 25.3544C11.8679 24.661 12.1799 23.933 12.4919 23.1704C12.8039 22.425 13.0986 21.6884 13.3759 20.9604C13.6706 20.2324 13.9219 19.5737 14.1299 18.9844H16.6259L16.7299 19.2704C16.4526 19.877 16.1232 20.5357 15.7419 21.2464C15.3606 21.9397 14.9619 22.633 14.5459 23.3264C14.1299 24.037 13.7139 24.713 13.2979 25.3544H11.5559Z",
3391
+ fill: "#21242C"
3392
+ }));
3393
+ }
3394
+ // period / US decimal separator
3390
3395
  return /*#__PURE__*/React__namespace.createElement("svg", {
3391
3396
  width: "40",
3392
3397
  height: "40",
3393
3398
  viewBox: "0 0 40 40",
3394
3399
  fill: "none",
3395
- xmlns: "http://www.w3.org/2000/svg"
3400
+ xmlns: "http://www.w3.org/2000/svg",
3401
+ "data-test-id": "period-decimal"
3396
3402
  }, /*#__PURE__*/React__namespace.createElement("path", {
3397
3403
  d: "M18.3401 27.512c0-.232.04-.448.12-.648.088-.208.204-.388.348-.54.152-.152.328-.272.528-.36.208-.088.428-.132.66-.132.232 0 .448.044.648.132.208.088.388.208.54.36.152.152.272.332.36.54.088.2.132.416.132.648 0 .24-.044.46-.132.66-.088.2-.208.376-.36.528-.152.152-.332.268-.54.348-.2.088-.416.132-.648.132-.232 0-.452-.044-.66-.132-.2-.08-.376-.196-.528-.348-.144-.152-.26-.328-.348-.528-.08-.2-.12-.42-.12-.66z",
3398
3404
  fill: "#21242C"