@khanacademy/perseus-editor 6.5.1 → 6.7.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/locked-figure-settings.d.ts +1 -0
- package/dist/components/locked-figures-section.d.ts +1 -0
- package/dist/es/index.js +49 -16
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +46 -14
- package/dist/index.js.map +1 -1
- package/dist/widgets/categorizer-editor.d.ts +0 -2
- package/dist/widgets/graded-group-editor.d.ts +0 -2
- package/dist/widgets/graded-group-set-editor.d.ts +0 -2
- package/dist/widgets/group-editor.d.ts +0 -2
- package/dist/widgets/interactive-graph-editor.d.ts +352 -585
- package/dist/widgets/radio/editor.d.ts +0 -2
- package/package.json +2 -2
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import type { Props as LockedLineProps } from "./locked-line-settings";
|
|
9
9
|
import type { Props as LockedPointProps } from "./locked-point-settings";
|
|
10
10
|
export type AccordionProps = {
|
|
11
|
+
showM2Features?: boolean;
|
|
11
12
|
/**
|
|
12
13
|
* Whether this accordion is expanded.
|
|
13
14
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Props as InteractiveGraphEditorProps } from "../widgets/interactive-graph-editor";
|
|
3
3
|
import type { LockedFigure } from "@khanacademy/perseus";
|
|
4
4
|
type Props = {
|
|
5
|
+
showM2Features?: boolean;
|
|
5
6
|
figures?: Array<LockedFigure>;
|
|
6
7
|
onChange: (props: Partial<InteractiveGraphEditorProps>) => void;
|
|
7
8
|
};
|
package/dist/es/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { PhosphorIcon } from '@khanacademy/wonder-blocks-icon';
|
|
|
14
14
|
import caretRight from '@phosphor-icons/core/bold/caret-right-bold.svg';
|
|
15
15
|
import classNames from 'classnames';
|
|
16
16
|
import ReactDOM from 'react-dom';
|
|
17
|
-
import { point, number } from '@khanacademy/kmath';
|
|
17
|
+
import { point, vector, number } from '@khanacademy/kmath';
|
|
18
18
|
import * as KAS from '@khanacademy/kas';
|
|
19
19
|
import { isTruthy, UnreachableCaseError } from '@khanacademy/wonder-stuff-core';
|
|
20
20
|
import { useMathInputI18n, createMathField } from '@khanacademy/math-input';
|
|
@@ -29,7 +29,7 @@ import trashIcon from '@phosphor-icons/core/bold/trash-bold.svg';
|
|
|
29
29
|
|
|
30
30
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
31
31
|
const libName = "@khanacademy/perseus-editor";
|
|
32
|
-
const libVersion = "6.
|
|
32
|
+
const libVersion = "6.7.0";
|
|
33
33
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
34
34
|
|
|
35
35
|
function _extends() {
|
|
@@ -30642,7 +30642,9 @@ const LockedLineSettings = props => {
|
|
|
30642
30642
|
const capitalizeKind = kind.charAt(0).toUpperCase() + kind.slice(1);
|
|
30643
30643
|
const lineLabel = `${capitalizeKind} (${point1.coord[0]},
|
|
30644
30644
|
${point1.coord[1]}), (${point2.coord[0]}, ${point2.coord[1]})`;
|
|
30645
|
-
|
|
30645
|
+
|
|
30646
|
+
// Check if the line has length 0.
|
|
30647
|
+
const isInvalid = vector.equal(point1.coord, point2.coord);
|
|
30646
30648
|
function handleChangePoint(newPointProps, index) {
|
|
30647
30649
|
const newPoints = [...points];
|
|
30648
30650
|
newPoints[index] = _extends({}, points[index], newPointProps);
|
|
@@ -30916,6 +30918,15 @@ function getDefaultFigureForType(type) {
|
|
|
30916
30918
|
showPoint1: false,
|
|
30917
30919
|
showPoint2: false
|
|
30918
30920
|
};
|
|
30921
|
+
case "circle":
|
|
30922
|
+
return {
|
|
30923
|
+
type: "circle",
|
|
30924
|
+
center: [0, 0],
|
|
30925
|
+
radius: 1,
|
|
30926
|
+
color: DEFAULT_COLOR,
|
|
30927
|
+
fillStyle: "none",
|
|
30928
|
+
strokeStyle: "solid"
|
|
30929
|
+
};
|
|
30919
30930
|
default:
|
|
30920
30931
|
throw new UnreachableCaseError(type);
|
|
30921
30932
|
}
|
|
@@ -30970,18 +30981,27 @@ const LockedFiguresSection = props => {
|
|
|
30970
30981
|
const allCollapsed = expandedStates.every(value => !value);
|
|
30971
30982
|
const buttonLabel = allCollapsed ? "Expand all" : "Collapse all";
|
|
30972
30983
|
const showExpandButton = !!(figures != null && figures.length);
|
|
30973
|
-
return /*#__PURE__*/React.createElement(View, null, figures == null ? void 0 : figures.map((figure, index) =>
|
|
30974
|
-
|
|
30975
|
-
|
|
30976
|
-
|
|
30977
|
-
|
|
30978
|
-
|
|
30979
|
-
}
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30984
|
+
return /*#__PURE__*/React.createElement(View, null, figures == null ? void 0 : figures.map((figure, index) => {
|
|
30985
|
+
if (figure.type === "circle") {
|
|
30986
|
+
// TODO(LEMS-1941): Implement circle locked figure settings.
|
|
30987
|
+
// Remove this block once circle locked figure settings are
|
|
30988
|
+
// implemented.
|
|
30989
|
+
return;
|
|
30990
|
+
}
|
|
30991
|
+
return /*#__PURE__*/React.createElement(LockedFigureSettings, _extends({
|
|
30992
|
+
showM2Features: props.showM2Features,
|
|
30993
|
+
expanded: expandedStates[index],
|
|
30994
|
+
onToggle: newValue => {
|
|
30995
|
+
const newExpanded = [...expandedStates];
|
|
30996
|
+
newExpanded[index] = newValue;
|
|
30997
|
+
setExpandedStates(newExpanded);
|
|
30998
|
+
},
|
|
30999
|
+
key: `${uniqueId}-locked-${figure}-${index}`
|
|
31000
|
+
}, figure, {
|
|
31001
|
+
onChangeProps: newProps => changeProps(index, newProps),
|
|
31002
|
+
onRemove: () => removeLockedFigure(index)
|
|
31003
|
+
}));
|
|
31004
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
30985
31005
|
style: styles$c.buttonContainer
|
|
30986
31006
|
}, /*#__PURE__*/React.createElement(LockedFigureSelect, {
|
|
30987
31007
|
id: `${uniqueId}-select`,
|
|
@@ -31079,13 +31099,25 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
31079
31099
|
correct: correct
|
|
31080
31100
|
});
|
|
31081
31101
|
};
|
|
31102
|
+
this.getSaveWarnings = () => {
|
|
31103
|
+
const issues = [];
|
|
31104
|
+
|
|
31105
|
+
// A locked line on the graph cannot have length 0.
|
|
31106
|
+
for (const figure of (_this$props$lockedFig = this.props.lockedFigures) != null ? _this$props$lockedFig : []) {
|
|
31107
|
+
var _this$props$lockedFig;
|
|
31108
|
+
if (figure.type === "line" && vector.equal(figure.points[0].coord, figure.points[1].coord)) {
|
|
31109
|
+
issues.push("The line cannot have length 0.");
|
|
31110
|
+
}
|
|
31111
|
+
}
|
|
31112
|
+
return issues;
|
|
31113
|
+
};
|
|
31082
31114
|
}
|
|
31083
31115
|
// TODO(jangmi, CP-3288): Remove usage of `UNSAFE_componentWillMount`
|
|
31084
31116
|
UNSAFE_componentWillMount() {
|
|
31085
31117
|
DeprecationMixin.UNSAFE_componentWillMount.call(this);
|
|
31086
31118
|
}
|
|
31087
31119
|
render() {
|
|
31088
|
-
var _this$props$graph$typ, _this$props$graph, _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$apiOption, _this$props$apiOption2;
|
|
31120
|
+
var _this$props$graph$typ, _this$props$graph, _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$apiOption, _this$props$apiOption2, _this$props$apiOption3;
|
|
31089
31121
|
let graph;
|
|
31090
31122
|
let equationString;
|
|
31091
31123
|
const gridStep = this.props.gridStep || Util.getGridStep(this.props.range, this.props.step, interactiveSizes.defaultBoxSize);
|
|
@@ -31337,6 +31369,7 @@ class InteractiveGraphEditor extends React.Component {
|
|
|
31337
31369
|
// Only show the "Add locked figure" dropdown if the graph
|
|
31338
31370
|
// is using Mafs.
|
|
31339
31371
|
this.props.graph && ((_this$props$apiOption = this.props.apiOptions) == null || (_this$props$apiOption = _this$props$apiOption.flags) == null || (_this$props$apiOption = _this$props$apiOption.mafs) == null ? void 0 : _this$props$apiOption["interactive-graph-locked-features-m1"]) && ((_this$props$apiOption2 = this.props.apiOptions) == null || (_this$props$apiOption2 = _this$props$apiOption2.flags) == null || (_this$props$apiOption2 = _this$props$apiOption2.mafs) == null ? void 0 : _this$props$apiOption2[this.props.graph.type]) && /*#__PURE__*/React.createElement(LockedFiguresSection, {
|
|
31372
|
+
showM2Features: (_this$props$apiOption3 = this.props.apiOptions) == null || (_this$props$apiOption3 = _this$props$apiOption3.flags) == null || (_this$props$apiOption3 = _this$props$apiOption3.mafs) == null ? void 0 : _this$props$apiOption3["interactive-graph-locked-features-m2"],
|
|
31340
31373
|
figures: this.props.lockedFigures,
|
|
31341
31374
|
onChange: this.props.onChange
|
|
31342
31375
|
}));
|