@khanacademy/perseus 67.1.2 → 68.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 (40) hide show
  1. package/dist/es/index.js +20 -18
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/hint-renderer.d.ts +0 -4
  4. package/dist/hints-renderer.d.ts +0 -4
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +19 -16
  7. package/dist/index.js.map +1 -1
  8. package/dist/mixins/widget-prop-denylist.d.ts +1 -1
  9. package/dist/renderer.d.ts +5 -16
  10. package/dist/server-item-renderer.d.ts +1 -5
  11. package/dist/types.d.ts +5 -11
  12. package/dist/user-input-manager.d.ts +1 -5
  13. package/dist/util/extract-widget-ids.d.ts +8 -0
  14. package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +1 -0
  15. package/dist/widgets/categorizer/categorizer.d.ts +2 -2
  16. package/dist/widgets/cs-program/cs-program.d.ts +1 -1
  17. package/dist/widgets/dropdown/dropdown.d.ts +2 -10
  18. package/dist/widgets/expression/expression.d.ts +4 -3
  19. package/dist/widgets/grapher/grapher.d.ts +3 -2
  20. package/dist/widgets/group/group.d.ts +0 -4
  21. package/dist/widgets/iframe/iframe.d.ts +1 -1
  22. package/dist/widgets/input-number/input-number.d.ts +2 -2
  23. package/dist/widgets/interactive-graphs/interactive-graph.d.ts +3 -2
  24. package/dist/widgets/label-image/label-image.d.ts +2 -2
  25. package/dist/widgets/matcher/matcher.d.ts +1 -1
  26. package/dist/widgets/matrix/matrix.d.ts +2 -2
  27. package/dist/widgets/mock-widgets/mock-widget.d.ts +3 -2
  28. package/dist/widgets/number-line/number-line.d.ts +2 -2
  29. package/dist/widgets/numeric-input/numeric-input.class.d.ts +3 -2
  30. package/dist/widgets/orderer/orderer.d.ts +2 -2
  31. package/dist/widgets/plotter/plotter.d.ts +3 -2
  32. package/dist/widgets/radio/multiple-choice-widget.new.d.ts +0 -4
  33. package/dist/widgets/radio/radio-component.d.ts +2 -4
  34. package/dist/widgets/radio/radio.d.ts +0 -4
  35. package/dist/widgets/radio/radio.ff.d.ts +7 -6
  36. package/dist/widgets/radio/util.d.ts +6 -3
  37. package/dist/widgets/radio/utils/general-utils.d.ts +2 -4
  38. package/dist/widgets/sorter/sorter.d.ts +2 -2
  39. package/dist/widgets/table/table.d.ts +2 -1
  40. package/package.json +7 -7
@@ -11,7 +11,7 @@
11
11
  */
12
12
  /**
13
13
  * @deprecated and likely a very broken API
14
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
14
+ * [LEMS-3185] do not trust serializedState
15
15
  */
16
16
  declare const denylist: string[];
17
17
  export declare function excludeDenylistKeys(obj: Record<any, any>): {};
@@ -5,8 +5,8 @@ import TranslationLinter from "./translation-linter";
5
5
  import WidgetContainer from "./widget-container";
6
6
  import type { DependenciesContext } from "./dependencies";
7
7
  import type { PerseusStrings } from "./strings";
8
- import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, SerializedState, Widget, WidgetProps } from "./types";
9
- import type { HandleUserInputCallback, InitializeUserInputCallback, RestoreUserInputFromSerializedStateCallback } from "./user-input-manager";
8
+ import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, Widget, WidgetProps } from "./types";
9
+ import type { HandleUserInputCallback, InitializeUserInputCallback } from "./user-input-manager";
10
10
  import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
11
11
  import type { KeypadAPI } from "@khanacademy/math-input";
12
12
  import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, PerseusScore, UserInputMap, UserInputArray } from "@khanacademy/perseus-core";
@@ -24,7 +24,6 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
24
24
  userInput?: UserInputMap;
25
25
  handleUserInput?: HandleUserInputCallback;
26
26
  initializeUserInput?: InitializeUserInputCallback;
27
- restoreUserInputFromSerializedState?: RestoreUserInputFromSerializedStateCallback;
28
27
  apiOptions?: APIOptions;
29
28
  alwaysUpdate?: boolean;
30
29
  findExternalWidgets: any;
@@ -43,10 +42,6 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
43
42
  */
44
43
  showSolutions?: ShowSolutions;
45
44
  content: PerseusRenderer["content"];
46
- /**
47
- * @deprecated - do not use in new code.
48
- */
49
- serializedState?: any;
50
45
  /**
51
46
  * If linterContext.highlightLint is true, then content will be passed to
52
47
  * the linter and any warnings will be highlighted in the rendered output.
@@ -69,7 +64,7 @@ type State = {
69
64
  jiptContent: any;
70
65
  lastUsedWidgetId: string | null | undefined;
71
66
  };
72
- type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "highlightedWidgets" | "images" | "linterContext" | "onInteractWithWidget" | "onRender" | "questionCompleted" | "showSolutions" | "reviewMode" | "serializedState" | "widgets">>;
67
+ type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "highlightedWidgets" | "images" | "linterContext" | "onInteractWithWidget" | "onRender" | "questionCompleted" | "showSolutions" | "reviewMode" | "widgets">>;
73
68
  /**
74
69
  * We want to be able to reset the question state when we go
75
70
  * from one question to another question. However it's kind of tricky:
@@ -114,13 +109,11 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
114
109
  _getDefaultWidgetInfo: (widgetId: string) => any;
115
110
  _getWidgetInfo: (widgetId: string) => PerseusWidget;
116
111
  renderWidget: (impliedType: string, id: string, state: WidgetState) => null | React.ReactNode;
112
+ _getWidgetIndexById(id: string): number;
117
113
  getWidgetProps(widgetId: string): WidgetProps<any, any, PerseusWidgetOptions>;
118
114
  /**
119
115
  * Serializes the questions state so it can be recovered.
120
116
  *
121
- * The return value of this function can be sent to the
122
- * `restoreSerializedState` method to restore this state.
123
- *
124
117
  * If an instance of widgetProps is passed in, it generates the serialized
125
118
  * state from that instead of the current widget props.
126
119
  */
@@ -130,10 +123,6 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
130
123
  getSerializedState: (widgetProps?: any) => {
131
124
  [id: string]: any;
132
125
  };
133
- /**
134
- * @deprecated - do not use in new code.
135
- */
136
- restoreSerializedState: (serializedState: SerializedState, callback?: () => void) => void;
137
126
  /**
138
127
  * Allows inter-widget communication.
139
128
  *
@@ -196,7 +185,7 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
196
185
  * Serializes widget state. Seems to be used only by editors though.
197
186
  *
198
187
  * @deprecated and likely a very broken API
199
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
188
+ * [LEMS-3185] do not trust serializedState
200
189
  */
201
190
  serialize: () => Record<any, any>;
202
191
  /**
@@ -53,7 +53,7 @@ type State = {
53
53
  };
54
54
  /**
55
55
  * @deprecated and likely a very broken API
56
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
56
+ * [LEMS-3185] do not trust serializedState
57
57
  */
58
58
  type SerializedState = {
59
59
  question: any;
@@ -117,10 +117,6 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
117
117
  * @deprecated - do not use in new code.
118
118
  */
119
119
  getSerializedState(): SerializedState;
120
- /**
121
- * @deprecated - do not use in new code.
122
- */
123
- restoreSerializedState(state: SerializedState, callback?: () => void): void;
124
120
  setAssetStatus: (assetKey: string, status: boolean) => void;
125
121
  render(): React.ReactNode;
126
122
  }
package/dist/types.d.ts CHANGED
@@ -14,15 +14,14 @@ export type Dimensions = {
14
14
  };
15
15
  export type DeviceType = "phone" | "tablet" | "desktop";
16
16
  /**
17
- * This is the type returned by a widget's `getSerializedState` function (and
18
- * provided to the same widget's `restoreSerializedState` function). However,
17
+ * This is the type returned by a widget's `getSerializedState` function. However,
19
18
  * note that in most cases the widgets do _not_ implement these functions.
20
19
  * In that case, the `Renderer` just returns the widget's render props as the
21
20
  * serialized state.
22
21
  */
23
22
  /**
24
23
  * @deprecated and likely a very broken API
25
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
24
+ * [LEMS-3185] do not trust serializedState
26
25
  */
27
26
  export type SerializedState = Record<string, any>;
28
27
  /**
@@ -47,19 +46,13 @@ export interface Widget {
47
46
  } | boolean;
48
47
  getDOMNodeForPath?: (path: FocusPath) => Element | Text | null;
49
48
  /**
50
- * Returns widget state that can be passed back to `restoreSerializedState`
51
- * to put the widget back into exactly the same state. If the widget does
52
- * not implement this function, the renderer simply returns all of the
53
- * widget's props.
49
+ * If the widget does not implement this function,
50
+ * the renderer simply returns all of the widget's props.
54
51
  */
55
52
  /**
56
53
  * @deprecated - do not use in new code.
57
54
  */
58
55
  getSerializedState?: () => SerializedState;
59
- /**
60
- * @deprecated - do not use in new code.
61
- */
62
- restoreSerializedState?: (props: any, callback: () => void) => any;
63
56
  blurInputPath?: (path: FocusPath) => void;
64
57
  focusInputPath?: (path: FocusPath) => void;
65
58
  getInputPaths?: () => ReadonlyArray<FocusPath>;
@@ -395,6 +388,7 @@ export type UniversalWidgetProps<ReviewModeRubric = Empty, TUserInput = Empty, T
395
388
  reviewModeRubric?: ReviewModeRubric | null | undefined;
396
389
  trackInteraction: (extraData?: TrackingExtraArgs) => void;
397
390
  widgetId: string;
391
+ widgetIndex: number;
398
392
  alignment: string | null | undefined;
399
393
  static: boolean | null | undefined;
400
394
  problemNum: number | null | undefined;
@@ -1,19 +1,15 @@
1
1
  import type { PerseusWidgetsMap, UserInputMap } from "@khanacademy/perseus-core";
2
2
  export type InitializeUserInputCallback = (widgetOptions: PerseusWidgetsMap, problemNum: number) => void;
3
- export type RestoreUserInputFromSerializedStateCallback = (serializedState: unknown, widgetOptions: PerseusWidgetsMap) => void;
4
3
  export type HandleUserInputCallback = (widgetId: string, userInput: UserInputMap[keyof UserInputMap], widgetsEmpty: boolean) => void;
5
4
  type FunctionChildParams = {
6
5
  userInput: UserInputMap;
7
6
  handleUserInput: HandleUserInputCallback;
8
7
  initializeUserInput: InitializeUserInputCallback;
9
- /**
10
- * @deprecated - do not use in new code.
11
- */
12
- restoreUserInputFromSerializedState: RestoreUserInputFromSerializedStateCallback;
13
8
  };
14
9
  type Props = {
15
10
  widgets: PerseusWidgetsMap;
16
11
  problemNum: number;
12
+ initialUserInput?: UserInputMap;
17
13
  handleUserInput?: (userInput: UserInputMap, widgetsEmpty: boolean) => void;
18
14
  children: (payload: FunctionChildParams) => JSX.Element | null;
19
15
  };
@@ -0,0 +1,8 @@
1
+ import type { PerseusRenderer } from "@khanacademy/perseus-core";
2
+ /**
3
+ * Extracts widget IDs from a PerseusRenderer in the order they appear in the content.
4
+ * Handles deduplication by only including the first occurrence of each widget ID.
5
+ */
6
+ export declare function extractWidgetIds(perseusRenderer: PerseusRenderer, options?: {
7
+ inline?: boolean;
8
+ }): ReadonlyArray<string>;
@@ -3,6 +3,7 @@ import type { PerseusRadioUserInput, RecursiveReadonly } from "@khanacademy/pers
3
3
  import type React from "react";
4
4
  type BasicOption = {
5
5
  value: string;
6
+ id: string;
6
7
  rationale?: string;
7
8
  };
8
9
  export type RadioPromptJSON = {
@@ -20,7 +20,7 @@ export declare class Categorizer extends React.Component<Props, State> implement
20
20
  state: State;
21
21
  /**
22
22
  * @deprecated and likely very broken API
23
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
23
+ * [LEMS-3185] do not trust serializedState
24
24
  */
25
25
  getSerializedState(): any;
26
26
  getPromptJSON(): CategorizerPromptJSON;
@@ -34,7 +34,7 @@ type RenderProps = {
34
34
  };
35
35
  /**
36
36
  * @deprecated and likely a very broken API
37
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
37
+ * [LEMS-3185] do not trust serializedState
38
38
  */
39
39
  declare function getUserInputFromSerializedState(serializedState: any): PerseusCategorizerUserInput;
40
40
  /**
@@ -22,7 +22,7 @@ declare class CSProgram extends React.Component<Props> implements Widget {
22
22
  }
23
23
  /**
24
24
  * @deprecated and likely a very broken API
25
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
25
+ * [LEMS-3185] do not trust serializedState
26
26
  */
27
27
  declare function getUserInputFromSerializedState(serializedState: any): PerseusCSProgramUserInput;
28
28
  declare function getStartUserInput(): PerseusCSProgramUserInput;
@@ -20,22 +20,14 @@ declare class Dropdown extends React.Component<Props> implements Widget {
20
20
  getPromptJSON(): DropdownPromptJSON;
21
21
  /**
22
22
  * @deprecated and likely very broken API
23
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
23
+ * [LEMS-3185] do not trust serializedState
24
24
  */
25
25
  getSerializedState(): any;
26
- /**
27
- * @deprecated and likely very broken API
28
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
29
- */
30
- restoreSerializedState(state: any): {
31
- state: any;
32
- choices: any;
33
- };
34
26
  render(): React.ReactNode;
35
27
  }
36
28
  /**
37
29
  * @deprecated and likely a very broken API
38
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
30
+ * [LEMS-3185] do not trust serializedState
39
31
  */
40
32
  declare function getUserInputFromSerializedState(serializedState: any): PerseusDropdownUserInput;
41
33
  declare function getStartUserInput(): PerseusDropdownUserInput;
@@ -49,7 +49,7 @@ export declare class Expression extends React.Component<Props> implements Widget
49
49
  getKeypadConfiguration(): KeypadConfiguration;
50
50
  /**
51
51
  * @deprecated and likely very broken API
52
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
52
+ * [LEMS-3185] do not trust serializedState
53
53
  */
54
54
  getSerializedState(): {
55
55
  value: string;
@@ -64,6 +64,7 @@ export declare class Expression extends React.Component<Props> implements Widget
64
64
  reviewModeRubric?: Empty | null | undefined;
65
65
  trackInteraction: (extraData?: Empty | undefined) => void;
66
66
  widgetId: string;
67
+ widgetIndex: number;
67
68
  alignment: string | null | undefined;
68
69
  static: boolean | null | undefined;
69
70
  problemNum: number | null | undefined;
@@ -137,7 +138,7 @@ export declare class Expression extends React.Component<Props> implements Widget
137
138
  }
138
139
  /**
139
140
  * @deprecated and likely a very broken API
140
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
141
+ * [LEMS-3185] do not trust serializedState
141
142
  */
142
143
  declare function getUserInputFromSerializedState(serializedState: any): PerseusExpressionUserInput;
143
144
  declare function getStartUserInput(): PerseusExpressionUserInput;
@@ -155,7 +156,7 @@ declare const _default: {
155
156
  times: NonNullable<ExternalProps["times"]>;
156
157
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
157
158
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
158
- }, "static" | "onChange" | "ariaLabel" | "extraKeys" | "buttonsVisible" | "trackInteraction" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "keypadElement" | "isLastUsedWidget" | "handleUserInput" | "showSolutions" | "reviewMode" | "reviewModeRubric" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "visibleLabel" | "answerForms"> & {
159
+ }, "static" | "onChange" | "ariaLabel" | "extraKeys" | "buttonsVisible" | "trackInteraction" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "keypadElement" | "isLastUsedWidget" | "handleUserInput" | "showSolutions" | "reviewMode" | "reviewModeRubric" | "widgetIndex" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "visibleLabel" | "answerForms"> & {
159
160
  buttonSets?: import("@khanacademy/perseus-core").LegacyButtonSets | undefined;
160
161
  onFocus?: ((blurPath: import("../..").FocusPath) => void) | undefined;
161
162
  onBlur?: ((blurPath: import("../..").FocusPath) => void) | undefined;
@@ -23,7 +23,7 @@ declare class Grapher extends React.Component<Props> implements Widget {
23
23
  getPromptJSON(): GrapherPromptJSON;
24
24
  /**
25
25
  * @deprecated and likely very broken API
26
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
26
+ * [LEMS-3185] do not trust serializedState
27
27
  */
28
28
  getSerializedState(): {
29
29
  plot: import("@khanacademy/perseus-core").GrapherAnswerTypes;
@@ -55,6 +55,7 @@ declare class Grapher extends React.Component<Props> implements Widget {
55
55
  reviewModeRubric?: Empty | null | undefined;
56
56
  trackInteraction: (extraData?: Empty | undefined) => void;
57
57
  widgetId: string;
58
+ widgetIndex: number;
58
59
  alignment: string | null | undefined;
59
60
  static: boolean | null | undefined;
60
61
  problemNum: number | null | undefined;
@@ -122,7 +123,7 @@ declare class Grapher extends React.Component<Props> implements Widget {
122
123
  }
123
124
  /**
124
125
  * @deprecated and likely a very broken API
125
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
126
+ * [LEMS-3185] do not trust serializedState
126
127
  */
127
128
  declare function getUserInputFromSerializedState(serializedState: any): PerseusGrapherUserInput;
128
129
  declare function getStartUserInput(options: GrapherPublicWidgetOptions): PerseusGrapherUserInput;
@@ -31,10 +31,6 @@ declare class Group extends React.Component<Props> implements Widget {
31
31
  * @deprecated - do not use in new code.
32
32
  */
33
33
  getSerializedState: () => any;
34
- /**
35
- * @deprecated - do not use in new code.
36
- */
37
- restoreSerializedState: (arg1: any, arg2: any) => null;
38
34
  getInputPaths(): readonly FocusPath[];
39
35
  focus(): boolean;
40
36
  focusInputPath: (arg1: FocusPath) => void;
@@ -30,7 +30,7 @@ declare class Iframe extends React.Component<Props> implements Widget {
30
30
  }
31
31
  /**
32
32
  * @deprecated and likely a very broken API
33
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
33
+ * [LEMS-3185] do not trust serializedState
34
34
  */
35
35
  declare function getUserInputFromSerializedState(serializedState: any): PerseusIFrameUserInput;
36
36
  declare function getStartUserInput(): PerseusIFrameUserInput;
@@ -28,7 +28,7 @@ declare class InputNumber extends React.Component<Props> implements Widget {
28
28
  examples(): ReadonlyArray<string>;
29
29
  /**
30
30
  * @deprecated and likely very broken API
31
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
31
+ * [LEMS-3185] do not trust serializedState
32
32
  */
33
33
  getSerializedState(): any;
34
34
  render(): React.ReactNode;
@@ -36,7 +36,7 @@ declare class InputNumber extends React.Component<Props> implements Widget {
36
36
  declare function getOneCorrectAnswerFromRubric(rubric: any): string | undefined;
37
37
  /**
38
38
  * @deprecated and likely a very broken API
39
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
39
+ * [LEMS-3185] do not trust serializedState
40
40
  */
41
41
  declare function getUserInputFromSerializedState(serializedState: any): PerseusInputNumberUserInput;
42
42
  declare function getStartUserInput(): PerseusInputNumberUserInput;
@@ -131,7 +131,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
131
131
  getPromptJSON(): InteractiveGraphPromptJSON | UnsupportedWidgetPromptJSON;
132
132
  /**
133
133
  * @deprecated and likely very broken API
134
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
134
+ * [LEMS-3185] do not trust serializedState
135
135
  */
136
136
  getSerializedState(): {
137
137
  graph: PerseusGraphType;
@@ -156,6 +156,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
156
156
  reviewModeRubric?: Empty | null | undefined;
157
157
  trackInteraction: (extraData?: Empty | undefined) => void;
158
158
  widgetId: string;
159
+ widgetIndex: number;
159
160
  alignment: string | null | undefined;
160
161
  static: boolean | null | undefined;
161
162
  problemNum: number | null | undefined;
@@ -271,7 +272,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
271
272
  }
272
273
  /**
273
274
  * @deprecated and likely a very broken API
274
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
275
+ * [LEMS-3185] do not trust serializedState
275
276
  */
276
277
  declare function getUserInputFromSerializedState(serializedState: any): PerseusInteractiveGraphUserInput;
277
278
  declare function getStartUserInput(options: InteractiveGraphPublicWidgetOptions): PerseusGraphType;
@@ -94,7 +94,7 @@ export declare class LabelImage extends React.Component<Props, LabelImageState>
94
94
  renderInstructions(): React.ReactNode;
95
95
  /**
96
96
  * @deprecated and likely very broken API
97
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
97
+ * [LEMS-3185] do not trust serializedState
98
98
  */
99
99
  getSerializedState(): any;
100
100
  render(): React.ReactNode;
@@ -102,7 +102,7 @@ export declare class LabelImage extends React.Component<Props, LabelImageState>
102
102
  declare function getStartUserInput(options: LabelImagePublicWidgetOptions): PerseusLabelImageUserInput;
103
103
  /**
104
104
  * @deprecated and likely a very broken API
105
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
105
+ * [LEMS-3185] do not trust serializedState
106
106
  */
107
107
  declare function getUserInputFromSerializedState(serializedState: any): PerseusLabelImageUserInput;
108
108
  declare const _default: {
@@ -37,7 +37,7 @@ export declare class Matcher extends React.Component<Props, State> implements Wi
37
37
  declare function getStartUserInput(options: MatcherPublicWidgetOptions, problemNum: number): PerseusMatcherUserInput;
38
38
  /**
39
39
  * @deprecated and likely a very broken API
40
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
40
+ * [LEMS-3185] do not trust serializedState
41
41
  */
42
42
  declare function getUserInputFromSerializedState(serializedState: any): PerseusMatcherUserInput;
43
43
  declare const _default: {
@@ -40,7 +40,7 @@ declare class Matrix extends React.Component<Props, State> implements Widget {
40
40
  getPromptJSON(): MatrixPromptJSON;
41
41
  /**
42
42
  * @deprecated and likely very broken API
43
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
43
+ * [LEMS-3185] do not trust serializedState
44
44
  */
45
45
  getSerializedState(): any;
46
46
  render(): React.ReactNode;
@@ -49,7 +49,7 @@ declare function getStartUserInput(): PerseusMatrixUserInput;
49
49
  declare function getCorrectUserInput(options: PerseusMatrixWidgetOptions): PerseusMatrixUserInput;
50
50
  /**
51
51
  * @deprecated and likely a very broken API
52
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
52
+ * [LEMS-3185] do not trust serializedState
53
53
  */
54
54
  declare function getUserInputFromSerializedState(serializedState: any): PerseusMatrixUserInput;
55
55
  declare const _default: {
@@ -31,7 +31,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
31
31
  handleChange: (newValue: string, cb?: () => unknown | null | undefined) => void;
32
32
  /**
33
33
  * @deprecated and likely very broken API
34
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
34
+ * [LEMS-3185] do not trust serializedState
35
35
  */
36
36
  getSerializedState(): {
37
37
  currentValue: string;
@@ -40,6 +40,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
40
40
  reviewModeRubric?: Empty | null | undefined;
41
41
  trackInteraction: (extraData?: Empty | undefined) => void;
42
42
  widgetId: string;
43
+ widgetIndex: number;
43
44
  alignment: string | null | undefined;
44
45
  problemNum: number | null | undefined;
45
46
  apiOptions: Readonly<Readonly<{
@@ -106,7 +107,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
106
107
  }
107
108
  /**
108
109
  * @deprecated and likely a very broken API
109
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
110
+ * [LEMS-3185] do not trust serializedState
110
111
  */
111
112
  declare function getUserInputFromSerializedState(serializedState: any): PerseusMockWidgetUserInput;
112
113
  declare function getStartUserInput(options: PerseusMockWidgetUserInput): {
@@ -73,7 +73,7 @@ declare class NumberLine extends React.Component<Props, State> implements Widget
73
73
  getPromptJSON(): NumberLinePromptJSON;
74
74
  /**
75
75
  * @deprecated and likely very broken API
76
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
76
+ * [LEMS-3185] do not trust serializedState
77
77
  */
78
78
  getSerializedState(): {
79
79
  alignment: string | null | undefined;
@@ -95,7 +95,7 @@ declare class NumberLine extends React.Component<Props, State> implements Widget
95
95
  }
96
96
  /**
97
97
  * @deprecated and likely a very broken API
98
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
98
+ * [LEMS-3185] do not trust serializedState
99
99
  */
100
100
  declare function getUserInputFromSerializedState(serializedState: any): PerseusNumberLineUserInput;
101
101
  declare function getCorrectUserInput(options: PerseusNumberLineWidgetOptions): PerseusNumberLineUserInput;
@@ -35,7 +35,7 @@ export declare class NumericInput extends React.Component<NumericInputProps> imp
35
35
  getPromptJSON(): NumericInputPromptJSON;
36
36
  /**
37
37
  * @deprecated and likely very broken API
38
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
38
+ * [LEMS-3185] do not trust serializedState
39
39
  */
40
40
  getSerializedState(): {
41
41
  currentValue: string;
@@ -47,6 +47,7 @@ export declare class NumericInput extends React.Component<NumericInputProps> imp
47
47
  reviewModeRubric?: Empty | null | undefined;
48
48
  trackInteraction: (extraData?: Empty | undefined) => void;
49
49
  widgetId: string;
50
+ widgetIndex: number;
50
51
  alignment: string | null | undefined;
51
52
  problemNum: number | null | undefined;
52
53
  apiOptions: Readonly<Readonly<{
@@ -115,7 +116,7 @@ export declare class NumericInput extends React.Component<NumericInputProps> imp
115
116
  declare function getStartUserInput(): PerseusNumericInputUserInput;
116
117
  /**
117
118
  * @deprecated and likely a very broken API
118
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
119
+ * [LEMS-3185] do not trust serializedState
119
120
  */
120
121
  declare function getUserInputFromSerializedState(serializedState: any): PerseusNumericInputUserInput;
121
122
  declare const _default: {
@@ -35,14 +35,14 @@ declare class Orderer extends React.Component<OrdererProps, OrdererState> implem
35
35
  getPromptJSON(): OrdererPromptJSON;
36
36
  /**
37
37
  * @deprecated and likely very broken API
38
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
38
+ * [LEMS-3185] do not trust serializedState
39
39
  */
40
40
  getSerializedState(): any;
41
41
  render(): React.ReactNode;
42
42
  }
43
43
  /**
44
44
  * @deprecated and likely a very broken API
45
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
45
+ * [LEMS-3185] do not trust serializedState
46
46
  */
47
47
  declare function getUserInputFromSerializedState(serializedState: any): PerseusOrdererUserInput;
48
48
  declare function getStartUserInput(): PerseusOrdererUserInput;
@@ -74,7 +74,7 @@ export declare class Plotter extends React.Component<Props, State> implements Wi
74
74
  getPromptJSON(): UnsupportedWidgetPromptJSON;
75
75
  /**
76
76
  * @deprecated and likely very broken API
77
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
77
+ * [LEMS-3185] do not trust serializedState
78
78
  */
79
79
  getSerializedState(): {
80
80
  values: PerseusPlotterUserInput;
@@ -93,6 +93,7 @@ export declare class Plotter extends React.Component<Props, State> implements Wi
93
93
  reviewModeRubric?: Empty | null | undefined;
94
94
  trackInteraction: (extraData?: Empty | undefined) => void;
95
95
  widgetId: string;
96
+ widgetIndex: number;
96
97
  alignment: string | null | undefined;
97
98
  static: boolean | null | undefined;
98
99
  problemNum: number | null | undefined;
@@ -162,7 +163,7 @@ declare function getStartUserInput(options: PlotterPublicWidgetOptions): Perseus
162
163
  declare function getCorrectUserInput(options: PerseusPlotterWidgetOptions): PerseusPlotterUserInput;
163
164
  /**
164
165
  * @deprecated and likely a very broken API
165
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
166
+ * [LEMS-3185] do not trust serializedState
166
167
  */
167
168
  declare function getUserInputFromSerializedState(serializedState: any): PerseusPlotterUserInput;
168
169
  declare const _default: {
@@ -1,5 +1,4 @@
1
1
  import * as React from "react";
2
- import type { PerseusStrings } from "../../strings";
3
2
  import type { ChoiceState, Widget } from "../../types";
4
3
  import type { PerseusRadioChoice, PerseusRadioRubric, PerseusRadioUserInput } from "@khanacademy/perseus-core";
5
4
  /**
@@ -26,10 +25,7 @@ export type RenderProps = {
26
25
  countChoices?: boolean;
27
26
  deselectEnabled?: boolean;
28
27
  choices: ReadonlyArray<RadioChoiceWithMetadata>;
29
- selectedChoices: ReadonlyArray<PerseusRadioChoice["correct"]>;
30
28
  choiceStates?: ReadonlyArray<ChoiceState>;
31
- values?: ReadonlyArray<boolean>;
32
- strings?: PerseusStrings;
33
29
  editMode?: boolean;
34
30
  labelWrap?: boolean;
35
31
  };
@@ -3,18 +3,16 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { FocusFunction } from "./base-radio";
4
4
  import type { WidgetProps, ChoiceState, Widget } from "../../types";
5
5
  import type { RadioPromptJSON } from "../../widget-ai-utils/radio/radio-ai-utils";
6
- import type { PerseusRadioChoice, ShowSolutions, PerseusRadioRubric, PerseusRadioUserInput } from "@khanacademy/perseus-core";
7
- export type RenderProps = {
6
+ import type { PerseusRadioChoice, ShowSolutions, PerseusRadioRubric, PerseusRadioUserInput, PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
7
+ export type RenderProps = PerseusRadioWidgetOptions & {
8
8
  numCorrect: number;
9
9
  hasNoneOfTheAbove?: boolean;
10
10
  multipleSelect?: boolean;
11
11
  countChoices?: boolean;
12
12
  deselectEnabled?: boolean;
13
13
  choices: RadioChoiceWithMetadata[];
14
- selectedChoices: PerseusRadioChoice["correct"][];
15
14
  showSolutions?: ShowSolutions;
16
15
  choiceStates?: ChoiceState[];
17
- values?: boolean[];
18
16
  };
19
17
  export type Props = WidgetProps<RenderProps, PerseusRadioUserInput, PerseusRadioRubric>;
20
18
  type DefaultProps = Required<Pick<Props, "choices" | "multipleSelect" | "countChoices" | "deselectEnabled" | "linterContext" | "showSolutions">>;
@@ -1,6 +1,4 @@
1
1
  import Radio from "./radio.ff";
2
- import type { RenderProps } from "./radio-component";
3
- import type { PerseusStrings } from "../../strings";
4
2
  import type { PerseusRadioUserInput, PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
5
3
  declare function getStartUserInput(): PerseusRadioUserInput;
6
4
  declare function getCorrectUserInput(options: PerseusRadioWidgetOptions): PerseusRadioUserInput;
@@ -8,8 +6,6 @@ declare const _default: {
8
6
  name: string;
9
7
  displayName: string;
10
8
  widget: typeof Radio;
11
- transform: (widgetOptions: PerseusRadioWidgetOptions, strings: PerseusStrings) => RenderProps;
12
- staticTransform: (widgetOptions: PerseusRadioWidgetOptions, strings: PerseusStrings) => RenderProps;
13
9
  getStartUserInput: typeof getStartUserInput;
14
10
  getCorrectUserInput: typeof getCorrectUserInput;
15
11
  version: import("@khanacademy/perseus-core").Version | undefined;
@@ -3,6 +3,7 @@ import * as React from "react";
3
3
  import RadioOld from "./radio-component";
4
4
  import type { RenderProps } from "./radio-component";
5
5
  import type { ChoiceState, WidgetProps } from "../../types";
6
+ import type { RadioPromptJSON } from "../../widget-ai-utils/radio/radio-ai-utils";
6
7
  type Props = WidgetProps<RenderProps, PerseusRadioUserInput, PerseusRadioRubric>;
7
8
  type ChoiceStateWithoutSelected = Omit<ChoiceState, "selected">;
8
9
  type State = {
@@ -25,22 +26,21 @@ declare class Radio extends RadioOld {
25
26
  UNSAFE_componentWillUpdate(nextProps: Props): void;
26
27
  /**
27
28
  * @deprecated and likely very broken API
28
- * [LEMS-3185] do not trust serializedState/restoreSerializedState
29
+ * [LEMS-3185] do not trust serializedState
29
30
  */
30
31
  getSerializedState(): {
31
- numCorrect: number;
32
+ choices: import("@khanacademy/perseus-core").PerseusRadioChoice[] & import("./radio-component").RadioChoiceWithMetadata[];
32
33
  hasNoneOfTheAbove?: boolean;
33
- multipleSelect?: boolean;
34
34
  countChoices?: boolean;
35
+ numCorrect: number;
36
+ multipleSelect?: boolean;
35
37
  deselectEnabled?: boolean;
36
- choices: import("./radio-component").RadioChoiceWithMetadata[];
37
- selectedChoices: import("@khanacademy/perseus-core").PerseusRadioChoice["correct"][];
38
38
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
39
39
  choiceStates?: ChoiceState[];
40
- values?: boolean[];
41
40
  reviewModeRubric?: PerseusRadioRubric | null | undefined;
42
41
  trackInteraction: (extraData?: Empty | undefined) => void;
43
42
  widgetId: string;
43
+ widgetIndex: number;
44
44
  alignment: string | null | undefined;
45
45
  static: boolean | null | undefined;
46
46
  problemNum: number | null | undefined;
@@ -103,6 +103,7 @@ declare class Radio extends RadioOld {
103
103
  linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
104
104
  containerSizeClass: import("../../util/sizing-utils").SizeClass;
105
105
  };
106
+ getPromptJSON(): RadioPromptJSON;
106
107
  _handleChange(arg: {
107
108
  choiceStates?: ChoiceState[];
108
109
  }): void;