@khanacademy/perseus 24.0.0 → 24.2.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 +29 -1
- package/dist/es/index.js +396 -42
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +29 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +404 -47
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -0
- package/dist/server-item-renderer.d.ts +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/util/svg.d.ts +5 -0
- package/dist/widgets/expression.d.ts +6 -0
- package/dist/widgets/interactive-graph.d.ts +2 -1
- package/dist/widgets/interactive-graphs/graphs/use-draggable.d.ts +20 -3
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +2 -0
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +2 -0
- package/dist/widgets/interactive-graphs/protractor.d.ts +5 -0
- package/dist/widgets/interactive-graphs/utils.d.ts +7 -1
- package/dist/widgets/label-image.d.ts +2 -0
- package/package.json +2 -1
package/dist/perseus-api.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export declare const ApiOptions: {
|
|
|
96
96
|
circle?: boolean | undefined;
|
|
97
97
|
polygon?: boolean | undefined;
|
|
98
98
|
linear?: boolean | undefined;
|
|
99
|
+
point?: boolean | undefined;
|
|
99
100
|
quadratic?: boolean | undefined;
|
|
100
101
|
sinusoid?: boolean | undefined;
|
|
101
102
|
"linear-system"?: boolean | undefined;
|
|
@@ -143,6 +143,7 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
|
|
|
143
143
|
circle?: boolean | undefined;
|
|
144
144
|
polygon?: boolean | undefined;
|
|
145
145
|
linear?: boolean | undefined;
|
|
146
|
+
point?: boolean | undefined;
|
|
146
147
|
quadratic?: boolean | undefined;
|
|
147
148
|
sinusoid?: boolean | undefined;
|
|
148
149
|
"linear-system"?: boolean | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ type TrackInteractionArgs = {
|
|
|
77
77
|
id: string;
|
|
78
78
|
correct?: boolean;
|
|
79
79
|
} & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
|
|
80
|
-
export declare const MafsGraphTypeFlags: readonly ["segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic", "sinusoid"];
|
|
80
|
+
export declare const MafsGraphTypeFlags: readonly ["segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic", "sinusoid", "point"];
|
|
81
81
|
export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-m2", "interactive-graph-locked-features-m2b"];
|
|
82
82
|
/**
|
|
83
83
|
* APIOptions provides different ways to customize the behaviour of Perseus.
|
package/dist/util/svg.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ export declare class PathBuilder {
|
|
|
4
4
|
private scaleFactor;
|
|
5
5
|
build(): string;
|
|
6
6
|
move(x: number, y: number): PathBuilder;
|
|
7
|
+
line(x: number, y: number): PathBuilder;
|
|
8
|
+
circularArc(radius: number, toX: number, toY: number, { sweep, largeArc, }?: {
|
|
9
|
+
sweep?: boolean;
|
|
10
|
+
largeArc?: boolean;
|
|
11
|
+
}): PathBuilder;
|
|
7
12
|
curve(control1X: number, control1Y: number, control2X: number, control2Y: number, endX: number, endY: number): PathBuilder;
|
|
8
13
|
scale(factor: number): PathBuilder;
|
|
9
14
|
}
|
|
@@ -137,6 +137,7 @@ declare const _default: Readonly<{
|
|
|
137
137
|
circle?: boolean | undefined;
|
|
138
138
|
polygon?: boolean | undefined;
|
|
139
139
|
linear?: boolean | undefined;
|
|
140
|
+
point?: boolean | undefined;
|
|
140
141
|
quadratic?: boolean | undefined;
|
|
141
142
|
sinusoid?: boolean | undefined;
|
|
142
143
|
"linear-system"?: boolean | undefined;
|
|
@@ -214,6 +215,7 @@ declare const _default: Readonly<{
|
|
|
214
215
|
circle?: boolean | undefined;
|
|
215
216
|
polygon?: boolean | undefined;
|
|
216
217
|
linear?: boolean | undefined;
|
|
218
|
+
point?: boolean | undefined;
|
|
217
219
|
quadratic?: boolean | undefined;
|
|
218
220
|
sinusoid?: boolean | undefined;
|
|
219
221
|
"linear-system"?: boolean | undefined;
|
|
@@ -291,6 +293,7 @@ declare const _default: Readonly<{
|
|
|
291
293
|
circle?: boolean | undefined;
|
|
292
294
|
polygon?: boolean | undefined;
|
|
293
295
|
linear?: boolean | undefined;
|
|
296
|
+
point?: boolean | undefined;
|
|
294
297
|
quadratic?: boolean | undefined;
|
|
295
298
|
sinusoid?: boolean | undefined;
|
|
296
299
|
"linear-system"?: boolean | undefined;
|
|
@@ -365,6 +368,7 @@ declare const _default: Readonly<{
|
|
|
365
368
|
circle?: boolean | undefined;
|
|
366
369
|
polygon?: boolean | undefined;
|
|
367
370
|
linear?: boolean | undefined;
|
|
371
|
+
point?: boolean | undefined;
|
|
368
372
|
quadratic?: boolean | undefined;
|
|
369
373
|
sinusoid?: boolean | undefined;
|
|
370
374
|
"linear-system"?: boolean | undefined;
|
|
@@ -442,6 +446,7 @@ declare const _default: Readonly<{
|
|
|
442
446
|
circle?: boolean | undefined;
|
|
443
447
|
polygon?: boolean | undefined;
|
|
444
448
|
linear?: boolean | undefined;
|
|
449
|
+
point?: boolean | undefined;
|
|
445
450
|
quadratic?: boolean | undefined;
|
|
446
451
|
sinusoid?: boolean | undefined;
|
|
447
452
|
"linear-system"?: boolean | undefined;
|
|
@@ -519,6 +524,7 @@ declare const _default: Readonly<{
|
|
|
519
524
|
circle?: boolean | undefined;
|
|
520
525
|
polygon?: boolean | undefined;
|
|
521
526
|
linear?: boolean | undefined;
|
|
527
|
+
point?: boolean | undefined;
|
|
522
528
|
quadratic?: boolean | undefined;
|
|
523
529
|
sinusoid?: boolean | undefined;
|
|
524
530
|
"linear-system"?: boolean | undefined;
|
|
@@ -5,7 +5,7 @@ import type { Coord } from "../interactive2/types";
|
|
|
5
5
|
import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, PerseusInteractiveGraphWidgetOptions } from "../perseus-types";
|
|
6
6
|
import type { Widget } from "../renderer";
|
|
7
7
|
import type { ChangeHandler, PerseusScore, WidgetProps } from "../types";
|
|
8
|
-
import type { QuadraticCoefficient,
|
|
8
|
+
import type { QuadraticCoefficient, Range, SineCoefficient } from "../util/geometry";
|
|
9
9
|
type RenderProps = PerseusInteractiveGraphWidgetOptions;
|
|
10
10
|
export type Rubric = {
|
|
11
11
|
correct: PerseusGraphType;
|
|
@@ -168,6 +168,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
|
|
|
168
168
|
static validate(userInput: PerseusGraphType, rubric: Rubric, component: any): PerseusScore;
|
|
169
169
|
static getUserInputFromProps(props: Props): PerseusGraphType;
|
|
170
170
|
}
|
|
171
|
+
export declare function shouldUseMafs(mafsFlags: Record<string, boolean> | undefined | boolean, graph: PerseusGraphType): boolean;
|
|
171
172
|
declare const _default: Readonly<{
|
|
172
173
|
name: string;
|
|
173
174
|
displayName: string;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { vec } from "mafs";
|
|
2
2
|
import type { RefObject } from "react";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Code in this file is derived from
|
|
5
|
+
* https://github.com/stevenpetryk/mafs/blob/4520319379a2cc2df8148d8baaef1f85db117103/src/interaction/useMovable.tsx#L20-L83
|
|
6
|
+
* and copied here under the terms of the MIT license.
|
|
7
|
+
*
|
|
8
|
+
* Copyright 2021 Steven Petryk
|
|
9
|
+
*
|
|
10
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
* in the Software without restriction, including without limitation the rights
|
|
13
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
* furnished to do so, subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in
|
|
18
|
+
* all copies or substantial portions of the Software.
|
|
19
|
+
*/
|
|
20
|
+
export type Params = {
|
|
4
21
|
gestureTarget: RefObject<Element>;
|
|
5
22
|
onMove: (point: vec.Vector2) => unknown;
|
|
6
23
|
point: vec.Vector2;
|
|
@@ -9,5 +26,5 @@ type Params = {
|
|
|
9
26
|
type DragState = {
|
|
10
27
|
dragging: boolean;
|
|
11
28
|
};
|
|
12
|
-
export declare function useDraggable(
|
|
29
|
+
export declare function useDraggable(args: Params): DragState;
|
|
13
30
|
export {};
|
|
@@ -10,6 +10,7 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
10
10
|
private yRange;
|
|
11
11
|
private snapStep;
|
|
12
12
|
private tickStep;
|
|
13
|
+
private showProtractor;
|
|
13
14
|
private interactiveFigureConfig;
|
|
14
15
|
private lockedFigures;
|
|
15
16
|
build(): PerseusRenderer;
|
|
@@ -20,6 +21,7 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
20
21
|
withYRange(min: number, max: number): InteractiveGraphQuestionBuilder;
|
|
21
22
|
withSnapStep(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
22
23
|
withTickStep(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
24
|
+
withProtractor(): InteractiveGraphQuestionBuilder;
|
|
23
25
|
withSegments(startCoords: CollinearTuple[]): InteractiveGraphQuestionBuilder;
|
|
24
26
|
withNumSegments(numSegments: number): InteractiveGraphQuestionBuilder;
|
|
25
27
|
withLinear(startCoords?: CollinearTuple): InteractiveGraphQuestionBuilder;
|
|
@@ -18,6 +18,7 @@ export type StatefulMafsGraphProps = {
|
|
|
18
18
|
markings: InteractiveGraphProps["markings"];
|
|
19
19
|
onChange: InteractiveGraphProps["onChange"];
|
|
20
20
|
showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
|
|
21
|
+
showProtractor: boolean;
|
|
21
22
|
labels: InteractiveGraphProps["labels"];
|
|
22
23
|
};
|
|
23
24
|
export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<StatefulMafsGraphProps & React.RefAttributes<Partial<Widget>>>;
|
|
@@ -30,6 +31,7 @@ export type MafsGraphProps = {
|
|
|
30
31
|
containerSizeClass: InteractiveGraphProps["containerSizeClass"];
|
|
31
32
|
markings: InteractiveGraphProps["markings"];
|
|
32
33
|
showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
|
|
34
|
+
showProtractor: boolean;
|
|
33
35
|
labels: InteractiveGraphProps["labels"];
|
|
34
36
|
state: InteractiveGraphState;
|
|
35
37
|
dispatch: React.Dispatch<InteractiveGraphAction>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Coord } from "../../interactive2/types";
|
|
2
2
|
import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
|
|
3
|
-
import type { vec } from "mafs";
|
|
3
|
+
import type { Interval, vec } from "mafs";
|
|
4
4
|
/**
|
|
5
5
|
* 44 is touch best practice and AAA compliant for WCAG
|
|
6
6
|
* https://www.w3.org/WAI/WCAG21/Understanding/target-size.html
|
|
@@ -9,3 +9,9 @@ export declare const TARGET_SIZE = 44;
|
|
|
9
9
|
export declare const normalizePoints: <A extends Coord[]>(range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"], coordsList: A, noSnap?: boolean) => A;
|
|
10
10
|
export declare const normalizeCoords: <A extends Coord[]>(coordsList: A, ranges: PerseusInteractiveGraphWidgetOptions["range"]) => A;
|
|
11
11
|
export declare function snap(snapStep: vec.Vector2, point: vec.Vector2): vec.Vector2;
|
|
12
|
+
export declare function bound({ snapStep, range, point, }: {
|
|
13
|
+
snapStep: vec.Vector2;
|
|
14
|
+
range: [Interval, Interval];
|
|
15
|
+
point: vec.Vector2;
|
|
16
|
+
}): vec.Vector2;
|
|
17
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -131,6 +131,7 @@ declare const _default: Readonly<{
|
|
|
131
131
|
circle?: boolean | undefined;
|
|
132
132
|
polygon?: boolean | undefined;
|
|
133
133
|
linear?: boolean | undefined;
|
|
134
|
+
point?: boolean | undefined;
|
|
134
135
|
quadratic?: boolean | undefined;
|
|
135
136
|
sinusoid?: boolean | undefined;
|
|
136
137
|
"linear-system"?: boolean | undefined;
|
|
@@ -192,6 +193,7 @@ declare const _default: Readonly<{
|
|
|
192
193
|
circle?: boolean | undefined;
|
|
193
194
|
polygon?: boolean | undefined;
|
|
194
195
|
linear?: boolean | undefined;
|
|
196
|
+
point?: boolean | undefined;
|
|
195
197
|
quadratic?: boolean | undefined;
|
|
196
198
|
sinusoid?: boolean | undefined;
|
|
197
199
|
"linear-system"?: boolean | 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": "24.
|
|
6
|
+
"version": "24.2.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"@khanacademy/perseus-linter": "^0.4.0",
|
|
47
47
|
"@khanacademy/pure-markdown": "^0.3.5",
|
|
48
48
|
"@khanacademy/simple-markdown": "^0.12.0",
|
|
49
|
+
"@use-gesture/react": "^10.2.27",
|
|
49
50
|
"mafs": "0.18.7"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|