@khanacademy/perseus 22.5.0 → 22.5.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
@@ -29683,14 +29683,12 @@ function initializeGraphState(params) {
29683
29683
  graph,
29684
29684
  step,
29685
29685
  snapStep,
29686
- range,
29687
- markings
29686
+ range
29688
29687
  } = params;
29689
29688
  const shared = {
29690
29689
  hasBeenInteractedWith: false,
29691
29690
  range,
29692
- snapStep,
29693
- markings
29691
+ snapStep
29694
29692
  };
29695
29693
  switch (graph.type) {
29696
29694
  case "segment":
@@ -31182,35 +31180,22 @@ function mafsStateToInteractiveGraph(state) {
31182
31180
  return _extends({}, state);
31183
31181
  }
31184
31182
  const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
31183
+ const {
31184
+ onChange
31185
+ } = props;
31185
31186
  const [state, dispatch] = React.useReducer(interactiveGraphReducer, props, initializeGraphState);
31186
31187
  useImperativeHandle(ref, () => ({
31187
31188
  getUserInput: () => getGradableGraph(state, props.graph)
31188
31189
  }));
31189
- function onChange(next) {
31190
- props.onChange(mafsStateToInteractiveGraph(next));
31191
- }
31192
- return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, props, {
31193
- state: state,
31194
- dispatch: dispatch,
31195
- onChange: onChange
31196
- }));
31197
- });
31198
- const MafsGraph = props => {
31199
- const {
31200
- state,
31201
- dispatch,
31202
- labels
31203
- } = props;
31204
- const [width, height] = props.box;
31205
31190
  const prevState = useRef(state);
31206
31191
  useEffect(() => {
31207
31192
  if (prevState.current !== state) {
31208
- props.onChange({
31193
+ onChange(mafsStateToInteractiveGraph({
31209
31194
  graph: state
31210
- });
31195
+ }));
31211
31196
  }
31212
31197
  prevState.current = state;
31213
- }, [props, state]);
31198
+ }, [onChange, state]);
31214
31199
 
31215
31200
  // Destructuring first to keep useEffect from making excess calls
31216
31201
  const [xSnap, ySnap] = props.snapStep;
@@ -31223,6 +31208,18 @@ const MafsGraph = props => {
31223
31208
  useEffect(() => {
31224
31209
  dispatch(changeRange([[xMinRange, xMaxRange], [yMinRange, yMaxRange]]));
31225
31210
  }, [dispatch, xMinRange, xMaxRange, yMinRange, yMaxRange]);
31211
+ return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, props, {
31212
+ state: state,
31213
+ dispatch: dispatch
31214
+ }));
31215
+ });
31216
+ const MafsGraph = props => {
31217
+ const {
31218
+ state,
31219
+ dispatch,
31220
+ labels
31221
+ } = props;
31222
+ const [width, height] = props.box;
31226
31223
  return /*#__PURE__*/React.createElement(GraphConfigContext.Provider, {
31227
31224
  value: {
31228
31225
  range: state.range,
@@ -31255,8 +31252,8 @@ const MafsGraph = props => {
31255
31252
  }, props.markings === "graph" && /*#__PURE__*/React.createElement(AxisLabels, null), /*#__PURE__*/React.createElement(Mafs, {
31256
31253
  preserveAspectRatio: false,
31257
31254
  viewBox: {
31258
- x: props.range[0],
31259
- y: props.range[1],
31255
+ x: state.range[0],
31256
+ y: state.range[1],
31260
31257
  padding: 0
31261
31258
  },
31262
31259
  pan: false,
@@ -31266,12 +31263,12 @@ const MafsGraph = props => {
31266
31263
  }, /*#__PURE__*/React.createElement(SvgDefs, null), /*#__PURE__*/React.createElement(Grid, {
31267
31264
  tickStep: props.step,
31268
31265
  gridStep: props.gridStep,
31269
- range: props.range,
31266
+ range: state.range,
31270
31267
  containerSizeClass: props.containerSizeClass,
31271
31268
  markings: props.markings
31272
31269
  }), props.lockedFigures && /*#__PURE__*/React.createElement(GraphLockedLayer, {
31273
31270
  lockedFigures: props.lockedFigures,
31274
- range: props.range
31271
+ range: state.range
31275
31272
  }), renderGraph({
31276
31273
  state,
31277
31274
  dispatch
@@ -43372,7 +43369,7 @@ const init = function init(options) {
43372
43369
 
43373
43370
  // This file is processed by a Rollup plugin (replace) to inject the production
43374
43371
  const libName = "@khanacademy/perseus";
43375
- const libVersion = "22.5.0";
43372
+ const libVersion = "22.5.1";
43376
43373
  addLibraryVersionToPerseusDebug(libName, libVersion);
43377
43374
 
43378
43375
  const apiVersion = {