@khanacademy/perseus 19.2.0 → 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/index.js CHANGED
@@ -1929,11 +1929,22 @@ const KhanAnswerTypes = {
1929
1929
 
1930
1930
  const ERROR_TITLE = i18n__namespace._("Oops!");
1931
1931
  const ERROR_MESSAGE = i18n__namespace._("Sorry, I don't understand that!");
1932
+
1933
+ // Map of international operator names to their English equivalents
1934
+ const englishOperators = {
1935
+ arctg: "arctan",
1936
+ cosec: "csc",
1937
+ cossec: "csc",
1938
+ cotg: "cot",
1939
+ ctg: "cot",
1940
+ sen: "sin",
1941
+ tg: "tan"
1942
+ };
1932
1943
  const anglicizeOperators = tex => {
1933
1944
  // sen is used instead of sin in some languages, e.g. Portuguese.
1934
1945
  // To ensure that answers in various languages are graded correctly, we
1935
1946
  // convert operators to their Englishy forms.
1936
- return tex.replace(/\\operatorname{sen}/g, "\\sin ");
1947
+ return tex.replace(/\\operatorname{([a-z]+)}/g, (_, op) => `\\${englishOperators[op] ?? op} `);
1937
1948
  };
1938
1949
  const normalizeTex = tex => {
1939
1950
  return anglicizeOperators(tex);
@@ -2421,6 +2432,7 @@ ExpressionWithDependencies.getOneCorrectAnswerFromRubric = Expression.getOneCorr
2421
2432
  var Expression$1 = {
2422
2433
  name: "expression",
2423
2434
  displayName: "Expression / Equation",
2435
+ accessible: true,
2424
2436
  defaultAlignment: "inline-block",
2425
2437
  widget: ExpressionWithDependencies,
2426
2438
  transform: widgetOptions => {
@@ -21681,15 +21693,6 @@ class InputNumber extends React__namespace.Component {
21681
21693
  };
21682
21694
  _handleFocus = () => {
21683
21695
  this.props.onFocus([]);
21684
- // HACK(kevinb): We want to dismiss the feedback popover that webapp
21685
- // displays as soon as a user clicks in in the input field so we call
21686
- // interactionCallback directly.
21687
- const {
21688
- interactionCallback
21689
- } = this.props.apiOptions;
21690
- if (interactionCallback) {
21691
- interactionCallback();
21692
- }
21693
21696
  };
21694
21697
  _handleBlur = () => {
21695
21698
  this.props.onBlur([]);
@@ -22093,15 +22096,6 @@ class NumericInput extends React__namespace.Component {
22093
22096
  };
22094
22097
  _handleFocus = () => {
22095
22098
  this.props.onFocus([]);
22096
- // HACK(kevinb): We want to dismiss the feedback popover that webapp
22097
- // displays as soon as a user clicks in in the input field so we call
22098
- // interactionCallback directly.
22099
- const {
22100
- interactionCallback
22101
- } = this.props.apiOptions;
22102
- if (interactionCallback) {
22103
- interactionCallback();
22104
- }
22105
22099
  };
22106
22100
  _handleBlur = () => {
22107
22101
  this.props.onBlur([]);
@@ -41696,7 +41690,7 @@ const init = function (options) {
41696
41690
 
41697
41691
  // This file is processed by a Rollup plugin (replace) to inject the production
41698
41692
  const libName = "@khanacademy/perseus";
41699
- const libVersion = "19.2.0";
41693
+ const libVersion = "19.3.0";
41700
41694
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
41701
41695
 
41702
41696
  const apiVersion = {
@@ -42289,6 +42283,9 @@ class ServerItemRenderer extends React__namespace.Component {
42289
42283
  _handleFocusChange = (newFocus, oldFocus) => {
42290
42284
  if (newFocus != null) {
42291
42285
  this._setCurrentFocus(newFocus);
42286
+
42287
+ // Call the interactionCallback, if it exists, with the current user input data
42288
+ this.props.apiOptions?.interactionCallback?.(this.questionRenderer.getUserInputForWidgets());
42292
42289
  } else {
42293
42290
  this._onRendererBlur(oldFocus);
42294
42291
  }
@@ -42396,9 +42393,9 @@ class ServerItemRenderer extends React__namespace.Component {
42396
42393
  questionCompleted: false,
42397
42394
  questionHighlightedWidgets: withRemoved
42398
42395
  });
42399
- if (this.props.apiOptions.interactionCallback) {
42400
- this.props.apiOptions.interactionCallback();
42401
- }
42396
+
42397
+ // Call the interactionCallback, if it exists, with the current user input data
42398
+ this.props.apiOptions?.interactionCallback?.(this.questionRenderer.getUserInputForWidgets());
42402
42399
  };
42403
42400
  focus() {
42404
42401
  return this.questionRenderer.focus();