@khanacademy/perseus 35.1.1 → 36.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.js +19336 -19385
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +19275 -19325
- package/dist/index.js.map +1 -1
- package/dist/multi-items/multi-renderer.d.ts +1 -2
- package/dist/perseus-types.d.ts +35 -35
- package/dist/renderer.d.ts +2 -33
- package/dist/server-item-renderer.d.ts +1 -1
- package/dist/types.d.ts +40 -4
- package/dist/util.d.ts +1 -8
- package/dist/validation.types.d.ts +3 -9
- package/dist/widgets/categorizer/categorizer.d.ts +2 -2
- package/dist/widgets/cs-program/cs-program.d.ts +3 -2
- package/dist/widgets/definition/definition.d.ts +4 -4
- package/dist/widgets/deprecated-standin/index.d.ts +6 -7
- package/dist/widgets/dropdown/dropdown.d.ts +2 -2
- package/dist/widgets/explanation/explanation.d.ts +4 -4
- package/dist/widgets/expression/expression.d.ts +36 -36
- package/dist/widgets/graded-group/graded-group.d.ts +2 -2
- package/dist/widgets/graded-group-set/graded-group-set.d.ts +2 -2
- package/dist/widgets/grapher/grapher.d.ts +2 -3
- package/dist/widgets/group/group.d.ts +5 -5
- package/dist/widgets/iframe/iframe.d.ts +2 -2
- package/dist/widgets/image/image.d.ts +4 -5
- package/dist/widgets/input-number/input-number.d.ts +2 -2
- package/dist/widgets/interaction/interaction.d.ts +4 -4
- package/dist/widgets/interactive-graph.d.ts +2 -2
- package/dist/widgets/label-image/label-image.d.ts +2 -2
- package/dist/widgets/matcher/matcher.d.ts +2 -2
- package/dist/widgets/matrix/matrix.d.ts +3 -3
- package/dist/widgets/measurer/measurer.d.ts +47 -2
- package/dist/widgets/molecule/molecule.d.ts +2 -1
- package/dist/widgets/number-line/number-line.d.ts +5 -5
- package/dist/widgets/numeric-input/numeric-input.d.ts +2 -2
- package/dist/widgets/orderer/orderer-validator.d.ts +3 -0
- package/dist/widgets/orderer/orderer.d.ts +4 -3
- package/dist/widgets/passage/passage.d.ts +4 -4
- package/dist/widgets/passage/utils.d.ts +12 -0
- package/dist/widgets/passage-ref/passage-ref.d.ts +4 -4
- package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +4 -4
- package/dist/widgets/phet-simulation/phet-simulation.d.ts +4 -4
- package/dist/widgets/plotter/plotter.d.ts +2 -2
- package/dist/widgets/python-program/python-program.d.ts +6 -1
- package/dist/widgets/radio/radio-component.d.ts +2 -2
- package/dist/widgets/sorter/sorter.d.ts +2 -2
- package/dist/widgets/table/table.d.ts +3 -3
- package/dist/widgets/video/video.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { PerseusOrdererWidgetOptions } from "../../perseus-types";
|
|
3
|
-
import type { WidgetProps } from "../../types";
|
|
3
|
+
import type { PerseusScore, WidgetProps, Widget } from "../../types";
|
|
4
4
|
import type { PerseusOrdererRubric, PerseusOrdererUserInput } from "../../validation.types";
|
|
5
5
|
type Position = {
|
|
6
6
|
left: number;
|
|
@@ -33,9 +33,10 @@ type OrdererState = {
|
|
|
33
33
|
animateTo: Position | null | undefined;
|
|
34
34
|
onAnimationEnd?: (arg1: any) => void;
|
|
35
35
|
};
|
|
36
|
-
declare class Orderer extends React.Component<OrdererProps, OrdererState> {
|
|
36
|
+
declare class Orderer extends React.Component<OrdererProps, OrdererState> implements Widget {
|
|
37
37
|
static defaultProps: OrdererDefaultProps;
|
|
38
38
|
state: OrdererState;
|
|
39
|
+
static validate(userInput: PerseusOrdererUserInput, rubric: PerseusOrdererRubric): PerseusScore;
|
|
39
40
|
UNSAFE_componentWillReceiveProps(nextProps: OrdererProps): void;
|
|
40
41
|
onClick: (arg1: string, arg2: number, arg3: any, arg4: Element) => void;
|
|
41
42
|
onRelease: (arg1: any) => void;
|
|
@@ -44,7 +45,7 @@ declare class Orderer extends React.Component<OrdererProps, OrdererState> {
|
|
|
44
45
|
isCardInBank: (arg1: any) => boolean;
|
|
45
46
|
setListValues: (arg1: ReadonlyArray<string>) => void;
|
|
46
47
|
getUserInput(): PerseusOrdererUserInput;
|
|
47
|
-
simpleValidate(rubric: PerseusOrdererRubric):
|
|
48
|
+
simpleValidate(rubric: PerseusOrdererRubric): PerseusScore;
|
|
48
49
|
render(): React.ReactNode;
|
|
49
50
|
}
|
|
50
51
|
declare const _default: Readonly<{
|
|
@@ -4,8 +4,8 @@ import type { ParseState } from "./passage-markdown";
|
|
|
4
4
|
import type { SerializedHighlightSet } from "../../components/highlighting/types";
|
|
5
5
|
import type { ChangeableProps } from "../../mixins/changeable";
|
|
6
6
|
import type { PerseusPassageWidgetOptions, PerseusWidget } from "../../perseus-types";
|
|
7
|
-
import type { WidgetProps } from "../../types";
|
|
8
|
-
import type {
|
|
7
|
+
import type { WidgetProps, Widget } from "../../types";
|
|
8
|
+
import type { NullUserInput, PerseusPassageRubric } from "../../validation.types";
|
|
9
9
|
import type { SingleASTNode } from "@khanacademy/simple-markdown";
|
|
10
10
|
export declare class LineHeightMeasurer extends React.Component<Record<any, any>> {
|
|
11
11
|
_line: HTMLDivElement | null | undefined;
|
|
@@ -41,7 +41,7 @@ export type Reference = {
|
|
|
41
41
|
endLine: number;
|
|
42
42
|
content: string | null | undefined;
|
|
43
43
|
};
|
|
44
|
-
export declare class Passage extends React.Component<PassageProps, PassageState> {
|
|
44
|
+
export declare class Passage extends React.Component<PassageProps, PassageState> implements Widget {
|
|
45
45
|
static contextType: React.Context<{
|
|
46
46
|
strings: import("../../strings").PerseusStrings;
|
|
47
47
|
locale: string;
|
|
@@ -93,7 +93,7 @@ export declare class Passage extends React.Component<PassageProps, PassageState>
|
|
|
93
93
|
*
|
|
94
94
|
* These are misc widget functions used for the widget API
|
|
95
95
|
*/
|
|
96
|
-
getUserInput():
|
|
96
|
+
getUserInput(): NullUserInput;
|
|
97
97
|
simpleValidate(): import("../../types").PerseusScore;
|
|
98
98
|
/**
|
|
99
99
|
* Rendering
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Passage } from "./passage";
|
|
2
|
+
/**
|
|
3
|
+
* A function that detects if the given widget is a `Passage` widget. This is
|
|
4
|
+
* also a type guard so that after this function is called, the widget that was
|
|
5
|
+
* passed in is refined to be a `Passage` widget on success.
|
|
6
|
+
*
|
|
7
|
+
* This makes it a handy function to use with `.filter()` calls on arrays of
|
|
8
|
+
* widgets.
|
|
9
|
+
*
|
|
10
|
+
* Type guards: https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types
|
|
11
|
+
*/
|
|
12
|
+
export declare function isPassageWidget(widget: any): widget is Passage;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
3
|
import type { PerseusPassageRefWidgetOptions } from "../../perseus-types";
|
|
4
|
-
import type { ChangeFn, WidgetProps } from "../../types";
|
|
5
|
-
import type {
|
|
4
|
+
import type { ChangeFn, Widget, WidgetProps } from "../../types";
|
|
5
|
+
import type { NullUserInput, PerseusPassageRefRubric } from "../../validation.types";
|
|
6
6
|
type RenderProps = {
|
|
7
7
|
passageNumber: PerseusPassageRefWidgetOptions["passageNumber"];
|
|
8
8
|
referenceNumber: PerseusPassageRefWidgetOptions["referenceNumber"];
|
|
@@ -18,7 +18,7 @@ type State = {
|
|
|
18
18
|
lineRange: [number, number] | null | undefined;
|
|
19
19
|
content: string | null | undefined;
|
|
20
20
|
};
|
|
21
|
-
declare class PassageRef extends React.Component<Props, State> {
|
|
21
|
+
declare class PassageRef extends React.Component<Props, State> implements Widget {
|
|
22
22
|
static contextType: React.Context<{
|
|
23
23
|
strings: import("../../strings").PerseusStrings;
|
|
24
24
|
locale: string;
|
|
@@ -34,7 +34,7 @@ declare class PassageRef extends React.Component<Props, State> {
|
|
|
34
34
|
shouldComponentUpdate(nextProps: Props, nextState: State): boolean;
|
|
35
35
|
componentDidUpdate(): void;
|
|
36
36
|
componentWillUnmount(): void;
|
|
37
|
-
getUserInput():
|
|
37
|
+
getUserInput(): NullUserInput;
|
|
38
38
|
change: ChangeFn;
|
|
39
39
|
_deferredUpdateRange: () => void;
|
|
40
40
|
_updateRange: () => void;
|
|
@@ -2,8 +2,8 @@ import * as React from "react";
|
|
|
2
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
3
|
import * as Changeable from "../../mixins/changeable";
|
|
4
4
|
import type { PerseusPassageRefTargetWidgetOptions } from "../../perseus-types";
|
|
5
|
-
import type { APIOptions } from "../../types";
|
|
6
|
-
import type {
|
|
5
|
+
import type { APIOptions, Widget } from "../../types";
|
|
6
|
+
import type { NullUserInput } from "../../validation.types";
|
|
7
7
|
import type { LinterContextProps } from "@khanacademy/perseus-linter";
|
|
8
8
|
type Props = Changeable.ChangeableProps & {
|
|
9
9
|
apiOptions: APIOptions;
|
|
@@ -14,7 +14,7 @@ type DefaultProps = {
|
|
|
14
14
|
content: Props["content"];
|
|
15
15
|
linterContext: Props["linterContext"];
|
|
16
16
|
};
|
|
17
|
-
declare class PassageRefTarget extends React.Component<Props> {
|
|
17
|
+
declare class PassageRefTarget extends React.Component<Props> implements Widget {
|
|
18
18
|
static contextType: React.Context<{
|
|
19
19
|
strings: import("../../strings").PerseusStrings;
|
|
20
20
|
locale: string;
|
|
@@ -22,7 +22,7 @@ declare class PassageRefTarget extends React.Component<Props> {
|
|
|
22
22
|
context: React.ContextType<typeof PerseusI18nContext>;
|
|
23
23
|
static defaultProps: DefaultProps;
|
|
24
24
|
static validate(): import("../../types").PerseusScore;
|
|
25
|
-
getUserInput():
|
|
25
|
+
getUserInput(): NullUserInput;
|
|
26
26
|
change: (arg1: any, arg2: any, arg3: any) => any;
|
|
27
27
|
simpleValidate(): import("../../types").PerseusScore;
|
|
28
28
|
render(): React.ReactNode;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
7
7
|
import type { PerseusPhetSimulationWidgetOptions } from "../../perseus-types";
|
|
8
|
-
import type { WidgetProps } from "../../types";
|
|
9
|
-
import type {
|
|
8
|
+
import type { WidgetProps, Widget } from "../../types";
|
|
9
|
+
import type { NullUserInput } from "../../validation.types";
|
|
10
10
|
type RenderProps = PerseusPhetSimulationWidgetOptions;
|
|
11
11
|
type Props = WidgetProps<RenderProps, PerseusPhetSimulationWidgetOptions>;
|
|
12
12
|
type State = {
|
|
@@ -16,7 +16,7 @@ type State = {
|
|
|
16
16
|
} | null;
|
|
17
17
|
url: URL | null;
|
|
18
18
|
};
|
|
19
|
-
export declare class PhetSimulation extends React.Component<Props, State> {
|
|
19
|
+
export declare class PhetSimulation extends React.Component<Props, State> implements Widget {
|
|
20
20
|
static contextType: React.Context<{
|
|
21
21
|
strings: import("../../strings").PerseusStrings;
|
|
22
22
|
locale: string;
|
|
@@ -28,7 +28,7 @@ export declare class PhetSimulation extends React.Component<Props, State> {
|
|
|
28
28
|
constructor(props: any);
|
|
29
29
|
componentDidMount(): Promise<void>;
|
|
30
30
|
componentDidUpdate(prevProps: any): Promise<void>;
|
|
31
|
-
getUserInput():
|
|
31
|
+
getUserInput(): NullUserInput;
|
|
32
32
|
getPhetCompatibleLocale: (arg1: string) => string;
|
|
33
33
|
displayLoadFailure: () => void;
|
|
34
34
|
updateSimState(urlString: string): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
3
|
import type { PerseusPlotterWidgetOptions } from "../../perseus-types";
|
|
4
|
-
import type { PerseusScore, WidgetProps } from "../../types";
|
|
4
|
+
import type { PerseusScore, Widget, WidgetProps } from "../../types";
|
|
5
5
|
import type { PerseusPlotterRubric, PerseusPlotterUserInput } from "../../validation.types";
|
|
6
6
|
type RenderProps = PerseusPlotterWidgetOptions;
|
|
7
7
|
type Props = WidgetProps<RenderProps, PerseusPlotterRubric> & {
|
|
@@ -25,7 +25,7 @@ type State = {
|
|
|
25
25
|
values: ReadonlyArray<number>;
|
|
26
26
|
categoryHeights: Record<string, number>;
|
|
27
27
|
};
|
|
28
|
-
export declare class Plotter extends React.Component<Props, State> {
|
|
28
|
+
export declare class Plotter extends React.Component<Props, State> implements Widget {
|
|
29
29
|
static contextType: React.Context<{
|
|
30
30
|
strings: import("../../strings").PerseusStrings;
|
|
31
31
|
locale: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { FocusPath, Widget } from "../../types";
|
|
2
3
|
type Props = {
|
|
3
4
|
programID: string;
|
|
4
5
|
height: number;
|
|
@@ -6,8 +7,12 @@ type Props = {
|
|
|
6
7
|
type DefaultProps = {
|
|
7
8
|
height: Props["height"];
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* This renders the program in an iframe.
|
|
12
|
+
*/
|
|
13
|
+
declare class PythonProgram extends React.Component<Props> implements Widget {
|
|
10
14
|
static defaultProps: DefaultProps;
|
|
15
|
+
getDOMNodeForPath(path: FocusPath): null;
|
|
11
16
|
render(): React.ReactNode;
|
|
12
17
|
}
|
|
13
18
|
declare const _default: Readonly<{
|
|
@@ -3,7 +3,7 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import type { FocusFunction } from "./base-radio";
|
|
4
4
|
import type { PerseusRadioChoice, PerseusRadioWidgetOptions, ShowSolutions } from "../../perseus-types";
|
|
5
5
|
import type { PerseusStrings } from "../../strings";
|
|
6
|
-
import type { PerseusScore, WidgetProps, ChoiceState } from "../../types";
|
|
6
|
+
import type { PerseusScore, WidgetProps, ChoiceState, Widget } from "../../types";
|
|
7
7
|
import type { PerseusRadioRubric, PerseusRadioUserInput } from "../../validation.types";
|
|
8
8
|
export type RenderProps = {
|
|
9
9
|
numCorrect: number;
|
|
@@ -23,7 +23,7 @@ export type RadioChoiceWithMetadata = PerseusRadioChoice & {
|
|
|
23
23
|
originalIndex: number;
|
|
24
24
|
correct: boolean;
|
|
25
25
|
};
|
|
26
|
-
declare class Radio extends React.Component<Props> {
|
|
26
|
+
declare class Radio extends React.Component<Props> implements Widget {
|
|
27
27
|
static contextType: React.Context<{
|
|
28
28
|
strings: PerseusStrings;
|
|
29
29
|
locale: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { SortableOption } from "../../components/sortable";
|
|
3
3
|
import type { PerseusSorterWidgetOptions } from "../../perseus-types";
|
|
4
|
-
import type { PerseusScore, WidgetProps } from "../../types";
|
|
4
|
+
import type { PerseusScore, Widget, WidgetProps } from "../../types";
|
|
5
5
|
import type { PerseusSorterRubric, PerseusSorterUserInput } from "../../validation.types";
|
|
6
6
|
type RenderProps = PerseusSorterWidgetOptions;
|
|
7
7
|
type Props = WidgetProps<RenderProps, PerseusSorterRubric>;
|
|
@@ -16,7 +16,7 @@ type DefaultProps = {
|
|
|
16
16
|
type State = {
|
|
17
17
|
changed: boolean;
|
|
18
18
|
};
|
|
19
|
-
declare class Sorter extends React.Component<Props, State> {
|
|
19
|
+
declare class Sorter extends React.Component<Props, State> implements Widget {
|
|
20
20
|
_isMounted: boolean;
|
|
21
21
|
static defaultProps: DefaultProps;
|
|
22
22
|
static validate(userInput: PerseusSorterUserInput, rubric: PerseusSorterRubric): PerseusScore;
|
|
@@ -3,7 +3,7 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import type { ChangeableProps } from "../../mixins/changeable";
|
|
4
4
|
import type { PerseusTableWidgetOptions } from "../../perseus-types";
|
|
5
5
|
import type { PerseusStrings } from "../../strings";
|
|
6
|
-
import type { PerseusScore, WidgetProps } from "../../types";
|
|
6
|
+
import type { PerseusScore, Widget, WidgetProps } from "../../types";
|
|
7
7
|
import type { PerseusTableRubric, PerseusTableUserInput } from "../../validation.types";
|
|
8
8
|
type RenderProps = PerseusTableWidgetOptions & {
|
|
9
9
|
editableHeaders: boolean;
|
|
@@ -19,7 +19,7 @@ type DefaultProps = {
|
|
|
19
19
|
answers: Props["answers"];
|
|
20
20
|
linterContext: Props["linterContext"];
|
|
21
21
|
};
|
|
22
|
-
declare class Table extends React.Component<Props> {
|
|
22
|
+
declare class Table extends React.Component<Props> implements Widget {
|
|
23
23
|
static contextType: React.Context<{
|
|
24
24
|
strings: PerseusStrings;
|
|
25
25
|
locale: string;
|
|
@@ -38,7 +38,7 @@ declare class Table extends React.Component<Props> {
|
|
|
38
38
|
focus: () => boolean;
|
|
39
39
|
focusInputPath: (arg1: any) => void;
|
|
40
40
|
blurInputPath: (arg1: any) => void;
|
|
41
|
-
getDOMNodeForPath
|
|
41
|
+
getDOMNodeForPath(path: any): Element | Text | null;
|
|
42
42
|
getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
|
|
43
43
|
getGrammarTypeForPath: (arg1: any) => string;
|
|
44
44
|
setInputValue: (arg1: any, arg2: any, arg3: any) => void;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
6
6
|
import type { PerseusVideoWidgetOptions } from "../../perseus-types";
|
|
7
|
-
import type { WidgetProps } from "../../types";
|
|
7
|
+
import type { Widget, WidgetProps } from "../../types";
|
|
8
8
|
import type { PerseusVideoRubric } from "../../validation.types";
|
|
9
9
|
type RenderProps = PerseusVideoWidgetOptions;
|
|
10
10
|
type Props = WidgetProps<RenderProps, PerseusVideoRubric> & {
|
|
@@ -13,7 +13,7 @@ type Props = WidgetProps<RenderProps, PerseusVideoRubric> & {
|
|
|
13
13
|
/**
|
|
14
14
|
* Video renderer.
|
|
15
15
|
*/
|
|
16
|
-
declare class Video extends React.Component<Props> {
|
|
16
|
+
declare class Video extends React.Component<Props> implements Widget {
|
|
17
17
|
static contextType: React.Context<{
|
|
18
18
|
strings: import("../../strings").PerseusStrings;
|
|
19
19
|
locale: string;
|