@khanacademy/perseus-editor 2.3.3 → 2.3.5

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.
@@ -3,7 +3,7 @@ import * as React from "react";
3
3
  declare class ExpressionEditor extends React.Component<any, any> {
4
4
  static propTypes: {
5
5
  answerForms: PropTypes.Requireable<(PropTypes.InferProps<{
6
- considered: PropTypes.Validator<string>;
6
+ considered: PropTypes.Validator<NonNullable<"correct" | "wrong" | "ungraded">>;
7
7
  value: PropTypes.Validator<string>;
8
8
  form: PropTypes.Validator<boolean>;
9
9
  simplify: PropTypes.Validator<boolean>;
@@ -10,7 +10,9 @@ declare class ExpressionEditor extends React.Component<any, any> {
10
10
  static propTypes: {|
11
11
  answerForms: PropTypes.Requireable<
12
12
  (PropTypes.InferProps<{|
13
- considered: PropTypes.Validator<string>,
13
+ considered: PropTypes.Validator<
14
+ $NonMaybeType<"correct" | "wrong" | "ungraded">
15
+ >,
14
16
  value: PropTypes.Validator<string>,
15
17
  form: PropTypes.Validator<boolean>,
16
18
  simplify: PropTypes.Validator<boolean>,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus editors",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "2.3.3",
6
+ "version": "2.3.5",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@khanacademy/kas": "^0.3.1",
25
25
  "@khanacademy/kmath": "^0.1.1",
26
- "@khanacademy/perseus": "^6.3.2"
26
+ "@khanacademy/perseus": "^6.4.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@khanacademy/wonder-blocks-button": "^4.0.8",
@@ -5,6 +5,7 @@ import {
5
5
  Changeable,
6
6
  Dependencies,
7
7
  Expression,
8
+ PerseusExpressionAnswerFormConsidered,
8
9
  } from "@khanacademy/perseus";
9
10
  // eslint-disable-next-line import/no-extraneous-dependencies
10
11
  import lens from "hubble";
@@ -17,11 +18,9 @@ import SortableArea from "../components/sortable";
17
18
  const {InfoTip, PropCheckBox, TexButtons} = components;
18
19
  const {getDependencies} = Dependencies;
19
20
 
20
- // An answer can be considered correct, wrong, or ungraded.
21
- const CONSIDERED = ["correct", "wrong", "ungraded"];
22
-
23
21
  const answerFormType = PropTypes.shape({
24
- considered: PropTypes.oneOf(CONSIDERED).isRequired,
22
+ considered: PropTypes.oneOf(PerseusExpressionAnswerFormConsidered)
23
+ .isRequired,
25
24
  value: PropTypes.string.isRequired,
26
25
  form: PropTypes.bool.isRequired,
27
26
  simplify: PropTypes.bool.isRequired,
@@ -433,8 +432,8 @@ class ExpressionEditor extends React.Component<any, any> {
433
432
  }
434
433
 
435
434
  // Find the next element in arr after val, wrapping around to the first.
436
- const findNextIn = function (arr: Array<string>, val: any) {
437
- let ix = _(arr).indexOf(val);
435
+ const findNextIn = function (arr: ReadonlyArray<string>, val: any) {
436
+ let ix = arr.indexOf(val);
438
437
  ix = (ix + 1) % arr.length;
439
438
  return arr[ix];
440
439
  };
@@ -442,7 +441,8 @@ const findNextIn = function (arr: Array<string>, val: any) {
442
441
  class AnswerOption extends React.Component<any, any> {
443
442
  static propTypes = {
444
443
  ...Changeable.propTypes,
445
- considered: PropTypes.oneOf(CONSIDERED).isRequired,
444
+ considered: PropTypes.oneOf(PerseusExpressionAnswerFormConsidered)
445
+ .isRequired,
446
446
  expressionProps: PropTypes.object.isRequired,
447
447
 
448
448
  // Must the answer have the same form as this answer.
@@ -560,7 +560,10 @@ class AnswerOption extends React.Component<any, any> {
560
560
  };
561
561
 
562
562
  toggleConsidered = () => {
563
- const newVal = findNextIn(CONSIDERED, this.props.considered);
563
+ const newVal = findNextIn(
564
+ PerseusExpressionAnswerFormConsidered,
565
+ this.props.considered,
566
+ );
564
567
  this.change({considered: newVal});
565
568
  };
566
569
  }