@khanacademy/perseus 43.0.1 → 43.1.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.
Files changed (33) hide show
  1. package/dist/components/number-input.d.ts +5 -3
  2. package/dist/components/text-input.d.ts +4 -2
  3. package/dist/es/index.js +433 -238
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.js +424 -229
  6. package/dist/index.js.map +1 -1
  7. package/dist/perseus-types.d.ts +14 -7
  8. package/dist/util/parse-perseus-json/general-purpose-parsers/defaulted.d.ts +1 -1
  9. package/dist/util/parse-perseus-json/general-purpose-parsers/index.d.ts +2 -0
  10. package/dist/util/parse-perseus-json/general-purpose-parsers/pipe-parsers.d.ts +7 -0
  11. package/dist/util/parse-perseus-json/general-purpose-parsers/pipe-parsers.typetest.d.ts +1 -0
  12. package/dist/util/parse-perseus-json/general-purpose-parsers/unknown.d.ts +2 -0
  13. package/dist/util/parse-perseus-json/perseus-parsers/images-map.d.ts +5 -0
  14. package/dist/util/parse-perseus-json/perseus-parsers/widget.d.ts +4 -0
  15. package/dist/validation.types.d.ts +14 -6
  16. package/dist/widgets/categorizer/categorizer.d.ts +2 -2
  17. package/dist/widgets/categorizer/score-categorizer.d.ts +2 -2
  18. package/dist/widgets/categorizer/validate-categorizer.d.ts +15 -0
  19. package/dist/widgets/dropdown/validate-dropdown.d.ts +10 -0
  20. package/dist/widgets/interactive-graphs/graphs/components/movable-point.d.ts +11 -7
  21. package/dist/widgets/interactive-graphs/graphs/components/use-control-point.d.ts +7 -3
  22. package/dist/widgets/interactive-graphs/types.d.ts +1 -0
  23. package/dist/widgets/matrix/matrix.d.ts +12 -5
  24. package/dist/widgets/measurer/measurer.d.ts +1 -1
  25. package/dist/widgets/orderer/validate-orderer.d.ts +12 -0
  26. package/dist/widgets/plotter/plotter.d.ts +2 -2
  27. package/dist/widgets/plotter/score-plotter.d.ts +2 -2
  28. package/dist/widgets/plotter/validate-plotter.d.ts +12 -0
  29. package/dist/widgets/radio/radio.d.ts +1 -1
  30. package/dist/widgets/radio/validate-radio.d.ts +14 -0
  31. package/dist/widgets/sorter/validate-sorter.d.ts +13 -0
  32. package/package.json +4 -4
  33. package/dist/util/parse-perseus-json/general-purpose-parsers/compose-parsers.d.ts +0 -2
@@ -82,7 +82,14 @@ export type PerseusItem = {
82
82
  question: PerseusRenderer;
83
83
  hints: ReadonlyArray<Hint>;
84
84
  answerArea: PerseusAnswerArea | null | undefined;
85
- itemDataVersion: Version;
85
+ /**
86
+ * The version of the item.
87
+ * @deprecated Not used.
88
+ */
89
+ itemDataVersion: any;
90
+ /**
91
+ * @deprecated Superseded by per-widget answers.
92
+ */
86
93
  answer: any;
87
94
  };
88
95
  /**
@@ -590,12 +597,12 @@ export type PerseusMatcherWidgetOptions = {
590
597
  };
591
598
  export type PerseusMatrixWidgetAnswers = ReadonlyArray<ReadonlyArray<number>>;
592
599
  export type PerseusMatrixWidgetOptions = {
593
- prefix: string;
594
- suffix: string;
600
+ prefix?: string | undefined;
601
+ suffix?: string | undefined;
595
602
  answers: PerseusMatrixWidgetAnswers;
596
- cursorPosition: ReadonlyArray<number>;
603
+ cursorPosition?: ReadonlyArray<number> | undefined;
597
604
  matrixBoardSize: ReadonlyArray<number>;
598
- static: boolean;
605
+ static?: boolean | undefined;
599
606
  };
600
607
  export type PerseusMeasurerWidgetOptions = {
601
608
  image: PerseusImageBackground;
@@ -651,8 +658,8 @@ export type PerseusOrdererWidgetOptions = {
651
658
  options: ReadonlyArray<PerseusRenderer>;
652
659
  correctOptions: ReadonlyArray<PerseusRenderer>;
653
660
  otherOptions: ReadonlyArray<PerseusRenderer>;
654
- height: string;
655
- layout: string;
661
+ height: "normal" | "auto";
662
+ layout: "horizontal" | "vertical";
656
663
  };
657
664
  export type PerseusPassageWidgetOptions = {
658
665
  footnotes: string;
@@ -1,2 +1,2 @@
1
1
  import type { Parser } from "../parser-types";
2
- export declare function defaulted<T, Default extends T | null | undefined>(parser: Parser<T>, fallback: (missingValue: null | undefined) => Default): Parser<T | Default>;
2
+ export declare function defaulted<T, Default>(parser: Parser<T>, fallback: (missingValue: null | undefined) => Default): Parser<T | Default>;
@@ -9,7 +9,9 @@ export * from "./number";
9
9
  export * from "./object";
10
10
  export * from "./optional";
11
11
  export * from "./pair";
12
+ export * from "./pipe-parsers";
12
13
  export * from "./record";
13
14
  export * from "./string";
14
15
  export * from "./trio";
15
16
  export * from "./union";
17
+ export * from "./unknown";
@@ -0,0 +1,7 @@
1
+ import type { Parser, PartialParser } from "../parser-types";
2
+ export declare function pipeParsers<T>(p: Parser<T>): ParserPipeline<T>;
3
+ export declare class ParserPipeline<T> {
4
+ readonly parser: Parser<T>;
5
+ constructor(parser: Parser<T>);
6
+ then<U>(nextParser: PartialParser<T, U>): ParserPipeline<U>;
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { Parser } from "../parser-types";
2
+ export declare const unknown: Parser<unknown>;
@@ -0,0 +1,5 @@
1
+ import type { PerseusImageDetail } from "../../../perseus-types";
2
+ import type { Parser } from "../parser-types";
3
+ export declare const parseImages: Parser<{
4
+ [key: string]: PerseusImageDetail;
5
+ }>;
@@ -1,3 +1,7 @@
1
1
  import type { WidgetOptions } from "../../../perseus-types";
2
2
  import type { Parser } from "../parser-types";
3
3
  export declare function parseWidget<Type extends string, Options>(parseType: Parser<Type>, parseOptions: Parser<Options>): Parser<WidgetOptions<Type, Options>>;
4
+ export declare function parseWidgetWithVersion<Version extends {
5
+ major: number;
6
+ minor: number;
7
+ } | undefined, Type extends string, Options>(parseVersion: Parser<Version>, parseType: Parser<Type>, parseOptions: Parser<Options>): Parser<WidgetOptions<Type, Options>>;
@@ -27,15 +27,18 @@
27
27
  * } & Perseus<Widget>ValidationData;
28
28
  * ```
29
29
  */
30
- import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType } from "./perseus-types";
30
+ import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType } from "./perseus-types";
31
31
  import type { InteractiveMarkerType } from "./widgets/label-image/types";
32
32
  import type { Relationship } from "./widgets/number-line/number-line";
33
33
  export type UserInputStatus = "correct" | "incorrect" | "incomplete";
34
- export type PerseusCategorizerRubric = {
34
+ export type PerseusCategorizerScoringData = {
35
35
  values: ReadonlyArray<number>;
36
- };
36
+ } & PerseusCategorizerValidationData;
37
37
  export type PerseusCategorizerUserInput = {
38
- values: PerseusCategorizerRubric["values"];
38
+ values: PerseusCategorizerScoringData["values"];
39
+ };
40
+ export type PerseusCategorizerValidationData = {
41
+ items: ReadonlyArray<string>;
39
42
  };
40
43
  export type PerseusCSProgramRubric = Empty;
41
44
  export type PerseusCSProgramUserInput = {
@@ -117,7 +120,12 @@ export type PerseusOrdererRubric = PerseusOrdererWidgetOptions;
117
120
  export type PerseusOrdererUserInput = {
118
121
  current: ReadonlyArray<string>;
119
122
  };
120
- export type PerseusPlotterRubric = PerseusPlotterWidgetOptions;
123
+ export type PerseusPlotterScoringData = {
124
+ correct: ReadonlyArray<number>;
125
+ } & PerseusPlotterValidationData;
126
+ export type PerseusPlotterValidationData = {
127
+ starting: ReadonlyArray<number>;
128
+ };
121
129
  export type PerseusPlotterUserInput = ReadonlyArray<number>;
122
130
  export type PerseusRadioRubric = {
123
131
  choices: ReadonlyArray<PerseusRadioChoice>;
@@ -136,7 +144,7 @@ export type PerseusTableRubric = {
136
144
  answers: ReadonlyArray<ReadonlyArray<string>>;
137
145
  };
138
146
  export type PerseusTableUserInput = ReadonlyArray<ReadonlyArray<string>>;
139
- export type Rubric = PerseusCategorizerRubric | PerseusCSProgramRubric | PerseusDropdownRubric | PerseusExpressionRubric | PerseusGroupRubric | PerseusGradedGroupRubric | PerseusGradedGroupSetRubric | PerseusGrapherRubric | PerseusIFrameRubric | PerseusInputNumberRubric | PerseusInteractiveGraphRubric | PerseusLabelImageRubric | PerseusMatcherRubric | PerseusMatrixRubric | PerseusNumberLineRubric | PerseusNumericInputRubric | PerseusOrdererRubric | PerseusPlotterRubric | PerseusRadioRubric | PerseusSorterRubric | PerseusTableRubric;
147
+ export type Rubric = PerseusCategorizerScoringData | PerseusCSProgramRubric | PerseusDropdownRubric | PerseusExpressionRubric | PerseusGroupRubric | PerseusGradedGroupRubric | PerseusGradedGroupSetRubric | PerseusGrapherRubric | PerseusIFrameRubric | PerseusInputNumberRubric | PerseusInteractiveGraphRubric | PerseusLabelImageRubric | PerseusMatcherRubric | PerseusMatrixRubric | PerseusNumberLineRubric | PerseusNumericInputRubric | PerseusOrdererRubric | PerseusPlotterScoringData | PerseusRadioRubric | PerseusSorterRubric | PerseusTableRubric;
140
148
  export type UserInput = PerseusCategorizerUserInput | PerseusCSProgramUserInput | PerseusDropdownUserInput | PerseusExpressionUserInput | PerseusGrapherUserInput | PerseusIFrameUserInput | PerseusInputNumberUserInput | PerseusInteractiveGraphUserInput | PerseusLabelImageUserInput | PerseusMatcherUserInput | PerseusMatrixUserInput | PerseusNumberLineUserInput | PerseusNumericInputUserInput | PerseusOrdererUserInput | PerseusPlotterUserInput | PerseusRadioUserInput | PerseusSorterUserInput | PerseusTableUserInput;
141
149
  export type UserInputMap = {
142
150
  [widgetId: string]: UserInput | UserInputMap;
@@ -3,9 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import scoreCategorizer from "./score-categorizer";
4
4
  import type { PerseusCategorizerWidgetOptions } from "../../perseus-types";
5
5
  import type { Widget, WidgetProps } from "../../types";
6
- import type { PerseusCategorizerRubric, PerseusCategorizerUserInput } from "../../validation.types";
6
+ import type { PerseusCategorizerScoringData, PerseusCategorizerUserInput } from "../../validation.types";
7
7
  import type { CategorizerPromptJSON } from "../../widget-ai-utils/categorizer/categorizer-ai-utils";
8
- type Props = WidgetProps<RenderProps, PerseusCategorizerRubric> & {
8
+ type Props = WidgetProps<RenderProps, PerseusCategorizerScoringData> & {
9
9
  values: ReadonlyArray<string>;
10
10
  };
11
11
  type DefaultProps = {
@@ -1,5 +1,5 @@
1
1
  import type { PerseusStrings } from "../../strings";
2
2
  import type { PerseusScore } from "../../types";
3
- import type { PerseusCategorizerRubric, PerseusCategorizerUserInput } from "../../validation.types";
4
- declare function scoreCategorizer(userInput: PerseusCategorizerUserInput, rubric: PerseusCategorizerRubric, strings: PerseusStrings): PerseusScore;
3
+ import type { PerseusCategorizerScoringData, PerseusCategorizerUserInput } from "../../validation.types";
4
+ declare function scoreCategorizer(userInput: PerseusCategorizerUserInput, scoringData: PerseusCategorizerScoringData, strings: PerseusStrings): PerseusScore;
5
5
  export default scoreCategorizer;
@@ -0,0 +1,15 @@
1
+ import type { PerseusStrings } from "../../strings";
2
+ import type { PerseusScore } from "../../types";
3
+ import type { PerseusCategorizerUserInput, PerseusCategorizerValidationData } from "../../validation.types";
4
+ /**
5
+ * Checks userInput from the categorizer widget to see if the user has selected
6
+ * a category for each item.
7
+ * @param userInput - The user's input corresponding to an array of indices that
8
+ * represent the selected category for each row/item.
9
+ * @param validationData - An array of strings corresponding to each row/item
10
+ * @param strings - Used to provide a validation message
11
+ */
12
+ declare function validateCategorizer(userInput: PerseusCategorizerUserInput, validationData: PerseusCategorizerValidationData, strings: PerseusStrings): Extract<PerseusScore, {
13
+ type: "invalid";
14
+ }> | null;
15
+ export default validateCategorizer;
@@ -0,0 +1,10 @@
1
+ import type { PerseusScore } from "../../types";
2
+ import type { PerseusDropdownUserInput } from "../../validation.types";
3
+ /**
4
+ * Checks if the user has selected an item from the dropdown before scoring.
5
+ * This is shown with a userInput value / index other than 0.
6
+ */
7
+ declare function validateDropdown(userInput: PerseusDropdownUserInput): Extract<PerseusScore, {
8
+ type: "invalid";
9
+ }> | null;
10
+ export default validateDropdown;
@@ -1,9 +1,16 @@
1
1
  import * as React from "react";
2
2
  import type { CSSCursor } from "./css-cursor";
3
+ import type { AriaLive } from "../../types";
3
4
  import type { KeyboardMovementConstraint } from "../use-draggable";
4
5
  import type { vec } from "mafs";
5
6
  type Props = {
6
7
  point: vec.Vector2;
8
+ ariaDescribedBy?: string;
9
+ ariaLabel?: string;
10
+ ariaLive?: AriaLive;
11
+ color?: string;
12
+ constrain?: KeyboardMovementConstraint;
13
+ cursor?: CSSCursor | undefined;
7
14
  /**
8
15
  * Represents where this point stands in the overall point sequence.
9
16
  * This is used to provide screen readers with context about the point.
@@ -12,14 +19,11 @@ type Props = {
12
19
  * Note: This number is 1-indexed, and should restart from 1 for each
13
20
  * interactive figure on the graph.
14
21
  */
15
- sequenceNumber: number;
16
- onMove?: (newPoint: vec.Vector2) => unknown;
22
+ sequenceNumber?: number;
23
+ onBlur?: (event: React.FocusEvent) => unknown;
17
24
  onClick?: () => unknown;
18
- color?: string;
19
- cursor?: CSSCursor | undefined;
20
- constrain?: KeyboardMovementConstraint;
21
- onFocus?: ((event: React.FocusEvent) => unknown) | undefined;
22
- onBlur?: ((event: React.FocusEvent) => unknown) | undefined;
25
+ onFocus?: (event: React.FocusEvent) => unknown;
26
+ onMove?: (newPoint: vec.Vector2) => unknown;
23
27
  };
24
28
  export declare const MovablePoint: React.ForwardRefExoticComponent<Props & React.RefAttributes<SVGGElement | null>>;
25
29
  export {};
@@ -1,11 +1,17 @@
1
1
  import * as React from "react";
2
2
  import type { CSSCursor } from "./css-cursor";
3
+ import type { AriaLive } from "../../types";
3
4
  import type { KeyboardMovementConstraint } from "../use-draggable";
4
5
  import type { vec } from "mafs";
5
6
  type Params = {
6
7
  point: vec.Vector2;
8
+ ariaDescribedBy?: string;
9
+ ariaLabel?: string;
10
+ ariaLive?: AriaLive;
7
11
  color?: string | undefined;
12
+ constrain?: KeyboardMovementConstraint;
8
13
  cursor?: CSSCursor | undefined;
14
+ forwardedRef?: React.ForwardedRef<SVGGElement | null> | undefined;
9
15
  /**
10
16
  * Represents where this point stands in the overall point sequence.
11
17
  * This is used to provide screen readers with context about the point.
@@ -14,13 +20,11 @@ type Params = {
14
20
  * Note: This number is 1-indexed, and should restart from 1 for each
15
21
  * interactive figure on the graph.
16
22
  */
17
- sequenceNumber: number;
18
- constrain?: KeyboardMovementConstraint;
23
+ sequenceNumber?: number;
19
24
  onMove?: ((newPoint: vec.Vector2) => unknown) | undefined;
20
25
  onClick?: (() => unknown) | undefined;
21
26
  onFocus?: ((event: React.FocusEvent) => unknown) | undefined;
22
27
  onBlur?: ((event: React.FocusEvent) => unknown) | undefined;
23
- forwardedRef?: React.ForwardedRef<SVGGElement | null> | undefined;
24
28
  };
25
29
  type Return = {
26
30
  focusableHandle: React.ReactNode;
@@ -90,3 +90,4 @@ export type GraphDimensions = {
90
90
  width: number;
91
91
  height: number;
92
92
  };
93
+ export type AriaLive = "off" | "assertive" | "polite" | undefined;
@@ -1,12 +1,19 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import scoreMatrix from "./score-matrix";
4
- import type { PerseusMatrixWidgetOptions } from "../../perseus-types";
4
+ import type { PerseusMatrixWidgetAnswers } from "../../perseus-types";
5
5
  import type { WidgetProps, Widget, FocusPath } from "../../types";
6
6
  import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
7
7
  import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
8
8
  export declare function getMatrixSize(matrix: ReadonlyArray<ReadonlyArray<number>>): number[];
9
- type ExternalProps = WidgetProps<PerseusMatrixWidgetOptions, PerseusMatrixRubric>;
9
+ type ExternalProps = WidgetProps<{
10
+ prefix: string;
11
+ suffix: string;
12
+ answers: PerseusMatrixWidgetAnswers;
13
+ cursorPosition: ReadonlyArray<number>;
14
+ matrixBoardSize: ReadonlyArray<number>;
15
+ static?: boolean | undefined;
16
+ }, PerseusMatrixRubric>;
10
17
  type Props = ExternalProps & {
11
18
  onChange: (arg1: {
12
19
  cursorPosition?: ReadonlyArray<number>;
@@ -17,9 +24,9 @@ type Props = ExternalProps & {
17
24
  type DefaultProps = {
18
25
  matrixBoardSize: Props["matrixBoardSize"];
19
26
  answers: Props["answers"];
20
- prefix: Props["prefix"];
21
- suffix: Props["suffix"];
22
- cursorPosition: Props["cursorPosition"];
27
+ prefix: string;
28
+ suffix: string;
29
+ cursorPosition: ReadonlyArray<number>;
23
30
  apiOptions: Props["apiOptions"];
24
31
  linterContext: Props["linterContext"];
25
32
  };
@@ -40,7 +40,7 @@ declare const _default: {
40
40
  minor: number;
41
41
  };
42
42
  propUpgrades: {
43
- readonly "1": (v0props: any) => any;
43
+ readonly "1": (v0props: any) => PerseusMeasurerWidgetOptions;
44
44
  };
45
45
  scorer: () => import("../../types").PerseusScore;
46
46
  };
@@ -0,0 +1,12 @@
1
+ import type { PerseusScore } from "../../types";
2
+ import type { PerseusOrdererUserInput } from "../../validation.types";
3
+ /**
4
+ * Checks user input from the orderer widget to see if the user has started
5
+ * ordering the options, making the widget scorable.
6
+ * @param userInput
7
+ * @see `scoreOrderer` for more details.
8
+ */
9
+ declare function validateOrderer(userInput: PerseusOrdererUserInput): Extract<PerseusScore, {
10
+ type: "invalid";
11
+ }> | null;
12
+ export default validateOrderer;
@@ -3,10 +3,10 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import scorePlotter from "./score-plotter";
4
4
  import type { PerseusPlotterWidgetOptions } from "../../perseus-types";
5
5
  import type { Widget, WidgetProps } from "../../types";
6
- import type { PerseusPlotterRubric, PerseusPlotterUserInput } from "../../validation.types";
6
+ import type { PerseusPlotterScoringData, PerseusPlotterUserInput } from "../../validation.types";
7
7
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
8
8
  type RenderProps = PerseusPlotterWidgetOptions;
9
- type Props = WidgetProps<RenderProps, PerseusPlotterRubric> & {
9
+ type Props = WidgetProps<RenderProps, PerseusPlotterScoringData> & {
10
10
  labelInterval: NonNullable<PerseusPlotterWidgetOptions["labelInterval"]>;
11
11
  picSize: NonNullable<PerseusPlotterWidgetOptions["picSize"]>;
12
12
  };
@@ -1,4 +1,4 @@
1
1
  import type { PerseusScore } from "../../types";
2
- import type { PerseusPlotterRubric, PerseusPlotterUserInput } from "../../validation.types";
3
- declare function scorePlotter(userInput: PerseusPlotterUserInput, rubric: PerseusPlotterRubric): PerseusScore;
2
+ import type { PerseusPlotterScoringData, PerseusPlotterUserInput } from "../../validation.types";
3
+ declare function scorePlotter(userInput: PerseusPlotterUserInput, scoringData: PerseusPlotterScoringData): PerseusScore;
4
4
  export default scorePlotter;
@@ -0,0 +1,12 @@
1
+ import type { PerseusScore } from "../../types";
2
+ import type { PerseusPlotterUserInput, PerseusPlotterValidationData } from "../../validation.types";
3
+ /**
4
+ * Checks user input to confirm it is not the same as the starting values for the graph.
5
+ * This means the user has modified the graph, and the question can be scored.
6
+ *
7
+ * @see 'scorePlotter' for more details on scoring.
8
+ */
9
+ declare function validatePlotter(userInput: PerseusPlotterUserInput, validationData: PerseusPlotterValidationData): Extract<PerseusScore, {
10
+ type: "invalid";
11
+ }> | null;
12
+ export default validatePlotter;
@@ -15,7 +15,7 @@ declare const _default: {
15
15
  minor: number;
16
16
  };
17
17
  propUpgrades: {
18
- readonly "1": (v0props: any) => any;
18
+ readonly "1": (v0props: any) => PerseusRadioWidgetOptions;
19
19
  };
20
20
  isLintable: true;
21
21
  scorer: typeof scoreRadio;
@@ -0,0 +1,14 @@
1
+ import type { PerseusScore } from "../../types";
2
+ import type { PerseusRadioUserInput } from "../../validation.types";
3
+ /**
4
+ * Checks if the user has selected at least one option. Additional validation
5
+ * is done in scoreRadio to check if the number of selected options is correct
6
+ * and if the user has selected both a correct option and the "none of the above"
7
+ * option.
8
+ * @param userInput
9
+ * @see `scoreRadio` for the additional validation logic and the scoring logic.
10
+ */
11
+ declare function validateRadio(userInput: PerseusRadioUserInput): Extract<PerseusScore, {
12
+ type: "invalid";
13
+ }> | null;
14
+ export default validateRadio;
@@ -0,0 +1,13 @@
1
+ import type { PerseusScore } from "../../types";
2
+ import type { PerseusSorterUserInput } from "../../validation.types";
3
+ /**
4
+ * Checks user input for the sorter widget to ensure that the user has made
5
+ * changes before attempting to score the widget.
6
+ * @param userInput
7
+ * @see 'scoreSorter' in 'packages/perseus/src/widgets/sorter/score-sorter.ts'
8
+ * for more details on how the sorter widget is scored.
9
+ */
10
+ declare function validateSorter(userInput: PerseusSorterUserInput): Extract<PerseusScore, {
11
+ type: "invalid";
12
+ }> | null;
13
+ export default validateSorter;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "43.0.1",
6
+ "version": "43.1.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -40,14 +40,14 @@
40
40
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
41
41
  },
42
42
  "dependencies": {
43
- "@khanacademy/kas": "^0.4.1",
43
+ "@khanacademy/kas": "^0.4.2",
44
44
  "@khanacademy/keypad-context": "^1.0.4",
45
45
  "@khanacademy/kmath": "^0.1.16",
46
46
  "@khanacademy/math-input": "^21.1.5",
47
47
  "@khanacademy/perseus-core": "1.5.3",
48
48
  "@khanacademy/perseus-linter": "^1.2.4",
49
- "@khanacademy/pure-markdown": "^0.3.12",
50
- "@khanacademy/simple-markdown": "^0.13.5",
49
+ "@khanacademy/pure-markdown": "^0.3.13",
50
+ "@khanacademy/simple-markdown": "^0.13.6",
51
51
  "@types/classnames": "2.2.0",
52
52
  "@use-gesture/react": "^10.2.27",
53
53
  "mafs": "0.19.0",
@@ -1,2 +0,0 @@
1
- import type { ParsedValue, PartialParser, Parser } from "../parser-types";
2
- export declare function composeParsers<A extends Parser<any>, B extends PartialParser<ParsedValue<A>, any>>(parserA: A, parserB: B): Parser<ParsedValue<B>>;