@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/index.js CHANGED
@@ -618,7 +618,6 @@ class InnerMathInput extends React__namespace.Component {
618
618
  }), /*#__PURE__*/React__namespace.createElement(wonderBlocksPopover.Popover, {
619
619
  opened: this.state.keypadOpen,
620
620
  onClose: () => this.closeKeypad(),
621
- portal: false,
622
621
  dismissEnabled: true,
623
622
  content: () => /*#__PURE__*/React__namespace.createElement(wonderBlocksPopover.PopoverContentCore, {
624
623
  closeButtonVisible: true,
@@ -25296,6 +25295,13 @@ class Explanation extends React__namespace.Component {
25296
25295
  state = {
25297
25296
  expanded: false
25298
25297
  };
25298
+ _mounted = false;
25299
+ componentDidMount() {
25300
+ this._mounted = true;
25301
+ }
25302
+ componentWillUnmount() {
25303
+ this._mounted = false;
25304
+ }
25299
25305
  change = (() => {
25300
25306
  var _this = this;
25301
25307
  return function () {
@@ -25314,7 +25320,7 @@ class Explanation extends React__namespace.Component {
25314
25320
  render() {
25315
25321
  const promptText = this.state.expanded ? this.props.hidePrompt : this.props.showPrompt;
25316
25322
  const caretIcon = this.state.expanded ? caretUp__default["default"] : caretDown__default["default"];
25317
- const allowTransition = mediaQueryIsMatched("(prefers-reduced-motion: no-preference)");
25323
+ const allowTransition = this._mounted && mediaQueryIsMatched("(prefers-reduced-motion: no-preference)");
25318
25324
 
25319
25325
  // Special styling is needed to fit the button in a block of text without throwing off the line spacing.
25320
25326
  // While the button is not normally included in a block of text, it needs to be able to accommodate such a case.
@@ -36250,6 +36256,10 @@ const styles$f = aphrodite.StyleSheet.create({
36250
36256
 
36251
36257
  /* eslint-disable @khanacademy/ts-no-error-suppressions */
36252
36258
  function shouldReduceMotion() {
36259
+ // We cannot use matchMedia during SSR.
36260
+ if (typeof window.matchMedia !== "function") {
36261
+ return true;
36262
+ }
36253
36263
  const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
36254
36264
  return !mediaQuery || mediaQuery.matches;
36255
36265
  }
@@ -36258,9 +36268,16 @@ class Marker extends React__namespace.Component {
36258
36268
  static contextType = PerseusI18nContext;
36259
36269
  // The marker icon element.
36260
36270
  _icon;
36271
+ _mounted = false;
36261
36272
  static defaultProps = {
36262
36273
  selected: []
36263
36274
  };
36275
+ componentDidMount() {
36276
+ this._mounted = true;
36277
+ }
36278
+ componentWillUnmount() {
36279
+ this._mounted = false;
36280
+ }
36264
36281
  renderIcon() {
36265
36282
  const {
36266
36283
  selected,
@@ -36303,7 +36320,7 @@ class Marker extends React__namespace.Component {
36303
36320
  size: 8
36304
36321
  };
36305
36322
  } else if (showPulsate) {
36306
- iconStyles = [styles$e.markerPulsateBase, shouldReduceMotion() ? showPulsate && styles$e.markerUnfilledPulsateOnce : showPulsate && styles$e.markerUnfilledPulsateInfinite];
36323
+ iconStyles = [styles$e.markerPulsateBase, this._mounted && shouldReduceMotion() ? showPulsate && styles$e.markerUnfilledPulsateOnce : showPulsate && styles$e.markerUnfilledPulsateInfinite];
36307
36324
  }
36308
36325
  return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
36309
36326
  style: [styles$e.markerIcon, iconStyles],
@@ -36431,6 +36448,7 @@ class LabelImage extends React__namespace.Component {
36431
36448
  static contextType = PerseusI18nContext;
36432
36449
  // The rendered markers on the question image for labeling.
36433
36450
  _markers;
36451
+ _mounted = false;
36434
36452
  static gradeMarker(marker) {
36435
36453
  const score = {
36436
36454
  hasAnswers: false,
@@ -36668,6 +36686,12 @@ class LabelImage extends React__namespace.Component {
36668
36686
  hideAnswers: false
36669
36687
  };
36670
36688
  }
36689
+ componentDidMount() {
36690
+ this._mounted = true;
36691
+ }
36692
+ componentWillUnmount() {
36693
+ this._mounted = false;
36694
+ }
36671
36695
  simpleValidate(rubric) {
36672
36696
  return LabelImage.validate(this.getUserInput(), rubric);
36673
36697
  }
@@ -36806,13 +36830,14 @@ class LabelImage extends React__namespace.Component {
36806
36830
  markersInteracted
36807
36831
  } = this.state;
36808
36832
 
36833
+ // Determine whether page is rendered in a narrow browser window.
36834
+ const isNarrowPage = this._mounted && window.matchMedia(mediaQueries.xsOrSmaller.replace("@media ", "")).matches;
36835
+
36836
+ // Determine whether the image is wider than it is tall.
36837
+ const isWideImage = this.props.imageWidth / 2 > this.props.imageHeight;
36838
+
36809
36839
  // Render all markers for widget.
36810
36840
  return markers.map((marker, index) => {
36811
- // Determine whether page is rendered in a narrow browser window.
36812
- const isNarrowPage = window.matchMedia(mediaQueries.xsOrSmaller.replace("@media ", "")).matches;
36813
-
36814
- // Determine whether the image is wider than it is tall.
36815
- const isWideImage = this.props.imageWidth / 2 > this.props.imageHeight;
36816
36841
  let side;
36817
36842
  let markerPosition;
36818
36843
  // Position popup closest to the center, preferring it renders
@@ -44445,7 +44470,7 @@ const init = function (options) {
44445
44470
 
44446
44471
  // This file is processed by a Rollup plugin (replace) to inject the production
44447
44472
  const libName = "@khanacademy/perseus";
44448
- const libVersion = "27.0.0";
44473
+ const libVersion = "27.0.2";
44449
44474
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
44450
44475
 
44451
44476
  const apiVersion = {