@khanacademy/perseus 27.0.0 → 27.0.2

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
@@ -501,7 +501,6 @@ class InnerMathInput extends React.Component {
501
501
  }), /*#__PURE__*/React.createElement(Popover, {
502
502
  opened: this.state.keypadOpen,
503
503
  onClose: () => this.closeKeypad(),
504
- portal: false,
505
504
  dismissEnabled: true,
506
505
  content: () => {
507
506
  var _this$props$keypadBut, _this$props;
@@ -25035,6 +25034,7 @@ class Explanation extends React.Component {
25035
25034
  this.state = {
25036
25035
  expanded: false
25037
25036
  };
25037
+ this._mounted = false;
25038
25038
  this.change = (...args) => {
25039
25039
  return change.apply(this, args);
25040
25040
  };
@@ -25059,10 +25059,16 @@ class Explanation extends React.Component {
25059
25059
  message: null
25060
25060
  };
25061
25061
  }
25062
+ componentDidMount() {
25063
+ this._mounted = true;
25064
+ }
25065
+ componentWillUnmount() {
25066
+ this._mounted = false;
25067
+ }
25062
25068
  render() {
25063
25069
  const promptText = this.state.expanded ? this.props.hidePrompt : this.props.showPrompt;
25064
25070
  const caretIcon = this.state.expanded ? caretUp : caretDown;
25065
- const allowTransition = mediaQueryIsMatched("(prefers-reduced-motion: no-preference)");
25071
+ const allowTransition = this._mounted && mediaQueryIsMatched("(prefers-reduced-motion: no-preference)");
25066
25072
 
25067
25073
  // Special styling is needed to fit the button in a block of text without throwing off the line spacing.
25068
25074
  // While the button is not normally included in a block of text, it needs to be able to accommodate such a case.
@@ -35902,6 +35908,10 @@ const styles$f = StyleSheet.create({
35902
35908
  });
35903
35909
 
35904
35910
  function shouldReduceMotion() {
35911
+ // We cannot use matchMedia during SSR.
35912
+ if (typeof window.matchMedia !== "function") {
35913
+ return true;
35914
+ }
35905
35915
  const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
35906
35916
  return !mediaQuery || mediaQuery.matches;
35907
35917
  }
@@ -35911,6 +35921,13 @@ class Marker extends React.Component {
35911
35921
  super(...args);
35912
35922
  // The marker icon element.
35913
35923
  this._icon = void 0;
35924
+ this._mounted = false;
35925
+ }
35926
+ componentDidMount() {
35927
+ this._mounted = true;
35928
+ }
35929
+ componentWillUnmount() {
35930
+ this._mounted = false;
35914
35931
  }
35915
35932
  renderIcon() {
35916
35933
  const {
@@ -35952,7 +35969,7 @@ class Marker extends React.Component {
35952
35969
  size: 8
35953
35970
  });
35954
35971
  } else if (showPulsate) {
35955
- iconStyles = [styles$e.markerPulsateBase, shouldReduceMotion() ? showPulsate && styles$e.markerUnfilledPulsateOnce : showPulsate && styles$e.markerUnfilledPulsateInfinite];
35972
+ iconStyles = [styles$e.markerPulsateBase, this._mounted && shouldReduceMotion() ? showPulsate && styles$e.markerUnfilledPulsateOnce : showPulsate && styles$e.markerUnfilledPulsateInfinite];
35956
35973
  }
35957
35974
  return /*#__PURE__*/React.createElement(View, {
35958
35975
  style: [styles$e.markerIcon, iconStyles],
@@ -36314,6 +36331,7 @@ class LabelImage extends React.Component {
36314
36331
  super(props);
36315
36332
  // The rendered markers on the question image for labeling.
36316
36333
  this._markers = void 0;
36334
+ this._mounted = false;
36317
36335
  this._markers = [];
36318
36336
  this.state = {
36319
36337
  activeMarkerIndex: -1,
@@ -36321,6 +36339,12 @@ class LabelImage extends React.Component {
36321
36339
  hideAnswers: false
36322
36340
  };
36323
36341
  }
36342
+ componentDidMount() {
36343
+ this._mounted = true;
36344
+ }
36345
+ componentWillUnmount() {
36346
+ this._mounted = false;
36347
+ }
36324
36348
  simpleValidate(rubric) {
36325
36349
  return LabelImage.validate(this.getUserInput(), rubric);
36326
36350
  }
@@ -36457,13 +36481,14 @@ class LabelImage extends React.Component {
36457
36481
  markersInteracted
36458
36482
  } = this.state;
36459
36483
 
36484
+ // Determine whether page is rendered in a narrow browser window.
36485
+ const isNarrowPage = this._mounted && window.matchMedia(mediaQueries.xsOrSmaller.replace("@media ", "")).matches;
36486
+
36487
+ // Determine whether the image is wider than it is tall.
36488
+ const isWideImage = this.props.imageWidth / 2 > this.props.imageHeight;
36489
+
36460
36490
  // Render all markers for widget.
36461
36491
  return markers.map((marker, index) => {
36462
- // Determine whether page is rendered in a narrow browser window.
36463
- const isNarrowPage = window.matchMedia(mediaQueries.xsOrSmaller.replace("@media ", "")).matches;
36464
-
36465
- // Determine whether the image is wider than it is tall.
36466
- const isWideImage = this.props.imageWidth / 2 > this.props.imageHeight;
36467
36492
  let side;
36468
36493
  let markerPosition;
36469
36494
  // Position popup closest to the center, preferring it renders
@@ -44089,7 +44114,7 @@ const init = function init(options) {
44089
44114
 
44090
44115
  // This file is processed by a Rollup plugin (replace) to inject the production
44091
44116
  const libName = "@khanacademy/perseus";
44092
- const libVersion = "27.0.0";
44117
+ const libVersion = "27.0.2";
44093
44118
  addLibraryVersionToPerseusDebug(libName, libVersion);
44094
44119
 
44095
44120
  const apiVersion = {