@khanacademy/perseus 24.0.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.
@@ -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, SineCoefficient, Range } from "../util/geometry";
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 type { vec } from "mafs";
1
+ import { vec } from "mafs";
2
2
  import type { RefObject } from "react";
3
- type Params = {
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(params: Params): DragState;
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>;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { vec } from "mafs";
3
+ import "./protractor.css";
4
+ export declare const centerToRotationHandle: vec.Vector2;
5
+ export declare function Protractor(): JSX.Element;
@@ -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": "24.0.0",
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": {