@khanacademy/perseus 65.8.0 → 66.0.1
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.
- package/dist/article-renderer.d.ts +2 -2
- package/dist/es/index.js +54 -52
- package/dist/es/index.js.map +1 -1
- package/dist/hint-renderer.d.ts +2 -0
- package/dist/index.js +53 -51
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +17 -6
- package/dist/server-item-renderer.d.ts +1 -1
- package/dist/types.d.ts +5 -20
- package/dist/user-input-manager.d.ts +45 -0
- package/dist/widget-ai-utils/categorizer/categorizer-ai-utils.d.ts +1 -2
- package/dist/widget-ai-utils/dropdown/dropdown-ai-utils.d.ts +1 -2
- package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +2 -2
- package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +1 -2
- package/dist/widget-ai-utils/label-image/label-image-ai-utils.d.ts +1 -2
- package/dist/widget-ai-utils/matcher/matcher-ai-utils.d.ts +2 -2
- package/dist/widget-ai-utils/matrix/matrix-ai-utils.d.ts +1 -2
- package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +1 -2
- package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +1 -2
- package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +1 -2
- package/dist/widget-ai-utils/orderer/orderer-ai-utils.d.ts +1 -2
- package/dist/widgets/categorizer/categorizer.d.ts +2 -5
- package/dist/widgets/cs-program/cs-program.d.ts +2 -1
- package/dist/widgets/dropdown/dropdown.d.ts +2 -5
- package/dist/widgets/expression/expression.d.ts +9 -16
- package/dist/widgets/free-response/free-response.d.ts +1 -5
- package/dist/widgets/graded-group/graded-group.d.ts +2 -3
- package/dist/widgets/graded-group-set/graded-group-set.d.ts +0 -1
- package/dist/widgets/grapher/grapher.d.ts +1 -2
- package/dist/widgets/group/group.d.ts +6 -8
- package/dist/widgets/iframe/iframe.d.ts +2 -1
- package/dist/widgets/input-number/input-number.d.ts +2 -6
- package/dist/widgets/interactive-graph.d.ts +3 -1
- package/dist/widgets/interactive-graphs/backgrounds/axis-labels.d.ts +3 -1
- package/dist/widgets/interactive-graphs/backgrounds/utils.d.ts +1 -0
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +2 -0
- package/dist/widgets/interactive-graphs/utils.d.ts +4 -0
- package/dist/widgets/label-image/label-image.d.ts +0 -5
- package/dist/widgets/matcher/matcher.d.ts +1 -6
- package/dist/widgets/matrix/matrix.d.ts +2 -6
- package/dist/widgets/mock-widgets/mock-widget.d.ts +8 -10
- package/dist/widgets/number-line/number-line.d.ts +0 -6
- package/dist/widgets/numeric-input/numeric-input.class.d.ts +6 -18
- package/dist/widgets/orderer/orderer.d.ts +3 -3
- package/dist/widgets/plotter/plotter.d.ts +2 -1
- package/dist/widgets/radio/multiple-choice-widget.new.d.ts +0 -12
- package/dist/widgets/radio/radio-component.d.ts +0 -5
- package/dist/widgets/radio/radio.d.ts +3 -2
- package/dist/widgets/sorter/sorter.d.ts +0 -5
- package/dist/widgets/table/table.d.ts +0 -2
- package/package.json +7 -7
package/dist/renderer.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import WidgetContainer from "./widget-container";
|
|
|
6
6
|
import type { DependenciesContext } from "./dependencies";
|
|
7
7
|
import type { PerseusStrings } from "./strings";
|
|
8
8
|
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, SerializedState, Widget, WidgetProps } from "./types";
|
|
9
|
+
import type { HandleUserInputCallback, InitializeUserInputCallback, RestoreUserInputFromSerializedStateCallback } from "./user-input-manager";
|
|
9
10
|
import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
|
|
10
11
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
11
|
-
import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, PerseusScore,
|
|
12
|
+
import type { PerseusRenderer, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, PerseusScore, UserInputMap, UserInputArray } from "@khanacademy/perseus-core";
|
|
12
13
|
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
13
14
|
import "./styles/perseus-renderer.css";
|
|
14
15
|
type WidgetState = {
|
|
@@ -20,6 +21,10 @@ type WidgetState = {
|
|
|
20
21
|
baseElements?: any;
|
|
21
22
|
};
|
|
22
23
|
type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
|
|
24
|
+
userInput?: UserInputMap;
|
|
25
|
+
handleUserInput?: HandleUserInputCallback;
|
|
26
|
+
initializeUserInput?: InitializeUserInputCallback;
|
|
27
|
+
restoreUserInputFromSerializedState?: RestoreUserInputFromSerializedStateCallback;
|
|
23
28
|
apiOptions?: APIOptions;
|
|
24
29
|
alwaysUpdate?: boolean;
|
|
25
30
|
findExternalWidgets: any;
|
|
@@ -61,11 +66,21 @@ type State = {
|
|
|
61
66
|
widgetProps: Readonly<{
|
|
62
67
|
[id: string]: any | null | undefined;
|
|
63
68
|
}>;
|
|
64
|
-
userInput: UserInputMap;
|
|
65
69
|
jiptContent: any;
|
|
66
70
|
lastUsedWidgetId: string | null | undefined;
|
|
67
71
|
};
|
|
68
72
|
type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "highlightedWidgets" | "images" | "linterContext" | "onInteractWithWidget" | "onRender" | "questionCompleted" | "showSolutions" | "reviewMode" | "serializedState" | "widgets">>;
|
|
73
|
+
/**
|
|
74
|
+
* We want to be able to reset the question state when we go
|
|
75
|
+
* from one question to another question. However it's kind of tricky:
|
|
76
|
+
* 1. Content could be the same
|
|
77
|
+
* 2. Problem number could be the same
|
|
78
|
+
* 3. We don't want to reset when going from answerless to answerful data
|
|
79
|
+
* So compare the prev props to the next props, but use
|
|
80
|
+
* answerless for both for the comparison
|
|
81
|
+
*/
|
|
82
|
+
export type DifferentQuestionPartialProps = Pick<Props, "content" | "widgets" | "problemNum">;
|
|
83
|
+
export declare function isDifferentQuestion(propsA: DifferentQuestionPartialProps, propsB: DifferentQuestionPartialProps): boolean;
|
|
69
84
|
declare class Renderer extends React.Component<Props, State> implements GetPromptJSONInterface {
|
|
70
85
|
static contextType: React.Context<import("./components/i18n-context").I18nContextType>;
|
|
71
86
|
context: React.ContextType<typeof PerseusI18nContext>;
|
|
@@ -94,9 +109,7 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
94
109
|
_getInitialWidgetState: (props: Props) => {
|
|
95
110
|
widgetInfo: State["widgetInfo"];
|
|
96
111
|
widgetProps: State["widgetProps"];
|
|
97
|
-
userInput: State["userInput"];
|
|
98
112
|
};
|
|
99
|
-
_getAllWidgetsStartUserInput(props: Props): UserInputMap;
|
|
100
113
|
_getAllWidgetsStartProps: (allWidgetInfo: PerseusWidgetsMap, props: Props) => PerseusWidgetsMap;
|
|
101
114
|
_getDefaultWidgetInfo: (widgetId: string) => any;
|
|
102
115
|
_getWidgetInfo: (widgetId: string) => PerseusWidget;
|
|
@@ -194,9 +207,7 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
194
207
|
*/
|
|
195
208
|
emptyWidgets(): ReadonlyArray<string>;
|
|
196
209
|
handleStateUpdate(id: string, cb: () => boolean, silent?: boolean): void;
|
|
197
|
-
_setUserInput(id: string, nextUserInput: UserInput, cb: () => boolean, silent?: boolean): void;
|
|
198
210
|
_setWidgetProps(id: string, nextWidgetProps: any, cb: () => boolean, silent?: boolean): void;
|
|
199
|
-
setInputValue: (path: FocusPath, newValue: string, cb?: () => void) => void;
|
|
200
211
|
/**
|
|
201
212
|
* Returns an array of the widget `.getUserInput()` results
|
|
202
213
|
*
|
|
@@ -67,6 +67,7 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
|
|
|
67
67
|
_currentFocus: FocusPath;
|
|
68
68
|
_fullyRendered: boolean;
|
|
69
69
|
blurTimeoutID: number | null | undefined;
|
|
70
|
+
userInput: UserInputMap;
|
|
70
71
|
static defaultProps: DefaultProps;
|
|
71
72
|
constructor(props: Props);
|
|
72
73
|
componentDidMount(): void;
|
|
@@ -83,7 +84,6 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
|
|
|
83
84
|
* for the whole answer area (if the answer area is a single widget).
|
|
84
85
|
*/
|
|
85
86
|
_setWidgetProps(widgetId: string, newProps: Props, callback: any): void;
|
|
86
|
-
setInputValue(path: FocusPath, newValue: any, focus: () => void): void;
|
|
87
87
|
focusPath(path: FocusPath): void;
|
|
88
88
|
blurPath(path: FocusPath): void;
|
|
89
89
|
getDOMNodeForPath(path: FocusPath): Element | Text | null | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PerseusStrings } from "./strings";
|
|
|
3
3
|
import type { SizeClass } from "./util/sizing-utils";
|
|
4
4
|
import type { WidgetPromptJSON } from "./widget-ai-utils/prompt-types";
|
|
5
5
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
6
|
-
import type { Hint, PerseusAnswerArea, PerseusFeatureFlags, PerseusWidget, PerseusWidgetsMap, AnalyticsEventHandlerFn, Version,
|
|
6
|
+
import type { Hint, PerseusAnswerArea, PerseusFeatureFlags, PerseusWidget, PerseusWidgetsMap, AnalyticsEventHandlerFn, Version, LabelImageMarkerPublicData, PerseusLabelImageMarker, ShowSolutions } from "@khanacademy/perseus-core";
|
|
7
7
|
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
8
8
|
import type { Result } from "@khanacademy/wonder-blocks-data";
|
|
9
9
|
import type * as React from "react";
|
|
@@ -63,21 +63,6 @@ export interface Widget {
|
|
|
63
63
|
blurInputPath?: (path: FocusPath) => void;
|
|
64
64
|
focusInputPath?: (path: FocusPath) => void;
|
|
65
65
|
getInputPaths?: () => ReadonlyArray<FocusPath>;
|
|
66
|
-
/**
|
|
67
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
68
|
-
* @deprecated get user input from Renderer state
|
|
69
|
-
*/
|
|
70
|
-
setInputValue?: (path: FocusPath, newValue: string, focus?: () => unknown) => void;
|
|
71
|
-
/**
|
|
72
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
73
|
-
* @deprecated get user input from Renderer state
|
|
74
|
-
*/
|
|
75
|
-
getUserInputMap?: () => UserInputMap | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
78
|
-
* @deprecated get user input from Renderer state
|
|
79
|
-
*/
|
|
80
|
-
getUserInput?: () => UserInputArray | UserInput | undefined;
|
|
81
66
|
getPromptJSON?: () => WidgetPromptJSON;
|
|
82
67
|
}
|
|
83
68
|
export type ImageDict = {
|
|
@@ -395,13 +380,13 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
|
|
|
395
380
|
* @deprecated see LEMS-3199
|
|
396
381
|
*/
|
|
397
382
|
staticTransform?: WidgetTransform;
|
|
398
|
-
getOneCorrectAnswerFromRubric?: (rubric:
|
|
383
|
+
getOneCorrectAnswerFromRubric?: (rubric: WidgetOptions) => string | null | undefined;
|
|
399
384
|
/**
|
|
400
385
|
* @deprecated - do not use in new code.
|
|
401
386
|
*/
|
|
402
|
-
getUserInputFromSerializedState?: (
|
|
403
|
-
getCorrectUserInput?: (widgetOptions:
|
|
404
|
-
getStartUserInput?: (widgetOptions:
|
|
387
|
+
getUserInputFromSerializedState?: (serializedState: unknown, widgetOptions?: WidgetOptions) => TUserInput;
|
|
388
|
+
getCorrectUserInput?: (widgetOptions: WidgetOptions) => TUserInput;
|
|
389
|
+
getStartUserInput?: (widgetOptions: WidgetOptions, problemNum: number) => TUserInput;
|
|
405
390
|
}>;
|
|
406
391
|
export type FilterCriterion = string | ((id: string, widgetInfo: PerseusWidget, widget?: Widget | null | undefined) => boolean);
|
|
407
392
|
/**
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PerseusWidgetsMap, UserInputMap } from "@khanacademy/perseus-core";
|
|
2
|
+
export type InitializeUserInputCallback = (widgetOptions: PerseusWidgetsMap, problemNum: number) => void;
|
|
3
|
+
export type RestoreUserInputFromSerializedStateCallback = (serializedState: unknown, widgetOptions: PerseusWidgetsMap) => void;
|
|
4
|
+
export type HandleUserInputCallback = (widgetId: string, userInput: UserInputMap[keyof UserInputMap]) => void;
|
|
5
|
+
type FunctionChildParams = {
|
|
6
|
+
userInput: UserInputMap;
|
|
7
|
+
handleUserInput: HandleUserInputCallback;
|
|
8
|
+
initializeUserInput: InitializeUserInputCallback;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated - do not use in new code.
|
|
11
|
+
*/
|
|
12
|
+
restoreUserInputFromSerializedState: RestoreUserInputFromSerializedStateCallback;
|
|
13
|
+
};
|
|
14
|
+
type Props = {
|
|
15
|
+
widgets: PerseusWidgetsMap;
|
|
16
|
+
problemNum: number;
|
|
17
|
+
handleUserInput?: (userInput: UserInputMap) => void;
|
|
18
|
+
children: (payload: FunctionChildParams) => JSX.Element | null;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the starting UserInput state:
|
|
22
|
+
* - for static widgets, that's the correct UserInput
|
|
23
|
+
* - some widgets just like having something to start with
|
|
24
|
+
* - some widgets use initial UserInput state as the "shuffled state"
|
|
25
|
+
* (which is why we need problemNum since it's the seed)
|
|
26
|
+
*/
|
|
27
|
+
export declare function sharedInitializeUserInput(widgetOptions: PerseusWidgetsMap | undefined, problemNum: number): UserInputMap;
|
|
28
|
+
/**
|
|
29
|
+
* Restore user input from serialized state. It's tricky
|
|
30
|
+
* because there is no definite type for serialized state,
|
|
31
|
+
* so widgets need to handle it themselves and overall the process
|
|
32
|
+
* is very fragile.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated - do not use in new code.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sharedRestoreUserInputFromSerializedState(serializedState: unknown, widgetsMap: PerseusWidgetsMap): UserInputMap;
|
|
37
|
+
/**
|
|
38
|
+
* UserInputManager is a stateful wrapper for handling and storing user input.
|
|
39
|
+
* Ideally we'll get to a place where widgets are functional components
|
|
40
|
+
* (or wrapped in functional components) and we can replace this with a
|
|
41
|
+
* combination of Context/Hooks so that it can just wrap all of Perseus and
|
|
42
|
+
* widgets can managing fetching/updating their own state via hooks.
|
|
43
|
+
*/
|
|
44
|
+
export default function UserInputManager(props: Props): JSX.Element | null;
|
|
45
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type categorizer from "../../widgets/categorizer/categorizer";
|
|
2
|
-
import type { PerseusCategorizerUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type CategorizerPromptJSON = {
|
|
5
4
|
type: "categorizer";
|
|
@@ -11,4 +10,4 @@ export type CategorizerPromptJSON = {
|
|
|
11
10
|
itemToCategoryMapping: ReadonlyArray<number>;
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof categorizer.widget
|
|
13
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof categorizer.widget>) => CategorizerPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type dropdown from "../../widgets/dropdown/dropdown";
|
|
2
|
-
import type { PerseusDropdownUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type DropdownPromptJSON = {
|
|
5
4
|
type: "dropdown";
|
|
@@ -10,4 +9,4 @@ export type DropdownPromptJSON = {
|
|
|
10
9
|
selectedIndex: number;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof dropdown.widget
|
|
12
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof dropdown.widget>) => DropdownPromptJSON;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type grapher from "../../widgets/grapher/grapher";
|
|
2
|
-
import type { GrapherAnswerTypes
|
|
2
|
+
import type { GrapherAnswerTypes } from "@khanacademy/perseus-core";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
export type GrapherPromptJSON = {
|
|
5
5
|
type: "grapher";
|
|
@@ -14,4 +14,4 @@ export type GrapherPromptJSON = {
|
|
|
14
14
|
};
|
|
15
15
|
userInput: GrapherAnswerTypes;
|
|
16
16
|
};
|
|
17
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof grapher.widget
|
|
17
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof grapher.widget>) => GrapherPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type inputNumber from "../../widgets/input-number/input-number";
|
|
2
|
-
import type { PerseusInputNumberUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type InputNumberPromptJSON = {
|
|
5
4
|
type: "input-number";
|
|
@@ -11,4 +10,4 @@ export type InputNumberPromptJSON = {
|
|
|
11
10
|
value: string;
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof inputNumber.widget
|
|
13
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof inputNumber.widget>) => InputNumberPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type labelImage from "../../widgets/label-image/label-image";
|
|
2
|
-
import type { PerseusLabelImageUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
type BaseMarker = {
|
|
5
4
|
label: string;
|
|
@@ -21,5 +20,5 @@ export type LabelImagePromptJSON = {
|
|
|
21
20
|
markers: UserInputMarker[];
|
|
22
21
|
};
|
|
23
22
|
};
|
|
24
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof labelImage.widget
|
|
23
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof labelImage.widget>) => LabelImagePromptJSON;
|
|
25
24
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type matcher from "../../widgets/matcher/matcher";
|
|
2
|
-
import type { PerseusMatcherUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type MatcherPromptJSON = {
|
|
5
4
|
type: "matcher";
|
|
@@ -14,4 +13,5 @@ export type MatcherPromptJSON = {
|
|
|
14
13
|
right: ReadonlyArray<string>;
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
|
-
export
|
|
16
|
+
export type RenderPropsPartial = Pick<React.ComponentProps<typeof matcher.widget>, "userInput" | "labels" | "left" | "right" | "orderMatters">;
|
|
17
|
+
export declare const getPromptJSON: (renderProps: RenderPropsPartial) => MatcherPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type matrix from "../../widgets/matrix/matrix";
|
|
2
|
-
import type { PerseusMatrixUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type MatrixPromptJSON = {
|
|
5
4
|
type: "matrix";
|
|
@@ -11,4 +10,4 @@ export type MatrixPromptJSON = {
|
|
|
11
10
|
answerRows: ReadonlyArray<ReadonlyArray<number>>;
|
|
12
11
|
};
|
|
13
12
|
};
|
|
14
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof matrix.widget
|
|
13
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof matrix.widget>) => MatrixPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type mockWidget from "../../widgets/mock-widgets/mock-widget";
|
|
2
|
-
import type { PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type MockWidgetPromptJSON = {
|
|
5
4
|
type: "mock-widget";
|
|
@@ -10,4 +9,4 @@ export type MockWidgetPromptJSON = {
|
|
|
10
9
|
value: string;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof mockWidget.widget
|
|
12
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof mockWidget.widget>) => MockWidgetPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type numberLine from "../../widgets/number-line/number-line";
|
|
2
|
-
import type { PerseusNumberLineUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type NumberLinePromptJSON = {
|
|
5
4
|
type: "number-line";
|
|
@@ -13,4 +12,4 @@ export type NumberLinePromptJSON = {
|
|
|
13
12
|
rel: string;
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof numberLine.widget
|
|
15
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof numberLine.widget>) => NumberLinePromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type numericInput from "../../widgets/numeric-input/numeric-input.class";
|
|
2
|
-
import type { PerseusNumericInputUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type NumericInputPromptJSON = {
|
|
5
4
|
type: "numeric-input";
|
|
@@ -8,4 +7,4 @@ export type NumericInputPromptJSON = {
|
|
|
8
7
|
value: string;
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof numericInput.widget
|
|
10
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof numericInput.widget>) => NumericInputPromptJSON;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type orderer from "../../widgets/orderer/orderer";
|
|
2
|
-
import type { PerseusOrdererUserInput } from "@khanacademy/perseus-core";
|
|
3
2
|
import type React from "react";
|
|
4
3
|
export type OrdererPromptJSON = {
|
|
5
4
|
type: "orderer";
|
|
@@ -10,4 +9,4 @@ export type OrdererPromptJSON = {
|
|
|
10
9
|
values: ReadonlyArray<string>;
|
|
11
10
|
};
|
|
12
11
|
};
|
|
13
|
-
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof orderer.widget
|
|
12
|
+
export declare const getPromptJSON: (renderProps: React.ComponentProps<typeof orderer.widget>) => OrdererPromptJSON;
|
|
@@ -18,11 +18,6 @@ export declare class Categorizer extends React.Component<Props, State> implement
|
|
|
18
18
|
context: React.ContextType<typeof PerseusI18nContext>;
|
|
19
19
|
static defaultProps: DefaultProps;
|
|
20
20
|
state: State;
|
|
21
|
-
/**
|
|
22
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
23
|
-
* @deprecated get user input from Renderer state
|
|
24
|
-
*/
|
|
25
|
-
getUserInput(): PerseusCategorizerUserInput;
|
|
26
21
|
/**
|
|
27
22
|
* @deprecated and likely very broken API
|
|
28
23
|
* [LEMS-3185] do not trust serializedState/restoreSerializedState
|
|
@@ -48,6 +43,7 @@ declare function getUserInputFromSerializedState(serializedState: any): PerseusC
|
|
|
48
43
|
* used to populate correct input and now can't
|
|
49
44
|
*/
|
|
50
45
|
declare function getCorrectUserInput(options: PerseusCategorizerWidgetOptions): PerseusCategorizerUserInput;
|
|
46
|
+
declare function getStartUserInput(): PerseusCategorizerUserInput;
|
|
51
47
|
declare function transform(widgetOptions: CategorizerPublicWidgetOptions): RenderProps;
|
|
52
48
|
declare const _default: {
|
|
53
49
|
name: string;
|
|
@@ -58,6 +54,7 @@ declare const _default: {
|
|
|
58
54
|
staticTransform: typeof transform;
|
|
59
55
|
getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
|
|
60
56
|
getCorrectUserInput: typeof getCorrectUserInput;
|
|
57
|
+
getStartUserInput: typeof getStartUserInput;
|
|
61
58
|
isLintable: true;
|
|
62
59
|
};
|
|
63
60
|
export default _default;
|
|
@@ -17,7 +17,6 @@ declare class CSProgram extends React.Component<Props> implements Widget {
|
|
|
17
17
|
componentDidMount(): void;
|
|
18
18
|
componentWillUnmount(): void;
|
|
19
19
|
handleMessageEvent: (arg1: any) => void;
|
|
20
|
-
getUserInput(): PerseusCSProgramUserInput;
|
|
21
20
|
getPromptJSON(): UnsupportedWidgetPromptJSON;
|
|
22
21
|
render(): React.ReactNode;
|
|
23
22
|
}
|
|
@@ -26,11 +25,13 @@ declare class CSProgram extends React.Component<Props> implements Widget {
|
|
|
26
25
|
* [LEMS-3185] do not trust serializedState/restoreSerializedState
|
|
27
26
|
*/
|
|
28
27
|
declare function getUserInputFromSerializedState(serializedState: any): PerseusCSProgramUserInput;
|
|
28
|
+
declare function getStartUserInput(): PerseusCSProgramUserInput;
|
|
29
29
|
declare const _default: {
|
|
30
30
|
name: string;
|
|
31
31
|
displayName: string;
|
|
32
32
|
widget: typeof CSProgram;
|
|
33
33
|
hidden: true;
|
|
34
|
+
getStartUserInput: typeof getStartUserInput;
|
|
34
35
|
getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
|
|
35
36
|
};
|
|
36
37
|
export default _default;
|
|
@@ -23,11 +23,6 @@ declare class Dropdown extends React.Component<Props> implements Widget {
|
|
|
23
23
|
focus: () => boolean;
|
|
24
24
|
_handleChangeEvent: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
|
|
25
25
|
_handleChange: (arg1: number) => void;
|
|
26
|
-
/**
|
|
27
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
28
|
-
* @deprecated get user input from Renderer state
|
|
29
|
-
*/
|
|
30
|
-
getUserInput(): PerseusDropdownUserInput;
|
|
31
26
|
getPromptJSON(): DropdownPromptJSON;
|
|
32
27
|
/**
|
|
33
28
|
* @deprecated and likely very broken API
|
|
@@ -42,11 +37,13 @@ declare function transform(widgetOptions: DropdownPublicWidgetOptions): RenderPr
|
|
|
42
37
|
* [LEMS-3185] do not trust serializedState/restoreSerializedState
|
|
43
38
|
*/
|
|
44
39
|
declare function getUserInputFromSerializedState(serializedState: any): PerseusDropdownUserInput;
|
|
40
|
+
declare function getStartUserInput(): PerseusDropdownUserInput;
|
|
45
41
|
declare const _default: {
|
|
46
42
|
name: string;
|
|
47
43
|
displayName: string;
|
|
48
44
|
widget: typeof Dropdown;
|
|
49
45
|
transform: typeof transform;
|
|
46
|
+
getStartUserInput: typeof getStartUserInput;
|
|
50
47
|
getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
|
|
51
48
|
};
|
|
52
49
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
3
|
import type { DependenciesContext } from "../../dependencies";
|
|
4
|
-
import type { WidgetProps, Widget
|
|
4
|
+
import type { WidgetProps, Widget } from "../../types";
|
|
5
5
|
import type { ExpressionPromptJSON } from "../../widget-ai-utils/expression/expression-ai-utils";
|
|
6
6
|
import type { PerseusExpressionWidgetOptions, ExpressionPublicWidgetOptions, KeypadConfiguration, KeypadKey, PerseusExpressionRubric, PerseusExpressionUserInput } from "@khanacademy/perseus-core";
|
|
7
7
|
type InputPath = ReadonlyArray<string>;
|
|
@@ -45,10 +45,6 @@ export declare class Expression extends React.Component<Props> implements Widget
|
|
|
45
45
|
displayName: string;
|
|
46
46
|
componentDidMount: () => void;
|
|
47
47
|
componentWillUnmount: () => void;
|
|
48
|
-
/**
|
|
49
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
50
|
-
* @deprecated get user input from Renderer state
|
|
51
|
-
*/
|
|
52
48
|
getUserInput(): PerseusExpressionUserInput;
|
|
53
49
|
getPromptJSON(): ExpressionPromptJSON;
|
|
54
50
|
changeAndTrack: (userInput: string, cb: () => void) => void;
|
|
@@ -59,11 +55,6 @@ export declare class Expression extends React.Component<Props> implements Widget
|
|
|
59
55
|
blurInputPath(inputPath: InputPath): void;
|
|
60
56
|
insert(keyPressed: KeypadKey): void;
|
|
61
57
|
getInputPaths: () => ReadonlyArray<ReadonlyArray<any>>;
|
|
62
|
-
/**
|
|
63
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
64
|
-
* @deprecated set user input in a parent component
|
|
65
|
-
*/
|
|
66
|
-
setInputValue(path: FocusPath, newValue: string, cb?: any): void;
|
|
67
58
|
/**
|
|
68
59
|
* @deprecated and likely very broken API
|
|
69
60
|
* [LEMS-3185] do not trust serializedState/restoreSerializedState
|
|
@@ -85,7 +76,7 @@ export declare class Expression extends React.Component<Props> implements Widget
|
|
|
85
76
|
problemNum: number | null | undefined;
|
|
86
77
|
apiOptions: Readonly<Readonly<{
|
|
87
78
|
isArticle?: boolean;
|
|
88
|
-
onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
79
|
+
onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
89
80
|
GroupMetadataEditor?: React.ComponentType<any>;
|
|
90
81
|
showAlignmentOptions?: boolean;
|
|
91
82
|
readOnly?: boolean;
|
|
@@ -133,8 +124,8 @@ export declare class Expression extends React.Component<Props> implements Widget
|
|
|
133
124
|
}>;
|
|
134
125
|
keypadElement?: any;
|
|
135
126
|
questionCompleted?: boolean;
|
|
136
|
-
onFocus: (blurPath: FocusPath) => void;
|
|
137
|
-
onBlur: (blurPath: FocusPath) => void;
|
|
127
|
+
onFocus: (blurPath: import("../..").FocusPath) => void;
|
|
128
|
+
onBlur: (blurPath: import("../..").FocusPath) => void;
|
|
138
129
|
findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
|
|
139
130
|
reviewMode: boolean;
|
|
140
131
|
showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
|
|
@@ -157,6 +148,7 @@ export declare class Expression extends React.Component<Props> implements Widget
|
|
|
157
148
|
* [LEMS-3185] do not trust serializedState/restoreSerializedState
|
|
158
149
|
*/
|
|
159
150
|
declare function getUserInputFromSerializedState(serializedState: any): PerseusExpressionUserInput;
|
|
151
|
+
declare function getStartUserInput(): PerseusExpressionUserInput;
|
|
160
152
|
declare const _default: {
|
|
161
153
|
name: string;
|
|
162
154
|
displayName: string;
|
|
@@ -172,11 +164,11 @@ declare const _default: {
|
|
|
172
164
|
ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
|
|
173
165
|
}, "static" | "onChange" | "ariaLabel" | "buttonsVisible" | "trackInteraction" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "keypadElement" | "isLastUsedWidget" | "handleUserInput" | "showSolutions" | "reviewMode" | "reviewModeRubric" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "visibleLabel" | "keypadConfiguration"> & {
|
|
174
166
|
buttonSets?: import("@khanacademy/perseus-core").LegacyButtonSets | undefined;
|
|
175
|
-
onFocus?: ((blurPath: FocusPath) => void) | undefined;
|
|
176
|
-
onBlur?: ((blurPath: FocusPath) => void) | undefined;
|
|
167
|
+
onFocus?: ((blurPath: import("../..").FocusPath) => void) | undefined;
|
|
168
|
+
onBlur?: ((blurPath: import("../..").FocusPath) => void) | undefined;
|
|
177
169
|
apiOptions?: Readonly<Readonly<{
|
|
178
170
|
isArticle?: boolean;
|
|
179
|
-
onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
171
|
+
onFocusChange?: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
|
|
180
172
|
GroupMetadataEditor?: React.ComponentType<any>;
|
|
181
173
|
showAlignmentOptions?: boolean;
|
|
182
174
|
readOnly?: boolean;
|
|
@@ -231,6 +223,7 @@ declare const _default: {
|
|
|
231
223
|
version: import("@khanacademy/perseus-core").Version | undefined;
|
|
232
224
|
isLintable: true;
|
|
233
225
|
getOneCorrectAnswerFromRubric(rubric: PerseusExpressionRubric): string | null | undefined;
|
|
226
|
+
getStartUserInput: typeof getStartUserInput;
|
|
234
227
|
getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
|
|
235
228
|
};
|
|
236
229
|
export default _default;
|
|
@@ -14,13 +14,9 @@ type DefaultProps = Pick<Props, "userInput">;
|
|
|
14
14
|
export declare class FreeResponse extends React.Component<Props> implements Widget {
|
|
15
15
|
static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
|
|
16
16
|
context: React.ContextType<typeof PerseusI18nContext>;
|
|
17
|
+
isWidget: true;
|
|
17
18
|
static defaultProps: DefaultProps;
|
|
18
19
|
characterCount: () => number;
|
|
19
|
-
/**
|
|
20
|
-
* TODO: remove this when everything is pulling from Renderer state
|
|
21
|
-
* @deprecated get user input from Renderer state
|
|
22
|
-
* */
|
|
23
|
-
getUserInput(): PerseusFreeResponseUserInput;
|
|
24
20
|
_handleUserInput: (newValue: string) => void;
|
|
25
21
|
isOverLimit(): boolean;
|
|
26
22
|
renderCharacterCount(): React.ReactNode;
|
|
@@ -12,7 +12,7 @@ declare const GRADING_STATUSES: {
|
|
|
12
12
|
readonly invalid: "invalid";
|
|
13
13
|
};
|
|
14
14
|
type RenderProps = PerseusGradedGroupWidgetOptions;
|
|
15
|
-
type Props = WidgetProps<RenderProps,
|
|
15
|
+
type Props = WidgetProps<RenderProps, Empty, TrackingGradedGroupExtraArguments> & {
|
|
16
16
|
inGradedGroupSet?: boolean;
|
|
17
17
|
onNextQuestion?: () => unknown;
|
|
18
18
|
};
|
|
@@ -40,11 +40,10 @@ export declare class GradedGroup extends React.Component<Props, State> implement
|
|
|
40
40
|
hintRendererRef: React.RefObject<Renderer>;
|
|
41
41
|
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
42
42
|
change: (...args: ReadonlyArray<unknown>) => any;
|
|
43
|
-
|
|
43
|
+
_handleUserInput(): void;
|
|
44
44
|
_checkAnswer: () => void;
|
|
45
45
|
getInputPaths: () => ReadonlyArray<FocusPath>;
|
|
46
46
|
getPromptJSON(): GradedGroupPromptJSON;
|
|
47
|
-
setInputValue: (arg1: any, arg2: any, arg3: any) => any;
|
|
48
47
|
focus: () => boolean;
|
|
49
48
|
focusInputPath: (arg1: any) => void;
|
|
50
49
|
blurInputPath: (arg1: any) => void;
|
|
@@ -21,7 +21,6 @@ declare class GradedGroupSet extends React.Component<Props, State> implements Wi
|
|
|
21
21
|
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
22
22
|
getInputPaths: () => ReadonlyArray<FocusPath>;
|
|
23
23
|
getPromptJSON(): GradedGroupSetPromptJSON;
|
|
24
|
-
setInputValue: (arg1: FocusPath, arg2: any, arg3: any) => any;
|
|
25
24
|
focus: () => boolean;
|
|
26
25
|
focusInputPath: (arg1: FocusPath) => void;
|
|
27
26
|
blurInputPath: (arg1: FocusPath) => void;
|
|
@@ -21,7 +21,6 @@ declare class Grapher extends React.Component<Props> implements Widget {
|
|
|
21
21
|
_setupGraphie: (arg1: any, arg2: any) => void;
|
|
22
22
|
showHairlines: (arg1: Coord) => void;
|
|
23
23
|
hideHairlines: () => void;
|
|
24
|
-
getUserInput(): PerseusGrapherUserInput;
|
|
25
24
|
getPromptJSON(): GrapherPromptJSON;
|
|
26
25
|
/**
|
|
27
26
|
* @deprecated and likely very broken API
|
|
@@ -125,7 +124,7 @@ declare class Grapher extends React.Component<Props> implements Widget {
|
|
|
125
124
|
}
|
|
126
125
|
declare function transform(options: GrapherPublicWidgetOptions): RenderProps;
|
|
127
126
|
declare function staticTransform(options: PerseusGrapherWidgetOptions): {
|
|
128
|
-
availableTypes: ("linear" | "quadratic" | "sinusoid" | "
|
|
127
|
+
availableTypes: ("linear" | "quadratic" | "sinusoid" | "tangent" | "exponential" | "logarithm" | "absolute_value")[];
|
|
129
128
|
plot: import("@khanacademy/perseus-core").GrapherAnswerTypes;
|
|
130
129
|
graph: {
|
|
131
130
|
backgroundImage: {
|
|
@@ -11,9 +11,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
11
11
|
import Renderer from "../../renderer";
|
|
12
12
|
import type { ChangeFn, FocusPath, Widget, WidgetProps } from "../../types";
|
|
13
13
|
import type { GroupPromptJSON } from "../../widget-ai-utils/group/group-ai-utils";
|
|
14
|
-
import type {
|
|
14
|
+
import type { PerseusGroupUserInput, PerseusGroupWidgetOptions, PerseusRenderer } from "@khanacademy/perseus-core";
|
|
15
15
|
type RenderProps = PerseusGroupWidgetOptions;
|
|
16
|
-
type Props = WidgetProps<RenderProps>;
|
|
16
|
+
type Props = WidgetProps<RenderProps, PerseusGroupUserInput>;
|
|
17
17
|
type DefaultProps = {
|
|
18
18
|
content: Props["content"];
|
|
19
19
|
widgets: Props["widgets"];
|
|
@@ -27,11 +27,6 @@ declare class Group extends React.Component<Props> implements Widget {
|
|
|
27
27
|
static defaultProps: DefaultProps;
|
|
28
28
|
componentDidMount(): void;
|
|
29
29
|
change: ChangeFn;
|
|
30
|
-
getUserInputMap(): UserInputMap | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated getUserInputMap should be used for Groups
|
|
33
|
-
*/
|
|
34
|
-
getUserInput(): UserInputArray | undefined;
|
|
35
30
|
getPromptJSON(): GroupPromptJSON;
|
|
36
31
|
/**
|
|
37
32
|
* @deprecated - do not use in new code.
|
|
@@ -42,17 +37,20 @@ declare class Group extends React.Component<Props> implements Widget {
|
|
|
42
37
|
*/
|
|
43
38
|
restoreSerializedState: (arg1: any, arg2: any) => null;
|
|
44
39
|
getInputPaths(): readonly FocusPath[];
|
|
45
|
-
setInputValue: (arg1: FocusPath, arg2: string, arg3?: () => unknown) => void;
|
|
46
40
|
focus(): boolean;
|
|
47
41
|
focusInputPath: (arg1: FocusPath) => void;
|
|
48
42
|
blurInputPath: (arg1: FocusPath) => void;
|
|
49
43
|
render(): React.ReactNode;
|
|
50
44
|
}
|
|
45
|
+
declare function getStartUserInput(options: PerseusRenderer, problemNum: number): PerseusGroupUserInput;
|
|
46
|
+
declare function getUserInputFromSerializedState(serializedState: unknown, widgetOptions: PerseusGroupWidgetOptions): PerseusGroupUserInput;
|
|
51
47
|
declare const _default: {
|
|
52
48
|
name: string;
|
|
53
49
|
displayName: string;
|
|
54
50
|
widget: typeof Group;
|
|
55
51
|
hidden: true;
|
|
56
52
|
isLintable: true;
|
|
53
|
+
getStartUserInput: typeof getStartUserInput;
|
|
54
|
+
getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
|
|
57
55
|
};
|
|
58
56
|
export default _default;
|
|
@@ -24,7 +24,6 @@ declare class Iframe extends React.Component<Props> implements Widget {
|
|
|
24
24
|
static defaultProps: DefaultProps;
|
|
25
25
|
componentDidMount(): void;
|
|
26
26
|
componentWillUnmount(): void;
|
|
27
|
-
getUserInput(): PerseusIFrameUserInput;
|
|
28
27
|
getPromptJSON(): UnsupportedWidgetPromptJSON;
|
|
29
28
|
handleMessageEvent: (arg1: any) => void;
|
|
30
29
|
render(): React.ReactNode;
|
|
@@ -34,11 +33,13 @@ declare class Iframe extends React.Component<Props> implements Widget {
|
|
|
34
33
|
* [LEMS-3185] do not trust serializedState/restoreSerializedState
|
|
35
34
|
*/
|
|
36
35
|
declare function getUserInputFromSerializedState(serializedState: any): PerseusIFrameUserInput;
|
|
36
|
+
declare function getStartUserInput(): PerseusIFrameUserInput;
|
|
37
37
|
declare const _default: {
|
|
38
38
|
name: string;
|
|
39
39
|
displayName: string;
|
|
40
40
|
widget: typeof Iframe;
|
|
41
41
|
hidden: true;
|
|
42
|
+
getStartUserInput: typeof getStartUserInput;
|
|
42
43
|
getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
|
|
43
44
|
};
|
|
44
45
|
export default _default;
|