@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/es/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/es/index.js CHANGED
@@ -669,9 +669,11 @@ const styles$D = StyleSheet.create({
669
669
  borderRadius: 1
670
670
  },
671
671
  iconInactive: {
672
+ border: "2px solid transparent",
672
673
  backgroundColor: color.offBlack8
673
674
  },
674
675
  iconActive: {
676
+ border: `2px solid ${color.white}`,
675
677
  backgroundColor: color.offBlack64
676
678
  },
677
679
  outerWrapper: {
@@ -764,7 +766,7 @@ const denylist = [
764
766
  // (technically the renderer still adds them)
765
767
  "key", "ref",
766
768
  // added by src/renderer.jsx
767
- "containerSizeClass", "widgetId", "onChange", "problemNum", "apiOptions", "questionCompleted", "findWidgets", "hintMode",
769
+ "containerSizeClass", "widgetId", "onChange", "problemNum", "apiOptions", "questionCompleted", "findWidgets",
768
770
  // added by src/editor.jsx, for widgets removing themselves
769
771
  // this is soooo not the right place for this, but alas.
770
772
  "onRemove",
@@ -18970,7 +18972,7 @@ const {
18970
18972
  // Note: these size cutoffs represent content-width cutoffs as specified in
18971
18973
  // http://zpl.io/1mVmvU (broken link - we no longer use Zeplin)
18972
18974
  // TODO(benkomalo): these values aren't used in JS outside of this file, but
18973
- // are coupled to the values in styles/articles.less - DRY it up at some point
18975
+ // are coupled to the values in styles/styles.less - DRY it up at some point
18974
18976
  const smMax = articleMaxWidthTableInPx;
18975
18977
  const mdMax = articleMaxWidthInPx;
18976
18978
  const containerSizeClass = {
@@ -19761,9 +19763,7 @@ class Renderer extends React.Component {
19761
19763
  return _extends({}, widgetProps, {
19762
19764
  widgetId: id,
19763
19765
  alignment: widgetInfo && widgetInfo.alignment,
19764
- // When determining if a widget is static, we verify that the widget is not an
19765
- // exercise question by verifying that it has no problem number.
19766
- static: widgetInfo && widgetInfo.static && !this.props.problemNum,
19766
+ static: widgetInfo == null ? void 0 : widgetInfo.static,
19767
19767
  problemNum: this.props.problemNum,
19768
19768
  apiOptions: this.getApiOptions(),
19769
19769
  keypadElement: this.props.keypadElement,
@@ -19773,7 +19773,6 @@ class Renderer extends React.Component {
19773
19773
  onBlur: _.partial(this._onWidgetBlur, id),
19774
19774
  findWidgets: this.findWidgets,
19775
19775
  reviewModeRubric: reviewModeRubric,
19776
- hintMode: this.props.hintMode,
19777
19776
  onChange: (newProps, cb, silent = false) => {
19778
19777
  this._setWidgetProps(id, newProps, cb, silent);
19779
19778
  },
@@ -20148,7 +20147,7 @@ class Renderer extends React.Component {
20148
20147
  }
20149
20148
  // Widgets can contain text nodes, so we don't center them with
20150
20149
  // markdown magic here.
20151
- // Instead, we center them with css magic in articles.less
20150
+ // Instead, we center them with css magic in styles.less
20152
20151
  // /cry(aria)
20153
20152
  this._foundTextNodes = true;
20154
20153
  if (_.contains(this.widgetIds, node.id)) {
@@ -20976,7 +20975,6 @@ Renderer.defaultProps = {
20976
20975
  findExternalWidgets: () => [],
20977
20976
  alwaysUpdate: false,
20978
20977
  reviewMode: false,
20979
- hintMode: false,
20980
20978
  serializedState: null,
20981
20979
  onSerializedStateUpdated: () => {},
20982
20980
  linterContext: PerseusLinter.linterContextDefault
@@ -21052,28 +21050,24 @@ class TextInput extends React.Component {
21052
21050
  style
21053
21051
  } = this.props;
21054
21052
  const formattedValue = value === null ? "" : value.toString();
21055
- return (
21056
- /*#__PURE__*/
21057
- // $FlowIgnore
21058
- React.createElement(TextField, {
21059
- style: style,
21060
- disabled: disabled,
21061
- id: this.id,
21062
- value: formattedValue,
21063
- type: "text",
21064
- "aria-label": labelText,
21065
- onChange: value => this.props.onChange(value),
21066
- placeholder: placeholder,
21067
- onFocus: onFocus,
21068
- onBlur: onBlur,
21069
- onKeyDown: onKeyDown
21070
- // @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>'.
21071
- ,
21072
- autoCorrect: "off",
21073
- autoCapitalize: "off",
21074
- autoComplete: "off"
21075
- })
21076
- );
21053
+ return /*#__PURE__*/React.createElement(TextField, {
21054
+ style: style,
21055
+ disabled: disabled,
21056
+ id: this.id,
21057
+ value: formattedValue,
21058
+ type: "text",
21059
+ "aria-label": labelText,
21060
+ onChange: value => this.props.onChange(value),
21061
+ placeholder: placeholder,
21062
+ onFocus: onFocus,
21063
+ onBlur: onBlur,
21064
+ onKeyDown: onKeyDown
21065
+ // @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>'.
21066
+ ,
21067
+ autoCorrect: "off",
21068
+ autoCapitalize: "off",
21069
+ autoComplete: "off"
21070
+ });
21077
21071
  }
21078
21072
  }
21079
21073
  TextInput.defaultProps = {
@@ -22598,7 +22592,7 @@ var sharedStyles = StyleSheet.create({
22598
22592
  },
22599
22593
  responsiveLabel: {
22600
22594
  // NOTE(charlie): The values used here should be kept in sync with the
22601
- // caption text sizing in Perseus' articles.less.
22595
+ // caption text sizing in Perseus' styles.less.
22602
22596
  // TODO(charlie): Migrate the captions over to using this style.
22603
22597
  [mediaQueries.smOrSmaller]: {
22604
22598
  fontSize: 14,
@@ -26917,7 +26911,7 @@ const propTransform$2 = editorProps => {
26917
26911
 
26918
26912
  // Note that in addition to the standard staticTransform, in static
26919
26913
  // mode we set static=true for the graph's handles in FunctionGrapher.
26920
- const staticTransform$3 = editorProps => {
26914
+ const staticTransform$4 = editorProps => {
26921
26915
  return _extends({}, propTransform$2(editorProps), {
26922
26916
  // Don't display graph type choices if we're in static mode
26923
26917
  availableTypes: [editorProps.correct.type],
@@ -26930,7 +26924,7 @@ var Grapher$1 = {
26930
26924
  displayName: "Grapher",
26931
26925
  widget: Grapher,
26932
26926
  transform: propTransform$2,
26933
- staticTransform: staticTransform$3
26927
+ staticTransform: staticTransform$4
26934
26928
  };
26935
26929
 
26936
26930
  // exports has no 'transform'
@@ -31870,7 +31864,6 @@ const MafsGraph = props => {
31870
31864
  state,
31871
31865
  dispatch,
31872
31866
  labels,
31873
- hintMode,
31874
31867
  readOnly
31875
31868
  } = props;
31876
31869
  const [width, height] = props.box;
@@ -31887,7 +31880,7 @@ const MafsGraph = props => {
31887
31880
  width,
31888
31881
  height,
31889
31882
  labels,
31890
- disableKeyboardInteraction: hintMode || readOnly
31883
+ disableKeyboardInteraction: readOnly || !!props.static
31891
31884
  }
31892
31885
  }, /*#__PURE__*/React.createElement(View, {
31893
31886
  className: "mafs-graph",
@@ -31899,7 +31892,7 @@ const MafsGraph = props => {
31899
31892
  boxSizing: "content-box",
31900
31893
  marginLeft: "20px",
31901
31894
  marginBottom: "20px",
31902
- pointerEvents: hintMode ? "none" : "auto"
31895
+ pointerEvents: props.static ? "none" : "auto"
31903
31896
  }
31904
31897
  }, /*#__PURE__*/React.createElement(LegacyGrid, {
31905
31898
  box: props.box,
@@ -33015,6 +33008,17 @@ const StatefulMafsGraph = /*#__PURE__*/React.forwardRef((props, ref) => {
33015
33008
  dispatch(reinitialize(latestPropsRef.current));
33016
33009
  }
33017
33010
  }, [graph.type, numPoints, numSegments, numSides, snapTo, showAngles, showSides, latestPropsRef, graph.startCoords]);
33011
+
33012
+ // If the graph is static, it always displays the correct answer. This is
33013
+ // standard behavior for Perseus widgets (e.g. compare the Radio widget).
33014
+ if (props.static) {
33015
+ return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, props, {
33016
+ state: initializeGraphState(_extends({}, props, {
33017
+ graph: props.correct
33018
+ })),
33019
+ dispatch: dispatch
33020
+ }));
33021
+ }
33018
33022
  return /*#__PURE__*/React.createElement(MafsGraph, _extends({}, props, {
33019
33023
  state: state,
33020
33024
  dispatch: dispatch
@@ -34334,7 +34338,6 @@ class InteractiveGraph extends React.Component {
34334
34338
  snapStep: snapStep,
34335
34339
  box: box,
34336
34340
  showTooltips: !!this.props.showTooltips,
34337
- hintMode: this.props.hintMode,
34338
34341
  readOnly: (_this$props$apiOption2 = this.props.apiOptions) == null ? void 0 : _this$props$apiOption2.readOnly
34339
34342
  }));
34340
34343
  }
@@ -34924,10 +34927,13 @@ function shouldUseMafs(mafsFlags, graph) {
34924
34927
  return Boolean(mafsFlags[graph.type]);
34925
34928
  }
34926
34929
  }
34930
+ // We don't need to change any of the original props for static mode
34931
+ const staticTransform$3 = _.identity;
34927
34932
  var InteractiveGraph$1 = {
34928
34933
  name: "interactive-graph",
34929
34934
  displayName: "Interactive graph",
34930
- widget: InteractiveGraph
34935
+ widget: InteractiveGraph,
34936
+ staticTransform: staticTransform$3
34931
34937
  };
34932
34938
 
34933
34939
  const black = "#000000";
@@ -44254,7 +44260,7 @@ const init = function init(options) {
44254
44260
 
44255
44261
  // This file is processed by a Rollup plugin (replace) to inject the production
44256
44262
  const libName = "@khanacademy/perseus";
44257
- const libVersion = "28.0.0";
44263
+ const libVersion = "28.2.0";
44258
44264
  addLibraryVersionToPerseusDebug(libName, libVersion);
44259
44265
 
44260
44266
  const apiVersion = {
@@ -44496,7 +44502,6 @@ class HintRenderer extends React.Component {
44496
44502
  // eslint-disable-next-line react/no-string-refs
44497
44503
  , {
44498
44504
  ref: "renderer",
44499
- hintMode: true,
44500
44505
  widgets: hint.widgets,
44501
44506
  content: hint.content || "",
44502
44507
  images: hint.images,