@khanacademy/perseus 34.1.0 → 35.0.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 (65) hide show
  1. package/dist/es/index.js +374 -380
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/strings.js +8 -2
  4. package/dist/es/strings.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +286 -302
  7. package/dist/index.js.map +1 -1
  8. package/dist/mixins/widget-prop-denylist.d.ts +0 -1
  9. package/dist/perseus-api.d.ts +3 -5
  10. package/dist/perseus-types.d.ts +6 -19
  11. package/dist/renderer.d.ts +4 -4
  12. package/dist/server-item-renderer.d.ts +3 -9
  13. package/dist/strings.d.ts +3 -0
  14. package/dist/strings.js +8 -2
  15. package/dist/strings.js.map +1 -1
  16. package/dist/types.d.ts +1 -3
  17. package/dist/validation.types.d.ts +111 -0
  18. package/dist/widgets/categorizer/categorizer-validator.d.ts +2 -2
  19. package/dist/widgets/categorizer/categorizer.d.ts +6 -6
  20. package/dist/widgets/cs-program/cs-program.d.ts +4 -9
  21. package/dist/widgets/definition/definition.d.ts +3 -4
  22. package/dist/widgets/dropdown/dropdown-validator.d.ts +2 -2
  23. package/dist/widgets/dropdown/dropdown.d.ts +5 -5
  24. package/dist/widgets/explanation/explanation.d.ts +3 -2
  25. package/dist/widgets/expression/expression-validator.d.ts +2 -2
  26. package/dist/widgets/expression/expression.d.ts +32 -26
  27. package/dist/widgets/expression/expression.types.d.ts +0 -1
  28. package/dist/widgets/graded-group/graded-group.d.ts +2 -2
  29. package/dist/widgets/graded-group-set/graded-group-set.d.ts +2 -2
  30. package/dist/widgets/grapher/grapher.d.ts +6 -7
  31. package/dist/widgets/group/group.d.ts +3 -2
  32. package/dist/widgets/iframe/iframe.d.ts +4 -9
  33. package/dist/widgets/image/image.d.ts +3 -4
  34. package/dist/widgets/input-number/input-number-validator.d.ts +3 -3
  35. package/dist/widgets/input-number/input-number.d.ts +7 -10
  36. package/dist/widgets/interaction/interaction.d.ts +3 -3
  37. package/dist/widgets/interactive-graph.d.ts +9 -12
  38. package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +8 -2
  39. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +5 -2
  40. package/dist/widgets/label-image/label-image-validator.d.ts +10 -0
  41. package/dist/widgets/label-image/label-image.d.ts +11 -10
  42. package/dist/widgets/label-image/types.d.ts +0 -4
  43. package/dist/widgets/matcher/matcher.d.ts +4 -4
  44. package/dist/widgets/matrix/matrix.d.ts +5 -5
  45. package/dist/widgets/molecule/molecule.d.ts +2 -1
  46. package/dist/widgets/number-line/number-line.d.ts +5 -3
  47. package/dist/widgets/numeric-input/numeric-input-validator.d.ts +2 -2
  48. package/dist/widgets/numeric-input/numeric-input.d.ts +7 -7
  49. package/dist/widgets/orderer/orderer.d.ts +4 -4
  50. package/dist/widgets/passage/passage.d.ts +3 -4
  51. package/dist/widgets/passage-ref/passage-ref.d.ts +3 -11
  52. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +2 -1
  53. package/dist/widgets/phet-simulation/phet-simulation.d.ts +2 -2
  54. package/dist/widgets/plotter/plotter.d.ts +5 -5
  55. package/dist/widgets/radio/radio-component.d.ts +6 -13
  56. package/dist/widgets/radio/radio-validator.d.ts +5 -0
  57. package/dist/widgets/sorter/sorter-validator.d.ts +4 -0
  58. package/dist/widgets/sorter/sorter.d.ts +7 -9
  59. package/dist/widgets/table/table.d.ts +5 -5
  60. package/dist/widgets/video/video.d.ts +2 -2
  61. package/package.json +1 -1
  62. package/dist/widgets/categorizer/categorizer.types.d.ts +0 -5
  63. package/dist/widgets/dropdown/dropdown.types.d.ts +0 -5
  64. package/dist/widgets/input-number/input-number.types.d.ts +0 -2
  65. package/dist/widgets/numeric-input/numeric-input.types.d.ts +0 -5
@@ -1,11 +1,13 @@
1
+ import { vec } from "mafs";
1
2
  import type { Coord } from "../../interactive2/types";
2
3
  import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedLineStyle, PerseusRenderer } from "../../perseus-types";
3
- import type { Interval, vec } from "mafs";
4
+ import type { Interval } from "mafs";
4
5
  export type LockedFunctionOptions = {
5
6
  color?: LockedFigureColor;
6
7
  strokeStyle?: LockedLineStyle;
7
8
  directionalAxis?: "x" | "y";
8
9
  domain?: Interval;
10
+ labels?: LockedFigureLabelOptions[];
9
11
  };
10
12
  type LockedFigureLabelOptions = {
11
13
  text: string;
@@ -119,12 +121,16 @@ declare class InteractiveGraphQuestionBuilder {
119
121
  showPoint2?: boolean;
120
122
  labels?: LockedFigureLabelOptions[];
121
123
  }): InteractiveGraphQuestionBuilder;
122
- addLockedVector(tail: vec.Vector2, tip: vec.Vector2, color?: LockedFigureColor): InteractiveGraphQuestionBuilder;
124
+ addLockedVector(tail: vec.Vector2, tip: vec.Vector2, options?: {
125
+ color?: LockedFigureColor;
126
+ labels?: LockedFigureLabelOptions[];
127
+ }): InteractiveGraphQuestionBuilder;
123
128
  addLockedEllipse(center: vec.Vector2, radius: [x: number, y: number], options?: {
124
129
  angle?: number;
125
130
  color?: LockedFigureColor;
126
131
  fillStyle?: LockedFigureFillType;
127
132
  strokeStyle?: "solid" | "dashed";
133
+ labels?: LockedFigureLabelOptions[];
128
134
  }): InteractiveGraphQuestionBuilder;
129
135
  addLockedPolygon(points: vec.Vector2[], options?: {
130
136
  color?: LockedFigureColor;
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { InteractiveGraphProps } from "./types";
3
3
  import type { PerseusGraphType } from "../../perseus-types";
4
- import type { Widget } from "../../renderer";
5
4
  import type { APIOptions } from "../../types";
5
+ import type { PerseusInteractiveGraphUserInput } from "../../validation.types";
6
6
  export type StatefulMafsGraphProps = {
7
7
  flags?: APIOptions["flags"];
8
8
  box: [number, number];
@@ -25,4 +25,7 @@ export type StatefulMafsGraphProps = {
25
25
  readOnly: boolean;
26
26
  static: InteractiveGraphProps["static"];
27
27
  };
28
- export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<StatefulMafsGraphProps & React.RefAttributes<Partial<Widget>>>;
28
+ export type StatefulMafsGraphType = {
29
+ getUserInput: () => PerseusInteractiveGraphUserInput;
30
+ };
31
+ export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<StatefulMafsGraphProps & React.RefAttributes<StatefulMafsGraphType>>;
@@ -0,0 +1,10 @@
1
+ import type { InteractiveMarkerType } from "./types";
2
+ import type { PerseusScore } from "../../types";
3
+ import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
4
+ type InteractiveMarkerScore = {
5
+ hasAnswers: boolean;
6
+ isCorrect: boolean;
7
+ };
8
+ export declare function scoreMarker(marker: InteractiveMarkerType): InteractiveMarkerScore;
9
+ declare function labelImageValidator(state: PerseusLabelImageUserInput, rubric?: PerseusLabelImageRubric): PerseusScore;
10
+ export default labelImageValidator;
@@ -8,14 +8,12 @@
8
8
  import * as React from "react";
9
9
  import { PerseusI18nContext } from "../../components/i18n-context";
10
10
  import Marker from "./marker";
11
- import type { InteractiveMarkerType, InteractiveMarkerScore } from "./types";
11
+ import type { InteractiveMarkerType } from "./types";
12
12
  import type { DependencyProps } from "../../dependencies";
13
13
  import type { ChangeableProps } from "../../mixins/changeable";
14
14
  import type { APIOptions, PerseusScore } from "../../types";
15
+ import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
15
16
  export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
16
- type MarkersState = {
17
- markers: ReadonlyArray<InteractiveMarkerType>;
18
- };
19
17
  /**
20
18
  * Represents a direction vector.
21
19
  * No diagonals allowed.
@@ -60,8 +58,7 @@ export declare class LabelImage extends React.Component<LabelImageProps, LabelIm
60
58
  context: React.ContextType<typeof PerseusI18nContext>;
61
59
  _markers: Array<Marker | null | undefined>;
62
60
  _mounted: boolean;
63
- static gradeMarker(marker: InteractiveMarkerType): InteractiveMarkerScore;
64
- static validate(state: MarkersState, rubric?: LabelImageProps): PerseusScore;
61
+ static validate(state: PerseusLabelImageUserInput, rubric?: PerseusLabelImageRubric): PerseusScore;
65
62
  /**
66
63
  * Test whether point is contained within triangle.
67
64
  *
@@ -82,8 +79,8 @@ export declare class LabelImage extends React.Component<LabelImageProps, LabelIm
82
79
  constructor(props: LabelImageProps);
83
80
  componentDidMount(): void;
84
81
  componentWillUnmount(): void;
85
- simpleValidate(rubric: LabelImageProps): PerseusScore;
86
- getUserInput(): MarkersState;
82
+ simpleValidate(rubric: PerseusLabelImageRubric): PerseusScore;
83
+ getUserInput(): PerseusLabelImageUserInput;
87
84
  showRationalesForCurrentlySelectedChoices(rubric: LabelImageProps): void;
88
85
  handleMarkerChange(index: number, marker: InteractiveMarkerType): void;
89
86
  activateMarker(index: number, opened: boolean): void;
@@ -99,7 +96,6 @@ declare const _default: Readonly<{
99
96
  getWidget?: (() => React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & {
100
97
  apiOptions: Readonly<{
101
98
  isArticle?: boolean | undefined;
102
- onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
103
99
  onFocusChange?: ((newFocusPath: import("../../types").FocusPath, oldFocusPath: import("../../types").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
104
100
  GroupMetadataEditor?: React.ComponentType<any> | undefined;
105
101
  showAlignmentOptions?: boolean | undefined;
@@ -147,6 +143,9 @@ declare const _default: Readonly<{
147
143
  "interactive-graph-locked-features-labels"?: boolean | undefined;
148
144
  "locked-point-labels"?: boolean | undefined;
149
145
  "locked-line-labels"?: boolean | undefined;
146
+ "locked-vector-labels"?: boolean | undefined;
147
+ "locked-ellipse-labels"?: boolean | undefined;
148
+ "locked-function-labels"?: boolean | undefined;
150
149
  }) | undefined;
151
150
  } | undefined;
152
151
  onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
@@ -165,7 +164,6 @@ declare const _default: Readonly<{
165
164
  widget: React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & {
166
165
  apiOptions: Readonly<{
167
166
  isArticle?: boolean | undefined;
168
- onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
169
167
  onFocusChange?: ((newFocusPath: import("../../types").FocusPath, oldFocusPath: import("../../types").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
170
168
  GroupMetadataEditor?: React.ComponentType<any> | undefined;
171
169
  showAlignmentOptions?: boolean | undefined;
@@ -213,6 +211,9 @@ declare const _default: Readonly<{
213
211
  "interactive-graph-locked-features-labels"?: boolean | undefined;
214
212
  "locked-point-labels"?: boolean | undefined;
215
213
  "locked-line-labels"?: boolean | undefined;
214
+ "locked-vector-labels"?: boolean | undefined;
215
+ "locked-ellipse-labels"?: boolean | undefined;
216
+ "locked-function-labels"?: boolean | undefined;
216
217
  }) | undefined;
217
218
  } | undefined;
218
219
  onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
@@ -9,7 +9,3 @@ export type InteractiveMarkerType = MarkerType & {
9
9
  showCorrectness?: "correct" | "incorrect";
10
10
  focused?: boolean;
11
11
  };
12
- export type InteractiveMarkerScore = {
13
- hasAnswers: boolean;
14
- isCorrect: boolean;
15
- };
@@ -3,9 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { SortableOption } from "../../components/sortable";
4
4
  import type { PerseusMatcherWidgetOptions } from "../../perseus-types";
5
5
  import type { WidgetProps } from "../../types";
6
+ import type { PerseusMatcherRubric, PerseusMatcherUserInput } from "../../validation.types";
6
7
  type RenderProps = PerseusMatcherWidgetOptions;
7
- type Rubric = PerseusMatcherWidgetOptions;
8
- type Props = WidgetProps<RenderProps, Rubric>;
8
+ type Props = WidgetProps<RenderProps, PerseusMatcherRubric>;
9
9
  type DefaultProps = {
10
10
  left: Props["left"];
11
11
  right: Props["right"];
@@ -32,10 +32,10 @@ export declare class Matcher extends React.Component<Props, State> {
32
32
  changeAndTrack: (arg1: any) => void;
33
33
  onMeasureLeft: (arg1: any) => void;
34
34
  onMeasureRight: (arg1: any) => void;
35
- getUserInput: () => any;
35
+ getUserInput: () => PerseusMatcherUserInput;
36
36
  moveLeftOptionToIndex: (option: SortableOption, index: number) => void;
37
37
  moveRightOptionToIndex: (option: SortableOption, index: number) => void;
38
- simpleValidate: (arg1: any) => any;
38
+ simpleValidate(rubric: PerseusMatcherRubric): any;
39
39
  render(): React.ReactElement;
40
40
  }
41
41
  declare const _default: Readonly<{
@@ -3,8 +3,8 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusMatrixWidgetOptions } from "../../perseus-types";
4
4
  import type { PerseusStrings } from "../../strings";
5
5
  import type { WidgetProps, PerseusScore } from "../../types";
6
- type Rubric = PerseusMatrixWidgetOptions;
7
- type ExternalProps = WidgetProps<PerseusMatrixWidgetOptions, Rubric>;
6
+ import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
7
+ type ExternalProps = WidgetProps<PerseusMatrixWidgetOptions, PerseusMatrixRubric>;
8
8
  type Props = ExternalProps & {
9
9
  onChange: (arg1: {
10
10
  cursorPosition?: ReadonlyArray<number>;
@@ -32,7 +32,7 @@ declare class Matrix extends React.Component<Props, State> {
32
32
  context: React.ContextType<typeof PerseusI18nContext>;
33
33
  cursorPosition: [number, number];
34
34
  static defaultProps: DefaultProps;
35
- static validate(state: any, rubric: any, strings: PerseusStrings): PerseusScore;
35
+ static validate(state: PerseusMatrixUserInput, rubric: PerseusMatrixRubric, strings: PerseusStrings): PerseusScore;
36
36
  state: State;
37
37
  componentDidMount(): void;
38
38
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
@@ -46,8 +46,8 @@ declare class Matrix extends React.Component<Props, State> {
46
46
  setInputValue: (arg1: any, arg2: any, arg3: any) => void;
47
47
  handleKeyDown: (arg1: any, arg2: any, arg3: any) => void;
48
48
  onValueChange: (arg1: any, arg2: any, arg3: any, arg4: any) => void;
49
- getUserInput: () => any;
50
- simpleValidate: (arg1: any) => any;
49
+ getUserInput(): PerseusMatrixUserInput;
50
+ simpleValidate(rubric: PerseusMatrixRubric): PerseusScore;
51
51
  render(): React.ReactNode;
52
52
  }
53
53
  declare const _default: Readonly<{
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusMoleculeRendererWidgetOptions } from "../../perseus-types";
4
+ import type { PerseusMoleculeUserInput } from "../../validation.types";
4
5
  type MoleculeState = {
5
6
  parsedSmiles: any;
6
7
  error: string | null;
@@ -32,7 +33,7 @@ type DefaultProps = {
32
33
  declare class MoleculeWidget extends React.Component<Props> {
33
34
  static defaultProps: DefaultProps;
34
35
  simpleValidate(): import("../../types").PerseusScore;
35
- getUserInput: () => ReadonlyArray<ReadonlyArray<string>>;
36
+ getUserInput(): PerseusMoleculeUserInput;
36
37
  validate(): import("../../types").PerseusScore;
37
38
  render(): React.ReactNode;
38
39
  }
@@ -2,6 +2,8 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { ChangeableProps } from "../../mixins/changeable";
4
4
  import type { APIOptions } from "../../types";
5
+ import type { PerseusNumberLineRubric, PerseusNumberLineUserInput } from "../../validation.types";
6
+ export type Relationship = "lt" | "gt" | "le" | "ge";
5
7
  type Props = ChangeableProps & {
6
8
  range: [number, number];
7
9
  labelRange: ReadonlyArray<number | null>;
@@ -13,7 +15,7 @@ type Props = ChangeableProps & {
13
15
  isTickCtrl: boolean;
14
16
  isInequality: boolean;
15
17
  numLinePosition: number;
16
- rel: "lt" | "gt" | "le" | "ge";
18
+ rel: Relationship;
17
19
  onFocus: (arg1: any) => void;
18
20
  onBlur: (arg1: any) => void;
19
21
  onChange: (arg1: any, arg2?: () => void | null | undefined) => void;
@@ -69,8 +71,8 @@ declare class NumberLine extends React.Component<Props, State> {
69
71
  _getInequalityEndpoint: (arg1: any) => [number, number];
70
72
  _renderInequality: (arg1: any) => React.ReactElement;
71
73
  _setupGraphie: (arg1: any, arg2: any) => void;
72
- getUserInput: () => any;
73
- simpleValidate: (arg1: any) => any;
74
+ getUserInput(): PerseusNumberLineUserInput;
75
+ simpleValidate(rubric: PerseusNumberLineRubric): any;
74
76
  render(): React.ReactNode;
75
77
  }
76
78
  declare const _default: Readonly<{
@@ -1,6 +1,6 @@
1
- import type { Rubric, UserInput } from "./numeric-input.types";
2
1
  import type { PerseusStrings } from "../../strings";
3
2
  import type { PerseusScore } from "../../types";
3
+ import type { PerseusNumericInputRubric, PerseusNumericInputUserInput } from "../../validation.types";
4
4
  export declare function maybeParsePercentInput(inputValue: string | number, normalizedAnswerExpected: boolean): string | number;
5
- declare function numericInputValidator(userInput: UserInput, rubric: Rubric, strings: PerseusStrings): PerseusScore;
5
+ declare function numericInputValidator(userInput: PerseusNumericInputUserInput, rubric: PerseusNumericInputRubric, strings: PerseusStrings): PerseusScore;
6
6
  export default numericInputValidator;
@@ -2,11 +2,11 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import InputWithExamples from "../../components/input-with-examples";
4
4
  import SimpleKeypadInput from "../../components/simple-keypad-input";
5
- import type { Rubric, UserInput } from "./numeric-input.types";
6
5
  import type { PerseusNumericInputWidgetOptions, PerseusNumericInputAnswerForm } from "../../perseus-types";
7
6
  import type { PerseusStrings } from "../../strings";
8
7
  import type { FocusPath, PerseusScore, WidgetProps } from "../../types";
9
- type ExternalProps = WidgetProps<PerseusNumericInputWidgetOptions, Rubric>;
8
+ import type { PerseusNumericInputRubric, PerseusNumericInputUserInput } from "../../validation.types";
9
+ type ExternalProps = WidgetProps<PerseusNumericInputWidgetOptions, PerseusNumericInputRubric>;
10
10
  type Props = ExternalProps & {
11
11
  size: NonNullable<ExternalProps["size"]>;
12
12
  rightAlign: NonNullable<ExternalProps["rightAlign"]>;
@@ -38,20 +38,20 @@ export declare class NumericInput extends React.Component<Props, State> {
38
38
  context: React.ContextType<typeof PerseusI18nContext>;
39
39
  inputRef: SimpleKeypadInput | InputWithExamples | null | undefined;
40
40
  static defaultProps: DefaultProps;
41
- static getUserInputFromProps(props: Props): UserInput;
42
- static getOneCorrectAnswerFromRubric(rubric: Rubric): string | null | undefined;
43
- static validate(userInput: UserInput, rubric: Rubric, strings: PerseusStrings): PerseusScore;
41
+ static getUserInputFromProps(props: Props): PerseusNumericInputUserInput;
42
+ static getOneCorrectAnswerFromRubric(rubric: PerseusNumericInputRubric): string | null | undefined;
43
+ static validate(userInput: PerseusNumericInputUserInput, rubric: PerseusNumericInputRubric, strings: PerseusStrings): PerseusScore;
44
44
  state: State;
45
45
  examples: () => ReadonlyArray<string>;
46
46
  shouldShowExamples: () => boolean;
47
- simpleValidate: (arg1: Rubric) => PerseusScore;
47
+ simpleValidate(rubric: PerseusNumericInputRubric): PerseusScore;
48
48
  focus: () => boolean;
49
49
  focusInputPath: () => void;
50
50
  blurInputPath: () => void;
51
51
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
52
52
  getGrammarTypeForPath: (arg1: FocusPath) => string;
53
53
  setInputValue: (arg1: FocusPath, arg2: string, arg3?: () => unknown | null | undefined) => void;
54
- getUserInput: () => UserInput;
54
+ getUserInput(): PerseusNumericInputUserInput;
55
55
  handleChange: (arg1: string, arg2?: () => unknown | null | undefined) => void;
56
56
  _handleFocus: () => void;
57
57
  _handleBlur: () => void;
@@ -1,15 +1,15 @@
1
1
  import * as React from "react";
2
2
  import type { PerseusOrdererWidgetOptions } from "../../perseus-types";
3
3
  import type { WidgetProps } from "../../types";
4
+ import type { PerseusOrdererRubric, PerseusOrdererUserInput } from "../../validation.types";
4
5
  type Position = {
5
6
  left: number;
6
7
  top: number;
7
8
  };
8
- type Rubric = PerseusOrdererWidgetOptions;
9
9
  type RenderProps = PerseusOrdererWidgetOptions & {
10
10
  current: any;
11
11
  };
12
- export type OrdererProps = WidgetProps<RenderProps, Rubric>;
12
+ export type OrdererProps = WidgetProps<RenderProps, PerseusOrdererRubric>;
13
13
  type OrdererDefaultProps = {
14
14
  current: OrdererProps["current"];
15
15
  options: OrdererProps["options"];
@@ -43,8 +43,8 @@ declare class Orderer extends React.Component<OrdererProps, OrdererState> {
43
43
  findCorrectIndex: (arg1: any, arg2: any) => any;
44
44
  isCardInBank: (arg1: any) => boolean;
45
45
  setListValues: (arg1: ReadonlyArray<string>) => void;
46
- getUserInput: () => any;
47
- simpleValidate: (arg1: any) => any;
46
+ getUserInput(): PerseusOrdererUserInput;
47
+ simpleValidate(rubric: PerseusOrdererRubric): any;
48
48
  render(): React.ReactNode;
49
49
  }
50
50
  declare const _default: Readonly<{
@@ -5,14 +5,13 @@ import type { SerializedHighlightSet } from "../../components/highlighting/types
5
5
  import type { ChangeableProps } from "../../mixins/changeable";
6
6
  import type { PerseusPassageWidgetOptions, PerseusWidget } from "../../perseus-types";
7
7
  import type { WidgetProps } from "../../types";
8
+ import type { PerseusPassageRubric, PerseusPassageUserInput } from "../../validation.types";
8
9
  import type { SingleASTNode } from "@khanacademy/simple-markdown";
9
10
  export declare class LineHeightMeasurer extends React.Component<Record<any, any>> {
10
11
  _line: HTMLDivElement | null | undefined;
11
12
  measureLineHeight(): number;
12
13
  render(): React.ReactNode;
13
14
  }
14
- type UserInput = null;
15
- type Rubric = PerseusPassageWidgetOptions;
16
15
  type RenderProps = {
17
16
  passageTitle: PerseusPassageWidgetOptions["passageTitle"];
18
17
  passageText: PerseusPassageWidgetOptions["passageText"];
@@ -20,7 +19,7 @@ type RenderProps = {
20
19
  showLineNumbers: PerseusPassageWidgetOptions["showLineNumbers"];
21
20
  };
22
21
  type FindWidgetsCallback = (id: string, widgetInfo: PerseusWidget) => boolean;
23
- type PassageProps = ChangeableProps & WidgetProps<RenderProps, Rubric> & {
22
+ type PassageProps = ChangeableProps & WidgetProps<RenderProps, PerseusPassageRubric> & {
24
23
  findWidgets: (arg1: FindWidgetsCallback) => ReadonlyArray<Passage>;
25
24
  highlights: SerializedHighlightSet;
26
25
  };
@@ -94,7 +93,7 @@ export declare class Passage extends React.Component<PassageProps, PassageState>
94
93
  *
95
94
  * These are misc widget functions used for the widget API
96
95
  */
97
- getUserInput(): UserInput;
96
+ getUserInput(): PerseusPassageUserInput;
98
97
  simpleValidate(): import("../../types").PerseusScore;
99
98
  /**
100
99
  * Rendering
@@ -2,21 +2,13 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusPassageRefWidgetOptions } from "../../perseus-types";
4
4
  import type { ChangeFn, WidgetProps } from "../../types";
5
- import type { LinterContextProps } from "@khanacademy/perseus-linter";
6
- type UserInput = RenderProps & {
7
- static: boolean | null | undefined;
8
- reviewModeRubric: Rubric;
9
- linterContext: LinterContextProps;
10
- isLastUsedWidget: boolean;
11
- alignment: string | null | undefined;
12
- };
5
+ import type { PerseusPassageRefRubric, PerseusPassageRefUserInput } from "../../validation.types";
13
6
  type RenderProps = {
14
7
  passageNumber: PerseusPassageRefWidgetOptions["passageNumber"];
15
8
  referenceNumber: PerseusPassageRefWidgetOptions["referenceNumber"];
16
9
  summaryText: PerseusPassageRefWidgetOptions["summaryText"];
17
10
  };
18
- type Rubric = PerseusPassageRefWidgetOptions;
19
- type Props = WidgetProps<RenderProps, Rubric>;
11
+ type Props = WidgetProps<RenderProps, PerseusPassageRefRubric>;
20
12
  type DefaultProps = {
21
13
  passageNumber: Props["passageNumber"];
22
14
  referenceNumber: Props["referenceNumber"];
@@ -42,7 +34,7 @@ declare class PassageRef extends React.Component<Props, State> {
42
34
  shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
43
35
  componentDidUpdate(): void;
44
36
  componentWillUnmount(): void;
45
- getUserInput: () => UserInput;
37
+ getUserInput(): PerseusPassageRefUserInput;
46
38
  change: ChangeFn;
47
39
  _deferredUpdateRange: () => void;
48
40
  _updateRange: () => void;
@@ -3,6 +3,7 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import * as Changeable from "../../mixins/changeable";
4
4
  import type { PerseusPassageRefTargetWidgetOptions } from "../../perseus-types";
5
5
  import type { APIOptions } from "../../types";
6
+ import type { PerseusPassageRefTargetUserInput } from "../../validation.types";
6
7
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
7
8
  type Props = Changeable.ChangeableProps & {
8
9
  apiOptions: APIOptions;
@@ -21,7 +22,7 @@ declare class PassageRefTarget extends React.Component<Props> {
21
22
  context: React.ContextType<typeof PerseusI18nContext>;
22
23
  static defaultProps: DefaultProps;
23
24
  static validate(): import("../../types").PerseusScore;
24
- getUserInput: () => any;
25
+ getUserInput(): PerseusPassageRefTargetUserInput;
25
26
  change: (arg1: any, arg2: any, arg3: any) => any;
26
27
  simpleValidate(): import("../../types").PerseusScore;
27
28
  render(): React.ReactNode;
@@ -6,9 +6,9 @@ import * as React from "react";
6
6
  import { PerseusI18nContext } from "../../components/i18n-context";
7
7
  import type { PerseusPhetSimulationWidgetOptions } from "../../perseus-types";
8
8
  import type { WidgetProps } from "../../types";
9
+ import type { PerseusPhetSimulationUserInput } from "../../validation.types";
9
10
  type RenderProps = PerseusPhetSimulationWidgetOptions;
10
11
  type Props = WidgetProps<RenderProps, PerseusPhetSimulationWidgetOptions>;
11
- type UserInput = null;
12
12
  type State = {
13
13
  banner: {
14
14
  message: string;
@@ -28,7 +28,7 @@ export declare class PhetSimulation extends React.Component<Props, State> {
28
28
  constructor(props: any);
29
29
  componentDidMount(): Promise<void>;
30
30
  componentDidUpdate(prevProps: any): Promise<void>;
31
- getUserInput(): UserInput;
31
+ getUserInput(): PerseusPhetSimulationUserInput;
32
32
  getPhetCompatibleLocale: (arg1: string) => string;
33
33
  displayLoadFailure: () => void;
34
34
  updateSimState(urlString: string): Promise<void>;
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusPlotterWidgetOptions } from "../../perseus-types";
4
- import type { WidgetProps } from "../../types";
5
- type Rubric = PerseusPlotterWidgetOptions;
4
+ import type { PerseusScore, WidgetProps } from "../../types";
5
+ import type { PerseusPlotterRubric, PerseusPlotterUserInput } from "../../validation.types";
6
6
  type RenderProps = PerseusPlotterWidgetOptions;
7
- type Props = WidgetProps<RenderProps, Rubric> & {
7
+ type Props = WidgetProps<RenderProps, PerseusPlotterRubric> & {
8
8
  labelInterval: NonNullable<PerseusPlotterWidgetOptions["labelInterval"]>;
9
9
  picSize: NonNullable<PerseusPlotterWidgetOptions["picSize"]>;
10
10
  };
@@ -67,8 +67,8 @@ export declare class Plotter extends React.Component<Props, State> {
67
67
  setPicHeight: (arg1: number, arg2: number) => void;
68
68
  changeAndTrack: (arg1: any) => void;
69
69
  drawPicHeights: (arg1: any, arg2: any) => void;
70
- getUserInput: () => any;
71
- simpleValidate: (arg1: any) => any;
70
+ getUserInput(): PerseusPlotterUserInput;
71
+ simpleValidate(rubric: PerseusPlotterRubric): PerseusScore;
72
72
  render(): React.ReactNode;
73
73
  }
74
74
  declare const _default: Readonly<{
@@ -4,6 +4,7 @@ import type { FocusFunction } from "./base-radio";
4
4
  import type { PerseusRadioChoice, PerseusRadioWidgetOptions, ShowSolutions } from "../../perseus-types";
5
5
  import type { PerseusStrings } from "../../strings";
6
6
  import type { PerseusScore, WidgetProps, ChoiceState } from "../../types";
7
+ import type { PerseusRadioRubric, PerseusRadioUserInput } from "../../validation.types";
7
8
  export type RenderProps = {
8
9
  numCorrect: number;
9
10
  hasNoneOfTheAbove?: boolean;
@@ -16,15 +17,7 @@ export type RenderProps = {
16
17
  choiceStates?: ReadonlyArray<ChoiceState>;
17
18
  values?: ReadonlyArray<boolean>;
18
19
  };
19
- type UserInput = {
20
- countChoices?: boolean;
21
- choicesSelected: ReadonlyArray<boolean>;
22
- numCorrect?: number;
23
- noneOfTheAboveIndex?: number | null | undefined;
24
- noneOfTheAboveSelected?: boolean;
25
- };
26
- type Rubric = PerseusRadioWidgetOptions;
27
- type Props = WidgetProps<RenderProps, Rubric>;
20
+ type Props = WidgetProps<RenderProps, PerseusRadioRubric>;
28
21
  type DefaultProps = Required<Pick<Props, "choices" | "multipleSelect" | "countChoices" | "deselectEnabled" | "linterContext" | "showSolutions">>;
29
22
  export type RadioChoiceWithMetadata = PerseusRadioChoice & {
30
23
  originalIndex: number;
@@ -38,8 +31,8 @@ declare class Radio extends React.Component<Props> {
38
31
  context: React.ContextType<typeof PerseusI18nContext>;
39
32
  focusFunction: FocusFunction;
40
33
  static defaultProps: DefaultProps;
41
- static validate(userInput: UserInput, rubric: Rubric, strings: PerseusStrings): PerseusScore;
42
- static getUserInputFromProps(props: Props): UserInput;
34
+ static validate(userInput: PerseusRadioUserInput, rubric: PerseusRadioRubric, strings: PerseusStrings): PerseusScore;
35
+ static getUserInputFromProps(props: Props): PerseusRadioUserInput;
43
36
  componentDidUpdate(prevProps: Props): void;
44
37
  _renderRenderer: (content?: string) => React.ReactElement;
45
38
  focus(choiceIndex?: number | null): boolean;
@@ -48,8 +41,8 @@ declare class Radio extends React.Component<Props> {
48
41
  checked: ReadonlyArray<boolean>;
49
42
  crossedOut: ReadonlyArray<boolean>;
50
43
  }>) => void;
51
- getUserInput: () => UserInput;
52
- simpleValidate: (arg1: PerseusRadioWidgetOptions) => PerseusScore;
44
+ getUserInput(): PerseusRadioUserInput;
45
+ simpleValidate(rubric: PerseusRadioRubric): PerseusScore;
53
46
  /**
54
47
  * Turn on rationale display for the currently selected choices. Note that
55
48
  * this leaves rationales on for choices that are already showing
@@ -0,0 +1,5 @@
1
+ import type { PerseusStrings } from "../../strings";
2
+ import type { PerseusScore } from "../../types";
3
+ import type { PerseusRadioRubric, PerseusRadioUserInput } from "../../validation.types";
4
+ declare function radioValidator(userInput: PerseusRadioUserInput, rubric: PerseusRadioRubric, strings: PerseusStrings): PerseusScore;
5
+ export default radioValidator;
@@ -0,0 +1,4 @@
1
+ import type { PerseusScore } from "../../types";
2
+ import type { PerseusSorterRubric, PerseusSorterUserInput } from "../../validation.types";
3
+ declare function sorterValidator(userInput: PerseusSorterUserInput, rubric: PerseusSorterRubric): PerseusScore;
4
+ export default sorterValidator;
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import type { SortableOption } from "../../components/sortable";
3
3
  import type { PerseusSorterWidgetOptions } from "../../perseus-types";
4
- import type { WidgetProps } from "../../types";
4
+ import type { PerseusScore, WidgetProps } from "../../types";
5
+ import type { PerseusSorterRubric, PerseusSorterUserInput } from "../../validation.types";
5
6
  type RenderProps = PerseusSorterWidgetOptions;
6
- type Rubric = PerseusSorterWidgetOptions;
7
- type Props = WidgetProps<RenderProps, Rubric>;
7
+ type Props = WidgetProps<RenderProps, PerseusSorterRubric>;
8
8
  type DefaultProps = {
9
9
  correct: Props["correct"];
10
10
  layout: Props["layout"];
@@ -19,16 +19,14 @@ type State = {
19
19
  declare class Sorter extends React.Component<Props, State> {
20
20
  _isMounted: boolean;
21
21
  static defaultProps: DefaultProps;
22
- static validate(state: any, rubric: any): any;
23
- state: any;
22
+ static validate(userInput: PerseusSorterUserInput, rubric: PerseusSorterRubric): PerseusScore;
23
+ state: State;
24
24
  componentDidMount(): void;
25
25
  componentWillUnmount(): void;
26
26
  handleChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
27
- getUserInput: () => {
28
- options: any;
29
- };
27
+ getUserInput(): PerseusSorterUserInput;
30
28
  moveOptionToIndex: (option: SortableOption, index: number) => void;
31
- simpleValidate: (arg1: any) => any;
29
+ simpleValidate(rubric: PerseusSorterRubric): PerseusScore;
32
30
  render(): React.ReactNode;
33
31
  }
34
32
  declare const _default: Readonly<{
@@ -3,13 +3,13 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { ChangeableProps } from "../../mixins/changeable";
4
4
  import type { PerseusTableWidgetOptions } from "../../perseus-types";
5
5
  import type { PerseusStrings } from "../../strings";
6
- import type { WidgetProps } from "../../types";
6
+ import type { PerseusScore, WidgetProps } from "../../types";
7
+ import type { PerseusTableRubric, PerseusTableUserInput } from "../../validation.types";
7
8
  type RenderProps = PerseusTableWidgetOptions & {
8
9
  editableHeaders: boolean;
9
10
  Editor: any;
10
11
  };
11
- type Rubric = PerseusTableWidgetOptions;
12
- type Props = ChangeableProps & WidgetProps<RenderProps, Rubric>;
12
+ type Props = ChangeableProps & WidgetProps<RenderProps, PerseusTableRubric>;
13
13
  type DefaultProps = {
14
14
  apiOptions: Props["apiOptions"];
15
15
  headers: Props["headers"];
@@ -28,10 +28,10 @@ declare class Table extends React.Component<Props> {
28
28
  static defaultProps: DefaultProps;
29
29
  _getRows: () => number;
30
30
  _getColumns: () => number;
31
- getUserInput: () => any;
31
+ getUserInput(): PerseusTableUserInput;
32
32
  onValueChange: (arg1: any, arg2: any, arg3: any) => void;
33
33
  onHeaderChange: (arg1: number, arg2: any) => void;
34
- simpleValidate: (arg1: any) => any;
34
+ simpleValidate(rubric: PerseusTableWidgetOptions): PerseusScore;
35
35
  _handleFocus: (arg1: any) => void;
36
36
  _handleBlur: (arg1: any) => void;
37
37
  focus: () => boolean;
@@ -5,9 +5,9 @@ import * as React from "react";
5
5
  import { PerseusI18nContext } from "../../components/i18n-context";
6
6
  import type { PerseusVideoWidgetOptions } from "../../perseus-types";
7
7
  import type { WidgetProps } from "../../types";
8
- type Rubric = PerseusVideoWidgetOptions;
8
+ import type { PerseusVideoRubric } from "../../validation.types";
9
9
  type RenderProps = PerseusVideoWidgetOptions;
10
- type Props = WidgetProps<RenderProps, Rubric> & {
10
+ type Props = WidgetProps<RenderProps, PerseusVideoRubric> & {
11
11
  alignment: string;
12
12
  };
13
13
  /**
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": "34.1.0",
6
+ "version": "35.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,5 +0,0 @@
1
- import type { PerseusCategorizerWidgetOptions } from "../../perseus-types";
2
- export type UserInput = {
3
- values: ReadonlyArray<number>;
4
- };
5
- export type Rubric = PerseusCategorizerWidgetOptions;
@@ -1,5 +0,0 @@
1
- import type { PerseusDropdownWidgetOptions } from "../../perseus-types";
2
- export type Rubric = PerseusDropdownWidgetOptions;
3
- export type UserInput = {
4
- value: number;
5
- };
@@ -1,2 +0,0 @@
1
- import type { PerseusInputNumberWidgetOptions } from "@khanacademy/perseus";
2
- export type Rubric = PerseusInputNumberWidgetOptions;