@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/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export { default as DesktopKeypad } from "./components/keypad";
13
13
  export { KeypadContext, StatefulKeypadContextProvider, } from "./components/keypad-context";
14
14
  export { keypadElementPropType } from "./components/prop-types";
15
15
  export type { KeypadAPI, KeypadConfiguration } from "./types";
16
+ export { convertDotToTimesByLocale } from "./utils";
16
17
  export type { default as Keys } from "./data/keys";
17
18
  export { KeyArray } from "./data/keys";
18
19
  export { default as KeyConfigs } from "./data/key-configs";
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
48
48
 
49
49
  // This file is processed by a Rollup plugin (replace) to inject the production
50
50
  const libName = "@khanacademy/math-input";
51
- const libVersion = "16.2.0";
51
+ const libVersion = "16.3.0";
52
52
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
53
53
 
54
54
  function _extends() {
@@ -821,6 +821,30 @@ const DecimalSeparator = {
821
821
  // - Some languages/locales use different decimal separators than the ones
822
822
  // listed here. Much of the Arab world uses U+066C.
823
823
  const decimalSeparator = i18n.getDecimalSeparator() === "," ? DecimalSeparator.COMMA : DecimalSeparator.PERIOD;
824
+ const CDOT_ONLY = ["az", "cs", "da", "de", "hu", "hy", "kk", "ky", "lt", "lv", "nb", "sk", "sr", "sv", "uz"];
825
+ const TIMES_ONLY = ["fr", "tr", "pt-pt"];
826
+
827
+ /**
828
+ * convertDotToTimes (aka `times`) is an option the content creators have to
829
+ * use × (TIMES) rather than · (CDOT) for multiplication (for younger learners).
830
+ * Some locales _only_ use one or the other for all multiplication regardless
831
+ * of age.
832
+ *
833
+ * convertDotToTimesByLocale overrides convertDotToTimes for those locales.
834
+ *
835
+ * @param {boolean} convertDotToTimes - the setting set by content creators
836
+ * @returns {boolean} - true to convert to × (TIMES), false to use · (CDOT)
837
+ */
838
+ function convertDotToTimesByLocale(convertDotToTimes) {
839
+ const locale = i18n.getLocale();
840
+ if (CDOT_ONLY.includes(locale)) {
841
+ return false;
842
+ }
843
+ if (TIMES_ONLY.includes(locale)) {
844
+ return true;
845
+ }
846
+ return convertDotToTimes;
847
+ }
824
848
 
825
849
  function handleLeftArrow(mathField, cursor) {
826
850
  // If we're inside a function, and just after the left parentheses, we
@@ -5162,7 +5186,7 @@ function SharedKeys(props) {
5162
5186
  coord: fractionCoord,
5163
5187
  secondary: true
5164
5188
  }), /*#__PURE__*/React__namespace.createElement(KeypadButton, {
5165
- keyConfig: convertDotToTimes ? KeyConfigs.TIMES : KeyConfigs.CDOT,
5189
+ keyConfig: convertDotToTimesByLocale(!!convertDotToTimes) ? KeyConfigs.TIMES : KeyConfigs.CDOT,
5166
5190
  onClickKey: onClickKey,
5167
5191
  coord: [4, 1],
5168
5192
  secondary: true
@@ -5907,6 +5931,7 @@ exports.KeypadInput = MathInput;
5907
5931
  exports.KeypadType = KeypadType;
5908
5932
  exports.MobileKeypad = MobileKeypad;
5909
5933
  exports.StatefulKeypadContextProvider = StatefulKeypadContextProvider;
5934
+ exports.convertDotToTimesByLocale = convertDotToTimesByLocale;
5910
5935
  exports.createMathField = createMathField;
5911
5936
  exports.getCursorContext = getCursorContext;
5912
5937
  exports.keyTranslator = keyToMathquillMap;