@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/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/index.js CHANGED
@@ -45,6 +45,7 @@ var reactPopper = require('react-popper');
45
45
  var IconButton = require('@khanacademy/wonder-blocks-icon-button');
46
46
  var cornersOutIcon = require('@phosphor-icons/core/regular/corners-out.svg');
47
47
  var Link = require('@khanacademy/wonder-blocks-link');
48
+ var perseusUtils = require('@khanacademy/perseus-utils');
48
49
 
49
50
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
50
51
 
@@ -1069,9 +1070,12 @@ class InnerMathInput extends React__namespace.Component {
1069
1070
  // a keyboard event is "keydown" type.
1070
1071
  // In react without WonderBlocks, "enter" or "space" keydown events
1071
1072
  // are also "click" events, differentiated by "detail".
1072
- if (e.type === "click") {
1073
+ if (e?.type === "click") {
1073
1074
  this.focus();
1074
1075
  }
1076
+ if (key === "DISMISS") {
1077
+ this.closeKeypad();
1078
+ }
1075
1079
  };
1076
1080
  render() {
1077
1081
  let className = classNames__default["default"]({
@@ -1111,17 +1115,15 @@ class InnerMathInput extends React__namespace.Component {
1111
1115
  onFocus: () => this.focus(),
1112
1116
  onBlur: () => this.blur()
1113
1117
  }), /*#__PURE__*/React__namespace.createElement(wonderBlocksPopover.Popover, {
1114
- rootBoundary: "document",
1115
1118
  opened: this.state.keypadOpen,
1116
- onClose: () => this.closeKeypad(),
1117
1119
  dismissEnabled: true,
1120
+ rootBoundary: "document",
1118
1121
  "aria-label": this.context.strings.mathInputTitle,
1119
1122
  "aria-describedby": `popover-content-${popoverContentUniqueId}`,
1120
1123
  content: () => /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.HeadingMedium, {
1121
1124
  id: `popover-content-${popoverContentUniqueId}`,
1122
1125
  style: a11y.srOnly
1123
1126
  }, this.context.strings.mathInputDescription), /*#__PURE__*/React__namespace.createElement(wonderBlocksPopover.PopoverContentCore, {
1124
- closeButtonVisible: true,
1125
1127
  style: styles$D.popoverContent
1126
1128
  }, /*#__PURE__*/React__namespace.createElement(mathInput.DesktopKeypad, _extends__default["default"]({
1127
1129
  onAnalyticsEvent: this.props.onAnalyticsEvent,
@@ -1129,7 +1131,9 @@ class InnerMathInput extends React__namespace.Component {
1129
1131
  onClickKey: this.handleKeypadPress,
1130
1132
  cursorContext: this.state.cursorContext,
1131
1133
  convertDotToTimes: this.props.convertDotToTimes
1132
- }, this.props.keypadButtonSets ?? mapButtonSets(this.props?.buttonSets)))))
1134
+ }, this.props.keypadButtonSets ?? mapButtonSets(this.props?.buttonSets), {
1135
+ showDismiss: true
1136
+ }))))
1133
1137
  }, this.props.buttonsVisible === "never" ? /*#__PURE__*/React__namespace.createElement(MathInputIcon, {
1134
1138
  hovered: false,
1135
1139
  focused: false,
@@ -1272,7 +1276,6 @@ const styles$D = aphrodite.StyleSheet.create({
1272
1276
  },
1273
1277
  popoverContent: {
1274
1278
  padding: 0,
1275
- paddingBottom: wonderBlocksTokens.spacing.xxSmall_6,
1276
1279
  maxWidth: "initial"
1277
1280
  }
1278
1281
  });
@@ -3275,6 +3278,7 @@ Zoom.prototype.zoomImage = function () {
3275
3278
  img.src = this._targetImage.src;
3276
3279
  img.alt = this._targetImage.alt;
3277
3280
  img.tabIndex = 0;
3281
+ img.role = "button";
3278
3282
  this.$zoomedImage = $zoomedImage;
3279
3283
  };
3280
3284
  Zoom.prototype._zoomOriginal = function () {
@@ -8244,6 +8248,7 @@ var createRoot;
8244
8248
  var m = ReactDOM__default["default"];
8245
8249
  if (process.env.NODE_ENV === 'production') {
8246
8250
  createRoot = m.createRoot;
8251
+ m.hydrateRoot;
8247
8252
  } else {
8248
8253
  var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
8249
8254
  createRoot = function(c, o) {
@@ -16147,12 +16152,19 @@ class ImageLoader extends React__namespace.Component {
16147
16152
  };
16148
16153
  }
16149
16154
  const staticUrl = getDependencies().staticUrl;
16155
+
16156
+ // If the image is interactive, it should have a role of "button"
16157
+ // to indicate that it is interactive.
16158
+ const imageRole = imgProps.onClick !== null ? "button" : "img";
16150
16159
  return (
16151
16160
  /*#__PURE__*/
16152
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- TODO(LEMS-2871): Address a11y error
16161
+ // (LEMS-2871) NOTE: This image IS interactive if it requires zooming, and LevelAccess specifically requested
16162
+ // that the role and tabIndex be set here. When users interact with the image on mobile, it will zoom in.
16163
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
16153
16164
  React__namespace.createElement("img", _extends__default["default"]({
16154
16165
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- TODO(LEMS-2871): Address a11y error
16155
16166
  tabIndex: 0,
16167
+ role: imageRole,
16156
16168
  src: staticUrl(src),
16157
16169
  onKeyUp: onKeyUp,
16158
16170
  onKeyDown: onKeyDown
@@ -30845,11 +30857,11 @@ const MovablePointView = /*#__PURE__*/React.forwardRef((props, hitboxRef) => {
30845
30857
  const {
30846
30858
  markings,
30847
30859
  showTooltips,
30848
- interactiveColor
30860
+ interactiveColor,
30861
+ disableKeyboardInteraction
30849
30862
  } = useGraphConfig();
30850
30863
  const {
30851
30864
  point,
30852
- color = interactiveColor,
30853
30865
  dragging,
30854
30866
  focused,
30855
30867
  cursor,
@@ -30857,12 +30869,14 @@ const MovablePointView = /*#__PURE__*/React.forwardRef((props, hitboxRef) => {
30857
30869
  onClick = () => {}
30858
30870
  } = props;
30859
30871
 
30860
- // WB Tooltip requires a color name for the background color.
30861
- // Since the color in props is a hex value, a reverse lookup is needed.
30862
- const wbColorName = Object.entries(wonderBlocksTokens.color).find(_ref => {
30863
- let [_, value] = _ref;
30864
- return value === color;
30865
- })?.[0] ?? "blue";
30872
+ // WB Tooltip requires a WB color name for the background color.
30873
+ // We use the blue color when the points are interactive, and
30874
+ // offBlack64 when they are disabled.
30875
+ // Note: The disabled point color is offBlack50 to contrast with
30876
+ // the interactive blue color, but the tooltip background has to be
30877
+ // darker to contrast with its white text - using offBlack64.
30878
+ const wbColorName = disableKeyboardInteraction ? "fadedOffBlack64" // not see-through
30879
+ : "blue";
30866
30880
  const pointClasses = classNames("movable-point", dragging && "movable-point--dragging", showFocusRing && "movable-point--focus");
30867
30881
  const [[x, y]] = useTransformVectorsToPixels(point);
30868
30882
  const showHairlines = (dragging || focused) && markings !== "none";
@@ -30875,7 +30889,7 @@ const MovablePointView = /*#__PURE__*/React.forwardRef((props, hitboxRef) => {
30875
30889
  ref: hitboxRef,
30876
30890
  className: pointClasses,
30877
30891
  style: {
30878
- "--movable-point-color": color,
30892
+ "--movable-point-color": interactiveColor,
30879
30893
  cursor
30880
30894
  },
30881
30895
  "data-testid": "movable-point",
@@ -30902,7 +30916,7 @@ const MovablePointView = /*#__PURE__*/React.forwardRef((props, hitboxRef) => {
30902
30916
  cx: x,
30903
30917
  cy: y,
30904
30918
  style: {
30905
- fill: color
30919
+ fill: interactiveColor
30906
30920
  },
30907
30921
  "data-testid": "movable-point__center"
30908
30922
  }));
@@ -30937,7 +30951,6 @@ function useControlPoint(params) {
30937
30951
  ariaDescribedBy,
30938
30952
  ariaLabel,
30939
30953
  ariaLive = "polite",
30940
- color,
30941
30954
  constrain = p => snap(snapStep, p),
30942
30955
  cursor,
30943
30956
  forwardedRef = noop$1,
@@ -30999,6 +31012,7 @@ function useControlPoint(params) {
30999
31012
  "aria-describedby": ariaDescribedBy,
31000
31013
  "aria-label": pointAriaLabel,
31001
31014
  "aria-live": ariaLive,
31015
+ "aria-disabled": disableKeyboardInteraction,
31002
31016
  onFocus: event => {
31003
31017
  onFocus(event);
31004
31018
  setFocused(true);
@@ -31017,7 +31031,6 @@ function useControlPoint(params) {
31017
31031
  point: point,
31018
31032
  dragging: dragging,
31019
31033
  focused: focused,
31020
- color: color,
31021
31034
  ref: visiblePointRef,
31022
31035
  showFocusRing: focused
31023
31036
  });
@@ -31161,6 +31174,7 @@ const Line$1 = props => {
31161
31174
  "aria-label": ariaLabel,
31162
31175
  "aria-describedby": ariaDescribedBy,
31163
31176
  "aria-live": ariaLive,
31177
+ "aria-disabled": disableKeyboardInteraction,
31164
31178
  className: "movable-line",
31165
31179
  "data-testid": "movable-line",
31166
31180
  style: {
@@ -31719,6 +31733,7 @@ function MovableCircle(props) {
31719
31733
  "aria-label": ariaLabel,
31720
31734
  "aria-describedby": ariaDescribedBy,
31721
31735
  "aria-live": "polite",
31736
+ "aria-disabled": disableKeyboardInteraction,
31722
31737
  ref: draggableRef,
31723
31738
  role: "button",
31724
31739
  tabIndex: disableKeyboardInteraction ? -1 : 0,
@@ -33648,7 +33663,8 @@ const LimitedPolygonGraph = statefulProps => {
33648
33663
  // Accessibility-related fields
33649
33664
  role: "button",
33650
33665
  "aria-label": srPolygonGraphPoints ? `${srPolygonElementsNum} ${srPolygonGraphPoints}` : srPolygonElementsNum,
33651
- "aria-live": ariaLives[0]
33666
+ "aria-live": ariaLives[0],
33667
+ "aria-disabled": disableKeyboardInteraction
33652
33668
  }
33653
33669
  }), points.map((point, i) => {
33654
33670
  const angleId = `${id}-angle-${i}`;
@@ -34938,7 +34954,7 @@ const MafsGraph = props => {
34938
34954
  handleKeyboardEvent(event, state, dispatch);
34939
34955
  },
34940
34956
  "aria-label": fullGraphAriaLabel,
34941
- "aria-describedby": describedByIds(fullGraphAriaDescription && descriptionId, interactiveElementsDescription && interactiveElementsDescriptionId, isUnlimitedGraphState(state) && unlimitedGraphKeyboardPromptId, state.type !== "none" && instructionsId),
34957
+ "aria-describedby": describedByIds(fullGraphAriaDescription && descriptionId, interactiveElementsDescription && interactiveElementsDescriptionId, isUnlimitedGraphState(state) && unlimitedGraphKeyboardPromptId, state.type !== "none" && !disableInteraction && instructionsId),
34942
34958
  ref: graphRef,
34943
34959
  tabIndex: 0,
34944
34960
  onFocus: event => {
@@ -41996,51 +42012,10 @@ const init = function () {
41996
42012
  replaceDeprecatedWidgets();
41997
42013
  };
41998
42014
 
41999
- /**
42000
- * Adds the given perseus library version information to the __perseus_debug__
42001
- * object and ensures that the object is attached to `globalThis` (`window` in
42002
- * browser environments).
42003
- *
42004
- * This allows each library to provide runtime version information to assist in
42005
- * debugging in production environments.
42006
- */
42007
- const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
42008
- // If the library version is the default value, then we don't want to
42009
- // prefix it with a "v" to indicate that it is a version number.
42010
- let prefix = "v";
42011
- if (libraryVersion === "__lib_version__") {
42012
- prefix = "";
42013
- }
42014
- const formattedVersion = `${prefix}${libraryVersion}`;
42015
- if (typeof globalThis !== "undefined") {
42016
- globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};
42017
- const existingVersionEntry = globalThis.__perseus_debug__[libraryName];
42018
- if (existingVersionEntry) {
42019
- // If we already have an entry and it doesn't match the registered
42020
- // version, we morph the entry into an array and log a warning.
42021
- if (existingVersionEntry !== formattedVersion) {
42022
- // Existing entry might be an array already (oops, at least 2
42023
- // versions of the library already loaded!).
42024
- const allVersions = Array.isArray(existingVersionEntry) ? existingVersionEntry : [existingVersionEntry];
42025
- allVersions.push(formattedVersion);
42026
- globalThis.__perseus_debug__[libraryName] = allVersions;
42027
-
42028
- // eslint-disable-next-line no-console
42029
- console.warn(`Multiple versions of ${libraryName} loaded on this page: ${allVersions.sort().join(", ")}`);
42030
- }
42031
- } else {
42032
- globalThis.__perseus_debug__[libraryName] = formattedVersion;
42033
- }
42034
- } else {
42035
- // eslint-disable-next-line no-console
42036
- console.warn(`globalThis not found found (${formattedVersion})`);
42037
- }
42038
- };
42039
-
42040
42015
  // This file is processed by a Rollup plugin (replace) to inject the production
42041
42016
  const libName = "@khanacademy/perseus";
42042
- const libVersion = "57.2.1";
42043
- addLibraryVersionToPerseusDebug(libName, libVersion);
42017
+ const libVersion = "57.2.2";
42018
+ perseusUtils.addLibraryVersionToPerseusDebug(libName, libVersion);
42044
42019
 
42045
42020
  const apiVersion = {
42046
42021
  major: 12,