@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/es/index.js +47 -11
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +46 -11
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/widgets/categorizer/categorizer.d.ts +2 -0
- package/dist/widgets/categorizer/categorizer.util.d.ts +17 -0
- package/dist/widgets.d.ts +2 -1
- package/package.json +39 -39
package/dist/es/index.js
CHANGED
|
@@ -504,7 +504,7 @@ const mockStrings = {
|
|
|
504
504
|
// The above strings are used for interactive graph SR descriptions.
|
|
505
505
|
};
|
|
506
506
|
|
|
507
|
-
|
|
507
|
+
const errorToString = {
|
|
508
508
|
[ErrorCodes.MISSING_PERCENT_ERROR]: strings.MISSING_PERCENT_ERROR,
|
|
509
509
|
[ErrorCodes.NEEDS_TO_BE_SIMPLIFIED_ERROR]: strings.NEEDS_TO_BE_SIMPLFIED_ERROR,
|
|
510
510
|
[ErrorCodes.APPROXIMATED_PI_ERROR]: strings.APPROXIMATED_PI_ERROR,
|
|
@@ -512,7 +512,13 @@ const mockStrings = {
|
|
|
512
512
|
[ErrorCodes.WRONG_CASE_ERROR]: strings.WRONG_CASE_ERROR,
|
|
513
513
|
[ErrorCodes.WRONG_LETTER_ERROR]: strings.WRONG_LETTER_ERROR,
|
|
514
514
|
[ErrorCodes.MULTIPLICATION_SIGN_ERROR]: strings.MULTIPLICATION_SIGN_ERROR
|
|
515
|
-
}
|
|
515
|
+
};
|
|
516
|
+
function mapErrorToString(err) {
|
|
517
|
+
if (!err) {
|
|
518
|
+
return err;
|
|
519
|
+
}
|
|
520
|
+
return errorToString[err] || err;
|
|
521
|
+
}
|
|
516
522
|
|
|
517
523
|
/**
|
|
518
524
|
* PerseusI18nContext provides a way to set the strings and locale that are
|
|
@@ -18248,6 +18254,10 @@ const getWidgetScorer = name => {
|
|
|
18248
18254
|
var _widgets$name$scorer, _widgets$name4;
|
|
18249
18255
|
return (_widgets$name$scorer = (_widgets$name4 = widgets[name]) == null ? void 0 : _widgets$name4.scorer) != null ? _widgets$name$scorer : null;
|
|
18250
18256
|
};
|
|
18257
|
+
const getPublicWidgetOptionsFunction = name => {
|
|
18258
|
+
var _widgets$name$getPubl, _widgets$name5;
|
|
18259
|
+
return (_widgets$name$getPubl = (_widgets$name5 = widgets[name]) == null ? void 0 : _widgets$name5.getPublicWidgetOptions) != null ? _widgets$name$getPubl : i => i;
|
|
18260
|
+
};
|
|
18251
18261
|
const getEditor = name => {
|
|
18252
18262
|
return _.has(editors, name) ? editors[name] : null;
|
|
18253
18263
|
};
|
|
@@ -18552,6 +18562,7 @@ var widgets$1 = /*#__PURE__*/Object.freeze({
|
|
|
18552
18562
|
getWidget: getWidget,
|
|
18553
18563
|
getWidgetExport: getWidgetExport,
|
|
18554
18564
|
getWidgetScorer: getWidgetScorer,
|
|
18565
|
+
getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
|
|
18555
18566
|
getEditor: getEditor,
|
|
18556
18567
|
getTransform: getTransform,
|
|
18557
18568
|
getVersion: getVersion,
|
|
@@ -26008,6 +26019,24 @@ const getPromptJSON$n = (renderProps, userInput) => {
|
|
|
26008
26019
|
};
|
|
26009
26020
|
};
|
|
26010
26021
|
|
|
26022
|
+
/**
|
|
26023
|
+
* For details on the individual options, see the
|
|
26024
|
+
* PerseusCategorizerWidgetOptions type
|
|
26025
|
+
*/
|
|
26026
|
+
|
|
26027
|
+
/**
|
|
26028
|
+
* Given a PerseusCategorizerWidgetOptions object, return a new object with only
|
|
26029
|
+
* the public options that should be exposed to the client.
|
|
26030
|
+
*/
|
|
26031
|
+
function getCategorizerPublicWidgetOptions(options) {
|
|
26032
|
+
return {
|
|
26033
|
+
items: options.items,
|
|
26034
|
+
categories: options.categories,
|
|
26035
|
+
randomizeItems: options.randomizeItems,
|
|
26036
|
+
static: options.static
|
|
26037
|
+
};
|
|
26038
|
+
}
|
|
26039
|
+
|
|
26011
26040
|
/**
|
|
26012
26041
|
* Checks userInput from the categorizer widget to see if the user has selected
|
|
26013
26042
|
* a category for each item.
|
|
@@ -26224,7 +26253,8 @@ var Categorizer$1 = {
|
|
|
26224
26253
|
isLintable: true,
|
|
26225
26254
|
// TODO(LEMS-2656): remove TS suppression
|
|
26226
26255
|
// @ts-expect-error: Type 'UserInput' is not assignable to type 'PerseusCSProgramUserInput'.
|
|
26227
|
-
scorer: scoreCategorizer
|
|
26256
|
+
scorer: scoreCategorizer,
|
|
26257
|
+
getPublicWidgetOptions: getCategorizerPublicWidgetOptions
|
|
26228
26258
|
};
|
|
26229
26259
|
|
|
26230
26260
|
/**
|
|
@@ -27063,7 +27093,7 @@ class GradedGroup extends React.Component {
|
|
|
27063
27093
|
DEFAULT_INVALID_MESSAGE_2
|
|
27064
27094
|
} = this.context.strings;
|
|
27065
27095
|
const status = score.type === "points" ? score.total === score.earned ? GRADING_STATUSES.correct : GRADING_STATUSES.incorrect : GRADING_STATUSES.invalid;
|
|
27066
|
-
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}`;
|
|
27096
|
+
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}`;
|
|
27067
27097
|
this.setState({
|
|
27068
27098
|
status: status,
|
|
27069
27099
|
message: message,
|
|
@@ -31591,7 +31621,8 @@ const LockedEllipse = props => {
|
|
|
31591
31621
|
return /*#__PURE__*/React.createElement("g", {
|
|
31592
31622
|
className: "locked-ellipse",
|
|
31593
31623
|
"aria-label": hasAria ? ariaLabel : undefined,
|
|
31594
|
-
"aria-hidden": !hasAria
|
|
31624
|
+
"aria-hidden": !hasAria,
|
|
31625
|
+
role: "img"
|
|
31595
31626
|
}, /*#__PURE__*/React.createElement(Ellipse, {
|
|
31596
31627
|
center: center,
|
|
31597
31628
|
radius: radius,
|
|
@@ -31636,7 +31667,8 @@ const LockedFunction = props => {
|
|
|
31636
31667
|
return /*#__PURE__*/React.createElement("g", {
|
|
31637
31668
|
className: "locked-function",
|
|
31638
31669
|
"aria-label": hasAria ? props.ariaLabel : undefined,
|
|
31639
|
-
"aria-hidden": !hasAria
|
|
31670
|
+
"aria-hidden": !hasAria,
|
|
31671
|
+
role: "img"
|
|
31640
31672
|
}, directionalAxis === "x" && /*#__PURE__*/React.createElement(Plot$3.OfX, _extends({
|
|
31641
31673
|
y: x => equation.eval({
|
|
31642
31674
|
x
|
|
@@ -31793,7 +31825,8 @@ const LockedLine = props => {
|
|
|
31793
31825
|
return /*#__PURE__*/React.createElement("g", {
|
|
31794
31826
|
className: kind === "ray" ? "locked-ray" : "locked-line",
|
|
31795
31827
|
"aria-label": hasAria ? ariaLabel : undefined,
|
|
31796
|
-
"aria-hidden": !hasAria
|
|
31828
|
+
"aria-hidden": !hasAria,
|
|
31829
|
+
role: "img"
|
|
31797
31830
|
}, line, showPoint1 && /*#__PURE__*/React.createElement(Point$2, {
|
|
31798
31831
|
x: point1.coord[X],
|
|
31799
31832
|
y: point1.coord[Y],
|
|
@@ -31829,7 +31862,8 @@ const LockedPoint = props => {
|
|
|
31829
31862
|
return /*#__PURE__*/React.createElement("g", {
|
|
31830
31863
|
className: "locked-point",
|
|
31831
31864
|
"aria-label": hasAria ? ariaLabel : undefined,
|
|
31832
|
-
"aria-hidden": !hasAria
|
|
31865
|
+
"aria-hidden": !hasAria,
|
|
31866
|
+
role: "img"
|
|
31833
31867
|
}, /*#__PURE__*/React.createElement(Point$2, {
|
|
31834
31868
|
x: x,
|
|
31835
31869
|
y: y,
|
|
@@ -31855,7 +31889,8 @@ const LockedPolygon = props => {
|
|
|
31855
31889
|
return /*#__PURE__*/React.createElement("g", {
|
|
31856
31890
|
className: "locked-polygon",
|
|
31857
31891
|
"aria-label": hasAria ? props.ariaLabel : undefined,
|
|
31858
|
-
"aria-hidden": !hasAria
|
|
31892
|
+
"aria-hidden": !hasAria,
|
|
31893
|
+
role: "img"
|
|
31859
31894
|
}, /*#__PURE__*/React.createElement(Polygon, {
|
|
31860
31895
|
points: [...points],
|
|
31861
31896
|
fillOpacity: lockedFigureFillStyles[fillStyle],
|
|
@@ -31889,7 +31924,8 @@ const LockedVector = props => {
|
|
|
31889
31924
|
return /*#__PURE__*/React.createElement("g", {
|
|
31890
31925
|
className: "locked-vector",
|
|
31891
31926
|
"aria-label": hasAria ? ariaLabel : undefined,
|
|
31892
|
-
"aria-hidden": !hasAria
|
|
31927
|
+
"aria-hidden": !hasAria,
|
|
31928
|
+
role: "img"
|
|
31893
31929
|
}, /*#__PURE__*/React.createElement(Vector, {
|
|
31894
31930
|
tail: tail,
|
|
31895
31931
|
tip: tip,
|
|
@@ -44559,7 +44595,7 @@ const init = function init() {
|
|
|
44559
44595
|
|
|
44560
44596
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44561
44597
|
const libName = "@khanacademy/perseus";
|
|
44562
|
-
const libVersion = "50.
|
|
44598
|
+
const libVersion = "50.1.0";
|
|
44563
44599
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44564
44600
|
|
|
44565
44601
|
const apiVersion = {
|