@khanacademy/perseus 28.0.0 → 28.2.0

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
@@ -1500,7 +1500,6 @@ body.mobile ul.inequalities-one-line-radios > li {
1500
1500
  .perseus-clearfix:after {
1501
1501
  clear: both;
1502
1502
  }
1503
- /* Fall back colors? Eg educator, talks & interviews */
1504
1503
  .framework-perseus code {
1505
1504
  font-family: Courier, monospace;
1506
1505
  }
@@ -2418,7 +2417,7 @@ img.zoom-img {
2418
2417
  width: 40px;
2419
2418
  }
2420
2419
  .framework-perseus .number-input.invalid-input {
2421
- background-color: #cf5044;
2420
+ background-color: #ffbaba;
2422
2421
  outline-color: red;
2423
2422
  }
2424
2423
  .framework-perseus .number-input.mini {
@@ -2604,7 +2603,7 @@ img.zoom-img {
2604
2603
  z-index: 2;
2605
2604
  }
2606
2605
  body.mobile .categorizer-container td.category input[type="radio"]:checked + span:before {
2607
- color: #005a88;
2606
+ color: #1c758a;
2608
2607
  }
2609
2608
  body.mobile .categorizer-container td.category input[type="radio"] + span:active:before {
2610
2609
  color: #666;
@@ -2677,7 +2676,7 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
2677
2676
  margin-left: 0;
2678
2677
  }
2679
2678
  .framework-perseus .perseus-graded-group.answer-incorrect {
2680
- border-left: 3px solid #b2392e;
2679
+ border-left: 3px solid #ff8787;
2681
2680
  margin-left: 0;
2682
2681
  }
2683
2682
  .framework-perseus .perseus-graded-group .group-icon {
@@ -3490,7 +3489,7 @@ body.mobile .framework-perseus table.perseus-widget-table-of-values.non-markdown
3490
3489
  background-color: #fcc;
3491
3490
  }
3492
3491
  .perseus-error {
3493
- background: #cf5044;
3492
+ background: #ffbaba;
3494
3493
  border: 2px solid red;
3495
3494
  border-radius: 5px;
3496
3495
  padding: 20px;
package/dist/index.d.ts CHANGED
@@ -87,7 +87,7 @@ export type { ILogger, LogErrorOptions } from "./logging/log";
87
87
  export type { ServerItemRenderer as ServerItemRendererComponent } from "./server-item-renderer";
88
88
  export type { Alignment, APIOptions, APIOptionsWithDefaults, ChangeHandler, DeviceType, DomInsertCheckFn, EditorMode, FocusPath, ImageDict, ImageUploader, JiptLabelStore, JiptRenderer, PerseusDependencies, PerseusScore, Version, VideoData, VideoKind, WidgetDict, WidgetExports, } from "./types";
89
89
  export type { ParsedValue } from "./util";
90
- export type { Hint, LockedFigure, LockedFigureColor, LockedFigureFillType, LockedFigureType, LockedPointType, LockedLineType, LockedVectorType, LockedEllipseType, LockedPolygonType, LockedFunctionType, PerseusGraphType, PerseusAnswerArea, PerseusExpressionWidgetOptions, Range, Size, CollinearTuple, MathFormat, InputNumberWidget, // TODO(jeremy): remove?
90
+ export type { Hint, LegacyButtonSets, LockedFigure, LockedFigureColor, LockedFigureFillType, LockedFigureType, LockedPointType, LockedLineType, LockedVectorType, LockedEllipseType, LockedPolygonType, LockedFunctionType, PerseusGraphType, PerseusAnswerArea, PerseusExpressionWidgetOptions, Range, Size, CollinearTuple, MathFormat, InputNumberWidget, // TODO(jeremy): remove?
91
91
  PerseusImageBackground, PerseusInputNumberWidgetOptions, PerseusInteractiveGraphWidgetOptions, PerseusItem, PerseusPlotterWidgetOptions, PerseusPythonProgramWidgetOptions, PerseusRadioWidgetOptions, PerseusExampleWidgetOptions, PerseusExampleGraphieWidgetOptions, PerseusSimpleMarkdownTesterWidgetOptions, PerseusRenderer, PerseusWidget, PerseusWidgetsMap, } from "./perseus-types";
92
92
  export type { Coord } from "./interactive2/types";
93
93
  export type { MarkerType } from "./widgets/label-image/types";
package/dist/index.js CHANGED
@@ -772,9 +772,11 @@ const styles$D = aphrodite.StyleSheet.create({
772
772
  borderRadius: 1
773
773
  },
774
774
  iconInactive: {
775
+ border: "2px solid transparent",
775
776
  backgroundColor: wonderBlocksTokens.color.offBlack8
776
777
  },
777
778
  iconActive: {
779
+ border: `2px solid ${wonderBlocksTokens.color.white}`,
778
780
  backgroundColor: wonderBlocksTokens.color.offBlack64
779
781
  },
780
782
  outerWrapper: {
@@ -867,7 +869,7 @@ const denylist = [
867
869
  // (technically the renderer still adds them)
868
870
  "key", "ref",
869
871
  // added by src/renderer.jsx
870
- "containerSizeClass", "widgetId", "onChange", "problemNum", "apiOptions", "questionCompleted", "findWidgets", "hintMode",
872
+ "containerSizeClass", "widgetId", "onChange", "problemNum", "apiOptions", "questionCompleted", "findWidgets",
871
873
  // added by src/editor.jsx, for widgets removing themselves
872
874
  // this is soooo not the right place for this, but alas.
873
875
  "onRemove",
@@ -19149,7 +19151,7 @@ const {
19149
19151
  // Note: these size cutoffs represent content-width cutoffs as specified in
19150
19152
  // http://zpl.io/1mVmvU (broken link - we no longer use Zeplin)
19151
19153
  // TODO(benkomalo): these values aren't used in JS outside of this file, but
19152
- // are coupled to the values in styles/articles.less - DRY it up at some point
19154
+ // are coupled to the values in styles/styles.less - DRY it up at some point
19153
19155
  const smMax = articleMaxWidthTableInPx;
19154
19156
  const mdMax = articleMaxWidthInPx;
19155
19157
  const containerSizeClass = {
@@ -19830,7 +19832,6 @@ class Renderer extends React__namespace.Component {
19830
19832
  findExternalWidgets: () => [],
19831
19833
  alwaysUpdate: false,
19832
19834
  reviewMode: false,
19833
- hintMode: false,
19834
19835
  serializedState: null,
19835
19836
  onSerializedStateUpdated: () => {},
19836
19837
  linterContext: PerseusLinter__namespace.linterContextDefault
@@ -20109,9 +20110,7 @@ class Renderer extends React__namespace.Component {
20109
20110
  ...widgetProps,
20110
20111
  widgetId: id,
20111
20112
  alignment: widgetInfo && widgetInfo.alignment,
20112
- // When determining if a widget is static, we verify that the widget is not an
20113
- // exercise question by verifying that it has no problem number.
20114
- static: widgetInfo && widgetInfo.static && !this.props.problemNum,
20113
+ static: widgetInfo?.static,
20115
20114
  problemNum: this.props.problemNum,
20116
20115
  apiOptions: this.getApiOptions(),
20117
20116
  keypadElement: this.props.keypadElement,
@@ -20121,7 +20120,6 @@ class Renderer extends React__namespace.Component {
20121
20120
  onBlur: ___default["default"].partial(this._onWidgetBlur, id),
20122
20121
  findWidgets: this.findWidgets,
20123
20122
  reviewModeRubric: reviewModeRubric,
20124
- hintMode: this.props.hintMode,
20125
20123
  onChange: function (newProps, cb) {
20126
20124
  let silent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
20127
20125
  _this._setWidgetProps(id, newProps, cb, silent);
@@ -20509,7 +20507,7 @@ class Renderer extends React__namespace.Component {
20509
20507
  }
20510
20508
  // Widgets can contain text nodes, so we don't center them with
20511
20509
  // markdown magic here.
20512
- // Instead, we center them with css magic in articles.less
20510
+ // Instead, we center them with css magic in styles.less
20513
20511
  // /cry(aria)
20514
20512
  this._foundTextNodes = true;
20515
20513
  if (___default["default"].contains(this.widgetIds, node.id)) {
@@ -21265,28 +21263,24 @@ class TextInput extends React__namespace.Component {
21265
21263
  style
21266
21264
  } = this.props;
21267
21265
  const formattedValue = value === null ? "" : value.toString();
21268
- return (
21269
- /*#__PURE__*/
21270
- // $FlowIgnore
21271
- React__namespace.createElement(wonderBlocksForm.TextField, {
21272
- style: style,
21273
- disabled: disabled,
21274
- id: this.id,
21275
- value: formattedValue,
21276
- type: "text",
21277
- "aria-label": labelText,
21278
- onChange: value => this.props.onChange(value),
21279
- placeholder: placeholder,
21280
- onFocus: onFocus,
21281
- onBlur: onBlur,
21282
- onKeyDown: onKeyDown
21283
- // @ts-expect-error - TS2322 - Type '{ style: StyleType; disabled: boolean | undefined; id: string; value: string; type: "text"; "aria-label": string | undefined; onChange: (value: string) => void; placeholder: string | undefined; ... 5 more ...; autoComplete: string; }' is not assignable to type 'IntrinsicAttributes & ExportProps & RefAttributes<HTMLInputElement>'.
21284
- ,
21285
- autoCorrect: "off",
21286
- autoCapitalize: "off",
21287
- autoComplete: "off"
21288
- })
21289
- );
21266
+ return /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, {
21267
+ style: style,
21268
+ disabled: disabled,
21269
+ id: this.id,
21270
+ value: formattedValue,
21271
+ type: "text",
21272
+ "aria-label": labelText,
21273
+ onChange: value => this.props.onChange(value),
21274
+ placeholder: placeholder,
21275
+ onFocus: onFocus,
21276
+ onBlur: onBlur,
21277
+ onKeyDown: onKeyDown
21278
+ // @ts-expect-error - TS2322 - Type '{ style: StyleType; disabled: boolean | undefined; id: string; value: string; type: "text"; "aria-label": string | undefined; onChange: (value: string) => void; placeholder: string | undefined; ... 5 more ...; autoComplete: string; }' is not assignable to type 'IntrinsicAttributes & ExportProps & RefAttributes<HTMLInputElement>'.
21279
+ ,
21280
+ autoCorrect: "off",
21281
+ autoCapitalize: "off",
21282
+ autoComplete: "off"
21283
+ });
21290
21284
  }
21291
21285
  focus = () => {
21292
21286
  // @ts-expect-error - TS2531 - Object is possibly 'null'. | TS2339 - Property 'focus' does not exist on type 'Element | Text'.
@@ -22813,7 +22807,7 @@ var sharedStyles = aphrodite.StyleSheet.create({
22813
22807
  },
22814
22808
  responsiveLabel: {
22815
22809
  // NOTE(charlie): The values used here should be kept in sync with the
22816
- // caption text sizing in Perseus' articles.less.
22810
+ // caption text sizing in Perseus' styles.less.
22817
22811
  // TODO(charlie): Migrate the captions over to using this style.
22818
22812
  [mediaQueries.smOrSmaller]: {
22819
22813
  fontSize: 14,
@@ -27188,7 +27182,7 @@ const propTransform$2 = editorProps => {
27188
27182
 
27189
27183
  // Note that in addition to the standard staticTransform, in static
27190
27184
  // mode we set static=true for the graph's handles in FunctionGrapher.
27191
- const staticTransform$3 = editorProps => {
27185
+ const staticTransform$4 = editorProps => {
27192
27186
  return {
27193
27187
  ...propTransform$2(editorProps),
27194
27188
  // Don't display graph type choices if we're in static mode
@@ -27202,7 +27196,7 @@ var Grapher$1 = {
27202
27196
  displayName: "Grapher",
27203
27197
  widget: Grapher,
27204
27198
  transform: propTransform$2,
27205
- staticTransform: staticTransform$3
27199
+ staticTransform: staticTransform$4
27206
27200
  };
27207
27201
 
27208
27202
  // exports has no 'transform'
@@ -32197,7 +32191,6 @@ const MafsGraph = props => {
32197
32191
  state,
32198
32192
  dispatch,
32199
32193
  labels,
32200
- hintMode,
32201
32194
  readOnly
32202
32195
  } = props;
32203
32196
  const [width, height] = props.box;
@@ -32214,7 +32207,7 @@ const MafsGraph = props => {
32214
32207
  width,
32215
32208
  height,
32216
32209
  labels,
32217
- disableKeyboardInteraction: hintMode || readOnly
32210
+ disableKeyboardInteraction: readOnly || !!props.static
32218
32211
  }
32219
32212
  }, /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
32220
32213
  className: "mafs-graph",
@@ -32226,7 +32219,7 @@ const MafsGraph = props => {
32226
32219
  boxSizing: "content-box",
32227
32220
  marginLeft: "20px",
32228
32221
  marginBottom: "20px",
32229
- pointerEvents: hintMode ? "none" : "auto"
32222
+ pointerEvents: props.static ? "none" : "auto"
32230
32223
  }
32231
32224
  }, /*#__PURE__*/React__namespace.createElement(LegacyGrid, {
32232
32225
  box: props.box,
@@ -33379,6 +33372,18 @@ const StatefulMafsGraph = /*#__PURE__*/React__namespace.forwardRef((props, ref)
33379
33372
  dispatch(reinitialize(latestPropsRef.current));
33380
33373
  }
33381
33374
  }, [graph.type, numPoints, numSegments, numSides, snapTo, showAngles, showSides, latestPropsRef, graph.startCoords]);
33375
+
33376
+ // If the graph is static, it always displays the correct answer. This is
33377
+ // standard behavior for Perseus widgets (e.g. compare the Radio widget).
33378
+ if (props.static) {
33379
+ return /*#__PURE__*/React__namespace.createElement(MafsGraph, _extends({}, props, {
33380
+ state: initializeGraphState({
33381
+ ...props,
33382
+ graph: props.correct
33383
+ }),
33384
+ dispatch: dispatch
33385
+ }));
33386
+ }
33382
33387
  return /*#__PURE__*/React__namespace.createElement(MafsGraph, _extends({}, props, {
33383
33388
  state: state,
33384
33389
  dispatch: dispatch
@@ -34682,7 +34687,6 @@ class InteractiveGraph extends React__namespace.Component {
34682
34687
  snapStep: snapStep,
34683
34688
  box: box,
34684
34689
  showTooltips: !!this.props.showTooltips,
34685
- hintMode: this.props.hintMode,
34686
34690
  readOnly: this.props.apiOptions?.readOnly
34687
34691
  }));
34688
34692
  }
@@ -35258,10 +35262,13 @@ function shouldUseMafs(mafsFlags, graph) {
35258
35262
  return Boolean(mafsFlags[graph.type]);
35259
35263
  }
35260
35264
  }
35265
+ // We don't need to change any of the original props for static mode
35266
+ const staticTransform$3 = ___default["default"].identity;
35261
35267
  var InteractiveGraph$1 = {
35262
35268
  name: "interactive-graph",
35263
35269
  displayName: "Interactive graph",
35264
- widget: InteractiveGraph
35270
+ widget: InteractiveGraph,
35271
+ staticTransform: staticTransform$3
35265
35272
  };
35266
35273
 
35267
35274
  const black = "#000000";
@@ -44605,7 +44612,7 @@ const init = function (options) {
44605
44612
 
44606
44613
  // This file is processed by a Rollup plugin (replace) to inject the production
44607
44614
  const libName = "@khanacademy/perseus";
44608
- const libVersion = "28.0.0";
44615
+ const libVersion = "28.2.0";
44609
44616
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
44610
44617
 
44611
44618
  const apiVersion = {
@@ -44853,7 +44860,6 @@ class HintRenderer extends React__namespace.Component {
44853
44860
  // eslint-disable-next-line react/no-string-refs
44854
44861
  , {
44855
44862
  ref: "renderer",
44856
- hintMode: true,
44857
44863
  widgets: hint.widgets,
44858
44864
  content: hint.content || "",
44859
44865
  images: hint.images,