@khanacademy/perseus 65.3.6 → 65.4.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 (60) hide show
  1. package/dist/components/scrollable-view.d.ts +1 -1
  2. package/dist/es/index.css +1 -1
  3. package/dist/es/index.css.map +1 -1
  4. package/dist/es/index.js +57 -55
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/hint-renderer.d.ts +6 -0
  7. package/dist/hints-renderer.d.ts +6 -0
  8. package/dist/index.css +1 -1
  9. package/dist/index.css.map +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +56 -54
  12. package/dist/index.js.map +1 -1
  13. package/dist/mixins/changeable.d.ts +14 -0
  14. package/dist/mixins/widget-prop-denylist.d.ts +5 -0
  15. package/dist/renderer.d.ts +23 -11
  16. package/dist/server-item-renderer.d.ts +10 -0
  17. package/dist/types.d.ts +47 -13
  18. package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +1 -1
  19. package/dist/widget-type-utils.d.ts +1 -1
  20. package/dist/widgets/categorizer/categorizer.d.ts +28 -10
  21. package/dist/widgets/cs-program/cs-program.d.ts +9 -5
  22. package/dist/widgets/definition/definition.d.ts +0 -1
  23. package/dist/widgets/dropdown/dropdown.d.ts +22 -9
  24. package/dist/widgets/explanation/explanation.d.ts +0 -1
  25. package/dist/widgets/expression/expression.d.ts +107 -11
  26. package/dist/widgets/free-response/free-response.d.ts +9 -7
  27. package/dist/widgets/graded-group-set/graded-group-set.d.ts +1 -3
  28. package/dist/widgets/grapher/grapher.d.ts +139 -14
  29. package/dist/widgets/grapher/util.d.ts +2 -2
  30. package/dist/widgets/group/group.d.ts +6 -0
  31. package/dist/widgets/iframe/iframe.d.ts +10 -8
  32. package/dist/widgets/image/image.d.ts +1 -2
  33. package/dist/widgets/input-number/input-number.d.ts +17 -6
  34. package/dist/widgets/interaction/interaction.d.ts +0 -2
  35. package/dist/widgets/interactive-graph.d.ts +102 -7
  36. package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +3 -2
  37. package/dist/widgets/interactive-graphs/locked-figures/utils.d.ts +2 -0
  38. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +2 -4
  39. package/dist/widgets/interactive-graphs/types.d.ts +2 -2
  40. package/dist/widgets/label-image/label-image.d.ts +28 -8
  41. package/dist/widgets/matcher/matcher.d.ts +19 -7
  42. package/dist/widgets/matrix/matrix.d.ts +30 -18
  43. package/dist/widgets/mock-widgets/mock-widget.d.ts +89 -8
  44. package/dist/widgets/number-line/number-line.d.ts +108 -13
  45. package/dist/widgets/numeric-input/numeric-input.class.d.ts +93 -4
  46. package/dist/widgets/numeric-input/numeric-input.d.ts +1 -2
  47. package/dist/widgets/orderer/orderer.d.ts +15 -8
  48. package/dist/widgets/passage-ref/passage-ref.d.ts +1 -2
  49. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +1 -3
  50. package/dist/widgets/phet-simulation/phet-simulation.d.ts +1 -2
  51. package/dist/widgets/plotter/plotter.d.ts +105 -6
  52. package/dist/widgets/radio/radio-component.d.ts +1 -1
  53. package/dist/widgets/radio/radio.class.new.d.ts +1 -1
  54. package/dist/widgets/radio/radio.d.ts +4 -0
  55. package/dist/widgets/radio/radio.ff.d.ts +2 -2
  56. package/dist/widgets/radio/radio.new.d.ts +2 -2
  57. package/dist/widgets/sorter/sorter.d.ts +26 -9
  58. package/dist/widgets/table/table.d.ts +88 -5
  59. package/dist/widgets/video/video.d.ts +0 -1
  60. package/package.json +7 -7
@@ -6,7 +6,7 @@ import type { WidgetProps } from "../types";
6
6
  import type { InteractiveGraphPromptJSON } from "../widget-ai-utils/interactive-graph/interactive-graph-ai-utils";
7
7
  import type { UnsupportedWidgetPromptJSON } from "../widget-ai-utils/unsupported-widget";
8
8
  import type { QuadraticCoefficient, SineCoefficient, Range } from "@khanacademy/kmath";
9
- import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypeSegment, GraphRange, LockedFigure, PerseusImageBackground, MarkingsType, PerseusInteractiveGraphUserInput, AxisLabelLocation } from "@khanacademy/perseus-core";
9
+ import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypeSegment, GraphRange, InteractiveGraphPublicWidgetOptions, LockedFigure, PerseusImageBackground, MarkingsType, PerseusInteractiveGraphUserInput, AxisLabelLocation } from "@khanacademy/perseus-core";
10
10
  type RenderProps = {
11
11
  /**
12
12
  * Where the little black axis lines & labels (ticks) should render.
@@ -89,9 +89,7 @@ type RenderProps = {
89
89
  */
90
90
  graph: PerseusGraphType;
91
91
  /**
92
- * The correct answer for this widget. Will be undefined if the graph is
93
- * being provided answerless data (e.g. because the learner has not yet
94
- * submitted their guess).
92
+ * The correct answer for this widget.
95
93
  */
96
94
  correct?: PerseusGraphType;
97
95
  /**
@@ -108,7 +106,7 @@ type RenderProps = {
108
106
  */
109
107
  fullGraphAriaDescription?: string;
110
108
  };
111
- type Props = WidgetProps<RenderProps>;
109
+ type Props = WidgetProps<RenderProps, PerseusInteractiveGraphUserInput>;
112
110
  type State = any;
113
111
  type DefaultProps = {
114
112
  labels: string[];
@@ -119,13 +117,103 @@ type DefaultProps = {
119
117
  markings: Props["markings"];
120
118
  showTooltips: Props["showTooltips"];
121
119
  showProtractor: Props["showProtractor"];
122
- graph: Props["graph"];
120
+ userInput: Props["userInput"];
123
121
  };
124
122
  declare class InteractiveGraph extends React.Component<Props, State> {
125
123
  mafsRef: React.RefObject<StatefulMafsGraphType>;
126
124
  static defaultProps: DefaultProps;
127
125
  getUserInput(): PerseusInteractiveGraphUserInput;
128
126
  getPromptJSON(): InteractiveGraphPromptJSON | UnsupportedWidgetPromptJSON;
127
+ /**
128
+ * @deprecated and likely very broken API
129
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
130
+ */
131
+ getSerializedState(): {
132
+ graph: PerseusGraphType;
133
+ step: [number, number];
134
+ gridStep?: [x: number, y: number];
135
+ snapStep?: [x: number, y: number];
136
+ backgroundImage?: PerseusImageBackground;
137
+ markings: MarkingsType;
138
+ labels: string[];
139
+ labelLocation: AxisLabelLocation;
140
+ showProtractor: boolean;
141
+ showRuler?: boolean;
142
+ showTooltips?: boolean;
143
+ rulerLabel?: string;
144
+ rulerTicks?: number;
145
+ range: GraphRange;
146
+ correct?: PerseusGraphType;
147
+ lockedFigures: LockedFigure[];
148
+ fullGraphAriaLabel?: string;
149
+ fullGraphAriaDescription?: string;
150
+ reviewModeRubric?: Empty | null | undefined;
151
+ trackInteraction: (extraData?: Empty | undefined) => void;
152
+ widgetId: string;
153
+ alignment: string | null | undefined;
154
+ static: boolean | null | undefined;
155
+ problemNum: number | null | undefined;
156
+ apiOptions: Readonly<Readonly<{
157
+ isArticle?: boolean;
158
+ onFocusChange?: (newFocusPath: import("..").FocusPath, oldFocusPath: import("..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
159
+ GroupMetadataEditor?: React.ComponentType<any>;
160
+ showAlignmentOptions?: boolean;
161
+ readOnly?: boolean;
162
+ answerableCallback?: (arg1: boolean) => unknown;
163
+ getAnotherHint?: () => unknown;
164
+ interactionCallback?: (widgetData: {
165
+ [widgetId: string]: any;
166
+ }) => void;
167
+ groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
168
+ imagePlaceholder?: React.ReactNode;
169
+ widgetPlaceholder?: React.ReactNode;
170
+ baseElements?: {
171
+ Link: React.ComponentType<any>;
172
+ };
173
+ imagePreloader?: (dimensions: import("../types").Dimensions) => React.ReactNode;
174
+ trackInteraction?: (args: {
175
+ type: string;
176
+ id: string;
177
+ correct?: boolean;
178
+ } & Partial<import("../types").TrackingGradedGroupExtraArguments> & Partial<{
179
+ visible: number;
180
+ }>) => void;
181
+ customKeypad?: boolean;
182
+ nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
183
+ isMobile?: boolean;
184
+ isMobileApp?: boolean;
185
+ setDrawingAreaAvailable?: (arg1: boolean) => unknown;
186
+ hintProgressColor?: string;
187
+ canScrollPage?: boolean;
188
+ editorChangeDelay?: number;
189
+ flags?: Record<"new-radio-widget", boolean>;
190
+ onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
191
+ }> & {
192
+ baseElements: NonNullable<import("..").APIOptions["baseElements"]>;
193
+ canScrollPage: NonNullable<import("..").APIOptions["canScrollPage"]>;
194
+ editorChangeDelay: NonNullable<import("..").APIOptions["editorChangeDelay"]>;
195
+ groupAnnotator: NonNullable<import("..").APIOptions["groupAnnotator"]>;
196
+ isArticle: NonNullable<import("..").APIOptions["isArticle"]>;
197
+ isMobile: NonNullable<import("..").APIOptions["isMobile"]>;
198
+ isMobileApp: NonNullable<import("..").APIOptions["isMobileApp"]>;
199
+ onFocusChange: NonNullable<import("..").APIOptions["onFocusChange"]>;
200
+ readOnly: NonNullable<import("..").APIOptions["readOnly"]>;
201
+ setDrawingAreaAvailable: NonNullable<import("..").APIOptions["setDrawingAreaAvailable"]>;
202
+ showAlignmentOptions: NonNullable<import("..").APIOptions["showAlignmentOptions"]>;
203
+ }>;
204
+ keypadElement?: any;
205
+ questionCompleted?: boolean;
206
+ onFocus: (blurPath: import("..").FocusPath) => void;
207
+ onBlur: (blurPath: import("..").FocusPath) => void;
208
+ findWidgets: (criterion: import("../types").FilterCriterion) => ReadonlyArray<import("../types").Widget>;
209
+ reviewMode: boolean;
210
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
211
+ onChange: import("..").ChangeHandler;
212
+ handleUserInput: (newUserInput: PerseusGraphType, cb?: () => void, silent?: boolean) => void;
213
+ isLastUsedWidget: boolean;
214
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
215
+ containerSizeClass: import("../util/sizing-utils").SizeClass;
216
+ };
129
217
  render(): React.JSX.Element;
130
218
  /**
131
219
  * @param {object} graph Like props.graph or props.correct
@@ -175,12 +263,19 @@ declare class InteractiveGraph extends React.Component<Props, State> {
175
263
  static getRayEquationString(props: Props): string;
176
264
  static getPolygonEquationString(props: Props): string;
177
265
  static getAngleEquationString(props: Props): string;
178
- static getUserInputFromProps(props: Props): PerseusGraphType;
179
266
  }
267
+ /**
268
+ * @deprecated and likely a very broken API
269
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
270
+ */
271
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusInteractiveGraphUserInput;
272
+ declare function getStartUserInput(options: InteractiveGraphPublicWidgetOptions): PerseusGraphType;
180
273
  declare const _default: {
181
274
  name: string;
182
275
  displayName: string;
183
276
  widget: typeof InteractiveGraph;
184
277
  staticTransform: <T>(value: T) => T;
278
+ getStartUserInput: typeof getStartUserInput;
279
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
185
280
  };
186
281
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import { vec } from "mafs";
2
2
  import type { SnapTo } from "./types";
3
3
  import type { Coord } from "../../interactive2/types";
4
- import type { AxisLabelLocation, CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedLineStyle, MarkingsType, PerseusRenderer } from "@khanacademy/perseus-core";
4
+ import type { AxisLabelLocation, CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedLineStyle, MarkingsType, PerseusRenderer, StrokeWeight } from "@khanacademy/perseus-core";
5
5
  export type LockedFunctionOptions = {
6
6
  color?: LockedFigureColor;
7
7
  strokeStyle?: LockedLineStyle;
@@ -143,7 +143,8 @@ declare class InteractiveGraphQuestionBuilder {
143
143
  color?: LockedFigureColor;
144
144
  showVertices?: boolean;
145
145
  fillStyle?: LockedFigureFillType;
146
- strokeStyle?: "solid" | "dashed";
146
+ strokeStyle?: LockedLineStyle;
147
+ weight?: StrokeWeight;
147
148
  labels?: LockedFigureLabelOptions[];
148
149
  ariaLabel?: string;
149
150
  }): InteractiveGraphQuestionBuilder;
@@ -1 +1,3 @@
1
+ import type { StrokeWeight } from "@khanacademy/perseus-core";
2
+ export declare const strokeWeights: Record<StrokeWeight, number>;
1
3
  export declare function clampDomain(domain: [number, number], graphBounds: [number, number]): [number, number] | null;
@@ -6,9 +6,7 @@ export type StatefulMafsGraphProps = {
6
6
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
7
7
  graph: PerseusGraphType;
8
8
  /**
9
- * The correct answer for this widget. Will be undefined if the graph is
10
- * being provided answerless data (e.g. because the learner has not yet
11
- * submitted their guess).
9
+ * The correct answer for this widget.
12
10
  */
13
11
  correct?: PerseusGraphType;
14
12
  lockedFigures: InteractiveGraphProps["lockedFigures"];
@@ -18,7 +16,7 @@ export type StatefulMafsGraphProps = {
18
16
  gridStep: [x: number, y: number];
19
17
  containerSizeClass: InteractiveGraphProps["containerSizeClass"];
20
18
  markings: InteractiveGraphProps["markings"];
21
- onChange: InteractiveGraphProps["onChange"];
19
+ onChange: (userInput: PerseusGraphType) => void;
22
20
  showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
23
21
  showProtractor: boolean;
24
22
  labels: ReadonlyArray<string>;
@@ -2,10 +2,10 @@ import type { InteractiveGraphAction } from "./reducer/interactive-graph-action"
2
2
  import type { Coord } from "../../interactive2/types";
3
3
  import type { WidgetProps } from "../../types";
4
4
  import type { QuadraticCoords } from "@khanacademy/kmath";
5
- import type { PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
5
+ import type { PerseusInteractiveGraphUserInput, PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
6
6
  import type { Interval, vec } from "mafs";
7
7
  import type { ReactNode } from "react";
8
- export type InteractiveGraphProps = WidgetProps<PerseusInteractiveGraphWidgetOptions>;
8
+ export type InteractiveGraphProps = WidgetProps<PerseusInteractiveGraphWidgetOptions, PerseusInteractiveGraphUserInput>;
9
9
  export type Dispatch = (action: InteractiveGraphAction) => unknown;
10
10
  export type MafsGraphProps<T extends InteractiveGraphState> = {
11
11
  graphState: T;
@@ -11,7 +11,7 @@ import Marker from "./marker";
11
11
  import type { DependencyProps } from "../../dependencies";
12
12
  import type { Widget, WidgetProps } from "../../types";
13
13
  import type { LabelImagePromptJSON } from "../../widget-ai-utils/label-image/label-image-ai-utils";
14
- import type { InteractiveMarkerType, PerseusLabelImageWidgetOptions, PerseusLabelImageUserInput, ShowSolutions } from "@khanacademy/perseus-core";
14
+ import type { InteractiveMarkerType, PerseusLabelImageWidgetOptions, PerseusLabelImageUserInput, LabelImagePublicWidgetOptions, ShowSolutions, PerseusLabelImageUserInputMarker } from "@khanacademy/perseus-core";
15
15
  type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
16
16
  /**
17
17
  * Represents a direction vector.
@@ -37,7 +37,8 @@ export type OptionalAnswersMarkerType = Omit<InteractiveMarkerType, "answers"> &
37
37
  type Options = Omit<PerseusLabelImageWidgetOptions, "markers"> & {
38
38
  markers: ReadonlyArray<OptionalAnswersMarkerType>;
39
39
  };
40
- type Props = WidgetProps<Options> & DependencyProps & {
40
+ type Props = WidgetProps<Options, PerseusLabelImageUserInput> & {
41
+ analytics: DependencyProps["analytics"];
41
42
  preferredPopoverDirection?: PreferredPopoverDirection;
42
43
  };
43
44
  type LabelImageState = {
@@ -46,14 +47,15 @@ type LabelImageState = {
46
47
  hideAnswers: boolean;
47
48
  };
48
49
  /**
49
- * Get marker with the appropriate selection state for current display mode.
50
+ * Get user input marker with the appropriate selection state for current display mode.
50
51
  * When showing solutions, it auto-selects correct answers, or clears
51
52
  * selections for markers without answers.
52
53
  *
53
- * @param marker - The marker to update.
54
- * @returns The updated marker state.
54
+ * @param marker - The widget options marker (possibly with answer).
55
+ * @param userInputMarker - The user input marker (with user selection).
56
+ * @returns A modified version of user input, possibly with correct answer.
55
57
  */
56
- export declare function getUpdatedMarkerState(marker: OptionalAnswersMarkerType, reviewMode: boolean, showSolutions?: ShowSolutions): OptionalAnswersMarkerType;
58
+ export declare function getComputedSelectedState(marker: OptionalAnswersMarkerType, userInputMarker: PerseusLabelImageUserInputMarker, reviewMode: boolean, showSolutions?: ShowSolutions): PerseusLabelImageUserInputMarker;
57
59
  export declare class LabelImage extends React.Component<Props, LabelImageState> implements Widget {
58
60
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
59
61
  context: React.ContextType<typeof PerseusI18nContext>;
@@ -83,24 +85,42 @@ export declare class LabelImage extends React.Component<Props, LabelImageState>
83
85
  constructor(props: Props);
84
86
  componentDidMount(): void;
85
87
  componentWillUnmount(): void;
88
+ /**
89
+ * TODO: remove this when everything is pulling from Renderer state
90
+ * @deprecated get user input from Renderer state
91
+ */
86
92
  getUserInput(): PerseusLabelImageUserInput;
87
93
  getPromptJSON(): LabelImagePromptJSON;
88
- handleMarkerChange(index: number, marker: Props["markers"][number]): void;
94
+ handleMarkerChange(index: number, marker: PerseusLabelImageUserInput["markers"][number]): void;
89
95
  activateMarker(index: number, opened: boolean): void;
90
96
  handleMarkerKeyDown(index: number, e: React.KeyboardEvent): void;
91
97
  handleAnswerChoicesChangeForMarker(index: number, selection: ReadonlyArray<boolean>): void;
92
98
  renderMarkers(): ReadonlyArray<React.ReactNode>;
93
99
  renderInstructions(): React.ReactNode;
100
+ /**
101
+ * @deprecated and likely very broken API
102
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
103
+ */
104
+ getSerializedState(): any;
94
105
  render(): React.ReactNode;
95
106
  }
107
+ declare function getStartUserInput(options: LabelImagePublicWidgetOptions): PerseusLabelImageUserInput;
108
+ /**
109
+ * @deprecated and likely a very broken API
110
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
111
+ */
112
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusLabelImageUserInput;
96
113
  declare const _default: {
97
114
  name: string;
98
115
  displayName: string;
99
116
  widget: React.ForwardRefExoticComponent<Omit<Omit<PerseusLabelImageWidgetOptions, "markers"> & {
100
117
  markers: ReadonlyArray<OptionalAnswersMarkerType>;
101
- } & import("../../types").UniversalWidgetProps<Empty, Empty> & Partial<import("../..").PerseusDependenciesV2> & {
118
+ } & import("../../types").UniversalWidgetProps<Empty, PerseusLabelImageUserInput, Empty> & {
119
+ analytics: DependencyProps["analytics"];
102
120
  preferredPopoverDirection?: PreferredPopoverDirection;
103
121
  }, keyof import("../..").PerseusDependenciesV2> & React.RefAttributes<LabelImage>>;
104
122
  isLintable: true;
123
+ getStartUserInput: typeof getStartUserInput;
124
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
105
125
  };
106
126
  export default _default;
@@ -3,18 +3,17 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { SortableOption } from "../../components/sortable";
4
4
  import type { WidgetProps, Widget } from "../../types";
5
5
  import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
6
- import type { PerseusMatcherWidgetOptions, PerseusMatcherUserInput } from "@khanacademy/perseus-core";
7
- type RenderProps = PerseusMatcherWidgetOptions;
8
- type Props = WidgetProps<RenderProps>;
6
+ import type { PerseusMatcherWidgetOptions, PerseusMatcherUserInput, MatcherPublicWidgetOptions } from "@khanacademy/perseus-core";
7
+ type RenderProps = Pick<PerseusMatcherWidgetOptions, "labels" | "orderMatters" | "padding">;
8
+ type Props = WidgetProps<RenderProps, PerseusMatcherUserInput>;
9
9
  type DefaultProps = {
10
- left: Props["left"];
11
- right: Props["right"];
12
10
  labels: Props["labels"];
13
11
  orderMatters: Props["orderMatters"];
14
12
  padding: Props["padding"];
15
13
  problemNum: Props["problemNum"];
16
14
  onChange: Props["onChange"];
17
15
  linterContext: Props["linterContext"];
16
+ userInput: Props["userInput"];
18
17
  };
19
18
  type State = {
20
19
  leftHeight: number;
@@ -26,19 +25,32 @@ export declare class Matcher extends React.Component<Props, State> implements Wi
26
25
  context: React.ContextType<typeof PerseusI18nContext>;
27
26
  static defaultProps: DefaultProps;
28
27
  state: State;
29
- changeAndTrack: (arg1: any) => void;
28
+ changeAndTrack: () => void;
30
29
  onMeasureLeft: (arg1: any) => void;
31
30
  onMeasureRight: (arg1: any) => void;
32
- getUserInput: () => PerseusMatcherUserInput;
31
+ _getUserInputFromSortable: () => PerseusMatcherUserInput;
32
+ /**
33
+ * TODO: remove this when everything is pulling from Renderer state
34
+ * @deprecated get user input from Renderer state
35
+ */
36
+ getUserInput(): PerseusMatcherUserInput;
33
37
  getPromptJSON(): MatcherPromptJSON;
34
38
  moveLeftOptionToIndex: (option: SortableOption, index: number) => void;
35
39
  moveRightOptionToIndex: (option: SortableOption, index: number) => void;
36
40
  render(): React.ReactElement;
37
41
  }
42
+ declare function getStartUserInput(options: MatcherPublicWidgetOptions, problemNum: number): PerseusMatcherUserInput;
43
+ /**
44
+ * @deprecated and likely a very broken API
45
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
46
+ */
47
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusMatcherUserInput;
38
48
  declare const _default: {
39
49
  name: string;
40
50
  displayName: string;
41
51
  widget: typeof Matcher;
42
52
  isLintable: true;
53
+ getStartUserInput: typeof getStartUserInput;
54
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
43
55
  };
44
56
  export default _default;
@@ -2,33 +2,22 @@ import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { FocusPath, Widget, WidgetProps } from "../../types";
4
4
  import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
5
- import type { MatrixPublicWidgetOptions, PerseusMatrixUserInput, PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
6
- type ExternalProps = WidgetProps<{
7
- prefix: string;
8
- suffix: string;
9
- answers: PerseusMatrixWidgetAnswers;
5
+ import type { MatrixPublicWidgetOptions, PerseusMatrixUserInput, PerseusMatrixWidgetOptions } from "@khanacademy/perseus-core";
6
+ type RenderProps = Pick<PerseusMatrixWidgetOptions, "matrixBoardSize" | "prefix" | "suffix">;
7
+ type Props = WidgetProps<RenderProps, PerseusMatrixUserInput> & {
10
8
  cursorPosition: ReadonlyArray<number>;
11
- matrixBoardSize: ReadonlyArray<number>;
12
- static?: boolean | undefined;
13
- }>;
14
- type RenderProps = MatrixPublicWidgetOptions & {
15
- emptyMatrix: ReadonlyArray<ReadonlyArray<string>>;
16
- };
17
- type Props = ExternalProps & {
18
- onChange: (arg1: {
9
+ onChange: (nextProps: {
19
10
  cursorPosition?: ReadonlyArray<number>;
20
- answers?: ReadonlyArray<ReadonlyArray<number | string>>;
21
- }, arg2: () => boolean) => void;
22
- numericInput?: boolean;
11
+ }, cb: () => boolean) => void;
23
12
  };
24
13
  type DefaultProps = {
25
14
  matrixBoardSize: Props["matrixBoardSize"];
26
- answers: Props["answers"];
27
15
  prefix: string;
28
16
  suffix: string;
29
17
  cursorPosition: ReadonlyArray<number>;
30
18
  apiOptions: Props["apiOptions"];
31
19
  linterContext: Props["linterContext"];
20
+ userInput: PerseusMatrixUserInput;
32
21
  };
33
22
  type State = {
34
23
  enterTheMatrix: number;
@@ -50,18 +39,41 @@ declare class Matrix extends React.Component<Props, State> implements Widget {
50
39
  setInputValue: (arg1: any, arg2: any, arg3: any) => void;
51
40
  handleKeyDown: (arg1: any, arg2: any, arg3: any) => void;
52
41
  onValueChange: (arg1: any, arg2: any, arg3: any, arg4: any) => void;
42
+ /**
43
+ * TODO: remove this when everything is pulling from Renderer state
44
+ * @deprecated get user input from Renderer state
45
+ */
53
46
  getUserInput(): PerseusMatrixUserInput;
54
47
  getPromptJSON(): MatrixPromptJSON;
48
+ /**
49
+ * @deprecated and likely very broken API
50
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
51
+ */
52
+ getSerializedState(): any;
55
53
  render(): React.ReactNode;
56
54
  }
55
+ /**
56
+ * TODO: I don't really think we need this. The default for a transform
57
+ * is an identity function and all this is doing is taking a selection from
58
+ * widget options; it's probably fine to pass all widget options down.
59
+ * @deprecated [LEMS-3199]
60
+ */
57
61
  declare function transform(widgetOptions: MatrixPublicWidgetOptions): RenderProps;
62
+ declare function getCorrectUserInput(options: PerseusMatrixWidgetOptions): PerseusMatrixUserInput;
63
+ /**
64
+ * @deprecated and likely a very broken API
65
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
66
+ */
67
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusMatrixUserInput;
58
68
  declare const _default: {
59
69
  name: string;
60
70
  displayName: string;
61
71
  hidden: true;
62
72
  widget: typeof Matrix;
63
73
  transform: typeof transform;
64
- staticTransform: (arg1: any) => any;
74
+ staticTransform: typeof transform;
65
75
  isLintable: true;
76
+ getCorrectUserInput: typeof getCorrectUserInput;
77
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
66
78
  };
67
79
  export default _default;
@@ -3,12 +3,10 @@ import type { MockWidgetOptions } from "./mock-widget-types";
3
3
  import type { WidgetProps, Widget, FocusPath } from "../../types";
4
4
  import type { MockWidgetPromptJSON } from "../../widget-ai-utils/mock-widget/prompt-utils";
5
5
  import type { PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
6
- type ExternalProps = WidgetProps<MockWidgetOptions>;
6
+ type ExternalProps = WidgetProps<MockWidgetOptions, PerseusMockWidgetUserInput>;
7
+ type Props = ExternalProps;
7
8
  type DefaultProps = {
8
- currentValue: Props["currentValue"];
9
- };
10
- type Props = ExternalProps & {
11
- currentValue: string;
9
+ userInput: Props["userInput"];
12
10
  };
13
11
  /**
14
12
  * This is a Mock Perseus widget, which is used for our various rendering tests
@@ -25,21 +23,104 @@ type Props = ExternalProps & {
25
23
  declare class MockWidgetComponent extends React.Component<Props> implements Widget {
26
24
  static defaultProps: DefaultProps;
27
25
  inputRef: HTMLElement | null;
28
- static getUserInputFromProps(props: Props): PerseusMockWidgetUserInput;
29
26
  getPromptJSON(): MockWidgetPromptJSON;
30
- setInputValue: (arg1: FocusPath, arg2: string, arg3?: () => unknown | null | undefined) => void;
27
+ setInputValue: (path: FocusPath, newValue: string, cb?: () => unknown | null | undefined) => void;
31
28
  focus: () => boolean;
32
29
  focusInputPath: () => void;
33
30
  blurInputPath: () => void;
34
31
  getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
32
+ /**
33
+ * TODO: remove this when everything is pulling from Renderer state
34
+ * @deprecated get user input from Renderer state
35
+ */
35
36
  getUserInput(): PerseusMockWidgetUserInput;
36
- handleChange: (arg1: string, arg2?: () => unknown | null | undefined) => void;
37
+ handleChange: (newValue: string, cb?: () => unknown | null | undefined) => void;
38
+ /**
39
+ * @deprecated and likely very broken API
40
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
41
+ */
42
+ getSerializedState(): {
43
+ currentValue: string;
44
+ static: boolean;
45
+ value: string;
46
+ reviewModeRubric?: Empty | null | undefined;
47
+ trackInteraction: (extraData?: Empty | undefined) => void;
48
+ widgetId: string;
49
+ alignment: string | null | undefined;
50
+ problemNum: number | null | undefined;
51
+ apiOptions: Readonly<Readonly<{
52
+ isArticle?: boolean;
53
+ onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
54
+ GroupMetadataEditor?: React.ComponentType<any>;
55
+ showAlignmentOptions?: boolean;
56
+ readOnly?: boolean;
57
+ answerableCallback?: (arg1: boolean) => unknown;
58
+ getAnotherHint?: () => unknown;
59
+ interactionCallback?: (widgetData: {
60
+ [widgetId: string]: any;
61
+ }) => void;
62
+ groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
63
+ imagePlaceholder?: React.ReactNode;
64
+ widgetPlaceholder?: React.ReactNode;
65
+ baseElements?: {
66
+ Link: React.ComponentType<any>;
67
+ };
68
+ imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
69
+ trackInteraction?: (args: {
70
+ type: string;
71
+ id: string;
72
+ correct?: boolean;
73
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
74
+ visible: number;
75
+ }>) => void;
76
+ customKeypad?: boolean;
77
+ nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
78
+ isMobile?: boolean;
79
+ isMobileApp?: boolean;
80
+ setDrawingAreaAvailable?: (arg1: boolean) => unknown;
81
+ hintProgressColor?: string;
82
+ canScrollPage?: boolean;
83
+ editorChangeDelay?: number;
84
+ flags?: Record<"new-radio-widget", boolean>;
85
+ onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
86
+ }> & {
87
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
88
+ canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
89
+ editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
90
+ groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
91
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
92
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
93
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
94
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
95
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
96
+ setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
97
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
98
+ }>;
99
+ keypadElement?: any;
100
+ questionCompleted?: boolean;
101
+ onFocus: (blurPath: FocusPath) => void;
102
+ onBlur: (blurPath: FocusPath) => void;
103
+ findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
104
+ reviewMode: boolean;
105
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
106
+ onChange: import("../..").ChangeHandler;
107
+ handleUserInput: (newUserInput: PerseusMockWidgetUserInput, cb?: () => void, silent?: boolean) => void;
108
+ isLastUsedWidget: boolean;
109
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
110
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
111
+ };
37
112
  render(): React.ReactNode;
38
113
  }
114
+ /**
115
+ * @deprecated and likely a very broken API
116
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
117
+ */
118
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusMockWidgetUserInput;
39
119
  declare const _default: {
40
120
  name: string;
41
121
  displayName: string;
42
122
  widget: typeof MockWidgetComponent;
43
123
  isLintable: true;
124
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
44
125
  };
45
126
  export default _default;