@khanacademy/perseus 23.3.0 → 23.5.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 +8 -0
- package/dist/es/index.js +469 -311
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +8 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +482 -328
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -1
- package/dist/perseus-types.d.ts +17 -9
- package/dist/server-item-renderer.d.ts +1 -1
- package/dist/widgets/expression.d.ts +6 -6
- package/dist/widgets/interactive-graphs/graphs/components/angle.d.ts +2 -1
- package/dist/widgets/interactive-graphs/graphs/components/movable-point.d.ts +1 -0
- package/dist/widgets/interactive-graphs/graphs/quadratic.d.ts +1 -2
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +10 -3
- package/dist/widgets/interactive-graphs/locked-polygon.d.ts +4 -0
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +2 -1
- package/dist/widgets/interactive-graphs/reducer/initialize-graph-state.d.ts +10 -0
- package/dist/widgets/interactive-graphs/reducer/interactive-graph-action.d.ts +8 -1
- package/dist/widgets/interactive-graphs/reducer/interactive-graph-state.d.ts +2 -9
- package/dist/widgets/interactive-graphs/types.d.ts +1 -0
- package/dist/widgets/label-image.d.ts +2 -2
- package/package.json +3 -3
package/dist/perseus-api.d.ts
CHANGED
|
@@ -98,9 +98,9 @@ export declare const ApiOptions: {
|
|
|
98
98
|
linear?: boolean | undefined;
|
|
99
99
|
quadratic?: boolean | undefined;
|
|
100
100
|
sinusoid?: boolean | undefined;
|
|
101
|
-
segment?: boolean | undefined;
|
|
102
101
|
"linear-system"?: boolean | undefined;
|
|
103
102
|
ray?: boolean | undefined;
|
|
103
|
+
segment?: boolean | undefined;
|
|
104
104
|
} & {
|
|
105
105
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
106
106
|
}) | undefined;
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -346,10 +346,10 @@ export type PerseusInteractiveGraphWidgetOptions = {
|
|
|
346
346
|
correct: PerseusGraphType;
|
|
347
347
|
lockedFigures?: ReadonlyArray<LockedFigure>;
|
|
348
348
|
};
|
|
349
|
-
declare const lockedFigureColorNames: readonly ["green", "grayH", "purple", "pink", "red"];
|
|
349
|
+
declare const lockedFigureColorNames: readonly ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
|
|
350
350
|
export type LockedFigureColor = (typeof lockedFigureColorNames)[number];
|
|
351
351
|
export declare const lockedFigureColors: Record<LockedFigureColor, string>;
|
|
352
|
-
export type LockedFigure = LockedPointType | LockedLineType | LockedEllipseType |
|
|
352
|
+
export type LockedFigure = LockedPointType | LockedLineType | LockedVectorType | LockedEllipseType | LockedPolygonType;
|
|
353
353
|
export type LockedFigureType = LockedFigure["type"];
|
|
354
354
|
export type LockedPointType = {
|
|
355
355
|
type: "point";
|
|
@@ -366,21 +366,29 @@ export type LockedLineType = {
|
|
|
366
366
|
showPoint1: boolean;
|
|
367
367
|
showPoint2: boolean;
|
|
368
368
|
};
|
|
369
|
-
export type
|
|
370
|
-
|
|
369
|
+
export type LockedVectorType = {
|
|
370
|
+
type: "vector";
|
|
371
|
+
points: [tail: Coord, tip: Coord];
|
|
372
|
+
color: LockedFigureColor;
|
|
373
|
+
};
|
|
374
|
+
export type LockedFigureFillType = "none" | "solid" | "translucent";
|
|
375
|
+
export declare const lockedFigureFillStyles: Record<LockedFigureFillType, number>;
|
|
371
376
|
export type LockedEllipseType = {
|
|
372
377
|
type: "ellipse";
|
|
373
378
|
center: Coord;
|
|
374
379
|
radius: [x: number, y: number];
|
|
375
380
|
angle: number;
|
|
376
381
|
color: LockedFigureColor;
|
|
377
|
-
fillStyle:
|
|
382
|
+
fillStyle: LockedFigureFillType;
|
|
378
383
|
strokeStyle: "solid" | "dashed";
|
|
379
384
|
};
|
|
380
|
-
export type
|
|
381
|
-
type: "
|
|
382
|
-
points:
|
|
385
|
+
export type LockedPolygonType = {
|
|
386
|
+
type: "polygon";
|
|
387
|
+
points: ReadonlyArray<Coord>;
|
|
383
388
|
color: LockedFigureColor;
|
|
389
|
+
showVertices: boolean;
|
|
390
|
+
fillStyle: LockedFigureFillType;
|
|
391
|
+
strokeStyle: "solid" | "dashed";
|
|
384
392
|
};
|
|
385
393
|
export type PerseusGraphType = PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid;
|
|
386
394
|
export type PerseusGraphTypeCommon = {
|
|
@@ -418,7 +426,7 @@ export type PerseusGraphTypePolygon = {
|
|
|
418
426
|
numSides?: number | "unlimited";
|
|
419
427
|
showAngles?: boolean;
|
|
420
428
|
showSides?: boolean;
|
|
421
|
-
snapTo?:
|
|
429
|
+
snapTo?: "grid" | "angles" | "sides";
|
|
422
430
|
match?: "similar" | "congruent" | "approx";
|
|
423
431
|
coords?: ReadonlyArray<Coord>;
|
|
424
432
|
} & PerseusGraphTypeCommon;
|
|
@@ -145,9 +145,9 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
|
|
|
145
145
|
linear?: boolean | undefined;
|
|
146
146
|
quadratic?: boolean | undefined;
|
|
147
147
|
sinusoid?: boolean | undefined;
|
|
148
|
-
segment?: boolean | undefined;
|
|
149
148
|
"linear-system"?: boolean | undefined;
|
|
150
149
|
ray?: boolean | undefined;
|
|
150
|
+
segment?: boolean | undefined;
|
|
151
151
|
} & {
|
|
152
152
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
153
153
|
}) | undefined;
|
|
@@ -139,9 +139,9 @@ declare const _default: Readonly<{
|
|
|
139
139
|
linear?: boolean | undefined;
|
|
140
140
|
quadratic?: boolean | undefined;
|
|
141
141
|
sinusoid?: boolean | undefined;
|
|
142
|
-
segment?: boolean | undefined;
|
|
143
142
|
"linear-system"?: boolean | undefined;
|
|
144
143
|
ray?: boolean | undefined;
|
|
144
|
+
segment?: boolean | undefined;
|
|
145
145
|
} & {
|
|
146
146
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
147
147
|
}) | undefined;
|
|
@@ -215,9 +215,9 @@ declare const _default: Readonly<{
|
|
|
215
215
|
linear?: boolean | undefined;
|
|
216
216
|
quadratic?: boolean | undefined;
|
|
217
217
|
sinusoid?: boolean | undefined;
|
|
218
|
-
segment?: boolean | undefined;
|
|
219
218
|
"linear-system"?: boolean | undefined;
|
|
220
219
|
ray?: boolean | undefined;
|
|
220
|
+
segment?: boolean | undefined;
|
|
221
221
|
} & {
|
|
222
222
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
223
223
|
}) | undefined;
|
|
@@ -291,9 +291,9 @@ declare const _default: Readonly<{
|
|
|
291
291
|
linear?: boolean | undefined;
|
|
292
292
|
quadratic?: boolean | undefined;
|
|
293
293
|
sinusoid?: boolean | undefined;
|
|
294
|
-
segment?: boolean | undefined;
|
|
295
294
|
"linear-system"?: boolean | undefined;
|
|
296
295
|
ray?: boolean | undefined;
|
|
296
|
+
segment?: boolean | undefined;
|
|
297
297
|
} & {
|
|
298
298
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
299
299
|
}) | undefined;
|
|
@@ -364,9 +364,9 @@ declare const _default: Readonly<{
|
|
|
364
364
|
linear?: boolean | undefined;
|
|
365
365
|
quadratic?: boolean | undefined;
|
|
366
366
|
sinusoid?: boolean | undefined;
|
|
367
|
-
segment?: boolean | undefined;
|
|
368
367
|
"linear-system"?: boolean | undefined;
|
|
369
368
|
ray?: boolean | undefined;
|
|
369
|
+
segment?: boolean | undefined;
|
|
370
370
|
} & {
|
|
371
371
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
372
372
|
}) | undefined;
|
|
@@ -440,9 +440,9 @@ declare const _default: Readonly<{
|
|
|
440
440
|
linear?: boolean | undefined;
|
|
441
441
|
quadratic?: boolean | undefined;
|
|
442
442
|
sinusoid?: boolean | undefined;
|
|
443
|
-
segment?: boolean | undefined;
|
|
444
443
|
"linear-system"?: boolean | undefined;
|
|
445
444
|
ray?: boolean | undefined;
|
|
445
|
+
segment?: boolean | undefined;
|
|
446
446
|
} & {
|
|
447
447
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
448
448
|
}) | undefined;
|
|
@@ -516,9 +516,9 @@ declare const _default: Readonly<{
|
|
|
516
516
|
linear?: boolean | undefined;
|
|
517
517
|
quadratic?: boolean | undefined;
|
|
518
518
|
sinusoid?: boolean | undefined;
|
|
519
|
-
segment?: boolean | undefined;
|
|
520
519
|
"linear-system"?: boolean | undefined;
|
|
521
520
|
ray?: boolean | undefined;
|
|
521
|
+
segment?: boolean | undefined;
|
|
522
522
|
} & {
|
|
523
523
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
524
524
|
}) | undefined;
|
|
@@ -9,8 +9,9 @@ interface Props {
|
|
|
9
9
|
active: boolean;
|
|
10
10
|
range: [Interval, Interval];
|
|
11
11
|
showAngles: boolean;
|
|
12
|
+
snapTo: "grid" | "angles" | "sides";
|
|
12
13
|
}
|
|
13
|
-
export declare const Angle: ({ centerPoint, endPoints, range, polygonLines, showAngles, }: Props) => JSX.Element | null;
|
|
14
|
+
export declare const Angle: ({ centerPoint, endPoints, range, polygonLines, showAngles, snapTo, }: Props) => JSX.Element | null;
|
|
14
15
|
/**
|
|
15
16
|
* Determines if an angle is an inside (false) or outside (true) angle.
|
|
16
17
|
* They way, we know to flip the `largeArc` and `sweepArc` flags.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { QuadraticGraphState, MafsGraphProps } from "../types";
|
|
3
|
-
import type { vec } from "mafs";
|
|
4
3
|
type QuadraticGraphProps = MafsGraphProps<QuadraticGraphState>;
|
|
5
4
|
type QuadraticCoefficient = [number, number, number];
|
|
5
|
+
export type QuadraticCoords = QuadraticGraphState["coords"];
|
|
6
6
|
export declare function QuadraticGraph(props: QuadraticGraphProps): JSX.Element;
|
|
7
|
-
export declare const isValidDestination: (destination: vec.Vector2, elementId: number, coords: [import("../../..").Coord, import("../../..").Coord, import("../../..").Coord]) => boolean;
|
|
8
7
|
export declare const getQuadraticCoefficients: (coords: [import("../../..").Coord, import("../../..").Coord, import("../../..").Coord]) => QuadraticCoefficient | undefined;
|
|
9
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LockedFigureFillType, LockedFigureColor, PerseusRenderer } from "../../perseus-types";
|
|
2
2
|
import type { vec } from "mafs";
|
|
3
3
|
export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
|
|
4
4
|
declare class InteractiveGraphQuestionBuilder {
|
|
@@ -21,15 +21,22 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
21
21
|
withTickStep(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
22
22
|
withSegments(numSegments: number): InteractiveGraphQuestionBuilder;
|
|
23
23
|
withCircle(): InteractiveGraphQuestionBuilder;
|
|
24
|
+
withPolygon(snapTo: "grid" | "angles" | "sides"): InteractiveGraphQuestionBuilder;
|
|
24
25
|
addLockedPointAt(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
25
26
|
addLockedLine(point1: vec.Vector2, point2: vec.Vector2): InteractiveGraphQuestionBuilder;
|
|
27
|
+
addLockedVector(tail: vec.Vector2, tip: vec.Vector2, color?: LockedFigureColor): InteractiveGraphQuestionBuilder;
|
|
26
28
|
addLockedEllipse(center: vec.Vector2, radius: [x: number, y: number], options?: {
|
|
27
29
|
angle?: number;
|
|
28
30
|
color?: LockedFigureColor;
|
|
29
|
-
fillStyle?:
|
|
31
|
+
fillStyle?: LockedFigureFillType;
|
|
32
|
+
strokeStyle?: "solid" | "dashed";
|
|
33
|
+
}): InteractiveGraphQuestionBuilder;
|
|
34
|
+
addLockedPolygon(points: vec.Vector2[], options?: {
|
|
35
|
+
color?: LockedFigureColor;
|
|
36
|
+
showVertices?: boolean;
|
|
37
|
+
fillStyle?: LockedFigureFillType;
|
|
30
38
|
strokeStyle?: "solid" | "dashed";
|
|
31
39
|
}): InteractiveGraphQuestionBuilder;
|
|
32
|
-
addLockedVector(tail: vec.Vector2, tip: vec.Vector2, color?: LockedFigureColor): InteractiveGraphQuestionBuilder;
|
|
33
40
|
private createLockedPoint;
|
|
34
41
|
private addLockedFigure;
|
|
35
42
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type InteractiveGraphAction } from "./reducer/interactive-graph-action";
|
|
3
3
|
import type { InteractiveGraphState, InteractiveGraphProps } from "./types";
|
|
4
|
+
import type { PerseusGraphType } from "../../perseus-types";
|
|
4
5
|
import type { Widget } from "../../renderer";
|
|
5
6
|
import "mafs/core.css";
|
|
6
7
|
import "./mafs-styles.css";
|
|
7
8
|
export type StatefulMafsGraphProps = {
|
|
8
9
|
box: [number, number];
|
|
9
10
|
backgroundImage?: InteractiveGraphProps["backgroundImage"];
|
|
10
|
-
graph:
|
|
11
|
+
graph: PerseusGraphType;
|
|
11
12
|
lockedFigures?: InteractiveGraphProps["lockedFigures"];
|
|
12
13
|
range: InteractiveGraphProps["range"];
|
|
13
14
|
snapStep: InteractiveGraphProps["snapStep"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PerseusGraphType } from "../../../perseus-types";
|
|
2
|
+
import type { InteractiveGraphState } from "../types";
|
|
3
|
+
import type { Interval } from "mafs";
|
|
4
|
+
export type InitializeGraphStateParams = {
|
|
5
|
+
range: [x: Interval, y: Interval];
|
|
6
|
+
step: [x: number, y: number];
|
|
7
|
+
snapStep: [x: number, y: number];
|
|
8
|
+
graph: PerseusGraphType;
|
|
9
|
+
};
|
|
10
|
+
export declare function initializeGraphState(params: InitializeGraphStateParams): InteractiveGraphState;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import type { InitializeGraphStateParams } from "./initialize-graph-state";
|
|
1
2
|
import type { Interval, vec } from "mafs";
|
|
2
|
-
export type InteractiveGraphAction = MoveControlPoint | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange;
|
|
3
|
+
export type InteractiveGraphAction = Reinitialize | MoveControlPoint | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange;
|
|
4
|
+
export declare const REINITIALIZE = "reinitialize";
|
|
5
|
+
export interface Reinitialize {
|
|
6
|
+
type: typeof REINITIALIZE;
|
|
7
|
+
params: InitializeGraphStateParams;
|
|
8
|
+
}
|
|
9
|
+
export declare function reinitialize(params: InitializeGraphStateParams): Reinitialize;
|
|
3
10
|
export declare const MOVE_CONTROL_POINT = "move-control-point";
|
|
4
11
|
export interface MoveControlPoint {
|
|
5
12
|
type: typeof MOVE_CONTROL_POINT;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export type InitializeGraphStateParam = {
|
|
4
|
-
range: InteractiveGraphProps["range"];
|
|
5
|
-
step: InteractiveGraphProps["step"];
|
|
6
|
-
snapStep: InteractiveGraphProps["snapStep"];
|
|
7
|
-
graph: PerseusGraphType;
|
|
8
|
-
};
|
|
9
|
-
export declare function initializeGraphState(params: InitializeGraphStateParam): InteractiveGraphState;
|
|
1
|
+
import type { CircleGraphState, InteractiveGraphState } from "../types";
|
|
2
|
+
import type { PerseusGraphType } from "@khanacademy/perseus";
|
|
10
3
|
export declare function getGradableGraph(state: InteractiveGraphState, initialGraph: PerseusGraphType): PerseusGraphType;
|
|
11
4
|
/**
|
|
12
5
|
* determine radius of a circle graph
|
|
@@ -38,6 +38,7 @@ export interface PolygonGraphState extends InteractiveGraphStateCommon {
|
|
|
38
38
|
type: "polygon";
|
|
39
39
|
showAngles: boolean;
|
|
40
40
|
showSides: boolean;
|
|
41
|
+
snapTo: "grid" | "angles" | "sides";
|
|
41
42
|
coords: Coord[];
|
|
42
43
|
}
|
|
43
44
|
export interface CircleGraphState extends InteractiveGraphStateCommon {
|
|
@@ -133,9 +133,9 @@ declare const _default: Readonly<{
|
|
|
133
133
|
linear?: boolean | undefined;
|
|
134
134
|
quadratic?: boolean | undefined;
|
|
135
135
|
sinusoid?: boolean | undefined;
|
|
136
|
-
segment?: boolean | undefined;
|
|
137
136
|
"linear-system"?: boolean | undefined;
|
|
138
137
|
ray?: boolean | undefined;
|
|
138
|
+
segment?: boolean | undefined;
|
|
139
139
|
} & {
|
|
140
140
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
141
141
|
}) | undefined;
|
|
@@ -193,9 +193,9 @@ declare const _default: Readonly<{
|
|
|
193
193
|
linear?: boolean | undefined;
|
|
194
194
|
quadratic?: boolean | undefined;
|
|
195
195
|
sinusoid?: boolean | undefined;
|
|
196
|
-
segment?: boolean | undefined;
|
|
197
196
|
"linear-system"?: boolean | undefined;
|
|
198
197
|
ray?: boolean | undefined;
|
|
198
|
+
segment?: boolean | undefined;
|
|
199
199
|
} & {
|
|
200
200
|
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
201
201
|
}) | undefined;
|
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": "23.
|
|
6
|
+
"version": "23.5.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@khanacademy/wonder-blocks-core": "6.4.0",
|
|
56
56
|
"@khanacademy/wonder-blocks-data": "13.0.7",
|
|
57
57
|
"@khanacademy/wonder-blocks-dropdown": "5.3.0",
|
|
58
|
-
"@khanacademy/wonder-blocks-form": "4.
|
|
58
|
+
"@khanacademy/wonder-blocks-form": "^4.7.1",
|
|
59
59
|
"@khanacademy/wonder-blocks-icon": "4.1.0",
|
|
60
60
|
"@khanacademy/wonder-blocks-layout": "2.0.32",
|
|
61
61
|
"@khanacademy/wonder-blocks-link": "6.1.1",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@khanacademy/wonder-blocks-core": "6.4.0",
|
|
91
91
|
"@khanacademy/wonder-blocks-data": "13.0.7",
|
|
92
92
|
"@khanacademy/wonder-blocks-dropdown": "5.3.0",
|
|
93
|
-
"@khanacademy/wonder-blocks-form": "4.
|
|
93
|
+
"@khanacademy/wonder-blocks-form": "^4.7.1",
|
|
94
94
|
"@khanacademy/wonder-blocks-icon": "4.1.0",
|
|
95
95
|
"@khanacademy/wonder-blocks-layout": "2.0.32",
|
|
96
96
|
"@khanacademy/wonder-blocks-link": "6.1.1",
|