@khanacademy/perseus 57.2.1 → 57.2.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.css CHANGED
@@ -1078,7 +1078,7 @@ div.graphie {
1078
1078
  font-size: 14px;
1079
1079
  }
1080
1080
  .framework-perseus .number-input {
1081
- border: 1px solid #ccc;
1081
+ border: 1px solid #909296;
1082
1082
  border-radius: 5px;
1083
1083
  margin: 0;
1084
1084
  padding: 5px 0;
@@ -2966,7 +2966,6 @@ html body .mq-editable-field .mq-selection .mq-nthroot-container * {
2966
2966
  --movable-point-hover-expansion: 2px;
2967
2967
  --movable-point-focus-ring-offset: 2px;
2968
2968
 
2969
- --movable-line-stroke-color: var(--mafs-blue);
2970
2969
  --movable-line-stroke-weight: 2px;
2971
2970
  --movable-line-stroke-weight-active: 4px;
2972
2971
  overflow: visible !important;
package/dist/es/index.js CHANGED
@@ -27,7 +27,7 @@ import { KeypadContext } from '@khanacademy/keypad-context';
27
27
  import { TextField } from '@khanacademy/wonder-blocks-form';
28
28
  import { entries, UnreachableCaseError, keys } from '@khanacademy/wonder-stuff-core';
29
29
  import { CircularSpinner } from '@khanacademy/wonder-blocks-progress-spinner';
30
- import { point, KhanMath, number, vector as vector$3, line, geometry, angles, coefficients } from '@khanacademy/kmath';
30
+ import { point, KhanMath, vector as vector$3, number, line, geometry, angles, coefficients } from '@khanacademy/kmath';
31
31
  import _classPrivateFieldLooseBase from '@babel/runtime/helpers/classPrivateFieldLooseBase';
32
32
  import _classPrivateFieldLooseKey from '@babel/runtime/helpers/classPrivateFieldLooseKey';
33
33
  import SimpleMarkdown from '@khanacademy/simple-markdown';
@@ -48,6 +48,7 @@ import { Popper } from 'react-popper';
48
48
  import IconButton from '@khanacademy/wonder-blocks-icon-button';
49
49
  import cornersOutIcon from '@phosphor-icons/core/regular/corners-out.svg';
50
50
  import Link from '@khanacademy/wonder-blocks-link';
51
+ import { addLibraryVersionToPerseusDebug } from '@khanacademy/perseus-utils';
51
52
 
52
53
  /**
53
54
  * The translated strings that are used to render Perseus.
@@ -767,9 +768,12 @@ class InnerMathInput extends React.Component {
767
768
  // a keyboard event is "keydown" type.
768
769
  // In react without WonderBlocks, "enter" or "space" keydown events
769
770
  // are also "click" events, differentiated by "detail".
770
- if (e.type === "click") {
771
+ if ((e == null ? void 0 : e.type) === "click") {
771
772
  this.focus();
772
773
  }
774
+ if (key === "DISMISS") {
775
+ this.closeKeypad();
776
+ }
773
777
  };
774
778
  }
775
779
  componentDidMount() {
@@ -829,10 +833,9 @@ class InnerMathInput extends React.Component {
829
833
  onFocus: () => this.focus(),
830
834
  onBlur: () => this.blur()
831
835
  }), /*#__PURE__*/React.createElement(Popover, {
832
- rootBoundary: "document",
833
836
  opened: this.state.keypadOpen,
834
- onClose: () => this.closeKeypad(),
835
837
  dismissEnabled: true,
838
+ rootBoundary: "document",
836
839
  "aria-label": this.context.strings.mathInputTitle,
837
840
  "aria-describedby": `popover-content-${popoverContentUniqueId}`,
838
841
  content: () => {
@@ -841,7 +844,6 @@ class InnerMathInput extends React.Component {
841
844
  id: `popover-content-${popoverContentUniqueId}`,
842
845
  style: a11y.srOnly
843
846
  }, this.context.strings.mathInputDescription), /*#__PURE__*/React.createElement(PopoverContentCore, {
844
- closeButtonVisible: true,
845
847
  style: styles$D.popoverContent
846
848
  }, /*#__PURE__*/React.createElement(DesktopKeypad, _extends({
847
849
  onAnalyticsEvent: this.props.onAnalyticsEvent,
@@ -849,7 +851,9 @@ class InnerMathInput extends React.Component {
849
851
  onClickKey: this.handleKeypadPress,
850
852
  cursorContext: this.state.cursorContext,
851
853
  convertDotToTimes: this.props.convertDotToTimes
852
- }, (_this$props$keypadBut = this.props.keypadButtonSets) != null ? _this$props$keypadBut : mapButtonSets((_this$props = this.props) == null ? void 0 : _this$props.buttonSets)))));
854
+ }, (_this$props$keypadBut = this.props.keypadButtonSets) != null ? _this$props$keypadBut : mapButtonSets((_this$props = this.props) == null ? void 0 : _this$props.buttonSets), {
855
+ showDismiss: true
856
+ }))));
853
857
  }
854
858
  }, this.props.buttonsVisible === "never" ? /*#__PURE__*/React.createElement(MathInputIcon, {
855
859
  hovered: false,
@@ -1003,7 +1007,6 @@ const styles$D = StyleSheet.create({
1003
1007
  },
1004
1008
  popoverContent: {
1005
1009
  padding: 0,
1006
- paddingBottom: spacing.xxSmall_6,
1007
1010
  maxWidth: "initial"
1008
1011
  }
1009
1012
  });
@@ -3021,6 +3024,7 @@ Zoom.prototype.zoomImage = function () {
3021
3024
  img.src = this._targetImage.src;
3022
3025
  img.alt = this._targetImage.alt;
3023
3026
  img.tabIndex = 0;
3027
+ img.role = "button";
3024
3028
  this.$zoomedImage = $zoomedImage;
3025
3029
  };
3026
3030
  Zoom.prototype._zoomOriginal = function () {
@@ -7980,6 +7984,7 @@ var createRoot;
7980
7984
  var m = ReactDOM__default;
7981
7985
  if (process.env.NODE_ENV === 'production') {
7982
7986
  createRoot = m.createRoot;
7987
+ m.hydrateRoot;
7983
7988
  } else {
7984
7989
  var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
7985
7990
  createRoot = function(c, o) {
@@ -15810,12 +15815,19 @@ class ImageLoader extends React.Component {
15810
15815
  };
15811
15816
  }
15812
15817
  const staticUrl = getDependencies().staticUrl;
15818
+
15819
+ // If the image is interactive, it should have a role of "button"
15820
+ // to indicate that it is interactive.
15821
+ const imageRole = imgProps.onClick !== null ? "button" : "img";
15813
15822
  return (
15814
15823
  /*#__PURE__*/
15815
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- TODO(LEMS-2871): Address a11y error
15824
+ // (LEMS-2871) NOTE: This image IS interactive if it requires zooming, and LevelAccess specifically requested
15825
+ // that the role and tabIndex be set here. When users interact with the image on mobile, it will zoom in.
15826
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
15816
15827
  React.createElement("img", _extends({
15817
15828
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- TODO(LEMS-2871): Address a11y error
15818
15829
  tabIndex: 0,
15830
+ role: imageRole,
15819
15831
  src: staticUrl(src),
15820
15832
  onKeyUp: onKeyUp,
15821
15833
  onKeyDown: onKeyDown
@@ -30372,15 +30384,14 @@ const hitboxSizePx = 48;
30372
30384
  // function with no state or effects) that renders the SVG for a movable point
30373
30385
  // on an interactive graph.
30374
30386
  const MovablePointView = /*#__PURE__*/forwardRef((props, hitboxRef) => {
30375
- var _Object$entries$find$, _Object$entries$find;
30376
30387
  const {
30377
30388
  markings,
30378
30389
  showTooltips,
30379
- interactiveColor
30390
+ interactiveColor,
30391
+ disableKeyboardInteraction
30380
30392
  } = useGraphConfig();
30381
30393
  const {
30382
30394
  point,
30383
- color: color$1 = interactiveColor,
30384
30395
  dragging,
30385
30396
  focused,
30386
30397
  cursor,
@@ -30388,9 +30399,14 @@ const MovablePointView = /*#__PURE__*/forwardRef((props, hitboxRef) => {
30388
30399
  onClick = () => {}
30389
30400
  } = props;
30390
30401
 
30391
- // WB Tooltip requires a color name for the background color.
30392
- // Since the color in props is a hex value, a reverse lookup is needed.
30393
- const wbColorName = (_Object$entries$find$ = (_Object$entries$find = Object.entries(color).find(([_, value]) => value === color$1)) == null ? void 0 : _Object$entries$find[0]) != null ? _Object$entries$find$ : "blue";
30402
+ // WB Tooltip requires a WB color name for the background color.
30403
+ // We use the blue color when the points are interactive, and
30404
+ // offBlack64 when they are disabled.
30405
+ // Note: The disabled point color is offBlack50 to contrast with
30406
+ // the interactive blue color, but the tooltip background has to be
30407
+ // darker to contrast with its white text - using offBlack64.
30408
+ const wbColorName = disableKeyboardInteraction ? "fadedOffBlack64" // not see-through
30409
+ : "blue";
30394
30410
  const pointClasses = classNames("movable-point", dragging && "movable-point--dragging", showFocusRing && "movable-point--focus");
30395
30411
  const [[x, y]] = useTransformVectorsToPixels(point);
30396
30412
  const showHairlines = (dragging || focused) && markings !== "none";
@@ -30403,7 +30419,7 @@ const MovablePointView = /*#__PURE__*/forwardRef((props, hitboxRef) => {
30403
30419
  ref: hitboxRef,
30404
30420
  className: pointClasses,
30405
30421
  style: {
30406
- "--movable-point-color": color$1,
30422
+ "--movable-point-color": interactiveColor,
30407
30423
  cursor
30408
30424
  },
30409
30425
  "data-testid": "movable-point",
@@ -30430,7 +30446,7 @@ const MovablePointView = /*#__PURE__*/forwardRef((props, hitboxRef) => {
30430
30446
  cx: x,
30431
30447
  cy: y,
30432
30448
  style: {
30433
- fill: color$1
30449
+ fill: interactiveColor
30434
30450
  },
30435
30451
  "data-testid": "movable-point__center"
30436
30452
  }));
@@ -30462,7 +30478,6 @@ function useControlPoint(params) {
30462
30478
  ariaDescribedBy,
30463
30479
  ariaLabel,
30464
30480
  ariaLive = "polite",
30465
- color,
30466
30481
  constrain = p => snap(snapStep, p),
30467
30482
  cursor,
30468
30483
  forwardedRef = noop$1,
@@ -30525,6 +30540,7 @@ function useControlPoint(params) {
30525
30540
  "aria-describedby": ariaDescribedBy,
30526
30541
  "aria-label": pointAriaLabel,
30527
30542
  "aria-live": ariaLive,
30543
+ "aria-disabled": disableKeyboardInteraction,
30528
30544
  onFocus: event => {
30529
30545
  onFocus(event);
30530
30546
  setFocused(true);
@@ -30544,7 +30560,6 @@ function useControlPoint(params) {
30544
30560
  point: point,
30545
30561
  dragging: dragging,
30546
30562
  focused: focused,
30547
- color: color,
30548
30563
  ref: visiblePointRef,
30549
30564
  showFocusRing: focused
30550
30565
  });
@@ -30688,6 +30703,7 @@ const Line$1 = props => {
30688
30703
  "aria-label": ariaLabel,
30689
30704
  "aria-describedby": ariaDescribedBy,
30690
30705
  "aria-live": ariaLive,
30706
+ "aria-disabled": disableKeyboardInteraction,
30691
30707
  className: "movable-line",
30692
30708
  "data-testid": "movable-line",
30693
30709
  style: {
@@ -31231,6 +31247,7 @@ function MovableCircle(props) {
31231
31247
  "aria-label": ariaLabel,
31232
31248
  "aria-describedby": ariaDescribedBy,
31233
31249
  "aria-live": "polite",
31250
+ "aria-disabled": disableKeyboardInteraction,
31234
31251
  ref: draggableRef,
31235
31252
  role: "button",
31236
31253
  tabIndex: disableKeyboardInteraction ? -1 : 0,
@@ -33107,7 +33124,8 @@ const LimitedPolygonGraph = statefulProps => {
33107
33124
  // Accessibility-related fields
33108
33125
  role: "button",
33109
33126
  "aria-label": srPolygonGraphPoints ? `${srPolygonElementsNum} ${srPolygonGraphPoints}` : srPolygonElementsNum,
33110
- "aria-live": ariaLives[0]
33127
+ "aria-live": ariaLives[0],
33128
+ "aria-disabled": disableKeyboardInteraction
33111
33129
  }
33112
33130
  }), points.map((point, i) => {
33113
33131
  const angleId = `${id}-angle-${i}`;
@@ -34391,7 +34409,7 @@ const MafsGraph = props => {
34391
34409
  handleKeyboardEvent(event, state, dispatch);
34392
34410
  },
34393
34411
  "aria-label": fullGraphAriaLabel,
34394
- "aria-describedby": describedByIds(fullGraphAriaDescription && descriptionId, interactiveElementsDescription && interactiveElementsDescriptionId, isUnlimitedGraphState(state) && unlimitedGraphKeyboardPromptId, state.type !== "none" && instructionsId),
34412
+ "aria-describedby": describedByIds(fullGraphAriaDescription && descriptionId, interactiveElementsDescription && interactiveElementsDescriptionId, isUnlimitedGraphState(state) && unlimitedGraphKeyboardPromptId, state.type !== "none" && !disableInteraction && instructionsId),
34395
34413
  ref: graphRef,
34396
34414
  tabIndex: 0,
34397
34415
  onFocus: event => {
@@ -41432,51 +41450,9 @@ const init = function init() {
41432
41450
  replaceDeprecatedWidgets();
41433
41451
  };
41434
41452
 
41435
- /**
41436
- * Adds the given perseus library version information to the __perseus_debug__
41437
- * object and ensures that the object is attached to `globalThis` (`window` in
41438
- * browser environments).
41439
- *
41440
- * This allows each library to provide runtime version information to assist in
41441
- * debugging in production environments.
41442
- */
41443
- const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
41444
- // If the library version is the default value, then we don't want to
41445
- // prefix it with a "v" to indicate that it is a version number.
41446
- let prefix = "v";
41447
- if (libraryVersion === "__lib_version__") {
41448
- prefix = "";
41449
- }
41450
- const formattedVersion = `${prefix}${libraryVersion}`;
41451
- if (typeof globalThis !== "undefined") {
41452
- var _globalThis$__perseus;
41453
- globalThis.__perseus_debug__ = (_globalThis$__perseus = globalThis.__perseus_debug__) != null ? _globalThis$__perseus : {};
41454
- const existingVersionEntry = globalThis.__perseus_debug__[libraryName];
41455
- if (existingVersionEntry) {
41456
- // If we already have an entry and it doesn't match the registered
41457
- // version, we morph the entry into an array and log a warning.
41458
- if (existingVersionEntry !== formattedVersion) {
41459
- // Existing entry might be an array already (oops, at least 2
41460
- // versions of the library already loaded!).
41461
- const allVersions = Array.isArray(existingVersionEntry) ? existingVersionEntry : [existingVersionEntry];
41462
- allVersions.push(formattedVersion);
41463
- globalThis.__perseus_debug__[libraryName] = allVersions;
41464
-
41465
- // eslint-disable-next-line no-console
41466
- console.warn(`Multiple versions of ${libraryName} loaded on this page: ${allVersions.sort().join(", ")}`);
41467
- }
41468
- } else {
41469
- globalThis.__perseus_debug__[libraryName] = formattedVersion;
41470
- }
41471
- } else {
41472
- // eslint-disable-next-line no-console
41473
- console.warn(`globalThis not found found (${formattedVersion})`);
41474
- }
41475
- };
41476
-
41477
41453
  // This file is processed by a Rollup plugin (replace) to inject the production
41478
41454
  const libName = "@khanacademy/perseus";
41479
- const libVersion = "57.2.1";
41455
+ const libVersion = "57.2.2";
41480
41456
  addLibraryVersionToPerseusDebug(libName, libVersion);
41481
41457
 
41482
41458
  const apiVersion = {