@khanacademy/perseus-editor 17.0.0 → 17.0.1
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 +27 -31
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +9 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/es/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import { addLibraryVersionToPerseusDebug, PerseusError, Errors } from '@khanacad
|
|
|
2
2
|
import { components, Widgets, iconChevronDown, iconTrash, WIDGET_PROP_DENYLIST, Util, Log, PerseusMarkdown, preprocessTex, ApiOptions, ItemExtras, itemDataVersion, ClassNames, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, PerseusExpressionAnswerFormConsidered, Expression, interactiveSizes, KhanMath, GrapherWidget, GrapherUtil, containerSizeClass, getInteractiveBoxFromSizeClass, PerseusI18nContext, KhanColors, lockedFigureColors, lockedFigureFillStyles, mathOnlyParser, getAngleCoords, getPolygonCoords, getPointCoords, getQuadraticCoords, getSinusoidCoords, getCircleCoords, getLinearSystemCoords, getSegmentCoords, getLineCoords, getClockwiseAngle, InteractiveGraphWidget, bodyXsmallBold, MatrixWidget, makeSafeUrl, PlotterWidget, plotterPlotTypes, BaseRadio, TableWidget, widgets } from '@khanacademy/perseus';
|
|
3
3
|
export { widgets } from '@khanacademy/perseus';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { useRef, useEffect, useState
|
|
5
|
+
import { useId, useRef, useEffect, useState } from 'react';
|
|
6
6
|
import _ from 'underscore';
|
|
7
7
|
import createReactClass from 'create-react-class';
|
|
8
8
|
import Clickable from '@khanacademy/wonder-blocks-clickable';
|
|
9
9
|
import { color, spacing, font } from '@khanacademy/wonder-blocks-tokens';
|
|
10
10
|
import { StyleSheet, css } from 'aphrodite';
|
|
11
11
|
import $ from 'jquery';
|
|
12
|
-
import { View
|
|
12
|
+
import { View } from '@khanacademy/wonder-blocks-core';
|
|
13
13
|
import Switch from '@khanacademy/wonder-blocks-switch';
|
|
14
14
|
import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
|
|
15
15
|
import caretRight from '@phosphor-icons/core/bold/caret-right-bold.svg';
|
|
@@ -46,7 +46,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
|
|
|
46
46
|
|
|
47
47
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
48
48
|
const libName = "@khanacademy/perseus-editor";
|
|
49
|
-
const libVersion = "17.0.
|
|
49
|
+
const libVersion = "17.0.1";
|
|
50
50
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
51
51
|
|
|
52
52
|
function _extends() {
|
|
@@ -20871,10 +20871,7 @@ function LabeledSwitch$1(props) {
|
|
|
20871
20871
|
label
|
|
20872
20872
|
} = props,
|
|
20873
20873
|
switchProps = _objectWithoutPropertiesLoose(props, _excluded$3);
|
|
20874
|
-
|
|
20875
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
20876
|
-
const ids = useUniqueIdWithMock();
|
|
20877
|
-
const id = ids.get("switch");
|
|
20874
|
+
const id = useId();
|
|
20878
20875
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("label", {
|
|
20879
20876
|
htmlFor: id
|
|
20880
20877
|
}, label), /*#__PURE__*/React.createElement(Strut, {
|
|
@@ -94945,11 +94942,7 @@ const LabeledSwitch = props => {
|
|
|
94945
94942
|
style,
|
|
94946
94943
|
onChange
|
|
94947
94944
|
} = props;
|
|
94948
|
-
|
|
94949
|
-
// TODO(WB-1812, somewhatabstract): Migrate to Id or useId
|
|
94950
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
94951
|
-
const ids = useUniqueIdWithMock();
|
|
94952
|
-
const switchId = ids.get("switch");
|
|
94945
|
+
const switchId = useId();
|
|
94953
94946
|
return /*#__PURE__*/React.createElement(View, {
|
|
94954
94947
|
style: [styles$o.row, style]
|
|
94955
94948
|
}, /*#__PURE__*/React.createElement(Switch, {
|
|
@@ -96027,10 +96020,7 @@ const LockedFiguresSection = props => {
|
|
|
96027
96020
|
const collapsedStateArray = Array(((_props$figures = props.figures) != null ? _props$figures : []).length).fill(false);
|
|
96028
96021
|
const [expandedStates, setExpandedStates] = React.useState(collapsedStateArray);
|
|
96029
96022
|
const [isExpanded, setIsExpanded] = React.useState(true);
|
|
96030
|
-
|
|
96031
|
-
// TODO(WB-1812, somewhatabstract): Migrate to Id or useId
|
|
96032
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
96033
|
-
const uniqueId = useUniqueIdWithMock().get("locked-figures-section");
|
|
96023
|
+
const uniqueId = useId();
|
|
96034
96024
|
const {
|
|
96035
96025
|
figures,
|
|
96036
96026
|
onChange
|
|
@@ -96767,6 +96757,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96767
96757
|
});
|
|
96768
96758
|
};
|
|
96769
96759
|
this.getSaveWarnings = () => {
|
|
96760
|
+
var _this$props$graph2;
|
|
96770
96761
|
const issues = [];
|
|
96771
96762
|
|
|
96772
96763
|
// A locked line on the graph cannot have length 0.
|
|
@@ -96776,6 +96767,11 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96776
96767
|
issues.push("The line cannot have length 0.");
|
|
96777
96768
|
}
|
|
96778
96769
|
}
|
|
96770
|
+
|
|
96771
|
+
// Do not save a unlimited polygon that is open (coords is null).
|
|
96772
|
+
if (((_this$props$graph2 = this.props.graph) == null ? void 0 : _this$props$graph2.type) === "polygon" && this.props.graph.numSides === "unlimited" && this.props.graph.coords === null) {
|
|
96773
|
+
issues.push("Polygon must be closed.");
|
|
96774
|
+
}
|
|
96779
96775
|
return issues;
|
|
96780
96776
|
};
|
|
96781
96777
|
}
|
|
@@ -96809,7 +96805,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96809
96805
|
return json;
|
|
96810
96806
|
}
|
|
96811
96807
|
render() {
|
|
96812
|
-
var _this$props$graph$typ, _this$props$
|
|
96808
|
+
var _this$props$graph$typ, _this$props$graph3, _this$props$apiOption, _this$props$apiOption2, _this$props$fullGraph, _this$props$fullGraph2, _this$props$correct, _this$props$correct2, _this$props$correct3, _this$props$correct4, _this$props$correct5, _this$props$correct6, _this$props$correct7, _this$props$correct8, _this$props$correct9, _this$props$correct10, _this$props$correct11, _this$props$correct12, _this$props$correct13, _this$props$correct14, _this$props$graph12, _this$props$apiOption3, _this$props$apiOption4;
|
|
96813
96809
|
let graph;
|
|
96814
96810
|
let equationString;
|
|
96815
96811
|
const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, interactiveSizes.defaultBoxSize);
|
|
@@ -96879,7 +96875,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96879
96875
|
return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(LabeledRow, {
|
|
96880
96876
|
label: "Answer type:"
|
|
96881
96877
|
}, /*#__PURE__*/React.createElement(GraphTypeSelector, {
|
|
96882
|
-
graphType: (_this$props$graph$typ = (_this$props$
|
|
96878
|
+
graphType: (_this$props$graph$typ = (_this$props$graph3 = this.props.graph) == null ? void 0 : _this$props$graph3.type) != null ? _this$props$graph$typ : InteractiveGraph.defaultProps.graph.type
|
|
96883
96879
|
// TODO(LEMS-2656): remove TS suppression
|
|
96884
96880
|
,
|
|
96885
96881
|
onChange: type => {
|
|
@@ -96923,8 +96919,8 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96923
96919
|
// Don't show indeterminate checkbox state
|
|
96924
96920
|
!!((_this$props$correct4 = this.props.correct) != null && _this$props$correct4.showAngles),
|
|
96925
96921
|
onChange: newValue => {
|
|
96926
|
-
var _this$props$
|
|
96927
|
-
if (((_this$props$
|
|
96922
|
+
var _this$props$graph4;
|
|
96923
|
+
if (((_this$props$graph4 = this.props.graph) == null ? void 0 : _this$props$graph4.type) === "angle") {
|
|
96928
96924
|
invariant(this.props.correct.type === "angle", `Expected graph type to be angle, but got ${this.props.correct.type}`);
|
|
96929
96925
|
this.props.onChange({
|
|
96930
96926
|
correct: _extends({}, this.props.correct, {
|
|
@@ -96944,9 +96940,9 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96944
96940
|
// Don't show indeterminate checkbox state
|
|
96945
96941
|
!!((_this$props$correct5 = this.props.correct) != null && _this$props$correct5.allowReflexAngles),
|
|
96946
96942
|
onChange: newValue => {
|
|
96947
|
-
var _this$props$
|
|
96943
|
+
var _this$props$graph5, _this$props$graph6;
|
|
96948
96944
|
invariant(this.props.correct.type === "angle", `Expected graph type to be angle, but got ${this.props.correct.type}`);
|
|
96949
|
-
invariant(((_this$props$
|
|
96945
|
+
invariant(((_this$props$graph5 = this.props.graph) == null ? void 0 : _this$props$graph5.type) === "angle", `Expected graph type to be angle, but got ${(_this$props$graph6 = this.props.graph) == null ? void 0 : _this$props$graph6.type}`);
|
|
96950
96946
|
const update = {
|
|
96951
96947
|
allowReflexAngles: newValue
|
|
96952
96948
|
};
|
|
@@ -96962,8 +96958,8 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96962
96958
|
selectedValue: (_this$props$correct7 = this.props.correct) != null && _this$props$correct7.numSides ? `${this.props.correct.numSides}` : "3",
|
|
96963
96959
|
placeholder: "",
|
|
96964
96960
|
onChange: newValue => {
|
|
96965
|
-
var _this$props$
|
|
96966
|
-
invariant(((_this$props$
|
|
96961
|
+
var _this$props$graph7;
|
|
96962
|
+
invariant(((_this$props$graph7 = this.props.graph) == null ? void 0 : _this$props$graph7.type) === "polygon");
|
|
96967
96963
|
const updates = {
|
|
96968
96964
|
numSides: parsePointCount(newValue),
|
|
96969
96965
|
coords: null,
|
|
@@ -96990,9 +96986,9 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
96990
96986
|
,
|
|
96991
96987
|
placeholder: "",
|
|
96992
96988
|
onChange: newValue => {
|
|
96993
|
-
var _this$props$
|
|
96989
|
+
var _this$props$graph8, _this$props$graph9;
|
|
96994
96990
|
invariant(this.props.correct.type === "polygon", `Expected correct answer type to be polygon, but got ${this.props.correct.type}`);
|
|
96995
|
-
invariant(((_this$props$
|
|
96991
|
+
invariant(((_this$props$graph8 = this.props.graph) == null ? void 0 : _this$props$graph8.type) === "polygon", `Expected graph type to be polygon, but got ${(_this$props$graph9 = this.props.graph) == null ? void 0 : _this$props$graph9.type}`);
|
|
96996
96992
|
const updates = {
|
|
96997
96993
|
snapTo: newValue,
|
|
96998
96994
|
coords: null
|
|
@@ -97020,8 +97016,8 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
97020
97016
|
// Don't show indeterminate checkbox state
|
|
97021
97017
|
!!((_this$props$correct11 = this.props.correct) != null && _this$props$correct11.showAngles),
|
|
97022
97018
|
onChange: () => {
|
|
97023
|
-
var _this$props$
|
|
97024
|
-
if (((_this$props$
|
|
97019
|
+
var _this$props$graph10;
|
|
97020
|
+
if (((_this$props$graph10 = this.props.graph) == null ? void 0 : _this$props$graph10.type) === "polygon") {
|
|
97025
97021
|
invariant(this.props.correct.type === "polygon", `Expected graph type to be polygon, but got ${this.props.correct.type}`);
|
|
97026
97022
|
this.props.onChange({
|
|
97027
97023
|
correct: _extends({}, this.props.correct, {
|
|
@@ -97041,8 +97037,8 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
97041
97037
|
// Don't show indeterminate checkbox state
|
|
97042
97038
|
!!((_this$props$correct12 = this.props.correct) != null && _this$props$correct12.showSides),
|
|
97043
97039
|
onChange: () => {
|
|
97044
|
-
var _this$props$
|
|
97045
|
-
if (((_this$props$
|
|
97040
|
+
var _this$props$graph11;
|
|
97041
|
+
if (((_this$props$graph11 = this.props.graph) == null ? void 0 : _this$props$graph11.type) === "polygon" && this.props.correct.type === "polygon") {
|
|
97046
97042
|
this.props.onChange({
|
|
97047
97043
|
correct: _extends({}, this.props.correct, {
|
|
97048
97044
|
showSides: !this.props.correct.showSides
|
|
@@ -97070,7 +97066,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
97070
97066
|
}
|
|
97071
97067
|
});
|
|
97072
97068
|
}
|
|
97073
|
-
})), ((_this$props$
|
|
97069
|
+
})), ((_this$props$graph12 = this.props.graph) == null ? void 0 : _this$props$graph12.type) && shouldShowStartCoordsUI(this.props.graph, this.props.static) && /*#__PURE__*/React.createElement(StartCoordsSettings, _extends({}, this.props.graph, {
|
|
97074
97070
|
range: this.props.range,
|
|
97075
97071
|
step: this.props.step,
|
|
97076
97072
|
onChange: this.changeStartCoords
|