@khanacademy/perseus 25.0.0 → 25.1.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/es/index.js CHANGED
@@ -31838,12 +31838,16 @@ function initializeGraphState(params) {
31838
31838
  }
31839
31839
  }
31840
31840
  function getPointCoords(graph, range, step) {
31841
- var _graph$coords;
31841
+ var _graph$coords, _graph$startCoords;
31842
31842
  const numPoints = graph.numPoints || 1;
31843
31843
  let coords = (_graph$coords = graph.coords) == null ? void 0 : _graph$coords.slice();
31844
31844
  if (coords) {
31845
31845
  return coords;
31846
31846
  }
31847
+ const startCoords = (_graph$startCoords = graph.startCoords) == null ? void 0 : _graph$startCoords.slice();
31848
+ if (startCoords) {
31849
+ return startCoords;
31850
+ }
31847
31851
  switch (numPoints) {
31848
31852
  case 1:
31849
31853
  // Back in the day, one point's coords were in graph.coord
@@ -31877,6 +31881,9 @@ function getSegmentCoords(graph, range, step) {
31877
31881
  if (graph.coords) {
31878
31882
  return graph.coords;
31879
31883
  }
31884
+ if (graph.startCoords) {
31885
+ return graph.startCoords;
31886
+ }
31880
31887
  const ys = n => {
31881
31888
  switch (n) {
31882
31889
  case 2:
@@ -31906,20 +31913,30 @@ function getLineCoords(graph, range, step) {
31906
31913
  if (graph.coords) {
31907
31914
  return graph.coords;
31908
31915
  }
31916
+ if (graph.startCoords) {
31917
+ return graph.startCoords;
31918
+ }
31909
31919
  return normalizePoints(range, step, defaultLinearCoords[0]);
31910
31920
  }
31911
31921
  function getLinearSystemCoords(graph, range, step) {
31912
31922
  if (graph.coords) {
31913
31923
  return graph.coords;
31914
31924
  }
31925
+ if (graph.startCoords) {
31926
+ return graph.startCoords;
31927
+ }
31915
31928
  return defaultLinearCoords.map(points => normalizePoints(range, step, points));
31916
31929
  }
31917
31930
  function getPolygonCoords(graph, range, step) {
31918
- var _graph$coords2;
31931
+ var _graph$coords2, _graph$startCoords2;
31919
31932
  let coords = (_graph$coords2 = graph.coords) == null ? void 0 : _graph$coords2.slice();
31920
31933
  if (coords) {
31921
31934
  return coords;
31922
31935
  }
31936
+ const startCoords = (_graph$startCoords2 = graph.startCoords) == null ? void 0 : _graph$startCoords2.slice();
31937
+ if (startCoords) {
31938
+ return startCoords;
31939
+ }
31923
31940
  const n = graph.numSides || 3;
31924
31941
  if (n === "unlimited") {
31925
31942
  coords = [];
@@ -31943,6 +31960,9 @@ function getSinusoidCoords(graph, range, step) {
31943
31960
  if (graph.coords) {
31944
31961
  return [graph.coords[0], graph.coords[1]];
31945
31962
  }
31963
+ if (graph.startCoords) {
31964
+ return [graph.startCoords[0], graph.startCoords[1]];
31965
+ }
31946
31966
  let coords = [[0.5, 0.5], [0.65, 0.6]];
31947
31967
  coords = normalizePoints(range, step, coords, true);
31948
31968
  return coords;
@@ -31951,6 +31971,9 @@ function getQuadraticCoords(graph, range, step) {
31951
31971
  if (graph.coords) {
31952
31972
  return graph.coords;
31953
31973
  }
31974
+ if (graph.startCoords) {
31975
+ return graph.startCoords;
31976
+ }
31954
31977
  const defaultCoords = [[0.25, 0.75], [0.5, 0.25], [0.75, 0.75]];
31955
31978
  return normalizePoints(range, step, defaultCoords, true);
31956
31979
  }
@@ -31961,6 +31984,12 @@ function getCircleCoords(graph) {
31961
31984
  radiusPoint: vec.add(graph.center, [graph.radius, 0])
31962
31985
  };
31963
31986
  }
31987
+ if (graph.startCoords) {
31988
+ return {
31989
+ center: graph.startCoords,
31990
+ radiusPoint: vec.add(graph.startCoords, [2, 0])
31991
+ };
31992
+ }
31964
31993
  return {
31965
31994
  center: [0, 0],
31966
31995
  radiusPoint: [2, 0]
@@ -32690,6 +32719,7 @@ function mafsStateToInteractiveGraph(state) {
32690
32719
  return _extends({}, state);
32691
32720
  }
32692
32721
  const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
32722
+ var _graph$startCoords;
32693
32723
  const {
32694
32724
  onChange,
32695
32725
  graph
@@ -32724,6 +32754,7 @@ const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
32724
32754
  const snapTo = graph.type === "polygon" ? graph.snapTo : null;
32725
32755
  const showAngles = graph.type === "polygon" ? graph.showAngles : null;
32726
32756
  const showSides = graph.type === "polygon" ? graph.showSides : null;
32757
+ const startCoords = (_graph$startCoords = graph.startCoords) != null ? _graph$startCoords : null;
32727
32758
  const originalPropsRef = useRef(props);
32728
32759
  const latestPropsRef = useLatestRef(props);
32729
32760
  useEffect(() => {
@@ -32734,7 +32765,7 @@ const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
32734
32765
  if (latestPropsRef.current !== originalPropsRef.current) {
32735
32766
  dispatch(reinitialize(latestPropsRef.current));
32736
32767
  }
32737
- }, [graph.type, numSegments, numSides, snapTo, showAngles, showSides, latestPropsRef]);
32768
+ }, [graph.type, numSegments, numSides, snapTo, showAngles, showSides, startCoords, latestPropsRef, startCoords]);
32738
32769
  return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, props, {
32739
32770
  state: state,
32740
32771
  dispatch: dispatch
@@ -44864,7 +44895,7 @@ const init = function init(options) {
44864
44895
 
44865
44896
  // This file is processed by a Rollup plugin (replace) to inject the production
44866
44897
  const libName = "@khanacademy/perseus";
44867
- const libVersion = "25.0.0";
44898
+ const libVersion = "25.1.0";
44868
44899
  addLibraryVersionToPerseusDebug(libName, libVersion);
44869
44900
 
44870
44901
  const apiVersion = {
@@ -47865,5 +47896,5 @@ const EditorJsonify = {
47865
47896
  }
47866
47897
  };
47867
47898
 
47868
- export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemExtras, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusExpressionAnswerFormConsidered, PerseusI18nContext, PerseusI18nContextProvider, PerseusMarkdown, Plotter$1 as PlotterWidget, QUESTION_WIDGETS, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, addWidget, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, contentHasWidgetType, convertWidgetNameToEnum, displaySigFigs, generateTestCategorizerWidget, generateTestExpressionWidget, generateTestInteractiveGraphWidget, generateTestNumericInputWidget, generateTestPerseusItem, generateTestRadioWidget, genericPerseusItemData, getAnswerFromUserInput, getAnswersFromWidgets, getCorrectAnswerForWidgetId, getValidWidgetIds, getWidgetFromWidgetMap, getWidgetIdsFromContent, getWidgetIdsFromContentByType, getWidgetTypeByWidgetId, getWidgetsFromWidgetMap, getWidgetsMapFromItemData, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, isWidgetIdInContent, isWrongAnswerSupported, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, lockedFigureColors, lockedFigureFillStyles, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, shouldHaveIndividualAnswer, traverse, usePerseusI18n, violatingWidgets, allWidgets as widgets };
47899
+ export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemExtras, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusExpressionAnswerFormConsidered, PerseusI18nContext, PerseusI18nContextProvider, PerseusMarkdown, Plotter$1 as PlotterWidget, QUESTION_WIDGETS, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, addWidget, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, contentHasWidgetType, convertWidgetNameToEnum, displaySigFigs, generateTestCategorizerWidget, generateTestExpressionWidget, generateTestInteractiveGraphWidget, generateTestNumericInputWidget, generateTestPerseusItem, generateTestRadioWidget, genericPerseusItemData, getAnswerFromUserInput, getAnswersFromWidgets, getCorrectAnswerForWidgetId, getLineCoords, getValidWidgetIds, getWidgetFromWidgetMap, getWidgetIdsFromContent, getWidgetIdsFromContentByType, getWidgetTypeByWidgetId, getWidgetsFromWidgetMap, getWidgetsMapFromItemData, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, isWidgetIdInContent, isWrongAnswerSupported, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, lockedFigureColors, lockedFigureFillStyles, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, shouldHaveIndividualAnswer, traverse, usePerseusI18n, violatingWidgets, allWidgets as widgets };
47869
47900
  //# sourceMappingURL=index.js.map