@khanacademy/perseus 19.6.3 → 19.7.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/es/index.css +171 -0
- package/dist/es/index.js +975 -745
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +171 -0
- package/dist/index.js +972 -740
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -0
- package/dist/perseus-types.d.ts +14 -2
- package/dist/server-item-renderer.d.ts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/widgets/expression.d.ts +6 -0
- package/dist/widgets/interactive-graph.d.ts +2 -0
- package/dist/widgets/interactive-graphs/graphs/index.d.ts +1 -0
- package/dist/widgets/interactive-graphs/graphs/segment.d.ts +5 -0
- package/dist/widgets/interactive-graphs/grid.d.ts +11 -0
- package/dist/widgets/interactive-graphs/index.d.ts +1 -0
- package/dist/widgets/interactive-graphs/legacy-grid.d.ts +7 -0
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +81 -0
- package/dist/widgets/interactive-graphs/types.d.ts +9 -0
- package/dist/widgets/interactive-graphs/utils.d.ts +15 -0
- package/dist/widgets/label-image.d.ts +2 -0
- package/package.json +3 -2
package/dist/perseus-api.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export declare const ApiOptions: {
|
|
|
96
96
|
crossOutEnabled?: boolean | undefined;
|
|
97
97
|
editorChangeDelay?: number | undefined;
|
|
98
98
|
onWidgetStartProps?: ((widgets: import("./types").PerseusWidgetMap) => import("./types").PerseusWidgetMap) | undefined;
|
|
99
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
99
100
|
}> & {
|
|
100
101
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
101
102
|
baseElements: {
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -244,7 +244,13 @@ export type PerseusInteractiveGraphWidgetOptions = {
|
|
|
244
244
|
gridStep: [number, number];
|
|
245
245
|
snapStep: [number, number];
|
|
246
246
|
backgroundImage?: PerseusImageBackground;
|
|
247
|
-
|
|
247
|
+
/**
|
|
248
|
+
* The type of markings to display on the graph.
|
|
249
|
+
* - graph: shows the axes and the grid lines
|
|
250
|
+
* - grid: shows only the grid lines
|
|
251
|
+
* - none: shows no markings
|
|
252
|
+
*/
|
|
253
|
+
markings: "graph" | "grid" | "none";
|
|
248
254
|
labels: ReadonlyArray<string>;
|
|
249
255
|
showProtractor: boolean;
|
|
250
256
|
showRuler: boolean;
|
|
@@ -518,7 +524,13 @@ export type PerseusInteractionGraph = {
|
|
|
518
524
|
labels: ReadonlyArray<string>;
|
|
519
525
|
range: [Range, Range];
|
|
520
526
|
gridStep: [number, number];
|
|
521
|
-
|
|
527
|
+
/**
|
|
528
|
+
* The type of markings to display on the graph.
|
|
529
|
+
* - graph: shows the axes and the grid lines
|
|
530
|
+
* - grid: shows only the grid lines
|
|
531
|
+
* - none: shows no markings
|
|
532
|
+
*/
|
|
533
|
+
markings: "graph" | "grid" | "none";
|
|
522
534
|
snapStep?: [number, number];
|
|
523
535
|
valid?: boolean | string;
|
|
524
536
|
backgroundImage?: PerseusImageBackground;
|
|
@@ -138,6 +138,7 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
|
|
|
138
138
|
crossOutEnabled?: boolean | undefined;
|
|
139
139
|
editorChangeDelay?: number | undefined;
|
|
140
140
|
onWidgetStartProps?: ((widgets: import("./types").PerseusWidgetMap) => import("./types").PerseusWidgetMap) | undefined;
|
|
141
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
141
142
|
}> | undefined;
|
|
142
143
|
linterContext?: PerseusLinter.LinterContextProps | undefined;
|
|
143
144
|
onRendered?: ((isRendered: boolean) => void) | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -106,6 +106,7 @@ export type APIOptions = Readonly<{
|
|
|
106
106
|
crossOutEnabled?: boolean;
|
|
107
107
|
editorChangeDelay?: number;
|
|
108
108
|
onWidgetStartProps?: (widgets: PerseusWidgetMap) => PerseusWidgetMap;
|
|
109
|
+
flags?: Record<string, boolean | Record<string, boolean>>;
|
|
109
110
|
}>;
|
|
110
111
|
type TeXProps = {
|
|
111
112
|
children: string;
|
|
@@ -124,6 +124,7 @@ declare const _default: Readonly<{
|
|
|
124
124
|
crossOutEnabled?: boolean | undefined;
|
|
125
125
|
editorChangeDelay?: number | undefined;
|
|
126
126
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
127
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
127
128
|
}> & {
|
|
128
129
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
129
130
|
baseElements: {
|
|
@@ -190,6 +191,7 @@ declare const _default: Readonly<{
|
|
|
190
191
|
crossOutEnabled?: boolean | undefined;
|
|
191
192
|
editorChangeDelay?: number | undefined;
|
|
192
193
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
194
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
193
195
|
}> & {
|
|
194
196
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
195
197
|
baseElements: {
|
|
@@ -256,6 +258,7 @@ declare const _default: Readonly<{
|
|
|
256
258
|
crossOutEnabled?: boolean | undefined;
|
|
257
259
|
editorChangeDelay?: number | undefined;
|
|
258
260
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
261
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
259
262
|
}> & {
|
|
260
263
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
261
264
|
baseElements: {
|
|
@@ -319,6 +322,7 @@ declare const _default: Readonly<{
|
|
|
319
322
|
crossOutEnabled?: boolean | undefined;
|
|
320
323
|
editorChangeDelay?: number | undefined;
|
|
321
324
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
325
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
322
326
|
}> & {
|
|
323
327
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
324
328
|
baseElements: {
|
|
@@ -385,6 +389,7 @@ declare const _default: Readonly<{
|
|
|
385
389
|
crossOutEnabled?: boolean | undefined;
|
|
386
390
|
editorChangeDelay?: number | undefined;
|
|
387
391
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
392
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
388
393
|
}> & {
|
|
389
394
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
390
395
|
baseElements: {
|
|
@@ -451,6 +456,7 @@ declare const _default: Readonly<{
|
|
|
451
456
|
crossOutEnabled?: boolean | undefined;
|
|
452
457
|
editorChangeDelay?: number | undefined;
|
|
453
458
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
459
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
454
460
|
}> & {
|
|
455
461
|
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
456
462
|
baseElements: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { Coord } from "../interactive2/types";
|
|
3
3
|
import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, PerseusInteractiveGraphWidgetOptions } from "../perseus-types";
|
|
4
|
+
import type { Widget } from "../renderer";
|
|
4
5
|
import type { PerseusScore, WidgetProps } from "../types";
|
|
5
6
|
import type { QuadraticCoefficient, SineCoefficient, Range } from "../util/geometry";
|
|
6
7
|
type RenderProps = PerseusInteractiveGraphWidgetOptions;
|
|
@@ -38,6 +39,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
|
|
|
38
39
|
trashCan: any | null | undefined;
|
|
39
40
|
vertHairline: any | null | undefined;
|
|
40
41
|
static defaultProps: DefaultProps;
|
|
42
|
+
mafsRef: React.RefObject<Widget>;
|
|
41
43
|
state: State;
|
|
42
44
|
UNSAFE_componentWillMount(): void;
|
|
43
45
|
componentDidMount(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SegmentGraph } from "./segment";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PerseusGraphTypeSegment } from "../../../perseus-types";
|
|
3
|
+
import type { MafsGraphProps } from "../types";
|
|
4
|
+
export type SegmentProps = MafsGraphProps<PerseusGraphTypeSegment>;
|
|
5
|
+
export declare const SegmentGraph: (props: SegmentProps) => JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SizeClass } from "../../util/sizing-utils";
|
|
3
|
+
interface GridProps {
|
|
4
|
+
step: [number, number];
|
|
5
|
+
gridStep: [number, number];
|
|
6
|
+
range: [[number, number], [number, number]];
|
|
7
|
+
containerSizeClass: SizeClass;
|
|
8
|
+
markings: "graph" | "grid" | "none";
|
|
9
|
+
}
|
|
10
|
+
export declare const Grid: (props: GridProps) => JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MafsGraph } from "./mafs-graph";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { PerseusImageBackground } from "../../perseus-types";
|
|
3
|
+
/**
|
|
4
|
+
* If a graphie URL is provided in `backgroundImage`, will return the rendered graphie background.
|
|
5
|
+
* Otherwise, returns `null`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getLegacyGrid: (box: [number, number], backgroundImage?: PerseusImageBackground) => JSX.Element | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Widget } from "../../renderer";
|
|
3
|
+
import "mafs/core.css";
|
|
4
|
+
import "mafs/font.css";
|
|
5
|
+
import "./mafs-styles.css";
|
|
6
|
+
export declare const MafsGraph: React.ForwardRefExoticComponent<import("../../perseus-types").PerseusInteractiveGraphWidgetOptions & {
|
|
7
|
+
widgetId: string;
|
|
8
|
+
alignment: string | null | undefined;
|
|
9
|
+
static: boolean | null | undefined;
|
|
10
|
+
problemNum: number | null | undefined;
|
|
11
|
+
apiOptions: Readonly<Readonly<{
|
|
12
|
+
isArticle?: boolean | undefined;
|
|
13
|
+
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
14
|
+
onFocusChange?: ((newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown) | undefined;
|
|
15
|
+
GroupMetadataEditor?: React.ComponentType<any> | undefined;
|
|
16
|
+
showAlignmentOptions?: boolean | undefined;
|
|
17
|
+
readOnly?: boolean | undefined;
|
|
18
|
+
answerableCallback?: ((arg1: boolean) => unknown) | undefined;
|
|
19
|
+
getAnotherHint?: (() => unknown) | undefined;
|
|
20
|
+
interactionCallback?: ((widgetData: {
|
|
21
|
+
[widgetId: string]: any;
|
|
22
|
+
}) => void) | undefined;
|
|
23
|
+
groupAnnotator?: ((groupNumber: number, widgetId: string) => React.ReactNode) | undefined;
|
|
24
|
+
imagePlaceholder?: React.ReactNode;
|
|
25
|
+
widgetPlaceholder?: React.ReactNode;
|
|
26
|
+
baseElements?: {
|
|
27
|
+
Link: React.ComponentType<any>;
|
|
28
|
+
} | undefined;
|
|
29
|
+
imagePreloader?: ((dimensions: import("../../types").Dimensions) => React.ReactNode) | undefined;
|
|
30
|
+
trackInteraction?: ((args: {
|
|
31
|
+
type: string;
|
|
32
|
+
id: string;
|
|
33
|
+
correct?: boolean | undefined;
|
|
34
|
+
} & Partial<import("../../types").TrackingGradedGroupExtraArguments> & Partial<import("../../types").TrackingSequenceExtraArguments>) => void) | undefined;
|
|
35
|
+
customKeypad?: boolean | undefined;
|
|
36
|
+
nativeKeypadProxy?: ((blur: () => void) => import("@khanacademy/math-input").KeypadAPI) | undefined;
|
|
37
|
+
isMobile?: boolean | undefined;
|
|
38
|
+
setDrawingAreaAvailable?: ((arg1: boolean) => unknown) | undefined;
|
|
39
|
+
useDraftEditor?: boolean | undefined;
|
|
40
|
+
hintProgressColor?: string | undefined;
|
|
41
|
+
canScrollPage?: boolean | undefined;
|
|
42
|
+
inModal?: boolean | undefined;
|
|
43
|
+
crossOutEnabled?: boolean | undefined;
|
|
44
|
+
editorChangeDelay?: number | undefined;
|
|
45
|
+
onWidgetStartProps?: ((widgets: import("../../types").PerseusWidgetMap) => import("../../types").PerseusWidgetMap) | undefined;
|
|
46
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
47
|
+
}> & {
|
|
48
|
+
GroupMetadataEditor: NonNullable<React.ComponentType<any> | undefined>;
|
|
49
|
+
baseElements: {
|
|
50
|
+
Link: React.ComponentType<any>;
|
|
51
|
+
};
|
|
52
|
+
canScrollPage: NonNullable<boolean | undefined>;
|
|
53
|
+
crossOutEnabled: NonNullable<boolean | undefined>;
|
|
54
|
+
editorChangeDelay: number;
|
|
55
|
+
groupAnnotator: (groupNumber: number, widgetId: string) => React.ReactNode;
|
|
56
|
+
inModal: NonNullable<boolean | undefined>;
|
|
57
|
+
isArticle: NonNullable<boolean | undefined>;
|
|
58
|
+
isMobile: NonNullable<boolean | undefined>;
|
|
59
|
+
onFocusChange: (newFocusPath: import("../..").FocusPath, oldFocusPath: import("../..").FocusPath, keypadHeight?: number | undefined, focusedElement?: HTMLElement | undefined) => unknown;
|
|
60
|
+
onInputError: (widgetId: any, value: string, message?: string | null | undefined) => unknown;
|
|
61
|
+
readOnly: NonNullable<boolean | undefined>;
|
|
62
|
+
setDrawingAreaAvailable: (arg1: boolean) => unknown;
|
|
63
|
+
showAlignmentOptions: NonNullable<boolean | undefined>;
|
|
64
|
+
useDraftEditor: NonNullable<boolean | undefined>;
|
|
65
|
+
}>;
|
|
66
|
+
keypadElement?: any;
|
|
67
|
+
questionCompleted?: boolean | undefined;
|
|
68
|
+
onFocus: (blurPath: import("../..").FocusPath) => void;
|
|
69
|
+
onBlur: (blurPath: import("../..").FocusPath) => void;
|
|
70
|
+
findWidgets: (arg1: import("../../types").FilterCriterion) => readonly any[];
|
|
71
|
+
reviewModeRubric: import("../../perseus-types").PerseusInteractiveGraphWidgetOptions;
|
|
72
|
+
onChange: import("../..").ChangeHandler;
|
|
73
|
+
trackInteraction: (extraData?: {} | undefined) => void;
|
|
74
|
+
isLastUsedWidget: boolean;
|
|
75
|
+
linterContext: import("../../../../perseus-linter/src").LinterContextProps;
|
|
76
|
+
containerSizeClass: import("../../util/sizing-utils").SizeClass;
|
|
77
|
+
} & {
|
|
78
|
+
children?: React.ReactNode;
|
|
79
|
+
} & {
|
|
80
|
+
box: [number, number];
|
|
81
|
+
} & React.RefAttributes<Partial<Widget>>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PerseusGraphType, PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
|
|
2
|
+
import type { WidgetProps } from "../../types";
|
|
3
|
+
export type InteractiveGraphProps = WidgetProps<PerseusInteractiveGraphWidgetOptions, PerseusInteractiveGraphWidgetOptions>;
|
|
4
|
+
export type OnGraphChange<T extends PerseusGraphType> = (callback: (current: T) => T) => void;
|
|
5
|
+
export type MafsGraphProps<T extends PerseusGraphType> = {
|
|
6
|
+
onGraphChange: OnGraphChange<T>;
|
|
7
|
+
} & Omit<InteractiveGraphProps, "graph"> & {
|
|
8
|
+
graph: T;
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Coord } from "../../interactive2/types";
|
|
2
|
+
import type { PerseusGraphTypeLinear, PerseusGraphTypeRay, PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
|
|
3
|
+
import type { vec } from "mafs";
|
|
4
|
+
import type { DependencyList } from "react";
|
|
5
|
+
export declare const useInteractivePoint: (coords: vec.Vector2, snaps: [number, number], range: [[number, number], [number, number]]) => import("mafs").UseMovablePoint;
|
|
6
|
+
/**
|
|
7
|
+
* We do not want to call `onGraphChange` until the user
|
|
8
|
+
* has interacted with the graph. See the test,
|
|
9
|
+
* "should reject no interaction"
|
|
10
|
+
*/
|
|
11
|
+
export declare const useEffectAfterFirstRender: (fn: () => void, deps: DependencyList) => void;
|
|
12
|
+
export declare const constrain: (coord: [number, number], snapStep: [number, number], range: [[number, number], [number, number]]) => [number, number];
|
|
13
|
+
export declare const normalizePoints: (range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"], coordsList: ReadonlyArray<Coord>, noSnap?: boolean) => Array<Coord>;
|
|
14
|
+
export declare const normalizeCoords: (coordsList: ReadonlyArray<Coord>, ranges: PerseusInteractiveGraphWidgetOptions["range"]) => Array<Coord>;
|
|
15
|
+
export declare const getLineCoords: (graph: PerseusGraphTypeRay | PerseusGraphTypeLinear, range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"]) => ReadonlyArray<Coord>;
|
|
@@ -128,6 +128,7 @@ declare const _default: Readonly<{
|
|
|
128
128
|
crossOutEnabled?: boolean | undefined;
|
|
129
129
|
editorChangeDelay?: number | undefined;
|
|
130
130
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
131
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
131
132
|
}>;
|
|
132
133
|
choices: readonly string[];
|
|
133
134
|
imageAlt: string;
|
|
@@ -181,6 +182,7 @@ declare const _default: Readonly<{
|
|
|
181
182
|
crossOutEnabled?: boolean | undefined;
|
|
182
183
|
editorChangeDelay?: number | undefined;
|
|
183
184
|
onWidgetStartProps?: ((widgets: import("../types").PerseusWidgetMap) => import("../types").PerseusWidgetMap) | undefined;
|
|
185
|
+
flags?: Record<string, boolean | Record<string, boolean>> | undefined;
|
|
184
186
|
}>;
|
|
185
187
|
choices: readonly string[];
|
|
186
188
|
imageAlt: string;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core Perseus API (includes renderers and widgets)",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "19.
|
|
6
|
+
"version": "19.7.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"@khanacademy/perseus-linter": "^0.3.12",
|
|
33
33
|
"@khanacademy/pure-markdown": "^0.3.0",
|
|
34
34
|
"@khanacademy/simple-markdown": "^0.11.3",
|
|
35
|
-
"@khanacademy/wonder-blocks-banner": "^3.0.33"
|
|
35
|
+
"@khanacademy/wonder-blocks-banner": "^3.0.33",
|
|
36
|
+
"mafs": "^0.18.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@khanacademy/mathjax-renderer": "git+ssh://git@github.com:Khan/mathjax-renderer.git#v1.6.2",
|