@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
@@ -14,7 +14,7 @@ type RenderProps = {
14
14
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
15
15
  keypadConfiguration: KeypadConfiguration;
16
16
  };
17
- type ExternalProps = WidgetProps<RenderProps>;
17
+ type ExternalProps = WidgetProps<RenderProps, PerseusExpressionUserInput>;
18
18
  type Props = ExternalProps & Partial<React.ContextType<typeof DependenciesContext>> & {
19
19
  apiOptions: NonNullable<ExternalProps["apiOptions"]>;
20
20
  buttonSets: NonNullable<ExternalProps["buttonSets"]>;
@@ -25,7 +25,6 @@ type Props = ExternalProps & Partial<React.ContextType<typeof DependenciesContex
25
25
  times: NonNullable<ExternalProps["times"]>;
26
26
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
27
27
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
28
- value: string;
29
28
  };
30
29
  type ExpressionState = {
31
30
  invalid: boolean;
@@ -40,14 +39,13 @@ type DefaultProps = {
40
39
  onBlur: Props["onBlur"];
41
40
  onFocus: Props["onFocus"];
42
41
  times: Props["times"];
43
- value: Props["value"];
42
+ userInput: Props["userInput"];
44
43
  };
45
44
  export declare class Expression extends React.Component<Props, ExpressionState> implements Widget {
46
45
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
47
46
  context: React.ContextType<typeof PerseusI18nContext>;
48
47
  _textareaId: string;
49
48
  _isMounted: boolean;
50
- static getUserInputFromProps(props: Props): PerseusExpressionUserInput;
51
49
  static defaultProps: DefaultProps;
52
50
  displayName: string;
53
51
  state: ExpressionState;
@@ -55,11 +53,14 @@ export declare class Expression extends React.Component<Props, ExpressionState>
55
53
  componentDidUpdate: (prevProps: Props) => void;
56
54
  componentWillUnmount: () => void;
57
55
  _handleMouseDown: () => void;
56
+ /**
57
+ * TODO: remove this when everything is pulling from Renderer state
58
+ * @deprecated get user input from Renderer state
59
+ */
58
60
  getUserInput(): PerseusExpressionUserInput;
59
61
  getPromptJSON(): ExpressionPromptJSON;
60
- change: (...args: any) => any | undefined;
61
62
  parse: (value: string, props: Props) => any;
62
- changeAndTrack: (e: any, cb: () => void) => void;
63
+ changeAndTrack: (userInput: string, cb: () => void) => void;
63
64
  _handleFocus: () => void;
64
65
  _handleBlur: () => void;
65
66
  focus: () => boolean;
@@ -67,13 +68,108 @@ export declare class Expression extends React.Component<Props, ExpressionState>
67
68
  blurInputPath(inputPath: InputPath): void;
68
69
  insert(keyPressed: KeypadKey): void;
69
70
  getInputPaths: () => ReadonlyArray<ReadonlyArray<any>>;
70
- setInputValue(path: FocusPath, newValue: string, cb?: () => void): void;
71
+ /**
72
+ * TODO: remove this when everything is pulling from Renderer state
73
+ * @deprecated set user input in a parent component
74
+ */
75
+ setInputValue(path: FocusPath, newValue: string, cb?: any): void;
76
+ /**
77
+ * @deprecated and likely very broken API
78
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
79
+ */
80
+ getSerializedState(): {
81
+ value: string;
82
+ buttonSets: PerseusExpressionWidgetOptions["buttonSets"];
83
+ buttonsVisible?: PerseusExpressionWidgetOptions["buttonsVisible"];
84
+ functions: PerseusExpressionWidgetOptions["functions"];
85
+ times: PerseusExpressionWidgetOptions["times"];
86
+ visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
87
+ ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
88
+ keypadConfiguration: KeypadConfiguration;
89
+ reviewModeRubric?: Empty | null | undefined;
90
+ trackInteraction: (extraData?: Empty | undefined) => void;
91
+ widgetId: string;
92
+ alignment: string | null | undefined;
93
+ static: boolean | null | undefined;
94
+ problemNum: number | null | undefined;
95
+ apiOptions: Readonly<Readonly<{
96
+ isArticle?: boolean;
97
+ onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
98
+ GroupMetadataEditor?: React.ComponentType<any>;
99
+ showAlignmentOptions?: boolean;
100
+ readOnly?: boolean;
101
+ answerableCallback?: (arg1: boolean) => unknown;
102
+ getAnotherHint?: () => unknown;
103
+ interactionCallback?: (widgetData: {
104
+ [widgetId: string]: any;
105
+ }) => void;
106
+ groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
107
+ imagePlaceholder?: React.ReactNode;
108
+ widgetPlaceholder?: React.ReactNode;
109
+ baseElements?: {
110
+ Link: React.ComponentType<any>;
111
+ };
112
+ imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
113
+ trackInteraction?: (args: {
114
+ type: string;
115
+ id: string;
116
+ correct?: boolean;
117
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
118
+ visible: number;
119
+ }>) => void;
120
+ customKeypad?: boolean;
121
+ nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
122
+ isMobile?: boolean;
123
+ isMobileApp?: boolean;
124
+ setDrawingAreaAvailable?: (arg1: boolean) => unknown;
125
+ hintProgressColor?: string;
126
+ canScrollPage?: boolean;
127
+ editorChangeDelay?: number;
128
+ flags?: Record<"new-radio-widget", boolean>;
129
+ onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
130
+ }> & {
131
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
132
+ canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
133
+ editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
134
+ groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
135
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
136
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
137
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
138
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
139
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
140
+ setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
141
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
142
+ }>;
143
+ keypadElement?: any;
144
+ questionCompleted?: boolean;
145
+ onFocus: (blurPath: FocusPath) => void;
146
+ onBlur: (blurPath: FocusPath) => void;
147
+ findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
148
+ reviewMode: boolean;
149
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
150
+ onChange: import("../..").ChangeHandler;
151
+ handleUserInput: (newUserInput: string, cb?: () => void, silent?: boolean) => void;
152
+ isLastUsedWidget: boolean;
153
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
154
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
155
+ analytics?: {
156
+ onAnalyticsEvent: import("@khanacademy/perseus-core").AnalyticsEventHandlerFn;
157
+ } | undefined;
158
+ useVideo?: ((id: string, kind: import("../..").VideoKind) => import("@khanacademy/wonder-blocks-data").Result<{
159
+ video: import("../..").VideoData | null | undefined;
160
+ }>) | undefined;
161
+ };
71
162
  render(): React.JSX.Element;
72
163
  }
164
+ /**
165
+ * @deprecated and likely a very broken API
166
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
167
+ */
168
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusExpressionUserInput;
73
169
  declare const _default: {
74
170
  name: string;
75
171
  displayName: string;
76
- widget: React.ForwardRefExoticComponent<Omit<Pick<RenderProps & import("../../types").UniversalWidgetProps<Empty, Empty> & Partial<import("../..").PerseusDependenciesV2> & {
172
+ widget: React.ForwardRefExoticComponent<Omit<Pick<RenderProps & import("../../types").UniversalWidgetProps<Empty, string, Empty> & Partial<import("../..").PerseusDependenciesV2> & {
77
173
  apiOptions: NonNullable<ExternalProps["apiOptions"]>;
78
174
  buttonSets: NonNullable<ExternalProps["buttonSets"]>;
79
175
  functions: NonNullable<ExternalProps["functions"]>;
@@ -83,9 +179,7 @@ declare const _default: {
83
179
  times: NonNullable<ExternalProps["times"]>;
84
180
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
85
181
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
86
- value: string;
87
- }, "static" | "onChange" | "ariaLabel" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "showSolutions" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "reviewModeRubric" | "alignment" | "isLastUsedWidget" | "visibleLabel" | "keypadConfiguration"> & {
88
- value?: string | undefined;
182
+ }, "static" | "onChange" | "ariaLabel" | "buttonsVisible" | "trackInteraction" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "keypadElement" | "isLastUsedWidget" | "handleUserInput" | "showSolutions" | "reviewMode" | "reviewModeRubric" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "visibleLabel" | "keypadConfiguration"> & {
89
183
  buttonSets?: import("@khanacademy/perseus-core").LegacyButtonSets | undefined;
90
184
  onFocus?: ((blurPath: FocusPath) => void) | undefined;
91
185
  onBlur?: ((blurPath: FocusPath) => void) | undefined;
@@ -138,6 +232,7 @@ declare const _default: {
138
232
  showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
139
233
  }> | undefined;
140
234
  linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
235
+ userInput?: string | undefined;
141
236
  functions?: string[] | undefined;
142
237
  times?: boolean | undefined;
143
238
  } & {}, keyof import("../..").PerseusDependenciesV2> & React.RefAttributes<Expression>>;
@@ -145,5 +240,6 @@ declare const _default: {
145
240
  version: import("@khanacademy/perseus-core").Version | undefined;
146
241
  isLintable: true;
147
242
  getOneCorrectAnswerFromRubric(rubric: PerseusExpressionRubric): string | null | undefined;
243
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
148
244
  };
149
245
  export default _default;
@@ -9,17 +9,19 @@ import { PerseusI18nContext } from "../../components/i18n-context";
9
9
  import type { Widget, WidgetExports, WidgetProps } from "../../types";
10
10
  import type { PerseusFreeResponseUserInput, PerseusFreeResponseWidgetOptions } from "@khanacademy/perseus-core";
11
11
  type RenderProps = Pick<PerseusFreeResponseWidgetOptions, "allowUnlimitedCharacters" | "characterLimit" | "placeholder" | "question">;
12
- type Props = WidgetProps<RenderProps>;
13
- type State = {
14
- currentValue: string;
15
- };
16
- export declare class FreeResponse extends React.Component<Props, State> implements Widget {
12
+ type Props = WidgetProps<RenderProps, PerseusFreeResponseUserInput>;
13
+ type DefaultProps = Pick<Props, "userInput">;
14
+ export declare class FreeResponse extends React.Component<Props> implements Widget {
17
15
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
18
16
  context: React.ContextType<typeof PerseusI18nContext>;
19
- state: State;
17
+ static defaultProps: DefaultProps;
20
18
  characterCount: () => number;
19
+ /**
20
+ * TODO: remove this when everything is pulling from Renderer state
21
+ * @deprecated get user input from Renderer state
22
+ * */
21
23
  getUserInput(): PerseusFreeResponseUserInput;
22
- handleChange: (newValue: string) => void;
24
+ _handleUserInput: (newValue: string) => void;
23
25
  isOverLimit(): boolean;
24
26
  renderCharacterCount(): React.ReactNode;
25
27
  render(): React.ReactNode;
@@ -1,11 +1,10 @@
1
1
  import * as React from "react";
2
- import * as Changeable from "../../mixins/changeable";
3
2
  import { GradedGroup } from "../graded-group/graded-group";
4
3
  import type { FocusPath, Widget, WidgetProps } from "../../types";
5
4
  import type { GradedGroupSetPromptJSON } from "../../widget-ai-utils/graded-group-set/graded-group-set-ai-utils";
6
5
  import type { PerseusGradedGroupSetWidgetOptions } from "@khanacademy/perseus-core";
7
6
  type RenderProps = PerseusGradedGroupSetWidgetOptions;
8
- type Props = Changeable.ChangeableProps & WidgetProps<RenderProps> & {
7
+ type Props = WidgetProps<RenderProps> & {
9
8
  trackInteraction: () => void;
10
9
  };
11
10
  type DefaultProps = {
@@ -20,7 +19,6 @@ declare class GradedGroupSet extends React.Component<Props, State> implements Wi
20
19
  static defaultProps: DefaultProps;
21
20
  state: State;
22
21
  shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
23
- change: (...args: ReadonlyArray<unknown>) => any;
24
22
  getInputPaths: () => ReadonlyArray<FocusPath>;
25
23
  getPromptJSON(): GradedGroupSetPromptJSON;
26
24
  setInputValue: (arg1: FocusPath, arg2: any, arg3: any) => any;
@@ -6,21 +6,11 @@ import type { GridDimensions } from "../../util";
6
6
  import type { GrapherPromptJSON } from "../../widget-ai-utils/grapher/grapher-ai-utils";
7
7
  import type { PerseusGrapherWidgetOptions, PerseusGrapherUserInput, GrapherPublicWidgetOptions } from "@khanacademy/perseus-core";
8
8
  import type { PropsFor } from "@khanacademy/wonder-blocks-core";
9
- type RenderProps = Pick<GrapherPublicWidgetOptions, "availableTypes" | "graph"> & {
10
- plot?: PerseusGrapherWidgetOptions["correct"];
11
- };
12
- type ExternalProps = WidgetProps<RenderProps>;
13
- type Props = ExternalProps & {
14
- plot: NonNullable<RenderProps["plot"]>;
15
- };
16
- type DefaultProps = {
17
- plot: RenderProps["plot"];
18
- };
9
+ type RenderProps = Pick<GrapherPublicWidgetOptions, "availableTypes" | "graph">;
10
+ type Props = WidgetProps<RenderProps, PerseusGrapherUserInput>;
19
11
  declare class Grapher extends React.Component<Props> implements Widget {
20
12
  horizHairline: any;
21
13
  vertHairline: any;
22
- static defaultProps: DefaultProps;
23
- static getUserInputFromProps(props: Props): PerseusGrapherUserInput;
24
14
  handlePlotChanges: (arg1: any) => any;
25
15
  handleActiveTypeChange: (arg1: any) => any;
26
16
  _getGridConfig(options: Props["graph"] & {
@@ -33,14 +23,149 @@ declare class Grapher extends React.Component<Props> implements Widget {
33
23
  hideHairlines: () => void;
34
24
  getUserInput(): PerseusGrapherUserInput;
35
25
  getPromptJSON(): GrapherPromptJSON;
26
+ /**
27
+ * @deprecated and likely very broken API
28
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
29
+ */
30
+ getSerializedState(): {
31
+ plot: import("@khanacademy/perseus-core").GrapherAnswerTypes;
32
+ graph: {
33
+ backgroundImage: {
34
+ bottom?: number;
35
+ height?: number;
36
+ left?: number;
37
+ scale?: number;
38
+ url?: string | null | undefined;
39
+ width?: number;
40
+ };
41
+ box?: [number, number];
42
+ editableSettings?: Array<"graph" | "snap" | "image" | "measure">;
43
+ gridStep?: [number, number];
44
+ labels: [string, string];
45
+ markings: import("@khanacademy/perseus-core").MarkingsType;
46
+ range: import("@khanacademy/perseus-core").GraphRange;
47
+ rulerLabel: "";
48
+ rulerTicks: number;
49
+ showProtractor?: boolean;
50
+ showRuler?: boolean;
51
+ showTooltips?: boolean;
52
+ snapStep?: [number, number];
53
+ step: [number, number];
54
+ valid?: boolean | string;
55
+ };
56
+ availableTypes: Array<"absolute_value" | "exponential" | "linear" | "logarithm" | "quadratic" | "sinusoid" | "tangent">;
57
+ reviewModeRubric?: Empty | null | undefined;
58
+ trackInteraction: (extraData?: Empty | undefined) => void;
59
+ widgetId: string;
60
+ alignment: string | null | undefined;
61
+ static: boolean | null | undefined;
62
+ problemNum: number | null | undefined;
63
+ apiOptions: Readonly<Readonly<{
64
+ isArticle?: boolean;
65
+ onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
66
+ GroupMetadataEditor?: React.ComponentType<any>;
67
+ showAlignmentOptions?: boolean;
68
+ readOnly?: boolean;
69
+ answerableCallback?: (arg1: boolean) => unknown;
70
+ getAnotherHint?: () => unknown;
71
+ interactionCallback?: (widgetData: {
72
+ [widgetId: string]: any;
73
+ }) => void;
74
+ groupAnnotator?: (groupNumber: number, widgetId: string) => React.ReactNode;
75
+ imagePlaceholder?: React.ReactNode;
76
+ widgetPlaceholder?: React.ReactNode;
77
+ baseElements?: {
78
+ Link: React.ComponentType<any>;
79
+ };
80
+ imagePreloader?: (dimensions: import("../../types").Dimensions) => React.ReactNode;
81
+ trackInteraction?: (args: {
82
+ type: string;
83
+ id: string;
84
+ correct?: boolean;
85
+ } & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<{
86
+ visible: number;
87
+ }>) => void;
88
+ customKeypad?: boolean;
89
+ nativeKeypadProxy?: (blur: () => void) => import("@khanacademy/math-input").KeypadAPI;
90
+ isMobile?: boolean;
91
+ isMobileApp?: boolean;
92
+ setDrawingAreaAvailable?: (arg1: boolean) => unknown;
93
+ hintProgressColor?: string;
94
+ canScrollPage?: boolean;
95
+ editorChangeDelay?: number;
96
+ flags?: Record<"new-radio-widget", boolean>;
97
+ onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
98
+ }> & {
99
+ baseElements: NonNullable<import("../..").APIOptions["baseElements"]>;
100
+ canScrollPage: NonNullable<import("../..").APIOptions["canScrollPage"]>;
101
+ editorChangeDelay: NonNullable<import("../..").APIOptions["editorChangeDelay"]>;
102
+ groupAnnotator: NonNullable<import("../..").APIOptions["groupAnnotator"]>;
103
+ isArticle: NonNullable<import("../..").APIOptions["isArticle"]>;
104
+ isMobile: NonNullable<import("../..").APIOptions["isMobile"]>;
105
+ isMobileApp: NonNullable<import("../..").APIOptions["isMobileApp"]>;
106
+ onFocusChange: NonNullable<import("../..").APIOptions["onFocusChange"]>;
107
+ readOnly: NonNullable<import("../..").APIOptions["readOnly"]>;
108
+ setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
109
+ showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
110
+ }>;
111
+ keypadElement?: any;
112
+ questionCompleted?: boolean;
113
+ onFocus: (blurPath: import("../..").FocusPath) => void;
114
+ onBlur: (blurPath: import("../..").FocusPath) => void;
115
+ findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
116
+ reviewMode: boolean;
117
+ showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
118
+ onChange: import("../..").ChangeHandler;
119
+ handleUserInput: (newUserInput: import("@khanacademy/perseus-core").GrapherAnswerTypes, cb?: () => void, silent?: boolean) => void;
120
+ isLastUsedWidget: boolean;
121
+ linterContext: import("@khanacademy/perseus-linter").LinterContextProps;
122
+ containerSizeClass: import("../../util/sizing-utils").SizeClass;
123
+ };
36
124
  render(): React.ReactNode;
37
125
  }
126
+ declare function transform(options: GrapherPublicWidgetOptions): RenderProps;
127
+ declare function staticTransform(options: PerseusGrapherWidgetOptions): {
128
+ availableTypes: ("linear" | "quadratic" | "sinusoid" | "absolute_value" | "exponential" | "logarithm" | "tangent")[];
129
+ plot: import("@khanacademy/perseus-core").GrapherAnswerTypes;
130
+ graph: {
131
+ backgroundImage: {
132
+ bottom?: number;
133
+ height?: number;
134
+ left?: number;
135
+ scale?: number;
136
+ url?: string | null | undefined;
137
+ width?: number;
138
+ };
139
+ box?: [number, number];
140
+ editableSettings?: Array<"graph" | "snap" | "image" | "measure">;
141
+ gridStep?: [number, number];
142
+ labels: [string, string];
143
+ markings: import("@khanacademy/perseus-core").MarkingsType;
144
+ range: import("@khanacademy/perseus-core").GraphRange;
145
+ rulerLabel: "";
146
+ rulerTicks: number;
147
+ showProtractor?: boolean;
148
+ showRuler?: boolean;
149
+ showTooltips?: boolean;
150
+ snapStep?: [number, number];
151
+ step: [number, number];
152
+ valid?: boolean | string;
153
+ };
154
+ };
155
+ /**
156
+ * @deprecated and likely a very broken API
157
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
158
+ */
159
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusGrapherUserInput;
160
+ declare function getStartUserInput(options: GrapherPublicWidgetOptions): PerseusGrapherUserInput;
38
161
  declare const _default: {
39
162
  name: string;
40
163
  displayName: string;
41
164
  hidden: true;
42
165
  widget: typeof Grapher;
43
- transform: (arg1: GrapherPublicWidgetOptions) => RenderProps;
44
- staticTransform: (arg1: PerseusGrapherWidgetOptions) => RenderProps;
166
+ transform: typeof transform;
167
+ staticTransform: typeof staticTransform;
168
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
169
+ getStartUserInput: typeof getStartUserInput;
45
170
  };
46
171
  export default _default;
@@ -1,11 +1,11 @@
1
1
  import { GrapherUtil } from "@khanacademy/perseus-core";
2
2
  import type { Coord } from "../../interactive2/types";
3
- import type { FunctionTypeMappingKeys } from "@khanacademy/perseus-core";
3
+ import type { FunctionTypeMappingKeys, GrapherAnswerTypes } from "@khanacademy/perseus-core";
4
4
  type MovableMap = {
5
5
  [K in keyof typeof GrapherUtil.MOVABLES]: any;
6
6
  };
7
7
  export declare const movableTypeToComponent: MovableMap;
8
- export declare const getEquationString: (props: any) => string;
8
+ export declare const getEquationString: (plot: GrapherAnswerTypes) => string;
9
9
  export declare const maybePointsFromNormalized: (coordsList: ReadonlyArray<Coord> | null | undefined, range: [Coord, Coord], step: [number, number], snapStep: [number, number]) => ReadonlyArray<Coord> | null | undefined;
10
10
  export declare const defaultPlotProps: (type: FunctionTypeMappingKeys, graph: any) => any;
11
11
  export declare const chooseType: <T>(list: ReadonlyArray<T>) => T | undefined;
@@ -33,7 +33,13 @@ declare class Group extends React.Component<Props> implements Widget {
33
33
  */
34
34
  getUserInput(): UserInputArray | undefined;
35
35
  getPromptJSON(): GroupPromptJSON;
36
+ /**
37
+ * @deprecated - do not use in new code.
38
+ */
36
39
  getSerializedState: () => any;
40
+ /**
41
+ * @deprecated - do not use in new code.
42
+ */
37
43
  restoreSerializedState: (arg1: any, arg2: any) => null;
38
44
  getInputPaths(): readonly FocusPath[];
39
45
  setInputValue: (arg1: FocusPath, arg2: string, arg3?: () => unknown) => void;
@@ -7,21 +7,18 @@
7
7
  * but could also be used for embedding viz's hosted elsewhere.
8
8
  */
9
9
  import * as React from "react";
10
- import type { WidgetProps, Widget, ChangeFn } from "../../types";
10
+ import type { WidgetProps, Widget } from "../../types";
11
11
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
12
- import type { PerseusIFrameUserInput, UserInputStatus, PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
12
+ import type { PerseusIFrameUserInput, PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
13
13
  type RenderProps = PerseusIFrameWidgetOptions & {
14
- status: UserInputStatus;
15
- message: string | null;
16
14
  width: string;
17
15
  height: string;
18
16
  };
19
- type Props = WidgetProps<RenderProps>;
17
+ type Props = WidgetProps<RenderProps, PerseusIFrameUserInput>;
20
18
  type DefaultProps = {
21
- status: Props["status"];
22
- message: Props["message"];
23
19
  allowFullScreen: Props["allowFullScreen"];
24
20
  allowTopNavigation: Props["allowTopNavigation"];
21
+ userInput: Props["userInput"];
25
22
  };
26
23
  declare class Iframe extends React.Component<Props> implements Widget {
27
24
  static defaultProps: DefaultProps;
@@ -30,13 +27,18 @@ declare class Iframe extends React.Component<Props> implements Widget {
30
27
  getUserInput(): PerseusIFrameUserInput;
31
28
  getPromptJSON(): UnsupportedWidgetPromptJSON;
32
29
  handleMessageEvent: (arg1: any) => void;
33
- change: ChangeFn;
34
30
  render(): React.ReactNode;
35
31
  }
32
+ /**
33
+ * @deprecated and likely a very broken API
34
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
35
+ */
36
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusIFrameUserInput;
36
37
  declare const _default: {
37
38
  name: string;
38
39
  displayName: string;
39
40
  widget: typeof Iframe;
40
41
  hidden: true;
42
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
41
43
  };
42
44
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { ChangeFn, WidgetProps, Widget } from "../../types";
3
+ import type { WidgetProps, Widget } from "../../types";
4
4
  import type { ImagePromptJSON } from "../../widget-ai-utils/image/image-ai-utils";
5
5
  import type { PerseusImageWidgetOptions } from "@khanacademy/perseus-core";
6
6
  type RenderProps = PerseusImageWidgetOptions;
@@ -32,7 +32,6 @@ declare class ImageWidget extends React.Component<Props> implements Widget {
32
32
  context: React.ContextType<typeof PerseusI18nContext>;
33
33
  static defaultProps: DefaultProps;
34
34
  isWidget: true;
35
- change: ChangeFn;
36
35
  getPromptJSON(): ImagePromptJSON;
37
36
  render(): React.ReactNode;
38
37
  }
@@ -4,23 +4,19 @@ import type { Path, Widget, WidgetProps } from "../../types";
4
4
  import type { InputNumberPromptJSON } from "../../widget-ai-utils/input-number/input-number-ai-utils";
5
5
  import type { PerseusInputNumberWidgetOptions, PerseusInputNumberUserInput } from "@khanacademy/perseus-core";
6
6
  type RenderProps = Pick<PerseusInputNumberWidgetOptions, "simplify" | "size" | "answerType" | "rightAlign">;
7
- type ExternalProps = WidgetProps<RenderProps>;
7
+ type ExternalProps = WidgetProps<RenderProps, PerseusInputNumberUserInput>;
8
8
  type Props = ExternalProps & {
9
9
  apiOptions: NonNullable<ExternalProps["apiOptions"]>;
10
10
  linterContext: NonNullable<ExternalProps["linterContext"]>;
11
11
  rightAlign: NonNullable<ExternalProps["rightAlign"]>;
12
12
  size: NonNullable<ExternalProps["size"]>;
13
- currentValue: string;
14
13
  answerType: NonNullable<ExternalProps["answerType"]>;
15
14
  };
16
- type DefaultProps = Pick<Props, "answerType" | "apiOptions" | "currentValue" | "linterContext" | "rightAlign" | "size">;
15
+ type DefaultProps = Pick<Props, "answerType" | "apiOptions" | "linterContext" | "rightAlign" | "size" | "userInput">;
17
16
  declare class InputNumber extends React.Component<Props> implements Widget {
18
17
  static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
19
18
  context: React.ContextType<typeof PerseusI18nContext>;
20
19
  static defaultProps: DefaultProps;
21
- static getUserInputFromProps(props: Props): {
22
- currentValue: string;
23
- };
24
20
  shouldShowExamples: () => boolean;
25
21
  handleChange: (arg1: string, arg2: () => void) => void;
26
22
  _handleFocus: () => void;
@@ -30,13 +26,27 @@ declare class InputNumber extends React.Component<Props> implements Widget {
30
26
  blurInputPath: (arg1: Path) => void;
31
27
  getInputPaths: () => ReadonlyArray<Path>;
32
28
  setInputValue: (arg1: Path, arg2: string, arg3: () => void) => void;
29
+ /**
30
+ * TODO: remove this when everything is pulling from Renderer state
31
+ * @deprecated get user input from Renderer state
32
+ */
33
33
  getUserInput(): PerseusInputNumberUserInput;
34
34
  getPromptJSON(): InputNumberPromptJSON;
35
35
  examples(): ReadonlyArray<string>;
36
+ /**
37
+ * @deprecated and likely very broken API
38
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
39
+ */
40
+ getSerializedState(): any;
36
41
  render(): React.ReactNode;
37
42
  }
38
43
  declare function transform(widgetOptions: PerseusInputNumberWidgetOptions): RenderProps;
39
44
  declare function getOneCorrectAnswerFromRubric(rubric: any): string | undefined;
45
+ /**
46
+ * @deprecated and likely a very broken API
47
+ * [LEMS-3185] do not trust serializedState/restoreSerializedState
48
+ */
49
+ declare function getUserInputFromSerializedState(serializedState: any): PerseusInputNumberUserInput;
40
50
  declare const _default: {
41
51
  name: string;
42
52
  displayName: string;
@@ -45,5 +55,6 @@ declare const _default: {
45
55
  isLintable: true;
46
56
  transform: typeof transform;
47
57
  getOneCorrectAnswerFromRubric: typeof getOneCorrectAnswerFromRubric;
58
+ getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
48
59
  };
49
60
  export default _default;
@@ -23,7 +23,6 @@ declare class Interaction extends React.Component<Props, State> implements Widge
23
23
  _updateLineLocation: (arg1: any, arg2: Coord) => void;
24
24
  _eval: (arg1: any, arg2: any) => number;
25
25
  _extractVars: (arg1: any) => ReadonlyArray<any>;
26
- change: (arg1: any, arg2: any, arg3: any) => any;
27
26
  getPromptJSON(): UnsupportedWidgetPromptJSON;
28
27
  render(): React.ReactNode;
29
28
  }
@@ -31,7 +30,6 @@ declare const _default: {
31
30
  name: string;
32
31
  displayName: string;
33
32
  widget: typeof Interaction;
34
- transform: <T>(value: T) => T;
35
33
  hidden: true;
36
34
  };
37
35
  export default _default;