@khanacademy/perseus-editor 14.8.1 → 14.9.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.
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- export type CheckboxProps = {
2
+ type CheckboxProps = {
3
3
  checked: boolean;
4
4
  disabled?: boolean;
5
5
  appearDisabled?: boolean;
@@ -18,3 +18,4 @@ export default class Checkbox extends React.Component<CheckboxProps> {
18
18
  };
19
19
  render(): React.ReactNode;
20
20
  }
21
+ export {};
@@ -1,18 +1,15 @@
1
1
  import * as React from "react";
2
- export type OptionRenderer = (children: React.ReactElement<any> | null | undefined, value: string, selected: boolean, disabled?: boolean) => React.ReactElement<any>;
3
2
  type Props = {
4
3
  value: string;
5
4
  children?: React.ReactNode;
6
5
  selected?: boolean;
7
6
  disabled?: boolean;
8
7
  onClick?: () => void;
9
- optionRenderer?: OptionRenderer;
10
8
  onDropdownClose?: () => void;
11
9
  hideFocusState?: boolean;
12
10
  testId?: string;
13
11
  ariaLabel?: string;
14
12
  };
15
- export declare const optionHeight = 30;
16
13
  declare class Option extends React.Component<Props> {
17
14
  node: HTMLDivElement;
18
15
  handleKeyDown(event: any): void;
@@ -22,7 +19,6 @@ declare class OptionGroup extends React.Component<{
22
19
  onSelected: (value: string) => void;
23
20
  children?: Array<React.ReactElement<React.ComponentProps<typeof Option>>>;
24
21
  selectedValues: Array<string>;
25
- optionRenderer?: OptionRenderer;
26
22
  noMargin?: boolean;
27
23
  onDropdownClose?: () => void;
28
24
  hideFocusState?: boolean;
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import CombinedHintsEditor from "./hint-editor";
3
3
  import ItemEditor from "./item-editor";
4
4
  import type { APIOptions, APIOptionsWithDefaults, ChangeHandler, DeviceType, Hint, ImageUploader, Version, PerseusItem } from "@khanacademy/perseus";
5
- import type { KEScore } from "@khanacademy/perseus-core";
6
5
  type Props = {
7
6
  apiOptions?: APIOptions;
8
7
  answerArea?: any;
@@ -51,7 +50,6 @@ declare class EditorPage extends React.Component<Props, State> {
51
50
  }): any | PerseusItem;
52
51
  handleChange: ChangeHandler;
53
52
  changeJSON: (newJson: PerseusItem) => void;
54
- scorePreview(): KEScore | null | undefined;
55
53
  render(): React.ReactNode;
56
54
  }
57
55
  export default EditorPage;
package/dist/es/index.js CHANGED
@@ -46,7 +46,7 @@ import arrowCounterClockwise from '@phosphor-icons/core/bold/arrow-counter-clock
46
46
 
47
47
  // This file is processed by a Rollup plugin (replace) to inject the production
48
48
  const libName = "@khanacademy/perseus-editor";
49
- const libVersion = "14.8.1";
49
+ const libVersion = "14.9.1";
50
50
  addLibraryVersionToPerseusDebug(libName, libVersion);
51
51
 
52
52
  function _extends() {
@@ -24285,13 +24285,6 @@ class EditorPage extends React.Component {
24285
24285
  hints: (_this$hintsEditor$cur2 = this.hintsEditor.current) == null ? void 0 : _this$hintsEditor$cur2.serialize(options)
24286
24286
  });
24287
24287
  }
24288
- scorePreview() {
24289
- // Do we actually ever set this.renderer anywhere in the codebase?
24290
- if (this.renderer) {
24291
- return this.renderer.scoreInput();
24292
- }
24293
- return null;
24294
- }
24295
24288
  render() {
24296
24289
  let className = "framework-perseus";
24297
24290
  const touch = this.props.previewDevice === "phone" || this.props.previewDevice === "tablet";
@@ -25617,10 +25610,6 @@ const StatefulEditorPage = createReactClass({
25617
25610
  this.setState(newState, cb);
25618
25611
  }
25619
25612
  },
25620
- scorePreview: function () {
25621
- // eslint-disable-next-line react/no-string-refs
25622
- return this.refs.editor.scorePreview();
25623
- },
25624
25613
  render: function () {
25625
25614
  const Component = this.props.componentClass;
25626
25615
  return /*#__PURE__*/React.createElement(Component, this.state);
@@ -30969,6 +30958,22 @@ function getDefaultFigureForType(type) {
30969
30958
  throw new UnreachableCaseError(type);
30970
30959
  }
30971
30960
  }
30961
+ function generateLockedFigureAppearanceDescription(color, strokeStyle = "solid", fill) {
30962
+ const convertedColor = color === "grayH" ? "gray" : color;
30963
+ switch (fill) {
30964
+ case "none":
30965
+ return `. Appearance ${strokeStyle} ${convertedColor} border, with no fill.`;
30966
+ case "white":
30967
+ return `. Appearance ${strokeStyle} ${convertedColor} border, with a white fill.`;
30968
+ case "solid":
30969
+ case "translucent":
30970
+ return `. Appearance ${strokeStyle} ${convertedColor} border, with a ${fill} ${convertedColor} fill.`;
30971
+ case undefined:
30972
+ return `. Appearance ${strokeStyle} ${convertedColor}.`;
30973
+ default:
30974
+ throw new UnreachableCaseError(fill);
30975
+ }
30976
+ }
30972
30977
 
30973
30978
  const {
30974
30979
  InfoTip: InfoTip$c
@@ -30994,7 +30999,7 @@ const LockedEllipseSettings = props => {
30994
30999
  function getPrepopulatedAriaLabel() {
30995
31000
  let visiblelabel = "";
30996
31001
  if (labels && labels.length > 0) {
30997
- visiblelabel += ` ${labels.map(l => l.text).join(" ")}`;
31002
+ visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
30998
31003
  }
30999
31004
  const isCircle = radius[0] === radius[1];
31000
31005
  let str = "";
@@ -31007,6 +31012,8 @@ const LockedEllipseSettings = props => {
31007
31012
  if (!isCircle && angle !== 0) {
31008
31013
  str += `, rotated by ${radianToDegree(angle)} degrees`;
31009
31014
  }
31015
+ const ellipseAppearance = generateLockedFigureAppearanceDescription(color, strokeStyle, fillStyle);
31016
+ str += ellipseAppearance;
31010
31017
  return str;
31011
31018
  }
31012
31019
  function handleCenterChange(newCoord) {
@@ -31263,6 +31270,8 @@ const LockedFunctionSettings = props => {
31263
31270
  if (domain && !(domain[0] === -Infinity && domain[1] === Infinity)) {
31264
31271
  str += `, domain from ${domain[0]} to ${domain[1]}`;
31265
31272
  }
31273
+ const functionAppearance = generateLockedFigureAppearanceDescription(lineColor, strokeStyle);
31274
+ str += functionAppearance;
31266
31275
  return str;
31267
31276
  }
31268
31277
 
@@ -31689,7 +31698,9 @@ const LockedPointSettings = props => {
31689
31698
  if (labels && labels.length > 0) {
31690
31699
  visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
31691
31700
  }
31692
- const str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
31701
+ let str = `Point${visiblelabel} at (${coord[0]}, ${coord[1]})`;
31702
+ const pointAppearance = generateLockedFigureAppearanceDescription(pointColor);
31703
+ str += pointAppearance;
31693
31704
  return str;
31694
31705
  }
31695
31706
  function handleColorChange(newValue) {
@@ -31890,7 +31901,9 @@ const LockedLineSettings = props => {
31890
31901
  if (labels && labels.length > 0) {
31891
31902
  visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
31892
31903
  }
31893
- const str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
31904
+ let str = `${capitalizeKind}${visiblelabel} from (${point1.coord[0]}, ${point1.coord[1]}) to (${point2.coord[0]}, ${point2.coord[1]})`;
31905
+ const lineAppearance = generateLockedFigureAppearanceDescription(lineColor, lineStyle);
31906
+ str += lineAppearance;
31894
31907
  return str;
31895
31908
  }
31896
31909
  function handleChangePoint(newPointProps, index) {
@@ -32156,6 +32169,8 @@ const LockedPolygonSettings = props => {
32156
32169
 
32157
32170
  // Add the coordinates of each point to the aria label
32158
32171
  str += points.map(([x, y]) => `(${x}, ${y})`).join(", ");
32172
+ const polygonAppearance = generateLockedFigureAppearanceDescription(color, strokeStyle, fillStyle);
32173
+ str += polygonAppearance;
32159
32174
  return str;
32160
32175
  }
32161
32176
  function handleColorChange(newValue) {
@@ -32471,7 +32486,9 @@ const LockedVectorSettings = props => {
32471
32486
  if (labels && labels.length > 0) {
32472
32487
  visiblelabel += ` ${labels.map(l => l.text).join(", ")}`;
32473
32488
  }
32474
- const str = `Vector${visiblelabel} from (${tail[0]}, ${tail[1]}) to (${tip[0]}, ${tip[1]})`;
32489
+ let str = `Vector${visiblelabel} from (${tail[0]}, ${tail[1]}) to (${tip[0]}, ${tip[1]})`;
32490
+ const vectorAppearance = generateLockedFigureAppearanceDescription(lineColor);
32491
+ str += vectorAppearance;
32475
32492
  return str;
32476
32493
  }
32477
32494
  function handleChangePoint(newCoord, index) {
@@ -34701,7 +34718,6 @@ class Option extends React.Component {
34701
34718
  value,
34702
34719
  onClick,
34703
34720
  children,
34704
- optionRenderer,
34705
34721
  disabled,
34706
34722
  hideFocusState,
34707
34723
  testId,
@@ -34728,14 +34744,7 @@ class Option extends React.Component {
34728
34744
  "aria-disabled": disabled,
34729
34745
  "aria-label": ariaLabel,
34730
34746
  "data-testid": testId
34731
- }, optionRenderer && optionRenderer(
34732
- /*#__PURE__*/
34733
- /**
34734
- * This expects a `React.Element<>` but `children` is a
34735
- * `React.Node`. We can convert a `React.Node` to a
34736
- * `React.Element<>` by wrapping it in a fragment.
34737
- */
34738
- React.createElement(React.Fragment, null, children), value || "", selected || false, disabled), !optionRenderer && /*#__PURE__*/React.createElement("span", {
34747
+ }, /*#__PURE__*/React.createElement("span", {
34739
34748
  className: css(styles$4.option, selected && styles$4.optionSelected, disabled && styles$4.optionDisabled)
34740
34749
  }, children, selected && /*#__PURE__*/React.createElement("span", {
34741
34750
  className: css(styles$4.check)
@@ -34765,7 +34774,6 @@ class OptionGroup extends React.Component {
34765
34774
  children,
34766
34775
  onSelected,
34767
34776
  selectedValues,
34768
- optionRenderer,
34769
34777
  noMargin,
34770
34778
  onDropdownClose,
34771
34779
  hideFocusState
@@ -34787,7 +34795,6 @@ class OptionGroup extends React.Component {
34787
34795
  selected: selected,
34788
34796
  // @ts-expect-error - TS2532 - Object is possibly 'undefined'.
34789
34797
  onClick: () => onSelected(child.props.value),
34790
- optionRenderer: optionRenderer,
34791
34798
  ref: reference,
34792
34799
  onDropdownClose: onDropdownClose,
34793
34800
  hideFocusState: hideFocusState
@@ -37423,6 +37430,7 @@ class RadioEditor extends React.Component {
37423
37430
  editMode: true,
37424
37431
  labelWrap: false,
37425
37432
  apiOptions: this.props.apiOptions,
37433
+ reviewMode: false,
37426
37434
  choices: this.props.choices.map((choice, i) => {
37427
37435
  return {
37428
37436
  content: /*#__PURE__*/React.createElement(ChoiceEditor, {