@khanacademy/perseus 23.6.0 → 24.1.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 +401 -45
- 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 +409 -50
- package/dist/index.js.map +1 -1
- package/dist/util/svg.d.ts +5 -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 +12 -3
- 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/package.json +2 -1
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
|
}
|
|
@@ -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 {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { LockedFigureFillType, LockedFigureColor, PerseusRenderer } from "../../perseus-types";
|
|
1
|
+
import type { LockedFigureFillType, LockedFigureColor, PerseusRenderer, CollinearTuple } from "../../perseus-types";
|
|
2
|
+
import type { Coord } from "@khanacademy/perseus";
|
|
2
3
|
import type { vec } from "mafs";
|
|
3
4
|
export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
|
|
4
5
|
declare class InteractiveGraphQuestionBuilder {
|
|
@@ -9,6 +10,7 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
9
10
|
private yRange;
|
|
10
11
|
private snapStep;
|
|
11
12
|
private tickStep;
|
|
13
|
+
private showProtractor;
|
|
12
14
|
private interactiveFigureConfig;
|
|
13
15
|
private lockedFigures;
|
|
14
16
|
build(): PerseusRenderer;
|
|
@@ -19,8 +21,15 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
19
21
|
withYRange(min: number, max: number): InteractiveGraphQuestionBuilder;
|
|
20
22
|
withSnapStep(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
21
23
|
withTickStep(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
withProtractor(): InteractiveGraphQuestionBuilder;
|
|
25
|
+
withSegments(startCoords: CollinearTuple[]): InteractiveGraphQuestionBuilder;
|
|
26
|
+
withNumSegments(numSegments: number): InteractiveGraphQuestionBuilder;
|
|
27
|
+
withLinear(startCoords?: CollinearTuple): InteractiveGraphQuestionBuilder;
|
|
28
|
+
withLinearSystem(startCoords?: CollinearTuple[]): InteractiveGraphQuestionBuilder;
|
|
29
|
+
withRay(startCoords?: CollinearTuple): InteractiveGraphQuestionBuilder;
|
|
30
|
+
withCircle(startCoords?: Coord): InteractiveGraphQuestionBuilder;
|
|
31
|
+
withQuadratic(startCoords?: [Coord, Coord, Coord]): InteractiveGraphQuestionBuilder;
|
|
32
|
+
withSinusoid(startCoords?: [Coord, Coord]): InteractiveGraphQuestionBuilder;
|
|
24
33
|
withPolygon(snapTo: "grid" | "angles" | "sides"): InteractiveGraphQuestionBuilder;
|
|
25
34
|
addLockedPointAt(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
26
35
|
addLockedLine(point1: vec.Vector2, point2: vec.Vector2): 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;
|
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": "
|
|
6
|
+
"version": "24.1.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": {
|