@khanacademy/perseus 34.0.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 (66) hide show
  1. package/dist/es/index.js +641 -525
  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 +573 -447
  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 +4 -5
  10. package/dist/perseus-types.d.ts +6 -18
  11. package/dist/renderer.d.ts +4 -4
  12. package/dist/server-item-renderer.d.ts +4 -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/__shared__/noop-validator.d.ts +2 -2
  19. package/dist/widgets/categorizer/categorizer-validator.d.ts +5 -0
  20. package/dist/widgets/categorizer/categorizer.d.ts +6 -9
  21. package/dist/widgets/cs-program/cs-program.d.ts +4 -9
  22. package/dist/widgets/definition/definition.d.ts +6 -7
  23. package/dist/widgets/dropdown/dropdown-validator.d.ts +2 -2
  24. package/dist/widgets/dropdown/dropdown.d.ts +5 -5
  25. package/dist/widgets/explanation/explanation.d.ts +6 -7
  26. package/dist/widgets/expression/expression-validator.d.ts +2 -2
  27. package/dist/widgets/expression/expression.d.ts +38 -26
  28. package/dist/widgets/expression/expression.types.d.ts +0 -1
  29. package/dist/widgets/graded-group/graded-group.d.ts +2 -2
  30. package/dist/widgets/graded-group-set/graded-group-set.d.ts +2 -2
  31. package/dist/widgets/grapher/grapher.d.ts +6 -7
  32. package/dist/widgets/group/group.d.ts +3 -2
  33. package/dist/widgets/iframe/iframe.d.ts +4 -9
  34. package/dist/widgets/image/image.d.ts +6 -7
  35. package/dist/widgets/input-number/input-number-validator.d.ts +41 -0
  36. package/dist/widgets/input-number/input-number.d.ts +7 -10
  37. package/dist/widgets/interaction/interaction.d.ts +6 -6
  38. package/dist/widgets/interactive-graph.d.ts +9 -12
  39. package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +15 -7
  40. package/dist/widgets/interactive-graphs/reducer/interactive-graph-action.d.ts +16 -1
  41. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +5 -2
  42. package/dist/widgets/interactive-graphs/types.d.ts +3 -0
  43. package/dist/widgets/label-image/label-image-validator.d.ts +10 -0
  44. package/dist/widgets/label-image/label-image.d.ts +13 -10
  45. package/dist/widgets/label-image/types.d.ts +0 -4
  46. package/dist/widgets/matcher/matcher.d.ts +4 -4
  47. package/dist/widgets/matrix/matrix.d.ts +5 -5
  48. package/dist/widgets/molecule/molecule.d.ts +4 -3
  49. package/dist/widgets/number-line/number-line.d.ts +5 -3
  50. package/dist/widgets/numeric-input/numeric-input-validator.d.ts +2 -2
  51. package/dist/widgets/numeric-input/numeric-input.d.ts +7 -7
  52. package/dist/widgets/orderer/orderer.d.ts +4 -4
  53. package/dist/widgets/passage/passage.d.ts +6 -7
  54. package/dist/widgets/passage-ref/passage-ref.d.ts +6 -14
  55. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +4 -3
  56. package/dist/widgets/phet-simulation/phet-simulation.d.ts +2 -2
  57. package/dist/widgets/plotter/plotter.d.ts +5 -5
  58. package/dist/widgets/radio/radio-component.d.ts +6 -13
  59. package/dist/widgets/radio/radio-validator.d.ts +5 -0
  60. package/dist/widgets/sorter/sorter-validator.d.ts +4 -0
  61. package/dist/widgets/sorter/sorter.d.ts +7 -9
  62. package/dist/widgets/table/table.d.ts +5 -5
  63. package/dist/widgets/video/video.d.ts +5 -6
  64. package/package.json +1 -1
  65. package/dist/widgets/dropdown/dropdown.types.d.ts +0 -5
  66. package/dist/widgets/numeric-input/numeric-input.types.d.ts +0 -5
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import type { Coord } from "../../interactive2/types";
3
3
  import type { PerseusInteractionWidgetOptions } from "../../perseus-types";
4
- import type { PerseusScore, WidgetProps } from "../../types";
4
+ import type { WidgetProps } from "../../types";
5
+ import type { PerseusInteractionRubric, PerseusInteractionUserInput } from "../../validation.types";
5
6
  type RenderProps = PerseusInteractionWidgetOptions;
6
- type Rubric = PerseusInteractionWidgetOptions;
7
- type Props = WidgetProps<RenderProps, Rubric>;
7
+ type Props = WidgetProps<RenderProps, PerseusInteractionRubric>;
8
8
  type DefaultProps = {
9
9
  graph: Props["graph"];
10
10
  elements: Props["elements"];
@@ -15,7 +15,7 @@ type State = {
15
15
  };
16
16
  declare class Interaction extends React.Component<Props, State> {
17
17
  static defaultProps: DefaultProps;
18
- static validate(state: any, rubric: any): PerseusScore;
18
+ static validate(): import("../../types").PerseusScore;
19
19
  state: State;
20
20
  UNSAFE_componentWillReceiveProps(nextProps: Props): void;
21
21
  _setupGraphie: (arg1: any, arg2: any) => void;
@@ -24,8 +24,8 @@ declare class Interaction extends React.Component<Props, State> {
24
24
  _eval: (arg1: any, arg2: any) => number;
25
25
  _extractVars: (arg1: any) => ReadonlyArray<any>;
26
26
  change: (arg1: any, arg2: any, arg3: any) => any;
27
- getUserInput: () => any;
28
- simpleValidate: (arg1: any) => any;
27
+ getUserInput(): PerseusInteractionUserInput;
28
+ simpleValidate(): import("../../types").PerseusScore;
29
29
  render(): React.ReactNode;
30
30
  }
31
31
  declare const _default: Readonly<{
@@ -1,17 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../components/i18n-context";
3
+ import type { StatefulMafsGraphType } from "./interactive-graphs/stateful-mafs-graph";
3
4
  import type { QuadraticGraphState } from "./interactive-graphs/types";
4
5
  import type { Coord } from "../interactive2/types";
5
6
  import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, PerseusInteractiveGraphWidgetOptions } from "../perseus-types";
6
- import type { Widget } from "../renderer";
7
7
  import type { ChangeHandler, PerseusScore, WidgetProps } from "../types";
8
8
  import type { QuadraticCoefficient, Range, SineCoefficient } from "../util/geometry";
9
+ import type { PerseusInteractiveGraphRubric, PerseusInteractiveGraphUserInput } from "../validation.types";
9
10
  type RenderProps = PerseusInteractiveGraphWidgetOptions;
10
- export type Rubric = {
11
- correct: PerseusGraphType;
12
- graph: PerseusGraphType;
13
- };
14
- type Props = WidgetProps<RenderProps, Rubric>;
11
+ type Props = WidgetProps<RenderProps, PerseusInteractiveGraphRubric>;
15
12
  type State = any;
16
13
  type DefaultProps = {
17
14
  labels: Props["labels"];
@@ -101,17 +98,17 @@ declare class LegacyInteractiveGraph extends React.Component<Props, State> {
101
98
  addAngleControls: () => void;
102
99
  removeAngleControls: () => void;
103
100
  toggleShowSides: () => void;
104
- getUserInput(): PerseusGraphType;
105
- simpleValidate(rubric: Rubric): PerseusScore;
101
+ getUserInput(): PerseusInteractiveGraphUserInput;
102
+ simpleValidate(rubric: PerseusInteractiveGraphRubric): PerseusScore;
106
103
  focus: () => void;
107
104
  render(): React.ReactNode;
108
105
  }
109
106
  declare class InteractiveGraph extends React.Component<Props, State> {
110
107
  legacyGraphRef: React.RefObject<LegacyInteractiveGraph>;
111
- mafsRef: React.RefObject<Widget>;
108
+ mafsRef: React.RefObject<StatefulMafsGraphType>;
112
109
  static defaultProps: DefaultProps;
113
- getUserInput: Widget["getUserInput"];
114
- simpleValidate(rubric: Rubric): PerseusScore;
110
+ getUserInput(): PerseusInteractiveGraphUserInput;
111
+ simpleValidate(rubric: PerseusInteractiveGraphRubric): PerseusScore;
115
112
  render(): React.JSX.Element;
116
113
  static getQuadraticCoefficients(coords: ReadonlyArray<Coord>): QuadraticCoefficient;
117
114
  static getSinusoidCoefficients(coords: ReadonlyArray<Coord>): SineCoefficient;
@@ -163,7 +160,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
163
160
  static getRayEquationString(props: Props): string;
164
161
  static getPolygonEquationString(props: Props): string;
165
162
  static getAngleEquationString(props: Props): string;
166
- static validate(userInput: PerseusGraphType, rubric: Rubric, component: any): PerseusScore;
163
+ static validate(userInput: PerseusGraphType, rubric: PerseusInteractiveGraphRubric, component: any): PerseusScore;
167
164
  static getUserInputFromProps(props: Props): PerseusGraphType;
168
165
  }
169
166
  export declare function shouldUseMafs(mafsFlags: Record<string, boolean> | undefined | boolean, graph: PerseusGraphType): boolean;
@@ -1,11 +1,18 @@
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[];
11
+ };
12
+ type LockedFigureLabelOptions = {
13
+ text: string;
14
+ coord?: Coord;
15
+ size?: "small" | "medium" | "large";
9
16
  };
10
17
  export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
11
18
  declare class InteractiveGraphQuestionBuilder {
@@ -103,11 +110,7 @@ declare class InteractiveGraphQuestionBuilder {
103
110
  addLockedPointAt(x: number, y: number, options?: {
104
111
  color?: LockedFigureColor;
105
112
  filled?: boolean;
106
- labels?: {
107
- text: string;
108
- coord?: Coord;
109
- size?: "small" | "medium" | "large";
110
- }[];
113
+ labels?: LockedFigureLabelOptions[];
111
114
  }): InteractiveGraphQuestionBuilder;
112
115
  addLockedLine(point1: vec.Vector2, point2: vec.Vector2, options?: {
113
116
  kind?: "line" | "ray" | "segment";
@@ -116,13 +119,18 @@ declare class InteractiveGraphQuestionBuilder {
116
119
  filled?: [boolean, boolean];
117
120
  showPoint1?: boolean;
118
121
  showPoint2?: boolean;
122
+ labels?: LockedFigureLabelOptions[];
123
+ }): InteractiveGraphQuestionBuilder;
124
+ addLockedVector(tail: vec.Vector2, tip: vec.Vector2, options?: {
125
+ color?: LockedFigureColor;
126
+ labels?: LockedFigureLabelOptions[];
119
127
  }): InteractiveGraphQuestionBuilder;
120
- addLockedVector(tail: vec.Vector2, tip: vec.Vector2, color?: LockedFigureColor): InteractiveGraphQuestionBuilder;
121
128
  addLockedEllipse(center: vec.Vector2, radius: [x: number, y: number], options?: {
122
129
  angle?: number;
123
130
  color?: LockedFigureColor;
124
131
  fillStyle?: LockedFigureFillType;
125
132
  strokeStyle?: "solid" | "dashed";
133
+ labels?: LockedFigureLabelOptions[];
126
134
  }): InteractiveGraphQuestionBuilder;
127
135
  addLockedPolygon(points: vec.Vector2[], options?: {
128
136
  color?: LockedFigureColor;
@@ -1,9 +1,12 @@
1
1
  import type { InitializeGraphStateParams } from "./initialize-graph-state";
2
+ import type { InteractionMode } from "../types";
2
3
  import type { Interval, vec } from "mafs";
3
- export type InteractiveGraphAction = Reinitialize | MovePointInFigure | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange | AddPoint | RemovePoint | FocusPoint | BlurPoint | DeleteIntent | ClickPoint;
4
+ export type InteractiveGraphAction = Reinitialize | MovePointInFigure | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange | AddPoint | RemovePoint | FocusPoint | BlurPoint | DeleteIntent | ClickPoint | ChangeInteractionMode | ChangeKeyboardInvitationVisibility;
4
5
  export declare const actions: {
5
6
  global: {
6
7
  deleteIntent: typeof deleteIntent;
8
+ changeInteractionMode: typeof changeInteractionMode;
9
+ changeKeyboardInvitationVisibility: typeof changeKeyboardInvitationVisibility;
7
10
  };
8
11
  angle: {
9
12
  movePoint: typeof movePoint;
@@ -88,6 +91,18 @@ export interface ClickPoint {
88
91
  index: number;
89
92
  }
90
93
  declare function clickPoint(index: number): ClickPoint;
94
+ export declare const CHANGE_INTERACTION_MODE = "point-change-interaction-mode";
95
+ export interface ChangeInteractionMode {
96
+ type: typeof CHANGE_INTERACTION_MODE;
97
+ mode: InteractionMode;
98
+ }
99
+ declare function changeInteractionMode(mode: InteractionMode): ChangeInteractionMode;
100
+ export declare const CHANGE_KEYBOARD_INVITATION_VISIBILITY = "change-keyboard-interaction-invitation-visibility";
101
+ export interface ChangeKeyboardInvitationVisibility {
102
+ type: typeof CHANGE_KEYBOARD_INVITATION_VISIBILITY;
103
+ shouldShow: boolean;
104
+ }
105
+ declare function changeKeyboardInvitationVisibility(shouldShow: boolean): ChangeKeyboardInvitationVisibility;
91
106
  export declare const MOVE_ALL = "move-all";
92
107
  export interface MoveAll {
93
108
  type: typeof MOVE_ALL;
@@ -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>>;
@@ -26,6 +26,7 @@ export interface LinearSystemGraphState extends InteractiveGraphStateCommon {
26
26
  type: "linear-system";
27
27
  coords: PairOfPoints[];
28
28
  }
29
+ export type InteractionMode = "mouse" | "keyboard";
29
30
  export interface NoneGraphState extends InteractiveGraphStateCommon {
30
31
  type: "none";
31
32
  }
@@ -35,6 +36,8 @@ export interface PointGraphState extends InteractiveGraphStateCommon {
35
36
  numPoints?: number | "unlimited";
36
37
  focusedPointIndex: number | null;
37
38
  showRemovePointButton: boolean;
39
+ interactionMode: InteractionMode;
40
+ showKeyboardInteractionInvitation: boolean;
38
41
  }
39
42
  export interface RayGraphState extends InteractiveGraphStateCommon {
40
43
  type: "ray";
@@ -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;
@@ -146,6 +142,10 @@ declare const _default: Readonly<{
146
142
  } & {
147
143
  "interactive-graph-locked-features-labels"?: boolean | undefined;
148
144
  "locked-point-labels"?: boolean | undefined;
145
+ "locked-line-labels"?: boolean | undefined;
146
+ "locked-vector-labels"?: boolean | undefined;
147
+ "locked-ellipse-labels"?: boolean | undefined;
148
+ "locked-function-labels"?: boolean | undefined;
149
149
  }) | undefined;
150
150
  } | undefined;
151
151
  onWidgetStartProps?: ((widgets: import("../..").PerseusWidgetsMap) => void) | undefined;
@@ -164,7 +164,6 @@ declare const _default: Readonly<{
164
164
  widget: React.ForwardRefExoticComponent<Omit<ChangeableProps & Partial<import("../../types").PerseusDependenciesV2> & {
165
165
  apiOptions: Readonly<{
166
166
  isArticle?: boolean | undefined;
167
- onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
168
167
  onFocusChange?: ((newFocusPath: import("../../types").FocusPath, oldFocusPath: import("../../types").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
169
168
  GroupMetadataEditor?: React.ComponentType<any> | undefined;
170
169
  showAlignmentOptions?: boolean | undefined;
@@ -211,6 +210,10 @@ declare const _default: Readonly<{
211
210
  } & {
212
211
  "interactive-graph-locked-features-labels"?: boolean | undefined;
213
212
  "locked-point-labels"?: boolean | undefined;
213
+ "locked-line-labels"?: boolean | undefined;
214
+ "locked-vector-labels"?: boolean | undefined;
215
+ "locked-ellipse-labels"?: boolean | undefined;
216
+ "locked-function-labels"?: boolean | undefined;
214
217
  }) | undefined;
215
218
  } | undefined;
216
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;
@@ -31,9 +32,9 @@ type DefaultProps = {
31
32
  };
32
33
  declare class MoleculeWidget extends React.Component<Props> {
33
34
  static defaultProps: DefaultProps;
34
- simpleValidate: (arg1: any) => any;
35
- getUserInput: () => ReadonlyArray<ReadonlyArray<string>>;
36
- validate: (arg1: any, arg2: any) => any;
35
+ simpleValidate(): import("../../types").PerseusScore;
36
+ getUserInput(): PerseusMoleculeUserInput;
37
+ validate(): import("../../types").PerseusScore;
37
38
  render(): React.ReactNode;
38
39
  }
39
40
  declare const _default: Readonly<{
@@ -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<{
@@ -4,15 +4,14 @@ import type { ParseState } from "./passage-markdown";
4
4
  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
- import type { PerseusScore, WidgetProps } from "../../types";
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
  };
@@ -54,7 +53,7 @@ export declare class Passage extends React.Component<PassageProps, PassageState>
54
53
  _stylesAppiedTimer: number;
55
54
  static defaultProps: DefaultPassageProps;
56
55
  state: PassageState;
57
- static validate(state: UserInput, rubric: Rubric): PerseusScore;
56
+ static validate(): import("../../types").PerseusScore;
58
57
  componentDidMount(): void;
59
58
  shouldComponentUpdate(nextProps: PassageProps, nextState: PassageState): any | boolean;
60
59
  componentDidUpdate(): void;
@@ -94,8 +93,8 @@ 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;
98
- simpleValidate(rubric: Rubric): PerseusScore;
96
+ getUserInput(): PerseusPassageUserInput;
97
+ simpleValidate(): import("../../types").PerseusScore;
99
98
  /**
100
99
  * Rendering
101
100
  *
@@ -1,22 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { PerseusPassageRefWidgetOptions } from "../../perseus-types";
4
- import type { ChangeFn, PerseusScore, 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
- };
4
+ import type { ChangeFn, WidgetProps } from "../../types";
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"];
@@ -37,16 +29,16 @@ declare class PassageRef extends React.Component<Props, State> {
37
29
  _throttledUpdateRange: () => void;
38
30
  static defaultProps: DefaultProps;
39
31
  state: State;
40
- static validate(userInput: UserInput, rubric: Rubric): PerseusScore;
32
+ static validate(): import("../../types").PerseusScore;
41
33
  componentDidMount(): void;
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;
49
- simpleValidate: (arg1: Rubric) => PerseusScore;
41
+ simpleValidate(): import("../../types").PerseusScore;
50
42
  render(): React.ReactNode;
51
43
  }
52
44
  declare const _default: Readonly<{
@@ -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;
@@ -20,10 +21,10 @@ declare class PassageRefTarget extends React.Component<Props> {
20
21
  }>;
21
22
  context: React.ContextType<typeof PerseusI18nContext>;
22
23
  static defaultProps: DefaultProps;
23
- static validate(state: any, rubric: any): any;
24
- getUserInput: () => any;
24
+ static validate(): import("../../types").PerseusScore;
25
+ getUserInput(): PerseusPassageRefTargetUserInput;
25
26
  change: (arg1: any, arg2: any, arg3: any) => any;
26
- simpleValidate: (arg1: any) => any;
27
+ simpleValidate(): import("../../types").PerseusScore;
27
28
  render(): React.ReactNode;
28
29
  }
29
30
  declare const _default: Readonly<{
@@ -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>;