@khanacademy/perseus 20.4.0 → 20.4.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 CHANGED
@@ -28418,7 +28418,8 @@ const LinearGraph = props => {
28418
28418
  };
28419
28419
  const LineView = props => {
28420
28420
  const {
28421
- onMoveLine: onMoveSegment,
28421
+ onMoveLine,
28422
+ onMovePoint,
28422
28423
  collinearPair: [start, end],
28423
28424
  range,
28424
28425
  stroke
@@ -28426,7 +28427,7 @@ const LineView = props => {
28426
28427
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MovableLine, {
28427
28428
  start: start,
28428
28429
  end: end,
28429
- onMove: onMoveSegment,
28430
+ onMove: onMoveLine,
28430
28431
  extend: {
28431
28432
  start: true,
28432
28433
  end: true,
@@ -28436,18 +28437,49 @@ const LineView = props => {
28436
28437
  }), /*#__PURE__*/React.createElement(StyledMovablePoint, {
28437
28438
  point: start,
28438
28439
  onMove: newPoint => {
28439
- props.onMovePoint(0, newPoint);
28440
+ onMovePoint(0, newPoint);
28440
28441
  },
28441
28442
  color: stroke
28442
28443
  }), /*#__PURE__*/React.createElement(StyledMovablePoint, {
28443
28444
  point: end,
28444
28445
  onMove: newPoint => {
28445
- props.onMovePoint(1, newPoint);
28446
+ onMovePoint(1, newPoint);
28446
28447
  },
28447
28448
  color: stroke
28448
28449
  }));
28449
28450
  };
28450
28451
 
28452
+ const RayGraph = props => {
28453
+ const {
28454
+ dispatch
28455
+ } = props;
28456
+ const {
28457
+ coords: lines,
28458
+ range
28459
+ } = props.graphState;
28460
+
28461
+ // a ray only has one line
28462
+ const [start, end] = lines[0];
28463
+ const handleMoveLine = delta => dispatch(moveSegment(0, delta));
28464
+ const handleMovePoint = (newPoint, pointIndex) => dispatch(moveControlPoint(0, pointIndex, newPoint));
28465
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MovableLine, {
28466
+ start: start,
28467
+ end: end,
28468
+ onMove: handleMoveLine,
28469
+ extend: {
28470
+ end: true,
28471
+ start: false,
28472
+ range
28473
+ }
28474
+ }), /*#__PURE__*/React.createElement(StyledMovablePoint, {
28475
+ point: start,
28476
+ onMove: newPoint => handleMovePoint(newPoint, 0)
28477
+ }), /*#__PURE__*/React.createElement(StyledMovablePoint, {
28478
+ point: end,
28479
+ onMove: newPoint => handleMovePoint(newPoint, 1)
28480
+ }));
28481
+ };
28482
+
28451
28483
  const renderLineLabel = (n, [min, max]) => n !== -1 && n !== min && n !== max;
28452
28484
  const axisOptions = (props, index) => ({
28453
28485
  axis: props.markings === "graph",
@@ -28565,11 +28597,11 @@ function updateAtIndex(args) {
28565
28597
  }
28566
28598
  function setAtIndex(args) {
28567
28599
  const {
28568
- array,
28600
+ array = [],
28569
28601
  index,
28570
28602
  newValue
28571
28603
  } = args;
28572
- const copy = [...(array || [])];
28604
+ const copy = [...array];
28573
28605
  copy[index] = newValue;
28574
28606
  // restoring readonly to array
28575
28607
  return copy;
@@ -28615,16 +28647,16 @@ function initializeGraphState(params) {
28615
28647
  range
28616
28648
  })
28617
28649
  };
28618
- // Ray can also fall through into this case-- same type, same default coords
28619
28650
  case "linear":
28620
28651
  case "linear-system":
28652
+ case "ray":
28621
28653
  return {
28622
28654
  type: graph.type,
28623
28655
  hasBeenInteractedWith: false,
28624
28656
  range,
28625
28657
  snapStep,
28626
- // A linear graph has a single tuple of points, while a linear
28627
- // system has two tuples of points.
28658
+ // Linear and ray graphs have a single tuple of points, while a
28659
+ // linear system has two tuples of points.
28628
28660
  coords: getLineCoords(graph, range, step)
28629
28661
  };
28630
28662
  }
@@ -28669,9 +28701,9 @@ function getGradableGraph(state, initialGraph) {
28669
28701
  return _extends({}, initialGraph, {
28670
28702
  coords: state.coords
28671
28703
  });
28672
- // RAY has the same type as below; can fall through
28673
28704
  // coords: CollinearTuple
28674
28705
  case state.type === "linear" && initialGraph.type === "linear":
28706
+ case state.type === "ray" && initialGraph.type === "ray":
28675
28707
  return _extends({}, initialGraph, {
28676
28708
  coords: (_state$coords = state.coords) == null ? void 0 : _state$coords[0]
28677
28709
  });
@@ -29399,6 +29431,11 @@ const renderGraph = props => {
29399
29431
  graphState: state,
29400
29432
  dispatch: dispatch
29401
29433
  });
29434
+ case "ray":
29435
+ return /*#__PURE__*/React.createElement(RayGraph, {
29436
+ graphState: state,
29437
+ dispatch: dispatch
29438
+ });
29402
29439
  default:
29403
29440
  return new UnreachableCaseError(type);
29404
29441
  }
@@ -41444,7 +41481,7 @@ const init = function init(options) {
41444
41481
 
41445
41482
  // This file is processed by a Rollup plugin (replace) to inject the production
41446
41483
  const libName = "@khanacademy/perseus";
41447
- const libVersion = "20.4.0";
41484
+ const libVersion = "20.4.1";
41448
41485
  addLibraryVersionToPerseusDebug(libName, libVersion);
41449
41486
 
41450
41487
  const apiVersion = {