@khanacademy/perseus 20.5.0 → 20.6.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/components/icon.d.ts +1 -0
- package/dist/es/index.js +123 -23
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +116 -19
- package/dist/index.js.map +1 -1
- package/dist/interactive2/movable.d.ts +1 -1
- package/dist/interactive2/objective_.d.ts +2 -2
- package/dist/styles/global-styles.d.ts +1 -0
- package/dist/styles/shared.d.ts +1 -0
- package/dist/types.d.ts +102 -0
- package/dist/util/a11y.d.ts +1 -0
- package/dist/util/extract-perseus-data.d.ts +8 -1
- package/dist/util/widget-enum-utils.d.ts +11 -0
- package/dist/util.d.ts +1 -1
- package/dist/widgets/interactive-graph.d.ts +9 -2
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +1 -1
- package/dist/widgets/label-image/answer-pill.d.ts +1 -0
- package/dist/widgets/label-image/marker.d.ts +1 -0
- package/dist/widgets/radio/choice-icon/shared-styles.d.ts +1 -0
- package/dist/widgets/radio.d.ts +1 -1
- package/package.json +3 -3
- /package/dist/widgets/radio/{widget.d.ts → radio.d.ts} +0 -0
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
* If you want to add an entirely new icon please read the note inside
|
|
29
29
|
* the `icon-paths.js` file.
|
|
30
30
|
*/
|
|
31
|
+
/// <reference path="../../types/aphrodite.d.ts" />
|
|
31
32
|
import * as React from "react";
|
|
32
33
|
import type { CSSProperties } from "aphrodite";
|
|
33
34
|
export type IconType = {
|
package/dist/es/index.js
CHANGED
|
@@ -19337,7 +19337,6 @@ class Renderer extends React.Component {
|
|
|
19337
19337
|
};
|
|
19338
19338
|
// @ts-expect-error - TS2322 - Type '(props: Props) => Partial<Record<string, CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ... 35 more ... | VideoWidget>>' is not assignable to type '(props: Props) => { [key: string]: PerseusWidget; }'.
|
|
19339
19339
|
this._getAllWidgetsInfo = props => {
|
|
19340
|
-
// @ts-expect-error - TS2345 - Argument of type '{ [key: string]: PerseusWidget; }' is not assignable to parameter of type 'Partial<Record<string, CategorizerWidget>>'.
|
|
19341
19340
|
return mapObject$1(props.widgets, (widgetInfo, widgetId) => {
|
|
19342
19341
|
if (!widgetInfo.type || !widgetInfo.alignment) {
|
|
19343
19342
|
const newValues = {};
|
|
@@ -29546,7 +29545,7 @@ const makeInvalidTypeError = (functionName, graphType) => {
|
|
|
29546
29545
|
|
|
29547
29546
|
// There's no transform function in exports
|
|
29548
29547
|
|
|
29549
|
-
class
|
|
29548
|
+
class LegacyInteractiveGraph extends React.Component {
|
|
29550
29549
|
constructor(...args) {
|
|
29551
29550
|
super(...args);
|
|
29552
29551
|
this.angle = void 0;
|
|
@@ -29567,7 +29566,6 @@ class InteractiveGraph extends React.Component {
|
|
|
29567
29566
|
this.sinusoid = void 0;
|
|
29568
29567
|
this.trashCan = void 0;
|
|
29569
29568
|
this.vertHairline = void 0;
|
|
29570
|
-
this.mafsRef = /*#__PURE__*/React.createRef();
|
|
29571
29569
|
this.state = {
|
|
29572
29570
|
shouldShowInstructions: _getShouldShowInstructions(this.props)
|
|
29573
29571
|
};
|
|
@@ -30647,10 +30645,7 @@ class InteractiveGraph extends React.Component {
|
|
|
30647
30645
|
graph: graph
|
|
30648
30646
|
});
|
|
30649
30647
|
};
|
|
30650
|
-
this.getUserInput = () =>
|
|
30651
|
-
var _this$mafsRef$current, _this$mafsRef$current2;
|
|
30652
|
-
return (_this$mafsRef$current = (_this$mafsRef$current2 = this.mafsRef.current) == null || _this$mafsRef$current2.getUserInput == null ? void 0 : _this$mafsRef$current2.getUserInput()) != null ? _this$mafsRef$current : InteractiveGraph.getUserInputFromProps(this.props);
|
|
30653
|
-
};
|
|
30648
|
+
this.getUserInput = () => InteractiveGraph.getUserInputFromProps(this.props);
|
|
30654
30649
|
this.simpleValidate = rubric => InteractiveGraph.validate(this.getUserInput(), rubric, this);
|
|
30655
30650
|
this.focus = $.noop;
|
|
30656
30651
|
}
|
|
@@ -30703,23 +30698,10 @@ class InteractiveGraph extends React.Component {
|
|
|
30703
30698
|
areSegmentGraphsEqual(prevGraph, currentGraph) {
|
|
30704
30699
|
return prevGraph.numSegments !== currentGraph.numSegments;
|
|
30705
30700
|
}
|
|
30706
|
-
// const segment: boolean = useFeatureIsOn("mafs-segment-graph");
|
|
30707
|
-
// <Renderer apiOptions={{flags: {mafs: {segment}}}}
|
|
30708
30701
|
render() {
|
|
30709
|
-
var _this$props$apiOption;
|
|
30710
30702
|
const box = getInteractiveBoxFromSizeClass(this.props.containerSizeClass);
|
|
30711
30703
|
const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, box[0]);
|
|
30712
30704
|
const snapStep = this.props.snapStep || Util.snapStepFromGridStep(gridStep);
|
|
30713
|
-
|
|
30714
|
-
// Mafs shim
|
|
30715
|
-
if ((_this$props$apiOption = this.props.apiOptions) != null && (_this$props$apiOption = _this$props$apiOption.flags) != null && (_this$props$apiOption = _this$props$apiOption["mafs"]) != null && _this$props$apiOption[this.props.graph.type]) {
|
|
30716
|
-
return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, this.props, {
|
|
30717
|
-
ref: this.mafsRef,
|
|
30718
|
-
gridStep: gridStep,
|
|
30719
|
-
snapStep: snapStep,
|
|
30720
|
-
box: box
|
|
30721
|
-
}));
|
|
30722
|
-
}
|
|
30723
30705
|
let instructions;
|
|
30724
30706
|
// isClickToAddPoints() only applies to points and polygons
|
|
30725
30707
|
if (this.isClickToAddPoints() && this.state.shouldShowInstructions) {
|
|
@@ -30765,6 +30747,60 @@ class InteractiveGraph extends React.Component {
|
|
|
30765
30747
|
isMobile: isMobile
|
|
30766
30748
|
}));
|
|
30767
30749
|
}
|
|
30750
|
+
}
|
|
30751
|
+
LegacyInteractiveGraph.defaultProps = {
|
|
30752
|
+
labels: ["x", "y"],
|
|
30753
|
+
range: [[-10, 10], [-10, 10]],
|
|
30754
|
+
step: [1, 1],
|
|
30755
|
+
backgroundImage: defaultBackgroundImage,
|
|
30756
|
+
markings: "graph",
|
|
30757
|
+
showTooltips: false,
|
|
30758
|
+
showProtractor: false,
|
|
30759
|
+
showRuler: false,
|
|
30760
|
+
rulerLabel: "",
|
|
30761
|
+
rulerTicks: 10,
|
|
30762
|
+
graph: {
|
|
30763
|
+
type: "linear"
|
|
30764
|
+
}
|
|
30765
|
+
};
|
|
30766
|
+
class InteractiveGraph extends React.Component {
|
|
30767
|
+
constructor(...args) {
|
|
30768
|
+
super(...args);
|
|
30769
|
+
this.legacyGraphRef = /*#__PURE__*/React.createRef();
|
|
30770
|
+
this.mafsRef = /*#__PURE__*/React.createRef();
|
|
30771
|
+
this.getUserInput = () => {
|
|
30772
|
+
if (this.mafsRef.current) {
|
|
30773
|
+
var _this$mafsRef$current, _this$mafsRef$current2;
|
|
30774
|
+
return (_this$mafsRef$current = (_this$mafsRef$current2 = this.mafsRef.current).getUserInput) == null ? void 0 : _this$mafsRef$current.call(_this$mafsRef$current2);
|
|
30775
|
+
}
|
|
30776
|
+
if (this.legacyGraphRef.current) {
|
|
30777
|
+
return this.legacyGraphRef.current.getUserInput();
|
|
30778
|
+
}
|
|
30779
|
+
throw new PerseusError("Cannot getUserInput from a graph that has never rendered", Errors.NotAllowed);
|
|
30780
|
+
};
|
|
30781
|
+
this.simpleValidate = rubric => {
|
|
30782
|
+
var _this$getUserInput;
|
|
30783
|
+
return InteractiveGraph.validate((_this$getUserInput = this.getUserInput) == null ? void 0 : _this$getUserInput.call(this), rubric, this);
|
|
30784
|
+
};
|
|
30785
|
+
}
|
|
30786
|
+
render() {
|
|
30787
|
+
var _this$props$apiOption;
|
|
30788
|
+
// Mafs shim
|
|
30789
|
+
if ((_this$props$apiOption = this.props.apiOptions) != null && (_this$props$apiOption = _this$props$apiOption.flags) != null && (_this$props$apiOption = _this$props$apiOption["mafs"]) != null && _this$props$apiOption[this.props.graph.type]) {
|
|
30790
|
+
const box = getInteractiveBoxFromSizeClass(this.props.containerSizeClass);
|
|
30791
|
+
const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, box[0]);
|
|
30792
|
+
const snapStep = this.props.snapStep || Util.snapStepFromGridStep(gridStep);
|
|
30793
|
+
return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, this.props, {
|
|
30794
|
+
ref: this.mafsRef,
|
|
30795
|
+
gridStep: gridStep,
|
|
30796
|
+
snapStep: snapStep,
|
|
30797
|
+
box: box
|
|
30798
|
+
}));
|
|
30799
|
+
}
|
|
30800
|
+
return /*#__PURE__*/React.createElement(LegacyInteractiveGraph, _extends({
|
|
30801
|
+
ref: this.legacyGraphRef
|
|
30802
|
+
}, this.props));
|
|
30803
|
+
}
|
|
30768
30804
|
static getQuadraticCoefficients(coords) {
|
|
30769
30805
|
const p1 = coords[0];
|
|
30770
30806
|
const p2 = coords[1];
|
|
@@ -41493,7 +41529,7 @@ const init = function init(options) {
|
|
|
41493
41529
|
|
|
41494
41530
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41495
41531
|
const libName = "@khanacademy/perseus";
|
|
41496
|
-
const libVersion = "20.
|
|
41532
|
+
const libVersion = "20.6.0";
|
|
41497
41533
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41498
41534
|
|
|
41499
41535
|
const apiVersion = {
|
|
@@ -42272,7 +42308,6 @@ class ServerItemRenderer extends React.Component {
|
|
|
42272
42308
|
const qScore = this.questionRenderer.scoreWidgets();
|
|
42273
42309
|
const qGuess = this.questionRenderer.getUserInputForWidgets();
|
|
42274
42310
|
const state = this.questionRenderer.getSerializedState();
|
|
42275
|
-
// @ts-expect-error - TS2322 - Type 'Partial<Record<string, KEScore>>' is not assignable to type '{ [key: string]: KEScore; }'. | TS2345 - Argument of type '{ [widgetId: string]: PerseusScore; }' is not assignable to parameter of type 'Partial<Record<string, { type: "invalid"; message?: string | null | undefined; suppressAlmostThere?: boolean | null | undefined; }>>'.
|
|
42276
42311
|
return mapObject(qScore, (score, id) => {
|
|
42277
42312
|
return Util.keScoreFromPerseusScore(score, qGuess[id], state);
|
|
42278
42313
|
});
|
|
@@ -44202,6 +44237,71 @@ function generateTestPerseusItem(customFields = {}) {
|
|
|
44202
44237
|
return _extends({}, genericPerseusItemData, customFields);
|
|
44203
44238
|
}
|
|
44204
44239
|
|
|
44240
|
+
/**
|
|
44241
|
+
* Some helpers for CEDAR logging. CEDAR convention dictates
|
|
44242
|
+
* that enum values should be upper case. Ex: for the
|
|
44243
|
+
* PerseusWidgetUsedInProblemAttempt CEDAR event, we needed
|
|
44244
|
+
* to: get the type and convert that to an enum value.
|
|
44245
|
+
*/
|
|
44246
|
+
|
|
44247
|
+
const widgetNameToEnum = {
|
|
44248
|
+
categorizer: "CATEGORIZER",
|
|
44249
|
+
"cs-program": "CS_PROGRAM",
|
|
44250
|
+
definition: "DEFINITION",
|
|
44251
|
+
"deprecated-standin": "DEPRECATED_STANDIN",
|
|
44252
|
+
dropdown: "DROPDOWN",
|
|
44253
|
+
explanation: "EXPLANATION",
|
|
44254
|
+
expression: "EXPRESSION",
|
|
44255
|
+
"graded-group-set": "GRADED_GROUP_SET",
|
|
44256
|
+
"graded-group": "GRADED_GROUP",
|
|
44257
|
+
grapher: "GRAPHER",
|
|
44258
|
+
group: "GROUP",
|
|
44259
|
+
iframe: "IFRAME",
|
|
44260
|
+
image: "IMAGE",
|
|
44261
|
+
"input-number": "INPUT_NUMBER",
|
|
44262
|
+
interaction: "INTERACTIVE",
|
|
44263
|
+
"interactive-graph": "INTERACTIVE_GRAPH",
|
|
44264
|
+
"label-image": "LABEL_IMAGE",
|
|
44265
|
+
"lights-puzzle": "LIGHTS_PUZZLE",
|
|
44266
|
+
matcher: "MATCHER",
|
|
44267
|
+
matrix: "MATRIX",
|
|
44268
|
+
measurer: "MEASURER",
|
|
44269
|
+
"molecule-renderer": "MOLECULE",
|
|
44270
|
+
"number-line": "NUMBER_LINE",
|
|
44271
|
+
"numeric-input": "NUMERIC_INPUT",
|
|
44272
|
+
orderer: "ORDERER",
|
|
44273
|
+
passage: "PASSAGE",
|
|
44274
|
+
"passage-ref": "PASSAGE_REF",
|
|
44275
|
+
"passage-ref-target": "PASSAGE_REF_TARGET",
|
|
44276
|
+
plotter: "PLOTTER",
|
|
44277
|
+
"python-program": "PYTHON_PROGRAM",
|
|
44278
|
+
"reaction-diagram": "REACTION_DIAGRAM",
|
|
44279
|
+
radio: "RADIO",
|
|
44280
|
+
sequence: "SEQUENCE",
|
|
44281
|
+
simulator: "SIMULATOR",
|
|
44282
|
+
sorter: "SORTER",
|
|
44283
|
+
table: "TABLE",
|
|
44284
|
+
"unit-input": "UNIT",
|
|
44285
|
+
video: "VIDEO"
|
|
44286
|
+
};
|
|
44287
|
+
function convertWidgetNameToEnum(name) {
|
|
44288
|
+
const widgetEnum = widgetNameToEnum[name];
|
|
44289
|
+
if (!widgetEnum) {
|
|
44290
|
+
throw new Error(`Unknown widget name: ${name}`);
|
|
44291
|
+
}
|
|
44292
|
+
return widgetEnum;
|
|
44293
|
+
}
|
|
44294
|
+
function getWidgetTypeFromWidgetId(widgetId) {
|
|
44295
|
+
const [widgetType, widgetNumber] = widgetId.split(" ");
|
|
44296
|
+
if (!widgetNumber) {
|
|
44297
|
+
throw new Error(`Incorrect format for widget ID: ${widgetId}`);
|
|
44298
|
+
}
|
|
44299
|
+
if (!widgetNameToEnum[widgetType]) {
|
|
44300
|
+
throw new Error(`Unknown widget type (${widgetType}) in widget ID: ${widgetId}`);
|
|
44301
|
+
}
|
|
44302
|
+
return widgetType;
|
|
44303
|
+
}
|
|
44304
|
+
|
|
44205
44305
|
const EditorJsonify = {
|
|
44206
44306
|
serialize: function () {
|
|
44207
44307
|
// Omit props that get passed to all widgets
|
|
@@ -44210,5 +44310,5 @@ const EditorJsonify = {
|
|
|
44210
44310
|
}
|
|
44211
44311
|
};
|
|
44212
44312
|
|
|
44213
|
-
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, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, generateTestPerseusItem, genericPerseusItemData, getAnswersFromWidgets, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
|
|
44313
|
+
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, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, convertWidgetNameToEnum, displaySigFigs, generateTestPerseusItem, genericPerseusItemData, getAnswersFromWidgets, getWidgetTypeFromWidgetId, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
|
|
44214
44314
|
//# sourceMappingURL=index.js.map
|