@khanacademy/perseus 50.0.0 → 50.1.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
@@ -675,7 +675,7 @@ const mockStrings = {
675
675
  // The above strings are used for interactive graph SR descriptions.
676
676
  };
677
677
 
678
- ({
678
+ const errorToString = {
679
679
  [perseusScore.ErrorCodes.MISSING_PERCENT_ERROR]: strings.MISSING_PERCENT_ERROR,
680
680
  [perseusScore.ErrorCodes.NEEDS_TO_BE_SIMPLIFIED_ERROR]: strings.NEEDS_TO_BE_SIMPLFIED_ERROR,
681
681
  [perseusScore.ErrorCodes.APPROXIMATED_PI_ERROR]: strings.APPROXIMATED_PI_ERROR,
@@ -683,7 +683,13 @@ const mockStrings = {
683
683
  [perseusScore.ErrorCodes.WRONG_CASE_ERROR]: strings.WRONG_CASE_ERROR,
684
684
  [perseusScore.ErrorCodes.WRONG_LETTER_ERROR]: strings.WRONG_LETTER_ERROR,
685
685
  [perseusScore.ErrorCodes.MULTIPLICATION_SIGN_ERROR]: strings.MULTIPLICATION_SIGN_ERROR
686
- });
686
+ };
687
+ function mapErrorToString(err) {
688
+ if (!err) {
689
+ return err;
690
+ }
691
+ return errorToString[err] || err;
692
+ }
687
693
 
688
694
  /**
689
695
  * PerseusI18nContext provides a way to set the strings and locale that are
@@ -18469,6 +18475,9 @@ const getWidgetExport = name => {
18469
18475
  const getWidgetScorer = name => {
18470
18476
  return widgets[name]?.scorer ?? null;
18471
18477
  };
18478
+ const getPublicWidgetOptionsFunction = name => {
18479
+ return widgets[name]?.getPublicWidgetOptions ?? (i => i);
18480
+ };
18472
18481
  const getEditor = name => {
18473
18482
  return ___default["default"].has(editors, name) ? editors[name] : null;
18474
18483
  };
@@ -18776,6 +18785,7 @@ var widgets$1 = /*#__PURE__*/Object.freeze({
18776
18785
  getWidget: getWidget,
18777
18786
  getWidgetExport: getWidgetExport,
18778
18787
  getWidgetScorer: getWidgetScorer,
18788
+ getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
18779
18789
  getEditor: getEditor,
18780
18790
  getTransform: getTransform,
18781
18791
  getVersion: getVersion,
@@ -26288,6 +26298,24 @@ const getPromptJSON$n = (renderProps, userInput) => {
26288
26298
  };
26289
26299
  };
26290
26300
 
26301
+ /**
26302
+ * For details on the individual options, see the
26303
+ * PerseusCategorizerWidgetOptions type
26304
+ */
26305
+
26306
+ /**
26307
+ * Given a PerseusCategorizerWidgetOptions object, return a new object with only
26308
+ * the public options that should be exposed to the client.
26309
+ */
26310
+ function getCategorizerPublicWidgetOptions(options) {
26311
+ return {
26312
+ items: options.items,
26313
+ categories: options.categories,
26314
+ randomizeItems: options.randomizeItems,
26315
+ static: options.static
26316
+ };
26317
+ }
26318
+
26291
26319
  /**
26292
26320
  * Checks userInput from the categorizer widget to see if the user has selected
26293
26321
  * a category for each item.
@@ -26507,7 +26535,8 @@ var Categorizer$1 = {
26507
26535
  isLintable: true,
26508
26536
  // TODO(LEMS-2656): remove TS suppression
26509
26537
  // @ts-expect-error: Type 'UserInput' is not assignable to type 'PerseusCSProgramUserInput'.
26510
- scorer: scoreCategorizer
26538
+ scorer: scoreCategorizer,
26539
+ getPublicWidgetOptions: getCategorizerPublicWidgetOptions
26511
26540
  };
26512
26541
 
26513
26542
  /**
@@ -27371,7 +27400,7 @@ class GradedGroup extends React__namespace.Component {
27371
27400
  DEFAULT_INVALID_MESSAGE_2
27372
27401
  } = this.context.strings;
27373
27402
  const status = score.type === "points" ? score.total === score.earned ? GRADING_STATUSES.correct : GRADING_STATUSES.incorrect : GRADING_STATUSES.invalid;
27374
- const message = score.type === "points" ? score.message || "" : score.message ? `${INVALID_MESSAGE_PREFIX} ${score.message}` : `${INVALID_MESSAGE_PREFIX} ${DEFAULT_INVALID_MESSAGE_1}${DEFAULT_INVALID_MESSAGE_2}`;
27403
+ const message = score.type === "points" ? score.message || "" : score.message ? `${INVALID_MESSAGE_PREFIX} ${mapErrorToString(score.message)}` : `${INVALID_MESSAGE_PREFIX} ${DEFAULT_INVALID_MESSAGE_1}${DEFAULT_INVALID_MESSAGE_2}`;
27375
27404
  this.setState({
27376
27405
  status: status,
27377
27406
  message: message,
@@ -31923,7 +31952,8 @@ const LockedEllipse = props => {
31923
31952
  return /*#__PURE__*/React__namespace.createElement("g", {
31924
31953
  className: "locked-ellipse",
31925
31954
  "aria-label": hasAria ? ariaLabel : undefined,
31926
- "aria-hidden": !hasAria
31955
+ "aria-hidden": !hasAria,
31956
+ role: "img"
31927
31957
  }, /*#__PURE__*/React__namespace.createElement(mafs.Ellipse, {
31928
31958
  center: center,
31929
31959
  radius: radius,
@@ -31968,7 +31998,8 @@ const LockedFunction = props => {
31968
31998
  return /*#__PURE__*/React__namespace.createElement("g", {
31969
31999
  className: "locked-function",
31970
32000
  "aria-label": hasAria ? props.ariaLabel : undefined,
31971
- "aria-hidden": !hasAria
32001
+ "aria-hidden": !hasAria,
32002
+ role: "img"
31972
32003
  }, directionalAxis === "x" && /*#__PURE__*/React__namespace.createElement(mafs.Plot.OfX, _extends({
31973
32004
  y: x => equation.eval({
31974
32005
  x
@@ -32128,7 +32159,8 @@ const LockedLine = props => {
32128
32159
  return /*#__PURE__*/React__namespace.createElement("g", {
32129
32160
  className: kind === "ray" ? "locked-ray" : "locked-line",
32130
32161
  "aria-label": hasAria ? ariaLabel : undefined,
32131
- "aria-hidden": !hasAria
32162
+ "aria-hidden": !hasAria,
32163
+ role: "img"
32132
32164
  }, line, showPoint1 && /*#__PURE__*/React__namespace.createElement(mafs.Point, {
32133
32165
  x: point1.coord[X],
32134
32166
  y: point1.coord[Y],
@@ -32164,7 +32196,8 @@ const LockedPoint = props => {
32164
32196
  return /*#__PURE__*/React__namespace.createElement("g", {
32165
32197
  className: "locked-point",
32166
32198
  "aria-label": hasAria ? ariaLabel : undefined,
32167
- "aria-hidden": !hasAria
32199
+ "aria-hidden": !hasAria,
32200
+ role: "img"
32168
32201
  }, /*#__PURE__*/React__namespace.createElement(mafs.Point, {
32169
32202
  x: x,
32170
32203
  y: y,
@@ -32190,7 +32223,8 @@ const LockedPolygon = props => {
32190
32223
  return /*#__PURE__*/React__namespace.createElement("g", {
32191
32224
  className: "locked-polygon",
32192
32225
  "aria-label": hasAria ? props.ariaLabel : undefined,
32193
- "aria-hidden": !hasAria
32226
+ "aria-hidden": !hasAria,
32227
+ role: "img"
32194
32228
  }, /*#__PURE__*/React__namespace.createElement(mafs.Polygon, {
32195
32229
  points: [...points],
32196
32230
  fillOpacity: perseusCore.lockedFigureFillStyles[fillStyle],
@@ -32224,7 +32258,8 @@ const LockedVector = props => {
32224
32258
  return /*#__PURE__*/React__namespace.createElement("g", {
32225
32259
  className: "locked-vector",
32226
32260
  "aria-label": hasAria ? ariaLabel : undefined,
32227
- "aria-hidden": !hasAria
32261
+ "aria-hidden": !hasAria,
32262
+ role: "img"
32228
32263
  }, /*#__PURE__*/React__namespace.createElement(Vector, {
32229
32264
  tail: tail,
32230
32265
  tip: tip,
@@ -44967,7 +45002,7 @@ const init = function () {
44967
45002
 
44968
45003
  // This file is processed by a Rollup plugin (replace) to inject the production
44969
45004
  const libName = "@khanacademy/perseus";
44970
- const libVersion = "50.0.0";
45005
+ const libVersion = "50.1.0";
44971
45006
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
44972
45007
 
44973
45008
  const apiVersion = {