@khanacademy/perseus 68.0.1 → 69.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.
- package/dist/es/index.css +6 -4
- package/dist/es/index.css.map +1 -1
- package/dist/es/index.js +43 -46
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +6 -4
- package/dist/index.css.map +1 -1
- package/dist/index.js +42 -45
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +1 -12
- package/dist/server-item-renderer.d.ts +0 -6
- package/dist/types.d.ts +3 -26
- package/dist/widget-ai-utils/categorizer/categorizer-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/definition/definition-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/dropdown/dropdown-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/explanation/explanation-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/expression/expression-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/graded-group-set/graded-group-set-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/image/image-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/label-image/label-image-ai-utils.d.ts +1 -1
- 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 -1
- package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +1 -1
- package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +1 -1
- package/dist/widget-ai-utils/orderer/orderer-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/passage/passage-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/passage-ref/passage-ref-ai-utils.d.ts +1 -1
- package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +1 -1
- package/dist/widget-container.d.ts +1 -4
- package/dist/widgets/categorizer/categorizer.d.ts +4 -11
- package/dist/widgets/cs-program/cs-program.d.ts +6 -2
- package/dist/widgets/definition/definition.d.ts +1 -2
- package/dist/widgets/explanation/explanation.d.ts +1 -3
- package/dist/widgets/free-response/free-response.d.ts +1 -2
- package/dist/widgets/graded-group/graded-group.d.ts +0 -1
- package/dist/widgets/group/group.d.ts +1 -2
- package/dist/widgets/iframe/iframe.d.ts +6 -5
- package/dist/widgets/interaction/interaction.d.ts +1 -2
- package/dist/widgets/interactive-graphs/interactive-graph.d.ts +3 -3
- package/dist/widgets/matcher/matcher.d.ts +1 -2
- package/dist/widgets/matrix/matrix.d.ts +2 -7
- package/dist/widgets/orderer/orderer.d.ts +1 -2
- package/dist/widgets/passage/passage.d.ts +2 -4
- package/dist/widgets/passage-ref/passage-ref.d.ts +1 -6
- package/dist/widgets/plotter/plotter.d.ts +1 -1
- package/dist/widgets/radio/index.d.ts +0 -1
- package/dist/widgets/radio/multiple-choice-widget.new.d.ts +2 -2
- package/dist/widgets/radio/radio-component.d.ts +2 -2
- package/dist/widgets/radio/radio.ff.d.ts +3 -3
- package/dist/widgets/table/table.d.ts +8 -9
- package/dist/widgets.d.ts +3 -11
- package/package.json +43 -43
package/dist/renderer.d.ts
CHANGED
|
@@ -58,9 +58,6 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
|
|
|
58
58
|
type State = {
|
|
59
59
|
translationLintErrors: ReadonlyArray<string>;
|
|
60
60
|
widgetInfo: Readonly<PerseusWidgetsMap>;
|
|
61
|
-
widgetProps: Readonly<{
|
|
62
|
-
[id: string]: any | null | undefined;
|
|
63
|
-
}>;
|
|
64
61
|
jiptContent: any;
|
|
65
62
|
lastUsedWidgetId: string | null | undefined;
|
|
66
63
|
};
|
|
@@ -88,8 +85,6 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
88
85
|
_isTwoColumn: boolean;
|
|
89
86
|
_translationLinter: TranslationLinter;
|
|
90
87
|
_widgetContainers: Map<string, WidgetContainer>;
|
|
91
|
-
lastRenderedMarkdown: React.ReactNode;
|
|
92
|
-
reuseMarkdown: boolean;
|
|
93
88
|
translationIndex: number;
|
|
94
89
|
widgetIds: Array<string>;
|
|
95
90
|
static defaultProps: DefaultProps;
|
|
@@ -97,15 +92,12 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
97
92
|
componentDidMount(): void;
|
|
98
93
|
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
99
94
|
shouldComponentUpdate(nextProps: Props, nextState: State): any | boolean;
|
|
100
|
-
UNSAFE_componentWillUpdate(nextProps: Props, nextState: State): void;
|
|
101
95
|
componentDidUpdate(prevProps: Props, prevState: State): void;
|
|
102
96
|
componentWillUnmount(): void;
|
|
103
97
|
getApiOptions: () => APIOptionsWithDefaults;
|
|
104
98
|
_getInitialWidgetState: (props: Props) => {
|
|
105
99
|
widgetInfo: State["widgetInfo"];
|
|
106
|
-
widgetProps: State["widgetProps"];
|
|
107
100
|
};
|
|
108
|
-
_getAllWidgetsStartProps: (allWidgetInfo: PerseusWidgetsMap, props: Props) => PerseusWidgetsMap;
|
|
109
101
|
_getDefaultWidgetInfo: (widgetId: string) => any;
|
|
110
102
|
_getWidgetInfo: (widgetId: string) => PerseusWidget;
|
|
111
103
|
renderWidget: (impliedType: string, id: string, state: WidgetState) => null | React.ReactNode;
|
|
@@ -120,9 +112,7 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
120
112
|
/**
|
|
121
113
|
* @deprecated - do not use in new code.
|
|
122
114
|
*/
|
|
123
|
-
getSerializedState:
|
|
124
|
-
[id: string]: any;
|
|
125
|
-
};
|
|
115
|
+
getSerializedState(): Record<string, any>;
|
|
126
116
|
/**
|
|
127
117
|
* Allows inter-widget communication.
|
|
128
118
|
*
|
|
@@ -196,7 +186,6 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
196
186
|
*/
|
|
197
187
|
emptyWidgets(): ReadonlyArray<string>;
|
|
198
188
|
handleStateUpdate(id: string, cb: () => boolean, silent?: boolean): void;
|
|
199
|
-
_setWidgetProps(id: string, nextWidgetProps: any, cb: () => boolean, silent?: boolean): void;
|
|
200
189
|
/**
|
|
201
190
|
* Returns an array of the widget `.getUserInput()` results
|
|
202
191
|
*
|
|
@@ -78,12 +78,6 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
|
|
|
78
78
|
_handleFocusChange: (newFocus: FocusPath, oldFocus: FocusPath) => void;
|
|
79
79
|
_setCurrentFocus(newFocus: FocusPath): void;
|
|
80
80
|
_onRendererBlur(blurPath: FocusPath): void;
|
|
81
|
-
/**
|
|
82
|
-
* Accepts a question area widgetId, or an answer area widgetId of
|
|
83
|
-
* the form "answer-input-number 1", or the string "answer-area"
|
|
84
|
-
* for the whole answer area (if the answer area is a single widget).
|
|
85
|
-
*/
|
|
86
|
-
_setWidgetProps(widgetId: string, newProps: Props, callback: any): void;
|
|
87
81
|
focusPath(path: FocusPath): void;
|
|
88
82
|
blurPath(path: FocusPath): void;
|
|
89
83
|
getDOMNodeForPath(path: FocusPath): Element | Text | null | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ILogger } from "./logging/log";
|
|
2
|
-
import type { PerseusStrings } from "./strings";
|
|
3
2
|
import type { SizeClass } from "./util/sizing-utils";
|
|
4
3
|
import type { WidgetPromptJSON } from "./widget-ai-utils/prompt-types";
|
|
5
4
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
@@ -326,12 +325,6 @@ type TrackingSequenceExtraArguments = {
|
|
|
326
325
|
visible: number;
|
|
327
326
|
};
|
|
328
327
|
type WidgetOptions = any;
|
|
329
|
-
/**
|
|
330
|
-
* A transform that maps the WidgetOptions (sometimes referred to as
|
|
331
|
-
* EditorProps) to the props used to render the widget. Often this is an
|
|
332
|
-
* identity transform.
|
|
333
|
-
*/
|
|
334
|
-
export type WidgetTransform = (widgetOptions: WidgetOptions, strings: PerseusStrings, problemNumber?: number) => any;
|
|
335
328
|
export type WidgetExports<T extends React.ComponentType<any> & Widget = React.ComponentType<any>, TUserInput = Empty> = Readonly<{
|
|
336
329
|
name: string;
|
|
337
330
|
displayName: string;
|
|
@@ -350,19 +343,6 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
|
|
|
350
343
|
version?: Version;
|
|
351
344
|
isLintable?: boolean;
|
|
352
345
|
tracking?: Tracking;
|
|
353
|
-
/**
|
|
354
|
-
* Transforms the widget options to the props used to render the widget.
|
|
355
|
-
*
|
|
356
|
-
* @deprecated see LEMS-3199
|
|
357
|
-
*/
|
|
358
|
-
transform?: WidgetTransform;
|
|
359
|
-
/**
|
|
360
|
-
* Transforms the widget options to the props used to render the widget for
|
|
361
|
-
* static renders.
|
|
362
|
-
*
|
|
363
|
-
* @deprecated see LEMS-3199
|
|
364
|
-
*/
|
|
365
|
-
staticTransform?: WidgetTransform;
|
|
366
346
|
getOneCorrectAnswerFromRubric?: (rubric: WidgetOptions) => string | null | undefined;
|
|
367
347
|
/**
|
|
368
348
|
* @deprecated - do not use in new code.
|
|
@@ -374,13 +354,10 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
|
|
|
374
354
|
export type FilterCriterion = string | ((id: string, widgetInfo: PerseusWidget, widget?: Widget | null | undefined) => boolean);
|
|
375
355
|
/**
|
|
376
356
|
* The full set of props provided to all widgets when they are rendered. The
|
|
377
|
-
* `
|
|
378
|
-
* from the
|
|
379
|
-
* widget options exactly as they are the result of running the options through
|
|
380
|
-
* the parser as well as its `transform` or `staticTransform` functions
|
|
381
|
-
* (depending on the options `static` flag).
|
|
357
|
+
* `TWidgetOptions` generic argument are the widget-specific props that originate
|
|
358
|
+
* from the PerseusItem.
|
|
382
359
|
*/
|
|
383
|
-
export type WidgetProps<
|
|
360
|
+
export type WidgetProps<TWidgetOptions, TUserInput = Empty, Rubric = Empty, TrackingExtraArgs = Empty> = TWidgetOptions & UniversalWidgetProps<Rubric, TUserInput, TrackingExtraArgs>;
|
|
384
361
|
/**
|
|
385
362
|
* The props passed to every widget, regardless of its `type`.
|
|
386
363
|
*/
|
|
@@ -10,4 +10,4 @@ export type CategorizerPromptJSON = {
|
|
|
10
10
|
itemToCategoryMapping: ReadonlyArray<number | null | undefined>;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare const getPromptJSON: (
|
|
13
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof categorizer.widget>) => CategorizerPromptJSON;
|
|
@@ -5,4 +5,4 @@ export type DefinitionPromptJSON = {
|
|
|
5
5
|
definition: string;
|
|
6
6
|
togglePrompt: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const getPromptJSON: (
|
|
8
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof definition.widget>) => DefinitionPromptJSON;
|
|
@@ -9,4 +9,4 @@ export type DropdownPromptJSON = {
|
|
|
9
9
|
selectedIndex: number;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const getPromptJSON: (
|
|
12
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof dropdown.widget>) => DropdownPromptJSON;
|
|
@@ -5,4 +5,4 @@ export type ExplanationPromptJSON = {
|
|
|
5
5
|
showPrompt: string;
|
|
6
6
|
explanation: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const getPromptJSON: (
|
|
8
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof explanation.widget>) => ExplanationPromptJSON;
|
|
@@ -8,4 +8,4 @@ export type ExpressionPromptJSON = {
|
|
|
8
8
|
value: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const getPromptJSON: (
|
|
11
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof expression.widget>, userInput: PerseusExpressionUserInput) => ExpressionPromptJSON;
|
|
@@ -8,4 +8,4 @@ export type GradedGroupSetPromptJSON = {
|
|
|
8
8
|
currentGroup: GradedGroupPromptJSON;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const getPromptJSON: (
|
|
11
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof gradedGroupSet.widget>, activeGroupJSON: GradedGroupPromptJSON) => GradedGroupSetPromptJSON;
|
|
@@ -14,4 +14,4 @@ export type GrapherPromptJSON = {
|
|
|
14
14
|
};
|
|
15
15
|
userInput: GrapherAnswerTypes;
|
|
16
16
|
};
|
|
17
|
-
export declare const getPromptJSON: (
|
|
17
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof grapher.widget>) => GrapherPromptJSON;
|
|
@@ -9,4 +9,4 @@ export type ImagePromptJSON = {
|
|
|
9
9
|
imageUrl: string | null | undefined;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const getPromptJSON: (
|
|
12
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof image.widget>) => ImagePromptJSON;
|
|
@@ -10,4 +10,4 @@ export type InputNumberPromptJSON = {
|
|
|
10
10
|
value: string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare const getPromptJSON: (
|
|
13
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof inputNumber.widget>) => InputNumberPromptJSON;
|
|
@@ -20,5 +20,5 @@ export type LabelImagePromptJSON = {
|
|
|
20
20
|
markers: UserInputMarker[];
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
export declare const getPromptJSON: (
|
|
23
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof labelImage.widget>) => LabelImagePromptJSON;
|
|
24
24
|
export {};
|
|
@@ -13,5 +13,5 @@ export type MatcherPromptJSON = {
|
|
|
13
13
|
right: ReadonlyArray<string>;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
17
|
-
export declare const getPromptJSON: (
|
|
16
|
+
export type widgetDataPartial = Pick<React.ComponentProps<typeof matcher.widget>, "userInput" | "labels" | "left" | "right" | "orderMatters">;
|
|
17
|
+
export declare const getPromptJSON: (widgetData: widgetDataPartial) => MatcherPromptJSON;
|
|
@@ -10,4 +10,4 @@ export type MatrixPromptJSON = {
|
|
|
10
10
|
answerRows: ReadonlyArray<ReadonlyArray<string>>;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare const getPromptJSON: (
|
|
13
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof matrix.widget>) => MatrixPromptJSON;
|
|
@@ -9,4 +9,4 @@ export type MockWidgetPromptJSON = {
|
|
|
9
9
|
value: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const getPromptJSON: (
|
|
12
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof mockWidget.widget>) => MockWidgetPromptJSON;
|
|
@@ -12,4 +12,4 @@ export type NumberLinePromptJSON = {
|
|
|
12
12
|
rel: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export declare const getPromptJSON: (
|
|
15
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof numberLine.widget>) => NumberLinePromptJSON;
|
|
@@ -7,4 +7,4 @@ export type NumericInputPromptJSON = {
|
|
|
7
7
|
value: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
export declare const getPromptJSON: (
|
|
10
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof numericInput.widget>) => NumericInputPromptJSON;
|
|
@@ -9,4 +9,4 @@ export type OrdererPromptJSON = {
|
|
|
9
9
|
values: ReadonlyArray<string>;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const getPromptJSON: (
|
|
12
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof orderer.widget>) => OrdererPromptJSON;
|
|
@@ -8,4 +8,4 @@ export type PassagePromptJSON = {
|
|
|
8
8
|
footnotes: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const getPromptJSON: (
|
|
11
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof passage.widget>) => PassagePromptJSON;
|
|
@@ -8,4 +8,4 @@ export type PassageRefPromptJSON = {
|
|
|
8
8
|
summaryText: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const getPromptJSON: (
|
|
11
|
+
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof passageRef.widget>) => PassageRefPromptJSON;
|
|
@@ -14,5 +14,5 @@ export type RadioPromptJSON = {
|
|
|
14
14
|
selectedOptions: ReadonlyArray<string>;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
-
export declare const getPromptJSON: (
|
|
17
|
+
export declare const getPromptJSON: (widgetData: RecursiveReadonly<React.ComponentProps<typeof radio.widget>>, userInput: RecursiveReadonly<PerseusRadioUserInput>) => RadioPromptJSON;
|
|
18
18
|
export {};
|
|
@@ -6,7 +6,7 @@ type Props = {
|
|
|
6
6
|
shouldHighlight: boolean;
|
|
7
7
|
type: string;
|
|
8
8
|
id: string;
|
|
9
|
-
|
|
9
|
+
widgetProps: WidgetProps<any, PerseusWidgetOptions>;
|
|
10
10
|
linterContext: LinterContextProps;
|
|
11
11
|
};
|
|
12
12
|
type DefaultProps = {
|
|
@@ -14,7 +14,6 @@ type DefaultProps = {
|
|
|
14
14
|
};
|
|
15
15
|
type State = {
|
|
16
16
|
sizeClass: "small" | "medium" | "large" | "xlarge";
|
|
17
|
-
widgetProps: WidgetProps<any, PerseusWidgetOptions>;
|
|
18
17
|
};
|
|
19
18
|
declare class WidgetContainer extends React.Component<Props, State> {
|
|
20
19
|
widgetRef: React.RefObject<React.ComponentType<any>>;
|
|
@@ -22,9 +21,7 @@ declare class WidgetContainer extends React.Component<Props, State> {
|
|
|
22
21
|
state: State;
|
|
23
22
|
componentDidMount(): void;
|
|
24
23
|
UNSAFE_componentWillReceiveProps(nextProps: Props): void;
|
|
25
|
-
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
26
24
|
getWidget: () => any;
|
|
27
|
-
replaceWidgetProps: (arg1: WidgetProps<any, PerseusWidgetOptions>) => void;
|
|
28
25
|
render(): React.ReactNode;
|
|
29
26
|
}
|
|
30
27
|
export default WidgetContainer;
|
|
@@ -3,13 +3,11 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import type { Widget, WidgetProps } from "../../types";
|
|
4
4
|
import type { CategorizerPromptJSON } from "../../widget-ai-utils/categorizer/categorizer-ai-utils";
|
|
5
5
|
import type { PerseusCategorizerWidgetOptions, PerseusCategorizerUserInput } from "@khanacademy/perseus-core";
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
categories: Props["categories"];
|
|
10
|
-
linterContext: Props["linterContext"];
|
|
11
|
-
userInput: Props["userInput"];
|
|
6
|
+
type ExternalProps = WidgetProps<PerseusCategorizerWidgetOptions, PerseusCategorizerUserInput>;
|
|
7
|
+
type Props = ExternalProps & {
|
|
8
|
+
linterContext: NonNullable<ExternalProps["linterContext"]>;
|
|
12
9
|
};
|
|
10
|
+
type DefaultProps = Pick<Props, "items" | "categories" | "linterContext" | "userInput">;
|
|
13
11
|
type State = {
|
|
14
12
|
uniqueId: string;
|
|
15
13
|
};
|
|
@@ -27,11 +25,6 @@ export declare class Categorizer extends React.Component<Props, State> implement
|
|
|
27
25
|
_handleUserInput(itemNum: number, catNum: number): void;
|
|
28
26
|
render(): React.ReactNode;
|
|
29
27
|
}
|
|
30
|
-
type RenderProps = {
|
|
31
|
-
items: PerseusCategorizerWidgetOptions["items"];
|
|
32
|
-
categories: PerseusCategorizerWidgetOptions["categories"];
|
|
33
|
-
randomizeItems: PerseusCategorizerWidgetOptions["randomizeItems"];
|
|
34
|
-
};
|
|
35
28
|
/**
|
|
36
29
|
* @deprecated and likely a very broken API
|
|
37
30
|
* [LEMS-3185] do not trust serializedState
|
|
@@ -5,8 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
import type { Widget, WidgetProps } from "../../types";
|
|
6
6
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
7
7
|
import type { PerseusCSProgramWidgetOptions, PerseusCSProgramUserInput } from "@khanacademy/perseus-core";
|
|
8
|
-
type
|
|
9
|
-
type Props = WidgetProps<RenderProps, PerseusCSProgramUserInput>;
|
|
8
|
+
type Props = WidgetProps<PerseusCSProgramWidgetOptions, PerseusCSProgramUserInput>;
|
|
10
9
|
type DefaultProps = {
|
|
11
10
|
showEditor: Props["showEditor"];
|
|
12
11
|
showButtons: Props["showButtons"];
|
|
@@ -18,6 +17,11 @@ declare class CSProgram extends React.Component<Props> implements Widget {
|
|
|
18
17
|
componentWillUnmount(): void;
|
|
19
18
|
handleMessageEvent: (arg1: any) => void;
|
|
20
19
|
getPromptJSON(): UnsupportedWidgetPromptJSON;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated and likely very broken API
|
|
22
|
+
* [LEMS-3185] do not trust serializedState
|
|
23
|
+
*/
|
|
24
|
+
getSerializedState(): any;
|
|
21
25
|
render(): React.ReactNode;
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
@@ -3,8 +3,7 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import type { Widget, WidgetProps } from "../../types";
|
|
4
4
|
import type { DefinitionPromptJSON } from "../../widget-ai-utils/definition/definition-ai-utils";
|
|
5
5
|
import type { PerseusRenderer, PerseusDefinitionWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
|
-
type
|
|
7
|
-
type DefinitionProps = WidgetProps<RenderProps> & {
|
|
6
|
+
type DefinitionProps = WidgetProps<PerseusDefinitionWidgetOptions> & {
|
|
8
7
|
widgets: PerseusRenderer["widgets"];
|
|
9
8
|
};
|
|
10
9
|
type DefaultProps = {
|
|
@@ -3,8 +3,7 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import type { Widget, WidgetProps } from "../../types";
|
|
4
4
|
import type { ExplanationPromptJSON } from "../../widget-ai-utils/explanation/explanation-ai-utils";
|
|
5
5
|
import type { PerseusExplanationWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
|
-
type
|
|
7
|
-
type Props = WidgetProps<RenderProps>;
|
|
6
|
+
type Props = WidgetProps<PerseusExplanationWidgetOptions>;
|
|
8
7
|
type DefaultProps = {
|
|
9
8
|
showPrompt: Props["showPrompt"];
|
|
10
9
|
hidePrompt: Props["hidePrompt"];
|
|
@@ -24,7 +23,6 @@ declare class Explanation extends React.Component<Props, State> implements Widge
|
|
|
24
23
|
_mounted: boolean;
|
|
25
24
|
componentDidMount(): void;
|
|
26
25
|
componentWillUnmount(): void;
|
|
27
|
-
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
28
26
|
_onClick: () => void;
|
|
29
27
|
getPromptJSON(): ExplanationPromptJSON;
|
|
30
28
|
render(): React.ReactNode;
|
|
@@ -8,8 +8,7 @@ import * as React from "react";
|
|
|
8
8
|
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
|
-
type
|
|
12
|
-
type Props = WidgetProps<RenderProps, PerseusFreeResponseUserInput>;
|
|
11
|
+
type Props = WidgetProps<PerseusFreeResponseWidgetOptions, PerseusFreeResponseUserInput>;
|
|
13
12
|
type DefaultProps = Pick<Props, "userInput">;
|
|
14
13
|
export declare class FreeResponse extends React.Component<Props> implements Widget {
|
|
15
14
|
static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
|
|
@@ -38,7 +38,6 @@ export declare class GradedGroup extends React.Component<Props, State> implement
|
|
|
38
38
|
rendererRef: React.RefObject<Renderer>;
|
|
39
39
|
hintRendererRef: React.RefObject<Renderer>;
|
|
40
40
|
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
41
|
-
change: (...args: ReadonlyArray<unknown>) => any;
|
|
42
41
|
_handleUserInput(_userInput: UserInputMap, widgetsEmpty: boolean): void;
|
|
43
42
|
_checkAnswer: () => void;
|
|
44
43
|
getInputPaths: () => ReadonlyArray<FocusPath>;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
11
11
|
import Renderer from "../../renderer";
|
|
12
|
-
import type {
|
|
12
|
+
import type { FocusPath, Widget, WidgetProps } from "../../types";
|
|
13
13
|
import type { GroupPromptJSON } from "../../widget-ai-utils/group/group-ai-utils";
|
|
14
14
|
import type { PerseusGroupUserInput, PerseusGroupWidgetOptions, PerseusRenderer } from "@khanacademy/perseus-core";
|
|
15
15
|
type Props = WidgetProps<PerseusGroupWidgetOptions, PerseusGroupUserInput>;
|
|
@@ -25,7 +25,6 @@ declare class Group extends React.Component<Props> implements Widget {
|
|
|
25
25
|
rendererRef: Renderer | null | undefined;
|
|
26
26
|
static defaultProps: DefaultProps;
|
|
27
27
|
componentDidMount(): void;
|
|
28
|
-
change: ChangeFn;
|
|
29
28
|
getPromptJSON(): GroupPromptJSON;
|
|
30
29
|
/**
|
|
31
30
|
* @deprecated - do not use in new code.
|
|
@@ -10,11 +10,7 @@ import * as React from "react";
|
|
|
10
10
|
import type { WidgetProps, Widget } from "../../types";
|
|
11
11
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
12
12
|
import type { PerseusIFrameUserInput, PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
|
|
13
|
-
type
|
|
14
|
-
width: string;
|
|
15
|
-
height: string;
|
|
16
|
-
};
|
|
17
|
-
type Props = WidgetProps<RenderProps, PerseusIFrameUserInput>;
|
|
13
|
+
type Props = WidgetProps<PerseusIFrameWidgetOptions, PerseusIFrameUserInput>;
|
|
18
14
|
type DefaultProps = {
|
|
19
15
|
allowFullScreen: Props["allowFullScreen"];
|
|
20
16
|
allowTopNavigation: Props["allowTopNavigation"];
|
|
@@ -25,6 +21,11 @@ declare class Iframe extends React.Component<Props> implements Widget {
|
|
|
25
21
|
componentDidMount(): void;
|
|
26
22
|
componentWillUnmount(): void;
|
|
27
23
|
getPromptJSON(): UnsupportedWidgetPromptJSON;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated and likely very broken API
|
|
26
|
+
* [LEMS-3185] do not trust serializedState
|
|
27
|
+
*/
|
|
28
|
+
getSerializedState(): any;
|
|
28
29
|
handleMessageEvent: (arg1: any) => void;
|
|
29
30
|
render(): React.ReactNode;
|
|
30
31
|
}
|
|
@@ -3,8 +3,7 @@ import type { Coord } from "../../interactive2/types";
|
|
|
3
3
|
import type { Widget, WidgetProps } from "../../types";
|
|
4
4
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
5
5
|
import type { PerseusInteractionWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
|
-
type
|
|
7
|
-
type Props = WidgetProps<RenderProps>;
|
|
6
|
+
type Props = WidgetProps<PerseusInteractionWidgetOptions>;
|
|
8
7
|
type DefaultProps = {
|
|
9
8
|
graph: Props["graph"];
|
|
10
9
|
elements: Props["elements"];
|
|
@@ -7,7 +7,7 @@ import type { InteractiveGraphPromptJSON } from "../../widget-ai-utils/interacti
|
|
|
7
7
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
8
8
|
import type { QuadraticCoefficient, SineCoefficient, Range } from "@khanacademy/kmath";
|
|
9
9
|
import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypeSegment, PerseusInteractiveGraphWidgetOptions, GraphRange, InteractiveGraphPublicWidgetOptions, LockedFigure, PerseusImageBackground, MarkingsType, PerseusInteractiveGraphUserInput, AxisLabelLocation, ShowAxisArrows } from "@khanacademy/perseus-core";
|
|
10
|
-
type
|
|
10
|
+
type InteractiveGraphProps = {
|
|
11
11
|
/**
|
|
12
12
|
* Where the little black axis lines & labels (ticks) should render.
|
|
13
13
|
* Also known as the tick step. default [1, 1]
|
|
@@ -110,8 +110,7 @@ type RenderProps = {
|
|
|
110
110
|
*/
|
|
111
111
|
fullGraphAriaDescription?: string;
|
|
112
112
|
};
|
|
113
|
-
type Props = WidgetProps<
|
|
114
|
-
type State = any;
|
|
113
|
+
type Props = WidgetProps<InteractiveGraphProps, PerseusInteractiveGraphUserInput>;
|
|
115
114
|
type DefaultProps = {
|
|
116
115
|
labels: string[];
|
|
117
116
|
labelLocation: Props["labelLocation"];
|
|
@@ -124,6 +123,7 @@ type DefaultProps = {
|
|
|
124
123
|
showProtractor: Props["showProtractor"];
|
|
125
124
|
userInput: Props["userInput"];
|
|
126
125
|
};
|
|
126
|
+
type State = any;
|
|
127
127
|
declare class InteractiveGraph extends React.Component<Props, State> {
|
|
128
128
|
mafsRef: React.RefObject<StatefulMafsGraphType>;
|
|
129
129
|
static defaultProps: DefaultProps;
|
|
@@ -4,8 +4,7 @@ import type { SortableOption } from "../../components/sortable";
|
|
|
4
4
|
import type { WidgetProps, Widget } from "../../types";
|
|
5
5
|
import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
|
|
6
6
|
import type { PerseusMatcherWidgetOptions, PerseusMatcherUserInput, MatcherPublicWidgetOptions } from "@khanacademy/perseus-core";
|
|
7
|
-
type
|
|
8
|
-
type Props = WidgetProps<RenderProps, PerseusMatcherUserInput>;
|
|
7
|
+
type Props = WidgetProps<PerseusMatcherWidgetOptions, PerseusMatcherUserInput>;
|
|
9
8
|
type DefaultProps = {
|
|
10
9
|
labels: Props["labels"];
|
|
11
10
|
orderMatters: Props["orderMatters"];
|
|
@@ -3,22 +3,17 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import type { FocusPath, Widget, WidgetProps } from "../../types";
|
|
4
4
|
import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
|
|
5
5
|
import type { MatrixPublicWidgetOptions, PerseusMatrixUserInput, PerseusMatrixWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
|
-
type Props = WidgetProps<MatrixPublicWidgetOptions, PerseusMatrixUserInput
|
|
7
|
-
cursorPosition: ReadonlyArray<number>;
|
|
8
|
-
onChange: (nextProps: {
|
|
9
|
-
cursorPosition?: ReadonlyArray<number>;
|
|
10
|
-
}, cb: () => boolean) => void;
|
|
11
|
-
};
|
|
6
|
+
type Props = WidgetProps<MatrixPublicWidgetOptions, PerseusMatrixUserInput>;
|
|
12
7
|
type DefaultProps = {
|
|
13
8
|
matrixBoardSize: Props["matrixBoardSize"];
|
|
14
9
|
prefix: string;
|
|
15
10
|
suffix: string;
|
|
16
|
-
cursorPosition: ReadonlyArray<number>;
|
|
17
11
|
apiOptions: Props["apiOptions"];
|
|
18
12
|
linterContext: Props["linterContext"];
|
|
19
13
|
userInput: PerseusMatrixUserInput;
|
|
20
14
|
};
|
|
21
15
|
type State = {
|
|
16
|
+
cursorPosition: ReadonlyArray<number>;
|
|
22
17
|
enterTheMatrix: number;
|
|
23
18
|
};
|
|
24
19
|
declare class Matrix extends React.Component<Props, State> implements Widget {
|
|
@@ -6,8 +6,7 @@ type Position = {
|
|
|
6
6
|
left: number;
|
|
7
7
|
top: number;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
10
|
-
type OrdererProps = WidgetProps<RenderProps, PerseusOrdererUserInput>;
|
|
9
|
+
type OrdererProps = WidgetProps<OrdererPublicWidgetOptions, PerseusOrdererUserInput>;
|
|
11
10
|
type OrdererDefaultProps = Pick<OrdererProps, "options" | "height" | "layout" | "linterContext" | "userInput">;
|
|
12
11
|
type OrdererState = {
|
|
13
12
|
dragging: boolean;
|
|
@@ -2,7 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
3
|
import type { ParseState } from "./passage-markdown";
|
|
4
4
|
import type { SerializedHighlightSet } from "../../components/highlighting/types";
|
|
5
|
-
import type { ChangeableProps } from "../../mixins/changeable";
|
|
6
5
|
import type { WidgetProps, Widget } from "../../types";
|
|
7
6
|
import type { PassagePromptJSON } from "../../widget-ai-utils/passage/passage-ai-utils";
|
|
8
7
|
import type { PerseusPassageWidgetOptions, PerseusWidget } from "@khanacademy/perseus-core";
|
|
@@ -13,22 +12,21 @@ export declare class LineHeightMeasurer extends React.Component<Record<any, any>
|
|
|
13
12
|
render(): React.ReactNode;
|
|
14
13
|
}
|
|
15
14
|
type FindWidgetsCallback = (id: string, widgetInfo: PerseusWidget) => boolean;
|
|
16
|
-
type PassageProps =
|
|
15
|
+
type PassageProps = WidgetProps<PerseusPassageWidgetOptions> & {
|
|
17
16
|
findWidgets: (arg1: FindWidgetsCallback) => ReadonlyArray<Passage>;
|
|
18
|
-
highlights: SerializedHighlightSet;
|
|
19
17
|
};
|
|
20
18
|
type DefaultPassageProps = {
|
|
21
19
|
passageTitle: PassageProps["passageTitle"];
|
|
22
20
|
passageText: PassageProps["passageText"];
|
|
23
21
|
footnotes: PassageProps["footnotes"];
|
|
24
22
|
showLineNumbers: PassageProps["showLineNumbers"];
|
|
25
|
-
highlights: PassageProps["highlights"];
|
|
26
23
|
linterContext: PassageProps["linterContext"];
|
|
27
24
|
};
|
|
28
25
|
type PassageState = {
|
|
29
26
|
nLines: number | null | undefined;
|
|
30
27
|
startLineNumbersAfter: number;
|
|
31
28
|
stylesAreApplied: boolean;
|
|
29
|
+
highlights: SerializedHighlightSet;
|
|
32
30
|
};
|
|
33
31
|
export type Reference = {
|
|
34
32
|
startLine: number;
|
|
@@ -3,12 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import type { Widget, WidgetProps } from "../../types";
|
|
5
5
|
import type { PassageRefPromptJSON } from "../../widget-ai-utils/passage-ref/passage-ref-ai-utils";
|
|
6
|
-
type
|
|
7
|
-
passageNumber: PerseusPassageRefWidgetOptions["passageNumber"];
|
|
8
|
-
referenceNumber: PerseusPassageRefWidgetOptions["referenceNumber"];
|
|
9
|
-
summaryText: string;
|
|
10
|
-
};
|
|
11
|
-
type Props = WidgetProps<RenderProps>;
|
|
6
|
+
type Props = WidgetProps<PerseusPassageRefWidgetOptions>;
|
|
12
7
|
type DefaultProps = {
|
|
13
8
|
passageNumber: Props["passageNumber"];
|
|
14
9
|
referenceNumber: Props["referenceNumber"];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type PerseusPlotterUserInput, type PerseusPlotterWidgetOptions, type PlotterPublicWidgetOptions } from "@khanacademy/perseus-core";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
4
|
import type { Widget, WidgetProps } from "../../types";
|
|
4
5
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
5
|
-
import type { PerseusPlotterUserInput, PerseusPlotterWidgetOptions, PlotterPublicWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
6
|
type Props = WidgetProps<PlotterPublicWidgetOptions, PerseusPlotterUserInput> & {
|
|
7
7
|
labelInterval: NonNullable<PerseusPlotterWidgetOptions["labelInterval"]>;
|
|
8
8
|
picSize: NonNullable<PerseusPlotterWidgetOptions["picSize"]>;
|
|
@@ -18,7 +18,7 @@ export interface ChoiceType {
|
|
|
18
18
|
revealNoneOfTheAbove: boolean;
|
|
19
19
|
disabled: boolean;
|
|
20
20
|
}
|
|
21
|
-
export type
|
|
21
|
+
export type RadioProps = {
|
|
22
22
|
numCorrect: number;
|
|
23
23
|
hasNoneOfTheAbove?: boolean;
|
|
24
24
|
multipleSelect?: boolean;
|
|
@@ -36,5 +36,5 @@ export interface RadioChoiceWithMetadata extends PerseusRadioChoice {
|
|
|
36
36
|
originalIndex: number;
|
|
37
37
|
correct?: boolean;
|
|
38
38
|
}
|
|
39
|
-
declare const Radio: React.ForwardRefExoticComponent<
|
|
39
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & import("../../types").UniversalWidgetProps<PerseusRadioRubric, PerseusRadioUserInput, Empty> & React.RefAttributes<Widget>>;
|
|
40
40
|
export default Radio;
|