@khanacademy/math-input 16.2.0 → 16.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @khanacademy/math-input
2
2
 
3
+ ## 16.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#863](https://github.com/Khan/perseus/pull/863) [`f910bd72`](https://github.com/Khan/perseus/commit/f910bd72fc5cbf88a1a00d57f8aefa8eea2c755d) Thanks [@handeyeco](https://github.com/handeyeco)! - Localize the multiplication symbol in MathInput
8
+
3
9
  ## 16.2.0
4
10
 
5
11
  ### Minor Changes
package/dist/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-core';
2
2
  import Color from '@khanacademy/wonder-blocks-color';
3
3
  import * as i18n from '@khanacademy/wonder-blocks-i18n';
4
- import { getDecimalSeparator } from '@khanacademy/wonder-blocks-i18n';
4
+ import { getDecimalSeparator, getLocale } from '@khanacademy/wonder-blocks-i18n';
5
5
  import { entries } from '@khanacademy/wonder-stuff-core';
6
6
  import { StyleSheet, css } from 'aphrodite';
7
7
  import * as React from 'react';
@@ -17,7 +17,7 @@ import PropTypes from 'prop-types';
17
17
 
18
18
  // This file is processed by a Rollup plugin (replace) to inject the production
19
19
  const libName = "@khanacademy/math-input";
20
- const libVersion = "16.2.0";
20
+ const libVersion = "16.3.0";
21
21
  addLibraryVersionToPerseusDebug(libName, libVersion);
22
22
 
23
23
  function _extends() {
@@ -789,6 +789,30 @@ const DecimalSeparator = {
789
789
  // - Some languages/locales use different decimal separators than the ones
790
790
  // listed here. Much of the Arab world uses U+066C.
791
791
  const decimalSeparator = getDecimalSeparator() === "," ? DecimalSeparator.COMMA : DecimalSeparator.PERIOD;
792
+ const CDOT_ONLY = ["az", "cs", "da", "de", "hu", "hy", "kk", "ky", "lt", "lv", "nb", "sk", "sr", "sv", "uz"];
793
+ const TIMES_ONLY = ["fr", "tr", "pt-pt"];
794
+
795
+ /**
796
+ * convertDotToTimes (aka `times`) is an option the content creators have to
797
+ * use × (TIMES) rather than · (CDOT) for multiplication (for younger learners).
798
+ * Some locales _only_ use one or the other for all multiplication regardless
799
+ * of age.
800
+ *
801
+ * convertDotToTimesByLocale overrides convertDotToTimes for those locales.
802
+ *
803
+ * @param {boolean} convertDotToTimes - the setting set by content creators
804
+ * @returns {boolean} - true to convert to × (TIMES), false to use · (CDOT)
805
+ */
806
+ function convertDotToTimesByLocale(convertDotToTimes) {
807
+ const locale = getLocale();
808
+ if (CDOT_ONLY.includes(locale)) {
809
+ return false;
810
+ }
811
+ if (TIMES_ONLY.includes(locale)) {
812
+ return true;
813
+ }
814
+ return convertDotToTimes;
815
+ }
792
816
 
793
817
  function handleLeftArrow(mathField, cursor) {
794
818
  // If we're inside a function, and just after the left parentheses, we
@@ -4879,7 +4903,7 @@ function SharedKeys(props) {
4879
4903
  coord: fractionCoord,
4880
4904
  secondary: true
4881
4905
  }), /*#__PURE__*/React.createElement(KeypadButton, {
4882
- keyConfig: convertDotToTimes ? KeyConfigs.TIMES : KeyConfigs.CDOT,
4906
+ keyConfig: convertDotToTimesByLocale(!!convertDotToTimes) ? KeyConfigs.TIMES : KeyConfigs.CDOT,
4883
4907
  onClickKey: onClickKey,
4884
4908
  coord: [4, 1],
4885
4909
  secondary: true
@@ -5619,5 +5643,5 @@ let KeypadType = /*#__PURE__*/function (KeypadType) {
5619
5643
  return KeypadType;
5620
5644
  }({});
5621
5645
 
5622
- export { CursorContext, Keypad as DesktopKeypad, KeyArray, KeyConfigs, KeypadContext, MathInput as KeypadInput, KeypadType, MobileKeypad, StatefulKeypadContextProvider, createMathField, getCursorContext, keyToMathquillMap as keyTranslator, keypadElementPropType, libVersion, mathQuillInstance };
5646
+ export { CursorContext, Keypad as DesktopKeypad, KeyArray, KeyConfigs, KeypadContext, MathInput as KeypadInput, KeypadType, MobileKeypad, StatefulKeypadContextProvider, convertDotToTimesByLocale, createMathField, getCursorContext, keyToMathquillMap as keyTranslator, keypadElementPropType, libVersion, mathQuillInstance };
5623
5647
  //# sourceMappingURL=index.js.map