@khanacademy/perseus 22.0.2 → 22.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.
@@ -103,8 +103,8 @@ declare class LegacyInteractiveGraph extends React.Component<Props, State> {
103
103
  addAngleControls: () => void;
104
104
  removeAngleControls: () => void;
105
105
  toggleShowSides: () => void;
106
- getUserInput: () => PerseusGraphType;
107
- simpleValidate: (rubric: Rubric) => PerseusScore;
106
+ getUserInput(): PerseusGraphType;
107
+ simpleValidate(rubric: Rubric): PerseusScore;
108
108
  focus: () => void;
109
109
  render(): React.ReactNode;
110
110
  }
@@ -113,7 +113,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
113
113
  mafsRef: React.RefObject<Widget>;
114
114
  static defaultProps: DefaultProps;
115
115
  getUserInput: Widget["getUserInput"];
116
- simpleValidate: (rubric: Rubric) => PerseusScore;
116
+ simpleValidate(rubric: Rubric): PerseusScore;
117
117
  render(): JSX.Element;
118
118
  static getQuadraticCoefficients(coords: ReadonlyArray<Coord>): QuadraticCoefficient;
119
119
  static getSinusoidCoefficients(coords: ReadonlyArray<Coord>): SineCoefficient;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function AxisLabels(): JSX.Element;
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import type { LockedFigure } from "../../perseus-types";
3
+ import type { Interval } from "mafs";
3
4
  type Props = {
4
5
  lockedFigures: ReadonlyArray<LockedFigure>;
6
+ range: [x: Interval, y: Interval];
5
7
  };
6
8
  declare const GraphLockedLayer: (props: Props) => JSX.Element;
7
9
  export default GraphLockedLayer;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
+ import { type vec } from "mafs";
2
3
  type Props = {
3
- x: number;
4
- y: number;
4
+ tip: vec.Vector2;
5
5
  angle: number;
6
6
  color?: string;
7
7
  };
@@ -13,4 +13,5 @@ type Props = {
13
13
  };
14
14
  };
15
15
  export declare const MovableLine: (props: Props) => JSX.Element;
16
+ export declare function trimRange(range: [Interval, Interval], graphDimensionsInPixels: vec.Vector2): [Interval, Interval];
16
17
  export {};
@@ -1,9 +1,10 @@
1
- /// <reference types="react" />
2
1
  import { vec } from "mafs";
2
+ import * as React from "react";
3
3
  type Props = {
4
4
  tail: vec.Vector2;
5
5
  tip: vec.Vector2;
6
6
  color: string;
7
+ style?: React.SVGProps<SVGLineElement>["style"];
7
8
  };
8
9
  export declare function Vector(props: Props): JSX.Element;
9
10
  export {};
@@ -1,2 +1,9 @@
1
- import { vec } from "mafs";
2
- export declare const useTransform: (...points: vec.Vector2[]) => vec.Vector2[];
1
+ import { type Interval, vec } from "mafs";
2
+ export type GraphDimensions = {
3
+ range: [Interval, Interval];
4
+ width: number;
5
+ height: number;
6
+ };
7
+ export declare function vectorsToPixels(vectors: vec.Vector2[], graphState: GraphDimensions, translation?: vec.Vector2): vec.Vector2[];
8
+ export declare function pointToPixel(point: vec.Vector2, graphState: GraphDimensions): vec.Vector2;
9
+ export declare const useTransformVectorsToPixels: (...vectors: vec.Vector2[]) => vec.Vector2[];
@@ -1,9 +1,11 @@
1
1
  import type { CollinearTuple } from "../../../perseus-types";
2
2
  import type { Interval, vec } from "mafs";
3
3
  /**
4
- * Given two points, find the tips that extends through the points to the edge of the range.
5
- * @param collinearPoint - The point that the line passes through. Needed to establish slope.
6
- * @param extendFrom - The point that the line extends from to the edge of the graph.
4
+ * Given a ray and a rectangular box, find the point where the ray intersects
5
+ * the edge of the box. Assumes the `initialPoint` is inside the box.
6
+ * @param initialPoint - The starting point of the ray.
7
+ * @param throughPoint - A point that the ray passes through. Must be different from initialPoint.
8
+ * @param box - The box with which to intersect the ray, in the form [[xMin, xMax], [yMin, yMax]]
7
9
  */
8
- export declare const getRayIntersectionCoords: (collinearPoint: vec.Vector2, extendFrom: vec.Vector2, range: [Interval, Interval]) => [number, number];
10
+ export declare const getIntersectionOfRayWithBox: (initialPoint: vec.Vector2, throughPoint: vec.Vector2, box: [x: Interval, y: Interval]) => [number, number];
9
11
  export declare const getLines: (points: readonly vec.Vector2[]) => CollinearTuple[];
@@ -1,4 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import type { LockedLineType } from "../../perseus-types";
3
- declare const LockedLine: (props: LockedLineType) => JSX.Element | null;
3
+ import type { Interval } from "mafs";
4
+ type Props = LockedLineType & {
5
+ range: [Interval, Interval];
6
+ };
7
+ declare const LockedLine: (props: Props) => JSX.Element;
4
8
  export default LockedLine;
@@ -17,6 +17,7 @@ export type Props = {
17
17
  markings: InteractiveGraphProps["markings"];
18
18
  onChange: InteractiveGraphProps["onChange"];
19
19
  showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
20
+ labels: InteractiveGraphProps["labels"];
20
21
  };
21
22
  export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<Props & React.RefAttributes<Partial<Widget>>>;
22
23
  type MafsGraphProps = Props & {
@@ -5,6 +5,10 @@ type GraphConfig = {
5
5
  snapStep: vec.Vector2;
6
6
  markings: "graph" | "grid" | "none";
7
7
  showTooltips: boolean;
8
+ graphDimensionsInPixels: vec.Vector2;
9
+ width: number;
10
+ height: number;
11
+ labels: readonly string[];
8
12
  };
9
13
  export declare const GraphConfigContext: React.Context<GraphConfig>;
10
14
  export default function useGraphConfig(): GraphConfig;
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": "22.0.2",
6
+ "version": "22.2.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -41,12 +41,12 @@
41
41
  "dependencies": {
42
42
  "@khanacademy/kas": "^0.3.9",
43
43
  "@khanacademy/kmath": "^0.1.12",
44
- "@khanacademy/math-input": "^18.0.0",
44
+ "@khanacademy/math-input": "^18.0.1",
45
45
  "@khanacademy/perseus-core": "1.4.2",
46
46
  "@khanacademy/perseus-linter": "^0.3.12",
47
- "@khanacademy/pure-markdown": "^0.3.2",
47
+ "@khanacademy/pure-markdown": "^0.3.3",
48
48
  "@khanacademy/simple-markdown": "^0.11.4",
49
- "mafs": "https://github.com/Khan/mafs/releases/download/v0.18.1%2Bbuild-cd8b2467893342ba0b02100073fe21f93f8b1125/mafs-0.18.1.tgz"
49
+ "mafs": "0.18.5"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@khanacademy/wonder-blocks-banner": "^3.0.41",
@@ -76,7 +76,7 @@
76
76
  "jquery": "^2.1.1",
77
77
  "katex": "^0.11.1",
78
78
  "lodash.debounce": "^4.0.8",
79
- "perseus-build-settings": "^0.4.0",
79
+ "perseus-build-settings": "^0.4.1",
80
80
  "prop-types": "^15.6.1",
81
81
  "react": "16.14.0",
82
82
  "react-dom": "16.14.0",