@khanacademy/perseus 19.2.1 → 19.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/es/index.js CHANGED
@@ -1904,11 +1904,25 @@ const KhanAnswerTypes = {
1904
1904
  const _excluded$4 = ["scoring"];
1905
1905
  const ERROR_TITLE = i18n._("Oops!");
1906
1906
  const ERROR_MESSAGE = i18n._("Sorry, I don't understand that!");
1907
+
1908
+ // Map of international operator names to their English equivalents
1909
+ const englishOperators = {
1910
+ arctg: "arctan",
1911
+ cosec: "csc",
1912
+ cossec: "csc",
1913
+ cotg: "cot",
1914
+ ctg: "cot",
1915
+ sen: "sin",
1916
+ tg: "tan"
1917
+ };
1907
1918
  const anglicizeOperators = tex => {
1908
1919
  // sen is used instead of sin in some languages, e.g. Portuguese.
1909
1920
  // To ensure that answers in various languages are graded correctly, we
1910
1921
  // convert operators to their Englishy forms.
1911
- return tex.replace(/\\operatorname{sen}/g, "\\sin ");
1922
+ return tex.replace(/\\operatorname{([a-z]+)}/g, (_, op) => {
1923
+ var _englishOperators$op;
1924
+ return `\\${(_englishOperators$op = englishOperators[op]) != null ? _englishOperators$op : op} `;
1925
+ });
1912
1926
  };
1913
1927
  const normalizeTex = tex => {
1914
1928
  return anglicizeOperators(tex);
@@ -21521,15 +21535,6 @@ class InputNumber extends React.Component {
21521
21535
  };
21522
21536
  this._handleFocus = () => {
21523
21537
  this.props.onFocus([]);
21524
- // HACK(kevinb): We want to dismiss the feedback popover that webapp
21525
- // displays as soon as a user clicks in in the input field so we call
21526
- // interactionCallback directly.
21527
- const {
21528
- interactionCallback
21529
- } = this.props.apiOptions;
21530
- if (interactionCallback) {
21531
- interactionCallback();
21532
- }
21533
21538
  };
21534
21539
  this._handleBlur = () => {
21535
21540
  this.props.onBlur([]);
@@ -21863,15 +21868,6 @@ class NumericInput extends React.Component {
21863
21868
  };
21864
21869
  this._handleFocus = () => {
21865
21870
  this.props.onFocus([]);
21866
- // HACK(kevinb): We want to dismiss the feedback popover that webapp
21867
- // displays as soon as a user clicks in in the input field so we call
21868
- // interactionCallback directly.
21869
- const {
21870
- interactionCallback
21871
- } = this.props.apiOptions;
21872
- if (interactionCallback) {
21873
- interactionCallback();
21874
- }
21875
21871
  };
21876
21872
  this._handleBlur = () => {
21877
21873
  this.props.onBlur([]);
@@ -41556,7 +41552,7 @@ const init = function init(options) {
41556
41552
 
41557
41553
  // This file is processed by a Rollup plugin (replace) to inject the production
41558
41554
  const libName = "@khanacademy/perseus";
41559
- const libVersion = "19.2.1";
41555
+ const libVersion = "19.3.0";
41560
41556
  addLibraryVersionToPerseusDebug(libName, libVersion);
41561
41557
 
41562
41558
  const apiVersion = {
@@ -42101,20 +42097,25 @@ class ServerItemRenderer extends React.Component {
42101
42097
  this.blurTimeoutID = void 0;
42102
42098
  this._handleFocusChange = (newFocus, oldFocus) => {
42103
42099
  if (newFocus != null) {
42100
+ var _this$props$apiOption;
42104
42101
  this._setCurrentFocus(newFocus);
42102
+
42103
+ // Call the interactionCallback, if it exists, with the current user input data
42104
+ (_this$props$apiOption = this.props.apiOptions) == null || _this$props$apiOption.interactionCallback == null || _this$props$apiOption.interactionCallback(this.questionRenderer.getUserInputForWidgets());
42105
42105
  } else {
42106
42106
  this._onRendererBlur(oldFocus);
42107
42107
  }
42108
42108
  };
42109
42109
  this.handleInteractWithWidget = widgetId => {
42110
+ var _this$props$apiOption2;
42110
42111
  const withRemoved = _.difference(this.state.questionHighlightedWidgets, [widgetId]);
42111
42112
  this.setState({
42112
42113
  questionCompleted: false,
42113
42114
  questionHighlightedWidgets: withRemoved
42114
42115
  });
42115
- if (this.props.apiOptions.interactionCallback) {
42116
- this.props.apiOptions.interactionCallback();
42117
- }
42116
+
42117
+ // Call the interactionCallback, if it exists, with the current user input data
42118
+ (_this$props$apiOption2 = this.props.apiOptions) == null || _this$props$apiOption2.interactionCallback == null || _this$props$apiOption2.interactionCallback(this.questionRenderer.getUserInputForWidgets());
42118
42119
  };
42119
42120
  // This must be pre-bound otherwise SvgImage's shouldComponentUpdate
42120
42121
  // won't behave correctly and we'll get an infinite loop.