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