@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/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as KAS from '@khanacademy/kas';
|
|
|
2
2
|
import { MathInputI18nContext, CursorContext, getKeyTranslator, createMathField, getCursorContext, DesktopKeypad, convertDotToTimesByLocale, mathQuillInstance, KeypadInput, KeypadType, KeyArray, keypadElementPropType } from '@khanacademy/math-input';
|
|
3
3
|
import * as PerseusLinter from '@khanacademy/perseus-linter';
|
|
4
4
|
import { linterContextDefault, Rule, linterContextProps } from '@khanacademy/perseus-linter';
|
|
5
|
-
import { View, RenderStateRoot, UniqueIDProvider, useUniqueIdWithMock, Text as Text$2 } from '@khanacademy/wonder-blocks-core';
|
|
5
|
+
import { View, RenderStateRoot, UniqueIDProvider, useLatestRef, useUniqueIdWithMock, Text as Text$2 } from '@khanacademy/wonder-blocks-core';
|
|
6
6
|
import Tooltip$1 from '@khanacademy/wonder-blocks-tooltip';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import * as React from 'react';
|
|
@@ -29,7 +29,7 @@ import { OptionItem, SingleSelect, MultiSelect } from '@khanacademy/wonder-block
|
|
|
29
29
|
import caretDown from '@phosphor-icons/core/regular/caret-down.svg';
|
|
30
30
|
import caretUp from '@phosphor-icons/core/regular/caret-up.svg';
|
|
31
31
|
import debounce$2 from 'lodash.debounce';
|
|
32
|
-
import { vec, Ellipse, Line as Line$4, Point as Point$2, useMovable, Text as Text$1,
|
|
32
|
+
import { vec, Ellipse, Line as Line$4, Point as Point$2, Polygon, useMovable, Text as Text$1, Plot as Plot$3, Coordinates, Mafs } from 'mafs';
|
|
33
33
|
import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
|
|
34
34
|
import { Body, LabelSmall, LabelMedium } from '@khanacademy/wonder-blocks-typography';
|
|
35
35
|
import questionIcon from '@phosphor-icons/core/regular/question.svg';
|
|
@@ -28656,13 +28656,15 @@ const ItemExtras = [
|
|
|
28656
28656
|
|
|
28657
28657
|
const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
|
|
28658
28658
|
const lockedFigureColors = {
|
|
28659
|
+
blue: "#3D7586",
|
|
28659
28660
|
green: "#447A53",
|
|
28660
28661
|
grayH: "#3B3D45",
|
|
28661
28662
|
purple: "#594094",
|
|
28662
28663
|
pink: "#B25071",
|
|
28663
|
-
red: "#D92916"
|
|
28664
|
+
red: "#D92916",
|
|
28665
|
+
orange: "#946700"
|
|
28664
28666
|
};
|
|
28665
|
-
const
|
|
28667
|
+
const lockedFigureFillStyles = {
|
|
28666
28668
|
none: 0,
|
|
28667
28669
|
solid: 1,
|
|
28668
28670
|
translucent: 0.4
|
|
@@ -28682,7 +28684,7 @@ const LockedEllipse = props => {
|
|
|
28682
28684
|
center: center,
|
|
28683
28685
|
radius: radius,
|
|
28684
28686
|
angle: angle,
|
|
28685
|
-
fillOpacity:
|
|
28687
|
+
fillOpacity: lockedFigureFillStyles[fillStyle],
|
|
28686
28688
|
strokeStyle: strokeStyle,
|
|
28687
28689
|
color: lockedFigureColors[color]
|
|
28688
28690
|
});
|
|
@@ -28942,6 +28944,29 @@ const LockedPoint = props => {
|
|
|
28942
28944
|
});
|
|
28943
28945
|
};
|
|
28944
28946
|
|
|
28947
|
+
const LockedPolygon = props => {
|
|
28948
|
+
const {
|
|
28949
|
+
points,
|
|
28950
|
+
color,
|
|
28951
|
+
showVertices,
|
|
28952
|
+
fillStyle,
|
|
28953
|
+
strokeStyle
|
|
28954
|
+
} = props;
|
|
28955
|
+
return /*#__PURE__*/React.createElement("g", {
|
|
28956
|
+
className: "locked-polygon"
|
|
28957
|
+
}, /*#__PURE__*/React.createElement(Polygon, {
|
|
28958
|
+
points: [...points],
|
|
28959
|
+
fillOpacity: lockedFigureFillStyles[fillStyle],
|
|
28960
|
+
strokeStyle: strokeStyle,
|
|
28961
|
+
color: lockedFigureColors[color]
|
|
28962
|
+
}), showVertices && points.map((point, index) => /*#__PURE__*/React.createElement(Point$2, {
|
|
28963
|
+
key: `locked-polygon-point-${index}`,
|
|
28964
|
+
x: point[0],
|
|
28965
|
+
y: point[1],
|
|
28966
|
+
color: lockedFigureColors[color]
|
|
28967
|
+
})));
|
|
28968
|
+
};
|
|
28969
|
+
|
|
28945
28970
|
const LockedVector = props => {
|
|
28946
28971
|
const {
|
|
28947
28972
|
color,
|
|
@@ -28972,13 +28997,17 @@ const GraphLockedLayer = props => {
|
|
|
28972
28997
|
key: `line-${index}`,
|
|
28973
28998
|
range: props.range
|
|
28974
28999
|
}, figure));
|
|
29000
|
+
case "vector":
|
|
29001
|
+
return /*#__PURE__*/React.createElement(LockedVector, _extends({
|
|
29002
|
+
key: `vector-${index}`
|
|
29003
|
+
}, figure));
|
|
28975
29004
|
case "ellipse":
|
|
28976
29005
|
return /*#__PURE__*/React.createElement(LockedEllipse, _extends({
|
|
28977
29006
|
key: `ellipse-${index}`
|
|
28978
29007
|
}, figure));
|
|
28979
|
-
case "
|
|
28980
|
-
return /*#__PURE__*/React.createElement(
|
|
28981
|
-
key: `
|
|
29008
|
+
case "polygon":
|
|
29009
|
+
return /*#__PURE__*/React.createElement(LockedPolygon, _extends({
|
|
29010
|
+
key: `polygon-${index}`
|
|
28982
29011
|
}, figure));
|
|
28983
29012
|
default:
|
|
28984
29013
|
/**
|
|
@@ -28992,6 +29021,13 @@ const GraphLockedLayer = props => {
|
|
|
28992
29021
|
}));
|
|
28993
29022
|
};
|
|
28994
29023
|
|
|
29024
|
+
const REINITIALIZE = "reinitialize";
|
|
29025
|
+
function reinitialize(params) {
|
|
29026
|
+
return {
|
|
29027
|
+
type: REINITIALIZE,
|
|
29028
|
+
params
|
|
29029
|
+
};
|
|
29030
|
+
}
|
|
28995
29031
|
const MOVE_CONTROL_POINT = "move-control-point";
|
|
28996
29032
|
function moveControlPoint(pointIndex, destination, itemIndex) {
|
|
28997
29033
|
return {
|
|
@@ -31284,6 +31320,8 @@ function getCircleCoords(graph) {
|
|
|
31284
31320
|
|
|
31285
31321
|
function interactiveGraphReducer(state, action) {
|
|
31286
31322
|
switch (action.type) {
|
|
31323
|
+
case REINITIALIZE:
|
|
31324
|
+
return initializeGraphState(action.params);
|
|
31287
31325
|
case MOVE_CONTROL_POINT:
|
|
31288
31326
|
return doMoveControlPoint(state, action);
|
|
31289
31327
|
case MOVE_LINE:
|
|
@@ -31908,11 +31946,12 @@ function mafsStateToInteractiveGraph(state) {
|
|
|
31908
31946
|
}
|
|
31909
31947
|
const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
31910
31948
|
const {
|
|
31911
|
-
onChange
|
|
31949
|
+
onChange,
|
|
31950
|
+
graph
|
|
31912
31951
|
} = props;
|
|
31913
31952
|
const [state, dispatch] = React.useReducer(interactiveGraphReducer, props, initializeGraphState);
|
|
31914
31953
|
useImperativeHandle(ref, () => ({
|
|
31915
|
-
getUserInput: () => getGradableGraph(state,
|
|
31954
|
+
getUserInput: () => getGradableGraph(state, graph)
|
|
31916
31955
|
}));
|
|
31917
31956
|
const prevState = useRef(state);
|
|
31918
31957
|
useEffect(() => {
|
|
@@ -31935,6 +31974,18 @@ const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
31935
31974
|
useEffect(() => {
|
|
31936
31975
|
dispatch(changeRange([[xMinRange, xMaxRange], [yMinRange, yMaxRange]]));
|
|
31937
31976
|
}, [dispatch, xMinRange, xMaxRange, yMinRange, yMaxRange]);
|
|
31977
|
+
const numSegments = graph.type === "segment" ? graph.numSegments : null;
|
|
31978
|
+
const originalPropsRef = useRef(props);
|
|
31979
|
+
const latestPropsRef = useLatestRef(props);
|
|
31980
|
+
useEffect(() => {
|
|
31981
|
+
// This conditional prevents the state from being "reinitialized" right
|
|
31982
|
+
// after the first render. This is an optimization, but also prevents
|
|
31983
|
+
// a bug where the graph would be marked "incorrect" during grading
|
|
31984
|
+
// even if the user never interacted with it.
|
|
31985
|
+
if (latestPropsRef.current !== originalPropsRef.current) {
|
|
31986
|
+
dispatch(reinitialize(latestPropsRef.current));
|
|
31987
|
+
}
|
|
31988
|
+
}, [graph.type, numSegments, latestPropsRef]);
|
|
31938
31989
|
return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, props, {
|
|
31939
31990
|
state: state,
|
|
31940
31991
|
dispatch: dispatch
|
|
@@ -44101,7 +44152,7 @@ const init = function init(options) {
|
|
|
44101
44152
|
|
|
44102
44153
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44103
44154
|
const libName = "@khanacademy/perseus";
|
|
44104
|
-
const libVersion = "23.
|
|
44155
|
+
const libVersion = "23.5.0";
|
|
44105
44156
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44106
44157
|
|
|
44107
44158
|
const apiVersion = {
|
|
@@ -47102,5 +47153,5 @@ const EditorJsonify = {
|
|
|
47102
47153
|
}
|
|
47103
47154
|
};
|
|
47104
47155
|
|
|
47105
|
-
export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemExtras, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusI18nContext, PerseusI18nContextProvider, PerseusMarkdown, Plotter$1 as PlotterWidget, QUESTION_WIDGETS, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, addWidget, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, contentHasWidgetType, convertWidgetNameToEnum, displaySigFigs, generateTestCategorizerWidget, generateTestExpressionWidget, generateTestInteractiveGraphWidget, generateTestNumericInputWidget, generateTestPerseusItem, generateTestRadioWidget, genericPerseusItemData, getAnswerFromUserInput, getAnswersFromWidgets, getCorrectAnswerForWidgetId, getValidWidgetIds, getWidgetFromWidgetMap, getWidgetIdsFromContent, getWidgetIdsFromContentByType, getWidgetTypeByWidgetId, getWidgetsFromWidgetMap, getWidgetsMapFromItemData, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, isWidgetIdInContent, isWrongAnswerSupported, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion,
|
|
47156
|
+
export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemExtras, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusI18nContext, PerseusI18nContextProvider, PerseusMarkdown, Plotter$1 as PlotterWidget, QUESTION_WIDGETS, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, addWidget, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, contentHasWidgetType, convertWidgetNameToEnum, displaySigFigs, generateTestCategorizerWidget, generateTestExpressionWidget, generateTestInteractiveGraphWidget, generateTestNumericInputWidget, generateTestPerseusItem, generateTestRadioWidget, genericPerseusItemData, getAnswerFromUserInput, getAnswersFromWidgets, getCorrectAnswerForWidgetId, getValidWidgetIds, getWidgetFromWidgetMap, getWidgetIdsFromContent, getWidgetIdsFromContentByType, getWidgetTypeByWidgetId, getWidgetsFromWidgetMap, getWidgetsMapFromItemData, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, isWidgetIdInContent, isWrongAnswerSupported, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, lockedFigureColors, lockedFigureFillStyles, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, shouldHaveIndividualAnswer, traverse, usePerseusI18n, violatingWidgets, allWidgets as widgets };
|
|
47106
47157
|
//# sourceMappingURL=index.js.map
|