@khanacademy/perseus 57.0.1 → 57.2.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
@@ -27920,10 +27920,11 @@ function AxisLabels({
27920
27920
  const [xAxisLabelLocation, yAxisLabelLocation] = getLabelPosition(graphInfo, labelLocation);
27921
27921
  const [xAxisLabelText, yAxisLabelText] = labels;
27922
27922
 
27923
- // If the labels are rotated, we need to center the
27924
- // x-axis label along the bottom of the graph.
27925
- const xLabelTransform = labelLocation === "onAxis" ? "translate(7px, -50%)" : "translate(-50%, -50%)";
27926
- const yLabelTransform = labelLocation === "onAxis" ? "translate(-50%, 0px)" : "translate(-50%, 0px) rotate(-90deg)";
27923
+ // Get the transform for the labels
27924
+ const {
27925
+ xLabelTransform,
27926
+ yLabelTransform
27927
+ } = getLabelTransform(labelLocation);
27927
27928
  const {
27928
27929
  TeX
27929
27930
  } = getDependencies();
@@ -27947,6 +27948,24 @@ function AxisLabels({
27947
27948
  }
27948
27949
  }, /*#__PURE__*/React__default.createElement(TeX, null, replaceOutsideTeX(yAxisLabelText))));
27949
27950
  }
27951
+
27952
+ /* Get the transform for the labels based on the labelLocation
27953
+ * Exported for testing purposes.
27954
+ */
27955
+ const getLabelTransform = labelLocation => {
27956
+ // onAxis is the default label location
27957
+ const isOnAxis = labelLocation === undefined || labelLocation === "onAxis";
27958
+ const xLabelTransform = isOnAxis ? "translate(7px, -50%)" : "translate(-50%, -50%)";
27959
+ const yLabelTransform = isOnAxis ? "translate(-50%, 0px)" : "translate(-50%, 0px) rotate(-90deg)";
27960
+ return {
27961
+ xLabelTransform,
27962
+ yLabelTransform
27963
+ };
27964
+ };
27965
+
27966
+ /* Calculate the position of the main axis labels based on the labelLocation
27967
+ * and the ranges of the graph. Exported for testing purposes.
27968
+ */
27950
27969
  const getLabelPosition = (graphInfo, labelLocation) => {
27951
27970
  // If the labels are placed along the edge of the graph, we need to place them at the
27952
27971
  // center of the graph, which is the average of the min and max values of the axes.
@@ -41429,7 +41448,7 @@ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
41429
41448
 
41430
41449
  // This file is processed by a Rollup plugin (replace) to inject the production
41431
41450
  const libName = "@khanacademy/perseus";
41432
- const libVersion = "57.0.1";
41451
+ const libVersion = "57.2.0";
41433
41452
  addLibraryVersionToPerseusDebug(libName, libVersion);
41434
41453
 
41435
41454
  const apiVersion = {