@khanacademy/perseus-editor 14.6.4 → 14.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/index.js CHANGED
@@ -98,7 +98,7 @@ var arrowCounterClockwise__default = /*#__PURE__*/_interopDefaultLegacy(arrowCou
98
98
 
99
99
  // This file is processed by a Rollup plugin (replace) to inject the production
100
100
  const libName = "@khanacademy/perseus-editor";
101
- const libVersion = "14.6.4";
101
+ const libVersion = "14.7.0";
102
102
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
103
103
 
104
104
  function _extends() {
@@ -33114,15 +33114,12 @@ const getQuadraticEquation = startCoords => {
33114
33114
  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;
33115
33115
  return "y = " + a.toFixed(3) + "x^2 + " + b.toFixed(3) + "x + " + c.toFixed(3);
33116
33116
  };
33117
- const findAngle = (point1, point2) => {
33118
- const x = point1[0] - point2[0];
33119
- const y = point1[1] - point2[1];
33120
- return (180 + Math.atan2(-y, -x) * 180 / Math.PI + 360) % 360;
33121
- };
33122
- const getAngleEquation = startCoords => {
33123
- const [point1, vertex, point2] = startCoords;
33124
- const angle = findAngle(point2, vertex) - findAngle(point1, vertex);
33125
- const roundedAngle = angle.toFixed(0);
33117
+ const getAngleEquation = function (startCoords) {
33118
+ let allowReflexAngles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
33119
+ const vertex = startCoords[1];
33120
+
33121
+ // Get the angle in degrees and round it to the nearest whole number
33122
+ const roundedAngle = perseus.getClockwiseAngle(startCoords, allowReflexAngles).toFixed(0);
33126
33123
  return `${roundedAngle}\u00B0 angle at (${vertex[0]}, ${vertex[1]})`;
33127
33124
  };
33128
33125
  const shouldShowStartCoordsUI = (graph, isStatic) => {
@@ -33156,13 +33153,14 @@ const shouldShowStartCoordsUI = (graph, isStatic) => {
33156
33153
  const StartCoordsAngle = props => {
33157
33154
  const {
33158
33155
  startCoords,
33156
+ allowReflexAngles,
33159
33157
  onChange
33160
33158
  } = props;
33161
33159
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
33162
33160
  style: styles$h.equationSection
33163
33161
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, "Starting equation:"), /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.BodyMonospace, {
33164
33162
  style: styles$h.equationBody
33165
- }, getAngleEquation(startCoords))), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
33163
+ }, getAngleEquation(startCoords, allowReflexAngles))), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
33166
33164
  style: styles$h.tile
33167
33165
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelLarge, null, "Point 1:"), /*#__PURE__*/React__namespace.createElement(Strut, {
33168
33166
  size: wonderBlocksTokens.spacing.small_12
@@ -33504,6 +33502,7 @@ const StartCoordsSettingsInner = props => {
33504
33502
  type,
33505
33503
  range,
33506
33504
  step,
33505
+ allowReflexAngles,
33507
33506
  onChange
33508
33507
  } = props;
33509
33508
  switch (type) {
@@ -33567,6 +33566,7 @@ const StartCoordsSettingsInner = props => {
33567
33566
  });
33568
33567
  return /*#__PURE__*/React__namespace.createElement(StartCoordsAngle, {
33569
33568
  startCoords: angleCoords,
33569
+ allowReflexAngles: allowReflexAngles,
33570
33570
  onChange: onChange
33571
33571
  });
33572
33572
  default:
@@ -33794,7 +33794,53 @@ class InteractiveGraphEditor extends React__namespace.Component {
33794
33794
  }
33795
33795
  });
33796
33796
  }
33797
- })), this.props.correct?.type === "polygon" && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(LabeledRow, {
33797
+ })), this.props.correct?.type === "angle" && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
33798
+ style: styles$a.row
33799
+ }, /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.Checkbox, {
33800
+ label: /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelSmall, null, "Show angle measures"),
33801
+ checked:
33802
+ // Don't show indeterminate checkbox state
33803
+ !!this.props.correct?.showAngles,
33804
+ onChange: newValue => {
33805
+ if (this.props.graph?.type === "angle") {
33806
+ invariant(this.props.correct.type === "angle", `Expected graph type to be angle, but got ${this.props.correct.type}`);
33807
+ this.props.onChange({
33808
+ correct: {
33809
+ ...this.props.correct,
33810
+ showAngles: newValue
33811
+ },
33812
+ graph: {
33813
+ ...this.props.graph,
33814
+ showAngles: newValue
33815
+ }
33816
+ });
33817
+ }
33818
+ }
33819
+ }), /*#__PURE__*/React__namespace.createElement(InfoTip$b, null, /*#__PURE__*/React__namespace.createElement("p", null, "Displays the interior angle measures."))), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
33820
+ style: styles$a.row
33821
+ }, /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.Checkbox, {
33822
+ label: /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelSmall, null, "Allow reflex angles"),
33823
+ checked:
33824
+ // Don't show indeterminate checkbox state
33825
+ !!this.props.correct?.allowReflexAngles,
33826
+ onChange: newValue => {
33827
+ invariant(this.props.correct.type === "angle", `Expected graph type to be angle, but got ${this.props.correct.type}`);
33828
+ invariant(this.props.graph?.type === "angle", `Expected graph type to be angle, but got ${this.props.graph?.type}`);
33829
+ const update = {
33830
+ allowReflexAngles: newValue
33831
+ };
33832
+ this.props.onChange({
33833
+ correct: {
33834
+ ...this.props.correct,
33835
+ ...update
33836
+ },
33837
+ graph: {
33838
+ ...this.props.graph,
33839
+ ...update
33840
+ }
33841
+ });
33842
+ }
33843
+ }), /*#__PURE__*/React__namespace.createElement(InfoTip$b, null, /*#__PURE__*/React__namespace.createElement("p", null, "Allow students to be able to create reflex angles.")))), this.props.correct?.type === "polygon" && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(LabeledRow, {
33798
33844
  label: "Number of sides:"
33799
33845
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.SingleSelect, {
33800
33846
  key: "polygon-select",