@khanacademy/perseus 23.4.0 → 23.5.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 +63 -12
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +61 -10
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -1
- package/dist/perseus-types.d.ts +16 -8
- package/dist/server-item-renderer.d.ts +1 -1
- package/dist/widgets/expression.d.ts +6 -6
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +9 -3
- package/dist/widgets/interactive-graphs/locked-polygon.d.ts +4 -0
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +2 -1
- package/dist/widgets/interactive-graphs/reducer/initialize-graph-state.d.ts +3 -2
- package/dist/widgets/interactive-graphs/reducer/interactive-graph-action.d.ts +8 -1
- package/dist/widgets/label-image.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export { default as KhanMath } from "./util/math";
|
|
|
51
51
|
export { default as LoadingContext } from "./loading-context";
|
|
52
52
|
export { default as mediaQueries } from "./styles/media-queries";
|
|
53
53
|
export { default as PerseusMarkdown } from "./perseus-markdown";
|
|
54
|
-
export { PerseusExpressionAnswerFormConsidered, plotterPlotTypes, ItemExtras, lockedFigureColors,
|
|
54
|
+
export { PerseusExpressionAnswerFormConsidered, plotterPlotTypes, ItemExtras, lockedFigureColors, lockedFigureFillStyles, } from "./perseus-types";
|
|
55
55
|
export { traverse } from "./traversal";
|
|
56
56
|
export { isItemRenderableByVersion } from "./renderability";
|
|
57
57
|
export { violatingWidgets } from "./a11y";
|
|
@@ -87,7 +87,7 @@ export type { ILogger, LogErrorOptions, ErrorKind } from "./logging/log";
|
|
|
87
87
|
export type { ServerItemRenderer as ServerItemRendererComponent } from "./server-item-renderer";
|
|
88
88
|
export type { Alignment, APIOptions, APIOptionsWithDefaults, ChangeHandler, DeviceType, DomInsertCheckFn, EditorMode, FocusPath, Hint, ImageDict, ImageUploader, JiptLabelStore, JiptRenderer, PerseusDependencies, PerseusScore, Version, VideoData, VideoKind, WidgetDict, WidgetExports, } from "./types";
|
|
89
89
|
export type { ParsedValue } from "./util";
|
|
90
|
-
export type { LockedFigure, LockedFigureColor, LockedFigureType, LockedPointType, LockedLineType,
|
|
90
|
+
export type { LockedFigure, LockedFigureColor, LockedFigureFillType, LockedFigureType, LockedPointType, LockedLineType, LockedVectorType, LockedEllipseType, LockedPolygonType, PerseusGraphType, PerseusAnswerArea, PerseusExpressionWidgetOptions, Range, Size, MathFormat, InputNumberWidget, // TODO(jeremy): remove?
|
|
91
91
|
PerseusImageBackground, PerseusInputNumberWidgetOptions, PerseusInteractiveGraphWidgetOptions, PerseusItem, PerseusPlotterWidgetOptions, PerseusPythonProgramWidgetOptions, PerseusRadioWidgetOptions, PerseusExampleWidgetOptions, PerseusExampleGraphieWidgetOptions, PerseusSimpleMarkdownTesterWidgetOptions, PerseusRenderer, PerseusWidget, PerseusWidgetsMap, } from "./perseus-types";
|
|
92
92
|
export type { Coord } from "./interactive2/types";
|
|
93
93
|
export type { MarkerType } from "./widgets/label-image/types";
|
package/dist/index.js
CHANGED
|
@@ -28947,13 +28947,15 @@ const ItemExtras = [
|
|
|
28947
28947
|
|
|
28948
28948
|
const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
|
|
28949
28949
|
const lockedFigureColors = {
|
|
28950
|
+
blue: "#3D7586",
|
|
28950
28951
|
green: "#447A53",
|
|
28951
28952
|
grayH: "#3B3D45",
|
|
28952
28953
|
purple: "#594094",
|
|
28953
28954
|
pink: "#B25071",
|
|
28954
|
-
red: "#D92916"
|
|
28955
|
+
red: "#D92916",
|
|
28956
|
+
orange: "#946700"
|
|
28955
28957
|
};
|
|
28956
|
-
const
|
|
28958
|
+
const lockedFigureFillStyles = {
|
|
28957
28959
|
none: 0,
|
|
28958
28960
|
solid: 1,
|
|
28959
28961
|
translucent: 0.4
|
|
@@ -28973,7 +28975,7 @@ const LockedEllipse = props => {
|
|
|
28973
28975
|
center: center,
|
|
28974
28976
|
radius: radius,
|
|
28975
28977
|
angle: angle,
|
|
28976
|
-
fillOpacity:
|
|
28978
|
+
fillOpacity: lockedFigureFillStyles[fillStyle],
|
|
28977
28979
|
strokeStyle: strokeStyle,
|
|
28978
28980
|
color: lockedFigureColors[color]
|
|
28979
28981
|
});
|
|
@@ -29232,6 +29234,29 @@ const LockedPoint = props => {
|
|
|
29232
29234
|
});
|
|
29233
29235
|
};
|
|
29234
29236
|
|
|
29237
|
+
const LockedPolygon = props => {
|
|
29238
|
+
const {
|
|
29239
|
+
points,
|
|
29240
|
+
color,
|
|
29241
|
+
showVertices,
|
|
29242
|
+
fillStyle,
|
|
29243
|
+
strokeStyle
|
|
29244
|
+
} = props;
|
|
29245
|
+
return /*#__PURE__*/React__namespace.createElement("g", {
|
|
29246
|
+
className: "locked-polygon"
|
|
29247
|
+
}, /*#__PURE__*/React__namespace.createElement(mafs.Polygon, {
|
|
29248
|
+
points: [...points],
|
|
29249
|
+
fillOpacity: lockedFigureFillStyles[fillStyle],
|
|
29250
|
+
strokeStyle: strokeStyle,
|
|
29251
|
+
color: lockedFigureColors[color]
|
|
29252
|
+
}), showVertices && points.map((point, index) => /*#__PURE__*/React__namespace.createElement(mafs.Point, {
|
|
29253
|
+
key: `locked-polygon-point-${index}`,
|
|
29254
|
+
x: point[0],
|
|
29255
|
+
y: point[1],
|
|
29256
|
+
color: lockedFigureColors[color]
|
|
29257
|
+
})));
|
|
29258
|
+
};
|
|
29259
|
+
|
|
29235
29260
|
const LockedVector = props => {
|
|
29236
29261
|
const {
|
|
29237
29262
|
color,
|
|
@@ -29262,13 +29287,17 @@ const GraphLockedLayer = props => {
|
|
|
29262
29287
|
key: `line-${index}`,
|
|
29263
29288
|
range: props.range
|
|
29264
29289
|
}, figure));
|
|
29290
|
+
case "vector":
|
|
29291
|
+
return /*#__PURE__*/React__namespace.createElement(LockedVector, _extends({
|
|
29292
|
+
key: `vector-${index}`
|
|
29293
|
+
}, figure));
|
|
29265
29294
|
case "ellipse":
|
|
29266
29295
|
return /*#__PURE__*/React__namespace.createElement(LockedEllipse, _extends({
|
|
29267
29296
|
key: `ellipse-${index}`
|
|
29268
29297
|
}, figure));
|
|
29269
|
-
case "
|
|
29270
|
-
return /*#__PURE__*/React__namespace.createElement(
|
|
29271
|
-
key: `
|
|
29298
|
+
case "polygon":
|
|
29299
|
+
return /*#__PURE__*/React__namespace.createElement(LockedPolygon, _extends({
|
|
29300
|
+
key: `polygon-${index}`
|
|
29272
29301
|
}, figure));
|
|
29273
29302
|
default:
|
|
29274
29303
|
/**
|
|
@@ -29282,6 +29311,13 @@ const GraphLockedLayer = props => {
|
|
|
29282
29311
|
}));
|
|
29283
29312
|
};
|
|
29284
29313
|
|
|
29314
|
+
const REINITIALIZE = "reinitialize";
|
|
29315
|
+
function reinitialize(params) {
|
|
29316
|
+
return {
|
|
29317
|
+
type: REINITIALIZE,
|
|
29318
|
+
params
|
|
29319
|
+
};
|
|
29320
|
+
}
|
|
29285
29321
|
const MOVE_CONTROL_POINT = "move-control-point";
|
|
29286
29322
|
function moveControlPoint(pointIndex, destination, itemIndex) {
|
|
29287
29323
|
return {
|
|
@@ -31609,6 +31645,8 @@ function getCircleCoords(graph) {
|
|
|
31609
31645
|
|
|
31610
31646
|
function interactiveGraphReducer(state, action) {
|
|
31611
31647
|
switch (action.type) {
|
|
31648
|
+
case REINITIALIZE:
|
|
31649
|
+
return initializeGraphState(action.params);
|
|
31612
31650
|
case MOVE_CONTROL_POINT:
|
|
31613
31651
|
return doMoveControlPoint(state, action);
|
|
31614
31652
|
case MOVE_LINE:
|
|
@@ -32258,11 +32296,12 @@ function mafsStateToInteractiveGraph(state) {
|
|
|
32258
32296
|
}
|
|
32259
32297
|
const StatefulMafsGraph = /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
|
|
32260
32298
|
const {
|
|
32261
|
-
onChange
|
|
32299
|
+
onChange,
|
|
32300
|
+
graph
|
|
32262
32301
|
} = props;
|
|
32263
32302
|
const [state, dispatch] = React__namespace.useReducer(interactiveGraphReducer, props, initializeGraphState);
|
|
32264
32303
|
React.useImperativeHandle(ref, () => ({
|
|
32265
|
-
getUserInput: () => getGradableGraph(state,
|
|
32304
|
+
getUserInput: () => getGradableGraph(state, graph)
|
|
32266
32305
|
}));
|
|
32267
32306
|
const prevState = React.useRef(state);
|
|
32268
32307
|
React.useEffect(() => {
|
|
@@ -32285,6 +32324,18 @@ const StatefulMafsGraph = /*#__PURE__*/React__namespace.forwardRef((props, ref)
|
|
|
32285
32324
|
React.useEffect(() => {
|
|
32286
32325
|
dispatch(changeRange([[xMinRange, xMaxRange], [yMinRange, yMaxRange]]));
|
|
32287
32326
|
}, [dispatch, xMinRange, xMaxRange, yMinRange, yMaxRange]);
|
|
32327
|
+
const numSegments = graph.type === "segment" ? graph.numSegments : null;
|
|
32328
|
+
const originalPropsRef = React.useRef(props);
|
|
32329
|
+
const latestPropsRef = wonderBlocksCore.useLatestRef(props);
|
|
32330
|
+
React.useEffect(() => {
|
|
32331
|
+
// This conditional prevents the state from being "reinitialized" right
|
|
32332
|
+
// after the first render. This is an optimization, but also prevents
|
|
32333
|
+
// a bug where the graph would be marked "incorrect" during grading
|
|
32334
|
+
// even if the user never interacted with it.
|
|
32335
|
+
if (latestPropsRef.current !== originalPropsRef.current) {
|
|
32336
|
+
dispatch(reinitialize(latestPropsRef.current));
|
|
32337
|
+
}
|
|
32338
|
+
}, [graph.type, numSegments, latestPropsRef]);
|
|
32288
32339
|
return /*#__PURE__*/React__namespace.createElement(MafsGraph, _extends({}, props, {
|
|
32289
32340
|
state: state,
|
|
32290
32341
|
dispatch: dispatch
|
|
@@ -44446,7 +44497,7 @@ const init = function (options) {
|
|
|
44446
44497
|
|
|
44447
44498
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44448
44499
|
const libName = "@khanacademy/perseus";
|
|
44449
|
-
const libVersion = "23.
|
|
44500
|
+
const libVersion = "23.5.0";
|
|
44450
44501
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44451
44502
|
|
|
44452
44503
|
const apiVersion = {
|
|
@@ -47546,8 +47597,8 @@ exports.itemDataVersion = itemDataVersion;
|
|
|
47546
47597
|
exports.itemToTree = itemToTree;
|
|
47547
47598
|
exports.itemVersion = ItemVersion;
|
|
47548
47599
|
exports.libVersion = libVersion;
|
|
47549
|
-
exports.lockedEllipseFillStyles = lockedEllipseFillStyles;
|
|
47550
47600
|
exports.lockedFigureColors = lockedFigureColors;
|
|
47601
|
+
exports.lockedFigureFillStyles = lockedFigureFillStyles;
|
|
47551
47602
|
exports.mediaQueries = mediaQueries;
|
|
47552
47603
|
exports.parsePerseusItem = parsePerseusItem;
|
|
47553
47604
|
exports.plotterPlotTypes = plotterPlotTypes;
|