@khanacademy/perseus-editor 14.6.4 → 14.6.5
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 +70 -31
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +58 -12
- package/dist/index.js.map +1 -1
- package/dist/widgets/interactive-graph-editor/interactive-graph-editor.d.ts +24 -2
- package/dist/widgets/interactive-graph-editor/start-coords/start-coords-angle.d.ts +1 -0
- package/dist/widgets/interactive-graph-editor/start-coords/start-coords-settings.d.ts +1 -0
- package/dist/widgets/interactive-graph-editor/start-coords/util.d.ts +1 -1
- package/package.json +7 -7
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addLibraryVersionToPerseusDebug, PerseusError, Errors } from '@khanacademy/perseus-core';
|
|
2
|
-
import { constants, components, Widgets, icons, WIDGET_PROP_DENYLIST, Util, Log, PerseusMarkdown, preprocessTex, ApiOptions, buildMapper, itemToTree, buildEmptyItemTreeForShape, shapes, ItemExtras, itemDataVersion, ClassNames, MultiItems, traverse, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, PerseusExpressionAnswerFormConsidered, Expression, interactiveSizes, KhanMath, GrapherWidget, GrapherUtil, SizingUtils, PerseusI18nContext, KhanColors, lockedFigureColors, lockedFigureFillStyles, getAngleCoords, getPolygonCoords, getPointCoords, getQuadraticCoords, getSinusoidCoords, getCircleCoords, getLinearSystemCoords, getSegmentCoords, getLineCoords, InteractiveGraphWidget, globalStyles, globalConstants, MatrixWidget, makeSafeUrl, PlotterWidget, plotterPlotTypes, BaseRadio, TableWidget, widgets } from '@khanacademy/perseus';
|
|
2
|
+
import { constants, components, Widgets, icons, WIDGET_PROP_DENYLIST, Util, Log, PerseusMarkdown, preprocessTex, ApiOptions, buildMapper, itemToTree, buildEmptyItemTreeForShape, shapes, ItemExtras, itemDataVersion, ClassNames, MultiItems, traverse, Categorizer as Categorizer$1, Changeable, EditorJsonify, Dependencies, PerseusExpressionAnswerFormConsidered, Expression, interactiveSizes, KhanMath, GrapherWidget, GrapherUtil, SizingUtils, PerseusI18nContext, KhanColors, lockedFigureColors, lockedFigureFillStyles, getAngleCoords, getPolygonCoords, getPointCoords, getQuadraticCoords, getSinusoidCoords, getCircleCoords, getLinearSystemCoords, getSegmentCoords, getLineCoords, getClockwiseAngle, InteractiveGraphWidget, globalStyles, globalConstants, 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
5
|
import { useRef, useEffect, useState, useId } from 'react';
|
|
@@ -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 = "14.6.
|
|
49
|
+
const libVersion = "14.6.5";
|
|
50
50
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
51
51
|
|
|
52
52
|
function _extends() {
|
|
@@ -32948,15 +32948,11 @@ const getQuadraticEquation = startCoords => {
|
|
|
32948
32948
|
const c = (p2[0] * p3[0] * (p2[0] - p3[0]) * p1[1] + p3[0] * p1[0] * (p3[0] - p1[0]) * p2[1] + p1[0] * p2[0] * (p1[0] - p2[0]) * p3[1]) / denom;
|
|
32949
32949
|
return "y = " + a.toFixed(3) + "x^2 + " + b.toFixed(3) + "x + " + c.toFixed(3);
|
|
32950
32950
|
};
|
|
32951
|
-
const
|
|
32952
|
-
const
|
|
32953
|
-
|
|
32954
|
-
|
|
32955
|
-
|
|
32956
|
-
const getAngleEquation = startCoords => {
|
|
32957
|
-
const [point1, vertex, point2] = startCoords;
|
|
32958
|
-
const angle = findAngle(point2, vertex) - findAngle(point1, vertex);
|
|
32959
|
-
const roundedAngle = angle.toFixed(0);
|
|
32951
|
+
const getAngleEquation = (startCoords, allowReflexAngles = false) => {
|
|
32952
|
+
const vertex = startCoords[1];
|
|
32953
|
+
|
|
32954
|
+
// Get the angle in degrees and round it to the nearest whole number
|
|
32955
|
+
const roundedAngle = getClockwiseAngle(startCoords, allowReflexAngles).toFixed(0);
|
|
32960
32956
|
return `${roundedAngle}\u00B0 angle at (${vertex[0]}, ${vertex[1]})`;
|
|
32961
32957
|
};
|
|
32962
32958
|
const shouldShowStartCoordsUI = (graph, isStatic) => {
|
|
@@ -32990,13 +32986,14 @@ const shouldShowStartCoordsUI = (graph, isStatic) => {
|
|
|
32990
32986
|
const StartCoordsAngle = props => {
|
|
32991
32987
|
const {
|
|
32992
32988
|
startCoords,
|
|
32989
|
+
allowReflexAngles,
|
|
32993
32990
|
onChange
|
|
32994
32991
|
} = props;
|
|
32995
32992
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
32996
32993
|
style: styles$h.equationSection
|
|
32997
32994
|
}, /*#__PURE__*/React.createElement(LabelMedium, null, "Starting equation:"), /*#__PURE__*/React.createElement(BodyMonospace, {
|
|
32998
32995
|
style: styles$h.equationBody
|
|
32999
|
-
}, getAngleEquation(startCoords))), /*#__PURE__*/React.createElement(View, {
|
|
32996
|
+
}, getAngleEquation(startCoords, allowReflexAngles))), /*#__PURE__*/React.createElement(View, {
|
|
33000
32997
|
style: styles$h.tile
|
|
33001
32998
|
}, /*#__PURE__*/React.createElement(LabelLarge, null, "Point 1:"), /*#__PURE__*/React.createElement(Strut, {
|
|
33002
32999
|
size: spacing.small_12
|
|
@@ -33338,6 +33335,7 @@ const StartCoordsSettingsInner = props => {
|
|
|
33338
33335
|
type,
|
|
33339
33336
|
range,
|
|
33340
33337
|
step,
|
|
33338
|
+
allowReflexAngles,
|
|
33341
33339
|
onChange
|
|
33342
33340
|
} = props;
|
|
33343
33341
|
switch (type) {
|
|
@@ -33401,6 +33399,7 @@ const StartCoordsSettingsInner = props => {
|
|
|
33401
33399
|
});
|
|
33402
33400
|
return /*#__PURE__*/React.createElement(StartCoordsAngle, {
|
|
33403
33401
|
startCoords: angleCoords,
|
|
33402
|
+
allowReflexAngles: allowReflexAngles,
|
|
33404
33403
|
onChange: onChange
|
|
33405
33404
|
});
|
|
33406
33405
|
default:
|
|
@@ -33515,7 +33514,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33515
33514
|
return json;
|
|
33516
33515
|
}
|
|
33517
33516
|
render() {
|
|
33518
|
-
var _this$props$graph$typ, _this$props$graph2, _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$
|
|
33517
|
+
var _this$props$graph$typ, _this$props$graph2, _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$graph11, _this$props$apiOption3, _this$props$apiOption4;
|
|
33519
33518
|
let graph;
|
|
33520
33519
|
let equationString;
|
|
33521
33520
|
const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, interactiveSizes.defaultBoxSize);
|
|
@@ -33619,15 +33618,55 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33619
33618
|
}
|
|
33620
33619
|
});
|
|
33621
33620
|
}
|
|
33622
|
-
})), ((_this$props$correct3 = this.props.correct) == null ? void 0 : _this$props$correct3.type) === "
|
|
33621
|
+
})), ((_this$props$correct3 = this.props.correct) == null ? void 0 : _this$props$correct3.type) === "angle" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
33622
|
+
style: styles$a.row
|
|
33623
|
+
}, /*#__PURE__*/React.createElement(Checkbox$1, {
|
|
33624
|
+
label: /*#__PURE__*/React.createElement(LabelSmall, null, "Show angle measures"),
|
|
33625
|
+
checked:
|
|
33626
|
+
// Don't show indeterminate checkbox state
|
|
33627
|
+
!!((_this$props$correct4 = this.props.correct) != null && _this$props$correct4.showAngles),
|
|
33628
|
+
onChange: newValue => {
|
|
33629
|
+
var _this$props$graph3;
|
|
33630
|
+
if (((_this$props$graph3 = this.props.graph) == null ? void 0 : _this$props$graph3.type) === "angle") {
|
|
33631
|
+
invariant(this.props.correct.type === "angle", `Expected graph type to be angle, but got ${this.props.correct.type}`);
|
|
33632
|
+
this.props.onChange({
|
|
33633
|
+
correct: _extends({}, this.props.correct, {
|
|
33634
|
+
showAngles: newValue
|
|
33635
|
+
}),
|
|
33636
|
+
graph: _extends({}, this.props.graph, {
|
|
33637
|
+
showAngles: newValue
|
|
33638
|
+
})
|
|
33639
|
+
});
|
|
33640
|
+
}
|
|
33641
|
+
}
|
|
33642
|
+
}), /*#__PURE__*/React.createElement(InfoTip$b, null, /*#__PURE__*/React.createElement("p", null, "Displays the interior angle measures."))), /*#__PURE__*/React.createElement(View, {
|
|
33643
|
+
style: styles$a.row
|
|
33644
|
+
}, /*#__PURE__*/React.createElement(Checkbox$1, {
|
|
33645
|
+
label: /*#__PURE__*/React.createElement(LabelSmall, null, "Allow reflex angles"),
|
|
33646
|
+
checked:
|
|
33647
|
+
// Don't show indeterminate checkbox state
|
|
33648
|
+
!!((_this$props$correct5 = this.props.correct) != null && _this$props$correct5.allowReflexAngles),
|
|
33649
|
+
onChange: newValue => {
|
|
33650
|
+
var _this$props$graph4, _this$props$graph5;
|
|
33651
|
+
invariant(this.props.correct.type === "angle", `Expected graph type to be angle, but got ${this.props.correct.type}`);
|
|
33652
|
+
invariant(((_this$props$graph4 = this.props.graph) == null ? void 0 : _this$props$graph4.type) === "angle", `Expected graph type to be angle, but got ${(_this$props$graph5 = this.props.graph) == null ? void 0 : _this$props$graph5.type}`);
|
|
33653
|
+
const update = {
|
|
33654
|
+
allowReflexAngles: newValue
|
|
33655
|
+
};
|
|
33656
|
+
this.props.onChange({
|
|
33657
|
+
correct: _extends({}, this.props.correct, update),
|
|
33658
|
+
graph: _extends({}, this.props.graph, update)
|
|
33659
|
+
});
|
|
33660
|
+
}
|
|
33661
|
+
}), /*#__PURE__*/React.createElement(InfoTip$b, null, /*#__PURE__*/React.createElement("p", null, "Allow students to be able to create reflex angles.")))), ((_this$props$correct6 = this.props.correct) == null ? void 0 : _this$props$correct6.type) === "polygon" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LabeledRow, {
|
|
33623
33662
|
label: "Number of sides:"
|
|
33624
33663
|
}, /*#__PURE__*/React.createElement(SingleSelect, {
|
|
33625
33664
|
key: "polygon-select",
|
|
33626
|
-
selectedValue: (_this$props$
|
|
33665
|
+
selectedValue: (_this$props$correct7 = this.props.correct) != null && _this$props$correct7.numSides ? `${this.props.correct.numSides}` : "3",
|
|
33627
33666
|
placeholder: "",
|
|
33628
33667
|
onChange: newValue => {
|
|
33629
|
-
var _this$props$
|
|
33630
|
-
invariant(((_this$props$
|
|
33668
|
+
var _this$props$graph6;
|
|
33669
|
+
invariant(((_this$props$graph6 = this.props.graph) == null ? void 0 : _this$props$graph6.type) === "polygon");
|
|
33631
33670
|
const updates = {
|
|
33632
33671
|
numSides: parsePointCount(newValue),
|
|
33633
33672
|
coords: null,
|
|
@@ -33649,14 +33688,14 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33649
33688
|
})])), /*#__PURE__*/React.createElement(LabeledRow, {
|
|
33650
33689
|
label: "Snap to:"
|
|
33651
33690
|
}, /*#__PURE__*/React.createElement(SingleSelect, {
|
|
33652
|
-
selectedValue: ((_this$props$
|
|
33691
|
+
selectedValue: ((_this$props$correct8 = this.props.correct) == null ? void 0 : _this$props$correct8.snapTo) || "grid"
|
|
33653
33692
|
// Never uses placeholder, always has value
|
|
33654
33693
|
,
|
|
33655
33694
|
placeholder: "",
|
|
33656
33695
|
onChange: newValue => {
|
|
33657
|
-
var _this$props$
|
|
33696
|
+
var _this$props$graph7, _this$props$graph8;
|
|
33658
33697
|
invariant(this.props.correct.type === "polygon", `Expected correct answer type to be polygon, but got ${this.props.correct.type}`);
|
|
33659
|
-
invariant(((_this$props$
|
|
33698
|
+
invariant(((_this$props$graph7 = this.props.graph) == null ? void 0 : _this$props$graph7.type) === "polygon", `Expected graph type to be polygon, but got ${(_this$props$graph8 = this.props.graph) == null ? void 0 : _this$props$graph8.type}`);
|
|
33660
33699
|
const updates = {
|
|
33661
33700
|
snapTo: newValue,
|
|
33662
33701
|
coords: null
|
|
@@ -33670,10 +33709,10 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33670
33709
|
}, /*#__PURE__*/React.createElement(OptionItem, {
|
|
33671
33710
|
value: "grid",
|
|
33672
33711
|
label: "grid"
|
|
33673
|
-
}), ((_this$props$
|
|
33712
|
+
}), ((_this$props$correct9 = this.props.correct) == null ? void 0 : _this$props$correct9.numSides) !== "unlimited" && /*#__PURE__*/React.createElement(OptionItem, {
|
|
33674
33713
|
value: "angles",
|
|
33675
33714
|
label: "interior angles"
|
|
33676
|
-
}), ((_this$props$
|
|
33715
|
+
}), ((_this$props$correct10 = this.props.correct) == null ? void 0 : _this$props$correct10.numSides) !== "unlimited" && /*#__PURE__*/React.createElement(OptionItem, {
|
|
33677
33716
|
value: "sides",
|
|
33678
33717
|
label: "side measures"
|
|
33679
33718
|
})), /*#__PURE__*/React.createElement(InfoTip$b, null, /*#__PURE__*/React.createElement("p", null, "These options affect the movement of the vertex points. The grid option will guide the points to the nearest half step along the grid."), /*#__PURE__*/React.createElement("p", null, "The interior angle and side measure options guide the points to the nearest whole angle or side measure respectively."))), /*#__PURE__*/React.createElement(View, {
|
|
@@ -33682,10 +33721,10 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33682
33721
|
label: /*#__PURE__*/React.createElement(LabelSmall, null, "Show angle measures"),
|
|
33683
33722
|
checked:
|
|
33684
33723
|
// Don't show indeterminate checkbox state
|
|
33685
|
-
!!((_this$props$
|
|
33724
|
+
!!((_this$props$correct11 = this.props.correct) != null && _this$props$correct11.showAngles),
|
|
33686
33725
|
onChange: () => {
|
|
33687
|
-
var _this$props$
|
|
33688
|
-
if (((_this$props$
|
|
33726
|
+
var _this$props$graph9;
|
|
33727
|
+
if (((_this$props$graph9 = this.props.graph) == null ? void 0 : _this$props$graph9.type) === "polygon") {
|
|
33689
33728
|
invariant(this.props.correct.type === "polygon", `Expected graph type to be polygon, but got ${this.props.correct.type}`);
|
|
33690
33729
|
this.props.onChange({
|
|
33691
33730
|
correct: _extends({}, this.props.correct, {
|
|
@@ -33703,10 +33742,10 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33703
33742
|
label: /*#__PURE__*/React.createElement(LabelSmall, null, "Show side measures"),
|
|
33704
33743
|
checked:
|
|
33705
33744
|
// Don't show indeterminate checkbox state
|
|
33706
|
-
!!((_this$props$
|
|
33745
|
+
!!((_this$props$correct12 = this.props.correct) != null && _this$props$correct12.showSides),
|
|
33707
33746
|
onChange: () => {
|
|
33708
|
-
var _this$props$
|
|
33709
|
-
if (((_this$props$
|
|
33747
|
+
var _this$props$graph10;
|
|
33748
|
+
if (((_this$props$graph10 = this.props.graph) == null ? void 0 : _this$props$graph10.type) === "polygon" && this.props.correct.type === "polygon") {
|
|
33710
33749
|
this.props.onChange({
|
|
33711
33750
|
correct: _extends({}, this.props.correct, {
|
|
33712
33751
|
showSides: !this.props.correct.showSides
|
|
@@ -33717,10 +33756,10 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33717
33756
|
});
|
|
33718
33757
|
}
|
|
33719
33758
|
}
|
|
33720
|
-
}), /*#__PURE__*/React.createElement(InfoTip$b, null, /*#__PURE__*/React.createElement("p", null, "Displays the side lengths.")))), ((_this$props$
|
|
33759
|
+
}), /*#__PURE__*/React.createElement(InfoTip$b, null, /*#__PURE__*/React.createElement("p", null, "Displays the side lengths.")))), ((_this$props$correct13 = this.props.correct) == null ? void 0 : _this$props$correct13.type) === "segment" && /*#__PURE__*/React.createElement(LabeledRow, {
|
|
33721
33760
|
label: "Number of segments:"
|
|
33722
33761
|
}, /*#__PURE__*/React.createElement(SegmentCountSelector, {
|
|
33723
|
-
numSegments: (_this$props$
|
|
33762
|
+
numSegments: (_this$props$correct14 = this.props.correct) == null ? void 0 : _this$props$correct14.numSegments,
|
|
33724
33763
|
onChange: sides => {
|
|
33725
33764
|
this.props.onChange({
|
|
33726
33765
|
correct: {
|
|
@@ -33734,7 +33773,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
33734
33773
|
}
|
|
33735
33774
|
});
|
|
33736
33775
|
}
|
|
33737
|
-
})), ((_this$props$
|
|
33776
|
+
})), ((_this$props$graph11 = this.props.graph) == null ? void 0 : _this$props$graph11.type) && shouldShowStartCoordsUI(this.props.graph, this.props.static) && /*#__PURE__*/React.createElement(StartCoordsSettings, _extends({}, this.props.graph, {
|
|
33738
33777
|
range: this.props.range,
|
|
33739
33778
|
step: this.props.step,
|
|
33740
33779
|
onChange: this.changeStartCoords
|